Index: modules/node/node.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.pages.inc,v retrieving revision 1.31 diff -u -p -r1.31 node.pages.inc --- modules/node/node.pages.inc 10 Jul 2008 11:12:02 -0000 1.31 +++ modules/node/node.pages.inc 15 Jul 2008 12:09:58 -0000 @@ -203,8 +203,7 @@ function node_form(&$form_state, $node) '#weight' => 25, ); $form['options']['status'] = array( - '#type' => 'checkbox', - '#title' => t('Published'), + '#type' => 'hidden', '#default_value' => $node->status, ); $form['options']['promote'] = array( @@ -228,12 +227,20 @@ function node_form(&$form_state, $node) // Add the buttons. $form['buttons'] = array(); - $form['buttons']['submit'] = array( + $form['buttons']['submit-publish'] = array( '#type' => 'submit', - '#value' => t('Save'), + '#access' => user_access('administer nodes') || $node->status, + '#value' => $node->status && isset($node->nid) ? t('Save changes') : t('Publish'), '#weight' => 5, '#submit' => array('node_form_submit'), ); + $form['buttons']['submit-unpublish'] = array( + '#type' => 'submit', + '#access' => user_access('administer nodes') || !$node->status, + '#value' => $node->status && isset($node->nid) ? t('Save and unpublish') : t('Save as draft'), + '#weight' => 6, + '#submit' => array('node_form_submit'), + ); $form['buttons']['preview'] = array( '#type' => 'submit', '#value' => t('Preview'), @@ -462,6 +469,11 @@ function node_form_submit($form, &$form_ watchdog('content', '@type: updated %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link); drupal_set_message(t('@type %title has been updated.', $t_args)); } + if ($form_state['old_status'] != $form_state['values']['status']) { + if ($form_state['values']['status']) drupal_set_message(t('@type %title has been published.', $t_args)); + else drupal_set_message(t('@type %title has been unpublished.', $t_args)); + } + if ($node->nid) { unset($form_state['rebuild']); $form_state['nid'] = $node->nid; @@ -478,6 +490,13 @@ function node_form_submit($form, &$form_ * Build a node by processing submitted form values and prepare for a form rebuild. */ function node_form_submit_build_node($form, &$form_state) { + $form_state['old_status'] = isset($form_state['values']['nid']) ? $form_state['values']['status'] : 0; + if ($form_state['clicked_button']['#id'] == 'edit-submit-publish') { + $form_state['values']['status'] = 1; + } + else if ($form_state['clicked_button']['#id'] == 'edit-submit-unpublish') { + $form_state['values']['status'] = 0; + } // Unset any button-level handlers, execute all the form-level submit // functions to process the form values into an updated node. unset($form_state['submit_handlers']);