Commit 45785f96 authored by Gerhard Killesreiter's avatar Gerhard Killesreiter
Browse files

#46549, more robust node_submit, patch by chx

parent b354396b
......@@ -1488,7 +1488,8 @@ function node_submit($node) {
$node->teaser = isset($node->body) ? node_teaser($node->body, isset($node->format) ? $node->format : NULL) : '';
}
if (user_access('administer nodes')) {
$access = user_access('administer nodes');
if ($access) {
// Populate the "authored by" field.
if ($account = user_load(array('name' => $node->name))) {
$node->uid = $account->uid;
......@@ -1499,10 +1500,10 @@ function node_submit($node) {
$node->created = $node->date ? strtotime($node->date) : NULL;
}
else {
// Force defaults in case people modify the form:
$node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
foreach (array('status', 'moderate', 'promote', 'sticky', 'revision') as $key) {
// Force defaults in case people modify the form:
$node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
foreach (array('status', 'moderate', 'promote', 'sticky', 'revision') as $key) {
if (!$access || !isset($node->$key)) {
$node->$key = in_array($key, $node_options);
}
}
......
......@@ -1488,7 +1488,8 @@ function node_submit($node) {
$node->teaser = isset($node->body) ? node_teaser($node->body, isset($node->format) ? $node->format : NULL) : '';
}
if (user_access('administer nodes')) {
$access = user_access('administer nodes');
if ($access) {
// Populate the "authored by" field.
if ($account = user_load(array('name' => $node->name))) {
$node->uid = $account->uid;
......@@ -1499,10 +1500,10 @@ function node_submit($node) {
$node->created = $node->date ? strtotime($node->date) : NULL;
}
else {
// Force defaults in case people modify the form:
$node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
foreach (array('status', 'moderate', 'promote', 'sticky', 'revision') as $key) {
// Force defaults in case people modify the form:
$node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
foreach (array('status', 'moderate', 'promote', 'sticky', 'revision') as $key) {
if (!$access || !isset($node->$key)) {
$node->$key = in_array($key, $node_options);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment