diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php index 240eda426..a96fd98ea 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php @@ -41,4 +41,17 @@ class DBLayer{ } } + public function executeReturnId($query,$params){ + try{ + $statement = $this->PDO->prepare($query); + $this->PDO->beginTransaction(); + $statement->execute($params); + $lastId =$this->PDO->lastInsertId(); + $this->PDO->commit(); + return $lastId; + }catch (PDOException $e) { + throw $e; + } + } + } \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php index 170a1c4bf..1c68b822b 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php @@ -25,13 +25,27 @@ class Sync{ switch($record['type']) { case 'createPermissions': - case 'user_edit': + case 'change_pass': + $decode = json_decode($record['query']); + $values = array('user' => $decode[0], 'pass' => $decode[1]); + //make connection with and put into shard db & delete from the lib + $dbs->execute("SET Password = :pass WHERE Login = :user",$values); + $dbl->execute("DELETE FROM ams_querycache WHERE SID=:SID",array('SID' => $record['SID'])); + break; + case 'change_mail': + $decode = json_decode($record['query']); + $values = array('user' => $decode[0], 'mail' => $decode[1]); + //make connection with and put into shard db & delete from the lib + $dbs->execute("SET Email = :mail WHERE Login = :user",$values); + $dbl->execute("DELETE FROM ams_querycache WHERE SID=:SID",array('SID' => $record['SID'])); + break; case 'createUser': $decode = json_decode($record['query']); - $query = array('login' => $decode[0], 'pass' => $decode[1], 'mail' => $decode[2] ); + $values = array('login' => $decode[0], 'pass' => $decode[1], 'mail' => $decode[2] ); //make connection with and put into shard db & delete from the lib - $dbs->execute("INSERT INTO user (Login, Password, Email) VALUES (:login, :pass, :mail)",$query); + $dbs->execute("INSERT INTO user (Login, Password, Email) VALUES (:login, :pass, :mail)",$values); $dbl->execute("DELETE FROM ams_querycache WHERE SID=:SID",array('SID' => $record['SID'])); + break; } } print('Syncing completed'); diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket.php new file mode 100644 index 000000000..f8f9f10e3 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket.php @@ -0,0 +1,169 @@ +execute("SELECT * FROM ticket INNER JOIN ticket_user ON ticket.Author = ticket_user.TUserId and ticket_user.ExternId=:id", array('id' => $author)); + $row = $statement->fetchAll(); + $result = Array(); + foreach($row as $ticket){ + $instance = new self($db_data); + $instance->setTimestamp($ticket['Timestamp']); + $instance->setTitle($ticket['Title']); + $instance->setStatus($ticket['Status']); + $instance->setQueue($ticket['Queue']); + $instance->setTicket_Category($ticket['Ticket_Category']); + $instance->setAuthor($ticket['Author']); + $result[] = $instance; + } + return $result; + } + + + /*FUNCTION: create_Ticket() + * creates a ticket + first initial reply and fills in the content of it! + * + */ + public static function create_Ticket( $title, $content, $category, $author, $db_data) { + + $ticket = new Ticket($db_data); + $ticket->set($title,0,0,$category,$author); + $ticket->create(); + $ticket_id = $ticket->getTId(); + + + $ticket_content = new Ticket_Content($db_data); + $ticket_content->setContent($content); + $ticket_content->create(); + $content_id = $ticket_content->getTContentId(); + + + $ticket_reply = new Ticket_Reply($db_data); + $ticket_reply->set($ticket_id, $content_id, $author); + $ticket_reply->create(); + + } + + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// + public function __construct($db_data) { + $this->db = $db_data; + } + + + //Set ticket object + public function set($t,$s,$q,$t_c,$a){ + $this->title = $t; + $this->status = $s; + $this->queue = $q; + $this->ticket_category = $t_c; + $this->author = $a; + } + + //create ticket by writing private data to DB. + public function create(){ + $dbl = new DBLayer($this->db); + $query = "INSERT INTO ticket (Timestamp, Title, Status, Queue, Ticket_Category, Author) VALUES (now(), :title, :status, :queue, :tcat, :author)"; + $values = Array('title' => $this->title, 'status' => $this->status, 'queue' => $this->queue, 'tcat' => $this->ticket_category, 'author' => $this->author); + $this->tId = $dbl->executeReturnId($query, $values); ; + } + + //return constructed element based on TId + public function load_With_TId( $id) { + $dbl = new DBLayer($this->db); + $statement = $dbl->execute("SELECT * FROM ticket WHERE TId=:id", array('id' => $id)); + $row = $statement->fetch(); + $this->tId = $row['TId']; + $this->timestamp = $row['Timestamp']; + $this->title = $row['Title']; + $this->status = $row['Status']; + $this->queue = $row['Queue']; + $this->ticket_category = $row['Ticket_Category']; + $this->author = $row['Author']; + } + + + //update private data to DB. + public function update(){ + $dbl = new DBLayer($this->db); + $query = "UPDATE ticket SET Timestamp = :timestamp, Title = :title, Status = :status, Queue = :queue, Ticket_Category = :tcat, Author = :author WHERE TId=:id"; + $values = Array('id' => $this->tId, 'timestamp' => $this->timestamp, 'title' => $this->title, 'status' => $this->status, 'queue' => $this->queue, 'tcat' => $this->ticket_category, 'author' => $this->author); + $statement = $dbl->execute($query, $values); + } + + + ////////////////////////////////////////////Getters//////////////////////////////////////////////////// + + public function getTId(){ + return $this->tId; + } + + public function getTimestamp(){ + return $this->timestamp; + } + + public function getTitle(){ + return $this->title; + } + + public function getStatus(){ + return $this->status; + } + + public function getQueue(){ + return $this->queue; + } + + public function getTicket_Category(){ + return $this->ticket_category; + } + + public function getAuthor(){ + return $this->author; + } + + ////////////////////////////////////////////Setters//////////////////////////////////////////////////// + + public function setTId($id){ + $this->tId = $id; + } + + public function setTimestamp($ts){ + $this->timestamp = $ts; + } + + public function setTitle($t){ + $this->title = $t; + } + + public function setStatus($s){ + $this->status = $s; + } + + public function setQueue($q){ + $this->queue = $q; + } + + public function setTicket_Category($tc){ + $this->ticket_category = $tc; + } + + public function setAuthor($a){ + $this->author = $a; + } + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_category.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_category.php new file mode 100644 index 000000000..1fe7227b7 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_category.php @@ -0,0 +1,94 @@ + $name); + $dbl->execute($query, $values); + + } + + + //return constructed element based on TCategoryId + public static function constr_TCategoryId( $id, $db_data) { + $instance = new self($db_data); + $instance->setTCategoryId($id); + return $instance; + } + + //returns list of all category objects + public static function getAllCategories($db_data) { + $dbl = new DBLayer($db_data); + $statement = $dbl->executeWithoutParams("SELECT * FROM ticket_category"); + $row = $statement->fetchAll(); + $result = Array(); + foreach($row as $category){ + $instance = new self($db_data); + $instance->tCategoryId = $category['TCategoryId']; + $instance->name = $category['Name']; + $result[] = $instance; + } + return $result; + } + + + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// + + public function __construct($db_data) { + $this->db = $db_data; + } + + //return constructed element based on TCategoryId + public function load_With_TCategoryId( $id) { + $dbl = new DBLayer($this->db); + $statement = $dbl->execute("SELECT * FROM ticket_category WHERE TCategoryId=:id", array('id' => $id)); + $row = $statement->fetch(); + $this->tCategoryId = $row['TCategoryId']; + $this->name = $row['Name']; + } + + + //update private data to DB. + public function update(){ + $dbl = new DBLayer($this->db); + $query = "UPDATE ticket_category SET Name = :name WHERE TCategoryId=:id"; + $values = Array('id' => $this->tCategoryId, 'name' => $this->name); + $statement = $dbl->execute($query, $values); + } + + ////////////////////////////////////////////Getters//////////////////////////////////////////////////// + + public function getName(){ + if ($this->name == ""){ + $this->load_With_TCategoryId($this->tCategoryId); + } + return $this->name; + } + + + public function getTCategoryId(){ + return $this->tCategoryId; + } + + + ////////////////////////////////////////////Setters//////////////////////////////////////////////////// + + public function setName($n){ + $this->name = $n; + } + + public function setTCategoryId($id){ + $this->tCategoryId = $id; + } + + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_content.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_content.php new file mode 100644 index 000000000..62130d1d9 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_content.php @@ -0,0 +1,75 @@ +setTContentId($id); + return $instance; + } + + + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// + + public function __construct($db_data) { + $this->db = $db_data; + } + + //Creates a ticket_content entry in the DB + public function create() { + $dbl = new DBLayer($this->db); + $query = "INSERT INTO ticket_content (Content) VALUES (:content)"; + $values = Array('content' => $this->content); + $this->tContentId = $dbl->executeReturnId($query, $values); ; + } + + //return constructed element based on TContentId + public function load_With_TContentId( $id) { + $dbl = new DBLayer($this->db); + $statement = $dbl->execute("SELECT * FROM ticket_content WHERE TContentId=:id", array('id' => $id)); + $row = $statement->fetch(); + $this->tContentId = $row['TContentId']; + $this->content = $row['Content']; + } + + //update private data to DB. + public function update(){ + $dbl = new DBLayer($this->db); + $query = "UPDATE ticket_content SET Content = :content WHERE TContentId=:id"; + $values = Array('id' => $this->tContentId, 'content' => $this->content); + $statement = $dbl->execute($query, $values); + } + + ////////////////////////////////////////////Getters//////////////////////////////////////////////////// + + public function getContent(){ + if ($this->content == ""){ + $this->load_With_TContentId($this->tContentId); + } + return $this->content; + } + + + public function getTContentId(){ + return $this->tContentId; + } + + + ////////////////////////////////////////////Setters//////////////////////////////////////////////////// + + public function setContent($c){ + $this->content = $c; + } + + public function setTContentId($c){ + $this->tContentId = $c; + } + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_reply.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_reply.php new file mode 100644 index 000000000..8f14a9f5f --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_reply.php @@ -0,0 +1,110 @@ +setTReplyId($id); + return $instance; + } + + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// + + public function __construct($db_data) { + $this->db = $db_data; + } + + + //Set ticket_reply object + public function set($t,$c,$a){ + $this->ticket = $t; + $this->content = $c; + $this->author = $a; + } + + //create ticket by writing private data to DB. + public function create(){ + $dbl = new DBLayer($this->db); + $query = "INSERT INTO ticket_reply (Ticket, Content, Author, Timestamp) VALUES (:ticket, :content, :author, now())"; + $values = Array('ticket' => $this->ticket, 'content' => $this->content, 'author' => $this->author); + $dbl->execute($query, $values); + } + + //return constructed element based on TId + public function load_With_TReplyId( $id) { + $dbl = new DBLayer($this->db); + $statement = $dbl->execute("SELECT * FROM ticket_reply WHERE TReplyId=:id", array('id' => $id)); + $row = $statement->fetch(); + $this->tReplyId = $row['TReplyId']; + $this->ticket = $row['Ticket']; + $this->content = $row['Content']; + $this->author = $row['Author']; + $this->timestamp = $row['Timestamp']; + } + + //update private data to DB. + public function update(){ + $dbl = new DBLayer($this->db); + $query = "UPDATE ticket SET Ticket = :ticket, Content = :content, Author = :author, Timestamp = :timestamp WHERE TReplyId=:id"; + $values = Array('id' => $this->tReplyId, 'timestamp' => $this->timestamp, 'ticket' => $this->ticket, 'content' => $this->content, 'author' => $this->author); + $statement = $dbl->execute($query, $values); + } + + ////////////////////////////////////////////Getters//////////////////////////////////////////////////// + + public function getTicket(){ + return $this->ticket; + } + + + public function getContent(){ + return $this->content; + } + + public function getAuthor(){ + return $this->author; + } + + public function getTimestamp(){ + return $this->timestamp; + } + + + public function getTReplyId(){ + return $this->tReplyId; + } + + + ////////////////////////////////////////////Setters//////////////////////////////////////////////////// + + public function setTicket($t){ + $this->ticket = $t; + } + + + public function setContent($c){ + $this->content = $c; + } + + public function setAuthor($a){ + $this->author = $a; + } + + public function setTimestamp($t){ + $this->timestamp = $t; + } + + + public function setTReplyId($i){ + $this->tReplyId = $i; + } +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_user.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_user.php new file mode 100644 index 000000000..b61c99f68 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_user.php @@ -0,0 +1,101 @@ + $permission, 'ext_id' => $extern_id); + $dbl->execute($query, $values); + + } + + + //return constructed element based on TUserId + public static function constr_TUserId( $id, $db_data) { + $instance = new self($db_data); + $instance->setTUserId($id); + return $instance; + + } + + //return constructed element based on ExternId + public static function constr_ExternId( $id, $db_data ) { + $instance = new self($db_data); + $dbl = new DBLayer($instance->db); + $statement = $dbl->execute("SELECT * FROM ticket_user WHERE ExternId=:id", array('id' => $id)); + $row = $statement->fetch(); + $instance->tUserId = $row['TUserId']; + $instance->permission = $row['Permission']; + $instance->externId = $row['ExternId']; + return $instance; + + } + + + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// + public function __construct($db_data) { + $this->db = $db_data; + } + + //return constructed element based on TUserId + public function load_With_TUserId( $id) { + $dbl = new DBLayer($this->db); + $statement = $dbl->execute("SELECT * FROM ticket_user WHERE TUserId=:id", array('id' => $id)); + $row = $statement->fetch(); + $instance->tUserId = $row['TUserId']; + $instance->permission = $row['Permission']; + $instance->externId = $row['ExternId']; + return $instance; + } + + //update private data to DB. + public function update(){ + $dbl = new DBLayer($this->db); + $query = "UPDATE ticket_user SET Permission = :perm, ExternId = :ext_id WHERE TUserId=:id"; + $values = Array('id' => $this->tUserId, 'perm' => $this->permission, 'ext_id' => $this->externId); + $statement = $dbl->execute($query, $values); + } + + ////////////////////////////////////////////Getters//////////////////////////////////////////////////// + + public function getPermission(){ + if ($this->permission == ""){ + $this->load_With_TUserId($this->tUserId); + } + return $this->permission; + } + + + public function getExternId(){ + if ($this->ExternId == ""){ + $this->load_With_TUserId($this->tUserId); + } + return $this->externId; + } + + + public function getTUserId(){ + return $this->tUserId; + } + + + ////////////////////////////////////////////Setters//////////////////////////////////////////////////// + + public function setPermission($perm){ + $this->permission = $perm; + } + + + public function setExternId($id){ + $this->externId = $id; + } + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php index 7373bc4a3..9ce16aa37 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php @@ -156,7 +156,7 @@ class Users{ * @takes $email * @return */ - private function checkEmail( $email ) + public function checkEmail( $email ) { if ( isset( $email ) ){ if ( !Users::validEmail( $email ) ){ @@ -284,12 +284,13 @@ class Users{ * @takes $array with name,pass and mail * @return ok if it's get correctly added to the shard, else return lib offline and put in libDB, if libDB is also offline return liboffline. */ - public function createUser($values){ + public function createUser($values, $user_id){ try { //make connection with and put into shard db global $cfg; $dbs = new DBLayer($cfg['db']['shard']); $dbs->execute("INSERT INTO user (Login, Password, Email) VALUES (:name, :pass, :mail)",$values); + ticket_user::createTicketUser( $user_id , 1, $cfg['db']['lib'] ); return "ok"; } catch (PDOException $e) { @@ -298,6 +299,7 @@ class Users{ $dbl = new DBLayer($cfg['db']['lib']); $dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "createUser", "query" => json_encode(array($values["name"],$values["pass"],$values["mail"])))); + ticket_user::createTicketUser( $user_id , 1, $cfg['db']['lib'] ); return "shardoffline"; }catch (PDOException $e) { print_r($e); @@ -365,25 +367,51 @@ class Users{ } } - protected function setPassword($user, $pass){ + protected function setAmsPassword($user, $pass){ + + global $cfg; + $values = Array('user' => $user, 'pass' => $pass); + try { //make connection with and put into shard db - global $cfg; $dbs = new DBLayer($cfg['db']['shard']); $dbs->execute("UPDATE user SET Password = :pass WHERE Login = :user ",$values); return "ok"; } catch (PDOException $e) { //oh noooz, the shard is offline! Put in query queue at ams_lib db! - /*try { - $dbl = new DBLayer($cfg['db']['lib']); - $dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "createUser", - "query" => json_encode(array($values["name"],$values["pass"],$values["mail"])))); + try { + $dbl = new DBLayer($cfg['db']['lib']); + $dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "change_pass", + "query" => json_encode(array($values["user"],$values["pass"])))); return "shardoffline"; }catch (PDOException $e) { - print_r($e); return "liboffline"; - }*/ + } + } + } + + protected function setAmsEmail($user, $mail){ + + global $cfg; + $values = Array('user' => $user, 'mail' => $mail); + + try { + //make connection with and put into shard db + $dbs = new DBLayer($cfg['db']['shard']); + $dbs->execute("UPDATE user SET Email = :mail WHERE Login = :user ",$values); + return "ok"; + } + catch (PDOException $e) { + //oh noooz, the shard is offline! Put in query queue at ams_lib db! + try { + $dbl = new DBLayer($cfg['db']['lib']); + $dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "change_mail", + "query" => json_encode(array($values["user"],$values["mail"])))); + return "shardoffline"; + }catch (PDOException $e) { + return "liboffline"; + } } } } diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini index 56c07761f..858c3020f 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini @@ -20,14 +20,24 @@ name = "Name" email = "Email" action = "Action" +[show_user] + +[createticket] + +[error] +title404 = "Not
Found!" +title403 = "Forbidden!" +error_message404 = "This is not the page you are looking for.." +error_message403 = "You cannot access this page!" +go_home = "Go Home" [userlist] userlist_info = "welcome to the userlist" [login] login_info = "Please login with your Username and Password." -login_error_message = "The filled in username/password were not correct!" -login_register_message ="RegisterIf you dont have an account yet, create one" +login_error_message = "The username/password were not correct!" +login_register_message ="Register If you don't have an account yet, create one" login_register_message_here = "here" [logout] @@ -67,6 +77,7 @@ email_tooltip = "Email Address to which a confirmation email will be sent." email_message = "Please verify that the e-mail address you enter here is valid and will remain valid in the future. It will only be used to manage your Ryzom Core account." email_default = "Email" -tac_tag = "YES, I agree to the terms of service." +tac_tag1= "YES, I agree to the " +tac_tag2="terms of service" tac_message = "You must accept the Terms of Service." diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini index 56c07b555..150a62c6b 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini @@ -20,6 +20,17 @@ name = "Nom" email = "Email" action = "Action" +[createticket] + +[show_user] + +[error] +title404 = "Pas
trouvez!" +title403 = "Interdit!" +error_message404 = "Ce page que vous cherchez n'existe pas." +error_message403 = "Vous n'avez pas permission d'access ce page!" +go_home = "Allez au main page" + [userlist] userlist_info = "bienvenue sur le userlist page!" @@ -66,5 +77,6 @@ email_tooltip = "Adresse de courriel (pour qui un email de confirmation vous ser email_message = "Veuillez vérifier que l'adresse e-mail que vous entrez ici est valable et restera valable à l'avenir. Elle ne sera utilisée que pour gérer votre compte de base de Ryzom." email_default = "email" -tac_tag = "OUI, j'accepte les termes de service." +tac_tag1 = "OUI, j'accepte les " +tac_tag2 = "termes de service" tac_message = "Vous devez accepter les Conditions d'utilisation." \ No newline at end of file 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 91c7bc317..6c22c57f8 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 @@ -50,7 +50,15 @@ class WebUsers extends Users{ } } - + public function getId($username){ + global $cfg; + + $dbw = new DBLayer($cfg['db']['web']); + $statement = $dbw->execute("SELECT * FROM ams_user WHERE Login=:username", array('username' => $username)); + $row = $statement->fetch(); + return $row['UId']; + } + public function getUsername($id){ global $cfg; @@ -60,6 +68,25 @@ class WebUsers extends Users{ return $row['Login']; } + public function getEmail($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(); + 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'])){ return true; @@ -74,4 +101,40 @@ class WebUsers extends Users{ return false; } + public function setPassword($user, $pass){ + global $cfg; + $reply = WebUsers::setAmsPassword($user, $pass); + $values = Array('user' => $user, 'pass' => $pass); + try { + //make connection with and put into shard db + $dbw = new DBLayer($cfg['db']['web']); + $dbw->execute("UPDATE ams_user SET Password = :pass WHERE Login = :user ",$values); + } + catch (PDOException $e) { + //ERROR: the web DB is offline + } + return $reply; + } + + public function setEmail($user, $mail){ + global $cfg; + $reply = WebUsers::setAmsEmail($user, $mail); + $values = Array('user' => $user, 'mail' => $mail); + try { + //make connection with and put into shard db + $dbw = new DBLayer($cfg['db']['web']); + $dbw->execute("UPDATE ams_user SET Email = :mail WHERE Login = :user ",$values); + } + catch (PDOException $e) { + //ERROR: the web DB is offline + } + return $reply; + } + + public function getUsers(){ + global $cfg; + $dbl = new DBLayer($cfg['db']['web']); + $data = $dbl->executeWithoutParams("SELECT * FROM ams_user"); + return $data; + } } \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/error.php b/code/ryzom/tools/server/ryzom_ams/www/html/error.php index 4d701a543..b84bd7de7 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/error.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/error.php @@ -73,7 +73,7 @@
The page your are looking for is not found. -
Go Home or
Search
+
Go Home
diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/add_user.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/add_user.php index 1f8d5ce22..e21e32d6a 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/func/add_user.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/add_user.php @@ -36,7 +36,7 @@ function add_user(){ function write_user($newUser){ - + //create salt here, because we want it to be the same on the web/server $hashpass = crypt($newUser["pass"], WebUsers::generateSALT()); @@ -45,16 +45,17 @@ function write_user($newUser){ 'pass' => $hashpass, 'mail' => $newUser["mail"] ); - - //Create the user on the shard + in case shard is offline put copy of query in query db - //returns: ok, shardoffline or liboffline - $result = WebUsers::createUser($params); try{ - //make connection with web db and put it in there global $cfg; + //make connection with web db and put it in there $dbw = new DBLayer($cfg['db']['web']); - $dbw->execute("INSERT INTO ams_user (Login, Password, Email) VALUES (:name, :pass, :mail)",$params); + $user_id = $dbw->executeReturnId("INSERT INTO ams_user (Login, Password, Email) VALUES (:name, :pass, :mail)",$params); + + //Create the user on the shard + in case shard is offline put copy of query in query db + //returns: ok, shardoffline or liboffline + $result = WebUsers::createUser($params, $user_id); + }catch (PDOException $e) { //go to error page or something, because can't access website db 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..baf28afc2 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/change_info.php @@ -0,0 +1,115 @@ +getInfo($_POST['target_id']); + + + $current_info['FirstName'] = filter_var($current_info['FirstName'], FILTER_SANITIZE_STRING); + $current_info['LastName'] = filter_var($current_info['LastName'], FILTER_SANITIZE_STRING); + $current_info['Country'] = filter_var($current_info['Country'], FILTER_SANITIZE_STRING); + $current_info['Gender'] = filter_var($current_info['Gender'], FILTER_SANITIZE_NUMBER_INT); + + + $updated = false; + $values = Array(); + $values['user'] = $target_username; + + //make the query that will update the data. + $query = "UPDATE ams_user SET "; + if(($_POST['FirstName'] != "") && ($_POST['FirstName'] != $current_info['FirstName'])){ + $query = $query . "FirstName = :fName "; + $updated = true; + $values['fName'] = filter_var($_POST['FirstName'], FILTER_SANITIZE_STRING); + } + if(($_POST['LastName'] != "") && ($_POST['LastName'] != $current_info['LastName'])){ + if($updated){ + $query = $query . ", LastName = :lName "; + }else{ + $query = $query . "LastName = :lName "; + } + $updated = true; + $values['lName'] = filter_var($_POST['LastName'], FILTER_SANITIZE_STRING); + } + if(($_POST['Country'] != "AA") && ($_POST['Country'] != $current_info['Country'])){ + if($updated){ + $query = $query . ", Country = :country "; + }else{ + $query = $query . "Country = :country "; + } + $updated = true; + $values['country'] = filter_var($_POST['Country'], FILTER_SANITIZE_STRING); + } + if($_POST['Gender'] != $current_info['Gender']){ + if($updated){ + $query = $query . ", Gender = :gender "; + }else{ + $query = $query . "Gender = :gender "; + } + $updated = true; + $values['gender'] = filter_var($_POST['Gender'], FILTER_SANITIZE_NUMBER_INT); + } + //finish the query! + $query = $query . "WHERE Login = :user"; + + //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']; + helpers :: loadtemplate( 'settings', $result); + exit; + + }else{ + //ERROR: permission denied! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + } + + }else{ + //ERROR: The form was not filled in correclty + header("Location: index.php?page=settings"); + exit; + } + }else{ + //ERROR: user is not logged in + header("Location: index.php"); + 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/func/change_mail.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/change_mail.php new file mode 100644 index 000000000..6905febae --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/change_mail.php @@ -0,0 +1,92 @@ +checkEmail($_POST['NewEmail']); + + global $SITEBASE; + require_once($SITEBASE . 'inc/settings.php'); + $result = settings(); + + if ( $reply != "success" ){ + $result['EMAIL_ERROR'] = 'TRUE'; + }else{ + $result['EMAIL_ERROR'] = 'FALSE'; + } + $result['prevNewEmail'] = filter_var($_POST["NewEmail"], FILTER_SANITIZE_EMAIL); + + if ($reply== "success"){ + $status = WebUsers::setEmail($target_username, filter_var($_POST["NewEmail"], FILTER_SANITIZE_EMAIL) ); + 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['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{ + $result['EMAIL'] = $reply; + $result['permission'] = $_SESSION['permission']; + $result['no_visible_elements'] = 'FALSE'; + $result['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! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + } + + }else{ + //ERROR: The form was not filled in correclty + header("Location: index.php?page=settings"); + exit; + } + }else{ + //ERROR: user is not logged in + header("Location: index.php"); + exit; + } + + }catch (PDOException $e) { + //go to error page or something, because can't access website db + print_r($e); + exit; + } + +} + diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/change_password.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/change_password.php index 3603c5144..57e675123 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/func/change_password.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/change_password.php @@ -18,44 +18,64 @@ function change_password(){ $adminChangesOther = true; $_POST["CurrentPass"] = "dummypass"; } - $id = $_POST['target_id']; $webUser = new WebUsers(); $params = Array( 'user' => $target_username, 'CurrentPass' => $_POST["CurrentPass"], 'NewPass' => $_POST["NewPass"], 'ConfirmNewPass' => $_POST["ConfirmNewPass"], 'adminChangesOther' => $adminChangesOther); $result = $webUser->check_change_password($params); if ($result == "success"){ //edit stuff into db + global $SITEBASE; + require_once($SITEBASE . 'inc/settings.php'); + $succresult = settings(); $hashpass = crypt($_POST["NewPass"], WebUsers::generateSALT()); - print('success!'); + $status = WebUsers::setPassword($target_username, $hashpass); + if($status == 'ok'){ + $succresult['SUCCESS_PASS'] = "OK"; + }else if($status == 'shardoffline'){ + $succresult['SUCCESS_PASS'] = "SHARDOFF"; + } + $succresult['permission'] = $_SESSION['permission']; + $succresult['no_visible_elements'] = 'FALSE'; + $succresult['username'] = $_SESSION['user']; + $succresult['target_id'] = $_POST['target_id']; + helpers :: loadtemplate( 'settings', $succresult); exit; }else{ - - $result['prevCurrentPass'] = $_POST["CurrentPass"]; - $result['prevNewPass'] = $_POST["NewPass"]; - $result['prevConfirmNewPass'] = $_POST["ConfirmNewPass"]; + + $result['prevCurrentPass'] = filter_var($_POST["CurrentPass"], FILTER_SANITIZE_STRING); + $result['prevNewPass'] = filter_var($_POST["NewPass"], FILTER_SANITIZE_STRING); + $result['prevConfirmNewPass'] = filter_var($_POST["ConfirmNewPass"], FILTER_SANITIZE_STRING); $result['permission'] = $_SESSION['permission']; $result['no_visible_elements'] = 'FALSE'; + $result['username'] = $_SESSION['user']; $result['target_id'] = $_POST['target_id']; - if(isset($_GET['id'])){ - if(WebUsers::isAdmin() && ($_POST['target_id'] != $_SESSION['id'])){ - $result['isAdmin'] = "TRUE"; - } - } + + global $SITEBASE; + require_once($SITEBASE . 'inc/settings.php'); + $settings = settings(); + + $result = array_merge($result,$settings); helpers :: loadtemplate( 'settings', $result); exit; } }else{ //ERROR: permission denied! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; } }else{ //ERROR: The form was not filled in correclty + header("Location: index.php?page=settings"); + exit; } }else{ //ERROR: user is not logged in - exit; + header("Location: index.php"); + exit; } }catch (PDOException $e) { diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/create_ticket.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/create_ticket.php new file mode 100644 index 000000000..8f8010889 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/create_ticket.php @@ -0,0 +1,48 @@ +getTUserId(); + }else{ + $author= Ticket_User::constr_ExternId($_POST['target_id'], $cfg['db']['lib'])->getTUserId(); + } + Ticket::create_Ticket($title, $content, $category, $author, $cfg['db']['lib'] ); + }catch (PDOException $e) { + //ERROR: LIB DB is not online! + header("Location: index.php"); + exit; + } + + }else{ + //ERROR: permission denied! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + } + + }else{ + //ERROR: The form was not filled in correclty + header("Location: index.php?page=settings"); + exit; + } + }else{ + //ERROR: user is not logged in + header("Location: index.php"); + exit; + } + +} + diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/login.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/login.php index a34203541..eb9be221f 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/func/login.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/login.php @@ -11,13 +11,14 @@ function login(){ $_SESSION['user'] = $_POST["Username"]; $_SESSION['permission'] = $result['Permission']; $_SESSION['id'] = $result['UId']; - print('id='); - print($_SESSION['id']); + $_SESSION['ticket_user'] = Ticket_User::constr_ExternId($result['UId'],$cfg['db']['lib']); + //go back to the index page. header( 'Location: index.php' ); exit; }else{ //handle login failure + $result = Array(); $result['login_error'] = 'TRUE'; $result['no_visible_elements'] = 'TRUE'; helpers :: loadtemplate( 'login', $result); diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/createticket.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/createticket.php new file mode 100644 index 000000000..4647bbfaf --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/createticket.php @@ -0,0 +1,45 @@ +getTCategoryId()] = $catObj->getName(); + } + + return $result; + + }else{ + //ERROR: not logged in! + header("Location: index.php"); + exit; + } + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/error.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/error.php new file mode 100644 index 000000000..eca129ff6 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/error.php @@ -0,0 +1,12 @@ +executeWithoutParams("SELECT * FROM ams_querycache")->rowCount(); - - //the array hat will contain all users - $pageResult['liblist'] = Array(); - if($rows > 0){ - //This is the number of results displayed per page - $page_rows = 2; - - //This tells us the page number of our last page - $last = ceil($rows/$page_rows); - - //this makes sure the page number isn't below one, or more than our maximum pages - if ($pagenum < 1) - { + if(WebUsers::isAdmin()){ + //This checks to see if there is a page number. If not, it will set it to page 1 + if (!(isset($_GET['pagenum']))){ $pagenum = 1; - }else if ($pagenum > $last) { - $pagenum = $last; - } - - //This sets the range to display in our query - $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; - - //This is your query again, the same one... the only difference is we add $max into it - $data = $dbl->executeWithoutParams("SELECT * FROM ams_querycache $max"); - - //This is where we put the results in a resultArray to be sent to smarty - - $i = 0; - while($row = $data->fetch(PDO::FETCH_ASSOC)){ - $decode = json_decode($row['query']); - $pageResult['liblist'][$i]['id'] = $row['SID']; - $pageResult['liblist'][$i]['type'] = $row['type']; - $pageResult['liblist'][$i]['name'] = $decode[0]; - $pageResult['liblist'][$i]['mail'] = $decode[2]; - $i++; + }else{ + $pagenum = $_GET['pagenum']; } + + //Here we count the number of results + global $cfg; + $dbl = new DBLayer($cfg['db']['lib']); + $rows = $dbl->executeWithoutParams("SELECT * FROM ams_querycache")->rowCount(); + + //the array hat will contain all users + $pageResult['liblist'] = Array(); + if($rows > 0){ + //This is the number of results displayed per page + $page_rows = 2; + + //This tells us the page number of our last page + $last = ceil($rows/$page_rows); + + //this makes sure the page number isn't below one, or more than our maximum pages + if ($pagenum < 1) + { + $pagenum = 1; + }else if ($pagenum > $last) { + $pagenum = $last; + } + + //This sets the range to display in our query + $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; + + //This is your query again, the same one... the only difference is we add $max into it + $data = $dbl->executeWithoutParams("SELECT * FROM ams_querycache $max"); + + //This is where we put the results in a resultArray to be sent to smarty + + $i = 0; + while($row = $data->fetch(PDO::FETCH_ASSOC)){ + $decode = json_decode($row['query']); + $pageResult['liblist'][$i]['id'] = $row['SID']; + $pageResult['liblist'][$i]['type'] = $row['type']; + //$pageResult['liblist'][$i]['name'] = $decode[0]; + //$pageResult['liblist'][$i]['mail'] = $decode[2]; + $i++; + } + } + + //check if shard is online + try{ + $dbs = new DBLayer($cfg['db']['shard']); + $pageResult['shard'] = "online"; + }catch(PDOException $e) { + $pageResult['shard'] = "offline"; + } + return $pageResult; + }else{ + //ERROR: No access! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; } - - //check if shard is online - try{ - $dbs = new DBLayer($cfg['db']['shard']); - $pageResult['shard'] = "online"; - }catch(PDOException $e) { - $pageResult['shard'] = "offline"; - } - return $pageResult; } \ 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 2248b7d70..90bafbefc 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,18 +4,288 @@ 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'])){ - if(WebUsers::isAdmin() && ($_GET['id']!= $_SESSION['id'])){ - $result['isAdmin'] = "TRUE"; + if(($_GET['id'] != $_SESSION['id']) && (!WebUsers::isAdmin()) ){ + //ERROR: No access! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + }else{ + $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']); } - $result['target_id'] = $_GET['id']; }else{ + $result = WebUsers::getInfo($_SESSION['id']); $result['target_id'] = $_SESSION['id']; + $result['current_mail'] = WebUsers::getEmail($_SESSION['id']); + + //Sanitize Data + $result['current_mail'] = filter_var($result['current_mail'], FILTER_SANITIZE_EMAIL); + //$result['Login'] = filter_var($result['Login'], FILTER_SANITIZE_STRING); + $result['FirstName'] = filter_var($result['FirstName'], FILTER_SANITIZE_STRING); + $result['LastName'] = filter_var($result['LastName'], FILTER_SANITIZE_STRING); + $result['Country'] = filter_var($result['Country'], FILTER_SANITIZE_STRING); + $result['Gender'] = filter_var($result['Gender'], FILTER_SANITIZE_NUMBER_INT); } - + $result['country_array'] = getCountryArray(); return $result; }else{ //ERROR: not logged in! - print("not logged in!"); + header("Location: index.php"); exit; } -} \ No newline at end of file +} + + +function getCountryArray(){ + +$countries = array( +'AA'=>'None Selected', +'AF'=>'Afghanistan', +'AL'=>'Albania', +'DZ'=>'Algeria', +'AS'=>'American Samoa', +'AD'=>'Andorra', +'AO'=>'Angola', +'AI'=>'Anguilla', +'AQ'=>'Antarctica', +'AG'=>'Antigua And Barbuda', +'AR'=>'Argentina', +'AM'=>'Armenia', +'AW'=>'Aruba', +'AU'=>'Australia', +'AT'=>'Austria', +'AZ'=>'Azerbaijan', +'BS'=>'Bahamas', +'BH'=>'Bahrain', +'BD'=>'Bangladesh', +'BB'=>'Barbados', +'BY'=>'Belarus', +'BE'=>'Belgium', +'BZ'=>'Belize', +'BJ'=>'Benin', +'BM'=>'Bermuda', +'BT'=>'Bhutan', +'BO'=>'Bolivia', +'BA'=>'Bosnia And Herzegovina', +'BW'=>'Botswana', +'BV'=>'Bouvet Island', +'BR'=>'Brazil', +'IO'=>'British Indian Ocean Territory', +'BN'=>'Brunei', +'BG'=>'Bulgaria', +'BF'=>'Burkina Faso', +'BI'=>'Burundi', +'KH'=>'Cambodia', +'CM'=>'Cameroon', +'CA'=>'Canada', +'CV'=>'Cape Verde', +'KY'=>'Cayman Islands', +'CF'=>'Central African Republic', +'TD'=>'Chad', +'CL'=>'Chile', +'CN'=>'China', +'CX'=>'Christmas Island', +'CC'=>'Cocos (Keeling) Islands', +'CO'=>'Columbia', +'KM'=>'Comoros', +'CG'=>'Congo', +'CK'=>'Cook Islands', +'CR'=>'Costa Rica', +'CI'=>'Cote D\'Ivorie (Ivory Coast)', +'HR'=>'Croatia (Hrvatska)', +'CU'=>'Cuba', +'CY'=>'Cyprus', +'CZ'=>'Czech Republic', +'CD'=>'Democratic Republic Of Congo (Zaire)', +'DK'=>'Denmark', +'DJ'=>'Djibouti', +'DM'=>'Dominica', +'DO'=>'Dominican Republic', +'TP'=>'East Timor', +'EC'=>'Ecuador', +'EG'=>'Egypt', +'SV'=>'El Salvador', +'GQ'=>'Equatorial Guinea', +'ER'=>'Eritrea', +'EE'=>'Estonia', +'ET'=>'Ethiopia', +'FK'=>'Falkland Islands (Malvinas)', +'FO'=>'Faroe Islands', +'FJ'=>'Fiji', +'FI'=>'Finland', +'FR'=>'France', +'FX'=>'France, Metropolitan', +'GF'=>'French Guinea', +'PF'=>'French Polynesia', +'TF'=>'French Southern Territories', +'GA'=>'Gabon', +'GM'=>'Gambia', +'GE'=>'Georgia', +'DE'=>'Germany', +'GH'=>'Ghana', +'GI'=>'Gibraltar', +'GR'=>'Greece', +'GL'=>'Greenland', +'GD'=>'Grenada', +'GP'=>'Guadeloupe', +'GU'=>'Guam', +'GT'=>'Guatemala', +'GN'=>'Guinea', +'GW'=>'Guinea-Bissau', +'GY'=>'Guyana', +'HT'=>'Haiti', +'HM'=>'Heard And McDonald Islands', +'HN'=>'Honduras', +'HK'=>'Hong Kong', +'HU'=>'Hungary', +'IS'=>'Iceland', +'IN'=>'India', +'ID'=>'Indonesia', +'IR'=>'Iran', +'IQ'=>'Iraq', +'IE'=>'Ireland', +'IL'=>'Israel', +'IT'=>'Italy', +'JM'=>'Jamaica', +'JP'=>'Japan', +'JO'=>'Jordan', +'KZ'=>'Kazakhstan', +'KE'=>'Kenya', +'KI'=>'Kiribati', +'KW'=>'Kuwait', +'KG'=>'Kyrgyzstan', +'LA'=>'Laos', +'LV'=>'Latvia', +'LB'=>'Lebanon', +'LS'=>'Lesotho', +'LR'=>'Liberia', +'LY'=>'Libya', +'LI'=>'Liechtenstein', +'LT'=>'Lithuania', +'LU'=>'Luxembourg', +'MO'=>'Macau', +'MK'=>'Macedonia', +'MG'=>'Madagascar', +'MW'=>'Malawi', +'MY'=>'Malaysia', +'MV'=>'Maldives', +'ML'=>'Mali', +'MT'=>'Malta', +'MH'=>'Marshall Islands', +'MQ'=>'Martinique', +'MR'=>'Mauritania', +'MU'=>'Mauritius', +'YT'=>'Mayotte', +'MX'=>'Mexico', +'FM'=>'Micronesia', +'MD'=>'Moldova', +'MC'=>'Monaco', +'MN'=>'Mongolia', +'MS'=>'Montserrat', +'MA'=>'Morocco', +'MZ'=>'Mozambique', +'MM'=>'Myanmar (Burma)', +'NA'=>'Namibia', +'NR'=>'Nauru', +'NP'=>'Nepal', +'NL'=>'Netherlands', +'AN'=>'Netherlands Antilles', +'NC'=>'New Caledonia', +'NZ'=>'New Zealand', +'NI'=>'Nicaragua', +'NE'=>'Niger', +'NG'=>'Nigeria', +'NU'=>'Niue', +'NF'=>'Norfolk Island', +'KP'=>'North Korea', +'MP'=>'Northern Mariana Islands', +'NO'=>'Norway', +'OM'=>'Oman', +'PK'=>'Pakistan', +'PW'=>'Palau', +'PA'=>'Panama', +'PG'=>'Papua New Guinea', +'PY'=>'Paraguay', +'PE'=>'Peru', +'PH'=>'Philippines', +'PN'=>'Pitcairn', +'PL'=>'Poland', +'PT'=>'Portugal', +'PR'=>'Puerto Rico', +'QA'=>'Qatar', +'RE'=>'Reunion', +'RO'=>'Romania', +'RU'=>'Russia', +'RW'=>'Rwanda', +'SH'=>'Saint Helena', +'KN'=>'Saint Kitts And Nevis', +'LC'=>'Saint Lucia', +'PM'=>'Saint Pierre And Miquelon', +'VC'=>'Saint Vincent And The Grenadines', +'SM'=>'San Marino', +'ST'=>'Sao Tome And Principe', +'SA'=>'Saudi Arabia', +'SN'=>'Senegal', +'SC'=>'Seychelles', +'SL'=>'Sierra Leone', +'SG'=>'Singapore', +'SK'=>'Slovak Republic', +'SI'=>'Slovenia', +'SB'=>'Solomon Islands', +'SO'=>'Somalia', +'ZA'=>'South Africa', +'GS'=>'South Georgia And South Sandwich Islands', +'KR'=>'South Korea', +'ES'=>'Spain', +'LK'=>'Sri Lanka', +'SD'=>'Sudan', +'SR'=>'Suriname', +'SJ'=>'Svalbard And Jan Mayen', +'SZ'=>'Swaziland', +'SE'=>'Sweden', +'CH'=>'Switzerland', +'SY'=>'Syria', +'TW'=>'Taiwan', +'TJ'=>'Tajikistan', +'TZ'=>'Tanzania', +'TH'=>'Thailand', +'TG'=>'Togo', +'TK'=>'Tokelau', +'TO'=>'Tonga', +'TT'=>'Trinidad And Tobago', +'TN'=>'Tunisia', +'TR'=>'Turkey', +'TM'=>'Turkmenistan', +'TC'=>'Turks And Caicos Islands', +'TV'=>'Tuvalu', +'UG'=>'Uganda', +'UA'=>'Ukraine', +'AE'=>'United Arab Emirates', +'UK'=>'United Kingdom', +'US'=>'United States', +'UM'=>'United States Minor Outlying Islands', +'UY'=>'Uruguay', +'UZ'=>'Uzbekistan', +'VU'=>'Vanuatu', +'VA'=>'Vatican City (Holy See)', +'VE'=>'Venezuela', +'VN'=>'Vietnam', +'VG'=>'Virgin Islands (British)', +'VI'=>'Virgin Islands (US)', +'WF'=>'Wallis And Futuna Islands', +'EH'=>'Western Sahara', +'WS'=>'Western Samoa', +'YE'=>'Yemen', +'YU'=>'Yugoslavia', +'ZM'=>'Zambia', +'ZW'=>'Zimbabwe' +); + +return $countries; + +} + diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_user.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_user.php new file mode 100644 index 000000000..a0d9c9132 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_user.php @@ -0,0 +1,63 @@ +getTUserId(),$cfg['db']['lib']); + $i = 0; + $result['ticketlist'] = Array(); + foreach($ticketlist as $ticket){ + $result['ticketlist'][$i]['tId'] = $ticket->getTId(); + $result['ticketlist'][$i]['timestamp'] = $ticket->getTimestamp(); + $result['ticketlist'][$i]['title'] = $ticket->getTitle(); + + //get the status + $statusId = $ticket->getStatus(); + if ($statusId == 0){ + $status = "Waiting on support.."; + }else if($statusId == 1){ + $status = "Being handled.."; + }else if($statusId == 2){ + $status = "Closed"; + } + + $result['ticketlist'][$i]['statusText'] = $status; + $result['ticketlist'][$i]['status'] = $statusId; + //get the category + $category = Ticket_Category::constr_TCategoryId($ticket->getTicket_Category(), $cfg['db']['lib']); + $result['ticketlist'][$i]['category'] = $category->getName(); + $i++; + } + + return $result; + + }else{ + //ERROR: No access! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + } + }else{ + //ERROR: not logged in! + header("Location: index.php"); + exit; + } +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/userlist.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/userlist.php new file mode 100644 index 000000000..e2c2cbfcb --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/userlist.php @@ -0,0 +1,22 @@ +fetch(PDO::FETCH_ASSOC)){ + $pageResult['userlist'][$i]['id'] = $row['UId']; + $pageResult['userlist'][$i]['username'] = $row['Login']; + $pageResult['userlist'][$i]['permission'] = $row['Permission']; + $pageResult['userlist'][$i]['email'] = $row['Email']; + $i++; + } + return $pageResult; + }else{ + //ERROR: No access! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + } +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/index.php b/code/ryzom/tools/server/ryzom_ams/www/html/index.php index d7f234d0d..040989bbb 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/index.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/index.php @@ -50,5 +50,11 @@ if($page == 'login' || $page == 'register' || $page == 'logout'){ }else{ $return['no_visible_elements'] = 'FALSE'; } + +//handle error page +if($page == 'error'){ + $return['permission'] = 0; + $return['no_visible_elements'] = 'FALSE'; +} //print_r($return); helpers :: loadTemplate( $page , $return ); diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/sql/DBScheme.png b/code/ryzom/tools/server/ryzom_ams/www/html/sql/DBScheme.png new file mode 100644 index 000000000..340e67c5c Binary files /dev/null and b/code/ryzom/tools/server/ryzom_ams/www/html/sql/DBScheme.png differ 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..2101f80da 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 @@ -11,8 +11,8 @@ //SETUP THE WWW DB $dbw = new DBLayer($cfg['db']['web']); $sql = " - CREATE DATABASE IF NOT EXISTS `ryzom_ams`; - USE `ryzom_ams`; + CREATE DATABASE IF NOT EXISTS `" . $cfg['db']['web']['name'] ."`; + USE `". $cfg['db']['web']['name'] . "`; DROP TABLE IF EXISTS ams_user; CREATE TABLE IF NOT EXISTS `ams_user` ( @@ -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'; @@ -31,15 +35,216 @@ //SETUP THE AMS_LIB DB $dbl = new DBLayer($cfg['db']['lib']); $sql = " - CREATE DATABASE IF NOT EXISTS `ryzom_ams_lib`; - USE `ryzom_ams_lib`; + CREATE DATABASE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`; + USE `" . $cfg['db']['lib']['name'] ."`; DROP TABLE IF EXISTS ams_querycache; CREATE TABLE ams_querycache ( `SID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `type` VARCHAR( 64 ) NOT NULL , `query` VARCHAR( 512 ) NOT NULL - ); + ); + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_category` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_category` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_category` ( + `TCategoryId` INT NOT NULL AUTO_INCREMENT , + `Name` VARCHAR(45) NOT NULL , + PRIMARY KEY (`TCategoryId`) , + UNIQUE INDEX `Name_UNIQUE` (`Name` ASC) ) + ENGINE = InnoDB; + + INSERT IGNORE INTO `" . $cfg['db']['lib']['name'] ."`.`ticket_category` (`Name`) VALUES ('Hacking'),('Ingame-Bug'),('Website-Bug'),('Installation'); + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_user` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_user` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_user` ( + `TUserId` INT(10) NOT NULL AUTO_INCREMENT , + `Permission` INT(3) NOT NULL DEFAULT 1 , + `ExternId` INT(10) NOT NULL , + PRIMARY KEY (`TUserId`) ) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket` ( + `TId` INT NOT NULL AUTO_INCREMENT , + `Timestamp` TIMESTAMP NOT NULL , + `Title` VARCHAR(120) NOT NULL , + `Status` INT NULL DEFAULT 0 , + `Queue` INT NULL DEFAULT 0 , + `Ticket_Category` INT NOT NULL , + `Author` INT NOT NULL , + PRIMARY KEY (`TId`) , + INDEX `fk_ticket_ticket_category_idx` (`Ticket_Category` ASC) , + INDEX `fk_ticket_ams_user_idx` (`Author` ASC) , + CONSTRAINT `fk_ticket_ticket_category` + FOREIGN KEY (`Ticket_Category` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_category` (`TCategoryId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_ticket_ams_user` + FOREIGN KEY (`Author` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`assigned` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`assigned` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`assigned` ( + `Ticket` INT NOT NULL , + `User` INT NOT NULL , + INDEX `fk_assigned_ticket_idx` (`Ticket` ASC) , + PRIMARY KEY (`Ticket`, `User`) , + INDEX `fk_assigned_ams_user_idx` (`User` ASC) , + CONSTRAINT `fk_assigned_ticket` + FOREIGN KEY (`Ticket` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_assigned_ams_user` + FOREIGN KEY (`User` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`tag` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`tag` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`tag` ( + `TagId` INT NOT NULL AUTO_INCREMENT , + `Value` VARCHAR(60) NOT NULL , + PRIMARY KEY (`TagId`) , + UNIQUE INDEX `Value_UNIQUE` (`Value` ASC) ) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`tagged` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`tagged` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`tagged` ( + `Ticket` INT NOT NULL , + `Tag` INT NOT NULL , + PRIMARY KEY (`Ticket`, `Tag`) , + INDEX `fk_tagged_tag_idx` (`Tag` ASC) , + CONSTRAINT `fk_tagged_ticket` + FOREIGN KEY (`Ticket` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_tagged_tag` + FOREIGN KEY (`Tag` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`tag` (`TagId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_content` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_content` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_content` ( + `TContentId` INT NOT NULL AUTO_INCREMENT , + `Content` TEXT NULL , + PRIMARY KEY (`TContentId`) ) + ENGINE = InnoDB + DEFAULT CHARACTER SET = utf8; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_reply` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_reply` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_reply` ( + `TReplyId` INT NOT NULL AUTO_INCREMENT , + `Ticket` INT NOT NULL , + `Author` INT NOT NULL , + `Content` INT NOT NULL , + `Timestamp` TIMESTAMP NULL , + PRIMARY KEY (`TReplyId`) , + INDEX `fk_ticket_reply_ticket_idx` (`Ticket` ASC) , + INDEX `fk_ticket_reply_ams_user_idx` (`Author` ASC) , + INDEX `fk_ticket_reply_content_idx` (`Content` ASC) , + CONSTRAINT `fk_ticket_reply_ticket` + FOREIGN KEY (`Ticket` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_ticket_reply_ams_user` + FOREIGN KEY (`Author` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_ticket_reply_ticket_content` + FOREIGN KEY (`Content` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_content` (`TContentId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_group` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_group` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_group` ( + `TGroupId` INT NOT NULL AUTO_INCREMENT , + `Title` VARCHAR(80) NOT NULL , + PRIMARY KEY (`TGroupId`) , + UNIQUE INDEX `Title_UNIQUE` (`Title` ASC) ) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`in_group` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`in_group` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`in_group` ( + `Ticket_Group` INT NOT NULL , + `Ticket` INT NOT NULL , + PRIMARY KEY (`Ticket_Group`, `Ticket`) , + INDEX `fk_in_group_ticket_group_idx` (`Ticket_Group` ASC) , + INDEX `fk_in_group_ticket_idx` (`Ticket` ASC) , + CONSTRAINT `fk_in_group_ticket_group` + FOREIGN KEY (`Ticket_Group` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_group` (`TGroupId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_in_group_ticket` + FOREIGN KEY (`Ticket` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + + "; $dbl->executeWithoutParams($sql); print "The Lib & Web database were correctly installed!
"; @@ -51,7 +256,7 @@ 'pass' => $hashpass, 'mail' => "admin@admin.com", ); - Users::createUser($params); + Users::createUser($params, 1); try{ $params['permission'] = 2; $dbw = new DBLayer($cfg['db']['web']); diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/sql/ticketsql.sql b/code/ryzom/tools/server/ryzom_ams/www/html/sql/ticketsql.sql new file mode 100644 index 000000000..0f22a9741 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/sql/ticketsql.sql @@ -0,0 +1,209 @@ +SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; +SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; +SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL'; + +CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ; +USE `mydb` ; + +-- ----------------------------------------------------- +-- Table `mydb`.`ticket_category` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `mydb`.`ticket_category` ; + +CREATE TABLE IF NOT EXISTS `mydb`.`ticket_category` ( + `TCategoryId` INT NOT NULL AUTO_INCREMENT , + `Name` VARCHAR(45) NOT NULL , + PRIMARY KEY (`TCategoryId`) , + UNIQUE INDEX `Name_UNIQUE` (`Name` ASC) ) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `mydb`.`ticket_user` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `mydb`.`ticket_user` ; + +CREATE TABLE IF NOT EXISTS `mydb`.`ticket_user` ( + `TUserId` INT(10) NOT NULL AUTO_INCREMENT , + `Permission` INT(3) NOT NULL DEFAULT 1 , + `ExternId` INT(10) NOT NULL , + PRIMARY KEY (`TUserId`) ) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `mydb`.`ticket` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `mydb`.`ticket` ; + +CREATE TABLE IF NOT EXISTS `mydb`.`ticket` ( + `TId` INT NOT NULL AUTO_INCREMENT , + `Timestamp` TIMESTAMP NOT NULL , + `Title` VARCHAR(120) NOT NULL , + `Status` INT NULL DEFAULT 0 , + `Queue` INT NULL DEFAULT 0 , + `Ticket_Category` INT NOT NULL , + `Author` INT NOT NULL , + PRIMARY KEY (`TId`) , + INDEX `fk_ticket_ticket_category_idx` (`Ticket_Category` ASC) , + INDEX `fk_ticket_ams_user_idx` (`Author` ASC) , + CONSTRAINT `fk_ticket_ticket_category` + FOREIGN KEY (`Ticket_Category` ) + REFERENCES `mydb`.`ticket_category` (`TCategoryId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_ticket_ams_user` + FOREIGN KEY (`Author` ) + REFERENCES `mydb`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `mydb`.`assigned` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `mydb`.`assigned` ; + +CREATE TABLE IF NOT EXISTS `mydb`.`assigned` ( + `Ticket` INT NOT NULL , + `User` INT NOT NULL , + INDEX `fk_assigned_ticket_idx` (`Ticket` ASC) , + PRIMARY KEY (`Ticket`, `User`) , + INDEX `fk_assigned_ams_user_idx` (`User` ASC) , + CONSTRAINT `fk_assigned_ticket` + FOREIGN KEY (`Ticket` ) + REFERENCES `mydb`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_assigned_ams_user` + FOREIGN KEY (`User` ) + REFERENCES `mydb`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `mydb`.`tag` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `mydb`.`tag` ; + +CREATE TABLE IF NOT EXISTS `mydb`.`tag` ( + `TagId` INT NOT NULL AUTO_INCREMENT , + `Value` VARCHAR(60) NOT NULL , + PRIMARY KEY (`TagId`) , + UNIQUE INDEX `Value_UNIQUE` (`Value` ASC) ) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `mydb`.`tagged` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `mydb`.`tagged` ; + +CREATE TABLE IF NOT EXISTS `mydb`.`tagged` ( + `Ticket` INT NOT NULL , + `Tag` INT NOT NULL , + PRIMARY KEY (`Ticket`, `Tag`) , + INDEX `fk_tagged_tag_idx` (`Tag` ASC) , + CONSTRAINT `fk_tagged_ticket` + FOREIGN KEY (`Ticket` ) + REFERENCES `mydb`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_tagged_tag` + FOREIGN KEY (`Tag` ) + REFERENCES `mydb`.`tag` (`TagId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `mydb`.`ticket_content` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `mydb`.`ticket_content` ; + +CREATE TABLE IF NOT EXISTS `mydb`.`ticket_content` ( + `TContentId` INT NOT NULL AUTO_INCREMENT , + `Content` TEXT NULL , + PRIMARY KEY (`TContentId`) ) +ENGINE = InnoDB +DEFAULT CHARACTER SET = utf8; + + +-- ----------------------------------------------------- +-- Table `mydb`.`ticket_reply` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `mydb`.`ticket_reply` ; + +CREATE TABLE IF NOT EXISTS `mydb`.`ticket_reply` ( + `TReplyId` INT NOT NULL AUTO_INCREMENT , + `Ticket` INT NOT NULL , + `Author` INT NOT NULL , + `Content` INT NOT NULL , + `Timestamp` TIMESTAMP NULL , + PRIMARY KEY (`TReplyId`) , + INDEX `fk_ticket_reply_ticket_idx` (`Ticket` ASC) , + INDEX `fk_ticket_reply_ams_user_idx` (`Author` ASC) , + INDEX `fk_ticket_reply_content_idx` (`Content` ASC) , + CONSTRAINT `fk_ticket_reply_ticket` + FOREIGN KEY (`Ticket` ) + REFERENCES `mydb`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_ticket_reply_ams_user` + FOREIGN KEY (`Author` ) + REFERENCES `mydb`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_ticket_reply_ticket_content` + FOREIGN KEY (`Content` ) + REFERENCES `mydb`.`ticket_content` (`TContentId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `mydb`.`ticket_group` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `mydb`.`ticket_group` ; + +CREATE TABLE IF NOT EXISTS `mydb`.`ticket_group` ( + `TGroupId` INT NOT NULL AUTO_INCREMENT , + `Title` VARCHAR(80) NOT NULL , + PRIMARY KEY (`TGroupId`) , + UNIQUE INDEX `Title_UNIQUE` (`Title` ASC) ) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `mydb`.`in_group` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `mydb`.`in_group` ; + +CREATE TABLE IF NOT EXISTS `mydb`.`in_group` ( + `Ticket_Group` INT NOT NULL , + `Ticket` INT NOT NULL , + PRIMARY KEY (`Ticket_Group`, `Ticket`) , + INDEX `fk_in_group_ticket_group_idx` (`Ticket_Group` ASC) , + INDEX `fk_in_group_ticket_idx` (`Ticket` ASC) , + CONSTRAINT `fk_in_group_ticket_group` + FOREIGN KEY (`Ticket_Group` ) + REFERENCES `mydb`.`ticket_group` (`TGroupId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_in_group_ticket` + FOREIGN KEY (`Ticket` ) + REFERENCES `mydb`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + + +SET SQL_MODE=@OLD_SQL_MODE; +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/sql/ticketsystemmodel.mwb b/code/ryzom/tools/server/ryzom_ams/www/html/sql/ticketsystemmodel.mwb new file mode 100644 index 000000000..53f58f037 Binary files /dev/null and b/code/ryzom/tools/server/ryzom_ams/www/html/sql/ticketsystemmodel.mwb differ diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/createticket.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/createticket.tpl new file mode 100644 index 000000000..0b2ad2813 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/createticket.tpl @@ -0,0 +1,59 @@ +{block name=content} +
+
+
+

Create a new Ticket

+
+ + +
+
+
+
+
+ New ticket + +
+ +
+
+ +
+
+
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + +
+ +
+ +
+
+
+
+
+
+
+{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/error.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/error.tpl new file mode 100644 index 000000000..375815af3 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/error.tpl @@ -0,0 +1,86 @@ + + + + + + + Error + + + +

+ {$error_code} +

+ {if $error_code eq "404"} +

{$title404}

+
+
+ {$error_message404} + {else if $error_code eq "403"} +

{$title403}

+
+
+ {$error_message403} + {/if} +
{$go_home} +
+ + + \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl index c15e668cb..32088c7b8 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl @@ -96,8 +96,7 @@
diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_admin.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_admin.tpl index b2c79ba00..cd7bc60ad 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_admin.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_admin.tpl @@ -2,9 +2,11 @@ {block name=menu}
  • Dashboard
  • +
  • Profile
  • Settings
  • Liblist
  • +
  • UserList
  • Logout
  • diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_user.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_user.tpl index 460a9b10b..8da6ca313 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_user.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_user.tpl @@ -2,9 +2,10 @@ {block name=menu}
  • Dashboard
  • +
  • Profile
  • Settings
  • -
  • Demo Userlist
  • +
  • Create New Ticket
  • Logout
  • {/block} diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl index e8dee32fd..645de53f2 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl @@ -51,9 +51,6 @@ {$id} {$type} - {$name} - {$email} - {$action} @@ -61,11 +58,7 @@ {$element.id} {$element.type} - {$element.name} - {$element.mail} - - Delete - + {/foreach} diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/register.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/register.tpl index 5a154bb92..c97323520 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/register.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/register.tpl @@ -64,7 +64,7 @@ isset($TAC) and $TAC eq "success"}success{else}{/if}">
    - {$tac_tag} + {$tac_tag1}{$tac_tag2}
    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 c0e4f7a7b..f9ad610d9 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 @@ -50,6 +50,20 @@ + + + {if isset($SUCCESS_PASS) and $SUCCESS_PASS eq "OK"} +
    + The password has been changed! +
    + {/if} + + {if isset($SUCCESS_PASS) and $SUCCESS_PASS eq "SHARDOFF"} +
    + The password has been changed, though the shard seems offline, it may take some time to see the change on the shard. +
    + {/if} +
    @@ -73,18 +87,34 @@
    -
    + Change Email -
    +
    - -
    + + {if isset($EMAIL_ERROR) and $EMAIL_ERROR eq "TRUE"}{$EMAIL}{/if} + +
    -
    - +
    + + {if isset($SUCCESS_MAIL) and $SUCCESS_MAIL eq "OK"} +
    + The email has been changed! +
    + {/if} + + {if isset($SUCCESS_MAIL) and $SUCCESS_MAIL eq "SHARDOFF"} +
    + The email has been changed, though the shard seems offline, it may take some time to see the change on the shard. +
    + {/if} + + +
    @@ -106,7 +136,7 @@
    - + Change Info
    @@ -114,7 +144,7 @@
    - +
    @@ -124,7 +154,7 @@
    - +
    @@ -132,257 +162,10 @@
    - + {foreach from=$country_array key=k item=v} + + {/foreach}
    @@ -391,24 +174,30 @@
    - - + {if isset($info_updated) and $info_updated eq "OK"} +
    + The Info has been updated! +
    + {/if} + + +
    diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_user.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_user.tpl new file mode 100644 index 000000000..0b2a57c2b --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_user.tpl @@ -0,0 +1,117 @@ +{block name=content} +
    +
    +
    +

    Profile of {$target_name}

    +
    + + +
    +
    +
    +
    + Info + + + + + + + {if $firstName neq ""} + + + + + {/if} + {if $lastName neq ""} + + + + + {/if} + {if $country neq ""} + + + + + {/if} + {if $gender neq 0} + + + {if $gender eq 1} + + {else if $gender eq 2} + + {/if} + + {/if} + +
    Email:{$mail}
    Firstname:{$firstName}
    LastName:{$lastName}
    Country:{$country}
    Gender:♂♀
    +
    +
    +
    + +
    +
    +

    Actions

    +
    + + +
    +
    +
    +
    +
    + + +
    +
    +
    +
    +
    + +
    +
    +
    +

    Tickets of {$target_name}

    +
    + + +
    +
    +
    +
    + Tickets + + + + + + + + + + + {foreach from=$ticketlist item=ticket} + + + + + + + + {/foreach} + + +
    TitleTimestampCategoryStatus
    {$ticket.title}{$ticket.timestamp}{$ticket.category}{$ticket.statusText}
    +
    +
    +
    +
    +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl index 891bbd04b..d09c46abe 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/userlist.tpl @@ -1,22 +1,46 @@ {block name=content} - -
    -
    -
    -

    {$userlist_info}

    -
    - - - - -
    -
    -
    -

    The shard/lib/web db user list You are about to see it here!

    - -
    -
    -
    -
    +
    +
    +
    +

    Members

    +
    + + + +
    +
    +
    + + + + + + + + + + + + {foreach from=$userlist item=element} + + + + + {if $element.permission eq 1}{/if} + {if $element.permission eq 2}{/if} + + + + {/foreach} + + +
    IdUsernameEmailPermissionAction
    {$element.id}{$element.username}{$element.email}UserAdmin + Show User + Edit User +
    +
    +
    + +
    {/block}