# NEW : add ActionComm categories accessible thru API (#30005)
* Update api_categories.class.php Add Actioncomm Categories management thru API * Update api_categories.class.php * Update api_categories.class.php * Update api_categories.class.php * Update api_categories.class.php * Update api_categories.class.php
This commit is contained in:
parent
0a1eb954d7
commit
d8b4f9248d
1 changed files with 32 additions and 7 deletions
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2024 Jose MARTINEZ <jose.martinez@pichinov.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -19,7 +20,7 @@ use Luracast\Restler\RestException;
|
|||
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/api_members.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/api_products.class.php';
|
||||
|
|
@ -125,7 +126,7 @@ class Categories extends DolibarrApi
|
|||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @param int $page Page number
|
||||
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact')
|
||||
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact', 'actioncomm')
|
||||
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
|
||||
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
|
||||
* @return array Array of category objects
|
||||
|
|
@ -295,7 +296,7 @@ class Categories extends DolibarrApi
|
|||
* Get the list of categories linked to an object
|
||||
*
|
||||
* @param int $id Object ID
|
||||
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact', 'project')
|
||||
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact', 'project', 'actioncomm')
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
|
|
@ -315,7 +316,8 @@ class Categories extends DolibarrApi
|
|||
Categorie::TYPE_SUPPLIER,
|
||||
Categorie::TYPE_MEMBER,
|
||||
Categorie::TYPE_PROJECT,
|
||||
Categorie::TYPE_KNOWLEDGEMANAGEMENT
|
||||
Categorie::TYPE_KNOWLEDGEMANAGEMENT,
|
||||
Categorie::TYPE_ACTIONCOMM
|
||||
])) {
|
||||
throw new RestException(403);
|
||||
}
|
||||
|
|
@ -334,6 +336,8 @@ class Categories extends DolibarrApi
|
|||
throw new RestException(403);
|
||||
} elseif ($type == Categorie::TYPE_KNOWLEDGEMANAGEMENT && !DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) {
|
||||
throw new RestException(403);
|
||||
} elseif ($type == Categorie::TYPE_ACTIONCOMM && !DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) {
|
||||
throw new RestException(403);
|
||||
}
|
||||
|
||||
$categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page);
|
||||
|
|
@ -348,7 +352,7 @@ class Categories extends DolibarrApi
|
|||
* Link an object to a category by id
|
||||
*
|
||||
* @param int $id ID of category
|
||||
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact')
|
||||
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact', 'actioncomm')
|
||||
* @param int $object_id ID of object
|
||||
*
|
||||
* @return array
|
||||
|
|
@ -396,6 +400,11 @@ class Categories extends DolibarrApi
|
|||
throw new RestException(403);
|
||||
}
|
||||
$object = new Adherent($this->db);
|
||||
} elseif ($type === Categorie::TYPE_ACTIONCOMM) {
|
||||
if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) {
|
||||
throw new RestException(403);
|
||||
}
|
||||
$object = new ActionComm($this->db);
|
||||
} else {
|
||||
throw new RestException(400, "this type is not recognized yet.");
|
||||
}
|
||||
|
|
@ -472,6 +481,11 @@ class Categories extends DolibarrApi
|
|||
throw new RestException(403);
|
||||
}
|
||||
$object = new Adherent($this->db);
|
||||
} elseif ($type === Categorie::TYPE_ACTIONCOMM) {
|
||||
if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) {
|
||||
throw new RestException(403);
|
||||
}
|
||||
$object = new ActionComm($this->db);
|
||||
} else {
|
||||
throw new RestException(400, "this type is not recognized yet.");
|
||||
}
|
||||
|
|
@ -500,7 +514,7 @@ class Categories extends DolibarrApi
|
|||
* Unlink an object from a category by id
|
||||
*
|
||||
* @param int $id ID of category
|
||||
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact')
|
||||
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact', 'actioncomm')
|
||||
* @param int $object_id ID of the object
|
||||
*
|
||||
* @return array
|
||||
|
|
@ -548,6 +562,11 @@ class Categories extends DolibarrApi
|
|||
throw new RestException(403);
|
||||
}
|
||||
$object = new Adherent($this->db);
|
||||
} elseif ($type === Categorie::TYPE_ACTIONCOMM) {
|
||||
if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) {
|
||||
throw new RestException(403);
|
||||
}
|
||||
$object = new ActionComm($this->db);
|
||||
} else {
|
||||
throw new RestException(400, "this type is not recognized yet.");
|
||||
}
|
||||
|
|
@ -574,7 +593,7 @@ class Categories extends DolibarrApi
|
|||
* Unlink an object from a category by ref
|
||||
*
|
||||
* @param int $id ID of category
|
||||
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact')
|
||||
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact', 'actioncomm')
|
||||
* @param string $object_ref Reference of the object
|
||||
*
|
||||
* @return array
|
||||
|
|
@ -622,6 +641,11 @@ class Categories extends DolibarrApi
|
|||
throw new RestException(403);
|
||||
}
|
||||
$object = new Adherent($this->db);
|
||||
} elseif ($type === Categorie::TYPE_ACTIONCOMM) {
|
||||
if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) {
|
||||
throw new RestException(403);
|
||||
}
|
||||
$object = new ActionComm($this->db);
|
||||
} else {
|
||||
throw new RestException(400, "this type is not recognized yet.");
|
||||
}
|
||||
|
|
@ -774,6 +798,7 @@ class Categories extends DolibarrApi
|
|||
} elseif ($type == 'project') {
|
||||
$objects_api = new Projects();
|
||||
}
|
||||
|
||||
if (is_object($objects_api)) {
|
||||
foreach ($objects as $obj) {
|
||||
$cleaned_objects[] = $objects_api->_cleanObjectDatas($obj);
|
||||
|
|
|
|||
Loading…
Reference in a new issue