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 // /////////////////