From 8e772f84180f27306839456e9a8f22aea6f36434 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Thu, 20 Nov 2014 14:02:46 +0000 Subject: [PATCH] authzgroups : Add ByID support in place of unique group support by name git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1868 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- authzgroups.php | 54 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/authzgroups.php b/authzgroups.php index cab578c..d11cb46 100644 --- a/authzgroups.php +++ b/authzgroups.php @@ -138,9 +138,9 @@ class authzgroups "comment"=>array ("varchar", "255")); $this->dbGroup->primary = "idgroup"; $this->dbGroup->unique = array ("idgroup", array ("module","group")); - $this->dbGroup->titles = array ("idobject"=>_("idobject"), + $this->dbGroup->titles = array ("idgroup"=>_("idgroup"), "module"=>_("Module"), - "object"=>_("Object"), + "group"=>_("Group"), "comment"=>_("Comment")); $this->dbGroupMember = new dblayer ($dsn, $username, $password, @@ -299,6 +299,19 @@ class authzgroups return $this->dbGroup->delete ($idgroups[0]["idgroup"]); } + /** Remove an group from database and all the rights using it */ + public function groupDelByID ($module, $idgroup) + { + if ($this->dbGroup == null) + throw new Exception (dgettext ("domframework", + "DB for Group is not connected"), 500); + $idgroups = $this->groupReadByID ($module, $idgroup); + if (! isset ($idgroups[0]["idgroup"])) + throw new Exception (dgettext ("domframework", + "Wanted group not found"), 404); + return $this->dbGroup->delete ($idgroups[0]["idgroup"]); + } + /** Update an group in the database */ public function groupUpdate ($module, $group, $newgroup, $comment="") { @@ -313,6 +326,20 @@ class authzgroups array ("group"=>$newgroup, "comment"=>$comment)); } + /** Update an group in the database */ + public function groupUpdateByID ($module, $idgroup, $newgroup, $comment="") + { + if ($this->dbGroup == null) + throw new Exception (dgettext ("domframework", + "DB for Group is not connected"), 500); + $idgroups = $this->groupReadByID ($module, $idgroup); + if (! isset ($idgroups[0]["idgroup"])) + throw new Exception (dgettext ("domframework", + "Wanted group not found"), 404); + return $this->dbGroup->update ($idgroups[0]["idgroup"], + array ("group"=>$newgroup, + "comment"=>$comment)); + } /** Return an array with all the available groups in the module */ public function groupRead ($module, $group=null) @@ -326,6 +353,29 @@ class authzgroups return $this->dbGroup->read ($select); } + public function groupReadByID ($module, $idgroup) + { + if ($this->dbGroup == null) + throw new Exception (dgettext ("domframework", + "DB for Group is not connected"), 500); + $select[] = array ("module", $module); + $select[] = array ("idgroup", $idgroup); + return $this->dbGroup->read ($select); + } + + /** Return an array containing the titles of the table translating in the user + language */ + public function groupTitles () + { + return $this->dbGroup->titles; + } + + /** Check if the provided datas are compilant with the group specification + @return array The errors found in the datas */ + public function groupVerify ($datas) + { + return $this->dbGroup->verify ($datas); + } ////////////////////// // GROUP MEMBER // //////////////////////