Merged in darojas/processmaker (pull request #183)

Fix notice CASE SCHEDULER.
This commit is contained in:
erik ao
2014-02-12 16:59:24 -04:00
3 changed files with 60 additions and 63 deletions

View File

@@ -463,11 +463,14 @@ class CaseScheduler
if ($sStartDay == '') {
$sStartDay = date('Y-m-d');
} else {
$aaStartDay = explode( "|", $aData['SCH_START_DAY'] );
$aaStartDay[0] = $aaStartDay[0];
$aaStartDay[1] = $aaStartDay[1];
$aaStartDay[2]= ($aaStartDay[2] == 7 ? 1 : $aaStartDay[2]);
$sStartDay = $aaStartDay[0].'|'.$aaStartDay[1].'|'.$aaStartDay[2];
$size = strlen($aData['SCH_START_DAY']);
if ( $size > 4 ) {
$aaStartDay = explode( "|", $aData['SCH_START_DAY'] );
$aaStartDay[0] = $aaStartDay[0];
$aaStartDay[1] = $aaStartDay[1];
$aaStartDay[2]= ($aaStartDay[2] == 7 ? 1 : $aaStartDay[2]);
$sStartDay = $aaStartDay[0].'|'.$aaStartDay[1].'|'.$aaStartDay[2];
}
}
$dCurrentDay = date("d");
$dCurrentMonth = date("m");
@@ -750,11 +753,14 @@ class CaseScheduler
if ($sStartDay == '') {
$sStartDay = date('Y-m-d');
} else {
$aaStartDay = explode( "|", $aData['SCH_START_DAY'] );
$aaStartDay[0] = $aaStartDay[0];
$aaStartDay[1] = $aaStartDay[1];
$aaStartDay[2]= ($aaStartDay[2] == 7 ? 1 : $aaStartDay[2]);
$sStartDay = $aaStartDay[0].'|'.$aaStartDay[1].'|'.$aaStartDay[2];
$size = strlen($aData['SCH_START_DAY']);
if ( $size > 4 ) {
$aaStartDay = explode( "|", $aData['SCH_START_DAY'] );
$aaStartDay[0] = $aaStartDay[0];
$aaStartDay[1] = $aaStartDay[1];
$aaStartDay[2]= ($aaStartDay[2] == 7 ? 1 : $aaStartDay[2]);
$sStartDay = $aaStartDay[0].'|'.$aaStartDay[1].'|'.$aaStartDay[2];
}
}
$dCurrentDay = date("d");
$dCurrentMonth = date("m");

View File

@@ -35,20 +35,25 @@ class FilesManager
* Return the Process Files Manager Path
*
* @param string $sProcessUID {@min 32} {@max 32}
* @param string $sMainDirectory
* @param string $path
*
* return array
*
* @access public
*/
public function getProcessFilesManagerPath($sProcessUID, $sMainDirectory)
public function getProcessFilesManagerPath($sProcessUID, $path)
{
try {
$sMainDirectory = current(explode("/", $path));
if ($path)
$sSubDirectory = substr($path, strpos($path, "/"));
switch ($sMainDirectory) {
case 'mailTemplates':
case 'templates':
//$sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP . $sSubDirectory;
$sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP;
break;
case 'public':
case 'folder':
//$sDirectory = PATH_DATA_PUBLIC . $sProcessUID . PATH_SEP . $sSubDirectory;
$sDirectory = PATH_DATA_PUBLIC . $sProcessUID . PATH_SEP;
break;
default:
@@ -59,12 +64,16 @@ class FilesManager
$aTheFiles = array();
$aDirectories = array();
$aFiles = array();
$sCurrentDirectory = $sSubDirectory;
$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 );
$aTheFiles[] = array('name' => $sObject,
'type' => "folder",
//'path' => $sDirectory);
'path' => ($sCurrentDirectory != '' ? $sCurrentDirectory . PATH_SEP : '') . $sObject);
} else {
$aAux = pathinfo($sPath);
$aAux['extension'] = (isset($aAux['extension'])?$aAux['extension']:'');
@@ -82,7 +91,7 @@ class FilesManager
}
$aTheFiles[] = array('name' => $aFile['FILE'],
'type' => "file",
'path' => $sDirectory.$aFile['FILE'],
'path' => $sDirectory,
'editable' => $sEditable);
}
return $aTheFiles;
@@ -128,6 +137,9 @@ class FilesManager
} else {
$sEditable = false;
}
if (file_exists(PATH_SEP.$sDirectory)) {
throw (new \Exception( 'The file: '. $sDirectory . ' exists.'));
}
$sPkProcessFiles = \G::generateUniqueID();
$oProcessFiles = new \ProcessFiles();
$sDate = date( 'Y-m-d H:i' );
@@ -159,23 +171,6 @@ class FilesManager
}
}
/**
* Return the Process Files Manager
*
* @param string $sProcessUID {@min 32} {@max 32}
*
* return array
*
* @access public
*/
public function getProcessFilesManagerDownload($sProcessUID)
{
try {
} catch (Exception $e) {
throw $e;
}
}
/**
* Return the Process Files Manager
*
@@ -321,12 +316,33 @@ class FilesManager
public function downloadProcessFilesManager($sProcessUID, $path)
{
try {
$arrayTaskUid = $this->getFileManagerUid($path);
$sPath = explode("/", $path);
$sfile = end(explode("/",$path));
$main = implode(array_slice($sPath, -3, 1));
if (file_exists(PATH_SEP.$path)) {
$path = PATH_SEP.$path;
//$url = http:
if (file_exists($path)) {
$sfile = end(explode("/",$path));
\G::streamFile($path, true);
# open file to write
$fp = fopen ($path, 'w+');
# start curl
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
# set return transfer to false
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, false );
curl_setopt( $ch, CURLOPT_BINARYTRANSFER, true );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
# increase timeout to download big file
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 10 );
# write data to local file
curl_setopt( $ch, CURLOPT_FILE, $fp );
# execute curl
curl_exec( $ch );
# close curl
curl_close( $ch );
# close local file
fclose( $fp );
if (filesize($path) > 0) return true;
}
} catch (Exception $e) {
throw $e;

View File

@@ -22,11 +22,6 @@ class FilesManager extends Api
try {
$filesManager = new \BusinessModel\FilesManager();
if ($path != '') {
if ($path == 'templates') {
$path = 'mailTemplates';
} else {
$path = 'public';
}
$arrayData = $filesManager->getProcessFilesManagerPath($prjUid, $path);
} else {
$arrayData = $filesManager->getProcessFilesManager($prjUid);
@@ -40,26 +35,6 @@ class FilesManager extends Api
return $response;
}
/**
* @param string $prjUid {@min 32} {@max 32}
* @param string $path
*
* @url GET /:prjUid/process-file-manager-download
*/
public function doGetProcessFilesManagerDownload($prjUid, $path = '')
{
try {
$filesManager = new \BusinessModel\FilesManager();
$arrayData = $filesManager->getProcessFilesManagerDownload($prjUid);
//Response
$response = $arrayData;
} catch (\Exception $e) {
//response
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
return $response;
}
/**
* @param string $prjUid {@min 32} {@max 32}
* @param ProcessFilesManagerStructure $request_data