summaryrefslogtreecommitdiff
path: root/modules/node/node.module
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2007-01-10 10:28:23 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2007-01-10 10:28:23 +0000
commit414b5e3901271b91bebdd03c3abe00f507dbc87c (patch)
tree0435c05dea66d1c4345fb26c25e016e1d1d9e44d /modules/node/node.module
parent23ffc2b9a9bb33b4ea8c8e70c225bc14026074e5 (diff)
downloadbrdo-414b5e3901271b91bebdd03c3abe00f507dbc87c.tar.gz
brdo-414b5e3901271b91bebdd03c3abe00f507dbc87c.tar.bz2
#38451: Fix node options reverting on non-admin edit (bad commit)
Diffstat (limited to 'modules/node/node.module')
-rw-r--r--modules/node/node.module27
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))));