From d715e0009518fd0289996aa0bd175a715f1f77f7 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Thu, 17 Jan 2019 12:55:50 +0000 Subject: [PATCH] authzgroupsoo : Get the state of the tables, allow to delete the tables and allow to use a tableprefix git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4859 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- authzgroupsoo.php | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/authzgroupsoo.php b/authzgroupsoo.php index 74d37f3..c40c122 100644 --- a/authzgroupsoo.php +++ b/authzgroupsoo.php @@ -300,7 +300,7 @@ class authzgroupsoo $this->dbGroupMember->unique (array ("idgroupmember", array ("user","idgroup"))); $this->dbGroupMember->foreign (array ( - "idgroup" => array ("authzgroup", "idgroup", + "idgroup" => array ($this->tableprefix."authzgroup", "idgroup", "ON UPDATE CASCADE ON DELETE CASCADE"))); $this->dbGroupMember->setForeignObj ($this->dbGroup); $this->dbGroupMember->titles (array ( @@ -323,9 +323,9 @@ class authzgroupsoo $this->dbRight->primary ("idright"); $this->dbRight->unique (array ("idright", array ("idgroup","idobject"))); $this->dbRight->foreign (array ( - "idgroup" => array ("authzgroup", "idgroup", + "idgroup" => array ($this->tableprefix."authzgroup", "idgroup", "ON UPDATE CASCADE ON DELETE CASCADE"), - "idobject" => array ("authzobject", "idobject", + "idobject" => array ($this->tableprefix."authzobject", "idobject", "ON UPDATE CASCADE ON DELETE CASCADE"), )); $this->dbRight->setForeignObj ($this->dbGroup); @@ -379,6 +379,42 @@ class authzgroupsoo return TRUE; } + /** Return true if all the tables are created, false otherwise + */ + public function stateTables () + { + if ($this->dbObject == null) + throw new \Exception (dgettext ("domframework", + "DB for Object is not connected"), 500); + $tables = $this->dbObject->listTables (); + $needed = array ("authzobject", "authzgroup", "authzgroupmember", + "authzright"); + foreach ($needed as $table) + { + if (! in_array ($this->tableprefix.$table, $tables)) + return false; + } + return true; + } + + /** Return true if all the tables are deleted, false otherwise + */ + public function deleteTables () + { + if ($this->dbObject == null) + throw new \Exception (dgettext ("domframework", + "DB for Object is not connected"), 500); + $tables = $this->dbObject->listTables (); + $needed = array ("Object", "Group", "GroupMember", "Right"); + $needed = array_reverse ($needed); + foreach ($needed as $table) + { + $class= "db$table"; + $this->$class->dropTable (); + } + return true; + } + ///////////////// // OBJECTS // /////////////////