This commit is contained in:
Paula Quispe
2018-10-16 15:45:20 -04:00
30 changed files with 1722 additions and 1072 deletions

View File

@@ -9,6 +9,7 @@ use AbeRequests;
use AbeRequestsPeer;
use AbeResponsesPeer;
use ApplicationPeer;
use AppDelegation;
use AppDelegationPeer;
use Criteria;
use EmailServerPeer;
@@ -23,6 +24,7 @@ use PMLicensedFeatures;
use ProcessPeer;
use ResultSet;
use SpoolRun;
use Users as ClassUsers;
use stdClass;
use UsersPeer;
use TaskPeer;
@@ -266,11 +268,18 @@ class ActionsByEmail
return $response;
}
/**
* Get the information for the log
*
* @param array $arrayData
*
* @return array
*/
public function loadActionByEmail(array $arrayData)
{
//Get the total
$criteria = new Criteria();
$criteria->addSelectColumn('COUNT(*)');
$criteria->addJoin(AbeConfigurationPeer::ABE_UID, AbeRequestsPeer::ABE_UID);
$criteria->addJoin(AppDelegationPeer::APP_UID, AbeRequestsPeer::APP_UID);
$criteria->addJoin(AppDelegationPeer::DEL_INDEX, AbeRequestsPeer::DEL_INDEX);
@@ -288,7 +297,6 @@ class ActionsByEmail
$criteria->addSelectColumn(AbeConfigurationPeer::ABE_TEMPLATE);
$criteria->addSelectColumn(AbeConfigurationPeer::ABE_ACTION_FIELD);
$criteria->addSelectColumn(AbeConfigurationPeer::DYN_UID);
$criteria->addSelectColumn(AbeRequestsPeer::ABE_REQ_UID);
$criteria->addSelectColumn(AbeRequestsPeer::APP_UID);
$criteria->addSelectColumn(AbeRequestsPeer::DEL_INDEX);
@@ -298,14 +306,10 @@ class ActionsByEmail
$criteria->addSelectColumn(AbeRequestsPeer::ABE_REQ_ANSWERED);
$criteria->addSelectColumn(AbeRequestsPeer::ABE_REQ_BODY);
$criteria->addSelectColumn(AbeRequestsPeer::ABE_REQ_DATE);
$criteria->addSelectColumn(ApplicationPeer::APP_NUMBER);
$criteria->addSelectColumn(AppDelegationPeer::APP_NUMBER);
$criteria->addSelectColumn(AppDelegationPeer::DEL_PREVIOUS);
$criteria->addSelectColumn(AppDelegationPeer::USR_UID);
$criteria->addJoin(AbeConfigurationPeer::ABE_UID, AbeRequestsPeer::ABE_UID);
$criteria->addJoin(ApplicationPeer::APP_UID, AbeRequestsPeer::APP_UID);
$criteria->addJoin(AppDelegationPeer::APP_UID, AbeRequestsPeer::APP_UID);
$criteria->addJoin(AppDelegationPeer::DEL_INDEX, AbeRequestsPeer::DEL_INDEX);
$criteria->addDescendingOrderByColumn(AbeRequestsPeer::ABE_REQ_DATE);
@@ -313,66 +317,37 @@ class ActionsByEmail
$criteria->setOffset($arrayData['start']);
$result = AbeConfigurationPeer::doSelectRS($criteria);
$result->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$data = Array();
$arrayPro = Array();
$arrayTAS = Array();
$data = [];
$index = 0;
while ($result->next()) {
$data[] = $result->getRow();
$criteriaRes = new Criteria();
$row = $result->getRow();
$row['ABE_REQ_STATUS'] = G::LoadTranslation('ID_MAIL_STATUS_' . $row['ABE_REQ_STATUS']);
$data[] = $row;
//Get the response
$abe = new AbeRequests();
$dataRes = $abe->load($data[$index]['ABE_REQ_UID']);
$data[$index]['ABE_RES_UID'] = !empty($dataRes['ABE_RES_UID']) ? $dataRes['ABE_RES_UID'] : '';
$data[$index]['ABE_RES_CLIENT_IP'] = !empty($dataRes['ABE_RES_CLIENT_IP']) ? $dataRes['ABE_RES_CLIENT_IP'] : '';
$data[$index]['ABE_RES_DATA'] = !empty($dataRes['ABE_RES_DATA']) ? $dataRes['ABE_RES_DATA'] : '';
$data[$index]['ABE_RES_STATUS'] = !empty($dataRes['ABE_RES_STATUS']) ? $dataRes['ABE_RES_STATUS'] : '';
$data[$index]['ABE_RES_MESSAGE'] = !empty($dataRes['ABE_RES_UID']) ? $dataRes['ABE_RES_MESSAGE'] : '';
$criteriaRes->addSelectColumn(AbeResponsesPeer::ABE_RES_UID);
$criteriaRes->addSelectColumn(AbeResponsesPeer::ABE_RES_CLIENT_IP);
$criteriaRes->addSelectColumn(AbeResponsesPeer::ABE_RES_DATA);
$criteriaRes->addSelectColumn(AbeResponsesPeer::ABE_RES_STATUS);
$criteriaRes->addSelectColumn(AbeResponsesPeer::ABE_RES_MESSAGE);
$criteriaRes->add(AbeResponsesPeer::ABE_REQ_UID, $data[$index]['ABE_REQ_UID']);
$resultRes = AbeResponsesPeer::doSelectRS($criteriaRes);
$resultRes->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$resultRes->next();
$dataRes = Array();
if ($dataRes = $resultRes->getRow()) {
$data[$index]['ABE_RES_UID'] = $dataRes['ABE_RES_UID'];
$data[$index]['ABE_RES_CLIENT_IP'] = $dataRes['ABE_RES_CLIENT_IP'];
$data[$index]['ABE_RES_DATA'] = $dataRes['ABE_RES_DATA'];
$data[$index]['ABE_RES_STATUS'] = $dataRes['ABE_RES_STATUS'];
$data[$index]['ABE_RES_MESSAGE'] = $dataRes['ABE_RES_MESSAGE'];
} else {
$data[$index]['ABE_RES_UID'] = '';
$data[$index]['ABE_RES_CLIENT_IP'] = '';
$data[$index]['ABE_RES_DATA'] = '';
$data[$index]['ABE_RES_STATUS'] = '';
$data[$index]['ABE_RES_MESSAGE'] = '';
}
$criteriaRes = new Criteria();
$criteriaRes->addSelectColumn(AppDelegationPeer::USR_UID);
$criteriaRes->addSelectColumn(UsersPeer::USR_FIRSTNAME);
$criteriaRes->addSelectColumn(UsersPeer::USR_LASTNAME);
$criteria->addJoin(AppDelegationPeer::APP_UID, $data[$index]['APP_UID']);
$criteria->addJoin(AppDelegationPeer::DEL_INDEX, $data[$index]['DEL_PREVIOUS']);
$criteria->addJoin(AppDelegationPeer::USR_UID, UsersPeer::USR_UID);
$resultRes = AppDelegationPeer::doSelectRS($criteriaRes);
$resultRes->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$resultRes->next();
if ($dataRes = $resultRes->getRow()) {
//Get the previous user
$appDelegation = new AppDelegation();
$usrUid = $appDelegation->getUserAssignedInThread($data[$index]['APP_UID'], $data[$index]['DEL_PREVIOUS']);
$users = new ClassUsers();
$dataRes = $users->load($usrUid);
if (!empty($dataRes)) {
$data[$index]['USER'] = $dataRes['USR_FIRSTNAME'] . ' ' . $dataRes['USR_LASTNAME'];
} else {
$data[$index]['USER'] = '';
}
$data[$index]['ABE_REQ_ANSWERED'] = ($data[$index]['ABE_REQ_ANSWERED'] == 1) ? 'YES' : 'NO';
$data[$index]['ABE_REQ_ANSWERED'] = ($data[$index]['ABE_REQ_ANSWERED'] == 1) ? G::LoadTranslation('ID_YES') : G::LoadTranslation('ID_NO');
$index++;
}
$response = array();
$response = [];
$response['totalCount'] = $totalCount;
$response['data'] = $data;

View File

@@ -386,11 +386,12 @@ class InputDocument
*
* @param string $applicationUid
* @param string $userUid
* @param array $documentsCanAccess
*
* @return array Return an array with data of an InputDocument
* @throws Exception
*/
public function getCasesInputDocuments($applicationUid, $userUid)
public function getCasesInputDocuments($applicationUid, $userUid, $documentsCanAccess = [])
{
try {
//Verify data inbox
@@ -415,7 +416,10 @@ class InputDocument
$criteria = $this->getAppDocumentCriteriaByData($applicationUid);
if (!$flagInbox) {
$criteria->add(AppDocumentPeer::USR_UID, $userUid, Criteria::EQUAL);
$criteria->add(
$criteria->getNewCriterion(AppDocumentPeer::USR_UID, $userUid, Criteria::EQUAL)->addOr(
$criteria->getNewCriterion(AppDocumentPeer::APP_DOC_UID, $documentsCanAccess, Criteria::IN))
);
}
$rsCriteria = AppDocumentPeer::doSelectRS($criteria);

View File

@@ -2,7 +2,11 @@
namespace ProcessMaker\BusinessModel;
use AdditionalTables;
use DynaformHandler;
use Exception;
use G;
use PmDynaform;
class DynaForm
{
@@ -407,6 +411,8 @@ class DynaForm
$this->throwExceptionIfExistsTitle($processUid, $arrayData["DYN_TITLE"], $this->arrayFieldNameForException["dynaFormTitle"]);
$this->throwExceptionIfTheColumnIdentifierIsNotValid($arrayData);
//Create
$dynaForm = new \Dynaform();
@@ -461,6 +467,8 @@ class DynaForm
$this->throwExceptionIfExistsTitle($processUid, $arrayData["DYN_TITLE"], $this->arrayFieldNameForException["dynaFormTitle"], $dynaFormUid);
}
$this->throwExceptionIfTheColumnIdentifierIsNotValid($arrayData);
//Update
$arrayData["DYN_UID"] = $dynaFormUid;
@@ -1131,4 +1139,74 @@ class DynaForm
throw $e;
}
}
/**
* Validates if the grid columns tha will be stored have valid names, otherwise
* it throws an exception.
*
* @param array $arrayData, form data that will be saved
*
* @throws Exception
*/
public function throwExceptionIfTheColumnIdentifierIsNotValid($arrayData)
{
if (isset($arrayData['DYN_CONTENT'])) {
$oldDynaform = $this->getDynaFormRecordByPk($arrayData['DYN_UID'], []);
$oldGrids = PmDynaform::getGridsAndFields($oldDynaform['DYN_CONTENT']);
$oldColumns = $this->getColumnsOfArrayGrids($oldGrids);
$grids = PmDynaform::getGridsAndFields($arrayData['DYN_CONTENT']);
$columns = $this->getColumnsOfArrayGrids($grids);
foreach ($oldColumns as $oldField) {
foreach ($columns as $key => $field) {
if ($oldField->id === $field->id) {
unset($columns[$key]);
break;
}
}
}
$invalids = [];
$identicals = [];
foreach ($columns as $column) {
try {
Validator::isValidVariableName($column->id);
} catch (Exception $e) {
$invalids[] = $column->id;
}
foreach ($oldColumns as $oldColumn) {
if (strtolower(AdditionalTables::getPHPName($column->id)) === strtolower(AdditionalTables::getPHPName($oldColumn->id))) {
$identicals[] = "'" . $column->id . "' - '" . $oldColumn->id . "'";
}
}
}
if (count($invalids) > 0) {
throw (new Exception(G::LoadTranslation("ID_GRID_VARIABLE_NAME_ERROR", [implode(', ', $invalids)])));
}
if (count($identicals) > 0) {
throw (new Exception(G::LoadTranslation("DYNAFIELD_PHPNAME_ALREADY_EXIST", [implode(', ', $identicals)])));
}
}
}
/**
* Gets a list of all columns of the grid array.
*
* @param array $grids
*
* @return array
*/
private function getColumnsOfArrayGrids($grids)
{
$columns = [];
foreach ($grids as $grid) {
if (isset($grid->columns)) {
$columns = array_merge($columns, $grid->columns);
}
}
return $columns;
}
}

View File

@@ -0,0 +1,146 @@
<?php
namespace ProcessMaker\BusinessModel\Files;
use ProcessMaker\Util\DateTime;
class Cron
{
/**
* Cron file log path.
*
* @var string
*/
private $filepath = '';
/**
* Class constructor.
*/
function __construct()
{
$this->setFilepath(PATH_DATA . 'log' . PATH_SEP . 'cron.log');
}
/**
* Set the cron file log path.
*
* @param string $filepath
*/
public function setFilepath($filepath)
{
$this->filepath = $filepath;
}
/**
* Get data from file.
*
* @param array $filter
* @param int $start
* @param int $limit
* @return array
*/
public function getData($filter, $start = 0, $limit = 20)
{
if (!file_exists($this->filepath)) {
return [0, []];
}
$result = [];
$count = 0;
$array = file($this->filepath);
foreach ($array as $line) {
if (empty($line)) {
continue;
}
$row = $this->getRow($line, $filter);
if ($row === null) {
continue;
}
$count = $count + 1;
if ($start < $count && count($result) < $limit) {
$row['DATE'] = DateTime::convertUtcToTimeZone($row['DATE']);
$result[] = $row;
}
}
return [$count, $result];
}
/**
* Get registry from string line.
*
* @param string $line
* @param array $filter
* @return array
*/
public function getRow($line, $filter)
{
$row = explode('|', $line);
$date = '';
$workspace = '';
$action = '';
$status = '';
$description = trim($row[0]);
if (!empty($row)) {
$date = isset($row[0]) ? trim($row[0]) : '';
$workspace = isset($row[1]) ? trim($row[1]) : '';
$action = isset($row[2]) ? trim($row[2]) : '';
$status = isset($row[3]) ? trim($row[3]) : '';
$description = isset($row[4]) ? trim($row[4]) : '';
}
$isValid = true;
if ($filter['workspace'] != 'ALL' && $workspace != $filter['workspace']) {
$isValid = false;
}
if ($filter['status'] != 'ALL') {
switch ($filter['status']) {
case 'COMPLETED':
if ($status != 'action') {
$isValid = false;
}
break;
case 'FAILED':
if ($status == 'action') {
$isValid = false;
}
break;
}
}
$mktDate = !empty($date) ? $this->mktimeDate($date) : 0;
if (!empty($filter['dateFrom']) && $mktDate > 0) {
if (!($this->mktimeDate($filter['dateFrom']) <= $mktDate)) {
$isValid = false;
}
}
if (!empty($filter['dateTo']) && $mktDate > 0) {
if (!($mktDate <= $this->mktimeDate($filter['dateTo'] . ' 23:59:59'))) {
$isValid = false;
}
}
if ($isValid) {
return [
'DATE' => $date,
'ACTION' => $action,
'STATUS' => $status,
'DESCRIPTION' => $description
];
}
return null;
}
/**
* Create a timestamp from a string value.
*
* @param string $date
* @return int|false
*/
public function mktimeDate($date)
{
$array = getdate(strtotime($date));
$mktime = mktime($array['hours'], $array['minutes'], $array['seconds'], $array['mon'], $array['mday'], $array['year']);
return $mktime;
}
}

View File

@@ -1,10 +1,12 @@
<?php
namespace ProcessMaker\BusinessModel;
use G;
use AdditionalTables;
use Fields;
use DynaformHandler;
use Exception;
use Fields;
use G;
use ProcessMaker\BusinessModel\ReportTable as BusinessModelRpt;
class Table
{
@@ -184,15 +186,16 @@ class Table
/**
* Save Data for Table
*
* @var string $tab_data. Data for table
* @var string $pro_uid. Uid for process
* @var string $reportFlag. If is report table
* @var string $createRep. Flag for create table
* @var boolean $reportFlag. If is report table
* @var boolean $createRep. Flag for create table
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @deprecated Method deprecated in Release 3.3.1
*
* @return array
* @throws Exception
*/
public function saveTable($tab_data, $pro_uid = '', $reportFlag = false, $createRep = true)
{
@@ -508,59 +511,163 @@ class Table
}
/**
* Update Data for Table
* @var string $tab_data. Data for table
* @var string $pro_uid. Uid for process
* @var string $reportFlag. If is report table
* Update Data for PmTable and Report Table
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
* @var string $tableData: Data for table
* @var string $pro_uid: Uid for process
* @var boolean $isReportTable: If is report table
*
* @return void
* @return object
* @throws Exception
*/
public function updateTable($tab_data, $pro_uid = '', $reportFlag = false)
public function updateTable($tableData, $proUid = '', $isReportTable = false)
{
if ($reportFlag) {
$tab_uid = $tab_data['rep_uid'];
$pro_uid = $this->validateProUid($pro_uid);
$tableDsc = false;
$tableFields = false;
if ($isReportTable) {
$tabUid = $tableData['rep_uid'];
$proUid = $this->validateProUid($proUid);
$tableData['pro_uid'] = $proUid;
$errorMssg = "The property rep_uid: '$tabUid' is incorrect.";
} else {
$tab_uid = $tab_data['pmt_uid'];
$tabUid = $tableData['pmt_uid'];
$errorMssg = "The property pmt_uid: '$tabUid' is incorrect.";
}
$tabUid = $this->validateTabUid($tabUid, $isReportTable);
$addTables = new AdditionalTables();
$dataValidate = $addTables->getTableProperties($tabUid, $tableData, $isReportTable);
if (empty($dataValidate)) {
throw (new Exception($errorMssg));
}
if ($isReportTable) {
if (!empty($tableData['rep_tab_dsc'])) {
$dataValidate['rep_tab_dsc'] = $tableData['rep_tab_dsc'];
$tableDsc = true;
}
} else {
if (!empty($tableData['pmt_tab_dsc'])) {
$dataValidate['rep_tab_dsc'] = $tableData['pmt_tab_dsc'];
$tableDsc = true;
}
}
if (!empty($tableData['fields'])) {
$dataValidate['fields'] = $tableData['fields'];
$tableFields = true;
} else {
throw (new Exception('Body doesn\'t contain fields arguments'));
}
if (!$tableDsc && !$tableFields) {
throw (new Exception('Body doesn\'t contain pmt_tad_dsc or fields arguments'));
}
$tab_uid = $this->validateTabUid($tab_uid, $reportFlag);
$dataValidate = array();
$oCriteria = new \Criteria('workflow');
$oCriteria->add(\AdditionalTablesPeer::ADD_TAB_UID, $tab_uid, \Criteria::EQUAL);
$oDataset = \AdditionalTablesPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
//We will validate the fields after update the pmTable structure
$result = $this->validateTableBeforeUpdate($dataValidate);
if ($oDataset->next()) {
$row = $oDataset->getRow();
if ($reportFlag) {
$dataValidate['rep_uid'] = $tab_uid;
$dataValidate['rep_tab_name'] = $row['ADD_TAB_NAME'];
$dataValidate['rep_tab_dsc'] = $tab_data['rep_tab_dsc'];
$dataValidate['rep_tab_connection'] = $row['DBS_UID'];
$dataValidate['rep_tab_type'] = $row['ADD_TAB_TYPE'];
$dataValidate['rep_tab_grid'] = '';
if (strpos($row['ADD_TAB_GRID'], '-')) {
list($gridName, $gridId) = explode( '-', $row['ADD_TAB_GRID'] );
$dataValidate['rep_tab_grid'] = $gridId;
return $result;
}
/**
* Will be validate the fields before saveStructureOfTable
*
* @param array $tableFields Properties for table
*
* @return object
* @throws Exception
*/
public function validateTableBeforeUpdate($tableFields)
{
$propertiesUpdate = [];
if (!empty($tableFields)){
$propertiesUpdate = array_change_key_case($tableFields, CASE_UPPER);
$propertiesUpdate['keepData'] = '1';
}
$columnsTable = [];
$flagKey = false;
if (!empty($propertiesUpdate['FIELDS'])) {
$columns = $propertiesUpdate['FIELDS'];
foreach ($columns as $i => $column) {
$columnsTable[$i] = [];
//Required fld_uid
if (!empty($columns[$i]['fld_uid'])) {
$columnsTable[$i]['field_uid'] = $columnsTable[$i]['uid'] = G::toUpper($columns[$i]['fld_uid']);
} else {
throw (new Exception(G::LoadTranslation("ID_CAN_NOT_BE_EMPTY", ['fld_uid'])));
}
} else {
$dataValidate['pmt_uid'] = $tab_uid;
$dataValidate['pmt_tab_name'] = $row['ADD_TAB_NAME'];
$dataValidate['pmt_tab_dsc'] = $tab_data['pmt_tab_dsc'];
}
$dataValidate['fields'] = $tab_data['fields'];
} else {
if ($reportFlag) {
throw (new \Exception("The property rep_uid: '$tab_uid' is incorrect."));
} else {
throw (new \Exception("The property pmt_uid: '$tab_uid' is incorrect."));
//Not required fld_dyn
$columnsTable[$i]['field_dyn'] = '';
if (!empty($columns[$i]['fld_dyn'])) {
$columnsTable[$i]['field_dyn'] = G::toUpper($columns[$i]['fld_dyn']);
}
//Required fld_name
if (!empty($columns[$i]['fld_name'])) {
$columnsTable[$i]['field_name'] = G::toUpper($columns[$i]['fld_name']);
} else {
throw (new Exception(G::LoadTranslation("ID_CAN_NOT_BE_EMPTY", ['fld_name'])));
}
//Required fld_label
if (!empty($columns[$i]['fld_label'])) {
$columnsTable[$i]['field_label'] = G::toUpper($columns[$i]['fld_label']);
} else {
throw (new Exception(G::LoadTranslation("ID_CAN_NOT_BE_EMPTY", ['fld_label'])));
}
//We will to define the autoincrement
$columnsTable[$i]['field_autoincrement'] = false;
//Required fld_type
if (!empty($columns[$i]['fld_type'])) {
$columnsTable[$i]['field_type'] = G::toUpper($columns[$i]['fld_type']);
//Will be validate if is the correct type of column
if (!in_array($columnsTable[$i]['field_type'], AdditionalTables::FLD_TYPE_VALUES)) {
throw (new Exception("The property fld_type: '" . $columns[$i]['fld_type'] . "' is incorrect."));
}
//Will be review if the column type has the correct definition with autoincrement
if (!empty($columns[$i]['fld_autoincrement']) && $columns[$i]['fld_autoincrement']) {
if ($columns[$i]['fld_key'] && in_array($columns[$i]['fld_type'], AdditionalTables::FLD_TYPE_WITH_AUTOINCREMENT)) {
$columnsTable[$i]['field_autoincrement'] = true;
} else {
throw (new Exception("The property field_autoincrement: '" . $columns[$i]['fld_autoincrement'] . "' is incorrect. "));
}
}
} else {
throw (new Exception(G::LoadTranslation("ID_CAN_NOT_BE_EMPTY", ['fld_type'])));
}
//Required fld_size depends of fld_type
$columnsTable[$i]['field_size'] = 0;
if (in_array($columns[$i]['fld_type'], AdditionalTables::FLD_TYPE_WITH_SIZE)) {
if (empty($columns[$i]['fld_size'])) {
throw (new Exception(G::LoadTranslation("ID_CAN_NOT_BE_EMPTY", ['fld_size'])));
}
if ((integer)$columns[$i]['fld_size'] === 0) {
throw (new Exception("The property fld_size: '" . $columns[$i]['fld_size'] . "' is incorrect."));
}
$columnsTable[$i]['field_size'] = (integer)$columns[$i]['fld_size'];
}
//Required only for one column
$columnsTable[$i]['field_key'] = false;
if (!empty($columns[$i]['fld_key'])) {
$flagKey = true;
$columnsTable[$i]['field_key'] = (boolean)$columns[$i]['fld_key'];
}
//Not required fld_null
$columnsTable[$i]['field_null'] = false;
if (!empty($columns[$i]['fld_null'])) {
$columnsTable[$i]['field_null'] = G::toUpper($columns[$i]['fld_null']);
}
//Not required fld_filter
$columnsTable[$i]['field_filter'] = false;
}
}
$this->saveTable($dataValidate, $pro_uid, $reportFlag, false);
if (!$flagKey) {
throw (new Exception("The table doesn't have a primary key 'fld_key'"));
}
$propertiesUpdate['columns'] = G::json_encode($columnsTable);
$reportTable = new BusinessModelRpt();
$result = $reportTable->saveStructureOfTable($propertiesUpdate);
return $result;
}
/**

File diff suppressed because it is too large Load Diff

View File

@@ -405,6 +405,7 @@ class Variable
if (isset($aData["VAR_NAME"])) {
Validator::isString($aData['VAR_NAME'], '$var_name');
Validator::isNotEmpty($aData['VAR_NAME'], '$var_name');
Validator::isValidVariableName($aData['VAR_NAME']);
}
if (isset($aData["VAR_FIELD_TYPE"])) {
Validator::isString($aData['VAR_FIELD_TYPE'], '$var_field_type');
@@ -462,7 +463,7 @@ class Variable
if ($variableName === $row["VAR_NAME"]) {
throw new Exception(G::LoadTranslation("DYNAFIELD_ALREADY_EXIST"));
}
if (AdditionalTables::getPHPName($variableName) === AdditionalTables::getPHPName($row["VAR_NAME"])) {
if (strtolower(AdditionalTables::getPHPName($variableName)) === strtolower(AdditionalTables::getPHPName($row["VAR_NAME"]))) {
throw new Exception(G::LoadTranslation("DYNAFIELD_PHPNAME_ALREADY_EXIST", array($row["VAR_NAME"])));
}
}

View File

@@ -195,7 +195,7 @@ abstract class Importer
} catch (\Exception $e) {
throw $e;
}
$this->removeProject();
$this->removeProject(true);
/*----------------------------------********---------------------------------*/
} else {
$granularObj = new \ProcessMaker\BusinessModel\Migrator\GranularImporter();
@@ -300,8 +300,6 @@ abstract class Importer
$this->preserveEmailEventConfiguration($emailEvent);
}
}
$this->preserveCurrentId($this->importData["tables"]["workflow"]);
$objectList = $granularObj->loadObjectsListSelected($this->importData, $newObjectArray);
if (sizeof($objectList) > 0 && $processGranulate) {
@@ -604,8 +602,6 @@ abstract class Importer
foreach ($arrayWorkflowTables["emailEvent"] as &$emailEvent) {
$this->preserveEmailEventConfiguration($emailEvent);
}
$this->preserveCurrentId($arrayWorkflowTables);
$this->importWfTables($arrayWorkflowTables);
@@ -952,70 +948,4 @@ abstract class Importer
}
}
/**
* Restore id values for the dynaforms, input documents and output documents.
*
* @param type $arrayWorkflowTables
*/
private function preserveCurrentId(&$arrayWorkflowTables)
{
$currentProcess = $this->getCurrentProcess();
//dynaforms
foreach ($arrayWorkflowTables["dynaforms"] as &$data) {
if (!is_object($currentProcess)) {
unset($data['DYN_ID']);
continue;
}
$currentElements = $currentProcess->dynaforms;
if (!is_array($currentElements)) {
unset($data['DYN_ID']);
continue;
}
foreach ($currentElements as $currentElement) {
if ($currentElement["PRO_UID"] === $data["PRO_UID"] &&
$currentElement["DYN_UID"] === $data["DYN_UID"]) {
$data['DYN_ID'] = $currentElement["DYN_ID"];
}
}
}
//input documents
foreach ($arrayWorkflowTables["inputs"] as &$data) {
if (!is_object($currentProcess)) {
unset($data['INP_DOC_ID']);
continue;
}
$currentElements = $currentProcess->inputs;
if (!is_array($currentElements)) {
unset($data['INP_DOC_ID']);
continue;
}
foreach ($currentElements as $currentElement) {
if ($currentElement["PRO_UID"] === $data["PRO_UID"] &&
$currentElement["INP_DOC_UID"] === $data["INP_DOC_UID"]) {
$data['INP_DOC_ID'] = $currentElement['INP_DOC_ID'];
}
}
}
//output documents
foreach ($arrayWorkflowTables["outputs"] as &$data) {
if (!is_object($currentProcess)) {
unset($data['OUT_DOC_ID']);
continue;
}
$currentElements = $currentProcess->outputs;
if (!is_array($currentElements)) {
unset($data['OUT_DOC_ID']);
continue;
}
foreach ($currentElements as $currentElement) {
if ($currentElement["PRO_UID"] === $data["PRO_UID"] &&
$currentElement["OUT_DOC_UID"] === $data["OUT_DOC_UID"]) {
$data['OUT_DOC_ID'] = $currentElement['OUT_DOC_ID'];
}
}
}
}
}

View File

@@ -1,10 +1,11 @@
<?php
namespace ProcessMaker\Services\Api\Cases;
use \ProcessMaker\Services\Api;
use \Luracast\Restler\RestException;
use ProcessMaker\BusinessModel\Cases\InputDocument AS CasesInputDocument;
use Exception;
use Luracast\Restler\RestException;
use ProcessMaker\BusinessModel\Cases\InputDocument as CasesInputDocument;
use ProcessMaker\BusinessModel\Cases as BussinessModelCases;
use ProcessMaker\Services\Api;
/**
* Cases\InputDocument Api Controller
@@ -16,23 +17,44 @@ class InputDocument extends Api
/**
* @url GET /:app_uid/input-documents
*
* @param string $app_uid {@min 32}{@max 32}
* @param string $app_uid {@min 32}{@max 32}
*
* @return array
* @throws RestException
*/
public function doGetInputDocuments($app_uid)
{
try {
$userUid = $this->getUserId();
$inputDocument = new \ProcessMaker\BusinessModel\Cases\InputDocument();
//We will to get list of documents that the user can be access
$bmCases = new BussinessModelCases();
$arrayApplicationData = $bmCases->getApplicationRecordByPk($app_uid, [], false);
$userAuthorization = $bmCases->userAuthorization(
$userUid,
$arrayApplicationData['PRO_UID'],
$app_uid,
[],
['INPUT_DOCUMENTS' => 'VIEW', 'ATTACHMENTS' => 'VIEW'],
true
);
$documentsCanAccess = array_merge(
$userAuthorization['objectPermissions']['INPUT_DOCUMENTS'],
$userAuthorization['objectPermissions']['ATTACHMENTS']
);
$response = $inputDocument->getCasesInputDocuments($app_uid, $userUid);
//We will to get documents information that the user uploaded and/or that the user has permission
$inputDocument = new CasesInputDocument();
//@todo we need to review the function getCasesInputDocuments with the ticket HOR-4755
$response = $inputDocument->getCasesInputDocuments($app_uid, $userUid, $documentsCanAccess);
if (empty($response)) {
//If the user is a supervisor we will to get the documents can be access
if (empty($response) && $userAuthorization['supervisor']) {
$response = $inputDocument->getCasesInputDocumentsBySupervisor($app_uid, $userUid);
}
//Return
return $response;
} catch (\Exception $e) {
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}

View File

@@ -2,28 +2,31 @@
namespace ProcessMaker\Services\Api;
use AppDelegation;
use Bootstrap;
use Cases as ClassesCases;
use Criteria;
use Exception;
use G;
use Luracast\Restler\RestException;
use PmDynaform;
use Process as ModelProcess;
use ProcessMaker\BusinessModel\Cases as BusinessModelCases;
use ProcessMaker\BusinessModel\DynaForm as BusinessModelDynaForm;
use ProcessMaker\BusinessModel\Light as BusinessModelLight;
use ProcessMaker\BusinessModel\Lists;
use ProcessMaker\BusinessModel\Process;
use ProcessMaker\BusinessModel\ProcessMap;
use ProcessMaker\BusinessModel\Task;
use ProcessMaker\BusinessModel\Validator;
use ProcessMaker\Project\Adapter;
use ProcessMaker\Services\Api;
use Luracast\Restler\RestException;
use ProcessMaker\BusinessModel\Validator;
use ProcessMaker\Services\Api\Project\Activity\Step;
use ProcessMaker\Util\DateTime;
use PmDynaform;
use Exception;
use ProcessMaker\BusinessModel\Light as BusinessModelLight;
use RBAC;
use ProcessMaker\BusinessModel\Cases as BusinessModelCases;
use Cases as ClassesCases;
use AppDelegation;
use ProcessMaker\BusinessModel\Lists;
use ProcessMaker\BusinessModel\Task;
use ProcessMaker\BusinessModel\ProcessMap;
use ProcessMaker\BusinessModel\Process;
use Criteria;
use StepPeer;
use stdclass;
use ProcessMaker\BusinessModel\DynaForm as BusinessModelDynaForm;
use StepPeer;
/**
*
* Process Api Controller
@@ -921,41 +924,57 @@ class Light extends Api
}
/**
* Get steps related to the task
* If the process is classic we does not return any step, this is not supported by Mobile
*
* @url GET /project/:prj_uid/activity/:act_uid/steps
*
* @param string $act_uid {@min 32}{@max 32}
* @param string $prj_uid {@min 32}{@max 32}
*
* @return array
* @throws Exception
*/
public function doGetActivitySteps($act_uid, $prj_uid)
{
try {
$task = new Task();
$task->setFormatFieldNameInUppercase(false);
$task->setArrayParamException(array("taskUid" => "act_uid", "stepUid" => "step_uid"));
$response = [];
$process = new ModelProcess();
$isBpmn = $process->isBpmnProcess($prj_uid);
if ($isBpmn) {
$task = new Task();
$dynaForm = new BusinessModelDynaForm();
$mobile = new BusinessModelLight();
$step = new Step();
$activitySteps = $task->getSteps($act_uid);
$_SESSION['PROCESS'] = $prj_uid;
$dynaForm = new BusinessModelDynaForm();
$dynaForm->setFormatFieldNameInUppercase(false);
$oMobile = new BusinessModelLight();
$step = new \ProcessMaker\Services\Api\Project\Activity\Step();
$response = array();
for ($i = 0; $i < count($activitySteps); $i++) {
if ($activitySteps[$i]['step_type_obj'] == "DYNAFORM") {
$dataForm = $dynaForm->getDynaForm($activitySteps[$i]['step_uid_obj']);
$result = $this->parserDataDynaForm($dataForm);
$result["formUpdateDate"] = DateTime::convertUtcToIso8601($result["formUpdateDate"]);
$result['index'] = $i;
$result['stepId'] = $activitySteps[$i]["step_uid"];
$result['stepUidObj'] = $activitySteps[$i]["step_uid_obj"];
$result['stepMode'] = $activitySteps[$i]['step_mode'];
$result['stepCondition'] = $activitySteps[$i]['step_condition'];
$result['stepPosition'] = $activitySteps[$i]['step_position'];
$trigger = $oMobile->statusTriggers($step->doGetActivityStepTriggers($activitySteps[$i]["step_uid"],
$act_uid, $prj_uid));
$result["triggers"] = $trigger;
unset($result["formContent"]);
$response[] = $result;
$task->setFormatFieldNameInUppercase(false);
$task->setArrayParamException(["taskUid" => "act_uid", "stepUid" => "step_uid"]);
$activitySteps = $task->getSteps($act_uid);
$_SESSION['PROCESS'] = $prj_uid;
$dynaForm->setFormatFieldNameInUppercase(false);
for ($i = 0; $i < count($activitySteps); $i++) {
if ($activitySteps[$i]['step_type_obj'] == "DYNAFORM") {
$dataForm = $dynaForm->getDynaForm($activitySteps[$i]['step_uid_obj']);
$result = $this->parserDataDynaForm($dataForm);
$result["formUpdateDate"] = DateTime::convertUtcToIso8601($result["formUpdateDate"]);
$result['index'] = $i;
$result['stepId'] = $activitySteps[$i]["step_uid"];
$result['stepUidObj'] = $activitySteps[$i]["step_uid_obj"];
$result['stepMode'] = $activitySteps[$i]['step_mode'];
$result['stepCondition'] = $activitySteps[$i]['step_condition'];
$result['stepPosition'] = $activitySteps[$i]['step_position'];
$trigger = $mobile->statusTriggers(
$step->doGetActivityStepTriggers(
$activitySteps[$i]["step_uid"],
$act_uid,
$prj_uid
)
);
$result["triggers"] = $trigger;
unset($result["formContent"]);
$response[] = $result;
}
}
}
} catch (Exception $e) {

View File

@@ -1,8 +1,10 @@
<?php
namespace ProcessMaker\Services\Api;
use \ProcessMaker\Services\Api;
use \Luracast\Restler\RestException;
use Exception;
use Luracast\Restler\RestException;
use ProcessMaker\BusinessModel\Table as BusinessModelTable;
use ProcessMaker\Services\Api;
/**
* Pmtable Api Controller
@@ -149,6 +151,7 @@ class Pmtable extends Api
*
* @access protected
* @class AccessControl {@permission PM_SETUP_PM_TABLES}
* @throws RestException
*/
public function doPutPmTable(
$pmt_uid,
@@ -156,9 +159,9 @@ class Pmtable extends Api
) {
try {
$request_data['pmt_uid'] = $pmt_uid;
$oReportTable = new \ProcessMaker\BusinessModel\Table();
$response = $oReportTable->updateTable($request_data);
} catch (\Exception $e) {
$pmTable = new BusinessModelTable();
$response = $pmTable->updateTable($request_data);
} catch (Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}