You are here

function flag_rules_action_info in Flag 6.2

Same name and namespace in other branches
  1. 6 includes/flag.rules.inc \flag_rules_action_info()
  2. 7.3 flag.rules.inc \flag_rules_action_info()
  3. 7.2 flag.rules.inc \flag_rules_action_info()

Implementation of hook_rules_action_info().

File

includes/flag.rules.inc, line 148
Rules integration for the Flag module.

Code

function flag_rules_action_info() {
  $items = array(
    'flag_rules_action_trim' => array(
      'label' => t('Trim a flag'),
      'arguments' => array(
        'flag' => array(
          'type' => 'flag',
          'label' => t('Flag'),
        ),
        'flagging_user' => array(
          'type' => 'user',
          'label' => t('User whose flag to trim'),
          'description' => t('For non-global flags, this is the user whose flag to trim. (For global flags, this argument is ignored.)'),
        ),
        'cutoff_size' => array(
          'type' => 'number',
          'label' => t('Flag queue size'),
          'description' => t('The maximum number of objects to keep in the queue. Newly flagged objects will be kept; older ones will be removed. Tip: by typing "1" here you implement a singleton.'),
        ),
      ),
      'module' => 'Flag',
    ),
    'flag_fetch_entity_by_user' => array(
      'label' => t('Fetch content flagged by user'),
      'base' => 'flag_rules_action_fetch_content_by_user',
      'parameter' => array(
        'flag' => array(
          'type' => 'flag',
          'label' => t('Flag'),
        ),
        'flagging_user' => array(
          'type' => 'user',
          'label' => t('User who flagged the content'),
          'description' => t('For non-global flags, this is the user who flagged the content. (For global flags, this argument is ignored.)'),
        ),
      ),
      'provides' => array(
        'content_flagged_by_user' => array(
          'label' => t('Content flagged by user'),
          'type' => 'list<node>',
        ),
      ),
      'group' => t('Flag'),
      'access callback' => 'flag_rules_integration_access',
    ),
  );
  foreach (flag_get_types() as $type) {
    $args = array(
      'flag' => array(
        'type' => 'flag',
        'label' => t('Flag'),
        'flag_type' => $type,
      ),
    );
    $flag = flag_create_handler($type);
    if ($flag
      ->rules_get_element_argument_definition()) {
      $args += array(
        'object' => $flag
          ->rules_get_element_argument_definition(),
      );
      $items += array(
        'flag_rules_action_flag_' . $type => array(
          'label' => t('Flag a @type', array(
            '@type' => $type,
          )),
          'base' => 'flag_rules_action_flag',
          'label callback' => 'flag_rules_action_flag_label',
          'arguments' => $args + array(
            'flagging_user' => array(
              'type' => 'user',
              'label' => t('User on whose behalf to flag'),
              'description' => t('For non-global flags, this is the user on whose behalf to flag the object. In addition, if checked below, the access permissions to the flag are checked against this user.'),
            ),
          ),
          'module' => 'Flag',
        ),
        'flag_rules_action_unflag_' . $type => array(
          'label' => t('Unflag a @type', array(
            '@type' => $type,
          )),
          'base' => 'flag_rules_action_unflag',
          'label callback' => 'flag_rules_action_unflag_label',
          'arguments' => $args + array(
            'flagging_user' => array(
              'type' => 'user',
              'label' => t('User on whose behalf to unflag'),
              'description' => t('For non-global flags, this is the user on whose behalf to unflag the object. In addition, if checked below, the access permissions to the flag are checked against this user.'),
            ),
          ),
          'module' => 'Flag',
        ),
      );
    }
  }
  return $items;
}