You are here

function rules_admin_filter_info in Rules 6

Filters the info about elements (actions, conditions), so that only elements compatible with the given variables are kept, which means suiting variables for all arguments are available, so that the action/condition can be configured. Additionally, arguments having no suiting variables are recorded in the 'unsatisfied arguments' slot of the element in $infos.

2 calls to rules_admin_filter_info()
rules_admin_form_add_action in rules_admin/rules_admin.rule_forms.inc
Returns the form for the first action add page
rules_admin_form_add_condition in rules_admin/rules_admin.rule_forms.inc
Returns the form for the first condition add page

File

rules_admin/rules_admin.inc, line 143

Code

function rules_admin_filter_info($variables, &$infos) {
  $filtered = array();
  foreach ($infos as $key => $info) {
    if (isset($info['arguments']) && is_array($info['arguments'])) {
      foreach ($info['arguments'] as $name => $argument_info) {
        if (!rules_admin_argument_satisifable($argument_info, $variables)) {

          // Get the unsatisfied arguments.
          $infos[$key] += array(
            'unsatisfied arguments' => array(),
          );
          $infos[$key]['unsatisfied arguments'][$name] = $argument_info['label'];
        }
      }
      if (empty($infos[$key]['unsatisfied arguments'])) {
        $filtered[$key] = $info;
      }
    }
    else {
      $filtered[$key] = $info;
    }
  }
  return $filtered;
}