/[drupal]/contributions/modules/recycle_node/recycle_node.module
ViewVC logotype

Contents of /contributions/modules/recycle_node/recycle_node.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Tue Nov 18 23:20:19 2008 UTC (12 months, 1 week ago) by deekayen
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-5
Changes since 1.1: +20 -21 lines
File MIME type: text/x-php
coder cleanup
use t() on the status message and output the node id
make UID 1 an exception to the rule on deletion
1 <?php
2 // $Id$
3
4 /**
5 * @file
6 * Unpublish nodes when using the delete function in the node's edit tab.
7 * Content deletion may still actually be done through Content Administration.
8 */
9
10 /**
11 * Implementation of hook_form_alter().
12 */
13 function recycle_node_form_alter($form_id, &$form) {
14 global $user;
15 // add Unpublish button to the delete node form
16 if ($form_id == 'node_delete_confirm' && $user->uid != 1) {
17 unset($form['#submit']['node_delete_confirm_submit']);
18 $form['#submit']['recycle_node_form_unpublish_submit'] = array();
19 }
20 }
21
22 function recycle_node_form_unpublish_submit($form_id, $form_values) {
23 if ($form_id == 'node_delete_confirm') {
24 $node = node_load($form_values['nid']);
25 $node->status = 0; // set status to unpublished
26 node_save($node);
27 drupal_set_message(t("Node @nid has been unpublished.", array('@nid' => $form_values['nid'])));
28 }
29 return '';
30 }

  ViewVC Help
Powered by ViewVC 1.1.2