dolibarr  21.0.0-alpha
api_categories.class.php
1 <?php
2 /* Copyright (C) 2015 Jean-Fran├žois Ferry <jfefe@aternatik.fr>
3  * Copyright (C) 2024 Jose MARTINEZ <jose.martinez@pichinov.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
19 use Luracast\Restler\RestException;
20 
21 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
22 require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
23 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
24 
25 require_once DOL_DOCUMENT_ROOT.'/adherents/class/api_members.class.php';
26 require_once DOL_DOCUMENT_ROOT.'/product/class/api_products.class.php';
27 require_once DOL_DOCUMENT_ROOT.'/societe/class/api_contacts.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/societe/class/api_thirdparties.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/projet/class/api_projects.class.php';
30 
37 class Categories extends DolibarrApi
38 {
42  public static $FIELDS = array(
43  'label',
44  'type'
45  );
46 
47  public static $TYPES = array(
48  0 => 'product',
49  1 => 'supplier',
50  2 => 'customer',
51  3 => 'member',
52  4 => 'contact',
53  5 => 'account',
54  6 => 'project',
55  7 => 'user',
56  8 => 'bank_line',
57  9 => 'warehouse',
58  10 => 'actioncomm',
59  11 => 'website_page',
60  12 => 'ticket',
61  13 => 'knowledgemanagement'
62  );
63 
67  public $category;
68 
72  public function __construct()
73  {
74  global $db;
75 
76  $this->db = $db;
77  $this->category = new Categorie($this->db);
78  }
79 
91  public function get($id, $include_childs = false)
92  {
93  if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
94  throw new RestException(403);
95  }
96 
97  $result = $this->category->fetch($id);
98  if (!$result) {
99  throw new RestException(404, 'category not found');
100  }
101 
102  if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) {
103  throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
104  }
105 
106  if ($include_childs) {
107  $cats = $this->category->get_filles();
108  if (!is_array($cats)) {
109  throw new RestException(500, 'Error when fetching child categories', array_merge(array($this->category->error), $this->category->errors));
110  }
111  $this->category->childs = array();
112  foreach ($cats as $cat) {
113  $this->category->childs[] = $this->_cleanObjectDatas($cat);
114  }
115  }
116 
117  return $this->_cleanObjectDatas($this->category);
118  }
119 
136  public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '', $properties = '')
137  {
138  $obj_ret = array();
139 
140  if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
141  throw new RestException(403);
142  }
143 
144  $sql = "SELECT t.rowid";
145  $sql .= " FROM ".MAIN_DB_PREFIX."categorie AS t LEFT JOIN ".MAIN_DB_PREFIX."categories_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
146  $sql .= ' WHERE t.entity IN ('.getEntity('category').')';
147  if (!empty($type)) {
148  $sql .= ' AND t.type='.array_search($type, Categories::$TYPES);
149  }
150  // Add sql filters
151  if ($sqlfilters) {
152  $errormessage = '';
153  $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage);
154  if ($errormessage) {
155  throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
156  }
157  }
158 
159  $sql .= $this->db->order($sortfield, $sortorder);
160  if ($limit) {
161  if ($page < 0) {
162  $page = 0;
163  }
164  $offset = $limit * $page;
165 
166  $sql .= $this->db->plimit($limit + 1, $offset);
167  }
168 
169  $result = $this->db->query($sql);
170  if ($result) {
171  $i = 0;
172  $num = $this->db->num_rows($result);
173  $min = min($num, ($limit <= 0 ? $num : $limit));
174  while ($i < $min) {
175  $obj = $this->db->fetch_object($result);
176  $category_static = new Categorie($this->db);
177  if ($category_static->fetch($obj->rowid)) {
178  $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($category_static), $properties);
179  }
180  $i++;
181  }
182  } else {
183  throw new RestException(503, 'Error when retrieve category list : '.$this->db->lasterror());
184  }
185 
186  return $obj_ret;
187  }
188 
195  public function post($request_data = null)
196  {
197  if (!DolibarrApiAccess::$user->hasRight('categorie', 'creer')) {
198  throw new RestException(403);
199  }
200 
201  // Check mandatory fields (throw an exception if wrong)
202  $this->_validate($request_data);
203 
204  foreach ($request_data as $field => $value) {
205  if ($field === 'caller') {
206  // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again with the caller
207  $this->category->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
208  continue;
209  }
210 
211  $this->category->$field = $this->_checkValForAPI($field, $value, $this->category);
212  }
213  if ($this->category->create(DolibarrApiAccess::$user) < 0) {
214  throw new RestException(500, 'Error when creating category', array_merge(array($this->category->error), $this->category->errors));
215  }
216  return $this->category->id;
217  }
218 
226  public function put($id, $request_data = null)
227  {
228  if (!DolibarrApiAccess::$user->hasRight('categorie', 'creer')) {
229  throw new RestException(403);
230  }
231 
232  $result = $this->category->fetch($id);
233  if (!$result) {
234  throw new RestException(404, 'category not found');
235  }
236 
237  if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) {
238  throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
239  }
240 
241  foreach ($request_data as $field => $value) {
242  if ($field == 'id') {
243  continue;
244  }
245  if ($field === 'caller') {
246  // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again with the caller
247  $this->category->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
248  continue;
249  }
250 
251  $this->category->$field = $this->_checkValForAPI($field, $value, $this->category);
252  }
253 
254  if ($this->category->update(DolibarrApiAccess::$user) > 0) {
255  return $this->get($id);
256  } else {
257  throw new RestException(500, $this->category->error);
258  }
259  }
260 
267  public function delete($id)
268  {
269  if (!DolibarrApiAccess::$user->hasRight('categorie', 'supprimer')) {
270  throw new RestException(403);
271  }
272  $result = $this->category->fetch($id);
273  if (!$result) {
274  throw new RestException(404, 'category not found');
275  }
276 
277  if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) {
278  throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
279  }
280 
281  if (!$this->category->delete(DolibarrApiAccess::$user)) {
282  throw new RestException(500, 'error when delete category');
283  }
284 
285  return array(
286  'success' => array(
287  'code' => 200,
288  'message' => 'Category deleted'
289  )
290  );
291  }
292 
310  public function getListForObject($id, $type, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
311  {
312  if (!in_array($type, [
313  Categorie::TYPE_PRODUCT,
314  Categorie::TYPE_CONTACT,
315  Categorie::TYPE_CUSTOMER,
316  Categorie::TYPE_SUPPLIER,
317  Categorie::TYPE_MEMBER,
318  Categorie::TYPE_PROJECT,
319  Categorie::TYPE_KNOWLEDGEMANAGEMENT,
320  Categorie::TYPE_ACTIONCOMM
321  ])) {
322  throw new RestException(403);
323  }
324 
325  if ($type == Categorie::TYPE_PRODUCT && !DolibarrApiAccess::$user->hasRight('produit', 'lire') && !DolibarrApiAccess::$user->hasRight('service', 'lire')) {
326  throw new RestException(403);
327  } elseif ($type == Categorie::TYPE_CONTACT && !DolibarrApiAccess::$user->hasRight('contact', 'lire')) {
328  throw new RestException(403);
329  } elseif ($type == Categorie::TYPE_CUSTOMER && !DolibarrApiAccess::$user->hasRight('societe', 'lire')) {
330  throw new RestException(403);
331  } elseif ($type == Categorie::TYPE_SUPPLIER && !DolibarrApiAccess::$user->hasRight('fournisseur', 'lire')) {
332  throw new RestException(403);
333  } elseif ($type == Categorie::TYPE_MEMBER && !DolibarrApiAccess::$user->hasRight('adherent', 'lire')) {
334  throw new RestException(403);
335  } elseif ($type == Categorie::TYPE_PROJECT && !DolibarrApiAccess::$user->hasRight('projet', 'lire')) {
336  throw new RestException(403);
337  } elseif ($type == Categorie::TYPE_KNOWLEDGEMANAGEMENT && !DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) {
338  throw new RestException(403);
339  } elseif ($type == Categorie::TYPE_ACTIONCOMM && !DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) {
340  throw new RestException(403);
341  }
342 
343  $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page);
344 
345  if (!is_array($categories)) {
346  throw new RestException(600, 'Error when fetching object categories', array_merge(array($this->category->error), $this->category->errors));
347  }
348  return $categories;
349  }
350 
363  public function linkObjectById($id, $type, $object_id)
364  {
365  if (empty($type) || empty($object_id)) {
366  throw new RestException(403);
367  }
368 
369  if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
370  throw new RestException(403);
371  }
372 
373  $result = $this->category->fetch($id);
374  if (!$result) {
375  throw new RestException(404, 'category not found');
376  }
377 
378  if ($type === Categorie::TYPE_PRODUCT) {
379  if (!DolibarrApiAccess::$user->hasRight('produit', 'creer') && !DolibarrApiAccess::$user->hasRight('service', 'creer')) {
380  throw new RestException(403);
381  }
382  $object = new Product($this->db);
383  } elseif ($type === Categorie::TYPE_CUSTOMER) {
384  if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
385  throw new RestException(403);
386  }
387  $object = new Societe($this->db);
388  } elseif ($type === Categorie::TYPE_SUPPLIER) {
389  if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
390  throw new RestException(403);
391  }
392  $object = new Societe($this->db);
393  } elseif ($type === Categorie::TYPE_CONTACT) {
394  if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) {
395  throw new RestException(403);
396  }
397  $object = new Contact($this->db);
398  } elseif ($type === Categorie::TYPE_MEMBER) {
399  if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) {
400  throw new RestException(403);
401  }
402  $object = new Adherent($this->db);
403  } elseif ($type === Categorie::TYPE_ACTIONCOMM) {
404  if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) {
405  throw new RestException(403);
406  }
407  $object = new ActionComm($this->db);
408  } else {
409  throw new RestException(400, "this type is not recognized yet.");
410  }
411 
412  $result = $object->fetch($object_id);
413  if ($result > 0) {
414  $result = $this->category->add_type($object, $type);
415  if ($result < 0) {
416  if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') {
417  throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors));
418  }
419  }
420  } else {
421  throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors));
422  }
423 
424  return array(
425  'success' => array(
426  'code' => 200,
427  'message' => 'Objects successfully linked to the category'
428  )
429  );
430  }
431 
444  public function linkObjectByRef($id, $type, $object_ref)
445  {
446  if (empty($type) || empty($object_ref)) {
447  throw new RestException(403);
448  }
449 
450  if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
451  throw new RestException(403);
452  }
453 
454  $result = $this->category->fetch($id);
455  if (!$result) {
456  throw new RestException(404, 'category not found');
457  }
458 
459  if ($type === Categorie::TYPE_PRODUCT) {
460  if (!DolibarrApiAccess::$user->hasRight('produit', 'creer') && !DolibarrApiAccess::$user->hasRight('service', 'creer')) {
461  throw new RestException(403);
462  }
463  $object = new Product($this->db);
464  } elseif ($type === Categorie::TYPE_CUSTOMER) {
465  if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
466  throw new RestException(403);
467  }
468  $object = new Societe($this->db);
469  } elseif ($type === Categorie::TYPE_SUPPLIER) {
470  if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
471  throw new RestException(403);
472  }
473  $object = new Societe($this->db);
474  } elseif ($type === Categorie::TYPE_CONTACT) {
475  if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) {
476  throw new RestException(403);
477  }
478  $object = new Contact($this->db);
479  } elseif ($type === Categorie::TYPE_MEMBER) {
480  if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) {
481  throw new RestException(403);
482  }
483  $object = new Adherent($this->db);
484  } elseif ($type === Categorie::TYPE_ACTIONCOMM) {
485  if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) {
486  throw new RestException(403);
487  }
488  $object = new ActionComm($this->db);
489  } else {
490  throw new RestException(400, "this type is not recognized yet.");
491  }
492 
493  $result = $object->fetch(0, $object_ref);
494  if ($result > 0) {
495  $result = $this->category->add_type($object, $type);
496  if ($result < 0) {
497  if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') {
498  throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors));
499  }
500  }
501  } else {
502  throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors));
503  }
504 
505  return array(
506  'success' => array(
507  'code' => 200,
508  'message' => 'Objects successfully linked to the category'
509  )
510  );
511  }
512 
525  public function unlinkObjectById($id, $type, $object_id)
526  {
527  if (empty($type) || empty($object_id)) {
528  throw new RestException(403);
529  }
530 
531  if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
532  throw new RestException(403);
533  }
534 
535  $result = $this->category->fetch($id);
536  if (!$result) {
537  throw new RestException(404, 'category not found');
538  }
539 
540  if ($type === Categorie::TYPE_PRODUCT) {
541  if (!DolibarrApiAccess::$user->hasRight('produit', 'creer') && !DolibarrApiAccess::$user->hasRight('service', 'creer')) {
542  throw new RestException(403);
543  }
544  $object = new Product($this->db);
545  } elseif ($type === Categorie::TYPE_CUSTOMER) {
546  if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
547  throw new RestException(403);
548  }
549  $object = new Societe($this->db);
550  } elseif ($type === Categorie::TYPE_SUPPLIER) {
551  if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
552  throw new RestException(403);
553  }
554  $object = new Societe($this->db);
555  } elseif ($type === Categorie::TYPE_CONTACT) {
556  if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) {
557  throw new RestException(403);
558  }
559  $object = new Contact($this->db);
560  } elseif ($type === Categorie::TYPE_MEMBER) {
561  if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) {
562  throw new RestException(403);
563  }
564  $object = new Adherent($this->db);
565  } elseif ($type === Categorie::TYPE_ACTIONCOMM) {
566  if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) {
567  throw new RestException(403);
568  }
569  $object = new ActionComm($this->db);
570  } else {
571  throw new RestException(400, "this type is not recognized yet.");
572  }
573 
574  $result = $object->fetch((int) $object_id);
575  if ($result > 0) {
576  $result = $this->category->del_type($object, $type);
577  if ($result < 0) {
578  throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors));
579  }
580  } else {
581  throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors));
582  }
583 
584  return array(
585  'success' => array(
586  'code' => 200,
587  'message' => 'Objects successfully unlinked from the category'
588  )
589  );
590  }
591 
604  public function unlinkObjectByRef($id, $type, $object_ref)
605  {
606  if (empty($type) || empty($object_ref)) {
607  throw new RestException(403);
608  }
609 
610  if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
611  throw new RestException(403);
612  }
613 
614  $result = $this->category->fetch($id);
615  if (!$result) {
616  throw new RestException(404, 'category not found');
617  }
618 
619  if ($type === Categorie::TYPE_PRODUCT) {
620  if (!DolibarrApiAccess::$user->hasRight('produit', 'creer') && !DolibarrApiAccess::$user->hasRight('service', 'creer')) {
621  throw new RestException(403);
622  }
623  $object = new Product($this->db);
624  } elseif ($type === Categorie::TYPE_CUSTOMER) {
625  if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
626  throw new RestException(403);
627  }
628  $object = new Societe($this->db);
629  } elseif ($type === Categorie::TYPE_SUPPLIER) {
630  if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
631  throw new RestException(403);
632  }
633  $object = new Societe($this->db);
634  } elseif ($type === Categorie::TYPE_CONTACT) {
635  if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) {
636  throw new RestException(403);
637  }
638  $object = new Contact($this->db);
639  } elseif ($type === Categorie::TYPE_MEMBER) {
640  if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) {
641  throw new RestException(403);
642  }
643  $object = new Adherent($this->db);
644  } elseif ($type === Categorie::TYPE_ACTIONCOMM) {
645  if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) {
646  throw new RestException(403);
647  }
648  $object = new ActionComm($this->db);
649  } else {
650  throw new RestException(400, "this type is not recognized yet.");
651  }
652 
653  $result = $object->fetch(0, (string) $object_ref);
654  if ($result > 0) {
655  $result = $this->category->del_type($object, $type);
656  if ($result < 0) {
657  throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors));
658  }
659  } else {
660  throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors));
661  }
662 
663  return array(
664  'success' => array(
665  'code' => 200,
666  'message' => 'Objects successfully unlinked from the category'
667  )
668  );
669  }
670 
671 
672  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
679  protected function _cleanObjectDatas($object)
680  {
681  // phpcs:enable
682  $object = parent::_cleanObjectDatas($object);
683 
684  // Remove fields not relevant to categories
685  unset($object->MAP_CAT_FK);
686  unset($object->MAP_CAT_TABLE);
687  unset($object->MAP_OBJ_CLASS);
688  unset($object->MAP_OBJ_TABLE);
689  unset($object->country);
690  unset($object->country_id);
691  unset($object->country_code);
692  unset($object->total_ht);
693  unset($object->total_ht);
694  unset($object->total_localtax1);
695  unset($object->total_localtax2);
696  unset($object->total_ttc);
697  unset($object->total_tva);
698  unset($object->lines);
699  unset($object->civility_id);
700  unset($object->name);
701  unset($object->lastname);
702  unset($object->firstname);
703  unset($object->shipping_method_id);
704  unset($object->fk_delivery_address);
705  unset($object->cond_reglement);
706  unset($object->cond_reglement_id);
707  unset($object->mode_reglement_id);
708  unset($object->barcode_type_coder);
709  unset($object->barcode_type_label);
710  unset($object->barcode_type_code);
711  unset($object->barcode_type);
712  unset($object->canvas);
713  unset($object->cats);
714  unset($object->motherof);
715  unset($object->context);
716  unset($object->socid);
717  unset($object->thirdparty);
718  unset($object->contact);
719  unset($object->contact_id);
720  unset($object->user);
721  unset($object->fk_account);
722  unset($object->fk_project);
723  unset($object->note);
724  unset($object->statut);
725 
726  return $object;
727  }
728 
737  private function _validate($data)
738  {
739  $category = array();
740  foreach (Categories::$FIELDS as $field) {
741  if (!isset($data[$field])) {
742  throw new RestException(400, "$field field missing");
743  }
744  $category[$field] = $data[$field];
745  }
746  return $category;
747  }
748 
760  public function getObjects($id, $type, $onlyids = 0)
761  {
762  dol_syslog("getObjects($id, $type, $onlyids)", LOG_DEBUG);
763 
764  if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
765  throw new RestException(403);
766  }
767 
768  if (empty($type)) {
769  throw new RestException(500, 'The "type" parameter is required.');
770  }
771 
772  $result = $this->category->fetch($id);
773  if (!$result) {
774  throw new RestException(404, 'category not found');
775  }
776 
777  if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) {
778  throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
779  }
780 
781  $result = $this->category->getObjectsInCateg($type, $onlyids);
782 
783  if ($result < 0) {
784  throw new RestException(503, 'Error when retrieving objects list : '.$this->category->error);
785  }
786 
787  $objects = $result;
788  $cleaned_objects = array();
789  $objects_api = null;
790  if ($type == 'member') {
791  $objects_api = new Members();
792  } elseif ($type == 'customer' || $type == 'supplier') {
793  $objects_api = new Thirdparties();
794  } elseif ($type == 'product') {
795  $objects_api = new Products();
796  } elseif ($type == 'contact') {
797  $objects_api = new Contacts();
798  } elseif ($type == 'project') {
799  $objects_api = new Projects();
800  }
801 
802  if (is_object($objects_api)) {
803  foreach ($objects as $obj) {
804  $cleaned_objects[] = $objects_api->_cleanObjectDatas($obj);
805  }
806  }
807 
808  return $cleaned_objects;
809  }
810 }
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition: card.php:58
Class to manage agenda events (actions)
Class to manage members of a foundation.
Class to manage categories.
__construct()
Constructor.
put($id, $request_data=null)
Update category.
unlinkObjectById($id, $type, $object_id)
Unlink an object from a category by id.
unlinkObjectByRef($id, $type, $object_ref)
Unlink an object from a category by ref.
_validate($data)
Validate fields before create or update object.
post($request_data=null)
Create category object.
_cleanObjectDatas($object)
Clean sensible object datas.
getObjects($id, $type, $onlyids=0)
Get the list of objects in a category.
getListForObject($id, $type, $sortfield="s.rowid", $sortorder='ASC', $limit=0, $page=0)
List categories of an object.
linkObjectById($id, $type, $object_id)
Link an object to a category by id.
linkObjectByRef($id, $type, $object_ref)
Link an object to a category by ref.
index($sortfield="t.rowid", $sortorder='ASC', $limit=100, $page=0, $type='', $sqlfilters='', $properties='')
List categories.
Class to manage contact/addresses.
Class for API REST v1.
Definition: api.class.php:30
_filterObjectProperties($object, $properties)
Filter properties that will be returned on object.
Definition: api.class.php:136
static _checkAccessToResource($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
Check access by user to a given resource.
Definition: api.class.php:369
_checkValForAPI($field, $value, $object)
Check and convert a string depending on its type/name.
Definition: api.class.php:82
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
Definition: index.php:751
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
sanitizeVal($out='', $check='alphanohtml', $filter=null, $options=null)
Return a sanitized or empty value after checking value against a rule.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.