1.20.x user.install user_update_1001()

Grant "administer account settings" to roles with "administer users."

Related topics

File

modules/user/user.install, line 224
Install, update and uninstall functions for the user module.

Code

function user_update_1001() {
  $rids = db_query("SELECT rid FROM {role_permission} WHERE permission = :perm", array(':perm' => 'administer users'))->fetchCol();
  // None found.
  if (empty($rids)) {
    return;
  }
  $insert = db_insert('role_permission')->fields(array('rid', 'permission', 'module'));
  foreach ($rids as $rid) {
    $insert->values(array(
      'rid' => $rid,
      'permission' => 'administer account settings',
      'module' => 'user'
    ));
  }
  $insert->execute();
}