Merge remote-tracking branch 'upstream/3.0.1.8' into 3.0.1.7-Gmail
This commit is contained in:
@@ -45,6 +45,21 @@ class Cases
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw the exception "The Case doesn't exist"
|
||||
*
|
||||
* @param string $applicationUid Unique id of Case
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function throwExceptionCaseDoesNotExist($applicationUid, $fieldNameForException)
|
||||
{
|
||||
throw new \Exception(\G::LoadTranslation(
|
||||
'ID_CASE_DOES_NOT_EXIST2', [$fieldNameForException, $applicationUid]
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if does not exist the Case in table APPLICATION
|
||||
*
|
||||
@@ -68,13 +83,91 @@ class Cases
|
||||
}
|
||||
|
||||
if ($flag) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_CASE_DOES_NOT_EXIST2", array($fieldNameForException, $applicationUid)));
|
||||
$this->throwExceptionCaseDoesNotExist($applicationUid, $fieldNameForException);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Application record
|
||||
*
|
||||
* @param string $applicationUid Unique id of Case
|
||||
* @param array $arrayVariableNameForException Variable name for exception
|
||||
* @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 Application record, ThrowTheException/FALSE otherwise
|
||||
*/
|
||||
public function getApplicationRecordByPk(
|
||||
$applicationUid,
|
||||
array $arrayVariableNameForException,
|
||||
$throwException = true
|
||||
) {
|
||||
try {
|
||||
$obj = \ApplicationPeer::retrieveByPK($applicationUid);
|
||||
|
||||
if (is_null($obj)) {
|
||||
if ($throwException) {
|
||||
$this->throwExceptionCaseDoesNotExist(
|
||||
$applicationUid, $arrayVariableNameForException['$applicationUid']
|
||||
);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Return
|
||||
return $obj->toArray(\BasePeer::TYPE_FIELDNAME);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get AppDelegation record
|
||||
*
|
||||
* @param string $applicationUid Unique id of Case
|
||||
* @param int $delIndex Delegation index
|
||||
* @param array $arrayVariableNameForException Variable name for exception
|
||||
* @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 AppDelegation record, ThrowTheException/FALSE otherwise
|
||||
*/
|
||||
public function getAppDelegationRecordByPk(
|
||||
$applicationUid,
|
||||
$delIndex,
|
||||
array $arrayVariableNameForException,
|
||||
$throwException = true
|
||||
) {
|
||||
try {
|
||||
$obj = \AppDelegationPeer::retrieveByPK($applicationUid, $delIndex);
|
||||
|
||||
if (is_null($obj)) {
|
||||
if ($throwException) {
|
||||
throw new \Exception(\G::LoadTranslation(
|
||||
'ID_CASE_DEL_INDEX_DOES_NOT_EXIST',
|
||||
[
|
||||
$arrayVariableNameForException['$applicationUid'],
|
||||
$applicationUid,
|
||||
$arrayVariableNameForException['$delIndex'],
|
||||
$delIndex
|
||||
]
|
||||
));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Return
|
||||
return $obj->toArray(\BasePeer::TYPE_FIELDNAME);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list counters
|
||||
*
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -268,6 +268,21 @@ class DynaForm
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw the exception "The DynaForm doesn't exist"
|
||||
*
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function throwExceptionDynaFormDoesNotExist($dynaFormUid, $fieldNameForException)
|
||||
{
|
||||
throw new \Exception(\G::LoadTranslation(
|
||||
'ID_DYNAFORM_DOES_NOT_EXIST', [$fieldNameForException, $dynaFormUid]
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if doesn't exists the DynaForm in table DYNAFORM
|
||||
*
|
||||
@@ -293,7 +308,7 @@ class DynaForm
|
||||
$rsCriteria = \DynaformPeer::doSelectRS($criteria);
|
||||
|
||||
if (!$rsCriteria->next()) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_DYNAFORM_DOES_NOT_EXIST", array($fieldNameForException, $dynaFormUid)));
|
||||
$this->throwExceptionDynaFormDoesNotExist($dynaFormUid, $fieldNameForException);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
@@ -345,6 +360,38 @@ class DynaForm
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get DynaForm record
|
||||
*
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
* @param array $arrayVariableNameForException Variable name for exception
|
||||
* @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 DynaForm record, ThrowTheException/FALSE otherwise
|
||||
*/
|
||||
public function getDynaFormRecordByPk($dynaFormUid, array $arrayVariableNameForException, $throwException = true)
|
||||
{
|
||||
try {
|
||||
$obj = \DynaformPeer::retrieveByPK($dynaFormUid);
|
||||
|
||||
if (is_null($obj)) {
|
||||
if ($throwException) {
|
||||
$this->throwExceptionDynaFormDoesNotExist(
|
||||
$dynaFormUid, $arrayVariableNameForException['$dynaFormUid']
|
||||
);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Return
|
||||
return $obj->toArray(\BasePeer::TYPE_FIELDNAME);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create DynaForm for a Process
|
||||
*
|
||||
@@ -553,7 +600,7 @@ class DynaForm
|
||||
$this->throwExceptionIfNotExistsDynaForm($dynaFormUidCopyImport, $processUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.DYN_UID"));
|
||||
|
||||
//Copy/Import
|
||||
|
||||
|
||||
//Copy content if version is 2
|
||||
if ($arrayData["DYN_VERSION"] === 2) {
|
||||
$dynaFormOld = new \Dynaform();
|
||||
@@ -562,7 +609,7 @@ class DynaForm
|
||||
|
||||
$arrayData["DYN_CONTENT"] = $arrayDynaFormData["DYN_CONTENT"];
|
||||
}
|
||||
|
||||
|
||||
//Create
|
||||
$arrayData = $this->create($processUid, $arrayData);
|
||||
|
||||
@@ -976,7 +1023,7 @@ class DynaForm
|
||||
if ($record["DYN_VERSION"] == 0) {
|
||||
$record["DYN_VERSION"] = 1;
|
||||
}
|
||||
|
||||
|
||||
$record["DYN_CONTENT"] = preg_replace("/\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", $record["DYN_CONTENT"]);
|
||||
|
||||
return array(
|
||||
@@ -1147,7 +1194,7 @@ class DynaForm
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get data of a DynaForm History
|
||||
*
|
||||
|
||||
193
workflow/engine/src/ProcessMaker/BusinessModel/DynaForm/Grid.php
Normal file
193
workflow/engine/src/ProcessMaker/BusinessModel/DynaForm/Grid.php
Normal file
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
namespace ProcessMaker\BusinessModel\DynaForm;
|
||||
|
||||
use \ProcessMaker\BusinessModel\Util\Attribute;
|
||||
|
||||
class Grid extends Attribute
|
||||
{
|
||||
private $runningWorkflow = true;
|
||||
|
||||
private $arrayFieldDefinition = [];
|
||||
|
||||
private $arrayFieldNameForException = [];
|
||||
|
||||
private $arrayVariableNameForException = [
|
||||
'$projectUid',
|
||||
'$dynaFormUid',
|
||||
'$gridName',
|
||||
'$fieldId'
|
||||
];
|
||||
|
||||
/**
|
||||
* Constructor of the class
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
try {
|
||||
parent::__construct(
|
||||
$this->runningWorkflow, $this->arrayFieldDefinition, $this->arrayVariableNameForException
|
||||
);
|
||||
|
||||
$this->arrayFieldNameForException = $this->getArrayFieldNameForException();
|
||||
$this->arrayVariableNameForException = $this->getArrayVariableNameForException();
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set runningWorkflow atributte
|
||||
*
|
||||
* @param bool $flag
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setRunningWorkflow($flag)
|
||||
{
|
||||
try {
|
||||
parent::setRunningWorkflow($flag);
|
||||
|
||||
$this->runningWorkflow = $flag;
|
||||
|
||||
$this->arrayFieldNameForException = $this->getArrayFieldNameForException();
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set arrayVariableNameForException atributte by data
|
||||
*
|
||||
* @param array $arrayData
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setArrayVariableNameForException(array $arrayData)
|
||||
{
|
||||
try {
|
||||
foreach ($arrayData as $key => $value) {
|
||||
$this->arrayVariableNameForException[$key] = $value;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fields of a Grid
|
||||
*
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
* @param string $gridName Grid name (Variable name)
|
||||
* @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 Fields of a Grid, ThrowTheException/FALSE otherwise
|
||||
*/
|
||||
public function getGridFieldDefinitions($dynaFormUid, $gridName, $throwException = true)
|
||||
{
|
||||
try {
|
||||
//Verify data and Set variables
|
||||
$dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
|
||||
|
||||
$arrayDynaFormData = $dynaForm->getDynaFormRecordByPk(
|
||||
$dynaFormUid, $this->arrayVariableNameForException, $throwException
|
||||
);
|
||||
|
||||
if ($arrayDynaFormData === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Get data
|
||||
$dynaFormContent = \G::json_decode($arrayDynaFormData['DYN_CONTENT']);
|
||||
|
||||
$arrayGridField = [];
|
||||
$flagFound = false;
|
||||
|
||||
foreach ($dynaFormContent->items[0]->items as $value) {
|
||||
$arrayField = $value;
|
||||
|
||||
foreach ($arrayField as $value2) {
|
||||
$fld = $value2;
|
||||
|
||||
if ($fld->type == 'grid' && $fld->variable == $gridName) {
|
||||
$arrayGridField = $fld->columns;
|
||||
$flagFound = true;
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$flagFound) {
|
||||
if ($throwException) {
|
||||
throw new \Exception(\G::LoadTranslation(
|
||||
'ID_GRID_DOES_NOT_EXIST_IN_DYNAFORM',
|
||||
[$this->arrayVariableNameForException['$gridName'], $gridName]
|
||||
));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Return
|
||||
return $arrayGridField;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Field of a Grid
|
||||
*
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
* @param string $gridName Grid name (Variable name)
|
||||
* @param string $fieldId Field id
|
||||
* @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 Field of a Grid, ThrowTheException/FALSE otherwise
|
||||
*/
|
||||
public function getGridFieldDefinition($dynaFormUid, $gridName, $fieldId, $throwException = true)
|
||||
{
|
||||
try {
|
||||
//Verify data and Set variables
|
||||
$arrayGridField = $this->getGridFieldDefinitions($dynaFormUid, $gridName, $throwException);
|
||||
|
||||
if ($arrayGridField === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Get data
|
||||
$field = null;
|
||||
$flagFound = false;
|
||||
|
||||
foreach ($arrayGridField as $value) {
|
||||
$fld = $value;
|
||||
|
||||
if ($fld->id == $fieldId) {
|
||||
$field = $fld;
|
||||
$flagFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$flagFound) {
|
||||
if ($throwException) {
|
||||
throw new \Exception(\G::LoadTranslation(
|
||||
'ID_GRID_FIELD_DOES_NOT_EXIST',
|
||||
[$this->arrayVariableNameForException['$fieldId'], $fieldId]
|
||||
));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Return
|
||||
return $field;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,12 +325,12 @@ class Process
|
||||
public function throwExceptionIfDataNotMetPagerVarDefinition($arrayData, $arrayFieldNameForException)
|
||||
{
|
||||
try {
|
||||
foreach ($arrayData as $key => $value) {
|
||||
$nameForException = (isset($arrayFieldNameForException[$key]))? $arrayFieldNameForException[$key] : $key;
|
||||
$result = \ProcessMaker\BusinessModel\Validator::validatePagerDataByPagerDefinition(
|
||||
$arrayData, $arrayFieldNameForException
|
||||
);
|
||||
|
||||
if (!is_null($value) && ($value . "" == "" || !preg_match("/^(?:\+|\-)?(?:0|[1-9]\d*)$/", $value . "") || (int)($value) < 0)) {
|
||||
throw new \Exception(\G::LoadTranslation('ID_INVALID_VALUE_EXPECTING_POSITIVE_INTEGER', [$nameForException]));
|
||||
}
|
||||
if ($result !== true) {
|
||||
throw new \Exception($result);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
namespace ProcessMaker\BusinessModel\Util;
|
||||
|
||||
class Attribute
|
||||
{
|
||||
private $runningWorkflow = true;
|
||||
|
||||
private $arrayFieldDefinition = [];
|
||||
|
||||
private $arrayFieldNameForException = [];
|
||||
|
||||
private $arrayVariableNameForException = [];
|
||||
|
||||
/**
|
||||
* Constructor of the class
|
||||
*
|
||||
* @param bool $runningWorkflow
|
||||
* @param array $arrayFieldDefinition
|
||||
* @param array $arrayVariableNameForException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($runningWorkflow, array $arrayFieldDefinition, array $arrayVariableNameForException)
|
||||
{
|
||||
try {
|
||||
$this->runningWorkflow = $runningWorkflow;
|
||||
$this->arrayFieldDefinition = $arrayFieldDefinition;
|
||||
|
||||
foreach ($arrayFieldDefinition as $key => $value) {
|
||||
if (isset($value['fieldNameAux'])) {
|
||||
$this->arrayFieldNameForException[$value['fieldNameAux']] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($arrayVariableNameForException as $value) {
|
||||
$this->arrayVariableNameForException[$value] = $value;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set runningWorkflow atributte
|
||||
*
|
||||
* @param bool $flag
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setRunningWorkflow($flag)
|
||||
{
|
||||
try {
|
||||
$this->runningWorkflow = $flag;
|
||||
|
||||
$this->setArrayFieldNameForException($this->arrayFieldNameForException);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set arrayFieldNameForException atributte by data
|
||||
*
|
||||
* @param array $arrayData
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setArrayFieldNameForException(array $arrayData)
|
||||
{
|
||||
try {
|
||||
foreach ($arrayData as $key => $value) {
|
||||
$this->arrayFieldNameForException[$key] = $this->convertFieldNameByRunningWorkflow($value);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set arrayVariableNameForException atributte by data
|
||||
*
|
||||
* @param array $arrayData
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setArrayVariableNameForException(array $arrayData)
|
||||
{
|
||||
try {
|
||||
foreach ($arrayData as $key => $value) {
|
||||
$this->arrayVariableNameForException[$key] = $value;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayFieldNameForException atributte
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getArrayFieldNameForException()
|
||||
{
|
||||
try {
|
||||
return $this->arrayFieldNameForException;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arrayVariableNameForException atributte
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getArrayVariableNameForException()
|
||||
{
|
||||
try {
|
||||
return $this->arrayVariableNameForException;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert field name by runningWorkflow
|
||||
*
|
||||
* @param string $fieldName
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function convertFieldNameByRunningWorkflow($fieldName)
|
||||
{
|
||||
try {
|
||||
return ($this->runningWorkflow)? strtoupper($fieldName) : strtolower($fieldName);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,5 +374,38 @@ class Validator
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate pager data
|
||||
*
|
||||
* @param array $arrayData Data
|
||||
* @param array $arrayVariableNameForException Variable name for exception
|
||||
*
|
||||
* @return mixed Returns TRUE when pager data is valid, Message Error otherwise
|
||||
*/
|
||||
public static function validatePagerDataByPagerDefinition($arrayPagerData, $arrayVariableNameForException)
|
||||
{
|
||||
try {
|
||||
foreach ($arrayPagerData as $key => $value) {
|
||||
$nameForException = (isset($arrayVariableNameForException[$key]))?
|
||||
$arrayVariableNameForException[$key] : $key;
|
||||
|
||||
if (!is_null($value) &&
|
||||
(
|
||||
(string)($value) == '' ||
|
||||
!preg_match('/^(?:\+|\-)?(?:0|[1-9]\d*)$/', $value . '') ||
|
||||
(int)($value) < 0
|
||||
)
|
||||
) {
|
||||
return \G::LoadTranslation('ID_INVALID_VALUE_EXPECTING_POSITIVE_INTEGER', [$nameForException]);
|
||||
}
|
||||
}
|
||||
|
||||
//Return
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -730,7 +730,7 @@ class Variable
|
||||
$stmt = $cnn->createStatement();
|
||||
|
||||
$replaceFields = G::replaceDataField($variableSql, $arrayVariable);
|
||||
|
||||
|
||||
$filter = "";
|
||||
if (isset($arrayVariable["filter"])) {
|
||||
$filter = $arrayVariable["filter"];
|
||||
@@ -763,7 +763,7 @@ class Variable
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function queryModified($sqlParsed, $inputSel = "", $searchType = "*searchtype*", $start = 0, $limit = "", $dbConnection = "workflow")
|
||||
{
|
||||
if (!empty($sqlParsed['SELECT'])) {
|
||||
@@ -876,7 +876,7 @@ class Variable
|
||||
} else {
|
||||
$sqlOrderBy = " ORDER BY " . $sFieldSel;
|
||||
}
|
||||
|
||||
|
||||
$sqlLimit = "";
|
||||
if ($start >= 0) {
|
||||
$sqlLimit = " LIMIT " . $start;
|
||||
@@ -887,7 +887,7 @@ class Variable
|
||||
if (!empty($sqlParsed['LIMIT'])) {
|
||||
$sqlLimit = " LIMIT " . $sqlParsed['LIMIT']['start'] . ", " . $sqlParsed['LIMIT']['end'];
|
||||
}
|
||||
|
||||
|
||||
//get database provider
|
||||
$a = new \Criteria("workflow");
|
||||
$a->addSelectColumn(\DbSourcePeer::DBS_TYPE);
|
||||
@@ -935,7 +935,7 @@ class Variable
|
||||
return $sCall;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function limitPgsql($start = 0, $limit = "")
|
||||
{
|
||||
$sqlLimit = "";
|
||||
@@ -990,4 +990,49 @@ class Variable
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Variable record by name
|
||||
*
|
||||
* @param string $projectUid Unique id of Project
|
||||
* @param string $variableName Variable name
|
||||
* @param array $arrayVariableNameForException Variable name for exception
|
||||
* @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
|
||||
*/
|
||||
public function getVariableRecordByName(
|
||||
$projectUid,
|
||||
$variableName,
|
||||
array $arrayVariableNameForException,
|
||||
$throwException = true
|
||||
) {
|
||||
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(
|
||||
$arrayVariableNameForException['$variableName'] . ': ' . $variableName. ' ' .
|
||||
\G::LoadTranslation('ID_DOES_NOT_EXIST')
|
||||
);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Return
|
||||
return $arrayVariableData;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user