[177a560] | 1 | <?php |
---|
| 2 | // $Id: revision_moderation_actions.inc,v 1.3 2007/12/18 03:14:40 webchick Exp $ |
---|
| 3 | |
---|
| 4 | /** |
---|
| 5 | * @file |
---|
| 6 | * Actions support for revision moderation module. |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | /** |
---|
| 10 | * Implementation of hook_action_info. |
---|
| 11 | */ |
---|
| 12 | function revision_moderation_action_info() { |
---|
| 13 | $actions['revision_moderation_enable_action'] = array( |
---|
| 14 | 'type' => 'node', |
---|
| 15 | 'description' => t('Enable revision moderation on node'), |
---|
| 16 | 'configurable' => FALSE, |
---|
| 17 | 'hooks' => array( |
---|
| 18 | 'nodeapi' => array('presave', 'insert', 'update'), |
---|
| 19 | 'comment' => array('delete', 'insert', 'update') |
---|
| 20 | ), |
---|
| 21 | ); |
---|
| 22 | $actions['revision_moderation_disable_action'] = array( |
---|
| 23 | 'type' => 'node', |
---|
| 24 | 'description' => t('Disable revision moderation on node'), |
---|
| 25 | 'configurable' => FALSE, |
---|
| 26 | 'hooks' => array( |
---|
| 27 | 'nodeapi' => array('presave', 'insert', 'update'), |
---|
| 28 | 'comment' => array('delete', 'insert', 'update') |
---|
| 29 | ), |
---|
| 30 | ); |
---|
| 31 | return $actions; |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | /** |
---|
| 35 | * Implementation of a Drupal action; enables revision moderation |
---|
| 36 | * on a node. |
---|
| 37 | */ |
---|
| 38 | function revision_moderation_enable_action(&$node, $context) { |
---|
| 39 | $node->revision_moderation = 1; |
---|
| 40 | // Also enable "Create new revisions" option, in case it isn't yet. |
---|
| 41 | $node->revision = 1; |
---|
| 42 | node_save($node); |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | /** |
---|
| 46 | * Implementation of a Drupal action; disables revision moderation |
---|
| 47 | * on a node. |
---|
| 48 | */ |
---|
| 49 | function revision_moderation_disable_action(&$node, $context) { |
---|
| 50 | $node->revision_moderation = 0; |
---|
| 51 | node_save($node); |
---|
| 52 | } |
---|