|
dolibarr 24.0.0-beta
|
Class for API REST v1. More...

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. | |
| _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. | |
| _cleanObjectDatas ($object) | |
| Clean sensitive object data @phpstan-template T. | |
| _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. | |
Class for API REST v1.
Definition at line 34 of file api.class.php.
| DolibarrApi::__construct | ( | $db, | |
| $cachedir = '', | |||
| $refreshCache = false ) |
Constructor.
Definition at line 53 of file api.class.php.
References $conf, $dolibarr_main_url_root, dol_is_dir(), dol_mkdir(), dol_syslog(), getDolGlobalBool(), and getDolGlobalString().
|
staticprotected |
Check access by user to a given resource.
| string | $resource | element to check |
| int | string | Object | $resource_id | Full object or object ID or list of object id. For example 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 | $feature2 | Feature to check, second level of permission (optional). Can be or check with 'level1|level2'. |
| string | $dbt_keyfield | Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional) |
| string | $dbt_select | Field name for select if not rowid. Not used if objectid is null (optional) |
Definition at line 493 of file api.class.php.
References checkUserAccessToObject().
Referenced by Invoices\_fetch(), Mailings\_fetch(), Orders\_fetch(), Products\_fetch(), Proposals\_fetch(), Thirdparties\_fetch(), Workstations\_fetch(), Mailings\_fetchTarget(), Invoices\_fetchTemplateInvoice(), Contracts\activateLine(), Contacts\addCategory(), Thirdparties\addCategory(), Interventions\addContact(), Invoices\addContact(), Projects\addContact(), Tasks\addContact(), Invoices\addPayment(), SupplierInvoices\addPayment(), Invoices\addPaymentDistributed(), Products\addPurchasePrice(), Thirdparties\addRepresentative(), Products\addSubproducts(), Thirdparties\addSupplierCategory(), Tasks\addTimeSpent(), Projects\addToContact(), ExpenseReports\approve(), Holidays\approve(), SupplierOrders\approve(), ExpenseReports\cancel(), Holidays\cancel(), Mailings\clone(), Contracts\close(), Interventions\close(), Orders\close(), Proposals\close(), Receptions\close(), Shipments\close(), Thirdparties\createFixedAmountDiscount(), Invoices\createInvoiceFromOrder(), Contacts\createUser(), AgendaEvents\delete(), Boms\delete(), Categories\delete(), Contacts\delete(), Contracts\delete(), Donations\delete(), ExpenseReports\delete(), Holidays\delete(), Interventions\delete(), Invoices\delete(), KnowledgeManagement\delete(), Mailings\delete(), Members\delete(), MembersTypes\delete(), Mos\delete(), MyModuleApi\delete(), Orders\delete(), Partnerships\delete(), Productlots\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(), Interventions\deleteContact(), Invoices\deleteContact(), Orders\deleteContact(), Products\deleteContact(), Projects\deleteContact(), Proposals\deleteContact(), SupplierOrders\deleteContact(), Tasks\deleteContact(), Tickets\deleteContact(), Recruitments\deleteJobPosition(), Boms\deleteLine(), Contracts\deleteLine(), ExpenseReports\deleteLine(), Interventions\deleteLine(), Invoices\deleteLine(), Orders\deleteLine(), Proposals\deleteLine(), Receptions\deleteLine(), Shipments\deleteLine(), SupplierInvoices\deleteLine(), Products\deletePurchasePrice(), Thirdparties\deleteRepresentative(), Thirdparties\deleteSupplierCategory(), Mailings\deleteTarget(), Mailings\deleteTargets(), Tasks\deleteTimeSpent(), Projects\deleteToContact(), Members\deleteType(), Products\delSubproducts(), ExpenseReports\deny(), AgendaEvents\get(), Boms\get(), Categories\get(), Contacts\get(), Contracts\get(), Donations\get(), ExpenseReports\get(), Holidays\get(), Interventions\get(), KnowledgeManagement\get(), Members\get(), MembersTypes\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(), Interventions\getContacts(), Invoices\getContacts(), Orders\getContacts(), Products\getContacts(), Projects\getContacts(), Proposals\getContacts(), SupplierOrders\getContacts(), Tasks\getContacts(), Invoices\getDiscount(), Thirdparties\getFixedAmountDiscounts(), Users\getInfo(), Thirdparties\getInvoicesQualifiedForCreditNote(), Thirdparties\getInvoicesQualifiedForReplacement(), Recruitments\getJobPosition(), Orders\getLine(), Boms\getLines(), Contracts\getLines(), ExpenseReports\getLines(), Invoices\getLines(), Orders\getLines(), Projects\getLines(), Proposals\getLines(), SupplierInvoices\getLines(), Categories\getObjects(), Thirdparties\getOutStandingInvoices(), Thirdparties\getOutStandingOrder(), Thirdparties\getOutStandingProposals(), Invoices\getPayments(), SupplierInvoices\getPayments(), Products\getPurchasePriceLogs(), Products\getPurchasePrices(), Projects\getRoles(), Tasks\getRoles(), Thirdparties\getSalesRepresentatives(), Thirdparties\getSocieteAccounts(), Thirdparties\getSocieteByAccounts(), Products\getStock(), Products\getSubproducts(), Projects\getTimespent(), Tasks\getTimespent(), Tasks\getTimeSpentByID(), Members\getType(), Users\getUserNotification(), Mailings\index(), Mailings\indexTargets(), SupplierOrders\makeOrder(), Invoices\markAsCreditAvailable(), Thirdparties\merge(), Contacts\post(), Contracts\post(), Invoices\post(), Mailings\post(), Orders\post(), Proposals\post(), Tickets\post(), Invoices\postContact(), Orders\postContact(), Products\postContact(), Proposals\postContact(), SupplierOrders\postContact(), Tickets\postContact(), Boms\postLine(), Contracts\postLine(), ExpenseReports\postLine(), Interventions\postLine(), Invoices\postLine(), Orders\postLine(), Proposals\postLine(), SupplierInvoices\postLine(), SupplierOrders\postLine(), Proposals\postLines(), Tickets\postNewMessage(), Mailings\postTarget(), AgendaEvents\put(), Boms\put(), Categories\put(), Contacts\put(), Contracts\put(), Donations\put(), ExpenseReports\put(), Holidays\put(), Interventions\put(), Invoices\put(), KnowledgeManagement\put(), Mailings\put(), Members\put(), MembersTypes\put(), Mos\put(), MyModuleApi\put(), Orders\put(), Partnerships\put(), Productlots\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(), ExpenseReports\putLine(), Interventions\putLine(), Invoices\putLine(), Orders\putLine(), Proposals\putLine(), SupplierInvoices\putLine(), Tasks\putTimeSpent(), Members\putType(), SupplierOrders\receiveOrder(), Holidays\refuse(), Holidays\reopen(), Mailings\resetTargetsStatus(), Users\setGroup(), Orders\setinvoiced(), Proposals\setinvoiced(), ExpenseReports\setPaid(), Users\setPassword(), Thirdparties\setThirdpartyPriceLevel(), ExpenseReports\setToDraft(), Interventions\settodraft(), Invoices\settodraft(), Mailings\settodraft(), Orders\settodraft(), Proposals\settodraft(), SupplierInvoices\settodraft(), Invoices\settopaid(), SupplierInvoices\settopaid(), Invoices\settounpaid(), SupplierInvoices\settounpaid(), Thirdparties\splitdiscount(), Contracts\unactivateLine(), Mailings\updateTarget(), Invoices\useCreditNote(), Invoices\useDiscount(), Contracts\validate(), Donations\validate(), ExpenseReports\validate(), Holidays\validate(), Interventions\validate(), Invoices\validate(), Mailings\validate(), Orders\validate(), Projects\validate(), Proposals\validate(), Receptions\validate(), Shipments\validate(), SupplierInvoices\validate(), and SupplierOrders\validate().
|
protected |
Return if a $sqlfilters parameter is valid Function no more used.
Kept for backward compatibility with old APIs of modules
| string | $sqlfilters | sqlfilter string |
| string | $error | Error message |
Definition at line 521 of file api.class.php.
|
protected |
Check and convert a string depending on its type/name.
| string | $field | Field name |
| string | string[] | $value | Value to check/clean |
| Object | $object | Object |
Definition at line 185 of file api.class.php.
References $object, _checkValExtrafieldsForAPI(), and sanitizeVal().
Referenced by _checkValExtrafieldsForAPI(), Contacts\post(), MyModuleApi\post(), SupplierProposals\post(), Thirdparties\post(), AgendaEvents\put(), BankAccounts\put(), Boms\put(), Categories\put(), Contacts\put(), Donations\put(), ExpenseReports\put(), Holidays\put(), Interventions\put(), Invoices\put(), KnowledgeManagement\put(), Mailings\put(), Members\put(), MembersTypes\put(), Mos\put(), MyModuleApi\put(), Orders\put(), Partnerships\put(), Productlots\put(), Products\put(), Projects\put(), Proposals\put(), Receptions\put(), Shipments\put(), Subscriptions\put(), SupplierInvoices\put(), SupplierOrders\put(), SupplierProposals\put(), Thirdparties\put(), Tickets\put(), Users\put(), and Warehouses\put().
|
protected |
Check and convert a string depending on its type/name.
| string | $field | Field name |
| string | string[] | $value | Value to check/clean |
| Object | $object | Object |
| RestException | 400 Bad parameters |
Definition at line 101 of file api.class.php.
References $object, _checkValForAPI(), dol_syslog(), and sanitizeVal().
Referenced by _checkValForAPI(), ObjectLinks\_setObjectLinkField(), ExpenseReports\addPayment(), Salaries\addPayment(), Thirdparties\createCompanyBankAccount(), Thirdparties\createCompanyNotification(), Thirdparties\createCompanyNotificationByCode(), Thirdparties\createSocieteAccount(), Users\createUserNotification(), Users\createUserNotificationByCode(), AgendaEvents\post(), BankAccounts\post(), Boms\post(), Categories\post(), Contacts\post(), Contracts\post(), Donations\post(), EmailTemplates\post(), EventAttendees\post(), ExpenseReports\post(), Holidays\post(), Interventions\post(), Invoices\post(), KnowledgeManagement\post(), Mailings\post(), Members\post(), MembersTypes\post(), Mos\post(), MultiCurrencies\post(), MyModuleApi\post(), Orders\post(), Partnerships\post(), Productlots\post(), Products\post(), Projects\post(), Proposals\post(), Receptions\post(), Salaries\post(), Shipments\post(), Subscriptions\post(), SupplierInvoices\post(), SupplierOrders\post(), SupplierProposals\post(), Tasks\post(), Thirdparties\post(), Tickets\post(), Users\post(), Warehouses\post(), Webhook\post(), Zapier\post(), Recruitments\postCandidature(), Setup\postExtrafields(), Users\postGroups(), Recruitments\postJobPosition(), Interventions\postLine(), Tickets\postNewMessage(), Thirdparties\postSocieteAccount(), Mailings\postTarget(), Members\postType(), AgendaEvents\put(), BankAccounts\put(), Boms\put(), Categories\put(), Contacts\put(), Donations\put(), ExpenseReports\put(), Holidays\put(), Interventions\put(), Invoices\put(), KnowledgeManagement\put(), Mailings\put(), Members\put(), MembersTypes\put(), Mos\put(), MultiCurrencies\put(), MyModuleApi\put(), Orders\put(), Paiements\put(), Partnerships\put(), Productlots\put(), Products\put(), Projects\put(), Proposals\put(), Receptions\put(), Salaries\put(), Shipments\put(), Subscriptions\put(), SupplierInvoices\put(), SupplierOrders\put(), SupplierProposals\put(), Tasks\put(), Thirdparties\put(), Tickets\put(), Users\put(), Warehouses\put(), Webhook\put(), EmailTemplates\putById(), EventAttendees\putById(), EmailTemplates\putbyLabel(), EventAttendees\putByRef(), Recruitments\putCandidature(), Users\putGroups(), Recruitments\putJobPosition(), Thirdparties\putSocieteAccount(), Members\putType(), Thirdparties\updateCompanyBankAccount(), Thirdparties\updateCompanyNotification(), Setup\updateExtrafields(), ExpenseReports\updatePayment(), Salaries\updatePayment(), Mailings\updateTarget(), and Users\updateUserNotification().
|
protected |
Clean sensitive object data @phpstan-template T.
| Object | $object | Object to clean |
@phpstan-param T $object @phpstan-return T
Reimplemented in AgendaEvents, BankAccounts, Boms, Categories, Contacts, Contracts, Donations, EmailTemplates, EventAttendees, ExpenseReports, Interventions, Invoices, KnowledgeManagement, Mailings, Members, MembersTypes, Mos, MultiCurrencies, MyModuleApi, ObjectLinks, Orders, Paiements, Partnerships, Productlots, Products, Projects, Proposals, Receptions, Recruitments, Salaries, Setup, Shipments, StockMovements, SupplierInvoices, SupplierOrders, SupplierProposals, Tasks, Thirdparties, Tickets, Users, Warehouses, Webhook, and Zapier.
Definition at line 299 of file api.class.php.
References $object, and _cleanObjectDatas().
Referenced by _cleanObjectDatas(), Workstations\_fetch(), Holidays\approve(), Holidays\cancel(), Holidays\get(), Subscriptions\get(), Holidays\index(), Subscriptions\index(), Workstations\index(), Holidays\refuse(), Holidays\reopen(), and Holidays\validate().
|
protected |
Filter properties that will be returned on object.
@phpstan-template T
| Object | $object | Object to clean |
| string | $properties | Comma separated list of properties names |
Definition at line 248 of file api.class.php.
References $object.
Referenced by Contracts\get(), Invoices\get(), Products\getAttributes(), Orders\getLine(), Contracts\getLines(), AgendaEvents\index(), BankAccounts\index(), Boms\index(), Categories\index(), Contacts\index(), Contracts\index(), Donations\index(), EmailTemplates\index(), EventAttendees\index(), ExpenseReports\index(), Holidays\index(), Interventions\index(), Invoices\index(), KnowledgeManagement\index(), Mailings\index(), Members\index(), MembersTypes\index(), Mos\index(), MultiCurrencies\index(), MyModuleApi\index(), Orders\index(), Paiements\index(), Partnerships\index(), Productlots\index(), Products\index(), Projects\index(), Proposals\index(), Receptions\index(), Shipments\index(), StockMovements\index(), Subscriptions\index(), SupplierInvoices\index(), SupplierOrders\index(), SupplierProposals\index(), Tasks\index(), Thirdparties\index(), Tickets\index(), Users\index(), Warehouses\index(), Webhook\index(), Workstations\index(), Zapier\index(), Recruitments\indexCandidature(), Recruitments\indexJobPosition(), Mailings\indexTargets(), Invoices\indexTemplateInvoices(), Members\indexType(), Users\listGroups(), Warehouses\listProducts(), and Projects\listTimespent().
|
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
| string[] | $matches | Array 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" |
Definition at line 539 of file api.class.php.