Skip to content

Instantly share code, notes, and snippets.

@masiorama
Created July 22, 2013 08:21
Show Gist options
  • Save masiorama/6052197 to your computer and use it in GitHub Desktop.
Save masiorama/6052197 to your computer and use it in GitHub Desktop.
PHP: Drupal 6 Rules unpublish date/email notification
/* Drupal 6 Rules
* Unpublish of content with Date field (identity check date-based)
* Send auto email with Datetime field (identity check date-based)
*/
//removes all the headers, this comment included
array (
'rules' =>
array (
'rules_send_auto_email' =>
array (
'#type' => 'rule',
'#set' => 'event_node_update',
'#label' => 'Send auto email',
'#active' => 1,
'#weight' => '0',
'#categories' =>
array (
),
'#status' => 'custom',
'#conditions' =>
array (
0 =>
array (
'#type' => 'condition',
'#settings' =>
array (
'type' =>
array (
'promo_eventi_focus' => 'promo_eventi_focus',
),
'#argument map' =>
array (
'node' => 'node',
),
),
'#name' => 'rules_condition_content_is_type',
'#info' =>
array (
'label' => 'Updated content is Promo Eventi Focus',
'arguments' =>
array (
'node' =>
array (
'type' => 'node',
'label' => 'Contenuto',
),
),
'module' => 'Node',
),
'#weight' => 0,
),
1 =>
array (
'#settings' =>
array (
'text1' => '[node:field_date_email_notificat-value]',
'text2' => '^$',
'regex' => 1,
'#eval input' =>
array (
'token_rules_input_evaluator' =>
array (
'text1' =>
array (
0 => 'node',
1 => ':global',
),
'text2' =>
array (
0 => ':global',
),
),
),
),
'#type' => 'condition',
'#name' => 'rules_condition_text_compare',
'#info' =>
array (
'label' => 'Textual comparison',
'arguments' =>
array (
'text1' =>
array (
'label' => 'Text 1',
'type' => 'string',
),
'text2' =>
array (
'label' => 'Text 2',
'type' => 'string',
),
),
'module' => 'Rules',
),
'#weight' => 0,
'#negate' => 1,
),
),
'#actions' =>
array (
1 =>
array (
'#type' => 'action',
'#settings' =>
array (
'severity' => '5',
'type' => 'rules',
'message' => 'send mail {rule} about to trigger the ruleset which sends',
'link' => '',
'#eval input' =>
array (
'token_rules_input_evaluator' =>
array (
'type' =>
array (
0 => ':global',
),
'message' =>
array (
0 => ':global',
),
'link' =>
array (
0 => ':global',
),
),
),
),
'#name' => 'rules_action_watchdog',
'#info' =>
array (
'label' => 'Log to watchdog',
'module' => 'System',
'eval input' =>
array (
0 => 'type',
1 => 'message',
2 => 'link',
),
),
'#weight' => 0,
),
2 =>
array (
'#weight' => 0,
'#info' =>
array (
'arguments' =>
array (
'task_identifier' =>
array (
'type' => 'string',
'label' => 'Identifier',
'description' => 'User provided string to identify the task. Existing tasks for this rule set with the same identifier will be replaced.',
),
'task_date' =>
array (
'type' => 'date',
'label' => 'Scheduled evaluation date',
),
'node' =>
array (
'label' => 'Contenuto',
'type' => 'node',
),
),
'label' => 'Schedule "Send auto email {rule set}"',
'status' => 'custom',
'categories' =>
array (
),
'module' => 'Rule Scheduler',
'base' => 'rules_scheduler_action',
'set' => 'rules_send_auto_email',
),
'#name' => 'rules_action_schedule_set_rules_send_auto_email',
'#settings' =>
array (
'task_identifier' => 'node [node:nid]',
'task_date' => '[node:field_date_email_notificat-value]',
'#argument map' =>
array (
'node' => 'node',
),
'#eval input' =>
array (
'token_rules_input_evaluator' =>
array (
'task_identifier' =>
array (
0 => 'node',
1 => ':global',
),
'task_date' =>
array (
0 => 'node',
1 => ':global',
),
),
),
),
'#type' => 'action',
),
),
'#version' => 6003,
),
'rules_unpublish_update_promo_eventi_focus' =>
array (
'#type' => 'rule',
'#set' => 'event_node_update',
'#label' => 'Unpublish update promo_eventi_focus',
'#active' => 1,
'#weight' => '0',
'#categories' =>
array (
),
'#status' => 'custom',
'#conditions' =>
array (
0 =>
array (
'#info' =>
array (
'label' => 'Saved content is Promo Eventi Focus',
'label callback' => false,
'arguments' =>
array (
'node' =>
array (
'type' => 'node',
'label' => 'Contenuto',
),
),
'module' => 'Node',
),
'#name' => 'rules_condition_content_is_type',
'#settings' =>
array (
'type' =>
array (
'promo_eventi_focus' => 'promo_eventi_focus',
),
'#argument map' =>
array (
'node' => 'node',
),
),
'#type' => 'condition',
'#weight' => 0,
),
1 =>
array (
'#type' => 'condition',
'#settings' =>
array (
'text1' => '[node:field_unpublish_date-value]',
'text2' => '^$',
'regex' => 1,
'#eval input' =>
array (
'token_rules_input_evaluator' =>
array (
'text1' =>
array (
0 => 'node',
1 => ':global',
),
'text2' =>
array (
0 => ':global',
),
),
),
),
'#name' => 'rules_condition_text_compare',
'#info' =>
array (
'label' => 'Textual comparison empty',
'label callback' => false,
'arguments' =>
array (
'text1' =>
array (
'label' => 'Text 1',
'type' => 'string',
),
'text2' =>
array (
'label' => 'Text 2',
'type' => 'string',
),
),
'module' => 'Rules',
),
'#negate' => 1,
'#weight' => 0,
),
),
'#actions' =>
array (
0 =>
array (
'#weight' => 0,
'#type' => 'action',
'#settings' =>
array (
'task_identifier' => 'node [node:nid]',
'task_date' => '[node:field_unpublish_date-value]',
'#argument map' =>
array (
'unpublish_content__content' => 'node',
),
'#eval input' =>
array (
'token_rules_input_evaluator' =>
array (
'task_identifier' =>
array (
0 => 'node',
1 => ':global',
),
'task_date' =>
array (
0 => 'node',
1 => ':global',
),
),
),
),
'#name' => 'rules_action_schedule_set_rules_unpublish_content',
'#info' =>
array (
'arguments' =>
array (
'task_identifier' =>
array (
'type' => 'string',
'label' => 'Identifier',
'description' => 'User provided string to identify the task. Existing tasks for this rule set with the same identifier will be replaced.',
),
'task_date' =>
array (
'type' => 'date',
'label' => 'Scheduled evaluation date',
),
'unpublish_content__content' =>
array (
'label' => 'Contenuto {argument}',
'type' => 'node',
),
),
'label' => 'Schedule "Unpublish Content {rule set}"',
'status' => 'custom',
'categories' =>
array (
),
'module' => 'Rule Scheduler',
'base' => 'rules_scheduler_action',
'set' => 'rules_unpublish_content',
),
),
1 =>
array (
'#info' =>
array (
'label' => 'Log to watchdog',
'module' => 'System',
'eval input' =>
array (
0 => 'type',
1 => 'message',
2 => 'link',
),
),
'#name' => 'rules_action_watchdog',
'#settings' =>
array (
'severity' => '4',
'type' => 'rules',
'message' => 'trigger azione di Unpublish action {rule}',
'link' => '',
'#eval input' =>
array (
'token_rules_input_evaluator' =>
array (
'type' =>
array (
0 => ':global',
),
'message' =>
array (
0 => ':global',
),
'link' =>
array (
0 => ':global',
),
),
),
),
'#type' => 'action',
'#weight' => 0,
),
),
'#version' => 6003,
),
'rules_send_mail' =>
array (
'#type' => 'rule',
'#set' => 'rules_send_auto_email',
'#label' => 'Send mail',
'#active' => 1,
'#weight' => '0',
'#categories' =>
array (
),
'#status' => 'custom',
'#conditions' =>
array (
0 =>
array (
'#type' => 'condition',
'#settings' =>
array (
'#argument map' =>
array (
'node' => 'node',
),
),
'#name' => 'rules_condition_content_is_published',
'#info' =>
array (
'label' => 'Contenuto is published',
'arguments' =>
array (
'node' =>
array (
'type' => 'node',
'label' => 'Contenuto',
),
),
'module' => 'Node',
),
'#weight' => 0,
),
),
'#actions' =>
array (
0 =>
array (
'#info' =>
array (
'label' => 'Send a mail to an arbitrary mail address',
'module' => 'System',
'eval input' =>
array (
0 => 'subject',
1 => 'message',
2 => 'from',
3 => 'to',
),
),
'#name' => 'rules_action_mail',
'#settings' =>
array (
'to' => 'marketing@sigesgroup.it',
'from' => '[:global:site-mail]',
'subject' => 'Email auto-notification from [:global:site-name] - drupal 6',
'message' => 'Auto mail da contenuto con titolo [node:title] ([node:node-url])
',
'#eval input' =>
array (
'token_rules_input_evaluator' =>
array (
'subject' =>
array (
0 => ':global',
),
'message' =>
array (
0 => 'node',
1 => ':global',
),
'from' =>
array (
0 => ':global',
),
'to' =>
array (
0 => ':global',
),
),
),
),
'#type' => 'action',
'#weight' => 0,
),
1 =>
array (
'#type' => 'action',
'#settings' =>
array (
'severity' => '1',
'type' => 'rules',
'message' => 'Auto mail {rule set} to admin done',
'link' => '',
'#eval input' =>
array (
'token_rules_input_evaluator' =>
array (
'type' =>
array (
0 => ':global',
),
'message' =>
array (
0 => ':global',
),
'link' =>
array (
0 => ':global',
),
),
),
),
'#name' => 'rules_action_watchdog',
'#info' =>
array (
'label' => 'Log to watchdog',
'module' => 'System',
'eval input' =>
array (
0 => 'type',
1 => 'message',
2 => 'link',
),
),
'#weight' => 0,
),
),
'#version' => 6003,
),
'rules_unpublish_action' =>
array (
'#type' => 'rule',
'#set' => 'rules_unpublish_content',
'#label' => 'Unpublish action {rule}',
'#active' => 1,
'#weight' => '0',
'#categories' =>
array (
),
'#status' => 'custom',
'#conditions' =>
array (
0 =>
array (
'#type' => 'condition',
'#settings' =>
array (
'#argument map' =>
array (
'node' => 'unpublish_content__content',
),
),
'#name' => 'rules_condition_content_is_published',
'#info' =>
array (
'label' => 'Contenuto {argument} is published',
'arguments' =>
array (
'node' =>
array (
'type' => 'node',
'label' => 'Contenuto',
),
),
'module' => 'Node',
),
'#weight' => 0,
),
),
'#actions' =>
array (
0 =>
array (
'#info' =>
array (
'label' => 'Log to watchdog',
'module' => 'System',
'eval input' =>
array (
0 => 'type',
1 => 'message',
2 => 'link',
),
),
'#name' => 'rules_action_watchdog',
'#settings' =>
array (
'severity' => '1',
'type' => 'rules',
'message' => 'trigger azione di Unpublish action {rule set}',
'link' => '',
'#eval input' =>
array (
'token_rules_input_evaluator' =>
array (
'type' =>
array (
0 => ':global',
),
'message' =>
array (
0 => ':global',
),
'link' =>
array (
0 => ':global',
),
),
),
),
'#type' => 'action',
'#weight' => 0,
),
1 =>
array (
'#type' => 'action',
'#settings' =>
array (
'auto_save' => 1,
'#argument map' =>
array (
'node' => 'unpublish_content__content',
),
),
'#name' => 'rules_core_node_unpublish_action',
'#info' =>
array (
'label' => 'Non pubblicare il Contenuto {argument}',
'module' => 'Node',
'arguments' =>
array (
'node' =>
array (
'label' => 'Contenuto',
'type' => 'node',
),
),
'base' => 'rules_core_action_execute',
'action_name' => 'node_unpublish_action',
'configurable' => false,
'label callback' => 'rules_core_node_label_callback',
'label_skeleton' => 'Non pubblicare il @node',
),
'#weight' => 0,
),
),
'#version' => 6003,
),
),
'rule_sets' =>
array (
'rules_send_auto_email' =>
array (
'arguments' =>
array (
'node' =>
array (
'label' => 'Contenuto',
'type' => 'node',
),
),
'label' => 'Send auto email {rule set}',
'status' => 'custom',
'categories' =>
array (
),
),
'rules_unpublish_content' =>
array (
'arguments' =>
array (
'unpublish_content__content' =>
array (
'label' => 'Contenuto {argument}',
'type' => 'node',
),
),
'label' => 'Unpublish Content {rule set}',
'status' => 'custom',
'categories' =>
array (
),
),
),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment