From a587f71a2f504eef3b60cee992045849e75736ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Carretero?=
 <frederic.carretero@veremes.com>
Date: Wed, 21 Nov 2018 11:19:48 +0100
Subject: [PATCH] =?UTF-8?q?V=C3=A9rification=20du=20fichier=20de=20widget?=
 =?UTF-8?q?=20sur=20S3=20(checkWidgetFile)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 web_service/ws/Workspaces.class.inc | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/web_service/ws/Workspaces.class.inc b/web_service/ws/Workspaces.class.inc
index d4670d92..a9f9942d 100755
--- a/web_service/ws/Workspaces.class.inc
+++ b/web_service/ws/Workspaces.class.inc
@@ -169,13 +169,11 @@ class Workspaces extends GTF {
             // Formatage de la colonne "form_type".
             if ($aReturn['sStatus'] == 1) {
                 foreach ($this->aObjects as &$oWorkspace) {
-                    $sFile = $this->aProperties['workspace_dir'] . "/" . $oWorkspace->aFields['workspace_id'] . '/form/Subform.json';
-                    if (!file_exists($sFile)) {
+                    if (!fileExistsInWsDataDir('gtf', 'workspace', $oWorkspace->aFields['workspace_id'], 'form', 'Subform.json'))
                         $oWorkspace->aFields['form_type'] = '';
-                    } else {
-                        if ($oWorkspace->aFields['form_type'] != "custom") {
+                    else {
+                        if ($oWorkspace->aFields['form_type'] != "custom")
                             $oWorkspace->aFields['form_type'] = "default";
-                        }
                     }
                 }
                 $aXmlRacineAttribute['status'] = 1;
@@ -1199,11 +1197,10 @@ class Workspaces extends GTF {
         $oWorkspace = new Workspace($this->aPath, $this->aValues, $this->aProperties, $this->oConnection);
         $oWorkspace->GET();
         $this->aFields['workspace_key'] = $oWorkspace->aFields["key"];
-        $sWidgetFilePath = $this->aProperties["vas_home"] . '/ws_data/gtf/widget/' . $this->aFields['workspace_key'] . '.html';
-        // Le fichier existe ?
-        if (!file_exists($sWidgetFilePath)) {
-            $aReturn = array('status' => 0, 'error_code' => 13, 'message' => 'The file ' . $this->aFields['workspace_key'] . '.html' . 'does not exist.');
-            WriteToErrorLog("The file '$sWidgetFilePath' does not exist.");
+        $sWidgetFile = $this->aFields['workspace_key'] . '.html';
+        if (!fileExistsInWsDataDir('gtf', 'widget', '', '', $sWidgetFile)) {
+            $aReturn = array('status' => 0, 'error_code' => 13, 'message' => 'The file ' . $sWidgetFile . ' does not exist.');
+            WriteToErrorLog("The file '$sWidgetFile' does not exist.");
         }
         return $aReturn;
     }
-- 
GitLab