diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 48d6bf5b903..1b98ad5f2ec 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -56,7 +56,7 @@ class Documents extends DolibarrApi * Note that, this API is similar to using the wrapper link "documents.php" to download a file (used for * internal HTML links of documents into application), but with no need to have a session cookie (the token is used instead). * - * @param string $module_part Name of module or area concerned by file download ('facture', ...) + * @param string $modulepart Name of module or area concerned by file download ('facture', ...) * @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf) * @return array List of documents * @@ -67,11 +67,11 @@ class Documents extends DolibarrApi * * @url GET /download */ - public function index($module_part, $original_file = '') + public function index($modulepart, $original_file = '') { global $conf, $langs; - if (empty($module_part)) { + if (empty($modulepart)) { throw new RestException(400, 'bad value for parameter modulepart'); } if (empty($original_file)) { @@ -81,7 +81,7 @@ class Documents extends DolibarrApi //--- Finds and returns the document $entity=$conf->entity; - $check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', 'read'); + $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'read'); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $original_file = $check_access['original_file']; @@ -98,6 +98,7 @@ class Documents extends DolibarrApi if (! file_exists($original_file_osencoded)) { + dol_syslog("Try to download not found file ".$original_file_osencoded, LOG_WARNING); throw new RestException(404, 'File not found'); } @@ -111,7 +112,7 @@ class Documents extends DolibarrApi * * Test sample 1: { "module_part": "invoice", "original_file": "FA1701-001/FA1701-001.pdf", "doctemplate": "crabe", "langcode": "fr_FR" }. * - * @param string $module_part Name of module or area concerned by file download ('invoice', 'order', ...). + * @param string $modulepart Name of module or area concerned by file download ('invoice', 'order', ...). * @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf). * @param string $doctemplate Set here the doc template to use for document generation (If not set, use the default template). * @param string $langcode Language code like 'en_US', 'fr_FR', 'es_ES', ... (If not set, use the default language). @@ -126,11 +127,11 @@ class Documents extends DolibarrApi * * @url PUT /builddoc */ - public function builddoc($module_part, $original_file = '', $doctemplate = '', $langcode = '') + public function builddoc($modulepart, $original_file = '', $doctemplate = '', $langcode = '') { global $conf, $langs; - if (empty($module_part)) { + if (empty($modulepart)) { throw new RestException(400, 'bad value for parameter modulepart'); } if (empty($original_file)) { @@ -147,7 +148,7 @@ class Documents extends DolibarrApi //--- Finds and returns the document $entity=$conf->entity; - $check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', 'write'); + $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'write'); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $original_file = $check_access['original_file']; @@ -166,7 +167,7 @@ class Documents extends DolibarrApi $templateused=''; - if ($module_part == 'facture' || $module_part == 'invoice') + if ($modulepart == 'facture' || $modulepart == 'invoice') { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $this->invoice = new Facture($this->db); @@ -181,7 +182,7 @@ class Documents extends DolibarrApi throw new RestException(500, 'Error generating document'); } } - elseif ($module_part == 'commande' || $module_part == 'order') + elseif ($modulepart == 'commande' || $modulepart == 'order') { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $this->order = new Commande($this->db); @@ -195,7 +196,7 @@ class Documents extends DolibarrApi throw new RestException(500, 'Error generating document'); } } - elseif ($module_part == 'propal' || $module_part == 'proposal') + elseif ($modulepart == 'propal' || $modulepart == 'proposal') { require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $this->propal = new Propal($this->db);