You are here

function webform_validation_get_rule_components in Webform Validation 7

Same name and namespace in other branches
  1. 6 webform_validation.rules.inc \webform_validation_get_rule_components()

Get an array of components linked to a rule.

2 calls to webform_validation_get_rule_components()
webform_validation_get_node_rules in ./webform_validation.rules.inc
Get an array of rules assigned to a webform node.
webform_validation_rule_load in ./webform_validation.module
Load a validation rule.

File

./webform_validation.rules.inc, line 71
Provides API and management functions for the webform validation rules.

Code

function webform_validation_get_rule_components($ruleid, $nid) {
  $cids = array();
  $components = array();
  $result = db_query("SELECT cid FROM {webform_validation_rule_components} WHERE ruleid = :ruleid", array(
    ':ruleid' => $ruleid,
  ));
  foreach ($result as $row) {
    $cids[] = $row->cid;
  }
  if ($cids) {
    $all_components = webform_validation_get_all_components($nid);
    $all_component_keys = array_keys($all_components);
    foreach ($cids as $cid) {
      if (in_array($cid, $all_component_keys)) {
        $components[$cid] = $all_components[$cid];
      }
    }
  }
  return $components;
}