dolibarr 21.0.0-beta
DolibarrApi Class Reference

Class for API REST v1. More...

Inheritance diagram for DolibarrApi:

Public Member Functions

 __construct ($db, $cachedir='', $refreshCache=false)
 Constructor.
 

Protected Member Functions

 _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.
 
 _cleanObjectDatas ($object)
 Clean sensitive object data @phpstan-template T of Object.
 
 _checkFilters ($sqlfilters, &$error='')
 Return if a $sqlfilters parameter is valid Function no more used.
 

Static Protected Member Functions

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

Class for API REST v1.

Definition at line 29 of file api.class.php.

Constructor & Destructor Documentation

◆ __construct()

DolibarrApi::__construct ( $db,
$cachedir = '',
$refreshCache = false )

Constructor.

Parameters
DoliDB$dbDatabase handler
string$cachedirCache dir
boolean$refreshCacheUpdate cache

Definition at line 48 of file api.class.php.

References $conf, and getDolGlobalBool().

Member Function Documentation

◆ _checkAccessToResource()

static DolibarrApi::_checkAccessToResource ( $resource,
$resource_id = 0,
$dbtablename = '',
$feature2 = '',
$dbt_keyfield = 'fk_soc',
$dbt_select = 'rowid' )
staticprotected

Check access by user to a given resource.

Parameters
string$resourceelement to check
int$resource_idObject ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional).
string$dbtablename'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity. Not used if objectid is null (optional)
string$feature2Feature to check, second level of permission (optional). Can be or check with 'level1|level2'.
string$dbt_keyfieldField name for socid foreign key if not fk_soc. Not used if objectid is null (optional)
string$dbt_selectField name for select if not rowid. Not used if objectid is null (optional)
Returns
bool

Definition at line 373 of file api.class.php.

References checkUserAccessToObject().

Referenced by Invoices\_fetch(), Orders\_fetch(), Products\_fetch(), Proposals\_fetch(), Thirdparties\_fetch(), Workstations\_fetch(), Invoices\_fetchTemplateInvoice(), Contracts\activateLine(), Contacts\addCategory(), Thirdparties\addCategory(), Invoices\addContact(), Invoices\addPayment(), SupplierInvoices\addPayment(), Invoices\addPaymentDistributed(), Products\addPurchasePrice(), Thirdparties\addRepresentative(), Products\addSubproducts(), Thirdparties\addSupplierCategory(), Tasks\addTimeSpent(), SupplierOrders\approve(), Contracts\close(), Orders\close(), Proposals\close(), Receptions\close(), Shipments\close(), Interventions\closeFichinter(), Contacts\createUser(), AgendaEvents\delete(), Boms\delete(), Categories\delete(), Contacts\delete(), Contracts\delete(), Donations\delete(), ExpenseReports\delete(), Interventions\delete(), Invoices\delete(), KnowledgeManagement\delete(), Members\delete(), Mos\delete(), MyModuleApi\delete(), Orders\delete(), Partnerships\delete(), Products\delete(), Projects\delete(), Proposals\delete(), Receptions\delete(), Shipments\delete(), SupplierInvoices\delete(), SupplierOrders\delete(), SupplierProposals\delete(), Tasks\delete(), Thirdparties\delete(), Tickets\delete(), Users\delete(), Warehouses\delete(), Zapier\delete(), Recruitments\deleteCandidature(), Contacts\deleteCategory(), Thirdparties\deleteCategory(), Invoices\deleteContact(), Orders\deleteContact(), Proposals\deleteContact(), SupplierOrders\deleteContact(), Recruitments\deleteJobPosition(), Boms\deleteLine(), Contracts\deleteLine(), Invoices\deleteLine(), Orders\deleteLine(), Proposals\deleteLine(), Receptions\deleteLine(), Shipments\deleteLine(), SupplierInvoices\deleteLine(), Products\deletePurchasePrice(), Thirdparties\deleteRepresentative(), Thirdparties\deleteSupplierCategory(), Tasks\deleteTimeSpent(), Members\deleteType(), Products\delSubproducts(), AgendaEvents\get(), Boms\get(), Categories\get(), Contacts\get(), Contracts\get(), Donations\get(), ExpenseReports\get(), Interventions\get(), KnowledgeManagement\get(), Members\get(), Mos\get(), MyModuleApi\get(), Partnerships\get(), Projects\get(), Receptions\get(), Shipments\get(), SupplierInvoices\get(), SupplierOrders\get(), SupplierProposals\get(), Tasks\get(), Users\get(), Warehouses\get(), Zapier\get(), Contacts\getByEmail(), Users\getByEmail(), Users\getByLogin(), Projects\getByMsgId(), Projects\getByRef(), Projects\getByRefExt(), Members\getByThirdparty(), Members\getByThirdpartyAccounts(), Members\getByThirdpartyBarcode(), Members\getByThirdpartyEmail(), Recruitments\getCandidature(), Tickets\getCommon(), Thirdparties\getCompanyBankAccount(), Thirdparties\getCompanyNotification(), Orders\getContacts(), SupplierOrders\getContacts(), Invoices\getDiscount(), Thirdparties\getFixedAmountDiscounts(), Users\getInfo(), Thirdparties\getInvoicesQualifiedForCreditNote(), Thirdparties\getInvoicesQualifiedForReplacement(), Recruitments\getJobPosition(), Boms\getLines(), Contracts\getLines(), Invoices\getLines(), Orders\getLines(), Projects\getLines(), Proposals\getLines(), SupplierInvoices\getLines(), Categories\getObjects(), Thirdparties\getOutStandingInvoices(), Thirdparties\getOutStandingOrder(), Thirdparties\getOutStandingProposals(), Invoices\getPayments(), SupplierInvoices\getPayments(), Products\getPurchasePrices(), Projects\getRoles(), Tasks\getRoles(), Thirdparties\getSalesRepresentatives(), Thirdparties\getSocieteAccounts(), Thirdparties\getSocieteByAccounts(), Products\getStock(), Products\getSubproducts(), Members\getType(), SupplierOrders\makeOrder(), Invoices\markAsCreditAvailable(), Thirdparties\merge(), Invoices\postContact(), Orders\postContact(), Proposals\postContact(), SupplierOrders\postContact(), Boms\postLine(), Contracts\postLine(), Interventions\postLine(), Invoices\postLine(), Orders\postLine(), Proposals\postLine(), SupplierInvoices\postLine(), Proposals\postLines(), AgendaEvents\put(), Boms\put(), Categories\put(), Contacts\put(), Contracts\put(), Donations\put(), ExpenseReports\put(), Invoices\put(), KnowledgeManagement\put(), Members\put(), Mos\put(), MyModuleApi\put(), Orders\put(), Partnerships\put(), Products\put(), Projects\put(), Proposals\put(), Receptions\put(), Shipments\put(), SupplierInvoices\put(), SupplierOrders\put(), SupplierProposals\put(), Tasks\put(), Thirdparties\put(), Tickets\put(), Users\put(), Warehouses\put(), Recruitments\putCandidature(), Recruitments\putJobPosition(), Boms\putLine(), Contracts\putLine(), Invoices\putLine(), Orders\putLine(), Proposals\putLine(), SupplierInvoices\putLine(), Tasks\putTimeSpent(), Members\putType(), SupplierOrders\receiveOrder(), Users\setGroup(), Orders\setinvoiced(), Proposals\setinvoiced(), Users\setPassword(), Thirdparties\setThirdpartyPriceLevel(), Invoices\settodraft(), Orders\settodraft(), Proposals\settodraft(), Invoices\settopaid(), Invoices\settounpaid(), Contracts\unactivateLine(), Invoices\useCreditNote(), Invoices\useDiscount(), Contracts\validate(), Donations\validate(), Interventions\validate(), Invoices\validate(), Orders\validate(), Projects\validate(), Proposals\validate(), Receptions\validate(), Shipments\validate(), SupplierInvoices\validate(), and SupplierOrders\validate().

◆ _checkFilters()

DolibarrApi::_checkFilters ( $sqlfilters,
& $error = '' )
protected

Return if a $sqlfilters parameter is valid Function no more used.

Kept for backward compatibility with old APIs of modules

Parameters
string$sqlfilterssqlfilter string
string$errorError message
Returns
boolean|string True if valid, False if not valid

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

References dolCheckFilters().

Referenced by Setup\getListOfIncoterms(), Setup\getListOfRegions(), and MultiCurrencies\index().

◆ _checkValForAPI()

DolibarrApi::_checkValForAPI ( $field,
$value,
$object )
protected

Check and convert a string depending on its type/name.

Parameters
string$fieldField name
string | string[]$valueValue to check/clean
Object$objectObject
Returns
string|array<string,mixed> Value cleaned

Definition at line 82 of file api.class.php.

References $object, _checkValForAPI(), and sanitizeVal().

Referenced by _checkValForAPI(), ExpenseReports\addPayment(), Salaries\addPayment(), Thirdparties\createCompanyBankAccount(), Thirdparties\createSocieteAccount(), Thirdparties\patchSocieteAccount(), AgendaEvents\post(), BankAccounts\post(), Boms\post(), Categories\post(), Contacts\post(), Contracts\post(), Donations\post(), ExpenseReports\post(), Interventions\post(), Invoices\post(), KnowledgeManagement\post(), Members\post(), Mos\post(), MultiCurrencies\post(), MyModuleApi\post(), Orders\post(), Partnerships\post(), Products\post(), Projects\post(), Proposals\post(), Receptions\post(), Salaries\post(), Shipments\post(), Subscriptions\post(), SupplierInvoices\post(), SupplierOrders\post(), Tasks\post(), Thirdparties\post(), Tickets\post(), Users\post(), Warehouses\post(), Webhook\post(), Zapier\post(), Recruitments\postCandidature(), Setup\postExtrafields(), Recruitments\postJobPosition(), Interventions\postLine(), Tickets\postNewMessage(), Members\postType(), AgendaEvents\put(), BankAccounts\put(), Boms\put(), Categories\put(), Contacts\put(), Contracts\put(), Donations\put(), ExpenseReports\put(), Invoices\put(), KnowledgeManagement\put(), Members\put(), Mos\put(), MultiCurrencies\put(), MyModuleApi\put(), Orders\put(), Partnerships\put(), Products\put(), Projects\put(), Proposals\put(), Receptions\put(), Salaries\put(), Shipments\put(), Subscriptions\put(), SupplierInvoices\put(), SupplierOrders\put(), Tasks\put(), Thirdparties\put(), Tickets\put(), Users\put(), Warehouses\put(), Webhook\put(), Recruitments\putCandidature(), Recruitments\putJobPosition(), Thirdparties\putSocieteAccount(), Members\putType(), Thirdparties\updateCompanyBankAccount(), Setup\updateExtrafields(), ExpenseReports\updatePayment(), and Salaries\updatePayment().

◆ _cleanObjectDatas()

DolibarrApi::_cleanObjectDatas ( $object)
protected

Clean sensitive object data @phpstan-template T of Object.

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

@phpstan-param T $object @phpstan-return T

Reimplemented in AgendaEvents, BankAccounts, Boms, Categories, Contacts, Contracts, Donations, ExpenseReports, Interventions, Invoices, KnowledgeManagement, Members, Mos, MultiCurrencies, MyModuleApi, Orders, Partnerships, Products, Projects, Proposals, Receptions, Recruitments, Salaries, Setup, Shipments, StockMovements, SupplierInvoices, SupplierOrders, SupplierProposals, Tasks, Thirdparties, Tickets, Users, Warehouses, Webhook, Workstations, and Zapier.

Definition at line 187 of file api.class.php.

References $object, and _cleanObjectDatas().

Referenced by _cleanObjectDatas(), Subscriptions\get(), and Subscriptions\index().

◆ _filterObjectProperties()

◆ _forge_criteria_callback()

static DolibarrApi::_forge_criteria_callback ( $matches)
staticprotected

Function to forge a SQL criteria from a Generic filter string.

Function no more used. Kept for backward compatibility with old APIs of modules

Parameters
string[]$matchesArray of found string by regex search. Each entry is 1 and only 1 criteria. Example: "t.ref:like:'SO-%'", "t.date_creation:<:'20160101'", "t.date_creation:<:'2016-01-01 12:30:00'", "t.nature:is:NULL", "t.field2:isnot:NULL"
Returns
string Forged criteria. Example: "t.field like 'abc%'"

Definition at line 419 of file api.class.php.

References dolForgeSQLCriteriaCallback().


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