diff --git a/workflow/engine/src/BusinessModel/FilesManager.php b/workflow/engine/src/BusinessModel/FilesManager.php new file mode 100644 index 000000000..65229a95b --- /dev/null +++ b/workflow/engine/src/BusinessModel/FilesManager.php @@ -0,0 +1,92 @@ + "templates", + 'type' => "folder", + 'path' => PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP, + 'editable' => false); + $aDirectories[] = array('name' => "public", + 'type' => "folder", + 'path' => PATH_DATA_PUBLIC . $sProcessUID . PATH_SEP, + 'editable' => false); + return $aDirectories; + } catch (Exception $e) { + throw $e; + } + } + + /** + * Return the Process Files Manager Path + * + * @param string $sProcessUID {@min 32} {@max 32} + * @param string $sMainDirectory + * + * return array + * + * @access public + */ + public function getProcessFilesManagerPath($sProcessUID, $sMainDirectory) + { + try { + switch ($sMainDirectory) { + case 'mailTemplates': + $sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP; + $sEditable = false; + break; + case 'public': + $sDirectory = PATH_DATA_PUBLIC . $sProcessUID . PATH_SEP; + $sEditable = true; + break; + default: + die(); + break; + } + \G::verifyPath($sDirectory, true); + $aTheFiles = array(); + $aDirectories = array(); + $aFiles = array(); + $oDirectory = dir($sDirectory); + while ($sObject = $oDirectory->read()) { + if (($sObject !== '.') && ($sObject !== '..')) { + $sPath = $sDirectory . $sObject; + if (is_dir($sPath)) { + $aDirectories[] = array('PATH' => ($sCurrentDirectory != '' ? $sCurrentDirectory . PATH_SEP : '') . $sObject, 'DIRECTORY' => $sObject ); + } else { + $aAux = pathinfo($sPath); + $aAux['extension'] = (isset($aAux['extension'])?$aAux['extension']:''); + $aFiles[] = array('FILE' => $sObject, 'EXT' => $aAux['extension'] ); + } + } + } + foreach ($aFiles as $aFile) { + $aTheFiles[] = array('name' => $aFile['FILE'], + 'type' => "file", + 'path' => $sDirectory.$aFile['FILE'], + 'editable' => $sEditable); + } + return $aTheFiles; + } catch (Exception $e) { + throw $e; + } + } + + + +} + diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Project/FilesManager.php b/workflow/engine/src/Services/Api/ProcessMaker/Project/FilesManager.php new file mode 100644 index 000000000..777878254 --- /dev/null +++ b/workflow/engine/src/Services/Api/ProcessMaker/Project/FilesManager.php @@ -0,0 +1,43 @@ +getProcessFilesManagerPath($prjUid, $path); + } else { + $arrayData = $filesManager->getProcessFilesManager($prjUid); + } + //Response + $response = $arrayData; + } catch (\Exception $e) { + //response + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + return $response; + } + +}