From 313563334ba4c55b1c8398ace6197c126ac88be6 Mon Sep 17 00:00:00 2001 From: davidcallizaya Date: Sun, 6 Aug 2017 18:28:53 -0400 Subject: [PATCH 1/3] HOR-3620 Fix pmTable generation problem. --- bootstrap/autoload.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bootstrap/autoload.php b/bootstrap/autoload.php index 08d81773d..b469d3361 100644 --- a/bootstrap/autoload.php +++ b/bootstrap/autoload.php @@ -8,7 +8,8 @@ require __DIR__ . '/../vendor/autoload.php'; set_include_path( get_include_path() . PATH_SEPARATOR . __DIR__ . '/../thirdparty/' . PATH_SEPARATOR - . __DIR__ . '/../thirdparty/pear/' . PATH_SEPARATOR + . __DIR__ . '/../thirdparty/propel-generator/classes/' . PATH_SEPARATOR + . __DIR__ . '/../thirdparty/pear/' . PATH_SEPARATOR . __DIR__ . '/../workflow/engine/' . PATH_SEPARATOR . __DIR__ . '/../rbac/engine/' ); From 6e1e83a4d2fd55f71007a3cd528103108a34f3a3 Mon Sep 17 00:00:00 2001 From: Paula Quispe Date: Mon, 7 Aug 2017 10:58:08 -0400 Subject: [PATCH 2/3] HOR-3616 --- workflow/engine/classes/class.case.php | 79 ++++++++++---------- workflow/engine/classes/class.derivation.php | 40 +--------- 2 files changed, 44 insertions(+), 75 deletions(-) diff --git a/workflow/engine/classes/class.case.php b/workflow/engine/classes/class.case.php index 4feec1018..a88aefe7b 100644 --- a/workflow/engine/classes/class.case.php +++ b/workflow/engine/classes/class.case.php @@ -1386,35 +1386,44 @@ class Cases * * @name searchOpenPreviousTasks, * @param string $taskUid - * @param string $sAppUid - * @param array $aPreviousTasks optional array that serves to trace the task routes and avoid infinite loops. - * @return $aThreads + * @param string $appUid + * @param array $previousTasks, optional array that serves to trace the task routes and avoid infinite loops. + * @return array, information about the threads in the case */ - public function searchOpenPreviousTasks($taskUid, $sAppUid, $aPreviousTasks = array()) + public function searchOpenPreviousTasks($taskUid, $appUid, $previousTasks = array()) { - //in this array we are storing all open delegation rows. - $aTaskReviewed = array(); + //In this array we are storing all open delegation rows. + $threads = array(); - //check if this task ( $taskUid ) has open delegations - $delegations = $this->getReviewedTasks($taskUid, $sAppUid); + //Check if this $taskUid has open delegations, this is a single review + $threads = $this->getReviewedTasks($taskUid, $appUid); - if ($delegations !== false) { - if (count($delegations['open']) > 0) { - //there is an open delegation, so we need to return the delegation row - return $delegations['open']; + if ($threads !== false) { + if (count($threads['open']) > 0) { + //There is an open delegation, so we need to return the delegation row + return $threads['open']; } else { - if(count($delegations['paused']) > 0){ + if (count($threads['paused']) > 0) { //there is an paused delegation, so we need to return the delegation row - return $delegations['paused']; - }else{ - return array(); //returning empty array + return $threads['paused']; } } } - // if not we check previous tasks - // until here this task has not appdelegations records. - // get all previous task from $taskUid, and return open delegations rows, if there are + //Search the open delegations in the previous task, this is a recursive review + $threads = $this->getReviewedTasksRecursive($taskUid, $appUid, $previousTasks); + return $threads; + } + /** + * This function get the last open task + * Usually is used when we have a SEC-JOIN and need to review if we need to route the case + * @param string $taskUid + * @param string $appUid + * @param array $previousTasks + * @return array $taskReviewed + */ + public function getReviewedTasksRecursive($taskUid, $appUid, $previousTasks) { + $taskReviewed = array(); $oCriteria = new Criteria('workflow'); $oCriteria->add(RoutePeer::ROU_NEXT_TASK, $taskUid); $oDataset = RoutePeer::doSelectRs($oCriteria); @@ -1422,33 +1431,27 @@ class Cases while ($oDataset->next()) { $aRow = $oDataset->getRow(); - - $delegations = $this->getReviewedTasks($aRow['TAS_UID'], $sAppUid); + $delegations = $this->getReviewedTasks($aRow['TAS_UID'], $appUid); if ($delegations !== false) { if (count($delegations['open']) > 0) { //there is an open delegation, so we need to return the delegation row - $aTaskReviewed = array_merge($aTaskReviewed, $delegations['open']); - } else { - if ($aRow['ROU_TYPE'] == 'PARALLEL-BY-EVALUATION') { - $aTaskReviewed = array(); - } else { - //$aTaskReviewed = array_merge($aTaskReviewed, $delegations['closed']); - } + $taskReviewed = array_merge($taskReviewed, $delegations['open']); + } elseif ($aRow['ROU_TYPE'] == 'PARALLEL-BY-EVALUATION') { + $taskReviewed = array(); } - } else { - if (!in_array($aRow['TAS_UID'], $aPreviousTasks)) { - // storing the current task uid of the task currently checked - $aPreviousTasks[] = $aRow['TAS_UID']; - // passing the array of previous tasks in oprder to avoid an infinite loop that prevents - $openPreviousTask = $this->searchOpenPreviousTasks($aRow['TAS_UID'], $sAppUid, $aPreviousTasks); - if (count($aPreviousTasks) > 0) { - $aTaskReviewed = array_merge($aTaskReviewed, $openPreviousTask); - } + } elseif (!in_array($aRow['TAS_UID'], $previousTasks)) { + //Storing the current task uid of the task currently checked + $previousTasks[] = $aRow['TAS_UID']; + //Passing the array of previous tasks in order to avoid an infinite loop that prevents + $openPreviousTask = $this->searchOpenPreviousTasks($aRow['TAS_UID'], $appUid, $previousTasks); + if (count($previousTasks) > 0) { + $taskReviewed = array_merge($taskReviewed, $openPreviousTask); } } } - return $aTaskReviewed; + + return $taskReviewed; } /** diff --git a/workflow/engine/classes/class.derivation.php b/workflow/engine/classes/class.derivation.php index d2cb27e00..9dbd41bcc 100644 --- a/workflow/engine/classes/class.derivation.php +++ b/workflow/engine/classes/class.derivation.php @@ -1,40 +1,4 @@ . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ -require_once ("classes/model/Task.php"); -require_once ("classes/model/Process.php"); -require_once ("classes/model/Step.php"); -require_once ("classes/model/Application.php"); -require_once ('classes/model/Groupwf.php'); -require_once ("classes/model/GroupUser.php"); -require_once ("classes/model/AppDelegation.php"); -require_once ("classes/model/Route.php"); -require_once ('classes/model/SubApplication.php'); -require_once ('classes/model/SubProcess.php'); -require_once ("classes/model/Users.php"); /** * derivation - derivation class @@ -87,6 +51,7 @@ class Derivation * @param array $arrayTaskData Task data (derivation) * * @return array Return array + * @throws Exception */ protected function prepareInformationTask(array $arrayTaskData) { @@ -161,7 +126,8 @@ class Derivation * @param array $arrayData Data * @param string $taskUid Unique id of Task * - * @return array Return array + * @return array + * @throws Exception */ public function prepareInformation(array $arrayData, $taskUid = "") { From 5d202bb6818a3bf7b7cc37bd24b785723b3e4dfe Mon Sep 17 00:00:00 2001 From: Paula Quispe Date: Sat, 5 Aug 2017 12:35:14 -0400 Subject: [PATCH 3/3] HOR-3331 --- workflow/engine/controllers/installer.php | 109 +++++++++++++------- workflow/engine/methods/install/newSite.php | 25 +---- 2 files changed, 74 insertions(+), 60 deletions(-) diff --git a/workflow/engine/controllers/installer.php b/workflow/engine/controllers/installer.php index fa3a896d1..64513a7b6 100644 --- a/workflow/engine/controllers/installer.php +++ b/workflow/engine/controllers/installer.php @@ -80,36 +80,42 @@ class Installer extends Controller G::RenderPage( 'publish', 'extJs' ); } + /** + * This function can be create a new workspace + * The user need permission PM_SETUP_ADVANCE for this action + * @return void + */ public function newSite () { - $textStep1 = G::LoadTranslation('ID_PROCESSMAKER_REQUIREMENTS_DESCRIPTION_STEP4_1'); - $textStep2 = G::LoadTranslation('ID_PROCESSMAKER_REQUIREMENTS_DESCRIPTION_STEP5'); + if (!$this->pmIsInstalled()) { + $textStep1 = G::LoadTranslation('ID_PROCESSMAKER_REQUIREMENTS_DESCRIPTION_STEP4_1'); + $textStep2 = G::LoadTranslation('ID_PROCESSMAKER_REQUIREMENTS_DESCRIPTION_STEP5'); - $this->includeExtJS( 'installer/CardLayout', false ); - $this->includeExtJS( 'installer/Wizard', false ); - $this->includeExtJS( 'installer/Header', false ); - $this->includeExtJS( 'installer/Card', false ); - $this->includeExtJS( 'installer/newSite', false ); + $this->includeExtJS('installer/CardLayout', false); + $this->includeExtJS('installer/Wizard', false); + $this->includeExtJS('installer/Header', false); + $this->includeExtJS('installer/Card', false); + $this->includeExtJS('installer/newSite', false); + $this->setJSVar('textStep1', $textStep1); + $this->setJSVar('textStep2', $textStep2); + $this->setJSVar('DB_ADAPTER', DB_ADAPTER); + $aux = explode(':', DB_HOST); + $this->setJSVar('DB_HOST', $aux[0]); + $this->setJSVar('DB_PORT', isset( $aux[1] ) ? $aux[1] : (DB_ADAPTER == 'mssql' ? '1433' : '3306')); + $this->setJSVar('DB_NAME', 'workflow'); + $this->setJSVar('DB_USER', ''); + $this->setJSVar('DB_PASS', ''); + $this->setJSVar('pathConfig', PATH_CORE . 'config' . PATH_SEP); + $this->setJSVar('pathLanguages', PATH_LANGUAGECONT); + $this->setJSVar('pathPlugins', PATH_PLUGINS); + $this->setJSVar('pathXmlforms', PATH_XMLFORM); + $this->setJSVar('pathShared', PATH_DATA); + $this->setView('installer/newSite'); - $this->setJSVar( 'textStep1', $textStep1 ); - $this->setJSVar( 'textStep2', $textStep2 ); - - $this->setJSVar( 'DB_ADAPTER', DB_ADAPTER ); - $aux = explode( ':', DB_HOST ); - $this->setJSVar( 'DB_HOST', $aux[0] ); - $this->setJSVar( 'DB_PORT', isset( $aux[1] ) ? $aux[1] : (DB_ADAPTER == 'mssql' ? '1433' : '3306') ); - $this->setJSVar( 'DB_NAME', 'workflow' ); - $this->setJSVar( 'DB_USER', '' ); - $this->setJSVar( 'DB_PASS', '' ); - $this->setJSVar( 'pathConfig', PATH_CORE . 'config' . PATH_SEP ); - $this->setJSVar( 'pathLanguages', PATH_LANGUAGECONT ); - $this->setJSVar( 'pathPlugins', PATH_PLUGINS ); - $this->setJSVar( 'pathXmlforms', PATH_XMLFORM ); - $this->setJSVar( 'pathShared', PATH_DATA ); - - $this->setView( 'installer/newSite' ); - - G::RenderPage( 'publish', 'extJs' ); + G::RenderPage('publish', 'extJs'); + } else { + $this->displayError(); + } } public function getSystemInfo () @@ -414,22 +420,49 @@ class Installer extends Controller /** * function to create a workspace * in fact this function is calling appropiate functions for mysql and mssql + * need permission PM_SETUP_ADVANCE for this action + * @return void */ public function createWorkspace () { - $pathSharedPartner = trim( $_REQUEST['pathShared'] ); - if (file_exists(trim($pathSharedPartner,PATH_SEP). PATH_SEP .'partner.info')) { - $this->systemName = $this->getSystemName($pathSharedPartner); - $_REQUEST["PARTNER_FLAG"] = true; - } - $this->setResponseType( 'json' ); - if ($_REQUEST['db_engine'] == 'mysql') { - $info = $this->createMySQLWorkspace(); - } else { - $info = $this->createMSSQLWorkspace(); - } + if (!$this->pmIsInstalled()) { + $pathSharedPartner = trim($_REQUEST['pathShared']); + if (file_exists(trim($pathSharedPartner, PATH_SEP) . PATH_SEP . 'partner.info')) { + $this->systemName = $this->getSystemName($pathSharedPartner); + $_REQUEST["PARTNER_FLAG"] = true; + } + $this->setResponseType('json'); + if ($_REQUEST['db_engine'] == 'mysql') { + $info = $this->createMySQLWorkspace(); + } else { + $info = $this->createMSSQLWorkspace(); + } - return $info; + return $info; + } else { + $this->displayError(); + } + } + + /** + * We check if processMaker is not installed + * + * @return boolean + */ + private function pmIsInstalled(){ + return file_exists(FILE_PATHS_INSTALLED); + } + + /** + * Display an error when processMaker is already installed + * + * @return void + */ + private function displayError(){ + $this->setJSVar('messageError', G::LoadTranslation('ID_PROCESSMAKER_ALREADY_INSTALLED')); + $this->includeExtJS('installer/stopInstall'); + $this->setView('installer/mainStopInstall'); + G::RenderPage('publish', 'extJs'); } public function forceTogenerateTranslationsFiles ($url) diff --git a/workflow/engine/methods/install/newSite.php b/workflow/engine/methods/install/newSite.php index 2ff893fc8..03f4f65a1 100644 --- a/workflow/engine/methods/install/newSite.php +++ b/workflow/engine/methods/install/newSite.php @@ -1,26 +1,7 @@ . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ + +global $RBAC; +$RBAC->allows(basename(__FILE__), basename(__FILE__)); if (isset( $_POST['form']['NW_TITLE'] )) { $action = (isset( $_POST['form']['ACTION'] )) ? trim( $_POST['form']['ACTION'] ) : 'test';