You are here

function flag_rules_condition_info in Flag 6

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

Implementation of hook_rules_condition_info().

File

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

Code

function flag_rules_condition_info() {
  $items = array();
  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_condition_threshold_' . $type => array(
          'label' => drupal_ucfirst(t('@type has flagging count', array(
            '@type' => $type,
          ))),
          'base' => 'flag_rules_condition_threshold',
          'label callback' => 'flag_rules_condition_threshold_label',
          'arguments' => $args + array(
            'number' => array(
              'type' => 'number',
              '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.'),
            ),
          ),
          'module' => 'Flag',
        ),
        'flag_rules_condition_flagged_' . $type => array(
          'label' => drupal_ucfirst(t('@type is flagged', array(
            '@type' => $type,
          ))),
          'base' => 'flag_rules_condition_flagged',
          'label callback' => 'flag_rules_condition_flagged_label',
          'arguments' => $args + array(
            '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.'),
            ),
          ),
          'module' => 'Flag',
        ),
      );
    }
  }
  return $items;
}