dolibarr 19.0.3
Users Class Reference
Inheritance diagram for Users:
Collaboration diagram for Users:

Public Member Functions

 __construct ()
 Constructor.
 
 index ($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $user_ids=0, $category=0, $sqlfilters='', $properties='')
 List Users.
 
 get ($id, $includepermissions=0)
 Get properties of an user object.
 
 getByLogin ($login, $includepermissions=0)
 Get properties of an user object by login.
 
 getByEmail ($email, $includepermissions=0)
 Get properties of an user object by Email.
 
 getInfo ($includepermissions=0)
 Get more properties of a user.
 
 post ($request_data=null)
 Create user account.
 
 put ($id, $request_data=null)
 Update user account.
 
 getGroups ($id)
 List the groups of a user.
 
 setGroup ($id, $group, $entity=1)
 Add a user into a group.
 
 listGroups ($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $group_ids=0, $sqlfilters='', $properties='')
 List Groups.
 
 infoGroups ($group, $load_members=0)
 Get properties of an group object.
 
 delete ($id)
 Delete account/user.
 
- Public Member Functions inherited from DolibarrApi
 __construct ($db, $cachedir='', $refreshCache=false)
 Constructor.
 

Protected Member Functions

 _cleanObjectDatas ($object)
 Clean sensible object datas.
 
- Protected Member Functions inherited from DolibarrApi
 _checkValForAPI ($field, $value, $object)
 Check and convert a string depending on its type/name.
 
 _filterObjectProperties ($object, $properties)
 Filter properties that will be returned on object.
 
 _checkFilters ($sqlfilters, &$error='')
 Return if a $sqlfilters parameter is valid Function no more used.
 

Private Member Functions

 _cleanUserGroupListDatas ($objectList)
 Clean sensible user group list datas.
 
 _validate ($data)
 Validate fields before create or update object.
 

Additional Inherited Members

- Static Protected Member Functions inherited from DolibarrApi
static _checkAccessToResource ($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
 Check access by user to a given resource.
 
static _forge_criteria_callback ($matches)
 Function to forge a SQL criteria from a Generic filter string.
 

Detailed Description

Definition at line 31 of file api_users.class.php.

Member Function Documentation

◆ _cleanObjectDatas()

Users::_cleanObjectDatas ( $object)
protected

Clean sensible object datas.

Parameters
Object$objectObject to clean
Returns
Object Object with cleaned properties

Reimplemented from DolibarrApi.

Definition at line 671 of file api_users.class.php.

Referenced by get(), getByEmail(), getByLogin(), getGroups(), getInfo(), index(), infoGroups(), and listGroups().

◆ _cleanUserGroupListDatas()

Users::_cleanUserGroupListDatas ( $objectList)
private

Clean sensible user group list datas.

Parameters
array$objectListArray of object to clean
Returns
array Array of cleaned object properties

Definition at line 730 of file api_users.class.php.

Referenced by getInfo().

◆ _validate()

Users::_validate ( $data)
private

Validate fields before create or update object.

Parameters
array | null$dataData to validate
Returns
array
Exceptions
RestException

Definition at line 778 of file api_users.class.php.

◆ delete()

Users::delete ( $id)

Delete account/user.

Parameters
int$idAccount ID
Returns
array
Exceptions
RestException401 Not allowed
RestException404 User not found

Definition at line 637 of file api_users.class.php.

References DolibarrApi\_checkAccessToResource().

◆ get()

Users::get ( $id,
$includepermissions = 0 )

Get properties of an user object.

Parameters
int$idID of user
int$includepermissionsSet this to 1 to have the array of permissions loaded (not done by default for performance purpose)
Returns
array|mixed data without useless information
Exceptions
RestException401 Insufficient rights
RestException404 User or group not found

Definition at line 151 of file api_users.class.php.

References DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().

◆ getByEmail()

Users::getByEmail ( $email,
$includepermissions = 0 )

Get properties of an user object by Email.

Parameters
string$emailEmail of user
int$includepermissionsSet this to 1 to have the array of permissions loaded (not done by default for performance purpose)
Returns
array|mixed Data without useless information

@url GET email/{email}

Exceptions
RestException400 Bad request
RestException401 Insufficient rights
RestException404 User or group not found

Definition at line 229 of file api_users.class.php.

References DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().

◆ getByLogin()

Users::getByLogin ( $login,
$includepermissions = 0 )

Get properties of an user object by login.

Parameters
string$loginLogin of user
int$includepermissionsSet this to 1 to have the array of permissions loaded (not done by default for performance purpose)
Returns
array|mixed Data without useless information

@url GET login/{login}

Exceptions
RestException400 Bad request
RestException401 Insufficient rights
RestException404 User or group not found

Definition at line 190 of file api_users.class.php.

References DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().

◆ getGroups()

Users::getGroups ( $id)

List the groups of a user.

Parameters
int$idId of user
Returns
array Array of group objects
Exceptions
RestException403 Not allowed
RestException404 Not found

@url GET {id}/groups

Definition at line 445 of file api_users.class.php.

References _cleanObjectDatas().

◆ getInfo()

Users::getInfo ( $includepermissions = 0)

Get more properties of a user.

@url GET /info

Parameters
int$includepermissionsSet this to 1 to have the array of permissions loaded (not done by default for performance purpose)
Returns
array|mixed Data without useless information
Exceptions
RestException401 Insufficient rights
RestException404 User or group not found

Definition at line 266 of file api_users.class.php.

References DolibarrApi\_checkAccessToResource(), _cleanObjectDatas(), and _cleanUserGroupListDatas().

◆ index()

Users::index ( $sortfield = "t.rowid",
$sortorder = 'ASC',
$limit = 100,
$page = 0,
$user_ids = 0,
$category = 0,
$sqlfilters = '',
$properties = '' )

List Users.

Get a list of Users

Parameters
string$sortfieldSort field
string$sortorderSort order
int$limitLimit for list
int$pagePage number
string$user_idsUser ids filter field. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i}
int$categoryUse this param to filter list by category
string$sqlfiltersOther criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
string$propertiesRestrict the data returned to theses properties. Ignored if empty. Comma separated list of properties names
Returns
array Array of User objects

Definition at line 72 of file api_users.class.php.

References _cleanObjectDatas(), DolibarrApi\_filterObjectProperties(), and forgeSQLFromUniversalSearchCriteria().

◆ infoGroups()

Users::infoGroups ( $group,
$load_members = 0 )

Get properties of an group object.

Return an array with group informations

@url GET /groups/{group}

Parameters
int$groupID of group
int$load_membersLoad members list or not {@min 0} {@max 1}
Returns
object object of User objects
Exceptions
RestException401 Not allowed
RestException404 User not found

Definition at line 609 of file api_users.class.php.

References _cleanObjectDatas(), and getDolGlobalString().

◆ listGroups()

Users::listGroups ( $sortfield = "t.rowid",
$sortorder = 'ASC',
$limit = 100,
$page = 0,
$group_ids = 0,
$sqlfilters = '',
$properties = '' )

List Groups.

Return an array with a list of Groups

@url GET /groups

Parameters
string$sortfieldSort field
string$sortorderSort order
int$limitLimit for list
int$pagePage number
string$group_idsGroups ids filter field. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i}
string$sqlfiltersOther criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
string$propertiesRestrict the data returned to theses properties. Ignored if empty. Comma separated list of properties names
Returns
array Array of User objects
Exceptions
RestException404 User not found
RestException503 Error

Definition at line 535 of file api_users.class.php.

References _cleanObjectDatas(), DolibarrApi\_filterObjectProperties(), forgeSQLFromUniversalSearchCriteria(), and getDolGlobalString().

◆ post()

Users::post ( $request_data = null)

Create user account.

Parameters
array$request_dataNew user data
Returns
int
Exceptions
RestException401 Not allowed

Definition at line 306 of file api_users.class.php.

◆ put()

Users::put ( $id,
$request_data = null )

Update user account.

Parameters
int$idId of account to update
array$request_dataDatas
Returns
array|mixed Record after update
Exceptions
RestException401 Not allowed
RestException404 Not found
RestException500 System error

Definition at line 361 of file api_users.class.php.

References DolibarrApi\_checkAccessToResource().

◆ setGroup()

Users::setGroup ( $id,
$group,
$entity = 1 )

Add a user into a group.

Parameters
int$idUser ID
int$groupGroup ID
int$entityEntity ID (valid only for superadmin in multicompany transverse mode)
Returns
int 1 if success
Exceptions
RestException401 Not allowed
RestException404 User not found
RestException500 System error

@url GET {id}/setGroup/{group}

Definition at line 483 of file api_users.class.php.

References DolibarrApi\_checkAccessToResource(), and getDolGlobalString().


The documentation for this class was generated from the following file: