dolibarr 21.0.0-beta
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 static $TYPES = array(
52 0 => 'product',
53 1 => 'supplier',
54 2 => 'customer',
55 3 => 'member',
56 4 => 'contact',
57 5 => 'account',
58 6 => 'project',
59 7 => 'user',
60 8 => 'bank_line',
61 9 => 'warehouse',
62 10 => 'actioncomm',
63 11 => 'website_page',
64 12 => 'ticket',
65 13 => 'knowledgemanagement'
66 );
67
71 public $category;
72
76 public function __construct()
77 {
78 global $db;
79
80 $this->db = $db;
81 $this->category = new Categorie($this->db);
82 }
83
95 public function get($id, $include_childs = false)
96 {
97 if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
98 throw new RestException(403);
99 }
100
101 $result = $this->category->fetch($id);
102 if (!$result) {
103 throw new RestException(404, 'category not found');
104 }
105
106 if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) {
107 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
108 }
109
110 if ($include_childs) {
111 $cats = $this->category->get_filles();
112 if (!is_array($cats)) {
113 throw new RestException(500, 'Error when fetching child categories', array_merge(array($this->category->error), $this->category->errors));
114 }
115 $this->category->childs = array();
116 foreach ($cats as $cat) {
117 $this->category->childs[] = $this->_cleanObjectDatas($cat);
118 }
119 }
120
121 return $this->_cleanObjectDatas($this->category);
122 }
123
140 public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '', $properties = '')
141 {
142 $obj_ret = array();
143
144 if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
145 throw new RestException(403);
146 }
147
148 $sql = "SELECT t.rowid";
149 $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
150 $sql .= ' WHERE t.entity IN ('.getEntity('category').')';
151 if (!empty($type)) {
152 $sql .= ' AND t.type='.array_search($type, Categories::$TYPES);
153 }
154 // Add sql filters
155 if ($sqlfilters) {
156 $errormessage = '';
157 $sql .= forgeSQLFromUniversalSearchCriteria($sqlfilters, $errormessage);
158 if ($errormessage) {
159 throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
160 }
161 }
162
163 $sql .= $this->db->order($sortfield, $sortorder);
164 if ($limit) {
165 if ($page < 0) {
166 $page = 0;
167 }
168 $offset = $limit * $page;
169
170 $sql .= $this->db->plimit($limit + 1, $offset);
171 }
172
173 $result = $this->db->query($sql);
174 if ($result) {
175 $i = 0;
176 $num = $this->db->num_rows($result);
177 $min = min($num, ($limit <= 0 ? $num : $limit));
178 while ($i < $min) {
179 $obj = $this->db->fetch_object($result);
180 $category_static = new Categorie($this->db);
181 if ($category_static->fetch($obj->rowid)) {
182 $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($category_static), $properties);
183 }
184 $i++;
185 }
186 } else {
187 throw new RestException(503, 'Error when retrieve category list : '.$this->db->lasterror());
188 }
189
190 return $obj_ret;
191 }
192
199 public function post($request_data = null)
200 {
201 if (!DolibarrApiAccess::$user->hasRight('categorie', 'creer')) {
202 throw new RestException(403);
203 }
204
205 // Check mandatory fields (throw an exception if wrong)
206 $this->_validate($request_data);
207
208 foreach ($request_data as $field => $value) {
209 if ($field === 'caller') {
210 // 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
211 $this->category->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
212 continue;
213 }
214
215 $this->category->$field = $this->_checkValForAPI($field, $value, $this->category);
216 }
217 if ($this->category->create(DolibarrApiAccess::$user) < 0) {
218 throw new RestException(500, 'Error when creating category', array_merge(array($this->category->error), $this->category->errors));
219 }
220 return $this->category->id;
221 }
222
230 public function put($id, $request_data = null)
231 {
232 if (!DolibarrApiAccess::$user->hasRight('categorie', 'creer')) {
233 throw new RestException(403);
234 }
235
236 $result = $this->category->fetch($id);
237 if (!$result) {
238 throw new RestException(404, 'category not found');
239 }
240
241 if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) {
242 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
243 }
244
245 foreach ($request_data as $field => $value) {
246 if ($field == 'id') {
247 continue;
248 }
249 if ($field === 'caller') {
250 // 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
251 $this->category->context['caller'] = sanitizeVal($request_data['caller'], 'aZ09');
252 continue;
253 }
254
255 $this->category->$field = $this->_checkValForAPI($field, $value, $this->category);
256 }
257
258 if ($this->category->update(DolibarrApiAccess::$user) > 0) {
259 return $this->get($id);
260 } else {
261 throw new RestException(500, $this->category->error);
262 }
263 }
264
271 public function delete($id)
272 {
273 if (!DolibarrApiAccess::$user->hasRight('categorie', 'supprimer')) {
274 throw new RestException(403);
275 }
276 $result = $this->category->fetch($id);
277 if (!$result) {
278 throw new RestException(404, 'category not found');
279 }
280
281 if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) {
282 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
283 }
284
285 if ($this->category->delete(DolibarrApiAccess::$user) <= 0) {
286 throw new RestException(500, 'Error when delete category : ' . $this->category->error);
287 }
288
289 return array(
290 'success' => array(
291 'code' => 200,
292 'message' => 'Category deleted'
293 )
294 );
295 }
296
314 public function getListForObject($id, $type, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
315 {
316 if (!in_array($type, [
317 Categorie::TYPE_PRODUCT,
318 Categorie::TYPE_CONTACT,
319 Categorie::TYPE_CUSTOMER,
320 Categorie::TYPE_SUPPLIER,
321 Categorie::TYPE_MEMBER,
322 Categorie::TYPE_PROJECT,
323 Categorie::TYPE_KNOWLEDGEMANAGEMENT,
324 Categorie::TYPE_ACTIONCOMM
325 ])) {
326 throw new RestException(403);
327 }
328
329 if ($type == Categorie::TYPE_PRODUCT && !DolibarrApiAccess::$user->hasRight('produit', 'lire') && !DolibarrApiAccess::$user->hasRight('service', 'lire')) {
330 throw new RestException(403);
331 } elseif ($type == Categorie::TYPE_CONTACT && !DolibarrApiAccess::$user->hasRight('contact', 'lire')) {
332 throw new RestException(403);
333 } elseif ($type == Categorie::TYPE_CUSTOMER && !DolibarrApiAccess::$user->hasRight('societe', 'lire')) {
334 throw new RestException(403);
335 } elseif ($type == Categorie::TYPE_SUPPLIER && !DolibarrApiAccess::$user->hasRight('fournisseur', 'lire')) {
336 throw new RestException(403);
337 } elseif ($type == Categorie::TYPE_MEMBER && !DolibarrApiAccess::$user->hasRight('adherent', 'lire')) {
338 throw new RestException(403);
339 } elseif ($type == Categorie::TYPE_PROJECT && !DolibarrApiAccess::$user->hasRight('projet', 'lire')) {
340 throw new RestException(403);
341 } elseif ($type == Categorie::TYPE_KNOWLEDGEMANAGEMENT && !DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) {
342 throw new RestException(403);
343 } elseif ($type == Categorie::TYPE_ACTIONCOMM && !DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) {
344 throw new RestException(403);
345 }
346
347 $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page);
348
349 if (!is_array($categories)) {
350 throw new RestException(600, 'Error when fetching object categories', array_merge(array($this->category->error), $this->category->errors));
351 }
352 return $categories;
353 }
354
367 public function linkObjectById($id, $type, $object_id)
368 {
369 if (empty($type) || empty($object_id)) {
370 throw new RestException(403);
371 }
372
373 if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
374 throw new RestException(403);
375 }
376
377 $result = $this->category->fetch($id);
378 if (!$result) {
379 throw new RestException(404, 'category not found');
380 }
381
382 if ($type === Categorie::TYPE_PRODUCT) {
383 if (!DolibarrApiAccess::$user->hasRight('produit', 'creer') && !DolibarrApiAccess::$user->hasRight('service', 'creer')) {
384 throw new RestException(403);
385 }
386 $object = new Product($this->db);
387 } elseif ($type === Categorie::TYPE_CUSTOMER) {
388 if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
389 throw new RestException(403);
390 }
391 $object = new Societe($this->db);
392 } elseif ($type === Categorie::TYPE_SUPPLIER) {
393 if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
394 throw new RestException(403);
395 }
396 $object = new Societe($this->db);
397 } elseif ($type === Categorie::TYPE_CONTACT) {
398 if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) {
399 throw new RestException(403);
400 }
401 $object = new Contact($this->db);
402 } elseif ($type === Categorie::TYPE_MEMBER) {
403 if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) {
404 throw new RestException(403);
405 }
406 $object = new Adherent($this->db);
407 } elseif ($type === Categorie::TYPE_ACTIONCOMM) {
408 if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) {
409 throw new RestException(403);
410 }
411 $object = new ActionComm($this->db);
412 } else {
413 throw new RestException(400, "this type is not recognized yet.");
414 }
415
416 $result = $object->fetch($object_id);
417 if ($result > 0) {
418 $result = $this->category->add_type($object, $type);
419 if ($result < 0) {
420 if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') {
421 throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors));
422 }
423 }
424 } else {
425 throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors));
426 }
427
428 return array(
429 'success' => array(
430 'code' => 200,
431 'message' => 'Objects successfully linked to the category'
432 )
433 );
434 }
435
448 public function linkObjectByRef($id, $type, $object_ref)
449 {
450 if (empty($type) || empty($object_ref)) {
451 throw new RestException(403);
452 }
453
454 if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
455 throw new RestException(403);
456 }
457
458 $result = $this->category->fetch($id);
459 if (!$result) {
460 throw new RestException(404, 'category not found');
461 }
462
463 if ($type === Categorie::TYPE_PRODUCT) {
464 if (!DolibarrApiAccess::$user->hasRight('produit', 'creer') && !DolibarrApiAccess::$user->hasRight('service', 'creer')) {
465 throw new RestException(403);
466 }
467 $object = new Product($this->db);
468 } elseif ($type === Categorie::TYPE_CUSTOMER) {
469 if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
470 throw new RestException(403);
471 }
472 $object = new Societe($this->db);
473 } elseif ($type === Categorie::TYPE_SUPPLIER) {
474 if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
475 throw new RestException(403);
476 }
477 $object = new Societe($this->db);
478 } elseif ($type === Categorie::TYPE_CONTACT) {
479 if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) {
480 throw new RestException(403);
481 }
482 $object = new Contact($this->db);
483 } elseif ($type === Categorie::TYPE_MEMBER) {
484 if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) {
485 throw new RestException(403);
486 }
487 $object = new Adherent($this->db);
488 } elseif ($type === Categorie::TYPE_ACTIONCOMM) {
489 if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) {
490 throw new RestException(403);
491 }
492 $object = new ActionComm($this->db);
493 } else {
494 throw new RestException(400, "this type is not recognized yet.");
495 }
496
497 $result = $object->fetch(0, $object_ref);
498 if ($result > 0) {
499 $result = $this->category->add_type($object, $type);
500 if ($result < 0) {
501 if ($this->category->error != 'DB_ERROR_RECORD_ALREADY_EXISTS') {
502 throw new RestException(500, 'Error when linking object', array_merge(array($this->category->error), $this->category->errors));
503 }
504 }
505 } else {
506 throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors));
507 }
508
509 return array(
510 'success' => array(
511 'code' => 200,
512 'message' => 'Objects successfully linked to the category'
513 )
514 );
515 }
516
529 public function unlinkObjectById($id, $type, $object_id)
530 {
531 if (empty($type) || empty($object_id)) {
532 throw new RestException(403);
533 }
534
535 if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
536 throw new RestException(403);
537 }
538
539 $result = $this->category->fetch($id);
540 if (!$result) {
541 throw new RestException(404, 'category not found');
542 }
543
544 if ($type === Categorie::TYPE_PRODUCT) {
545 if (!DolibarrApiAccess::$user->hasRight('produit', 'creer') && !DolibarrApiAccess::$user->hasRight('service', 'creer')) {
546 throw new RestException(403);
547 }
548 $object = new Product($this->db);
549 } elseif ($type === Categorie::TYPE_CUSTOMER) {
550 if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
551 throw new RestException(403);
552 }
553 $object = new Societe($this->db);
554 } elseif ($type === Categorie::TYPE_SUPPLIER) {
555 if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
556 throw new RestException(403);
557 }
558 $object = new Societe($this->db);
559 } elseif ($type === Categorie::TYPE_CONTACT) {
560 if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) {
561 throw new RestException(403);
562 }
563 $object = new Contact($this->db);
564 } elseif ($type === Categorie::TYPE_MEMBER) {
565 if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) {
566 throw new RestException(403);
567 }
568 $object = new Adherent($this->db);
569 } elseif ($type === Categorie::TYPE_ACTIONCOMM) {
570 if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) {
571 throw new RestException(403);
572 }
573 $object = new ActionComm($this->db);
574 } else {
575 throw new RestException(400, "this type is not recognized yet.");
576 }
577
578 $result = $object->fetch((int) $object_id);
579 if ($result > 0) {
580 $result = $this->category->del_type($object, $type);
581 if ($result < 0) {
582 throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors));
583 }
584 } else {
585 throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors));
586 }
587
588 return array(
589 'success' => array(
590 'code' => 200,
591 'message' => 'Objects successfully unlinked from the category'
592 )
593 );
594 }
595
608 public function unlinkObjectByRef($id, $type, $object_ref)
609 {
610 if (empty($type) || empty($object_ref)) {
611 throw new RestException(403);
612 }
613
614 if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
615 throw new RestException(403);
616 }
617
618 $result = $this->category->fetch($id);
619 if (!$result) {
620 throw new RestException(404, 'category not found');
621 }
622
623 if ($type === Categorie::TYPE_PRODUCT) {
624 if (!DolibarrApiAccess::$user->hasRight('produit', 'creer') && !DolibarrApiAccess::$user->hasRight('service', 'creer')) {
625 throw new RestException(403);
626 }
627 $object = new Product($this->db);
628 } elseif ($type === Categorie::TYPE_CUSTOMER) {
629 if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
630 throw new RestException(403);
631 }
632 $object = new Societe($this->db);
633 } elseif ($type === Categorie::TYPE_SUPPLIER) {
634 if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) {
635 throw new RestException(403);
636 }
637 $object = new Societe($this->db);
638 } elseif ($type === Categorie::TYPE_CONTACT) {
639 if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) {
640 throw new RestException(403);
641 }
642 $object = new Contact($this->db);
643 } elseif ($type === Categorie::TYPE_MEMBER) {
644 if (!DolibarrApiAccess::$user->hasRight('adherent', 'creer')) {
645 throw new RestException(403);
646 }
647 $object = new Adherent($this->db);
648 } elseif ($type === Categorie::TYPE_ACTIONCOMM) {
649 if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) {
650 throw new RestException(403);
651 }
652 $object = new ActionComm($this->db);
653 } else {
654 throw new RestException(400, "this type is not recognized yet.");
655 }
656
657 $result = $object->fetch(0, (string) $object_ref);
658 if ($result > 0) {
659 $result = $this->category->del_type($object, $type);
660 if ($result < 0) {
661 throw new RestException(500, 'Error when unlinking object', array_merge(array($this->category->error), $this->category->errors));
662 }
663 } else {
664 throw new RestException(500, 'Error when fetching object', array_merge(array($object->error), $object->errors));
665 }
666
667 return array(
668 'success' => array(
669 'code' => 200,
670 'message' => 'Objects successfully unlinked from the category'
671 )
672 );
673 }
674
675
676 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
683 protected function _cleanObjectDatas($object)
684 {
685 // phpcs:enable
686 $object = parent::_cleanObjectDatas($object);
687
688 // Remove fields not relevant to categories
689 unset($object->MAP_CAT_FK);
690 unset($object->MAP_CAT_TABLE);
691 unset($object->MAP_OBJ_CLASS);
692 unset($object->MAP_OBJ_TABLE);
693 unset($object->country);
694 unset($object->country_id);
695 unset($object->country_code);
696 unset($object->total_ht);
697 unset($object->total_ht);
698 unset($object->total_localtax1);
699 unset($object->total_localtax2);
700 unset($object->total_ttc);
701 unset($object->total_tva);
702 unset($object->lines);
703 unset($object->civility_id);
704 unset($object->name);
705 unset($object->lastname);
706 unset($object->firstname);
707 unset($object->shipping_method_id);
708 unset($object->fk_delivery_address);
709 unset($object->cond_reglement);
710 unset($object->cond_reglement_id);
711 unset($object->mode_reglement_id);
712 unset($object->barcode_type_coder);
713 unset($object->barcode_type_label);
714 unset($object->barcode_type_code);
715 unset($object->barcode_type);
716 unset($object->canvas);
717 unset($object->cats);
718 unset($object->motherof);
719 unset($object->context);
720 unset($object->socid);
721 unset($object->thirdparty);
722 unset($object->contact);
723 unset($object->contact_id);
724 unset($object->user);
725 unset($object->fk_account);
726 unset($object->fk_project);
727 unset($object->note);
728 unset($object->statut);
729
730 return $object;
731 }
732
741 private function _validate($data)
742 {
743 $category = array();
744 foreach (Categories::$FIELDS as $field) {
745 if (!isset($data[$field])) {
746 throw new RestException(400, "$field field missing");
747 }
748 $category[$field] = $data[$field];
749 }
750 return $category;
751 }
752
764 public function getObjects($id, $type, $onlyids = 0)
765 {
766 dol_syslog("getObjects($id, $type, $onlyids)", LOG_DEBUG);
767
768 if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) {
769 throw new RestException(403);
770 }
771
772 if (empty($type)) {
773 throw new RestException(500, 'The "type" parameter is required.');
774 }
775
776 $result = $this->category->fetch($id);
777 if (!$result) {
778 throw new RestException(404, 'category not found');
779 }
780
781 if (!DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) {
782 throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
783 }
784
785 $result = $this->category->getObjectsInCateg($type, $onlyids);
786
787 if ($result < 0) {
788 throw new RestException(503, 'Error when retrieving objects list : '.$this->category->error);
789 }
790
791 $objects = $result;
792 $cleaned_objects = array();
793 $objects_api = null;
794 if ($type == 'member') {
795 $objects_api = new Members();
796 } elseif ($type == 'customer' || $type == 'supplier') {
797 $objects_api = new Thirdparties();
798 } elseif ($type == 'product') {
799 $objects_api = new Products();
800 } elseif ($type == 'contact') {
801 $objects_api = new Contacts();
802 } elseif ($type == 'project') {
803 $objects_api = new Projects();
804 }
805
806 if (is_object($objects_api)) {
807 foreach ($objects as $obj) {
808 $cleaned_objects[] = $objects_api->_cleanObjectDatas($obj);
809 }
810 }
811
812 return $cleaned_objects;
813 }
814}
$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:30
_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:82
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.