|
dolibarr 25.0.0-alpha
|


Public Member Functions | |
| __construct () | |
| Constructor. | |
| get ($id) | |
| Get properties of a resource object by id. | |
| index ($sortfield="t.ref", $sortorder='ASC', $limit=100, $page=0, $sqlfilters='', $properties='') | |
| List resources. | |
| post ($request_data=null) | |
| Create resource object. | |
| put ($id, $request_data=null) | |
| Update resource. | |
| delete ($id) | |
| Delete resource. | |
| getElementResources ($element_type, $element_id) | |
| Get the resources linked to an element. | |
| postElementResources ($element_type, $element_id, $request_data=null) | |
| Link a resource to an element. | |
| deleteElementResources ($element_type, $element_id, $id) | |
| Unlink a resource from an element. | |
| getBookingConflicts ($id, $date_start, $date_end) | |
| Get the bookings that conflict with a period for a resource. | |
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. | |
| _checkValExtrafieldsForAPI ($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 | |
| _fetchElement ($element_type, $element_id) | |
| Load the element carrying the resources and check the access to it. | |
| _formatLink ($link) | |
| Format a link of llx_element_resources for the answer. | |
| _describeConflicts ($conflicts) | |
| Describe conflicting bookings for an error message. | |
| _toTimestamp ($value, $name) | |
| Convert a date given to the API into a timestamp. | |
| _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', $parenttableforentity='') |
| Check access by user to a given resource. | |
| static | _forge_criteria_callback ($matches) |
| Function to forge a SQL criteria from a Generic filter string. | |
Definition at line 40 of file api_dolresources.class.php.
|
protected |
Clean sensible object datas.
| Object | $object | Object to clean |
Reimplemented from DolibarrApi.
Definition at line 510 of file api_dolresources.class.php.
References $object.
Referenced by _formatLink(), get(), and index().
|
private |
Describe conflicting bookings for an error message.
| array<int,array{element_type:string,element_id:int,ref:string}> | $conflicts Conflicting bookings |
Definition at line 637 of file api_dolresources.class.php.
Referenced by postElementResources().
|
private |
Load the element carrying the resources and check the access to it.
| string | $element_type | Type of the element, as stored in element_type |
| int | $element_id | ID of the element |
| RestException | 400 Bad element type |
| RestException | 403 Access denied |
| RestException | 404 Element not found |
Definition at line 543 of file api_dolresources.class.php.
References DolibarrApi\_checkAccessToResource().
Referenced by deleteElementResources(), getElementResources(), and postElementResources().
|
private |
Format a link of llx_element_resources for the answer.
| array<string,mixed> | $link Link as returned by getElementResources() |
Definition at line 573 of file api_dolresources.class.php.
References _cleanObjectDatas().
Referenced by getElementResources(), and postElementResources().
|
private |
Convert a date given to the API into a timestamp.
| string | $value | Date, format YYYY-MM-DD HH:MM:SS or a Unix timestamp |
| string | $name | Name of the parameter, for the error message |
| RestException | 400 Bad date |
Definition at line 656 of file api_dolresources.class.php.
References dol_stringtotime().
Referenced by getBookingConflicts().
|
private |
Validate fields before create or update object.
| ?array<string,string> | $data Datas to validate |
| RestException | 400 Mandatory field missing |
Definition at line 678 of file api_dolresources.class.php.
Referenced by post().
| Dolresources::delete | ( | $id | ) |
Delete resource.
| int | $id | Resource ID |
| RestException | 403 Access denied |
| RestException | 404 Resource not found |
| RestException | 500 Error when deleting the resource |
Definition at line 276 of file api_dolresources.class.php.
References $id, and DolibarrApi\_checkAccessToResource().
| Dolresources::deleteElementResources | ( | $element_type, | |
| $element_id, | |||
| $id ) |
Unlink a resource from an element.
| string | $element_type | Type of the element, as stored in element_type (for example "action" for an agenda event) |
| int | $element_id | ID of the element |
| int | $id | ID of the link to delete (the id returned by the GET, not the id of the resource) |
@url DELETE {element_type}/{element_id}/resources/{id}
| RestException | 403 Access denied |
| RestException | 404 Element or link not found |
| RestException | 500 Error when deleting the link |
Definition at line 426 of file api_dolresources.class.php.
References $id, and _fetchElement().
| Dolresources::get | ( | $id | ) |
Get properties of a resource object by id.
Return an array with resource information.
| int | $id | ID of resource |
@url GET {id}
| RestException | 403 Access denied |
| RestException | 404 Resource not found |
Definition at line 78 of file api_dolresources.class.php.
References $id, DolibarrApi\_checkAccessToResource(), and _cleanObjectDatas().
| Dolresources::getBookingConflicts | ( | $id, | |
| $date_start, | |||
| $date_end ) |
Get the bookings that conflict with a period for a resource.
Answers the availability question without having to create a link first. Only the links flagged busy are considered, as in the interface.
| int | $id | ID of resource |
| string | $date_start | Start of the period, format YYYY-MM-DD HH:MM:SS or a Unix timestamp |
| string | $date_end | End of the period, format YYYY-MM-DD HH:MM:SS or a Unix timestamp |
@url GET {id}/bookingconflicts
| RestException | 400 Bad date |
| RestException | 403 Access denied |
| RestException | 404 Resource not found |
| RestException | 500 Error when searching the conflicts |
Definition at line 479 of file api_dolresources.class.php.
References $date_start, $id, and _toTimestamp().
| Dolresources::getElementResources | ( | $element_type, | |
| $element_id ) |
Get the resources linked to an element.
Return the links stored in llx_element_resources for an element, so the endpoint works for any element type that can carry resources (agenda events, interventions, ...) and not only for one module.
| string | $element_type | Type of the element, as stored in element_type (for example "action" for an agenda event) |
| int | $element_id | ID of the element |
@url GET {element_type}/{element_id}/resources
| RestException | 403 Access denied |
| RestException | 404 Element not found |
Definition at line 321 of file api_dolresources.class.php.
References _fetchElement(), and _formatLink().
| Dolresources::index | ( | $sortfield = "t.ref", | |
| $sortorder = 'ASC', | |||
| $limit = 100, | |||
| $page = 0, | |||
| $sqlfilters = '', | |||
| $properties = '' ) |
List resources.
Get a list of resources
| string | $sortfield | Sort field |
| string | $sortorder | Sort order |
| int | $limit | Limit for list |
| int | $page | Page number |
| string | $sqlfilters | Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'A%')" |
| string | $properties | Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names |
| RestException | 400 Error on the sqlfilters |
| RestException | 403 Access denied |
| RestException | 503 Error when retrieving the list |
Definition at line 115 of file api_dolresources.class.php.
References _cleanObjectDatas(), DolibarrApi\_filterObjectProperties(), and forgeSQLFromUniversalSearchCriteria().
| Dolresources::post | ( | $request_data = null | ) |
Create resource object.
| array | $request_data | Request data @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data |
| RestException | 400 Mandatory field missing |
| RestException | 403 Access denied |
| RestException | 500 Error when creating the resource |
Definition at line 178 of file api_dolresources.class.php.
References DolibarrApi\_checkValForAPI(), _validate(), and sanitizeVal().
| Dolresources::postElementResources | ( | $element_type, | |
| $element_id, | |||
| $request_data = null ) |
Link a resource to an element.
| string | $element_type | Type of the element, as stored in element_type (for example "action" for an agenda event) |
| int | $element_id | ID of the element |
| array | $request_data | Request data. Mandatory: resource_id. Optional: busy, mandatory @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data |
@url POST {element_type}/{element_id}/resources
| RestException | 400 Mandatory field missing |
| RestException | 403 Access denied |
| RestException | 404 Element or resource not found |
| RestException | 409 Resource already linked to this element, or already busy on the period |
| RestException | 500 Error when creating the link |
Definition at line 357 of file api_dolresources.class.php.
References _describeConflicts(), _fetchElement(), and _formatLink().
| Dolresources::put | ( | $id, | |
| $request_data = null ) |
Update resource.
| int | $id | ID of resource to update |
| array | $request_data | Datas @phan-param ?array<string,string> $request_data @phpstan-param ?array<string,string> $request_data |
| RestException | 403 Access denied |
| RestException | 404 Resource not found |
| RestException | 500 Error when updating the resource |
Definition at line 220 of file api_dolresources.class.php.
References $id, DolibarrApi\_checkAccessToResource(), DolibarrApi\_checkValForAPI(), dol_clone(), and sanitizeVal().