From a1c2de3bd800b4afc0006f104bbf85bc3d8a7413 Mon Sep 17 00:00:00 2001 From: Quitta Date: Tue, 2 Jul 2013 16:07:55 +0200 Subject: [PATCH] change info page basics --- .../ryzom_ams/www/html/autoload/webusers.php | 9 +++ .../ryzom_ams/www/html/func/change_info.php | 78 +++++++++++++++++++ .../ryzom_ams/www/html/inc/settings.php | 2 + .../server/ryzom_ams/www/html/sql/install.php | 4 + .../ryzom_ams/www/html/templates/settings.tpl | 7 +- 5 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 code/ryzom/tools/server/ryzom_ams/www/html/func/change_info.php diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php b/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php index af851e273..4e0e25df8 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php @@ -69,6 +69,15 @@ class WebUsers extends Users{ return $row['Email']; } + public function getInfo($id){ + global $cfg; + + $dbw = new DBLayer($cfg['db']['web']); + $statement = $dbw->execute("SELECT * FROM ams_user WHERE UId=:id", array('id' => $id)); + $row = $statement->fetch(); + $result = Array('FirstName' => $row['FirstName'], 'LastName' => $row['LastName'], 'Gender' => $row['Gender'], 'Country' => $row['Country']); + return $result; + } public function isLoggedIn(){ if(isset($_SESSION['user'])){ diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/change_info.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/change_info.php new file mode 100644 index 000000000..f0b49fff0 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/change_info.php @@ -0,0 +1,78 @@ +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"; + } + } + helpers :: loadtemplate( 'settings', $result); + exit; + } + + }else{ + //ERROR: permission denied! + } + + }else{ + //ERROR: The form was not filled in correclty + } + }else{ + //ERROR: user is not logged in + exit; + } + + }catch (PDOException $e) { + //go to error page or something, because can't access website db + print_r($e); + exit; + } +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/settings.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/settings.php index a85877cda..7fd264aa2 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/settings.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/settings.php @@ -4,12 +4,14 @@ function settings(){ if(WebUsers::isLoggedIn()){ //in case id-GET param set it's value as target_id, if no id-param is given, ue the session id. if(isset($_GET['id'])){ + $result = WebUsers::getInfo($_GET['id']); if(WebUsers::isAdmin() && ($_GET['id']!= $_SESSION['id'])){ $result['isAdmin'] = "TRUE"; } $result['target_id'] = $_GET['id']; $result['current_mail'] = WebUsers::getEmail($_GET['id']); }else{ + $result = WebUsers::getInfo($_SESSION['id']); $result['target_id'] = $_SESSION['id']; $result['current_mail'] = WebUsers::getEmail($_SESSION['id']); } diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php b/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php index e9e3ecac1..e2cf4190f 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php @@ -21,6 +21,10 @@ `Password` varchar(13) DEFAULT NULL, `Email` varchar(255) NOT NULL DEFAULT '', `Permission` int(3) NOT NULL DEFAULT 1, + `FirstName` varchar(255) NOT NULL DEFAULT '', + `LastName` varchar(255) NOT NULL DEFAULT '', + `Gender` tinyint(1) unsigned NOT NULL DEFAULT '0', + `Country` char(2) NOT NULL DEFAULT '', PRIMARY KEY (`UId`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='contains all users information for ryzom_ams'; diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/settings.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/settings.tpl index 46c3da902..66bb1c8b3 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/settings.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/settings.tpl @@ -136,7 +136,7 @@
-
+ Change Info
@@ -144,7 +144,7 @@
- +
@@ -438,7 +438,8 @@
- + +