/[drupal]/contributions/modules/node_expire/node_expire.rules.inc
ViewVC logotype

Contents of /contributions/modules/node_expire/node_expire.rules.inc

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


Revision 1.1 - (show annotations) (download) (as text)
Mon Jan 26 23:56:49 2009 UTC (10 months ago) by brmassa
Branch: MAIN
CVS Tags: DRUPAL-6--2-01, DRUPAL-6--2-02, DRUPAL-6--2-03, DRUPAL-6--2-0, HEAD
File MIME type: text/x-php
New features:
* Complete module rewrite. It now uses Rules module in order to allow admins to perform a customizable list of actions with expired nodes. Also export all data to Views (if enabled) and uses jQuery UI DatePicker plugin (if enabled).

NOTE: not yet compatible with previous versions
1 <?php
2 // $Id: $
3
4 /**
5 * @file
6 * Rules module integration.
7 */
8
9 /**
10 * Implementation of hook_rules_action_info().
11 * @ingroup rules
12 */
13 function node_expire_rules_action_info() {
14 return array(
15 'node_expire_set_expired' => array(
16 'arguments' => array(
17 'node' => array('type' => 'node', 'label' => t('content expired')),
18 ),
19 'label' => t('Unset the expired flag'),
20 'module' => 'Node',
21 ),
22 );
23 }
24
25 /**
26 * Implementation of hook_rules_condition_info().
27 * @ingroup rules
28 */
29 function node_expire_rules_condition_info() {
30 return array(
31 'node_expire_rules_expired_check' => array(
32 'arguments' => array(
33 'node' => array('type' => 'node', 'label' => t('Content')),
34 ),
35 'label' => t('Content is expired'),
36 'help' => 'Evaluates to TRUE, if the given content has one of the selected content types.',
37 'module' => 'Node',
38 ),
39 );
40 }
41
42 /**
43 * Implementation of hook_rules_event_info().
44 * @ingroup rules
45 */
46 function node_expire_rules_event_info() {
47 return array(
48 'node_expired' => array(
49 'arguments' => rules_events_node_arguments(t('content expired'), t("content's author")),
50 'label' => t('Content expired'),
51 'module' => 'Node',
52 ),
53 );
54 }
55
56 /**
57 * Check if the node has the the "Expired" flag on.
58 *
59 * @param $node
60 * Object. The Node object.
61 */
62 function node_expire_rules_expired_check($node) {
63 return (!empty($node->expire) and $node->expire <= time());
64 }
65
66 /**
67 * Set the "Expired" flag on nodes after they are called by Rules module
68 * or prevent it from happening.
69 *
70 * @param $nids
71 * Object or Array. The Node object or a array list with all node IDs
72 * that shuold be changed the expired flag to TRUE.
73 * @param $set
74 * Boolean (optional). Only TRUE if its time to set the nodes list as expired.
75 */
76 function node_expire_set_expired($nids, $set = FALSE) {
77 static $nid_no = array();
78 if (empty($close)) {
79 $nid_no[] = $node->nid;
80 }
81 else {
82 if ($nids = array_diff($nids, $nid_no)) {
83 db_query('UPDATE {node_expire} SET expired = 1
84 WHERE nid IN ('. implode(',', $nids) .')');
85 }
86 }
87 }

  ViewVC Help
Powered by ViewVC 1.1.2