From a42443054e814a82a2a9b5f238c222cfabd1ed05 Mon Sep 17 00:00:00 2001 From: Quitta Date: Sat, 6 Jul 2013 22:38:57 +0200 Subject: [PATCH] Creation of a ticket (not the content yet though) seems to work --- .../ryzom_ams/ams_lib/autoload/ticket.php | 7 ++- .../www/html/func/change_password.php | 1 + .../ryzom_ams/www/html/func/create_ticket.php | 51 +++++++++++++++++++ .../ryzom_ams/www/html/inc/createticket.php | 47 ++++++++++++++--- .../www/html/templates/createticket.tpl | 2 +- 5 files changed, 95 insertions(+), 13 deletions(-) create mode 100644 code/ryzom/tools/server/ryzom_ams/www/html/func/create_ticket.php 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 index 62461e33f..ac91bbc39 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket.php @@ -16,8 +16,7 @@ class Ticket{ //Set ticket object - public function setTicket($ts,$t,$s,$q,$t_c,$a){ - $this->timestamp = $ts; + public function setTicket($t,$s,$q,$t_c,$a){ $this->title = $t; $this->status = $s; $this->queue = $q; @@ -28,8 +27,8 @@ class Ticket{ //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 (:timestamp, :title, :status, :queue, :tcat, :author)"; - $values = Array('timestamp' => $this->timestamp, 'title' => $this->title, 'status' => $this->status, 'queue' => $this->queue, 'tcat' => $this->ticket_category, 'author' => $this->author); + $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); $dbl->execute($query, $values); } 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 e13e859c3..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 @@ -42,6 +42,7 @@ function change_password(){ exit; }else{ + $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); 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..628bb9ca8 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/create_ticket.php @@ -0,0 +1,51 @@ +getTUserId(); + }else{ + $author= Ticket_User::constr_ExternId($_POST['target_id'], $cfg['db']['lib'])->getTUserId(); + } + $ticket = new Ticket($cfg['db']['lib']); + $ticket->setTicket($title,0,0,$category,$author); + $ticket->create(); + + }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/inc/createticket.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/createticket.php index 4f83b4631..4647bbfaf 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/createticket.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/createticket.php @@ -1,14 +1,45 @@ getTCategoryId()] = $catObj->getName(); + } + + return $result; - //create array of category id & names - global $cfg; - $catArray = Ticket_Category::getAllCategories($cfg['db']['lib']); - $result['category'] = Array(); - foreach($catArray as $catObj){ - $result['category'][$catObj->getTCategoryId()] = $catObj->getName(); + }else{ + //ERROR: not logged in! + header("Location: index.php"); + exit; } - //print_r($result); - return $result; + } \ No newline at end of file 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 index eb0fb45f1..fac2edb81 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/createticket.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/createticket.tpl @@ -42,7 +42,7 @@ - +