function webform_update_6202 in Webform 6.2
Same name and namespace in other branches
- 6.3 webform.install \webform_update_6202()
Per-webform submission access control based on roles.
File
- ./
webform.install, line 852 - Webform module install/schema hooks.
Code
function webform_update_6202() {
$ret = array();
// This update will already be run as webform_update_5202 on Drupal 5.
if (db_table_exists('webform_roles')) {
return $ret;
}
db_create_table($ret, 'webform_roles', array(
'description' => 'Holds access information regarding which roles are allowed to submit which webform nodes. Does not prevent access to the webform node entirely, use the {node_access} table for that purpose.',
'fields' => array(
'nid' => array(
'description' => 'The node identifier of a webform.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'rid' => array(
'description' => 'The role identifier.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'nid',
'rid',
),
));
$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;
}