Commit 414b5e39 authored by Steven Wittens's avatar Steven Wittens
Browse files

#38451: Fix node options reverting on non-admin edit (bad commit)

parent 23ffc2b9
......@@ -1861,9 +1861,28 @@ function node_submit($node) {
else {
$node->uid = 0;
}
$node->created = $node->date ? strtotime($node->date) : NULL;
}
// Process the workflow options and provide defaults. If the user
// can not administer nodes, ignore the form and either use the
// saved values if the node exists, or force the defaults.
if (!$access && $node->nid) {
$saved_node = node_load($node->nid);
}
else {
$node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
}
foreach (array('status', 'promote', 'sticky', 'revision') as $key) {
if (!$access && $node->nid) {
$node->$key = $saved_node->$key;
}
else if (!isset($node->$key) || !$access) {
$node->$key = in_array($key, $node_options);
}
}
// Do node-type-specific validation checks.
node_invoke($node, 'submit');
node_invoke_nodeapi($node, 'submit');
......@@ -2224,14 +2243,6 @@ function node_form_submit($form_id, $form_values) {
drupal_set_message(t('The %post has been updated.', array ('%post' => node_get_types('name', $node))));
}
else {
// Add defaults for new nodes
$access = user_access('administer nodes');
$node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
foreach (array('status', 'promote', 'sticky', 'revision') as $key) {
if (!$access || !isset($node->$key)) {
$node->$key = in_array($key, $node_options);
}
}
node_save($node);
watchdog('content', t('@type: added %title.', array('@type' => t($node->type), '%title' => $node->title)), WATCHDOG_NOTICE, l(t('view'), "node/$node->nid"));
drupal_set_message(t('Your %post has been created.', array ('%post' => node_get_types('name', $node))));
......
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