From a804999d92e3a1145d831ddab85a46164546eef1 Mon Sep 17 00:00:00 2001 From: Sarah Mainguet Date: Mon, 1 May 2023 22:11:35 +0200 Subject: [PATCH] Can now add documents to events in agenda --- htdocs/api/class/api_documents.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 78442622c7e..bec16dfc8b7 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -666,6 +666,10 @@ class Documents extends DolibarrApi $modulepart = 'propale'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $object = new Propal($this->db); + } elseif ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event') { + $modulepart = 'agenda'; + require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; + $object = new ActionComm($this->db); } else { // TODO Implement additional moduleparts throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); @@ -742,6 +746,11 @@ class Documents extends DolibarrApi throw new RestException(500, "File with name '".$original_file."' already exists."); } + // in case temporary directory doesn't exist + if (!dol_is_dir(dirname(DOL_DATA_ROOT . '/admin/temp/'))) { + dol_mkdir(DOL_DATA_ROOT . '/admin/temp/'); + } + $fhandle = @fopen($destfiletmp, 'w'); if ($fhandle) { $nbofbyteswrote = fwrite($fhandle, $newfilecontent);