Merged in darojas/processmaker (pull request #235)
Se cambia url para download y se mejora BEHAT en FILESMANAGER.
This commit is contained in:
@@ -1329,7 +1329,7 @@ class RestContext extends BehatContext
|
|||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL,$postUrl);
|
curl_setopt($ch, CURLOPT_URL,$postUrl);
|
||||||
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');
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
$postResult = curl_exec($ch);
|
$postResult = curl_exec($ch);
|
||||||
|
|||||||
@@ -92,7 +92,8 @@ class FilesManager
|
|||||||
} else {
|
} else {
|
||||||
$editable = 'false';
|
$editable = 'false';
|
||||||
}
|
}
|
||||||
$aTheFiles[] = array( 'prf_filename' => $aFile['FILE'],
|
$aTheFiles[] = array( 'prf_uid' => $oProcessFiles->getPrfUid(),
|
||||||
|
'prf_filename' => $aFile['FILE'],
|
||||||
'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,
|
||||||
@@ -103,7 +104,8 @@ class FilesManager
|
|||||||
'prf_content' => $fcontent);
|
'prf_content' => $fcontent);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$aTheFiles[] = array('prf_filename' => $aFile['FILE'],
|
$aTheFiles[] = array('prf_uid' => $oProcessFiles->getPrfUid(),
|
||||||
|
'prf_filename' => $aFile['FILE'],
|
||||||
'usr_uid' => '',
|
'usr_uid' => '',
|
||||||
'prf_update_usr_uid' => '',
|
'prf_update_usr_uid' => '',
|
||||||
'prf_path' => $sMainDirectory. PATH_SEP .$sSubDirectory,
|
'prf_path' => $sMainDirectory. PATH_SEP .$sSubDirectory,
|
||||||
@@ -403,44 +405,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 downloadProcessFilesManager($sProcessUID, $path)
|
public function downloadProcessFilesManager($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 == ''){
|
||||||
$sMainDirectory = 'mailTemplates';
|
throw new \Exception('invalid value specified for `prf_uid`.');
|
||||||
}
|
}
|
||||||
$sfile = end(explode("/",$path));
|
$sFile = end(explode("/",$path));
|
||||||
$sSubDirectorytemp = substr($path, strpos($path, "/")+1);
|
$sPath = str_replace($sFile,'',$path);
|
||||||
if (strstr($sSubDirectorytemp,'/')) {
|
$sSubDirectory = str_replace('/','',str_replace($sProcessUID,'',substr($sPath,(strpos($sPath, $sProcessUID)))));
|
||||||
$sSubDirectory = str_replace('/'.$sfile,"",$sSubDirectorytemp);
|
$sMainDirectory = str_replace(substr($sPath, strpos($sPath, $sProcessUID)),'', $sPath);
|
||||||
$sSubDirectoryCheck = str_replace($sfile,"",$sSubDirectorytemp);
|
if ($sMainDirectory == PATH_DATA_MAILTEMPLATES){
|
||||||
|
$sMainDirectory = 'mainTemplates';
|
||||||
} else {
|
} else {
|
||||||
$sSubDirectory = '';
|
$sMainDirectory = 'public';
|
||||||
$sSubDirectoryCheck = '';
|
|
||||||
}
|
}
|
||||||
switch ($sMainDirectory) {
|
if (file_exists($path)) {
|
||||||
case 'mailTemplates':
|
|
||||||
$sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP . $sSubDirectoryCheck . $sfile;
|
|
||||||
break;
|
|
||||||
case 'public':
|
|
||||||
$sDirectory = PATH_DATA_PUBLIC . $sProcessUID . PATH_SEP . $sSubDirectoryCheck . $sfile;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP . $sfile;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (file_exists(PATH_SEP.$sDirectory)) {
|
|
||||||
$oProcessMap = new \processMap(new \DBConnection());
|
$oProcessMap = new \processMap(new \DBConnection());
|
||||||
$oProcessMap->downloadFile($sProcessUID,$sMainDirectory,$sSubDirectory,$sfile);
|
$oProcessMap->downloadFile($sProcessUID,$sMainDirectory,$sSubDirectory,$sFile);
|
||||||
|
die();
|
||||||
} else {
|
} else {
|
||||||
throw (new \Exception( 'invalid value specified for `path`.'));
|
throw (new \Exception( 'invalid value specified for `path`.'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,15 +116,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 GET /:prjUid/file-manager/download
|
* @url GET /:prjUid/file-manager/:prfUid/download
|
||||||
*/
|
*/
|
||||||
public function doGetProcessFilesManagerDownload($prjUid, $path)
|
public function doGetProcessFilesManagerDownload($prjUid, $prfUid)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$filesManager = new \BusinessModel\FilesManager();
|
$filesManager = new \BusinessModel\FilesManager();
|
||||||
$filesManager->downloadProcessFilesManager($prjUid, $path);
|
$filesManager->downloadProcessFilesManager($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());
|
||||||
|
|||||||
Reference in New Issue
Block a user