forked from science-ation/science-ation
Fix user loading
This commit is contained in:
parent
7b454e322a
commit
9f3dc6c9dc
50
user.inc.php
50
user.inc.php
@ -57,24 +57,24 @@ function user_load($users_id, $accounts_id = false)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Load the user */
|
/* Load the user */
|
||||||
$ret = mysql_fetch_assoc($q);
|
$u = mysql_fetch_assoc($q);
|
||||||
|
|
||||||
/* Sanitize before using these in mysql queries */
|
/* Sanitize before using these in mysql queries */
|
||||||
$ret['id'] = intval($ret['id']);
|
$u['id'] = intval($u['id']);
|
||||||
$ret['accounts_id'] = intval($ret['accounts_id']);
|
$u['accounts_id'] = intval($u['accounts_id']);
|
||||||
$ret['year'] = intval($ret['year']);
|
$u['year'] = intval($u['year']);
|
||||||
|
|
||||||
|
|
||||||
/* Get roles, and active/complete status for each role */
|
/* Get roles, and active/complete status for each role */
|
||||||
$query = "SELECT user_roles.*,roles.type,roles.name FROM user_roles LEFT JOIN roles ON roles.id=user_roles.roles_id WHERE user_roles.users_id={$ret['id']}";
|
$query = "SELECT user_roles.*,roles.type,roles.name FROM user_roles LEFT JOIN roles ON roles.id=user_roles.roles_id WHERE user_roles.users_id={$u['id']}";
|
||||||
$q = mysql_query($query);
|
$q = mysql_query($query);
|
||||||
|
|
||||||
$ret['roles'] = array();
|
$u['roles'] = array();
|
||||||
while(($roledata = mysql_fetch_assoc($q))) {
|
while(($roledata = mysql_fetch_assoc($q))) {
|
||||||
$ret['roles'][$roledata['type']] = $roledata;
|
$u['roles'][$roledata['type']] = $roledata;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($ret['roles']) == 0) {
|
if(count($u['roles']) == 0) {
|
||||||
/* No roles, that's ok actually, the previous logic here was that
|
/* No roles, that's ok actually, the previous logic here was that
|
||||||
* a user without roles is deleted.. but.. this could happen for
|
* a user without roles is deleted.. but.. this could happen for
|
||||||
* new users, or if someone deletes all their roles before adding
|
* new users, or if someone deletes all their roles before adding
|
||||||
@ -82,26 +82,26 @@ function user_load($users_id, $accounts_id = false)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Convenience */
|
/* Convenience */
|
||||||
$ret['name'] = ($ret['firstname'] ? "{$ret['firstname']} " : '').$ret['lastname'];
|
$u['name'] = ($u['firstname'] ? "{$u['firstname']} " : '').$u['lastname'];
|
||||||
|
|
||||||
/* Email recipient for "to" field on emails */
|
/* Email recipient for "to" field on emails */
|
||||||
if( ($ret['firstname'] || $ret['lastname']) && $ret['email']) {
|
if( ($u['firstname'] || $u['lastname']) && $u['email']) {
|
||||||
//use their full name if we have it
|
//use their full name if we have it
|
||||||
//if the name contains anything non-standard, we need to quote it.
|
//if the name contains anything non-standard, we need to quote it.
|
||||||
if(eregi("[^a-z0-9 ]",$ret['name']))
|
if(eregi("[^a-z0-9 ]",$u['name']))
|
||||||
$ret['emailrecipient']="\"{$ret['name']}\" <{$ret['email']}>";
|
$u['emailrecipient']="\"{$u['name']}\" <{$u['email']}>";
|
||||||
else
|
else
|
||||||
$ret['emailrecipient']="{$ret['name']} <{$ret['email']}>";
|
$u['emailrecipient']="{$u['name']} <{$u['email']}>";
|
||||||
}
|
}
|
||||||
else if($ret['email']) {
|
else if($u['email']) {
|
||||||
//otherwise, just their email address
|
//otherwise, just their email address
|
||||||
$ret['emailrecipient']=$ret['email'];
|
$u['emailrecipient']=$u['email'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$ret['emailrecipient']="";
|
$u['emailrecipient']="";
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(array_keys($ret['roles']) as $r) {
|
foreach(array_keys($u['roles']) as $r) {
|
||||||
/* Do the load routines inline, the explosion of user roles
|
/* Do the load routines inline, the explosion of user roles
|
||||||
* means it's just silly to have a different function for each
|
* means it's just silly to have a different function for each
|
||||||
* one. If we get one that has a crazy amount of stuff to do,
|
* one. If we get one that has a crazy amount of stuff to do,
|
||||||
@ -119,11 +119,11 @@ function user_load($users_id, $accounts_id = false)
|
|||||||
$u['years_national'] = intval($u['years_national']);
|
$u['years_national'] = intval($u['years_national']);
|
||||||
$u['willing_chair'] = ($u['willing_chair'] == 'yes') ? 'yes' : 'no';
|
$u['willing_chair'] = ($u['willing_chair'] == 'yes') ? 'yes' : 'no';
|
||||||
$u['special_award_only'] = ($u['special_award_only'] == 'yes') ? 'yes' : 'no';
|
$u['special_award_only'] = ($u['special_award_only'] == 'yes') ? 'yes' : 'no';
|
||||||
$u['cat_prefs'] = strlen($u['cat_prefs'] > 0) ? unserialize($u['cat_prefs']) : array();
|
$u['cat_prefs'] = (strlen($u['cat_prefs']) > 0) ? unserialize($u['cat_prefs']) : array();
|
||||||
$u['div_prefs'] = strlen($u['div_prefs'] > 0) ? unserialize($u['div_prefs']) : array();
|
$u['div_prefs'] = (strlen($u['div_prefs']) > 0) ? unserialize($u['div_prefs']) : array();
|
||||||
$u['divsub_prefs'] = strlen($u['divsub_prefs'] > 0) ? unserialize($u['divsub_prefs']) : array();
|
$u['divsub_prefs'] = (strlen($u['divsub_prefs']) > 0) ? unserialize($u['divsub_prefs']) : array();
|
||||||
// $u['expertise_other'] = $u['expertise_other'];
|
// $u['expertise_other'] = $u['expertise_other'];
|
||||||
$u['languages'] = strlen($u['languages'] > 0) ? unserialize($u['languages']) : array();
|
$u['languages'] = (strlen($u['languages']) > 0) ? unserialize($u['languages']) : array();
|
||||||
// $u['highest_psd'] = $u['highest_psd'];
|
// $u['highest_psd'] = $u['highest_psd'];
|
||||||
|
|
||||||
/* Sanity check the arrays, make sure they are arrays */
|
/* Sanity check the arrays, make sure they are arrays */
|
||||||
@ -149,11 +149,11 @@ function user_load($users_id, $accounts_id = false)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Do this assignment without recursion :) */
|
/* Do this assignment without recursion :) */
|
||||||
unset($ret['orig']);
|
unset($u['orig']);
|
||||||
$orig = $ret;
|
$orig = $u;
|
||||||
$ret['orig'] = $orig;
|
$u['orig'] = $orig;
|
||||||
|
|
||||||
return $ret;
|
return $u;
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_load_by_accounts_id($accounts_id)
|
function user_load_by_accounts_id($accounts_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user