You are here

function rules_rules_action_info in Rules 6

Same name and namespace in other branches
  1. 7.2 rules.rules.inc \rules_rules_action_info()

Implementation of hook_rules_action_info().

Related topics

File

rules/modules/rules.rules.inc, line 205
rules integration for the rules module

Code

function rules_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_invoke_set_' . $name] = $set_info + array(
      'module' => 'Rule Sets',
      'base' => 'rules_action_invoke_set',
      'set' => $name,
    );
  }

  // Add drupal 6 core actions.
  $core_actions = actions_list();
  foreach ($core_actions as $name => $core_action_info) {
    $type_map = rules_gather_data('rules_action_type_map');
    $items['rules_core_' . $name] = rules_core_action_transform_info($name, $core_action_info, $type_map);
  }
  $items = array_filter($items);

  // Add an action to add a new variable for all data types that use an input form.
  foreach (rules_get_data_types() as $name => $type_info) {
    $type_info += array(
      'use_input_form' => empty($type_info['identifiable']),
    );
    if (!empty($type_info['use_input_form']) && empty($type_info['hidden'])) {
      $items['rules_add_var_' . $name] = array(
        'module' => 'Rules',
        'base' => 'rules_action_save_variable',
        'label' => t('Add a new @type variable', array(
          '@type' => $type_info['label'],
        )),
        'arguments' => array(
          'var_name' => array(
            'type' => 'value',
            'default value' => $name,
          ),
          $name => array(
            'type' => $name,
            'label' => $type_info['label'],
          ),
        ),
        'new variables' => array(
          $name => array(
            'type' => $name,
            'label' => t('Added @type', array(
              '@type' => $type_info['label'],
            )),
          ),
        ),
      );
    }
  }

  // Add an action to save savable data types
  foreach (rules_get_data_types() as $name => $type_info) {
    if (!empty($type_info['savable']) && empty($type_info['hidden']) && empty($type_info['use_input_form'])) {
      $items['rules_save_var_' . $name] = array(
        'module' => isset($type_info['module']) ? $type_info['module'] : 'Rules',
        'base' => 'rules_action_save_variable',
        'label' => t('Save a @type', array(
          '@type' => $type_info['label'],
        )),
        'arguments' => array(
          'var_name' => array(
            'type' => 'value',
            'default value' => $name,
          ),
          $name => array(
            'type' => $name,
            'label' => $type_info['label'],
          ),
        ),
      );
    }
  }
  return $items;
}