From 1a45e803646cef030d34114526933d85949d23e3 Mon Sep 17 00:00:00 2001 From: Armand Bahi <armand.bahi@veremes.com> Date: Wed, 9 Jan 2019 14:34:00 +0100 Subject: [PATCH] Gestion des fichiers multiples en PUT --- .../web_service/ws/Querys.class.inc | 32 ++++++------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/src/module_vmap/web_service/ws/Querys.class.inc b/src/module_vmap/web_service/ws/Querys.class.inc index 8780bb04..bcaff1db 100644 --- a/src/module_vmap/web_service/ws/Querys.class.inc +++ b/src/module_vmap/web_service/ws/Querys.class.inc @@ -1440,32 +1440,18 @@ class Querys extends Vmap { $this->aValues['my_vitis_id'] = $this->aValues[$bo_id_field]; - // Définit si il a des fichiers a uploader - $bUploadFiles = false; - foreach ($this->aValues as $key => $value) { - if (strrpos($key, '_file')) { - $sName = substr($key, 0, strrpos($key, '_file')); - if (isset($this->aValues[$sName . '_name'])) { - $bUploadFiles = true; - } - } - } - // Fichiers à uploader ? - if ($bUploadFiles) { - // Création du dossier contenneur si il n'existe pas - $sDirPath = $this->createElementFilesFolder($sBusinessObjectId, $this->aValues['my_vitis_id']); - if (!is_dir($sDirPath)) { - $oError = new VitisError(1, "Unable to acces to the business object direrctory :" . $sDirPath); - $aXmlRacineAttribute['status'] = 0; - $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']); - return $sMessage; + if (!empty($_FILES) && !empty($this->aValues['my_vitis_id'])) { + + // Écriture du fichier + $oFileManager = new Files_manager($this->aProperties); + foreach ($_FILES as $sName => $aFile) { + $aUploadReturn = $oFileManager->uploadInWsDataDir('vitis', $sBusinessObjectId, $this->aValues['my_vitis_id'], $sName, 'documents'); + $this->aValues[$sName] = $aUploadReturn['field_value']; } - // Mise en place des fichiers - $this->aValues = $this->extractFiles($this->aValues, $sDirPath); - } - $aReturn = $this->genericPut($bo_schema, $bo_table, $bo_id_field); + $this->genericPut($bo_schema, $bo_table, $bo_id_field); + } // Lance l'évènement webSocket if (!empty($bo_event)) { -- GitLab