You are here

function webform_validation_get_rule_components in Webform Validation 6

Same name and namespace in other branches
  1. 7 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_get_rule in ./webform_validation.rules.inc
Get a rule entry

File

./webform_validation.rules.inc, line 35
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 v.cid, c.name FROM {webform_validation_rule_components} v INNER JOIN {webform_component} c ON v.cid = c.cid AND c.nid = %d WHERE v.ruleid = %d", $ruleid);
  $result = db_query("SELECT cid FROM {webform_validation_rule_components} WHERE ruleid = %d", $ruleid);
  while ($row = db_fetch_array($result)) {
    $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;
}