dolibarr 21.0.0-alpha
Projects Class Reference
Inheritance diagram for Projects:
Collaboration diagram for Projects:

Public Member Functions

 __construct ()
 Constructor.
 
 get ($id)
 Get properties of a project object.
 
 getByRef ($ref)
 Get properties of a project object.
 
 getByRefExt ($ref_ext)
 Get properties of a project object.
 
 getByMsgId ($email_msgid)
 Get properties of a project object.
 
 index ($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $thirdparty_ids='', $category=0, $sqlfilters='', $properties='', $pagination_data=false)
 List projects.
 
 post ($request_data=null)
 Create project object.
 
 getLines ($id, $includetimespent=0)
 Get tasks of a project.
 
 getRoles ($id, $userid=0)
 Get roles a user is assigned to a project with.
 
 put ($id, $request_data=null)
 Add a task to given project.
 
 delete ($id)
 Delete project.
 
 validate ($id, $notrigger=0)
 Validate a project.
 
- 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 31 of file api_projects.class.php.

Member Function Documentation

◆ _cleanObjectDatas()

Projects::_cleanObjectDatas ( $object)
protected

Clean sensible object datas.

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

Reimplemented from DolibarrApi.

Definition at line 753 of file api_projects.class.php.

References $object.

Referenced by get(), getByMsgId(), getByRef(), getByRefExt(), getLines(), getRoles(), and index().

◆ _validate()

Projects::_validate ( $data)
private

Validate fields before create or update object.

Parameters
array<string,mixed>$data Array with data to verify
Returns
array<string,mixed>
Exceptions
RestException

Definition at line 805 of file api_projects.class.php.

References $object.

Referenced by post().

◆ delete()

Projects::delete ( $id)

Delete project.

Parameters
int$idProject ID
Returns
array @phan-return array{success:array{code:int,message:string}} @phpstan-return array{success:array{code:int,message:string}}

Definition at line 667 of file api_projects.class.php.

References $id, and DolibarrApi\_checkAccessToResource().

◆ get()

Projects::get ( $id)

Get properties of a project object.

Return an array with project information

Parameters
int$idID of project
Returns
Object Object with cleaned properties
Exceptions
RestException

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

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

◆ getByMsgId()

Projects::getByMsgId ( $email_msgid)

Get properties of a project object.

Return an array with project information

Parameters
string$email_msgidEmail msgid of project
Returns
Object Object with cleaned properties

@url GET email_msgid/{email_msgid}

Exceptions
RestException

Definition at line 166 of file api_projects.class.php.

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

◆ getByRef()

Projects::getByRef ( $ref)

Get properties of a project object.

Return an array with project information

Parameters
string$refRef of project
Returns
Object Object with cleaned properties

@url GET ref/{ref}

Exceptions
RestException

Definition at line 104 of file api_projects.class.php.

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

◆ getByRefExt()

Projects::getByRefExt ( $ref_ext)

Get properties of a project object.

Return an array with project information

Parameters
string$ref_extRef_Ext of project
Returns
Object Object with cleaned properties

@url GET ref_ext/{ref_ext}

Exceptions
RestException

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

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

◆ getLines()

Projects::getLines ( $id,
$includetimespent = 0 )

Get tasks of a project.

See also API /tasks

Parameters
int$idId of project
int$includetimespent0=Return only list of tasks. 1=Include a summary of time spent, 2=Include details of time spent lines
Returns
array @phan-return Object[] @phpstan-return Object[]

@url GET {id}/tasks

Definition at line 398 of file api_projects.class.php.

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

◆ getRoles()

Projects::getRoles ( $id,
$userid = 0 )

Get roles a user is assigned to a project with.

Parameters
int$idId of project
int$useridId of user (0 = connected user)
Returns
array @phan-return Object[] @phpstan-return Object[]

@url GET {id}/roles

Definition at line 438 of file api_projects.class.php.

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

◆ index()

Projects::index ( $sortfield = "t.rowid",
$sortorder = 'ASC',
$limit = 100,
$page = 0,
$thirdparty_ids = '',
$category = 0,
$sqlfilters = '',
$properties = '',
$pagination_data = false )

List projects.

Get a list of projects

Parameters
string$sortfieldSort field
string$sortorderSort order
int$limitLimit for list
int$pagePage number
string$thirdparty_idsThirdparty ids to filter projects 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')"
string$propertiesRestrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
bool$pagination_dataIf this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0*
Returns
array Array of project objects @phan-return array{data:Project[],pagination:array{total:int,page:int,page_count:int,limit:int}} @phpstan-return array{data:Project[],pagination:array{total:int,page:int,page_count:int,limit:int}}

Definition at line 203 of file api_projects.class.php.

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

◆ post()

Projects::post ( $request_data = null)

Create project object.

Parameters
array$request_dataRequest data @phan-param array<string,mixed> $request_data @phpstan-param array<string,mixed> $request_data
Returns
int ID of project

Definition at line 311 of file api_projects.class.php.

References DolibarrApi\_checkValForAPI(), _validate(), dol_buildpath(), dol_include_once(), dol_now(), dol_print_date(), dol_syslog(), getDolGlobalString(), and sanitizeVal().

◆ put()

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

Add a task to given project.

Parameters
int$idId of project to update
array$request_dataProjectline data @phan-param array<string,mixed> $request_data @phpstan-param array<string,mixed> $request_data

@url POST {id}/tasks

Returns
int Update a task to given project
Parameters
int$idId of project to update
int$taskidId of task to update
array$request_dataProjectline data @phan-param array<string,mixed> $request_data @phpstan-param array<string,mixed> $request_data

@url PUT {id}/tasks/{taskid}

Returns
object Update project general fields (won't touch lines of project)
Parameters
int$idId of project to update
array$request_dataDatas @phan-param ?array<string,mixed> $request_data @phpstan-param ?array<string,mixed> $request_data
Returns
Object Updated object @phan-return Object|false @phpstan-return Object|false

Definition at line 618 of file api_projects.class.php.

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

◆ validate()

Projects::validate ( $id,
$notrigger = 0 )

Validate a project.

You can test this API with the following input message { "notrigger": 0 }

Parameters
int$idProject ID
int$notrigger1=Does not execute triggers, 0= execute triggers @phan-param int<0,1> $notrigger @phpstan-param int<0,1> $notrigger

@url POST {id}/validate

Returns
array @phan-return array{success:array{code:int,message:string}} @phpstan-return array{success:array{code:int,message:string}} FIXME An error 403 is returned if the request has an empty body. Error message: "Forbidden: Content type `text/plain` is not supported." Workaround: send this in the body { "notrigger": 0 }

Definition at line 715 of file api_projects.class.php.

References $id, and DolibarrApi\_checkAccessToResource().


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