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
This commit is contained in:
@@ -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 //
|
||||
/////////////////
|
||||
|
||||
Reference in New Issue
Block a user