You are here

function webform_conditional_update_6001 in Webform Conditional (Same Page Conditionals) 6

Same name and namespace in other branches
  1. 7.2 webform_conditional.install \webform_conditional_update_6001()
  2. 7 webform_conditional.install \webform_conditional_update_6001()

File

./webform_conditional.install, line 68
Used for module updates

Code

function webform_conditional_update_6001() {
  $ret = array();
  $sql = "SELECT nid, cid,extra FROM {webform_component}";
  $result = db_query($sql);
  if ($result) {
    while ($row = db_fetch_array($result)) {
      $extra = unserialize($row['extra']);
      if (!empty($extra['webform_conditional_mandatory'])) {
        $update_components[$row['nid']][] = $row['cid'];
      }
    }
    if ($update_components) {
      foreach ($update_components as $nid => $cids) {
        $ret[] = update_sql("UPDATE {webform_component} SET mandatory = 1 where nid = {$nid} and cid in (" . implode(",", $cids) . ")");
      }
    }
  }
  return $ret;
}