You are here

function flag_rules_action_info in Flag 7.2

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

Implements hook_rules_action_info().

File

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

Code

function flag_rules_action_info() {
  $items = array(
    'flag_trim' => array(
      'label' => t('Trim a flag'),
      'base' => 'flag_rules_action_trim',
      'parameter' => 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' => 'integer',
          '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.'),
        ),
      ),
      'group' => t('Flag'),
      'access callback' => 'flag_rules_integration_access',
    ),
    'flag_fetch_entity_by_user' => array(
      'label' => t('Fetch content flagged by user'),
      'base' => 'flag_rules_action_fetch_entity_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',
    ),
  );
  $param_defaults = 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.'),
    ),
    'permission_check' => array(
      'type' => 'boolean',
      'label' => t('Skip permission check'),
      'description' => t('Whether to ignore permissions of the user on whose behalf to flag.'),
      'restriction' => 'input',
    ),
  );
  foreach (flag_get_types() as $type) {
    $flag = flag_create_handler($type);
    $entity_info = entity_get_info($type);
    $items += array(
      'flag_flag' . $type => array(
        'label' => t('Flag a @type', array(
          '@type' => $type,
        )),
        'base' => 'flag_rules_action_flag',
        'parameter' => array(
          'flag' => array(
            'type' => 'flag',
            'label' => t('Flag'),
            'flag_type' => $type,
            'description' => t('The flag to check for.'),
          ),
          $type => array(
            'type' => $type,
            'label' => isset($entity_info[$type]['label']) ? $entity_info[$type]['label'] : $type,
          ),
        ) + $param_defaults,
        'group' => t('Flag'),
        'access callback' => 'flag_rules_integration_access',
      ),
      'flag_unflag' . $type => array(
        'label' => t('Unflag a @type', array(
          '@type' => $type,
        )),
        'base' => 'flag_rules_action_unflag',
        'parameter' => array(
          'flag' => array(
            'type' => 'flag',
            'label' => t('Flag'),
            'flag_type' => $type,
            'description' => t('The flag to check for.'),
          ),
          $type => array(
            'type' => $type,
            'label' => isset($entity_info[$type]['label']) ? $entity_info[$type]['label'] : $type,
          ),
        ) + $param_defaults,
        'group' => t('Flag'),
        'access callback' => 'flag_rules_integration_access',
      ),
    );
    $items['flag_fetch_users_' . $type] = array(
      'label' => t('Fetch users who have flagged a @type', array(
        '@type' => $type,
      )),
      'base' => 'flag_rules_action_fetch_users',
      'parameter' => array(
        'flag' => array(
          'type' => 'flag',
          'label' => t('Flag'),
          'flag_type' => $type,
          'description' => t('Choose the flag for which to fetch the users.'),
        ),
        $type => array(
          'type' => $type,
          'label' => isset($entity_info[$type]['label']) ? $entity_info[$type]['label'] : $type,
        ),
      ),
      'provides' => array(
        'users' => array(
          'label' => t('Users who flagged'),
          'type' => 'list<user>',
        ),
      ),
      'group' => t('Flag'),
      'access callback' => 'flag_rules_integration_access',
    );
  }
  return $items;
}