From 14e7ccc08f17295ed36f9bbf9e10a56cac096bbf Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Thu, 20 Nov 2014 15:54:23 +0000 Subject: [PATCH] authzgroups : add ByID in object Del/update support git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1871 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- authzgroups.php | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/authzgroups.php b/authzgroups.php index e5191d5..3357e37 100644 --- a/authzgroups.php +++ b/authzgroups.php @@ -246,6 +246,19 @@ class authzgroups return $this->dbObject->delete ($idobjects[0]["idobject"]); } + /** Remove an object from database and all the rights using it */ + public function objectDelByID ($module, $idobject) + { + if ($this->dbObject == null) + throw new Exception (dgettext ("domframework", + "DB for Object is not connected"), 500); + $idobjects = $this->objectReadByID ($module, $idobject); + if (! isset ($idobjects[0]["idobject"])) + throw new Exception (dgettext ("domframework", + "Wanted object not found"), 404); + return $this->dbObject->delete ($idobjects[0]["idobject"]); + } + /** Update an object in the database */ public function objectUpdate ($module, $object, $newobject, $newcomment="") { @@ -261,6 +274,22 @@ class authzgroups "comment"=>$newcomment)); } + /** Update an object in the database */ + public function objectUpdateByID ($module, $idobject, $newobject, + $newcomment="") + { + if ($this->dbObject == null) + throw new Exception (dgettext ("domframework", + "DB for Object is not connected"), 500); + $idobjects = $this->objectReadByID ($module, $idobject); + if (! isset ($idobjects[0]["idobject"])) + throw new Exception (dgettext ("domframework", + "Wanted object not found"), 404); + return $this->dbObject->update ($idobjects[0]["idobject"], + array ("object"=>$newobject, + "comment"=>$newcomment)); + } + /** Return an array with all the available objects in the module, or only one object if $object is provided */ public function objectRead ($module, $object=null) @@ -274,6 +303,19 @@ class authzgroups return $this->dbObject->read ($select); } + /** Return an array with all the available objects in the module, or only + one object if $object is provided */ + public function objectReadByID ($module, $idobject=null) + { + if ($this->dbObject == null) + throw new Exception (dgettext ("domframework", + "DB for Object is not connected"), 500); + $select[] = array ("module", $module); + if ($idobject !== null) + $select[] = array ("idobject", $idobject); + return $this->dbObject->read ($select); + } + /** Return an array containing the titles of the table translating in the user language */ public function objectTitles ()