Merged in feature/HOR-3559 (pull request #5906)
Feature/HOR-3559 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use \G;
|
||||
use \UsersPeer;
|
||||
use \CasesPeer;
|
||||
use G;
|
||||
use UsersPeer;
|
||||
use CasesPeer;
|
||||
use AppDelegation;
|
||||
use Exception;
|
||||
use wsBase;
|
||||
use RBAC;
|
||||
|
||||
/**
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
@@ -25,7 +29,7 @@ class Cases
|
||||
{
|
||||
try {
|
||||
$this->formatFieldNameInUppercase = $flag;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -41,7 +45,7 @@ class Cases
|
||||
{
|
||||
try {
|
||||
return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -56,7 +60,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]
|
||||
));
|
||||
}
|
||||
@@ -86,7 +90,7 @@ class Cases
|
||||
if ($flag) {
|
||||
$this->throwExceptionCaseDoesNotExist($applicationUid, $fieldNameForException);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -121,7 +125,7 @@ class Cases
|
||||
|
||||
//Return
|
||||
return $obj->toArray(\BasePeer::TYPE_FIELDNAME);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -148,7 +152,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'],
|
||||
@@ -164,7 +168,7 @@ class Cases
|
||||
|
||||
//Return
|
||||
return $obj->toArray(\BasePeer::TYPE_FIELDNAME);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -208,7 +212,7 @@ class Cases
|
||||
|
||||
//Return
|
||||
return $arrayListCounter;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -461,11 +465,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'];
|
||||
@@ -525,15 +529,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'];
|
||||
@@ -591,7 +595,7 @@ class Cases
|
||||
//Return
|
||||
return $oResponse;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -620,7 +624,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
|
||||
@@ -628,8 +632,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);
|
||||
@@ -651,11 +655,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;
|
||||
}
|
||||
}
|
||||
@@ -674,19 +678,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'];
|
||||
@@ -699,7 +703,7 @@ class Cases
|
||||
$oResponse = json_decode(json_encode($array), false);
|
||||
//Return
|
||||
return $oResponse;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -718,7 +722,7 @@ class Cases
|
||||
{
|
||||
try {
|
||||
|
||||
$ws = new \wsBase();
|
||||
$ws = new wsBase();
|
||||
if ($variables) {
|
||||
$variables = array_shift($variables);
|
||||
} elseif ($variables == null) {
|
||||
@@ -727,17 +731,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'];
|
||||
@@ -750,7 +754,7 @@ class Cases
|
||||
$oResponse = json_decode(json_encode($array), false);
|
||||
//Return
|
||||
return $oResponse;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -770,24 +774,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;
|
||||
}
|
||||
}
|
||||
@@ -813,14 +817,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();
|
||||
@@ -839,7 +843,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 );
|
||||
@@ -867,7 +871,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');
|
||||
@@ -875,13 +879,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();
|
||||
@@ -903,7 +907,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) {
|
||||
@@ -933,14 +937,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();
|
||||
@@ -959,7 +963,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();
|
||||
@@ -970,39 +974,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1031,11 +1041,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();
|
||||
@@ -1056,26 +1066,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;
|
||||
@@ -1546,7 +1556,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
|
||||
@@ -1657,7 +1667,7 @@ class Cases
|
||||
|
||||
//Return
|
||||
return $caseVariable;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -1756,11 +1766,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();
|
||||
@@ -1776,7 +1786,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;
|
||||
@@ -1857,11 +1867,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') {
|
||||
@@ -1945,7 +1955,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');
|
||||
@@ -1953,11 +1963,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);
|
||||
@@ -1988,7 +1998,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;
|
||||
}
|
||||
}
|
||||
@@ -2256,7 +2266,7 @@ class Cases
|
||||
|
||||
//Return
|
||||
return $arrayTask;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -2334,7 +2344,7 @@ class Cases
|
||||
|
||||
//Return
|
||||
return $arrayData;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -2521,7 +2531,7 @@ class Cases
|
||||
|
||||
//Return
|
||||
return array();
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -2543,7 +2553,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()));
|
||||
}
|
||||
}
|
||||
@@ -2625,7 +2635,7 @@ class Cases
|
||||
}
|
||||
|
||||
return $processList;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -2808,7 +2818,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;
|
||||
}
|
||||
}
|
||||
@@ -3167,7 +3177,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'])) {
|
||||
@@ -3181,7 +3191,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');
|
||||
}
|
||||
}
|
||||
@@ -3245,7 +3255,7 @@ class Cases
|
||||
* @param array $appData
|
||||
* @param array $dataVariable
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getGlobalVariables($appData = array(), $dataVariable = array())
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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' );
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
use \G;
|
||||
use \Exception;
|
||||
use \Bootstrap;
|
||||
|
||||
class EmailServer
|
||||
{
|
||||
@@ -19,6 +22,8 @@ class EmailServer
|
||||
"MESS_DEFAULT" => array("type" => "int", "required" => false, "empty" => false, "defaultValues" => array(0, 1), "fieldNameAux" => "emailServerDefault")
|
||||
);
|
||||
|
||||
private $contextLog = array();
|
||||
|
||||
private $formatFieldNameInUppercase = true;
|
||||
|
||||
private $arrayFieldNameForException = array(
|
||||
@@ -37,17 +42,51 @@ class EmailServer
|
||||
foreach ($this->arrayFieldDefinition as $key => $value) {
|
||||
$this->arrayFieldNameForException[$value["fieldNameAux"]] = $key;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
|
||||
//Define the variables for the logging
|
||||
global $RBAC;
|
||||
$currentUser = $RBAC->aUserInfo['USER_INFO'];
|
||||
$info = array(
|
||||
'ip' => G::getIpAddress(),
|
||||
'workspace' => (defined("SYS_SYS"))? SYS_SYS : "Workspace undefined",
|
||||
'usrUid' => $currentUser['USR_UID']
|
||||
);
|
||||
$this->setContextLog($info);
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the $contextLog value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContextLog()
|
||||
{
|
||||
return $this->contextLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of $contextLog.
|
||||
*
|
||||
* @param array $k
|
||||
* @return void
|
||||
*/
|
||||
public function setContextLog($k)
|
||||
{
|
||||
$this->contextLog = array_merge($this->contextLog, $k);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the format of the fields name (uppercase, lowercase)
|
||||
*
|
||||
* @param bool $flag Value that set the format
|
||||
*
|
||||
* return void
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setFormatFieldNameInUppercase($flag)
|
||||
{
|
||||
@@ -55,7 +94,7 @@ class EmailServer
|
||||
$this->formatFieldNameInUppercase = $flag;
|
||||
|
||||
$this->setArrayFieldNameForException($this->arrayFieldNameForException);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -65,7 +104,8 @@ class EmailServer
|
||||
*
|
||||
* @param array $arrayData Data with the fields
|
||||
*
|
||||
* return void
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setArrayFieldNameForException(array $arrayData)
|
||||
{
|
||||
@@ -73,7 +113,7 @@ class EmailServer
|
||||
foreach ($arrayData as $key => $value) {
|
||||
$this->arrayFieldNameForException[$key] = $this->getFieldNameByFormatFieldName($value);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -83,13 +123,14 @@ class EmailServer
|
||||
*
|
||||
* @param string $fieldName Field name
|
||||
*
|
||||
* return string Return the field name according the format
|
||||
* @return string, return the field name according the format
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getFieldNameByFormatFieldName($fieldName)
|
||||
{
|
||||
try {
|
||||
return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -99,7 +140,8 @@ class EmailServer
|
||||
*
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return array Return array with result of send test mail
|
||||
* @return array, return array with result of send test mail
|
||||
* @throws Exception
|
||||
*/
|
||||
public function sendTestMail(array $arrayData)
|
||||
{
|
||||
@@ -117,20 +159,20 @@ class EmailServer
|
||||
"SMTPSecure" => (isset($arrayData["SMTPSecure"]))? $arrayData["SMTPSecure"] : "none"
|
||||
);
|
||||
|
||||
$sFrom = \G::buildFrom($aConfiguration);
|
||||
$sFrom = G::buildFrom($aConfiguration);
|
||||
|
||||
$sSubject = \G::LoadTranslation("ID_MESS_TEST_SUBJECT");
|
||||
$msg = \G::LoadTranslation("ID_MESS_TEST_BODY");
|
||||
$sSubject = G::LoadTranslation("ID_MESS_TEST_SUBJECT");
|
||||
$msg = G::LoadTranslation("ID_MESS_TEST_BODY");
|
||||
|
||||
switch ($arrayData["MESS_ENGINE"]) {
|
||||
case "MAIL":
|
||||
$engine = \G::LoadTranslation("ID_MESS_ENGINE_TYPE_1");
|
||||
$engine = G::LoadTranslation("ID_MESS_ENGINE_TYPE_1");
|
||||
break;
|
||||
case "PHPMAILER":
|
||||
$engine = \G::LoadTranslation("ID_MESS_ENGINE_TYPE_2");
|
||||
$engine = G::LoadTranslation("ID_MESS_ENGINE_TYPE_2");
|
||||
break;
|
||||
case "OPENMAIL":
|
||||
$engine = \G::LoadTranslation("ID_MESS_ENGINE_TYPE_3");
|
||||
$engine = G::LoadTranslation("ID_MESS_ENGINE_TYPE_3");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -175,7 +217,7 @@ class EmailServer
|
||||
if ($oSpool->status == "sent") {
|
||||
$arrayTestMailResult["status"] = true;
|
||||
$arrayTestMailResult["success"] = true;
|
||||
$arrayTestMailResult["msg"] = \G::LoadTranslation("ID_MAIL_TEST_SUCCESS");
|
||||
$arrayTestMailResult["msg"] = G::LoadTranslation("ID_MAIL_TEST_SUCCESS");
|
||||
} else {
|
||||
$arrayTestMailResult["status"] = false;
|
||||
$arrayTestMailResult["success"] = false;
|
||||
@@ -183,7 +225,7 @@ class EmailServer
|
||||
}
|
||||
|
||||
return $arrayTestMailResult;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -194,7 +236,8 @@ class EmailServer
|
||||
* @param array $arrayData Data
|
||||
* @param int $step Step
|
||||
*
|
||||
* return array Return array with result of test connection by step
|
||||
* @return array, return array with result of test connection by step
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testConnectionByStep(array $arrayData, $step = 0)
|
||||
{
|
||||
@@ -208,7 +251,7 @@ class EmailServer
|
||||
$eregMail = "/^[0-9a-zA-Z]+(?:[._][0-9a-zA-Z]+)*@[0-9a-zA-Z]+(?:[._-][0-9a-zA-Z]+)*\.[0-9a-zA-Z]{2,3}$/";
|
||||
|
||||
$arrayDataMail["FROM_EMAIL"] = ($arrayData["MESS_FROM_MAIL"] != "" && preg_match($eregMail, $arrayData["MESS_FROM_MAIL"]))? $arrayData["MESS_FROM_MAIL"] : "";
|
||||
$arrayDataMail["FROM_NAME"] = ($arrayData["MESS_FROM_NAME"] != "")? $arrayData["MESS_FROM_NAME"] : \G::LoadTranslation("ID_MESS_TEST_BODY");
|
||||
$arrayDataMail["FROM_NAME"] = ($arrayData["MESS_FROM_NAME"] != "")? $arrayData["MESS_FROM_NAME"] : G::LoadTranslation("ID_MESS_TEST_BODY");
|
||||
$arrayDataMail["MESS_ENGINE"] = "MAIL";
|
||||
$arrayDataMail["MESS_SERVER"] = "localhost";
|
||||
$arrayDataMail["MESS_PORT"] = 25;
|
||||
@@ -233,7 +276,7 @@ class EmailServer
|
||||
);
|
||||
|
||||
if ($arrayTestMailResult["status"] == false) {
|
||||
$arrayResult["message"] = \G::LoadTranslation("ID_SENDMAIL_NOT_INSTALLED");
|
||||
$arrayResult["message"] = G::LoadTranslation("ID_SENDMAIL_NOT_INSTALLED");
|
||||
}
|
||||
|
||||
//Return
|
||||
@@ -252,7 +295,7 @@ class EmailServer
|
||||
$passwdHide = "";
|
||||
}
|
||||
|
||||
$passwdDec = \G::decrypt($passwd,"EMAILENCRYPT");
|
||||
$passwdDec = G::decrypt($passwd,"EMAILENCRYPT");
|
||||
$auxPass = explode("hash:", $passwdDec);
|
||||
|
||||
if (count($auxPass) > 1) {
|
||||
@@ -378,7 +421,7 @@ class EmailServer
|
||||
$eregMail = "/^[0-9a-zA-Z]+(?:[._][0-9a-zA-Z]+)*@[0-9a-zA-Z]+(?:[._-][0-9a-zA-Z]+)*\.[0-9a-zA-Z]{2,3}$/";
|
||||
|
||||
$arrayDataPhpMailer["FROM_EMAIL"] = ($fromMail != "" && preg_match($eregMail, $fromMail))? $fromMail : "";
|
||||
$arrayDataPhpMailer["FROM_NAME"] = $arrayData["MESS_FROM_NAME"] != "" ? $arrayData["MESS_FROM_NAME"] : \G::LoadTranslation("ID_MESS_TEST_BODY");
|
||||
$arrayDataPhpMailer["FROM_NAME"] = $arrayData["MESS_FROM_NAME"] != "" ? $arrayData["MESS_FROM_NAME"] : G::LoadTranslation("ID_MESS_TEST_BODY");
|
||||
$arrayDataPhpMailer["MESS_ENGINE"] = "PHPMAILER";
|
||||
$arrayDataPhpMailer["MESS_SERVER"] = $server;
|
||||
$arrayDataPhpMailer["MESS_PORT"] = $port;
|
||||
@@ -421,7 +464,7 @@ class EmailServer
|
||||
|
||||
//Return
|
||||
return $arrayResult;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$arrayResult = array();
|
||||
|
||||
$arrayResult["result"] = false;
|
||||
@@ -437,7 +480,8 @@ class EmailServer
|
||||
*
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return array Return array with result of test connection
|
||||
* @return array, return array with result of test connection
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testConnection(array $arrayData)
|
||||
{
|
||||
@@ -467,11 +511,11 @@ class EmailServer
|
||||
$arrayDataAux["MAIL_TO"] = "admin@processmaker.com";
|
||||
|
||||
$arrayResult[$arrayMailTestName[1]] = $this->testConnectionByStep($arrayDataAux);
|
||||
$arrayResult[$arrayMailTestName[1]]["title"] = \G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_VERIFYING_MAIL");
|
||||
$arrayResult[$arrayMailTestName[1]]["title"] = G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_VERIFYING_MAIL");
|
||||
|
||||
if ((int)($arrayData["MESS_TRY_SEND_INMEDIATLY"]) == 1 && $arrayData['MAIL_TO'] != '') {
|
||||
$arrayResult[$arrayMailTestName[2]] = $this->testConnectionByStep($arrayData);
|
||||
$arrayResult[$arrayMailTestName[2]]["title"] = \G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_SENDING_EMAIL", array($arrayData["MAIL_TO"]));
|
||||
$arrayResult[$arrayMailTestName[2]]["title"] = G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_SENDING_EMAIL", array($arrayData["MAIL_TO"]));
|
||||
}
|
||||
break;
|
||||
case "PHPMAILER":
|
||||
@@ -482,19 +526,19 @@ class EmailServer
|
||||
|
||||
switch ($step) {
|
||||
case 1:
|
||||
$arrayResult[$arrayPhpMailerTestName[$step]]["title"] = \G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_RESOLVING_NAME", array($arrayData["MESS_SERVER"]));
|
||||
$arrayResult[$arrayPhpMailerTestName[$step]]["title"] = G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_RESOLVING_NAME", array($arrayData["MESS_SERVER"]));
|
||||
break;
|
||||
case 2:
|
||||
$arrayResult[$arrayPhpMailerTestName[$step]]["title"] = \G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_CHECK_PORT", array($arrayData["MESS_PORT"]));
|
||||
$arrayResult[$arrayPhpMailerTestName[$step]]["title"] = G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_CHECK_PORT", array($arrayData["MESS_PORT"]));
|
||||
break;
|
||||
case 3:
|
||||
$arrayResult[$arrayPhpMailerTestName[$step]]["title"] = \G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_ESTABLISHING_CON_HOST", array($arrayData["MESS_SERVER"] . ":" . $arrayData["MESS_PORT"]));
|
||||
$arrayResult[$arrayPhpMailerTestName[$step]]["title"] = G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_ESTABLISHING_CON_HOST", array($arrayData["MESS_SERVER"] . ":" . $arrayData["MESS_PORT"]));
|
||||
break;
|
||||
case 4:
|
||||
$arrayResult[$arrayPhpMailerTestName[$step]]["title"] = \G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_LOGIN", array($arrayData["MESS_ACCOUNT"], $arrayData["MESS_SERVER"]));
|
||||
$arrayResult[$arrayPhpMailerTestName[$step]]["title"] = G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_LOGIN", array($arrayData["MESS_ACCOUNT"], $arrayData["MESS_SERVER"]));
|
||||
break;
|
||||
case 5:
|
||||
$arrayResult[$arrayPhpMailerTestName[$step]]["title"] = \G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_SENDING_EMAIL", array($arrayData["MAIL_TO"]));
|
||||
$arrayResult[$arrayPhpMailerTestName[$step]]["title"] = G::LoadTranslation("ID_EMAIL_SERVER_TEST_CONNECTION_SENDING_EMAIL", array($arrayData["MAIL_TO"]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -503,7 +547,7 @@ class EmailServer
|
||||
|
||||
//Result
|
||||
return $arrayResult;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -513,7 +557,8 @@ class EmailServer
|
||||
*
|
||||
* @param string $emailServerUid Unique id of Email Server
|
||||
*
|
||||
* return bool Return true if is default Email Server, false otherwise
|
||||
* @return bool, return true if is default Email Server, false otherwise
|
||||
* @throws Exception
|
||||
*/
|
||||
public function checkIfIsDefault($emailServerUid)
|
||||
{
|
||||
@@ -530,7 +575,7 @@ class EmailServer
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -541,7 +586,8 @@ class EmailServer
|
||||
* @param string $emailServerUid Unique id of Email Server
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return void Throw exception if data has an invalid value
|
||||
* @return void Throw exception if data has an invalid value
|
||||
* @throws Exception
|
||||
*/
|
||||
public function throwExceptionIfDataIsInvalid($emailServerUid, array $arrayData)
|
||||
{
|
||||
@@ -609,10 +655,10 @@ class EmailServer
|
||||
}
|
||||
|
||||
if ($msg != "") {
|
||||
throw new \Exception($msg);
|
||||
throw new Exception($msg);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -623,7 +669,8 @@ class EmailServer
|
||||
* @param string $emailServerUid Unique id of Email Server
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if does not exist the Email Server in table EMAIL_SERVER
|
||||
* @return void Throw exception if does not exist the Email Server in table EMAIL_SERVER
|
||||
* @throws Exception
|
||||
*/
|
||||
public function throwExceptionIfNotExistsEmailServer($emailServerUid, $fieldNameForException)
|
||||
{
|
||||
@@ -631,9 +678,9 @@ class EmailServer
|
||||
$obj = \EmailServerPeer::retrieveByPK($emailServerUid);
|
||||
|
||||
if (is_null($obj)) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_EMAIL_SERVER_DOES_NOT_EXIST", array($fieldNameForException, $emailServerUid)));
|
||||
throw new Exception(G::LoadTranslation("ID_EMAIL_SERVER_DOES_NOT_EXIST", array($fieldNameForException, $emailServerUid)));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -644,15 +691,16 @@ class EmailServer
|
||||
* @param string $emailServerUid Unique id of Email Server
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if is default Email Server
|
||||
* @return void Throw exception if is default Email Server
|
||||
* @throws Exception
|
||||
*/
|
||||
public function throwExceptionIfIsDefault($emailServerUid, $fieldNameForException)
|
||||
{
|
||||
try {
|
||||
if ($this->checkIfIsDefault($emailServerUid)) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_EMAIL_SERVER_IS_DEFAULT", array($fieldNameForException, $emailServerUid)));
|
||||
throw new Exception(G::LoadTranslation("ID_EMAIL_SERVER_IS_DEFAULT", array($fieldNameForException, $emailServerUid)));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -662,7 +710,8 @@ class EmailServer
|
||||
*
|
||||
* @param string $emailServerUid Unique id of Email Server
|
||||
*
|
||||
* return void
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setEmailServerDefaultByUid($emailServerUid)
|
||||
{
|
||||
@@ -703,7 +752,8 @@ class EmailServer
|
||||
*
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return array Return data of the new Email Server created
|
||||
* @return array, data of the new Email Server created
|
||||
* @throws Exception
|
||||
*/
|
||||
public function create(array $arrayData)
|
||||
{
|
||||
@@ -729,7 +779,7 @@ class EmailServer
|
||||
$emailServer = new \EmailServer();
|
||||
|
||||
$passwd = $arrayData["MESS_PASSWORD"];
|
||||
$passwdDec = \G::decrypt($passwd, "EMAILENCRYPT");
|
||||
$passwdDec = G::decrypt($passwd, "EMAILENCRYPT");
|
||||
$auxPass = explode("hash:", $passwdDec);
|
||||
|
||||
if (count($auxPass) > 1) {
|
||||
@@ -745,7 +795,7 @@ class EmailServer
|
||||
|
||||
if ($arrayData["MESS_PASSWORD"] != "") {
|
||||
$arrayData["MESS_PASSWORD"] = "hash:" . $arrayData["MESS_PASSWORD"];
|
||||
$arrayData["MESS_PASSWORD"] = \G::encrypt($arrayData["MESS_PASSWORD"], "EMAILENCRYPT");
|
||||
$arrayData["MESS_PASSWORD"] = G::encrypt($arrayData["MESS_PASSWORD"], "EMAILENCRYPT");
|
||||
}
|
||||
|
||||
$emailServer->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME);
|
||||
@@ -765,7 +815,28 @@ class EmailServer
|
||||
$this->setEmailServerDefaultByUid($emailServerUid);
|
||||
}
|
||||
|
||||
//Return
|
||||
//Logging the create action
|
||||
$info = array(
|
||||
'action' => 'Create email server',
|
||||
'messUid'=> $emailServerUid,
|
||||
'engine'=> $arrayData["MESS_ENGINE"],
|
||||
'server' => $arrayData["MESS_SERVER"],
|
||||
'port' => $arrayData["MESS_PORT"],
|
||||
'requireAuthentication' => $arrayData["MESS_RAUTH"],
|
||||
'account' => $arrayData["MESS_ACCOUNT"],
|
||||
'senderEmail' => $arrayData["MESS_FROM_MAIL"],
|
||||
'senderName' => $arrayData["MESS_FROM_NAME"],
|
||||
'useSecureConnection' => $arrayData["SMTPSECURE"],
|
||||
'sendTestEmail' => $arrayData["MESS_TRY_SEND_INMEDIATLY"],
|
||||
'setAsDefaultConfiguration' => $arrayData["MESS_DEFAULT"]
|
||||
);
|
||||
$this->setContextLog($info);
|
||||
$this->syslog(
|
||||
'CreateEmailServer',
|
||||
200,
|
||||
'New email server was created',
|
||||
$this->getContextLog()
|
||||
);
|
||||
return $this->getEmailServer($emailServerUid);
|
||||
} else {
|
||||
$msg = "";
|
||||
@@ -774,14 +845,14 @@ class EmailServer
|
||||
$msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage();
|
||||
}
|
||||
|
||||
throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : ""));
|
||||
throw new Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : ""));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$cnn->rollback();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -791,7 +862,8 @@ class EmailServer
|
||||
*
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return array Return data of the new Email Server created
|
||||
* @return array, return data of the new Email Server created
|
||||
* @throws Exception
|
||||
*/
|
||||
public function create2(array $arrayData)
|
||||
{
|
||||
@@ -828,14 +900,14 @@ class EmailServer
|
||||
$msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage();
|
||||
}
|
||||
|
||||
throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : ""));
|
||||
throw new Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : ""));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$cnn->rollback();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -846,7 +918,8 @@ class EmailServer
|
||||
* @param string $emailServerUid Unique id of Group
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return array Return data of the Email Server updated
|
||||
* @return array Return data of the Email Server updated
|
||||
* @throws Exception
|
||||
*/
|
||||
public function update($emailServerUid, $arrayData)
|
||||
{
|
||||
@@ -874,7 +947,7 @@ class EmailServer
|
||||
|
||||
if (isset($arrayData['MESS_PASSWORD'])) {
|
||||
$passwd = $arrayData['MESS_PASSWORD'];
|
||||
$passwdDec = \G::decrypt($passwd, 'EMAILENCRYPT');
|
||||
$passwdDec = G::decrypt($passwd, 'EMAILENCRYPT');
|
||||
$auxPass = explode('hash:', $passwdDec);
|
||||
|
||||
if (count($auxPass) > 1) {
|
||||
@@ -890,7 +963,7 @@ class EmailServer
|
||||
|
||||
if ($arrayData['MESS_PASSWORD'] != '') {
|
||||
$arrayData['MESS_PASSWORD'] = 'hash:' . $arrayData['MESS_PASSWORD'];
|
||||
$arrayData['MESS_PASSWORD'] = \G::encrypt($arrayData['MESS_PASSWORD'], 'EMAILENCRYPT');
|
||||
$arrayData['MESS_PASSWORD'] = G::encrypt($arrayData['MESS_PASSWORD'], 'EMAILENCRYPT');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -912,6 +985,29 @@ class EmailServer
|
||||
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
||||
}
|
||||
|
||||
//Logging the update action
|
||||
$info = array(
|
||||
'action' => 'Update email server',
|
||||
'messUid' => $emailServerUid,
|
||||
'engine' => $arrayData["MESS_ENGINE"],
|
||||
'server' => $arrayData["MESS_SERVER"],
|
||||
'port' => $arrayData["MESS_PORT"],
|
||||
'requireAuthentication' => $arrayData["MESS_RAUTH"],
|
||||
'account' => $arrayData["MESS_ACCOUNT"],
|
||||
'senderEmail' => $arrayData["MESS_FROM_MAIL"],
|
||||
'senderName' => $arrayData["MESS_FROM_NAME"],
|
||||
'useSecureConnection' => $arrayData["SMTPSECURE"],
|
||||
'sendTestEmail' => $arrayData["MESS_TRY_SEND_INMEDIATLY"],
|
||||
'setAsDefaultConfiguration' => $arrayData["MESS_DEFAULT"]
|
||||
);
|
||||
$this->setContextLog($info);
|
||||
$this->syslog(
|
||||
'UpdateEmailServer',
|
||||
200,
|
||||
'The email server was updated',
|
||||
$this->getContextLog()
|
||||
);
|
||||
|
||||
return $arrayData;
|
||||
} else {
|
||||
$msg = "";
|
||||
@@ -920,14 +1016,14 @@ class EmailServer
|
||||
$msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage();
|
||||
}
|
||||
|
||||
throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : ""));
|
||||
throw new Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : ""));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$cnn->rollback();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -937,22 +1033,32 @@ class EmailServer
|
||||
*
|
||||
* @param string $emailServerUid Unique id of Email Server
|
||||
*
|
||||
* return void
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function delete($emailServerUid)
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$this->throwExceptionIfNotExistsEmailServer($emailServerUid, $this->arrayFieldNameForException["emailServerUid"]);
|
||||
|
||||
$this->throwExceptionIfIsDefault($emailServerUid, $this->arrayFieldNameForException["emailServerUid"]);
|
||||
|
||||
$criteria = $this->getEmailServerCriteria();
|
||||
|
||||
$criteria->add(\EmailServerPeer::MESS_UID, $emailServerUid, \Criteria::EQUAL);
|
||||
|
||||
\EmailServerPeer::doDelete($criteria);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
//Logging the delete action
|
||||
$info = array(
|
||||
'action' => 'Delete email server',
|
||||
'messUid' => $emailServerUid
|
||||
);
|
||||
$this->setContextLog($info);
|
||||
$this->syslog(
|
||||
'DeleteEmailServer',
|
||||
200,
|
||||
'The email server was deleted',
|
||||
$this->getContextLog()
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -982,7 +1088,7 @@ class EmailServer
|
||||
$criteria->addSelectColumn(\EmailServerPeer::MESS_DEFAULT);
|
||||
|
||||
return $criteria;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -992,7 +1098,8 @@ class EmailServer
|
||||
*
|
||||
* @param array $record Record
|
||||
*
|
||||
* return array Return an array with data Email Server
|
||||
* @return array, return an array with data Email Server
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getEmailServerDataFromRecord(array $record)
|
||||
{
|
||||
@@ -1016,7 +1123,7 @@ class EmailServer
|
||||
$this->getFieldNameByFormatFieldName("MESS_EXECUTE_EVERY") => '',
|
||||
$this->getFieldNameByFormatFieldName("MESS_SEND_MAX") => ''
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -1064,7 +1171,7 @@ class EmailServer
|
||||
|
||||
//Return
|
||||
return $arrayData;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -1078,7 +1185,8 @@ class EmailServer
|
||||
* @param int $start Start
|
||||
* @param int $limit Limit
|
||||
*
|
||||
* return array Return an array with all Email Servers
|
||||
* @return array, return an array with all Email Servers
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getEmailServers($arrayFilterData = null, $sortField = null, $sortDir = null, $start = null, $limit = null)
|
||||
{
|
||||
@@ -1101,10 +1209,10 @@ class EmailServer
|
||||
if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]) && trim($arrayFilterData["filter"]) != "") {
|
||||
$criteria->add(
|
||||
$criteria->getNewCriterion(\EmailServerPeer::MESS_ENGINE, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE)->addOr(
|
||||
$criteria->getNewCriterion(\EmailServerPeer::MESS_SERVER, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE))->addOr(
|
||||
$criteria->getNewCriterion(\EmailServerPeer::MESS_ACCOUNT, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE))->addOr(
|
||||
$criteria->getNewCriterion(\EmailServerPeer::MESS_FROM_NAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE))->addOr(
|
||||
$criteria->getNewCriterion(\EmailServerPeer::SMTPSECURE, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE))
|
||||
$criteria->getNewCriterion(\EmailServerPeer::MESS_SERVER, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE))->addOr(
|
||||
$criteria->getNewCriterion(\EmailServerPeer::MESS_ACCOUNT, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE))->addOr(
|
||||
$criteria->getNewCriterion(\EmailServerPeer::MESS_FROM_NAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE))->addOr(
|
||||
$criteria->getNewCriterion(\EmailServerPeer::SMTPSECURE, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1156,7 +1264,7 @@ class EmailServer
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
$passwd = $row["MESS_PASSWORD"];
|
||||
$passwdDec = \G::decrypt($passwd, "EMAILENCRYPT");
|
||||
$passwdDec = G::decrypt($passwd, "EMAILENCRYPT");
|
||||
$auxPass = explode("hash:", $passwdDec);
|
||||
|
||||
if (count($auxPass) > 1) {
|
||||
@@ -1181,7 +1289,7 @@ class EmailServer
|
||||
"filter" => (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]))? $arrayFilterData["filter"] : "",
|
||||
"data" => $arrayEmailServer
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -1192,7 +1300,8 @@ class EmailServer
|
||||
* @param string $emailServerUid Unique id of Email Server
|
||||
* @param bool $flagGetRecord Value that set the getting
|
||||
*
|
||||
* return array Return an array with data of a Email Server
|
||||
* @return array, return an array with data of a Email Server
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getEmailServer($emailServerUid, $flagGetRecord = false)
|
||||
{
|
||||
@@ -1224,7 +1333,7 @@ class EmailServer
|
||||
|
||||
//Return
|
||||
return (!$flagGetRecord)? $this->getEmailServerDataFromRecord($row) : $row;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -1246,5 +1355,31 @@ class EmailServer
|
||||
$rsCriteria->next();
|
||||
return $rsCriteria->getRow();
|
||||
}
|
||||
|
||||
/**
|
||||
* Logging information related to the email server
|
||||
* When the user create, update, delete the email server
|
||||
*
|
||||
* @param string $channel
|
||||
* @param string $level
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
private function syslog(
|
||||
$channel,
|
||||
$level,
|
||||
$message,
|
||||
$context = array()
|
||||
)
|
||||
{
|
||||
try {
|
||||
Bootstrap::registerMonolog($channel, $level, $message, $context, $context['workspace'], 'processmaker.log');
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use G;
|
||||
use Criteria;
|
||||
use DynaformHandler;
|
||||
|
||||
class Process
|
||||
{
|
||||
@@ -1686,7 +1687,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
|
||||
@@ -1739,7 +1740,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
|
||||
@@ -1785,7 +1786,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();
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -1894,7 +1894,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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user