You are here

function rb_misc_rules_condition_info in Rules Bonus Pack 7

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

Implements hook_rules_condition_info().

File

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

Code

function rb_misc_rules_condition_info() {

  // Add conditions that depend on required modules only.
  $conditions = array(
    'rb_misc_condition_is_numeric' => array(
      'label' => t('String contains number'),
      'group' => t('Rules Bonus: Miscellaneous'),
      'parameter' => array(
        'string' => array(
          'type' => 'text',
          'label' => t('String to check'),
        ),
      ),
    ),
    'rb_misc_condition_user_has_permission' => array(
      'label' => t('User has permission(s)'),
      'parameter' => array(
        'account' => array(
          'type' => 'user',
          'label' => t('User'),
        ),
        'permissions' => array(
          'type' => 'list<text>',
          'label' => t('Permissions'),
          'multiple' => TRUE,
          'options list' => 'rb_misc_user_permissions_options_list',
        ),
        'operation' => array(
          'type' => 'text',
          'label' => t('Match permissions'),
          'options list' => 'rules_user_condition_operations',
          'restriction' => 'input',
          'optional' => TRUE,
          'default value' => 'AND',
          'description' => t('If matching against all selected permissions, the user must have <em>all</em> the permissions selected.'),
        ),
      ),
      'group' => t('Rules Bonus: Miscellaneous'),
      'access callback' => 'rules_user_integration_access',
    ),
  );

  // Add conditions that depend on non-required modules.
  if (module_exists('views')) {
    $conditions['rb_misc_action_views_result_count'] = array(
      'label' => t('Check number of results from a view'),
      'parameter' => array(
        'view' => array(
          'type' => 'text',
          'label' => t('View and display'),
          'options list' => 'rb_misc_views_list',
          'description' => t('Select the view and display you want to check'),
          '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,
        ),
        'minimum' => array(
          'type' => 'integer',
          'label' => t('Minimum number of results'),
          'description' => t('This condition returns TRUE if the view has at
            least the given number of results.'),
        ),
      ),
      'group' => t('Rules Bonus: Miscellaneous'),
    );
  }

  // Automatic nodetitles.
  if (module_exists('auto_nodetitle')) {
    $conditions['rb_misc_condition_auto_nodetitle_is_needed'] = array(
      'label' => t('Automatic Nodetitle is needed'),
      'group' => t('Rules Bonus: Miscellaneous'),
      'parameter' => array(
        'node' => array(
          'type' => 'node',
          'label' => t('Node'),
        ),
      ),
    );
  }
  return $conditions;
}