You are here

function rb_misc_rules_action_info in Rules Bonus Pack 7

Same name and namespace in other branches
  1. 6 rb_misc.module \rb_misc_rules_action_info()

Implements hook_rules_action_info().

File

./rb_misc.rules.inc, line 105
Miscellaneous conditions and actions for Rules.

Code

function rb_misc_rules_action_info() {

  // Add actions that depend on required modules only.
  $actions = array(
    'rb_misc_action_set_title' => array(
      'label' => t('Set page title'),
      'parameter' => array(
        'page_title' => array(
          'type' => 'text',
          'label' => t('Title to set'),
          'description' => t('Choose which page title should be set on this action. This title is set as $title in page.tpl.php'),
        ),
      ),
      'group' => t('Rules Bonus: Miscellaneous'),
    ),
    'rb_misc_action_node_clone' => array(
      'label' => t('Clone a node'),
      'parameter' => array(
        'node' => array(
          'type' => 'node',
          'label' => t('Node to clone'),
          'description' => t('All properties except node ID, version ID and
            a few other meta data will be cloned. Use the node save action
            to provide the new node with a node ID.'),
        ),
      ),
      'provides' => array(
        'cloned_node' => array(
          'type' => 'node',
          'label' => t('Cloned node'),
          'save' => TRUE,
        ),
      ),
      'group' => t('Rules Bonus: Miscellaneous'),
    ),
    'rb_misc_action_integer_to_date' => array(
      'label' => t('Create a date from a number'),
      'parameter' => array(
        'integer' => array(
          'type' => 'integer',
          'label' => t('Integer number'),
        ),
      ),
      'provides' => array(
        'date' => array(
          'type' => 'date',
          'label' => t('Date'),
        ),
      ),
      'group' => t('Rules Bonus: Miscellaneous'),
    ),
    'rb_misc_action_concatenate_strings' => array(
      'label' => t('Merge two strings'),
      'parameter' => array(
        'string1' => array(
          'type' => 'text',
          'label' => t('First text string'),
        ),
        'string2' => array(
          'type' => 'text',
          'label' => t('Second text string'),
        ),
      ),
      'provides' => array(
        'string' => array(
          'type' => 'text',
          'label' => t('Merged string'),
        ),
      ),
      'group' => t('Rules Bonus: Miscellaneous'),
    ),
    'rb_misc_action_string_to_integer' => array(
      'label' => t('Get integer from string'),
      'parameter' => array(
        'string' => array(
          'type' => 'text',
          'label' => t('String'),
          'description' => t('If the string is not numeric, 0 will be returned.'),
        ),
      ),
      'provides' => array(
        'integer' => array(
          'type' => 'integer',
          'label' => t('Integer'),
        ),
      ),
      'group' => t('Rules Bonus: Miscellaneous'),
    ),
  );

  // Add actions that depend on non-required modules.
  if (module_exists('views')) {
    $actions['rb_misc_action_views_load_list'] = array(
      'label' => t('Load a node list with Views'),
      'parameter' => array(
        'view' => array(
          'type' => 'text',
          'label' => t('View and display'),
          'options list' => 'rb_misc_views_list_node',
          'description' => t('Select the view and display you want to use to
            create a list.'),
          'restriction' => 'input',
        ),
        'args' => array(
          'type' => 'text',
          'label' => t('Arguments'),
          'description' => t('Any arguments to pass to the view, one per line.
            You may use token replacement patterns.'),
          'optional' => TRUE,
        ),
      ),
      'provides' => array(
        'node_list' => array(
          'type' => 'list<node>',
          'label' => t('View node list'),
        ),
      ),
      'group' => t('Rules Bonus: Miscellaneous'),
    );
    $actions['rb_misc_action_views_load_user_list'] = array(
      'label' => t('Load a user list with Views'),
      'parameter' => array(
        'view' => array(
          'type' => 'text',
          'label' => t('View and display'),
          'options list' => 'rb_misc_views_list_user',
          'description' => t('Select the view and display you want to use to
            create a list.'),
          'restriction' => 'input',
        ),
        'args' => array(
          'type' => 'text',
          'label' => t('Arguments'),
          'description' => t('Any arguments to pass to the view, one per line.
            You may use token replacement patterns.'),
          'optional' => TRUE,
        ),
      ),
      'provides' => array(
        'user_list' => array(
          'type' => 'list<user>',
          'label' => t('View user list'),
        ),
      ),
      'group' => t('Rules Bonus: Miscellaneous'),
    );
    $actions['rb_misc_action_views_load_node'] = array(
      'label' => t('Load the first node in a Views list'),
      'parameter' => array(
        'view' => array(
          'type' => 'text',
          'label' => t('View and display'),
          'options list' => 'rb_misc_views_list_node',
          'description' => t('Select the view and display you want to use to
            load a node.'),
          'restriction' => 'input',
        ),
        'args' => array(
          'type' => 'text',
          'label' => t('Arguments'),
          'description' => t('Any arguments to pass to the view, one per line.
            You may use token replacement patterns.'),
          'optional' => TRUE,
        ),
      ),
      'provides' => array(
        'node' => array(
          'type' => 'node',
          'label' => t('Node from Views'),
        ),
      ),
      'group' => t('Rules Bonus: Miscellaneous'),
    );

    // Note that the following if statement *should* be inside the Views if
    // statement.
    if (module_exists('comment')) {
      $actions['rb_misc_action_views_load_comment_list'] = array(
        'label' => t('Load a comment list with Views'),
        'parameter' => array(
          'view' => array(
            'type' => 'text',
            'label' => t('View and display'),
            'options list' => 'rb_misc_views_list_comment',
            'description' => t('Select the view and display you want to use to
              create a list.'),
            'restriction' => 'input',
          ),
          'args' => array(
            'type' => 'text',
            'label' => t('Arguments'),
            'description' => t('Any arguments to pass to the view, one per line.
              You may use token replacement patterns.'),
            'optional' => TRUE,
          ),
        ),
        'provides' => array(
          'comment_list' => array(
            'type' => 'list<comment>',
            'label' => t('View comment list'),
          ),
        ),
        'group' => t('Rules Bonus: Miscellaneous'),
      );
    }
  }
  if (module_exists('menu') && module_exists('menu_position')) {
    $actions['rb_misc_action_set_active_menu_item'] = array(
      'label' => t('Set the active menu item'),
      'parameter' => array(
        'menu_item' => array(
          'type' => 'text',
          'label' => t('Menu item'),
          'options list' => 'rb_misc_action_set_active_menu_item_list',
          'restriction' => 'input',
          'description' => t('Select the menu item that should be marked active.'),
        ),
      ),
      'group' => t('Rules Bonus: Miscellaneous'),
    );
  }
  if (module_exists('path')) {
    $actions['rb_misc_action_get_path_alias'] = array(
      'label' => t('Load a path alias'),
      'parameter' => array(
        'path' => array(
          'type' => 'text',
          'label' => t('Internal path to fetch alias for'),
          'description' => t('If multiple aliases exist, only the first will be fetched.'),
        ),
        'language' => array(
          'type' => 'token',
          'label' => t('Language'),
          'description' => t('The language for which the URL alias applies, if any.'),
          'options list' => 'entity_metadata_language_list',
          'optional' => TRUE,
          'default value' => LANGUAGE_NONE,
        ),
      ),
      'provides' => array(
        'alias' => array(
          'type' => 'text',
          'label' => t('Path alias'),
          'save' => TRUE,
        ),
      ),
      'group' => t('Rules Bonus: Miscellaneous'),
    );
  }

  // Automatic Nodetitles.
  if (module_exists('auto_nodetitle')) {
    $actions['rb_misc_action_auto_nodetitle'] = array(
      'label' => t('Set auto nodetitle'),
      'parameter' => array(
        'node' => array(
          'type' => 'node',
          'label' => t('Content'),
          'save' => TRUE,
        ),
      ),
      'access callback' => 'rules_node_admin_access',
      'group' => t('Rules Bonus: Miscellaneous'),
    );
  }
  return $actions;
}