function system_update_7011 in Drupal 7
Split the 'bypass node access' permission from 'administer nodes'.
Related topics
File
- modules/
system/ system.install, line 2060 - Install, update and uninstall functions for the system module.
Code
function system_update_7011() {
// Get existing roles that can 'administer nodes'.
$rids = array();
$rids = db_query("SELECT rid FROM {role_permission} WHERE permission = :perm", array(
':perm' => 'administer nodes',
))
->fetchCol();
// None found.
if (empty($rids)) {
return;
}
$insert = db_insert('role_permission')
->fields(array(
'rid',
'permission',
));
foreach ($rids as $rid) {
$insert
->values(array(
'rid' => $rid,
'permission' => 'bypass node access',
));
}
$insert
->execute();
}