You are here

function flag_rules_condition_info in Flag 7.3

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

Implements hook_rules_condition_info().

File

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

Code

function flag_rules_condition_info() {
  $items = array();
  foreach (flag_get_types() as $type) {
    $entity_info = entity_get_info($type);
    $label = isset($entity_info[$type]['label']) ? $entity_info[$type]['label'] : $type;
    $items += array(
      'flag_threshold_' . $type => array(
        'label' => drupal_ucfirst(t('@type has flagging count', array(
          '@type' => $label,
        ))),
        'base' => 'flag_rules_condition_threshold',
        'parameter' => array(
          'flag' => array(
            'type' => 'flag',
            'label' => t('Flag'),
            'flag_type' => $type,
            'description' => t('The flag to check for.'),
          ),
          $type => array(
            'type' => $type,
            'label' => $label,
          ),
          'number' => array(
            'type' => 'integer',
            'label' => t('Number'),
            'description' => t('The number against which to test the number of
              times the object is flagged. For example, if you type "3" here,
              and choose "Greater than" for the operator, then this condition
              will return TRUE if the object is flagged more than three times.
              During a flagging or an unflagging event the count will take into
              account the current flag/unflag process.'),
          ),
          'operator' => array(
            'type' => 'text',
            'label' => t('Comparison operator'),
            'options list' => 'flag_rules_condition_threshold_operator_options',
            'restriction' => 'input',
            'default value' => '=',
            'optional' => TRUE,
          ),
        ),
        'group' => t('Flag'),
        'access callback' => 'flag_rules_integration_access',
      ),
      'flag_flagged_' . $type => array(
        'label' => drupal_ucfirst(t('@type is flagged', array(
          '@type' => $label,
        ))),
        'base' => 'flag_rules_condition_flagged',
        'parameter' => array(
          'flag' => array(
            'type' => 'flag',
            'label' => t('Flag'),
            'flag_type' => $type,
            'description' => t('The flag to check for.'),
          ),
          $type => array(
            'type' => $type,
            'label' => $label,
          ),
          'flagging_user' => array(
            'type' => 'user',
            'label' => t('User on whose behalf to check'),
            'description' => t('For non-global flags, this is the user on whose behalf the flag is checked.'),
          ),
        ),
        'group' => t('Flag'),
        'access callback' => 'flag_rules_integration_access',
      ),
    );
  }
  return $items;
}