From dca48e4fb67654ac7923963360ccf47c92c71ef8 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 11 Dec 2020 10:21:10 +0100 Subject: [PATCH] NEW : add ECM files table info into API document entry GET --- htdocs/api/class/api_documents.class.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 92404b81a35..da9545aa248 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -497,6 +497,17 @@ class Documents extends DolibarrApi $filearray = dol_dir_list($upload_dir, $type, $recursive, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); if (empty($filearray)) { throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(!empty($object->ref) ? ' or Ref '.$object->ref : '').' does not return any document.'); + } else { + if (($object->id) > 0 && !empty($modulepart)) { + require_once DOL_DOCUMENT_ROOT . '/ecm/class/ecmfiles.class.php'; + $ecmfile = new EcmFiles($this->db); + $result = $ecmfile->fetchAll('', '', 0, 0, array('t.src_object_type' => $modulepart, 't.src_object_id' => $object->id)); + if ($result < 0) { + throw new RestException(503, 'Error when retrieve ecm list : ' . $this->db->lasterror()); + } elseif (is_array($ecmfile->lines) && count($ecmfile->lines) > 0) { + $filearray['ecmfiles_infos'] = $ecmfile->lines; + } + } } return $filearray;