Merged in darojas/processmaker (pull request #241)
Se cambia url para download y delete se actualiza BEHAT en FILESMANAGER
This commit is contained in:
@@ -42,55 +42,52 @@ Feature: Files Manager Resources
|
|||||||
And store "prf_uid" in session array as variable "prf_uid<i>"
|
And store "prf_uid" in session array as variable "prf_uid<i>"
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
| test_description | file_name | path | content | http_code | type |
|
| test_description | file_name | path | content | http_code | type | i |
|
||||||
| into public folder | testbehat.txt | public/ | test | 200 | object |
|
| into public folder | testbehat.txt | public/ | test | 200 | object | 0 |
|
||||||
| into maintemplates folder | testbehat.txt | templates/ | test | 200 | object |
|
| into mailtemplates folder | testbehat.txt | templates/ | test | 200 | object | 1 |
|
||||||
| into public subfolder | testbehat.txt | public/test_folder | test | 200 | object |
|
| into public subfolder | testbehat.txt | public/test_folder | test | 200 | object | 2 |
|
||||||
| into public subfolder | testbehat.txt | templates/test_folder | test | 200 | object |
|
| into mailtemplates subfolder | testbehat.txt | templates/test_folder | test | 200 | object | 3 |
|
||||||
|
|
||||||
Scenario Outline: Post files
|
Scenario Outline: Post files
|
||||||
Given PUT this data:
|
Given PUT this data:
|
||||||
"""
|
"""
|
||||||
{
|
{
|
||||||
"prf_filename": "<file_name>",
|
|
||||||
"prf_content": "<content>"
|
"prf_content": "<content>"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
And I request "project/1265557095225ff5c688f46031700471/file-manager?path=<path>"
|
And that I want to update a resource with the key "prf_uid" stored in session array as variable "prf_uid<i>"
|
||||||
|
And I request "project/1265557095225ff5c688f46031700471/file-manager"
|
||||||
Then the response status code should be <http_code>
|
Then the response status code should be <http_code>
|
||||||
And the response charset is "UTF-8"
|
And the response charset is "UTF-8"
|
||||||
And the content type is "application/json"
|
And the content type is "application/json"
|
||||||
And the type is "<type>"
|
And the type is "<type>"
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
| test_description | file_name | path | content | http_code | type |
|
| test_description | content | http_code | type | i |
|
||||||
| put into public folder | testbehat.txt | public/ | put test | 200 | object |
|
| put into public folder | put test | 200 | object | 0 |
|
||||||
| put into maintemplates folder | testbehat.txt | templates/ | put test | 200 | object |
|
| put into mailtemplates folder | put test | 200 | object | 1 |
|
||||||
| put into public subfolder | testbehat.txt | public/test_folder | put test | 200 | object |
|
| put into public subfolder | put test | 200 | object | 2 |
|
||||||
| put into public subfolder | testbehat.txt | templates/test_folder | put test | 200 | object |
|
| put into mailtemplates subfolder | put test | 200 | object | 3 |
|
||||||
|
|
||||||
|
|
||||||
Scenario Outline: Delete file
|
Scenario Outline: Delete file
|
||||||
Given that I want to delete a "<path>"
|
Given that I want to delete a resource with the key "prf_uid" stored in session array as variable "prf_uid<i>"
|
||||||
And I request "project/1265557095225ff5c688f46031700471/file-manager?path=<path>"
|
And I request "project/1265557095225ff5c688f46031700471/file-manager"
|
||||||
And the content type is "application/json"
|
|
||||||
Then the response status code should be 200
|
Then the response status code should be 200
|
||||||
And the response charset is "UTF-8"
|
And the response charset is "UTF-8"
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
| test_description | path |
|
| test_description | i |
|
||||||
| delete public folder | public/testbehat.txt |
|
| delete public folder | 0 |
|
||||||
| delete maintemplates folder | templates/testbehat.txt |
|
| delete mailtemplates folder | 1 |
|
||||||
| delete public subfolder | public/test_folder/testbehat.txt |
|
| delete public subfolder | 2 |
|
||||||
| delete public subfolder | templates/test_folder/testbehat.txt |
|
| delete mailtemplates subfolder | 3 |
|
||||||
|
|
||||||
#Para que funcione este test, debe existir el archivo que se quiere subir
|
#Para que funcione este test, debe existir el archivo que se quiere subir
|
||||||
Scenario: Post files
|
Scenario: Post files
|
||||||
Given POST I want to upload the file "/home/daniel/test.txt" to path "public". Url to create prf_uid "project/1265557095225ff5c688f46031700471/file-manager" and updload "project/1265557095225ff5c688f46031700471/file-manager"
|
Given POST I want to upload the file "/home/daniel/test.txt" to path "templates". Url "project/1265557095225ff5c688f46031700471/file-manager"
|
||||||
|
|
||||||
Scenario: Delete file
|
Scenario: Delete file
|
||||||
Given that I want to delete a "public/test.txt"
|
Given that I want to delete a resource with the key "prf_uid" stored in session array as variable "prf_uid"
|
||||||
And I request "project/1265557095225ff5c688f46031700471/file-manager?path=public/test.txt"
|
And I request "project/1265557095225ff5c688f46031700471/file-manager"
|
||||||
And the content type is "application/json"
|
|
||||||
Then the response status code should be 200
|
Then the response status code should be 200
|
||||||
And the response charset is "UTF-8"
|
And the response charset is "UTF-8"
|
||||||
|
|||||||
@@ -1312,14 +1312,13 @@ class RestContext extends BehatContext
|
|||||||
$this->iRequest($url);
|
$this->iRequest($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
//*********** POST - UPLOAD FILE MANAGER
|
//UPLOAD FILE MANAGER
|
||||||
/**
|
/**
|
||||||
* @Given /^POST I want to upload the file "([^"]*)" to path "([^"]*)". Url to create prf_uid "([^"]*)" and updload "([^"]*)"$/
|
* @Given /^POST I want to upload the file "([^"]*)" to path "([^"]*)". Url "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
public function postIWantToUploadTheFileToPathPublicUrlToCreatePrfUidAndUpdload($prfFile, $prfPath, $postUrl, $url)
|
public function postIWantToUploadTheFileToPathPublicUrl($prfFile, $prfPath, $url)
|
||||||
{
|
{
|
||||||
$baseUrl = $this->getParameter('base_url');
|
$baseUrl = $this->getParameter('base_url');
|
||||||
$postUrl = $baseUrl.$postUrl;
|
|
||||||
$url = $baseUrl.$url;
|
$url = $baseUrl.$url;
|
||||||
$accesstoken = $this->getParameter('access_token');
|
$accesstoken = $this->getParameter('access_token');
|
||||||
$headr = array();
|
$headr = array();
|
||||||
@@ -1327,7 +1326,7 @@ class RestContext extends BehatContext
|
|||||||
$path = rtrim($prfPath, '/') . '/';
|
$path = rtrim($prfPath, '/') . '/';
|
||||||
$sfile = end(explode("/",$prfFile));
|
$sfile = end(explode("/",$prfFile));
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL,$postUrl);
|
curl_setopt($ch, CURLOPT_URL,$url);
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER,$headr);
|
curl_setopt($ch, CURLOPT_HTTPHEADER,$headr);
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, array('prf_filename'=>$sfile, "prf_path" => $path, "prf_content" => null));
|
curl_setopt($ch, CURLOPT_POSTFIELDS, array('prf_filename'=>$sfile, "prf_path" => $path, "prf_content" => null));
|
||||||
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
|
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
|
||||||
@@ -1340,7 +1339,7 @@ class RestContext extends BehatContext
|
|||||||
} else {
|
} else {
|
||||||
var_dump($postResult["error"]);
|
var_dump($postResult["error"]);
|
||||||
}
|
}
|
||||||
$url = $url.$prfUid."/upload";
|
$url = $url.'/'.$prfUid."/upload";
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL,$url);
|
curl_setopt($ch, CURLOPT_URL,$url);
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER,$headr);
|
curl_setopt($ch, CURLOPT_HTTPHEADER,$headr);
|
||||||
@@ -1349,9 +1348,15 @@ class RestContext extends BehatContext
|
|||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
$postResult = curl_exec($ch);
|
$postResult = curl_exec($ch);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
|
//se guarda el prf_uid en una variable
|
||||||
|
$varName = 'prf_uid';
|
||||||
|
$sessionData = new StdClass();
|
||||||
|
$sessionData->$varName = $prfUid;
|
||||||
|
file_put_contents("session.data", json_encode($sessionData));
|
||||||
}
|
}
|
||||||
|
|
||||||
//*********** POST - UPLOAD IMAGE
|
//UPLOAD IMAGE
|
||||||
/**
|
/**
|
||||||
* @Given /^POST I want to upload the image "([^"]*)" to user "([^"]*)". Url "([^"]*)"$/
|
* @Given /^POST I want to upload the image "([^"]*)" to user "([^"]*)". Url "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
@@ -1378,7 +1383,7 @@ class RestContext extends BehatContext
|
|||||||
. curl_error($ch));
|
. curl_error($ch));
|
||||||
}
|
}
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
echo $postResult;
|
echo $postResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class FilesManager
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$sMainDirectory = current(explode("/", $path));
|
$sMainDirectory = current(explode("/", $path));
|
||||||
|
$path = str_replace('/', '', $path);
|
||||||
if (strstr($path,'/')) {
|
if (strstr($path,'/')) {
|
||||||
$sSubDirectory = substr($path, strpos($path, "/")+1). PATH_SEP ;
|
$sSubDirectory = substr($path, strpos($path, "/")+1). PATH_SEP ;
|
||||||
} else {
|
} else {
|
||||||
@@ -86,12 +87,12 @@ class FilesManager
|
|||||||
$fileUid = $arrayFileUid["PRF_UID"];
|
$fileUid = $arrayFileUid["PRF_UID"];
|
||||||
if ($fileUid) {
|
if ($fileUid) {
|
||||||
$oProcessFiles = \ProcessFilesPeer::retrieveByPK($fileUid);
|
$oProcessFiles = \ProcessFilesPeer::retrieveByPK($fileUid);
|
||||||
$editable = $oProcessFiles->getPrfEditable();
|
$editable = $oProcessFiles->getPrfEditable();
|
||||||
if ($editable == 1){
|
if ($editable == 1){
|
||||||
$editable = 'true';
|
$editable = 'true';
|
||||||
} else {
|
} else {
|
||||||
$editable = 'false';
|
$editable = 'false';
|
||||||
}
|
}
|
||||||
$aTheFiles[] = array( 'prf_uid' => $oProcessFiles->getPrfUid(),
|
$aTheFiles[] = array( 'prf_uid' => $oProcessFiles->getPrfUid(),
|
||||||
'prf_filename' => $aFile['FILE'],
|
'prf_filename' => $aFile['FILE'],
|
||||||
'usr_uid' => $oProcessFiles->getUsrUid(),
|
'usr_uid' => $oProcessFiles->getUsrUid(),
|
||||||
@@ -104,7 +105,14 @@ class FilesManager
|
|||||||
'prf_content' => $fcontent);
|
'prf_content' => $fcontent);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$aTheFiles[] = array('prf_uid' => $oProcessFiles->getPrfUid(),
|
$extention = end(explode(".", $aFile['FILE']));
|
||||||
|
if ($extention == 'docx' || $extention == 'doc' || $extention == 'html' || $extention == 'php' || $extention == 'jsp' ||
|
||||||
|
$extention == 'xlsx' || $extention == 'xls' || $extention == 'js' || $extention == 'css' || $extention == 'txt') {
|
||||||
|
$editable = 'true';
|
||||||
|
} else {
|
||||||
|
$editable = 'false';
|
||||||
|
}
|
||||||
|
$aTheFiles[] = array('prf_uid' => '',
|
||||||
'prf_filename' => $aFile['FILE'],
|
'prf_filename' => $aFile['FILE'],
|
||||||
'usr_uid' => '',
|
'usr_uid' => '',
|
||||||
'prf_update_usr_uid' => '',
|
'prf_update_usr_uid' => '',
|
||||||
@@ -237,12 +245,15 @@ class FilesManager
|
|||||||
if ($file == $_FILES['prf_file']['name']) {
|
if ($file == $_FILES['prf_file']['name']) {
|
||||||
if ($_FILES['prf_file']['error'] != 1) {
|
if ($_FILES['prf_file']['error'] != 1) {
|
||||||
if ($_FILES['prf_file']['tmp_name'] != '') {
|
if ($_FILES['prf_file']['tmp_name'] != '') {
|
||||||
\G::uploadFile($_FILES['prf_file']['tmp_name'],$path , $_FILES['prf_file']['name']);
|
\G::uploadFile($_FILES['prf_file']['tmp_name'], $path, $_FILES['prf_file']['name']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new \Exception(\G::LoadTranslation('ID_PMTABLE_UPLOADING_FILE_PROBLEM'));
|
throw new \Exception(\G::LoadTranslation('ID_PMTABLE_UPLOADING_FILE_PROBLEM'));
|
||||||
}
|
}
|
||||||
|
$oProcessFile = array('prf_uid' => $prfUid);
|
||||||
|
var_dump($oProcessFile);
|
||||||
|
return $oProcessFile;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
@@ -274,44 +285,41 @@ class FilesManager
|
|||||||
* Return the Process Files Manager
|
* Return the Process Files Manager
|
||||||
*
|
*
|
||||||
* @param string $sProcessUID {@min 32} {@max 32}
|
* @param string $sProcessUID {@min 32} {@max 32}
|
||||||
* @param string $path
|
|
||||||
* @param string $userUID {@min 32} {@max 32}
|
* @param string $userUID {@min 32} {@max 32}
|
||||||
* @param array $aData
|
* @param array $aData
|
||||||
|
* @param string $prfUid {@min 32} {@max 32}
|
||||||
*
|
*
|
||||||
* return array
|
* return array
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public function updateProcessFilesManager($sProcessUID, $userUID, $aData, $path)
|
public function updateProcessFilesManager($sProcessUID, $userUID, $aData, $prfUid)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$path = rtrim($path, '/') . '/';
|
$path = '';
|
||||||
$sMainDirectory = current(explode("/", $path));
|
$criteria = new \Criteria("workflow");
|
||||||
if ($sMainDirectory != 'public' && $sMainDirectory != 'templates') {
|
$criteria->addSelectColumn(\ProcessFilesPeer::PRF_PATH);
|
||||||
throw (new \Exception( 'invalid value specified for `prf_path`. Expecting `templates/` or `public/`'));
|
$criteria->add(\ProcessFilesPeer::PRF_UID, $prfUid, \Criteria::EQUAL);
|
||||||
|
$rsCriteria = \ProcessFilesPeer::doSelectRS($criteria);
|
||||||
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||||
|
$rsCriteria->next();
|
||||||
|
while ($aRow = $rsCriteria->getRow()) {
|
||||||
|
$path = $aRow['PRF_PATH'];
|
||||||
|
$rsCriteria->next();
|
||||||
}
|
}
|
||||||
if (strstr($path,'/')) {
|
if ($path == ''){
|
||||||
$sSubDirectory = substr($path, strpos($path, "/")+1) ;
|
throw new \Exception('invalid value specified for `prf_uid`.');
|
||||||
|
}
|
||||||
|
$sFile = end(explode("/",$path));
|
||||||
|
$sPath = str_replace($sFile,'',$path);
|
||||||
|
$sSubDirectory = str_replace('/','',str_replace($sProcessUID,'',substr($sPath,(strpos($sPath, $sProcessUID)))));
|
||||||
|
$sMainDirectory = str_replace(substr($sPath, strpos($sPath, $sProcessUID)),'', $sPath);
|
||||||
|
if ($sMainDirectory == PATH_DATA_MAILTEMPLATES){
|
||||||
|
$sMainDirectory = 'mailTemplates';
|
||||||
} else {
|
} else {
|
||||||
$sSubDirectory = '';
|
$sMainDirectory = 'public';
|
||||||
}
|
}
|
||||||
switch ($sMainDirectory) {
|
$extention = end(explode(".", $sFile));
|
||||||
case 'templates':
|
|
||||||
$sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP . $sSubDirectory . $aData['prf_filename'];
|
|
||||||
$sEditable = false;
|
|
||||||
break;
|
|
||||||
case 'public':
|
|
||||||
$sDirectory = PATH_DATA_PUBLIC . $sProcessUID . PATH_SEP . $sSubDirectory . $aData['prf_filename'];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP . $aData['prf_filename'];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$arrayFileUid = $this->getFileManagerUid($sDirectory);
|
|
||||||
if (!$arrayFileUid) {
|
|
||||||
throw (new \Exception( 'invalid value specified for `path`.'));
|
|
||||||
}
|
|
||||||
$extention = end(explode(".", $aData['prf_filename']));
|
|
||||||
if ($extention == 'docx' || $extention == 'doc' || $extention == 'html' || $extention == 'php' || $extention == 'jsp' ||
|
if ($extention == 'docx' || $extention == 'doc' || $extention == 'html' || $extention == 'php' || $extention == 'jsp' ||
|
||||||
$extention == 'xlsx' || $extention == 'xls' || $extention == 'js' || $extention == 'css' || $extention == 'txt') {
|
$extention == 'xlsx' || $extention == 'xls' || $extention == 'js' || $extention == 'css' || $extention == 'txt') {
|
||||||
$sEditable = true;
|
$sEditable = true;
|
||||||
@@ -321,20 +329,20 @@ class FilesManager
|
|||||||
if ($sEditable == false) {
|
if ($sEditable == false) {
|
||||||
throw (new \Exception( 'Can`t edit. Make sure your file has an editable extension.'));
|
throw (new \Exception( 'Can`t edit. Make sure your file has an editable extension.'));
|
||||||
}
|
}
|
||||||
$fileUid = $arrayFileUid["PRF_UID"];
|
$oProcessFiles = \ProcessFilesPeer::retrieveByPK($prfUid);
|
||||||
$oProcessFiles = \ProcessFilesPeer::retrieveByPK($fileUid);
|
|
||||||
$sDate = date('Y-m-d H:i:s');
|
$sDate = date('Y-m-d H:i:s');
|
||||||
$oProcessFiles->setPrfUpdateUsrUid($userUID);
|
$oProcessFiles->setPrfUpdateUsrUid($userUID);
|
||||||
$oProcessFiles->setPrfUpdateDate($sDate);
|
$oProcessFiles->setPrfUpdateDate($sDate);
|
||||||
$oProcessFiles->save();
|
$oProcessFiles->save();
|
||||||
$fp = fopen($sDirectory, 'w');
|
$fp = fopen($path, 'w');
|
||||||
$content = $aData['prf_content'];
|
$content = $aData['prf_content'];
|
||||||
fwrite($fp, $content);
|
fwrite($fp, $content);
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
$oProcessFile = array('prf_uid' => $oProcessFiles->getPrfUid(),
|
$oProcessFile = array('prf_uid' => $oProcessFiles->getPrfUid(),
|
||||||
|
'prf_filename' => $sFile,
|
||||||
'usr_uid' => $oProcessFiles->getUsrUid(),
|
'usr_uid' => $oProcessFiles->getUsrUid(),
|
||||||
'prf_update_usr_uid' => $oProcessFiles->getPrfUpdateUsrUid(),
|
'prf_update_usr_uid' => $oProcessFiles->getPrfUpdateUsrUid(),
|
||||||
'prf_path' => $sMainDirectory. PATH_SEP . $sSubDirectory,
|
'prf_path' => $sMainDirectory.PATH_SEP.$sSubDirectory,
|
||||||
'prf_type' => $oProcessFiles->getPrfType(),
|
'prf_type' => $oProcessFiles->getPrfType(),
|
||||||
'prf_editable' => $sEditable,
|
'prf_editable' => $sEditable,
|
||||||
'prf_create_date' => $oProcessFiles->getPrfCreateDate(),
|
'prf_create_date' => $oProcessFiles->getPrfCreateDate(),
|
||||||
@@ -349,53 +357,41 @@ class FilesManager
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param string $sProcessUID {@min 32} {@max 32}
|
* @param string $sProcessUID {@min 32} {@max 32}
|
||||||
* @param string $path
|
* @param string $prfUid {@min 32} {@max 32}
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public function deleteProcessFilesManager($sProcessUID, $path)
|
public function deleteProcessFilesManager($sProcessUID, $prfUid)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$sMainDirectory = current(explode("/", $path));
|
$path = '';
|
||||||
if ($sMainDirectory != 'public' && $sMainDirectory != 'templates') {
|
$criteria = new \Criteria("workflow");
|
||||||
throw (new \Exception( 'invalid value specified for `prf_path`. Expecting `templates/` or `public/`'));
|
$criteria->addSelectColumn(\ProcessFilesPeer::PRF_PATH);
|
||||||
|
$criteria->add(\ProcessFilesPeer::PRF_UID, $prfUid, \Criteria::EQUAL);
|
||||||
|
$rsCriteria = \ProcessFilesPeer::doSelectRS($criteria);
|
||||||
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||||
|
$rsCriteria->next();
|
||||||
|
while ($aRow = $rsCriteria->getRow()) {
|
||||||
|
$path = $aRow['PRF_PATH'];
|
||||||
|
$rsCriteria->next();
|
||||||
}
|
}
|
||||||
if ($sMainDirectory == 'templates') {
|
if ($path == ''){
|
||||||
|
throw new \Exception('invalid value specified for `prf_uid`.');
|
||||||
|
}
|
||||||
|
$sFile = end(explode("/",$path));
|
||||||
|
$sPath = str_replace($sFile,'',$path);
|
||||||
|
$sSubDirectory = str_replace('/','',str_replace($sProcessUID,'',substr($sPath,(strpos($sPath, $sProcessUID)))));
|
||||||
|
$sMainDirectory = str_replace(substr($sPath, strpos($sPath, $sProcessUID)),'', $sPath);
|
||||||
|
if ($sMainDirectory == PATH_DATA_MAILTEMPLATES){
|
||||||
$sMainDirectory = 'mailTemplates';
|
$sMainDirectory = 'mailTemplates';
|
||||||
}
|
|
||||||
$sfile = end(explode("/",$path));
|
|
||||||
$sSubDirectorytemp = substr($path, strpos($path, "/")+1);
|
|
||||||
if (strstr($sSubDirectorytemp,'/')) {
|
|
||||||
$sSubDirectory = str_replace('/'.$sfile,"",$sSubDirectorytemp);
|
|
||||||
$sSubDirectoryCheck = str_replace($sfile,"",$sSubDirectorytemp);
|
|
||||||
} else {
|
} else {
|
||||||
$sSubDirectory = '';
|
$sMainDirectory = 'public';
|
||||||
$sSubDirectoryCheck = '';
|
|
||||||
}
|
|
||||||
switch ($sMainDirectory) {
|
|
||||||
case 'mailTemplates':
|
|
||||||
$sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP . $sSubDirectoryCheck . $sfile;
|
|
||||||
$sEditable = false;
|
|
||||||
break;
|
|
||||||
case 'public':
|
|
||||||
$sDirectory = PATH_DATA_PUBLIC . $sProcessUID . PATH_SEP . $sSubDirectoryCheck . $sfile;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP . $sfile;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$arrayTaskUid = $this->getFileManagerUid($sDirectory);
|
|
||||||
if (!$arrayTaskUid){
|
|
||||||
throw (new \Exception( 'invalid value specified for `path`.'));
|
|
||||||
}
|
}
|
||||||
$oProcessMap = new \processMap(new \DBConnection());
|
$oProcessMap = new \processMap(new \DBConnection());
|
||||||
$oProcessMap->deleteFile($sProcessUID,
|
$oProcessMap->deleteFile($sProcessUID, $sMainDirectory, $sSubDirectory, $sFile);
|
||||||
$sMainDirectory,
|
|
||||||
$sSubDirectory,
|
|
||||||
$sfile);
|
|
||||||
$c = new \Criteria("workflow");
|
$c = new \Criteria("workflow");
|
||||||
$c->add(\ProcessFilesPeer::PRF_PATH, $sDirectory, \Criteria::EQUAL);
|
$c->add(\ProcessFilesPeer::PRF_UID, $prfUid, \Criteria::EQUAL);
|
||||||
$rs = \ProcessFilesPeer::doDelete($c);
|
$rs = \ProcessFilesPeer::doDelete($c);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
@@ -432,7 +428,7 @@ class FilesManager
|
|||||||
$sSubDirectory = str_replace('/','',str_replace($sProcessUID,'',substr($sPath,(strpos($sPath, $sProcessUID)))));
|
$sSubDirectory = str_replace('/','',str_replace($sProcessUID,'',substr($sPath,(strpos($sPath, $sProcessUID)))));
|
||||||
$sMainDirectory = str_replace(substr($sPath, strpos($sPath, $sProcessUID)),'', $sPath);
|
$sMainDirectory = str_replace(substr($sPath, strpos($sPath, $sProcessUID)),'', $sPath);
|
||||||
if ($sMainDirectory == PATH_DATA_MAILTEMPLATES){
|
if ($sMainDirectory == PATH_DATA_MAILTEMPLATES){
|
||||||
$sMainDirectory = 'mainTemplates';
|
$sMainDirectory = 'mailTemplates';
|
||||||
} else {
|
} else {
|
||||||
$sMainDirectory = 'public';
|
$sMainDirectory = 'public';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,9 @@ class FilesManager extends Api
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$filesManager = new \BusinessModel\FilesManager();
|
$filesManager = new \BusinessModel\FilesManager();
|
||||||
$filesManager->uploadProcessFilesManager($prjUid, $prfUid);
|
$sData = $filesManager->uploadProcessFilesManager($prjUid, $prfUid);
|
||||||
|
//Response
|
||||||
|
$response = $sData;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
//response
|
//response
|
||||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||||
@@ -76,18 +78,18 @@ class FilesManager extends Api
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $prjUid {@min 32} {@max 32}
|
* @param string $prjUid {@min 32} {@max 32}
|
||||||
* @param ProcessFilesManagerStructurePut $request_data
|
* @param ProcessFilesManagerStructure $request_data
|
||||||
* @param string $path
|
* @param string $prfUid {@min 32} {@max 32}
|
||||||
*
|
*
|
||||||
* @url PUT /:prjUid/file-manager
|
* @url PUT /:prjUid/file-manager/:prfUid
|
||||||
*/
|
*/
|
||||||
public function doPutProcessFilesManager($prjUid, ProcessFilesManagerStructurePut $request_data, $path)
|
public function doPutProcessFilesManager($prjUid, ProcessFilesManagerStructure $request_data, $prfUid)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$userUid = $this->getUserId();
|
$userUid = $this->getUserId();
|
||||||
$request_data = (array)($request_data);
|
$request_data = (array)($request_data);
|
||||||
$filesManager = new \BusinessModel\FilesManager();
|
$filesManager = new \BusinessModel\FilesManager();
|
||||||
$arrayData = $filesManager->updateProcessFilesManager($prjUid, $userUid, $request_data, $path);
|
$arrayData = $filesManager->updateProcessFilesManager($prjUid, $userUid, $request_data, $prfUid);
|
||||||
//Response
|
//Response
|
||||||
$response = $arrayData;
|
$response = $arrayData;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -99,15 +101,15 @@ class FilesManager extends Api
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $prjUid {@min 32} {@max 32}
|
* @param string $prjUid {@min 32} {@max 32}
|
||||||
* @param string $path
|
* @param string $prfUid {@min 32} {@max 32}
|
||||||
*
|
*
|
||||||
* @url DELETE /:prjUid/file-manager
|
* @url DELETE /:prjUid/file-manager/:prfUid
|
||||||
*/
|
*/
|
||||||
public function doDeleteProcessFilesManager($prjUid, $path)
|
public function doDeleteProcessFilesManager($prjUid, $prfUid)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$filesManager = new \BusinessModel\FilesManager();
|
$filesManager = new \BusinessModel\FilesManager();
|
||||||
$filesManager->deleteProcessFilesManager($prjUid, $path);
|
$filesManager->deleteProcessFilesManager($prjUid, $prfUid);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
//response
|
//response
|
||||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||||
@@ -150,17 +152,3 @@ class ProcessFilesManagerStructure
|
|||||||
public $prf_content;
|
public $prf_content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class ProcessFilesManagerStructurePut
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var string {@from body}
|
|
||||||
*/
|
|
||||||
public $prf_filename;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string {@from body}
|
|
||||||
*/
|
|
||||||
public $prf_content;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user