forked from science-ation/science-ation
Implement user/edit
Remove saving some stuff from user_save
This commit is contained in:
parent
895bcc36e2
commit
a92544bbea
41
api.php
41
api.php
@ -437,14 +437,8 @@ switch($request[0]) {
|
||||
*/
|
||||
case "view":
|
||||
if($u=user_load($_SESSION['users_id'])) {
|
||||
//we dont need to send the 'orig' part of it
|
||||
unset($u['orig']);
|
||||
unset($u['types']);
|
||||
unset($u['username']);
|
||||
unset($u['password']);
|
||||
unset($u['year']);
|
||||
unset($u['access_admin']);
|
||||
unset($u['access_config']);
|
||||
unset($u['access_super']);
|
||||
$ret['status']="ok";
|
||||
$ret['user']=$u;
|
||||
}
|
||||
@ -453,14 +447,43 @@ switch($request[0]) {
|
||||
$ret['error']="Error loading user";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* APIDOC: user/edit
|
||||
notimplemented
|
||||
description(edit user information for current conference)
|
||||
post(user array)
|
||||
return(user array)
|
||||
*/
|
||||
case "edit":
|
||||
if($origu=user_load($_SESSION['users_id'])) {
|
||||
$u=json_decode($_POST['user']);
|
||||
if(!is_array($u)) {
|
||||
$ret['status']="error";
|
||||
$ret['error']="user (array) is required";
|
||||
break;
|
||||
}
|
||||
|
||||
if($origu['id']!=$u['id']) {
|
||||
$ret['status']="error";
|
||||
$ret['error']="User ID mismatch";
|
||||
break;
|
||||
}
|
||||
|
||||
$u['orig']=$origu['orig'];
|
||||
|
||||
if(user_save($u)) {
|
||||
$ret['status']="ok";
|
||||
$ret['user']=$u;
|
||||
} else {
|
||||
$ret['status']="error";
|
||||
$ret['error']="Error saving user";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$ret['status']="error";
|
||||
$ret['error']="Error loading user in order to edit";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
|
@ -241,8 +241,8 @@ function user_save(&$u)
|
||||
|
||||
/* Sanity check */
|
||||
if($u['conferences_id'] != $u['orig']['conferences_id']) {
|
||||
echo "The user's conference changed. Can't save a user to a difference conference, use user_dupe to copy the user to a new conference.\n";
|
||||
exit;
|
||||
//echo "The user's conference changed. Can't save a user to a difference conference, use user_dupe to copy the user to a new conference.\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Add any new roles */
|
||||
@ -277,13 +277,12 @@ function user_save(&$u)
|
||||
}
|
||||
|
||||
|
||||
$fields = array('salutation','firstname','lastname','username',
|
||||
$fields = array('salutation','firstname','lastname',
|
||||
'phonehome','phonework','phonecell','fax','organization',
|
||||
'address','address2','city','province','postalcode','sex',
|
||||
'firstaid', 'cpr', 'lang', 'notes');
|
||||
|
||||
$fields_for_role['committee'] = array('emailprivate','ord','displayemail',
|
||||
'access_admin','access_config','access_super');
|
||||
$fields_for_role['committee'] = array('emailprivate','ord','displayemail');
|
||||
$fields_for_role['judge'] = array('years_school','years_regional','years_national',
|
||||
'willing_chair','special_award_only',
|
||||
'cat_prefs','div_prefs','divsub_prefs',
|
||||
|
Loading…
Reference in New Issue
Block a user