Commit d093f4ee authored by Steven Wittens's avatar Steven Wittens
Browse files

#38451: Maintain node options when a non-admin edits a node.

parent 7ea92ac3
...@@ -1861,16 +1861,8 @@ function node_submit($node) { ...@@ -1861,16 +1861,8 @@ function node_submit($node) {
else { else {
$node->uid = 0; $node->uid = 0;
} }
$node->created = $node->date ? strtotime($node->date) : NULL; $node->created = $node->date ? strtotime($node->date) : NULL;
} }
// Force defaults in case people modify the form:
$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);
}
}
// Do node-type-specific validation checks. // Do node-type-specific validation checks.
node_invoke($node, 'submit'); node_invoke($node, 'submit');
...@@ -2232,6 +2224,14 @@ function node_form_submit($form_id, $form_values) { ...@@ -2232,6 +2224,14 @@ function node_form_submit($form_id, $form_values) {
drupal_set_message(t('The %post has been updated.', array ('%post' => node_get_types('name', $node)))); drupal_set_message(t('The %post has been updated.', array ('%post' => node_get_types('name', $node))));
} }
else { 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); 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")); 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)))); 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