You are here

function webform_update_4 in Webform 5.2

Same name and namespace in other branches
  1. 5 webform.install \webform_update_4()
  2. 6.2 webform.install \webform_update_4()

Schema change 4: Remove the webform_role_node table, node access can be handled by other modules made for this purpose. Add additional columns to webform_submissions for recording of repeated submissions (IP Address, Browser, etc). Add additional columns to webform for setting submission limitations Change 'maintain webforms' permission into two seperate perms: 'edit webforms', 'access webform results'

File

./webform.install, line 266

Code

function webform_update_4() {
  $ret[] = update_sql('DROP TABLE if exists {webform_role_node}');
  $ret[] = update_sql('ALTER TABLE {webform_submissions} ADD user varchar(128) AFTER submitted');
  $ret[] = update_sql('ALTER TABLE {webform_submissions} ADD remote_addr varchar(128) AFTER user');
  $ret[] = update_sql("ALTER TABLE {webform} ADD submit_limit int(2) NOT NULL DEFAULT '-1' AFTER redirect_post");
  $ret[] = update_sql("ALTER TABLE {webform} ADD submit_interval int(10) NOT NULL DEFAULT '157784630' AFTER submit_limit");

  // 5 years in seconds.
  // Split 'maintain webforms' permissions into both 'edit webforms' and 'access webform results'.
  $result = db_query('SELECT rid, perm FROM {permission}');
  while ($row = db_fetch_object($result)) {
    if (strpos($row->perm, 'maintain webforms') !== FALSE) {
      $updated_perm = str_replace('maintain webforms', 'edit webforms, access webform results', $row->perm);
      db_query("UPDATE {permission} SET perm = '%s' WHERE rid = %d", $updated_perm, $row->rid);
    }
  }
  return $ret;
}