diff options
Diffstat (limited to 'modules/node/node.module')
-rw-r--r-- | modules/node/node.module | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/modules/node/node.module b/modules/node/node.module index c82271aa9..3552ba945 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -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)))); |