4 * \defgroup User User module
11 * Main user module file.
12 * Core Module. Deals with user integration.
19 * Verifies user access to certain utilities
22 * The access permition to be looked for
24 * The data casting (array)$access is not working, no idea why
26 * The query to select perms will return a count($p) of one when there are no perms set for the group. Could be a bug in the db_query function actually
28 * Working with regular accounts, not only the root admin and an entirely new system
31 function user_access($access, $owner){
35 //TRUE or FALSE access with an array
36 if(is_array($access)){
38 //$access = array($access);
40 for($i = 0; $i < count($access); $i++){
41 //If we find any permission from the array, then it is a valid permission
42 if(core_variable_get($access, FALSE, $owner, 'perms')){
49 //Give main account an all access pass and Dungeon Master group if settings apply
50 if($user['uid'] == 1 || (core_variable_get('dungeon_full_access', FALSE, 'user') && $user['uid'] == 2)){
54 return core_variable_get($access, FALSE, $owner, 'perms');
59 * Loads a users details
64 * No idea, I guess it won't be used
66 * Remove the $logged param use in calling functions
68 function user_load($uid){
72 //Security for main admin and anonymous
77 $user = db_query("SELECT * FROM {PRE_}users WHERE uid = ".$uid." AND uid > 0", TRUE, TRUE);
83 $roles = db_query("SELECT ur. * , r. * FROM {PRE_}users_roles ur INNER JOIN role r WHERE ur.rid = r.rid AND ur.uid = ".$uid."", TRUE);
86 foreach($roles as $r){
87 $user['roles'][$r['rid']] = $r['name'];
90 //Add the role registered because anyone with an account is a registred user
92 $user['roles'][3] = user_roles(3);
96 $user['data'] = unserialize($user['data']);
103 * Manage user sessions
109 function user_sessions($key){
113 $u = db_query("SELECT uid FROM {PRE_}sessions WHERE sid = '".$key."'", TRUE, TRUE);
118 $user['session'] = '';
121 $user = user_load($u['uid'], TRUE);
122 $user['session'] = $u;
132 * Sets details for anonymous users browsing the website
135 * Session information
138 function user_anonymous($session = ''){
143 $user['hostname'] = core_ip_address();
144 $user['roles'] = array(2 => user_roles(2));
145 $user['session'] = $session;
150 * Retrieves a list of users roles and their public names
153 * Specific role id if you just want one
156 function user_roles($rid = NULL){
161 $role = db_query("SELECT * FROM {PRE_}role", TRUE);
163 foreach($role as $r){
164 $roles[$r['rid']] = $r['name'];
177 * Add tabs to the user pages pages
182 function user_tabs($uid){
184 $skin_tabs = array('user/'.$uid => 'View',
185 'user/edit/'.$uid => 'Edit'
188 skin_tabs($skin_tabs);
193 * Displays a user profile
199 function user_display($uid = NULL){
201 global $user, $user_profile;
203 $uid = (!$uid ? $user['uid'] : $uid);
205 $user_profile = user_load($uid);
209 //Roles to which s/he belongs to
210 $user_profile['roles'] = 'roles-' . implode(' roles-', $user_profile['roles']);
212 hooks_invoke('user_display');
214 return skin_dressme_tpl('user', 'user_VAR_', $user_profile, 'tmp');