function system_update_7011

Split the 'bypass node access' permission from 'administer nodes'.

Related topics

File

modules/system/system.install, line 2079

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();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.