dolibarr 20.0.0
Contacts Class Reference
Inheritance diagram for Contacts:
Collaboration diagram for Contacts:

Public Member Functions

 __construct ()
 Constructor.
 
 get ($id, $includecount=0, $includeroles=0)
 Get properties of a contact object.
 
 getByEmail ($email, $includecount=0, $includeroles=0)
 Get properties of a contact object by Email.
 
 index ($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $thirdparty_ids='', $category=0, $sqlfilters='', $includecount=0, $includeroles=0, $properties='')
 List contacts.
 
 post ($request_data=null)
 Create contact object.
 
 put ($id, $request_data=null)
 Update contact.
 
 delete ($id)
 Delete contact.
 
 createUser ($id, $request_data=null)
 Create an user account object from contact (external user)
 
 getCategories ($id, $sortfield="s.rowid", $sortorder='ASC', $limit=0, $page=0)
 Get categories for a contact.
 
 addCategory ($id, $category_id)
 Add a category to a contact.
 
 deleteCategory ($id, $category_id)
 Remove the link between a category and a contact.
 
- 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

 _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 32 of file api_contacts.class.php.

Member Function Documentation

◆ _cleanObjectDatas()

Contacts::_cleanObjectDatas ( $object)
protected

Clean sensible object datas.

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

Reimplemented from DolibarrApi.

Definition at line 563 of file api_contacts.class.php.

References $object.

Referenced by addCategory(), deleteCategory(), get(), getByEmail(), and index().

◆ _validate()

Contacts::_validate ( $data)
private

Validate fields before create or update object.

Parameters
string[] | null$dataData to validate
Returns
string[]
Exceptions
RestException

Definition at line 588 of file api_contacts.class.php.

Referenced by post().

◆ addCategory()

Contacts::addCategory ( $id,
$category_id )

Add a category to a contact.

@url PUT {id}/categories/{category_id}

Parameters
int$idId of contact
int$category_idId of category
Returns
mixed
Exceptions
RestException401 Insufficient rights
RestException404 Category or contact not found

Definition at line 488 of file api_contacts.class.php.

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

◆ createUser()

Contacts::createUser ( $id,
$request_data = null )

Create an user account object from contact (external user)

Parameters
int$idId of contact
array$request_dataRequest datas
Returns
int ID of user

@url POST {id}/createUser @suppress PhanPluginUnknownArrayMethodParamType Luracast limitation

Definition at line 401 of file api_contacts.class.php.

References DolibarrApi\_checkAccessToResource().

◆ delete()

Contacts::delete ( $id)

Delete contact.

Parameters
int$idContact ID
Returns
integer

Definition at line 374 of file api_contacts.class.php.

References DolibarrApi\_checkAccessToResource().

◆ deleteCategory()

Contacts::deleteCategory ( $id,
$category_id )

Remove the link between a category and a contact.

@url DELETE {id}/categories/{category_id}

Parameters
int$idId of contact
int$category_idId of category
Returns
mixed
Exceptions
RestException401 Insufficient rights
RestException404 Category or contact not found

Definition at line 528 of file api_contacts.class.php.

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

◆ get()

Contacts::get ( $id,
$includecount = 0,
$includeroles = 0 )

Get properties of a contact object.

Return an array with contact information

Parameters
int$idID of contact
int$includecountCount and return also number of elements the contact is used as a link for
int$includerolesIncludes roles of the contact
Returns
object data without useless information
Exceptions
RestException

Definition at line 73 of file api_contacts.class.php.

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

◆ getByEmail()

Contacts::getByEmail ( $email,
$includecount = 0,
$includeroles = 0 )

Get properties of a contact object by Email.

Parameters
string$emailEmail of contact
int$includecountCount and return also number of elements the contact is used as a link for
int$includerolesIncludes roles of the contact
Returns
array|mixed data without useless information

@url GET email/{email}

Exceptions
RestException401 Insufficient rights
RestException404 User or group not found

Definition at line 121 of file api_contacts.class.php.

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

◆ getCategories()

Contacts::getCategories ( $id,
$sortfield = "s.rowid",
$sortorder = 'ASC',
$limit = 0,
$page = 0 )

Get categories for a contact.

Parameters
int$idID of contact
string$sortfieldSort field
string$sortorderSort order
int$limitLimit for list
int$pagePage number
Returns
mixed

@url GET {id}/categories

Definition at line 458 of file api_contacts.class.php.

◆ index()

Contacts::index ( $sortfield = "t.rowid",
$sortorder = 'ASC',
$limit = 100,
$page = 0,
$thirdparty_ids = '',
$category = 0,
$sqlfilters = '',
$includecount = 0,
$includeroles = 0,
$properties = '' )

List contacts.

Get a list of contacts

Parameters
string$sortfieldSort field
string$sortorderSort order
int$limitLimit for list
int$pagePage number
string$thirdparty_idsThirdparty ids to filter contacts of (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')"
int$includecountCount and return also number of elements the contact is used as a link for
int$includerolesIncludes roles of the contact
string$propertiesRestrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
Returns
Contact[] Array of contact objects
Exceptions
RestException

Definition at line 175 of file api_contacts.class.php.

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

◆ post()

Contacts::post ( $request_data = null)

Create contact object.

Parameters
array$request_dataRequest datas
Returns
int ID of contact

@suppress PhanPluginUnknownArrayMethodParamType Luracast limitation

Definition at line 280 of file api_contacts.class.php.

References DolibarrApi\_checkValForAPI(), _validate(), and sanitizeVal().

◆ put()

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

Update contact.

Parameters
int$idId of contact to update
array$request_dataDatas
Returns
Object|false Updated object, false when issue toupdate
Exceptions
RestException401
RestException404
RestException500

Definition at line 323 of file api_contacts.class.php.

References DolibarrApi\_checkAccessToResource(), DolibarrApi\_checkValForAPI(), and sanitizeVal().


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