diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/support_group.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/support_group.php index 6c3350bcb..ab0f29c75 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/support_group.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/support_group.php @@ -105,7 +105,20 @@ class Support_Group{ return $result; } - + //wrapper for adding user to a support group + public static function deleteSupportGroup($group_id) { + + //check if group id exists + if (self::supportGroup_Exists($group_id)){ + $sGroup = new self(); + $sGroup->setSGroupId($group_id); + $sGroup->delete(); + }else{ + //return that group doesn't exist + return "GROUP_NOT_EXISTING"; + } + + } //wrapper for adding user to a support group public static function deleteUserOfSupportGroup( $user_id, $group_id) { @@ -184,7 +197,7 @@ class Support_Group{ //Load with sGroupId public function load_With_SGroupId( $id) { $dbl = new DBLayer("lib"); - $statement = $dbl->execute("SELECT * FROM ticket_log WHERE TLogId=:id", array('id' => $id)); + $statement = $dbl->execute("SELECT * FROM `support_group` WHERE `SGroupId` = :id", array('id' => $id)); $row = $statement->fetch(); $this->set($row); } @@ -193,11 +206,19 @@ class Support_Group{ //update private data to DB. public function update(){ $dbl = new DBLayer("lib"); - $query = "UPDATE ticket_log SET Timestamp = :timestamp, Query = :query, Author = :author, Ticket = :ticket WHERE TLogId=:id"; - $values = Array('id' => $this->getTLogId(), 'timestamp' => $this->getTimestamp(), 'query' => $this->getQuery(), 'author' => $this->getAuthor(), 'ticket' => $this->getTicket() ); + $query = "UPDATE `support_group` SET `Name` = :name, `Tag` = :tag WHERE `SGroupId` = :id"; + $values = Array('id' => $this->getSGroupId(), 'name' => $this->getName(), 'tag' => $this->getTag() ); $statement = $dbl->execute($query, $values); } + //delete entry + public function delete(){ + $dbl = new DBLayer("lib"); + $query = "DELETE FROM `support_group` WHERE `SGroupId` = :id"; + $values = Array('id' => $this->getSGroupId()); + $statement = $dbl->execute($query, $values); + } + ////////////////////////////////////////////Getters//////////////////////////////////////////////////// public function getSGroupId(){ diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/sgroup_list.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/sgroup_list.php index 061fa3daf..236d62b7c 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/sgroup_list.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/sgroup_list.php @@ -4,6 +4,13 @@ function sgroup_list(){ //if logged in if(WebUsers::isLoggedIn()){ if( WebUsers::isAdmin()){ + + if(isset($_GET['delete'])){ + $delete_id = filter_var($_GET['delete'], FILTER_SANITIZE_NUMBER_INT); + $result['delete'] = Support_Group::deleteSupportGroup( $delete_id); + header("Location: index.php?page=sgroup_list"); + exit; + } $result['grouplist'] = Gui_Elements::make_table(Support_Group::getGroups(), Array("getSGroupId","getName","getTag"), Array("sGroupId","name","tag")); return $result; }else{ diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_sgroup.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_sgroup.php index 5b4767e4b..6b414cbb3 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_sgroup.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_sgroup.php @@ -6,12 +6,13 @@ function show_sgroup(){ if( WebUsers::isAdmin()){ if( isset($_GET['id'])){ + //['target_id'] holds the id of the group! $result['target_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT); if(isset($_GET['delete'])){ $delete_id = filter_var($_GET['delete'], FILTER_SANITIZE_NUMBER_INT); $result['delete'] = Support_Group::deleteUserOfSupportGroup( $delete_id, $result['target_id'] ); - header("Location: index.php?page=show_sgroup&id=1"); + header("Location: index.php?page=show_sgroup&id=" . $result['target_id']); exit; } 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 6f4f3004c..c8cf05b69 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 @@ -307,7 +307,7 @@ CONSTRAINT `fk_in_support_group_support_group1` FOREIGN KEY (`Group` ) REFERENCES `" . $cfg['db']['lib']['name'] ."`.`support_group` (`SGroupId` ) - ON DELETE NO ACTION + ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; 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 786e8e873..137a823c3 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 @@ -264,7 +264,7 @@ CREATE TABLE IF NOT EXISTS `mydb`.`in_support_group` ( CONSTRAINT `fk_in_support_group_support_group1` FOREIGN KEY (`Group` ) REFERENCES `mydb`.`support_group` (`SGroupId` ) - ON DELETE NO ACTION + ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; 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 5a500c989..a605c7a19 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 diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/sgroup_list.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/sgroup_list.tpl index 564d5890d..48ba87bfc 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/sgroup_list.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/sgroup_list.tpl @@ -28,7 +28,7 @@