dolibarr 21.0.3
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20use Luracast\Restler\RestException;
21
22require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
23require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
24require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
25
26require_once DOL_DOCUMENT_ROOT.'/adherents/class/api_members.class.php';
27require_once DOL_DOCUMENT_ROOT.'/product/class/api_products.class.php';
28require_once DOL_DOCUMENT_ROOT.'/societe/class/api_contacts.class.php';
29require_once DOL_DOCUMENT_ROOT.'/societe/class/api_thirdparties.class.php';
30require_once DOL_DOCUMENT_ROOT.'/projet/class/api_projects.class.php';
31
39{
43 public static $FIELDS = array(
44 'label',
45 'type'
46 );
47
51 public $category;
52
56 public function __construct()
57 {
58 global $db;
59
60 $this->db = $db;
61 $this->category = new Categorie($this->db);
62 }
63
75 public function get($id, $include_childs = false)
76 {
77 if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
78 throw new RestException(403);
79 }
80
81 $result = $this->category->fetch($id);
82 if (!$result) {
83 throw new RestException(404, 'category not found');
84 }
85
86 if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) {
87 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
88 }
89
90 if ($include_childs) {
91 $cats = $this->category->get_filles();
92 if (!is_array($cats)) {
93 throw new RestException(500, 'Error when fetching child categories', array_merge(array($this->category->error), $this->category->errors));
94 }
95 $this->category->childs = array();
96 foreach ($cats as $cat) {
97 $this->category->childs[] = $this->_cleanObjectDatas($cat);
98 }
99 }
100
101 return $this->_cleanObjectDatas($this->category);
102 }
103
120 public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '', $properties = '')
121 {
122 $obj_ret = array();
123
124 if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
125 throw new RestException(403);
126 }
127
128 $sql = "SELECT t.rowid";
129 $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
130 $sql .= ' WHERE t.entity IN ('.getEntity('category').')';
131 if (!empty($type)) {
132 $category_static = new Categorie($this->db);
133 if (is_numeric($type)) {
134 $sql .= ' AND t.type = '.((int) $type);
135 } else {
136 $sql .= ' AND t.type = '.((int) (array_key_exists($type, $category_static->MAP_ID) ? $category_static->MAP_ID[$type] : -1));
137 }
138 }
139
140 // Add sql filters
141 if ($sqlfilters) {
142 $errormessage = '';
143 $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage);
144 if ($errormessage) {
145 throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
146 }
147 }
148
149 $sql .= $this->db->order($sortfield, $sortorder);
150 if ($limit) {
151 if ($page < 0) {
152 $page = 0;
153 }
154 $offset = $limit * $page;
155
156 $sql .= $this->db->plimit($limit + 1, $offset);
157 }
158
159 $result = $this->db->query($sql);
160 if ($result) {
161 $i = 0;
162 $num = $this->db->num_rows($result);
163 $min = min($num, ($limit <= 0 ? $num : $limit));
164 while ($i < $min) {
165 $obj = $this->db->fetch_object($result);
166 $category_static = new Categorie($this->db);
167 if ($category_static->fetch($obj->rowid)) {
168 $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($category_static), $properties);
169 }
170 $i++;
171 }
172 } else {
173 throw new RestException(503, 'Error when retrieve category list : '.$this->db->lasterror());
174 }
175
176 return $obj_ret;
177 }
178
185 public function post($request_data = null)
186 {
187 if (!DolibarrApiAccess::$user->hasRight('categorie', 'creer')) {
188 throw new RestException(403);
189 }
190
191 // Check mandatory fields (throw an exception if wrong)
192 $this->_validate($request_data);
193
194 foreach ($request_data as $field => $value) {
195 if ($field === 'caller') {
196 // 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
197 $this->category->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
198 continue;
199 }
200
201 $this->category->$field = $this->_checkValForAPI($field, $value, $this->category);
202 }
203 if ($this->category->create(DolibarrApiAccess::$user) < 0) {
204 throw new RestException(500, 'Error when creating category', array_merge(array($this->category->error), $this->category->errors));
205 }
206 return $this->category->id;
207 }
208
216 public function put($id, $request_data = null)
217 {
218 if (!DolibarrApiAccess::$user->hasRight('categorie', 'creer')) {
219 throw new RestException(403);
220 }
221
222 $result = $this->category->fetch($id);
223 if (!$result) {
224 throw new RestException(404, 'category not found');
225 }
226
227 if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) {
228 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
229 }
230
231 foreach ($request_data as $field => $value) {
232 if ($field == 'id') {
233 continue;
234 }
235 if ($field === 'caller') {
236 // 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
237 $this->category->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
238 continue;
239 }
240
241 if ($field == 'array_options' && is_array($value)) {
242 foreach ($value as $index => $val) {
243 $this->category->array_options[$index] = $this->_checkValForAPI($field, $val, $this->category);
244 }
245 continue;
246 }
247
248 $this->category->$field = $this->_checkValForAPI($field, $value, $this->category);
249 }
250
251 if ($this->category->update(DolibarrApiAccess::$user) > 0) {
252 return $this->get($id);
253 } else {
254 throw new RestException(500, $this->category->error);
255 }
256 }
257
264 public function delete($id)
265 {
266 if (!DolibarrApiAccess::$user->hasRight('categorie', 'supprimer')) {
267 throw new RestException(403);
268 }
269 $result = $this->category->fetch($id);
270 if (!$result) {
271 throw new RestException(404, 'category not found');
272 }
273
274 if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) {
275 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
276 }
277
278 if ($this->category->delete(DolibarrApiAccess::$user) <= 0) {
279 throw new RestException(500, 'Error when delete category : ' . $this->category->error);
280 }
281
282 return array(
283 'success' => array(
284 'code' => 200,
285 'message' => 'Category deleted'
286 )
287 );
288 }
289
307 public function getListForObject($id, $type, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
308 {
309 if (!in_array($type, [
310 Categorie::TYPE_PRODUCT,
311 Categorie::TYPE_CONTACT,
312 Categorie::TYPE_CUSTOMER,
313 Categorie::TYPE_SUPPLIER,
314 Categorie::TYPE_MEMBER,
315 Categorie::TYPE_PROJECT,
316 Categorie::TYPE_KNOWLEDGEMANAGEMENT,
317 Categorie::TYPE_ACTIONCOMM
318 ])) {
319 throw new RestException(403);
320 }
321
322 if ($type == Categorie::TYPE_PRODUCT && !DolibarrApiAccess::$user->hasRight('produit', 'lire') && !DolibarrApiAccess::$user->hasRight('service', 'lire')) {
323 throw new RestException(403);
324 } elseif ($type == Categorie::TYPE_CONTACT && !DolibarrApiAccess::$user->hasRight('contact', 'lire')) {
325 throw new RestException(403);
326 } elseif ($type == Categorie::TYPE_CUSTOMER && !DolibarrApiAccess::$user->hasRight('societe', 'lire')) {
327 throw new RestException(403);
328 } elseif ($type == Categorie::TYPE_SUPPLIER && !DolibarrApiAccess::$user->hasRight('fournisseur', 'lire')) {
329 throw new RestException(403);
330 } elseif ($type == Categorie::TYPE_MEMBER && !DolibarrApiAccess::$user->hasRight('adherent', 'lire')) {
331 throw new RestException(403);
332 } elseif ($type == Categorie::TYPE_PROJECT && !DolibarrApiAccess::$user->hasRight('projet', 'lire')) {
333 throw new RestException(403);
334 } elseif ($type == Categorie::TYPE_KNOWLEDGEMANAGEMENT && !DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) {
335 throw new RestException(403);
336 } elseif ($type == Categorie::TYPE_ACTIONCOMM && !DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) {
337 throw new RestException(403);
338 }
339
340 $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page);
341
342 if (!is_array($categories)) {
343 throw new RestException(600, 'Error when fetching object categories', array_merge(array($this->category->error), $this->category->errors));
344 }
345 return $categories;
346 }
347
360 public function linkObjectById($id, $type, $object_id)
361 {
362 if (empty($type) || empty($object_id)) {
363 throw new RestException(403);
364 }
365
366 if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
367 throw new RestException(403);
368 }
369
370 $result = $this->category->fetch($id);
371 if (!$result) {
372 throw new RestException(404, 'category not found');
373 }
374
375 if ($type === Categorie::TYPE_PRODUCT) {
376 if (!DolibarrApiAccess::$user->hasRight('produit', 'creer') && !DolibarrApiAccess::$user->hasRight('service', 'creer')) {
377 throw new RestException(403);
378 }
379 $object = new Product($this->db);
380 } elseif ($type === Categorie::TYPE_CUSTOMER) {
381 if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
382 throw new RestException(403);
383 }
384 $object = new Societe($this->db);
385 } elseif ($type === Categorie::TYPE_SUPPLIER) {
386 if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
387 throw new RestException(403);
388 }
389 $object = new Societe($this->db);
390 } elseif ($type === Categorie::TYPE_CONTACT) {
391 if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) {
392 throw new RestException(403);
393 }
394 $object = new Contact($this->db);
395 } elseif ($type === Categorie::TYPE_MEMBER) {
396 if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) {
397 throw new RestException(403);
398 }
399 $object = new Adherent($this->db);
400 } elseif ($type === Categorie::TYPE_ACTIONCOMM) {
401 if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) {
402 throw new RestException(403);
403 }
404 $object = new ActionComm($this->db);
405 } else {
406 throw new RestException(400, "this type is not recognized yet.");
407 }
408
409 $result = $object->fetch($object_id);
410 if ($result > 0) {
411 $result = $this->category->add_type($object, $type);
412 if ($result < 0) {
413 if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') {
414 throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors));
415 }
416 }
417 } else {
418 throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors));
419 }
420
421 return array(
422 'success' => array(
423 'code' => 200,
424 'message' => 'Objects successfully linked to the category'
425 )
426 );
427 }
428
441 public function linkObjectByRef($id, $type, $object_ref)
442 {
443 if (empty($type) || empty($object_ref)) {
444 throw new RestException(403);
445 }
446
447 if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
448 throw new RestException(403);
449 }
450
451 $result = $this->category->fetch($id);
452 if (!$result) {
453 throw new RestException(404, 'category not found');
454 }
455
456 if ($type === Categorie::TYPE_PRODUCT) {
457 if (!DolibarrApiAccess::$user->hasRight('produit', 'creer') && !DolibarrApiAccess::$user->hasRight('service', 'creer')) {
458 throw new RestException(403);
459 }
460 $object = new Product($this->db);
461 } elseif ($type === Categorie::TYPE_CUSTOMER) {
462 if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
463 throw new RestException(403);
464 }
465 $object = new Societe($this->db);
466 } elseif ($type === Categorie::TYPE_SUPPLIER) {
467 if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
468 throw new RestException(403);
469 }
470 $object = new Societe($this->db);
471 } elseif ($type === Categorie::TYPE_CONTACT) {
472 if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) {
473 throw new RestException(403);
474 }
475 $object = new Contact($this->db);
476 } elseif ($type === Categorie::TYPE_MEMBER) {
477 if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) {
478 throw new RestException(403);
479 }
480 $object = new Adherent($this->db);
481 } elseif ($type === Categorie::TYPE_ACTIONCOMM) {
482 if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) {
483 throw new RestException(403);
484 }
485 $object = new ActionComm($this->db);
486 } else {
487 throw new RestException(400, "this type is not recognized yet.");
488 }
489
490 $result = $object->fetch(0, $object_ref);
491 if ($result > 0) {
492 $result = $this->category->add_type($object, $type);
493 if ($result < 0) {
494 if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') {
495 throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors));
496 }
497 }
498 } else {
499 throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors));
500 }
501
502 return array(
503 'success' => array(
504 'code' => 200,
505 'message' => 'Objects successfully linked to the category'
506 )
507 );
508 }
509
522 public function unlinkObjectById($id, $type, $object_id)
523 {
524 if (empty($type) || empty($object_id)) {
525 throw new RestException(403);
526 }
527
528 if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
529 throw new RestException(403);
530 }
531
532 $result = $this->category->fetch($id);
533 if (!$result) {
534 throw new RestException(404, 'category not found');
535 }
536
537 if ($type === Categorie::TYPE_PRODUCT) {
538 if (!DolibarrApiAccess::$user->hasRight('produit', 'creer') && !DolibarrApiAccess::$user->hasRight('service', 'creer')) {
539 throw new RestException(403);
540 }
541 $object = new Product($this->db);
542 } elseif ($type === Categorie::TYPE_CUSTOMER) {
543 if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
544 throw new RestException(403);
545 }
546 $object = new Societe($this->db);
547 } elseif ($type === Categorie::TYPE_SUPPLIER) {
548 if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
549 throw new RestException(403);
550 }
551 $object = new Societe($this->db);
552 } elseif ($type === Categorie::TYPE_CONTACT) {
553 if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) {
554 throw new RestException(403);
555 }
556 $object = new Contact($this->db);
557 } elseif ($type === Categorie::TYPE_MEMBER) {
558 if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) {
559 throw new RestException(403);
560 }
561 $object = new Adherent($this->db);
562 } elseif ($type === Categorie::TYPE_ACTIONCOMM) {
563 if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) {
564 throw new RestException(403);
565 }
566 $object = new ActionComm($this->db);
567 } else {
568 throw new RestException(400, "this type is not recognized yet.");
569 }
570
571 $result = $object->fetch((int) $object_id);
572 if ($result > 0) {
573 $result = $this->category->del_type($object, $type);
574 if ($result < 0) {
575 throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors));
576 }
577 } else {
578 throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors));
579 }
580
581 return array(
582 'success' => array(
583 'code' => 200,
584 'message' => 'Objects successfully unlinked from the category'
585 )
586 );
587 }
588
601 public function unlinkObjectByRef($id, $type, $object_ref)
602 {
603 if (empty($type) || empty($object_ref)) {
604 throw new RestException(403);
605 }
606
607 if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
608 throw new RestException(403);
609 }
610
611 $result = $this->category->fetch($id);
612 if (!$result) {
613 throw new RestException(404, 'category not found');
614 }
615
616 if ($type === Categorie::TYPE_PRODUCT) {
617 if (!DolibarrApiAccess::$user->hasRight('produit', 'creer') && !DolibarrApiAccess::$user->hasRight('service', 'creer')) {
618 throw new RestException(403);
619 }
620 $object = new Product($this->db);
621 } elseif ($type === Categorie::TYPE_CUSTOMER) {
622 if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
623 throw new RestException(403);
624 }
625 $object = new Societe($this->db);
626 } elseif ($type === Categorie::TYPE_SUPPLIER) {
627 if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
628 throw new RestException(403);
629 }
630 $object = new Societe($this->db);
631 } elseif ($type === Categorie::TYPE_CONTACT) {
632 if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) {
633 throw new RestException(403);
634 }
635 $object = new Contact($this->db);
636 } elseif ($type === Categorie::TYPE_MEMBER) {
637 if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) {
638 throw new RestException(403);
639 }
640 $object = new Adherent($this->db);
641 } elseif ($type === Categorie::TYPE_ACTIONCOMM) {
642 if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) {
643 throw new RestException(403);
644 }
645 $object = new ActionComm($this->db);
646 } else {
647 throw new RestException(400, "this type is not recognized yet.");
648 }
649
650 $result = $object->fetch(0, (string) $object_ref);
651 if ($result > 0) {
652 $result = $this->category->del_type($object, $type);
653 if ($result < 0) {
654 throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors));
655 }
656 } else {
657 throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors));
658 }
659
660 return array(
661 'success' => array(
662 'code' => 200,
663 'message' => 'Objects successfully unlinked from the category'
664 )
665 );
666 }
667
668
669 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
676 protected function _cleanObjectDatas($object)
677 {
678 // phpcs:enable
679 $object = parent::_cleanObjectDatas($object);
680
681 // Remove fields not relevant to categories
682 unset($object->MAP_CAT_FK);
683 unset($object->MAP_CAT_TABLE);
684 unset($object->MAP_OBJ_CLASS);
685 unset($object->MAP_OBJ_TABLE);
686 unset($object->country);
687 unset($object->country_id);
688 unset($object->country_code);
689 unset($object->total_ht);
690 unset($object->total_ht);
691 unset($object->total_localtax1);
692 unset($object->total_localtax2);
693 unset($object->total_ttc);
694 unset($object->total_tva);
695 unset($object->lines);
696 unset($object->civility_id);
697 unset($object->name);
698 unset($object->lastname);
699 unset($object->firstname);
700 unset($object->shipping_method_id);
701 unset($object->fk_delivery_address);
702 unset($object->cond_reglement);
703 unset($object->cond_reglement_id);
704 unset($object->mode_reglement_id);
705 unset($object->barcode_type_coder);
706 unset($object->barcode_type_label);
707 unset($object->barcode_type_code);
708 unset($object->barcode_type);
709 unset($object->canvas);
710 unset($object->cats);
711 unset($object->motherof);
712 unset($object->context);
713 unset($object->socid);
714 unset($object->thirdparty);
715 unset($object->contact);
716 unset($object->contact_id);
717 unset($object->user);
718 unset($object->fk_account);
719 unset($object->fk_project);
720 unset($object->note);
721 unset($object->statut);
722
723 return $object;
724 }
725
734 private function _validate($data)
735 {
736 $category = array();
737 foreach (Categories::$FIELDS as $field) {
738 if (!isset($data[$field])) {
739 throw new RestException(400, "$field field missing");
740 }
741 $category[$field] = $data[$field];
742 }
743 return $category;
744 }
745
757 public function getObjects($id, $type, $onlyids = 0)
758 {
759 dol_syslog("getObjects($id, $type, $onlyids)", LOG_DEBUG);
760
761 if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
762 throw new RestException(403);
763 }
764
765 if (empty($type)) {
766 throw new RestException(500, 'The "type" parameter is required.');
767 }
768
769 $result = $this->category->fetch($id);
770 if (!$result) {
771 throw new RestException(404, 'category not found');
772 }
773
774 if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) {
775 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
776 }
777
778 $result = $this->category->getObjectsInCateg($type, $onlyids);
779
780 if ($result < 0) {
781 throw new RestException(503, 'Error when retrieving objects list : '.$this->category->error);
782 }
783
784 $objects = $result;
785 $cleaned_objects = array();
786 $objects_api = null;
787 if ($type == 'member') {
788 $objects_api = new Members();
789 } elseif ($type == 'customer' || $type == 'supplier') {
790 $objects_api = new Thirdparties();
791 } elseif ($type == 'product') {
792 $objects_api = new Products();
793 } elseif ($type == 'contact') {
794 $objects_api = new Contacts();
795 } elseif ($type == 'project') {
796 $objects_api = new Projects();
797 }
798
799 if (is_object($objects_api)) {
800 foreach ($objects as $obj) {
801 $cleaned_objects[] = $objects_api->_cleanObjectDatas($obj);
802 }
803 }
804
805 return $cleaned_objects;
806 }
807}
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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:31
_filterObjectProperties($object, $properties)
Filter properties that will be returned on object.
static _checkAccessToResource($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
Check access by user to a given resource.
_checkValForAPI($field, $value, $object)
Check and convert a string depending on its type/name.
Definition api.class.php:83
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
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.