You are here

function rules_scheduler_rules_action_info in Rules 6

Same name and namespace in other branches
  1. 7.2 rules_scheduler/rules_scheduler.rules.inc \rules_scheduler_rules_action_info()

Implementation of hook_rules_action_info().

File

rules_scheduler/rules_scheduler.rules.inc, line 12
Rules integration for the rules scheduler module.

Code

function rules_scheduler_rules_action_info() {
  $items = array();

  // Add actions for all rule sets.
  foreach (rules_get_configured_items('rule_sets') as $name => $set_info) {
    $items['rules_action_schedule_set_' . $name] = $set_info + array(
      'module' => 'Rule Scheduler',
      'base' => 'rules_scheduler_action',
      'set' => $name,
    );
    $item =& $items['rules_action_schedule_set_' . $name];
    $item['label'] = t('Schedule "@set"', array(
      '@set' => $set_info['label'],
    ));
    $item += array(
      'arguments' => array(),
    );
    $date_arg = array(
      'task_date' => array(
        'type' => 'date',
        'label' => t('Scheduled evaluation date'),
      ),
    );
    $item['arguments'] = array_merge($date_arg, $item['arguments']);
    $identifier_arg = array(
      'task_identifier' => array(
        'type' => 'string',
        'label' => t('Identifier'),
        'description' => t('User provided string to identify the task. Existing tasks for this rule set with the same identifier will be replaced.'),
      ),
    );
    $item['arguments'] = array_merge($identifier_arg, $item['arguments']);
  }

  // Add action to delete scheduled tasks
  $items['rules_action_delete_scheduled_set'] = array(
    'label' => t('Delete scheduled tasks'),
    'module' => 'Rule Scheduler',
    'base' => 'rules_scheduler_action_delete',
    'arguments' => array(
      'task_identifier' => array(
        'type' => 'string',
        'label' => t('Identifier'),
        'description' => t('All tasks that are annotated with this user provided identifier will be deleted.'),
      ),
      'ruleset' => array(
        'type' => 'string',
        'label' => t('Rule set'),
        'description' => t('All tasks that execute this rule set will be deleted.'),
      ),
    ),
  );
  return $items;
}