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:
48
auth.php
48
auth.php
@@ -10,10 +10,14 @@ class auth
|
||||
public $appName = null;
|
||||
|
||||
/** Display the authentication page
|
||||
The message is displayed to the user in case of error
|
||||
The url is the caller url to go back if authentication is correct
|
||||
@param string|null $message Message to display to the user
|
||||
@param string|null $url URL to go back after successful authentication */
|
||||
* The message is displayed to the user in case of error
|
||||
* The url is the caller url to go back if authentication is correct
|
||||
* @param string $baseURL The URL base to use for the links
|
||||
* @param string|null $message Message to display to the user
|
||||
* @param string|null $url URL to go back after successful authentication
|
||||
* @param mixed $alreadyAuth If the user is already authenticated, the value
|
||||
* will be displayed if the user is coming on the page.
|
||||
*/
|
||||
public function pageHTML ($baseURL, $message="", $url="", $alreadyAuth=false)
|
||||
{
|
||||
$res = "";
|
||||
@@ -133,7 +137,8 @@ class auth
|
||||
return $res;
|
||||
}
|
||||
|
||||
/** Establish the connection to authentication server */
|
||||
/** Establish the connection to authentication server
|
||||
*/
|
||||
public function connect ()
|
||||
{
|
||||
throw new Exception (dgettext("domframework",
|
||||
@@ -142,17 +147,19 @@ class auth
|
||||
}
|
||||
|
||||
/** Check if the email and password are correct
|
||||
Return TRUE if the authentication is correct
|
||||
Return an exception if there is a problem
|
||||
@param string $email Email to authenticate
|
||||
@param string $password Password to authenticate */
|
||||
* Return TRUE if the authentication is correct
|
||||
* Return an exception if there is a problem
|
||||
* @param string $email Email to authenticate
|
||||
* @param string $password Password to authenticate
|
||||
*/
|
||||
public function authentication ($email, $password)
|
||||
{
|
||||
throw new exception (dgettext("domframework",
|
||||
"No authentication available"), 405);
|
||||
}
|
||||
|
||||
/** Return all the parameters recorded for the authenticate user */
|
||||
/** Return all the parameters recorded for the authenticate user
|
||||
*/
|
||||
public function getdetails ()
|
||||
{
|
||||
throw new exception (dgettext("domframework",
|
||||
@@ -160,9 +167,10 @@ class auth
|
||||
}
|
||||
|
||||
/** Method to change the password
|
||||
@param string $oldpassword The old password (to check if the user have the
|
||||
rights to change the password)
|
||||
@param string $newpassword The new password to be recorded */
|
||||
* @param string $oldpassword The old password (to check if the user have the
|
||||
* rights to change the password)
|
||||
* @param string $newpassword The new password to be recorded
|
||||
*/
|
||||
public function changepassword ($oldpassword, $newpassword)
|
||||
{
|
||||
throw new exception (dgettext("domframework",
|
||||
@@ -170,10 +178,11 @@ class auth
|
||||
}
|
||||
|
||||
/** Method to overwrite the password (without oldpassword check)
|
||||
Must be reserved to the administrators. For the users, use changepassword
|
||||
method
|
||||
@param string $email the user identifier to select
|
||||
@param string $newpassword The new password to be recorded */
|
||||
* Must be reserved to the administrators. For the users, use changepassword
|
||||
* method
|
||||
* @param string $email the user identifier to select
|
||||
* @param string $newpassword The new password to be recorded
|
||||
*/
|
||||
public function overwritepassword ($email, $newpassword)
|
||||
{
|
||||
throw new exception (dgettext("domframework",
|
||||
@@ -181,13 +190,16 @@ class auth
|
||||
}
|
||||
|
||||
/** List all the users available in the database
|
||||
Return firstname, lastname, mail, with mail is an array */
|
||||
* Return firstname, lastname, mail, with mail is an array
|
||||
*/
|
||||
public function listusers ()
|
||||
{
|
||||
throw new exception (dgettext("domframework",
|
||||
"No List User available"), 405);
|
||||
}
|
||||
|
||||
/** Method to disconnect the authenticated user
|
||||
*/
|
||||
public function logout ()
|
||||
{
|
||||
throw new exception (dgettext("domframework",
|
||||
|
||||
@@ -9,9 +9,13 @@ require_once ("domframework/dblayer.php");
|
||||
class authsql extends auth
|
||||
{
|
||||
|
||||
/** The DSN to use to connect to SQL database */
|
||||
public $dsn = null;
|
||||
/** The username to connect to the database */
|
||||
public $username = null;
|
||||
/** The password to use to connecto to the database */
|
||||
public $password = null;
|
||||
/** The driver options for the PDO driver */
|
||||
public $driver_options = null;
|
||||
/** The table name to use */
|
||||
public $table = null;
|
||||
|
||||
302
authzgroups.php
302
authzgroups.php
@@ -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);
|
||||
|
||||
23
cli.php
23
cli.php
@@ -7,12 +7,13 @@
|
||||
class cli
|
||||
{
|
||||
/** Run in CLI mode with parameters
|
||||
Example of cli code :
|
||||
#!/usr/bin/php5
|
||||
<?php
|
||||
require ("domframework/cli.php");
|
||||
$cli = new cli;
|
||||
$cli->run(); */
|
||||
* Example of cli code :
|
||||
* #!/usr/bin/php5
|
||||
* <?php
|
||||
* require ("domframework/cli.php");
|
||||
* $cli = new cli;
|
||||
* $cli->run();
|
||||
*/
|
||||
/** The expert mode allow to see/execute the models */
|
||||
private $EXPERT = false;
|
||||
|
||||
@@ -29,7 +30,12 @@ class cli
|
||||
set_error_handler(array(&$this, "cliErrorHandler"));
|
||||
}
|
||||
|
||||
/** The error handler for CLI : display error in STDERR */
|
||||
/** The error handler for CLI : display error in STDERR
|
||||
* @param integer $errno The error type
|
||||
* @param string $errstr The string to send in error
|
||||
* @param string $errfile The error file which generate the error
|
||||
* @param integer $errline The line with an error
|
||||
*/
|
||||
public function cliErrorHandler ($errno, $errstr, $errfile, $errline)
|
||||
{
|
||||
if (!(error_reporting() & $errno))
|
||||
@@ -66,7 +72,8 @@ class cli
|
||||
}
|
||||
}
|
||||
|
||||
/** The real application launcher and helpers */
|
||||
/** The real application launcher and helpers
|
||||
*/
|
||||
public function run ()
|
||||
{
|
||||
global $argv;
|
||||
|
||||
70
config.php
70
config.php
@@ -6,22 +6,22 @@
|
||||
require_once ("domframework/form.php");
|
||||
|
||||
/** Manage the configurations of the module done by administrator in a config
|
||||
file
|
||||
It is based on the module configuration defaults
|
||||
The DocType allow to define the configuration HTML page. It must contains
|
||||
@param : the name of the parameter
|
||||
@description : the textual description of the parameter
|
||||
@type : the type of the parameter (string, integer, array)
|
||||
@values : an array containing the allowed values to the parameter. Can be
|
||||
a function like timezone_identifiers_list
|
||||
@default : the default value (can be an array or a string or a number)
|
||||
@group : Group all the parameters in a group
|
||||
POC :
|
||||
$config = new config();
|
||||
$config->default = array ("param"=>"default",
|
||||
"param2"=>array (1,2,3),
|
||||
"param3"=>null);
|
||||
$var = $config->get ("param");
|
||||
* file
|
||||
* It is based on the module configuration defaults
|
||||
* The DocType allow to define the configuration HTML page. It must contains
|
||||
* @param : the name of the parameter
|
||||
* @description : the textual description of the parameter
|
||||
* @type : the type of the parameter (string, integer, array)
|
||||
* @values : an array containing the allowed values to the parameter. Can be
|
||||
* a function like timezone_identifiers_list
|
||||
* @default : the default value (can be an array or a string or a number)
|
||||
* @group : Group all the parameters in a group
|
||||
* POC :
|
||||
* $config = new config();
|
||||
* $config->default = array ("param"=>"default",
|
||||
* "param2"=>array (1,2,3),
|
||||
* "param3"=>null);
|
||||
* $var = $config->get ("param");
|
||||
*/
|
||||
class config
|
||||
{
|
||||
@@ -30,7 +30,8 @@ class config
|
||||
/** Use the .php to protect the information */
|
||||
public $confFile = null;
|
||||
|
||||
/** Select the configuration file */
|
||||
/** Select the configuration file
|
||||
*/
|
||||
public function selectConfFile ()
|
||||
{
|
||||
if ($this->confFile !== null)
|
||||
@@ -45,14 +46,16 @@ class config
|
||||
$this->confFile = "./data/configuration.php";
|
||||
}
|
||||
|
||||
/** List all the parameters configurable in the software */
|
||||
/** List all the parameters configurable in the software
|
||||
*/
|
||||
public function params ()
|
||||
{
|
||||
$this->selectConfFile ();
|
||||
return $this->default;
|
||||
}
|
||||
|
||||
/** Return the defined values */
|
||||
/** Return the defined values
|
||||
*/
|
||||
public function getAll ()
|
||||
{
|
||||
$this->selectConfFile ();
|
||||
@@ -64,8 +67,9 @@ class config
|
||||
}
|
||||
|
||||
/** Get the value of the provided parameter recorded in .php file
|
||||
If it is not set in .php file, use the default value
|
||||
@param string $param The option name to be returned */
|
||||
* If it is not set in .php file, use the default value
|
||||
* @param string $param The option name to be returned
|
||||
*/
|
||||
public function get ($param)
|
||||
{
|
||||
$this->selectConfFile ();
|
||||
@@ -125,10 +129,11 @@ class config
|
||||
}
|
||||
|
||||
/** Define a value for the parameter in the config file. Add all the default
|
||||
values if they are not defined
|
||||
@param string $param The option name
|
||||
@param mixed $value The option value
|
||||
@return TRUE if the parameter is saved or an exception */
|
||||
* values if they are not defined
|
||||
* @param string $param The option name
|
||||
* @param mixed $value The option value
|
||||
* @return TRUE if the parameter is saved or an exception
|
||||
*/
|
||||
public function set ($param, $value)
|
||||
{
|
||||
$this->selectConfFile ();
|
||||
@@ -171,9 +176,10 @@ class config
|
||||
}
|
||||
|
||||
/** Display the $values in PHP format to be "require" easily
|
||||
@param mixed $values Values to be recorded
|
||||
@param string $phpcode Actual value of the php code
|
||||
@param integer $indent Number of spaces in the indentation of config */
|
||||
* @param mixed $values Values to be recorded
|
||||
* @param string $phpcode Actual value of the php code
|
||||
* @param integer $indent Number of spaces in the indentation of config
|
||||
*/
|
||||
private function writePHP ($values, $phpcode, $indent)
|
||||
{
|
||||
foreach ($values as $key=>$val)
|
||||
@@ -207,7 +213,9 @@ class config
|
||||
return $phpcode;
|
||||
}
|
||||
|
||||
/** Convert a string to the right PHP type, without using the eval function */
|
||||
/** Convert a string to the right PHP type, without using the eval function
|
||||
* @param string $values The string to convert
|
||||
*/
|
||||
private function strToType ($values)
|
||||
{
|
||||
$values = str_replace ("array (", "array(", $values);
|
||||
@@ -260,7 +268,9 @@ class config
|
||||
}
|
||||
|
||||
/** Return an array containing the definitions read from the default config
|
||||
file */
|
||||
* file
|
||||
* @param string $modelFile The file model to read
|
||||
*/
|
||||
public function docComment ($modelFile)
|
||||
{
|
||||
$debug = 0;
|
||||
|
||||
13
dbjson.php
13
dbjson.php
@@ -17,14 +17,20 @@
|
||||
/** DBJSON : a NoSQL DB in JSON */
|
||||
class dbjson
|
||||
{
|
||||
/** The DSN of the connection */
|
||||
private $dsn = "";
|
||||
/** The database file */
|
||||
private $dbfile = "";
|
||||
/** The lock file */
|
||||
private $dbfileLock = "";
|
||||
/** The last Insert Id */
|
||||
private $lastInsertId = 0;
|
||||
// The database content
|
||||
/** The database content */
|
||||
private $db;
|
||||
|
||||
/** The constructor */
|
||||
/** The constructor
|
||||
* @param string $dsn The DSN of the connection
|
||||
*/
|
||||
public function __construct ($dsn)
|
||||
{
|
||||
if (! function_exists ("openssl_random_pseudo_bytes"))
|
||||
@@ -80,7 +86,7 @@ class dbjson
|
||||
|
||||
/** Store multiple documents in database
|
||||
* @param string $collection The collection name
|
||||
* @param array documents array(array ())
|
||||
* @param array $documents array(array ())
|
||||
* @return integer The number of documents inserted in the database
|
||||
*/
|
||||
public function insertMany ($collection, $documents)
|
||||
@@ -414,7 +420,6 @@ class dbjson
|
||||
}
|
||||
|
||||
/** Write the dbfile with the provided data. This function don't do locks !
|
||||
* @param array $data The database to store
|
||||
* @return bool True if the recording is OK, false if there is a problem
|
||||
*/
|
||||
private function writeDB ()
|
||||
|
||||
213
dblayer.php
213
dblayer.php
@@ -111,11 +111,12 @@ class dblayer
|
||||
private static $instance = array ();
|
||||
|
||||
/** Connection to the database engine
|
||||
See http://fr2.php.net/manual/en/pdo.construct.php for the $dsn format
|
||||
@param string $dsn PDO Data Source Name
|
||||
@param string|null $username Username to connect
|
||||
@param string|null $password Password to connect
|
||||
@param string|null $driver_options Driver options to the database */
|
||||
* See http://fr2.php.net/manual/en/pdo.construct.php for the $dsn format
|
||||
* @param string $dsn PDO Data Source Name
|
||||
* @param string|null $username Username to connect
|
||||
* @param string|null $password Password to connect
|
||||
* @param string|null $driver_options Driver options to the database
|
||||
*/
|
||||
public function __construct ($dsn, $username=null, $password=null,
|
||||
$driver_options=null)
|
||||
{
|
||||
@@ -229,7 +230,8 @@ class dblayer
|
||||
return self::$instance[$this->dsn];
|
||||
}
|
||||
|
||||
/** Return the connected database name from DSN used to connect */
|
||||
/** Return the connected database name from DSN used to connect
|
||||
*/
|
||||
public function databasename ()
|
||||
{
|
||||
if ($this->sep === "")
|
||||
@@ -247,7 +249,8 @@ class dblayer
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Return all the tables available in the database */
|
||||
/** Return all the tables available in the database
|
||||
*/
|
||||
public function listTables ()
|
||||
{
|
||||
if ($this->sep === "")
|
||||
@@ -291,9 +294,9 @@ class dblayer
|
||||
}
|
||||
|
||||
/** Verify if the provided data can be inserted/updated in the database.
|
||||
@param array $data An array containing the data to verify with keys
|
||||
@param mixed|null $updatekey the key to update
|
||||
@return an array with the errors in array($key=>array($priority,$message))
|
||||
* @param array $data An array containing the data to verify with keys
|
||||
* @param mixed|null $updatekey the key to update
|
||||
* @return an array with the errors in array($key=>array($priority,$message))
|
||||
*/
|
||||
public function verify ($data, $updatekey=false)
|
||||
{
|
||||
@@ -589,7 +592,8 @@ class dblayer
|
||||
}
|
||||
|
||||
/** Insert a new line of data in the table. Datas must be an indexed array
|
||||
@param array $data Datas to be recorded (column=>value)*/
|
||||
* @param array $data Datas to be recorded (column=>value)
|
||||
*/
|
||||
public function insert ($data)
|
||||
{
|
||||
if ($this->debug) echo "== Entering insert\n";
|
||||
@@ -867,11 +871,12 @@ class dblayer
|
||||
}
|
||||
|
||||
/** Update the key tuple with the provided data
|
||||
Return the number of rows modified
|
||||
@param string|integer $updatekey The key applied on primary key to be
|
||||
updated
|
||||
@param array $data The values to be updated
|
||||
@return the number of lines modified */
|
||||
* Return the number of rows modified
|
||||
* @param string|integer $updatekey The key applied on primary key to be
|
||||
* updated
|
||||
* @param array $data The values to be updated
|
||||
* @return the number of lines modified
|
||||
*/
|
||||
public function update ($updatekey, $data)
|
||||
{
|
||||
if ($this->debug) echo "== Entering update\n";
|
||||
@@ -971,8 +976,9 @@ class dblayer
|
||||
}
|
||||
|
||||
/** Delete a tuple identified by its primary key
|
||||
Return the number of deleted rows (can be 0 !)
|
||||
@param string|integer $deletekey The key of primary key to be deleted */
|
||||
* Return the number of deleted rows (can be 0 !)
|
||||
* @param string|integer $deletekey The key of primary key to be deleted
|
||||
*/
|
||||
public function delete ($deletekey)
|
||||
{
|
||||
if ($this->debug) echo "== Entering delete\n";
|
||||
@@ -1004,7 +1010,8 @@ class dblayer
|
||||
return $nbLinesDeleted;
|
||||
}
|
||||
|
||||
/** Translation of fields */
|
||||
/** Translation of fieldsi
|
||||
*/
|
||||
public function titles ()
|
||||
{
|
||||
if ($this->debug) echo "== Entering titles\n";
|
||||
@@ -1024,7 +1031,8 @@ class dblayer
|
||||
return $arr;
|
||||
}
|
||||
|
||||
/** Drop the table */
|
||||
/** Drop the table
|
||||
*/
|
||||
public function dropTable ()
|
||||
{
|
||||
if ($this->debug) echo "== Entering dropTables\n";
|
||||
@@ -1040,20 +1048,20 @@ class dblayer
|
||||
}
|
||||
|
||||
/** Create the table defined by the differents fields.
|
||||
Define the SQL syntax based on SQL engines
|
||||
$table = "dns zones";
|
||||
$fields = array (
|
||||
"id"=>array ("integer", "not null", "autoincrement"),
|
||||
"zo ne"=>array ("varchar", "255", "not null"),
|
||||
"vie wname"=>array ("varchar", "255"),
|
||||
"view clients"=>array ("varchar", "255"),
|
||||
"comme nt"=>array ("varchar", "1024"),
|
||||
"opendate"=>array ("datetime", "not null"),
|
||||
"closedate"=>array ("datetime"),
|
||||
);
|
||||
$primary = "id";
|
||||
$unique = array ("id", array ("zo ne", "vie wname"));
|
||||
$foreign = array ("zone"=>"table.field",...);
|
||||
* Define the SQL syntax based on SQL engines
|
||||
* $table = "dns zones";
|
||||
* $fields = array (
|
||||
* "id"=>array ("integer", "not null", "autoincrement"),
|
||||
* "zo ne"=>array ("varchar", "255", "not null"),
|
||||
* "vie wname"=>array ("varchar", "255"),
|
||||
* "view clients"=>array ("varchar", "255"),
|
||||
* "comme nt"=>array ("varchar", "1024"),
|
||||
* "opendate"=>array ("datetime", "not null"),
|
||||
* "closedate"=>array ("datetime"),
|
||||
* );
|
||||
* $primary = "id";
|
||||
* $unique = array ("id", array ("zo ne", "vie wname"));
|
||||
* $foreign = array ("zone"=>"table.field",...);
|
||||
*/
|
||||
public function createTable ()
|
||||
{
|
||||
@@ -1366,7 +1374,9 @@ class dblayer
|
||||
}
|
||||
|
||||
/** This function permit to send a SQL request to the database to do a SELECT
|
||||
Return the an array with the data */
|
||||
* Return the an array with the data
|
||||
* @param string $sql A valid SQL request to be execute
|
||||
*/
|
||||
public function directRead ($sql)
|
||||
{
|
||||
if ($this->debug) echo "== Entering directRead\n";
|
||||
@@ -1381,50 +1391,58 @@ class dblayer
|
||||
}
|
||||
|
||||
/** This function disconnect the database. It is normally only used in phpunit
|
||||
unit tests */
|
||||
* unit tests
|
||||
*/
|
||||
public function disconnect ()
|
||||
{
|
||||
unset (self::$instance[$this->dsn]);
|
||||
}
|
||||
|
||||
/** The prepare method */
|
||||
/** The prepare method
|
||||
* @param string $statement The valid template to be replaced
|
||||
* @param array|null $driver_options The replacement to be done
|
||||
*/
|
||||
public function prepare ($statement, $driver_options = array())
|
||||
{
|
||||
return self::$instance[$this->dsn]->prepare ($statement, $driver_options);
|
||||
}
|
||||
|
||||
/** Start a new Transaction */
|
||||
/** Start a new Transaction
|
||||
*/
|
||||
public function beginTransaction ()
|
||||
{
|
||||
return self::$instance[$this->dsn]->beginTransaction ();
|
||||
}
|
||||
|
||||
/** Commit (validate) a transaction */
|
||||
/** Commit (validate) a transaction
|
||||
*/
|
||||
public function commit ()
|
||||
{
|
||||
return self::$instance[$this->dsn]->commit ();
|
||||
}
|
||||
|
||||
/** RollBack a transaction */
|
||||
/** RollBack a transaction
|
||||
*/
|
||||
public function rollback ()
|
||||
{
|
||||
return self::$instance[$this->dsn]->rollback ();
|
||||
}
|
||||
|
||||
/** Hook preread
|
||||
This hook is run before selecting the data in the database, after the
|
||||
verification
|
||||
@param array|null &$select Rows to select with
|
||||
$select = array (array ($key, $val, $operator), ...)
|
||||
$key=>column, $val=>value to found, $operator=>'LIKE', =...
|
||||
@param array|null &$display Columns displayed
|
||||
$display = array ($col1, $col2...);
|
||||
@param array|null &$order Sort the columns by orientation
|
||||
$order = array (array ($key, $orientation), ...)
|
||||
$key=>column, $orientation=ASC/DESC
|
||||
@param boolean|null &$whereOr The WHERE parameters are separated by OR
|
||||
instead of AND
|
||||
@param array|null &$foreignSelect Add a filter on foreign keys */
|
||||
* This hook is run before selecting the data in the database, after the
|
||||
* verification
|
||||
* @param array|null &$select Rows to select with
|
||||
* $select = array (array ($key, $val, $operator), ...)
|
||||
* $key=>column, $val=>value to found, $operator=>'LIKE', =...
|
||||
* @param array|null &$display Columns displayed
|
||||
* $display = array ($col1, $col2...);
|
||||
* @param array|null &$order Sort the columns by orientation
|
||||
* $order = array (array ($key, $orientation), ...)
|
||||
* $key=>column, $orientation=ASC/DESC
|
||||
* @param boolean|null &$whereOr The WHERE parameters are separated by OR
|
||||
* instead of AND
|
||||
* @param array|null &$foreignSelect Add a filter on foreign keys
|
||||
*/
|
||||
public function hookpreread (&$select, &$display, &$order, &$whereOr,
|
||||
&$foreignSelect)
|
||||
{
|
||||
@@ -1432,60 +1450,77 @@ class dblayer
|
||||
}
|
||||
|
||||
/** Hook postread
|
||||
This hook is run after selecting the data.
|
||||
@param array $data the data selected by the select
|
||||
@return array The data modified by the hook */
|
||||
* This hook is run after selecting the data.
|
||||
* @param array $data the data selected by the select
|
||||
* @return array The data modified by the hook
|
||||
*/
|
||||
public function hookpostread ($data)
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
|
||||
/** Hook preinsert
|
||||
This hook is run before inserting a new data in the database, after the
|
||||
verification
|
||||
@param array the data to insert in the database
|
||||
@return the modified data */
|
||||
* This hook is run before inserting a new data in the database, after the
|
||||
* verification
|
||||
* @param array $data the data to insert in the database
|
||||
* @return the modified data
|
||||
*/
|
||||
public function hookpreinsert ($data)
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
|
||||
/** Hook postinsert
|
||||
This hook is run after successfuly insert a new data in the database
|
||||
@return the modified lastID */
|
||||
* This hook is run after successfuly insert a new data in the database
|
||||
* @param array $data the data selected by the select
|
||||
* @param integer $lastID the insert identifier
|
||||
* @return the modified lastID
|
||||
*/
|
||||
public function hookpostinsert ($data, $lastID)
|
||||
{
|
||||
return $lastID;
|
||||
}
|
||||
|
||||
/** Hook preupdate
|
||||
This hook is run before updating a data in the database, after the
|
||||
verification
|
||||
@return the modified data */
|
||||
* This hook is run before updating a data in the database, after the
|
||||
* verification
|
||||
* @param string $updatekey the key to be modify
|
||||
* @param array $data the data selected by the select
|
||||
* @return the modified data
|
||||
*/
|
||||
public function hookpreupdate ($updatekey, $data)
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
|
||||
/** Hook postupdate
|
||||
This hook is run after successfuly update a data in the database
|
||||
@return the modified $nbLinesUpdated */
|
||||
* This hook is run after successfuly update a data in the database
|
||||
* @param string $updatekey the key which was modified
|
||||
* @param array $data the data selected by the select
|
||||
* @param integer $nbLinesUpdated The number of modified lines
|
||||
* @return the modified $nbLinesUpdated
|
||||
*/
|
||||
public function hookpostupdate ($updatekey, $data, $nbLinesUpdated)
|
||||
{
|
||||
return $nbLinesUpdated;
|
||||
}
|
||||
|
||||
/** Hook predelete
|
||||
This hook is run before deleting a data in the database
|
||||
@return the modified $deletekey */
|
||||
* This hook is run before deleting a data in the database
|
||||
* @param string $deletekey The key to be removed
|
||||
* @return the modified $deletekey
|
||||
*/
|
||||
public function hookpredelete ($deletekey)
|
||||
{
|
||||
return $deletekey;
|
||||
}
|
||||
|
||||
/** Hook postdelete
|
||||
This hook is run after successfuly deleting a data in the database
|
||||
@return $nbLinesUpdated */
|
||||
* This hook is run after successfuly deleting a data in the database
|
||||
* @param string $deletekey The removed key
|
||||
* @param integer $nbLinesDeleted The number of deleted lines
|
||||
* @return $nbLinesUpdated
|
||||
*/
|
||||
public function hookpostdelete ($deletekey, $nbLinesDeleted)
|
||||
{
|
||||
return $nbLinesDeleted;
|
||||
@@ -1494,63 +1529,81 @@ class dblayer
|
||||
///////////////////
|
||||
/// SETTERS ///
|
||||
///////////////////
|
||||
/** Set the table property */
|
||||
/** Set the table property
|
||||
* @param string $table The table name to use
|
||||
*/
|
||||
public function tableSet ($table)
|
||||
{
|
||||
$this->table = $table;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the tableprefix property */
|
||||
/** Set the tableprefix property
|
||||
* @param string $tableprefix The prefix to add in table names
|
||||
*/
|
||||
public function tableprefixSet ($tableprefix)
|
||||
{
|
||||
$this->tableprefix = $tableprefix;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the fields property */
|
||||
/** Set the fields property
|
||||
* @param array $fields Set the definition of the fields
|
||||
*/
|
||||
public function fieldsSet ($fields)
|
||||
{
|
||||
$this->fields = $fields;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the primary property */
|
||||
/** Set the primary property
|
||||
* @param string $primary The primary field
|
||||
*/
|
||||
public function primarySet ($primary)
|
||||
{
|
||||
$this->primary = $primary;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the unique property */
|
||||
/** Set the unique property
|
||||
* @param array $unique The array of the unique contraints
|
||||
*/
|
||||
public function uniqueSet ($unique)
|
||||
{
|
||||
$this->unique = $unique;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the foreign property */
|
||||
/** Set the foreign property
|
||||
* @param array $foreign The foreign array
|
||||
*/
|
||||
public function foreignSet ($foreign)
|
||||
{
|
||||
$this->foreign = $foreign;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the debug property */
|
||||
/** Set the debug property
|
||||
* @param integer $debug The debug value
|
||||
*/
|
||||
public function debugSet ($debug)
|
||||
{
|
||||
$this->debug = $debug;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the dsn property */
|
||||
/** Set the dsn property
|
||||
* @param string $dsn The DSN to use
|
||||
*/
|
||||
public function dsnSet ($dsn)
|
||||
{
|
||||
$this->dsn = $dsn;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the titles property */
|
||||
/** Set the titles property
|
||||
* @param array $titles The titles of the fields
|
||||
*/
|
||||
public function titlesSet ($titles)
|
||||
{
|
||||
$this->titles = $titles;
|
||||
|
||||
@@ -31,19 +31,20 @@ class dblayerauthzgroups extends dblayer
|
||||
/// MAIN METHODS ///
|
||||
////////////////////////
|
||||
/** Hook preread
|
||||
This hook is run before selecting the data in the database, after the
|
||||
verification
|
||||
@param array|null &$select Rows to select with
|
||||
$select = array (array ($key, $val, $operator), ...)
|
||||
$key=>column, $val=>value to found, $operator=>'LIKE', =...
|
||||
@param array|null &$display Columns displayed
|
||||
$display = array ($col1, $col2...);
|
||||
@param array|null &$order Sort the columns by orientation
|
||||
$order = array (array ($key, $orientation), ...)
|
||||
$key=>column, $orientation=ASC/DESC
|
||||
@param boolean|null &$whereOr The WHERE parameters are separated by OR
|
||||
instead of AND
|
||||
@param array|null &$foreignSelect Add a filter on foreign keys */
|
||||
* This hook is run before selecting the data in the database, after the
|
||||
* verification
|
||||
* @param array|null &$select Rows to select with
|
||||
* $select = array (array ($key, $val, $operator), ...)
|
||||
* $key=>column, $val=>value to found, $operator=>'LIKE', =...
|
||||
* @param array|null &$display Columns displayed
|
||||
* $display = array ($col1, $col2...);
|
||||
* @param array|null &$order Sort the columns by orientation
|
||||
* $order = array (array ($key, $orientation), ...)
|
||||
* $key=>column, $orientation=ASC/DESC
|
||||
* @param boolean|null &$whereOr The WHERE parameters are separated by OR
|
||||
* instead of AND
|
||||
* @param array|null &$foreignSelect Add a filter on foreign keys
|
||||
*/
|
||||
public function hookpreread (&$select, &$display, &$order, &$whereOr,
|
||||
&$foreignSelect)
|
||||
{
|
||||
@@ -67,10 +68,11 @@ class dblayerauthzgroups extends dblayer
|
||||
}
|
||||
|
||||
/** Hook postread
|
||||
This hook is run after selecting the data. Return only the allowed data to
|
||||
the user. It must have at least the RO flag.
|
||||
@param array $data the data selected by the select
|
||||
@return array The data modified by the hook */
|
||||
* This hook is run after selecting the data. Return only the allowed data to
|
||||
* the user. It must have at least the RO flag.
|
||||
* @param array $data the data selected by the select
|
||||
* @return array The data modified by the hook
|
||||
*/
|
||||
public function hookpostread ($data)
|
||||
{
|
||||
// TODO : If foreign keys, do we check if the access is allowed too ?
|
||||
@@ -103,10 +105,11 @@ class dblayerauthzgroups extends dblayer
|
||||
}
|
||||
|
||||
/** Hook preinsert
|
||||
This hook is run before inserting a new data in the database, after the
|
||||
verification
|
||||
@param array the data to insert in the database
|
||||
@return the modified data */
|
||||
* This hook is run before inserting a new data in the database, after the
|
||||
* verification
|
||||
* @param array $data the data to insert in the database
|
||||
* @return the modified data
|
||||
*/
|
||||
public function hookpreinsert ($data)
|
||||
{
|
||||
if ($this->module === null)
|
||||
@@ -128,8 +131,11 @@ class dblayerauthzgroups extends dblayer
|
||||
}
|
||||
|
||||
/** Hook postinsert
|
||||
This hook is run after successfuly insert a new data in the database
|
||||
@return the modified lastID */
|
||||
* This hook is run after successfuly insert a new data in the database
|
||||
* @param array $data The data stored in the database
|
||||
* @param integer $lastID The lastID stored
|
||||
* @return the modified lastID
|
||||
*/
|
||||
public function hookpostinsert ($data, $lastID)
|
||||
{
|
||||
if ($this->module === null)
|
||||
@@ -169,9 +175,12 @@ class dblayerauthzgroups extends dblayer
|
||||
}
|
||||
|
||||
/** Hook preupdate
|
||||
This hook is run before updating a data in the database, after the
|
||||
verification
|
||||
@return the modified data */
|
||||
* This hook is run before updating a data in the database, after the
|
||||
* verification
|
||||
* @param integer $updatekey The key which will be updated
|
||||
* @param array $data The data to store in the provided key
|
||||
* @return the modified data
|
||||
*/
|
||||
public function hookpreupdate ($updatekey, $data)
|
||||
{
|
||||
if ($this->module === null)
|
||||
@@ -192,8 +201,10 @@ class dblayerauthzgroups extends dblayer
|
||||
}
|
||||
|
||||
/** Hook predelete
|
||||
This hook is run before deleting a data in the database
|
||||
@return the modified $deletekey */
|
||||
* This hook is run before deleting a data in the database
|
||||
* @param string $deletekey The key to delete
|
||||
* @return the modified $deletekey
|
||||
*/
|
||||
public function hookpredelete ($deletekey)
|
||||
{
|
||||
if ($this->module === null)
|
||||
@@ -214,8 +225,11 @@ class dblayerauthzgroups extends dblayer
|
||||
}
|
||||
|
||||
/** Hook postdelete
|
||||
This hook is run after successfuly deleting a data in the database
|
||||
@return $nbLinesUpdated */
|
||||
* This hook is run after successfuly deleting a data in the database
|
||||
* @param string $deletekey The key to delete
|
||||
* @param integer $nbLinesDeleted The number of deleted lines
|
||||
* @return $nbLinesUpdated
|
||||
*/
|
||||
public function hookpostdelete ($deletekey, $nbLinesDeleted)
|
||||
{
|
||||
if ($this->module === null)
|
||||
@@ -232,7 +246,8 @@ class dblayerauthzgroups extends dblayer
|
||||
return $nbLinesDeleted;
|
||||
}
|
||||
|
||||
/** Return true if all the paths are allowed. Throw an exception elsewhere */
|
||||
/** Return true if all the paths are allowed. Throw an exception elsewhere
|
||||
*/
|
||||
private function allowPath ()
|
||||
{
|
||||
if ($this->module === null)
|
||||
@@ -261,49 +276,63 @@ class dblayerauthzgroups extends dblayer
|
||||
///////////////////
|
||||
/// SETTERS ///
|
||||
///////////////////
|
||||
/** Set the authzgroups property */
|
||||
/** Set the authzgroups property
|
||||
* @param object $authzgroups The object of the authzgroups
|
||||
*/
|
||||
public function authzgroupsSet ($authzgroups)
|
||||
{
|
||||
$this->authzgroups = $authzgroups;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the module property */
|
||||
/** Set the module property
|
||||
* @param string $module The module name to use
|
||||
*/
|
||||
public function moduleSet ($module)
|
||||
{
|
||||
$this->module = $module;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the auth property */
|
||||
/** Set the auth property
|
||||
* @param array $auth The auth array
|
||||
*/
|
||||
public function authSet ($auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the user property */
|
||||
/** Set the user property
|
||||
* @param string $user The user to authorize
|
||||
*/
|
||||
public function userSet ($user)
|
||||
{
|
||||
$this->user = $user;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the createGroup property */
|
||||
/** Set the createGroup property
|
||||
* @param array|string $createGroup The createGroup to set
|
||||
*/
|
||||
public function createGroupSet ($createGroup)
|
||||
{
|
||||
$this->createGroup = $createGroup;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the createRight property */
|
||||
/** Set the createRight property
|
||||
* @param string $createRight The right to create
|
||||
*/
|
||||
public function createRightSet ($createRight)
|
||||
{
|
||||
$this->createRight = $createRight;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Set the path property */
|
||||
/** Set the path property
|
||||
* @param string $path The pre-path to use
|
||||
*/
|
||||
public function pathSet ($path)
|
||||
{
|
||||
$this->path = $path;
|
||||
|
||||
4
file.php
4
file.php
@@ -25,6 +25,7 @@ class file
|
||||
public $debug = 0;
|
||||
|
||||
/** Change the current working directory
|
||||
* @param string $directory Go in the provided directory
|
||||
* @return bool true if the directory is changed
|
||||
* @throws If directory not exists, or the directory is not executable
|
||||
*/
|
||||
@@ -66,6 +67,7 @@ class file
|
||||
|
||||
/** Change the rights mode for a file/dir...
|
||||
* @param string $filename The file/directory to change
|
||||
* @param integer $mode The mode to use for the filename
|
||||
* @throws If filename not exists, or the directory is not RW
|
||||
*/
|
||||
public function chmod ($filename, $mode)
|
||||
@@ -600,6 +602,8 @@ class file
|
||||
* @param string $filename the filename
|
||||
* @param integer|null $time the timestamp to use (actual timestamp if not
|
||||
* defined)
|
||||
* @param integer|null $atime the access timestamp to use (actual timestamp
|
||||
* if not defined)
|
||||
* @return bool true or false on failure
|
||||
* @throws If parent directory not exists, is not writeable
|
||||
*/
|
||||
|
||||
223
imap.php
223
imap.php
@@ -19,7 +19,18 @@ class imap
|
||||
private static $instance = array ();
|
||||
|
||||
/** The constructor
|
||||
The IMAP standard port is 143, but SSL tunnelled is 993 */
|
||||
* The IMAP standard port is 143, but SSL tunnelled is 993
|
||||
* @param string|null $imapserver The IMAP server to connect. Localhost is
|
||||
* used if not defined
|
||||
* @param integer|null $imapport The IMAP port to connect. 143 is used if not
|
||||
* defined
|
||||
* @param string|null $username The username to connect
|
||||
* @param string|null $password The password to connect
|
||||
* @param boolean|null $imapssl Use the SSL connection layer. Not used by
|
||||
* default
|
||||
* @param boolean|null $imapcertvalidate Check the certificates if using the
|
||||
* SSL connection. True by default
|
||||
*/
|
||||
public function __construct ($imapserver = "localhost", $imapport = 143,
|
||||
$username = null, $password = null,
|
||||
$imapssl = false, $imapcertvalidate = true)
|
||||
@@ -29,8 +40,19 @@ class imap
|
||||
}
|
||||
|
||||
/** The connect can be used when extends the imap class. The constructor can
|
||||
be override by the child class.
|
||||
The IMAP standard port is 143, but SSL tunnelled is 993 */
|
||||
* be override by the child class.
|
||||
* The IMAP standard port is 143, but SSL tunnelled is 993
|
||||
* @param string|null $imapserver The IMAP server to connect. Localhost is
|
||||
* used if not defined
|
||||
* @param integer|null $imapport The IMAP port to connect. 143 is used if not
|
||||
* defined
|
||||
* @param string|null $username The username to connect
|
||||
* @param string|null $password The password to connect
|
||||
* @param boolean|null $imapssl Use the SSL connection layer. Not used by
|
||||
* default
|
||||
* @param boolean|null $imapcertvalidate Check the certificates if using the
|
||||
* SSL connection. True by default
|
||||
*/
|
||||
public function connect ($imapserver = "localhost", $imapport = 143,
|
||||
$username = null, $password = null,
|
||||
$imapssl = false, $imapcertvalidate = true)
|
||||
@@ -75,8 +97,9 @@ class imap
|
||||
/// FOLDERS ///
|
||||
///////////////////
|
||||
/** Return an array of the existing folders. The sub-folders are with slash
|
||||
separator
|
||||
The names of folders are converted in UTF-8 */
|
||||
* separator
|
||||
* The names of folders are converted in UTF-8
|
||||
*/
|
||||
public function foldersList ()
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -87,7 +110,8 @@ class imap
|
||||
}
|
||||
|
||||
/** Return an array with folder name in key and attributes in value. The
|
||||
attributes allow to see if there is new mails in folders */
|
||||
* attributes allow to see if there is new mails in folders
|
||||
*/
|
||||
public function foldersListWithAttr ()
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -107,7 +131,9 @@ class imap
|
||||
}
|
||||
|
||||
/** Change to provided folder
|
||||
The folder name must be in UTF-8. The folder must be absolute */
|
||||
* The folder name must be in UTF-8. The folder must be absolute
|
||||
* @param string $folder Change to the provided folder
|
||||
*/
|
||||
public function changeFolder ($folder)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -124,7 +150,8 @@ class imap
|
||||
return $rc;
|
||||
}
|
||||
|
||||
/** Return the current folder in UTF-8 */
|
||||
/** Return the current folder in UTF-8
|
||||
*/
|
||||
public function getFolder ()
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -132,7 +159,9 @@ class imap
|
||||
return $this->curDir;
|
||||
}
|
||||
|
||||
/** Create a new folder, provided in UTF-8. The folder must be absolute */
|
||||
/** Create a new folder, provided in UTF-8. The folder must be absolute
|
||||
* @param string $folder Create the provided folder
|
||||
*/
|
||||
public function createFolder ($folder)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -145,6 +174,7 @@ class imap
|
||||
}
|
||||
|
||||
/** Delete an existing folder provided in UTF-8. The folder must be absolute
|
||||
* @param string $folder The folder to delete
|
||||
*/
|
||||
public function deleteFolder ($folder)
|
||||
{
|
||||
@@ -158,7 +188,8 @@ class imap
|
||||
}
|
||||
|
||||
/** Return the list of the folders substcribed by the user. The folders are
|
||||
in UTF-8 */
|
||||
* in UTF-8
|
||||
*/
|
||||
public function getSubscribe ()
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -178,7 +209,10 @@ class imap
|
||||
return $res;
|
||||
}
|
||||
|
||||
/** Add a subscription for a folder. The folder must be in UTF-8 */
|
||||
/** Add a subscription for a folder. The folder must be in UTF-8
|
||||
* @param string $folder Add the provided folder to the subscription file of
|
||||
* the user
|
||||
*/
|
||||
public function addSubscribe ($folder)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -188,7 +222,10 @@ class imap
|
||||
$this->mailbox.$folder);
|
||||
}
|
||||
|
||||
/** Remove a subscription for a folder. The folder must be in UTF-8 */
|
||||
/** Remove a subscription for a folder. The folder must be in UTF-8
|
||||
* @param string $folder Remove the provided folder to the subscription file
|
||||
* of the user
|
||||
*/
|
||||
public function delSubscribe ($folder)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -199,15 +236,17 @@ class imap
|
||||
}
|
||||
|
||||
/** Return the information concerning a folder. It return an object with the
|
||||
following properties :
|
||||
Date date of last change (current datetime)
|
||||
Driver driver
|
||||
Mailbox name of the mailbox
|
||||
Nmsgs number of messages
|
||||
Recent number of recent messages
|
||||
Unread number of unread messages
|
||||
Deleted number of deleted messages
|
||||
Size mailbox size */
|
||||
* following properties :
|
||||
* Date date of last change (current datetime)
|
||||
* Driver driver
|
||||
* Mailbox name of the mailbox
|
||||
* Nmsgs number of messages
|
||||
* Recent number of recent messages
|
||||
* Unread number of unread messages
|
||||
* Deleted number of deleted messages
|
||||
* Size mailbox size
|
||||
* @param string $folder The folder to get the informations
|
||||
*/
|
||||
public function getFolderInfo ($folder)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -225,6 +264,9 @@ class imap
|
||||
/// LIST MAILS ///
|
||||
//////////////////////
|
||||
/** Return an array of mailHeaders order by $field and by order ASC or DESC
|
||||
* @param array $mailHeaders The headers to sort
|
||||
* @param string $field The field to examine
|
||||
* @param boolean|null $orderAsc The order of sorting. Asc if not defined
|
||||
*/
|
||||
public function imapSortMail ($mailHeaders, $field, $orderAsc = TRUE)
|
||||
{
|
||||
@@ -249,12 +291,16 @@ class imap
|
||||
}
|
||||
|
||||
/** Fetch the headers for all messages in the current folder sorted by date
|
||||
Return an array of mail object containing information like the subject,
|
||||
the date, if the message is already read (recent), answered...
|
||||
(see http://www.php.net/manual/en/function.imap-fetch-overview.php)
|
||||
If the $from is negative, take the LAST $from mails
|
||||
If from is zero, it's value is override to 1
|
||||
For information, takes 0.4s to select 30 mails on 1552 **/
|
||||
* Return an array of mail object containing information like the subject,
|
||||
* the date, if the message is already read (recent), answered...
|
||||
* (see http://www.php.net/manual/en/function.imap-fetch-overview.php)
|
||||
* If the $from is negative, take the LAST $from mails
|
||||
* If from is zero, it's value is override to 1
|
||||
* For information, takes 0.4s to select 30 mails on 1552
|
||||
* @param integer|null $from The selector of the mails. 1 if not defined
|
||||
* @param integer|null $nbmails The number of mails returned by the method
|
||||
* 30 if not defined
|
||||
**/
|
||||
public function mailsDate ($from = 1, $nbmails = 30)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -301,7 +347,8 @@ class imap
|
||||
}
|
||||
|
||||
/** Return all the mails numbers order by thread in an array.
|
||||
[] => array ("msgno"=>msgno, "depth"=>depth) */
|
||||
* [] => array ("msgno"=>msgno, "depth"=>depth)
|
||||
*/
|
||||
public function mailsThread ()
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -331,7 +378,8 @@ class imap
|
||||
return $thread;
|
||||
}
|
||||
|
||||
/** Send back the number of mails in the mailbox */
|
||||
/** Send back the number of mails in the mailbox
|
||||
*/
|
||||
public function mailsNumber ()
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -341,7 +389,9 @@ class imap
|
||||
return $MC->Nmsgs;
|
||||
}
|
||||
|
||||
/** Return an array containing the msgno corresponding to the criteria */
|
||||
/** Return an array containing the msgno corresponding to the criteria
|
||||
* @param string $criteria The criteria to use for the IMAP search
|
||||
*/
|
||||
public function mailsSearch ($criteria)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -351,8 +401,11 @@ class imap
|
||||
}
|
||||
|
||||
/** Move the mail provided in the $folder in UTF-8.
|
||||
If $msgno is an array, all the mails with the contain msgno are deleted
|
||||
Expunge automatically the current folder to remove the old emails */
|
||||
* If $msgno is an array, all the mails with the contain msgno are deleted
|
||||
* Expunge automatically the current folder to remove the old emails
|
||||
* @param integer|array $msgno The message number(s) to copy
|
||||
* @param string $folder The destination folder of the move. Must exists
|
||||
*/
|
||||
public function mailMove ($msgno, $folder)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -372,7 +425,10 @@ class imap
|
||||
}
|
||||
|
||||
/** Copy the mail provided in the $folder in UTF-8.
|
||||
If $msgno is an array, all the mails with the contain msgno are copied */
|
||||
* If $msgno is an array, all the mails with the contain msgno are copied
|
||||
* @param integer|array $msgno The message number(s) to copy
|
||||
* @param string $folder The destination folder of the copy. Must exists
|
||||
*/
|
||||
public function mailCopy ($msgno, $folder)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -390,7 +446,8 @@ class imap
|
||||
}
|
||||
|
||||
/** Expunge the mailbox. If the autoexpunge is activated, it is normally not
|
||||
needed */
|
||||
* needed
|
||||
*/
|
||||
public function expunge ()
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -402,7 +459,9 @@ class imap
|
||||
/////////////////////////////
|
||||
/// GET/SET/DEL EMAIL ///
|
||||
/////////////////////////////
|
||||
/** Get an existing email in the current folder in raw format */
|
||||
/** Get an existing email in the current folder in raw format
|
||||
* @param integer $msgno The message number to examine
|
||||
*/
|
||||
public function getEmailRaw ($msgno)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -418,7 +477,9 @@ class imap
|
||||
return $content;
|
||||
}
|
||||
|
||||
/** Get the headers of the email (in raw format) */
|
||||
/** Get the headers of the email (in raw format)
|
||||
* @param integer $msgno The message number to examine
|
||||
*/
|
||||
public function getEmailHeadersRaw ($msgno)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -433,7 +494,9 @@ class imap
|
||||
return $content;
|
||||
}
|
||||
|
||||
/** Get all the body (and attached files) of an email in raw format */
|
||||
/** Get all the body (and attached files) of an email in raw format
|
||||
* @param integer $msgno The message number to examine
|
||||
*/
|
||||
public function getEmailBodyRaw ($msgno)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -448,7 +511,9 @@ class imap
|
||||
return $content;
|
||||
}
|
||||
|
||||
/** Return email structure of the body */
|
||||
/** Return email structure of the body
|
||||
* @param integer $msgno The message number to examine
|
||||
*/
|
||||
public function getStructure ($msgno)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -463,7 +528,9 @@ class imap
|
||||
return $structure;
|
||||
}
|
||||
|
||||
/** Return the structure of the mail body with the associated content */
|
||||
/** Return the structure of the mail body with the associated content
|
||||
* @param integer $msgno The message number to examine
|
||||
*/
|
||||
public function getStructureWithContent ($msgno)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -591,9 +658,12 @@ class imap
|
||||
}
|
||||
|
||||
/** Return the content of a part of the mail body defined in the structure in
|
||||
an object, with the associated mimetype, the parameters like the charset
|
||||
if they are defined, the number of lines associated to this part in the
|
||||
mail and some other info */
|
||||
* an object, with the associated mimetype, the parameters like the charset
|
||||
* if they are defined, the number of lines associated to this part in the
|
||||
* mail and some other info
|
||||
* @param integer $msgno The message number to examine
|
||||
* @param integer $part The message part to get
|
||||
*/
|
||||
public function getStructureContent ($msgno, $part)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -605,7 +675,9 @@ class imap
|
||||
}
|
||||
|
||||
/** Return the part identifiers of the structure of the mail body. To be used
|
||||
in getStructureContent */
|
||||
* in getStructureContent
|
||||
* @param integer $msgno The message number to examine
|
||||
*/
|
||||
public function getStructureParts ($msgno)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -617,9 +689,11 @@ class imap
|
||||
}
|
||||
|
||||
/** Delete all the mailIDs (msgno) provided in an array or a single mail if
|
||||
$msgno is not an array
|
||||
DO NOT MOVE THE MAIL IN TRASH, DESTROY THE MAIL REALLY
|
||||
Expunge the mails at the end of the operation */
|
||||
* $msgno is not an array
|
||||
* DO NOT MOVE THE MAIL IN TRASH, DESTROY THE MAIL REALLY
|
||||
* Expunge the mails at the end of the operation
|
||||
* @param array|integer $msgno The message number(s) to remove
|
||||
*/
|
||||
public function mailsDel ($msgno)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -637,8 +711,10 @@ class imap
|
||||
}
|
||||
|
||||
/** Add a new mail in the current folder. The content must be a string
|
||||
containing all the mail (header and body). If the content is invalid, the
|
||||
directory listing can provide erroneous data */
|
||||
* containing all the mail (header and body). If the content is invalid, the
|
||||
* directory listing can provide erroneous data
|
||||
* @param string $content the content of the mail to add
|
||||
*/
|
||||
public function mailAdd ($content)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -657,7 +733,8 @@ class imap
|
||||
/////////////////
|
||||
/// QUOTA ///
|
||||
/////////////////
|
||||
/** Return the quota used by the user in Mo */
|
||||
/** Return the quota used by the user in Mo
|
||||
*/
|
||||
public function getQuota ()
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -675,13 +752,16 @@ class imap
|
||||
/// FLAGS ///
|
||||
/////////////////
|
||||
/** Set the flags of the msgno. If msgno is an array, the flags will be write
|
||||
on the list of mails. The others flags of the email are not modified.
|
||||
The flags must be an array containing :
|
||||
\Seen Message has been read
|
||||
\Answered Message has been answered
|
||||
\Flagged Message is "flagged" for urgent/special attention
|
||||
\Deleted Message is "deleted" for removal by later EXPUNGE
|
||||
\Draft Message has not completed composition (marked as a draft). */
|
||||
* on the list of mails. The others flags of the email are not modified.
|
||||
* The flags must be an array containing :
|
||||
* \Seen Message has been read
|
||||
* \Answered Message has been answered
|
||||
* \Flagged Message is "flagged" for urgent/special attention
|
||||
* \Deleted Message is "deleted" for removal by later EXPUNGE
|
||||
* \Draft Message has not completed composition (marked as a draft).
|
||||
* @param integer|array $msgno The messages number(s) to add the flags
|
||||
* @param array $flags The flags to add
|
||||
*/
|
||||
public function setFlag ($msgno, $flags)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -698,14 +778,17 @@ class imap
|
||||
}
|
||||
|
||||
/** Unset the flags of the msgno. If msgno is an array, the flags will be
|
||||
write on the list of mails. The others flags of the email are not
|
||||
modified.
|
||||
The flags must be an array containing :
|
||||
\Seen Message has been read
|
||||
\Answered Message has been answered
|
||||
\Flagged Message is "flagged" for urgent/special attention
|
||||
\Deleted Message is "deleted" for removal by later EXPUNGE
|
||||
\Draft Message has not completed composition (marked as a draft). */
|
||||
* write on the list of mails. The others flags of the email are not
|
||||
* modified.
|
||||
* The flags must be an array containing :
|
||||
* \Seen Message has been read
|
||||
* \Answered Message has been answered
|
||||
* \Flagged Message is "flagged" for urgent/special attention
|
||||
* \Deleted Message is "deleted" for removal by later EXPUNGE
|
||||
* \Draft Message has not completed composition (marked as a draft).
|
||||
* @param integer|array $msgno The messages number(s) to remove the flags
|
||||
* @param array $flags The flags to remove
|
||||
*/
|
||||
public function unsetFlag ($msgno, $flags)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -722,8 +805,10 @@ class imap
|
||||
}
|
||||
|
||||
/** Mark mail(s) as read.
|
||||
If msgno is an array, a list of mails will be modified.
|
||||
If msgno is an integer, only one mail will be modified */
|
||||
* If msgno is an array, a list of mails will be modified.
|
||||
* If msgno is an integer, only one mail will be modified
|
||||
* @param integer|array $msgno The messages number(s) to mark as read
|
||||
*/
|
||||
public function markMailAsRead ($msgno)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
@@ -740,8 +825,10 @@ class imap
|
||||
}
|
||||
|
||||
/** Mark mail(s) as unread.
|
||||
If msgno is an array, a list of mails will be modified.
|
||||
If msgno is an integer, only one mail will be modified */
|
||||
* If msgno is an array, a list of mails will be modified.
|
||||
* If msgno is an integer, only one mail will be modified
|
||||
* @param integer|array $msgno The messages number(s) to mark as unread
|
||||
*/
|
||||
public function markMailAsUnread ($msgno)
|
||||
{
|
||||
if ($this->mailbox === null)
|
||||
|
||||
29
inifile.php
29
inifile.php
@@ -8,8 +8,12 @@
|
||||
class inifile
|
||||
{
|
||||
/** Return an array with the .ini file content
|
||||
If the sections are true, the sections are analyzed too
|
||||
This function is the same as parse_ini_file PHP internal */
|
||||
* If the sections are true, the sections are analyzed too
|
||||
* This function is the same as parse_ini_file PHP internal
|
||||
* @param string $file The ini file to read
|
||||
* @param boolean|null $sections Manage the sections if true. False by
|
||||
* default
|
||||
*/
|
||||
public function getFile ($file, $sections=false)
|
||||
{
|
||||
if (! file_exists ($file))
|
||||
@@ -22,8 +26,12 @@ class inifile
|
||||
}
|
||||
|
||||
/** Return an array with the .ini string content
|
||||
If the sections are true, the sections are analyzed too
|
||||
This function is the same as parse_ini_string PHP internal */
|
||||
* If the sections are true, the sections are analyzed too
|
||||
* This function is the same as parse_ini_string PHP internal
|
||||
* @param string $string The ini string to read
|
||||
* @param boolean|null $sections Manage the sections if true. False by
|
||||
* default
|
||||
*/
|
||||
public function getString ($string, $sections=false)
|
||||
{
|
||||
$res = parse_ini_string ($string, $sections);
|
||||
@@ -58,7 +66,10 @@ class inifile
|
||||
}
|
||||
|
||||
/** Return a string containing a .ini content from the provided array.
|
||||
If the sections are true, define the first child of the array as sections
|
||||
* If the sections are true, define the first child of the array as sections
|
||||
* @param array $array The array read from a .ini file
|
||||
* @param boolean|null $sections Manage the sections if true. False by
|
||||
* default
|
||||
*/
|
||||
public function setString ($array, $sections=false)
|
||||
{
|
||||
@@ -132,8 +143,12 @@ class inifile
|
||||
}
|
||||
|
||||
/** Save a file containing a .ini content from the provided array.
|
||||
Don't create the directory if it doesn't exists
|
||||
If the sections are true, define the first child of the array as sections
|
||||
* Don't create the directory if it doesn't exists
|
||||
* If the sections are true, define the first child of the array as sections
|
||||
* @param string $file The .ini file to store
|
||||
* @param array $array The array to store in file
|
||||
* @param boolean|null $sections Manage the sections if true. False by
|
||||
* default
|
||||
*/
|
||||
public function setFile ($file, $array, $sections=false)
|
||||
{
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
/** Manage the IP addresses conversions */
|
||||
class ipaddresses
|
||||
{
|
||||
/** Return true if the provided IP address is valid (IPv4 or IPv6) */
|
||||
/** Return true if the provided IP address is valid (IPv4 or IPv6)
|
||||
* @param string $ip The IP Address to validate
|
||||
*/
|
||||
public function validIPAddress ($ip)
|
||||
{
|
||||
if (!is_string ($ip) || $ip === "")
|
||||
@@ -19,7 +21,9 @@ class ipaddresses
|
||||
return $rc;
|
||||
}
|
||||
|
||||
/** Return true if the provided IP address is valid and is IPv4 */
|
||||
/** Return true if the provided IP address is valid and is IPv4
|
||||
* @param string $ip The IP Address to validate
|
||||
*/
|
||||
public function validIPv4Address ($ip)
|
||||
{
|
||||
if (!is_string ($ip) || $ip === "")
|
||||
@@ -31,7 +35,9 @@ class ipaddresses
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Return true if the provided IP address is valid and is IPv6 */
|
||||
/** Return true if the provided IP address is valid and is IPv6
|
||||
* @param string $ip The IP Address to validate
|
||||
*/
|
||||
public function validIPv6Address ($ip)
|
||||
{
|
||||
if (!is_string ($ip) || $ip === "")
|
||||
@@ -44,10 +50,12 @@ class ipaddresses
|
||||
}
|
||||
|
||||
/** Return the IPv6 uncompressed (all the fields exists). They are not filled
|
||||
by zeros
|
||||
If the provided IP is IPv4, there is no change applied
|
||||
Return False if the parameter is invalid
|
||||
Based on http://www.weberdev.com/get_example.php3?ExampleID=3921 */
|
||||
* by zeros
|
||||
* If the provided IP is IPv4, there is no change applied
|
||||
* Return False if the parameter is invalid
|
||||
* Based on http://www.weberdev.com/get_example.php3?ExampleID=3921
|
||||
* @param string $ip The IP address to uncompress
|
||||
*/
|
||||
public function uncompressIPv6 ($ip)
|
||||
{
|
||||
if (! is_string ($ip) || $ip === "")
|
||||
@@ -80,11 +88,13 @@ class ipaddresses
|
||||
return $ip;
|
||||
}
|
||||
|
||||
/* Get an IPv6 address with the format
|
||||
x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x
|
||||
and return it with format
|
||||
xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx
|
||||
Return false if the IP provided is not complete */
|
||||
/** Get an IPv6 address with the format
|
||||
* x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x
|
||||
* and return it with format
|
||||
* xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx
|
||||
* Return false if the IP provided is not complete
|
||||
* @param string $ipv6 The IPv6 to group
|
||||
*/
|
||||
public function groupIPv6 ($ipv6)
|
||||
{
|
||||
if (! is_string ($ipv6) || $ipv6 === "")
|
||||
@@ -106,9 +116,11 @@ class ipaddresses
|
||||
return $new;
|
||||
}
|
||||
|
||||
/* Return the IP adddress with filling the fields with the missing zeros.
|
||||
Valid only on IPv6 (but don't change anything if the provided address is
|
||||
IPv4) */
|
||||
/** Return the IP adddress with filling the fields with the missing zeros.
|
||||
* Valid only on IPv6 (but don't change anything if the provided address is
|
||||
* IPv4)
|
||||
* @param string $ip The IP to complete
|
||||
*/
|
||||
public function completeAddressWithZero ($ip)
|
||||
{
|
||||
if (! is_string ($ip) || $ip === "")
|
||||
@@ -139,8 +151,11 @@ class ipaddresses
|
||||
throw new \Exception (dgettext("domframework", "Invalid IP address"), 500);
|
||||
}
|
||||
|
||||
/* Return the provided CIDR in binary. Length must be in bytes.
|
||||
Return FALSE if the parameters are invalid */
|
||||
/** Return the provided CIDR in binary. Length must be in bytes.
|
||||
* Return FALSE if the parameters are invalid
|
||||
* @param integer $cidr The CIDR to convert
|
||||
* @param integer $length The length to use
|
||||
*/
|
||||
public function cidrToBin ($cidr, $length)
|
||||
{
|
||||
if (! is_numeric ($cidr) || $cidr < 0 || $cidr > 128)
|
||||
@@ -156,8 +171,14 @@ class ipaddresses
|
||||
return pack ('H*', $this->str_base_convert ($val, 2, 16));
|
||||
}
|
||||
|
||||
/* Base conversion with 128 bits support for IPv6
|
||||
Based on http://fr2.php.net/manual/en/function.base-convert.php#109660 */
|
||||
/** Base conversion with 128 bits support for IPv6
|
||||
* Based on http://fr2.php.net/manual/en/function.base-convert.php#109660
|
||||
* @param string $str The string to convert
|
||||
* @param integer|null $frombase The base of the provided string (10 by
|
||||
* default)
|
||||
* @param integer|null $tobase The base of the returned string (36 by
|
||||
* default)
|
||||
*/
|
||||
public function str_base_convert($str, $frombase=10, $tobase=36)
|
||||
{
|
||||
$str = trim ($str);
|
||||
@@ -194,9 +215,11 @@ class ipaddresses
|
||||
return $s;
|
||||
}
|
||||
|
||||
/* Reverse the provided IP address
|
||||
The IPv6 are returned in format :
|
||||
x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x */
|
||||
/** Reverse the provided IP address
|
||||
* The IPv6 are returned in format :
|
||||
* x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x
|
||||
* @param string $ipReverse The IPv6 to reverse
|
||||
*/
|
||||
function reverseIPAddress ($ipReverse)
|
||||
{
|
||||
if (!is_string ($ipReverse) || $ipReverse === "")
|
||||
@@ -229,10 +252,12 @@ class ipaddresses
|
||||
throw new \Exception (dgettext("domframework", "Invalid IP address"), 500);
|
||||
}
|
||||
|
||||
/* This function return the CIDR associated to the provided netmask
|
||||
Ex. Return 24 for a mask 255.255.255.0
|
||||
Work only in IPv4
|
||||
Return FALSE if the provided IP is invalid */
|
||||
/** This function return the CIDR associated to the provided netmask
|
||||
* Ex. Return 24 for a mask 255.255.255.0
|
||||
* Work only in IPv4
|
||||
* Return FALSE if the provided IP is invalid
|
||||
* @param string $netmask The mask to convert in CIDR
|
||||
*/
|
||||
public function netmask2cidr ($netmask)
|
||||
{
|
||||
$netmask = ip2long ($netmask);
|
||||
|
||||
51
language.php
51
language.php
@@ -24,10 +24,11 @@ class language
|
||||
public $cacheDir = "data/locale";
|
||||
|
||||
/** Choose the best language in the browser list and which is available in
|
||||
locale path
|
||||
@param string|null $repLocale Directory where are stored the translations
|
||||
@param string|null $languageCode The coding langugage of the soft
|
||||
@return string The choosed locale whithout charset (like fr_FR) */
|
||||
* locale path
|
||||
* @param string|null $repLocale Directory where are stored the translations
|
||||
* @param string|null $languageCode The coding langugage of the soft
|
||||
* @return string The choosed locale whithout charset (like fr_FR)
|
||||
*/
|
||||
function languageSelection ($repLocale = "./locale", $languageCode = "fr_FR")
|
||||
{
|
||||
$arrAccept = array ();
|
||||
@@ -128,8 +129,9 @@ class language
|
||||
}
|
||||
|
||||
/** Return the language recorded in the Cookie. Check if this language is
|
||||
allowed
|
||||
@return string The language allowed or FALSE */
|
||||
* allowed
|
||||
* @return string The language allowed or FALSE
|
||||
*/
|
||||
function languageCookie ($cookieName, $repLocale = "./locale")
|
||||
{
|
||||
if (!isset ($_COOKIE[$cookieName]))
|
||||
@@ -143,17 +145,19 @@ class language
|
||||
}
|
||||
|
||||
/** Set the cookie with a TTL of one month
|
||||
@param string $cookieName The name of the cookie
|
||||
@param string $languageCode Language to store
|
||||
@param string $sitepath The site path */
|
||||
* @param string $cookieName The name of the cookie
|
||||
* @param string $languageCode Language to store
|
||||
* @param string $sitepath The site path
|
||||
*/
|
||||
function languageCookieSet ($cookieName, $languageCode, $sitepath)
|
||||
{
|
||||
@setcookie ($cookieName, $languageCode, time()+60*60*24*30, $sitepath);
|
||||
}
|
||||
|
||||
/** Return an array with all the languages available in the $repLocale dir
|
||||
The languages are in the format 'en_US' without the codeset.
|
||||
Return FALSE if there is an error */
|
||||
* The languages are in the format 'en_US' without the codeset.
|
||||
* Return FALSE if there is an error
|
||||
*/
|
||||
function languageTraductionsList ($repLocale = "./locale")
|
||||
{
|
||||
if (! is_dir ($repLocale) || ! is_readable ($repLocale))
|
||||
@@ -172,10 +176,12 @@ class language
|
||||
return $list;
|
||||
}
|
||||
|
||||
/** Return the full text of the category
|
||||
* Return false if it doesn't exists
|
||||
* @param string $category The category to analyze
|
||||
*/
|
||||
private function languageCategoryText ($category)
|
||||
{
|
||||
// Renvoie en texte la catégorie fournie en entier
|
||||
// Renvoie FALSE si elle n'existe pas
|
||||
$categories[LC_ALL] = "LC_ALL";
|
||||
$categories[LC_COLLATE] = "LC_COLLATE";
|
||||
$categories[LC_CTYPE] = "LC_CTYPE";
|
||||
@@ -189,12 +195,12 @@ class language
|
||||
}
|
||||
|
||||
/** This function manage the cache of $package.mo files as Apache cache them
|
||||
It return the directory to use
|
||||
@param string $languageCode Language with format "fr_FR"
|
||||
@param string|null $package The package name of the soft ($package.mo
|
||||
file). "messages" by default
|
||||
@param string|null $category The folder name LC_MESSAGES by default
|
||||
@param string|null $repLocale The folder where all the locales are stored
|
||||
* It return the directory to use
|
||||
* @param string $languageCode Language with format "fr_FR"
|
||||
* @param string|null $package The package name of the soft ($package.mo
|
||||
* file). "messages" by default
|
||||
* @param string|null $category The folder name LC_MESSAGES by default
|
||||
* @param string|null $repLocale The folder where all the locales are stored
|
||||
*/
|
||||
function languageCache ($languageCode, $package="messages",
|
||||
$category=LC_MESSAGES, $repLocale = "./locale")
|
||||
@@ -255,6 +261,13 @@ class language
|
||||
return $moFile;
|
||||
}
|
||||
|
||||
/** Start the Gettext support with the cached file .mo provided as parameter
|
||||
* @param string $moFile The .mo file
|
||||
* @param string $languageCode The language code to use
|
||||
* @param integer $category the LC_ type to use
|
||||
* @param string|null $repLocale The locale directory. Use "./locale" if not
|
||||
* provided
|
||||
*/
|
||||
function languageActivation ($moFile, $languageCode, $category = LC_MESSAGES,
|
||||
$repLocale = "./locale")
|
||||
{
|
||||
|
||||
5
mail.php
5
mail.php
@@ -181,7 +181,7 @@ class mail
|
||||
|
||||
/** Return the content array of the section
|
||||
* @param string $sectionID The section ID to get
|
||||
* @param array The content of the section
|
||||
* @return array The content of the section
|
||||
*/
|
||||
private function sectionGet ($sectionID)
|
||||
{
|
||||
@@ -967,7 +967,7 @@ class mail
|
||||
}
|
||||
|
||||
/** Set the subject
|
||||
* @param string In UTF8
|
||||
* @param string $subject In UTF8
|
||||
*/
|
||||
public function setSubject ($subject)
|
||||
{
|
||||
@@ -1148,6 +1148,7 @@ class mail
|
||||
/** Get a generic header
|
||||
* If there is multiple headers with the same name, return the first
|
||||
* @param string $header The header to get
|
||||
* @param array|null $headers Optional headers to examine
|
||||
* @return string|bool the literal value or false if it doesn't exist
|
||||
*/
|
||||
public function getHeader ($header, $headers=null)
|
||||
|
||||
69
markdown.php
69
markdown.php
@@ -9,10 +9,13 @@ class markdown
|
||||
/** To debug the markdown analyzer, activate the option */
|
||||
public $debug = false;
|
||||
|
||||
/** The list of the HTML elements used by block */
|
||||
private $blockid = array ("<h1>","<h2>","<h3>","<h4>","<h5>","<h6>",
|
||||
"<hr/>");
|
||||
|
||||
/** Convert the markdown text to html */
|
||||
/** Convert the markdown text to html
|
||||
* @param string $markdown The markdown to convert
|
||||
*/
|
||||
public function html ($markdown)
|
||||
{
|
||||
$markdown = rtrim ($markdown);
|
||||
@@ -47,7 +50,9 @@ class markdown
|
||||
return $html;
|
||||
}
|
||||
|
||||
/** Search and replace in the paragraph on one line */
|
||||
/** Search and replace in the paragraph on one line
|
||||
* @param string $line The line to analyze
|
||||
*/
|
||||
private function searchReplace ($line)
|
||||
{
|
||||
if ($this->debug)
|
||||
@@ -118,9 +123,10 @@ class markdown
|
||||
}
|
||||
|
||||
/** Return HTML code corresponding to the code block
|
||||
@param array $text The Markdown text to translate split by \n
|
||||
@param integer $depth The depth of current bloc (in number of space)
|
||||
@param integer $pos The start line number of the bloc */
|
||||
* @param array $text The Markdown text to translate split by \n
|
||||
* @param integer $depth The depth of current bloc (in number of space)
|
||||
* @param integer $pos The start line number of the bloc
|
||||
*/
|
||||
private function typeCode ($text, $depth, &$pos)
|
||||
{
|
||||
if ($this->debug) echo "CALL typeCode (\$text, $depth, $pos)\n";
|
||||
@@ -143,9 +149,10 @@ class markdown
|
||||
}
|
||||
|
||||
/** Return HTML code corresponding to the OL block
|
||||
@param array $text The Markdown text to translate split by \n
|
||||
@param integer $depth The depth of current bloc (in number of space)
|
||||
@param integer $pos The start line number of the bloc */
|
||||
* @param array $text The Markdown text to translate split by \n
|
||||
* @param integer $depth The depth of current bloc (in number of space)
|
||||
* @param integer $pos The start line number of the bloc
|
||||
*/
|
||||
private function typeOL ($text, $depth, &$pos)
|
||||
{
|
||||
if ($this->debug) echo "CALL typeOL (\$text, $depth, $pos)\n";
|
||||
@@ -155,9 +162,10 @@ class markdown
|
||||
}
|
||||
|
||||
/** Return HTML code corresponding to the UL block
|
||||
@param array $text The Markdown text to translate split by \n
|
||||
@param integer $depth The depth of current bloc (in number of space)
|
||||
@param integer $pos The start line number of the bloc */
|
||||
* @param array $text The Markdown text to translate split by \n
|
||||
* @param integer $depth The depth of current bloc (in number of space)
|
||||
* @param integer $pos The start line number of the bloc
|
||||
*/
|
||||
private function typeUL ($text, $depth, &$pos)
|
||||
{
|
||||
if ($this->debug) echo "CALL typeUL (\$text, $depth, $pos)\n";
|
||||
@@ -166,6 +174,12 @@ class markdown
|
||||
return $content;
|
||||
}
|
||||
|
||||
/** Return the HTML code corresponding to the OL/UL block
|
||||
* @param array $text The Markdown text to translate split by \n
|
||||
* @param integer $depth The depth of current bloc (in number of space)
|
||||
* @param integer $pos The start line number of the bloc
|
||||
* @param string $type The block type : "ul" or "ol"
|
||||
*/
|
||||
private function typeOLUL ($text, $depth, &$pos, $type)
|
||||
{
|
||||
if ($this->debug) echo "CALL typeOLUL (\$text, $depth, $pos, $type)\n";
|
||||
@@ -230,8 +244,12 @@ class markdown
|
||||
}
|
||||
|
||||
/** Return HTML code corresponding to the NONE block
|
||||
The NONE type exists only on empty strings. Just skip the current and
|
||||
empty line, and return an empty string */
|
||||
* The NONE type exists only on empty strings. Just skip the current and
|
||||
* empty line, and return an empty string
|
||||
* @param string $text The Markdown text to translate split by \n
|
||||
* @param integer $depth The depth of the current bloc (in number of space)
|
||||
* @param integer $pos The start line number of the bloc
|
||||
*/
|
||||
private function typeNONE ($text, $depth, &$pos)
|
||||
{
|
||||
if ($this->debug) echo "CALL typeNONE (\$text, $depth, $pos)\n";
|
||||
@@ -240,9 +258,10 @@ class markdown
|
||||
}
|
||||
|
||||
/** Return HTML code corresponding to the P block
|
||||
@param array $text The Markdown text to translate split by \n
|
||||
@param integer $depth The depth of current bloc (in number of space)
|
||||
@param integer $pos The start line number of the bloc */
|
||||
* @param array $text The Markdown text to translate split by \n
|
||||
* @param integer $depth The depth of current bloc (in number of space)
|
||||
* @param integer $pos The start line number of the bloc
|
||||
*/
|
||||
private function typeP ($text, $depth, &$pos)
|
||||
{
|
||||
if ($this->debug) echo "CALL typeP (\$text, $depth, $pos)\n";
|
||||
@@ -276,10 +295,11 @@ class markdown
|
||||
}
|
||||
|
||||
/** Detect the type of the text and call the appropriate function *
|
||||
@param array $text The Markdown text to translate split by \n
|
||||
@param integer $depth The depth of current bloc (in number of space)
|
||||
@param integer $pos The start line number of the bloc
|
||||
@return the HTML code */
|
||||
* @param array $text The Markdown text to translate split by \n
|
||||
* @param integer $depth The depth of current bloc (in number of space)
|
||||
* @param integer $pos The start line number of the bloc
|
||||
* @return the HTML code
|
||||
*/
|
||||
private function detectBlock ($text, $depth, &$pos)
|
||||
{
|
||||
if ($this->debug) echo "CALL detectBlock (\$text, $depth, $pos)\n";
|
||||
@@ -323,7 +343,9 @@ class markdown
|
||||
}
|
||||
|
||||
/** Return the Type of object in the provided line
|
||||
p, ul, ol, code */
|
||||
* p, ul, ol, code
|
||||
* @param string $line The line to get the type
|
||||
*/
|
||||
private function lineType ($line)
|
||||
{
|
||||
if (! isset ($line{0}))
|
||||
@@ -338,8 +360,9 @@ class markdown
|
||||
}
|
||||
|
||||
/** Return the depth of the provided line
|
||||
@param string $line Line to analyze
|
||||
@return the depth of the line */
|
||||
* @param string $line Line to analyze
|
||||
* @return the depth of the line
|
||||
*/
|
||||
private function depth ($line)
|
||||
{
|
||||
return strspn ($line, " ");
|
||||
|
||||
28
module.php
28
module.php
@@ -7,14 +7,16 @@
|
||||
class module
|
||||
{
|
||||
/** The modules are not allowed if $toplevel=0
|
||||
The modules can be in a module directory if $toplevel=1
|
||||
The modules can be in the parent directory if $toplevel=2
|
||||
The modules can be in the local directory if $toplevel=4
|
||||
The values can be added to allow multiple possibilities */
|
||||
* The modules can be in a module directory if $toplevel=1
|
||||
* The modules can be in the parent directory if $toplevel=2
|
||||
* The modules can be in the local directory if $toplevel=4
|
||||
* The values can be added to allow multiple possibilities
|
||||
*/
|
||||
public $toplevel = 0;
|
||||
|
||||
/** List all the available (enable or disable) modules
|
||||
@return array The list of the available modules names with the path */
|
||||
* @return array The list of the available modules names with the path
|
||||
*/
|
||||
public function listAvailable ()
|
||||
{
|
||||
$list = array ();
|
||||
@@ -47,10 +49,11 @@ class module
|
||||
}
|
||||
|
||||
/** List all the enable modules coming from the configuration and available
|
||||
in the system
|
||||
@param array $confModules the list of the available modules coming from
|
||||
the configuration. Can have some non available modules.
|
||||
@return array the list of the available modules names with the path */
|
||||
* in the system
|
||||
* @param array $confModules the list of the available modules coming from
|
||||
* the configuration. Can have some non available modules.
|
||||
* @return array the list of the available modules names with the path
|
||||
*/
|
||||
public function listEnable ($confModules)
|
||||
{
|
||||
$listAvailable = $this->listAvailable ();
|
||||
@@ -65,8 +68,10 @@ class module
|
||||
}
|
||||
|
||||
/** Return the name of the module translated in the provided language
|
||||
The module name must be defined in the translation under the "modulename"
|
||||
item
|
||||
* The module name must be defined in the translation under the "modulename"
|
||||
* item
|
||||
* @param string $modulepath The module path
|
||||
* @param string $lang The lang to use
|
||||
*/
|
||||
public function translateName ($modulepath, $lang)
|
||||
{
|
||||
@@ -75,4 +80,3 @@ class module
|
||||
return basename ($modulepath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ class outputhtml extends output
|
||||
* @param array|null $replacement Replace the {key}=>value
|
||||
* @param array|null $variable PHP variables send to the view and to layout
|
||||
* (can be processed by foreach, if...)
|
||||
* @param string|null $module The module name to use if needed
|
||||
* @return Exit from PHP at the end of HTML display
|
||||
*/
|
||||
public function out ($data, $title = FALSE,
|
||||
@@ -131,7 +132,7 @@ EOT;
|
||||
|
||||
/** Get the layout and provide it the variables. The variables will be push in
|
||||
* global to the layout (they can be used like $XX)
|
||||
* @param string the layout file to load
|
||||
* @param string $layout the layout file to load
|
||||
* @param array $variables The variables array to push to the layout
|
||||
* @return string the Layout with variables interpreted */
|
||||
private function layoutVariables ($layout, $variables)
|
||||
|
||||
@@ -22,6 +22,7 @@ class outputrest extends output
|
||||
* @param array|null $replacement Replace the {key}=>value
|
||||
* @param array|null $variable PHP variables send to the view and to layout
|
||||
* (can be processed by foreach, if...)
|
||||
* @param string|null $module The module name to use if needed
|
||||
* @return Exit from PHP at the end of HTML display
|
||||
*/
|
||||
public function out ($data, $title = FALSE,
|
||||
|
||||
@@ -12,8 +12,10 @@ class ratelimit
|
||||
public $unittime = 60;
|
||||
|
||||
/** The function set a rate-limit
|
||||
@return bool true if the rate-limit is not overloaded
|
||||
false if the rate-limit is overloaded */
|
||||
* @param string $name The rate-limit object to set
|
||||
* @return bool true if the rate-limit is not overloaded
|
||||
* false if the rate-limit is overloaded
|
||||
*/
|
||||
public function set ($name)
|
||||
{
|
||||
throw new Exception (dgettext("domframework",
|
||||
@@ -22,7 +24,9 @@ class ratelimit
|
||||
}
|
||||
|
||||
/** The function delete a rate-limit
|
||||
@return bool */
|
||||
* @param string $name The rate-limit object to del
|
||||
* @return bool
|
||||
*/
|
||||
public function del ($name)
|
||||
{
|
||||
throw new Exception (dgettext("domframework",
|
||||
@@ -31,7 +35,8 @@ class ratelimit
|
||||
}
|
||||
|
||||
/** The function clean the storage
|
||||
@return bool */
|
||||
* @return bool
|
||||
*/
|
||||
public function clean ()
|
||||
{
|
||||
throw new Exception (dgettext("domframework",
|
||||
|
||||
@@ -15,8 +15,10 @@ class ratelimitfile extends ratelimit
|
||||
public $debug = false;
|
||||
|
||||
/** The function set a rate-limit
|
||||
@return bool true if the rate-limit is not overloaded
|
||||
false if the rate-limit is overloaded */
|
||||
* @param string $name The rate-limit object to set
|
||||
* @return bool true if the rate-limit is not overloaded
|
||||
* false if the rate-limit is overloaded
|
||||
*/
|
||||
public function set ($name)
|
||||
{
|
||||
$this->storageOK();
|
||||
@@ -62,7 +64,9 @@ class ratelimitfile extends ratelimit
|
||||
}
|
||||
|
||||
/** The function delete a rate-limit
|
||||
@return bool */
|
||||
* @param string $name The rate-limit object to del
|
||||
* @return bool
|
||||
*/
|
||||
public function del ($name)
|
||||
{
|
||||
$this->storageOK();
|
||||
@@ -77,7 +81,8 @@ class ratelimitfile extends ratelimit
|
||||
}
|
||||
|
||||
/** The function clean the storage with expired entries
|
||||
@return bool */
|
||||
* @return bool
|
||||
*/
|
||||
public function clean ()
|
||||
{
|
||||
$this->storageOK();
|
||||
@@ -95,7 +100,8 @@ class ratelimitfile extends ratelimit
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Check the storageDir state */
|
||||
/** Check the storageDir state
|
||||
*/
|
||||
private function storageOK ()
|
||||
{
|
||||
if (file_exists ($this->storageDir))
|
||||
|
||||
78
users.php
78
users.php
@@ -1,67 +1,89 @@
|
||||
<?php
|
||||
/** The abstraction class of the users
|
||||
Allow to manage the users in multiple storages (SQL, HTPasswd, passwd file).
|
||||
CRUD the users and allow to modify the password */
|
||||
* Allow to manage the users in multiple storages (SQL, HTPasswd, passwd file).
|
||||
* CRUD the users and allow to modify the password
|
||||
*/
|
||||
class users
|
||||
{
|
||||
/** Connect to the storage */
|
||||
/** Connect to the storage
|
||||
*/
|
||||
public function connect ()
|
||||
{
|
||||
}
|
||||
|
||||
/** Initialise the storage
|
||||
Create the structure of data needed to the class */
|
||||
* Create the structure of data needed to the class
|
||||
*/
|
||||
public function initStorage ()
|
||||
{
|
||||
}
|
||||
|
||||
/** Create a new user
|
||||
If the password is not provided, create a default passwd (can be disable
|
||||
password) */
|
||||
* If the password is not provided, create a default passwd (can be disable
|
||||
* password)
|
||||
* @param string $email The email to create
|
||||
* @param string $firstname The firstname to create
|
||||
* @param string $lastname The lastname to create
|
||||
* @param string|null $password The password of the user
|
||||
*/
|
||||
public function adduser ($email, $firstname, $lastname, $password=null)
|
||||
{
|
||||
}
|
||||
|
||||
/** Delete a user */
|
||||
/** Delete a user
|
||||
* @param string $email The email to delete
|
||||
*/
|
||||
public function deluser ($email)
|
||||
{
|
||||
}
|
||||
|
||||
/** Update a user */
|
||||
/** Update a user
|
||||
* @param string $oldemail The old email to update
|
||||
* @param string $newemail The new mail to store
|
||||
* @param string $firstname The new firstname to store
|
||||
* @param string $lastname The lastname to store
|
||||
*/
|
||||
public function updateuser ($oldemail, $newemail, $firstname, $lastname)
|
||||
{
|
||||
}
|
||||
|
||||
/** List the users */
|
||||
/** List the users
|
||||
*/
|
||||
public function listusers ()
|
||||
{
|
||||
}
|
||||
|
||||
/** Change password
|
||||
@param string $email the user email to change the password
|
||||
@param string $oldpassword The old password (to check if the user have the
|
||||
rights to change the password)
|
||||
@param string $newpassword The new password to be recorded */
|
||||
* @param string $email the user email to change the password
|
||||
* @param string $oldpassword The old password (to check if the user have the
|
||||
* rights to change the password)
|
||||
* @param string $newpassword The new password to be recorded
|
||||
*/
|
||||
public function changepassword ($email, $oldpassword, $newpassword)
|
||||
{
|
||||
}
|
||||
|
||||
/** Overwrite password (without oldpassword check)
|
||||
Must be reserved to the administrators. For the users, use changepassword
|
||||
method
|
||||
@param string $email the user email to change the password
|
||||
@param string $newpassword The new password to be recorded */
|
||||
* Must be reserved to the administrators. For the users, use changepassword
|
||||
* method
|
||||
* @param string $email the user email to change the password
|
||||
* @param string $newpassword The new password to be recorded
|
||||
*/
|
||||
public function overwritepassword ($email, $newpassword)
|
||||
{
|
||||
}
|
||||
|
||||
/** Check if the provided password is correctely associated to the email user
|
||||
* @param string $email The email to validate
|
||||
* @param string $password The password to validate
|
||||
*/
|
||||
public function checkValidPassword ($email, $password)
|
||||
{
|
||||
}
|
||||
|
||||
/** Check if the user provided is correct */
|
||||
/** Check if the user provided is correct
|
||||
* @param string $email The email to validate
|
||||
*/
|
||||
public function checkEmail ($email)
|
||||
{
|
||||
if (! is_string ($email))
|
||||
@@ -79,7 +101,9 @@ class users
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Check if the firstname provided is correct */
|
||||
/** Check if the firstname provided is correct
|
||||
* @param string $firstname The firstname to check
|
||||
*/
|
||||
public function checkFirstname ($firstname)
|
||||
{
|
||||
if (! is_string ($firstname))
|
||||
@@ -97,7 +121,9 @@ class users
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Check if the lastname provided is correct */
|
||||
/** Check if the lastname provided is correct
|
||||
* @param string $lastname The lastname to check
|
||||
*/
|
||||
public function checkLastname ($lastname)
|
||||
{
|
||||
if (! is_string ($lastname))
|
||||
@@ -111,7 +137,9 @@ class users
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Check if the password provided is correct */
|
||||
/** Check if the password provided is correct
|
||||
* @param string $password The password to check
|
||||
*/
|
||||
public function checkPassword ($password)
|
||||
{
|
||||
if (! is_string ($password))
|
||||
@@ -129,7 +157,9 @@ class users
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Crypt the password with the best algorithm available */
|
||||
/** Crypt the password with the best algorithm available
|
||||
* @param string $password The password to crypt
|
||||
*/
|
||||
public function cryptPasswd ($password)
|
||||
{
|
||||
if (! function_exists ("openssl_random_pseudo_bytes"))
|
||||
@@ -149,7 +179,9 @@ class users
|
||||
}
|
||||
|
||||
/** Check if the password is enough complex
|
||||
Return True if the password is enough complex */
|
||||
* Return True if the password is enough complex
|
||||
* @param string $password The password to check
|
||||
*/
|
||||
public function passwdComplexity ($password)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user