function drd_server_load_user in Drupal Remote Dashboard Server 6
Same name and namespace in other branches
- 7 drd_server.module \drd_server_load_user()
Get the user from the given session and check permission
11 calls to drd_server_load_user()
File
- ./
drd_server.module, line 75
Code
function drd_server_load_user($sid) {
$account = drd_server_get_account_by_session($sid);
if (isset($account) && $account && $account->uid > 0) {
$account = drupal_unpack($account);
$account->roles = array();
$account->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user';
$result = db_query("SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d", $account->uid);
while ($role = db_fetch_object($result)) {
$account->roles[$role->rid] = $role->name;
}
}
else {
return t('You are not logged in.');
}
if (user_access('administer site configuration', $account)) {
global $user;
$user = $account;
return $user;
}
return t('You do not have permission to access system data.');
}