You are here

function webform_update_5202 in Webform 5.2

Per-webform submission access control based on roles.

File

./webform.install, line 712

Code

function webform_update_5202() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
      $ret[] = update_sql("CREATE TABLE {webform_roles} (\n        nid int(10) unsigned NOT NULL default '0',\n        rid int(10) unsigned NOT NULL default '0',\n        PRIMARY KEY (nid, rid)\n        ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */");
      break;
    case 'pgsql':
      $ret[] = update_sql("CREATE TABLE {webform_roles} (\n        nid integer NOT NULL default '0',\n        rid integer NOT NULL default '0',\n        PRIMARY KEY (nid, rid)\n        )");
      break;
  }
  $result = db_query("SELECT nid FROM {node} WHERE type = 'webform'");
  while ($node = db_fetch_object($result)) {
    db_query("INSERT INTO {webform_roles} (nid, rid) VALUES (%d, 1)", $node->nid);
    db_query("INSERT INTO {webform_roles} (nid, rid) VALUES (%d, 2)", $node->nid);
  }
  return $ret;
}