function system_update_7007
Convert to new method of storing permissions.
Related topics
File
-
modules/
system/ system.install, line 2045
Code
function system_update_7007() {
// Copy the permissions from the old {permission} table to the new {role_permission} table.
$messages = array();
$result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid ASC");
$query = db_insert('role_permission')->fields(array(
'rid',
'permission',
));
foreach ($result as $role) {
foreach (array_unique(explode(', ', $role->perm)) as $perm) {
$query->values(array(
'rid' => $role->rid,
'permission' => $perm,
));
}
$messages[] = t('Inserted into {role_permission} the permissions for role ID !id', array(
'!id' => $role->rid,
));
}
$query->execute();
db_drop_table('permission');
return implode(', ', $messages);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.