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..ff2412b16 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket.php @@ -0,0 +1,89 @@ +db = $db_data; + } + + + //Set ticket object + public function setTicket($ts,$t,$s,$q,$t_c,$a){ + $this->timestamp = $ts; + $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 (: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); + $dbl->execute($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 getPermission(){ + return $this->permission; + } + + + public function getExternId(){ + return $this->externId; + } + + + public function getTUserId(){ + return $this->tUserId; + } + + //setters + public function setPermission($perm){ + $this->permission = $perm; + } + + + public function setExternId($id){ + $this->externId = $id; + } + + + public function setTUserId($id){ + $this->tUserId = $id; + } +} \ 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..2de93a867 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_category.php @@ -0,0 +1,70 @@ +db = $db_data; + } + + + //Creates a ticket_Catergory in the DB + public static function createTicketCategory( $name ,$db ) { + $dbl = new DBLayer($db); + $query = "INSERT INTO ticket_category (Name) VALUES (:name)"; + $values = Array('name' => $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; + + } + + //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(); + $instance->tCategoryId = $row['TCategoryId']; + $instance->name = $row['Name']; + return $instance; + } + + //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; + } + + +} \ 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..544f047b9 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_user.php @@ -0,0 +1,100 @@ +db = $db_data; + } + + + //Creates a ticket_user in the DB + public static function createTicketUser( $extern_id, $permission,$db ) { + $dbl = new DBLayer($db); + $query = "INSERT INTO ticket_user (Permission, ExternId) VALUES (:perm, :ext_id)"; + $values = Array('perm' => $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 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; + } + + + //return constructed element based on ExternId + public static function constr_ExternId( $id, $db_data ) { + $instance = new self($db_data); + $dbl = new DBLayer($this->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; + + } + + + //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/www/html/sql/install.php b/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php index a20bdc20a..e233bb322 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 @@ -58,17 +58,17 @@ 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` ( - `UId` INT(10) NOT NULL AUTO_INCREMENT , + `TUserId` INT(10) NOT NULL AUTO_INCREMENT , `Permission` INT(3) NOT NULL DEFAULT 1 , - `Extern_Id` INT(10) NOT NULL , - PRIMARY KEY (`UId`) ) + `ExternId` INT(10) NOT NULL , + PRIMARY KEY (`TUserId`) ) ENGINE = InnoDB; @@ -95,7 +95,7 @@ ON UPDATE NO ACTION, CONSTRAINT `fk_ticket_ams_user` FOREIGN KEY (`Author` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`UId` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; @@ -119,7 +119,7 @@ ON UPDATE NO ACTION, CONSTRAINT `fk_assigned_ams_user` FOREIGN KEY (`User` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`UId` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; @@ -196,7 +196,7 @@ ON UPDATE NO ACTION, CONSTRAINT `fk_ticket_reply_ams_user` FOREIGN KEY (`Author` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`UId` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_ticket_reply_ticket_content` @@ -244,6 +244,7 @@ ENGINE = InnoDB; + "; $dbl->executeWithoutParams($sql); print "The Lib & Web database were correctly installed!
"; 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 index 67b5112ec..0f22a9741 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/sql/ticketsql.sql +++ b/code/ryzom/tools/server/ryzom_ams/www/html/sql/ticketsql.sql @@ -24,10 +24,10 @@ ENGINE = InnoDB; DROP TABLE IF EXISTS `mydb`.`ticket_user` ; CREATE TABLE IF NOT EXISTS `mydb`.`ticket_user` ( - `UId` INT(10) NOT NULL AUTO_INCREMENT , + `TUserId` INT(10) NOT NULL AUTO_INCREMENT , `Permission` INT(3) NOT NULL DEFAULT 1 , - `Extern_Id` INT(10) NOT NULL, - PRIMARY KEY (`UId`) ) + `ExternId` INT(10) NOT NULL , + PRIMARY KEY (`TUserId`) ) ENGINE = InnoDB; @@ -54,7 +54,7 @@ CREATE TABLE IF NOT EXISTS `mydb`.`ticket` ( ON UPDATE NO ACTION, CONSTRAINT `fk_ticket_ams_user` FOREIGN KEY (`Author` ) - REFERENCES `mydb`.`ticket_user` (`UId` ) + REFERENCES `mydb`.`ticket_user` (`TUserId` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; @@ -78,7 +78,7 @@ CREATE TABLE IF NOT EXISTS `mydb`.`assigned` ( ON UPDATE NO ACTION, CONSTRAINT `fk_assigned_ams_user` FOREIGN KEY (`User` ) - REFERENCES `mydb`.`ticket_user` (`UId` ) + REFERENCES `mydb`.`ticket_user` (`TUserId` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; @@ -155,7 +155,7 @@ CREATE TABLE IF NOT EXISTS `mydb`.`ticket_reply` ( ON UPDATE NO ACTION, CONSTRAINT `fk_ticket_reply_ams_user` FOREIGN KEY (`Author` ) - REFERENCES `mydb`.`ticket_user` (`UId` ) + REFERENCES `mydb`.`ticket_user` (`TUserId` ) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_ticket_reply_ticket_content` 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 index ba70ad4b2..53f58f037 100644 Binary files a/code/ryzom/tools/server/ryzom_ams/www/html/sql/ticketsystemmodel.mwb and b/code/ryzom/tools/server/ryzom_ams/www/html/sql/ticketsystemmodel.mwb differ