Merge remote-tracking branch 'origin/feature/HOR-3559' into feature/HOR-3629

This commit is contained in:
Ronald Quenta
2017-08-10 18:33:14 -04:00
68 changed files with 818 additions and 760 deletions

View File

@@ -1,10 +1,14 @@
<?php
namespace ProcessMaker\BusinessModel;
use \G;
use G;
use UsersPeer;
use CasesPeer;
use AppDelegation;
use ProcessMaker\Plugins\PluginRegistry;
use \UsersPeer;
use \CasesPeer;
use Exception;
use wsBase;
use RBAC;
/**
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
@@ -26,7 +30,7 @@ class Cases
{
try {
$this->formatFieldNameInUppercase = $flag;
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -42,7 +46,7 @@ class Cases
{
try {
return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName);
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -57,7 +61,7 @@ class Cases
*/
private function throwExceptionCaseDoesNotExist($applicationUid, $fieldNameForException)
{
throw new \Exception(\G::LoadTranslation(
throw new Exception(\G::LoadTranslation(
'ID_CASE_DOES_NOT_EXIST2', [$fieldNameForException, $applicationUid]
));
}
@@ -87,7 +91,7 @@ class Cases
if ($flag) {
$this->throwExceptionCaseDoesNotExist($applicationUid, $fieldNameForException);
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -122,7 +126,7 @@ class Cases
//Return
return $obj->toArray(\BasePeer::TYPE_FIELDNAME);
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -149,7 +153,7 @@ class Cases
if (is_null($obj)) {
if ($throwException) {
throw new \Exception(\G::LoadTranslation(
throw new Exception(\G::LoadTranslation(
'ID_CASE_DEL_INDEX_DOES_NOT_EXIST',
[
$arrayVariableNameForException['$applicationUid'],
@@ -165,7 +169,7 @@ class Cases
//Return
return $obj->toArray(\BasePeer::TYPE_FIELDNAME);
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -209,7 +213,7 @@ class Cases
//Return
return $arrayListCounter;
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -462,11 +466,11 @@ class Cases
if (!isset($row)) {
continue;
}
$ws = new \wsBase();
$ws = new wsBase();
$fields = $ws->getCaseInfo($applicationUid, $row["DEL_INDEX"]);
$array = json_decode(json_encode($fields), true);
if ($array ["status_code"] != 0) {
throw (new \Exception($array ["message"]));
throw (new Exception($array ["message"]));
} else {
$array['app_uid'] = $array['caseId'];
$array['app_number'] = $array['caseNumber'];
@@ -526,15 +530,15 @@ class Cases
"app_name" => $e->getMessage(),
"del_index" => $e->getMessage(),
"pro_uid" => $e->getMessage());
throw (new \Exception($arrayData));
throw (new Exception($arrayData));
}
} else {
$ws = new \wsBase();
$ws = new wsBase();
$fields = $ws->getCaseInfo($applicationUid, 0);
$array = json_decode(json_encode($fields), true);
if ($array ["status_code"] != 0) {
throw (new \Exception($array ["message"]));
throw (new Exception($array ["message"]));
} else {
$array['app_uid'] = $array['caseId'];
$array['app_number'] = $array['caseNumber'];
@@ -592,7 +596,7 @@ class Cases
//Return
return $oResponse;
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -621,7 +625,7 @@ class Cases
$rsCriteria = \ApplicationPeer::doSelectRS($criteria);
if ($rsCriteria->next()) {
throw new \Exception(\G::LoadTranslation("ID_CASE_NO_CURRENT_TASKS_BECAUSE_CASE_ITS_COMPLETED", array($this->getFieldNameByFormatFieldName("APP_UID"), $applicationUid)));
throw new Exception(\G::LoadTranslation("ID_CASE_NO_CURRENT_TASKS_BECAUSE_CASE_ITS_COMPLETED", array($this->getFieldNameByFormatFieldName("APP_UID"), $applicationUid)));
}
//Get data
@@ -629,8 +633,8 @@ class Cases
$oCriteria = new \Criteria( 'workflow' );
$del = \DBAdapter::getStringDelimiter();
$oCriteria->addSelectColumn( \AppDelegationPeer::DEL_INDEX );
$oCriteria->addSelectColumn( \AppDelegationPeer::TAS_UID );
$oCriteria->addSelectColumn(\AppDelegationPeer::DEL_INDEX);
$oCriteria->addSelectColumn(\AppDelegationPeer::TAS_UID);
$oCriteria->addSelectColumn(\AppDelegationPeer::DEL_INIT_DATE);
$oCriteria->addSelectColumn(\AppDelegationPeer::DEL_TASK_DUE_DATE);
$oCriteria->addSelectColumn(\TaskPeer::TAS_TITLE);
@@ -652,11 +656,11 @@ class Cases
}
//Return
if (empty($result)) {
throw new \Exception(\G::LoadTranslation("ID_CASES_INCORRECT_INFORMATION", array($applicationUid)));
throw new Exception(\G::LoadTranslation("ID_CASES_INCORRECT_INFORMATION", array($applicationUid)));
} else {
return $result;
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -675,19 +679,19 @@ class Cases
{
try {
$ws = new \wsBase();
$ws = new wsBase();
if ($variables) {
$variables = array_shift($variables);
}
Validator::proUid($processUid, '$pro_uid');
$oTask = new \Task();
if (! $oTask->taskExists($taskUid)) {
throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('tas_uid')));
throw new Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('tas_uid')));
}
$fields = $ws->newCase($processUid, $userUid, $taskUid, $variables);
$array = json_decode(json_encode($fields), true);
if ($array ["status_code"] != 0) {
throw (new \Exception($array ["message"]));
throw (new Exception($array ["message"]));
} else {
$array['app_uid'] = $array['caseId'];
$array['app_number'] = $array['caseNumber'];
@@ -700,7 +704,7 @@ class Cases
$oResponse = json_decode(json_encode($array), false);
//Return
return $oResponse;
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -719,7 +723,7 @@ class Cases
{
try {
$ws = new \wsBase();
$ws = new wsBase();
if ($variables) {
$variables = array_shift($variables);
} elseif ($variables == null) {
@@ -728,17 +732,17 @@ class Cases
Validator::proUid($processUid, '$pro_uid');
$user = new \Users();
if (! $user->userExists( $userUid )) {
throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('usr_uid')));
throw new Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('usr_uid')));
}
$fields = $ws->newCaseImpersonate($processUid, $userUid, $variables, $taskUid);
$array = json_decode(json_encode($fields), true);
if ($array ["status_code"] != 0) {
if ($array ["status_code"] == 12) {
throw (new \Exception(\G::loadTranslation('ID_NO_STARTING_TASK') . '. tas_uid.'));
throw (new Exception(\G::loadTranslation('ID_NO_STARTING_TASK') . '. tas_uid.'));
} elseif ($array ["status_code"] == 13) {
throw (new \Exception(\G::loadTranslation('ID_MULTIPLE_STARTING_TASKS') . '. tas_uid.'));
throw (new Exception(\G::loadTranslation('ID_MULTIPLE_STARTING_TASKS') . '. tas_uid.'));
}
throw (new \Exception($array ["message"]));
throw (new Exception($array ["message"]));
} else {
$array['app_uid'] = $array['caseId'];
$array['app_number'] = $array['caseNumber'];
@@ -751,7 +755,7 @@ class Cases
$oResponse = json_decode(json_encode($array), false);
//Return
return $oResponse;
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -771,24 +775,24 @@ class Cases
{
try {
if (!$delIndex) {
$delIndex = \AppDelegation::getCurrentIndex($applicationUid);
$delIndex = AppDelegation::getCurrentIndex($applicationUid);
}
$ws = new \wsBase();
$ws = new wsBase();
$fields = $ws->reassignCase($userUid, $applicationUid, $delIndex, $userUidSource, $userUidTarget);
$array = json_decode(json_encode($fields), true);
if (array_key_exists("status_code", $array)) {
if ($array ["status_code"] != 0) {
throw (new \Exception($array ["message"]));
throw (new Exception($array ["message"]));
} else {
unset($array['status_code']);
unset($array['message']);
unset($array['timestamp']);
}
} else {
throw new \Exception(\G::LoadTranslation("ID_CASES_INCORRECT_INFORMATION", array($applicationUid)));
throw new Exception(\G::LoadTranslation("ID_CASES_INCORRECT_INFORMATION", array($applicationUid)));
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -814,14 +818,14 @@ class Cases
Validator::usrUid($usr_uid, '$usr_uid');
if ($del_index === false) {
$del_index = \AppDelegation::getCurrentIndex($app_uid);
$del_index = AppDelegation::getCurrentIndex($app_uid);
}
Validator::isInteger($del_index, '$del_index');
$case = new \Cases();
$fields = $case->loadCase($app_uid);
if ($fields['APP_STATUS'] == 'CANCELLED') {
throw (new \Exception(\G::LoadTranslation("ID_CASE_ALREADY_CANCELED", array($app_uid))));
throw (new Exception(\G::LoadTranslation("ID_CASE_ALREADY_CANCELED", array($app_uid))));
}
$appCacheView = new \AppCacheView();
@@ -840,7 +844,7 @@ class Cases
$rsCriteria = \AppDelegationPeer::doSelectRS($criteria);
if (!$rsCriteria->next()) {
throw (new \Exception(\G::LoadTranslation("ID_CASE_USER_INVALID_CANCEL_CASE", array($usr_uid))));
throw (new Exception(\G::LoadTranslation("ID_CASE_USER_INVALID_CANCEL_CASE", array($usr_uid))));
}
$case->cancelCase( $app_uid, $del_index, $usr_uid );
@@ -868,7 +872,7 @@ class Cases
Validator::usrUid($usr_uid, '$usr_uid');
if ($del_index === false) {
$del_index = \AppDelegation::getCurrentIndex($app_uid);
$del_index = AppDelegation::getCurrentIndex($app_uid);
}
Validator::isInteger($del_index, '$del_index');
@@ -876,13 +880,13 @@ class Cases
$case = new \Cases();
$fields = $case->loadCase($app_uid);
if ($fields['APP_STATUS'] == 'CANCELLED') {
throw (new \Exception(\G::LoadTranslation("ID_CASE_IS_CANCELED", array($app_uid))));
throw (new Exception(\G::LoadTranslation("ID_CASE_IS_CANCELED", array($app_uid))));
}
$oDelay = new \AppDelay();
if ($oDelay->isPaused($app_uid, $del_index)) {
throw (new \Exception(\G::LoadTranslation("ID_CASE_PAUSED", array($app_uid))));
throw (new Exception(\G::LoadTranslation("ID_CASE_PAUSED", array($app_uid))));
}
$appCacheView = new \AppCacheView();
@@ -904,7 +908,7 @@ class Cases
$rsCriteria = \AppDelegationPeer::doSelectRS($criteria);
if (!$rsCriteria->next()) {
throw (new \Exception(\G::LoadTranslation("ID_CASE_USER_INVALID_PAUSED_CASE", array($usr_uid))));
throw (new Exception(\G::LoadTranslation("ID_CASE_USER_INVALID_PAUSED_CASE", array($usr_uid))));
}
if ($unpaused_date != null) {
@@ -934,14 +938,14 @@ class Cases
Validator::usrUid($usr_uid, '$usr_uid');
if ($del_index === false) {
$del_index = \AppDelegation::getCurrentIndex($app_uid);
$del_index = AppDelegation::getCurrentIndex($app_uid);
}
Validator::isInteger($del_index, '$del_index');
$oDelay = new \AppDelay();
if (!$oDelay->isPaused($app_uid, $del_index)) {
throw (new \Exception(\G::LoadTranslation("ID_CASE_NOT_PAUSED", array($app_uid))));
throw (new Exception(\G::LoadTranslation("ID_CASE_NOT_PAUSED", array($app_uid))));
}
$appCacheView = new \AppCacheView();
@@ -960,7 +964,7 @@ class Cases
$rsCriteria = \AppDelegationPeer::doSelectRS($criteria);
if (!$rsCriteria->next()) {
throw (new \Exception(\G::LoadTranslation("ID_CASE_USER_INVALID_UNPAUSE_CASE", array($usr_uid))));
throw (new Exception(\G::LoadTranslation("ID_CASE_USER_INVALID_UNPAUSE_CASE", array($usr_uid))));
}
$case = new \Cases();
@@ -971,39 +975,45 @@ class Cases
* Put execute trigger case
*
* @access public
* @param string $app_uid , Uid for case
* @param string $usr_uid , Uid for user
* @param bool|string $del_index , Index for case
* @param string $appUid, Uid for case
* @param string $triUid, Uid for trigger
* @param string $userUid, Uid for user
* @param bool|string $delIndex, Index for case
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @return array
* @throws Exception
*/
public function putExecuteTriggerCase($app_uid, $tri_uid, $usr_uid, $del_index = false)
public function putExecuteTriggerCase($appUid, $triUid, $userUid, $delIndex = false)
{
Validator::isString($app_uid, '$app_uid');
Validator::isString($tri_uid, '$tri_uid');
Validator::isString($usr_uid, '$usr_uid');
Validator::isString($appUid, '$appUid');
Validator::isString($triUid, '$triUid');
Validator::isString($userUid, '$userUid');
Validator::appUid($app_uid, '$app_uid');
Validator::triUid($tri_uid, '$tri_uid');
Validator::usrUid($usr_uid, '$usr_uid');
Validator::appUid($appUid, '$appUid');
Validator::triUid($triUid, '$triUid');
Validator::usrUid($userUid, '$userUid');
if ($del_index === false) {
$del_index = \AppDelegation::getCurrentIndex($app_uid);
if ($delIndex === false) {
//We need to find the last delIndex open related to the user $usr_uid
$delIndex = (integer)$this->getLastParticipatedByUser($appUid, $userUid, 'OPEN');
//If the is assigned another user the function will be return 0
if ($delIndex === 0) {
throw new Exception(G::loadTranslation('ID_CASE_ASSIGNED_ANOTHER_USER'));
}
}
Validator::isInteger($del_index, '$del_index');
Validator::isInteger($delIndex, '$del_index');
global $RBAC;
if (!method_exists($RBAC, 'initRBAC')) {
$RBAC = \RBAC::getSingleton( PATH_DATA, session_id() );
$RBAC = RBAC::getSingleton( PATH_DATA, session_id() );
$RBAC->sSystem = 'PROCESSMAKER';
}
$case = new \wsBase();
$result = $case->executeTrigger($usr_uid, $app_uid, $tri_uid, $del_index);
$case = new wsBase();
$result = $case->executeTrigger($userUid, $appUid, $triUid, $delIndex);
if ($result->status_code != 0) {
throw new \Exception($result->message);
throw new Exception($result->message);
}
}
@@ -1032,11 +1042,11 @@ class Cases
$dataset->next();
$aRow = $dataset->getRow();
if ($aRow['APP_STATUS'] != 'DRAFT') {
throw (new \Exception(\G::LoadTranslation("ID_DELETE_CASE_NO_STATUS")));
throw (new Exception(\G::LoadTranslation("ID_DELETE_CASE_NO_STATUS")));
}
if ($aRow['APP_INIT_USER'] != $usr_uid) {
throw (new \Exception(\G::LoadTranslation("ID_DELETE_CASE_NO_OWNER")));
throw (new Exception(\G::LoadTranslation("ID_DELETE_CASE_NO_OWNER")));
}
$case = new \Cases();
@@ -1057,26 +1067,26 @@ class Cases
{
try {
if (!$delIndex) {
$delIndex = \AppDelegation::getCurrentIndex($applicationUid);
$delIndex = AppDelegation::getCurrentIndex($applicationUid);
//Check if the next task is a subprocess SYNCHRONOUS with a thread Open
$subAppData = new \SubApplication();
$caseSubprocessPending = $subAppData->isSubProcessWithCasePending($applicationUid, $delIndex);
if ($caseSubprocessPending) {
throw (new \Exception(\G::LoadTranslation("ID_CASE_ALREADY_DERIVATED")));
throw (new Exception(\G::LoadTranslation("ID_CASE_ALREADY_DERIVATED")));
}
}
$ws = new \wsBase();
$ws = new wsBase();
$fields = $ws->derivateCase($userUid, $applicationUid, $delIndex, $bExecuteTriggersBeforeAssignment = false);
$array = json_decode(json_encode($fields), true);
if ($array ["status_code"] != 0) {
throw (new \Exception($array ["message"]));
throw (new Exception($array ["message"]));
} else {
unset($array['status_code']);
unset($array['message']);
unset($array['timestamp']);
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -1392,7 +1402,7 @@ class Cases
$conf = new \Configurations();
$confEnvSetting = $conf->getFormats();
$cases = new \cases();
$listing = false;
@@ -1545,7 +1555,7 @@ class Cases
try {
$aAux1 = $oUser->load($aAux['USR_UID']);
$sUser = $conf->usersNameFormatBySetParameters($confEnvSetting["format"], $aAux1["USR_USERNAME"], $aAux1["USR_FIRSTNAME"], $aAux1["USR_LASTNAME"]);
} catch (\Exception $oException) {
} catch (Exception $oException) {
$sUser = '(USER DELETED)';
}
//if both documents were generated, we choose the pdf one, only if doc was
@@ -1656,7 +1666,7 @@ class Cases
//Return
return $caseVariable;
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -1755,11 +1765,11 @@ class Cases
$arrayResult = $this->getStatusInfo($app_uid);
if ($arrayResult["APP_STATUS"] == "CANCELLED") {
throw new \Exception(\G::LoadTranslation("ID_CASE_CANCELLED", array($app_uid)));
throw new Exception(\G::LoadTranslation("ID_CASE_CANCELLED", array($app_uid)));
}
if ($arrayResult["APP_STATUS"] == "COMPLETED") {
throw new \Exception(\G::LoadTranslation("ID_CASE_IS_COMPLETED", array($app_uid)));
throw new Exception(\G::LoadTranslation("ID_CASE_IS_COMPLETED", array($app_uid)));
}
$appCacheView = new \AppCacheView();
@@ -1775,7 +1785,7 @@ class Cases
$rsCriteria = \AppDelegationPeer::doSelectRS($criteria);
if (!$rsCriteria->next()) {
throw (new \Exception(\G::LoadTranslation("ID_NO_PERMISSION_NO_PARTICIPATED", array($usr_uid))));
throw (new Exception(\G::LoadTranslation("ID_NO_PERMISSION_NO_PARTICIPATED", array($usr_uid))));
}
$_SESSION['APPLICATION'] = $app_uid;
@@ -1856,11 +1866,11 @@ class Cases
$case = new \Cases();
$caseLoad = $case->loadCase($app_uid);
$pro_uid = $caseLoad['PRO_UID'];
$tas_uid = \AppDelegation::getCurrentTask($app_uid);
$tas_uid = AppDelegation::getCurrentTask($app_uid);
$respView = $case->getAllObjectsFrom( $pro_uid, $app_uid, $tas_uid, $usr_uid, 'VIEW' );
$respBlock = $case->getAllObjectsFrom( $pro_uid, $app_uid, $tas_uid, $usr_uid, 'BLOCK' );
if ($respView['CASES_NOTES'] == 0 && $respBlock['CASES_NOTES'] == 0) {
throw (new \Exception(\G::LoadTranslation("ID_CASES_NOTES_NO_PERMISSIONS")));
throw (new Exception(\G::LoadTranslation("ID_CASES_NOTES_NO_PERMISSIONS")));
}
if ($sort != 'APP_NOTE.NOTE_DATE') {
@@ -1944,7 +1954,7 @@ class Cases
Validator::isString($note_content, '$note_content');
if (strlen($note_content) > 500) {
throw (new \Exception(\G::LoadTranslation("ID_INVALID_MAX_PERMITTED", array($note_content,'500'))));
throw (new Exception(\G::LoadTranslation("ID_INVALID_MAX_PERMITTED", array($note_content,'500'))));
}
Validator::isBoolean($send_mail, '$send_mail');
@@ -1952,11 +1962,11 @@ class Cases
$case = new \Cases();
$caseLoad = $case->loadCase($app_uid);
$pro_uid = $caseLoad['PRO_UID'];
$tas_uid = \AppDelegation::getCurrentTask($app_uid);
$tas_uid = AppDelegation::getCurrentTask($app_uid);
$respView = $case->getAllObjectsFrom( $pro_uid, $app_uid, $tas_uid, $usr_uid, 'VIEW' );
$respBlock = $case->getAllObjectsFrom( $pro_uid, $app_uid, $tas_uid, $usr_uid, 'BLOCK' );
if ($respView['CASES_NOTES'] == 0 && $respBlock['CASES_NOTES'] == 0) {
throw (new \Exception(\G::LoadTranslation("ID_CASES_NOTES_NO_PERMISSIONS")));
throw (new Exception(\G::LoadTranslation("ID_CASES_NOTES_NO_PERMISSIONS")));
}
$note_content = addslashes($note_content);
@@ -1987,7 +1997,7 @@ class Cases
$this->getFieldNameByFormatFieldName("USR_FIRSTNAME") => $record["USR_FIRSTNAME"] . "",
$this->getFieldNameByFormatFieldName("USR_LASTNAME") => $record["USR_LASTNAME"] . ""
);
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -2255,7 +2265,7 @@ class Cases
//Return
return $arrayTask;
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -2333,7 +2343,7 @@ class Cases
//Return
return $arrayData;
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -2520,7 +2530,7 @@ class Cases
//Return
return array();
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -2542,7 +2552,7 @@ class Cases
$response = $case->getProcessListStartCase($usrUid, $typeView);
return $response;
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -2624,7 +2634,7 @@ class Cases
}
return $processList;
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
@@ -2807,7 +2817,7 @@ class Cases
$filterName => (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData['filter']))? $arrayFilterData['filter'] : '',
'data' => $arrayUser
];
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -3166,7 +3176,7 @@ class Cases
}
}
//Delete simple files.
//Delete simple files.
//The observations suggested by 'pull request' approver are applied (please see pull request).
foreach ($arrayVariableDocumentToDelete as $key => $value) {
if (isset($value['appDocUid'])) {
@@ -3180,7 +3190,7 @@ class Cases
}
}
$arrayApplicationData['APP_DATA'][$key] = G::json_encode($files);
} catch (\Exception $e) {
} catch (Exception $e) {
Bootstrap::registerMonolog('DeleteFile', 400, $e->getMessage(), $value, SYS_SYS, 'processmaker.log');
}
}
@@ -3244,7 +3254,7 @@ class Cases
* @param array $appData
* @param array $dataVariable
* @return array
* @throws \Exception
* @throws Exception
*/
public static function getGlobalVariables($appData = array(), $dataVariable = array())
{

View File

@@ -390,8 +390,7 @@ class Dashboard {
$data['USR_UID'] = $usrUid;
$data['PRO_UID'] = "";
$data['APP_UID'] = "";
//require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Configuration.php");
$oConfig = new \Configuration();
$response = $oConfig->create($data);
@@ -409,7 +408,6 @@ class Dashboard {
*/
public function getConfig($usr_uid)
{
//require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Configuration.php");
$oConfig = new \Configuration();
$response = array();

View File

@@ -1,9 +1,9 @@
<?php
namespace ProcessMaker\BusinessModel;
use \G;
use \DbSource;
use \dbConnections;
use G;
use DbSource;
use DbConnections;
class DataBaseConnection
{
@@ -61,7 +61,7 @@ class DataBaseConnection
$dbs_uid = $this->validateDbsUid($dbs_uid, $pro_uid);
}
$dbs = new dbConnections($pro_uid);
$dbs = new DbConnections($pro_uid);
$oDBConnection = new DbSource();
$aFields = $oDBConnection->load($dbs_uid, $pro_uid);
if ($aFields['DBS_PORT'] == '0') {
@@ -162,7 +162,7 @@ class DataBaseConnection
if (isset($dataDBConnection['DBS_ENCODE'])) {
$encodesExists = array();
$dbs = new dbConnections();
$dbs = new DbConnections();
$dbEncodes = $dbs->getEncondeList($dataDBConnection['DBS_TYPE']);
foreach ($dbEncodes as $value) {
$encodesExists[] = $value['0'];
@@ -423,7 +423,7 @@ class DataBaseConnection
*/
public function getDbEngines ()
{
$dbs = new dbConnections();
$dbs = new DbConnections();
$dbServices = $dbs->getDbServicesAvailables();
return $dbServices;
}

View File

@@ -1,5 +1,6 @@
<?php
namespace ProcessMaker\BusinessModel;
use DynaformHandler;
class DynaForm
{
@@ -155,7 +156,7 @@ class DynaForm
while ($oDataset->next()) {
$dataForms = $oDataset->getRow();
$dynHandler = new \dynaFormHandler(PATH_DYNAFORM . $proUid . PATH_SEP . $dataForms["DYN_UID"] . ".xml");
$dynHandler = new DynaformHandler(PATH_DYNAFORM . $proUid . PATH_SEP . $dataForms["DYN_UID"] . ".xml");
$dynFields = $dynHandler->getFields();
foreach ($dynFields as $field) {
$sType = \Step::getAttribute( $field, 'type' );

View File

@@ -3,6 +3,7 @@ namespace ProcessMaker\BusinessModel;
use G;
use Criteria;
use DynaformHandler;
class Process
{
@@ -1676,7 +1677,7 @@ class Process
while ($aRow = $oDataset->getRow()) {
if (is_file(PATH_DYNAFORM . $aRow['DYN_FILENAME'] . ".xml")) {
$dyn = new \dynaFormHandler(PATH_DYNAFORM . $aRow['DYN_FILENAME'] . ".xml");
$dyn = new DynaformHandler(PATH_DYNAFORM . $aRow['DYN_FILENAME'] . ".xml");
if ($dyn->getHeaderAttribute("type") !== "xmlform" && $dyn->getHeaderAttribute("type") !== "") {
// skip it, if that is not a xmlform
@@ -1729,7 +1730,7 @@ class Process
$oDataset->next();
while ($aRow = $oDataset->getRow()) {
if (is_file(PATH_DYNAFORM . $aRow['DYN_FILENAME'] . ".xml")) {
$dyn = new \dynaFormHandler(PATH_DYNAFORM . $aRow['DYN_FILENAME'] . ".xml");
$dyn = new DynaformHandler(PATH_DYNAFORM . $aRow['DYN_FILENAME'] . ".xml");
if ($dyn->getHeaderAttribute("type") === "xmlform") {
// skip it, if that is not a xmlform
@@ -1775,7 +1776,7 @@ class Process
$aMultipleSelectionFields = array("listbox", "checkgroup", "grid");
if (is_file( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/'. $proUid .'/'.$dynUid. '.xml' ) && filesize( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/'. $proUid .'/'. $dynUid .'.xml' ) > 0) {
$dyn = new \dynaFormHandler( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/' .$proUid. '/' . $dynUid .'.xml' );
$dyn = new DynaformHandler( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/' .$proUid. '/' . $dynUid .'.xml' );
$dynaformFields[] = $dyn->getFields();
$fields = $dyn->getFields();

View File

@@ -1,9 +1,10 @@
<?php
namespace ProcessMaker\BusinessModel;
use \G;
use \AdditionalTables;
use \Fields;
use G;
use AdditionalTables;
use Fields;
use DynaformHandler;
class Table
{
@@ -798,7 +799,7 @@ class Table
while ($oDataset->next()) {
$aRow = $oDataset->getRow();
if (file_exists( PATH_DYNAFORM . PATH_SEP . $aRow['DYN_FILENAME'] . '.xml' )) {
$dynaformHandler = new \dynaformHandler( PATH_DYNAFORM . $aRow['DYN_FILENAME'] . '.xml' );
$dynaformHandler = new DynaformHandler( PATH_DYNAFORM . $aRow['DYN_FILENAME'] . '.xml' );
$nodeFieldsList = $dynaformHandler->getFields();
foreach ($nodeFieldsList as $node) {
@@ -1052,7 +1053,7 @@ class Table
while ($oDataset->next()) {
$aRow = $oDataset->getRow();
$dynaformHandler = new \dynaformHandler( PATH_DYNAFORM . $aRow['DYN_FILENAME'] . '.xml' );
$dynaformHandler = new DynaformHandler( PATH_DYNAFORM . $aRow['DYN_FILENAME'] . '.xml' );
$nodeFieldsList = $dynaformHandler->getFields();
foreach ($nodeFieldsList as $node) {
$arrayNode = $dynaformHandler->getArray( $node );

View File

@@ -1897,7 +1897,12 @@ class Task
}
}
public function getValidateSelfService($data)
/**
* This method verify if an activity has cases
* @param $data
* @return \stdclass
*/
public function hasPendingCases($data)
{
$paused = false;
$data = array_change_key_case($data, CASE_LOWER);

View File

@@ -785,7 +785,7 @@ class User
$oUser = new Users();
$aUser = $oUser->load($userUid);
$oUserProperty = new UsersProperties();
$aUserProperty = $oUserProperty->loadOrCreateIfNotExists($userUid, array("USR_PASSWORD_HISTORY" => serialize(array($aUser["USR_PASSWORD"]))));
$aUserProperty = $oUserProperty->loadOrCreateIfNotExists($userUid, array("USR_PASSWORD_HISTORY" => serialize(array($oUser->getUsrPassword()))));
$aUserProperty["USR_LOGGED_NEXT_TIME"] = $arrayData["USR_LOGGED_NEXT_TIME"];
$oUserProperty->update($aUserProperty);
}

View File

@@ -1,7 +1,9 @@
<?php
namespace ProcessMaker\BusinessModel;
use \G;
use G;
use Exception;
use AdditionalTables;
class Variable
{
@@ -13,25 +15,22 @@ class Variable
* @param string $processUid Unique id of Process
* @param array $arrayData Data
*
* return array Return data of the new Variable created
* @return array, return data of the new Variable created
* @throws Exception
*/
public function create($processUid, array $arrayData)
{
try {
//Verify data
Validator::proUid($processUid, '$prj_uid');
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
$this->existsName($processUid, $arrayData["VAR_NAME"], "");
$this->throwExceptionFieldDefinition($arrayData);
//Create
$cnn = \Propel::getConnection("workflow");
try {
$variable = new \ProcessVariables();
$sPkProcessVariables = \ProcessMaker\Util\Common::generateUID();
$variable->setVarUid($sPkProcessVariables);
@@ -43,13 +42,13 @@ class Variable
if (isset($arrayData["VAR_NAME"])) {
$variable->setVarName($arrayData["VAR_NAME"]);
} else {
throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_name' )));
throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_name' )));
}
if (isset($arrayData["VAR_FIELD_TYPE"])) {
$arrayData["VAR_FIELD_TYPE"] = $this->validateVarFieldType($arrayData["VAR_FIELD_TYPE"]);
$variable->setVarFieldType($arrayData["VAR_FIELD_TYPE"]);
} else {
throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_field_type' )));
throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_field_type' )));
}
if (isset($arrayData["VAR_FIELD_SIZE"])) {
$variable->setVarFieldSize($arrayData["VAR_FIELD_SIZE"]);
@@ -57,7 +56,7 @@ class Variable
if (isset($arrayData["VAR_LABEL"])) {
$variable->setVarLabel($arrayData["VAR_LABEL"]);
} else {
throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_label' )));
throw new Exception(G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_label' )));
}
if (isset($arrayData["VAR_DBCONNECTION"])) {
$variable->setVarDbconnection($arrayData["VAR_DBCONNECTION"]);
@@ -78,7 +77,7 @@ class Variable
$variable->setVarDefault($arrayData["VAR_DEFAULT"]);
}
if (isset($arrayData["VAR_ACCEPTED_VALUES"])) {
$encodeAcceptedValues = \G::json_encode($arrayData["VAR_ACCEPTED_VALUES"]);
$encodeAcceptedValues = G::json_encode($arrayData["VAR_ACCEPTED_VALUES"]);
$variable->setVarAcceptedValues($encodeAcceptedValues);
}
if (isset($arrayData["INP_DOC_UID"])) {
@@ -94,10 +93,10 @@ class Variable
$msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage();
}
throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . "\n" . $msg);
throw new Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . "\n" . $msg);
}
} catch (\Exception $e) {
} catch (Exception $e) {
$cnn->rollback();
throw $e;
@@ -108,7 +107,7 @@ class Variable
return $variable;
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -120,7 +119,8 @@ class Variable
* @param string $variableUid Unique id of Variable
* @param array $arrayData Data
*
* return array Return data of the Variable updated
* @return array,return data of the Variable updated
* @throws Exception
*/
public function update($processUid, $variableUid, $arrayData)
{
@@ -128,7 +128,6 @@ class Variable
//Verify data
Validator::proUid($processUid, '$prj_uid');
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
$this->throwExceptionFieldDefinition($arrayData);
//Update
@@ -150,7 +149,6 @@ class Variable
$cnn->begin();
if (isset($arrayData["VAR_NAME"])) {
$this->existsName($processUid, $arrayData["VAR_NAME"], $variableUid);
$variable->setVarName($arrayData["VAR_NAME"]);
}
if (isset($arrayData["VAR_FIELD_TYPE"])) {
@@ -176,7 +174,7 @@ class Variable
$variable->setVarDefault($arrayData["VAR_DEFAULT"]);
}
if (isset($arrayData["VAR_ACCEPTED_VALUES"])) {
$encodeAcceptedValues = \G::json_encode($arrayData["VAR_ACCEPTED_VALUES"]);
$encodeAcceptedValues = G::json_encode($arrayData["VAR_ACCEPTED_VALUES"]);
$variable->setVarAcceptedValues($encodeAcceptedValues);
}
if (isset($arrayData["INP_DOC_UID"])) {
@@ -206,15 +204,15 @@ class Variable
$msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage();
}
throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . "\n" . $msg);
throw new Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . "\n" . $msg);
}
} catch (\Exception $e) {
} catch (Exception $e) {
$cnn->rollback();
throw $e;
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -225,35 +223,31 @@ class Variable
* @param string $processUid Unique id of Process
* @param string $variableUid Unique id of Variable
*
* return void
* @return void
* @throws Exception
*/
public function delete($processUid, $variableUid)
{
try {
//Verify data
Validator::proUid($processUid, '$prj_uid');
$this->throwExceptionIfNotExistsVariable($variableUid);
//Verify variable
$this->throwExceptionIfVariableIsAssociatedAditionalTable($variableUid);
$variable = $this->getVariable($processUid, $variableUid);
$pmDynaform = new \pmDynaform();
$isUsed = $pmDynaform->isUsed($processUid, $variable);
if ($isUsed !== false) {
$titleDynaform=$pmDynaform->getDynaformTitle($isUsed);
throw new \Exception(\G::LoadTranslation("ID_VARIABLE_IN_USE", array($titleDynaform)));
throw new Exception(G::LoadTranslation("ID_VARIABLE_IN_USE", array($titleDynaform)));
}
//Delete
$criteria = new \Criteria("workflow");
$criteria->add(\ProcessVariablesPeer::VAR_UID, $variableUid);
\ProcessVariablesPeer::doDelete($criteria);
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -263,19 +257,18 @@ class Variable
* @param string $processUid Unique id of Process
* @param string $variableUid Unique id of Variable
*
* return array Return an array with data of a Variable
* @return array, return an array with data of a Variable
* @throws Exception
*/
public function getVariable($processUid, $variableUid)
{
try {
//Verify data
Validator::proUid($processUid, '$prj_uid');
$this->throwExceptionIfNotExistsVariable($variableUid);
//Get data
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\ProcessVariablesPeer::VAR_UID);
$criteria->addSelectColumn(\ProcessVariablesPeer::PRJ_UID);
$criteria->addSelectColumn(\ProcessVariablesPeer::VAR_NAME);
@@ -292,23 +285,18 @@ class Variable
$criteria->addSelectColumn(\DbSourcePeer::DBS_PORT);
$criteria->addSelectColumn(\DbSourcePeer::DBS_DATABASE_NAME);
$criteria->addSelectColumn(\DbSourcePeer::DBS_TYPE);
$criteria->add(\ProcessVariablesPeer::PRJ_UID, $processUid, \Criteria::EQUAL);
$criteria->add(\ProcessVariablesPeer::VAR_UID, $variableUid, \Criteria::EQUAL);
$criteria->addJoin(\ProcessVariablesPeer::VAR_DBCONNECTION, \DbSourcePeer::DBS_UID, \Criteria::LEFT_JOIN);
$rsCriteria = \ProcessVariablesPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$rsCriteria->next();
$arrayVariables = array();
while ($aRow = $rsCriteria->getRow()) {
$VAR_ACCEPTED_VALUES = \G::json_decode($aRow['VAR_ACCEPTED_VALUES'], true);
$VAR_ACCEPTED_VALUES = G::json_decode($aRow['VAR_ACCEPTED_VALUES'], true);
if(sizeof($VAR_ACCEPTED_VALUES)) {
$encodeAcceptedValues = preg_replace("/\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", \G::json_encode($VAR_ACCEPTED_VALUES));
$encodeAcceptedValues = preg_replace("/\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", G::json_encode($VAR_ACCEPTED_VALUES));
} else {
$encodeAcceptedValues = $aRow['VAR_ACCEPTED_VALUES'];
}
@@ -331,7 +319,7 @@ class Variable
//Return
return $arrayVariables;
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -342,7 +330,8 @@ class Variable
*
* @param string $processUid Unique id of Process
*
* return array Return an array with data of a DynaForm
* @return array, return an array with data of a DynaForm
* @throws Exception
*/
public function getVariables($processUid)
{
@@ -352,7 +341,6 @@ class Variable
//Get data
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\ProcessVariablesPeer::VAR_UID);
$criteria->addSelectColumn(\ProcessVariablesPeer::PRJ_UID);
$criteria->addSelectColumn(\ProcessVariablesPeer::VAR_NAME);
@@ -369,22 +357,17 @@ class Variable
$criteria->addSelectColumn(\DbSourcePeer::DBS_PORT);
$criteria->addSelectColumn(\DbSourcePeer::DBS_DATABASE_NAME);
$criteria->addSelectColumn(\DbSourcePeer::DBS_TYPE);
$criteria->add(\ProcessVariablesPeer::PRJ_UID, $processUid, \Criteria::EQUAL);
$criteria->addJoin(\ProcessVariablesPeer::VAR_DBCONNECTION, \DbSourcePeer::DBS_UID . " AND " . \DbSourcePeer::PRO_UID . " = '" . $processUid . "'", \Criteria::LEFT_JOIN);
$rsCriteria = \ProcessVariablesPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$rsCriteria->next();
$arrayVariables = array();
while ($aRow = $rsCriteria->getRow()) {
$VAR_ACCEPTED_VALUES = \G::json_decode($aRow['VAR_ACCEPTED_VALUES'], true);
$VAR_ACCEPTED_VALUES = G::json_decode($aRow['VAR_ACCEPTED_VALUES'], true);
if(sizeof($VAR_ACCEPTED_VALUES)) {
$encodeAcceptedValues = preg_replace("/\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", \G::json_encode($VAR_ACCEPTED_VALUES));
$encodeAcceptedValues = preg_replace("/\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", G::json_encode($VAR_ACCEPTED_VALUES));
} else {
$encodeAcceptedValues = $aRow['VAR_ACCEPTED_VALUES'];
}
@@ -407,7 +390,7 @@ class Variable
//Return
return $arrayVariables;
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -416,7 +399,8 @@ class Variable
* Verify field definition
*
* @param array $aData Unique id of Variable to exclude
*
* @return void
* @throws Exception
*/
public function throwExceptionFieldDefinition($aData)
{
@@ -428,10 +412,6 @@ class Variable
if (isset($aData["VAR_FIELD_TYPE"])) {
Validator::isString($aData['VAR_FIELD_TYPE'], '$var_field_type');
Validator::isNotEmpty($aData['VAR_FIELD_TYPE'], '$var_field_type');
/*if ($aData["VAR_FIELD_TYPE"] != 'string' && $aData["VAR_FIELD_TYPE"] != 'integer' && $aData["VAR_FIELD_TYPE"] != 'boolean' && $aData["VAR_FIELD_TYPE"] != 'float' &&
$aData["VAR_FIELD_TYPE"] != 'datetime' && $aData["VAR_FIELD_TYPE"] != 'date_of_birth' && $aData["VAR_FIELD_TYPE"] != 'date') {
throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('$var_field_type')));
}*/
}
if (isset($aData["VAR_FIELD_SIZE"])) {
Validator::isInteger($aData["VAR_FIELD_SIZE"], '$var_field_size');
@@ -449,10 +429,10 @@ class Variable
if (isset($aData["VAR_NULL"])) {
Validator::isInteger($aData['VAR_NULL'], '$var_null');
if ($aData["VAR_NULL"] != 0 && $aData["VAR_NULL"] !=1 ) {
throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_ONLY_ACCEPTS_VALUES", array('$var_null','0, 1' )));
throw new Exception(G::LoadTranslation("ID_INVALID_VALUE_ONLY_ACCEPTS_VALUES", array('$var_null','0, 1' )));
}
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -460,8 +440,10 @@ class Variable
/**
* Verify if exists the name of a variable
*
* @param string $processUid Unique id of Process
* @param string $variableName Name
* @param string $processUid, unique id of Process
* @param string $variableName, name of variable
* @param string $variableUidToExclude
* @throws Exception
*
*/
public function existsName($processUid, $variableName, $variableUidToExclude = "")
@@ -471,25 +453,23 @@ class Variable
$criteria->addSelectColumn(\ProcessVariablesPeer::VAR_UID);
$criteria->addSelectColumn(\ProcessVariablesPeer::VAR_NAME);
if ($variableUidToExclude != "") {
$criteria->add(\ProcessVariablesPeer::VAR_UID, $variableUidToExclude, \Criteria::NOT_EQUAL);
}
$criteria->add(\ProcessVariablesPeer::VAR_NAME, $variableName, \Criteria::EQUAL);
$criteria->add(\ProcessVariablesPeer::PRJ_UID, $processUid, \Criteria::EQUAL);
$rsCriteria = \ProcessVariablesPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
if ($variableName == $row["VAR_NAME"]) {
throw new \Exception(\G::LoadTranslation("DYNAFIELD_ALREADY_EXIST"));
if ($variableName === $row["VAR_NAME"]) {
throw new Exception(G::LoadTranslation("DYNAFIELD_ALREADY_EXIST"));
}
if (AdditionalTables::getPHPName($variableName) === AdditionalTables::getPHPName($row["VAR_NAME"])) {
throw new Exception(G::LoadTranslation("DYNAFIELD_PHPNAME_ALREADY_EXIST", array($row["VAR_NAME"])));
}
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -499,21 +479,20 @@ class Variable
*
* @param string $sql SQL
*
* return array Return an array with required variables in the SQL
* @return array, return an array with required variables in the SQL
* @throws Exception
*/
public function sqlGetRequiredVariables($sql)
{
try {
$arrayVariableRequired = array();
preg_match_all("/@[@%#\?\x24\=]([A-Za-z_]\w*)/", $sql, $arrayMatch, PREG_SET_ORDER);
foreach ($arrayMatch as $value) {
$arrayVariableRequired[] = $value[1];
}
return $arrayVariableRequired;
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -525,17 +504,17 @@ class Variable
* @param string $variableSql SQL
* @param array $arrayVariable The variables
*
* return void Throw exception if some required variable in the SQL is missing in the variables
* @return void Throw exception if some required variable in the SQL is missing in the variables
* @throws Exception
*/
public function throwExceptionIfSomeRequiredVariableSqlIsMissingInVariables($variableName, $variableSql, array $arrayVariable)
{
try {
$arrayResult = array_diff(array_unique($this->sqlGetRequiredVariables($variableSql)), array_keys($arrayVariable));
if (count($arrayResult) > 0) {
throw new \Exception(\G::LoadTranslation("ID_PROCESS_VARIABLE_REQUIRED_VARIABLES_FOR_QUERY", array($variableName, implode(", ", $arrayResult))));
throw new Exception(G::LoadTranslation("ID_PROCESS_VARIABLE_REQUIRED_VARIABLES_FOR_QUERY", array($variableName, implode(", ", $arrayResult))));
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -547,13 +526,14 @@ class Variable
* @param string $variableName Variable name
* @param array $arrayVariable The variables
*
* return array Return an array with all records
* @return array, return an array with all records
* @throws Exception
*/
public function executeSql($processUid, $variableName, array $arrayVariable = array())
{
try {
return $this->executeSqlControl($processUid, $arrayVariable);
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -563,7 +543,8 @@ class Variable
*
* @param string $variableUid Unique id of variable
*
* return void Throw exception if does not exist the variable in table PROCESS_VARIABLES
* @return void
* @throws Exception, throw exception if does not exist the variable in table PROCESS_VARIABLES
*/
public function throwExceptionIfNotExistsVariable($variableUid)
{
@@ -571,9 +552,9 @@ class Variable
$obj = \ProcessVariablesPeer::retrieveByPK($variableUid);
if (is_null($obj)) {
throw new \Exception('var_uid: '.$variableUid. ' '.\G::LoadTranslation("ID_DOES_NOT_EXIST"));
throw new Exception('var_uid: '.$variableUid. ' '.G::LoadTranslation("ID_DOES_NOT_EXIST"));
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -584,30 +565,25 @@ class Variable
* @param string $variableUid Unique id of variable
*
* @return void Throw exception
* @throws Exception
*/
public function throwExceptionIfVariableIsAssociatedAditionalTable($variableUid)
{
try {
$criteria = new \Criteria('workflow');
$criteria->addSelectColumn(\ProcessVariablesPeer::VAR_UID);
$criteria->addJoin(\ProcessVariablesPeer::PRJ_UID, \AdditionalTablesPeer::PRO_UID, \Criteria::INNER_JOIN);
$arrayCondition = [];
$arrayCondition[] = array(\AdditionalTablesPeer::ADD_TAB_UID, \FieldsPeer::ADD_TAB_UID, \Criteria::EQUAL);
$arrayCondition[] = array(\ProcessVariablesPeer::VAR_NAME, \FieldsPeer::FLD_NAME, \Criteria::EQUAL);
$criteria->addJoinMC($arrayCondition, \Criteria::INNER_JOIN);
$criteria->add(\ProcessVariablesPeer::VAR_UID, $variableUid, \Criteria::EQUAL);
$rsCriteria = \ProcessVariablesPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
if ($rsCriteria->next()) {
throw new \Exception(\G::LoadTranslation('ID_VARIABLE_ASSOCIATED_WITH_REPORT_TABLE', array($variableUid)));
throw new Exception(G::LoadTranslation('ID_VARIABLE_ASSOCIATED_WITH_REPORT_TABLE', array($variableUid)));
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -615,8 +591,10 @@ class Variable
/**
* Verify if the variable is being used in a Dynaform
*
* @param string $processUid Unique id of Process
* @param string $variableUid Unique id of Variable
* @param string $processUid, Unique id of Process
* @param string $variableUid, Unique id of Variable
* @return void
* @throws Exception
*
*/
public function verifyUse($processUid, $variableUid)
@@ -631,10 +609,8 @@ class Variable
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$contentDecode = \G::json_decode($row["DYN_CONTENT"], true);
$contentDecode = G::json_decode($row["DYN_CONTENT"], true);
$content = $contentDecode['items'][0]['items'];
if (is_array($content)) {
foreach ($content as $key => $value) {
@@ -649,14 +625,14 @@ class Variable
$rsCriteria->next();
if ($rsCriteria->getRow()) {
throw new \Exception(\G::LoadTranslation("ID_VARIABLE_IN_USE", array($variableUid, $row["DYN_UID"])));
throw new Exception(G::LoadTranslation("ID_VARIABLE_IN_USE", array($variableUid, $row["DYN_UID"])));
}
}
}
}
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -668,13 +644,14 @@ class Variable
* @param string $variableName Variable name
* @param array $arrayVariable The variables
*
* return array Return an array with all records
* @return array, return an array with all records
* @throws Exception
*/
public function executeSqlSuggest($processUid, $variableName, array $arrayVariable = array())
{
try {
return $this->executeSqlControl($processUid, $arrayVariable);
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -698,7 +675,7 @@ class Variable
return sizeof($row) ? $row : false;
}
return false;
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -712,7 +689,8 @@ class Variable
* @param bool $throwException Flag to throw the exception if the main parameters are invalid or do not exist
* (TRUE: throw the exception; FALSE: returns FALSE)
*
* @return array Returns an array with Variable record, ThrowTheException/FALSE otherwise
* @return array, returns an array with Variable record
* @throws Exception, ThrowTheException/FALSE otherwise
*/
public function getVariableRecordByName(
$projectUid,
@@ -722,20 +700,17 @@ class Variable
) {
try {
$criteria = new \Criteria('workflow');
$criteria->add(\ProcessVariablesPeer::PRJ_UID, $projectUid, \Criteria::EQUAL);
$criteria->add(\ProcessVariablesPeer::VAR_NAME, $variableName, \Criteria::EQUAL);
$rsCriteria = \ProcessVariablesPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
if ($rsCriteria->next()) {
$arrayVariableData = $rsCriteria->getRow();
} else {
if ($throwException) {
throw new \Exception(
throw new Exception(
$arrayVariableNameForException['$variableName'] . ': ' . $variableName. ' ' .
\G::LoadTranslation('ID_DOES_NOT_EXIST')
G::LoadTranslation('ID_DOES_NOT_EXIST')
);
} else {
return false;
@@ -744,7 +719,7 @@ class Variable
//Return
return $arrayVariableData;
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}
@@ -753,7 +728,7 @@ class Variable
{
$vType = strtolower($type);
if(!in_array($vType, $this->variableTypes)) {
throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED"));
throw new Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED"));
}
return $vType;
}
@@ -774,7 +749,7 @@ class Variable
* @param type $proUid
* @param array $params
* @return array
* @throws \Exception
* @throws Exception
*/
public function executeSqlControl($proUid, array $params = array())
{
@@ -829,7 +804,7 @@ class Variable
}
}
return $result;
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
}

View File

@@ -382,7 +382,7 @@ class WebEntry
$arrayUserData = $user->load($arrayWebEntryData["USR_UID"]);
$usrUsername = $arrayUserData["USR_USERNAME"];
$usrPassword = $arrayUserData["USR_PASSWORD"];
$usrPassword = $user->getUsrPassword();
$dynaForm = new \Dynaform();

View File

@@ -5,7 +5,7 @@ use ProcessMaker\Project;
class ProjectNotFound extends \RuntimeException
{
const EXCEPTION_CODE = 20;
const EXCEPTION_CODE = 400;
public function __construct(Project\Handler $obj, $uid, $message = "", \Exception $previous = null) {
$message = empty($message) ? sprintf("Project \"%s\" with UID: %s, does not exist.", get_class($obj), $uid) : $message;

View File

@@ -1,39 +1,36 @@
<?php
namespace ProcessMaker\Project;
use \BpmnProject as Project;
use \BpmnProcess as Process;
use \BpmnDiagram as Diagram;
use \BasePeer;
use \BpmnActivity as Activity;
use \BpmnBound as Bound;
use \BpmnEvent as Event;
use \BpmnGateway as Gateway;
use \BpmnFlow as Flow;
use \BpmnArtifact as Artifact;
use \BpmnProjectPeer as ProjectPeer;
use \BpmnProcessPeer as ProcessPeer;
use \BpmnDiagramPeer as DiagramPeer;
use \BpmnActivityPeer as ActivityPeer;
use \BpmnBoundPeer as BoundPeer;
use \BpmnEventPeer as EventPeer;
use \BpmnGatewayPeer as GatewayPeer;
use \BpmnFlowPeer as FlowPeer;
use \BpmnArtifactPeer as ArtifactPeer;
use \BpmnParticipant as Participant;
use \BpmnParticipantPeer as ParticipantPeer;
use \BpmnBound as Bound;
use \BpmnBoundPeer as BoundPeer;
use \BpmnDiagram as Diagram;
use \BpmnDiagramPeer as DiagramPeer;
use \BpmnEvent as Event;
use \BpmnEventPeer as EventPeer;
use \BpmnFlow as Flow;
use \BpmnFlowPeer as FlowPeer;
use \BpmnGateway as Gateway;
use \BpmnGatewayPeer as GatewayPeer;
use \BpmnLaneset as Laneset;
use \BpmnLanesetPeer as LanesetPeer;
use \BpmnLane as Lane;
use \BpmnLanePeer as LanePeer;
use \BasePeer;
use \BpmnParticipant as Participant;
use \BpmnParticipantPeer as ParticipantPeer;
use \BpmnProject as Project;
use \BpmnProcess as Process;
use \BpmnProjectPeer as ProjectPeer;
use \BpmnProcessPeer as ProcessPeer;
use \Criteria as Criteria;
use \Exception;
use \G;
use \ResultSet as ResultSet;
use ProcessMaker\Util\Common;
use ProcessMaker\Exception;
use \ProcessMaker\Util\Common;
/**
* Class Bpmn
@@ -428,9 +425,12 @@ class Bpmn extends Handler
self::log("Remove Activity: $actUid");
$activity = ActivityPeer::retrieveByPK($actUid);
$activity->delete();
//TODO if the activity was removed, the related flows to that activity must be removed
if (isset($activity)) {
$activity->delete();
Flow::removeAllRelated($actUid);
} else {
throw new Exception(G::LoadTranslation("ID_ACTIVITY_DOES_NOT_EXIST", array("act_uid", $actUid)));
}
self::log("Remove Activity Success!");
} catch (\Exception $e) {
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());

View File

@@ -1,8 +1,11 @@
<?php
namespace ProcessMaker\Services\Api\Project;
use \ProcessMaker\Services\Api;
use \Exception;
use \Luracast\Restler\RestException;
use \ProcessMaker\BusinessModel\Task;
use \ProcessMaker\Project\Adapter\BpmnWorkflow;
use \ProcessMaker\Services\Api;
/**
* Project\Activity Api Controller
@@ -136,22 +139,32 @@ class Activity extends Api
/**
* This method remove an activity and all related components
* @param string $prj_uid {@min 32} {@max 32}
* @param string $act_uid {@min 32} {@max 32}
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @return array
*
* @access protected
* @class AccessControl {@permission PM_FACTORY}
* @url DELETE /:prj_uid/activity/:act_uid
*/
public function doDeleteProjectActivity($prj_uid, $act_uid)
{
try {
$task = new \ProcessMaker\BusinessModel\Task();
$task->deleteTask($prj_uid, $act_uid);
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
$task = new Task();
$task->setFormatFieldNameInUppercase(false);
$task->setArrayParamException(array("taskUid" => "act_uid"));
$response = $task->hasPendingCases(array("act_uid" => $act_uid, "case_type" => "assigned"));
if ($response->result !== false) {
$project = new BpmnWorkflow();
$prj = $project->load($prj_uid);
$prj->removeActivity($act_uid);
} else {
throw new RestException(403, $response->message);
}
} catch (Exception $e) {
$resCode = $e->getCode() == 0 ? Api::STAT_APP_EXCEPTION : $e->getCode();
throw new RestException($resCode, $e->getMessage());
}
}
@@ -215,7 +228,7 @@ class Activity extends Api
$task->setFormatFieldNameInUppercase(false);
$task->setArrayParamException(array("taskUid" => "act_uid"));
$response = $task->getValidateSelfService($request_data);
$response = $task->hasPendingCases($request_data);
return $response;
} catch (\Exception $e) {