|
|
|
@ -17,64 +17,53 @@ function change_info(){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$webUser = new WebUsers();
|
|
|
|
|
//use current info to check for changes
|
|
|
|
|
$current_info = $webUser->getInfo($_POST['target_id']);
|
|
|
|
|
//TODO: XSS filtering
|
|
|
|
|
|
|
|
|
|
//make the query that will update the data.
|
|
|
|
|
$updated = false;
|
|
|
|
|
$values = Array();
|
|
|
|
|
$values['user'] = $target_username;
|
|
|
|
|
$query = "UPDATE ams_user SET ";
|
|
|
|
|
if(($_POST['FirstName'] != "") && ($_POST['FirstName'] != $current_info['FirstName'])){
|
|
|
|
|
$query = $query . "FirstName = :fName ";
|
|
|
|
|
$updated = true;
|
|
|
|
|
$values['fName'] = $_POST['FirstName'];
|
|
|
|
|
}
|
|
|
|
|
if(($_POST['LastName'] != "") && ($_POST['LastName'] != $current_info['LastName'])){
|
|
|
|
|
$query = $query . "LastName = :lName ";
|
|
|
|
|
$updated = true;
|
|
|
|
|
$values['lName'] = $_POST['LastName'];
|
|
|
|
|
}
|
|
|
|
|
//TODO: add the other fields too
|
|
|
|
|
$query = $query . "WHERE Login = :user";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print($query);
|
|
|
|
|
exit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$reply = $webUser->checkEmail($_POST['NewEmail']);
|
|
|
|
|
if ( $reply != "success" ){
|
|
|
|
|
$result['EMAIL_ERROR'] = 'TRUE';
|
|
|
|
|
}else{
|
|
|
|
|
$result['EMAIL_ERROR'] = 'FALSE';
|
|
|
|
|
}
|
|
|
|
|
$result['prevNewEmail'] = $_POST["NewEmail"];
|
|
|
|
|
|
|
|
|
|
if ($reply== "success"){
|
|
|
|
|
$status = WebUsers::setEmail($target_username, $_POST["NewEmail"] );
|
|
|
|
|
if($status == 'ok'){
|
|
|
|
|
$result['SUCCESS_MAIL'] = "OK";
|
|
|
|
|
}else if($status == 'shardoffline'){
|
|
|
|
|
$result['SUCCESS_MAIL'] = "SHARDOFF";
|
|
|
|
|
}
|
|
|
|
|
$result['permission'] = $_SESSION['permission'];
|
|
|
|
|
$result['no_visible_elements'] = 'FALSE';
|
|
|
|
|
$result['target_id'] = $_POST['target_id'];
|
|
|
|
|
if(isset($_GET['id'])){
|
|
|
|
|
if(WebUsers::isAdmin() && ($_POST['target_id'] != $_SESSION['id'])){
|
|
|
|
|
$result['isAdmin'] = "TRUE";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
helpers :: loadtemplate( 'settings', $result);
|
|
|
|
|
exit;
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
$result['EMAIL'] = $reply;
|
|
|
|
|
$result['permission'] = $_SESSION['permission'];
|
|
|
|
|
$result['no_visible_elements'] = 'FALSE';
|
|
|
|
|
$return['username'] = $_SESSION['user'];
|
|
|
|
|
$result['target_id'] = $_POST['target_id'];
|
|
|
|
|
if(isset($_GET['id'])){
|
|
|
|
|
if(WebUsers::isAdmin() && ($_POST['target_id'] != $_SESSION['id'])){
|
|
|
|
|
$result['isAdmin'] = "TRUE";
|
|
|
|
|
}
|
|
|
|
|
//if some field is update then:
|
|
|
|
|
if($updated){
|
|
|
|
|
global $cfg;
|
|
|
|
|
//execute the query in the web DB.
|
|
|
|
|
$dbw = new DBLayer($cfg['db']['web']);
|
|
|
|
|
$dbw->execute($query,$values);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
global $SITEBASE;
|
|
|
|
|
require_once($SITEBASE . 'inc/settings.php');
|
|
|
|
|
$result = settings();
|
|
|
|
|
if($updated){
|
|
|
|
|
$result['info_updated'] = "OK";
|
|
|
|
|
}
|
|
|
|
|
$result['permission'] = $_SESSION['permission'];
|
|
|
|
|
$result['username'] = $_SESSION['user'];
|
|
|
|
|
$result['no_visible_elements'] = 'FALSE';
|
|
|
|
|
$result['target_id'] = $_POST['target_id'];
|
|
|
|
|
if(isset($_GET['id'])){
|
|
|
|
|
if(WebUsers::isAdmin() && ($_POST['target_id'] != $_SESSION['id'])){
|
|
|
|
|
$result['isAdmin'] = "TRUE";
|
|
|
|
|
}
|
|
|
|
|
helpers :: loadtemplate( 'settings', $result);
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
helpers :: loadtemplate( 'settings', $result);
|
|
|
|
|
exit;
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
//ERROR: permission denied!
|
|
|
|
|