You are here

function adminrole_update_permissions in Admin role 5

Same name and namespace in other branches
  1. 6 adminrole.module \adminrole_update_permissions()
  2. 7 adminrole.module \adminrole_update_permissions()

Update the admin role with all current available permissions.

3 calls to adminrole_update_permissions()
adminrole_enable in ./adminrole.install
Implements hook_enable().
adminrole_node_type in ./adminrole.module
Implements hook_node_type().
drush_adminrole_update in ./adminrole.drush.inc
Drush callback; update the admin role with all current available permissions.

File

./adminrole.module, line 53
This module simply gives a designated role all permissions every time the modules page is submitted.

Code

function adminrole_update_permissions() {
  if ($rid = variable_get('user_admin_role', 0)) {
    $permissions = module_invoke_all('perm');
    if ($excluded = variable_get('adminrole_exclude_permissions', array())) {
      $permissions = array_diff($permissions, $excluded);
    }
    db_query('DELETE FROM {permission} WHERE rid = %d', $rid);
    if ($permissions) {
      db_query("INSERT INTO {permission} (rid, perm) VALUES (%d, '%s')", $rid, implode(', ', $permissions));
    }
  }
}