I am working on a module to add multiple superusers (as if multiple users had uid 1) to a Drupal site. But before I can start overriding functions, I need to know which ones to override and how to change them. For experimentation purposes, I am modifying core code to see if I can achieve what I'm trying to do.
This is a slightly modified version of user_access() from modules/user/user.module. In theory, it should allow uid 2 to have all the same permissions that uid 1 has, but it does not work.
Is this even the right function to be changing? Are there more than this that I need to change?
function user_access($string, $account = NULL) {
global $user;
static $perm = array();
if (is_null($account)) {
$account = $user;
}
// User #1 has all privileges:
if ($account->uid == 1) {
return TRUE;
}
// User #2 has all privileges: <<<< HERE IS MY CODE
if ($account->uid == 2) {
return TRUE;
}
// To reduce the number of SQL queries, we cache the user's permissions
// in a static variable.
if (!isset($perm[$account->uid])) {
$result = db_query("SELECT DISTINCT(p.perm) FROM {role} r INNER JOIN {permission} p ON p.rid = r.rid WHERE r.rid IN (%s)", implode(',', array_keys($account->roles)));
$perm[$account->uid] = '';
while ($row = db_fetch_object($result)) {