mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-22 08:43:16 +01:00
API get documents dont support "projects_tasks" (#35671)
* API get documents dont support "projects_tasks" Fixes #35650 * fix: add missing whitespace formatting in api_documents class --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
@@ -80,6 +80,11 @@ class Documents extends DolibarrApi
|
||||
throw new RestException(400, 'bad value for parameter original_file');
|
||||
}
|
||||
|
||||
// Normalize modulepart for project_task
|
||||
if ($modulepart == 'task' || $modulepart == 'project_task') {
|
||||
$modulepart = 'project_task';
|
||||
}
|
||||
|
||||
//--- Finds and returns the document
|
||||
$entity = $conf->entity;
|
||||
|
||||
@@ -314,11 +319,11 @@ class Documents extends DolibarrApi
|
||||
* List documents of an element
|
||||
*
|
||||
* Use element ID or Ref.
|
||||
* Supported modules: thirdparty, user, member, proposal, order, supplier_order, shipment, invoice, supplier_invoice, product, event, expensereport, knowledgemanagement, category, contract
|
||||
* Supported modules: thirdparty, user, member, proposal, order, supplier_order, shipment, invoice, supplier_invoice, product, event, expensereport, knowledgemanagement, category, contract, project, project_task
|
||||
*
|
||||
* @since 7.0.0 Initial implementation
|
||||
*
|
||||
* @param string $modulepart Name of module or area concerned ('thirdparty', 'member', 'proposal', 'order', 'invoice', 'supplier_invoice', 'shipment', 'project', ...)
|
||||
* @param string $modulepart Name of module or area concerned ('thirdparty', 'member', 'proposal', 'order', 'invoice', 'supplier_invoice', 'shipment', 'project', 'project_task', ...)
|
||||
* @param int $id ID of element
|
||||
* @param string $ref Ref of element
|
||||
* @param string $sortfield Sort criteria ('','fullname','relativename','name','date','size')
|
||||
@@ -634,8 +639,28 @@ class Documents extends DolibarrApi
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Project not found');
|
||||
}
|
||||
$upload_dir = $conf->project->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'project');
|
||||
} elseif ($modulepart == 'task' || $modulepart == 'project_task') {
|
||||
$modulepart = 'project_task';
|
||||
require_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php';
|
||||
|
||||
$upload_dir = getMultidirOutput($object) . "/" . get_exdir(0, 0, 0, 1, $object, 'project');
|
||||
if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) {
|
||||
throw new RestException(403);
|
||||
}
|
||||
|
||||
$object = new Task($this->db);
|
||||
$result = $object->fetch($id, $ref);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Task not found');
|
||||
}
|
||||
|
||||
// Fetch the project to build the correct path
|
||||
$project_result = $object->fetchProject();
|
||||
if ($project_result < 0) {
|
||||
throw new RestException(500, 'Error while fetching project for task');
|
||||
}
|
||||
|
||||
$upload_dir = $conf->project->dir_output . "/" . dol_sanitizeFileName($object->project->ref) . "/" . dol_sanitizeFileName($object->ref);
|
||||
} elseif ($modulepart == 'mrp') {
|
||||
$modulepart = 'mrp';
|
||||
require_once DOL_DOCUMENT_ROOT . '/mrp/class/mo.class.php';
|
||||
@@ -1067,7 +1092,7 @@ class Documents extends DolibarrApi
|
||||
*
|
||||
* @since 11.0.0 Initial implementation
|
||||
*
|
||||
* @param string $modulepart Name of module or area concerned by file download ('product', ...)
|
||||
* @param string $modulepart Name of module or area concerned by file download ('product', 'project', 'project_task', ...)
|
||||
* @param string $original_file Relative path with filename, relative to modulepart (for example: PRODUCT-REF-999/IMAGE-999.jpg)
|
||||
* @return array Success code
|
||||
* @phan-return array{success:array{code:int,message:string}}
|
||||
@@ -1092,6 +1117,11 @@ class Documents extends DolibarrApi
|
||||
throw new RestException(400, 'bad value for parameter original_file');
|
||||
}
|
||||
|
||||
// Normalize modulepart for project_task
|
||||
if ($modulepart == 'task') {
|
||||
$modulepart = 'project_task';
|
||||
}
|
||||
|
||||
//--- Finds and returns the document
|
||||
$entity = $conf->entity;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user