dolibarr  20.0.0-beta
Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
Categories Class Reference
Inheritance diagram for Categories:
Inheritance graph
[legend]
Collaboration diagram for Categories:
Collaboration graph
[legend]

Public Member Functions

 __construct ()
 Constructor.
 
 get ($id, $include_childs=false)
 Get properties of a category object. More...
 
 index ($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $type='', $sqlfilters='', $properties='')
 List categories. More...
 
 post ($request_data=null)
 Create category object. More...
 
 put ($id, $request_data=null)
 Update category. More...
 
 delete ($id)
 Delete category. More...
 
 getListForObject ($id, $type, $sortfield="s.rowid", $sortorder='ASC', $limit=0, $page=0)
 List categories of an object. More...
 
 linkObjectById ($id, $type, $object_id)
 Link an object to a category by id. More...
 
 linkObjectByRef ($id, $type, $object_ref)
 Link an object to a category by ref. More...
 
 unlinkObjectById ($id, $type, $object_id)
 Unlink an object from a category by id. More...
 
 unlinkObjectByRef ($id, $type, $object_ref)
 Unlink an object from a category by ref. More...
 
 getObjects ($id, $type, $onlyids=0)
 Get the list of objects in a category. More...
 
- Public Member Functions inherited from DolibarrApi
 __construct ($db, $cachedir='', $refreshCache=false)
 Constructor. More...
 

Protected Member Functions

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

Private Member Functions

 _validate ($data)
 Validate fields before create or update object. More...
 

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. More...
 
static _forge_criteria_callback ($matches)
 Function to forge a SQL criteria from a Generic filter string. More...
 

Detailed Description

Definition at line 36 of file api_categories.class.php.

Member Function Documentation

◆ _cleanObjectDatas()

Categories::_cleanObjectDatas (   $object)
protected

Clean sensible object datas.

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

Reimplemented from DolibarrApi.

Definition at line 655 of file api_categories.class.php.

References $object.

◆ _validate()

Categories::_validate (   $data)
private

Validate fields before create or update object.

Parameters
array | null$dataData to validate
Returns
array Return array with validated mandatory fields and their value
Exceptions
RestException

Definition at line 713 of file api_categories.class.php.

Referenced by post().

◆ delete()

Categories::delete (   $id)

Delete category.

Parameters
int$idCategory ID
Returns
array

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

◆ get()

Categories::get (   $id,
  $include_childs = false 
)

Get properties of a category object.

Return an array with category information

Parameters
int$idID of category
bool$include_childsInclude child categories list (true or false)
Returns
array|mixed data without useless information
Exceptions
RestException

Definition at line 90 of file api_categories.class.php.

◆ getListForObject()

Categories::getListForObject (   $id,
  $type,
  $sortfield = "s.rowid",
  $sortorder = 'ASC',
  $limit = 0,
  $page = 0 
)

List categories of an object.

Get the list of categories linked to an object

Parameters
int$idObject ID
string$typeType of category ('member', 'customer', 'supplier', 'product', 'contact', 'project')
string$sortfieldSort field
string$sortorderSort order
int$limitLimit for list
int$pagePage number
Returns
array Array of category objects
Exceptions
RestException@url GET /object/{type}/{id}

Definition at line 309 of file api_categories.class.php.

◆ getObjects()

Categories::getObjects (   $id,
  $type,
  $onlyids = 0 
)

Get the list of objects in a category.

Parameters
int$idID of category
string$typeType of category ('member', 'customer', 'supplier', 'product', 'contact', 'project')
int$onlyidsReturn only ids of objects (consume less memory)
Returns
mixed

@url GET {id}/objects

Definition at line 736 of file api_categories.class.php.

◆ index()

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

List categories.

Get a list of categories

Parameters
string$sortfieldSort field
string$sortorderSort order
int$limitLimit for list
int$pagePage number
string$typeType of category ('member', 'customer', 'supplier', 'product', 'contact')
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 these properties. Ignored if empty. Comma separated list of properties names
Returns
array Array of category objects
Exceptions
RestException

Definition at line 135 of file api_categories.class.php.

◆ linkObjectById()

Categories::linkObjectById (   $id,
  $type,
  $object_id 
)

Link an object to a category by id.

Parameters
int$idID of category
string$typeType of category ('member', 'customer', 'supplier', 'product', 'contact')
int$object_idID of object
Returns
array
Exceptions
RestException@url POST {id}/objects/{type}/{object_id}

Definition at line 359 of file api_categories.class.php.

◆ linkObjectByRef()

Categories::linkObjectByRef (   $id,
  $type,
  $object_ref 
)

Link an object to a category by ref.

Parameters
int$idID of category
string$typeType of category ('member', 'customer', 'supplier', 'product', 'contact')
string$object_refReference of object
Returns
array
Exceptions
RestException@url POST {id}/objects/{type}/ref/{object_ref}

Definition at line 435 of file api_categories.class.php.

◆ post()

Categories::post (   $request_data = null)

Create category object.

Parameters
array$request_dataRequest data
Returns
int ID of category

Definition at line 194 of file api_categories.class.php.

References _validate().

◆ put()

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

Update category.

Parameters
int$idId of category to update
array$request_dataDatas
Returns
Object Updated object

Definition at line 225 of file api_categories.class.php.

◆ unlinkObjectById()

Categories::unlinkObjectById (   $id,
  $type,
  $object_id 
)

Unlink an object from a category by id.

Parameters
int$idID of category
string$typeType of category ('member', 'customer', 'supplier', 'product', 'contact')
int$object_idID of the object
Returns
array
Exceptions
RestException@url DELETE {id}/objects/{type}/{object_id}

Definition at line 511 of file api_categories.class.php.

◆ unlinkObjectByRef()

Categories::unlinkObjectByRef (   $id,
  $type,
  $object_ref 
)

Unlink an object from a category by ref.

Parameters
int$idID of category
string$typeType of category ('member', 'customer', 'supplier', 'product', 'contact')
string$object_refReference of the object
Returns
array
Exceptions
RestException@url DELETE {id}/objects/{type}/ref/{object_ref}

Definition at line 585 of file api_categories.class.php.


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