Merge branch 'master' of bitbucket.org:colosa/processmaker

This commit is contained in:
Victor Saisa Lopez
2014-02-27 09:12:24 -04:00
10 changed files with 156 additions and 149 deletions

View File

@@ -346,7 +346,7 @@ class CaseScheduler
$nSW = 0;
$aData['SCH_DAYS_PERFORM_TASK'] = '';
switch ($sOption) {
case '1':
case '1': // If the option is zero, set by default 1
$aData['SCH_DAYS_PERFORM_TASK'] = '1';
$sValue = $aData['SCH_DAYS_PERFORM_TASK'];
switch ($sValue) {
@@ -637,7 +637,7 @@ class CaseScheduler
$nSW = 0;
$aData['SCH_DAYS_PERFORM_TASK'] = '';
switch ($sOption) {
case '1':
case '1': // If the option is zero, set by default 1
$aData['SCH_DAYS_PERFORM_TASK'] = '1';
$sValue = $aData['SCH_DAYS_PERFORM_TASK'];
switch ($sValue) {

View File

@@ -44,6 +44,10 @@ class FilesManager
public function getProcessFilesManagerPath($sProcessUID, $path)
{
try {
$checkPath = substr($path, -1);
if ($checkPath == '/') {
$path = substr($path, 0, -1);
}
$sMainDirectory = current(explode("/", $path));
if (strstr($path,'/')) {
$sSubDirectory = substr($path, strpos($path, "/")+1). PATH_SEP ;
@@ -84,10 +88,10 @@ class FilesManager
$arrayFileUid = $this->getFileManagerUid($sDirectory.$aFile['FILE']);
$fcontent = file_get_contents($sDirectory.$aFile['FILE']);
$fileUid = $arrayFileUid["PRF_UID"];
if ($fileUid) {
if ($fileUid != null) {
$oProcessFiles = \ProcessFilesPeer::retrieveByPK($fileUid);
$editable = $oProcessFiles->getPrfEditable();
if ($editable == 1){
if ($editable == '1') {
$editable = 'true';
} else {
$editable = 'false';
@@ -102,11 +106,10 @@ class FilesManager
'prf_create_date' => $oProcessFiles->getPrfCreateDate(),
'prf_update_date' => $oProcessFiles->getPrfUpdateDate(),
'prf_content' => $fcontent);
} else {
$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') {
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';
@@ -122,7 +125,6 @@ class FilesManager
'prf_update_date' => '',
'prf_content' => $fcontent);
}
}
return $aTheFiles;
} catch (Exception $e) {
@@ -145,7 +147,7 @@ class FilesManager
{
try {
$aData['prf_path'] = rtrim($aData['prf_path'], '/') . '/';
if (!$aData['prf_filename']){
if (!$aData['prf_filename']) {
throw (new \Exception( 'invalid value specified for `prf_filename`.'));
}
$sMainDirectory = current(explode("/", $aData['prf_path']));
@@ -199,6 +201,7 @@ class FilesManager
fwrite($fp, $content);
fclose($fp);
$oProcessFile = array('prf_uid' => $oProcessFiles->getPrfUid(),
'prf_filename' => $aData['prf_filename'],
'usr_uid' => $oProcessFiles->getUsrUid(),
'prf_update_usr_uid' => $oProcessFiles->getPrfUpdateUsrUid(),
'prf_path' => $sMainDirectory. PATH_SEP . $sSubDirectory,
@@ -236,7 +239,7 @@ class FilesManager
$path = $aRow['PRF_PATH'];
$rsCriteria->next();
}
if ($path == ''){
if ($path == '') {
throw new \Exception(\G::LoadTranslation('ID_PMTABLE_UPLOADING_FILE_PROBLEM'));
}
$file = end(explode("/",$path));
@@ -246,7 +249,7 @@ class FilesManager
if ($_FILES['prf_file']['tmp_name'] != '') {
\G::uploadFile($_FILES['prf_file']['tmp_name'], $path, $_FILES['prf_file']['name']);
}
}
}
} else {
throw new \Exception(\G::LoadTranslation('ID_PMTABLE_UPLOADING_FILE_PROBLEM'));
}
@@ -306,14 +309,14 @@ class FilesManager
$path = $aRow['PRF_PATH'];
$rsCriteria->next();
}
if ($path == ''){
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){
if ($sMainDirectory == PATH_DATA_MAILTEMPLATES) {
$sMainDirectory = 'mailTemplates';
} else {
$sMainDirectory = 'public';
@@ -375,14 +378,14 @@ class FilesManager
$path = $aRow['PRF_PATH'];
$rsCriteria->next();
}
if ($path == ''){
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){
if ($sMainDirectory == PATH_DATA_MAILTEMPLATES) {
$sMainDirectory = 'mailTemplates';
} else {
$sMainDirectory = 'public';
@@ -419,14 +422,14 @@ class FilesManager
$path = $aRow['PRF_PATH'];
$rsCriteria->next();
}
if ($path == ''){
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){
if ($sMainDirectory == PATH_DATA_MAILTEMPLATES) {
$sMainDirectory = 'mailTemplates';
} else {
$sMainDirectory = 'public';

View File

@@ -1027,7 +1027,6 @@ class Task
'aas_type' => "user" );
}
$oDataset->next();
}
if ($start) {
if ($start < 0) {
@@ -1933,8 +1932,9 @@ class Task
*
* @return array
*/
public function arrayPagination($display_array, $page, $show_per_page) {
$page = $page+1;
public function arrayPagination($display_array, $page, $show_per_page)
{
$page = $page + 1;
$show_per_page = $show_per_page -1;
$start = ($page - 1) * ($show_per_page + 1);
$offset = $show_per_page + 1;

View File

@@ -220,26 +220,26 @@ class User
if ($form['USR_COUNTRY'] != '') {
$oCountry = \IsoCountryPeer::retrieveByPK($form['USR_COUNTRY']);
if (is_null($oCountry)) {
throw new \Exception('invalid value for `usr_country`: '.$form['USR_COUNTRY']);
}
throw new \Exception('invalid value for `usr_country`: '.$form['USR_COUNTRY']);
}
}
if ($form['USR_CITY'] != '') {
$oCity = \IsoSubdivisionPeer::retrieveByPK($form['USR_COUNTRY'], $form['USR_CITY']);
if (is_null($oCity)) {
throw new \Exception('invalid value for `usr_city`: '.$form['USR_CITY']);
}
throw new \Exception('invalid value for `usr_city`: '.$form['USR_CITY']);
}
}
if ($form['USR_LOCATION'] != '') {
$oLocation = \IsoLocationPeer::retrieveByPK($form['USR_COUNTRY'], $form['USR_LOCATION']);
if (is_null($oLocation)) {
throw new \Exception('invalid value for `usr_location`: '.$form['USR_LOCATION']);
}
throw new \Exception('invalid value for `usr_location`: '.$form['USR_LOCATION']);
}
}
if ($form['USR_COUNTRY'] != '') {
$oReplacedBy = \IsoCountryPeer::retrieveByPK($form['USR_COUNTRY']);
if (is_null($oReplacedBy)) {
throw new \Exception('invalid value for `usr_country`: '.$form['USR_COUNTRY']);
}
throw new \Exception('invalid value for `usr_country`: '.$form['USR_COUNTRY']);
}
}
if (isset($arrayData['USR_UID'])) {
$form['USR_UID'] = $arrayData['USR_UID'];
@@ -313,7 +313,7 @@ class User
$aData['USR_BIRTHDAY'] = date('Y-m-d');
$aData['USR_AUTH_USER_DN'] = $form['USR_AUTH_USER_DN'];
$statusWF = $form['USR_STATUS'];
if ($form['USR_STATUS'] == '') {
if ($form['USR_STATUS'] == '') {
throw new \Exception('invalid value specified for `usr_status`, can`t be null');
} else {
if ($form['USR_STATUS'] == 'ACTIVE' || $form['USR_STATUS'] == 'INACTIVE' || $form['USR_STATUS'] == 'VACATION') {
@@ -322,7 +322,7 @@ class User
throw new \Exception('`usr_status`. Invalid value for status field.');
}
}
if ($form['USR_ROLE'] == '') {
if ($form['USR_ROLE'] == '') {
throw new \Exception('invalid value specified for `usr_role`, can`t be null');
} else {
$oCriteria = new \Criteria('rbac');

View File

@@ -368,8 +368,9 @@ class BpmnWorkflow extends Project\Bpmn
default:
throw new \LogicException(sprintf("Unsupported Gateway type: %s", $gateway['GAT_TYPE']));
}
$condition = array_key_exists('FLO_CONDITION', $gatewayFlow) ? $gatewayFlow["FLO_CONDITION"] : '';
$this->wp->addRoute($activity["ACT_UID"], $gatewayFlow['FLO_ELEMENT_DEST'], $routeType);
$this->wp->addRoute($activity["ACT_UID"], $gatewayFlow['FLO_ELEMENT_DEST'], $routeType, $condition);
break;
default:
// for processmaker is only allowed flows between "gateway -> activity"
@@ -386,115 +387,115 @@ class BpmnWorkflow extends Project\Bpmn
}
}
public static function mapBpmnFlowsToWorkflowRoute2($flow, $flows, $gateways, $events)
{
$fromUid = $flow['FLO_ELEMENT_ORIGIN'];
$result = array();
if ($flow['FLO_ELEMENT_ORIGIN_TYPE'] != "bpmnActivity") {
// skip flows that comes from a element that is not an Activity
self::log("Skip map FlowsToWorkflowRoute for -> flow with FLO_UID: {$flow['FLO_UID']}, that have FLO_ELEMENT_ORIGIN: {$flow['FLO_ELEMENT_ORIGIN_TYPE']}:$fromUid");
return null;
}
if ($flow['FLO_TYPE'] != 'SEQUENCE') {
throw new \LogicException(sprintf(
"Unsupported flow type: %s, ProcessMaker only support type '', Given: '%s'",
'SEQUENCE', $flow['FLO_TYPE']
));
}
switch ($flow['FLO_ELEMENT_DEST_TYPE']) {
case 'bpmnActivity':
// the most easy case, when the flow is connecting a activity with another activity
$result[] = array("from" => $fromUid, "to" => $flow['FLO_ELEMENT_DEST'], "type" => 'SEQUENTIAL');
break;
case 'bpmnGateway':
$gatUid = $flow['FLO_ELEMENT_DEST'];
// if it is a gateway it can fork one or more routes
$gatFlows = self::findInArray($gatUid, "FLO_ELEMENT_ORIGIN", $flows);
foreach ($gatFlows as $gatFlow) {
switch ($gatFlow['FLO_ELEMENT_DEST_TYPE']) {
case 'bpmnActivity':
// getting gateway properties
$gateways = self::findInArray($gatUid, "GAT_UID", $gateways);
if (! empty($gateways)) {
$gateway = $gateways[0];
$routeType = "";
switch ($gateway['GAT_TYPE']) {
case self::BPMN_GATEWAY_COMPLEX:
$routeType = 'SELECT';
break;
case self::BPMN_GATEWAY_EXCLUSIVE:
$routeType = 'EVALUATE';
break;
case self::BPMN_GATEWAY_INCLUSIVE:
switch ($gateway['GAT_DIRECTION']) {
case "DIVERGING":
$routeType = 'PARALLEL-BY-EVALUATION';
break;
case "CONVERGING":
$routeType = 'SEC-JOIN';
break;
default:
throw new \LogicException(sprintf("Unsupported Gateway direction: %s", $gateway['GAT_DIRECTION']));
}
break;
case self::BPMN_GATEWAY_PARALLEL:
switch ($gateway['GAT_DIRECTION']) {
case "DIVERGING":
$routeType = 'PARALLEL';
break;
case "CONVERGING":
$routeType = 'SEC-JOIN';
break;
default:
throw new \LogicException(sprintf("Unsupported Gateway direction: %s", $gateway['GAT_DIRECTION']));
}
break;
default:
throw new \LogicException(sprintf("Unsupported Gateway type: %s", $gateway['GAT_TYPE']));
}
$result[] = array("from" => $fromUid, "to" => $gatFlow['FLO_ELEMENT_DEST'], "type" => $routeType);
}
break;
default:
// for processmaker is only allowed flows between "gateway -> activity"
// any another flow is considered invalid
throw new \LogicException(sprintf(
"For ProcessMaker is only allowed flows between \"gateway -> activity\" " . PHP_EOL .
"Given: bpmnGateway -> " . $gatFlow['FLO_ELEMENT_DEST_TYPE']
));
}
}
break;
case 'bpmnEvent':
$evnUid = $flow['FLO_ELEMENT_DEST'];
$events = self::findInArray($evnUid, "EVN_UID", $events);
if (! empty($events)) {
$event = $events[0];
switch ($event['EVN_TYPE']) {
case 'END':
$routeType = 'SEQUENTIAL';
$result[] = array("from" => $fromUid, "to" => "-1", "type" => $routeType);
break;
default:
throw new \LogicException("Invalid connection to Event object type");
}
}
break;
}
return empty($result) ? null : $result;
}
// public static function mapBpmnFlowsToWorkflowRoute2($flow, $flows, $gateways, $events)
// {
// $fromUid = $flow['FLO_ELEMENT_ORIGIN'];
// $result = array();
//
// if ($flow['FLO_ELEMENT_ORIGIN_TYPE'] != "bpmnActivity") {
// // skip flows that comes from a element that is not an Activity
// self::log("Skip map FlowsToWorkflowRoute for -> flow with FLO_UID: {$flow['FLO_UID']}, that have FLO_ELEMENT_ORIGIN: {$flow['FLO_ELEMENT_ORIGIN_TYPE']}:$fromUid");
// return null;
// }
//
// if ($flow['FLO_TYPE'] != 'SEQUENCE') {
// throw new \LogicException(sprintf(
// "Unsupported flow type: %s, ProcessMaker only support type '', Given: '%s'",
// 'SEQUENCE', $flow['FLO_TYPE']
// ));
// }
//
// switch ($flow['FLO_ELEMENT_DEST_TYPE']) {
// case 'bpmnActivity':
// // the most easy case, when the flow is connecting a activity with another activity
// $result[] = array("from" => $fromUid, "to" => $flow['FLO_ELEMENT_DEST'], "type" => 'SEQUENTIAL');
// break;
// case 'bpmnGateway':
// $gatUid = $flow['FLO_ELEMENT_DEST'];
//
// // if it is a gateway it can fork one or more routes
// $gatFlows = self::findInArray($gatUid, "FLO_ELEMENT_ORIGIN", $flows);
//
// foreach ($gatFlows as $gatFlow) {
// switch ($gatFlow['FLO_ELEMENT_DEST_TYPE']) {
// case 'bpmnActivity':
// // getting gateway properties
// $gateways = self::findInArray($gatUid, "GAT_UID", $gateways);
//
// if (! empty($gateways)) {
// $gateway = $gateways[0];
// $routeType = "";
//
// switch ($gateway['GAT_TYPE']) {
// case self::BPMN_GATEWAY_COMPLEX:
// $routeType = 'SELECT';
// break;
// case self::BPMN_GATEWAY_EXCLUSIVE:
// $routeType = 'EVALUATE';
// break;
// case self::BPMN_GATEWAY_INCLUSIVE:
// switch ($gateway['GAT_DIRECTION']) {
// case "DIVERGING":
// $routeType = 'PARALLEL-BY-EVALUATION';
// break;
// case "CONVERGING":
// $routeType = 'SEC-JOIN';
// break;
// default:
// throw new \LogicException(sprintf("Unsupported Gateway direction: %s", $gateway['GAT_DIRECTION']));
// }
// break;
// case self::BPMN_GATEWAY_PARALLEL:
// switch ($gateway['GAT_DIRECTION']) {
// case "DIVERGING":
// $routeType = 'PARALLEL';
// break;
// case "CONVERGING":
// $routeType = 'SEC-JOIN';
// break;
// default:
// throw new \LogicException(sprintf("Unsupported Gateway direction: %s", $gateway['GAT_DIRECTION']));
// }
// break;
// default:
// throw new \LogicException(sprintf("Unsupported Gateway type: %s", $gateway['GAT_TYPE']));
// }
//
// $result[] = array("from" => $fromUid, "to" => $gatFlow['FLO_ELEMENT_DEST'], "type" => $routeType);
// }
// break;
// default:
// // for processmaker is only allowed flows between "gateway -> activity"
// // any another flow is considered invalid
// throw new \LogicException(sprintf(
// "For ProcessMaker is only allowed flows between \"gateway -> activity\" " . PHP_EOL .
// "Given: bpmnGateway -> " . $gatFlow['FLO_ELEMENT_DEST_TYPE']
// ));
// }
// }
// break;
// case 'bpmnEvent':
// $evnUid = $flow['FLO_ELEMENT_DEST'];
// $events = self::findInArray($evnUid, "EVN_UID", $events);
//
//
// if (! empty($events)) {
// $event = $events[0];
//
// switch ($event['EVN_TYPE']) {
// case 'END':
// $routeType = 'SEQUENTIAL';
// $result[] = array("from" => $fromUid, "to" => "-1", "type" => $routeType);
// break;
// default:
// throw new \LogicException("Invalid connection to Event object type");
// }
// }
// break;
// }
//
// return empty($result) ? null : $result;
// }
public function remove()
{

View File

@@ -269,7 +269,7 @@ class Workflow extends Handler
}
}
public function addRoute($fromTasUid, $toTasUid, $type, $delete = null)
public function addRoute($fromTasUid, $toTasUid, $type, $condition = "")
{
try {
self::log("Add Route from task: $fromTasUid -> to task: $toTasUid ($type)");
@@ -291,7 +291,7 @@ class Workflow extends Handler
//$oTasks->deleteAllRoutesOfTask($this->proUid, $fromTasUid);
//}
$result = $this->saveNewPattern($this->proUid, $fromTasUid, $toTasUid, $type, $delete);
$result = $this->saveNewPattern($this->proUid, $fromTasUid, $toTasUid, $type, $condition);
self::log("Add Route Success! - ROU_UID: ", $result);
return $result;
@@ -362,9 +362,9 @@ class Workflow extends Handler
return $route->load($rouUid);
}
public function getRoutes()
public function getRoutes($start = null, $limit = null, $filter = '', $changeCaseTo = CASE_UPPER)
{
return Route::getAll($proUid = null, $start = null, $limit = null, $filter = '', $changeCaseTo = CASE_UPPER);
return Route::getAll($this->getUid(), $start, $limit, $filter, $changeCaseTo);
}
@@ -392,7 +392,7 @@ class Workflow extends Handler
}
}
private function saveNewPattern($sProcessUID = '', $sTaskUID = '', $sNextTask = '', $sType = '', $sDelete = '')
private function saveNewPattern($sProcessUID = '', $sTaskUID = '', $sNextTask = '', $sType = '', $condition = '')
{
try {
$oCriteria = new Criteria('workflow');
@@ -413,6 +413,10 @@ class Workflow extends Handler
$aFields['ROU_TYPE'] = $sType;
$aFields['ROU_CASE'] = (int) $aRow['ROUTE_NUMBER'] + 1;
if(! empty($condition)) {
$aFields['ROU_CONDITION'] = $condition;
}
//$sGatewayUID = $aRow['GATEWAY_UID'];
//if ($sDelete && $sGatewayUID != '') {

View File

@@ -239,6 +239,6 @@ class Assignee extends Api
//Response
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
}
}

View File

@@ -145,7 +145,7 @@ class ProcessFilesManagerStructure
* @var string {@from body}
*/
public $prf_path;
/**
* @var string {@from body}
*/

View File

@@ -90,7 +90,7 @@ class OutputDocuments extends Api
} catch (\Exception $e) {
//Response
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
}
/**

View File

@@ -112,6 +112,5 @@ class User extends Api
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
}