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
This commit is contained in:
2014-11-20 14:02:46 +00:00
parent 6b9198f27c
commit 8e772f8418

View File

@@ -138,9 +138,9 @@ class authzgroups
"comment"=>array ("varchar", "255")); "comment"=>array ("varchar", "255"));
$this->dbGroup->primary = "idgroup"; $this->dbGroup->primary = "idgroup";
$this->dbGroup->unique = array ("idgroup", array ("module","group")); $this->dbGroup->unique = array ("idgroup", array ("module","group"));
$this->dbGroup->titles = array ("idobject"=>_("idobject"), $this->dbGroup->titles = array ("idgroup"=>_("idgroup"),
"module"=>_("Module"), "module"=>_("Module"),
"object"=>_("Object"), "group"=>_("Group"),
"comment"=>_("Comment")); "comment"=>_("Comment"));
$this->dbGroupMember = new dblayer ($dsn, $username, $password, $this->dbGroupMember = new dblayer ($dsn, $username, $password,
@@ -299,6 +299,19 @@ class authzgroups
return $this->dbGroup->delete ($idgroups[0]["idgroup"]); 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 */ /** Update an group in the database */
public function groupUpdate ($module, $group, $newgroup, $comment="") public function groupUpdate ($module, $group, $newgroup, $comment="")
{ {
@@ -313,6 +326,20 @@ class authzgroups
array ("group"=>$newgroup, array ("group"=>$newgroup,
"comment"=>$comment)); "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 */ /** Return an array with all the available groups in the module */
public function groupRead ($module, $group=null) public function groupRead ($module, $group=null)
@@ -326,6 +353,29 @@ class authzgroups
return $this->dbGroup->read ($select); 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 // // GROUP MEMBER //
////////////////////// //////////////////////