You are here

function webform_update_15 in Webform 6.2

Same name and namespace in other branches
  1. 5.2 webform.install \webform_update_15()

Convert 'CC' option in extra column to simply 'email'. Set email value to '%useremail' instead of 'user email'. Change the 'disabled' option from an attributes option to an individual option.

File

./webform.install, line 646
Webform module install/schema hooks.

Code

function webform_update_15() {
  $ret = array();
  $result = db_query("SELECT nid, cid, extra, value FROM {webform_component} WHERE type = 'email'");
  while ($row = db_fetch_array($result)) {
    $extra = unserialize($row['extra']);
    if ($extra['carboncopy']) {
      $extra['email'] = 1;
      unset($extra['carboncopy']);
    }
    $value = $row['value'] == 'user email' ? '%useremail' : '';
    db_query("UPDATE {webform_component} SET extra = '%s', value = '%s' WHERE nid = %d and cid = %d", serialize($extra), $value, $row['nid'], $row['cid']);
  }
  $result = db_query("SELECT nid, cid, extra FROM {webform_component} WHERE type IN ('email', 'textfield', 'textarea')");
  while ($row = db_fetch_array($result)) {
    $extra = unserialize($row['extra']);
    if ($extra['attributes']['disabled']) {
      $extra['disabled'] = 1;
      unset($extra['attributes']['disabled']);
      db_query("UPDATE {webform_component} SET extra = '%s' WHERE nid = %d and cid = %d", serialize($extra), $row['nid'], $row['cid']);
    }
  }
  return $ret;
}