DomCI : Update all the PHPDoc

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3279 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2016-12-09 14:47:48 +00:00
parent b102168208
commit b55ea95fae
21 changed files with 953 additions and 424 deletions

View File

@@ -9,12 +9,17 @@ require_once ("domframework/dblayer.php");
user by its groups membership */
class authzgroups
{
/** The table prefix to use */
public $tableprefix = "";
/** The dblayer object use to manage the Object table */
private $dbObject = null;
/** The dblayer object use to manage the Group table */
private $dbGroup = null;
/** The dblayer object use to manage the GroupMember table */
private $dbGroupMember = null;
/** The dblayer object use to manage the Right table */
private $dbRight = null;
/** Set the debug level */
public $debug = 0;
/** A local cache of the rights if multiple tests are needed */
private $rightCache = null;
@@ -23,8 +28,11 @@ class authzgroups
// USER RIGHTS //
/////////////////////
/** Return an array with all the rights of the user in the module.
Cache this information to be quicker with next requests
Remove the entries where path is not at least readable */
* Cache this information to be quicker with next requests
* Remove the entries where path is not at least readable
* @param string $module The module to use
* @param string $user The user to get the rights
*/
public function userrightsget ($module, $user)
{
// if (isset ($_SESSION["domframework"]["authzgroups"][$module][$user]))
@@ -103,7 +111,11 @@ class authzgroups
return $res;
}
/** Return the right defined for this user in the module for one object */
/** Return the right defined for this user in the module for one object
* @param string $module The module to use
* @param string $user The user to get the rights
* @param string $object The object to return the rights for the user
*/
public function allow ($module, $user, $object)
{
$ressource = $this->userrightsget ($module, $user);
@@ -133,8 +145,12 @@ class authzgroups
}
/** Return TRUE if the user right allow to see the object (RO or RW)
Return a 403 Exception if the user don't have the right
Return a 401 Exception if the user is not connected */
* Return a 403 Exception if the user don't have the right
* Return a 401 Exception if the user is not connected
* @param string $module The module to use
* @param string $user The user to get the rights
* @param string $object The object to check the rights for the user
*/
public function accessRight ($module, $user, $object)
{
if ($this->dbObject === null)
@@ -164,8 +180,12 @@ class authzgroups
}
/** Return TRUE if the user right allow to edit the object (RW only)
Return a 403 Exception if the user don't have the right
Return a 401 Exception if the user is not connected */
* Return a 403 Exception if the user don't have the right
* Return a 401 Exception if the user is not connected
* @param string $module The module to use
* @param string $user The user to get the rights
* @param string $object The object to check the rights for the user
*/
public function accessWrite ($module, $user, $object)
{
if ($this->dbObject === null)
@@ -196,9 +216,13 @@ class authzgroups
}
/** Return TRUE if the user right allow to see but without modification
the object (RO only)
Return a 403 Exception if the user don't have the right
Return a 401 Exception if the user is not connected */
* the object (RO only)
* Return a 403 Exception if the user don't have the right
* Return a 401 Exception if the user is not connected
* @param string $module The module to use
* @param string $user The user to get the rights
* @param string $object The object to check the rights for the user
*/
public function accessReadOnly ($module, $user, $object)
{
if ($this->dbObject === null)
@@ -226,10 +250,18 @@ class authzgroups
401);
throw new Exception (dgettext("domframework", "Access forbidden"), 403);
}
/////////////////////////
// DATABASE STORAGE //
/////////////////////////
/** Connect to the database before using it */
/** Connect to the database before using it
* @param string $dsn The DSN to use to connect to the database
* @param string|null $username The username to use to connect to the
* database
* @param string|null $password The password to use to connect to the
* database
* @param array|null $driver_options The options to pass to PDO driver
*/
public function connect ($dsn, $username=null, $password=null,
$driver_options=null)
{
@@ -329,13 +361,15 @@ class authzgroups
return TRUE;
}
/** Disconnect from the database. Should be only used in the unit tests */
/** Disconnect from the database. Should be only used in the unit tests
*/
public function disconnect ()
{
$this->dbObject->disconnect ();
}
/** Create the tables in the database to store the data */
/** Create the tables in the database to store the data
*/
public function createTables ()
{
if ($this->dbObject == null)
@@ -371,7 +405,11 @@ class authzgroups
// OBJECTS //
/////////////////
/** Add a new object to object list
Return the idobject created */
* Return the idobject created
* @param string $module The module to use
* @param string $object The object to create
* @param string|null $comment The comment to save
*/
public function objectAdd ($module, $object, $comment="")
{
if ($this->dbObject == null)
@@ -384,7 +422,10 @@ class authzgroups
"comment"=>$comment));
}
/** Remove an object from database and all the rights using it */
/** Remove an object from database and all the rights using it
* @param string $module The module to use
* @param string $object The object to delete
*/
public function objectDel ($module, $object)
{
if ($this->dbObject == null)
@@ -398,7 +439,10 @@ class authzgroups
return $this->dbObject->delete ($idobjects[0]["idobject"]);
}
/** Remove an object from database and all the rights using it */
/** Remove an object from database and all the rights using it
* @param string $module The module to use
* @param integer $idobject The object to delete
*/
public function objectDelByID ($module, $idobject)
{
if ($this->dbObject == null)
@@ -412,7 +456,12 @@ class authzgroups
return $this->dbObject->delete ($idobjects[0]["idobject"]);
}
/** Update an object in the database */
/** Update an object in the database
* @param string $module The module to use
* @param string $object The object to update
* @param string $newobject The new name of the object
* @param string|null $newcomment The new comment of the object
*/
public function objectUpdate ($module, $object, $newobject, $newcomment="")
{
if ($this->dbObject == null)
@@ -428,7 +477,12 @@ class authzgroups
"comment"=>$newcomment));
}
/** Update an object in the database */
/** Update an object in the database
* @param string $module The module to use
* @param integer $idobject The object to update
* @param string $newobject The new name of the object
* @param string|null $newcomment The new comment of the object
*/
public function objectUpdateByID ($module, $idobject, $newobject,
$newcomment="")
{
@@ -446,7 +500,10 @@ class authzgroups
}
/** Return an array with all the available objects in the module, or only
one object if $object is provided */
* one object if $object is provided
* @param string $module The module to use
* @param string $object The name of the object to get
*/
public function objectRead ($module, $object=null)
{
if ($this->dbObject == null)
@@ -459,7 +516,10 @@ class authzgroups
}
/** Return an array with all the available objects in the module, or only
one object if $object is provided */
* one object if $object is provided
* @param string $module The module to use
* @param integer $idobject The name of the object to get
*/
public function objectReadByID ($module, $idobject=null)
{
if ($this->dbObject == null)
@@ -472,14 +532,18 @@ class authzgroups
}
/** Return an array containing the titles of the table translating in the user
language */
* language
*/
public function objectTitles ()
{
return $this->dbObject->titles;
}
/** Check if the provided data are compilant with the object specification
@return array The errors found in the data */
/** Check if the provided data are compliant with the object specification
* @param array $data The name of the object to get
* @param integer|null $idobject The object to check
* @return array The errors found in the data
*/
public function objectVerify ($data, $idobject=false)
{
return $this->dbObject->verify ($data, $idobject);
@@ -489,7 +553,11 @@ class authzgroups
// GROUPS //
////////////////
/** Add a new group to group list
Return the idgroup created */
* Return the idgroup created
* @param string $module The module to use
* @param string $group The group to create
* @param string|null $comment The comment to add with the group
*/
public function groupAdd ($module, $group, $comment="")
{
if ($this->dbGroup == null)
@@ -501,7 +569,10 @@ class authzgroups
"comment"=>$comment));
}
/** Remove an group from database and all the rights using it */
/** Remove an group from database and all the rights using it
* @param string $module The module to use
* @param string $group The group to delete
*/
public function groupDel ($module, $group)
{
if ($this->dbGroup == null)
@@ -514,7 +585,10 @@ class authzgroups
return $this->dbGroup->delete ($idgroups[0]["idgroup"]);
}
/** Remove an group from database and all the rights using it */
/** Remove an group from database and all the rights using it
* @param string $module The module to use
* @param integer $idgroup The group to delete
*/
public function groupDelByID ($module, $idgroup)
{
if ($this->dbGroup == null)
@@ -527,7 +601,12 @@ class authzgroups
return $this->dbGroup->delete ($idgroups[0]["idgroup"]);
}
/** Update an group in the database */
/** Update an group in the database
* @param string $module The module to use
* @param string $group The group to update
* @param string $newgroup The new group name
* @param string|null $comment The comment for the group
*/
public function groupUpdate ($module, $group, $newgroup, $comment="")
{
if ($this->dbGroup == null)
@@ -541,7 +620,13 @@ class authzgroups
array ("group"=>$newgroup,
"comment"=>$comment));
}
/** Update an group in the database */
/** Update an group in the database
* @param string $module The module to use
* @param integer $idgroup The group to update
* @param string $newgroup The new group name
* @param string|null $comment The comment for the group
*/
public function groupUpdateByID ($module, $idgroup, $newgroup, $comment="")
{
if ($this->dbGroup == null)
@@ -556,7 +641,10 @@ class authzgroups
"comment"=>$comment));
}
/** Return an array with all the available groups in the module */
/** Return an array with all the available groups in the module
* @param string $module The module to use
* @param string|null $group The group to check if exists
*/
public function groupRead ($module, $group=null)
{
if ($this->dbGroup == null)
@@ -568,6 +656,11 @@ class authzgroups
return $this->dbGroup->read ($select, null, array (array ("group", "ASC")));
}
/** Return an array with all the available groups in the module
* @param string $module The module to use
* @param integer $idgroup The group to check if exists
*/
public function groupReadByID ($module, $idgroup)
{
if ($this->dbGroup == null)
@@ -579,14 +672,18 @@ class authzgroups
}
/** Return an array containing the titles of the table translating in the user
language */
* language
*/
public function groupTitles ()
{
return $this->dbGroup->titles;
}
/** Check if the provided data are compilant with the group specification
@return array The errors found in the data */
* @param array $data The data to check
* @param integer|null $idgroup The idgroup to check
* @return array The errors found in the data
*/
public function groupVerify ($data, $idgroup=false)
{
return $this->dbGroup->verify ($data, $idgroup);
@@ -596,7 +693,12 @@ class authzgroups
// GROUP MEMBER //
//////////////////////
/** Add a new groupmember to groupmember list
Return the idgroupmember created */
* Return the idgroupmember created
* @param string $module The module to use
* @param string $group The group to use
* @param string $user The user to add in group
* @param string|null $comment The comment to save
*/
public function groupmemberAdd ($module, $group, $user, $comment="")
{
if ($this->dbGroupMember == null)
@@ -614,7 +716,11 @@ class authzgroups
"comment"=>$comment));
}
/** Remove an groupmember from database and all the rights using it */
/** Remove an groupmember from database and all the rights using it
* @param string $module The module to use
* @param string $group The group to use
* @param string $user The user to remove
*/
public function groupmemberDel ($module, $group, $user)
{
if ($this->dbGroupMember == null)
@@ -635,7 +741,11 @@ class authzgroups
return $this->dbGroupMember->delete ($groupsMembers[0]["idgroupmember"]);
}
/** Remove an groupmember from database and all the rights using it */
/** Remove an groupmember from database and all the rights using it
* @param string $module The module to use
* @param integer $idgroup The group to use
* @param integer $idgroupmember The user to remove
*/
public function groupmemberDelByID ($module, $idgroup, $idgroupmember)
{
if ($this->dbGroupMember == null)
@@ -656,14 +766,25 @@ class authzgroups
return $this->dbGroupMember->delete ($groupsMembers[0]["idgroupmember"]);
}
/** Update an groupmember in the database */
/** Update an groupmember in the database
* @param string $module The module to use
* @param string $group The group to use
* @param string $user The user to update
* @param string|null $comment The comment to update
*/
public function groupmemberUpdate ($module, $group, $user, $comment="")
{
$this->rightCache = null;
die ("This function is not available : contact us if you need it\n");
}
/** Update an groupmember in the database */
/** Update an groupmember in the database
* @param string $module The module to use
* @param integer $idgroup The group to use
* @param integer $iduser The user to update
* @param string $user The new user name
* @param string|null $comment The comment to update
*/
public function groupmemberUpdateByID ($module, $idgroup, $iduser, $user,
$comment="")
{
@@ -679,6 +800,8 @@ class authzgroups
/** Return an array with all the groups where the user is in and in the module
* @param string $module The module to use
* @param string $user The user to search
*/
public function groupmemberReadUser ($module, $user)
{
@@ -703,6 +826,8 @@ class authzgroups
}
/** Return an array with all the groups where the user is in and in the module
* @param string $module The module to use
* @param integer $idgroupmember The user to search
*/
public function groupmemberReadUserByID ($module, $idgroupmember)
{
@@ -727,7 +852,10 @@ class authzgroups
}
/** Return an array with all the available users in the group and in the
module */
* module
* @param string $module The module to use
* @param string $group The group to search
*/
public function groupmemberReadGroup ($module, $group)
{
if ($this->dbGroupMember == null)
@@ -743,7 +871,10 @@ class authzgroups
}
/** Return an array with all the available users in the group and in the
module */
* module
* @param string $module The module to use
* @param integer $idgroup The group to search
*/
public function groupmemberReadGroupByID ($module, $idgroup)
{
if ($this->dbGroupMember == null)
@@ -759,6 +890,9 @@ class authzgroups
}
/** Return an array containing the information of a user in a specific group
* @param string $module The module to use
* @param integer $idgroup The group to search
* @param integer $iduser The user to search
*/
public function groupmemberReadUserDataByID ($module, $idgroup, $iduser)
{
@@ -776,14 +910,18 @@ class authzgroups
}
/** Return an array containing the titles of the table translating in the user
language */
* language
*/
public function groupmembersTitles ()
{
return $this->dbGroupMember->titles;
}
/** Check if the provided data are compilant with the group specification
@return array The errors found in the data */
* @param array $data The data to check
* @param integer|null $idgroupmember The group member associated to verify
* @return array The errors found in the data
*/
public function groupmembersVerify ($data, $idgroupmember=false)
{
return $this->dbGroupMember->verify ($data, $idgroupmember);
@@ -793,7 +931,13 @@ class authzgroups
// RIGHTS //
////////////////
/** Add a new right to right list
Return the idright created */
* Return the idright created
* @param string $module The module to use
* @param string $group The group to use
* @param string $object The object to use
* @param string $right The right to add
* @param string|null $comment The comment to add
*/
public function rightAdd ($module, $group, $object, $right, $comment="")
{
if ($this->dbRight == null)
@@ -822,8 +966,15 @@ class authzgroups
"right"=>$right,
"comment"=>$comment));
}
/** Add a new right to right list by ID
Return the idright created */
* Return the idright created
* @param string $module The module to use
* @param integer $idgroup The group to use
* @param integer $idobject The object to use
* @param integer $idright The right to add
* @param string|null $comment The comment to add
*/
public function rightAddByID ($module, $idgroup, $idobject, $idright,
$comment="")
{
@@ -854,8 +1005,11 @@ class authzgroups
"comment"=>$comment));
}
/** Remove an right from database and all the rights using it */
/** Remove an right from database and all the rights using it
* @param string $module The module to use
* @param string $group The group to use
* @param string $object The object to remove the rights
*/
public function rightDel ($module, $group, $object)
{
if ($this->dbRight == null)
@@ -869,7 +1023,10 @@ class authzgroups
return $this->dbRight->delete ($idrights[0]["idright"]);
}
/** Remove an right from database by ID and all the rights using it */
/** Remove an right from database by ID and all the rights using it
* @param string $module The module to use
* @param integer $idright The idright to be deleted
*/
public function rightDelByID ($module, $idright)
{
if ($this->dbRight == null)
@@ -883,7 +1040,13 @@ class authzgroups
return $this->dbRight->delete ($idrights[0]["idright"]);
}
/** Update a right in the database */
/** Update a right in the database
* @param string $module The module to use
* @param string $group The group to update the right
* @param string $object The object ot update the right
* @param string $newright The new right to save
* @param string|null $newcomment The new comment to save
*/
public function rightUpdate ($module, $group, $object, $newright,
$newcomment="")
{
@@ -909,7 +1072,13 @@ class authzgroups
"comment"=>$newcomment));
}
/** Update a right by ID in the database */
/** Update a right by ID in the database
* @param string $module The module to use
* @param integer $idright The idright to update the right
* @param integer $newidobject The object ot update the right
* @param integer $newright The new right to save
* @param string|null $newcomment The new comment to save
*/
public function rightUpdateByID ($module, $idright, $newidobject, $newright,
$newcomment="")
{
@@ -938,7 +1107,11 @@ class authzgroups
/** Return an array with all the available rights in the module, for a group,
and concerning an object */
* and concerning an object
* @param string $module The module to use
* @param string $group The group to get the rights
* @param string $object The object to get the rights
*/
public function rightRead ($module, $group, $object)
{
if ($this->dbRight == null)
@@ -957,7 +1130,10 @@ class authzgroups
return $this->dbRight->read ($select);
}
/** Return an array with all the available rights for a module and a group */
/** Return an array with all the available rights for a module and a group
* @param string $module The module to use
* @param string $group The group to get the rights
*/
public function rightReadByGroup ($module, $group)
{
if ($this->dbRight == null)
@@ -970,7 +1146,10 @@ class authzgroups
return $this->rightReadByGroupByID ($module, $objects[0]["idgroup"]);
}
/** Return an array with all the available rights for a module and a group */
/** Return an array with all the available rights for a module and a group
* @param string $module The module to use
* @param integer $idgroup The group to get the rights
*/
public function rightReadByGroupByID ($module, $idgroup)
{
if ($this->dbRight == null)
@@ -981,7 +1160,10 @@ class authzgroups
}
/** Return an array with all the information concerning a right selected by
ID*/
* @param string $module The module to use
* @param integer $idright The right to search
* ID
*/
public function rightReadByID ($module, $idright)
{
if ($this->dbRight == null)
@@ -992,6 +1174,8 @@ class authzgroups
}
/** Return an array with all the available rights for a module and an object
* @param string $module The module to use
* @param string $object The object to search
*/
public function rightReadByObject ($module, $object)
{
@@ -1007,32 +1191,40 @@ class authzgroups
}
/** Return an array with all the available rights for a module and an idobject
* @param string $module The module to use
* @param integer $idobject The object to search
*/
public function rightReadByObjectByID ($module, $idobject)
{
if ($this->dbRight == null)
throw new Exception (dgettext ("domframework",
"DB for Right is not connected"), 500);
// FIXME : Do not use $module ?
$select[] = array ("idobject", $idobject);
return $this->dbRight->read ($select);
}
/** Return an array containing the titles of the table translating in the user
language */
* language
*/
public function rightTitles ()
{
return $this->dbRight->titles;
}
/** Return all the types of rights available (RO and RW) */
/** Return all the types of rights available (RO and RW)
*/
public function rightTypes ()
{
return array ("1"=>"RO", "2"=>"RW");
}
/** Check if the provided data are compilant with the group specification
@return array The errors found in the data */
* @param array $data The data of the right to check
* @param integer $idright The right to search
* @return array The errors found in the data
*/
public function rightVerify ($data, $idright=false)
{
return $this->dbRight->verify ($data, $idright);