This commit is contained in:
Paula Quispe
2017-08-23 12:20:54 -04:00
parent 3574f0de2a
commit 2be3ca49b2

View File

@@ -10,6 +10,31 @@ use AppDelayPeer;
use ProcessMaker\Core\System;
use ProcessMaker\Util\DateTime;
use PmLicenseManager;
use Bootstrap;
use ProcessPeer;
use BpmnProjectPeer;
use Propel;
use ResultSet;
use Process;
use Cases;
use ProcessMaker\BusinessModel\Task as BusinessModelTask;
use ProcessMaker\Services\Api\Project\Activity\Step;
use Exception;
use AppCacheView;
use database;
use TaskPeer;
use StepPeer;
use GulliverBasePeer;
use AppDocument;
use Users;
use ProcessMaker\BusinessModel\User as BusinessModelUser;
use ProcessMaker\BusinessModel\Cases as BusinessModelCases;
use ProcessMaker\Core\RoutingScreen;
use Configurations;
use InputDocument;
use AppFolder;
use PMmemcached;
use RBAC;
class Light
{
@@ -19,7 +44,7 @@ class Light
*
* @param $userId User id
* @return array
* @throws \Exception
* @throws Exception
*/
public function getProcessListStartCase($userId)
{
@@ -27,9 +52,9 @@ class Light
try {
// getting bpmn projects
$c = new Criteria('workflow');
$c->addSelectColumn(\BpmnProjectPeer::PRJ_UID);
$ds = \ProcessPeer::doSelectRS($c, \Propel::getDbConnection('workflow_ro'));
$ds->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$c->addSelectColumn(BpmnProjectPeer::PRJ_UID);
$ds = ProcessPeer::doSelectRS($c, Propel::getDbConnection('workflow_ro'));
$ds->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$bpmnProjects = array();
while ($ds->next()) {
@@ -37,8 +62,8 @@ class Light
$bpmnProjects[] = $row['PRJ_UID'];
}
$oProcess = new \Process();
$oCase = new \Cases();
$oProcess = new Process();
$oCase = new Cases();
//Get ProcessStatistics Info
$start = 0;
@@ -66,11 +91,11 @@ class Light
$proData[$proInfo['PRO_UID']] = $proInfo;
}
$task = new \ProcessMaker\BusinessModel\Task();
$task = new BusinessModelTask();
$task->setFormatFieldNameInUppercase(false);
$task->setArrayParamException(array("taskUid" => "act_uid", "stepUid" => "step_uid"));
$step = new \ProcessMaker\Services\Api\Project\Activity\Step();
$step = new Step();
$response = array();
foreach ($processList as $key => $processInfo) {
$tempTreeChildren = array();
@@ -79,7 +104,8 @@ class Light
$tempTreeChild['text'] = $keyChild; //ellipsis ( $keyChild, 50 );
$tempTreeChild['processId'] = $processInfoChild['pro_uid'];
$tempTreeChild['taskId'] = $processInfoChild['uid'];
list($tempTreeChild['offlineEnabled'], $tempTreeChild['autoRoot']) = $task->getColumnValues($processInfoChild['pro_uid'], $processInfoChild['uid'], array('TAS_OFFLINE', 'TAS_AUTO_ROOT'));
list($tempTreeChild['offlineEnabled'], $tempTreeChild['autoRoot']) = $task->getColumnValues($processInfoChild['pro_uid'],
$processInfoChild['uid'], array('TAS_OFFLINE', 'TAS_AUTO_ROOT'));
//Add process category
$tempTreeChild['categoryName'] = $processInfoChild['catname'];
$tempTreeChild['categoryId'] = $processInfoChild['cat'];
@@ -100,7 +126,8 @@ class Light
$newForm[$c]['stepMode'] = $form['step_mode'];
$newForm[$c]['stepCondition'] = $form['step_condition'];
$newForm[$c]['stepPosition'] = $form['step_position'];
$trigger = $this->statusTriggers($step->doGetActivityStepTriggers($form["step_uid"], $tempTreeChild['taskId'], $tempTreeChild['processId']));
$trigger = $this->statusTriggers($step->doGetActivityStepTriggers($form["step_uid"],
$tempTreeChild['taskId'], $tempTreeChild['processId']));
$newForm[$c]["triggers"] = $trigger;
$c++;
}
@@ -113,9 +140,10 @@ class Light
}
$response = array_merge($response, $tempTreeChildren);
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
return $response;
}
@@ -135,6 +163,7 @@ class Light
$return["after"] = true;
}
}
return $return;
}
@@ -142,13 +171,13 @@ class Light
* Get counters each type of list
* @param $userId
* @return array
* @throws \Exception
* @throws Exception
*/
public function getCounterCase($userId)
{
try {
$userUid = (isset($userId) && $userId != '') ? $userId : null;
$oAppCache = new \AppCacheView();
$oAppCache = new AppCacheView();
$aTypes = Array();
$aTypes['to_do'] = 'toDo';
@@ -165,9 +194,10 @@ class Light
foreach ($aCount as $type => $count) {
$response[$aTypes[$type]] = $count;
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
return $response;
}
@@ -189,10 +219,11 @@ class Light
$sDataBase = 'database_' . strtolower(DB_ADAPTER);
if (G::LoadSystemExist($sDataBase)) {
$oDataBase = new \database();
$oDataBase = new database();
$c->addAsColumn('USR_NAME', $oDataBase->concatString("USR_LASTNAME", "' '", "USR_FIRSTNAME"));
$c->addAsColumn(
'DEL_FINISH_DATE', $oDataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'-'", AppDelegationPeer::DEL_FINISH_DATE)
'DEL_FINISH_DATE',
$oDataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'-'", AppDelegationPeer::DEL_FINISH_DATE)
);
$c->addAsColumn(
'APP_TYPE', $oDataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'IN_PROGRESS'", AppDelayPeer::APP_TYPE)
@@ -201,13 +232,10 @@ class Light
$c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
$c->addSelectColumn(AppDelayPeer::APP_ENABLE_ACTION_DATE);
$c->addSelectColumn(AppDelayPeer::APP_DISABLE_ACTION_DATE);
$c->addSelectColumn(\TaskPeer::TAS_TITLE);
$c->addSelectColumn(TaskPeer::TAS_TITLE);
//APP_DELEGATION LEFT JOIN USERS
$c->addJoin(AppDelegationPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
//APP_DELAY FOR MORE DESCRIPTION
//$c->addJoin(AppDelegationPeer::DEL_INDEX, AppDelayPeer::APP_DEL_INDEX, Criteria::LEFT_JOIN);
//$c->addJoin(AppDelegationPeer::APP_UID, AppDelayPeer::APP_UID, Criteria::LEFT_JOIN);
$del = \DBAdapter::getStringDelimiter();
$app = array();
$app[] = array(AppDelegationPeer::DEL_INDEX, AppDelayPeer::APP_DEL_INDEX);
@@ -215,7 +243,7 @@ class Light
$c->addJoinMC($app, Criteria::LEFT_JOIN);
//LEFT JOIN TASK TAS_TITLE
$c->addJoin(AppDelegationPeer::TAS_UID, \TaskPeer::TAS_UID, Criteria::LEFT_JOIN);
$c->addJoin(AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN);
//WHERE
$c->add(AppDelegationPeer::APP_UID, $sAppUid);
@@ -232,19 +260,17 @@ class Light
*
* @param $app_uid
* @return array
* @throws \Exception
* @throws Exception
*/
public function getCasesListHistory($app_uid)
{
//global $G_PUBLISH;
$c = $this->getTransferHistoryCriteria($app_uid);
//$result = new \stdClass();
$aProcesses = Array();
$rs = \GulliverBasePeer::doSelectRs( $c );
$rs->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
$rs = GulliverBasePeer::doSelectRs($c);
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$rs->next();
for ($j = 0; $j < $rs->getRecordCount(); $j++) {
$result = $rs->getRow();
@@ -254,17 +280,14 @@ class Light
$processUid = $result["PRO_UID"];
}
$process = new \Process();
$process = new Process();
$arrayProcessData = $process->load($processUid);
//$newDir = '/tmp/test/directory';
//G::verifyPath( $newDir );
$result = array();
$result["processName"] = $arrayProcessData["PRO_TITLE"];
//$result["PRO_DESCRIPTION"] = $arrayProcessData["PRO_DESCRIPTION"];
$result['flow'] = $aProcesses;
return $result;
}
@@ -275,16 +298,16 @@ class Light
* @param string $proUid
* @param string $taskUid
* @return array
* @throws \Exception
* @throws Exception
*/
public function startCase($userId = '', $proUid = '', $taskUid = '')
{
try {
$oCase = new \Cases();
$oCase = new Cases();
$aData = $oCase->startCase($taskUid, $userId);
$user = new \ProcessMaker\BusinessModel\User();
$user = new BusinessModelUser();
$arrayUserData = $user->getUserRecordByPk($userId, ['$userUid' => '$userId']);
$_SESSION['APPLICATION'] = $aData['APPLICATION'];
@@ -303,11 +326,13 @@ class Light
$response['caseNumber'] = $aData['CASE_NUMBER'];
//Log
\Bootstrap::registerMonolog('MobileCreateCase', 200, "Create case", ['application_uid' => $aData['APPLICATION'], 'usr_uid' => $userId], SYS_SYS, 'processmaker.log');
Bootstrap::registerMonolog('MobileCreateCase', 200, "Create case",
['application_uid' => $aData['APPLICATION'], 'usr_uid' => $userId], SYS_SYS, 'processmaker.log');
} catch (Exception $e) {
$response['status'] = 'failure';
$response['message'] = $e->getMessage();
}
return $response;
}
@@ -315,33 +340,34 @@ class Light
{
$oContent = new \Content();
///we are looking for a pro title for this process $sproUid
$oCriteria = new \Criteria( 'workflow' );
$oCriteria->add(\ProcessPeer::PRO_UID, $sproUid);
$oDataset = \ProcessPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$oCriteria = new Criteria('workflow');
$oCriteria->add(ProcessPeer::PRO_UID, $sproUid);
$oDataset = ProcessPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$aRow = $oDataset->getRow();
if (!is_array($aRow)) {
$oC = new \Criteria('workflow');
$oC->addSelectColumn(\TaskPeer::TAS_UID);
$oC->addSelectColumn(\TaskPeer::TAS_TITLE);
$oC->add(\TaskPeer::PRO_UID, $sproUid);
$oDataset1 = \TaskPeer::doSelectRS($oC);
$oDataset1->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$oC = new Criteria('workflow');
$oC->addSelectColumn(TaskPeer::TAS_UID);
$oC->addSelectColumn(TaskPeer::TAS_TITLE);
$oC->add(TaskPeer::PRO_UID, $sproUid);
$oDataset1 = TaskPeer::doSelectRS($oC);
$oDataset1->setFetchmode(ResultSet::FETCHMODE_ASSOC);
while ($oDataset1->next()) {
$aRow1 = $oDataset1->getRow();
\Content::insertContent('TAS_TITLE', '', $aRow1['TAS_UID'], 'en', $aRow1['TAS_TITLE']);
}
$oC2 = new Criteria('workflow');
$oC2->addSelectColumn(\ProcessPeer::PRO_UID);
$oC2->addSelectColumn(\ProcessPeer::PRO_TITLE);
$oC2->add(\ProcessPeer::PRO_UID, $sproUid);
$oDataset3 = \ProcessPeer::doSelectRS($oC2);
$oDataset3->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$oC2->addSelectColumn(ProcessPeer::PRO_UID);
$oC2->addSelectColumn(ProcessPeer::PRO_TITLE);
$oC2->add(ProcessPeer::PRO_UID, $sproUid);
$oDataset3 = ProcessPeer::doSelectRS($oC2);
$oDataset3->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset3->next();
$aRow3 = $oDataset3->getRow();
\Content::insertContent('PRO_TITLE', '', $aRow3['PRO_UID'], 'en', $aRow3['PRO_TITLE']);
}
return 1;
}
@@ -353,20 +379,20 @@ class Light
public function doExecuteTriggerCase($usr_uid, $prj_uid, $act_uid, $cas_uid, $step_uid, $type, $del_index = null)
{
$userData = $this->getUserData($usr_uid);
$c = new \Criteria();
$c = new Criteria();
$c->clearSelectColumns();
$c->addSelectColumn(\StepPeer::STEP_UID);
$c->addSelectColumn(\StepPeer::STEP_UID_OBJ);
$c->add(\StepPeer::TAS_UID, $act_uid);
$c->add(\StepPeer::STEP_TYPE_OBJ, 'DYNAFORM');
$c->add(\StepPeer::STEP_UID, $step_uid);
$rs = \StepPeer::doSelectRS($c);
$rs->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$c->addSelectColumn(StepPeer::STEP_UID);
$c->addSelectColumn(StepPeer::STEP_UID_OBJ);
$c->add(StepPeer::TAS_UID, $act_uid);
$c->add(StepPeer::STEP_TYPE_OBJ, 'DYNAFORM');
$c->add(StepPeer::STEP_UID, $step_uid);
$rs = StepPeer::doSelectRS($c);
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$rs->next();
$row = $rs->getRow();
$step_uid_obj = $row['STEP_UID_OBJ'];
$oCase = new \Cases();
$oCase = new Cases();
$Fields = $oCase->loadCase($cas_uid);
$_SESSION["APPLICATION"] = $cas_uid;
$_SESSION["PROCESS"] = $prj_uid;
@@ -377,7 +403,8 @@ class Light
$Fields['APP_DATA'] = array_merge($Fields['APP_DATA'], G::getSystemConstants());
$triggers = $oCase->loadTriggers($act_uid, 'DYNAFORM', $step_uid_obj, strtoupper($type));
if ($triggers) {
$Fields['APP_DATA'] = $oCase->ExecuteTriggers( $act_uid, 'DYNAFORM', $step_uid_obj, strtoupper($type), $Fields['APP_DATA'] );
$Fields['APP_DATA'] = $oCase->ExecuteTriggers($act_uid, 'DYNAFORM', $step_uid_obj, strtoupper($type),
$Fields['APP_DATA']);
}
$Fields['TAS_UID'] = $act_uid;
$Fields['CURRENT_DYNAFORM'] = $step_uid_obj;
@@ -385,6 +412,7 @@ class Light
$Fields['PRO_UID'] = $prj_uid;
$oCase->updateCase($cas_uid, $Fields);
$response = array('status' => 'ok');
return $response;
}
@@ -397,7 +425,7 @@ class Light
public function getPrepareInformation($usr_uid, $tas_uid, $app_uid, $del_index = null)
{
try {
$oCase = new \Cases();
$oCase = new Cases();
$Fields = $oCase->loadCase($app_uid);
$_SESSION["APPLICATION"] = $app_uid;
$_SESSION["PROCESS"] = $Fields['PRO_UID'];
@@ -409,7 +437,8 @@ class Light
$triggers = $oCase->loadTriggers($tas_uid, 'ASSIGN_TASK', '-1', 'BEFORE');
if (isset($triggers)) {
$Fields['APP_DATA'] = array_merge($Fields['APP_DATA'], G::getSystemConstants());
$Fields['APP_DATA'] = $oCase->ExecuteTriggers( $tas_uid, 'DYNAFORM', '-1', 'BEFORE', $Fields['APP_DATA'] );
$Fields['APP_DATA'] = $oCase->ExecuteTriggers($tas_uid, 'DYNAFORM', '-1', 'BEFORE',
$Fields['APP_DATA']);
$oCase->updateCase($app_uid, $Fields);
}
$oDerivation = new \Derivation();
@@ -417,15 +446,17 @@ class Light
$aData['APP_UID'] = $app_uid;
$aData['DEL_INDEX'] = $del_index;
$aData['USER_UID'] = $usr_uid;
$oRoute = new \ProcessMaker\Core\RoutingScreen();
$oRoute = new RoutingScreen();
$derive = $oRoute->prepareRoutingScreen($aData);
$response = array();
foreach ($derive as $sKey => &$aValues) {
$sPriority = ''; //set priority value
if ($derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'] != '') {
//TO DO: review this type of assignment
if (isset( $aData['APP_DATA'][str_replace( '@@', '', $derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'] )] )) {
$sPriority = $aData['APP_DATA'][str_replace( '@@', '', $derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'] )];
if (isset($aData['APP_DATA'][str_replace('@@', '',
$derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'])])) {
$sPriority = $aData['APP_DATA'][str_replace('@@', '',
$derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'])];
}
} //set priority value
@@ -500,11 +531,12 @@ class Light
}
if (empty($response)) {
throw new \Exception(G::LoadTranslation("ID_NO_DERIVATION_RULE"));
throw new Exception(G::LoadTranslation("ID_NO_DERIVATION_RULE"));
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
return $response;
}
@@ -527,11 +559,12 @@ class Light
}
$ws = new \WsBase();
$fields = $ws->derivateCase($userUid, $applicationUid, $delIndex, $bExecuteTriggersBeforeAssignment = false, $tasks);
$fields = $ws->derivateCase($userUid, $applicationUid, $delIndex, $bExecuteTriggersBeforeAssignment = false,
$tasks);
$array = json_decode(json_encode($fields), true);
$array['message'] = trim(strip_tags($array['message']));
if ($array ["status_code"] != 0) {
throw (new \Exception($array ["message"]));
throw (new Exception($array ["message"]));
} else {
unset($array['status_code']);
unset($array['message']);
@@ -539,10 +572,12 @@ class Light
}
//Log
\Bootstrap::registerMonolog('MobileRouteCase', 200, 'Route case', ['application_uid' => $applicationUid, 'usr_uid' => $userUid], SYS_SYS, 'processmaker.log');
} catch (\Exception $e) {
Bootstrap::registerMonolog('MobileRouteCase', 200, 'Route case',
['application_uid' => $applicationUid, 'usr_uid' => $userUid], SYS_SYS, 'processmaker.log');
} catch (Exception $e) {
throw $e;
}
return $fields;
}
@@ -578,9 +613,10 @@ class Light
$response['userPhone'] = $aUserLog['USR_PHONE'];
$response['updateDate'] = $aUserLog['USR_UPDATE_DATE'];
$response['userPhoto'] = base64_encode($contenido);
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
return $response;
}
@@ -593,7 +629,7 @@ class Light
public function downloadFile($app_uid, $request_data)
{
try {
$oAppDocument = new \AppDocument();
$oAppDocument = new AppDocument();
$arrayFiles = array();
foreach ($request_data as $key => $fileData) {
if (!isset($fileData['version'])) {
@@ -609,8 +645,8 @@ class Light
$info = pathinfo($oAppDocument->getAppDocFilename());
$ext = (isset($info['extension']) ? $info['extension'] : '');//BUG fix: must handle files without any extension
//$app_uid = \G::getPathFromUID($oAppDocument->Fields['APP_UID']);
$file = \G::getPathFromFileUID($oAppDocument->Fields['APP_UID'], $sAppDocUid);
//$app_uid = G::getPathFromUID($oAppDocument->Fields['APP_UID']);
$file = G::getPathFromFileUID($oAppDocument->Fields['APP_UID'], $sAppDocUid);
$realPath = PATH_DOCUMENT . G::getPathFromUID($app_uid) . '/' . $file[0] . $file[1] . '_' . $iDocVersion . '.' . $ext;
$realPath1 = PATH_DOCUMENT . G::getPathFromUID($app_uid) . '/' . $file[0] . $file[1] . '.' . $ext;
@@ -624,7 +660,8 @@ class Light
case 'gif':
case 'png':
$arrayFiles[$key]['fileId'] = $fileData['fileId'];
$arrayFiles[$key]['fileContent'] = base64_encode($this->imagesThumbnails($realPath, $ext, $width, $height));
$arrayFiles[$key]['fileContent'] = base64_encode($this->imagesThumbnails($realPath, $ext,
$width, $height));
break;
default:
$fileTmp = fopen($realPath, "r");
@@ -641,7 +678,8 @@ class Light
case 'gif':
case 'png':
$arrayFiles[$key]['fileId'] = $fileData['fileId'];
$arrayFiles[$key]['fileContent'] = $this->imagesThumbnails($realPath1, $ext, $width, $height);
$arrayFiles[$key]['fileContent'] = $this->imagesThumbnails($realPath1, $ext, $width,
$height);
break;
default:
$fileTmp = fopen($realPath, "r");
@@ -653,9 +691,10 @@ class Light
}
}
}
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
return $arrayFiles;
}
@@ -725,6 +764,7 @@ class Light
}
$image = ob_get_clean();
imagedestroy($thumb);
return $image;
}
@@ -782,7 +822,8 @@ class Light
/*----------------------------------********---------------------------------*/
$licenseManager =& PmLicenseManager::getSingleton();
if (in_array(md5($licenseManager->result), array('38afd7ae34bd5e3e6fc170d8b09178a3', 'ba2b45bdc11e2a4a6e86aab2ac693cbb'))) {
if (in_array(md5($licenseManager->result),
array('38afd7ae34bd5e3e6fc170d8b09178a3', 'ba2b45bdc11e2a4a6e86aab2ac693cbb'))) {
$G_PUBLISH = new \Publisher();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/licenseExpired', '', array(), 'licenseUpdate');
G::RenderPage('publish');
@@ -799,6 +840,7 @@ class Light
$response["status"] = "ERROR";
$response["message"] = $e->getMessage();
}
return $response;
}
@@ -809,7 +851,7 @@ class Light
* @param $userUid
* @param $type
* @param $app_uid
* @throws \Exception
* @throws Exception
*/
public function getInformation($userUid, $type, $app_uid)
{
@@ -818,22 +860,23 @@ class Light
case 'unassigned':
case 'paused':
case 'participated':
$oCase = new \Cases();
$oCase = new Cases();
$iDelIndex = $oCase->getCurrentDelegationCase($app_uid);
$aFields = $oCase->loadCase($app_uid, $iDelIndex);
$response = $this->getInfoResume($userUid, $aFields, $type);
break;
case 'lastopenindex':
//Get the last participate from a user
$oNewCase = new \ProcessMaker\BusinessModel\Cases();
$oNewCase = new BusinessModelCases();
$iDelIndex = $oNewCase->getLastParticipatedByUser($app_uid, $userUid, 'OPEN');
$oCase = new \Cases();
$oCase = new Cases();
$aFields = $oCase->loadCase($app_uid, $iDelIndex);
$aFields['DEL_INDEX'] = $iDelIndex === 0 ? '' : $iDelIndex;
$aFields['USR_UID'] = $userUid;
$response = $this->getInfoResume($userUid, $aFields, $type);
break;
}
return $response;
}
@@ -843,12 +886,12 @@ class Light
* @param $userUid
* @param $Fields
* @param $type
* @throws \Exception
* @throws Exception
*/
public function getInfoResume($userUid, $Fields, $type)
{
/* Prepare page before to show */
$objProc = new \Process();
$objProc = new Process();
$aProc = $objProc->load($Fields['PRO_UID']);
$Fields['PRO_TITLE'] = $aProc['PRO_TITLE'];
@@ -873,43 +916,47 @@ class Light
}
/**
* first step for upload file
* First step for upload file
* create uid app_document for upload file
*
* @param $userUid
* @param $Fields
* @param $type
* @throws \Exception
* @param string $userUid
* @param string $appUid
* @param array $requestData
* @return array $response
* @throws Exception
*/
public function postUidUploadFiles($userUid, $app_uid, $request_data)
public function postUidUploadFiles($userUid, $appUid, $requestData)
{
$response = array();
if (is_array($request_data)) {
foreach ($request_data as $k => $file) {
if (is_array($requestData)) {
$config = new Configurations();
$confEnvSetting = $config->getFormats();
$user = new Users();
foreach ($requestData as $k => $file) {
$ext = pathinfo($file['name'], PATHINFO_EXTENSION);
if (\Bootstrap::getDisablePhpUploadExecution() === 1 && $ext === 'php') {
$message = \G::LoadTranslation('THE_UPLOAD_OF_PHP_FILES_WAS_DISABLED');
\Bootstrap::registerMonologPhpUploadExecution('phpUpload', 550, $message, $file['name']);
if (Bootstrap::getDisablePhpUploadExecution() === 1 && $ext === 'php') {
$message = G::LoadTranslation('THE_UPLOAD_OF_PHP_FILES_WAS_DISABLED');
Bootstrap::registerMonologPhpUploadExecution('phpUpload', 550, $message, $file['name']);
$response[$k]['error'] = array(
"code" => "400",
"message" => $message
);
continue;
}
$oCase = new \Cases();
$delIndex = $oCase->getCurrentDelegation($app_uid, $userUid);
$cases = new Cases();
$delIndex = $cases->getCurrentDelegation($appUid, $userUid);
$docUid = !empty($file['docUid']) ? $file['docUid'] : -1;
$folderId = '';
if ($docUid !== -1) {
$inputDocument = new \InputDocument();
$inputDocument = new InputDocument();
$aInputDocumentData = $inputDocument->load($docUid);
$appFolder = new \AppFolder();
$folderId = $appFolder->createFromPath($aInputDocumentData["INP_DOC_DESTINATION_PATH"], $app_uid);
$appFolder = new AppFolder();
$folderId = $appFolder->createFromPath($aInputDocumentData["INP_DOC_DESTINATION_PATH"], $appUid);
}
$appDocType = !empty($file['appDocType']) ? $file['appDocType'] : "ATTACHED";
$fieldName = !empty($file['fieldName']) ? $file['fieldName'] : null;
$aFields = array(
"APP_UID" => $app_uid,
$fieldsInput = array(
"APP_UID" => $appUid,
"DEL_INDEX" => $delIndex,
"USR_UID" => $userUid,
"DOC_UID" => $docUid,
@@ -921,12 +968,31 @@ class Light
"APP_DOC_FIELDNAME" => $fieldName,
"FOLDER_UID" => $folderId
);
$oAppDocument = new \AppDocument();
$oAppDocument->create($aFields);
$response[$k]['docVersion'] = $iDocVersion = $oAppDocument->getDocVersion();
$response[$k]['appDocUid'] = $sAppDocUid = $oAppDocument->getAppDocUid();
//We will to create a new version related to the appDocUid
if (isset($file['appDocUid'])) {
$fieldsInput['APP_DOC_UID'] = $file['appDocUid'];
}
$appDocument = new AppDocument();
$appDocument->create($fieldsInput);
//todo, we need to uniform the response format with camelCase
$response[$k]['appDocUid'] = $appDocUid = $appDocument->getAppDocUid();
$response[$k]['docVersion'] = $docVersion = $appDocument->getDocVersion();
$response[$k]['appDocFilename'] = $appDocument->getAppDocFilename();
$response[$k]['appDocCreateDate'] = $appDocument->getAppDocCreateDate();
$response[$k]['appDocType'] = $appDocument->getAppDocType();
$response[$k]['appDocIndex'] = $appDocument->getAppDocIndex();
//todo, we use this *** in others endpoint for mark that user not exist, but we need to change
$userInfo = '***';
if ($userUid !== '-1') {
$arrayUserData = $user->load($userUid);
$userInfo = $config->usersNameFormatBySetParameters($confEnvSetting["format"],
$arrayUserData["USR_USERNAME"], $arrayUserData["USR_FIRSTNAME"],
$arrayUserData["USR_LASTNAME"]);
}
$response[$k]['appDocCreateUser'] = $userInfo;
}
}
return $response;
}
@@ -937,7 +1003,7 @@ class Light
* @param $userUid
* @param $Fields
* @param $type
* @throws \Exception
* @throws Exception
*/
public function documentUploadFiles($userUid, $app_uid, $app_doc_uid, $request_data)
{
@@ -981,7 +1047,7 @@ class Light
$fieldName = null;
$fileSizeByField = 0;
$oAppDocument = new \AppDocument();
$oAppDocument = new AppDocument();
$aAux = $oAppDocument->load($app_doc_uid);
$iDocVersion = $oAppDocument->getDocVersion();
@@ -1007,12 +1073,12 @@ class Light
* @param $userUid
* @param $Fields
* @param $type
* @throws \Exception
* @throws Exception
*/
public function claimCaseUser($userUid, $sAppUid)
{
$response = array("status" => "fail");
$oCase = new \Cases();
$oCase = new Cases();
$iDelIndex = $oCase->getCurrentDelegation($sAppUid, '', true);
$oAppDelegation = new \AppDelegation();
@@ -1025,6 +1091,7 @@ class Light
} else {
//G::SendMessageText( G::LoadTranslation( 'ID_CASE_ALREADY_DERIVATED' ), 'error' );
}
return $response;
}
@@ -1039,18 +1106,19 @@ class Light
$category[] = array("", G::LoadTranslation("ID_ALL_CATEGORIES"));
$criteria = new Criteria('workflow');
$criteria->addSelectColumn( \ProcessCategoryPeer::CATEGORY_UID );
$criteria->addSelectColumn( \ProcessCategoryPeer::CATEGORY_NAME );
$criteria->addAscendingOrderByColumn(\ProcessCategoryPeer::CATEGORY_NAME);
$criteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_UID);
$criteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_NAME);
$criteria->addAscendingOrderByColumn(ProcessCategoryPeer::CATEGORY_NAME);
$dataset = \ProcessCategoryPeer::doSelectRS( $criteria );
$dataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
$dataset = ProcessCategoryPeer::doSelectRS($criteria);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$dataset->next();
while ($row = $dataset->getRow()) {
$category[] = array($row['CATEGORY_UID'], $row['CATEGORY_NAME']);
$dataset->next();
}
return $category;
}
@@ -1059,7 +1127,7 @@ class Light
* @param $categoryUid
* @param $userUid
* @return array
* @throws \PropelException
* @throws PropelException
*/
public function getProcessList($action, $categoryUid, $userUid)
{
@@ -1068,7 +1136,7 @@ class Light
//$userUid = (isset( $_SESSION['USER_LOGGED'] ) && $_SESSION['USER_LOGGED'] != '') ? $_SESSION['USER_LOGGED'] : null;
// global $oAppCache;
$oAppCache = new \AppCacheView();
$oAppCache = new AppCacheView();
$processes = array();
$processes[] = array('', G::LoadTranslation('ID_ALL_PROCESS'));
@@ -1085,29 +1153,30 @@ class Light
//in search action, the query to obtain all process is too slow, so we need to query directly to
//process and content tables, and for that reason we need the current language in AppCacheView.
$oConf = new \Configurations();
$oConf = new Configurations();
$oConf->loadConfig($x, 'APP_CACHE_VIEW_ENGINE', '', '', '', '');
$appCacheViewEngine = $oConf->aConfig;
$lang = isset($appCacheViewEngine['LANG']) ? $appCacheViewEngine['LANG'] : 'en';
$cProcess = new Criteria('workflow');
$cProcess->clearSelectColumns();
$cProcess->addSelectColumn( \ProcessPeer::PRO_UID );
$cProcess->addSelectColumn( \ProcessPeer::PRO_TITLE );
$cProcess->addSelectColumn(ProcessPeer::PRO_UID);
$cProcess->addSelectColumn(ProcessPeer::PRO_TITLE);
if ($categoryUid) {
$cProcess->add( \ProcessPeer::PRO_CATEGORY, $categoryUid );
$cProcess->add(ProcessPeer::PRO_CATEGORY, $categoryUid);
}
$cProcess->add(ProcessPeer::PRO_STATUS, 'ACTIVE');
$cProcess->addAscendingOrderByColumn(\ProcessPeer::PRO_TITLE);
$cProcess->addAscendingOrderByColumn(ProcessPeer::PRO_TITLE);
$oDataset = \ProcessPeer::doSelectRS( $cProcess );
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
$oDataset = ProcessPeer::doSelectRS($cProcess);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
while ($aRow = $oDataset->getRow()) {
$processes[] = array($aRow['PRO_UID'], $aRow['PRO_TITLE']);
$oDataset->next();
}
return print G::json_encode($processes);
break;
case 'unassigned':
@@ -1132,28 +1201,31 @@ class Light
}
//get the processes for this user in this action
$cProcess->clearSelectColumns();
$cProcess->addSelectColumn( \AppCacheViewPeer::PRO_UID );
$cProcess->addSelectColumn( \AppCacheViewPeer::APP_PRO_TITLE );
$cProcess->setDistinct( \AppCacheViewPeer::PRO_UID );
$cProcess->addSelectColumn(AppCacheViewPeer::PRO_UID);
$cProcess->addSelectColumn(AppCacheViewPeer::APP_PRO_TITLE);
$cProcess->setDistinct(AppCacheViewPeer::PRO_UID);
if ($categoryUid) {
require_once 'classes/model/Process.php';
$cProcess->addAlias('CP', 'PROCESS');
$cProcess->add('CP.PRO_CATEGORY', $categoryUid, Criteria::EQUAL);
$cProcess->addJoin( \AppCacheViewPeer::PRO_UID, 'CP.PRO_UID', Criteria::LEFT_JOIN );
$cProcess->addJoin(AppCacheViewPeer::PRO_UID, 'CP.PRO_UID', Criteria::LEFT_JOIN);
$cProcess->addAsColumn('CATEGORY_UID', 'CP.PRO_CATEGORY');
}
$cProcess->addAscendingOrderByColumn(\AppCacheViewPeer::APP_PRO_TITLE);
$cProcess->addAscendingOrderByColumn(AppCacheViewPeer::APP_PRO_TITLE);
$oDataset = \AppCacheViewPeer::doSelectRS( $cProcess, \Propel::getDbConnection('workflow_ro') );
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
$oDataset = AppCacheViewPeer::doSelectRS($cProcess, Propel::getDbConnection('workflow_ro'));
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
while ($aRow = $oDataset->getRow()) {
$processes[] = array ($aRow['PRO_UID'],$aRow['APP_PRO_TITLE']
$processes[] = array(
$aRow['PRO_UID'],
$aRow['APP_PRO_TITLE']
);
$oDataset->next();
}
return $processes;
}
@@ -1163,22 +1235,23 @@ class Light
public function getUsersToReassign($usr_uid, $task_uid)
{
$memcache = \PMmemcached::getSingleton( SYS_SYS );
$RBAC = \RBAC::getSingleton( PATH_DATA, session_id() );
$memcache = PMmemcached::getSingleton(SYS_SYS);
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
$RBAC->sSystem = 'PROCESSMAKER';
$RBAC->initRBAC();
$memKey = 'rbacSession' . session_id();
if (($RBAC->aUserInfo = $memcache->get($memKey)) === false) {
$RBAC->loadUserRolePermission($RBAC->sSystem, $usr_uid);
$memcache->set( $memKey, $RBAC->aUserInfo, \PMmemcached::EIGHT_HOURS );
$memcache->set($memKey, $RBAC->aUserInfo, PMmemcached::EIGHT_HOURS);
}
$GLOBALS['RBAC'] = $RBAC;
$task = new \Task();
$tasks = $task->load($task_uid);
$case = new \Cases();
$case = new Cases();
$result = new \stdclass();
$result->data = $case->getUsersToReassign($task_uid, $usr_uid, $tasks['PRO_UID']);
return $result;
}
@@ -1187,7 +1260,7 @@ class Light
*/
public function reassignCase($usr_uid, $app_uid, $TO_USR_UID)
{
$cases = new \Cases();
$cases = new Cases();
$user = new \Users();
$app = new \Application();
$result = new \stdclass();
@@ -1201,7 +1274,7 @@ class Light
$data['USER'] = $userData['USR_LASTNAME'] . ' ' . $userData['USR_FIRSTNAME']; //TODO change with the farmated username from environment conf
$result->status = 0;
$result->msg = G::LoadTranslation('ID_REASSIGNMENT_SUCCESS', SYS_LANG, $data);
} catch (\Exception $e) {
} catch (Exception $e) {
$result->status = 1;
$result->msg = $e->getMessage();
}
@@ -1217,7 +1290,7 @@ class Light
$result = new \stdclass();
try {
$oCase = new \Cases();
$oCase = new Cases();
$iDelIndex = $oCase->getCurrentDelegation($app_uid, $usr_uid);
// Save the note pause reason
if ($request_data['noteContent'] != '') {
@@ -1236,9 +1309,10 @@ class Light
$result->success = true;
$result->msg = G::LoadTranslation('ID_CASE_PAUSED_SUCCESSFULLY', SYS_LANG, $data);
} catch (\Exception $e) {
} catch (Exception $e) {
throw $e;
}
return $result;
}
@@ -1248,7 +1322,7 @@ class Light
*/
public function getConfiguration($params)
{
$sysConf = \Bootstrap::getSystemConfiguration('','',SYS_SYS);
$sysConf = Bootstrap::getSystemConfiguration('', '', SYS_SYS);
$multiTimeZone = false;
//Set Time Zone
/*----------------------------------********---------------------------------*/
@@ -1259,7 +1333,8 @@ class Light
/*----------------------------------********---------------------------------*/
$tz = isset($_SESSION['USR_TIME_ZONE']) ? $_SESSION['USR_TIME_ZONE'] : $sysConf['time_zone'];
$offset = timezone_offset_get(new \DateTimeZone($tz), new \DateTime());
$response['timeZone'] = sprintf( "GMT%s%02d:%02d", ( $offset >= 0 ) ? '+' : '-', abs( $offset / 3600 ), abs( ($offset % 3600) / 60 ) );
$response['timeZone'] = sprintf("GMT%s%02d:%02d", ($offset >= 0) ? '+' : '-', abs($offset / 3600),
abs(($offset % 3600) / 60));
$response['multiTimeZone'] = $multiTimeZone;
$fields = System::getSysInfo();
$response['version'] = $fields['PM_VERSION'];
@@ -1270,7 +1345,7 @@ class Light
/*----------------------------------********---------------------------------*/
$response['buildType'] = $buildType;
$conf = new \Configurations();
$conf = new Configurations();
$confEnvironment = $conf->getFormats();
$response['environment'] = array();
@@ -1307,6 +1382,7 @@ class Light
if (isset($params['tz']) && $params['tz']) {
$response['tz'] = isset($_SESSION['USR_TIME_ZONE']) ? $_SESSION['USR_TIME_ZONE'] : $sysConf['time_zone'];
}
return $response;
}
@@ -1339,12 +1415,13 @@ class Light
$oCriteria->add(AppDelegationPeer::APP_UID, $app_uid);
$oCriteria->add(AppDelegationPeer::DEL_PREVIOUS, $del_index);
$oDataset = AppDelegationPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
while ($row = $oDataset->getRow()) {
$children[] = $row;
$oDataset->next();
}
return $children;
}