From b17a5eff62efc891bc185e7f539d0326e1287b34 Mon Sep 17 00:00:00 2001 From: norahmollo Date: Fri, 19 Oct 2012 18:07:17 +0000 Subject: [PATCH 1/4] CODE STYLE Format Change format --- workflow/engine/classes/class.processes.php | 7564 ++++++++--------- .../classes/model/CalendarDefinition.php | 922 +- workflow/engine/classes/model/Content.php | 874 +- workflow/engine/classes/model/Translation.php | 910 +- 4 files changed, 5129 insertions(+), 5141 deletions(-) diff --git a/workflow/engine/classes/class.processes.php b/workflow/engine/classes/class.processes.php index 06692368e..a63a0b1d9 100755 --- a/workflow/engine/classes/class.processes.php +++ b/workflow/engine/classes/class.processes.php @@ -1,3465 +1,3477 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ - -require_once 'classes/model/Content.php'; -require_once 'classes/model/Process.php'; -require_once 'classes/model/Task.php'; -require_once 'classes/model/Route.php'; -require_once 'classes/model/SwimlanesElements.php'; -require_once 'classes/model/InputDocument.php'; -require_once 'classes/model/ObjectPermission.php'; -require_once 'classes/model/OutputDocument.php'; -require_once 'classes/model/Step.php'; -require_once 'classes/model/StepTrigger.php'; -require_once 'classes/model/Dynaform.php'; -require_once 'classes/model/Triggers.php'; -require_once 'classes/model/Groupwf.php'; -require_once 'classes/model/ReportTable.php'; -require_once 'classes/model/ReportVar.php'; -require_once 'classes/model/DbSource.php'; -require_once 'classes/model/StepSupervisor.php'; -require_once 'classes/model/SubProcess.php'; -require_once 'classes/model/CaseTracker.php'; -require_once 'classes/model/CaseTrackerObject.php'; -require_once 'classes/model/Stage.php'; -require_once 'classes/model/TaskUser.php'; -require_once 'classes/model/FieldCondition.php'; -require_once 'classes/model/Event.php'; -require_once 'classes/model/CaseScheduler.php'; -require_once 'classes/model/ProcessCategory.php'; - -G::LoadClass( 'tasks' ); -G::LoadClass( 'reportTables' ); -G::LoadClass( 'processMap' ); -G::LoadThirdParty( 'pear/json', 'class.json' ); - -class Processes -{ - - /** - * change Status of any Process - * - * @param string $sProUid - * @return boolean - * @package workflow.engine.ProcessMaker - */ - function changeStatus ($sProUid = '') - { - $oProcess = new Process(); - $Fields = $oProcess->Load( $sProUid ); - $proFields['PRO_UID'] = $sProUid; - if ($Fields['PRO_STATUS'] == 'ACTIVE') - $proFields['PRO_STATUS'] = 'INACTIVE'; - else - $proFields['PRO_STATUS'] = 'ACTIVE'; - - $oProcess->Update( $proFields ); - } - - /** - * change debug mode of any Process - * - * @param string $sProUid - * @return boolean - * @package workflow.engine.ProcessMaker - */ - function changeDebugMode ($sProUid = '') - { - $oProcess = new Process(); - $Fields = $oProcess->Load( $sProUid ); - $proFields['PRO_UID'] = $sProUid; - if ($Fields['PRO_DEBUG'] == '1') - $proFields['PRO_DEBUG'] = '0'; - else - $proFields['PRO_DEBUG'] = '1'; - - $oProcess->Update( $proFields ); - } - - /** - * changes in DB the parent GUID - * - * @param $sProUid process uid - * @param $sParentUid process parent uid - * @return $sProUid - */ - function changeProcessParent ($sProUid, $sParentUid) - { - $oProcess = new Process(); - $Fields = $oProcess->Load( $sProUid ); - $proFields['PRO_UID'] = $sProUid; - $Fields['PRO_PARENT'] == $sParentUid; - $oProcess->Update( $proFields ); - } - - /** - * verify if the process $sProUid exists - * - * @param string $sProUid - * @return boolean - */ - function processExists ($sProUid = '') - { - $oProcess = new Process(); - return $oProcess->processExists( $sProUid ); - } - - /** - * get an unused process GUID - * - * @return $sProUid - */ - function getUnusedProcessGUID () - { - do { - $sNewProUid = G::generateUniqueID(); - } while ($this->processExists( $sNewProUid )); - return $sNewProUid; - } - - /** - * verify if the task $sTasUid exists - * - * @param string $sTasUid - * @return boolean - */ - function taskExists ($sTasUid = '') - { - $oTask = new Task(); - return $oTask->taskExists( $sTasUid ); - } - - /** - * get an unused task GUID - * - * @return $sTasUid - */ - function getUnusedTaskGUID () - { - do { - $sNewTasUid = G::generateUniqueID(); - } while ($this->taskExists( $sNewTasUid )); - return $sNewTasUid; - } - - /** - * verify if the dynaform $sDynUid exists - * - * @param string $sDynUid - * @return boolean - */ - function dynaformExists ($sDynUid = '') - { - $oDynaform = new Dynaform(); - return $oDynaform->dynaformExists( $sDynUid ); - } - - /** - * verify if the object exists - * - * @param string $sUid - * @return boolean - */ - function inputExists ($sUid = '') - { - $oInput = new InputDocument(); - return $oInput->inputExists( $sUid ); - } - - /** - * verify if the object exists - * - * @param string $sUid - * @return boolean - */ - function outputExists ($sUid = '') - { - $oOutput = new OutputDocument(); - return $oOutput->outputExists( $sUid ); - } - - /** - * verify if the object exists - * - * @param string $sUid - * @return boolean - */ - function triggerExists ($sUid = '') - { - $oTrigger = new Triggers(); - return $oTrigger->triggerExists( $sUid ); - } - - /** - * verify if the object exists - * - * @param string $sUid - * @return boolean - */ - function SubProcessExists ($sUid = '') - { - $oSubProcess = new SubProcess(); - return $oSubProcess->subProcessExists( $sUid ); - } - - /** - * verify if a caseTrackerObject object exists - * - * @param string $sUid - * @return boolean - */ - function caseTrackerObjectExists ($sUid = '') - { - $oCaseTrackerObject = new CaseTrackerObject(); - return $oCaseTrackerObject->caseTrackerObjectExists( $sUid ); - } - - /** - * verify if a caseTracker Object exists - * - * @param string $sUid - * @return boolean - */ - function caseTrackerExists ($sUid = '') - { - $oCaseTracker = new CaseTracker(); - return $oCaseTracker->caseTrackerExists( $sUid ); - } - - /** - * verify if a dbconnection exists - * - * @param string $sUid - * @return boolean - */ - function dbConnectionExists ($sUid = '') - { - $oDBSource = new DbSource(); - return $oDBSource->Exists( $sUid ); - } - - /** - * verify if a objectPermission exists - * - * @param string $sUid - * @return boolean - */ - function objectPermissionExists ($sUid = '') - { - $oObjectPermission = new ObjectPermission(); - return $oObjectPermission->Exists( $sUid ); - } - - /** - * verify if a route exists - * - * @param string $sUid - * @return boolean - */ - function routeExists ($sUid = '') - { - $oRoute = new Route(); - return $oRoute->routeExists( $sUid ); - } - - /** - * verify if a stage exists - * - * @param string $sUid - * @return boolean - */ - function stageExists ($sUid = '') - { - $oStage = new Stage(); - return $oStage->Exists( $sUid ); - } - - /** - * verify if a swimlane exists - * - * @param string $sUid - * @return boolean - */ - function slExists ($sUid = '') - { - $oSL = new SwimlanesElements(); - return $oSL->swimlanesElementsExists( $sUid ); - } - - /** - * verify if a reportTable exists - * - * @param string $sUid - * @return boolean - */ - function reportTableExists ($sUid = '') - { - $oReportTable = new ReportTable(); - return $oReportTable->reportTableExists( $sUid ); - } - - /** - * verify if a reportVar exists - * - * @param string $sUid - * @return boolean - */ - function reportVarExists ($sUid = '') - { - $oReportVar = new ReportVar(); - return $oReportVar->reportVarExists( $sUid ); - } - - /** - * verify if a caseTrackerObject exists - * - * @param string $sUid - * @return boolean - */ - function fieldsConditionsExists ($sUid = '') - { - $oFieldCondition = new FieldCondition(); - return $oFieldCondition->Exists( $sUid ); - } - - /** - * verify if an event exists - * - * @param string $sUid - * @return boolean - */ - function eventExists ($sUid = '') - { - $oEvent = new Event(); - return $oEvent->Exists( $sUid ); - } - - /** - * verify if a caseScheduler exists - * - * @param string $sUid - * @return boolean - */ - function caseSchedulerExists ($sUid = '') - { - $oCaseScheduler = new CaseScheduler(); - return $oCaseScheduler->Exists( $sUid ); - } - - /** - * get an unused input GUID - * - * @return $sProUid - */ - function getUnusedInputGUID () - { - do { - $sNewUid = G::generateUniqueID(); - } while ($this->inputExists( $sNewUid )); - return $sNewUid; - } - - /** - * get an unused output GUID - * - * @return $sProUid - */ - function getUnusedOutputGUID () - { - do { - $sNewUid = G::generateUniqueID(); - } while ($this->outputExists( $sNewUid )); - return $sNewUid; - } - - /** - * get an unused trigger GUID - * - * @return $sProUid - */ - function getUnusedTriggerGUID () - { - do { - $sNewUid = G::generateUniqueID(); - } while ($this->triggerExists( $sNewUid )); - return $sNewUid; - } - - /** - * get an unused trigger GUID - * - * @return $sProUid - */ - function getUnusedSubProcessGUID () - { - do { - $sNewUid = G::generateUniqueID(); - } while ($this->subProcessExists( $sNewUid )); - return $sNewUid; - } - - /** - * get a Unused CaseTrackerObject GUID - * - * @return $sNewUid a new generated Uid - */ - function getUnusedCaseTrackerObjectGUID () - { - do { - $sNewUid = G::generateUniqueID(); - } while ($this->caseTrackerObjectExists( $sNewUid )); - return $sNewUid; - } - - /** - * get a Unused Database Source GUID - * - * @return $sNewUid a new generated Uid - */ - function getUnusedDBSourceGUID () - { - do { - $sNewUid = G::generateUniqueID(); - } while ($this->dbConnectionExists( $sNewUid )); - return $sNewUid; - } - - /** - * get a Unused Object Permission GUID - * - * @return $sNewUid a new generated Uid - */ - function getUnusedObjectPermissionGUID () - { - do { - $sNewUid = G::generateUniqueID(); - } while ($this->objectPermissionExists( $sNewUid )); - return $sNewUid; - } - - /** - * get a Unused Route GUID - * - * @return $sNewUid a new generated Uid - */ - function getUnusedRouteGUID () - { - do { - $sNewUid = G::generateUniqueID(); - } while ($this->routeExists( $sNewUid )); - return $sNewUid; - } - - /** - * get a Unused Stage GUID - * - * @return $sNewUid a new generated Uid - */ - function getUnusedStageGUID () - { - do { - $sNewUid = G::generateUniqueID(); - } while ($this->stageExists( $sNewUid )); - return $sNewUid; - } - - /** - * get a Unused SL GUID - * - * @return $sNewUid a new generated Uid - */ - function getUnusedSLGUID () - { - do { - $sNewUid = G::generateUniqueID(); - } while ($this->slExists( $sNewUid )); - return $sNewUid; - } - - /** - * get a Unused Report Table GUID - * - * @return $sNewUid a new generated Uid - */ - function getUnusedRTGUID () - { - do { - $sNewUid = G::generateUniqueID(); - } while ($this->reportTableExists( $sNewUid )); - return $sNewUid; - } - - /** - * get a Unused Report Var GUID - * - * @return $sNewUid a new generated Uid - */ - function getUnusedRTVGUID () - { - do { - $sNewUid = G::generateUniqueID(); - } while ($this->reportVarExists( $sNewUid )); - return $sNewUid; - } - - /** - * verify if the object exists - * - * @param string $sUid - * @return boolean - */ - function stepExists ($sUid = '') - { - $oStep = new Step(); - return $oStep->stepExists( $sUid ); - } - - /** - * get an unused step GUID - * - * @return $sUid - */ - function getUnusedStepGUID () - { - do { - $sNewUid = G::generateUniqueID(); - } while ($this->stepExists( $sNewUid )); - return $sNewUid; - } - +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ + +require_once 'classes/model/Content.php'; +require_once 'classes/model/Process.php'; +require_once 'classes/model/Task.php'; +require_once 'classes/model/Route.php'; +require_once 'classes/model/SwimlanesElements.php'; +require_once 'classes/model/InputDocument.php'; +require_once 'classes/model/ObjectPermission.php'; +require_once 'classes/model/OutputDocument.php'; +require_once 'classes/model/Step.php'; +require_once 'classes/model/StepTrigger.php'; +require_once 'classes/model/Dynaform.php'; +require_once 'classes/model/Triggers.php'; +require_once 'classes/model/Groupwf.php'; +require_once 'classes/model/ReportTable.php'; +require_once 'classes/model/ReportVar.php'; +require_once 'classes/model/DbSource.php'; +require_once 'classes/model/StepSupervisor.php'; +require_once 'classes/model/SubProcess.php'; +require_once 'classes/model/CaseTracker.php'; +require_once 'classes/model/CaseTrackerObject.php'; +require_once 'classes/model/Stage.php'; +require_once 'classes/model/TaskUser.php'; +require_once 'classes/model/FieldCondition.php'; +require_once 'classes/model/Event.php'; +require_once 'classes/model/CaseScheduler.php'; +require_once 'classes/model/ProcessCategory.php'; + +G::LoadClass( 'tasks' ); +G::LoadClass( 'reportTables' ); +G::LoadClass( 'processMap' ); +G::LoadThirdParty( 'pear/json', 'class.json' ); + +class Processes +{ + /** + * change Status of any Process + * + * @param string $sProUid + * @return boolean + * @package workflow.engine.ProcessMaker + */ + public function changeStatus ($sProUid = '') + { + $oProcess = new Process(); + $Fields = $oProcess->Load( $sProUid ); + $proFields['PRO_UID'] = $sProUid; + if ($Fields['PRO_STATUS'] == 'ACTIVE') { + $proFields['PRO_STATUS'] = 'INACTIVE'; + } else { + $proFields['PRO_STATUS'] = 'ACTIVE'; + } + $oProcess->Update( $proFields ); + } + + /** + * change debug mode of any Process + * + * @param string $sProUid + * @return boolean + * @package workflow.engine.ProcessMaker + */ + public function changeDebugMode ($sProUid = '') + { + $oProcess = new Process(); + $Fields = $oProcess->Load( $sProUid ); + $proFields['PRO_UID'] = $sProUid; + if ($Fields['PRO_DEBUG'] == '1') { + $proFields['PRO_DEBUG'] = '0'; + } else { + $proFields['PRO_DEBUG'] = '1'; + } + $oProcess->Update( $proFields ); + } + + /** + * changes in DB the parent GUID + * + * @param $sProUid process uid + * @param $sParentUid process parent uid + * @return $sProUid + */ + public function changeProcessParent ($sProUid, $sParentUid) + { + $oProcess = new Process(); + $Fields = $oProcess->Load( $sProUid ); + $proFields['PRO_UID'] = $sProUid; + $Fields['PRO_PARENT'] == $sParentUid; + $oProcess->Update( $proFields ); + } + + /** + * verify if the process $sProUid exists + * + * @param string $sProUid + * @return boolean + */ + public function processExists ($sProUid = '') + { + $oProcess = new Process(); + return $oProcess->processExists( $sProUid ); + } + + /** + * get an unused process GUID + * + * @return $sProUid + */ + public function getUnusedProcessGUID () + { + do { + $sNewProUid = G::generateUniqueID(); + } while ($this->processExists( $sNewProUid )); + return $sNewProUid; + } + + /** + * verify if the task $sTasUid exists + * + * @param string $sTasUid + * @return boolean + */ + public function taskExists ($sTasUid = '') + { + $oTask = new Task(); + return $oTask->taskExists( $sTasUid ); + } + + /** + * get an unused task GUID + * + * @return $sTasUid + */ + public function getUnusedTaskGUID () + { + do { + $sNewTasUid = G::generateUniqueID(); + } while ($this->taskExists( $sNewTasUid )); + return $sNewTasUid; + } + + /** + * verify if the dynaform $sDynUid exists + * + * @param string $sDynUid + * @return boolean + */ + public function dynaformExists ($sDynUid = '') + { + $oDynaform = new Dynaform(); + return $oDynaform->dynaformExists( $sDynUid ); + } + + /** + * verify if the object exists + * + * @param string $sUid + * @return boolean + */ + public function inputExists ($sUid = '') + { + $oInput = new InputDocument(); + return $oInput->inputExists( $sUid ); + } + + /** + * verify if the object exists + * + * @param string $sUid + * @return boolean + */ + public function outputExists ($sUid = '') + { + $oOutput = new OutputDocument(); + return $oOutput->outputExists( $sUid ); + } + + /** + * verify if the object exists + * + * @param string $sUid + * @return boolean + */ + public function triggerExists ($sUid = '') + { + $oTrigger = new Triggers(); + return $oTrigger->triggerExists( $sUid ); + } + + /** + * verify if the object exists + * + * @param string $sUid + * @return boolean + */ + public function SubProcessExists ($sUid = '') + { + $oSubProcess = new SubProcess(); + return $oSubProcess->subProcessExists( $sUid ); + } + + /** + * verify if a caseTrackerObject object exists + * + * @param string $sUid + * @return boolean + */ + public function caseTrackerObjectExists ($sUid = '') + { + $oCaseTrackerObject = new CaseTrackerObject(); + return $oCaseTrackerObject->caseTrackerObjectExists( $sUid ); + } + + /** + * verify if a caseTracker Object exists + * + * @param string $sUid + * @return boolean + */ + public function caseTrackerExists ($sUid = '') + { + $oCaseTracker = new CaseTracker(); + return $oCaseTracker->caseTrackerExists( $sUid ); + } + + /** + * verify if a dbconnection exists + * + * @param string $sUid + * @return boolean + */ + public function dbConnectionExists ($sUid = '') + { + $oDBSource = new DbSource(); + return $oDBSource->Exists( $sUid ); + } + + /** + * verify if a objectPermission exists + * + * @param string $sUid + * @return boolean + */ + public function objectPermissionExists ($sUid = '') + { + $oObjectPermission = new ObjectPermission(); + return $oObjectPermission->Exists( $sUid ); + } + + /** + * verify if a route exists + * + * @param string $sUid + * @return boolean + */ + public function routeExists ($sUid = '') + { + $oRoute = new Route(); + return $oRoute->routeExists( $sUid ); + } + + /** + * verify if a stage exists + * + * @param string $sUid + * @return boolean + */ + public function stageExists ($sUid = '') + { + $oStage = new Stage(); + return $oStage->Exists( $sUid ); + } + + /** + * verify if a swimlane exists + * + * @param string $sUid + * @return boolean + */ + public function slExists ($sUid = '') + { + $oSL = new SwimlanesElements(); + return $oSL->swimlanesElementsExists( $sUid ); + } + + /** + * verify if a reportTable exists + * + * @param string $sUid + * @return boolean + */ + public function reportTableExists ($sUid = '') + { + $oReportTable = new ReportTable(); + return $oReportTable->reportTableExists( $sUid ); + } + + /** + * verify if a reportVar exists + * + * @param string $sUid + * @return boolean + */ + public function reportVarExists ($sUid = '') + { + $oReportVar = new ReportVar(); + return $oReportVar->reportVarExists( $sUid ); + } + + /** + * verify if a caseTrackerObject exists + * + * @param string $sUid + * @return boolean + */ + public function fieldsConditionsExists ($sUid = '') + { + $oFieldCondition = new FieldCondition(); + return $oFieldCondition->Exists( $sUid ); + } + + /** + * verify if an event exists + * + * @param string $sUid + * @return boolean + */ + public function eventExists ($sUid = '') + { + $oEvent = new Event(); + return $oEvent->Exists( $sUid ); + } + + /** + * verify if a caseScheduler exists + * + * @param string $sUid + * @return boolean + */ + public function caseSchedulerExists ($sUid = '') + { + $oCaseScheduler = new CaseScheduler(); + return $oCaseScheduler->Exists( $sUid ); + } + + /** + * get an unused input GUID + * + * @return $sProUid + */ + public function getUnusedInputGUID () + { + do { + $sNewUid = G::generateUniqueID(); + } while ($this->inputExists( $sNewUid )); + return $sNewUid; + } + + /** + * get an unused output GUID + * + * @return $sProUid + */ + public function getUnusedOutputGUID () + { + do { + $sNewUid = G::generateUniqueID(); + } while ($this->outputExists( $sNewUid )); + return $sNewUid; + } + + /** + * get an unused trigger GUID + * + * @return $sProUid + */ + public function getUnusedTriggerGUID () + { + do { + $sNewUid = G::generateUniqueID(); + } while ($this->triggerExists( $sNewUid )); + return $sNewUid; + } + + /** + * get an unused trigger GUID + * + * @return $sProUid + */ + public function getUnusedSubProcessGUID () + { + do { + $sNewUid = G::generateUniqueID(); + } while ($this->subProcessExists( $sNewUid )); + return $sNewUid; + } + + /** + * get a Unused CaseTrackerObject GUID + * + * @return $sNewUid a new generated Uid + */ + public function getUnusedCaseTrackerObjectGUID () + { + do { + $sNewUid = G::generateUniqueID(); + } while ($this->caseTrackerObjectExists( $sNewUid )); + return $sNewUid; + } + + /** + * get a Unused Database Source GUID + * + * @return $sNewUid a new generated Uid + */ + public function getUnusedDBSourceGUID () + { + do { + $sNewUid = G::generateUniqueID(); + } while ($this->dbConnectionExists( $sNewUid )); + return $sNewUid; + } + + /** + * get a Unused Object Permission GUID + * + * @return $sNewUid a new generated Uid + */ + public function getUnusedObjectPermissionGUID () + { + do { + $sNewUid = G::generateUniqueID(); + } while ($this->objectPermissionExists( $sNewUid )); + return $sNewUid; + } + + /** + * get a Unused Route GUID + * + * @return $sNewUid a new generated Uid + */ + public function getUnusedRouteGUID () + { + do { + $sNewUid = G::generateUniqueID(); + } while ($this->routeExists( $sNewUid )); + return $sNewUid; + } + + /** + * get a Unused Stage GUID + * + * @return $sNewUid a new generated Uid + */ + public function getUnusedStageGUID () + { + do { + $sNewUid = G::generateUniqueID(); + } while ($this->stageExists( $sNewUid )); + return $sNewUid; + } + + /** + * get a Unused SL GUID + * + * @return $sNewUid a new generated Uid + */ + public function getUnusedSLGUID () + { + do { + $sNewUid = G::generateUniqueID(); + } while ($this->slExists( $sNewUid )); + return $sNewUid; + } + + /** + * get a Unused Report Table GUID + * + * @return $sNewUid a new generated Uid + */ + public function getUnusedRTGUID () + { + do { + $sNewUid = G::generateUniqueID(); + } while ($this->reportTableExists( $sNewUid )); + return $sNewUid; + } + + /** + * get a Unused Report Var GUID + * + * @return $sNewUid a new generated Uid + */ + public function getUnusedRTVGUID () + { + do { + $sNewUid = G::generateUniqueID(); + } while ($this->reportVarExists( $sNewUid )); + return $sNewUid; + } + + /** + * verify if the object exists + * + * @param string $sUid + * @return boolean + */ + public function stepExists ($sUid = '') + { + $oStep = new Step(); + return $oStep->stepExists( $sUid ); + } + + /** + * get an unused step GUID + * + * @return $sUid + */ + public function getUnusedStepGUID () + { + do { + $sNewUid = G::generateUniqueID(); + } while ($this->stepExists( $sNewUid )); + return $sNewUid; + } + /* * get an unused Dynaform GUID * @return $sDynUid - */ - function getUnusedDynaformGUID () - { - do { - $sNewUid = G::generateUniqueID(); - } while ($this->dynaformExists( $sNewUid )); - return $sNewUid; - } - - /** - * get a Unused Field Condition GUID - * - * @return $sNewUid a new generated Uid - */ - function getUnusedFieldConditionGUID () - { - do { - $sNewUid = G::generateUniqueID(); - } while ($this->fieldsConditionsExists( $sNewUid )); - return $sNewUid; - } - - /** - * get a Unused Event GUID - * - * @return $sNewUid a new generated Uid - */ - function getUnusedEventGUID () - { - do { - $sNewUid = G::generateUniqueID(); - } while ($this->eventExists( $sNewUid )); - return $sNewUid; - } - - /** - * get a Unused Case Scheduler GUID - * - * @return $sNewUid a new generated Uid - */ - function getUnusedCaseSchedulerGUID () - { - do { - $sNewUid = G::generateUniqueID(); - } while ($this->caseSchedulerExists( $sNewUid )); - return $sNewUid; - } - - /** - * change the GUID for a serialized process - * - * @param string $sProUid - * @return boolean - */ - function setProcessGUID (&$oData, $sNewProUid) - { - $sProUid = $oData->process['PRO_UID']; - $oData->process['PRO_UID'] = $sNewProUid; - - if (isset( $oData->tasks ) && is_array( $oData->tasks )) { - foreach ($oData->tasks as $key => $val) { - $oData->tasks[$key]['PRO_UID'] = $sNewProUid; - } - } - - if (isset( $oData->routes ) && is_array( $oData->routes )) { - foreach ($oData->routes as $key => $val) { - $oData->routes[$key]['PRO_UID'] = $sNewProUid; - } - } - - if (isset( $oData->lanes ) && is_array( $oData->lanes )) { - foreach ($oData->lanes as $key => $val) { - $oData->lanes[$key]['PRO_UID'] = $sNewProUid; - } - } - - if (isset( $oData->inputs ) && is_array( $oData->inputs )) { - foreach ($oData->inputs as $key => $val) { - $oData->inputs[$key]['PRO_UID'] = $sNewProUid; - } - } - - if (isset( $oData->outputs ) && is_array( $oData->outputs )) { - foreach ($oData->outputs as $key => $val) { - $oData->outputs[$key]['PRO_UID'] = $sNewProUid; - } - } - - if (isset( $oData->steps ) && is_array( $oData->steps )) { - foreach ($oData->steps as $key => $val) { - $oData->steps[$key]['PRO_UID'] = $sNewProUid; - } - } - - if (isset( $oData->dynaforms ) && is_array( $oData->dynaforms )) { - foreach ($oData->dynaforms as $key => $val) { - $oData->dynaforms[$key]['PRO_UID'] = $sNewProUid; - } - } - - if (isset( $oData->triggers ) && is_array( $oData->triggers )) { - foreach ($oData->triggers as $key => $val) { - $oData->triggers[$key]['PRO_UID'] = $sNewProUid; - } - } - - if (isset( $oData->reportTables ) && is_array( $oData->reportTables )) { - foreach ($oData->reportTables as $key => $val) { - $oData->reportTables[$key]['PRO_UID'] = $sNewProUid; - } - } - - if (isset( $oData->reportTablesVars ) && is_array( $oData->reportTablesVars )) { - foreach ($oData->reportTablesVars as $key => $val) { - $oData->reportTablesVars[$key]['PRO_UID'] = $sNewProUid; - } - } - - if (isset( $oData->dbconnections ) && is_array( $oData->dbconnections )) { - foreach ($oData->dbconnections as $key => $val) { - $oData->dbconnections[$key]['PRO_UID'] = $sNewProUid; - } - } - - if (isset( $oData->stepSupervisor ) && is_array( $oData->stepSupervisor )) { - foreach ($oData->stepSupervisor as $key => $val) { - $oData->stepSupervisor[$key]['PRO_UID'] = $sNewProUid; - } - } - - if (isset( $oData->objectPermissions ) && is_array( $oData->objectPermissions )) { - foreach ($oData->objectPermissions as $key => $val) { - $oData->objectPermissions[$key]['PRO_UID'] = $sNewProUid; - } - } - - if (isset( $oData->caseTracker ) && is_array( $oData->caseTracker )) { - foreach ($oData->caseTracker as $key => $val) { - $oData->caseTracker[$key]['PRO_UID'] = $sNewProUid; - } - } - - if (isset( $oData->caseTrackerObject ) && is_array( $oData->caseTrackerObject )) { - foreach ($oData->caseTrackerObject as $key => $val) { - $oData->caseTrackerObject[$key]['PRO_UID'] = $sNewProUid; - } - } - - if (isset( $oData->stage ) && is_array( $oData->stage )) { - foreach ($oData->stage as $key => $val) { - $oData->stage[$key]['PRO_UID'] = $sNewProUid; - } - } - - if (isset( $oData->subProcess ) && is_array( $oData->subProcess )) { - foreach ($oData->subProcess as $key => $val) { - $oData->subProcess[$key]['PRO_PARENT'] = $sNewProUid; - } - } - - if (isset( $oData->event ) && is_array( $oData->event )) { - foreach ($oData->event as $key => $val) { - $oData->event[$key]['PRO_UID'] = $sNewProUid; - } - } - - if (isset( $oData->caseScheduler ) && is_array( $oData->caseScheduler )) { - foreach ($oData->caseScheduler as $key => $val) { - $oData->caseScheduler[$key]['PRO_UID'] = $sNewProUid; - } - } - return true; - } - - /** - * change the GUID Parent for a serialized process, only in serialized data - * - * @param string $sProUid - * @return boolean - */ - function setProcessParent (&$oData, $sParentUid) - { - $oData->process['PRO_PARENT'] = $sParentUid; - $oData->process['PRO_CREATE_DATE'] = date( 'Y-m-d H:i:s' ); - $oData->process['PRO_UPDATE_DATE'] = date( 'Y-m-d H:i:s' ); - return true; - } - - /** - * change and Renew all Task GUID, because the process needs to have a new set of tasks - * - * @param string $oData - * @return boolean - */ - function renewAllTaskGuid (&$oData) - { - $map = array (); - foreach ($oData->tasks as $key => $val) { - $newGuid = $this->getUnusedTaskGUID(); - $map[$val['TAS_UID']] = $newGuid; - $oData->tasks[$key]['TAS_UID'] = $newGuid; - } - if (isset( $oData->routes ) && is_array( $oData->routes )) { - foreach ($oData->routes as $key => $val) { - $newGuid = $map[$val['TAS_UID']]; - $oData->routes[$key]['TAS_UID'] = $newGuid; - if (strlen( $val['ROU_NEXT_TASK'] ) > 0 && $val['ROU_NEXT_TASK'] > 0) { - $newGuid = $map[$val['ROU_NEXT_TASK']]; - $oData->routes[$key]['ROU_NEXT_TASK'] = $newGuid; - } - } - } - - if (isset( $oData->steps ) && is_array( $oData->steps )) { - foreach ($oData->steps as $key => $val) { - $newGuid = $map[$val['TAS_UID']]; - $oData->steps[$key]['TAS_UID'] = $newGuid; - } - } - - if (isset( $oData->steptriggers ) && is_array( $oData->steptriggers )) { - foreach ($oData->steptriggers as $key => $val) { - $newGuid = $map[$val['TAS_UID']]; - $oData->steptriggers[$key]['TAS_UID'] = $newGuid; - } - } - - if (isset( $oData->taskusers ) && is_array( $oData->taskusers )) { - foreach ($oData->taskusers as $key => $val) { - $newGuid = $map[$val['TAS_UID']]; - $oData->taskusers[$key]['TAS_UID'] = $newGuid; - } - } - - if (isset( $oData->subProcess ) && is_array( $oData->subProcess )) { - foreach ($oData->subProcess as $key => $val) { - $newGuid = $map[$val['TAS_PARENT']]; - $oData->subProcess[$key]['TAS_PARENT'] = $newGuid; - if (isset( $map[$val['TAS_UID']] )) { - $newGuid = $map[$val['TAS_UID']]; - $oData->subProcess[$key]['TAS_UID'] = $newGuid; - } - } - } - - if (isset( $oData->objectPermissions ) && is_array( $oData->objectPermissions )) { - foreach ($oData->objectPermissions as $key => $val) { - if (isset( $map[$val['TAS_UID']] )) { - $newGuid = $map[$val['TAS_UID']]; - $oData->objectPermissions[$key]['TAS_UID'] = $newGuid; - } - } - } - + */ + public function getUnusedDynaformGUID () + { + do { + $sNewUid = G::generateUniqueID(); + } while ($this->dynaformExists( $sNewUid )); + return $sNewUid; + } + + /** + * get a Unused Field Condition GUID + * + * @return $sNewUid a new generated Uid + */ + public function getUnusedFieldConditionGUID () + { + do { + $sNewUid = G::generateUniqueID(); + } while ($this->fieldsConditionsExists( $sNewUid )); + return $sNewUid; + } + + /** + * get a Unused Event GUID + * + * @return $sNewUid a new generated Uid + */ + public function getUnusedEventGUID () + { + do { + $sNewUid = G::generateUniqueID(); + } while ($this->eventExists( $sNewUid )); + return $sNewUid; + } + + /** + * get a Unused Case Scheduler GUID + * + * @return $sNewUid a new generated Uid + */ + public function getUnusedCaseSchedulerGUID () + { + do { + $sNewUid = G::generateUniqueID(); + } while ($this->caseSchedulerExists( $sNewUid )); + return $sNewUid; + } + + /** + * change the GUID for a serialized process + * + * @param string $sProUid + * @return boolean + */ + public function setProcessGUID (&$oData, $sNewProUid) + { + $sProUid = $oData->process['PRO_UID']; + $oData->process['PRO_UID'] = $sNewProUid; + + if (isset( $oData->tasks ) && is_array( $oData->tasks )) { + foreach ($oData->tasks as $key => $val) { + $oData->tasks[$key]['PRO_UID'] = $sNewProUid; + } + } + + if (isset( $oData->routes ) && is_array( $oData->routes )) { + foreach ($oData->routes as $key => $val) { + $oData->routes[$key]['PRO_UID'] = $sNewProUid; + } + } + + if (isset( $oData->lanes ) && is_array( $oData->lanes )) { + foreach ($oData->lanes as $key => $val) { + $oData->lanes[$key]['PRO_UID'] = $sNewProUid; + } + } + + if (isset( $oData->inputs ) && is_array( $oData->inputs )) { + foreach ($oData->inputs as $key => $val) { + $oData->inputs[$key]['PRO_UID'] = $sNewProUid; + } + } + + if (isset( $oData->outputs ) && is_array( $oData->outputs )) { + foreach ($oData->outputs as $key => $val) { + $oData->outputs[$key]['PRO_UID'] = $sNewProUid; + } + } + + if (isset( $oData->steps ) && is_array( $oData->steps )) { + foreach ($oData->steps as $key => $val) { + $oData->steps[$key]['PRO_UID'] = $sNewProUid; + } + } + + if (isset( $oData->dynaforms ) && is_array( $oData->dynaforms )) { + foreach ($oData->dynaforms as $key => $val) { + $oData->dynaforms[$key]['PRO_UID'] = $sNewProUid; + } + } + + if (isset( $oData->triggers ) && is_array( $oData->triggers )) { + foreach ($oData->triggers as $key => $val) { + $oData->triggers[$key]['PRO_UID'] = $sNewProUid; + } + } + + if (isset( $oData->reportTables ) && is_array( $oData->reportTables )) { + foreach ($oData->reportTables as $key => $val) { + $oData->reportTables[$key]['PRO_UID'] = $sNewProUid; + } + } + + if (isset( $oData->reportTablesVars ) && is_array( $oData->reportTablesVars )) { + foreach ($oData->reportTablesVars as $key => $val) { + $oData->reportTablesVars[$key]['PRO_UID'] = $sNewProUid; + } + } + + if (isset( $oData->dbconnections ) && is_array( $oData->dbconnections )) { + foreach ($oData->dbconnections as $key => $val) { + $oData->dbconnections[$key]['PRO_UID'] = $sNewProUid; + } + } + + if (isset( $oData->stepSupervisor ) && is_array( $oData->stepSupervisor )) { + foreach ($oData->stepSupervisor as $key => $val) { + $oData->stepSupervisor[$key]['PRO_UID'] = $sNewProUid; + } + } + + if (isset( $oData->objectPermissions ) && is_array( $oData->objectPermissions )) { + foreach ($oData->objectPermissions as $key => $val) { + $oData->objectPermissions[$key]['PRO_UID'] = $sNewProUid; + } + } + + if (isset( $oData->caseTracker ) && is_array( $oData->caseTracker )) { + foreach ($oData->caseTracker as $key => $val) { + $oData->caseTracker[$key]['PRO_UID'] = $sNewProUid; + } + } + + if (isset( $oData->caseTrackerObject ) && is_array( $oData->caseTrackerObject )) { + foreach ($oData->caseTrackerObject as $key => $val) { + $oData->caseTrackerObject[$key]['PRO_UID'] = $sNewProUid; + } + } + + if (isset( $oData->stage ) && is_array( $oData->stage )) { + foreach ($oData->stage as $key => $val) { + $oData->stage[$key]['PRO_UID'] = $sNewProUid; + } + } + + if (isset( $oData->subProcess ) && is_array( $oData->subProcess )) { + foreach ($oData->subProcess as $key => $val) { + $oData->subProcess[$key]['PRO_PARENT'] = $sNewProUid; + } + } + + if (isset( $oData->event ) && is_array( $oData->event )) { + foreach ($oData->event as $key => $val) { + $oData->event[$key]['PRO_UID'] = $sNewProUid; + } + } + + if (isset( $oData->caseScheduler ) && is_array( $oData->caseScheduler )) { + foreach ($oData->caseScheduler as $key => $val) { + $oData->caseScheduler[$key]['PRO_UID'] = $sNewProUid; + } + } + return true; + } + + /** + * change the GUID Parent for a serialized process, only in serialized data + * + * @param string $sProUid + * @return boolean + */ + public function setProcessParent (&$oData, $sParentUid) + { + $oData->process['PRO_PARENT'] = $sParentUid; + $oData->process['PRO_CREATE_DATE'] = date( 'Y-m-d H:i:s' ); + $oData->process['PRO_UPDATE_DATE'] = date( 'Y-m-d H:i:s' ); + return true; + } + + /** + * change and Renew all Task GUID, because the process needs to have a new set of tasks + * + * @param string $oData + * @return boolean + */ + public function renewAllTaskGuid (&$oData) + { + $map = array (); + foreach ($oData->tasks as $key => $val) { + $newGuid = $this->getUnusedTaskGUID(); + $map[$val['TAS_UID']] = $newGuid; + $oData->tasks[$key]['TAS_UID'] = $newGuid; + } + if (isset( $oData->routes ) && is_array( $oData->routes )) { + foreach ($oData->routes as $key => $val) { + $newGuid = $map[$val['TAS_UID']]; + $oData->routes[$key]['TAS_UID'] = $newGuid; + if (strlen( $val['ROU_NEXT_TASK'] ) > 0 && $val['ROU_NEXT_TASK'] > 0) { + $newGuid = $map[$val['ROU_NEXT_TASK']]; + $oData->routes[$key]['ROU_NEXT_TASK'] = $newGuid; + } + } + } + + if (isset( $oData->steps ) && is_array( $oData->steps )) { + foreach ($oData->steps as $key => $val) { + $newGuid = $map[$val['TAS_UID']]; + $oData->steps[$key]['TAS_UID'] = $newGuid; + } + } + + if (isset( $oData->steptriggers ) && is_array( $oData->steptriggers )) { + foreach ($oData->steptriggers as $key => $val) { + $newGuid = $map[$val['TAS_UID']]; + $oData->steptriggers[$key]['TAS_UID'] = $newGuid; + } + } + + if (isset( $oData->taskusers ) && is_array( $oData->taskusers )) { + foreach ($oData->taskusers as $key => $val) { + $newGuid = $map[$val['TAS_UID']]; + $oData->taskusers[$key]['TAS_UID'] = $newGuid; + } + } + + if (isset( $oData->subProcess ) && is_array( $oData->subProcess )) { + foreach ($oData->subProcess as $key => $val) { + $newGuid = $map[$val['TAS_PARENT']]; + $oData->subProcess[$key]['TAS_PARENT'] = $newGuid; + if (isset( $map[$val['TAS_UID']] )) { + $newGuid = $map[$val['TAS_UID']]; + $oData->subProcess[$key]['TAS_UID'] = $newGuid; + } + } + } + + if (isset( $oData->objectPermissions ) && is_array( $oData->objectPermissions )) { + foreach ($oData->objectPermissions as $key => $val) { + if (isset( $map[$val['TAS_UID']] )) { + $newGuid = $map[$val['TAS_UID']]; + $oData->objectPermissions[$key]['TAS_UID'] = $newGuid; + } + } + } + // New process bpmn - if (isset( $oData->event ) && is_array( $oData->event )) { - foreach ($oData->event as $key => $val) { - if (isset( $val['EVN_TAS_UID_FROM'] ) && isset( $map[$val['EVN_TAS_UID_FROM']] )) { - $newGuid = $map[$val['EVN_TAS_UID_FROM']]; - $oData->event[$key]['EVN_TAS_UID_FROM'] = $newGuid; - } - } - } - - if (isset( $oData->caseScheduler ) && is_array( $oData->caseScheduler )) { - foreach ($oData->caseScheduler as $key => $val) { - if (isset( $map[$val['TAS_UID']] )) { - $newGuid = $map[$val['TAS_UID']]; - $oData->caseScheduler[$key]['TAS_UID'] = $newGuid; - } - } - } - - } - - /** - * change and Renew all Dynaform GUID, because the process needs to have a new set of dynaforms - * - * @param string $oData - * @return boolean - */ - function renewAllDynaformGuid (&$oData) - { - $map = array (); - foreach ($oData->dynaforms as $key => $val) { - $newGuid = $this->getUnusedDynaformGUID(); - $map[$val['DYN_UID']] = $newGuid; - $oData->dynaforms[$key]['DYN_UID'] = $newGuid; - } - - if (isset( $oData->process['PRO_DYNAFORMS'] ) && ! is_array( $oData->process['PRO_DYNAFORMS'] )) { - $oData->process['PRO_DYNAFORMS'] = @unserialize( $oData->process['PRO_DYNAFORMS'] ); - } - - if (! isset( $oData->process['PRO_DYNAFORMS']['PROCESS'] )) { - $oData->process['PRO_DYNAFORMS']['PROCESS'] = ''; - } - - if ($oData->process['PRO_DYNAFORMS']['PROCESS'] != '') { - $oData->process['PRO_DYNAFORMS']['PROCESS'] = $map[$oData->process['PRO_DYNAFORMS']['PROCESS']]; - } - - foreach ($oData->steps as $key => $val) { - if ($val['STEP_TYPE_OBJ'] == 'DYNAFORM') { - $newGuid = $map[$val['STEP_UID_OBJ']]; - $oData->steps[$key]['STEP_UID_OBJ'] = $newGuid; - } - } - - if (isset( $oData->caseTrackerObject ) && is_array( $oData->caseTrackerObject )) { - foreach ($oData->caseTrackerObject as $key => $val) { - if ($val['CTO_TYPE_OBJ'] == 'DYNAFORM') { - $newGuid = $map[$val['CTO_UID_OBJ']]; - $oData->steps[$key]['CTO_UID_OBJ'] = $newGuid; - } - } - } - if (isset( $oData->objectPermissions ) && is_array( $oData->objectPermissions )) { - foreach ($oData->objectPermissions as $key => $val) { - if ($val['OP_OBJ_TYPE'] == 'DYNAFORM') { - if (isset( $map[$val['OP_OBJ_UID']] )) { - $newGuid = $map[$val['OP_OBJ_UID']]; - $oData->objectPermissions[$key]['OP_OBJ_UID'] = $newGuid; - } - } - } - } - if (isset( $oData->stepSupervisor ) && is_array( $oData->stepSupervisor )) { - foreach ($oData->stepSupervisor as $key => $val) { - if ($val['STEP_TYPE_OBJ'] == 'DYNAFORM') { - $newGuid = $map[$val['STEP_UID_OBJ']]; - $oData->stepSupervisor[$key]['STEP_UID_OBJ'] = $newGuid; - } - } - foreach ($oData->dynaformFiles as $key => $val) { - $newGuid = $map[$key]; - $oData->dynaformFiles[$key] = $newGuid; - } - } - if (isset( $oData->gridFiles )) { - foreach ($oData->gridFiles as $key => $val) { - $newGuid = $map[$key]; - $oData->gridFiles[$key] = $newGuid; - } - } - if (isset( $oData->fieldCondition ) && is_array( $oData->fieldCondition )) { - foreach ($oData->fieldCondition as $key => $val) { - $newGuid = $map[$val['FCD_DYN_UID']]; - $oData->fieldCondition[$key]['FCD_DYN_UID'] = $newGuid; - } - } - - } - - /** - * get a Process with a search based in the process Uid - * - * @param $sProUid string process Uid - * @return $oProcess Process object - */ - function getProcessRow ($sProUid, $getAllLang = false) - { - $oProcess = new Process(); - return $oProcess->Load( $sProUid, $getAllLang ); - } - - /** - * creates a process new process if a process exists with the same uid of the - * $row['PRO_UID'] parameter then deletes it from the database and creates - * a new one based on the $row parameter - * - * @param $row array parameter with the process data - * @return $oProcess Process object - */ - function createProcessRow ($row) - { - $oProcess = new Process(); - if ($oProcess->processExists( $row['PRO_UID'] )) { - $oProcess->remove( $row['PRO_UID'] ); - } - - return $oProcess->createRow( $row ); - } - - /** - * Update a Process register in DB, if the process doesn't exist with the same - * uid of the $row['PRO_UID'] parameter the function creates a new one based - * on the $row parameter data. - * - * @param $row array parameter with the process data - * @return $oProcess Process object - */ - function updateProcessRow ($row) - { - $oProcess = new Process(); - if ($oProcess->processExists( $row['PRO_UID'] )) - $oProcess->update( $row ); - else - $oProcess->create( $row ); - } - - /** - * Gets the subprocess data from a process and returns it in an array. - * - * @param $sProUid string for the process Uid - * @return $aSubProcess array - */ - function getSubProcessRow ($sProUid) - { - try { - $aSubProcess = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( SubProcessPeer::PRO_PARENT, $sProUid ); - $oDataset = SubProcessPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $aSubProcess[] = $aRow; - $oDataset->next(); - } - return $aSubProcess; - } catch (Exception $oError) { - throw ($oError); - } - } - - /** - * Gets a case Tracker Row from a process and returns it in an array. - * - * @param $sProUid string for the process Uid - * @return $aCaseTracker array - */ - - function getCaseTrackerRow ($sProUid) - { - try { - $aCaseTracker = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( CaseTrackerPeer::PRO_UID, $sProUid ); - $oDataset = CaseTrackerPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $aCaseTracker[] = $aRow; - $oDataset->next(); - } - return $aCaseTracker; - } catch (Exception $oError) { - throw ($oError); - } - } - - /** - * Gets a case TrackerObject Row from a process and returns it in an array. - * - * @param $sProUid string for the process Uid - * @return $aCaseTracker array - */ - function getCaseTrackerObjectRow ($sProUid) - { - try { - $aCaseTrackerObject = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( CaseTrackerObjectPeer::PRO_UID, $sProUid ); - $oDataset = CaseTrackerObjectPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $aCaseTrackerObject[] = $aRow; - $oDataset->next(); - } - return $aCaseTrackerObject; - } catch (Exception $oError) { - throw ($oError); - } - } - - /** - * Gets a Stage Row from a process and returns it in an array. - * - * @param $sProUid string for the process Uid - * @return $aStage array - */ - function getStageRow ($sProUid) - { - try { - $aStage = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( StagePeer::PRO_UID, $sProUid ); - $oDataset = StagePeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $oStage = new Stage(); - $aStage[] = $oStage->load( $aRow['STG_UID'] ); - $oDataset->next(); - } - return $aStage; - } catch (Exception $oError) { - throw ($oError); - } - } - - /** - * Gets the Field Conditions from a process and returns those in an array. - * - * @param $sProUid string for the process Uid - * @return $aFieldCondition array - */ - - function getFieldCondition ($sProUid) - { - try { - $aFieldCondition = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( DynaformPeer::PRO_UID, $sProUid ); - $oCriteria->addJoin( DynaformPeer::DYN_UID, FieldConditionPeer::FCD_DYN_UID ); - - $oDataset = FieldConditionPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $aFieldCondition[] = $aRow; - $oDataset->next(); - } - return $aFieldCondition; - } catch (Exception $oError) { - throw ($oError); - } - } - - /** - * Gets the Event rows from a process and returns those in an array. - * - * @param $sProUid string for the process Uid - * @return $aEvent array - */ - function getEventRow ($sProUid) - { - try { - $aEvent = array (); - $oCriteria = new Criteria( 'workflow' ); - - $oCriteria->add( EventPeer::PRO_UID, $sProUid ); - $oDataset = EventPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $oEvent = new Event(); - $aEvent[] = $oEvent->load( $aRow['EVN_UID'] ); - $oDataset->next(); - } - return $aEvent; - } catch (Exception $oError) { - throw ($oError); - } - } - - /** - * Gets the Cases Scheduler rows from a process and returns those in an array. - * - * @param $sProUid string for the process Uid - * @return $aCaseScheduler array - */ - function getCaseSchedulerRow ($sProUid) - { - try { - $aCaseScheduler = array (); - $oCriteria = new Criteria( 'workflow' ); - - $oCriteria->add( CaseSchedulerPeer::PRO_UID, $sProUid ); - $oDataset = CaseSchedulerPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $oCaseScheduler = new CaseScheduler(); - $aCaseScheduler[] = $oCaseScheduler->load( $aRow['SCH_UID'] ); - $oDataset->next(); - } - return $aCaseScheduler; - } catch (Exception $oError) { - throw ($oError); - } - } - - /** - * Gets processCategory record, if the process had one - * - * @param $sProUid string for the process Uid - * @return $processCategory array - */ - public function getProcessCategoryRow ($sProUid) - { - $process = ProcessPeer::retrieveByPK( $sProUid ); - - if ($process->getProCategory() == '') { - return null; - } - - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( ProcessCategoryPeer::CATEGORY_UID, $process->getProCategory() ); - $oDataset = ProcessCategoryPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - - return $oDataset->getRow(); - } - - /** - * Get all Swimlanes Elements for any Process - * - * @param string $sProUid - * @return array - */ - public function getAllLanes ($sProUid) - { - try { - $aLanes = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( SwimlanesElementsPeer::PRO_UID, $sProUid ); - $oDataset = SwimlanesElementsPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $oSwim = new SwimlanesElements(); - $aLanes[] = $oSwim->Load( $aRow['SWI_UID'] ); - $oDataset->next(); - } - return $aLanes; - } catch (Exception $oError) { - throw ($oError); - } - } - - /** - * Get Task Rows from a process and returns those in an array. - * - * @param $sProUid string for the process Uid - * @return $oTask array - */ - function getTaskRows ($sProUid) - { - $oTask = new Tasks(); - return $oTask->getAllTasks( $sProUid ); - } - - /** - * Create Task Rows from a $aTasks array data and returns those in an array. - * - * @param $aTasks array - * @return $oTask array - */ - function createTaskRows ($aTasks) - { - $oTask = new Tasks(); - return $oTask->createTaskRows( $aTasks ); - } - - /** - * Update Task Rows from a $aTasks array data and returns those in an array. - * - * @param $aTasks array - * @return $oTask array - */ - function updateTaskRows ($aTasks) - { - $oTask = new Tasks(); - return $oTask->updateTaskRows( $aTasks ); - } - - /** - * Gets all Route rows from a Process and returns those in an array. - * - * @param $sProUid string for the process Uid - * @return $oTask Tasks array - */ - function getRouteRows ($sProUid) - { - $oTask = new Tasks(); - return $oTask->getAllRoutes( $sProUid ); - } - - /** - * Create Route Rows from a $aRoutes array data and returns those in an array. - * - * @param $aRoutes array - * @return $oTask Tasks array - */ - function createRouteRows ($aRoutes) - { - $oTask = new Tasks(); - return $oTask->createRouteRows( $aRoutes ); - } - - /** - * Update Route Rows from a $aRoutes array data and returns those in an array. - * - * @param $aRoutes array - * @return $oTask Tasks array - */ - function updateRouteRows ($aRoutes) - { - $oTask = new Tasks(); - return $oTask->updateRouteRows( $aRoutes ); - } - - /** - * Get Lane Rows from a Process and returns those in an array. - * - * @param $sProUid string for the process Uid - * @return array - */ - function getLaneRows ($sProUid) - { - return $this->getAllLanes( $sProUid ); - } - - /** - * Get Gateway Rows from a process and returns those in an array. - * - * @param $sProUid string for the process Uid - * @return $oTask array - */ - function getGatewayRows ($sProUid) - { - $oTask = new Tasks(); - return $oTask->getAllGateways( $sProUid ); - } - - /** - * Create Gateway Rows from a $aGateways array data and returns those in an array. - * - * @param $aGateways array - * @return $oGateway array - */ - function createGatewayRows ($aGateways) - { - $oTask = new Tasks(); - return $oTask->createGatewayRows( $aGateways ); - } - - /** - * Create Lane Rows from a $aLanes array data and returns those in an array. - * - * @param $aLanes array. - * @return void - */ - function createLaneRows ($aLanes) - { - foreach ($aLanes as $key => $row) { - $oLane = new SwimlanesElements(); - if ($oLane->swimlanesElementsExists( $row['SWI_UID'] )) - $oLane->remove( $row['SWI_UID'] ); - - $res = $oLane->create( $row ); - } - return; - } - - /** - * Create Sub Process rows from an array, removing those subprocesses with - * the same UID. - * - * @param $SubProcess array - * @return void. - */ - function createSubProcessRows ($SubProcess) - { - foreach ($SubProcess as $key => $row) { - $oSubProcess = new SubProcess(); - if ($oSubProcess->subProcessExists( $row['SP_UID'] )) - $oSubProcess->remove( $row['SP_UID'] ); - - $res = $oSubProcess->create( $row ); - } - return; - } - - /** - * Create Case Tracker rows from an array, removing those Trackers with - * the same UID. - * - * @param $CaseTracker array. - * @return void - */ - function createCaseTrackerRows ($CaseTracker) - { - if (is_array( $CaseTracker )) - foreach ($CaseTracker as $key => $row) { - $oCaseTracker = new CaseTracker(); - if ($oCaseTracker->caseTrackerExists( $row['PRO_UID'] )) - $oCaseTracker->remove( $row['PRO_UID'] ); - $res = $oCaseTracker->create( $row ); - } - return; - } - - /** - * Create Case Tracker Objects rows from an array, removing those Objects - * with the same UID, and recreaiting those from the array data. - * - * @param $CaseTrackerObject array. - * @return void - */ - function createCaseTrackerObjectRows ($CaseTrackerObject) - { - foreach ($CaseTrackerObject as $key => $row) { - $oCaseTrackerObject = new CaseTrackerObject(); - if ($oCaseTrackerObject->caseTrackerObjectExists( $row['CTO_UID'] )) - $oCaseTrackerObject->remove( $row['CTO_UID'] ); - $res = $oCaseTrackerObject->create( $row ); - } - return; - } - - /** - * Create Object Permissions rows from an array, removing those Objects - * with the same UID, and recreaiting the records from the array data. - * - * @param $sProUid string for the process Uid. - * @return void - */ - function createObjectPermissionsRows ($ObjectPermissions) - { - foreach ($ObjectPermissions as $key => $row) { - $oObjectPermissions = new ObjectPermission(); - if ($oObjectPermissions->Exists( $row['OP_UID'] )) - $oObjectPermissions->remove( $row['OP_UID'] ); - $res = $oObjectPermissions->create( $row ); - } - return; - } - - /** - * Create Stage rows from an array, removing those Objects - * with the same UID, and recreaiting the records from the array data. - * - * @param $Stage array. - * @return void - */ - function createStageRows ($Stage) - { - foreach ($Stage as $key => $row) { - $oStage = new Stage(); - if ($oStage->Exists( $row['STG_UID'] )) - $oStage->remove( $row['STG_UID'] ); - $res = $oStage->create( $row ); - } - return; - } - - /** - * Create Field Conditions from an array of Field Conditions and Dynaforms, - * removing those Objects with the same UID, and recreaiting the records - * from the arrays data. - * - * @param $aFieldCondition array. - * @param $aDynaform array. - * @return void - */ - function createFieldCondition ($aFieldCondition, $aDynaform) - { - if (is_array( $aFieldCondition )) - foreach ($aFieldCondition as $key => $row) { - $oFieldCondition = new FieldCondition(); - if ($oFieldCondition->fieldConditionExists( $row['FCD_UID'], $aDynaform )) - $oFieldCondition->remove( $row['FCD_UID'] ); - $res = $oFieldCondition->create( $row ); - } - return; - } - - /** - * Create Event rows from an array, removing those Objects - * with the same UID, and recreaiting the records from the array data. - * - * @param $Event array. - * @return void - */ - function createEventRows ($Event) - { - foreach ($Event as $key => $row) { - $oEvent = new Event(); - if ($oEvent->Exists( $row['EVN_UID'] )) - $oEvent->remove( $row['EVN_UID'] ); - - $res = $oEvent->create( $row ); - } - return; - } - - /** - * Create Case Scheduler Rows from an array, removing those Objects - * with the same UID, and recreaiting the records from the array data. - * - * @param $CaseScheduler array. - * @return void - */ - function createCaseSchedulerRows ($CaseScheduler) - { - foreach ($CaseScheduler as $key => $row) { - $oCaseScheduler = new CaseScheduler(); - if ($oCaseScheduler->Exists( $row['SCH_UID'] )) - $oCaseScheduler->remove( $row['SCH_UID'] ); - - $res = $oCaseScheduler->create( $row ); - } - return; - } - - /** - * Create ProcessCategory record - * - * @param $ProcessCategory array. - * @return void - */ - function createProcessCategoryRow ($row) - { - if ($row && is_array( $row ) && isset( $row['CATEGORY_UID'] )) { - $record = ProcessCategoryPeer::retrieveByPK( $row['CATEGORY_UID'] ); + if (isset( $oData->event ) && is_array( $oData->event )) { + foreach ($oData->event as $key => $val) { + if (isset( $val['EVN_TAS_UID_FROM'] ) && isset( $map[$val['EVN_TAS_UID_FROM']] )) { + $newGuid = $map[$val['EVN_TAS_UID_FROM']]; + $oData->event[$key]['EVN_TAS_UID_FROM'] = $newGuid; + } + } + } + + if (isset( $oData->caseScheduler ) && is_array( $oData->caseScheduler )) { + foreach ($oData->caseScheduler as $key => $val) { + if (isset( $map[$val['TAS_UID']] )) { + $newGuid = $map[$val['TAS_UID']]; + $oData->caseScheduler[$key]['TAS_UID'] = $newGuid; + } + } + } + + } + + /** + * change and Renew all Dynaform GUID, because the process needs to have a new set of dynaforms + * + * @param string $oData + * @return boolean + */ + public function renewAllDynaformGuid (&$oData) + { + $map = array (); + foreach ($oData->dynaforms as $key => $val) { + $newGuid = $this->getUnusedDynaformGUID(); + $map[$val['DYN_UID']] = $newGuid; + $oData->dynaforms[$key]['DYN_UID'] = $newGuid; + } + + if (isset( $oData->process['PRO_DYNAFORMS'] ) && ! is_array( $oData->process['PRO_DYNAFORMS'] )) { + $oData->process['PRO_DYNAFORMS'] = @unserialize( $oData->process['PRO_DYNAFORMS'] ); + } + + if (! isset( $oData->process['PRO_DYNAFORMS']['PROCESS'] )) { + $oData->process['PRO_DYNAFORMS']['PROCESS'] = ''; + } + + if ($oData->process['PRO_DYNAFORMS']['PROCESS'] != '') { + $oData->process['PRO_DYNAFORMS']['PROCESS'] = $map[$oData->process['PRO_DYNAFORMS']['PROCESS']]; + } + + foreach ($oData->steps as $key => $val) { + if ($val['STEP_TYPE_OBJ'] == 'DYNAFORM') { + $newGuid = $map[$val['STEP_UID_OBJ']]; + $oData->steps[$key]['STEP_UID_OBJ'] = $newGuid; + } + } + + if (isset( $oData->caseTrackerObject ) && is_array( $oData->caseTrackerObject )) { + foreach ($oData->caseTrackerObject as $key => $val) { + if ($val['CTO_TYPE_OBJ'] == 'DYNAFORM') { + $newGuid = $map[$val['CTO_UID_OBJ']]; + $oData->steps[$key]['CTO_UID_OBJ'] = $newGuid; + } + } + } + if (isset( $oData->objectPermissions ) && is_array( $oData->objectPermissions )) { + foreach ($oData->objectPermissions as $key => $val) { + if ($val['OP_OBJ_TYPE'] == 'DYNAFORM') { + if (isset( $map[$val['OP_OBJ_UID']] )) { + $newGuid = $map[$val['OP_OBJ_UID']]; + $oData->objectPermissions[$key]['OP_OBJ_UID'] = $newGuid; + } + } + } + } + if (isset( $oData->stepSupervisor ) && is_array( $oData->stepSupervisor )) { + foreach ($oData->stepSupervisor as $key => $val) { + if ($val['STEP_TYPE_OBJ'] == 'DYNAFORM') { + $newGuid = $map[$val['STEP_UID_OBJ']]; + $oData->stepSupervisor[$key]['STEP_UID_OBJ'] = $newGuid; + } + } + foreach ($oData->dynaformFiles as $key => $val) { + $newGuid = $map[$key]; + $oData->dynaformFiles[$key] = $newGuid; + } + } + if (isset( $oData->gridFiles )) { + foreach ($oData->gridFiles as $key => $val) { + $newGuid = $map[$key]; + $oData->gridFiles[$key] = $newGuid; + } + } + if (isset( $oData->fieldCondition ) && is_array( $oData->fieldCondition )) { + foreach ($oData->fieldCondition as $key => $val) { + $newGuid = $map[$val['FCD_DYN_UID']]; + $oData->fieldCondition[$key]['FCD_DYN_UID'] = $newGuid; + } + } + + } + + /** + * get a Process with a search based in the process Uid + * + * @param $sProUid string process Uid + * @return $oProcess Process object + */ + public function getProcessRow ($sProUid, $getAllLang = false) + { + $oProcess = new Process(); + return $oProcess->Load( $sProUid, $getAllLang ); + } + + /** + * creates a process new process if a process exists with the same uid of the + * $row['PRO_UID'] parameter then deletes it from the database and creates + * a new one based on the $row parameter + * + * @param $row array parameter with the process data + * @return $oProcess Process object + */ + public function createProcessRow ($row) + { + $oProcess = new Process(); + if ($oProcess->processExists( $row['PRO_UID'] )) { + $oProcess->remove( $row['PRO_UID'] ); + } + return $oProcess->createRow( $row ); + } + + /** + * Update a Process register in DB, if the process doesn't exist with the same + * uid of the $row['PRO_UID'] parameter the function creates a new one based + * on the $row parameter data. + * + * @param $row array parameter with the process data + * @return $oProcess Process object + */ + public function updateProcessRow ($row) + { + $oProcess = new Process(); + if ($oProcess->processExists( $row['PRO_UID'] )) { + $oProcess->update( $row ); + } else { + $oProcess->create( $row ); + } + } + + /** + * Gets the subprocess data from a process and returns it in an array. + * + * @param $sProUid string for the process Uid + * @return $aSubProcess array + */ + public function getSubProcessRow ($sProUid) + { + try { + $aSubProcess = array (); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( SubProcessPeer::PRO_PARENT, $sProUid ); + $oDataset = SubProcessPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $aSubProcess[] = $aRow; + $oDataset->next(); + } + return $aSubProcess; + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * Gets a case Tracker Row from a process and returns it in an array. + * + * @param $sProUid string for the process Uid + * @return $aCaseTracker array + */ + + public function getCaseTrackerRow ($sProUid) + { + try { + $aCaseTracker = array (); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( CaseTrackerPeer::PRO_UID, $sProUid ); + $oDataset = CaseTrackerPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $aCaseTracker[] = $aRow; + $oDataset->next(); + } + return $aCaseTracker; + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * Gets a case TrackerObject Row from a process and returns it in an array. + * + * @param $sProUid string for the process Uid + * @return $aCaseTracker array + */ + public function getCaseTrackerObjectRow ($sProUid) + { + try { + $aCaseTrackerObject = array (); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( CaseTrackerObjectPeer::PRO_UID, $sProUid ); + $oDataset = CaseTrackerObjectPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $aCaseTrackerObject[] = $aRow; + $oDataset->next(); + } + return $aCaseTrackerObject; + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * Gets a Stage Row from a process and returns it in an array. + * + * @param $sProUid string for the process Uid + * @return $aStage array + */ + public function getStageRow ($sProUid) + { + try { + $aStage = array (); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( StagePeer::PRO_UID, $sProUid ); + $oDataset = StagePeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $oStage = new Stage(); + $aStage[] = $oStage->load( $aRow['STG_UID'] ); + $oDataset->next(); + } + return $aStage; + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * Gets the Field Conditions from a process and returns those in an array. + * + * @param $sProUid string for the process Uid + * @return $aFieldCondition array + */ + + public function getFieldCondition ($sProUid) + { + try { + $aFieldCondition = array (); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( DynaformPeer::PRO_UID, $sProUid ); + $oCriteria->addJoin( DynaformPeer::DYN_UID, FieldConditionPeer::FCD_DYN_UID ); + $oDataset = FieldConditionPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $aFieldCondition[] = $aRow; + $oDataset->next(); + } + return $aFieldCondition; + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * Gets the Event rows from a process and returns those in an array. + * + * @param $sProUid string for the process Uid + * @return $aEvent array + */ + public function getEventRow ($sProUid) + { + try { + $aEvent = array (); + $oCriteria = new Criteria( 'workflow' ); + + $oCriteria->add( EventPeer::PRO_UID, $sProUid ); + $oDataset = EventPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $oEvent = new Event(); + $aEvent[] = $oEvent->load( $aRow['EVN_UID'] ); + $oDataset->next(); + } + return $aEvent; + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * Gets the Cases Scheduler rows from a process and returns those in an array. + * + * @param $sProUid string for the process Uid + * @return $aCaseScheduler array + */ + public function getCaseSchedulerRow ($sProUid) + { + try { + $aCaseScheduler = array (); + $oCriteria = new Criteria( 'workflow' ); + + $oCriteria->add( CaseSchedulerPeer::PRO_UID, $sProUid ); + $oDataset = CaseSchedulerPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $oCaseScheduler = new CaseScheduler(); + $aCaseScheduler[] = $oCaseScheduler->load( $aRow['SCH_UID'] ); + $oDataset->next(); + } + return $aCaseScheduler; + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * Gets processCategory record, if the process had one + * + * @param $sProUid string for the process Uid + * @return $processCategory array + */ + public function getProcessCategoryRow ($sProUid) + { + $process = ProcessPeer::retrieveByPK( $sProUid ); + + if ($process->getProCategory() == '') { + return null; + } + + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( ProcessCategoryPeer::CATEGORY_UID, $process->getProCategory() ); + $oDataset = ProcessCategoryPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + + return $oDataset->getRow(); + } + + /** + * Get all Swimlanes Elements for any Process + * + * @param string $sProUid + * @return array + */ + public function getAllLanes ($sProUid) + { + try { + $aLanes = array (); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( SwimlanesElementsPeer::PRO_UID, $sProUid ); + $oDataset = SwimlanesElementsPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $oSwim = new SwimlanesElements(); + $aLanes[] = $oSwim->Load( $aRow['SWI_UID'] ); + $oDataset->next(); + } + return $aLanes; + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * Get Task Rows from a process and returns those in an array. + * + * @param $sProUid string for the process Uid + * @return $oTask array + */ + public function getTaskRows ($sProUid) + { + $oTask = new Tasks(); + return $oTask->getAllTasks( $sProUid ); + } + + /** + * Create Task Rows from a $aTasks array data and returns those in an array. + * + * @param $aTasks array + * @return $oTask array + */ + public function createTaskRows ($aTasks) + { + $oTask = new Tasks(); + return $oTask->createTaskRows( $aTasks ); + } + + /** + * Update Task Rows from a $aTasks array data and returns those in an array. + * + * @param $aTasks array + * @return $oTask array + */ + public function updateTaskRows ($aTasks) + { + $oTask = new Tasks(); + return $oTask->updateTaskRows( $aTasks ); + } + + /** + * Gets all Route rows from a Process and returns those in an array. + * + * @param $sProUid string for the process Uid + * @return $oTask Tasks array + */ + public function getRouteRows ($sProUid) + { + $oTask = new Tasks(); + return $oTask->getAllRoutes( $sProUid ); + } + + /** + * Create Route Rows from a $aRoutes array data and returns those in an array. + * + * @param $aRoutes array + * @return $oTask Tasks array + */ + public function createRouteRows ($aRoutes) + { + $oTask = new Tasks(); + return $oTask->createRouteRows( $aRoutes ); + } + + /** + * Update Route Rows from a $aRoutes array data and returns those in an array. + * + * @param $aRoutes array + * @return $oTask Tasks array + */ + public function updateRouteRows ($aRoutes) + { + $oTask = new Tasks(); + return $oTask->updateRouteRows( $aRoutes ); + } + + /** + * Get Lane Rows from a Process and returns those in an array. + * + * @param $sProUid string for the process Uid + * @return array + */ + public function getLaneRows ($sProUid) + { + return $this->getAllLanes( $sProUid ); + } + + /** + * Get Gateway Rows from a process and returns those in an array. + * + * @param $sProUid string for the process Uid + * @return $oTask array + */ + public function getGatewayRows ($sProUid) + { + $oTask = new Tasks(); + return $oTask->getAllGateways( $sProUid ); + } + + /** + * Create Gateway Rows from a $aGateways array data and returns those in an array. + * + * @param $aGateways array + * @return $oGateway array + */ + public function createGatewayRows ($aGateways) + { + $oTask = new Tasks(); + return $oTask->createGatewayRows( $aGateways ); + } + + /** + * Create Lane Rows from a $aLanes array data and returns those in an array. + * + * @param $aLanes array. + * @return void + */ + public function createLaneRows ($aLanes) + { + foreach ($aLanes as $key => $row) { + $oLane = new SwimlanesElements(); + if ($oLane->swimlanesElementsExists( $row['SWI_UID'] )) { + $oLane->remove( $row['SWI_UID'] ); + } + $res = $oLane->create( $row ); + } + return; + } + + /** + * Create Sub Process rows from an array, removing those subprocesses with + * the same UID. + * + * @param $SubProcess array + * @return void. + */ + public function createSubProcessRows ($SubProcess) + { + foreach ($SubProcess as $key => $row) { + $oSubProcess = new SubProcess(); + if ($oSubProcess->subProcessExists( $row['SP_UID'] )) { + $oSubProcess->remove( $row['SP_UID'] ); + } + $res = $oSubProcess->create( $row ); + } + return; + } + + /** + * Create Case Tracker rows from an array, removing those Trackers with + * the same UID. + * + * @param $CaseTracker array. + * @return void + */ + public function createCaseTrackerRows ($CaseTracker) + { + if (is_array( $CaseTracker )) { + foreach ($CaseTracker as $key => $row) { + $oCaseTracker = new CaseTracker(); + if ($oCaseTracker->caseTrackerExists( $row['PRO_UID'] )) { + $oCaseTracker->remove( $row['PRO_UID'] ); + } + $res = $oCaseTracker->create( $row ); + } + } + return; + } + + /** + * Create Case Tracker Objects rows from an array, removing those Objects + * with the same UID, and recreaiting those from the array data. + * + * @param $CaseTrackerObject array. + * @return void + */ + public function createCaseTrackerObjectRows ($CaseTrackerObject) + { + foreach ($CaseTrackerObject as $key => $row) { + $oCaseTrackerObject = new CaseTrackerObject(); + if ($oCaseTrackerObject->caseTrackerObjectExists( $row['CTO_UID'] )) { + $oCaseTrackerObject->remove( $row['CTO_UID'] ); + } + $res = $oCaseTrackerObject->create( $row ); + } + return; + } + + /** + * Create Object Permissions rows from an array, removing those Objects + * with the same UID, and recreaiting the records from the array data. + * + * @param $sProUid string for the process Uid. + * @return void + */ + public function createObjectPermissionsRows ($ObjectPermissions) + { + foreach ($ObjectPermissions as $key => $row) { + $oObjectPermissions = new ObjectPermission(); + if ($oObjectPermissions->Exists( $row['OP_UID'] )) { + $oObjectPermissions->remove( $row['OP_UID'] ); + } + $res = $oObjectPermissions->create( $row ); + } + return; + } + + /** + * Create Stage rows from an array, removing those Objects + * with the same UID, and recreaiting the records from the array data. + * + * @param $Stage array. + * @return void + */ + public function createStageRows ($Stage) + { + foreach ($Stage as $key => $row) { + $oStage = new Stage(); + if ($oStage->Exists( $row['STG_UID'] )) { + $oStage->remove( $row['STG_UID'] ); + } + $res = $oStage->create( $row ); + } + return; + } + + /** + * Create Field Conditions from an array of Field Conditions and Dynaforms, + * removing those Objects with the same UID, and recreaiting the records + * from the arrays data. + * + * @param $aFieldCondition array. + * @param $aDynaform array. + * @return void + */ + public function createFieldCondition ($aFieldCondition, $aDynaform) + { + if (is_array( $aFieldCondition )) { + foreach ($aFieldCondition as $key => $row) { + $oFieldCondition = new FieldCondition(); + if ($oFieldCondition->fieldConditionExists( $row['FCD_UID'], $aDynaform )) { + $oFieldCondition->remove( $row['FCD_UID'] ); + } + $res = $oFieldCondition->create( $row ); + } + } + return; + } + + /** + * Create Event rows from an array, removing those Objects + * with the same UID, and recreaiting the records from the array data. + * + * @param $Event array. + * @return void + */ + public function createEventRows ($Event) + { + foreach ($Event as $key => $row) { + $oEvent = new Event(); + if ($oEvent->Exists( $row['EVN_UID'] )) { + $oEvent->remove( $row['EVN_UID'] ); + } + $res = $oEvent->create( $row ); + } + return; + } + + /** + * Create Case Scheduler Rows from an array, removing those Objects + * with the same UID, and recreaiting the records from the array data. + * + * @param $CaseScheduler array. + * @return void + */ + public function createCaseSchedulerRows ($CaseScheduler) + { + foreach ($CaseScheduler as $key => $row) { + $oCaseScheduler = new CaseScheduler(); + if ($oCaseScheduler->Exists( $row['SCH_UID'] )) { + $oCaseScheduler->remove( $row['SCH_UID'] ); + } + $res = $oCaseScheduler->create( $row ); + } + return; + } + + /** + * Create ProcessCategory record + * + * @param $ProcessCategory array. + * @return void + */ + public function createProcessCategoryRow ($row) + { + if ($row && is_array( $row ) && isset( $row['CATEGORY_UID'] )) { + $record = ProcessCategoryPeer::retrieveByPK( $row['CATEGORY_UID'] ); // create only if the category doesn't exists - if (! $record) { - $processCategory = new ProcessCategory(); - $processCategory->fromArray( $row, BasePeer::TYPE_FIELDNAME ); - $processCategory->save(); - } - } - } - - /** - * Gets Input Documents Rows from aProcess. - * - * @param $sProUid string. - * @return void - */ - function getInputRows ($sProUid) - { - try { - $aInput = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( InputdocumentPeer::PRO_UID, $sProUid ); - $oDataset = InputdocumentPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $oInput = new Inputdocument(); - $aInput[] = $oInput->Load( $aRow['INP_DOC_UID'] ); - $oDataset->next(); - } - return $aInput; - } catch (Exception $oError) { - throw ($oError); - } - } - - /** - * Create Input Documents Rows from an array, removing those Objects - * with the same UID, and recreaiting the records from the array data. - * - * @param $aInput array. - * @return void - */ - function createInputRows ($aInput) - { - foreach ($aInput as $key => $row) { - $oInput = new Inputdocument(); + if (! $record) { + $processCategory = new ProcessCategory(); + $processCategory->fromArray( $row, BasePeer::TYPE_FIELDNAME ); + $processCategory->save(); + } + } + } + + /** + * Gets Input Documents Rows from aProcess. + * + * @param $sProUid string. + * @return void + */ + public function getInputRows ($sProUid) + { + try { + $aInput = array (); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( InputdocumentPeer::PRO_UID, $sProUid ); + $oDataset = InputdocumentPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $oInput = new Inputdocument(); + $aInput[] = $oInput->Load( $aRow['INP_DOC_UID'] ); + $oDataset->next(); + } + return $aInput; + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * Create Input Documents Rows from an array, removing those Objects + * with the same UID, and recreaiting the records from the array data. + * + * @param $aInput array. + * @return void + */ + public function createInputRows ($aInput) + { + foreach ($aInput as $key => $row) { + $oInput = new Inputdocument(); //unset ($row['TAS_UID']); - if ($oInput->InputExists( $row['INP_DOC_UID'] )) - $oInput->remove( $row['INP_DOC_UID'] ); - - $res = $oInput->create( $row ); - } - return; - } - - /** - * change and Renew all Input GUID, because the process needs to have a new set of Inputs - * - * @param string $oData - * @return boolean - */ - function renewAllInputGuid (&$oData) - { - $map = array (); - foreach ($oData->inputs as $key => $val) { - $newGuid = $this->getUnusedInputGUID(); - $map[$val['INP_DOC_UID']] = $newGuid; - $oData->inputs[$key]['INP_DOC_UID'] = $newGuid; - } - foreach ($oData->steps as $key => $val) { - if (isset( $val['STEP_TYPE_OBJ'] )) { - if ($val['STEP_TYPE_OBJ'] == 'INPUT_DOCUMENT') { - $newGuid = $map[$val['STEP_UID_OBJ']]; - $oData->steps[$key]['STEP_UID_OBJ'] = $newGuid; - } - } - } - if (isset( $oData->caseTrackerObject ) && is_array( $oData->caseTrackerObject )) { - foreach ($oData->caseTrackerObject as $key => $val) { - if ($val['CTO_TYPE_OBJ'] == 'INPUT_DOCUMENT') { - $newGuid = $map[$val['CTO_UID_OBJ']]; - $oData->steps[$key]['CTO_UID_OBJ'] = $newGuid; - } - } - } - if (isset( $oData->objectPermissions ) && is_array( $oData->objectPermissions )) { - foreach ($oData->objectPermissions as $key => $val) { - if ($val['OP_OBJ_TYPE'] == 'INPUT_DOCUMENT') { - if (isset( $map[$val['OP_OBJ_UID']] )) { - $newGuid = $map[$val['OP_OBJ_UID']]; - $oData->objectPermissions[$key]['OP_OBJ_UID'] = $newGuid; - } - } - } - } - if (isset( $oData->stepSupervisor ) && is_array( $oData->stepSupervisor )) { - foreach ($oData->stepSupervisor as $key => $val) { - if ($val['STEP_TYPE_OBJ'] == 'INPUT_DOCUMENT') { - $newGuid = $map[$val['STEP_UID_OBJ']]; - $oData->stepSupervisor[$key]['STEP_UID_OBJ'] = $newGuid; - } - } - } - } - - /** - * Gets the Output Documents Rows from a Process. - * - * @param $sProUid string. - * @return $aOutput array - */ - function getOutputRows ($sProUid) - { - try { - $aOutput = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( OutputdocumentPeer::PRO_UID, $sProUid ); - $oDataset = OutputdocumentPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $oOutput = new Outputdocument(); - $aOutput[] = $oOutput->Load( $aRow['OUT_DOC_UID'] ); - $oDataset->next(); - } - return $aOutput; - } catch (Exception $oError) { - throw ($oError); - } - } - - /** - * Create Input Documents Rows from an array, removing those Objects - * with the same UID, and recreaiting the records from the array data. - * - * @param $aOutput array. - * @return void - */ - function createOutputRows ($aOutput) - { - foreach ($aOutput as $key => $row) { - $oOutput = new Outputdocument(); + if ($oInput->InputExists( $row['INP_DOC_UID'] )) { + $oInput->remove( $row['INP_DOC_UID'] ); + } + $res = $oInput->create( $row ); + } + return; + } + + /** + * change and Renew all Input GUID, because the process needs to have a new set of Inputs + * + * @param string $oData + * @return boolean + */ + public function renewAllInputGuid (&$oData) + { + $map = array (); + foreach ($oData->inputs as $key => $val) { + $newGuid = $this->getUnusedInputGUID(); + $map[$val['INP_DOC_UID']] = $newGuid; + $oData->inputs[$key]['INP_DOC_UID'] = $newGuid; + } + foreach ($oData->steps as $key => $val) { + if (isset( $val['STEP_TYPE_OBJ'] )) { + if ($val['STEP_TYPE_OBJ'] == 'INPUT_DOCUMENT') { + $newGuid = $map[$val['STEP_UID_OBJ']]; + $oData->steps[$key]['STEP_UID_OBJ'] = $newGuid; + } + } + } + if (isset( $oData->caseTrackerObject ) && is_array( $oData->caseTrackerObject )) { + foreach ($oData->caseTrackerObject as $key => $val) { + if ($val['CTO_TYPE_OBJ'] == 'INPUT_DOCUMENT') { + $newGuid = $map[$val['CTO_UID_OBJ']]; + $oData->steps[$key]['CTO_UID_OBJ'] = $newGuid; + } + } + } + if (isset( $oData->objectPermissions ) && is_array( $oData->objectPermissions )) { + foreach ($oData->objectPermissions as $key => $val) { + if ($val['OP_OBJ_TYPE'] == 'INPUT_DOCUMENT') { + if (isset( $map[$val['OP_OBJ_UID']] )) { + $newGuid = $map[$val['OP_OBJ_UID']]; + $oData->objectPermissions[$key]['OP_OBJ_UID'] = $newGuid; + } + } + } + } + if (isset( $oData->stepSupervisor ) && is_array( $oData->stepSupervisor )) { + foreach ($oData->stepSupervisor as $key => $val) { + if ($val['STEP_TYPE_OBJ'] == 'INPUT_DOCUMENT') { + $newGuid = $map[$val['STEP_UID_OBJ']]; + $oData->stepSupervisor[$key]['STEP_UID_OBJ'] = $newGuid; + } + } + } + } + + /** + * Gets the Output Documents Rows from a Process. + * + * @param $sProUid string. + * @return $aOutput array + */ + public function getOutputRows ($sProUid) + { + try { + $aOutput = array (); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( OutputdocumentPeer::PRO_UID, $sProUid ); + $oDataset = OutputdocumentPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $oOutput = new Outputdocument(); + $aOutput[] = $oOutput->Load( $aRow['OUT_DOC_UID'] ); + $oDataset->next(); + } + return $aOutput; + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * Create Input Documents Rows from an array, removing those Objects + * with the same UID, and recreaiting the records from the array data. + * + * @param $aOutput array. + * @return void + */ + public function createOutputRows ($aOutput) + { + foreach ($aOutput as $key => $row) { + $oOutput = new Outputdocument(); //unset ($row['TAS_UID']); - if ($oOutput->OutputExists( $row['OUT_DOC_UID'] )) - $oOutput->remove( $row['OUT_DOC_UID'] ); - - $res = $oOutput->create( $row ); - } - return; - } - - /** - * change and Renew all Output GUID, because the process needs to have a new set of Outputs - * - * @param string $oData - * @return boolean - */ - function renewAllOutputGuid (&$oData) - { - $map = array (); - foreach ($oData->outputs as $key => $val) { - $newGuid = $this->getUnusedOutputGUID(); - $map[$val['OUT_DOC_UID']] = $newGuid; - $oData->outputs[$key]['OUT_DOC_UID'] = $newGuid; - } - foreach ($oData->steps as $key => $val) { - if (isset( $val['STEP_TYPE_OBJ'] )) { - if ($val['STEP_TYPE_OBJ'] == 'OUTPUT_DOCUMENT') { - $newGuid = $map[$val['STEP_UID_OBJ']]; - $oData->steps[$key]['STEP_UID_OBJ'] = $newGuid; - } - } - } - foreach ($oData->caseTrackerObject as $key => $val) { - if ($val['CTO_TYPE_OBJ'] == 'OUTPUT_DOCUMENT') { - $newGuid = $map[$val['CTO_UID_OBJ']]; - $oData->steps[$key]['CTO_UID_OBJ'] = $newGuid; - } - } - foreach ($oData->objectPermissions as $key => $val) { - if ($val['OP_OBJ_TYPE'] == 'OUTPUT_DOCUMENT') { - $newGuid = $map[$val['OP_OBJ_UID']]; - $oData->objectPermissions[$key]['OP_OBJ_UID'] = $newGuid; - } - } - foreach ($oData->stepSupervisor as $key => $val) { - if ($val['STEP_TYPE_OBJ'] == 'OUTPUT_DOCUMENT') { - $newGuid = $map[$val['STEP_UID_OBJ']]; - $oData->stepSupervisor[$key]['STEP_UID_OBJ'] = $newGuid; - } - } - } - - /** - * change and Renew all Trigger GUID, because the process needs to have a new set of Triggers - * - * @param string $oData - * @return boolean - */ - function renewAllTriggerGuid (&$oData) - { - $map = array (); - foreach ($oData->triggers as $key => $val) { - $newGuid = $this->getUnusedTriggerGUID(); - $map[$val['TRI_UID']] = $newGuid; - $oData->triggers[$key]['TRI_UID'] = $newGuid; - } - foreach ($oData->steptriggers as $key => $val) { - if (isset( $map[$val['TRI_UID']] )) { - $newGuid = $map[$val['TRI_UID']]; - $oData->steptriggers[$key]['TRI_UID'] = $newGuid; - } else { - $oData->steptriggers[$key]['TRI_UID'] = $this->getUnusedTriggerGUID(); - } - } - } - - /** - * Renew all the GUID's for Subprocesses - * - * @param $oData array. - * @return void - */ - function renewAllSubProcessGuid (&$oData) - { - $map = array (); - foreach ($oData->subProcess as $key => $val) { - $newGuid = $this->getUnusedSubProcessGUID(); - $map[$val['SP_UID']] = $newGuid; - $oData->subProcess[$key]['SP_UID'] = $newGuid; - } - } - - /** - * Renew all the GUID's for Case Tracker Objects - * - * @param $oData array. - * @return void - */ - function renewAllCaseTrackerObjectGuid (&$oData) - { - $map = array (); - foreach ($oData->caseTrackerObject as $key => $val) { - $newGuid = $this->getUnusedCaseTrackerObjectGUID(); - $map[$val['CTO_UID']] = $newGuid; - $oData->caseTrackerObject[$key]['CTO_UID'] = $newGuid; - } - } - - /** - * Renew all the GUID's for DB Sources - * - * @param $oData array. - * @return void - */ - function renewAllDBSourceGuid (&$oData) - { - $map = array (); - $aSqlConnections = array (); - foreach ($oData->dbconnections as $key => $val) { + if ($oOutput->OutputExists( $row['OUT_DOC_UID'] )) { + $oOutput->remove( $row['OUT_DOC_UID'] ); + } + $res = $oOutput->create( $row ); + } + return; + } + + /** + * change and Renew all Output GUID, because the process needs to have a new set of Outputs + * + * @param string $oData + * @return boolean + */ + public function renewAllOutputGuid (&$oData) + { + $map = array (); + foreach ($oData->outputs as $key => $val) { + $newGuid = $this->getUnusedOutputGUID(); + $map[$val['OUT_DOC_UID']] = $newGuid; + $oData->outputs[$key]['OUT_DOC_UID'] = $newGuid; + } + foreach ($oData->steps as $key => $val) { + if (isset( $val['STEP_TYPE_OBJ'] )) { + if ($val['STEP_TYPE_OBJ'] == 'OUTPUT_DOCUMENT') { + $newGuid = $map[$val['STEP_UID_OBJ']]; + $oData->steps[$key]['STEP_UID_OBJ'] = $newGuid; + } + } + } + foreach ($oData->caseTrackerObject as $key => $val) { + if ($val['CTO_TYPE_OBJ'] == 'OUTPUT_DOCUMENT') { + $newGuid = $map[$val['CTO_UID_OBJ']]; + $oData->steps[$key]['CTO_UID_OBJ'] = $newGuid; + } + } + foreach ($oData->objectPermissions as $key => $val) { + if ($val['OP_OBJ_TYPE'] == 'OUTPUT_DOCUMENT') { + $newGuid = $map[$val['OP_OBJ_UID']]; + $oData->objectPermissions[$key]['OP_OBJ_UID'] = $newGuid; + } + } + foreach ($oData->stepSupervisor as $key => $val) { + if ($val['STEP_TYPE_OBJ'] == 'OUTPUT_DOCUMENT') { + $newGuid = $map[$val['STEP_UID_OBJ']]; + $oData->stepSupervisor[$key]['STEP_UID_OBJ'] = $newGuid; + } + } + } + + /** + * change and Renew all Trigger GUID, because the process needs to have a new set of Triggers + * + * @param string $oData + * @return boolean + */ + public function renewAllTriggerGuid (&$oData) + { + $map = array (); + foreach ($oData->triggers as $key => $val) { + $newGuid = $this->getUnusedTriggerGUID(); + $map[$val['TRI_UID']] = $newGuid; + $oData->triggers[$key]['TRI_UID'] = $newGuid; + } + foreach ($oData->steptriggers as $key => $val) { + if (isset( $map[$val['TRI_UID']] )) { + $newGuid = $map[$val['TRI_UID']]; + $oData->steptriggers[$key]['TRI_UID'] = $newGuid; + } else { + $oData->steptriggers[$key]['TRI_UID'] = $this->getUnusedTriggerGUID(); + } + } + } + + /** + * Renew all the GUID's for Subprocesses + * + * @param $oData array. + * @return void + */ + public function renewAllSubProcessGuid (&$oData) + { + $map = array (); + foreach ($oData->subProcess as $key => $val) { + $newGuid = $this->getUnusedSubProcessGUID(); + $map[$val['SP_UID']] = $newGuid; + $oData->subProcess[$key]['SP_UID'] = $newGuid; + } + } + + /** + * Renew all the GUID's for Case Tracker Objects + * + * @param $oData array. + * @return void + */ + public function renewAllCaseTrackerObjectGuid (&$oData) + { + $map = array (); + foreach ($oData->caseTrackerObject as $key => $val) { + $newGuid = $this->getUnusedCaseTrackerObjectGUID(); + $map[$val['CTO_UID']] = $newGuid; + $oData->caseTrackerObject[$key]['CTO_UID'] = $newGuid; + } + } + + /** + * Renew all the GUID's for DB Sources + * + * @param $oData array. + * @return void + */ + public function renewAllDBSourceGuid (&$oData) + { + $map = array (); + $aSqlConnections = array (); + foreach ($oData->dbconnections as $key => $val) { $newGuid = $val['DBS_UID']; ///-- $this->getUnusedDBSourceGUID(); - $map[$val['DBS_UID']] = $newGuid; - $oData->dbconnections[$key]['DBS_UID'] = $newGuid; - } - $oData->sqlConnections = $map; - } - - /** - * Renew all the GUID's for Object Permissions - * - * @param $oData array. - * @return void - */ - function renewAllObjectPermissionGuid (&$oData) - { - $map = array (); - foreach ($oData->objectPermissions as $key => $val) { - $newGuid = $this->getUnusedObjectPermissionGUID(); - $map[$val['OP_UID']] = $newGuid; - $oData->objectPermissions[$key]['OP_UID'] = $newGuid; - } - } - - /** - * Renew all the GUID's for Routes Objects - * - * @param $oData array. - * @return void - */ - function renewAllRouteGuid (&$oData) - { - $map = array (); - if (isset( $oData->routes ) && is_array( $oData->routes )) { - foreach ($oData->routes as $key => $val) { - $newGuid = $this->getUnusedRouteGUID(); - $map[$val['ROU_UID']] = $newGuid; - $oData->routes[$key]['ROU_UID'] = $newGuid; - } - } - } - - /** - * Renew all the GUID's for Stage Objects - * - * @param $oData array. - * @return void - */ - function renewAllStageGuid (&$oData) - { - $map = array (); - foreach ($oData->stage as $key => $val) { - $newGuid = $this->getUnusedStageGUID(); - $map[$val['STG_UID']] = $newGuid; - $oData->stage[$key]['STG_UID'] = $newGuid; - } - foreach ($oData->tasks as $key => $val) { - if (isset( $map[$val['STG_UID']] )) { - $newGuid = $map[$val['STG_UID']]; - $oData->tasks[$key]['STG_UID'] = $newGuid; - } - } - } - - /** - * Renew all the GUID's for Swimlanes Elements Objects - * - * @param $oData array. - * @return void - */ - function renewAllSwimlanesElementsGuid (&$oData) - { - $map = array (); - foreach ($oData->lanes as $key => $val) { - $newGuid = $this->getUnusedSLGUID(); - $map[$val['SWI_UID']] = $newGuid; - $oData->lanes[$key]['SWI_UID'] = $newGuid; - } - } - - /** - * Renew the GUID's for all the Report Tables Objects - * - * @param $oData array. - * @return void - */ - function renewAllReportTableGuid (&$oData) - { - $map = array (); - foreach ($oData->reportTables as $key => $val) { - $newGuid = $this->getUnusedRTGUID(); - $map[$val['REP_TAB_UID']] = $newGuid; - $oData->reportTables[$key]['REP_TAB_UID'] = $newGuid; - } - foreach ($oData->reportTablesVars as $key => $val) { - if (isset( $map[$val['REP_TAB_UID']] )) { + $map[$val['DBS_UID']] = $newGuid; + $oData->dbconnections[$key]['DBS_UID'] = $newGuid; + } + $oData->sqlConnections = $map; + } + + /** + * Renew all the GUID's for Object Permissions + * + * @param $oData array. + * @return void + */ + public function renewAllObjectPermissionGuid (&$oData) + { + $map = array (); + foreach ($oData->objectPermissions as $key => $val) { + $newGuid = $this->getUnusedObjectPermissionGUID(); + $map[$val['OP_UID']] = $newGuid; + $oData->objectPermissions[$key]['OP_UID'] = $newGuid; + } + } + + /** + * Renew all the GUID's for Routes Objects + * + * @param $oData array. + * @return void + */ + public function renewAllRouteGuid (&$oData) + { + $map = array (); + if (isset( $oData->routes ) && is_array( $oData->routes )) { + foreach ($oData->routes as $key => $val) { + $newGuid = $this->getUnusedRouteGUID(); + $map[$val['ROU_UID']] = $newGuid; + $oData->routes[$key]['ROU_UID'] = $newGuid; + } + } + } + + /** + * Renew all the GUID's for Stage Objects + * + * @param $oData array. + * @return void + */ + public function renewAllStageGuid (&$oData) + { + $map = array (); + foreach ($oData->stage as $key => $val) { + $newGuid = $this->getUnusedStageGUID(); + $map[$val['STG_UID']] = $newGuid; + $oData->stage[$key]['STG_UID'] = $newGuid; + } + foreach ($oData->tasks as $key => $val) { + if (isset( $map[$val['STG_UID']] )) { + $newGuid = $map[$val['STG_UID']]; + $oData->tasks[$key]['STG_UID'] = $newGuid; + } + } + } + + /** + * Renew all the GUID's for Swimlanes Elements Objects + * + * @param $oData array. + * @return void + */ + public function renewAllSwimlanesElementsGuid (&$oData) + { + $map = array (); + foreach ($oData->lanes as $key => $val) { + $newGuid = $this->getUnusedSLGUID(); + $map[$val['SWI_UID']] = $newGuid; + $oData->lanes[$key]['SWI_UID'] = $newGuid; + } + } + + /** + * Renew the GUID's for all the Report Tables Objects + * + * @param $oData array. + * @return void + */ + public function renewAllReportTableGuid (&$oData) + { + $map = array (); + foreach ($oData->reportTables as $key => $val) { + $newGuid = $this->getUnusedRTGUID(); + $map[$val['REP_TAB_UID']] = $newGuid; + $oData->reportTables[$key]['REP_TAB_UID'] = $newGuid; + } + foreach ($oData->reportTablesVars as $key => $val) { + if (isset( $map[$val['REP_TAB_UID']] )) { /*TODO: Why this can be not defined?? The scenario was when * imported an existing process but as a new one - */ - $newGuid = $map[$val['REP_TAB_UID']]; - $oData->reportTablesVars[$key]['REP_TAB_UID'] = $newGuid; - } - } - } - - /** - * Renew all the GUID's for All The Report Vars Objects - * - * @param $oData array. - * @return void - */ - function renewAllReportVarGuid (&$oData) - { - $map = array (); - foreach ($oData->reportTablesVars as $key => $val) { - $newGuid = $this->getUnusedRTVGUID(); - $map[$val['REP_VAR_UID']] = $newGuid; - $oData->reportTablesVars[$key]['REP_VAR_UID'] = $newGuid; - } - } - - /** - * Renew the GUID's for all the Field Conditions Objects - * - * @param $oData array. - * @return void - */ - function renewAllFieldCondition (&$oData) - { - $map = array (); - foreach ($oData->fieldCondition as $key => $val) { - $newGuid = $this->getUnusedFieldConditionGUID(); - $map[$val['FCD_UID']] = $newGuid; - $oData->fieldCondition[$key]['FCD_UID'] = $newGuid; - } - } - - /** - * Renew the GUID's for all the Events Objects - * - * @param $oData array. - * @return void - */ - function renewAllEvent (&$oData) - { - $map = array (); - foreach ($oData->event as $key => $val) { - $newGuid = $this->getUnusedEventGUID(); - $map[$val['EVN_UID']] = $newGuid; - $oData->event[$key]['EVN_UID'] = $newGuid; - } - } - - /** - * Renew the GUID's for all Case Scheduler Objects - * - * @param $oData array. - * @return void - */ - function renewAllCaseScheduler (&$oData) - { - $map = array (); - foreach ($oData->caseScheduler as $key => $val) { - $newGuid = $this->getUnusedCaseSchedulerGUID(); - $map[$val['SCH_UID']] = $newGuid; - $oData->caseScheduler[$key]['SCH_UID'] = $newGuid; - } - } - - /** - * Renew the GUID's for all the Uids for all the elements - * - * @param $oData array. - * @return void - */ - function renewAll (&$oData) - { - $this->renewAllTaskGuid( $oData ); - $this->renewAllDynaformGuid( $oData ); - $this->renewAllInputGuid( $oData ); - $this->renewAllOutputGuid( $oData ); - $this->renewAllStepGuid( $oData ); - $this->renewAllTriggerGuid( $oData ); - $this->renewAllSubProcessGuid( $oData ); - $this->renewAllCaseTrackerObjectGuid( $oData ); - $this->renewAllDBSourceGuid( $oData ); - $this->renewAllObjectPermissionGuid( $oData ); - $this->renewAllRouteGuid( $oData ); - $this->renewAllStageGuid( $oData ); - $this->renewAllSwimlanesElementsGuid( $oData ); - $this->renewAllReportTableGuid( $oData ); - $this->renewAllReportVarGuid( $oData ); - $this->renewAllFieldCondition( $oData ); - $this->renewAllEvent( $oData ); - $this->renewAllCaseScheduler( $oData ); - } - - /** - * Get Step Rows from a Process - * - * @param $sProUid array. - * @return array $aStep. - */ - function getStepRows ($sProUid) - { - try { - $aStep = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( StepPeer::PRO_UID, $sProUid ); - $oDataset = StepPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $oStep = new Step(); - $aStep[] = $oStep->Load( $aRow['STEP_UID'] ); - $oDataset->next(); - } - return $aStep; - } catch (Exception $oError) { - throw ($oError); - } - } - - /** - * Create Step Rows from a Process - * - * @param $aStep array. - * @return void. - */ - function createStepRows ($aStep) - { - foreach ($aStep as $key => $row) { - $oStep = new Step(); - if (isset( $row['STEP_UID'] )) { - if ($oStep->StepExists( $row['STEP_UID'] )) - $oStep->remove( $row['STEP_UID'] ); - - $res = $oStep->create( $row ); - } - } - return; - } - - /** - * Create Step Supervisor Rows for a Process from an array of data - * - * @param $aStepSupervisor array. - * @return void. - */ - function createStepSupervisorRows ($aStepSupervisor) - { - foreach ($aStepSupervisor as $key => $row) { - $oStepSupervisor = new StepSupervisor(); - if ($oStepSupervisor->Exists( $row['STEP_UID'] )) { - $oStepSupervisor->remove( $row['STEP_UID'] ); - } - $oStepSupervisor->create( $row ); - } + */ + $newGuid = $map[$val['REP_TAB_UID']]; + $oData->reportTablesVars[$key]['REP_TAB_UID'] = $newGuid; + } + } + } + + /** + * Renew all the GUID's for All The Report Vars Objects + * + * @param $oData array. + * @return void + */ + public function renewAllReportVarGuid (&$oData) + { + $map = array (); + foreach ($oData->reportTablesVars as $key => $val) { + $newGuid = $this->getUnusedRTVGUID(); + $map[$val['REP_VAR_UID']] = $newGuid; + $oData->reportTablesVars[$key]['REP_VAR_UID'] = $newGuid; + } + } + + /** + * Renew the GUID's for all the Field Conditions Objects + * + * @param $oData array. + * @return void + */ + public function renewAllFieldCondition (&$oData) + { + $map = array (); + foreach ($oData->fieldCondition as $key => $val) { + $newGuid = $this->getUnusedFieldConditionGUID(); + $map[$val['FCD_UID']] = $newGuid; + $oData->fieldCondition[$key]['FCD_UID'] = $newGuid; + } + } + + /** + * Renew the GUID's for all the Events Objects + * + * @param $oData array. + * @return void + */ + public function renewAllEvent (&$oData) + { + $map = array (); + foreach ($oData->event as $key => $val) { + $newGuid = $this->getUnusedEventGUID(); + $map[$val['EVN_UID']] = $newGuid; + $oData->event[$key]['EVN_UID'] = $newGuid; + } + } + + /** + * Renew the GUID's for all Case Scheduler Objects + * + * @param $oData array. + * @return void + */ + public function renewAllCaseScheduler (&$oData) + { + $map = array (); + foreach ($oData->caseScheduler as $key => $val) { + $newGuid = $this->getUnusedCaseSchedulerGUID(); + $map[$val['SCH_UID']] = $newGuid; + $oData->caseScheduler[$key]['SCH_UID'] = $newGuid; + } + } + + /** + * Renew the GUID's for all the Uids for all the elements + * + * @param $oData array. + * @return void + */ + public function renewAll (&$oData) + { + $this->renewAllTaskGuid( $oData ); + $this->renewAllDynaformGuid( $oData ); + $this->renewAllInputGuid( $oData ); + $this->renewAllOutputGuid( $oData ); + $this->renewAllStepGuid( $oData ); + $this->renewAllTriggerGuid( $oData ); + $this->renewAllSubProcessGuid( $oData ); + $this->renewAllCaseTrackerObjectGuid( $oData ); + $this->renewAllDBSourceGuid( $oData ); + $this->renewAllObjectPermissionGuid( $oData ); + $this->renewAllRouteGuid( $oData ); + $this->renewAllStageGuid( $oData ); + $this->renewAllSwimlanesElementsGuid( $oData ); + $this->renewAllReportTableGuid( $oData ); + $this->renewAllReportVarGuid( $oData ); + $this->renewAllFieldCondition( $oData ); + $this->renewAllEvent( $oData ); + $this->renewAllCaseScheduler( $oData ); + } + + /** + * Get Step Rows from a Process + * + * @param $sProUid array. + * @return array $aStep. + */ + public function getStepRows ($sProUid) + { + try { + $aStep = array (); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( StepPeer::PRO_UID, $sProUid ); + $oDataset = StepPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $oStep = new Step(); + $aStep[] = $oStep->Load( $aRow['STEP_UID'] ); + $oDataset->next(); + } + return $aStep; + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * Create Step Rows from a Process + * + * @param $aStep array. + * @return void. + */ + public function createStepRows ($aStep) + { + foreach ($aStep as $key => $row) { + $oStep = new Step(); + if (isset( $row['STEP_UID'] )) { + if ($oStep->StepExists( $row['STEP_UID'] )) { + $oStep->remove( $row['STEP_UID'] ); + } + $res = $oStep->create( $row ); + } + } + return; + } + + /** + * Create Step Supervisor Rows for a Process from an array of data + * + * @param $aStepSupervisor array. + * @return void. + */ + public function createStepSupervisorRows ($aStepSupervisor) + { + foreach ($aStepSupervisor as $key => $row) { + $oStepSupervisor = new StepSupervisor(); + if ($oStepSupervisor->Exists( $row['STEP_UID'] )) { + $oStepSupervisor->remove( $row['STEP_UID'] ); + } + $oStepSupervisor->create( $row ); + } } #@!Neyek - - - /** - * change and Renew all Step GUID, because the process needs to have a new set of Steps - * - * @param string $oData - * @return boolean - */ - function renewAllStepGuid (&$oData) - { - $map = array (); - foreach ($oData->steps as $key => $val) { - if (isset( $val['STEP_UID'] )) { - $newGuid = $this->getUnusedStepGUID(); - $map[$val['STEP_UID']] = $newGuid; - $oData->steps[$key]['STEP_UID'] = $newGuid; - } - } - foreach ($oData->steptriggers as $key => $val) { - if ($val['STEP_UID'] > 0) { - if (isset( $map[$val['STEP_UID']] )) { - $newGuid = $map[$val['STEP_UID']]; - $oData->steptriggers[$key]['STEP_UID'] = $newGuid; - } else { - $oData->steptriggers[$key]['STEP_UID'] = $this->getUnusedStepGUID(); - } - } - } - foreach ($oData->stepSupervisor as $key => $val) { - if ($val['STEP_UID'] > 0) { - if (isset( $map[$val['STEP_UID']] )) { - $newGuid = $map[$val['STEP_UID']]; - $oData->stepSupervisor[$key]['STEP_UID'] = $newGuid; - } else { - $oData->stepSupervisor[$key]['STEP_UID'] = $this->getUnusedStepGUID(); - } - } - } - } - - /** - * Get Dynaform Rows from a Process - * - * @param string $sProUid - * @return $aDynaform array - */ - function getDynaformRows ($sProUid) - { - try { - $aDynaform = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( DynaformPeer::PRO_UID, $sProUid ); - $oDataset = DynaformPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $oDynaform = new Dynaform(); - $aDynaform[] = $oDynaform->Load( $aRow['DYN_UID'] ); - $oDataset->next(); - } - return $aDynaform; - } catch (Exception $oError) { - throw ($oError); - } - } - - /** - * Get Object Permission Rows from a Process - * - * @param string $sProUid - * @return $aDynaform array - */ - function getObjectPermissionRows ($sProUid) - { // by erik - try { - $oPermissions = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( ObjectPermissionPeer::PRO_UID, $sProUid ); - $oCriteria->add( ObjectPermissionPeer::OP_USER_RELATION, 2 ); - $oDataset = ObjectPermissionPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $o = new ObjectPermission(); - $oPermissions[] = $o->Load( $aRow['OP_UID'] ); - $oDataset->next(); - } - return $oPermissions; - } catch (Exception $oError) { - throw ($oError); - } - } #@!neyek - - - /** - * Create Dynaform Rows for a Process form an array - * - * @param array $aDynaform - * @return void - */ - function createDynaformRows ($aDynaform) - { - foreach ($aDynaform as $key => $row) { - $oDynaform = new Dynaform(); - //unset ($row['TAS_UID']); - if ($oDynaform->exists( $row['DYN_UID'] )) - $oDynaform->remove( $row['DYN_UID'] ); - - $res = $oDynaform->create( $row ); - } - return; - } + + + /** + * change and Renew all Step GUID, because the process needs to have a new set of Steps + * + * @param string $oData + * @return boolean + */ + public function renewAllStepGuid (&$oData) + { + $map = array (); + foreach ($oData->steps as $key => $val) { + if (isset( $val['STEP_UID'] )) { + $newGuid = $this->getUnusedStepGUID(); + $map[$val['STEP_UID']] = $newGuid; + $oData->steps[$key]['STEP_UID'] = $newGuid; + } + } + foreach ($oData->steptriggers as $key => $val) { + if ($val['STEP_UID'] > 0) { + if (isset( $map[$val['STEP_UID']] )) { + $newGuid = $map[$val['STEP_UID']]; + $oData->steptriggers[$key]['STEP_UID'] = $newGuid; + } else { + $oData->steptriggers[$key]['STEP_UID'] = $this->getUnusedStepGUID(); + } + } + } + foreach ($oData->stepSupervisor as $key => $val) { + if ($val['STEP_UID'] > 0) { + if (isset( $map[$val['STEP_UID']] )) { + $newGuid = $map[$val['STEP_UID']]; + $oData->stepSupervisor[$key]['STEP_UID'] = $newGuid; + } else { + $oData->stepSupervisor[$key]['STEP_UID'] = $this->getUnusedStepGUID(); + } + } + } + } + + /** + * Get Dynaform Rows from a Process + * + * @param string $sProUid + * @return $aDynaform array + */ + public function getDynaformRows ($sProUid) + { + try { + $aDynaform = array (); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( DynaformPeer::PRO_UID, $sProUid ); + $oDataset = DynaformPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $oDynaform = new Dynaform(); + $aDynaform[] = $oDynaform->Load( $aRow['DYN_UID'] ); + $oDataset->next(); + } + return $aDynaform; + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * Get Object Permission Rows from a Process + * + * @param string $sProUid + * @return $aDynaform array + */ + public function getObjectPermissionRows ($sProUid) + { + // by erik + try { + $oPermissions = array (); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( ObjectPermissionPeer::PRO_UID, $sProUid ); + $oCriteria->add( ObjectPermissionPeer::OP_USER_RELATION, 2 ); + $oDataset = ObjectPermissionPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $o = new ObjectPermission(); + $oPermissions[] = $o->Load( $aRow['OP_UID'] ); + $oDataset->next(); + } + return $oPermissions; + } catch (Exception $oError) { + throw ($oError); + } + } #@!neyek - - - /** - * Create Step Trigger Rows for a Process form an array - * - * @param array $aStepTrigger - * @return void - */ - function createStepTriggerRows ($aStepTrigger) - { - foreach ($aStepTrigger as $key => $row) { - $oStepTrigger = new StepTrigger(); + + + /** + * Create Dynaform Rows for a Process form an array + * + * @param array $aDynaform + * @return void + */ + public function createDynaformRows ($aDynaform) + { + foreach ($aDynaform as $key => $row) { + $oDynaform = new Dynaform(); //unset ($row['TAS_UID']); - if ($oStepTrigger->stepTriggerExists( $row['STEP_UID'], $row['TAS_UID'], $row['TRI_UID'], $row['ST_TYPE'] )) - $oStepTrigger->remove( $row['STEP_UID'], $row['TAS_UID'], $row['TRI_UID'], $row['ST_TYPE'] ); - - $res = $oStepTrigger->createRow( $row ); - } - return; - } - - /** - * Get Step Trigger Rows for a Process form an array - * - * @param array $aTask - * @return array $aStepTrigger - */ - function getStepTriggerRows ($aTask) - { - try { - $aInTasks = array (); - foreach ($aTask as $key => $val) { - $aInTasks[] = $val['TAS_UID']; - } - - $aTrigger = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( StepTriggerPeer::TAS_UID, $aInTasks, Criteria::IN ); - $oDataset = StepTriggerPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - $aStepTrigger = array (); - while ($aRow = $oDataset->getRow()) { - $aStepTrigger[] = $aRow; - $oDataset->next(); - } - return $aStepTrigger; - } catch (Exception $oError) { - throw ($oError); - } - } - - /** - * Get Step Trigger Rows for a Process form an array - * - * @param array $aTask - * @return array $aStepTrigger - */ - function getTriggerRows ($sProUid) - { - try { - $aTrigger = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( TriggersPeer::PRO_UID, $sProUid ); - $oDataset = TriggersPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $oTrigger = new Triggers(); - $aTrigger[] = $oTrigger->Load( $aRow['TRI_UID'] ); - $oDataset->next(); - } - return $aTrigger; - } catch (Exception $oError) { - throw ($oError); - } - } - - /** - * Create Step Trigger Rows for a Process form an array - * - * @param array $aTrigger - * @return void - */ - function createTriggerRows ($aTrigger) - { - foreach ($aTrigger as $key => $row) { - $oTrigger = new Triggers(); + if ($oDynaform->exists( $row['DYN_UID'] )) { + $oDynaform->remove( $row['DYN_UID'] ); + } + $res = $oDynaform->create( $row ); + } + return; + } + #@!neyek + + + /** + * Create Step Trigger Rows for a Process form an array + * + * @param array $aStepTrigger + * @return void + */ + public function createStepTriggerRows ($aStepTrigger) + { + foreach ($aStepTrigger as $key => $row) { + $oStepTrigger = new StepTrigger(); //unset ($row['TAS_UID']); - if ($oTrigger->TriggerExists( $row['TRI_UID'] )) - $oTrigger->remove( $row['TRI_UID'] ); - - $res = $oTrigger->create( $row ); - } - return; - } - - /** - * Get Groupwf Rows for a Process form an array - * - * @param array $aGroups - * @return array $aGroupwf - */ - function getGroupwfRows ($aGroups) - { - try { - $aInGroups = array (); - foreach ($aGroups as $key => $val) { - $aInGroups[] = $val['USR_UID']; - } - - $aGroupwf = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( GroupwfPeer::GRP_UID, $aInGroups, Criteria::IN ); - $oDataset = GroupwfPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $oGroupwf = new Groupwf(); - $aGroupwf[] = $oGroupwf->Load( $aRow['GRP_UID'] ); - $oDataset->next(); - } - return $aGroupwf; - } catch (Exception $oError) { - throw ($oError); - } - } - - /** - * Get DB Connections Rows for a Process - * - * @param array $sProUid - * @return array $aConnections - */ - function getDBConnectionsRows ($sProUid) - { - try { - $aConnections = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( DbSourcePeer::PRO_UID, $sProUid ); - $oDataset = DbSourcePeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $oConnection = new DbSource(); - $aConnections[] = $oConnection->Load( $aRow['DBS_UID'], $aRow['PRO_UID'] ); - $oDataset->next(); - } - return $aConnections; - } catch (Exception $oError) { - throw $oError; - } - } - - /** - * Get Step Supervisor Rows for a Process form an array - * - * @param array $sProUid - * @return array $aStepSup - */ - function getStepSupervisorRows ($sProUid) - { - try { - $aConnections = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( StepSupervisorPeer::PRO_UID, $sProUid ); - $oDataset = StepSupervisorPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - $aStepSup = array (); - while ($aRow = $oDataset->getRow()) { - $aStepSup[] = $aRow; - $oDataset->next(); - } - return $aStepSup; - } catch (Exception $oError) { - throw $oError; - } - } - - /** - * Get Report Tables Rows for a Process form an array - * - * @param array $aTask - * @return array $aReps - */ - function getReportTablesRows ($sProUid) - { - try { - $aReps = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( ReportTablePeer::PRO_UID, $sProUid ); - $oDataset = ReportTablePeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $oRep = new ReportTable(); - $aReps[] = $oRep->load( $aRow['REP_TAB_UID'] ); - $oDataset->next(); - } - return $aReps; - } catch (Exception $oError) { - throw $oError; - } - } - - /** - * Get Report Tables Vars Rows for a Process - * - * @param string $sProUid - * @return array $aRepVars - */ - function getReportTablesVarsRows ($sProUid) - { - try { - $aRepVars = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( ReportVarPeer::PRO_UID, $sProUid ); - $oDataset = ReportVarPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $oRepVar = new ReportVar(); - $aRepVars[] = $oRepVar->load( $aRow['REP_VAR_UID'] ); - $oDataset->next(); - } - return $aRepVars; - } catch (Exception $oError) { - throw $oError; - } - } - - /** - * Get Task User Rows for a Process - * - * @param array $aTask - * @return array $aStepTrigger - */ - function getTaskUserRows ($aTask) - { - try { - $aInTasks = array (); - foreach ($aTask as $key => $val) { - $aInTasks[] = $val['TAS_UID']; - } - - $aTaskUser = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( TaskUserPeer::TAS_UID, $aInTasks, Criteria::IN ); - $oCriteria->add( TaskUserPeer::TU_RELATION, 2 ); - $oDataset = TaskUserPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $oCriteria2 = new Criteria( 'workflow' ); - $oCriteria2->clearSelectColumns(); - $oCriteria2->addSelectColumn( 'COUNT(*)' ); - $oCriteria2->add( GroupwfPeer::GRP_UID, $aRow['USR_UID'] ); - $oCriteria2->add( GroupwfPeer::GRP_STATUS, 'ACTIVE' ); - $oDataset2 = GroupwfPeer::doSelectRS( $oCriteria2 ); + if ($oStepTrigger->stepTriggerExists( $row['STEP_UID'], $row['TAS_UID'], $row['TRI_UID'], $row['ST_TYPE'] )) { + $oStepTrigger->remove( $row['STEP_UID'], $row['TAS_UID'], $row['TRI_UID'], $row['ST_TYPE'] ); + } + $res = $oStepTrigger->createRow( $row ); + } + return; + } + + /** + * Get Step Trigger Rows for a Process form an array + * + * @param array $aTask + * @return array $aStepTrigger + */ + public function getStepTriggerRows ($aTask) + { + try { + $aInTasks = array (); + foreach ($aTask as $key => $val) { + $aInTasks[] = $val['TAS_UID']; + } + + $aTrigger = array (); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( StepTriggerPeer::TAS_UID, $aInTasks, Criteria::IN ); + $oDataset = StepTriggerPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aStepTrigger = array (); + while ($aRow = $oDataset->getRow()) { + $aStepTrigger[] = $aRow; + $oDataset->next(); + } + return $aStepTrigger; + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * Get Step Trigger Rows for a Process form an array + * + * @param array $aTask + * @return array $aStepTrigger + */ + public function getTriggerRows ($sProUid) + { + try { + $aTrigger = array (); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( TriggersPeer::PRO_UID, $sProUid ); + $oDataset = TriggersPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $oTrigger = new Triggers(); + $aTrigger[] = $oTrigger->Load( $aRow['TRI_UID'] ); + $oDataset->next(); + } + return $aTrigger; + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * Create Step Trigger Rows for a Process form an array + * + * @param array $aTrigger + * @return void + */ + public function createTriggerRows ($aTrigger) + { + foreach ($aTrigger as $key => $row) { + $oTrigger = new Triggers(); + //unset ($row['TAS_UID']); + if ($oTrigger->TriggerExists( $row['TRI_UID'] )) { + $oTrigger->remove( $row['TRI_UID'] ); + } + $res = $oTrigger->create( $row ); + } + return; + } + + /** + * Get Groupwf Rows for a Process form an array + * + * @param array $aGroups + * @return array $aGroupwf + */ + public function getGroupwfRows ($aGroups) + { + try { + $aInGroups = array (); + foreach ($aGroups as $key => $val) { + $aInGroups[] = $val['USR_UID']; + } + + $aGroupwf = array (); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( GroupwfPeer::GRP_UID, $aInGroups, Criteria::IN ); + $oDataset = GroupwfPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $oGroupwf = new Groupwf(); + $aGroupwf[] = $oGroupwf->Load( $aRow['GRP_UID'] ); + $oDataset->next(); + } + return $aGroupwf; + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * Get DB Connections Rows for a Process + * + * @param array $sProUid + * @return array $aConnections + */ + public function getDBConnectionsRows ($sProUid) + { + try { + $aConnections = array (); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( DbSourcePeer::PRO_UID, $sProUid ); + $oDataset = DbSourcePeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $oConnection = new DbSource(); + $aConnections[] = $oConnection->Load( $aRow['DBS_UID'], $aRow['PRO_UID'] ); + $oDataset->next(); + } + return $aConnections; + } catch (Exception $oError) { + throw $oError; + } + } + + /** + * Get Step Supervisor Rows for a Process form an array + * + * @param array $sProUid + * @return array $aStepSup + */ + public function getStepSupervisorRows ($sProUid) + { + try { + $aConnections = array (); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( StepSupervisorPeer::PRO_UID, $sProUid ); + $oDataset = StepSupervisorPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aStepSup = array (); + while ($aRow = $oDataset->getRow()) { + $aStepSup[] = $aRow; + $oDataset->next(); + } + return $aStepSup; + } catch (Exception $oError) { + throw $oError; + } + } + + /** + * Get Report Tables Rows for a Process form an array + * + * @param array $aTask + * @return array $aReps + */ + public function getReportTablesRows ($sProUid) + { + try { + $aReps = array (); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( ReportTablePeer::PRO_UID, $sProUid ); + $oDataset = ReportTablePeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $oRep = new ReportTable(); + $aReps[] = $oRep->load( $aRow['REP_TAB_UID'] ); + $oDataset->next(); + } + return $aReps; + } catch (Exception $oError) { + throw $oError; + } + } + + /** + * Get Report Tables Vars Rows for a Process + * + * @param string $sProUid + * @return array $aRepVars + */ + public function getReportTablesVarsRows ($sProUid) + { + try { + $aRepVars = array (); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( ReportVarPeer::PRO_UID, $sProUid ); + $oDataset = ReportVarPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $oRepVar = new ReportVar(); + $aRepVars[] = $oRepVar->load( $aRow['REP_VAR_UID'] ); + $oDataset->next(); + } + return $aRepVars; + } catch (Exception $oError) { + throw $oError; + } + } + + /** + * Get Task User Rows for a Process + * + * @param array $aTask + * @return array $aStepTrigger + */ + public function getTaskUserRows ($aTask) + { + try { + $aInTasks = array (); + foreach ($aTask as $key => $val) { + $aInTasks[] = $val['TAS_UID']; + } + + $aTaskUser = array (); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( TaskUserPeer::TAS_UID, $aInTasks, Criteria::IN ); + $oCriteria->add( TaskUserPeer::TU_RELATION, 2 ); + $oDataset = TaskUserPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $oCriteria2 = new Criteria( 'workflow' ); + $oCriteria2->clearSelectColumns(); + $oCriteria2->addSelectColumn( 'COUNT(*)' ); + $oCriteria2->add( GroupwfPeer::GRP_UID, $aRow['USR_UID'] ); + $oCriteria2->add( GroupwfPeer::GRP_STATUS, 'ACTIVE' ); + $oDataset2 = GroupwfPeer::doSelectRS( $oCriteria2 ); //$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset2->next(); - $aRow2 = $oDataset2->getRow(); - $bActiveGroup = $aRow2[0]; - if ($bActiveGroup == 1) - $aTaskUser[] = $aRow; - $oDataset->next(); - } - return $aTaskUser; - } catch (Exception $oError) { - throw ($oError); - } - } - - /** - * Get Task User Rows from an array of data - * - * @param array $aTaskUser - * @return array $aStepTrigger - */ - function createTaskUserRows ($aTaskUser) - { - foreach ($aTaskUser as $key => $row) { - $oTaskUser = new TaskUser(); - if ($oTaskUser->TaskUserExists( $row['TAS_UID'], $row['USR_UID'], $row['TU_TYPE'], $row['TU_RELATION'] )) - $oTaskUser->remove( $row['TAS_UID'], $row['USR_UID'], $row['TU_TYPE'], $row['TU_RELATION'] ); - - $res = $oTaskUser->create( $row ); - } - return; - } - - /** - * Get Task User Rows from an array of data - * - * @param array $aTaskUser - * @return array $aStepTrigger - */ - function createGroupRow ($aGroupwf) - { - foreach ($aGroupwf as $key => $row) { - $oGroupwf = new Groupwf(); - if ($oGroupwf->GroupwfExists( $row['GRP_UID'] )) { - $oGroupwf->remove( $row['GRP_UID'] ); - } - $res = $oGroupwf->create( $row ); - } - } - - /** - * Create DB Connections rows from an array of data - * - * @param array $aConnections - * @return void - */ - function createDBConnectionsRows ($aConnections) - { - foreach ($aConnections as $sKey => $aRow) { - $oConnection = new DbSource(); - if ($oConnection->Exists( $aRow['DBS_UID'], $aRow['PRO_UID'] )) { - $oConnection->remove( $aRow['DBS_UID'], $aRow['PRO_UID'] ); - } - $oConnection->create( $aRow ); - + $oDataset2->next(); + $aRow2 = $oDataset2->getRow(); + $bActiveGroup = $aRow2[0]; + if ($bActiveGroup == 1) { + $aTaskUser[] = $aRow; + } + $oDataset->next(); + } + return $aTaskUser; + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * Get Task User Rows from an array of data + * + * @param array $aTaskUser + * @return array $aStepTrigger + */ + public function createTaskUserRows ($aTaskUser) + { + foreach ($aTaskUser as $key => $row) { + $oTaskUser = new TaskUser(); + if ($oTaskUser->TaskUserExists( $row['TAS_UID'], $row['USR_UID'], $row['TU_TYPE'], $row['TU_RELATION'] )) { + $oTaskUser->remove( $row['TAS_UID'], $row['USR_UID'], $row['TU_TYPE'], $row['TU_RELATION'] ); + } + $res = $oTaskUser->create( $row ); + } + return; + } + + /** + * Get Task User Rows from an array of data + * + * @param array $aTaskUser + * @return array $aStepTrigger + */ + public function createGroupRow ($aGroupwf) + { + foreach ($aGroupwf as $key => $row) { + $oGroupwf = new Groupwf(); + if ($oGroupwf->GroupwfExists( $row['GRP_UID'] )) { + $oGroupwf->remove( $row['GRP_UID'] ); + } + $res = $oGroupwf->create( $row ); + } + } + + /** + * Create DB Connections rows from an array of data + * + * @param array $aConnections + * @return void + */ + public function createDBConnectionsRows ($aConnections) + { + foreach ($aConnections as $sKey => $aRow) { + $oConnection = new DbSource(); + if ($oConnection->Exists( $aRow['DBS_UID'], $aRow['PRO_UID'] )) { + $oConnection->remove( $aRow['DBS_UID'], $aRow['PRO_UID'] ); + } + $oConnection->create( $aRow ); + // Update information in the table of contents - $oContent = new Content(); - $ConCategory = 'DBS_DESCRIPTION'; - $ConParent = ''; - $ConId = $aRow['DBS_UID']; - $ConLang = SYS_LANG; - if ($oContent->Exists( $ConCategory, $ConParent, $ConId, $ConLang )) { - $oContent->removeContent( $ConCategory, $ConParent, $ConId ); - } - $oContent->addContent( $ConCategory, $ConParent, $ConId, $ConLang, "" ); - } + $oContent = new Content(); + $ConCategory = 'DBS_DESCRIPTION'; + $ConParent = ''; + $ConId = $aRow['DBS_UID']; + $ConLang = SYS_LANG; + if ($oContent->Exists( $ConCategory, $ConParent, $ConId, $ConLang )) { + $oContent->removeContent( $ConCategory, $ConParent, $ConId ); + } + $oContent->addContent( $ConCategory, $ConParent, $ConId, $ConLang, "" ); + } } #@!neyek - - - /** - * Create Report Tables from an array of data - * - * @param array $aReportTables - * @param array $aReportTablesVars - * @return void - */ - function createReportTables ($aReportTables, $aReportTablesVars) - { - $this->createReportTablesVars( $aReportTablesVars ); - $oReportTables = new ReportTables(); - foreach ($aReportTables as $sKey => $aRow) { - $bExists = true; - $sTable = $aRow['REP_TAB_NAME']; - $iCounter = 1; - while ($bExists) { - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( ReportTablePeer::REP_TAB_NAME, $sTable ); - $oDataset = ReportTablePeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - $bExists = ($aRow2 = $oDataset->getRow()); - if ($bExists) { - $sTable = $aRow['REP_TAB_NAME'] . '_' . $iCounter; - $iCounter ++; - } else { - $aRow['REP_TAB_NAME'] = $sTable; - } - } - $aFields = $oReportTables->getTableVars( $aRow['REP_TAB_UID'], true ); - $oReportTables->createTable( $aRow['REP_TAB_NAME'], $aRow['REP_TAB_CONNECTION'], $aRow['REP_TAB_TYPE'], $aFields ); - $oReportTables->populateTable( $aRow['REP_TAB_NAME'], $aRow['REP_TAB_CONNECTION'], $aRow['REP_TAB_TYPE'], $aFields, $aRow['PRO_UID'], $aRow['REP_TAB_GRID'] ); - $aReportTables[$sKey]['REP_TAB_NAME'] = $aRow['REP_TAB_NAME']; - $oRep = new ReportTable(); - if ($oRep->reportTableExists( $aRow['REP_TAB_UID'] )) - $oRep->remove( $aRow['REP_TAB_UID'] ); - $oRep->create( $aRow ); - } + + + /** + * Create Report Tables from an array of data + * + * @param array $aReportTables + * @param array $aReportTablesVars + * @return void + */ + public function createReportTables ($aReportTables, $aReportTablesVars) + { + $this->createReportTablesVars( $aReportTablesVars ); + $oReportTables = new ReportTables(); + foreach ($aReportTables as $sKey => $aRow) { + $bExists = true; + $sTable = $aRow['REP_TAB_NAME']; + $iCounter = 1; + while ($bExists) { + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( ReportTablePeer::REP_TAB_NAME, $sTable ); + $oDataset = ReportTablePeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $bExists = ($aRow2 = $oDataset->getRow()); + if ($bExists) { + $sTable = $aRow['REP_TAB_NAME'] . '_' . $iCounter; + $iCounter ++; + } else { + $aRow['REP_TAB_NAME'] = $sTable; + } + } + $aFields = $oReportTables->getTableVars( $aRow['REP_TAB_UID'], true ); + $oReportTables->createTable( $aRow['REP_TAB_NAME'], $aRow['REP_TAB_CONNECTION'], $aRow['REP_TAB_TYPE'], $aFields ); + $oReportTables->populateTable( $aRow['REP_TAB_NAME'], $aRow['REP_TAB_CONNECTION'], $aRow['REP_TAB_TYPE'], $aFields, $aRow['PRO_UID'], $aRow['REP_TAB_GRID'] ); + $aReportTables[$sKey]['REP_TAB_NAME'] = $aRow['REP_TAB_NAME']; + $oRep = new ReportTable(); + if ($oRep->reportTableExists( $aRow['REP_TAB_UID'] )) { + $oRep->remove( $aRow['REP_TAB_UID'] ); + } + $oRep->create( $aRow ); + } + } + #@!neyek + + /** + * Update Report Tables from an array of data + * + * @param array $aReportTables + * @param array $aReportTablesVars + * @return void + */ + public function updateReportTables ($aReportTables, $aReportTablesVars) + { + $this->cleanupReportTablesReferences( $aReportTables ); + $this->createReportTables( $aReportTables, $aReportTablesVars ); } #@!neyek - - - /** - * Update Report Tables from an array of data - * - * @param array $aReportTables - * @param array $aReportTablesVars - * @return void - */ - function updateReportTables ($aReportTables, $aReportTablesVars) - { - $this->cleanupReportTablesReferences( $aReportTables ); - $this->createReportTables( $aReportTables, $aReportTablesVars ); + + + /** + * Create Report Tables Vars from an array of data + * + * @param array $aReportTablesVars + * @return void + */ + public function createReportTablesVars ($aReportTablesVars) + { + foreach ($aReportTablesVars as $sKey => $aRow) { + $oRep = new ReportVar(); + if ($oRep->reportVarExists( $aRow['REP_VAR_UID'] )) { + $oRep->remove( $aRow['REP_VAR_UID'] ); + } + $oRep->create( $aRow ); + } } #@!neyek - - - /** - * Create Report Tables Vars from an array of data - * - * @param array $aReportTablesVars - * @return void - */ - function createReportTablesVars ($aReportTablesVars) - { - foreach ($aReportTablesVars as $sKey => $aRow) { - $oRep = new ReportVar(); - if ($oRep->reportVarExists( $aRow['REP_VAR_UID'] )) - $oRep->remove( $aRow['REP_VAR_UID'] ); - - $oRep->create( $aRow ); - } + + + /** + * Cleanup Report Tables References from an array of data + * + * @param array $aReportTables + * @return void + */ + public function cleanupReportTablesReferences ($aReportTables) + { + foreach ($aReportTables as $sKey => $aRow) { + $oReportTables = new ReportTables(); + $oReportTables->deleteReportTable( $aRow['REP_TAB_UID'] ); + $oReportTables->deleteAllReportVars( $aRow['REP_TAB_UID'] ); + $oReportTables->dropTable( $aRow['REP_TAB_NAME'] ); + } } #@!neyek - - - /** - * Cleanup Report Tables References from an array of data - * - * @param array $aReportTables - * @return void - */ - function cleanupReportTablesReferences ($aReportTables) - { - foreach ($aReportTables as $sKey => $aRow) { - $oReportTables = new ReportTables(); - $oReportTables->deleteReportTable( $aRow['REP_TAB_UID'] ); - $oReportTables->deleteAllReportVars( $aRow['REP_TAB_UID'] ); - $oReportTables->dropTable( $aRow['REP_TAB_NAME'] ); - } - } #@!neyek - - - /** - * change Status of any Process - * - * @param string $sProUid - * @return boolean - */ - function serializeProcess ($sProUid = '') - { - $oProcess = new Process(); - $oData->process = $this->getProcessRow( $sProUid, false ); - $oData->tasks = $this->getTaskRows( $sProUid ); - $oData->routes = $this->getRouteRows( $sProUid ); - $oData->lanes = $this->getLaneRows( $sProUid ); - $oData->gateways = $this->getGatewayRows( $sProUid ); - $oData->inputs = $this->getInputRows( $sProUid ); - $oData->outputs = $this->getOutputRows( $sProUid ); - $oData->dynaforms = $this->getDynaformRows( $sProUid ); - $oData->steps = $this->getStepRows( $sProUid ); - $oData->triggers = $this->getTriggerRows( $sProUid ); - $oData->taskusers = $this->getTaskUserRows( $oData->tasks ); - $oData->groupwfs = $this->getGroupwfRows( $oData->taskusers ); - $oData->steptriggers = $this->getStepTriggerRows( $oData->tasks ); - $oData->dbconnections = $this->getDBConnectionsRows( $sProUid ); - $oData->reportTables = $this->getReportTablesRows( $sProUid ); - $oData->reportTablesVars = $this->getReportTablesVarsRows( $sProUid ); - $oData->stepSupervisor = $this->getStepSupervisorRows( $sProUid ); - $oData->objectPermissions = $this->getObjectPermissionRows( $sProUid ); - $oData->subProcess = $this->getSubProcessRow( $sProUid ); - $oData->caseTracker = $this->getCaseTrackerRow( $sProUid ); - $oData->caseTrackerObject = $this->getCaseTrackerObjectRow( $sProUid ); - $oData->stage = $this->getStageRow( $sProUid ); - $oData->fieldCondition = $this->getFieldCondition( $sProUid ); - $oData->event = $this->getEventRow( $sProUid ); - $oData->caseScheduler = $this->getCaseSchedulerRow( $sProUid ); - $oData->processCategory = $this->getProcessCategoryRow( $sProUid ); - + + + /** + * change Status of any Process + * + * @param string $sProUid + * @return boolean + */ + public function serializeProcess ($sProUid = '') + { + $oProcess = new Process(); + $oData->process = $this->getProcessRow( $sProUid, false ); + $oData->tasks = $this->getTaskRows( $sProUid ); + $oData->routes = $this->getRouteRows( $sProUid ); + $oData->lanes = $this->getLaneRows( $sProUid ); + $oData->gateways = $this->getGatewayRows( $sProUid ); + $oData->inputs = $this->getInputRows( $sProUid ); + $oData->outputs = $this->getOutputRows( $sProUid ); + $oData->dynaforms = $this->getDynaformRows( $sProUid ); + $oData->steps = $this->getStepRows( $sProUid ); + $oData->triggers = $this->getTriggerRows( $sProUid ); + $oData->taskusers = $this->getTaskUserRows( $oData->tasks ); + $oData->groupwfs = $this->getGroupwfRows( $oData->taskusers ); + $oData->steptriggers = $this->getStepTriggerRows( $oData->tasks ); + $oData->dbconnections = $this->getDBConnectionsRows( $sProUid ); + $oData->reportTables = $this->getReportTablesRows( $sProUid ); + $oData->reportTablesVars = $this->getReportTablesVarsRows( $sProUid ); + $oData->stepSupervisor = $this->getStepSupervisorRows( $sProUid ); + $oData->objectPermissions = $this->getObjectPermissionRows( $sProUid ); + $oData->subProcess = $this->getSubProcessRow( $sProUid ); + $oData->caseTracker = $this->getCaseTrackerRow( $sProUid ); + $oData->caseTrackerObject = $this->getCaseTrackerObjectRow( $sProUid ); + $oData->stage = $this->getStageRow( $sProUid ); + $oData->fieldCondition = $this->getFieldCondition( $sProUid ); + $oData->event = $this->getEventRow( $sProUid ); + $oData->caseScheduler = $this->getCaseSchedulerRow( $sProUid ); + $oData->processCategory = $this->getProcessCategoryRow( $sProUid ); + //krumo ($oData);die; //$oJSON = new Services_JSON(); //krumo ( $oJSON->encode($oData) ); //return $oJSON->encode($oData); - return serialize( $oData ); - } - - /** - * Save a Serialized Process from an object - * - * @param array $oData - * @return $result an array - */ - function saveSerializedProcess ($oData) - { + return serialize( $oData ); + } + + /** + * Save a Serialized Process from an object + * + * @param array $oData + * @return $result an array + */ + public function saveSerializedProcess ($oData) + { //$oJSON = new Services_JSON(); //$data = $oJSON->decode($oData); //$sProUid = $data->process->PRO_UID; - $data = unserialize( $oData ); - $sProUid = $data->process['PRO_UID']; - $path = PATH_DOCUMENT . 'output' . PATH_SEP; - - if (! is_dir( $path )) { - G::verifyPath( $path, true ); - } - $proTitle = (substr( G::inflect( $data->process['PRO_TITLE'] ), 0, 245 )); - $proTitle = preg_replace( "/[^A-Za-z0-9_]/", "", $proTitle ); + $data = unserialize( $oData ); + $sProUid = $data->process['PRO_UID']; + $path = PATH_DOCUMENT . 'output' . PATH_SEP; + + if (! is_dir( $path )) { + G::verifyPath( $path, true ); + } + + $proTitle = (substr( G::inflect( $data->process['PRO_TITLE'] ), 0, 245 )); + $proTitle = preg_replace( "/[^A-Za-z0-9_]/", "", $proTitle ); //Calculating the maximum length of file name - $pathLength = strlen( PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP ); - $length = strlen( $proTitle ) + $pathLength; - if ($length >= 250) { - $proTitle = myTruncate( $proTitle, 250 - $pathLength, '_', '' ); - } - $index = ''; - - $lastIndex = ''; - - do { - $filename = $path . $proTitle . $index . '.pm'; - $lastIndex = $index; - - if ($index == '') - $index = 1; - else - $index ++; - } while (file_exists( $filename )); - - $proTitle .= $lastIndex; - - $filenameOnly = $proTitle . '.pm'; - - $fp = fopen( $filename . 'tpm', "wb" ); - - $fsData = sprintf( "%09d", strlen( $oData ) ); + $pathLength = strlen( PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP ); + $length = strlen( $proTitle ) + $pathLength; + if ($length >= 250) { + $proTitle = myTruncate( $proTitle, 250 - $pathLength, '_', '' ); + } + $index = ''; + + $lastIndex = ''; + + do { + $filename = $path . $proTitle . $index . '.pm'; + $lastIndex = $index; + + if ($index == '') { + $index = 1; + } else { + $index ++; + } + } while (file_exists( $filename )); + + $proTitle .= $lastIndex; + + $filenameOnly = $proTitle . '.pm'; + + $fp = fopen( $filename . 'tpm', "wb" ); + + $fsData = sprintf( "%09d", strlen( $oData ) ); $bytesSaved = fwrite( $fp, $fsData ); //writing the size of $oData $bytesSaved += fwrite( $fp, $oData ); //writing the $oData - - - foreach ($data->dynaforms as $key => $val) { - $sFileName = PATH_DYNAFORM . $val['DYN_FILENAME'] . '.xml'; - if (file_exists( $sFileName )) { - $xmlGuid = $val['DYN_UID']; - $fsXmlGuid = sprintf( "%09d", strlen( $xmlGuid ) ); + + + foreach ($data->dynaforms as $key => $val) { + $sFileName = PATH_DYNAFORM . $val['DYN_FILENAME'] . '.xml'; + if (file_exists( $sFileName )) { + $xmlGuid = $val['DYN_UID']; + $fsXmlGuid = sprintf( "%09d", strlen( $xmlGuid ) ); $bytesSaved += fwrite( $fp, $fsXmlGuid ); //writing the size of xml file $bytesSaved += fwrite( $fp, $xmlGuid ); //writing the xmlfile - - - $xmlContent = file_get_contents( $sFileName ); - $fsXmlContent = sprintf( "%09d", strlen( $xmlContent ) ); + + $xmlContent = file_get_contents( $sFileName ); + $fsXmlContent = sprintf( "%09d", strlen( $xmlContent ) ); $bytesSaved += fwrite( $fp, $fsXmlContent ); //writing the size of xml file $bytesSaved += fwrite( $fp, $xmlContent ); //writing the xmlfile - } - - $sFileName2 = PATH_DYNAFORM . $val['DYN_FILENAME'] . '.html'; - if (file_exists( $sFileName2 )) { - $htmlGuid = $val['DYN_UID']; - $fsHtmlGuid = sprintf( "%09d", strlen( $htmlGuid ) ); + } + + $sFileName2 = PATH_DYNAFORM . $val['DYN_FILENAME'] . '.html'; + if (file_exists( $sFileName2 )) { + $htmlGuid = $val['DYN_UID']; + $fsHtmlGuid = sprintf( "%09d", strlen( $htmlGuid ) ); $bytesSaved += fwrite( $fp, $fsHtmlGuid ); //writing size dynaform id $bytesSaved += fwrite( $fp, $htmlGuid ); //writing dynaform id - - - $htmlContent = file_get_contents( $sFileName2 ); - $fsHtmlContent = sprintf( "%09d", strlen( $htmlContent ) ); + + + $htmlContent = file_get_contents( $sFileName2 ); + $fsHtmlContent = sprintf( "%09d", strlen( $htmlContent ) ); $bytesSaved += fwrite( $fp, $fsHtmlContent ); //writing the size of xml file $bytesSaved += fwrite( $fp, $htmlContent ); //writing the htmlfile - } - } - /** - * By - * here we should work for the new functionalities - * we have a many files for attach into this file - * - * here we go with the anothers files ;) - */ + } + } + /** + * By + * here we should work for the new functionalities + * we have a many files for attach into this file + * + * here we go with the anothers files ;) + */ //before to do something we write a header into pm file for to do a differentiation between document types - - + + //create the store object //$file_objects = new ObjectCellection(); - - + + // for mailtemplates files - $MAILS_ROOT_PATH = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'mailTemplates' . PATH_SEP . $data->process['PRO_UID']; - - $isMailTempSent = false; - $isPublicSent = false; + $MAILS_ROOT_PATH = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'mailTemplates' . PATH_SEP . $data->process['PRO_UID']; + + $isMailTempSent = false; + $isPublicSent = false; //if this process have any mailfile - if (is_dir( $MAILS_ROOT_PATH )) { - + if (is_dir( $MAILS_ROOT_PATH )) { + //get mail files list from this directory - $file_list = scandir( $MAILS_ROOT_PATH ); - - foreach ($file_list as $filename) { + $file_list = scandir( $MAILS_ROOT_PATH ); + + foreach ($file_list as $filename) { // verify if this filename is a valid file, because it could be . or .. on *nix systems - if ($filename != '.' && $filename != '..') { - if (@is_readable( $MAILS_ROOT_PATH . PATH_SEP . $filename )) { - $sFileName = $MAILS_ROOT_PATH . PATH_SEP . $filename; - if (file_exists( $sFileName )) { - if (! $isMailTempSent) { - $bytesSaved += fwrite( $fp, 'MAILTEMPL' ); - $isMailTempSent = true; - } + if ($filename != '.' && $filename != '..') { + if (@is_readable( $MAILS_ROOT_PATH . PATH_SEP . $filename )) { + $sFileName = $MAILS_ROOT_PATH . PATH_SEP . $filename; + if (file_exists( $sFileName )) { + if (! $isMailTempSent) { + $bytesSaved += fwrite( $fp, 'MAILTEMPL' ); + $isMailTempSent = true; + } //$htmlGuid = $val['DYN_UID']; - $fsFileName = sprintf( "%09d", strlen( $filename ) ); + $fsFileName = sprintf( "%09d", strlen( $filename ) ); $bytesSaved += fwrite( $fp, $fsFileName ); //writing the fileName size $bytesSaved += fwrite( $fp, $filename ); //writing the fileName size - - - $fileContent = file_get_contents( $sFileName ); - $fsFileContent = sprintf( "%09d", strlen( $fileContent ) ); + + $fileContent = file_get_contents( $sFileName ); + $fsFileContent = sprintf( "%09d", strlen( $fileContent ) ); $bytesSaved += fwrite( $fp, $fsFileContent ); //writing the size of xml file $bytesSaved += fwrite( $fp, $fileContent ); //writing the htmlfile - } - - } - } - } - } - + } + } + } + } + } + // for public files - $PUBLIC_ROOT_PATH = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'public' . PATH_SEP . $data->process['PRO_UID']; - + $PUBLIC_ROOT_PATH = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'public' . PATH_SEP . $data->process['PRO_UID']; + //if this process have any mailfile - if (is_dir( $PUBLIC_ROOT_PATH )) { - + if (is_dir( $PUBLIC_ROOT_PATH )) { //get mail files list from this directory - $file_list = scandir( $PUBLIC_ROOT_PATH ); - - foreach ($file_list as $filename) { + $file_list = scandir( $PUBLIC_ROOT_PATH ); + foreach ($file_list as $filename) { // verify if this filename is a valid file, because it could be . or .. on *nix systems - if ($filename != '.' && $filename != '..') { - if (@is_readable( $PUBLIC_ROOT_PATH . PATH_SEP . $filename )) { - $sFileName = $PUBLIC_ROOT_PATH . PATH_SEP . $filename; - if (file_exists( $sFileName )) { - if (! $isPublicSent) { - $bytesSaved += fwrite( $fp, 'PUBLIC ' ); - $isPublicSent = true; - } + if ($filename != '.' && $filename != '..') { + if (@is_readable( $PUBLIC_ROOT_PATH . PATH_SEP . $filename )) { + $sFileName = $PUBLIC_ROOT_PATH . PATH_SEP . $filename; + if (file_exists( $sFileName )) { + if (! $isPublicSent) { + $bytesSaved += fwrite( $fp, 'PUBLIC ' ); + $isPublicSent = true; + } //$htmlGuid = $val['DYN_UID']; - $fsFileName = sprintf( "%09d", strlen( $filename ) ); - $bytesSaved += fwrite( $fp, $fsFileName ); //writing the fileName size - $bytesSaved += fwrite( $fp, $filename ); //writing the fileName size - - - $fileContent = file_get_contents( $sFileName ); - $fsFileContent = sprintf( "%09d", strlen( $fileContent ) ); - $bytesSaved += fwrite( $fp, $fsFileContent ); //writing the size of xml file - $bytesSaved += fwrite( $fp, $fileContent ); //writing the htmlfile - } - - } - } - } - } - + $fsFileName = sprintf( "%09d", strlen( $filename ) ); + $bytesSaved += fwrite( $fp, $fsFileName ); + //writing the fileName size + $bytesSaved += fwrite( $fp, $filename ); + //writing the fileName size + $fileContent = file_get_contents( $sFileName ); + $fsFileContent = sprintf( "%09d", strlen( $fileContent ) ); + $bytesSaved += fwrite( $fp, $fsFileContent ); + //writing the size of xml file + $bytesSaved += fwrite( $fp, $fileContent ); + //writing the htmlfile + } + } + } + } + } + /* - // for public files - $PUBLIC_ROOT_PATH = PATH_DATA.'sites'.PATH_SEP.SYS_SYS.PATH_SEP.'public'.PATH_SEP.$data->process['PRO_UID']; - - //if this process have any mailfile - if ( is_dir( $PUBLIC_ROOT_PATH ) ) { - - //get mail files list from this directory - $files_list = scandir($PUBLIC_ROOT_PATH); - foreach ($file_list as $filename) { - // verify if this filename is a valid file, beacuse it could be . or .. on *nix systems - if($filename != '.' && $filename != '..'){ - if (@is_readable($PUBLIC_ROOT_PATH.PATH_SEP.$nombre_archivo)) { - $tmp = explode('.', $filename); - $ext = $tmp[1]; - $ext_fp = fopen($PUBLIC_ROOT_PATH.PATH_SEP.$nombre_archivo, 'r'); - $file_data = fread($ext_fp, filesize($PUBLIC_ROOT_PATH.PATH_SEP.$nombre_archivo)); - fclose($ext_fp); - $file_objects->add($filename, $ext, $file_data,'public'); + // for public files + $PUBLIC_ROOT_PATH = PATH_DATA.'sites'.PATH_SEP.SYS_SYS.PATH_SEP.'public'.PATH_SEP.$data->process['PRO_UID']; + //if this process have any mailfile + if ( is_dir( $PUBLIC_ROOT_PATH ) ) { + //get mail files list from this directory + $files_list = scandir($PUBLIC_ROOT_PATH); + foreach ($file_list as $filename) { + // verify if this filename is a valid file, beacuse it could be . or .. on *nix systems + if($filename != '.' && $filename != '..'){ + if (@is_readable($PUBLIC_ROOT_PATH.PATH_SEP.$nombre_archivo)) { + $tmp = explode('.', $filename); + $ext = $tmp[1]; + $ext_fp = fopen($PUBLIC_ROOT_PATH.PATH_SEP.$nombre_archivo, 'r'); + $file_data = fread($ext_fp, filesize($PUBLIC_ROOT_PATH.PATH_SEP.$nombre_archivo)); + fclose($ext_fp); + $file_objects->add($filename, $ext, $file_data,'public'); + } + } + } } - } - } - } - - //So,. we write the store object into pm export file - $extended_data = serialize($file_objects); - $bytesSaved += fwrite( $fp, $extended_data ); - */ - /* under here, I've not modified those lines */ - - fclose( $fp ); + //So,. we write the store object into pm export file + $extended_data = serialize($file_objects); + $bytesSaved += fwrite( $fp, $extended_data ); + */ + /* under here, I've not modified those lines */ + fclose( $fp ); //$bytesSaved = file_put_contents ( $filename , $oData ); - $filenameLink = 'processes_DownloadFile?p=' . $proTitle . '&r=' . rand( 100, 1000 ); - $result['PRO_UID'] = $data->process['PRO_UID']; - $result['PRO_TITLE'] = $data->process['PRO_TITLE']; - $result['PRO_DESCRIPTION'] = $data->process['PRO_DESCRIPTION']; - $result['SIZE'] = $bytesSaved; - $result['FILENAME'] = $filenameOnly; - $result['FILENAME_LINK'] = $filenameLink; - return $result; - } - - /** - * Get the process Data form a filename - * - * @param array $pmFilename - * @return void - */ - function getProcessData ($pmFilename) - { - $oProcess = new Process(); - if (! file_exists( $pmFilename )) - throw (new Exception( 'Unable to read uploaded file, please check permissions. ' )); - - if (! filesize( $pmFilename ) >= 9) - throw (new Exception( 'Uploaded file is corrupted, please check the file before continuing. ' )); - clearstatcache(); - $fp = fopen( $pmFilename, "rb" ); + $filenameLink = 'processes_DownloadFile?p=' . $proTitle . '&r=' . rand( 100, 1000 ); + $result['PRO_UID'] = $data->process['PRO_UID']; + $result['PRO_TITLE'] = $data->process['PRO_TITLE']; + $result['PRO_DESCRIPTION'] = $data->process['PRO_DESCRIPTION']; + $result['SIZE'] = $bytesSaved; + $result['FILENAME'] = $filenameOnly; + $result['FILENAME_LINK'] = $filenameLink; + return $result; + } + + /** + * Get the process Data form a filename + * + * @param array $pmFilename + * @return void + */ + public function getProcessData ($pmFilename) + { + $oProcess = new Process(); + if (! file_exists( $pmFilename )) { + throw (new Exception( 'Unable to read uploaded file, please check permissions. ' )); + } + if (! filesize( $pmFilename ) >= 9) { + throw (new Exception( 'Uploaded file is corrupted, please check the file before continuing. ' )); + } + clearstatcache(); + $fp = fopen( $pmFilename, "rb" ); $fsData = intval( fread( $fp, 9 ) ); //reading the size of $oData - $contents = ''; + $contents = ''; $contents = @fread( $fp, $fsData ); //reading string $oData - - - if ($contents != '') { - $oData = unserialize( $contents ); - if ($oData === false) - throw new Exception( "Process file is not valid" ); - - foreach ($oData->dynaforms as $key => $value) { - if ($value['DYN_TYPE'] == 'grid') { - $oData->gridFiles[$value['DYN_UID']] = $value['DYN_UID']; - } - } - - $oData->dynaformFiles = array (); - $sIdentifier = 0; - while (! feof( $fp ) && is_numeric( $sIdentifier )) { - $sIdentifier = fread( $fp, 9 ); //reading the block identifier - if (is_numeric( $sIdentifier )) { + + if ($contents != '') { + $oData = unserialize( $contents ); + if ($oData === false) { + throw new Exception( "Process file is not valid" ); + } + foreach ($oData->dynaforms as $key => $value) { + if ($value['DYN_TYPE'] == 'grid') { + $oData->gridFiles[$value['DYN_UID']] = $value['DYN_UID']; + } + } + + $oData->dynaformFiles = array (); + $sIdentifier = 0; + while (! feof( $fp ) && is_numeric( $sIdentifier )) { + $sIdentifier = fread( $fp, 9 );//reading the block identifier + if (is_numeric( $sIdentifier )) { $fsXmlGuid = intval( $sIdentifier ); //reading the size of $filename - if ($fsXmlGuid > 0) + if ($fsXmlGuid > 0) { $XmlGuid = fread( $fp, $fsXmlGuid ); //reading string $XmlGuid - - + } + $fsXmlContent = intval( fread( $fp, 9 ) ); //reading the size of $XmlContent - if ($fsXmlContent > 0) { - $oData->dynaformFiles[$XmlGuid] = $XmlGuid; + if ($fsXmlContent > 0) { + $oData->dynaformFiles[$XmlGuid] = $XmlGuid; $XmlContent = fread( $fp, $fsXmlContent ); //reading string $XmlContent - unset( $XmlContent ); - } - } - } - } else { - $oData = null; - } - fclose( $fp ); - return $oData; - } - + unset( $XmlContent ); + } + } + } + } else { + $oData = null; + } + fclose( $fp ); + return $oData; + } + // import process related functions - - - /** - * function checkExistingGroups - * checkExistingGroups check if any of the groups listed in the parameter - * array exist and wich are those, that is the result $sFilteredGroups array. - * - * @author gustavo cruz gustavo-at-colosa.com - * @param $sGroupList array of a group list - * @return $existingGroupList array of existing groups or null - */ - function checkExistingGroups ($sGroupList) - { - $aGroupwf = array (); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->addSelectColumn( GroupwfPeer::GRP_UID ); - $oCriteria->addSelectColumn( ContentPeer::CON_ID ); - $oCriteria->addSelectColumn( ContentPeer::CON_VALUE ); - $oCriteria->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' ); - $oCriteria->add( ContentPeer::CON_LANG, 'en' ); - $oCriteria->addJoin( ContentPeer::CON_ID, GroupwfPeer::GRP_UID ); - $oDataset = ContentPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $aGroupwf[] = $aRow; - $oDataset->next(); - } + + + /** + * function checkExistingGroups + * checkExistingGroups check if any of the groups listed in the parameter + * array exist and wich are those, that is the result $sFilteredGroups array. + * + * @author gustavo cruz gustavo-at-colosa.com + * @param $sGroupList array of a group list + * @return $existingGroupList array of existing groups or null + */ + public function checkExistingGroups ($sGroupList) + { + $aGroupwf = array (); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->addSelectColumn( GroupwfPeer::GRP_UID ); + $oCriteria->addSelectColumn( ContentPeer::CON_ID ); + $oCriteria->addSelectColumn( ContentPeer::CON_VALUE ); + $oCriteria->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' ); + $oCriteria->add( ContentPeer::CON_LANG, 'en' ); + $oCriteria->addJoin( ContentPeer::CON_ID, GroupwfPeer::GRP_UID ); + $oDataset = ContentPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $aGroupwf[] = $aRow; + $oDataset->next(); + } //check if any group name exists in the dbase - if (is_array( $sGroupList )) { - foreach ($aGroupwf as $groupBase) { - foreach ($sGroupList as $group) { - if ($groupBase['CON_VALUE'] == $group['GRP_TITLE'] && $groupBase['CON_ID'] != $group['GRP_UID']) { - $existingGroupList[] = $group; - } - } - } - } + if (is_array( $sGroupList )) { + foreach ($aGroupwf as $groupBase) { + foreach ($sGroupList as $group) { + if ($groupBase['CON_VALUE'] == $group['GRP_TITLE'] && $groupBase['CON_ID'] != $group['GRP_UID']) { + $existingGroupList[] = $group; + } + } + } + } //return $sGroupList; - if (isset( $existingGroupList )) - return $existingGroupList; - else - return null; - - } - - /** - * function renameExistingGroups - * renameExistingGroups check if any of the groups listed in the parameter - * array exist and wich are those, then rename the file adding a number - * suffix to the title atribute of each element of the $renamedGroupList array. - * - * @author gustavo cruz gustavo-at-colosa.com - * @param $sGroupList array of a group list - * @return $renamedGroupList array of existing groups - */ - - function renameExistingGroups ($sGroupList) - { - $checkedGroup = $this->checkExistingGroups( $sGroupList ); - foreach ($sGroupList as $groupBase) { - foreach ($checkedGroup as $group) { - if ($groupBase['GRP_TITLE'] == $group['GRP_TITLE']) { - $index = substr( $groupBase['GRP_TITLE'], - 1, 0 ); - if (is_int( $index )) { - $index ++; - } else { - $index = 1; - } - $groupBase['GRP_TITLE'] = $groupBase['GRP_TITLE'] . $index; - } - - } - $renamedGroupList[] = $groupBase; - } - - if (isset( $renamedGroupList )) - return $renamedGroupList; - else - return null; - - } - - /** - * function mergeExistingGroups - * mergeExistingGroups check if any of the groups listed in the parameter - * array exist and wich are those, then replaces the id of the elements in - * in the $mergedGroupList array. - * - * @author gustavo cruz gustavo-at-colosa.com - * @param $sGroupList array of a group list - * @return $mergedGroupList array of existing groups - */ - function mergeExistingGroups ($sGroupList) - { - - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->addSelectColumn( GroupwfPeer::GRP_UID ); - $oCriteria->addSelectColumn( ContentPeer::CON_ID ); - $oCriteria->addSelectColumn( ContentPeer::CON_VALUE ); - $oCriteria->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' ); - $oCriteria->add( ContentPeer::CON_LANG, 'en' ); - $oCriteria->addJoin( ContentPeer::CON_ID, GroupwfPeer::GRP_UID ); - $oDataset = ContentPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $aGroupwf[] = $aRow; - $oDataset->next(); - } + if (isset( $existingGroupList )) { + return $existingGroupList; + } else { + return null; + } + } + + /** + * function renameExistingGroups + * renameExistingGroups check if any of the groups listed in the parameter + * array exist and wich are those, then rename the file adding a number + * suffix to the title atribute of each element of the $renamedGroupList array. + * + * @author gustavo cruz gustavo-at-colosa.com + * @param $sGroupList array of a group list + * @return $renamedGroupList array of existing groups + */ + + public function renameExistingGroups ($sGroupList) + { + $checkedGroup = $this->checkExistingGroups( $sGroupList ); + foreach ($sGroupList as $groupBase) { + foreach ($checkedGroup as $group) { + if ($groupBase['GRP_TITLE'] == $group['GRP_TITLE']) { + $index = substr( $groupBase['GRP_TITLE'], - 1, 0 ); + if (is_int( $index )) { + $index ++; + } else { + $index = 1; + } + $groupBase['GRP_TITLE'] = $groupBase['GRP_TITLE'] . $index; + } + + } + $renamedGroupList[] = $groupBase; + } + + if (isset( $renamedGroupList )) { + return $renamedGroupList; + } else { + return null; + } + } + + /** + * function mergeExistingGroups + * mergeExistingGroups check if any of the groups listed in the parameter + * array exist and wich are those, then replaces the id of the elements in + * in the $mergedGroupList array. + * + * @author gustavo cruz gustavo-at-colosa.com + * @param $sGroupList array of a group list + * @return $mergedGroupList array of existing groups + */ + public function mergeExistingGroups ($sGroupList) + { + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->addSelectColumn( GroupwfPeer::GRP_UID ); + $oCriteria->addSelectColumn( ContentPeer::CON_ID ); + $oCriteria->addSelectColumn( ContentPeer::CON_VALUE ); + $oCriteria->add( ContentPeer::CON_CATEGORY, 'GRP_TITLE' ); + $oCriteria->add( ContentPeer::CON_LANG, 'en' ); + $oCriteria->addJoin( ContentPeer::CON_ID, GroupwfPeer::GRP_UID ); + $oDataset = ContentPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $aGroupwf[] = $aRow; + $oDataset->next(); + } //check if any group name exists in the dbase - foreach ($sGroupList as $group) { - $merged = false; - foreach ($aGroupwf as $groupBase) { - if ($groupBase['CON_VALUE'] == $group['GRP_TITLE'] && $groupBase['CON_ID'] != $group['GRP_UID']) { - $group['GRP_UID'] = $groupBase['CON_ID']; - $mergedGroupList[] = $group; - $merged = true; - } - } - // - if (! $merged) { - $mergedGroupList[] = $group; - } - } - - if (isset( $mergedGroupList )) { - return $mergedGroupList; - } else { - return null; - } - } - - /** - * function mergeExistingUsers - * mergeExistingGroups check if any of the groups listed in the parameter - * array exist and wich are those, then replaces the id of the elements in - * in the $mergedGroupList array. - * - * @author gustavo cruz gustavo-at-colosa.com - * @param $sBaseGroupList array of a group list with the original group list - * @param $sGroupList array of a group list with the merged group list - * @param $sTaskUserList array of the task user list, it contents the link between - * the task and the group list - * @return $mergedTaskUserList array of the merged task user list - */ - function mergeExistingUsers ($sBaseGroupList, $sGroupList, $sTaskUserList) - { - foreach ($sTaskUserList as $taskuser) { - $merged = false; - foreach ($sBaseGroupList as $groupBase) { - foreach ($sGroupList as $group) { + foreach ($sGroupList as $group) { + $merged = false; + foreach ($aGroupwf as $groupBase) { + if ($groupBase['CON_VALUE'] == $group['GRP_TITLE'] && $groupBase['CON_ID'] != $group['GRP_UID']) { + $group['GRP_UID'] = $groupBase['CON_ID']; + $mergedGroupList[] = $group; + $merged = true; + } + } + + if (! $merged) { + $mergedGroupList[] = $group; + } + } + + if (isset( $mergedGroupList )) { + return $mergedGroupList; + } else { + return null; + } + } + + /** + * function mergeExistingUsers + * mergeExistingGroups check if any of the groups listed in the parameter + * array exist and wich are those, then replaces the id of the elements in + * in the $mergedGroupList array. + * + * @author gustavo cruz gustavo-at-colosa.com + * @param $sBaseGroupList array of a group list with the original group list + * @param $sGroupList array of a group list with the merged group list + * @param $sTaskUserList array of the task user list, it contents the link between + * the task and the group list + * @return $mergedTaskUserList array of the merged task user list + */ + public function mergeExistingUsers ($sBaseGroupList, $sGroupList, $sTaskUserList) + { + foreach ($sTaskUserList as $taskuser) { + $merged = false; + foreach ($sBaseGroupList as $groupBase) { + foreach ($sGroupList as $group) { // check if the group has been merged - if ($groupBase['GRP_TITLE'] == $group['GRP_TITLE'] && $groupBase['GRP_UID'] != $group['GRP_UID'] && $groupBase['GRP_UID'] == $taskuser['USR_UID']) { + if ($groupBase['GRP_TITLE'] == $group['GRP_TITLE'] && $groupBase['GRP_UID'] != $group['GRP_UID'] && $groupBase['GRP_UID'] == $taskuser['USR_UID']) { // merging the user id to match the merged group - $taskuser['USR_UID'] = $group['GRP_UID']; - $mergedTaskUserList[] = $taskuser; - $merged = true; - } - } - } + $taskuser['USR_UID'] = $group['GRP_UID']; + $mergedTaskUserList[] = $taskuser; + $merged = true; + } + } + } //if hasn't been merged set the default value - if (! $merged) { - $mergedTaskUserList[] = $taskuser; - } - } - if (isset( $mergedTaskUserList )) { - return $mergedTaskUserList; - } else { - return null; - } - } - + if (! $merged) { + $mergedTaskUserList[] = $taskuser; + } + } + if (isset( $mergedTaskUserList )) { + return $mergedTaskUserList; + } else { + return null; + } + } + // end of import process related functions - - - /** - * disable all previous process with the parent $sProUid - * - * @param $sProUid process uid - * @return void - */ - function disablePreviousProcesses ($sProUid) - { + + + /** + * disable all previous process with the parent $sProUid + * + * @param $sProUid process uid + * @return void + */ + public function disablePreviousProcesses ($sProUid) + { //change status of process - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( ProcessPeer::PRO_PARENT, $sProUid ); - $oDataset = ProcessPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - $oProcess = new Process(); - while ($aRow = $oDataset->getRow()) { - $aRow['PRO_STATUS'] = 'DISABLED'; - $aRow['PRO_UPDATE_DATE'] = 'now'; - $oProcess->update( $aRow ); - $oDataset->next(); - } - - } - - /** - * create the files from a . - * pm file - * - * @param $oData process data - * @param $pmFilename process file name - * @return boolean true - */ - function createFiles ($oData, $pmFilename) - { - if (! file_exists( $pmFilename )) - throw (new Exception( 'Unable to read uploaded .pm file, please check permissions. ' )); - - if (! filesize( $pmFilename ) >= 9) - throw (new Exception( 'Uploaded .pm file is corrupted, please check the file before continue. ' )); - - $fp = fopen( $pmFilename, "rb" ); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( ProcessPeer::PRO_PARENT, $sProUid ); + $oDataset = ProcessPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $oProcess = new Process(); + while ($aRow = $oDataset->getRow()) { + $aRow['PRO_STATUS'] = 'DISABLED'; + $aRow['PRO_UPDATE_DATE'] = 'now'; + $oProcess->update( $aRow ); + $oDataset->next(); + } + } + + /** + * create the files from a . + * + * pm file + * + * @param $oData process data + * @param $pmFilename process file name + * @return boolean true + */ + public function createFiles ($oData, $pmFilename) + { + if (! file_exists( $pmFilename )) { + throw (new Exception( 'Unable to read uploaded .pm file, please check permissions. ' )); + } + if (! filesize( $pmFilename ) >= 9) { + throw (new Exception( 'Uploaded .pm file is corrupted, please check the file before continue. ' )); + } + $fp = fopen( $pmFilename, "rb" ); $fsData = intval( fread( $fp, 9 ) ); //reading the size of $oData $contents = fread( $fp, $fsData ); //reading string $oData - - - $path = PATH_DYNAFORM . $oData->process['PRO_UID'] . PATH_SEP; - if (! is_dir( $path )) { - G::verifyPath( $path, true ); - } - - $sIdentifier = 1; - while (! feof( $fp ) && is_numeric( $sIdentifier )) { + + $path = PATH_DYNAFORM . $oData->process['PRO_UID'] . PATH_SEP; + if (! is_dir( $path )) { + G::verifyPath( $path, true ); + } + + $sIdentifier = 1; + while (! feof( $fp ) && is_numeric( $sIdentifier )) { $sIdentifier = fread( $fp, 9 ); //reading the size of $filename - if (is_numeric( $sIdentifier )) { + if (is_numeric( $sIdentifier )) { $fsXmlGuid = intval( $sIdentifier ); //reading the size of $filename - if ($fsXmlGuid > 0) + if ($fsXmlGuid > 0) $XmlGuid = fread( $fp, $fsXmlGuid ); //reading string $XmlGuid $fsXmlContent = intval( fread( $fp, 9 ) ); //reading the size of $XmlContent - if ($fsXmlContent > 0) { - $newXmlGuid = $oData->dynaformFiles[$XmlGuid]; - if (isset( $oData->process['PRO_UID_OLD'] )) { + if ($fsXmlContent > 0) { + $newXmlGuid = $oData->dynaformFiles[$XmlGuid]; + if (isset( $oData->process['PRO_UID_OLD'] )) { $XmlContent = fread( $fp, $fsXmlContent ); //reading string $XmlContent - - - $XmlContent = str_replace( $oData->process['PRO_UID_OLD'], $oData->process['PRO_UID'], $XmlContent ); - $XmlContent = str_replace( $XmlGuid, $newXmlGuid, $XmlContent ); - + $XmlContent = str_replace( $oData->process['PRO_UID_OLD'], $oData->process['PRO_UID'], $XmlContent ); + $XmlContent = str_replace( $XmlGuid, $newXmlGuid, $XmlContent ); + //foreach - if (isset( $oData->gridFiles )) { - if (is_array( $oData->gridFiles )) { - foreach ($oData->gridFiles as $key => $value) { - $XmlContent = str_replace( $key, $value, $XmlContent ); - } - } - } - - if (isset( $oData->sqlConnections )) { - foreach ($oData->sqlConnections as $key => $value) { - $XmlContent = str_replace( $key, $value, $XmlContent ); - } - - } - + if (isset( $oData->gridFiles )) { + if (is_array( $oData->gridFiles )) { + foreach ($oData->gridFiles as $key => $value) { + $XmlContent = str_replace( $key, $value, $XmlContent ); + } + } + } + + if (isset( $oData->sqlConnections )) { + foreach ($oData->sqlConnections as $key => $value) { + $XmlContent = str_replace( $key, $value, $XmlContent ); + } + + } + #here we verify if is adynaform or a html - $aAux = explode( ' ', $XmlContent ); - $ext = (strpos( $aAux[0], 'process['PRO_UID'] . PATH_SEP; - $pathMailTem = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $oData->process['PRO_UID'] . PATH_SEP; - G::mk_dir( $pathPublic ); - G::mk_dir( $pathMailTem ); - - if ($sIdentifier == 'MAILTEMPL') { - $sIdentifier = 1; - while (! feof( $fp ) && is_numeric( $sIdentifier )) { + $pathPublic = PATH_DATA_SITE . 'public' . PATH_SEP . $oData->process['PRO_UID'] . PATH_SEP; + $pathMailTem = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $oData->process['PRO_UID'] . PATH_SEP; + G::mk_dir( $pathPublic ); + G::mk_dir( $pathMailTem ); + + if ($sIdentifier == 'MAILTEMPL') { + $sIdentifier = 1; + while (! feof( $fp ) && is_numeric( $sIdentifier )) { $sIdentifier = fread( $fp, 9 ); //reading the size of $filename - if (is_numeric( $sIdentifier )) { + if (is_numeric( $sIdentifier )) { $fsFileName = intval( $sIdentifier ); //reading the size of $filename - if ($fsFileName > 0) + if ($fsFileName > 0) { $sFileName = fread( $fp, $fsFileName ); //reading filename string + } $fsContent = function_exists( 'mb_strlen' ) ? mb_strlen( fread( $fp, 9 ) ) : strlen( fread( $fp, 9 ) ); //reading the size of $Content - if ($fsContent > 0) { + if ($fsContent > 0) { $fileContent = fread( $fp, $fsContent ); //reading string $XmlContent - $newFileName = $pathMailTem . $sFileName; - $bytesSaved = @file_put_contents( $newFileName, $fileContent ); - if ($bytesSaved != $fsContent) - throw (new Exception( 'Error writing MailTemplate file in directory : ' . $pathMailTem )); - } - } - } - } - - if (trim( $sIdentifier ) == 'PUBLIC') { - $sIdentifier = 1; - while (! feof( $fp ) && is_numeric( $sIdentifier )) { + $newFileName = $pathMailTem . $sFileName; + $bytesSaved = @file_put_contents( $newFileName, $fileContent ); + if ($bytesSaved != $fsContent) { + throw (new Exception( 'Error writing MailTemplate file in directory : ' . $pathMailTem )); + } + } + } + } + } + + if (trim( $sIdentifier ) == 'PUBLIC') { + $sIdentifier = 1; + while (! feof( $fp ) && is_numeric( $sIdentifier )) { $sIdentifier = fread( $fp, 9 ); //reading the size of $filename - if (is_numeric( $sIdentifier )) { + if (is_numeric( $sIdentifier )) { $fsFileName = intval( $sIdentifier ); //reading the size of $filename - if ($fsFileName > 0) + if ($fsFileName > 0) { $sFileName = fread( $fp, $fsFileName ); //reading filename string + } $fsContent = function_exists( 'mb_strlen' ) ? mb_strlen( fread( $fp, 9 ) ) : strlen( fread( $fp, 9 ) ); //reading the size of $Content - if ($fsContent > 0) { + if ($fsContent > 0) { $fileContent = fread( $fp, $fsContent ); //reading string $XmlContent - $newFileName = $pathPublic . $sFileName; - $bytesSaved = @file_put_contents( $newFileName, $fileContent ); - if ($bytesSaved != $fsContent) - throw (new Exception( 'Error writing Public file in directory : ' . $pathPublic )); - } - } - } - } - - fclose( $fp ); - - return true; - - } - - /** - * this function remove all Process except the PROCESS ROW - * - * @param string $sProUid - * @return boolean - */ - function removeProcessRows ($sProUid) - { - try { + $newFileName = $pathPublic . $sFileName; + $bytesSaved = @file_put_contents( $newFileName, $fileContent ); + if ($bytesSaved != $fsContent) { + throw (new Exception( 'Error writing Public file in directory : ' . $pathPublic )); + } + } + } + } + } + + fclose( $fp ); + + return true; + + } + + /** + * this function remove all Process except the PROCESS ROW + * + * @param string $sProUid + * @return boolean + */ + public function removeProcessRows ($sProUid) + { + try { //Instance all classes necesaries - $oProcess = new Process(); - $oDynaform = new Dynaform(); - $oInputDocument = new InputDocument(); - $oOutputDocument = new OutputDocument(); - $oTrigger = new Triggers(); - $oStepTrigger = new StepTrigger(); - $oRoute = new Route(); - $oStep = new Step(); - $oSubProcess = new SubProcess(); - $oCaseTracker = new CaseTracker(); - $oCaseTrackerObject = new CaseTrackerObject(); - $oObjectPermission = new ObjectPermission(); - $oSwimlaneElement = new SwimlanesElements(); - $oConnection = new DbSource(); - $oStage = new Stage(); - $oEvent = new Event(); - $oCaseScheduler = new CaseScheduler(); - + $oProcess = new Process(); + $oDynaform = new Dynaform(); + $oInputDocument = new InputDocument(); + $oOutputDocument = new OutputDocument(); + $oTrigger = new Triggers(); + $oStepTrigger = new StepTrigger(); + $oRoute = new Route(); + $oStep = new Step(); + $oSubProcess = new SubProcess(); + $oCaseTracker = new CaseTracker(); + $oCaseTrackerObject = new CaseTrackerObject(); + $oObjectPermission = new ObjectPermission(); + $oSwimlaneElement = new SwimlanesElements(); + $oConnection = new DbSource(); + $oStage = new Stage(); + $oEvent = new Event(); + $oCaseScheduler = new CaseScheduler(); + //Delete the tasks of process - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( TaskPeer::PRO_UID, $sProUid ); - $oDataset = TaskPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - $oTask = new Task(); - while ($aRow = $oDataset->getRow()) { - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( StepTriggerPeer::TAS_UID, $aRow['TAS_UID'] ); - StepTriggerPeer::doDelete( $oCriteria ); - if ($oTask->taskExists( $aRow['TAS_UID'] )) - $oTask->remove( $aRow['TAS_UID'] ); - $oDataset->next(); - } - + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( TaskPeer::PRO_UID, $sProUid ); + $oDataset = TaskPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $oTask = new Task(); + while ($aRow = $oDataset->getRow()) { + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( StepTriggerPeer::TAS_UID, $aRow['TAS_UID'] ); + StepTriggerPeer::doDelete( $oCriteria ); + if ($oTask->taskExists( $aRow['TAS_UID'] )) { + $oTask->remove( $aRow['TAS_UID'] ); + } + $oDataset->next(); + } + //Delete the dynaforms of process - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( DynaformPeer::PRO_UID, $sProUid ); - $oDataset = DynaformPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $sWildcard = PATH_DYNAFORM . $aRow['PRO_UID'] . PATH_SEP . $aRow['DYN_UID'] . '_tmp*'; - foreach (glob( $sWildcard ) as $fn) { - @unlink( $fn ); - } - $sWildcard = PATH_DYNAFORM . $aRow['PRO_UID'] . PATH_SEP . $aRow['DYN_UID'] . '.*'; - foreach (glob( $sWildcard ) as $fn) { - @unlink( $fn ); - } - if ($oDynaform->dynaformExists( $aRow['DYN_UID'] )) - $oDynaform->remove( $aRow['DYN_UID'] ); - $oDataset->next(); - } - + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( DynaformPeer::PRO_UID, $sProUid ); + $oDataset = DynaformPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $sWildcard = PATH_DYNAFORM . $aRow['PRO_UID'] . PATH_SEP . $aRow['DYN_UID'] . '_tmp*'; + foreach (glob( $sWildcard ) as $fn) { + @unlink( $fn ); + } + $sWildcard = PATH_DYNAFORM . $aRow['PRO_UID'] . PATH_SEP . $aRow['DYN_UID'] . '.*'; + foreach (glob( $sWildcard ) as $fn) { + @unlink( $fn ); + } + if ($oDynaform->dynaformExists( $aRow['DYN_UID'] )) { + $oDynaform->remove( $aRow['DYN_UID'] ); + } + $oDataset->next(); + } + //Delete the input documents of process - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( InputDocumentPeer::PRO_UID, $sProUid ); - $oDataset = InputDocumentPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - if ($oInputDocument->InputExists( $aRow['INP_DOC_UID'] )) - $oInputDocument->remove( $aRow['INP_DOC_UID'] ); - $oDataset->next(); - } - + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( InputDocumentPeer::PRO_UID, $sProUid ); + $oDataset = InputDocumentPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + if ($oInputDocument->InputExists( $aRow['INP_DOC_UID'] )) { + $oInputDocument->remove( $aRow['INP_DOC_UID'] ); + } + $oDataset->next(); + } + //Delete the output documents of process - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( OutputDocumentPeer::PRO_UID, $sProUid ); - $oDataset = OutputDocumentPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - if ($oOutputDocument->OutputExists( $aRow['OUT_DOC_UID'] )) - $oOutputDocument->remove( $aRow['OUT_DOC_UID'] ); - $oDataset->next(); - } - + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( OutputDocumentPeer::PRO_UID, $sProUid ); + $oDataset = OutputDocumentPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + if ($oOutputDocument->OutputExists( $aRow['OUT_DOC_UID'] )) { + $oOutputDocument->remove( $aRow['OUT_DOC_UID'] ); + } + $oDataset->next(); + } + //Delete the steps - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( StepPeer::PRO_UID, $sProUid ); - $oDataset = StepPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - //Delete the steptrigger of process - /*$oCriteria = new Criteria('workflow'); - $oCriteria->add(StepTriggerPeer::STEP_UID, $aRow['STEP_UID']); - $oDataseti = StepTriggerPeer::doSelectRS($oCriteria); - $oDataseti->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataseti->next(); - while ($aRowi = $oDataseti->getRow()) { - if ($oStepTrigger->stepTriggerExists($aRowi['STEP_UID'], $aRowi['TAS_UID'], $aRowi['TRI_UID'], $aRowi['ST_TYPE'])) - $oStepTrigger->remove($aRowi['STEP_UID'], $aRowi['TAS_UID'], $aRowi['TRI_UID'], $aRowi['ST_TYPE']); - $oDataseti->next(); - }*/ - $oStep->remove( $aRow['STEP_UID'] ); - $oDataset->next(); - } - + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( StepPeer::PRO_UID, $sProUid ); + $oDataset = StepPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + //Delete the steptrigger of process + /*$oCriteria = new Criteria('workflow'); + $oCriteria->add(StepTriggerPeer::STEP_UID, $aRow['STEP_UID']); + $oDataseti = StepTriggerPeer::doSelectRS($oCriteria); + $oDataseti->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $oDataseti->next(); + while ($aRowi = $oDataseti->getRow()) { + if ($oStepTrigger->stepTriggerExists($aRowi['STEP_UID'], $aRowi['TAS_UID'], $aRowi['TRI_UID'], $aRowi['ST_TYPE'])) + $oStepTrigger->remove($aRowi['STEP_UID'], $aRowi['TAS_UID'], $aRowi['TRI_UID'], $aRowi['ST_TYPE']); + $oDataseti->next(); + }*/ + $oStep->remove( $aRow['STEP_UID'] ); + $oDataset->next(); + } + //Delete the StepSupervisor - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( StepSupervisorPeer::PRO_UID, $sProUid ); - $oDataset = StepSupervisorPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - if ($oStep->StepExists( $aRow['STEP_UID'] )) - $oStep->remove( $aRow['STEP_UID'] ); - $oDataset->next(); - } - + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( StepSupervisorPeer::PRO_UID, $sProUid ); + $oDataset = StepSupervisorPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + if ($oStep->StepExists( $aRow['STEP_UID'] )) { + $oStep->remove( $aRow['STEP_UID'] ); + } + $oDataset->next(); + } + //Delete the triggers of process - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( TriggersPeer::PRO_UID, $sProUid ); - $oDataset = TriggersPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - if ($oTrigger->TriggerExists( $aRow['TRI_UID'] )) - $oTrigger->remove( $aRow['TRI_UID'] ); - $oDataset->next(); - } - - //Delete the routes of process - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( RoutePeer::PRO_UID, $sProUid ); - $oDataset = RoutePeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - if ($oRoute->routeExists( $aRow['ROU_UID'] )) - $oRoute->remove( $aRow['ROU_UID'] ); - $oDataset->next(); - } - + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( TriggersPeer::PRO_UID, $sProUid ); + $oDataset = TriggersPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + if ($oTrigger->TriggerExists( $aRow['TRI_UID'] )) { + $oTrigger->remove( $aRow['TRI_UID'] ); + } + $oDataset->next(); + } + //Delete the routes of process + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( RoutePeer::PRO_UID, $sProUid ); + $oDataset = RoutePeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + if ($oRoute->routeExists( $aRow['ROU_UID'] )) { + $oRoute->remove( $aRow['ROU_UID'] ); + } + $oDataset->next(); + } //Delete the swimlanes elements of process - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( SwimlanesElementsPeer::PRO_UID, $sProUid ); - $oDataset = SwimlanesElementsPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - if ($oSwimlaneElement->swimlanesElementsExists( $aRow['SWI_UID'] )) - $oSwimlaneElement->remove( $aRow['SWI_UID'] ); - $oDataset->next(); - } - + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( SwimlanesElementsPeer::PRO_UID, $sProUid ); + $oDataset = SwimlanesElementsPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + if ($oSwimlaneElement->swimlanesElementsExists( $aRow['SWI_UID'] )) { + $oSwimlaneElement->remove( $aRow['SWI_UID'] ); + } + $oDataset->next(); + } + //Delete the DB connections of process - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( DbSourcePeer::PRO_UID, $sProUid ); - $oDataset = DbSourcePeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - if ($oConnection->Exists( $aRow['DBS_UID'], $aRow['PRO_UID'] )) - $oConnection->remove( $aRow['DBS_UID'], $aRow['PRO_UID'] ); - $oDataset->next(); - } - + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( DbSourcePeer::PRO_UID, $sProUid ); + $oDataset = DbSourcePeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + if ($oConnection->Exists( $aRow['DBS_UID'], $aRow['PRO_UID'] )) { + $oConnection->remove( $aRow['DBS_UID'], $aRow['PRO_UID'] ); + } + $oDataset->next(); + } + //Delete the sub process of process - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( SubProcessPeer::PRO_PARENT, $sProUid ); - $oDataset = SubProcessPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - if ($oSubProcess->subProcessExists( $aRow['SP_UID'] )) - $oSubProcess->remove( $aRow['SP_UID'] ); - $oDataset->next(); - } - + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( SubProcessPeer::PRO_PARENT, $sProUid ); + $oDataset = SubProcessPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + if ($oSubProcess->subProcessExists( $aRow['SP_UID'] )) { + $oSubProcess->remove( $aRow['SP_UID'] ); + } + $oDataset->next(); + } + //Delete the caseTracker of process - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( CaseTrackerPeer::PRO_UID, $sProUid ); - $oDataset = CaseTrackerPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - if ($oCaseTracker->caseTrackerExists( $aRow['PRO_UID'] )) - $oCaseTracker->remove( $aRow['PRO_UID'] ); - $oDataset->next(); - } - + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( CaseTrackerPeer::PRO_UID, $sProUid ); + $oDataset = CaseTrackerPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + if ($oCaseTracker->caseTrackerExists( $aRow['PRO_UID'] )) { + $oCaseTracker->remove( $aRow['PRO_UID'] ); + } + $oDataset->next(); + } + //Delete the caseTrackerObject of process - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( CaseTrackerObjectPeer::PRO_UID, $sProUid ); - $oDataset = CaseTrackerObjectPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - if ($oCaseTrackerObject->caseTrackerObjectExists( $aRow['CTO_UID'] )) { - $oCaseTrackerObject->remove( $aRow['CTO_UID'] ); - } - $oDataset->next(); - } - + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( CaseTrackerObjectPeer::PRO_UID, $sProUid ); + $oDataset = CaseTrackerObjectPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + if ($oCaseTrackerObject->caseTrackerObjectExists( $aRow['CTO_UID'] )) { + $oCaseTrackerObject->remove( $aRow['CTO_UID'] ); + } + $oDataset->next(); + } + //Delete the ObjectPermission of process - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( ObjectPermissionPeer::PRO_UID, $sProUid ); - $oDataset = ObjectPermissionPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - if ($oObjectPermission->Exists( $aRow['OP_UID'] )) { - $oObjectPermission->remove( $aRow['OP_UID'] ); - } - $oDataset->next(); - } - + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( ObjectPermissionPeer::PRO_UID, $sProUid ); + $oDataset = ObjectPermissionPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + if ($oObjectPermission->Exists( $aRow['OP_UID'] )) { + $oObjectPermission->remove( $aRow['OP_UID'] ); + } + $oDataset->next(); + } + //Delete the Stage of process - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( StagePeer::PRO_UID, $sProUid ); - $oDataset = StagePeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - if ($oStage->Exists( $aRow['STG_UID'] )) - $oStage->remove( $aRow['STG_UID'] ); - $oDataset->next(); - } - + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( StagePeer::PRO_UID, $sProUid ); + $oDataset = StagePeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + if ($oStage->Exists( $aRow['STG_UID'] )) { + $oStage->remove( $aRow['STG_UID'] ); + } + $oDataset->next(); + } + //Delete the Event of process - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( EventPeer::PRO_UID, $sProUid ); - $oDataset = EventPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - if ($oEvent->Exists( $aRow['EVN_UID'] )) - $oEvent->remove( $aRow['EVN_UID'] ); - $oDataset->next(); - if ($oEvent->existsByTaskUidFrom( $aRow['TAS_UID'] )) { - $aRowEvent = $oEvent->getRowByTaskUidFrom( $aRow['TAS_UID'] ); - $oEvent->remove( $aRowEvent['EVN_UID'] ); - } - $oDataset->next(); - } - + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( EventPeer::PRO_UID, $sProUid ); + $oDataset = EventPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + if ($oEvent->Exists( $aRow['EVN_UID'] )) { + $oEvent->remove( $aRow['EVN_UID'] ); + } + $oDataset->next(); + if ($oEvent->existsByTaskUidFrom( $aRow['TAS_UID'] )) { + $aRowEvent = $oEvent->getRowByTaskUidFrom( $aRow['TAS_UID'] ); + $oEvent->remove( $aRowEvent['EVN_UID'] ); + } + $oDataset->next(); + } + //Delete the CaseScheduler of process - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( CaseSchedulerPeer::PRO_UID, $sProUid ); - $oDataset = CaseSchedulerPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - if ($oCaseScheduler->Exists( $aRow['SCH_UID'] )) - $oCaseScheduler->remove( $aRow['SCH_UID'] ); - $oDataset->next(); - } - - return true; - } catch (Exception $oError) { - throw ($oError); - } - } - - /** - * this function creates a new Process, defined in the object $oData - * - * @param string $sProUid - * @return boolean - */ - function createProcessFromData ($oData, $pmFilename) - { - $this->removeProcessRows( $oData->process['PRO_UID'] ); - + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( CaseSchedulerPeer::PRO_UID, $sProUid ); + $oDataset = CaseSchedulerPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + if ($oCaseScheduler->Exists( $aRow['SCH_UID'] )) { + $oCaseScheduler->remove( $aRow['SCH_UID'] ); + } + $oDataset->next(); + } + + return true; + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * this function creates a new Process, defined in the object $oData + * + * @param string $sProUid + * @return boolean + */ + public function createProcessFromData ($oData, $pmFilename) + { + $this->removeProcessRows( $oData->process['PRO_UID'] ); + // (*) Creating process dependencies // creating the process category - $this->createProcessCategoryRow( isset( $oData->processCategory ) ? $oData->processCategory : null ); - + $this->createProcessCategoryRow( isset( $oData->processCategory ) ? $oData->processCategory : null ); + // create the process - $this->createProcessRow( $oData->process ); - - $this->createTaskRows( $oData->tasks ); + $this->createProcessRow( $oData->process ); + $this->createTaskRows( $oData->tasks ); //it was commented becuase it seems to be working fine //$this->createEventRows(isset($oData->event) ? $oData->event : array()); - - - $aRoutesUID = $this->createRouteRows( $oData->routes ); - $this->createLaneRows( $oData->lanes ); - + + $aRoutesUID = $this->createRouteRows( $oData->routes ); + $this->createLaneRows( $oData->lanes ); + /*if(!isset($oData->gateways)){ //Adding gateway information while importing processes from older version //Making compatible with old export process @@ -3481,447 +3493,435 @@ class Processes } } } - else*/ - - if (isset( $oData->gateways )) - $this->createGatewayRows( $oData->gateways ); - - $this->createDynaformRows( $oData->dynaforms ); - $this->createInputRows( $oData->inputs ); - $this->createOutputRows( $oData->outputs ); - $this->createStepRows( $oData->steps ); - $this->createStepSupervisorRows( isset( $oData->stepSupervisor ) ? $oData->stepSupervisor : array () ); - $this->createTriggerRows( $oData->triggers ); - $this->createStepTriggerRows( $oData->steptriggers ); - $this->createTaskUserRows( $oData->taskusers ); - $this->createGroupRow( $oData->groupwfs ); - $this->createDBConnectionsRows( isset( $oData->dbconnections ) ? $oData->dbconnections : array () ); - $this->createReportTables( isset( $oData->reportTables ) ? $oData->reportTables : array (), isset( $oData->reportTablesVars ) ? $oData->reportTablesVars : array () ); - $this->createSubProcessRows( isset( $oData->subProcess ) ? $oData->subProcess : array () ); - $this->createCaseTrackerRows( isset( $oData->caseTracker ) ? $oData->caseTracker : array () ); - $this->createCaseTrackerObjectRows( isset( $oData->caseTrackerObject ) ? $oData->caseTrackerObject : array () ); - $this->createObjectPermissionsRows( isset( $oData->objectPermissions ) ? $oData->objectPermissions : array () ); - $this->createStageRows( isset( $oData->stage ) ? $oData->stage : array () ); - - $this->createFieldCondition( isset( $oData->fieldCondition ) ? $oData->fieldCondition : array (), $oData->dynaforms ); - + else*/ + + if (isset( $oData->gateways )) { + $this->createGatewayRows( $oData->gateways ); + } + $this->createDynaformRows( $oData->dynaforms ); + $this->createInputRows( $oData->inputs ); + $this->createOutputRows( $oData->outputs ); + $this->createStepRows( $oData->steps ); + $this->createStepSupervisorRows( isset( $oData->stepSupervisor ) ? $oData->stepSupervisor : array () ); + $this->createTriggerRows( $oData->triggers ); + $this->createStepTriggerRows( $oData->steptriggers ); + $this->createTaskUserRows( $oData->taskusers ); + $this->createGroupRow( $oData->groupwfs ); + $this->createDBConnectionsRows( isset( $oData->dbconnections ) ? $oData->dbconnections : array () ); + $this->createReportTables( isset( $oData->reportTables ) ? $oData->reportTables : array (), isset( $oData->reportTablesVars ) ? $oData->reportTablesVars : array () ); + $this->createSubProcessRows( isset( $oData->subProcess ) ? $oData->subProcess : array () ); + $this->createCaseTrackerRows( isset( $oData->caseTracker ) ? $oData->caseTracker : array () ); + $this->createCaseTrackerObjectRows( isset( $oData->caseTrackerObject ) ? $oData->caseTrackerObject : array () ); + $this->createObjectPermissionsRows( isset( $oData->objectPermissions ) ? $oData->objectPermissions : array () ); + $this->createStageRows( isset( $oData->stage ) ? $oData->stage : array () ); + + $this->createFieldCondition( isset( $oData->fieldCondition ) ? $oData->fieldCondition : array (), $oData->dynaforms ); + // Create before to createRouteRows for avoid duplicates - $this->createEventRows( isset( $oData->event ) ? $oData->event : array () ); - - $this->createCaseSchedulerRows( isset( $oData->caseScheduler ) ? $oData->caseScheduler : array () ); - + $this->createEventRows( isset( $oData->event ) ? $oData->event : array () ); + + $this->createCaseSchedulerRows( isset( $oData->caseScheduler ) ? $oData->caseScheduler : array () ); + // and finally create the files, dynaforms (xml and html), emailTemplates and Public files - $this->createFiles( $oData, $pmFilename ); - } - - /** - * this function creates a new Process, defined in the object $oData - * - * @param string $sProUid - * @return boolean - */ - function updateProcessFromData ($oData, $pmFilename) - { - $this->updateProcessRow( $oData->process ); - $this->removeProcessRows( $oData->process['PRO_UID'] ); - $this->createTaskRows( $oData->tasks ); - $this->createRouteRows( $oData->routes ); - $this->createLaneRows( $oData->lanes ); - $this->createDynaformRows( $oData->dynaforms ); - $this->createInputRows( $oData->inputs ); - $this->createOutputRows( $oData->outputs ); - $this->createStepRows( $oData->steps ); - $this->createStepSupervisorRows( $oData->stepSupervisor ); - $this->createTriggerRows( $oData->triggers ); - $this->createStepTriggerRows( $oData->steptriggers ); - $this->createTaskUserRows( $oData->taskusers ); - $this->createGroupRow( $oData->groupwfs ); - $this->createDBConnectionsRows( $oData->dbconnections ); - $this->updateReportTables( $oData->reportTables, $oData->reportTablesVars ); - $this->createFiles( $oData, $pmFilename ); - $this->createSubProcessRows( $oData->subProcess ); - $this->createCaseTrackerRows( $oData->caseTracker ); - $this->createCaseTrackerObjectRows( $oData->caseTrackerObject ); - $this->createObjectPermissionsRows( $oData->objectPermissions ); - $this->createStageRows( $oData->stage ); - $this->createFieldCondition( $oData->fieldCondition, $oData->dynaforms ); - $this->createEventRows( $oData->event ); - $this->createCaseSchedulerRows( $oData->caseScheduler ); - $this->createProcessCategoryRow( isset( $oData->processCategory ) ? $oData->processCategory : null ); - - } - - /** - * get the starting task for a user but from a Tasks object - * - * @param $sProUid process uid - * @param $sUserUid user uid - * @return an array of tasks - */ - function getStartingTaskForUser ($sProUid, $sUsrUid) - { - $oTask = new Tasks(); - - return $oTask->getStartingTaskForUser( $sProUid, $sUsrUid ); - } - - /** - * *********************************************** - * functions to enable open ProcessMaker Library - * *********************************************** - */ - /** - * Open a WebService connection - * - * @param $user username for pm - * @param $pass password for the user - * @return 1 integer. - */ - function ws_open ($user, $pass) - { - global $sessionId; - global $client; - $endpoint = PML_WSDL_URL; - $sessionId = ''; - $proxy = array (); - $sysConf = System::getSystemConfiguration(); - if ($sysConf['proxy_host'] != '') { - $proxy['proxy_host'] = $sysConf['proxy_host']; - if ($sysConf['proxy_port'] != '') { - $proxy['proxy_port'] = $sysConf['proxy_port']; - } - if ($sysConf['proxy_user'] != '') { - $proxy['proxy_login'] = $sysConf['proxy_user']; - } - if ($sysConf['proxy_pass'] != '') { - $proxy['proxy_password'] = $sysConf['proxy_pass']; - } - } - $client = new SoapClient( $endpoint, $proxy ); - - $params = array ('userid' => $user,'password' => $pass - ); - $result = $client->__SoapCall( 'login', array ($params - ) ); - if ($result->status_code == 0) { - $sessionId = $result->message; - return 1; - } - throw (new Exception( $result->message )); - return 1; - } - - /** - * Open a WebService public connection - * - * @param $user username for pm - * @param $pass password for the user - * @return 1 integer. - */ - function ws_open_public () - { - - global $sessionId; - global $client; - $endpoint = PML_WSDL_URL; - $sessionId = ''; + $this->createFiles( $oData, $pmFilename ); + } + + /** + * this function creates a new Process, defined in the object $oData + * + * @param string $sProUid + * @return boolean + */ + public function updateProcessFromData ($oData, $pmFilename) + { + $this->updateProcessRow( $oData->process ); + $this->removeProcessRows( $oData->process['PRO_UID'] ); + $this->createTaskRows( $oData->tasks ); + $this->createRouteRows( $oData->routes ); + $this->createLaneRows( $oData->lanes ); + $this->createDynaformRows( $oData->dynaforms ); + $this->createInputRows( $oData->inputs ); + $this->createOutputRows( $oData->outputs ); + $this->createStepRows( $oData->steps ); + $this->createStepSupervisorRows( $oData->stepSupervisor ); + $this->createTriggerRows( $oData->triggers ); + $this->createStepTriggerRows( $oData->steptriggers ); + $this->createTaskUserRows( $oData->taskusers ); + $this->createGroupRow( $oData->groupwfs ); + $this->createDBConnectionsRows( $oData->dbconnections ); + $this->updateReportTables( $oData->reportTables, $oData->reportTablesVars ); + $this->createFiles( $oData, $pmFilename ); + $this->createSubProcessRows( $oData->subProcess ); + $this->createCaseTrackerRows( $oData->caseTracker ); + $this->createCaseTrackerObjectRows( $oData->caseTrackerObject ); + $this->createObjectPermissionsRows( $oData->objectPermissions ); + $this->createStageRows( $oData->stage ); + $this->createFieldCondition( $oData->fieldCondition, $oData->dynaforms ); + $this->createEventRows( $oData->event ); + $this->createCaseSchedulerRows( $oData->caseScheduler ); + $this->createProcessCategoryRow( isset( $oData->processCategory ) ? $oData->processCategory : null ); + } + + /** + * get the starting task for a user but from a Tasks object + * + * @param $sProUid process uid + * @param $sUserUid user uid + * @return an array of tasks + */ + public function getStartingTaskForUser ($sProUid, $sUsrUid) + { + $oTask = new Tasks(); + return $oTask->getStartingTaskForUser( $sProUid, $sUsrUid ); + } + + /** + * *********************************************** + * functions to enable open ProcessMaker Library + * *********************************************** + */ + /** + * Open a WebService connection + * + * @param $user username for pm + * @param $pass password for the user + * @return 1 integer. + */ + public function ws_open ($user, $pass) + { + global $sessionId; + global $client; + $endpoint = PML_WSDL_URL; + $sessionId = ''; + $proxy = array (); + $sysConf = System::getSystemConfiguration(); + if ($sysConf['proxy_host'] != '') { + $proxy['proxy_host'] = $sysConf['proxy_host']; + if ($sysConf['proxy_port'] != '') { + $proxy['proxy_port'] = $sysConf['proxy_port']; + } + if ($sysConf['proxy_user'] != '') { + $proxy['proxy_login'] = $sysConf['proxy_user']; + } + if ($sysConf['proxy_pass'] != '') { + $proxy['proxy_password'] = $sysConf['proxy_pass']; + } + } + $client = new SoapClient( $endpoint, $proxy ); + $params = array ('userid' => $user,'password' => $pass); + $result = $client->__SoapCall( 'login', array ($params) ); + if ($result->status_code == 0) { + $sessionId = $result->message; + return 1; + } + throw (new Exception( $result->message )); + return 1; + } + + /** + * Open a WebService public connection + * + * @param $user username for pm + * @param $pass password for the user + * @return 1 integer. + */ + public function ws_open_public () + { + global $sessionId; + global $client; + $endpoint = PML_WSDL_URL; + $sessionId = ''; ini_set( "soap.wsdl_cache_enabled", "0" ); // enabling WSDL cache - try { - $proxy = array (); - $sysConf = System::getSystemConfiguration(); - if ($sysConf['proxy_host'] != '') { - $proxy['proxy_host'] = $sysConf['proxy_host']; - if ($sysConf['proxy_port'] != '') { - $proxy['proxy_port'] = $sysConf['proxy_port']; - } - if ($sysConf['proxy_user'] != '') { - $proxy['proxy_login'] = $sysConf['proxy_user']; - } - if ($sysConf['proxy_pass'] != '') { - $proxy['proxy_password'] = $sysConf['proxy_pass']; - } - } - $client = @new SoapClient( $endpoint, $proxy ); - } catch (Exception $e) { - throw (new Exception( $e->getMessage() )); - } - - return 1; - } - - /** - * Consume the processList WebService - * - * @return $result process list. - */ - function ws_processList () - { - global $sessionId; - global $client; - - $endpoint = PML_WSDL_URL; - $proxy = array (); - $sysConf = System::getSystemConfiguration(); - if ($sysConf['proxy_host'] != '') { - $proxy['proxy_host'] = $sysConf['proxy_host']; - if ($sysConf['proxy_port'] != '') { - $proxy['proxy_port'] = $sysConf['proxy_port']; - } - if ($sysConf['proxy_user'] != '') { - $proxy['proxy_login'] = $sysConf['proxy_user']; - } - if ($sysConf['proxy_pass'] != '') { - $proxy['proxy_password'] = $sysConf['proxy_pass']; - } - } - $client = new SoapClient( $endpoint, $proxy ); - - $sessionId = ''; - $params = array ('sessionId' => $sessionId - ); - $result = $client->__SoapCall( 'processList', array ($params - ) ); - if ($result->status_code == 0) { - return $result; - } - throw (new Exception( $result->message )); - } - - /** - * download a File - * - * @param $file file to download - * @param $local_path path of the file - * @param $newfilename - * @return $errorMsg process list. - */ - function downloadFile ($file, $local_path, $newfilename) - { - $err_msg = ''; - $out = fopen( $local_path . $newfilename, 'wb' ); - if ($out == FALSE) { - throw (new Exception( "File $newfilename not opened" )); - } - - if (! function_exists( 'curl_init' )) { - G::SendTemporalMessage( 'ID_CURLFUN_ISUNDEFINED', "warning", 'LABEL', '', '100%', '' ); - G::header( 'location: ../processes/processes_Library' ); - die(); - } - $ch = curl_init(); - - curl_setopt( $ch, CURLOPT_FILE, $out ); - curl_setopt( $ch, CURLOPT_HEADER, 0 ); - curl_setopt( $ch, CURLOPT_URL, $file ); - - curl_exec( $ch ); - $errorMsg = curl_error( $ch ); - fclose( $out ); - - curl_close( $ch ); - return $errorMsg; - + try { + $proxy = array (); + $sysConf = System::getSystemConfiguration(); + if ($sysConf['proxy_host'] != '') { + $proxy['proxy_host'] = $sysConf['proxy_host']; + if ($sysConf['proxy_port'] != '') { + $proxy['proxy_port'] = $sysConf['proxy_port']; + } + if ($sysConf['proxy_user'] != '') { + $proxy['proxy_login'] = $sysConf['proxy_user']; + } + if ($sysConf['proxy_pass'] != '') { + $proxy['proxy_password'] = $sysConf['proxy_pass']; + } + } + $client = @new SoapClient( $endpoint, $proxy ); + } catch (Exception $e) { + throw (new Exception( $e->getMessage() )); + } + return 1; + } + + /** + * Consume the processList WebService + * + * @return $result process list. + */ + public function ws_processList () + { + global $sessionId; + global $client; + + $endpoint = PML_WSDL_URL; + $proxy = array (); + $sysConf = System::getSystemConfiguration(); + + if ($sysConf['proxy_host'] != '') { + $proxy['proxy_host'] = $sysConf['proxy_host']; + if ($sysConf['proxy_port'] != '') { + $proxy['proxy_port'] = $sysConf['proxy_port']; + } + if ($sysConf['proxy_user'] != '') { + $proxy['proxy_login'] = $sysConf['proxy_user']; + } + if ($sysConf['proxy_pass'] != '') { + $proxy['proxy_password'] = $sysConf['proxy_pass']; + } + } + + $client = new SoapClient( $endpoint, $proxy ); + $sessionId = ''; + $params = array ('sessionId' => $sessionId); + $result = $client->__SoapCall( 'processList', array ($params) ); + if ($result->status_code == 0) { + return $result; + } + throw (new Exception( $result->message )); + } + + /** + * download a File + * + * @param $file file to download + * @param $local_path path of the file + * @param $newfilename + * @return $errorMsg process list. + */ + public function downloadFile ($file, $local_path, $newfilename) + { + $err_msg = ''; + $out = fopen( $local_path . $newfilename, 'wb' ); + if ($out == false) { + throw (new Exception( "File $newfilename not opened" )); + } + + if (! function_exists( 'curl_init' )) { + G::SendTemporalMessage( 'ID_CURLFUN_ISUNDEFINED', "warning", 'LABEL', '', '100%', '' ); + G::header( 'location: ../processes/processes_Library' ); + die(); + } + $ch = curl_init(); + + curl_setopt( $ch, CURLOPT_FILE, $out ); + curl_setopt( $ch, CURLOPT_HEADER, 0 ); + curl_setopt( $ch, CURLOPT_URL, $file ); + + curl_exec( $ch ); + $errorMsg = curl_error( $ch ); + fclose( $out ); + + curl_close( $ch ); + return $errorMsg; + } //end function - - - /** - * get the process Data from a process - * - * @param $proId process Uid - * @return $result - */ - function ws_processGetData ($proId) - { - global $sessionId; - global $client; - - $endpoint = PML_WSDL_URL; - $proxy = array (); - $sysConf = System::getSystemConfiguration(); - if ($sysConf['proxy_host'] != '') { - $proxy['proxy_host'] = $sysConf['proxy_host']; - if ($sysConf['proxy_port'] != '') { - $proxy['proxy_port'] = $sysConf['proxy_port']; - } - if ($sysConf['proxy_user'] != '') { - $proxy['proxy_login'] = $sysConf['proxy_user']; - } - if ($sysConf['proxy_pass'] != '') { - $proxy['proxy_password'] = $sysConf['proxy_pass']; - } - } - $client = new SoapClient( $endpoint, $proxy ); - - $sessionId = ''; - $params = array ('sessionId' => $sessionId,'processId' => $proId - ); - $result = $client->__SoapCall( 'processGetData', array ($params - ) ); - if ($result->status_code == 0) { - return $result; - } - throw (new Exception( $result->message )); - } - - /** - * parse an array of Items - * - * @param $proId process Uid - * @return $result - */ - function parseItemArray ($array) - { - if (! isset( $array->item ) && ! is_array( $array )) { - return null; - } - - $result = array (); - if (isset( $array->item )) { - foreach ($array->item as $key => $value) { - $result[$value->key] = $value->value; - } - } else { - foreach ($array as $key => $value) { - $result[$value->key] = $value->value; - } - } - return $result; - } - - public function getProcessFiles ($proUid, $type) - { - $filesList = array (); - - switch ($type) { - case "mail": - case "email": - $basePath = PATH_DATA_MAILTEMPLATES; - break; - case "public": - $basePath = PATH_DATA_PUBLIC; - break; - default: - throw new Exception( "Unknow Process Files Type \"$type\"." ); - break; - } - - $dir = $basePath . $proUid . PATH_SEP; - + + + /** + * get the process Data from a process + * + * @param $proId process Uid + * @return $result + */ + public function ws_processGetData ($proId) + { + global $sessionId; + global $client; + + $endpoint = PML_WSDL_URL; + $proxy = array (); + $sysConf = System::getSystemConfiguration(); + if ($sysConf['proxy_host'] != '') { + $proxy['proxy_host'] = $sysConf['proxy_host']; + if ($sysConf['proxy_port'] != '') { + $proxy['proxy_port'] = $sysConf['proxy_port']; + } + if ($sysConf['proxy_user'] != '') { + $proxy['proxy_login'] = $sysConf['proxy_user']; + } + if ($sysConf['proxy_pass'] != '') { + $proxy['proxy_password'] = $sysConf['proxy_pass']; + } + } + $client = new SoapClient( $endpoint, $proxy ); + + $sessionId = ''; + $params = array ('sessionId' => $sessionId,'processId' => $proId); + $result = $client->__SoapCall( 'processGetData', array ($params) ); + if ($result->status_code == 0) { + return $result; + } + throw (new Exception( $result->message )); + } + + /** + * parse an array of Items + * + * @param $proId process Uid + * @return $result + */ + public function parseItemArray ($array) + { + if (! isset( $array->item ) && ! is_array( $array )) { + return null; + } + + $result = array (); + if (isset( $array->item )) { + foreach ($array->item as $key => $value) { + $result[$value->key] = $value->value; + } + } else { + foreach ($array as $key => $value) { + $result[$value->key] = $value->value; + } + } + return $result; + } + + public function getProcessFiles ($proUid, $type) + { + $filesList = array (); + + switch ($type) { + case "mail": + case "email": + $basePath = PATH_DATA_MAILTEMPLATES; + break; + case "public": + $basePath = PATH_DATA_PUBLIC; + break; + default: + throw new Exception( "Unknow Process Files Type \"$type\"." ); + break; + } + + $dir = $basePath . $proUid . PATH_SEP; + G::verifyPath( $dir, true ); //Create if it does not exist - - + //Creating the default template (if not exists) - if (! file_exists( $dir . "alert_message.html" )) { - @copy( PATH_TPL . "mails" . PATH_SEP . "alert_message.html", $dir . "alert_message.html" ); - } - - if (! file_exists( $dir . "unassignedMessage.html" )) { - @copy( PATH_TPL . "mails" . PATH_SEP . "unassignedMessage.html", $dir . "unassignedMessage.html" ); - } - - $files = glob( $dir . "*.*" ); - - foreach ($files as $file) { - $fileName = basename( $file ); - - if ($fileName != "alert_message.html" && $fileName != "unassignedMessage.html") { - $filesList[] = array ("filepath" => $file,"filename" => $fileName - ); - } - } - - return $filesList; - } - + if (! file_exists( $dir . "alert_message.html" )) { + @copy( PATH_TPL . "mails" . PATH_SEP . "alert_message.html", $dir . "alert_message.html" ); + } + + if (! file_exists( $dir . "unassignedMessage.html" )) { + @copy( PATH_TPL . "mails" . PATH_SEP . "unassignedMessage.html", $dir . "unassignedMessage.html" ); + } + + $files = glob( $dir . "*.*" ); + + foreach ($files as $file) { + $fileName = basename( $file ); + + if ($fileName != "alert_message.html" && $fileName != "unassignedMessage.html") { + $filesList[] = array ("filepath" => $file,"filename" => $fileName); + } + } + return $filesList; + } + } //end class processes - - -/** - * Object Document class - * - * @package workflow.engine.ProcessMaker - */ -class ObjectDocument -{ - public $type; - public $name; - public $data; - public $origin; - - /** - * Constructor - */ - function __construct () - { - $this->type = ''; - $this->name = ''; - $this->data = ''; - $this->origin = ''; - } -} - -/** - * ObjectDocument Collection - * - * @package workflow.engine.ProcessMaker - */ -class ObjectCellection -{ - public $num; - public $swapc; - public $objects; - - /** - * Constructor - */ - function __construct () - { - $this->objects = Array (); - $this->num = 0; - $this->swapc = $this->num; - array_push( $this->objects, 'void' ); - } - - /** - * add in the collecetion a new object Document - * - * @param $name name object document - * @param $type type object document - * @param $data data object document - * @param $origin origin object document - * @return void - */ - function add ($name, $type, $data, $origin) - { - $o = new ObjectDocument(); - $o->name = $name; - $o->type = $type; - $o->data = $data; - $o->origin = $origin; - - $this->num ++; - array_push( $this->objects, $o ); - $this->swapc = $this->num; - } - - /** - * get the collection of ObjectDocument - * - * @param $name name object document - * @param $type type object document - * @param $data data object document - * @param $origin origin object document - * @return void - */ - function get () - { - if ($this->swapc > 0) { - $e = $this->objects[$this->swapc]; - $this->swapc --; - return $e; - } else { - $this->swapc = $this->num; - return false; - } - } -} + + +/** + * Object Document class + * + * @package workflow.engine.ProcessMaker + */ +class ObjectDocument +{ + public $type; + public $name; + public $data; + public $origin; + + /** + * Constructor + */ + public function __construct () + { + $this->type = ''; + $this->name = ''; + $this->data = ''; + $this->origin = ''; + } +} + +/** + * ObjectDocument Collection + * + * @package workflow.engine.ProcessMaker + */ +class ObjectCellection +{ + public $num; + public $swapc; + public $objects; + + /** + * Constructor + */ + public function __construct () + { + $this->objects = Array (); + $this->num = 0; + $this->swapc = $this->num; + array_push( $this->objects, 'void' ); + } + + /** + * add in the collecetion a new object Document + * + * @param $name name object document + * @param $type type object document + * @param $data data object document + * @param $origin origin object document + * @return void + */ + public function add ($name, $type, $data, $origin) + { + $o = new ObjectDocument(); + $o->name = $name; + $o->type = $type; + $o->data = $data; + $o->origin = $origin; + + $this->num ++; + array_push( $this->objects, $o ); + $this->swapc = $this->num; + } + + /** + * get the collection of ObjectDocument + * + * @param $name name object document + * @param $type type object document + * @param $data data object document + * @param $origin origin object document + * @return void + */ + public function get () + { + if ($this->swapc > 0) { + $e = $this->objects[$this->swapc]; + $this->swapc --; + return $e; + } else { + $this->swapc = $this->num; + return false; + } + } +} + diff --git a/workflow/engine/classes/model/CalendarDefinition.php b/workflow/engine/classes/model/CalendarDefinition.php index 076393d07..a64308a18 100755 --- a/workflow/engine/classes/model/CalendarDefinition.php +++ b/workflow/engine/classes/model/CalendarDefinition.php @@ -1,467 +1,455 @@ -clearSelectColumns (); - - $Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_UID ); - $Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_NAME ); - $Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_CREATE_DATE ); - $Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE ); - $Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_DESCRIPTION ); - $Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_STATUS ); - // $Criteria->addAsColumn('DELETABLE', "IF (CALENDAR_UID <> '00000000000000000000000000000001', '".G::LoadTranslation('ID_DELETE')."','') "); - $Criteria->addAsColumn('DELETABLE', "CASE WHEN CALENDAR_UID <> '00000000000000000000000000000001' THEN '".G::LoadTranslation('ID_DELETE')."' ELSE '' END "); - // Note: This list doesn't show deleted items (STATUS = DELETED) - if ($onlyActive) { // Show only active. Used on assignment lists - $Criteria->add ( calendarDefinitionPeer::CALENDAR_STATUS, "ACTIVE", CRITERIA::EQUAL ); - } else { // Show Active and Inactive calendars. USed in main list - $Criteria->add ( calendarDefinitionPeer::CALENDAR_STATUS, array ("ACTIVE", "INACTIVE" ), CRITERIA::IN ); - } - - $Criteria->add ( calendarDefinitionPeer::CALENDAR_UID, "xx", CRITERIA::NOT_EQUAL ); - - if (! $arrayMode) { - return $Criteria; - } else { - $oDataset = calendarDefinitionPeer::doSelectRS ( $Criteria ); - $oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next (); - $calendarA = array (0 => 'dummy' ); - $calendarCount = 0; - while ( is_array ( $aRow = $oDataset->getRow () ) ) { - $calendarCount ++; - $calendarA [$calendarCount] = $aRow; - $oDataset->next (); - } - $return ['criteria'] = $Criteria; - $return ['array'] = $calendarA; - return $return; - } - } - //Added by qennix - //Gets criteria for listing - function getCalendarCriterias($filter, $start, $limit){ - $Criteria = new Criteria ( 'workflow' ); - $Criteria->clearSelectColumns (); - $Criteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_UID ); - if ($filter !=''){ - $Criteria->add( - $Criteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_NAME,'%'.$filter.'%',Criteria::LIKE)->addOr( - $Criteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_DESCRIPTION,'%'.$filter.'%',Criteria::LIKE))); - } - $Criteria->add(CalendarDefinitionPeer::CALENDAR_STATUS,'DELETED',Criteria::NOT_EQUAL); - - $oCriteria = new Criteria ( 'workflow' ); - $oCriteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_UID ); - $oCriteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_NAME ); - $oCriteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_CREATE_DATE ); - $oCriteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE ); - $oCriteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_DESCRIPTION ); - $oCriteria->addSelectColumn ( CalendarDefinitionPeer::CALENDAR_STATUS ); - if ($filter !=''){ - $oCriteria->add( - $oCriteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_NAME,'%'.$filter.'%',Criteria::LIKE)->addOr( - $oCriteria->getNewCriterion(CalendarDefinitionPeer::CALENDAR_DESCRIPTION,'%'.$filter.'%',Criteria::LIKE))); - } - $oCriteria->add(CalendarDefinitionPeer::CALENDAR_STATUS,'DELETED',Criteria::NOT_EQUAL); - $oCriteria->setLimit($limit); - $oCriteria->setOffset($start); - - $criterias = array(); - $criterias['COUNTER'] = $Criteria; - $criterias['LIST'] = $oCriteria; - return $criterias; - } - function getCalendarInfo($CalendarUid) { - //if exists the row in the database propel will update it, otherwise will insert. - $tr = CalendarDefinitionPeer::retrieveByPK ( $CalendarUid ); - - $defaultCalendar ['CALENDAR_UID'] = "00000000000000000000000000000001"; - $defaultCalendar ['CALENDAR_NAME'] = "Default"; - $defaultCalendar ['CALENDAR_CREATE_DATE'] = date ( "Y-m-d" ); - $defaultCalendar ['CALENDAR_UPDATE_DATE'] = date ( "Y-m-d" ); - $defaultCalendar ['CALENDAR_DESCRIPTION'] = "Default"; - $defaultCalendar ['CALENDAR_STATUS'] = "ACTIVE"; - $defaultCalendar ['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; - $defaultCalendar ['CALENDAR_WORK_DAYS'] = explode ( "|", "1|2|3|4|5" ); - $defaultCalendar ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_DAY'] = 7; - $defaultCalendar ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_START'] = "09:00"; - $defaultCalendar ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_END'] = "17:00"; - $defaultCalendar ['HOLIDAY'] = array (); - - if ((is_object ( $tr ) && get_class ( $tr ) == 'CalendarDefinition')) { - $fields ['CALENDAR_UID'] = $tr->getCalendarUid (); - $fields ['CALENDAR_NAME'] = $tr->getCalendarName (); - $fields ['CALENDAR_CREATE_DATE'] = $tr->getCalendarCreateDate (); - $fields ['CALENDAR_UPDATE_DATE'] = $tr->getCalendarUpdateDate (); - $fields ['CALENDAR_DESCRIPTION'] = $tr->getCalendarDescription (); - $fields ['CALENDAR_STATUS'] = $tr->getCalendarStatus (); - $fields ['CALENDAR_WORK_DAYS'] = $tr->getCalendarWorkDays (); - $fields ['CALENDAR_WORK_DAYS_A'] = explode ( "|", $tr->getCalendarWorkDays () ); - } else { - $fields=$defaultCalendar; - $this->saveCalendarInfo ( $fields ); - $fields ['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; - $fields ['CALENDAR_WORK_DAYS_A'] = explode ( "|", "1|2|3|4|5" ); - $tr = CalendarDefinitionPeer::retrieveByPK ( $CalendarUid ); - } - $CalendarBusinessHoursObj = new CalendarBusinessHours ( ); - $CalendarBusinessHours = $CalendarBusinessHoursObj->getCalendarBusinessHours ( $CalendarUid ); - $fields ['BUSINESS_DAY'] = $CalendarBusinessHours; - - $CalendarHolidaysObj = new CalendarHolidays ( ); - $CalendarHolidays = $CalendarHolidaysObj->getCalendarHolidays ( $CalendarUid ); - $fields ['HOLIDAY'] = $CalendarHolidays; - $fields=$this->validateCalendarInfo($fields, $defaultCalendar); //******************** - - return $fields; - - } - //for edit - function getCalendarInfoE($CalendarUid) { - //if exists the row in the database propel will update it, otherwise will insert. - $tr = CalendarDefinitionPeer::retrieveByPK ( $CalendarUid ); - - $defaultCalendar ['CALENDAR_UID'] = "00000000000000000000000000000001"; - $defaultCalendar ['CALENDAR_NAME'] = "Default"; - $defaultCalendar ['CALENDAR_CREATE_DATE'] = date ( "Y-m-d" ); - $defaultCalendar ['CALENDAR_UPDATE_DATE'] = date ( "Y-m-d" ); - $defaultCalendar ['CALENDAR_DESCRIPTION'] = "Default"; - $defaultCalendar ['CALENDAR_STATUS'] = "ACTIVE"; - $defaultCalendar ['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; - $defaultCalendar ['CALENDAR_WORK_DAYS'] = explode ( "|", "1|2|3|4|5" ); - $defaultCalendar ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_DAY'] = 7; - $defaultCalendar ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_START'] = "09:00"; - $defaultCalendar ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_END'] = "17:00"; - $defaultCalendar ['HOLIDAY'] = array (); - - if ((is_object ( $tr ) && get_class ( $tr ) == 'CalendarDefinition')) { - $fields ['CALENDAR_UID'] = $tr->getCalendarUid (); - $fields ['CALENDAR_NAME'] = $tr->getCalendarName (); - $fields ['CALENDAR_CREATE_DATE'] = $tr->getCalendarCreateDate (); - $fields ['CALENDAR_UPDATE_DATE'] = $tr->getCalendarUpdateDate (); - $fields ['CALENDAR_DESCRIPTION'] = $tr->getCalendarDescription (); - $fields ['CALENDAR_STATUS'] = $tr->getCalendarStatus (); - $fields ['CALENDAR_WORK_DAYS'] = $tr->getCalendarWorkDays (); - $fields ['CALENDAR_WORK_DAYS_A'] = explode ( "|", $tr->getCalendarWorkDays () ); - } else { - $fields=$defaultCalendar; - $this->saveCalendarInfo ( $fields ); - $fields ['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; - $fields ['CALENDAR_WORK_DAYS_A'] = explode ( "|", "1|2|3|4|5" ); - $tr = CalendarDefinitionPeer::retrieveByPK ( $CalendarUid ); - } - $CalendarBusinessHoursObj = new CalendarBusinessHours ( ); - $CalendarBusinessHours = $CalendarBusinessHoursObj->getCalendarBusinessHours ( $CalendarUid ); - $fields ['BUSINESS_DAY'] = $CalendarBusinessHours; - - $CalendarHolidaysObj = new CalendarHolidays ( ); - $CalendarHolidays = $CalendarHolidaysObj->getCalendarHolidays ( $CalendarUid ); - $fields ['HOLIDAY'] = $CalendarHolidays; - // $fields=$this->validateCalendarInfo($fields, $defaultCalendar); //******************** - - return $fields; - - } - //end for edit - - function validateCalendarInfo($fields,$defaultCalendar){ - try { - //Validate if Working days are Correct - //Minimun 3 ? - $workingDays=explode ( "|", $fields['CALENDAR_WORK_DAYS'] ); - if(count($workingDays)<3){ - throw (new Exception ( "You must define at least 3 Working Days!" )); - } - //Validate that all Working Days have Bussines Hours - if(count($fields ['BUSINESS_DAY'])<1){ - throw (new Exception ( "You must define at least one Business Day for all days" )); - } - $workingDaysOK=array(); - foreach($workingDays as $key => $day){ - $workingDaysOK[$day]=false; - } - $sw_all=false; - foreach($fields ['BUSINESS_DAY'] as $keyB => $businessHours){ - if(($businessHours['CALENDAR_BUSINESS_DAY']==7)){ - $sw_all=true; - }elseif((in_array($businessHours['CALENDAR_BUSINESS_DAY'],$workingDays))){ - $workingDaysOK[$businessHours['CALENDAR_BUSINESS_DAY']]=true; - } - } - $sw_days=true; - - foreach($workingDaysOK as $day =>$sw_day){ - $sw_days=$sw_days && $sw_day; - } - if(!($sw_all || $sw_days)){ - throw (new Exception ( "Not all working days have their correspondent business day" )); - } - //Validate Holidays - - return $fields; - } catch (Exception $e) { - //print $e->getMessage(); - $this->addCalendarLog("!!!!!!! BAD CALENDAR DEFINITION. ".$e->getMessage()); - $defaultCalendar ['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; - $defaultCalendar ['CALENDAR_WORK_DAYS_A'] = explode ( "|", "1|2|3|4|5" ); - return $defaultCalendar; - } - - - } - function saveCalendarInfo($aData) { - $CalendarUid = $aData ['CALENDAR_UID']; - $CalendarName = $aData ['CALENDAR_NAME']; - $CalendarDescription = $aData ['CALENDAR_DESCRIPTION']; - $CalendarStatus = isset ( $aData ['CALENDAR_STATUS'] ) ? $aData ['CALENDAR_STATUS'] : "INACTIVE"; - $defaultCalendars [] = '00000000000000000000000000000001'; - if (in_array ( $aData ['CALENDAR_UID'], $defaultCalendars )) { - $CalendarStatus = 'ACTIVE'; - $CalendarName = 'Default'; - } - $CalendarWorkDays = isset ( $aData ['CALENDAR_WORK_DAYS'] ) ? implode ( "|", $aData ['CALENDAR_WORK_DAYS'] ) : ""; - - //if exists the row in the database propel will update it, otherwise will insert. - $tr = CalendarDefinitionPeer::retrieveByPK ( $CalendarUid ); - if (! (is_object ( $tr ) && get_class ( $tr ) == 'CalendarDefinition')) { - $tr = new CalendarDefinition ( ); - $tr->setCalendarCreateDate ( 'now' ); - } - $tr->setCalendarUid ( $CalendarUid ); - $tr->setCalendarName ( $CalendarName ); - - $tr->setCalendarUpdateDate ( 'now' ); - $tr->setCalendarDescription ( $CalendarDescription ); - $tr->setCalendarStatus ( $CalendarStatus ); - $tr->setCalendarWorkDays ( $CalendarWorkDays ); - - if ($tr->validate ()) { - // we save it, since we get no validation errors, or do whatever else you like. - $res = $tr->save (); - //Calendar Business Hours Save code. - //First Delete all current records - $CalendarBusinessHoursObj = new CalendarBusinessHours ( ); - $CalendarBusinessHoursObj->deleteAllCalendarBusinessHours ( $CalendarUid ); - //Save all the sent records - foreach ( $aData ['BUSINESS_DAY'] as $key => $objData ) { - $objData ['CALENDAR_UID'] = $CalendarUid; - $CalendarBusinessHoursObj->saveCalendarBusinessHours ( $objData ); - } - - //Holiday Save code. - //First Delete all current records - $CalendarHolidayObj = new CalendarHolidays ( ); - $CalendarHolidayObj->deleteAllCalendarHolidays ( $CalendarUid ); - //Save all the sent records - foreach ( $aData ['HOLIDAY'] as $key => $objData ) { - if (($objData ['CALENDAR_HOLIDAY_NAME'] != "") && ($objData ['CALENDAR_HOLIDAY_START'] != "") && ($objData ['CALENDAR_HOLIDAY_END'] != "")) { - $objData ['CALENDAR_UID'] = $CalendarUid; - $CalendarHolidayObj->saveCalendarHolidays ( $objData ); - } - } - } else { - // Something went wrong. We can now get the validationFailures and handle them. - $msg = ''; - $validationFailuresArray = $tr->getValidationFailures (); - foreach ( $validationFailuresArray as $objValidationFailure ) { - $msg .= $objValidationFailure->getMessage () . "
"; - } - //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); - } - //return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => ''); - - - //to do: uniform coderror structures for all classes - - - //if ( $res['codError'] < 0 ) { - // G::SendMessageText ( $res['message'] , 'error' ); - //} - - - } - function deleteCalendar($CalendarUid) { - //if exists the row in the database propel will update it, otherwise will insert. - $tr = CalendarDefinitionPeer::retrieveByPK ( $CalendarUid ); - - if (! (is_object ( $tr ) && get_class ( $tr ) == 'CalendarDefinition')) { - // - return false; - } - - $defaultCalendars [] = '00000000000000000000000000000001'; - if (in_array ( $tr->getCalendarUid(), $defaultCalendars )) { - return false; - } - - $tr->setCalendarStatus ( 'DELETED' ); - $tr->setCalendarUpdateDate ( 'now' ); - if ($tr->validate ()) { - // we save it, since we get no validation errors, or do whatever else you like. - $res = $tr->save (); - - } else { - // Something went wrong. We can now get the validationFailures and handle them. - $msg = ''; - $validationFailuresArray = $tr->getValidationFailures (); - foreach ( $validationFailuresArray as $objValidationFailure ) { - $msg .= $objValidationFailure->getMessage () . "
"; - } - G::SendMessage ( "ERROR", $msg ); - //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); - } - //return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => ''); - - - //to do: uniform coderror structures for all classes - - - //if ( $res['codError'] < 0 ) { - // G::SendMessageText ( $res['message'] , 'error' ); - //} - - - } - function getCalendarFor($userUid, $proUid, $tasUid, $sw_validate=true) { - $Criteria = new Criteria ( 'workflow' ); - - //Default Calendar - $calendarUid = "00000000000000000000000000000001"; - $calendarOwner = "DEFAULT"; - - //Load User,Task and Process calendars (if exist) - $Criteria->addSelectColumn ( CalendarAssignmentsPeer::CALENDAR_UID ); - $Criteria->addSelectColumn ( CalendarAssignmentsPeer::OBJECT_UID ); - $Criteria->addSelectColumn ( CalendarAssignmentsPeer::OBJECT_TYPE ); - $Criteria->add ( CalendarAssignmentsPeer::OBJECT_UID, array($userUid, $proUid, $tasUid), CRITERIA::IN ); - $oDataset = CalendarAssignmentsPeer::doSelectRS ( $Criteria ); - $oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next (); - $calendarArray=array(); - while(is_array($aRow = $oDataset->getRow ())){ - if($aRow['OBJECT_UID']==$userUid){ - $calendarArray['USER']=$aRow ['CALENDAR_UID']; - } - if($aRow['OBJECT_UID']==$proUid){ - $calendarArray['PROCESS']=$aRow ['CALENDAR_UID']; - } - if($aRow['OBJECT_UID']==$tasUid){ - $calendarArray['TASK']=$aRow ['CALENDAR_UID']; - } - $oDataset->next (); - } - if(isset($calendarArray['USER'])){ - $calendarUid = $calendarArray['USER']; - $calendarOwner = "USER"; - }elseif (isset($calendarArray['PROCESS'])){ - $calendarUid = $calendarArray['PROCESS']; - $calendarOwner = "PROCESS"; - }elseif (isset($calendarArray['TASK'])){ - $calendarUid = $calendarArray['TASK']; - $calendarOwner = "TASK"; - } - - //print "

$calendarUid

"; - if($sw_validate){ - $calendarDefinition = $this->getCalendarInfo ( $calendarUid ); - }else{ - $calendarDefinition = $this->getCalendarInfoE ( $calendarUid ); - } - $calendarDefinition ['CALENDAR_APPLIED'] = $calendarOwner; - $this->addCalendarLog ( "--=== Calendar Applied: " . $calendarDefinition ['CALENDAR_NAME'] . " -> $calendarOwner" ); - return $calendarDefinition; - } - - function assignCalendarTo($objectUid, $calendarUid, $objectType) { - //if exists the row in the database propel will update it, otherwise will insert. - $tr = CalendarAssignmentsPeer::retrieveByPK ( $objectUid ); - if ($calendarUid != "") { - if (! (is_object ( $tr ) && get_class ( $tr ) == 'CalendarAssignments')) { - $tr = new CalendarAssignments ( ); - - } - $tr->setObjectUid ( $objectUid ); - $tr->setCalendarUid ( $calendarUid ); - $tr->setObjectType ( $objectType ); - - if ($tr->validate ()) { - // we save it, since we get no validation errors, or do whatever else you like. - $res = $tr->save (); - - } else { - // Something went wrong. We can now get the validationFailures and handle them. - $msg = ''; - $validationFailuresArray = $tr->getValidationFailures (); - foreach ( $validationFailuresArray as $objValidationFailure ) { - $msg .= $objValidationFailure->getMessage () . "
"; - } - //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); - } - } else { //Delete record - if ((is_object ( $tr ) && get_class ( $tr ) == 'CalendarAssignments')) { - $tr->delete (); - } - } - - } - //Added by Qennix - //Counts all users,task,process by calendar - function getAllCounterByCalendar($type){ - $oCriteria = new Criteria('workflow'); - $oCriteria->addSelectColumn(CalendarAssignmentsPeer::CALENDAR_UID); - $oCriteria->addSelectColumn('COUNT(*) AS CNT'); - $oCriteria->addGroupByColumn(CalendarAssignmentsPeer::CALENDAR_UID); - $oCriteria->add(CalendarAssignmentsPeer::OBJECT_TYPE,$type); - $oDataset = CalendarAssignmentsPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $aCounter = Array(); - while($oDataset->next()){ - $row = $oDataset->getRow(); - $aCounter[$row['CALENDAR_UID']] = $row['CNT']; - } - return $aCounter; - } - - function loadByCalendarName($calendarName) - { - $Criteria = new Criteria('workflow'); - $Criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_UID); - $Criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_NAME); - $Criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_CREATE_DATE); - $Criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_UPDATE_DATE); - $Criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_DESCRIPTION); - $Criteria->addSelectColumn(CalendarDefinitionPeer::CALENDAR_STATUS); - $Criteria->add(calendarDefinitionPeer::CALENDAR_NAME, $calendarName, CRITERIA::EQUAL); - $oDataset = calendarDefinitionPeer::doSelectRS ($Criteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - - return $oDataset->getRow(); - } -} // CalendarDefinition - - +clearSelectColumns(); + + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_NAME ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_CREATE_DATE ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_DESCRIPTION ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_STATUS ); + // $Criteria->addAsColumn('DELETABLE', "IF (CALENDAR_UID <> '00000000000000000000000000000001', '".G::LoadTranslation('ID_DELETE')."','') "); + $Criteria->addAsColumn( 'DELETABLE', "CASE WHEN CALENDAR_UID <> '00000000000000000000000000000001' THEN '" . G::LoadTranslation( 'ID_DELETE' ) . "' ELSE '' END " ); + // Note: This list doesn't show deleted items (STATUS = DELETED) + if ($onlyActive) { + // Show only active. Used on assignment lists + $Criteria->add( calendarDefinitionPeer::CALENDAR_STATUS, "ACTIVE", CRITERIA::EQUAL ); + } else { + // Show Active and Inactive calendars. USed in main list + $Criteria->add( calendarDefinitionPeer::CALENDAR_STATUS, array ("ACTIVE","INACTIVE"), CRITERIA::IN ); + } + + $Criteria->add( calendarDefinitionPeer::CALENDAR_UID, "xx", CRITERIA::NOT_EQUAL ); + + if (! $arrayMode) { + return $Criteria; + } else { + $oDataset = calendarDefinitionPeer::doSelectRS( $Criteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $calendarA = array (0 => 'dummy'); + $calendarCount = 0; + while (is_array( $aRow = $oDataset->getRow() )) { + $calendarCount ++; + $calendarA[$calendarCount] = $aRow; + $oDataset->next(); + } + $return['criteria'] = $Criteria; + $return['array'] = $calendarA; + return $return; + } + } + //Added by qennix + //Gets criteria for listing + public function getCalendarCriterias ($filter, $start, $limit) + { + $Criteria = new Criteria( 'workflow' ); + $Criteria->clearSelectColumns(); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID ); + if ($filter != '') { + $Criteria->add( $Criteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_NAME, '%' . $filter . '%', Criteria::LIKE )->addOr( $Criteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_DESCRIPTION, '%' . $filter . '%', Criteria::LIKE ) ) ); + } + $Criteria->add( CalendarDefinitionPeer::CALENDAR_STATUS, 'DELETED', Criteria::NOT_EQUAL ); + + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID ); + $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_NAME ); + $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_CREATE_DATE ); + $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE ); + $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_DESCRIPTION ); + $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_STATUS ); + if ($filter != '') { + $oCriteria->add( $oCriteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_NAME, '%' . $filter . '%', Criteria::LIKE )->addOr( $oCriteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_DESCRIPTION, '%' . $filter . '%', Criteria::LIKE ) ) ); + } + $oCriteria->add( CalendarDefinitionPeer::CALENDAR_STATUS, 'DELETED', Criteria::NOT_EQUAL ); + $oCriteria->setLimit( $limit ); + $oCriteria->setOffset( $start ); + + $criterias = array (); + $criterias['COUNTER'] = $Criteria; + $criterias['LIST'] = $oCriteria; + return $criterias; + } + + public function getCalendarInfo ($CalendarUid) + { + //if exists the row in the database propel will update it, otherwise will insert. + $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid ); + + $defaultCalendar['CALENDAR_UID'] = "00000000000000000000000000000001"; + $defaultCalendar['CALENDAR_NAME'] = "Default"; + $defaultCalendar['CALENDAR_CREATE_DATE'] = date( "Y-m-d" ); + $defaultCalendar['CALENDAR_UPDATE_DATE'] = date( "Y-m-d" ); + $defaultCalendar['CALENDAR_DESCRIPTION'] = "Default"; + $defaultCalendar['CALENDAR_STATUS'] = "ACTIVE"; + $defaultCalendar['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; + $defaultCalendar['CALENDAR_WORK_DAYS'] = explode( "|", "1|2|3|4|5" ); + $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_DAY'] = 7; + $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_START'] = "09:00"; + $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_END'] = "17:00"; + $defaultCalendar['HOLIDAY'] = array (); + + if ((is_object( $tr ) && get_class( $tr ) == 'CalendarDefinition')) { + $fields['CALENDAR_UID'] = $tr->getCalendarUid(); + $fields['CALENDAR_NAME'] = $tr->getCalendarName(); + $fields['CALENDAR_CREATE_DATE'] = $tr->getCalendarCreateDate(); + $fields['CALENDAR_UPDATE_DATE'] = $tr->getCalendarUpdateDate(); + $fields['CALENDAR_DESCRIPTION'] = $tr->getCalendarDescription(); + $fields['CALENDAR_STATUS'] = $tr->getCalendarStatus(); + $fields['CALENDAR_WORK_DAYS'] = $tr->getCalendarWorkDays(); + $fields['CALENDAR_WORK_DAYS_A'] = explode( "|", $tr->getCalendarWorkDays() ); + } else { + $fields = $defaultCalendar; + $this->saveCalendarInfo( $fields ); + $fields['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; + $fields['CALENDAR_WORK_DAYS_A'] = explode( "|", "1|2|3|4|5" ); + $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid ); + } + $CalendarBusinessHoursObj = new CalendarBusinessHours(); + $CalendarBusinessHours = $CalendarBusinessHoursObj->getCalendarBusinessHours( $CalendarUid ); + $fields['BUSINESS_DAY'] = $CalendarBusinessHours; + $CalendarHolidaysObj = new CalendarHolidays(); + $CalendarHolidays = $CalendarHolidaysObj->getCalendarHolidays( $CalendarUid ); + $fields['HOLIDAY'] = $CalendarHolidays; + $fields = $this->validateCalendarInfo( $fields, $defaultCalendar ); + //******************** + return $fields; + } + //for edit + public function getCalendarInfoE ($CalendarUid) + { + //if exists the row in the database propel will update it, otherwise will insert. + $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid ); + $defaultCalendar['CALENDAR_UID'] = "00000000000000000000000000000001"; + $defaultCalendar['CALENDAR_NAME'] = "Default"; + $defaultCalendar['CALENDAR_CREATE_DATE'] = date( "Y-m-d" ); + $defaultCalendar['CALENDAR_UPDATE_DATE'] = date( "Y-m-d" ); + $defaultCalendar['CALENDAR_DESCRIPTION'] = "Default"; + $defaultCalendar['CALENDAR_STATUS'] = "ACTIVE"; + $defaultCalendar['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; + $defaultCalendar['CALENDAR_WORK_DAYS'] = explode( "|", "1|2|3|4|5" ); + $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_DAY'] = 7; + $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_START'] = "09:00"; + $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_END'] = "17:00"; + $defaultCalendar['HOLIDAY'] = array (); + + if ((is_object( $tr ) && get_class( $tr ) == 'CalendarDefinition')) { + $fields['CALENDAR_UID'] = $tr->getCalendarUid(); + $fields['CALENDAR_NAME'] = $tr->getCalendarName(); + $fields['CALENDAR_CREATE_DATE'] = $tr->getCalendarCreateDate(); + $fields['CALENDAR_UPDATE_DATE'] = $tr->getCalendarUpdateDate(); + $fields['CALENDAR_DESCRIPTION'] = $tr->getCalendarDescription(); + $fields['CALENDAR_STATUS'] = $tr->getCalendarStatus(); + $fields['CALENDAR_WORK_DAYS'] = $tr->getCalendarWorkDays(); + $fields['CALENDAR_WORK_DAYS_A'] = explode( "|", $tr->getCalendarWorkDays() ); + } else { + $fields = $defaultCalendar; + $this->saveCalendarInfo( $fields ); + $fields['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; + $fields['CALENDAR_WORK_DAYS_A'] = explode( "|", "1|2|3|4|5" ); + $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid ); + } + $CalendarBusinessHoursObj = new CalendarBusinessHours(); + $CalendarBusinessHours = $CalendarBusinessHoursObj->getCalendarBusinessHours( $CalendarUid ); + $fields['BUSINESS_DAY'] = $CalendarBusinessHours; + $CalendarHolidaysObj = new CalendarHolidays(); + $CalendarHolidays = $CalendarHolidaysObj->getCalendarHolidays( $CalendarUid ); + $fields['HOLIDAY'] = $CalendarHolidays; + // $fields=$this->validateCalendarInfo($fields, $defaultCalendar); //******************** + return $fields; + } + //end for edit + + public function validateCalendarInfo ($fields, $defaultCalendar) + { + try { + //Validate if Working days are Correct + //Minimun 3 ? + $workingDays = explode( "|", $fields['CALENDAR_WORK_DAYS'] ); + if (count( $workingDays ) < 3) { + throw (new Exception( "You must define at least 3 Working Days!" )); + } + //Validate that all Working Days have Bussines Hours + if (count( $fields['BUSINESS_DAY'] ) < 1) { + throw (new Exception( "You must define at least one Business Day for all days" )); + } + $workingDaysOK = array (); + foreach ($workingDays as $key => $day) { + $workingDaysOK[$day] = false; + } + $sw_all = false; + foreach ($fields['BUSINESS_DAY'] as $keyB => $businessHours) { + if (($businessHours['CALENDAR_BUSINESS_DAY'] == 7)) { + $sw_all = true; + } elseif ((in_array( $businessHours['CALENDAR_BUSINESS_DAY'], $workingDays ))) { + $workingDaysOK[$businessHours['CALENDAR_BUSINESS_DAY']] = true; + } + } + $sw_days = true; + + foreach ($workingDaysOK as $day => $sw_day) { + $sw_days = $sw_days && $sw_day; + } + if (! ($sw_all || $sw_days)) { + throw (new Exception( "Not all working days have their correspondent business day" )); + } + //Validate Holidays + return $fields; + } catch (Exception $e) { + //print $e->getMessage(); + $this->addCalendarLog( "!!!!!!! BAD CALENDAR DEFINITION. " . $e->getMessage() ); + $defaultCalendar['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; + $defaultCalendar['CALENDAR_WORK_DAYS_A'] = explode( "|", "1|2|3|4|5" ); + return $defaultCalendar; + } + + } + + public function saveCalendarInfo ($aData) + { + $CalendarUid = $aData['CALENDAR_UID']; + $CalendarName = $aData['CALENDAR_NAME']; + $CalendarDescription = $aData['CALENDAR_DESCRIPTION']; + $CalendarStatus = isset( $aData['CALENDAR_STATUS'] ) ? $aData['CALENDAR_STATUS'] : "INACTIVE"; + $defaultCalendars[] = '00000000000000000000000000000001'; + if (in_array( $aData['CALENDAR_UID'], $defaultCalendars )) { + $CalendarStatus = 'ACTIVE'; + $CalendarName = 'Default'; + } + $CalendarWorkDays = isset( $aData['CALENDAR_WORK_DAYS'] ) ? implode( "|", $aData['CALENDAR_WORK_DAYS'] ) : ""; + + //if exists the row in the database propel will update it, otherwise will insert. + $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid ); + if (! (is_object( $tr ) && get_class( $tr ) == 'CalendarDefinition')) { + $tr = new CalendarDefinition(); + $tr->setCalendarCreateDate( 'now' ); + } + $tr->setCalendarUid( $CalendarUid ); + $tr->setCalendarName( $CalendarName ); + $tr->setCalendarUpdateDate( 'now' ); + $tr->setCalendarDescription( $CalendarDescription ); + $tr->setCalendarStatus( $CalendarStatus ); + $tr->setCalendarWorkDays( $CalendarWorkDays ); + + if ($tr->validate()) { + // we save it, since we get no validation errors, or do whatever else you like. + $res = $tr->save(); + //Calendar Business Hours Save code. + //First Delete all current records + $CalendarBusinessHoursObj = new CalendarBusinessHours(); + $CalendarBusinessHoursObj->deleteAllCalendarBusinessHours( $CalendarUid ); + //Save all the sent records + foreach ($aData['BUSINESS_DAY'] as $key => $objData) { + $objData['CALENDAR_UID'] = $CalendarUid; + $CalendarBusinessHoursObj->saveCalendarBusinessHours( $objData ); + } + //Holiday Save code. + //First Delete all current records + $CalendarHolidayObj = new CalendarHolidays(); + $CalendarHolidayObj->deleteAllCalendarHolidays( $CalendarUid ); + //Save all the sent records + foreach ($aData['HOLIDAY'] as $key => $objData) { + if (($objData['CALENDAR_HOLIDAY_NAME'] != "") && ($objData['CALENDAR_HOLIDAY_START'] != "") && ($objData['CALENDAR_HOLIDAY_END'] != "")) { + $objData['CALENDAR_UID'] = $CalendarUid; + $CalendarHolidayObj->saveCalendarHolidays( $objData ); + } + } + } else { + // Something went wrong. We can now get the validationFailures and handle them. + $msg = ''; + $validationFailuresArray = $tr->getValidationFailures(); + foreach ($validationFailuresArray as $objValidationFailure) { + $msg .= $objValidationFailure->getMessage() . "
"; + } + //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); + } + //return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => ''); + //to do: uniform coderror structures for all classes + //if ( $res['codError'] < 0 ) { + // G::SendMessageText ( $res['message'] , 'error' ); + //} + } + + public function deleteCalendar ($CalendarUid) + { + //if exists the row in the database propel will update it, otherwise will insert. + $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid ); + + if (! (is_object( $tr ) && get_class( $tr ) == 'CalendarDefinition')) { + // + return false; + } + + $defaultCalendars[] = '00000000000000000000000000000001'; + if (in_array( $tr->getCalendarUid(), $defaultCalendars )) { + return false; + } + + $tr->setCalendarStatus( 'DELETED' ); + $tr->setCalendarUpdateDate( 'now' ); + if ($tr->validate()) { + // we save it, since we get no validation errors, or do whatever else you like. + $res = $tr->save(); + } else { + // Something went wrong. We can now get the validationFailures and handle them. + $msg = ''; + $validationFailuresArray = $tr->getValidationFailures(); + foreach ($validationFailuresArray as $objValidationFailure) { + $msg .= $objValidationFailure->getMessage() . "
"; + } + G::SendMessage( "ERROR", $msg ); + //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); + } + //return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => ''); + //to do: uniform coderror structures for all classes + //if ( $res['codError'] < 0 ) { + // G::SendMessageText ( $res['message'] , 'error' ); + //} + } + + public function getCalendarFor ($userUid, $proUid, $tasUid, $sw_validate = true) + { + $Criteria = new Criteria( 'workflow' ); + //Default Calendar + $calendarUid = "00000000000000000000000000000001"; + $calendarOwner = "DEFAULT"; + //Load User,Task and Process calendars (if exist) + $Criteria->addSelectColumn( CalendarAssignmentsPeer::CALENDAR_UID ); + $Criteria->addSelectColumn( CalendarAssignmentsPeer::OBJECT_UID ); + $Criteria->addSelectColumn( CalendarAssignmentsPeer::OBJECT_TYPE ); + $Criteria->add( CalendarAssignmentsPeer::OBJECT_UID, array ($userUid,$proUid,$tasUid), CRITERIA::IN ); + $oDataset = CalendarAssignmentsPeer::doSelectRS( $Criteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $calendarArray = array (); + while (is_array( $aRow = $oDataset->getRow() )) { + if ($aRow['OBJECT_UID'] == $userUid) { + $calendarArray['USER'] = $aRow['CALENDAR_UID']; + } + if ($aRow['OBJECT_UID'] == $proUid) { + $calendarArray['PROCESS'] = $aRow['CALENDAR_UID']; + } + if ($aRow['OBJECT_UID'] == $tasUid) { + $calendarArray['TASK'] = $aRow['CALENDAR_UID']; + } + $oDataset->next(); + } + + if (isset( $calendarArray['USER'] )) { + $calendarUid = $calendarArray['USER']; + $calendarOwner = "USER"; + } elseif (isset( $calendarArray['PROCESS'] )) { + $calendarUid = $calendarArray['PROCESS']; + $calendarOwner = "PROCESS"; + } elseif (isset( $calendarArray['TASK'] )) { + $calendarUid = $calendarArray['TASK']; + $calendarOwner = "TASK"; + } + + //print "

$calendarUid

"; + if ($sw_validate) { + $calendarDefinition = $this->getCalendarInfo( $calendarUid ); + } else { + $calendarDefinition = $this->getCalendarInfoE( $calendarUid ); + } + $calendarDefinition['CALENDAR_APPLIED'] = $calendarOwner; + $this->addCalendarLog( "--=== Calendar Applied: " . $calendarDefinition['CALENDAR_NAME'] . " -> $calendarOwner" ); + return $calendarDefinition; + } + + public function assignCalendarTo ($objectUid, $calendarUid, $objectType) + { + //if exists the row in the database propel will update it, otherwise will insert. + $tr = CalendarAssignmentsPeer::retrieveByPK( $objectUid ); + if ($calendarUid != "") { + if (! (is_object( $tr ) && get_class( $tr ) == 'CalendarAssignments')) { + $tr = new CalendarAssignments(); + } + $tr->setObjectUid( $objectUid ); + $tr->setCalendarUid( $calendarUid ); + $tr->setObjectType( $objectType ); + + if ($tr->validate()) { + // we save it, since we get no validation errors, or do whatever else you like. + $res = $tr->save(); + } else { + // Something went wrong. We can now get the validationFailures and handle them. + $msg = ''; + $validationFailuresArray = $tr->getValidationFailures(); + foreach ($validationFailuresArray as $objValidationFailure) { + $msg .= $objValidationFailure->getMessage() . "
"; + } + //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); + } + } else { + //Delete record + if ((is_object( $tr ) && get_class( $tr ) == 'CalendarAssignments')) { + $tr->delete(); + } + } + } + //Added by Qennix + //Counts all users,task,process by calendar + public function getAllCounterByCalendar ($type) + { + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->addSelectColumn( CalendarAssignmentsPeer::CALENDAR_UID ); + $oCriteria->addSelectColumn( 'COUNT(*) AS CNT' ); + $oCriteria->addGroupByColumn( CalendarAssignmentsPeer::CALENDAR_UID ); + $oCriteria->add( CalendarAssignmentsPeer::OBJECT_TYPE, $type ); + $oDataset = CalendarAssignmentsPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $aCounter = Array (); + while ($oDataset->next()) { + $row = $oDataset->getRow(); + $aCounter[$row['CALENDAR_UID']] = $row['CNT']; + } + return $aCounter; + } + + public function loadByCalendarName ($calendarName) + { + $Criteria = new Criteria( 'workflow' ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_NAME ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_CREATE_DATE ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_DESCRIPTION ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_STATUS ); + $Criteria->add( calendarDefinitionPeer::CALENDAR_NAME, $calendarName, CRITERIA::EQUAL ); + $oDataset = calendarDefinitionPeer::doSelectRS( $Criteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + return $oDataset->getRow(); + } +} +// CalendarDefinition + diff --git a/workflow/engine/classes/model/Content.php b/workflow/engine/classes/model/Content.php index 31e208f5b..654e3fb85 100755 --- a/workflow/engine/classes/model/Content.php +++ b/workflow/engine/classes/model/Content.php @@ -1,479 +1,485 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -require_once 'classes/model/om/BaseContent.php'; - -/** - * Skeleton subclass for representing a row from the 'CONTENT' table. - * - * - * - * You should add additional methods to this class to meet the - * application requirements. This class will only be generated as - * long as it does not already exist in the output directory. - * - * @package workflow.engine.classes.model - */ -class Content extends BaseContent { - - public $langs; - public $rowsProcessed; - public $rowsInserted; - public $rowsUnchanged; - public $rowsClustered; - public $langsAsoc; - /* - * Load the content row specified by the parameters: +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + */ + +require_once 'classes/model/om/BaseContent.php'; + +/** + * Skeleton subclass for representing a row from the 'CONTENT' table. + * + * + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + * + * @package workflow.engine.classes.model + */ +class Content extends BaseContent +{ + public $langs; + public $rowsProcessed; + public $rowsInserted; + public $rowsUnchanged; + public $rowsClustered; + public $langsAsoc; + /* + * Load the content row specified by the parameters: * @param string $sUID * @return variant - */ - function load($ConCategory, $ConParent, $ConId, $ConLang) { - $content = ContentPeer::retrieveByPK ( $ConCategory, $ConParent, $ConId, $ConLang ); - if (is_null ( $content )) { - //we dont find any value for this field and language in CONTENT table - $ConValue = Content::autoLoadSave ( $ConCategory, $ConParent, $ConId, $ConLang ); - } else { - //krumo($content); - $ConValue = $content->getConValue (); - if ($ConValue == "") { //try to find a valid translation - $ConValue = Content::autoLoadSave ( $ConCategory, $ConParent, $ConId, $ConLang ); - } - } - return $ConValue; - } - /* - * Find a valid Lang for current Content. The most recent + */ + public function load ($ConCategory, $ConParent, $ConId, $ConLang) + { + $content = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $ConLang ); + if (is_null( $content )) { + //we dont find any value for this field and language in CONTENT table; + $ConValue = Content::autoLoadSave( $ConCategory, $ConParent, $ConId, $ConLang ); + } else { + //krumo($content); + $ConValue = $content->getConValue(); + if ($ConValue == "") { + //try to find a valid translation + $ConValue = Content::autoLoadSave( $ConCategory, $ConParent, $ConId, $ConLang ); + } + } + return $ConValue; + } + /* + * Find a valid Lang for current Content. The most recent * @param string $ConCategory * @param string $ConParent - * @param string $ConId + * @param string $ConId * @return string - * - */ - function getDefaultContentLang($ConCategory, $ConParent, $ConId, $destConLang) { - $Criteria = new Criteria ( 'workflow' ); - $Criteria->clearSelectColumns ()->clearOrderByColumns (); - - $Criteria->addSelectColumn ( ContentPeer::CON_CATEGORY ); - $Criteria->addSelectColumn ( ContentPeer::CON_PARENT ); - $Criteria->addSelectColumn ( ContentPeer::CON_ID ); - $Criteria->addSelectColumn ( ContentPeer::CON_LANG ); - $Criteria->addSelectColumn ( ContentPeer::CON_VALUE ); - - $Criteria->add ( ContentPeer::CON_CATEGORY, $ConCategory, CRITERIA::EQUAL ); - $Criteria->add ( ContentPeer::CON_PARENT, $ConParent, CRITERIA::EQUAL ); - $Criteria->add ( ContentPeer::CON_ID, $ConId, CRITERIA::EQUAL ); - - $Criteria->add ( ContentPeer::CON_LANG, $destConLang, CRITERIA::NOT_EQUAL ); - - $rs = ContentPeer::doSelectRS ( $Criteria ); - $rs->setFetchmode ( ResultSet::FETCHMODE_ASSOC ); - $rs->next (); - - if (is_array ( $row = $rs->getRow () )) { - $defaultLang = $row ['CON_LANG']; - - } else { - $defaultLang = ""; - } - return ($defaultLang); - } - /* - * Load the content row and the Save automatically the row for the destination language - * @param string $ConCategory - * @param string $ConParent - * @param string $ConId - * @param string $destConLang - * @return string - * if the row doesn't exist, it will be created automatically, even the default 'en' language - */ - function autoLoadSave($ConCategory, $ConParent, $ConId, $destConLang) { - //search in 'en' language, the default language - $content = ContentPeer::retrieveByPK ( $ConCategory, $ConParent, $ConId, 'en' ); - - if ((is_null ( $content )) || ($content->getConValue () == "")) { - $differentLang = Content::getDefaultContentLang ( $ConCategory, $ConParent, $ConId, $destConLang ); - $content = ContentPeer::retrieveByPK ( $ConCategory, $ConParent, $ConId, $differentLang ); - } - - //to do: review if the $destConLang is a valid language/ - if (is_null ( $content )) - $ConValue = ''; //we dont find any value for this field and language in CONTENT table - else - $ConValue = $content->getConValue (); - - try { - $con = ContentPeer::retrieveByPK ( $ConCategory, $ConParent, $ConId, $destConLang ); - if (is_null ( $con )) { - $con = new Content ( ); - } - $con->setConCategory ( $ConCategory ); - $con->setConParent ( $ConParent ); - $con->setConId ( $ConId ); - $con->setConLang ( $destConLang ); - $con->setConValue ( $ConValue ); - if ($con->validate ()) { - $res = $con->save (); - } - } catch ( Exception $e ) { - throw ($e); - } - - return $ConValue; - } - - /* - * Insert a content row + * + */ + public function getDefaultContentLang ($ConCategory, $ConParent, $ConId, $destConLang) + { + $Criteria = new Criteria( 'workflow' ); + $Criteria->clearSelectColumns()->clearOrderByColumns(); + + $Criteria->addSelectColumn( ContentPeer::CON_CATEGORY ); + $Criteria->addSelectColumn( ContentPeer::CON_PARENT ); + $Criteria->addSelectColumn( ContentPeer::CON_ID ); + $Criteria->addSelectColumn( ContentPeer::CON_LANG ); + $Criteria->addSelectColumn( ContentPeer::CON_VALUE ); + + $Criteria->add( ContentPeer::CON_CATEGORY, $ConCategory, CRITERIA::EQUAL ); + $Criteria->add( ContentPeer::CON_PARENT, $ConParent, CRITERIA::EQUAL ); + $Criteria->add( ContentPeer::CON_ID, $ConId, CRITERIA::EQUAL ); + $Criteria->add( ContentPeer::CON_LANG, $destConLang, CRITERIA::NOT_EQUAL ); + + $rs = ContentPeer::doSelectRS( $Criteria ); + $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $rs->next(); + + if (is_array( $row = $rs->getRow() )) { + $defaultLang = $row['CON_LANG']; + } else { + $defaultLang = ""; + } + return ($defaultLang); + } + /* + * Load the content row and the Save automatically the row for the destination language + * @param string $ConCategory + * @param string $ConParent + * @param string $ConId + * @param string $destConLang + * @return string + * if the row doesn't exist, it will be created automatically, even the default 'en' language + */ + public function autoLoadSave ($ConCategory, $ConParent, $ConId, $destConLang) + { + //search in 'en' language, the default language + $content = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, 'en' ); + + if ((is_null( $content )) || ($content->getConValue() == "")) { + $differentLang = Content::getDefaultContentLang( $ConCategory, $ConParent, $ConId, $destConLang ); + $content = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $differentLang ); + } + + //to do: review if the $destConLang is a valid language/ + if (is_null( $content )) { + $ConValue = ''; + //we dont find any value for this field and language in CONTENT table + } else { + $ConValue = $content->getConValue(); + } + + try { + $con = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $destConLang ); + if (is_null( $con )) { + $con = new Content(); + } + $con->setConCategory( $ConCategory ); + $con->setConParent( $ConParent ); + $con->setConId( $ConId ); + $con->setConLang( $destConLang ); + $con->setConValue( $ConValue ); + if ($con->validate()) { + $res = $con->save(); + } + } catch (Exception $e) { + throw ($e); + } + + return $ConValue; + } + + /* + * Insert a content row * @param string $ConCategory * @param string $ConParent * @param string $ConId * @param string $ConLang - * @param string $ConValue + * @param string $ConValue * @return variant - */ - function addContent($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) { - try { - if ($ConLang != 'en') { - $baseLangContent = ContentPeer::retrieveByPk($ConCategory, $ConParent, $ConId, 'en'); - if ($baseLangContent === null) { - Content::addContent($ConCategory, $ConParent, $ConId, 'en', $ConValue); - } - } - - $con = ContentPeer::retrieveByPK ( $ConCategory, $ConParent, $ConId, $ConLang ); - - if (is_null ( $con )) { - $con = new Content ( ); - } else { - if ($con->getConParent () == $ConParent && $con->getConCategory () == $ConCategory && $con->getConValue () == $ConValue && $con->getConLang () == $ConLang && $con->getConId () == $ConId) - return true; - } - $con->setConCategory ( $ConCategory ); - if ($con->getConParent () != $ConParent) - $con->setConParent ( $ConParent ); - $con->setConId ( $ConId ); - $con->setConLang ( $ConLang ); - $con->setConValue ( $ConValue ); - if ($con->validate ()) { - $res = $con->save (); - return $res; - } else { - $e = new Exception ( "Error in addcontent, the row $ConCategory, $ConParent, $ConId, $ConLang is not Valid" ); - throw ($e); - } - } catch ( Exception $e ) { - throw ($e); - } - } - - /* - * Insert a content row + */ + public function addContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) + { + try { + if ($ConLang != 'en') { + $baseLangContent = ContentPeer::retrieveByPk( $ConCategory, $ConParent, $ConId, 'en' ); + if ($baseLangContent === null) { + Content::addContent( $ConCategory, $ConParent, $ConId, 'en', $ConValue ); + } + } + + $con = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $ConLang ); + + if (is_null( $con )) { + $con = new Content(); + } else { + if ($con->getConParent() == $ConParent && $con->getConCategory() == $ConCategory && $con->getConValue() == $ConValue && $con->getConLang() == $ConLang && $con->getConId() == $ConId) { + return true; + } + } + $con->setConCategory( $ConCategory ); + if ($con->getConParent() != $ConParent) { + $con->setConParent( $ConParent ); + } + $con->setConId( $ConId ); + $con->setConLang( $ConLang ); + $con->setConValue( $ConValue ); + if ($con->validate()) { + $res = $con->save(); + return $res; + } else { + $e = new Exception( "Error in addcontent, the row $ConCategory, $ConParent, $ConId, $ConLang is not Valid" ); + throw ($e); + } + } catch (Exception $e) { + throw ($e); + } + } + + /* + * Insert a content row * @param string $ConCategory * @param string $ConParent * @param string $ConId * @param string $ConLang - * @param string $ConValue + * @param string $ConValue * @return variant - */ - function insertContent($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) { - try { - $con = new Content ( ); - $con->setConCategory ( $ConCategory ); - $con->setConParent ( $ConParent ); - $con->setConId ( $ConId ); - $con->setConLang ( $ConLang ); - $con->setConValue ( $ConValue ); - if ($con->validate ()) { - $res = $con->save (); - return $res; - } else { - $e = new Exception ( "Error in addcontent, the row $ConCategory, $ConParent, $ConId, $ConLang is not Valid" ); - throw ($e); - } - } catch ( Exception $e ) { - throw ($e); - } - } - - /* - * remove a content row + */ + public function insertContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) + { + try { + $con = new Content(); + $con->setConCategory( $ConCategory ); + $con->setConParent( $ConParent ); + $con->setConId( $ConId ); + $con->setConLang( $ConLang ); + $con->setConValue( $ConValue ); + if ($con->validate()) { + $res = $con->save(); + return $res; + } else { + $e = new Exception( "Error in addcontent, the row $ConCategory, $ConParent, $ConId, $ConLang is not Valid" ); + throw ($e); + } + } catch (Exception $e) { + throw ($e); + } + } + + /* + * remove a content row * @param string $ConCategory * @param string $ConParent * @param string $ConId * @param string $ConLang - * @param string $ConValue + * @param string $ConValue * @return variant - */ - function removeContent($ConCategory, $ConParent, $ConId) { - try { - $c = new Criteria ( ); - $c->add ( ContentPeer::CON_CATEGORY, $ConCategory ); - $c->add ( ContentPeer::CON_PARENT, $ConParent ); - $c->add ( ContentPeer::CON_ID, $ConId ); - $result = ContentPeer::doSelectRS ( $c ); - $result->next (); - $row = $result->getRow (); - while ( is_array ( $row ) ) { - ContentPeer::doDelete ( array ($ConCategory, $ConParent, $ConId, $row [3] ) ); - $result->next (); - $row = $result->getRow (); - } - } catch ( Exception $e ) { - throw ($e); - } - - } - - /* + */ + public function removeContent ($ConCategory, $ConParent, $ConId) + { + try { + $c = new Criteria(); + $c->add( ContentPeer::CON_CATEGORY, $ConCategory ); + $c->add( ContentPeer::CON_PARENT, $ConParent ); + $c->add( ContentPeer::CON_ID, $ConId ); + $result = ContentPeer::doSelectRS( $c ); + $result->next(); + $row = $result->getRow(); + while (is_array( $row )) { + ContentPeer::doDelete( array ($ConCategory,$ConParent,$ConId,$row[3]) ); + $result->next(); + $row = $result->getRow(); + } + } catch (Exception $e) { + throw ($e); + } + + } + + /* * Reasons if the record already exists * * @param string $ConCategory * @param string $ConParent * @param string $ConId * @param string $ConLang - * @param string $ConValue + * @param string $ConValue * @return boolean true or false - */ - function Exists ($ConCategory, $ConParent, $ConId, $ConLang) - { - try { - $oPro = ContentPeer::retrieveByPk($ConCategory, $ConParent, $ConId, $ConLang); - if (is_object($oPro) && get_class ($oPro) == 'Content' ) { - return true; - } else { - return false; - } - } - catch (Exception $oError) { - throw($oError); - } - } - + */ + public function Exists ($ConCategory, $ConParent, $ConId, $ConLang) + { + try { + $oPro = ContentPeer::retrieveByPk( $ConCategory, $ConParent, $ConId, $ConLang ); + if (is_object( $oPro ) && get_class( $oPro ) == 'Content') { + return true; + } else { + return false; + } + } catch (Exception $oError) { + throw ($oError); + } + } + /* * Regenerate Table Content * * @param array $langs - */ - function regenerateContent($langs, $workSpace=SYS_SYS) - { + */ + public function regenerateContent ($langs, $workSpace = SYS_SYS) + { //Search the language - $key = array_search('en',$langs); - if ($key === false) { - $key = array_search(SYS_LANG,$langs); - if ($key === false) { - $key = '0'; - } - } - $this->langsAsoc = array(); - foreach ($langs as $key=>$value) { - $this->langsAsoc[$value] = $value; - } - - $this->langs = $langs; - $this->rowsProcessed = 0; - $this->rowsInserted = 0; - $this->rowsUnchanged = 0; - $this->rowsClustered = 0; - + $key = array_search( 'en', $langs ); + if ($key === false) { + $key = array_search( SYS_LANG, $langs ); + if ($key === false) { + $key = '0'; + } + } + $this->langsAsoc = array (); + foreach ($langs as $key => $value) { + $this->langsAsoc[$value] = $value; + } + + $this->langs = $langs; + $this->rowsProcessed = 0; + $this->rowsInserted = 0; + $this->rowsUnchanged = 0; + $this->rowsClustered = 0; + //Creating table CONTENT_BACKUP - $oConnection = Propel::getConnection('workflow'); - $oStatement = $oConnection->prepareStatement("CREATE TABLE IF NOT EXISTS `CONTENT_BACKUP` ( + $oConnection = Propel::getConnection( 'workflow' ); + $oStatement = $oConnection->prepareStatement( "CREATE TABLE IF NOT EXISTS `CONTENT_BACKUP` ( `CON_CATEGORY` VARCHAR(30) default '' NOT NULL, `CON_PARENT` VARCHAR(32) default '' NOT NULL, `CON_ID` VARCHAR(100) default '' NOT NULL, `CON_LANG` VARCHAR(10) default '' NOT NULL, `CON_VALUE` MEDIUMTEXT NOT NULL, CONSTRAINT CONTENT_BACKUP_PK PRIMARY KEY (CON_CATEGORY,CON_PARENT,CON_ID,CON_LANG) - )Engine=MyISAM DEFAULT CHARSET='utf8' COMMENT='Table for add content';"); - $oStatement->executeQuery(); - - $con = Propel::getConnection('workflow'); + )Engine=MyISAM DEFAULT CHARSET='utf8' COMMENT='Table for add content';" ); + $oStatement->executeQuery(); + + $con = Propel::getConnection( 'workflow' ); $sql = " SELECT DISTINCT CON_LANG - FROM CONTENT "; - $stmt = $con->createStatement(); - $rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC); - while ($rs->next()) { - $row = $rs->getRow(); - $language = $row['CON_LANG']; - if (array_search($row['CON_LANG'],$langs) === false) { - Content::removeLanguageContent($row['CON_LANG']); - } - } - + FROM CONTENT "; + $stmt = $con->createStatement(); + $rs = $stmt->executeQuery( $sql, ResultSet::FETCHMODE_ASSOC ); + while ($rs->next()) { + $row = $rs->getRow(); + $language = $row['CON_LANG']; + if (array_search( $row['CON_LANG'], $langs ) === false) { + Content::removeLanguageContent( $row['CON_LANG'] ); + } + } + $sql = " SELECT CON_ID, CON_CATEGORY, CON_LANG, CON_PARENT, CON_VALUE FROM CONTENT - ORDER BY CON_ID, CON_CATEGORY, CON_PARENT, CON_LANG"; - - G::LoadClass("wsTools"); - $workSpace = new workspaceTools($workSpace); - $workSpace->getDBInfo(); - - $link = mysql_pconnect($workSpace->dbHost, $workSpace->dbUser, $workSpace->dbPass) - or die ("Could not connect"); - - mysql_select_db($workSpace->dbName, $link); - mysql_query("SET NAMES 'utf8';"); - mysql_query('SET OPTION SQL_BIG_SELECTS=1'); - $result = mysql_unbuffered_query($sql, $link); - $list = array(); - $default = array(); - $sw = array('CON_ID'=>'','CON_CATEGORY'=>'','CON_PARENT'=>''); - while ($row = mysql_fetch_assoc($result)) { - if ($sw['CON_ID'] == $row['CON_ID'] && - $sw['CON_CATEGORY'] == $row['CON_CATEGORY'] && - $sw['CON_PARENT'] == $row['CON_PARENT']) { - $list[] = $row; - } else { - $this->rowsClustered++; - if (count($langs) != count($list)) { - $this->checkLanguage($list, $default); - } else { - $this->rowsUnchanged = $this->rowsUnchanged + count($langs); - } - $sw = array(); - $sw['CON_ID'] = $row['CON_ID']; - $sw['CON_CATEGORY'] = $row['CON_CATEGORY']; - $sw['CON_LANG'] = $row['CON_LANG']; - $sw['CON_PARENT'] = $row['CON_PARENT']; - unset($list); - unset($default); - $list = array(); - $default = array(); - $list[] = $row; - } - if ($sw['CON_LANG'] == $langs[$key]) { - $default = $row; - } - $this->rowsProcessed++; - } - if (count($langs) != count($list)) { - $this->checkLanguage($list, $default); - } else { - $this->rowsUnchanged = $this->rowsUnchanged + count($langs); - } - mysql_free_result($result); - $total = $this->rowsProcessed + $this->rowsInserted; - - $connection = Propel::getConnection('workflow'); - $statement = $connection->prepareStatement("INSERT INTO CONTENT + ORDER BY CON_ID, CON_CATEGORY, CON_PARENT, CON_LANG"; + + G::LoadClass( "wsTools" ); + $workSpace = new workspaceTools( $workSpace ); + $workSpace->getDBInfo(); + + $link = mysql_pconnect( $workSpace->dbHost, $workSpace->dbUser, $workSpace->dbPass ) or die( "Could not connect" ); + + mysql_select_db( $workSpace->dbName, $link ); + mysql_query( "SET NAMES 'utf8';" ); + mysql_query( 'SET OPTION SQL_BIG_SELECTS=1' ); + $result = mysql_unbuffered_query( $sql, $link ); + $list = array (); + $default = array (); + $sw = array ('CON_ID' => '','CON_CATEGORY' => '','CON_PARENT' => '' + ); + while ($row = mysql_fetch_assoc( $result )) { + if ($sw['CON_ID'] == $row['CON_ID'] && $sw['CON_CATEGORY'] == $row['CON_CATEGORY'] && $sw['CON_PARENT'] == $row['CON_PARENT']) { + $list[] = $row; + } else { + $this->rowsClustered ++; + if (count( $langs ) != count( $list )) { + $this->checkLanguage( $list, $default ); + } else { + $this->rowsUnchanged = $this->rowsUnchanged + count( $langs ); + } + $sw = array (); + $sw['CON_ID'] = $row['CON_ID']; + $sw['CON_CATEGORY'] = $row['CON_CATEGORY']; + $sw['CON_LANG'] = $row['CON_LANG']; + $sw['CON_PARENT'] = $row['CON_PARENT']; + unset( $list ); + unset( $default ); + $list = array (); + $default = array (); + $list[] = $row; + } + if ($sw['CON_LANG'] == $langs[$key]) { + $default = $row; + } + $this->rowsProcessed ++; + } + if (count( $langs ) != count( $list )) { + $this->checkLanguage( $list, $default ); + } else { + $this->rowsUnchanged = $this->rowsUnchanged + count( $langs ); + } + mysql_free_result( $result ); + $total = $this->rowsProcessed + $this->rowsInserted; + $connection = Propel::getConnection( 'workflow' ); + $statement = $connection->prepareStatement( "INSERT INTO CONTENT SELECT CON_CATEGORY, CON_PARENT, CON_ID , CON_LANG, CON_VALUE - FROM CONTENT_BACKUP"); - $statement->executeQuery(); - - $statement = $connection->prepareStatement("DROP TABLE CONTENT_BACKUP"); - $statement->executeQuery(); - - if (!isset($_SERVER['SERVER_NAME'])) { - CLI::logging("Rows Processed ---> $this->rowsProcessed ..... \n"); - CLI::logging("Rows Clustered ---> $this->rowsClustered ..... \n"); - CLI::logging("Rows Unchanged ---> $this->rowsUnchanged ..... \n"); - CLI::logging("Rows Inserted ---> $this->rowsInserted ..... \n"); - CLI::logging("Rows Total ---> $total ..... \n"); - } - } - - function checkLanguage($content, $default) - { - if (count($content)>0) { - $langs = $this->langs; - $langsAsoc = $this->langsAsoc; + FROM CONTENT_BACKUP" ); + $statement->executeQuery(); + + $statement = $connection->prepareStatement( "DROP TABLE CONTENT_BACKUP" ); + $statement->executeQuery(); + + if (! isset( $_SERVER['SERVER_NAME'] )) { + CLI::logging( "Rows Processed ---> $this->rowsProcessed ..... \n" ); + CLI::logging( "Rows Clustered ---> $this->rowsClustered ..... \n" ); + CLI::logging( "Rows Unchanged ---> $this->rowsUnchanged ..... \n" ); + CLI::logging( "Rows Inserted ---> $this->rowsInserted ..... \n" ); + CLI::logging( "Rows Total ---> $total ..... \n" ); + } + } + + public function checkLanguage ($content, $default) + { + if (count( $content ) > 0) { + $langs = $this->langs; + $langsAsoc = $this->langsAsoc; //Element default - $default = (count($default)>0) ? $default : $content[0]; - foreach ($content as $key => $value) { - unset($langsAsoc[$value['CON_LANG']]); - } - foreach ($langsAsoc as $key => $value) { - $this->rowsInserted++; - $this->fastInsertContent( - $default['CON_CATEGORY'], - $default['CON_PARENT'], - $default['CON_ID'], - $value, - $default['CON_VALUE'] - ); - } - } - } - - function fastInsertContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) { - $ConValue = mysql_real_escape_string($ConValue); - $connection = Propel::getConnection('workflow'); - $statement = $connection->prepareStatement("INSERT INTO CONTENT_BACKUP ( + $default = (count( $default ) > 0) ? $default : $content[0]; + foreach ($content as $key => $value) { + unset( $langsAsoc[$value['CON_LANG']] ); + } + foreach ($langsAsoc as $key => $value) { + $this->rowsInserted ++; + $this->fastInsertContent( $default['CON_CATEGORY'], $default['CON_PARENT'], $default['CON_ID'], $value, $default['CON_VALUE'] ); + } + } + } + + public function fastInsertContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) + { + $ConValue = mysql_real_escape_string( $ConValue ); + $connection = Propel::getConnection( 'workflow' ); + $statement = $connection->prepareStatement( "INSERT INTO CONTENT_BACKUP ( CON_CATEGORY, CON_PARENT, CON_ID , CON_LANG, CON_VALUE) - VALUES ('$ConCategory', '$ConParent', '$ConId', '$ConLang', '$ConValue');"); - $statement->executeQuery(); - } - - function removeLanguageContent($lanId) { - try { - $c = new Criteria ( ); - $c->addSelectColumn(ContentPeer::CON_CATEGORY); - $c->addSelectColumn(ContentPeer::CON_PARENT); - $c->addSelectColumn(ContentPeer::CON_ID); - $c->addSelectColumn(ContentPeer::CON_LANG); - - $c->add ( ContentPeer::CON_LANG, $lanId ); - - $result = ContentPeer::doSelectRS ( $c ); - $result->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $result->next (); - $row = $result->getRow (); - - while ( is_array ( $row ) ) { - $content = ContentPeer::retrieveByPK( $row['CON_CATEGORY'], $row['CON_PARENT'], $row['CON_ID'], $lanId); - - if( $content !== null ) - $content->delete(); - - $result->next (); - $row = $result->getRow (); - } - - } catch ( Exception $e ) { - throw ($e); - } - } - //Added by Enrique at Feb 9th,2011 - //Gets all Role Names by Role - function getAllContentsByRole($sys_lang=SYS_LANG){ - if (!isset($sys_lang)) $sys_lang = 'en'; - $oCriteria = new Criteria('workflow'); - $oCriteria->clearSelectColumns(); - $oCriteria->addSelectColumn(ContentPeer::CON_ID); - $oCriteria->addAsColumn('ROL_NAME', ContentPeer::CON_VALUE); - //$oCriteria->addAsColumn('ROL_UID', ContentPeer::CON_ID); - $oCriteria->add(ContentPeer::CON_CATEGORY,'ROL_NAME'); - $oCriteria->add(ContentPeer::CON_LANG, $sys_lang); - $oDataset = ContentPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $aRoles = Array(); - while ($oDataset->next()){ - $xRow = $oDataset->getRow(); - $aRoles[$xRow['CON_ID']] = $xRow['ROL_NAME']; - } - return $aRoles; - } - -} // Content + VALUES ('$ConCategory', '$ConParent', '$ConId', '$ConLang', '$ConValue');" ); + $statement->executeQuery(); + } + + public function removeLanguageContent ($lanId) + { + try { + $c = new Criteria(); + $c->addSelectColumn( ContentPeer::CON_CATEGORY ); + $c->addSelectColumn( ContentPeer::CON_PARENT ); + $c->addSelectColumn( ContentPeer::CON_ID ); + $c->addSelectColumn( ContentPeer::CON_LANG ); + + $c->add( ContentPeer::CON_LANG, $lanId ); + + $result = ContentPeer::doSelectRS( $c ); + $result->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $result->next(); + $row = $result->getRow(); + + while (is_array( $row )) { + $content = ContentPeer::retrieveByPK( $row['CON_CATEGORY'], $row['CON_PARENT'], $row['CON_ID'], $lanId ); + + if ($content !== null) { + $content->delete(); + } + $result->next(); + $row = $result->getRow(); + } + + } catch (Exception $e) { + throw ($e); + } + } + //Added by Enrique at Feb 9th,2011 + //Gets all Role Names by Role + public function getAllContentsByRole ($sys_lang = SYS_LANG) + { + if (! isset( $sys_lang )) { + $sys_lang = 'en'; + } + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->clearSelectColumns(); + $oCriteria->addSelectColumn( ContentPeer::CON_ID ); + $oCriteria->addAsColumn( 'ROL_NAME', ContentPeer::CON_VALUE ); + //$oCriteria->addAsColumn('ROL_UID', ContentPeer::CON_ID); + $oCriteria->add( ContentPeer::CON_CATEGORY, 'ROL_NAME' ); + $oCriteria->add( ContentPeer::CON_LANG, $sys_lang ); + $oDataset = ContentPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $aRoles = Array (); + while ($oDataset->next()) { + $xRow = $oDataset->getRow(); + $aRoles[$xRow['CON_ID']] = $xRow['ROL_NAME']; + } + return $aRoles; + } +} +// Content + diff --git a/workflow/engine/classes/model/Translation.php b/workflow/engine/classes/model/Translation.php index 5a50c1b04..154df7f0c 100755 --- a/workflow/engine/classes/model/Translation.php +++ b/workflow/engine/classes/model/Translation.php @@ -1,461 +1,455 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -require_once 'classes/model/om/BaseTranslation.php'; - - -/** - * Skeleton subclass for representing a row from the 'TRANSLATION' table. - * - * - * - * You should add additional methods to this class to meet the - * application requirements. This class will only be generated as - * long as it does not already exist in the output directory. - * - * @package workflow.engine.classes.model - */ -class Translation extends BaseTranslation { - - public static $meta; - public static $localeSeparator = '-'; - - private $envFilePath; - - function __construct(){ - $this->envFilePath = PATH_DATA . "META-INF" . PATH_SEP . "translations.env"; - } - - function getAllCriteria(){ - - //SELECT * from TRANSLATION WHERE TRN_LANG = 'en' order by TRN_CATEGORY, TRN_ID - $oCriteria = new Criteria('workflow'); - $oCriteria->addSelectColumn(TranslationPeer::TRN_ID); - $oCriteria->addSelectColumn(TranslationPeer::TRN_CATEGORY); - $oCriteria->addSelectColumn(TranslationPeer::TRN_LANG); - $oCriteria->addSelectColumn(TranslationPeer::TRN_VALUE); - //$c->add(TranslationPeer::TRN_LANG, 'en'); - - return $oCriteria; - } - - function getAll($lang='en', $start=null, $limit=null, $search=null, $dateFrom=null, $dateTo=null){ - $totalCount = 0; - - $oCriteria = new Criteria('workflow'); - $oCriteria->addSelectColumn(TranslationPeer::TRN_ID); - $oCriteria->addSelectColumn(TranslationPeer::TRN_CATEGORY); - $oCriteria->addSelectColumn(TranslationPeer::TRN_LANG); - $oCriteria->addSelectColumn(TranslationPeer::TRN_VALUE); - $oCriteria->addSelectColumn(TranslationPeer::TRN_UPDATE_DATE); - $oCriteria->add(TranslationPeer::TRN_LANG, $lang); - $oCriteria->add(TranslationPeer::TRN_CATEGORY, 'LABEL'); - //$oCriteria->addAscendingOrderByColumn ( 'TRN_CATEGORY' ); - $oCriteria->addAscendingOrderByColumn ( 'TRN_ID' ); - - - if( $search ) { - $oCriteria->add( - $oCriteria->getNewCriterion( - TranslationPeer::TRN_ID, - "%$search%", Criteria::LIKE - )->addOr($oCriteria->getNewCriterion( - TranslationPeer::TRN_VALUE, - "%$search%", Criteria::LIKE - )) - ); - } - // for date filter - if( ($dateFrom)&&($dateTo) ) { - $oCriteria->add( - $oCriteria->getNewCriterion( - TranslationPeer::TRN_UPDATE_DATE, - "$dateFrom", Criteria::GREATER_EQUAL//LESS_EQUAL - )->addAnd($oCriteria->getNewCriterion( - TranslationPeer::TRN_UPDATE_DATE, - "$dateTo", Criteria::LESS_EQUAL//GREATER_EQUAL - )) - ); - } - // end filter - $c = clone $oCriteria; - $c->clearSelectColumns(); - $c->addSelectColumn('COUNT(*)'); - $oDataset = TranslationPeer::doSelectRS($c); - $oDataset->next(); - $aRow = $oDataset->getRow(); - - if( is_array($aRow) ) - $totalCount = $aRow[0]; - - if($start) - $oCriteria->setOffset($start); - if($limit) //&& !isset($seach) && !isset($search)) - $oCriteria->setLimit($limit); - - $rs = TranslationPeer::doSelectRS($oCriteria); - $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $rows = Array(); - while( $rs->next() ) { - $rows[] = $rs->getRow(); - } - - $result->data = $rows; - $result->totalCount = $totalCount; - - return $result; - } - - - /* Load strings from a Database . +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + */ + +require_once 'classes/model/om/BaseTranslation.php'; + +/** + * Skeleton subclass for representing a row from the 'TRANSLATION' table. + * + * + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + * + * @package workflow.engine.classes.model + */ +class Translation extends BaseTranslation +{ + + public static $meta; + public static $localeSeparator = '-'; + + private $envFilePath; + + public function __construct () + { + $this->envFilePath = PATH_DATA . "META-INF" . PATH_SEP . "translations.env"; + } + + public function getAllCriteria () + { + + //SELECT * from TRANSLATION WHERE TRN_LANG = 'en' order by TRN_CATEGORY, TRN_ID + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->addSelectColumn( TranslationPeer::TRN_ID ); + $oCriteria->addSelectColumn( TranslationPeer::TRN_CATEGORY ); + $oCriteria->addSelectColumn( TranslationPeer::TRN_LANG ); + $oCriteria->addSelectColumn( TranslationPeer::TRN_VALUE ); + //$c->add(TranslationPeer::TRN_LANG, 'en'); + + + return $oCriteria; + } + + public function getAll ($lang = 'en', $start = null, $limit = null, $search = null, $dateFrom = null, $dateTo = null) + { + $totalCount = 0; + + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->addSelectColumn( TranslationPeer::TRN_ID ); + $oCriteria->addSelectColumn( TranslationPeer::TRN_CATEGORY ); + $oCriteria->addSelectColumn( TranslationPeer::TRN_LANG ); + $oCriteria->addSelectColumn( TranslationPeer::TRN_VALUE ); + $oCriteria->addSelectColumn( TranslationPeer::TRN_UPDATE_DATE ); + $oCriteria->add( TranslationPeer::TRN_LANG, $lang ); + $oCriteria->add( TranslationPeer::TRN_CATEGORY, 'LABEL' ); + //$oCriteria->addAscendingOrderByColumn ( 'TRN_CATEGORY' ); + $oCriteria->addAscendingOrderByColumn( 'TRN_ID' ); + + if ($search) { + $oCriteria->add( $oCriteria->getNewCriterion( TranslationPeer::TRN_ID, "%$search%", Criteria::LIKE )->addOr( $oCriteria->getNewCriterion( TranslationPeer::TRN_VALUE, "%$search%", Criteria::LIKE ) ) ); + } + // for date filter + if (($dateFrom) && ($dateTo)) { + $oCriteria->add( $oCriteria->getNewCriterion( TranslationPeer::TRN_UPDATE_DATE, "$dateFrom", Criteria::GREATER_EQUAL ) //LESS_EQUAL +->addAnd( $oCriteria->getNewCriterion( TranslationPeer::TRN_UPDATE_DATE, "$dateTo", Criteria::LESS_EQUAL ) //GREATER_EQUAL + ) ); + } + // end filter + $c = clone $oCriteria; + $c->clearSelectColumns(); + $c->addSelectColumn( 'COUNT(*)' ); + $oDataset = TranslationPeer::doSelectRS( $c ); + $oDataset->next(); + $aRow = $oDataset->getRow(); + + if (is_array( $aRow )) { + $totalCount = $aRow[0]; + } + if ($start) { + $oCriteria->setOffset( $start ); + } + if ($limit) { + //&& !isset($seach) && !isset($search)) + $oCriteria->setLimit( $limit ); + } + $rs = TranslationPeer::doSelectRS( $oCriteria ); + $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $rows = Array (); + while ($rs->next()) { + $rows[] = $rs->getRow(); + } + + $result->data = $rows; + $result->totalCount = $totalCount; + + return $result; + } + + /* Load strings from a Database . * @author Fernando Ontiveros * @parameter $languageId (es|en|...). - */ - - function generateFileTranslation ($languageId = '') { - $translation = Array(); - $translationJS = Array(); - - if ($languageId === '') - $languageId = defined('SYS_LANG') ? SYS_LANG : 'en'; - - $c = new Criteria(); - $c->add(TranslationPeer::TRN_LANG, $languageId ); - $c->addAscendingOrderByColumn ( 'TRN_CATEGORY' ); - $c->addAscendingOrderByColumn ( 'TRN_ID' ); - $tranlations = TranslationPeer::doSelect($c); - - $cacheFile = PATH_LANGUAGECONT . "translation." . $languageId; - $cacheFileJS = PATH_CORE . 'js' . PATH_SEP . 'labels' . PATH_SEP . $languageId.".js"; - - foreach ( $tranlations as $key => $row ) { - if ( $row->getTrnCategory() === 'LABEL' ) { - $translation[ $row->getTrnId() ] = $row->getTrnValue(); - } - if ( $row->getTrnCategory() === 'JAVASCRIPT') { - $translationJS[ $row->getTrnId() ] = $row->getTrnValue(); - } - } - - try { - - if( ! is_dir(dirname($cacheFile)) ) - G::mk_dir(dirname($cacheFile)); - - if( ! is_dir(dirname($cacheFileJS)) ) - G::mk_dir(dirname($cacheFileJS)); - - $f = fopen( $cacheFile , 'w+'); - fwrite( $f , "" ); - fclose( $f ); - - $json=new Services_JSON(); - - $f = fopen( $cacheFileJS , 'w'); - fwrite( $f , "var G_STRINGS =". $json->encode( $translationJS ) . ";\n"); - fclose( $f ); - - $res['cacheFile'] = $cacheFile; - $res['cacheFileJS'] = $cacheFileJS; - $res['rows'] = count ( $translation ); - $res['rowsJS'] = count ( $translationJS ); - return $res; - } catch( Exception $e ) { - echo $e->getMessage(); - } - } - - /** - * returns an array with - * codError 0 - no error, < 0 error - * rowsAffected 0,1 the number of rows affected - * message message error. - */ - function addTranslation ( $category, $id, $languageId, $value ) { - //if exists the row in the database propel will update it, otherwise will insert. - $tr = TranslationPeer::retrieveByPK( $category, $id, $languageId ); - if ( ! ( is_object ( $tr ) && get_class ($tr) == 'Translation' ) ) { - $tr = new Translation(); - } - $tr->setTrnCategory( $category ); - $tr->setTrnId( $id ); - $tr->setTrnLang( $languageId); - $tr->setTrnValue( $value ); - $tr->setTrnUpdateDate( date('Y-m-d') ); - - if ($tr->validate() ) { - // we save it, since we get no validation errors, or do whatever else you like. - $res = $tr->save(); - } - else { - // Something went wrong. We can now get the validationFailures and handle them. - $msg = ''; - $validationFailuresArray = $tr->getValidationFailures(); - foreach($validationFailuresArray as $objValidationFailure) { - $msg .= $objValidationFailure->getMessage() . "\n"; - } - return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); - } - return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => ''); - //to do: uniform coderror structures for all classes - } - - function remove($sCategory, $sId, $sLang) { - $oTranslation = TranslationPeer::retrieveByPK($sCategory, $sId, $sLang); - if ( ( is_object ( $oTranslation ) && get_class ($oTranslation) == 'Translation' ) ) { - $oTranslation->delete(); - } - } - - function addTranslationEnvironment($locale, $headers, $numRecords) - { - $filePath = $this->envFilePath; - $environments = Array(); - - if( file_exists($filePath) ) { - $environments = unserialize(file_get_contents($filePath)); - } - - $environment['LOCALE'] = $locale; - $environment['HEADERS'] = $headers; - $environment['DATE'] = date('Y-m-d H:i:s'); - $environment['NUM_RECORDS'] = $numRecords; - $environment['LANGUAGE'] = $headers['X-Poedit-Language']; - $environment['COUNTRY'] = $headers['X-Poedit-Country']; - - if( strpos($locale, self::$localeSeparator) !== false ) { - list($environment['LAN_ID'], $environment['IC_UID']) = explode(self::$localeSeparator, strtoupper($locale)); - $environments[$environment['LAN_ID']][$environment['IC_UID']] = $environment; - } else { - $environment['LAN_ID'] = strtoupper($locale); - $environment['IC_UID'] = ''; - $environments[$locale]['__INTERNATIONAL__'] = $environment; - } - - - file_put_contents($filePath, serialize($environments)); - } - - function removeTranslationEnvironment($locale) - { - $filePath = $this->envFilePath; - if (strpos($locale, self::$localeSeparator) !== false) { - list($LAN_ID, $IC_UID) = explode('-', strtoupper($locale)); - } else { - $LAN_ID = $locale; - $IC_UID = '__INTERNATIONAL__'; + */ + + public function generateFileTranslation ($languageId = '') + { + $translation = Array (); + $translationJS = Array (); + + if ($languageId === '') { + $languageId = defined( 'SYS_LANG' ) ? SYS_LANG : 'en'; + } + $c = new Criteria(); + $c->add( TranslationPeer::TRN_LANG, $languageId ); + $c->addAscendingOrderByColumn( 'TRN_CATEGORY' ); + $c->addAscendingOrderByColumn( 'TRN_ID' ); + $tranlations = TranslationPeer::doSelect( $c ); + + $cacheFile = PATH_LANGUAGECONT . "translation." . $languageId; + $cacheFileJS = PATH_CORE . 'js' . PATH_SEP . 'labels' . PATH_SEP . $languageId . ".js"; + + foreach ($tranlations as $key => $row) { + if ($row->getTrnCategory() === 'LABEL') { + $translation[$row->getTrnId()] = $row->getTrnValue(); + } + if ($row->getTrnCategory() === 'JAVASCRIPT') { + $translationJS[$row->getTrnId()] = $row->getTrnValue(); + } + } + + try { + + if (! is_dir( dirname( $cacheFile ) )) { + G::mk_dir( dirname( $cacheFile ) ); + } + if (! is_dir( dirname( $cacheFileJS ) )) { + G::mk_dir( dirname( $cacheFileJS ) ); + } + $f = fopen( $cacheFile, 'w+' ); + fwrite( $f, "" ); + fclose( $f ); + + $json = new Services_JSON(); + + $f = fopen( $cacheFileJS, 'w' ); + fwrite( $f, "var G_STRINGS =" . $json->encode( $translationJS ) . ";\n" ); + fclose( $f ); + + $res['cacheFile'] = $cacheFile; + $res['cacheFileJS'] = $cacheFileJS; + $res['rows'] = count( $translation ); + $res['rowsJS'] = count( $translationJS ); + return $res; + } catch (Exception $e) { + echo $e->getMessage(); + } + } + + /** + * returns an array with + * codError 0 - no error, < 0 error + * rowsAffected 0,1 the number of rows affected + * message message error. + */ + public function addTranslation ($category, $id, $languageId, $value) + { + //if exists the row in the database propel will update it, otherwise will insert. + $tr = TranslationPeer::retrieveByPK( $category, $id, $languageId ); + if (! (is_object( $tr ) && get_class( $tr ) == 'Translation')) { + $tr = new Translation(); + } + $tr->setTrnCategory( $category ); + $tr->setTrnId( $id ); + $tr->setTrnLang( $languageId ); + $tr->setTrnValue( $value ); + $tr->setTrnUpdateDate( date( 'Y-m-d' ) ); + + if ($tr->validate()) { + // we save it, since we get no validation errors, or do whatever else you like. + $res = $tr->save(); + } else { + // Something went wrong. We can now get the validationFailures and handle them. + $msg = ''; + $validationFailuresArray = $tr->getValidationFailures(); + foreach ($validationFailuresArray as $objValidationFailure) { + $msg .= $objValidationFailure->getMessage() . "\n"; + } + return array ('codError' => - 100,'rowsAffected' => 0,'message' => $msg); + } + return array ('codError' => 0,'rowsAffected' => $res,'message' => ''); + //to do: uniform coderror structures for all classes + } + + public function remove ($sCategory, $sId, $sLang) + { + $oTranslation = TranslationPeer::retrieveByPK( $sCategory, $sId, $sLang ); + if ((is_object( $oTranslation ) && get_class( $oTranslation ) == 'Translation')) { + $oTranslation->delete(); + } + } + + public function addTranslationEnvironment ($locale, $headers, $numRecords) + { + $filePath = $this->envFilePath; + $environments = Array (); + + if (file_exists( $filePath )) { + $environments = unserialize( file_get_contents( $filePath ) ); + } + + $environment['LOCALE'] = $locale; + $environment['HEADERS'] = $headers; + $environment['DATE'] = date( 'Y-m-d H:i:s' ); + $environment['NUM_RECORDS'] = $numRecords; + $environment['LANGUAGE'] = $headers['X-Poedit-Language']; + $environment['COUNTRY'] = $headers['X-Poedit-Country']; + + if (strpos( $locale, self::$localeSeparator ) !== false) { + list ($environment['LAN_ID'], $environment['IC_UID']) = explode( self::$localeSeparator, strtoupper( $locale ) ); + $environments[$environment['LAN_ID']][$environment['IC_UID']] = $environment; + } else { + $environment['LAN_ID'] = strtoupper( $locale ); + $environment['IC_UID'] = ''; + $environments[$locale]['__INTERNATIONAL__'] = $environment; + } + + file_put_contents( $filePath, serialize( $environments ) ); + } + + public function removeTranslationEnvironment ($locale) + { + $filePath = $this->envFilePath; + if (strpos( $locale, self::$localeSeparator ) !== false) { + list ($LAN_ID, $IC_UID) = explode( '-', strtoupper( $locale ) ); + } else { + $LAN_ID = $locale; + $IC_UID = '__INTERNATIONAL__'; + } + + if (file_exists( $filePath )) { + $environments = unserialize( file_get_contents( $filePath ) ); + if (! isset( $environments[$LAN_ID][$IC_UID] )) { + return null; + } + + unset( $environments[$LAN_ID][$IC_UID] ); + file_put_contents( $filePath, serialize( $environments ) ); + + if (file_exists( PATH_CORE . "META-INF" . PATH_SEP . "translation." . $locale )) { + G::rm_dir( PATH_DATA . "META-INF" . PATH_SEP . "translation." . $locale ); + } + if (file_exists( PATH_CORE . PATH_SEP . 'content' . PATH_SEP . 'translations' . PATH_SEP . 'processmaker' . $locale . '.po' )) { + G::rm_dir( PATH_CORE . PATH_SEP . 'content' . PATH_SEP . 'translations' . PATH_SEP . 'processmaker' . $locale . '.po' ); + } + } + } + + public function getTranslationEnvironments () + { + $filePath = $this->envFilePath; + $envs = Array (); + + if (! file_exists( $filePath )) { + //the transaltions table file doesn't exist, then build it + + + if (! is_dir( dirname( $this->envFilePath ) )) { + G::mk_dir( dirname( $this->envFilePath ) ); + } + $translationsPath = PATH_CORE . "content" . PATH_SEP . 'translations' . PATH_SEP; + $basePOFile = $translationsPath . 'english' . PATH_SEP . 'processmaker.en.po'; + + $params = self::getInfoFromPOFile( $basePOFile ); + $this->addTranslationEnvironment( $params['LOCALE'], $params['HEADERS'], $params['COUNT'] ); + //getting more lanuguage translations + $files = glob( $translationsPath . "*.po" ); + foreach ($files as $file) { + $params = self::getInfoFromPOFile( $file ); + $this->addTranslationEnvironment( $params['LOCALE'], $params['HEADERS'], $params['COUNT'] ); + } + } + $envs = unserialize( file_get_contents( $filePath ) ); + + $environments = Array (); + foreach ($envs as $LAN_ID => $rec1) { + foreach ($rec1 as $IC_UID => $rec2) { + $environments[] = $rec2; + } + } + + return $environments; + + /* + G::LoadSystem('dbMaintenance'); + $o = new DataBaseMaintenance('localhost', 'root', 'atopml2005'); + $o->connect('wf_os'); + $r = $o->query('select * from ISO_COUNTRY'); + foreach ($r as $i=>$v) { + $r[$i]['IC_NAME'] = utf8_encode($r[$i]['IC_NAME']); + unset($r[$i]['IC_SORT_ORDER']); + } + $r1 = $o->query('select * from LANGUAGE'); + $r2 = Array(); + foreach ($r1 as $i=>$v) { + $r2[$i]['LAN_NAME'] = utf8_encode($r1[$i]['LAN_NAME']); + $r2[$i]['LAN_ID'] = utf8_encode($r1[$i]['LAN_ID']); } - - if (file_exists($filePath)) { - $environments = unserialize(file_get_contents($filePath)); - if (!isset($environments[$LAN_ID][$IC_UID])) { - return NULL; - } - - unset($environments[$LAN_ID][$IC_UID]); - file_put_contents($filePath, serialize($environments)); - - if (file_exists(PATH_CORE . "META-INF" . PATH_SEP . "translation.".$locale)) { - G::rm_dir(PATH_DATA . "META-INF" . PATH_SEP . "translation.".$locale); - } - if (file_exists(PATH_CORE . PATH_SEP . 'content' . PATH_SEP . 'translations' . PATH_SEP . 'processmaker' . $locale . '.po')) { - G::rm_dir(PATH_CORE . PATH_SEP . 'content' . PATH_SEP . 'translations' . PATH_SEP . 'processmaker' . $locale . '.po'); - } - } - } - - function getTranslationEnvironments(){ - $filePath = $this->envFilePath; - $envs = Array(); - - if( ! file_exists($filePath) ) { - //the transaltions table file doesn't exist, then build it - - if( ! is_dir(dirname($this->envFilePath)) ) - G::mk_dir(dirname($this->envFilePath)); - - $translationsPath = PATH_CORE . "content" . PATH_SEP . 'translations' . PATH_SEP; - $basePOFile = $translationsPath . 'english' . PATH_SEP . 'processmaker.en.po'; - - $params = self::getInfoFromPOFile($basePOFile); - $this->addTranslationEnvironment($params['LOCALE'], $params['HEADERS'], $params['COUNT']); - - //getting more lanuguage translations - $files = glob($translationsPath . "*.po"); - foreach( $files as $file ){ - $params = self::getInfoFromPOFile($file); - $this->addTranslationEnvironment($params['LOCALE'], $params['HEADERS'], $params['COUNT']); - } - } - $envs = unserialize(file_get_contents($filePath)); - - $environments = Array(); - foreach($envs as $LAN_ID => $rec1 ){ - foreach($rec1 as $IC_UID => $rec2 ){ - $environments[] = $rec2; - } - } - - return $environments; - - /*G::LoadSystem('dbMaintenance'); - $o = new DataBaseMaintenance('localhost', 'root', 'atopml2005'); - $o->connect('wf_os'); - $r = $o->query('select * from ISO_COUNTRY'); - foreach($r as $i=>$v){ - $r[$i]['IC_NAME'] = utf8_encode($r[$i]['IC_NAME']); - unset($r[$i]['IC_SORT_ORDER']); - } - $r1 = $o->query('select * from LANGUAGE'); - $r2 = Array(); - foreach($r1 as $i=>$v){ - $r2[$i]['LAN_NAME'] = utf8_encode($r1[$i]['LAN_NAME']); - $r2[$i]['LAN_ID'] = utf8_encode($r1[$i]['LAN_ID']); - } - $s = Array('ISO_COUNTRY'=>$r, 'LANGUAGE'=>$r2); - file_put_contents($translationsPath . 'pmos-translations.meta', serialize($s)); - */ - } - - function getInfoFromPOFile($file){ - G::loadClass('i18n_po'); - $POFile = new i18n_PO($file); - $POFile->readInit(); - $POHeaders = $POFile->getHeaders(); - - if( $POHeaders['X-Poedit-Country'] != '.' ) { - $country = self::getTranslationMetaByCountryName($POHeaders['X-Poedit-Country']); - } else { - $country = '.'; - } - $language = self::getTranslationMetaByLanguageName($POHeaders['X-Poedit-Language']); - - if( $language !== false ) { - if( $country !== false ) { - if( $country != '.') { - $LOCALE = $language['LAN_ID'] . '-' . $country['IC_UID']; - } else if( $country == '.' ) { - //this a trsnlation file with a language international, no country name was set - $LOCALE = $language['LAN_ID']; - } else - throw new Exception('PO File Error: "'.$file.'" has a invalid country definition!'); - } else - throw new Exception('PO File Error: "'.$file.'" has a invalid country definition!'); - } else - throw new Exception('PO File Error: "'.$file.'" has a invalid language definition!'); - - $countItems = 0; - try { - while( $rowTranslation = $POFile->getTranslation() ) { - $countItems++; - } - } catch(Exception $e) { - $countItems = '-'; - } - - return Array('LOCALE'=>$LOCALE, 'HEADERS'=>$POHeaders , 'COUNT'=>$countItems); - } - - function getTranslationEnvironment($locale){ - $filePath = $this->envFilePath; - $environments = Array(); - - if( ! file_exists($filePath) ) { - throw new Exception("The file $filePath doesn't exist"); - } - - $environments = unserialize(file_get_contents($filePath)); - if( strpos($locale, self::$localeSeparator) !== false ) { - list($LAN_ID, $IC_UID) = explode(self::localeSeparator, strtoupper($locale)); - } else { - $LAN_ID = $locale; - $IC_UID = '__INTERNATIONAL__'; - } - - if( isset($environments[$LAN_ID][$IC_UID]) ) - return $environments[$LAN_ID][$IC_UID]; - else - return false; - } - - function saveTranslationEnvironment($locale, $data){ - $filePath = $this->envFilePath; - $environments = Array(); - - if( ! file_exists($filePath) ) { - throw new Exception("The file $filePath doesn't exist"); - } - - $environments = unserialize(file_get_contents($filePath)); - if( strpos($locale, self::$localeSeparator) !== false ) { - list($LAN_ID, $IC_UID) = explode(self::localeSeparator, strtoupper($locale)); - } else { - $LAN_ID = $locale; - $IC_UID = '__INTERNATIONAL__'; - } - - $environments[$LAN_ID][$IC_UID] = $data; - file_put_contents($filePath, serialize($environments)); - } - - function getTranslationMeta(){ - $translationsPath = PATH_CORE . "content" . PATH_SEP . 'translations' . PATH_SEP; - $translationsTable = unserialize(file_get_contents($translationsPath . 'pmos-translations.meta')); - return $translationsTable; - } - - function getTranslationMetaByCountryName($IC_NAME){ - $translationsTable = self::getTranslationMeta(); - - foreach ($translationsTable['ISO_COUNTRY'] as $row) { - if( $row['IC_NAME'] == $IC_NAME ) - return $row; - } - return false; - } - - function getTranslationMetaByLanguageName($LAN_NAME){ - $translationsTable = self::getTranslationMeta(); - - foreach ($translationsTable['LANGUAGE'] as $row) { - if( $row['LAN_NAME'] == $LAN_NAME ) - return $row; - } - return false; - } -} // Translation - - - - - - - - - - + $s = Array('ISO_COUNTRY'=>$r, 'LANGUAGE'=>$r2); + file_put_contents($translationsPath . 'pmos-translations.meta', serialize($s)); + */ + } + + public function getInfoFromPOFile ($file) + { + G::loadClass( 'i18n_po' ); + $POFile = new i18n_PO( $file ); + $POFile->readInit(); + $POHeaders = $POFile->getHeaders(); + + if ($POHeaders['X-Poedit-Country'] != '.') { + $country = self::getTranslationMetaByCountryName( $POHeaders['X-Poedit-Country'] ); + } else { + $country = '.'; + } + $language = self::getTranslationMetaByLanguageName( $POHeaders['X-Poedit-Language'] ); + + if ($language !== false) { + if ($country !== false) { + if ($country != '.') { + $LOCALE = $language['LAN_ID'] . '-' . $country['IC_UID']; + } else if ($country == '.') { + //this a trsnlation file with a language international, no country name was set + $LOCALE = $language['LAN_ID']; + } else + throw new Exception( 'PO File Error: "' . $file . '" has a invalid country definition!' ); + } else + throw new Exception( 'PO File Error: "' . $file . '" has a invalid country definition!' ); + } else + throw new Exception( 'PO File Error: "' . $file . '" has a invalid language definition!' ); + + $countItems = 0; + try { + while ($rowTranslation = $POFile->getTranslation()) { + $countItems ++; + } + } catch (Exception $e) { + $countItems = '-'; + } + return Array ('LOCALE' => $LOCALE,'HEADERS' => $POHeaders,'COUNT' => $countItems); + } + + public function getTranslationEnvironment ($locale) + { + $filePath = $this->envFilePath; + $environments = Array (); + + if (! file_exists( $filePath )) { + throw new Exception( "The file $filePath doesn't exist" ); + } + + $environments = unserialize( file_get_contents( $filePath ) ); + if (strpos( $locale, self::$localeSeparator ) !== false) { + list ($LAN_ID, $IC_UID) = explode( self::localeSeparator, strtoupper( $locale ) ); + } else { + $LAN_ID = $locale; + $IC_UID = '__INTERNATIONAL__'; + } + + if (isset( $environments[$LAN_ID][$IC_UID] )) { + return $environments[$LAN_ID][$IC_UID]; + } else { + return false; + } + } + + public function saveTranslationEnvironment ($locale, $data) + { + $filePath = $this->envFilePath; + $environments = Array (); + + if (! file_exists( $filePath )) { + throw new Exception( "The file $filePath doesn't exist" ); + } + + $environments = unserialize( file_get_contents( $filePath ) ); + if (strpos( $locale, self::$localeSeparator ) !== false) { + list ($LAN_ID, $IC_UID) = explode( self::localeSeparator, strtoupper( $locale ) ); + } else { + $LAN_ID = $locale; + $IC_UID = '__INTERNATIONAL__'; + } + + $environments[$LAN_ID][$IC_UID] = $data; + file_put_contents( $filePath, serialize( $environments ) ); + } + + public function getTranslationMeta () + { + $translationsPath = PATH_CORE . "content" . PATH_SEP . 'translations' . PATH_SEP; + $translationsTable = unserialize( file_get_contents( $translationsPath . 'pmos-translations.meta' ) ); + return $translationsTable; + } + + public function getTranslationMetaByCountryName ($IC_NAME) + { + $translationsTable = self::getTranslationMeta(); + + foreach ($translationsTable['ISO_COUNTRY'] as $row) { + if ($row['IC_NAME'] == $IC_NAME) { + return $row; + } + } + return false; + } + + public function getTranslationMetaByLanguageName ($LAN_NAME) + { + $translationsTable = self::getTranslationMeta(); + + foreach ($translationsTable['LANGUAGE'] as $row) { + if ($row['LAN_NAME'] == $LAN_NAME) { + return $row; + } + } + return false; + } +} +// Translation + From 4a4321615f461999178437b22c140ab1180316cd Mon Sep 17 00:00:00 2001 From: Ralph Asendeteufrer Date: Fri, 19 Oct 2012 14:38:15 -0400 Subject: [PATCH 2/4] CODE STYLE changes files modified: workflow/engine/methods/cases/cases_Ajax.php workflow/engine/methods/cases/cases_CatchExecute.php workflow/engine/methods/cases/cases_CatchSelfService.php workflow/engine/methods/cases/cases_Delete.php workflow/engine/methods/cases/cases_DeleteDocument.php workflow/engine/methods/cases/cases_DeleteDocumentToRevise.php workflow/engine/methods/cases/cases_Derivate.php workflow/engine/methods/cases/cases_List.php workflow/engine/methods/cases/cases_New.php workflow/engine/methods/cases/cases_NextStep.php workflow/engine/methods/cases/cases_Open.php workflow/engine/methods/cases/cases_OpenToRevise.php workflow/engine/methods/cases/cases_PrintView.php workflow/engine/methods/cases/cases_generatePMTable.php --- workflow/engine/methods/cases/cases_Ajax.php | 1736 ++++++++--------- .../methods/cases/cases_CatchExecute.php | 126 +- .../methods/cases/cases_CatchSelfService.php | 176 +- .../engine/methods/cases/cases_Delete.php | 112 +- .../methods/cases/cases_DeleteDocument.php | 112 +- .../cases/cases_DeleteDocumentToRevise.php | 94 +- .../engine/methods/cases/cases_Derivate.php | 324 +-- workflow/engine/methods/cases/cases_List.php | 305 +-- workflow/engine/methods/cases/cases_New.php | 306 +-- .../engine/methods/cases/cases_NextStep.php | 63 +- workflow/engine/methods/cases/cases_Open.php | 401 ++-- .../methods/cases/cases_OpenToRevise.php | 149 +- .../engine/methods/cases/cases_PrintView.php | 190 +- .../methods/cases/cases_generatePMTable.php | 176 +- 14 files changed, 2140 insertions(+), 2130 deletions(-) diff --git a/workflow/engine/methods/cases/cases_Ajax.php b/workflow/engine/methods/cases/cases_Ajax.php index 00df8bf7f..49b6b6cb0 100755 --- a/workflow/engine/methods/cases/cases_Ajax.php +++ b/workflow/engine/methods/cases/cases_Ajax.php @@ -1,89 +1,89 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ - -G::LoadClass( 'case' ); -$oCase = new Cases(); - +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ + +G::LoadClass( 'case' ); +$oCase = new Cases(); + //if($RBAC->userCanAccess('PM_ALLCASES') < 0) { // $oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], // $_SESSION['INDEX'], // $_SESSION['USER_LOGGED'], // 'SHOW_MESSAGE'); //} - - -if (($RBAC_Response = $RBAC->userCanAccess( "PM_CASES" )) != 1) { - return $RBAC_Response; -} - -if (isset( $_POST['showWindow'] )) { - if ($_POST['showWindow'] == 'steps') { - $fn = 'showSteps();'; - } elseif ($_POST['showWindow'] == 'information') { - $fn = 'showInformation();'; - } elseif ($_POST['showWindow'] == 'actions') { - $fn = 'showActions();'; - } elseif ($_POST['showWindow'] == 'false') { - $fn = ''; - } else { - if ($_POST['showWindow'] != '') { - $fn = false; - } - } - $_SESSION['showCasesWindow'] = $fn; -} - -if (! isset( $_POST['action'] )) { - $_POST['action'] = ''; -} - -switch (($_POST['action']) ? $_POST['action'] : $_REQUEST['action']) { - case 'steps': - global $G_PUBLISH; - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'view', 'cases/cases_StepsTree' ); - G::RenderPage( 'publish', 'raw' ); - break; - case 'information': - global $G_PUBLISH; - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'view', 'cases/cases_InformationTree' ); - G::RenderPage( 'publish', 'raw' ); - break; - case 'actions': - global $G_PUBLISH; - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'view', 'cases/cases_ActionsTree' ); - G::RenderPage( 'publish', 'raw' ); - break; - case 'showProcessMap': - G::LoadClass( 'processMap' ); - $oTemplatePower = new TemplatePower( PATH_TPL . 'processes/processes_Map.html' ); - $oTemplatePower->prepare(); - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'template', '', '', '', $oTemplatePower ); - $oHeadPublisher = & headPublisher::getSingleton(); + + +if (($RBAC_Response = $RBAC->userCanAccess( "PM_CASES" )) != 1) { + return $RBAC_Response; +} + +if (isset( $_POST['showWindow'] )) { + if ($_POST['showWindow'] == 'steps') { + $fn = 'showSteps();'; + } elseif ($_POST['showWindow'] == 'information') { + $fn = 'showInformation();'; + } elseif ($_POST['showWindow'] == 'actions') { + $fn = 'showActions();'; + } elseif ($_POST['showWindow'] == 'false') { + $fn = ''; + } else { + if ($_POST['showWindow'] != '') { + $fn = false; + } + } + $_SESSION['showCasesWindow'] = $fn; +} + +if (! isset( $_POST['action'] )) { + $_POST['action'] = ''; +} + +switch (($_POST['action']) ? $_POST['action'] : $_REQUEST['action']) { + case 'steps': + global $G_PUBLISH; + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'view', 'cases/cases_StepsTree' ); + G::RenderPage( 'publish', 'raw' ); + break; + case 'information': + global $G_PUBLISH; + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'view', 'cases/cases_InformationTree' ); + G::RenderPage( 'publish', 'raw' ); + break; + case 'actions': + global $G_PUBLISH; + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'view', 'cases/cases_ActionsTree' ); + G::RenderPage( 'publish', 'raw' ); + break; + case 'showProcessMap': + G::LoadClass( 'processMap' ); + $oTemplatePower = new TemplatePower( PATH_TPL . 'processes/processes_Map.html' ); + $oTemplatePower->prepare(); + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'template', '', '', '', $oTemplatePower ); + $oHeadPublisher = & headPublisher::getSingleton(); $oHeadPublisher->addScriptCode( ' var maximunX = ' . processMap::getMaximunTaskX( $_SESSION['PROCESS'] ) . '; var pb=leimnud.dom.capture("tag.body 0"); @@ -134,119 +134,119 @@ switch (($_POST['action']) ? $_POST['action'] : $_REQUEST['action']) { rw : false, hideMenu : false } - Pm.make();' ); - G::RenderPage( 'publish', 'raw' ); - break; - case 'showLeyends': - $aFields = array (); - $aFields['sLabel1'] = G::LoadTranslation( 'ID_TASK_IN_PROGRESS' ); - $aFields['sLabel2'] = G::LoadTranslation( 'ID_COMPLETED_TASK' ); - $aFields['sLabel3'] = G::LoadTranslation( 'ID_PENDING_TASK' ); - $aFields['sLabel4'] = G::LoadTranslation( 'ID_PARALLEL_TASK' ); - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'smarty', 'cases/cases_Leyends', '', '', $aFields ); - G::RenderPage( 'publish', 'raw' ); - break; - case 'showProcessInformation': - require_once 'classes/model/Process.php'; - $oProcess = new Process(); - $aFields = $oProcess->load( $_SESSION['PROCESS'] ); - require_once 'classes/model/Users.php'; - $oUser = new Users(); - try { - $aUser = $oUser->load( $aFields['PRO_CREATE_USER'] ); - $aFields['PRO_AUTHOR'] = $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME']; - } catch (Exception $oError) { - $aFields['PRO_AUTHOR'] = '(USER DELETED)'; - } - $aFields['PRO_CREATE_DATE'] = date( 'F j, Y', strtotime( $aFields['PRO_CREATE_DATE'] ) ); - global $G_PUBLISH; - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_ProcessInformation', '', $aFields ); - G::RenderPage( 'publish', 'raw' ); - break; - case 'showTransferHistory': - G::LoadClass( "case" ); - $c = Cases::getTransferHistoryCriteria( $_SESSION['APPLICATION'] ); - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'cases/cases_TransferHistory', $c, array () ); - G::RenderPage( 'publish', 'raw' ); - break; - case 'showDynaformListHistory': - require_once 'classes/model/AppHistory.php'; - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'view', 'cases/cases_DynaformHistory' ); - G::RenderPage( 'publish', 'raw' ); - break; - case 'showTaskInformation': - require_once 'classes/model/AppDelegation.php'; - require_once 'classes/model/Task.php'; - $oTask = new Task(); - $aFields = $oTask->load( $_SESSION['TASK'] ); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( AppDelegationPeer::APP_UID, $_SESSION['APPLICATION'] ); - $oCriteria->add( AppDelegationPeer::DEL_INDEX, $_SESSION['INDEX'] ); - $oDataset = AppDelegationPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - $aDelegation = $oDataset->getRow(); - $iDiff = strtotime( $aDelegation['DEL_FINISH_DATE'] ) - strtotime( $aDelegation['DEL_INIT_DATE'] ); - $aFields['INIT_DATE'] = ($aDelegation['DEL_INIT_DATE'] != null ? $aDelegation['DEL_INIT_DATE'] : G::LoadTranslation( 'ID_CASE_NOT_YET_STARTED' )); - $aFields['DUE_DATE'] = ($aDelegation['DEL_TASK_DUE_DATE'] != null ? $aDelegation['DEL_TASK_DUE_DATE'] : G::LoadTranslation( 'ID_NOT_FINISHED' )); - $aFields['FINISH'] = ($aDelegation['DEL_FINISH_DATE'] != null ? $aDelegation['DEL_FINISH_DATE'] : G::LoadTranslation( 'ID_NOT_FINISHED' )); - $aFields['DURATION'] = ($aDelegation['DEL_FINISH_DATE'] != null ? (int) ($iDiff / 3600) . ' ' . ((int) ($iDiff / 3600) == 1 ? G::LoadTranslation( 'ID_HOUR' ) : G::LoadTranslation( 'ID_HOURS' )) . ' ' . (int) (($iDiff % 3600) / 60) . ' ' . ((int) (($iDiff % 3600) / 60) == 1 ? G::LoadTranslation( 'ID_MINUTE' ) : G::LoadTranslation( 'ID_MINUTES' )) . ' ' . (int) (($iDiff % 3600) % 60) . ' ' . ((int) (($iDiff % 3600) % 60) == 1 ? G::LoadTranslation( 'ID_SECOND' ) : G::LoadTranslation( 'ID_SECONDS' )) : G::LoadTranslation( 'ID_NOT_FINISHED' )); - global $G_PUBLISH; - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_TaskInformation', '', $aFields ); - G::RenderPage( 'publish', 'raw' ); - break; - case 'showTaskDetails': - require_once 'classes/model/AppDelegation.php'; - require_once 'classes/model/Task.php'; - require_once 'classes/model/Users.php'; - $oTask = new Task(); - $aRow = $oTask->load( $_POST['sTaskUID'] ); - $sTitle = $aRow['TAS_TITLE']; - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->addSelectColumn( UsersPeer::USR_UID ); - $oCriteria->addSelectColumn( UsersPeer::USR_FIRSTNAME ); - $oCriteria->addSelectColumn( UsersPeer::USR_LASTNAME ); - $oCriteria->addSelectColumn( AppDelegationPeer::DEL_INIT_DATE ); - $oCriteria->addSelectColumn( AppDelegationPeer::DEL_TASK_DUE_DATE ); - $oCriteria->addSelectColumn( AppDelegationPeer::DEL_FINISH_DATE ); - $oCriteria->addJoin( AppDelegationPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN ); - $oCriteria->add( AppDelegationPeer::APP_UID, $_SESSION['APPLICATION'] ); - $oCriteria->add( AppDelegationPeer::TAS_UID, $_POST['sTaskUID'] ); - $oCriteria->addDescendingOrderByColumn( AppDelegationPeer::DEL_INDEX ); - $oDataset = AppDelegationPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - $aRow = $oDataset->getRow(); - $iDiff = strtotime( $aRow['DEL_FINISH_DATE'] ) - strtotime( $aRow['DEL_INIT_DATE'] ); - $aFields = array (); - $aFields['TASK'] = $sTitle; - $aFields['USER'] = ($aRow['USR_UID'] != null ? $aRow['USR_FIRSTNAME'] . ' ' . $aRow['USR_LASTNAME'] : G::LoadTranslation( 'ID_NONE' )); - $aFields['INIT_DATE'] = ($aRow['DEL_INIT_DATE'] != null ? $aRow['DEL_INIT_DATE'] : G::LoadTranslation( 'ID_CASE_NOT_YET_STARTED' )); - $aFields['DUE_DATE'] = ($aRow['DEL_TASK_DUE_DATE'] != null ? $aRow['DEL_TASK_DUE_DATE'] : G::LoadTranslation( 'ID_CASE_NOT_YET_STARTED' )); - $aFields['FINISH'] = ($aRow['DEL_FINISH_DATE'] != null ? $aRow['DEL_FINISH_DATE'] : G::LoadTranslation( 'ID_NOT_FINISHED' )); - $aFields['DURATION'] = ($aRow['DEL_FINISH_DATE'] != null ? (int) ($iDiff / 3600) . ' ' . ((int) ($iDiff / 3600) == 1 ? G::LoadTranslation( 'ID_HOUR' ) : G::LoadTranslation( 'ID_HOURS' )) . ' ' . (int) (($iDiff % 3600) / 60) . ' ' . ((int) (($iDiff % 3600) / 60) == 1 ? G::LoadTranslation( 'ID_MINUTE' ) : G::LoadTranslation( 'ID_MINUTES' )) . ' ' . (int) (($iDiff % 3600) % 60) . ' ' . ((int) (($iDiff % 3600) % 60) == 1 ? G::LoadTranslation( 'ID_SECOND' ) : G::LoadTranslation( 'ID_SECONDS' )) : G::LoadTranslation( 'ID_NOT_FINISHED' )); - global $G_PUBLISH; - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_TaskDetails', '', $aFields ); - G::RenderPage( 'publish', 'raw' ); - break; - case 'showUsers': - switch ($_POST['TAS_ASSIGN_TYPE']) { + Pm.make();' ); + G::RenderPage( 'publish', 'raw' ); + break; + case 'showLeyends': + $aFields = array (); + $aFields['sLabel1'] = G::LoadTranslation( 'ID_TASK_IN_PROGRESS' ); + $aFields['sLabel2'] = G::LoadTranslation( 'ID_COMPLETED_TASK' ); + $aFields['sLabel3'] = G::LoadTranslation( 'ID_PENDING_TASK' ); + $aFields['sLabel4'] = G::LoadTranslation( 'ID_PARALLEL_TASK' ); + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'smarty', 'cases/cases_Leyends', '', '', $aFields ); + G::RenderPage( 'publish', 'raw' ); + break; + case 'showProcessInformation': + require_once 'classes/model/Process.php'; + $oProcess = new Process(); + $aFields = $oProcess->load( $_SESSION['PROCESS'] ); + require_once 'classes/model/Users.php'; + $oUser = new Users(); + try { + $aUser = $oUser->load( $aFields['PRO_CREATE_USER'] ); + $aFields['PRO_AUTHOR'] = $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME']; + } catch (Exception $oError) { + $aFields['PRO_AUTHOR'] = '(USER DELETED)'; + } + $aFields['PRO_CREATE_DATE'] = date( 'F j, Y', strtotime( $aFields['PRO_CREATE_DATE'] ) ); + global $G_PUBLISH; + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_ProcessInformation', '', $aFields ); + G::RenderPage( 'publish', 'raw' ); + break; + case 'showTransferHistory': + G::LoadClass( "case" ); + $c = Cases::getTransferHistoryCriteria( $_SESSION['APPLICATION'] ); + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'cases/cases_TransferHistory', $c, array () ); + G::RenderPage( 'publish', 'raw' ); + break; + case 'showDynaformListHistory': + require_once 'classes/model/AppHistory.php'; + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'view', 'cases/cases_DynaformHistory' ); + G::RenderPage( 'publish', 'raw' ); + break; + case 'showTaskInformation': + require_once 'classes/model/AppDelegation.php'; + require_once 'classes/model/Task.php'; + $oTask = new Task(); + $aFields = $oTask->load( $_SESSION['TASK'] ); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( AppDelegationPeer::APP_UID, $_SESSION['APPLICATION'] ); + $oCriteria->add( AppDelegationPeer::DEL_INDEX, $_SESSION['INDEX'] ); + $oDataset = AppDelegationPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aDelegation = $oDataset->getRow(); + $iDiff = strtotime( $aDelegation['DEL_FINISH_DATE'] ) - strtotime( $aDelegation['DEL_INIT_DATE'] ); + $aFields['INIT_DATE'] = ($aDelegation['DEL_INIT_DATE'] != null ? $aDelegation['DEL_INIT_DATE'] : G::LoadTranslation( 'ID_CASE_NOT_YET_STARTED' )); + $aFields['DUE_DATE'] = ($aDelegation['DEL_TASK_DUE_DATE'] != null ? $aDelegation['DEL_TASK_DUE_DATE'] : G::LoadTranslation( 'ID_NOT_FINISHED' )); + $aFields['FINISH'] = ($aDelegation['DEL_FINISH_DATE'] != null ? $aDelegation['DEL_FINISH_DATE'] : G::LoadTranslation( 'ID_NOT_FINISHED' )); + $aFields['DURATION'] = ($aDelegation['DEL_FINISH_DATE'] != null ? (int) ($iDiff / 3600) . ' ' . ((int) ($iDiff / 3600) == 1 ? G::LoadTranslation( 'ID_HOUR' ) : G::LoadTranslation( 'ID_HOURS' )) . ' ' . (int) (($iDiff % 3600) / 60) . ' ' . ((int) (($iDiff % 3600) / 60) == 1 ? G::LoadTranslation( 'ID_MINUTE' ) : G::LoadTranslation( 'ID_MINUTES' )) . ' ' . (int) (($iDiff % 3600) % 60) . ' ' . ((int) (($iDiff % 3600) % 60) == 1 ? G::LoadTranslation( 'ID_SECOND' ) : G::LoadTranslation( 'ID_SECONDS' )) : G::LoadTranslation( 'ID_NOT_FINISHED' )); + global $G_PUBLISH; + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_TaskInformation', '', $aFields ); + G::RenderPage( 'publish', 'raw' ); + break; + case 'showTaskDetails': + require_once 'classes/model/AppDelegation.php'; + require_once 'classes/model/Task.php'; + require_once 'classes/model/Users.php'; + $oTask = new Task(); + $aRow = $oTask->load( $_POST['sTaskUID'] ); + $sTitle = $aRow['TAS_TITLE']; + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->addSelectColumn( UsersPeer::USR_UID ); + $oCriteria->addSelectColumn( UsersPeer::USR_FIRSTNAME ); + $oCriteria->addSelectColumn( UsersPeer::USR_LASTNAME ); + $oCriteria->addSelectColumn( AppDelegationPeer::DEL_INIT_DATE ); + $oCriteria->addSelectColumn( AppDelegationPeer::DEL_TASK_DUE_DATE ); + $oCriteria->addSelectColumn( AppDelegationPeer::DEL_FINISH_DATE ); + $oCriteria->addJoin( AppDelegationPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN ); + $oCriteria->add( AppDelegationPeer::APP_UID, $_SESSION['APPLICATION'] ); + $oCriteria->add( AppDelegationPeer::TAS_UID, $_POST['sTaskUID'] ); + $oCriteria->addDescendingOrderByColumn( AppDelegationPeer::DEL_INDEX ); + $oDataset = AppDelegationPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aRow = $oDataset->getRow(); + $iDiff = strtotime( $aRow['DEL_FINISH_DATE'] ) - strtotime( $aRow['DEL_INIT_DATE'] ); + $aFields = array (); + $aFields['TASK'] = $sTitle; + $aFields['USER'] = ($aRow['USR_UID'] != null ? $aRow['USR_FIRSTNAME'] . ' ' . $aRow['USR_LASTNAME'] : G::LoadTranslation( 'ID_NONE' )); + $aFields['INIT_DATE'] = ($aRow['DEL_INIT_DATE'] != null ? $aRow['DEL_INIT_DATE'] : G::LoadTranslation( 'ID_CASE_NOT_YET_STARTED' )); + $aFields['DUE_DATE'] = ($aRow['DEL_TASK_DUE_DATE'] != null ? $aRow['DEL_TASK_DUE_DATE'] : G::LoadTranslation( 'ID_CASE_NOT_YET_STARTED' )); + $aFields['FINISH'] = ($aRow['DEL_FINISH_DATE'] != null ? $aRow['DEL_FINISH_DATE'] : G::LoadTranslation( 'ID_NOT_FINISHED' )); + $aFields['DURATION'] = ($aRow['DEL_FINISH_DATE'] != null ? (int) ($iDiff / 3600) . ' ' . ((int) ($iDiff / 3600) == 1 ? G::LoadTranslation( 'ID_HOUR' ) : G::LoadTranslation( 'ID_HOURS' )) . ' ' . (int) (($iDiff % 3600) / 60) . ' ' . ((int) (($iDiff % 3600) / 60) == 1 ? G::LoadTranslation( 'ID_MINUTE' ) : G::LoadTranslation( 'ID_MINUTES' )) . ' ' . (int) (($iDiff % 3600) % 60) . ' ' . ((int) (($iDiff % 3600) % 60) == 1 ? G::LoadTranslation( 'ID_SECOND' ) : G::LoadTranslation( 'ID_SECONDS' )) : G::LoadTranslation( 'ID_NOT_FINISHED' )); + global $G_PUBLISH; + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_TaskDetails', '', $aFields ); + G::RenderPage( 'publish', 'raw' ); + break; + case 'showUsers': + switch ($_POST['TAS_ASSIGN_TYPE']) { // switch verify $_POST['TAS_ASSIGN_TYPE'] - case 'BALANCED': - G::LoadClass( 'user' ); - $oUser = new User( new DBConnection() ); - $oUser->load( $_POST['USR_UID'] ); - echo $oUser->Fields['USR_FIRSTNAME'] . ' ' . $oUser->Fields['USR_LASTNAME'] . ''; - break; - case 'MANUAL': - $sAux = ''; + break; + case 'MANUAL': + $sAux = ''; - echo $sAux; - break; - case 'EVALUATE': - G::LoadClass( 'application' ); - $oApplication = new Application( new DBConnection() ); - $oApplication->load( $_SESSION['APPLICATION'] ); - $sUser = ''; - if ($_POST['TAS_ASSIGN_VARIABLE'] != '') { - if (isset( $oApplication->Fields['APP_DATA'][str_replace( '@@', '', $_POST['TAS_ASSIGN_VARIABLE'] )] )) { - $sUser = $oApplication->Fields['APP_DATA'][str_replace( '@@', '', $_POST['TAS_ASSIGN_VARIABLE'] )]; - } - } - if ($sUser != '') { - G::LoadClass( 'user' ); - $oUser = new User( new DBConnection() ); - $oUser->load( $sUser ); - echo $oUser->Fields['USR_FIRSTNAME'] . ' ' . $oUser->Fields['USR_LASTNAME'] . ''; - } else { - echo 'Error: ' . $_POST['TAS_ASSIGN_VARIABLE'] . ' ' . G::LoadTranslation( 'ID_EMPTY' ); - echo ''; - } - break; - case 'SELFSERVICE': + U.USR_STATUS = 1"; + $oDataset = $oSession->Execute( $sSQL ); + + while ($aRow = $oDataset->Read()) { + $sAux .= ''; + } + $sAux .= ''; + echo $sAux; + break; + case 'EVALUATE': + G::LoadClass( 'application' ); + $oApplication = new Application( new DBConnection() ); + $oApplication->load( $_SESSION['APPLICATION'] ); + $sUser = ''; + if ($_POST['TAS_ASSIGN_VARIABLE'] != '') { + if (isset( $oApplication->Fields['APP_DATA'][str_replace( '@@', '', $_POST['TAS_ASSIGN_VARIABLE'] )] )) { + $sUser = $oApplication->Fields['APP_DATA'][str_replace( '@@', '', $_POST['TAS_ASSIGN_VARIABLE'] )]; + } + } + if ($sUser != '') { + G::LoadClass( 'user' ); + $oUser = new User( new DBConnection() ); + $oUser->load( $sUser ); + echo $oUser->Fields['USR_FIRSTNAME'] . ' ' . $oUser->Fields['USR_LASTNAME'] . ''; + } else { + echo 'Error: ' . $_POST['TAS_ASSIGN_VARIABLE'] . ' ' . G::LoadTranslation( 'ID_EMPTY' ); + echo ''; + } + break; + case 'SELFSERVICE': //Next release - break; - } - break; - case 'cancelCase': - $oCase = new Cases(); - $multiple = false; - - if (isset( $_POST['APP_UID'] ) && isset( $_POST['DEL_INDEX'] )) { - $APP_UID = $_POST['APP_UID']; - $DEL_INDEX = $_POST['DEL_INDEX']; - - $appUids = explode( ',', $APP_UID ); - $delIndexes = explode( ',', $DEL_INDEX ); - if (count( $appUids ) > 1 && count( $delIndexes ) > 1) { - $multiple = true; - } - } elseif (isset( $_POST['sApplicationUID'] ) && isset( $_POST['iIndex'] )) { - $APP_UID = $_POST['sApplicationUID']; - $DEL_INDEX = $_POST['iIndex']; - } else { - $APP_UID = $_SESSION['APPLICATION']; - $DEL_INDEX = $_SESSION['INDEX']; - } - - if ($multiple) { - foreach ($appUids as $i => $appUid) { - $oCase->cancelCase( $appUid, $delIndexes[$i], $_SESSION['USER_LOGGED'] ); - } - } else { - $oCase->cancelCase( $APP_UID, $DEL_INDEX, $_SESSION['USER_LOGGED'] ); - } - break; - case 'reactivateCase': - $sApplicationUID = isset( $_POST['sApplicationUID'] ) ? $_POST['sApplicationUID'] : $_SESSION['APPLICATION']; - $iIndex = (isset( $_POST['sApplicationUID'] )) ? $_POST['iIndex'] : $_SESSION['INDEX']; - $oCase = new Cases(); - $oCase->reactivateCase( $sApplicationUID, $iIndex, $_SESSION['USER_LOGGED'] ); - break; - case 'showPauseCaseInput': + break; + } + break; + case 'cancelCase': + $oCase = new Cases(); + $multiple = false; + + if (isset( $_POST['APP_UID'] ) && isset( $_POST['DEL_INDEX'] )) { + $APP_UID = $_POST['APP_UID']; + $DEL_INDEX = $_POST['DEL_INDEX']; + + $appUids = explode( ',', $APP_UID ); + $delIndexes = explode( ',', $DEL_INDEX ); + if (count( $appUids ) > 1 && count( $delIndexes ) > 1) { + $multiple = true; + } + } elseif (isset( $_POST['sApplicationUID'] ) && isset( $_POST['iIndex'] )) { + $APP_UID = $_POST['sApplicationUID']; + $DEL_INDEX = $_POST['iIndex']; + } else { + $APP_UID = $_SESSION['APPLICATION']; + $DEL_INDEX = $_SESSION['INDEX']; + } + + if ($multiple) { + foreach ($appUids as $i => $appUid) { + $oCase->cancelCase( $appUid, $delIndexes[$i], $_SESSION['USER_LOGGED'] ); + } + } else { + $oCase->cancelCase( $APP_UID, $DEL_INDEX, $_SESSION['USER_LOGGED'] ); + } + break; + case 'reactivateCase': + $sApplicationUID = isset( $_POST['sApplicationUID'] ) ? $_POST['sApplicationUID'] : $_SESSION['APPLICATION']; + $iIndex = (isset( $_POST['sApplicationUID'] )) ? $_POST['iIndex'] : $_SESSION['INDEX']; + $oCase = new Cases(); + $oCase->reactivateCase( $sApplicationUID, $iIndex, $_SESSION['USER_LOGGED'] ); + break; + case 'showPauseCaseInput': //echo ''; - $aFields = Array (); - $G_PUBLISH = new Publisher(); - $aFields['TIME_STAMP'] = G::getformatedDate( date( 'Y-m-d' ), 'M d, yyyy', SYS_LANG ); - - $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_UnpauseDateInput', '', $aFields ); - G::RenderPage( 'publish', 'raw' ); - break; - case 'pauseCase': + $aFields = Array (); + $G_PUBLISH = new Publisher(); + $aFields['TIME_STAMP'] = G::getformatedDate( date( 'Y-m-d' ), 'M d, yyyy', SYS_LANG ); + + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_UnpauseDateInput', '', $aFields ); + G::RenderPage( 'publish', 'raw' ); + break; + case 'pauseCase': // Save the note pause reason - if ($_POST['NOTE_REASON'] != '') { - require_once ("classes/model/AppNotes.php"); - $appNotes = new AppNotes(); - $noteContent = addslashes( $_POST['NOTE_REASON'] ); - $result = $appNotes->postNewNote( $_POST['APP_UID'], $_SESSION['USER_LOGGED'], $noteContent, $_POST['NOTIFY_PAUSE'] ); - } + if ($_POST['NOTE_REASON'] != '') { + require_once ("classes/model/AppNotes.php"); + $appNotes = new AppNotes(); + $noteContent = addslashes( $_POST['NOTE_REASON'] ); + $result = $appNotes->postNewNote( $_POST['APP_UID'], $_SESSION['USER_LOGGED'], $noteContent, $_POST['NOTIFY_PAUSE'] ); + } // End save - - - $unpauseDate = $_POST['unpausedate']; - $oCase = new Cases(); - if (isset( $_POST['APP_UID'] ) && isset( $_POST['DEL_INDEX'] )) { - $APP_UID = $_POST['APP_UID']; - $DEL_INDEX = $_POST['DEL_INDEX']; - } elseif (isset( $_POST['sApplicationUID'] ) && isset( $_POST['iIndex'] )) { - $APP_UID = $_POST['sApplicationUID']; - $DEL_INDEX = $_POST['iIndex']; - } else { - $APP_UID = $_SESSION['APPLICATION']; - $DEL_INDEX = $_SESSION['INDEX']; - } - - $oCase->pauseCase( $APP_UID, $DEL_INDEX, $_SESSION['USER_LOGGED'], $unpauseDate ); - break; - case 'unpauseCase': - $sApplicationUID = (isset( $_POST['sApplicationUID'] )) ? $_POST['sApplicationUID'] : $_SESSION['APPLICATION']; - $iIndex = (isset( $_POST['sApplicationUID'] )) ? $_POST['iIndex'] : $_SESSION['INDEX']; - $oCase = new Cases(); - $oCase->unpauseCase( $sApplicationUID, $iIndex, $_SESSION['USER_LOGGED'] ); - break; - case 'deleteCase': - $oCase = new Cases(); - $sApplicationUID = (isset( $_POST['sApplicationUID'] )) ? $_POST['sApplicationUID'] : $_SESSION['APPLICATION']; - $oCase->removeCase( $sApplicationUID ); - break; - case 'view_reassignCase': - G::LoadClass( 'groups' ); - G::LoadClass( 'tasks' ); - - $oTasks = new Tasks(); - $aAux = $oTasks->getGroupsOfTask( $_SESSION['TASK'], 1 ); - $row = array (); - - $groups = new Groups(); - foreach ($aAux as $aGroup) { - $aUsers = $groups->getUsersOfGroup( $aGroup['GRP_UID'] ); - foreach ($aUsers as $aUser) { - if ($aUser['USR_UID'] != $_SESSION['USER_LOGGED']) { - $row[] = $aUser['USR_UID']; - } - } - } - - $aAux = $oTasks->getUsersOfTask( $_SESSION['TASK'], 1 ); - foreach ($aAux as $aUser) { - if ($aUser['USR_UID'] != $_SESSION['USER_LOGGED']) { - $row[] = $aUser['USR_UID']; - } - } - - require_once 'classes/model/Users.php'; - $c = new Criteria( 'workflow' ); - $c->addSelectColumn( UsersPeer::USR_UID ); - $c->addSelectColumn( UsersPeer::USR_FIRSTNAME ); - $c->addSelectColumn( UsersPeer::USR_LASTNAME ); - $c->add( UsersPeer::USR_UID, $row, Criteria::IN ); - - global $G_PUBLISH; - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'processes/processes_viewreassignCase', $c ); - G::RenderPage( 'publish', 'raw' ); - break; - case 'reassignCase': - $cases = new Cases(); - $cases->reassignCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], $_POST['USR_UID'], $_POST['THETYPE'] ); - break; - case 'toRevisePanel': - $_GET['APP_UID'] = $_POST['APP_UID']; - $_GET['DEL_INDEX'] = $_POST['DEL_INDEX']; - $G_PUBLISH = new Publisher(); - - echo ""; + + + $unpauseDate = $_POST['unpausedate']; + $oCase = new Cases(); + if (isset( $_POST['APP_UID'] ) && isset( $_POST['DEL_INDEX'] )) { + $APP_UID = $_POST['APP_UID']; + $DEL_INDEX = $_POST['DEL_INDEX']; + } elseif (isset( $_POST['sApplicationUID'] ) && isset( $_POST['iIndex'] )) { + $APP_UID = $_POST['sApplicationUID']; + $DEL_INDEX = $_POST['iIndex']; + } else { + $APP_UID = $_SESSION['APPLICATION']; + $DEL_INDEX = $_SESSION['INDEX']; + } + + $oCase->pauseCase( $APP_UID, $DEL_INDEX, $_SESSION['USER_LOGGED'], $unpauseDate ); + break; + case 'unpauseCase': + $sApplicationUID = (isset( $_POST['sApplicationUID'] )) ? $_POST['sApplicationUID'] : $_SESSION['APPLICATION']; + $iIndex = (isset( $_POST['sApplicationUID'] )) ? $_POST['iIndex'] : $_SESSION['INDEX']; + $oCase = new Cases(); + $oCase->unpauseCase( $sApplicationUID, $iIndex, $_SESSION['USER_LOGGED'] ); + break; + case 'deleteCase': + $oCase = new Cases(); + $sApplicationUID = (isset( $_POST['sApplicationUID'] )) ? $_POST['sApplicationUID'] : $_SESSION['APPLICATION']; + $oCase->removeCase( $sApplicationUID ); + break; + case 'view_reassignCase': + G::LoadClass( 'groups' ); + G::LoadClass( 'tasks' ); + + $oTasks = new Tasks(); + $aAux = $oTasks->getGroupsOfTask( $_SESSION['TASK'], 1 ); + $row = array (); + + $groups = new Groups(); + foreach ($aAux as $aGroup) { + $aUsers = $groups->getUsersOfGroup( $aGroup['GRP_UID'] ); + foreach ($aUsers as $aUser) { + if ($aUser['USR_UID'] != $_SESSION['USER_LOGGED']) { + $row[] = $aUser['USR_UID']; + } + } + } + + $aAux = $oTasks->getUsersOfTask( $_SESSION['TASK'], 1 ); + foreach ($aAux as $aUser) { + if ($aUser['USR_UID'] != $_SESSION['USER_LOGGED']) { + $row[] = $aUser['USR_UID']; + } + } + + require_once 'classes/model/Users.php'; + $c = new Criteria( 'workflow' ); + $c->addSelectColumn( UsersPeer::USR_UID ); + $c->addSelectColumn( UsersPeer::USR_FIRSTNAME ); + $c->addSelectColumn( UsersPeer::USR_LASTNAME ); + $c->add( UsersPeer::USR_UID, $row, Criteria::IN ); + + global $G_PUBLISH; + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'processes/processes_viewreassignCase', $c ); + G::RenderPage( 'publish', 'raw' ); + break; + case 'reassignCase': + $cases = new Cases(); + $cases->reassignCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], $_POST['USR_UID'], $_POST['THETYPE'] ); + break; + case 'toRevisePanel': + $_GET['APP_UID'] = $_POST['APP_UID']; + $_GET['DEL_INDEX'] = $_POST['DEL_INDEX']; + $G_PUBLISH = new Publisher(); + + echo ""; // $G_PUBLISH->AddContent( 'smarty', 'cases/cases_toRevise' ); // $G_PUBLISH->AddContent('smarty', 'cases/cases_toReviseIn', '', '', array()); - G::RenderPage( 'publish', 'raw' ); - break; - case 'showUploadedDocuments': - $oCase = new Cases(); - global $G_PUBLISH; - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'cases/cases_AllInputdocsList', $oCase->getAllUploadedDocumentsCriteria( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['TASK'], $_SESSION['USER_LOGGED'] ) ); - G::RenderPage( 'publish', 'raw' ); - break; - case 'showUploadedDocument': - require_once 'classes/model/AppDocument.php'; - require_once 'classes/model/AppDelegation.php'; - require_once 'classes/model/InputDocument.php'; - require_once 'classes/model/Users.php'; - $oAppDocument = new AppDocument(); - $oAppDocument->Fields = $oAppDocument->load( $_POST['APP_DOC_UID'] ); - $oInputDocument = new InputDocument(); - if ($oAppDocument->Fields['DOC_UID'] != - 1) { - $Fields = $oInputDocument->load( $oAppDocument->Fields['DOC_UID'] ); - } else { - $Fields = array ('INP_DOC_FORM_NEEDED' => '','FILENAME' => $oAppDocument->Fields['APP_DOC_FILENAME']); - } - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( AppDelegationPeer::APP_UID, $oAppDocument->Fields['APP_UID'] ); - $oCriteria->add( AppDelegationPeer::DEL_INDEX, $oAppDocument->Fields['DEL_INDEX'] ); - $oDataset = AppDelegationPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - $aRow = $oDataset->getRow(); - $oTask = new Task(); - try { - $aTask = $oTask->load( $aRow['TAS_UID'] ); - $Fields['ORIGIN'] = $aTask['TAS_TITLE']; - $oAppDocument->Fields['VIEW'] = G::LoadTranslation( 'ID_OPEN' ); - } catch (Exception $oException) { - $Fields['ORIGIN'] = '(TASK DELETED)'; - } - - try { - $oUser = new Users(); - $aUser = $oUser->load( $oAppDocument->Fields['USR_UID'] ); - $Fields['CREATOR'] = $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME']; - } catch (Exception $e) { - $Fields['CREATOR'] = '***'; - } - switch ($Fields['INP_DOC_FORM_NEEDED']) { + G::RenderPage( 'publish', 'raw' ); + break; + case 'showUploadedDocuments': + $oCase = new Cases(); + global $G_PUBLISH; + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'cases/cases_AllInputdocsList', $oCase->getAllUploadedDocumentsCriteria( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['TASK'], $_SESSION['USER_LOGGED'] ) ); + G::RenderPage( 'publish', 'raw' ); + break; + case 'showUploadedDocument': + require_once 'classes/model/AppDocument.php'; + require_once 'classes/model/AppDelegation.php'; + require_once 'classes/model/InputDocument.php'; + require_once 'classes/model/Users.php'; + $oAppDocument = new AppDocument(); + $oAppDocument->Fields = $oAppDocument->load( $_POST['APP_DOC_UID'] ); + $oInputDocument = new InputDocument(); + if ($oAppDocument->Fields['DOC_UID'] != - 1) { + $Fields = $oInputDocument->load( $oAppDocument->Fields['DOC_UID'] ); + } else { + $Fields = array ('INP_DOC_FORM_NEEDED' => '','FILENAME' => $oAppDocument->Fields['APP_DOC_FILENAME']); + } + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( AppDelegationPeer::APP_UID, $oAppDocument->Fields['APP_UID'] ); + $oCriteria->add( AppDelegationPeer::DEL_INDEX, $oAppDocument->Fields['DEL_INDEX'] ); + $oDataset = AppDelegationPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aRow = $oDataset->getRow(); + $oTask = new Task(); + try { + $aTask = $oTask->load( $aRow['TAS_UID'] ); + $Fields['ORIGIN'] = $aTask['TAS_TITLE']; + $oAppDocument->Fields['VIEW'] = G::LoadTranslation( 'ID_OPEN' ); + } catch (Exception $oException) { + $Fields['ORIGIN'] = '(TASK DELETED)'; + } + + try { + $oUser = new Users(); + $aUser = $oUser->load( $oAppDocument->Fields['USR_UID'] ); + $Fields['CREATOR'] = $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME']; + } catch (Exception $e) { + $Fields['CREATOR'] = '***'; + } + switch ($Fields['INP_DOC_FORM_NEEDED']) { // switch verify $Fields['INP_DOC_FORM_NEEDED'] - case 'REAL': - $sXmlForm = 'cases/cases_ViewAnyInputDocument2'; - break; - case 'VIRTUAL': - $sXmlForm = 'cases/cases_ViewAnyInputDocument1'; - break; - case 'VREAL': - $sXmlForm = 'cases/cases_ViewAnyInputDocument3'; - break; - default: - $sXmlForm = 'cases/cases_ViewAnyInputDocument'; - break; - } + case 'REAL': + $sXmlForm = 'cases/cases_ViewAnyInputDocument2'; + break; + case 'VIRTUAL': + $sXmlForm = 'cases/cases_ViewAnyInputDocument1'; + break; + case 'VREAL': + $sXmlForm = 'cases/cases_ViewAnyInputDocument3'; + break; + default: + $sXmlForm = 'cases/cases_ViewAnyInputDocument'; + break; + } //$oAppDocument->Fields['VIEW'] = G::LoadTranslation('ID_OPEN'); - $oAppDocument->Fields['FILE'] = 'cases_ShowDocument?a=' . $_POST['APP_DOC_UID'] . '&r=' . rand(); - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'xmlform', 'xmlform', $sXmlForm, '', G::array_merges( $Fields, $oAppDocument->Fields ), '' ); - G::RenderPage( 'publish', 'raw' ); - break; - case 'showGeneratedDocuments': - global $G_PUBLISH; - $oCase = new Cases(); - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'cases/cases_AllOutputdocsList', $oCase->getAllGeneratedDocumentsCriteria( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['TASK'], $_SESSION['USER_LOGGED'] ) ); - - G::RenderPage( 'publish', 'raw' ); - break; - case 'uploadDocumentGrid_Ajax': - G::LoadClass( 'case' ); - G::LoadClass( "BasePeer" ); - global $G_PUBLISH; - - $oCase = new Cases(); - $aProcesses = Array (); - $G_PUBLISH = new Publisher(); - $c = $oCase->getAllUploadedDocumentsCriteria( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['TASK'], $_SESSION['USER_LOGGED'] ); - - if ($c->getDbName() == 'dbarray') { - $rs = ArrayBasePeer::doSelectRs( $c ); - } else { - $rs = GulliverBasePeer::doSelectRs( $c ); - } - - $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $rs->next(); - - $totalCount = 0; - - for ($j = 0; $j < $rs->getRecordCount(); $j ++) { - $result = $rs->getRow(); - $aProcesses[] = $result; - $rs->next(); - $totalCount ++; - } - - $newDir = '/tmp/test/directory'; - $r = G::verifyPath( $newDir ); - $r->data = $aProcesses; - $r->totalCount = $totalCount; - - echo G::json_encode( $r ); - break; - case 'generateDocumentGrid_Ajax': - - G::LoadClass( 'case' ); - G::LoadClass( "BasePeer" ); - G::LoadClass( 'configuration' ); - global $G_PUBLISH; - - $oCase = new Cases(); - $aProcesses = Array (); - $G_PUBLISH = new Publisher(); - $c = $oCase->getAllGeneratedDocumentsCriteria( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['TASK'], $_SESSION['USER_LOGGED'] ); - - if ($c->getDbName() == 'dbarray') { - $rs = ArrayBasePeer::doSelectRs( $c ); - } else { - $rs = GulliverBasePeer::doSelectRs( $c ); - } - - $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $rs->next(); - - $totalCount = 0; - - for ($j = 0; $j < $rs->getRecordCount(); $j ++) { - $result = $rs->getRow(); - $result["FILEDOCEXIST"] = ($result["FILEDOC"]); - $result["FILEPDFEXIST"] = ($result["FILEPDF"]); - $result["DELETE_FILE"] = (isset( $result['ID_DELETE'] ) && $result['ID_DELETE'] == 'Delete') ? true : false; - - $aProcesses[] = $result; - - $rs->next(); - $totalCount ++; - } - + $oAppDocument->Fields['FILE'] = 'cases_ShowDocument?a=' . $_POST['APP_DOC_UID'] . '&r=' . rand(); + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', $sXmlForm, '', G::array_merges( $Fields, $oAppDocument->Fields ), '' ); + G::RenderPage( 'publish', 'raw' ); + break; + case 'showGeneratedDocuments': + global $G_PUBLISH; + $oCase = new Cases(); + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'cases/cases_AllOutputdocsList', $oCase->getAllGeneratedDocumentsCriteria( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['TASK'], $_SESSION['USER_LOGGED'] ) ); + + G::RenderPage( 'publish', 'raw' ); + break; + case 'uploadDocumentGrid_Ajax': + G::LoadClass( 'case' ); + G::LoadClass( "BasePeer" ); + global $G_PUBLISH; + + $oCase = new Cases(); + $aProcesses = Array (); + $G_PUBLISH = new Publisher(); + $c = $oCase->getAllUploadedDocumentsCriteria( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['TASK'], $_SESSION['USER_LOGGED'] ); + + if ($c->getDbName() == 'dbarray') { + $rs = ArrayBasePeer::doSelectRs( $c ); + } else { + $rs = GulliverBasePeer::doSelectRs( $c ); + } + + $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $rs->next(); + + $totalCount = 0; + + for ($j = 0; $j < $rs->getRecordCount(); $j ++) { + $result = $rs->getRow(); + $aProcesses[] = $result; + $rs->next(); + $totalCount ++; + } + + $newDir = '/tmp/test/directory'; + $r = G::verifyPath( $newDir ); + $r->data = $aProcesses; + $r->totalCount = $totalCount; + + echo G::json_encode( $r ); + break; + case 'generateDocumentGrid_Ajax': + + G::LoadClass( 'case' ); + G::LoadClass( "BasePeer" ); + G::LoadClass( 'configuration' ); + global $G_PUBLISH; + + $oCase = new Cases(); + $aProcesses = Array (); + $G_PUBLISH = new Publisher(); + $c = $oCase->getAllGeneratedDocumentsCriteria( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['TASK'], $_SESSION['USER_LOGGED'] ); + + if ($c->getDbName() == 'dbarray') { + $rs = ArrayBasePeer::doSelectRs( $c ); + } else { + $rs = GulliverBasePeer::doSelectRs( $c ); + } + + $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $rs->next(); + + $totalCount = 0; + + for ($j = 0; $j < $rs->getRecordCount(); $j ++) { + $result = $rs->getRow(); + $result["FILEDOCEXIST"] = ($result["FILEDOC"]); + $result["FILEPDFEXIST"] = ($result["FILEPDF"]); + $result["DELETE_FILE"] = (isset( $result['ID_DELETE'] ) && $result['ID_DELETE'] == 'Delete') ? true : false; + + $aProcesses[] = $result; + + $rs->next(); + $totalCount ++; + } + //!dateFormat - $conf = new Configurations(); - - try { - $globaleneralConfCasesList = $conf->getConfiguration( 'ENVIRONMENT_SETTINGS', '' ); - } catch (Exception $e) { - $generalConfCasesList = array (); - } - - $dateFormat = ""; - $varFlag = isset( $generalConfCasesList['casesListDateFormat'] ); - if ($varFlag && ! empty( $generalConfCasesList['casesListDateFormat'] )) { - $dateFormat = $generalConfCasesList['casesListDateFormat']; - } - - $newDir = '/tmp/test/directory'; - $r = G::verifyPath( $newDir ); - $r->data = $aProcesses; - $r->totalCount = $totalCount; - $r->dataFormat = $dateFormat; - - echo G::json_encode( $r ); - break; - case 'showGeneratedDocument': - require_once 'classes/model/AppDocument.php'; - require_once 'classes/model/AppDelegation.php'; - $oAppDocument = new AppDocument(); - $aFields = $oAppDocument->load( $_POST['APP_DOC_UID'] ); - require_once 'classes/model/OutputDocument.php'; - $oOutputDocument = new OutputDocument(); - $aOD = $oOutputDocument->load( $aFields['DOC_UID'] ); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( AppDelegationPeer::APP_UID, $aFields['APP_UID'] ); - $oCriteria->add( AppDelegationPeer::DEL_INDEX, $aFields['DEL_INDEX'] ); - $oDataset = AppDelegationPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - $aRow = $oDataset->getRow(); - $oTask = new Task(); - $aTask = $oTask->load( $aRow['TAS_UID'] ); - $aFields['ORIGIN'] = $aTask['TAS_TITLE']; - require_once 'classes/model/Users.php'; - $oUser = new Users(); - $aUser = $oUser->load( $aFields['USR_UID'] ); - $aFields['CREATOR'] = $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME']; - $aFields['VIEW'] = G::LoadTranslation( 'ID_OPEN' ); - $aFields['FILE1'] = 'cases_ShowOutputDocument?a=' . $aFields['APP_DOC_UID'] . '&ext=doc&random=' . rand(); - $aFields['FILE2'] = 'cases_ShowOutputDocument?a=' . $aFields['APP_DOC_UID'] . '&ext=pdf&random=' . rand(); - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_ViewAnyOutputDocument', '', G::array_merges( $aOD, $aFields ), '' ); - G::RenderPage( 'publish', 'raw' ); - break; - case 'showDynaformList': - $oCase = new Cases(); - global $G_PUBLISH; - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'cases/cases_AllDynaformsList', $oCase->getallDynaformsCriteria( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['TASK'], $_SESSION['USER_LOGGED'] ) ); - G::RenderPage( 'publish', 'raw' ); - break; - case 'showDynaform': - $G_PUBLISH = new Publisher(); - $oCase = new Cases(); - $Fields = $oCase->loadCase( $_SESSION['APPLICATION'] ); - $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PREVIOUS_STEP_LABEL'] = ''; - $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_STEP_LABEL'] = ''; - $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_STEP'] = '#'; - $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_ACTION'] = 'return false;'; - if (isset( $_POST['DYN_UID'] )) { - $_SESSION['DYN_UID_PRINT'] = $_POST['DYN_UID']; - } else { - $_SESSION['DYN_UID_PRINT'] = $_REQUEST['DYN_UID']; - } - if (! isset( $_SESSION['CURRENT_DYN_UID'] )) { - $_SESSION['CURRENT_DYN_UID'] = $_POST['DYN_UID'] ? $_POST['DYN_UID'] : $_REQUEST['DYN_UID']; - } - $G_PUBLISH->AddContent( 'dynaform', 'xmlform', $_SESSION['PROCESS'] . '/' . $_REQUEST['DYN_UID'], '', $Fields['APP_DATA'], '', '', 'view' ); - G::RenderPage( 'publish', 'blank' ); - break; - case 'showDynaformHistory': - $G_PUBLISH = new Publisher(); - $FieldsHistory = unserialize( $_SESSION['HISTORY_DATA'] ); - $Fields['APP_DATA'] = $FieldsHistory[$_POST['HISTORY_ID']]; - $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PREVIOUS_STEP_LABEL'] = ''; - $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_STEP_LABEL'] = ''; - $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_STEP'] = '#'; - $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_ACTION'] = 'return false;'; - $G_PUBLISH->AddContent( 'dynaform', 'xmlform', $_SESSION['PROCESS'] . '/' . $_POST['DYN_UID'], '', $Fields['APP_DATA'], '', '', 'view' ); - G::RenderPage( 'publish', 'raw' ); - break; - case 'adhocAssignmentUsers': - G::LoadClass( 'groups' ); - G::LoadClass( 'tasks' ); - $oTasks = new Tasks(); - $aAux = $oTasks->getGroupsOfTask( $_SESSION['TASK'], 2 ); - $aAdhocUsers = array (); - $oGroups = new Groups(); - foreach ($aAux as $aGroup) { - $aUsers = $oGroups->getUsersOfGroup( $aGroup['GRP_UID'] ); - foreach ($aUsers as $aUser) { - if ($aUser['USR_UID'] != $_SESSION['USER_LOGGED']) { - $aAdhocUsers[] = $aUser['USR_UID']; - } - } - } - $aAux = $oTasks->getUsersOfTask( $_SESSION['TASK'], 2 ); - foreach ($aAux as $aUser) { - if ($aUser['USR_UID'] != $_SESSION['USER_LOGGED']) { - $aAdhocUsers[] = $aUser['USR_UID']; - } - } - require_once 'classes/model/Users.php'; - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->addSelectColumn( UsersPeer::USR_UID ); - $oCriteria->addSelectColumn( UsersPeer::USR_FIRSTNAME ); - $oCriteria->addSelectColumn( UsersPeer::USR_LASTNAME ); - $oCriteria->add( UsersPeer::USR_UID, $aAdhocUsers, Criteria::IN ); - - global $G_PUBLISH; - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'processes/processes_viewreassignCase', $oCriteria, array ('THETYPE' => 'ADHOC' - ) ); - G::RenderPage( 'publish', 'raw' ); - break; - case 'showHistoryMessages': - $oCase = new Cases(); - global $G_PUBLISH; - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'cases/cases_Messages', $oCase->getHistoryMessagesTracker( $_SESSION['APPLICATION'] ) ); - G::RenderPage( 'publish', 'raw' ); - break; - case 'showHistoryMessage': - $G_PUBLISH = new Publisher(); - $oCase = new Cases(); - - $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_MessagesView', '', $oCase->getHistoryMessagesTrackerView( $_POST['APP_UID'], $_POST['APP_MSG_UID'] ) ); - G::RenderPage( 'publish', 'raw' ); - break; - case 'deleteUploadedDocument': - require_once 'classes/model/AppDocument.php'; - $oAppDocument = new AppDocument(); - $oAppDocument->remove( $_POST['DOC'] ); - $oCase = new Cases(); - $oCase->getAllUploadedDocumentsCriteria( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['TASK'], $_SESSION['USER_LOGGED'] ); - break; - case 'deleteGeneratedDocument': - require_once 'classes/model/AppDocument.php'; - $oAppDocument = new AppDocument(); - $oAppDocument->remove( $_POST['DOC'] ); - $oCase = new Cases(); - $oCase->getAllGeneratedDocumentsCriteria( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['TASK'], $_SESSION['USER_LOGGED'] ); - break; - /* @Author Erik Amaru Ortiz */ - case 'resendMessage': - require_once 'classes/model/Configuration.php'; - G::LoadClass( 'spool' ); - - $oCase = new Cases(); - $data = $oCase->getHistoryMessagesTrackerView( $_POST['APP_UID'], $_POST['APP_MSG_UID'] ); + $conf = new Configurations(); + + try { + $globaleneralConfCasesList = $conf->getConfiguration( 'ENVIRONMENT_SETTINGS', '' ); + } catch (Exception $e) { + $generalConfCasesList = array (); + } + + $dateFormat = ""; + $varFlag = isset( $generalConfCasesList['casesListDateFormat'] ); + if ($varFlag && ! empty( $generalConfCasesList['casesListDateFormat'] )) { + $dateFormat = $generalConfCasesList['casesListDateFormat']; + } + + $newDir = '/tmp/test/directory'; + $r = G::verifyPath( $newDir ); + $r->data = $aProcesses; + $r->totalCount = $totalCount; + $r->dataFormat = $dateFormat; + + echo G::json_encode( $r ); + break; + case 'showGeneratedDocument': + require_once 'classes/model/AppDocument.php'; + require_once 'classes/model/AppDelegation.php'; + $oAppDocument = new AppDocument(); + $aFields = $oAppDocument->load( $_POST['APP_DOC_UID'] ); + require_once 'classes/model/OutputDocument.php'; + $oOutputDocument = new OutputDocument(); + $aOD = $oOutputDocument->load( $aFields['DOC_UID'] ); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( AppDelegationPeer::APP_UID, $aFields['APP_UID'] ); + $oCriteria->add( AppDelegationPeer::DEL_INDEX, $aFields['DEL_INDEX'] ); + $oDataset = AppDelegationPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aRow = $oDataset->getRow(); + $oTask = new Task(); + $aTask = $oTask->load( $aRow['TAS_UID'] ); + $aFields['ORIGIN'] = $aTask['TAS_TITLE']; + require_once 'classes/model/Users.php'; + $oUser = new Users(); + $aUser = $oUser->load( $aFields['USR_UID'] ); + $aFields['CREATOR'] = $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME']; + $aFields['VIEW'] = G::LoadTranslation( 'ID_OPEN' ); + $aFields['FILE1'] = 'cases_ShowOutputDocument?a=' . $aFields['APP_DOC_UID'] . '&ext=doc&random=' . rand(); + $aFields['FILE2'] = 'cases_ShowOutputDocument?a=' . $aFields['APP_DOC_UID'] . '&ext=pdf&random=' . rand(); + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_ViewAnyOutputDocument', '', G::array_merges( $aOD, $aFields ), '' ); + G::RenderPage( 'publish', 'raw' ); + break; + case 'showDynaformList': + $oCase = new Cases(); + global $G_PUBLISH; + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'cases/cases_AllDynaformsList', $oCase->getallDynaformsCriteria( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['TASK'], $_SESSION['USER_LOGGED'] ) ); + G::RenderPage( 'publish', 'raw' ); + break; + case 'showDynaform': + $G_PUBLISH = new Publisher(); + $oCase = new Cases(); + $Fields = $oCase->loadCase( $_SESSION['APPLICATION'] ); + $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PREVIOUS_STEP_LABEL'] = ''; + $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_STEP_LABEL'] = ''; + $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_STEP'] = '#'; + $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_ACTION'] = 'return false;'; + if (isset( $_POST['DYN_UID'] )) { + $_SESSION['DYN_UID_PRINT'] = $_POST['DYN_UID']; + } else { + $_SESSION['DYN_UID_PRINT'] = $_REQUEST['DYN_UID']; + } + if (! isset( $_SESSION['CURRENT_DYN_UID'] )) { + $_SESSION['CURRENT_DYN_UID'] = $_POST['DYN_UID'] ? $_POST['DYN_UID'] : $_REQUEST['DYN_UID']; + } + $G_PUBLISH->AddContent( 'dynaform', 'xmlform', $_SESSION['PROCESS'] . '/' . $_REQUEST['DYN_UID'], '', $Fields['APP_DATA'], '', '', 'view' ); + G::RenderPage( 'publish', 'blank' ); + break; + case 'showDynaformHistory': + $G_PUBLISH = new Publisher(); + $FieldsHistory = unserialize( $_SESSION['HISTORY_DATA'] ); + $Fields['APP_DATA'] = $FieldsHistory[$_POST['HISTORY_ID']]; + $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PREVIOUS_STEP_LABEL'] = ''; + $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_STEP_LABEL'] = ''; + $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_STEP'] = '#'; + $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_ACTION'] = 'return false;'; + $G_PUBLISH->AddContent( 'dynaform', 'xmlform', $_SESSION['PROCESS'] . '/' . $_POST['DYN_UID'], '', $Fields['APP_DATA'], '', '', 'view' ); + G::RenderPage( 'publish', 'raw' ); + break; + case 'adhocAssignmentUsers': + G::LoadClass( 'groups' ); + G::LoadClass( 'tasks' ); + $oTasks = new Tasks(); + $aAux = $oTasks->getGroupsOfTask( $_SESSION['TASK'], 2 ); + $aAdhocUsers = array (); + $oGroups = new Groups(); + foreach ($aAux as $aGroup) { + $aUsers = $oGroups->getUsersOfGroup( $aGroup['GRP_UID'] ); + foreach ($aUsers as $aUser) { + if ($aUser['USR_UID'] != $_SESSION['USER_LOGGED']) { + $aAdhocUsers[] = $aUser['USR_UID']; + } + } + } + $aAux = $oTasks->getUsersOfTask( $_SESSION['TASK'], 2 ); + foreach ($aAux as $aUser) { + if ($aUser['USR_UID'] != $_SESSION['USER_LOGGED']) { + $aAdhocUsers[] = $aUser['USR_UID']; + } + } + require_once 'classes/model/Users.php'; + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->addSelectColumn( UsersPeer::USR_UID ); + $oCriteria->addSelectColumn( UsersPeer::USR_FIRSTNAME ); + $oCriteria->addSelectColumn( UsersPeer::USR_LASTNAME ); + $oCriteria->add( UsersPeer::USR_UID, $aAdhocUsers, Criteria::IN ); + + global $G_PUBLISH; + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'processes/processes_viewreassignCase', $oCriteria, array ('THETYPE' => 'ADHOC' + ) ); + G::RenderPage( 'publish', 'raw' ); + break; + case 'showHistoryMessages': + $oCase = new Cases(); + global $G_PUBLISH; + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'cases/cases_Messages', $oCase->getHistoryMessagesTracker( $_SESSION['APPLICATION'] ) ); + G::RenderPage( 'publish', 'raw' ); + break; + case 'showHistoryMessage': + $G_PUBLISH = new Publisher(); + $oCase = new Cases(); + + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_MessagesView', '', $oCase->getHistoryMessagesTrackerView( $_POST['APP_UID'], $_POST['APP_MSG_UID'] ) ); + G::RenderPage( 'publish', 'raw' ); + break; + case 'deleteUploadedDocument': + require_once 'classes/model/AppDocument.php'; + $oAppDocument = new AppDocument(); + $oAppDocument->remove( $_POST['DOC'] ); + $oCase = new Cases(); + $oCase->getAllUploadedDocumentsCriteria( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['TASK'], $_SESSION['USER_LOGGED'] ); + break; + case 'deleteGeneratedDocument': + require_once 'classes/model/AppDocument.php'; + $oAppDocument = new AppDocument(); + $oAppDocument->remove( $_POST['DOC'] ); + $oCase = new Cases(); + $oCase->getAllGeneratedDocumentsCriteria( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['TASK'], $_SESSION['USER_LOGGED'] ); + break; + /* @Author Erik Amaru Ortiz */ + case 'resendMessage': + require_once 'classes/model/Configuration.php'; + G::LoadClass( 'spool' ); + + $oCase = new Cases(); + $data = $oCase->getHistoryMessagesTrackerView( $_POST['APP_UID'], $_POST['APP_MSG_UID'] ); //print_r($data); - - - $oConfiguration = new Configuration(); - $sDelimiter = DBAdapter::getStringDelimiter(); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( ConfigurationPeer::CFG_UID, 'Emails' ); - $oCriteria->add( ConfigurationPeer::OBJ_UID, '' ); - $oCriteria->add( ConfigurationPeer::PRO_UID, '' ); - $oCriteria->add( ConfigurationPeer::USR_UID, '' ); - $oCriteria->add( ConfigurationPeer::APP_UID, '' ); - if (ConfigurationPeer::doCount( $oCriteria ) == 0) { - $oConfiguration->create( array ('CFG_UID' => 'Emails','OBJ_UID' => '','CFG_VALUE' => '','PRO_UID' => '','USR_UID' => '','APP_UID' => '' - ) ); - $aConfiguration = array (); - } else { - $aConfiguration = $oConfiguration->load( 'Emails', '', '', '', '' ); - if ($aConfiguration['CFG_VALUE'] != '') { - $aConfiguration = unserialize( $aConfiguration['CFG_VALUE'] ); - } else { - $aConfiguration = array (); - } - } - - $oSpool = new spoolRun(); - $oSpool->setConfig( array ('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'],'MESS_SERVER' => $aConfiguration['MESS_SERVER'],'MESS_PORT' => $aConfiguration['MESS_PORT'],'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'],'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'],'SMTPAuth' => $aConfiguration['MESS_RAUTH'] - ) ); - $passwd = $oSpool->config['MESS_PASSWORD']; - $passwdDec = G::decrypt( $passwd, 'EMAILENCRYPT' ); - $auxPass = explode( 'hash:', $passwdDec ); - if (count( $auxPass ) > 1) { - if (count( $auxPass ) == 2) { - $passwd = $auxPass[1]; - } else { - array_shift( $auxPass ); - $passwd = implode( '', $auxPass ); - } - } - $oSpool->config['MESS_PASSWORD'] = $passwd; - $oSpool->create( array ('msg_uid' => $data['MSG_UID'],'app_uid' => $data['APP_UID'],'del_index' => $data['DEL_INDEX'],'app_msg_type' => $data['APP_MSG_TYPE'],'app_msg_subject' => $data['APP_MSG_SUBJECT'],'app_msg_from' => $data['APP_MSG_FROM'],'app_msg_to' => $data['APP_MSG_TO'],'app_msg_body' => $data['APP_MSG_BODY'],'app_msg_cc' => $data['APP_MSG_CC'],'app_msg_bcc' => $data['APP_MSG_BCC'],'app_msg_attach' => $data['APP_MSG_ATTACH'],'app_msg_template' => $data['APP_MSG_TEMPLATE'],'app_msg_status' => 'pending' - ) ); - $oSpool->sendMail(); - break; - /* @Author Erik Amaru Ortiz */ - case 'showdebug': - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'view', 'cases/showDebugFrame' ); - G::RenderPage( 'publish', 'raw' ); - break; - /* @Author Erik Amaru Ortiz */ - case 'reassignByUserList': - $APP_UIDS = explode( ',', $_POST['APP_UIDS'] ); - $sReassignFromUser = $_POST['FROM_USR_ID']; - - G::LoadClass( 'tasks' ); - G::LoadClass( 'groups' ); - G::LoadClass( 'case' ); - - $oTasks = new Tasks(); - $oGroups = new Groups(); - $oUser = new Users(); - $oCases = new Cases(); - - $aCasesList = Array (); - - foreach ($APP_UIDS as $APP_UID) { - $aCase = $oCases->loadCaseInCurrentDelegation( $APP_UID, true ); - - $aUsersInvolved = Array (); - $aCaseGroups = $oTasks->getGroupsOfTask( $aCase['TAS_UID'], 1 ); - - foreach ($aCaseGroups as $aCaseGroup) { - $aCaseUsers = $oGroups->getUsersOfGroup( $aCaseGroup['GRP_UID'] ); - foreach ($aCaseUsers as $aCaseUser) { - if ($aCaseUser['USR_UID'] != $sReassignFromUser) { - $aCaseUserRecord = $oUser->load( $aCaseUser['USR_UID'] ); - $aUsersInvolved[$aCaseUser['USR_UID']] = $aCaseUserRecord['USR_FIRSTNAME'] . ' ' . $aCaseUserRecord['USR_LASTNAME']; + + + $oConfiguration = new Configuration(); + $sDelimiter = DBAdapter::getStringDelimiter(); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( ConfigurationPeer::CFG_UID, 'Emails' ); + $oCriteria->add( ConfigurationPeer::OBJ_UID, '' ); + $oCriteria->add( ConfigurationPeer::PRO_UID, '' ); + $oCriteria->add( ConfigurationPeer::USR_UID, '' ); + $oCriteria->add( ConfigurationPeer::APP_UID, '' ); + if (ConfigurationPeer::doCount( $oCriteria ) == 0) { + $oConfiguration->create( array ('CFG_UID' => 'Emails','OBJ_UID' => '','CFG_VALUE' => '','PRO_UID' => '','USR_UID' => '','APP_UID' => '' + ) ); + $aConfiguration = array (); + } else { + $aConfiguration = $oConfiguration->load( 'Emails', '', '', '', '' ); + if ($aConfiguration['CFG_VALUE'] != '') { + $aConfiguration = unserialize( $aConfiguration['CFG_VALUE'] ); + } else { + $aConfiguration = array (); + } + } + + $oSpool = new spoolRun(); + $oSpool->setConfig( array ('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'],'MESS_SERVER' => $aConfiguration['MESS_SERVER'],'MESS_PORT' => $aConfiguration['MESS_PORT'],'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'],'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'],'SMTPAuth' => $aConfiguration['MESS_RAUTH'] + ) ); + $passwd = $oSpool->config['MESS_PASSWORD']; + $passwdDec = G::decrypt( $passwd, 'EMAILENCRYPT' ); + $auxPass = explode( 'hash:', $passwdDec ); + if (count( $auxPass ) > 1) { + if (count( $auxPass ) == 2) { + $passwd = $auxPass[1]; + } else { + array_shift( $auxPass ); + $passwd = implode( '', $auxPass ); + } + } + $oSpool->config['MESS_PASSWORD'] = $passwd; + $oSpool->create( array ('msg_uid' => $data['MSG_UID'],'app_uid' => $data['APP_UID'],'del_index' => $data['DEL_INDEX'],'app_msg_type' => $data['APP_MSG_TYPE'],'app_msg_subject' => $data['APP_MSG_SUBJECT'],'app_msg_from' => $data['APP_MSG_FROM'],'app_msg_to' => $data['APP_MSG_TO'],'app_msg_body' => $data['APP_MSG_BODY'],'app_msg_cc' => $data['APP_MSG_CC'],'app_msg_bcc' => $data['APP_MSG_BCC'],'app_msg_attach' => $data['APP_MSG_ATTACH'],'app_msg_template' => $data['APP_MSG_TEMPLATE'],'app_msg_status' => 'pending' + ) ); + $oSpool->sendMail(); + break; + /* @Author Erik Amaru Ortiz */ + case 'showdebug': + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'view', 'cases/showDebugFrame' ); + G::RenderPage( 'publish', 'raw' ); + break; + /* @Author Erik Amaru Ortiz */ + case 'reassignByUserList': + $APP_UIDS = explode( ',', $_POST['APP_UIDS'] ); + $sReassignFromUser = $_POST['FROM_USR_ID']; + + G::LoadClass( 'tasks' ); + G::LoadClass( 'groups' ); + G::LoadClass( 'case' ); + + $oTasks = new Tasks(); + $oGroups = new Groups(); + $oUser = new Users(); + $oCases = new Cases(); + + $aCasesList = Array (); + + foreach ($APP_UIDS as $APP_UID) { + $aCase = $oCases->loadCaseInCurrentDelegation( $APP_UID, true ); + + $aUsersInvolved = Array (); + $aCaseGroups = $oTasks->getGroupsOfTask( $aCase['TAS_UID'], 1 ); + + foreach ($aCaseGroups as $aCaseGroup) { + $aCaseUsers = $oGroups->getUsersOfGroup( $aCaseGroup['GRP_UID'] ); + foreach ($aCaseUsers as $aCaseUser) { + if ($aCaseUser['USR_UID'] != $sReassignFromUser) { + $aCaseUserRecord = $oUser->load( $aCaseUser['USR_UID'] ); + $aUsersInvolved[$aCaseUser['USR_UID']] = $aCaseUserRecord['USR_FIRSTNAME'] . ' ' . $aCaseUserRecord['USR_LASTNAME']; // . ' (' . $aCaseUserRecord['USR_USERNAME'] . ')'; - } - } - } - - $aCaseUsers = $oTasks->getUsersOfTask( $aCase['TAS_UID'], 1 ); - foreach ($aCaseUsers as $aCaseUser) { - if ($aCaseUser['USR_UID'] != $sReassignFromUser) { - $aCaseUserRecord = $oUser->load( $aCaseUser['USR_UID'] ); - $aUsersInvolved[$aCaseUser['USR_UID']] = $aCaseUserRecord['USR_FIRSTNAME'] . ' ' . $aCaseUserRecord['USR_LASTNAME']; + } + } + } + + $aCaseUsers = $oTasks->getUsersOfTask( $aCase['TAS_UID'], 1 ); + foreach ($aCaseUsers as $aCaseUser) { + if ($aCaseUser['USR_UID'] != $sReassignFromUser) { + $aCaseUserRecord = $oUser->load( $aCaseUser['USR_UID'] ); + $aUsersInvolved[$aCaseUser['USR_UID']] = $aCaseUserRecord['USR_FIRSTNAME'] . ' ' . $aCaseUserRecord['USR_LASTNAME']; // . ' (' . $aCaseUserRecord['USR_USERNAME'] . ')'; - } - } - $oTmp = new stdClass(); - $oTmp->items = $aUsersInvolved; - $oTmp->id = $aCase['APP_UID']; - $aCase['USERS'] = $oTmp; - array_push( $aCasesList, $aCase ); - } - - $filedNames = Array ("APP_UID","APP_NUMBER","APP_UPDATE_DATE","DEL_PRIORITY","DEL_INDEX","TAS_UID","DEL_INIT_DATE","DEL_FINISH_DATE","USR_UID","APP_STATUS","DEL_TASK_DUE_DATE","APP_CURRENT_USER","APP_TITLE","APP_PRO_TITLE","APP_TAS_TITLE","APP_DEL_PREVIOUS_USER","USERS" - ); - - $aCasesList = array_merge( Array ($filedNames - ), $aCasesList ); - - global $_DBArray; - $_DBArray['reassign_byuser'] = $aCasesList; - G::LoadClass( 'ArrayPeer' ); - $oCriteria = new Criteria( 'dbarray' ); - $oCriteria->setDBArrayTable( 'reassign_byuser' ); - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'propeltable', 'cases/paged-table-reassigByUser2', 'cases/cases_ToReassignByUserList2', $oCriteria ); - G::RenderPage( 'publish', 'raw' ); - break; - /* @Author Erik Amaru Ortiz */ - case 'reassignByUser': - G::LoadClass( 'case' ); - - $oCases = new Cases(); - $aCases = Array (); - - if (isset( $_POST['items'] ) && trim( $_POST['items'] ) != '') { - $sItems = $_POST['items']; - $aItems = explode( ',', $sItems ); - $FROM_USR_UID = $_POST['USR_UID']; - - foreach ($aItems as $item) { - list ($APP_UID, $USR_UID) = explode( '|', $item ); - $aCase = $oCases->loadCaseInCurrentDelegation( $APP_UID, true ); - $oCase->reassignCase( $aCase['APP_UID'], $aCase['DEL_INDEX'], $FROM_USR_UID, $USR_UID ); - array_push( $aCases, $aCase ); - } + } + } + $oTmp = new stdClass(); + $oTmp->items = $aUsersInvolved; + $oTmp->id = $aCase['APP_UID']; + $aCase['USERS'] = $oTmp; + array_push( $aCasesList, $aCase ); + } + + $filedNames = Array ("APP_UID","APP_NUMBER","APP_UPDATE_DATE","DEL_PRIORITY","DEL_INDEX","TAS_UID","DEL_INIT_DATE","DEL_FINISH_DATE","USR_UID","APP_STATUS","DEL_TASK_DUE_DATE","APP_CURRENT_USER","APP_TITLE","APP_PRO_TITLE","APP_TAS_TITLE","APP_DEL_PREVIOUS_USER","USERS" + ); + + $aCasesList = array_merge( Array ($filedNames + ), $aCasesList ); + + global $_DBArray; + $_DBArray['reassign_byuser'] = $aCasesList; + G::LoadClass( 'ArrayPeer' ); + $oCriteria = new Criteria( 'dbarray' ); + $oCriteria->setDBArrayTable( 'reassign_byuser' ); + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'propeltable', 'cases/paged-table-reassigByUser2', 'cases/cases_ToReassignByUserList2', $oCriteria ); + G::RenderPage( 'publish', 'raw' ); + break; + /* @Author Erik Amaru Ortiz */ + case 'reassignByUser': + G::LoadClass( 'case' ); + + $oCases = new Cases(); + $aCases = Array (); + + if (isset( $_POST['items'] ) && trim( $_POST['items'] ) != '') { + $sItems = $_POST['items']; + $aItems = explode( ',', $sItems ); + $FROM_USR_UID = $_POST['USR_UID']; + + foreach ($aItems as $item) { + list ($APP_UID, $USR_UID) = explode( '|', $item ); + $aCase = $oCases->loadCaseInCurrentDelegation( $APP_UID, true ); + $oCase->reassignCase( $aCase['APP_UID'], $aCase['DEL_INDEX'], $FROM_USR_UID, $USR_UID ); + array_push( $aCases, $aCase ); + } //G::pr($aCases); - - - require_once 'classes/model/Users.php'; - $oUser = new Users(); - $sText = ''; - foreach ($aCases as $aCase) { - $aCaseUpdated = $oCases->loadCaseInCurrentDelegation( $aCase['APP_UID'], true ); - $aUser = $oUser->load( $aCaseUpdated['USR_UID'] ); - $sText .= $aCaseUpdated['APP_PRO_TITLE'] . ' - ' . ' Case: ' . $aCaseUpdated['APP_NUMBER'] . '# (' . $aCaseUpdated['APP_TAS_TITLE'] . ') => Reassigned to => ' . $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' [' . $aUser['USR_USERNAME'] . ']' . '
'; - } - - $G_PUBLISH = new Publisher(); - $aMessage['MESSAGE'] = $sText; - $aMessage['URL'] = 'cases_ReassignByUser?REASSIGN_USER=' . $_POST['USR_UID']; - $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_ReassignShowInfo', '', $aMessage ); - G::RenderPage( 'publish', 'raw' ); - } - break; - case "uploadInputDocument": + + + require_once 'classes/model/Users.php'; + $oUser = new Users(); + $sText = ''; + foreach ($aCases as $aCase) { + $aCaseUpdated = $oCases->loadCaseInCurrentDelegation( $aCase['APP_UID'], true ); + $aUser = $oUser->load( $aCaseUpdated['USR_UID'] ); + $sText .= $aCaseUpdated['APP_PRO_TITLE'] . ' - ' . ' Case: ' . $aCaseUpdated['APP_NUMBER'] . '# (' . $aCaseUpdated['APP_TAS_TITLE'] . ') => Reassigned to => ' . $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' [' . $aUser['USR_USERNAME'] . ']' . '
'; + } + + $G_PUBLISH = new Publisher(); + $aMessage['MESSAGE'] = $sText; + $aMessage['URL'] = 'cases_ReassignByUser?REASSIGN_USER=' . $_POST['USR_UID']; + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_ReassignShowInfo', '', $aMessage ); + G::RenderPage( 'publish', 'raw' ); + } + break; + case "uploadInputDocument": //krumo($_POST); - $G_PUBLISH = new Publisher(); - $Fields['DOC_UID'] = $_POST['docID']; - $Fields['APP_DOC_UID'] = $_POST['appDocId']; - $Fields['actionType'] = $_POST['actionType']; - $Fields['docVersion'] = $_POST['docVersion']; - $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_AttachInputDocumentGeneral', '', $Fields, 'cases_SaveDocument?UID=' . $_POST['docID'] ); - G::RenderPage( 'publish', 'raw' ); - break; - case "uploadToReviseInputDocument": + $G_PUBLISH = new Publisher(); + $Fields['DOC_UID'] = $_POST['docID']; + $Fields['APP_DOC_UID'] = $_POST['appDocId']; + $Fields['actionType'] = $_POST['actionType']; + $Fields['docVersion'] = $_POST['docVersion']; + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_AttachInputDocumentGeneral', '', $Fields, 'cases_SaveDocument?UID=' . $_POST['docID'] ); + G::RenderPage( 'publish', 'raw' ); + break; + case "uploadToReviseInputDocument": //krumo($_POST); - $G_PUBLISH = new Publisher(); - $Fields['DOC_UID'] = $_POST['docID']; - $Fields['APP_DOC_UID'] = $_POST['appDocId']; - $Fields['actionType'] = $_POST['actionType']; - $Fields['docVersion'] = $_POST['docVersion']; - $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_AttachInputDocumentGeneral', '', $Fields, 'cases_SupervisorSaveDocument?UID=' . $_POST['docID'] . '&APP_UID=' . $_POST['appDocId'] ); - G::RenderPage( 'publish', 'raw' ); - break; - case "inputDocumentVersionHistory": + $G_PUBLISH = new Publisher(); + $Fields['DOC_UID'] = $_POST['docID']; + $Fields['APP_DOC_UID'] = $_POST['appDocId']; + $Fields['actionType'] = $_POST['actionType']; + $Fields['docVersion'] = $_POST['docVersion']; + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_AttachInputDocumentGeneral', '', $Fields, 'cases_SupervisorSaveDocument?UID=' . $_POST['docID'] . '&APP_UID=' . $_POST['appDocId'] ); + G::RenderPage( 'publish', 'raw' ); + break; + case "inputDocumentVersionHistory": //krumo($_POST); - $G_PUBLISH = new Publisher(); - $Fields['DOC_UID'] = $_POST['docID']; - $Fields['APP_DOC_UID'] = $_POST['appDocId']; + $G_PUBLISH = new Publisher(); + $Fields['DOC_UID'] = $_POST['docID']; + $Fields['APP_DOC_UID'] = $_POST['appDocId']; $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'cases/cases_InputdocsListHistory', $oCase->getInputDocumentsCriteria( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_POST['docID'], $_POST['appDocId'] ), array () ); //$aFields //$G_PUBLISH->AddContent('xmlform', 'xmlform', 'cases/cases_AttachInputDocumentGeneral', // '', $Fields, 'cases_SaveDocument?UID=' . $_POST['docID']); - G::RenderPage( 'publish', 'raw' ); - break; - case "getCountCasesFolder": - $json = new Services_JSON(); - $aTypes = Array ('to_do','draft','cancelled','sent','paused','completed','selfservice','to_revise','to_reassign'); - $aTypesID = Array ('to_do' => 'CASES_INBOX','draft' => 'CASES_DRAFT','cancelled' => 'CASES_CANCELLED','sent' => 'CASES_SENT','paused' => 'CASES_PAUSED','completed' => 'CASES_COMPLETED','selfservice' => 'CASES_SELFSERVICE','to_revise' => 'CASES_TO_REVISE','to_reassign' => 'CASES_TO_REASSIGN'); - - if (! isset( $_POST['A'] )) { - $oCases = new Cases(); - $aCount = $oCases->getAllConditionCasesCount( $aTypes, true ); - echo $json->encode( $aCount ); - } else { - echo $json->encode( $aTypesID ); - } - break; - case "previusJump": - require_once 'classes/model/Application.php'; - - $oCriteria = new Criteria( 'workflow' ); - $response = array ("success" => true ); - - $oCriteria->add( ApplicationPeer::APP_NUMBER, $_POST['appNumber'] ); - $oDataset = ApplicationPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - $aApplication = $oDataset->getRow(); - - if (is_array( $aApplication )) { - $response['exists'] = true; - } else { - $response['exists'] = false; - } - - echo G::json_encode( $response ); - break; - default: - echo 'default'; -} - -function getCasesTypeIds () -{ - $aTypes = Array ('to_do','draft','cancelled','sent','paused','completed','selfservice','to_revise','to_reassign'); - return $aTypesID; -} - + G::RenderPage( 'publish', 'raw' ); + break; + case "getCountCasesFolder": + $json = new Services_JSON(); + $aTypes = Array ('to_do','draft','cancelled','sent','paused','completed','selfservice','to_revise','to_reassign'); + $aTypesID = Array ('to_do' => 'CASES_INBOX','draft' => 'CASES_DRAFT','cancelled' => 'CASES_CANCELLED','sent' => 'CASES_SENT','paused' => 'CASES_PAUSED','completed' => 'CASES_COMPLETED','selfservice' => 'CASES_SELFSERVICE','to_revise' => 'CASES_TO_REVISE','to_reassign' => 'CASES_TO_REASSIGN'); + + if (! isset( $_POST['A'] )) { + $oCases = new Cases(); + $aCount = $oCases->getAllConditionCasesCount( $aTypes, true ); + echo $json->encode( $aCount ); + } else { + echo $json->encode( $aTypesID ); + } + break; + case "previusJump": + require_once 'classes/model/Application.php'; + + $oCriteria = new Criteria( 'workflow' ); + $response = array ("success" => true ); + + $oCriteria->add( ApplicationPeer::APP_NUMBER, $_POST['appNumber'] ); + $oDataset = ApplicationPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aApplication = $oDataset->getRow(); + + if (is_array( $aApplication )) { + $response['exists'] = true; + } else { + $response['exists'] = false; + } + + echo G::json_encode( $response ); + break; + default: + echo 'default'; +} + +function getCasesTypeIds () +{ + $aTypes = Array ('to_do','draft','cancelled','sent','paused','completed','selfservice','to_revise','to_reassign'); + return $aTypesID; +} + diff --git a/workflow/engine/methods/cases/cases_CatchExecute.php b/workflow/engine/methods/cases/cases_CatchExecute.php index 2deba8920..9d39d48e3 100755 --- a/workflow/engine/methods/cases/cases_CatchExecute.php +++ b/workflow/engine/methods/cases/cases_CatchExecute.php @@ -1,65 +1,65 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ - -/* Permissions */ -switch ($RBAC->userCanAccess( 'PM_CASES' )) { - case - 2: - G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); - G::header( 'location: ../login/login' ); - die(); - break; - case - 1: - G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); - G::header( 'location: ../login/login' ); - die(); - break; -} - -if (isset( $_POST['form']['BTN_CANCEL'] )) { - header( "Location: ../cases/main" ); - die(); -} - -/* Includes */ -G::LoadClass( 'case' ); - -$oCase = new Cases(); -$sAppUid = $_SESSION['APPLICATION']; -$iDelIndex = $_SESSION['INDEX']; - -$oAppDelegation = new AppDelegation(); -$aDelegation = $oAppDelegation->load( $sAppUid, $iDelIndex ); - +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ + +/* Permissions */ +switch ($RBAC->userCanAccess( 'PM_CASES' )) { + case - 2: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; + case - 1: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; +} + +if (isset( $_POST['form']['BTN_CANCEL'] )) { + header( "Location: ../cases/main" ); + die(); +} + +/* Includes */ +G::LoadClass( 'case' ); + +$oCase = new Cases(); +$sAppUid = $_SESSION['APPLICATION']; +$iDelIndex = $_SESSION['INDEX']; + +$oAppDelegation = new AppDelegation(); +$aDelegation = $oAppDelegation->load( $sAppUid, $iDelIndex ); + //if there are no user in the delegation row, this case is still in selfservice -if ($aDelegation['USR_UID'] == "") { - $oCase->setCatchUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'] ); -} else { - G::SendMessageText( G::LoadTranslation( 'ID_CASE_ALREADY_DERIVATED' ), 'error' ); -} - -$validation = (SYS_SKIN != 'uxs') ? 'true' : 'false'; - +if ($aDelegation['USR_UID'] == "") { + $oCase->setCatchUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'] ); +} else { + G::SendMessageText( G::LoadTranslation( 'ID_CASE_ALREADY_DERIVATED' ), 'error' ); +} + +$validation = (SYS_SKIN != 'uxs') ? 'true' : 'false'; + die( '' ); - + ' ); + diff --git a/workflow/engine/methods/cases/cases_CatchSelfService.php b/workflow/engine/methods/cases/cases_CatchSelfService.php index 29e6df412..a66a41688 100755 --- a/workflow/engine/methods/cases/cases_CatchSelfService.php +++ b/workflow/engine/methods/cases/cases_CatchSelfService.php @@ -1,90 +1,90 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ -/* Permissions */ -switch ($RBAC->userCanAccess( 'PM_CASES' )) { - case - 2: - G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); - G::header( 'location: ../login/login' ); - die(); - break; - case - 1: - G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); - G::header( 'location: ../login/login' ); - die(); - break; -} - -/* Includes */ -G::LoadClass( 'case' ); - -$oCase = new Cases(); -$Fields = $oCase->loadCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'] ); - -/* Render page */ -require_once 'classes/model/Process.php'; -require_once 'classes/model/Task.php'; - -$objProc = new Process(); -$aProc = $objProc->load( $Fields['PRO_UID'] ); -$Fields['PRO_TITLE'] = $aProc['PRO_TITLE']; - -$objTask = new Task(); -$aTask = $objTask->load( $Fields['TAS_UID'] ); -$Fields['TAS_TITLE'] = $aTask['TAS_TITLE']; - -$Fields['STATUS'] .= ' ( ' . G::LoadTranslation( 'ID_UNASSIGNED' ) . ' )'; - +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ +/* Permissions */ +switch ($RBAC->userCanAccess( 'PM_CASES' )) { + case - 2: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; + case - 1: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; +} + +/* Includes */ +G::LoadClass( 'case' ); + +$oCase = new Cases(); +$Fields = $oCase->loadCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'] ); + +/* Render page */ +require_once 'classes/model/Process.php'; +require_once 'classes/model/Task.php'; + +$objProc = new Process(); +$aProc = $objProc->load( $Fields['PRO_UID'] ); +$Fields['PRO_TITLE'] = $aProc['PRO_TITLE']; + +$objTask = new Task(); +$aTask = $objTask->load( $Fields['TAS_UID'] ); +$Fields['TAS_TITLE'] = $aTask['TAS_TITLE']; + +$Fields['STATUS'] .= ' ( ' . G::LoadTranslation( 'ID_UNASSIGNED' ) . ' )'; + //now getting information about the PREVIOUS task. If is the first task then no preious, use 1 -$oAppDel = new AppDelegation(); -$oAppDel->Load( $Fields['APP_UID'], ($Fields['DEL_PREVIOUS'] == 0 ? $Fields['DEL_PREVIOUS'] = 1 : $Fields['DEL_PREVIOUS']) ); - -$aAppDel = $oAppDel->toArray( BasePeer::TYPE_FIELDNAME ); -try { - $oCurUser = new Users(); - $oCurUser->load( $aAppDel['USR_UID'] ); - $Fields['PREVIOUS_USER'] = $oCurUser->getUsrFirstname() . ' ' . $oCurUser->getUsrLastname(); -} catch (Exception $oError) { - $Fields['PREVIOUS_USER'] = ''; -} - -$objTask = new Task(); -$aTask = $objTask->load( $aAppDel['TAS_UID'] ); -$Fields['PREVIOUS_TASK'] = $aTask['TAS_TITLE']; - +$oAppDel = new AppDelegation(); +$oAppDel->Load( $Fields['APP_UID'], ($Fields['DEL_PREVIOUS'] == 0 ? $Fields['DEL_PREVIOUS'] = 1 : $Fields['DEL_PREVIOUS']) ); + +$aAppDel = $oAppDel->toArray( BasePeer::TYPE_FIELDNAME ); +try { + $oCurUser = new Users(); + $oCurUser->load( $aAppDel['USR_UID'] ); + $Fields['PREVIOUS_USER'] = $oCurUser->getUsrFirstname() . ' ' . $oCurUser->getUsrLastname(); +} catch (Exception $oError) { + $Fields['PREVIOUS_USER'] = ''; +} + +$objTask = new Task(); +$aTask = $objTask->load( $aAppDel['TAS_UID'] ); +$Fields['PREVIOUS_TASK'] = $aTask['TAS_TITLE']; + //To enable information (dynaforms, steps) before claim a case -$_SESSION['bNoShowSteps'] = true; -$G_MAIN_MENU = 'processmaker'; -$G_SUB_MENU = 'caseOptions'; -$G_ID_MENU_SELECTED = 'CASES'; -$G_ID_SUB_MENU_SELECTED = '_'; -$oHeadPublisher = & headPublisher::getSingleton(); +$_SESSION['bNoShowSteps'] = true; +$G_MAIN_MENU = 'processmaker'; +$G_SUB_MENU = 'caseOptions'; +$G_ID_MENU_SELECTED = 'CASES'; +$G_ID_SUB_MENU_SELECTED = '_'; +$oHeadPublisher = & headPublisher::getSingleton(); $oHeadPublisher->addScriptCode( " if (typeof parent != 'undefined') { if (parent.showCaseNavigatorPanel) { parent.showCaseNavigatorPanel('{$Fields['APP_STATUS']}'); } -}" ); +}" ); $oHeadPublisher->addScriptCode( ' var Cse = {}; Cse.panels = {}; @@ -96,11 +96,11 @@ $oHeadPublisher->addScriptCode( ' leimnud.Package.Load("cases_Step",{Type:"file",Absolute:true,Path:"/jscore/cases/core/cases_Step.js"}); leimnud.Package.Load("processmap",{Type:"file",Absolute:true,Path:"/jscore/processmap/core/processmap.js"}); leimnud.exec(leimnud.fix.memoryLeak); - ' ); -$oHeadPublisher = & headPublisher::getSingleton(); -$oHeadPublisher->addScriptFile( '/jscore/cases/core/cases_Step.js' ); - -$G_PUBLISH = new Publisher(); -$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_CatchSelfService.xml', '', $Fields, 'cases_CatchExecute' ); -G::RenderPage( 'publish', 'blank' ); - + ' ); +$oHeadPublisher = & headPublisher::getSingleton(); +$oHeadPublisher->addScriptFile( '/jscore/cases/core/cases_Step.js' ); + +$G_PUBLISH = new Publisher(); +$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_CatchSelfService.xml', '', $Fields, 'cases_CatchExecute' ); +G::RenderPage( 'publish', 'blank' ); + diff --git a/workflow/engine/methods/cases/cases_Delete.php b/workflow/engine/methods/cases/cases_Delete.php index 29d0bc3ef..5fa4c0182 100755 --- a/workflow/engine/methods/cases/cases_Delete.php +++ b/workflow/engine/methods/cases/cases_Delete.php @@ -1,57 +1,59 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ -/* Permissions */ -switch ($RBAC->userCanAccess( 'PM_CASES' )) { - case - 2: - G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); - G::header( 'location: ../login/login' ); - die(); - break; - case - 1: - G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); - G::header( 'location: ../login/login' ); - die(); - break; -} - -/* Includes */ -G::LoadClass( 'case' ); - -/* Process the info */ -try { - $oCase = new Cases(); - if (isset( $_POST['APP_UIDS'] )) { - $ids = explode( ',', $_POST['APP_UIDS'] ); - foreach ($ids as $id) - $oCase->removeCase( $id ); - - if (count( $_POST['APP_UIDS'] ) > 1) - echo 'The Case was deleted successfully'; - else - echo 'All Cases were deleted successfully'; - } -} catch (Exception $e) { - echo $e->getMessage(); +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ +/* Permissions */ +switch ($RBAC->userCanAccess( 'PM_CASES' )) { + case - 2: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; + case - 1: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; +} + +/* Includes */ +G::LoadClass( 'case' ); + +/* Process the info */ +try { + $oCase = new Cases(); + if (isset( $_POST['APP_UIDS'] )) { + $ids = explode( ',', $_POST['APP_UIDS'] ); + foreach ($ids as $id) { + $oCase->removeCase( $id ); + } + + if (count( $_POST['APP_UIDS'] ) > 1) { + echo 'The Case was deleted successfully'; + } else { + echo 'All Cases were deleted successfully'; + } + } +} catch (Exception $e) { + echo $e->getMessage(); } diff --git a/workflow/engine/methods/cases/cases_DeleteDocument.php b/workflow/engine/methods/cases/cases_DeleteDocument.php index 90e77b7c5..6c3a589a8 100755 --- a/workflow/engine/methods/cases/cases_DeleteDocument.php +++ b/workflow/engine/methods/cases/cases_DeleteDocument.php @@ -1,59 +1,59 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ -/* Permissions */ -switch ($RBAC->userCanAccess( 'PM_CASES' )) { - case - 2: - G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); - G::header( 'location: ../login/login' ); - die(); - break; - case - 1: - G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); - G::header( 'location: ../login/login' ); - die(); - break; -} - -/* Includes */ -require_once ("classes/model/AppDocumentPeer.php"); -G::LoadClass( 'case' ); - +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ +/* Permissions */ +switch ($RBAC->userCanAccess( 'PM_CASES' )) { + case - 2: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; + case - 1: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; +} + +/* Includes */ +require_once ("classes/model/AppDocumentPeer.php"); +G::LoadClass( 'case' ); + /* GET , POST & $_SESSION Vars */ /* Process the info */ -$oAppDocument = new AppDocument(); -$oAppDocument->remove( $_GET['DOC'] ); -$oCase = new Cases(); -$oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'cases_List' ); -if ($_GET['TYPE'] == 'INPUT') { - $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] - 1 ); -} -if ($_GET['TYPE'] == 'OUTPUT') { - $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] ); -} -$_SESSION['STEP_POSITION'] = $aNextStep['POSITION']; - -/* Redirect */ -G::header( 'location: ' . $aNextStep['PAGE'] ); - +$oAppDocument = new AppDocument(); +$oAppDocument->remove( $_GET['DOC'] ); +$oCase = new Cases(); +$oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'cases_List' ); +if ($_GET['TYPE'] == 'INPUT') { + $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] - 1 ); +} +if ($_GET['TYPE'] == 'OUTPUT') { + $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] ); +} +$_SESSION['STEP_POSITION'] = $aNextStep['POSITION']; + +/* Redirect */ +G::header( 'location: ' . $aNextStep['PAGE'] ); + diff --git a/workflow/engine/methods/cases/cases_DeleteDocumentToRevise.php b/workflow/engine/methods/cases/cases_DeleteDocumentToRevise.php index 5569d6595..3980caa86 100644 --- a/workflow/engine/methods/cases/cases_DeleteDocumentToRevise.php +++ b/workflow/engine/methods/cases/cases_DeleteDocumentToRevise.php @@ -1,50 +1,50 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ -/* Permissions */ -switch ($RBAC->userCanAccess( 'PM_CASES' )) { - case - 2: - G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); - G::header( 'location: ../login/login' ); - die(); - break; - case - 1: - G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); - G::header( 'location: ../login/login' ); - die(); - break; -} - -/* Includes */ -require_once ("classes/model/AppDocumentPeer.php"); -G::LoadClass( 'case' ); - +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ +/* Permissions */ +switch ($RBAC->userCanAccess( 'PM_CASES' )) { + case - 2: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; + case - 1: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; +} + +/* Includes */ +require_once ("classes/model/AppDocumentPeer.php"); +G::LoadClass( 'case' ); + /* GET , POST & $_SESSION Vars */ /* Process the info */ -$oAppDocument = new AppDocument(); -$oAppDocument->remove( $_GET['DOC'] ); - -/* Redirect */ -G::header( 'location: ' . $_SERVER['HTTP_REFERER'] ); - +$oAppDocument = new AppDocument(); +$oAppDocument->remove( $_GET['DOC'] ); + +/* Redirect */ +G::header( 'location: ' . $_SERVER['HTTP_REFERER'] ); + diff --git a/workflow/engine/methods/cases/cases_Derivate.php b/workflow/engine/methods/cases/cases_Derivate.php index 369baa1ff..b8df8e4a9 100755 --- a/workflow/engine/methods/cases/cases_Derivate.php +++ b/workflow/engine/methods/cases/cases_Derivate.php @@ -1,185 +1,185 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ - -/* Permissions */ -switch ($RBAC->userCanAccess( 'PM_CASES' )) { - case - 2: - G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); - G::header( 'location: ../login/login' ); - die(); - break; - case - 1: - G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); - G::header( 'location: ../login/login' ); - die(); - break; -} - -/* Includes */ -G::LoadClass( 'pmScript' ); -G::LoadClass( 'case' ); -G::LoadClass( 'derivation' ); - -require_once 'classes/model/Event.php'; - +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ + +/* Permissions */ +switch ($RBAC->userCanAccess( 'PM_CASES' )) { + case - 2: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; + case - 1: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; +} + +/* Includes */ +G::LoadClass( 'pmScript' ); +G::LoadClass( 'case' ); +G::LoadClass( 'derivation' ); + +require_once 'classes/model/Event.php'; + /* GET , POST & $_SESSION Vars */ /* Process the info */ -$sStatus = 'TO_DO'; -foreach ($_POST['form']['TASKS'] as $aValues) { -} - -try { +$sStatus = 'TO_DO'; +foreach ($_POST['form']['TASKS'] as $aValues) { +} + +try { //load data - $oCase = new Cases(); + $oCase = new Cases(); //warning: we are not using the result value of function thisIsTheCurrentUser, so I'm commenting to optimize speed. //$oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'cases_List'); - $appFields = $oCase->loadCase( $_SESSION['APPLICATION'] ); - $appFields['APP_DATA'] = array_merge( $appFields['APP_DATA'], G::getSystemConstants() ); + $appFields = $oCase->loadCase( $_SESSION['APPLICATION'] ); + $appFields['APP_DATA'] = array_merge( $appFields['APP_DATA'], G::getSystemConstants() ); //cleaning debug variables - $_SESSION['TRIGGER_DEBUG']['DATA'] = Array (); - $_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = Array (); - $_SESSION['TRIGGER_DEBUG']['TRIGGERS_VALUES'] = Array (); - - $triggers = $oCase->loadTriggers( $_SESSION['TASK'], 'ASSIGN_TASK', - 2, 'BEFORE' ); - + $_SESSION['TRIGGER_DEBUG']['DATA'] = Array (); + $_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = Array (); + $_SESSION['TRIGGER_DEBUG']['TRIGGERS_VALUES'] = Array (); + + $triggers = $oCase->loadTriggers( $_SESSION['TASK'], 'ASSIGN_TASK', - 2, 'BEFORE' ); + //if there are some triggers to execute - if (sizeof( $triggers ) > 0) { + if (sizeof( $triggers ) > 0) { //Execute triggers before derivation - $appFields['APP_DATA'] = $oCase->ExecuteTriggers( $_SESSION['TASK'], 'ASSIGN_TASK', - 2, 'BEFORE', $appFields['APP_DATA'] ); - + $appFields['APP_DATA'] = $oCase->ExecuteTriggers( $_SESSION['TASK'], 'ASSIGN_TASK', - 2, 'BEFORE', $appFields['APP_DATA'] ); + //save trigger variables for debugger - $_SESSION['TRIGGER_DEBUG']['info'][0]['NUM_TRIGGERS'] = sizeof( $triggers ); - $_SESSION['TRIGGER_DEBUG']['info'][0]['TIME'] = 'BEFORE'; - $_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_NAMES'] = $oCase->getTriggerNames( $triggers ); - $_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_VALUES'] = $triggers; - } - - $appFields['DEL_INDEX'] = $_SESSION['INDEX']; - $appFields['TAS_UID'] = $_SESSION['TASK']; - + $_SESSION['TRIGGER_DEBUG']['info'][0]['NUM_TRIGGERS'] = sizeof( $triggers ); + $_SESSION['TRIGGER_DEBUG']['info'][0]['TIME'] = 'BEFORE'; + $_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_NAMES'] = $oCase->getTriggerNames( $triggers ); + $_SESSION['TRIGGER_DEBUG']['info'][0]['TRIGGERS_VALUES'] = $triggers; + } + + $appFields['DEL_INDEX'] = $_SESSION['INDEX']; + $appFields['TAS_UID'] = $_SESSION['TASK']; + $oCase->updateCase( $_SESSION['APPLICATION'], $appFields ); //Save data - - + + //derivate case - $oDerivation = new Derivation(); - $aCurrentDerivation = array ('APP_UID' => $_SESSION['APPLICATION'],'DEL_INDEX' => $_SESSION['INDEX'],'APP_STATUS' => $sStatus,'TAS_UID' => $_SESSION['TASK'],'ROU_TYPE' => $_POST['form']['ROU_TYPE'] - ); - - $oDerivation->derivate( $aCurrentDerivation, $_POST['form']['TASKS'] ); - + $oDerivation = new Derivation(); + $aCurrentDerivation = array ('APP_UID' => $_SESSION['APPLICATION'],'DEL_INDEX' => $_SESSION['INDEX'],'APP_STATUS' => $sStatus,'TAS_UID' => $_SESSION['TASK'],'ROU_TYPE' => $_POST['form']['ROU_TYPE'] + ); + + $oDerivation->derivate( $aCurrentDerivation, $_POST['form']['TASKS'] ); + $appFields = $oCase->loadCase( $_SESSION['APPLICATION'] ); //refresh appFields, because in derivations should change some values $triggers = $oCase->loadTriggers( $_SESSION['TASK'], 'ASSIGN_TASK', - 2, 'AFTER' ); //load the triggers after derivation - if (sizeof( $triggers ) > 0) { + if (sizeof( $triggers ) > 0) { $appFields['APP_DATA'] = $oCase->ExecuteTriggers( $_SESSION['TASK'], 'ASSIGN_TASK', - 2, 'AFTER', $appFields['APP_DATA'] ); //Execute triggers after derivation - - - $_SESSION['TRIGGER_DEBUG']['info'][1]['NUM_TRIGGERS'] = sizeof( $triggers ); - $_SESSION['TRIGGER_DEBUG']['info'][1]['TIME'] = 'AFTER'; - $_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_NAMES'] = $oCase->getTriggerNames( $triggers ); - $_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_VALUES'] = $triggers; - } - $oCase->updateCase( $_SESSION['APPLICATION'], $appFields ); - + + + $_SESSION['TRIGGER_DEBUG']['info'][1]['NUM_TRIGGERS'] = sizeof( $triggers ); + $_SESSION['TRIGGER_DEBUG']['info'][1]['TIME'] = 'AFTER'; + $_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_NAMES'] = $oCase->getTriggerNames( $triggers ); + $_SESSION['TRIGGER_DEBUG']['info'][1]['TRIGGERS_VALUES'] = $triggers; + } + $oCase->updateCase( $_SESSION['APPLICATION'], $appFields ); + // Send notifications - Start - $oUser = new Users(); - $aUser = $oUser->load( $_SESSION['USER_LOGGED'] ); - if (trim( $aUser['USR_EMAIL'] ) == '') { - $aUser['USR_EMAIL'] = 'info@' . $_SERVER['HTTP_HOST']; - } - $sFromName = '"' . $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . '" <' . $aUser['USR_EMAIL'] . '>'; - try { - $oCase->sendNotifications( $_SESSION['TASK'], $_POST['form']['TASKS'], $appFields['APP_DATA'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $sFromName ); - } catch (Exception $e) { - G::SendTemporalMessage( G::loadTranslation( 'ID_NOTIFICATION_ERROR' ) . ' - ' . $e->getMessage(), 'warning', 'string', null, '100%' ); - } + $oUser = new Users(); + $aUser = $oUser->load( $_SESSION['USER_LOGGED'] ); + if (trim( $aUser['USR_EMAIL'] ) == '') { + $aUser['USR_EMAIL'] = 'info@' . $_SERVER['HTTP_HOST']; + } + $sFromName = '"' . $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . '" <' . $aUser['USR_EMAIL'] . '>'; + try { + $oCase->sendNotifications( $_SESSION['TASK'], $_POST['form']['TASKS'], $appFields['APP_DATA'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $sFromName ); + } catch (Exception $e) { + G::SendTemporalMessage( G::loadTranslation( 'ID_NOTIFICATION_ERROR' ) . ' - ' . $e->getMessage(), 'warning', 'string', null, '100%' ); + } // Send notifications - End - - + + // Events - Start - $oEvent = new Event(); - - $oEvent->closeAppEvents( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['TASK'] ); - $oCurrentAppDel = AppDelegationPeer::retrieveByPk( $_SESSION['APPLICATION'], $_SESSION['INDEX'] + 1 ); - $multipleDelegation = false; + $oEvent = new Event(); + + $oEvent->closeAppEvents( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['TASK'] ); + $oCurrentAppDel = AppDelegationPeer::retrieveByPk( $_SESSION['APPLICATION'], $_SESSION['INDEX'] + 1 ); + $multipleDelegation = false; // check if there are multiple derivations - if (count( $_POST['form']['TASKS'] ) > 1) { - $multipleDelegation = true; - } + if (count( $_POST['form']['TASKS'] ) > 1) { + $multipleDelegation = true; + } // If the case has been delegated - if (isset( $oCurrentAppDel )) { + if (isset( $oCurrentAppDel )) { // if there is just a single derivation the TASK_UID can be set by the delegation data - if (! $multipleDelegation) { - $aCurrentAppDel = $oCurrentAppDel->toArray( BasePeer::TYPE_FIELDNAME ); - $oEvent->createAppEvents( $aCurrentAppDel['PRO_UID'], $aCurrentAppDel['APP_UID'], $aCurrentAppDel['DEL_INDEX'], $aCurrentAppDel['TAS_UID'] ); - } else { + if (! $multipleDelegation) { + $aCurrentAppDel = $oCurrentAppDel->toArray( BasePeer::TYPE_FIELDNAME ); + $oEvent->createAppEvents( $aCurrentAppDel['PRO_UID'], $aCurrentAppDel['APP_UID'], $aCurrentAppDel['DEL_INDEX'], $aCurrentAppDel['TAS_UID'] ); + } else { // else we need to check every task and create the events if it have any - foreach ($_POST['form']['TASKS'] as $taskDelegated) { - $aCurrentAppDel = $oCurrentAppDel->toArray( BasePeer::TYPE_FIELDNAME ); - $oEvent->createAppEvents( $aCurrentAppDel['PRO_UID'], $aCurrentAppDel['APP_UID'], $aCurrentAppDel['DEL_INDEX'], $taskDelegated['TAS_UID'] ); - } - } - } + foreach ($_POST['form']['TASKS'] as $taskDelegated) { + $aCurrentAppDel = $oCurrentAppDel->toArray( BasePeer::TYPE_FIELDNAME ); + $oEvent->createAppEvents( $aCurrentAppDel['PRO_UID'], $aCurrentAppDel['APP_UID'], $aCurrentAppDel['DEL_INDEX'], $taskDelegated['TAS_UID'] ); + } + } + } //Events - End - $debuggerAvailable = true; - - if (isset( $_SESSION['user_experience'] )) { - $aNextStep['PAGE'] = 'casesListExtJsRedirector?ux=' . $_SESSION['user_experience']; - $debuggerAvailable = false; - } else { - $aNextStep['PAGE'] = 'casesListExtJsRedirector'; - } - - if (isset( $_SESSION['PMDEBUGGER'] ) && $_SESSION['PMDEBUGGER'] && $debuggerAvailable) { - $_SESSION['TRIGGER_DEBUG']['BREAKPAGE'] = $aNextStep['PAGE']; - $loc = 'cases_Step?' . 'breakpoint=triggerdebug'; - } else { - $loc = $aNextStep['PAGE']; - } + $debuggerAvailable = true; + + if (isset( $_SESSION['user_experience'] )) { + $aNextStep['PAGE'] = 'casesListExtJsRedirector?ux=' . $_SESSION['user_experience']; + $debuggerAvailable = false; + } else { + $aNextStep['PAGE'] = 'casesListExtJsRedirector'; + } + + if (isset( $_SESSION['PMDEBUGGER'] ) && $_SESSION['PMDEBUGGER'] && $debuggerAvailable) { + $_SESSION['TRIGGER_DEBUG']['BREAKPAGE'] = $aNextStep['PAGE']; + $loc = 'cases_Step?' . 'breakpoint=triggerdebug'; + } else { + $loc = $aNextStep['PAGE']; + } //Triggers After - if (isset( $_SESSION['TRIGGER_DEBUG']['ISSET'] )) { - if ($_SESSION['TRIGGER_DEBUG']['ISSET'] == 1) { - $oTemplatePower = new TemplatePower( PATH_TPL . 'cases/cases_Step.html' ); - $oTemplatePower->prepare(); - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'template', '', '', '', $oTemplatePower ); - $_POST['NextStep'] = $loc; - $G_PUBLISH->AddContent( 'view', 'cases/showDebugFrameLoader' ); - $G_PUBLISH->AddContent( 'view', 'cases/showDebugFrameBreaker' ); - $_SESSION['TRIGGER_DEBUG']['ISSET'] == 0; - G::RenderPage( 'publish', 'blank' ); - exit(); - } else { - unset( $_SESSION['TRIGGER_DEBUG'] ); - } - } - - G::header( "location: $loc" ); -} catch (Exception $e) { - $aMessage = array (); - $aMessage['MESSAGE'] = $e->getMessage() . '
' . $e->getTraceAsString(); - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); - G::RenderPage( 'publish', 'blank' ); -} - + if (isset( $_SESSION['TRIGGER_DEBUG']['ISSET'] )) { + if ($_SESSION['TRIGGER_DEBUG']['ISSET'] == 1) { + $oTemplatePower = new TemplatePower( PATH_TPL . 'cases/cases_Step.html' ); + $oTemplatePower->prepare(); + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'template', '', '', '', $oTemplatePower ); + $_POST['NextStep'] = $loc; + $G_PUBLISH->AddContent( 'view', 'cases/showDebugFrameLoader' ); + $G_PUBLISH->AddContent( 'view', 'cases/showDebugFrameBreaker' ); + $_SESSION['TRIGGER_DEBUG']['ISSET'] == 0; + G::RenderPage( 'publish', 'blank' ); + exit(); + } else { + unset( $_SESSION['TRIGGER_DEBUG'] ); + } + } + + G::header( "location: $loc" ); +} catch (Exception $e) { + $aMessage = array (); + $aMessage['MESSAGE'] = $e->getMessage() . '
' . $e->getTraceAsString(); + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); + G::RenderPage( 'publish', 'blank' ); +} + diff --git a/workflow/engine/methods/cases/cases_List.php b/workflow/engine/methods/cases/cases_List.php index dba1e1488..714c862f4 100755 --- a/workflow/engine/methods/cases/cases_List.php +++ b/workflow/engine/methods/cases/cases_List.php @@ -1,111 +1,113 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ - -/** - * Cases list (Refactored) - * By Erik A. - * O. - */ - -/* Permissions */ -if (($RBAC_Response = $RBAC->userCanAccess( "PM_CASES" )) != 1) - return $RBAC_Response; - - /* Includes */ -G::LoadClass( 'case' ); -G::LoadClass( 'configuration' ); - +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ + +/** + * Cases list (Refactored) + * By Erik A. + * O. + */ + +/* Permissions */ +if (($RBAC_Response = $RBAC->userCanAccess( "PM_CASES" )) != 1) { + return $RBAC_Response; +} + + /* Includes */ +G::LoadClass( 'case' ); +G::LoadClass( 'configuration' ); + // $_GET['l'] has the type of cases list like todo,pause,cancel, all - - -$conf = new Configurations(); -if (! isset( $_GET['l'] )) { - $confCasesList = $conf->loadObject( 'ProcessMaker', 'cases_List', '', $_SESSION['USER_LOGGED'], '' ); - if (is_array( $confCasesList )) { - $sTypeList = $confCasesList['sTypeList']; - } else { - $sTypeList = 'to_do'; - } -} else { - $sTypeList = $_GET['l']; - $confCasesList = array ('sTypeList' => $sTypeList - ); - $conf->saveObject( $confCasesList, 'ProcessMaker', 'cases_List', '', $_SESSION['USER_LOGGED'], '' ); -} - -$sUIDUserLogged = $_SESSION['USER_LOGGED']; -$_SESSION['CASES_MENU_OPTION'] = $sTypeList; - -$oCases = new Cases(); - -/** - * here we verify if there is a any case with a unpause on this day - */ -if ($sTypeList === 'to_do' or $sTypeList === 'draft' or $sTypeList === 'paused') { - $oCases->ThrowUnpauseDaemon( date( 'Y-m-d' ) ); -} - + + +$conf = new Configurations(); +if (! isset( $_GET['l'] )) { + $confCasesList = $conf->loadObject( 'ProcessMaker', 'cases_List', '', $_SESSION['USER_LOGGED'], '' ); + if (is_array( $confCasesList )) { + $sTypeList = $confCasesList['sTypeList']; + } else { + $sTypeList = 'to_do'; + } +} else { + $sTypeList = $_GET['l']; + $confCasesList = array ('sTypeList' => $sTypeList + ); + $conf->saveObject( $confCasesList, 'ProcessMaker', 'cases_List', '', $_SESSION['USER_LOGGED'], '' ); +} + +$sUIDUserLogged = $_SESSION['USER_LOGGED']; +$_SESSION['CASES_MENU_OPTION'] = $sTypeList; + +$oCases = new Cases(); + +/** + * here we verify if there is a any case with a unpause on this day + */ +if ($sTypeList === 'to_do' or $sTypeList === 'draft' or $sTypeList === 'paused') { + $oCases->ThrowUnpauseDaemon( date( 'Y-m-d' ) ); +} + /* * * Prepare the addtional filters before to show * By Erik - */ - -$aAdditionalFilter = Array (); - -if (isset( $_GET['PROCESS_UID'] ) and $_GET['PROCESS_UID'] != "0" && $_GET['PROCESS_UID'] != "") { - $PRO_UID = $_GET['PROCESS_UID']; - $aAdditionalFilter['PRO_UID'] = $PRO_UID; -} else { - $PRO_UID = "0"; -} -if (isset( $_GET['READ'] ) and $_GET['READ'] == "1") { - $aAdditionalFilter['READ'] = $_GET['READ']; -} -if (isset( $_GET['UNREAD'] ) and $_GET['UNREAD'] == "1") { - $aAdditionalFilter['UNREAD'] = $_GET['UNREAD']; -} - -if (isset( $_GET['APP_STATUS_FILTER'] ) and $_GET['APP_STATUS_FILTER'] != "ALL") { - $aAdditionalFilter['APP_STATUS_FILTER'] = $_GET['APP_STATUS_FILTER']; -} - -if (isset( $_GET['MINE'] ) and $_GET['MINE'] == "1") { - $aAdditionalFilter['MINE'] = $_GET['MINE']; -} - -switch ($sTypeList) { - case 'to_do': - if (defined( 'ENABLE_CASE_LIST_OPTIMIZATION' )) { - $aCriteria = $oCases->prepareCriteriaForToDo( $sUIDUserLogged ); - $xmlfile = 'cases/cases_ListTodoNew'; - } else - list ($aCriteria, $xmlfile) = $oCases->getConditionCasesList( $sTypeList, $sUIDUserLogged, true, $aAdditionalFilter ); - break; - default: - list ($aCriteria, $xmlfile) = $oCases->getConditionCasesList( $sTypeList, $sUIDUserLogged, true, $aAdditionalFilter ); -} - + */ + +$aAdditionalFilter = Array (); + +if (isset( $_GET['PROCESS_UID'] ) and $_GET['PROCESS_UID'] != "0" && $_GET['PROCESS_UID'] != "") { + $PRO_UID = $_GET['PROCESS_UID']; + $aAdditionalFilter['PRO_UID'] = $PRO_UID; +} else { + $PRO_UID = "0"; +} +if (isset( $_GET['READ'] ) and $_GET['READ'] == "1") { + $aAdditionalFilter['READ'] = $_GET['READ']; +} +if (isset( $_GET['UNREAD'] ) and $_GET['UNREAD'] == "1") { + $aAdditionalFilter['UNREAD'] = $_GET['UNREAD']; +} + +if (isset( $_GET['APP_STATUS_FILTER'] ) and $_GET['APP_STATUS_FILTER'] != "ALL") { + $aAdditionalFilter['APP_STATUS_FILTER'] = $_GET['APP_STATUS_FILTER']; +} + +if (isset( $_GET['MINE'] ) and $_GET['MINE'] == "1") { + $aAdditionalFilter['MINE'] = $_GET['MINE']; +} + +switch ($sTypeList) { + case 'to_do': + if (defined( 'ENABLE_CASE_LIST_OPTIMIZATION' )) { + $aCriteria = $oCases->prepareCriteriaForToDo( $sUIDUserLogged ); + $xmlfile = 'cases/cases_ListTodoNew'; + } else { + list ($aCriteria, $xmlfile) = $oCases->getConditionCasesList( $sTypeList, $sUIDUserLogged, true, $aAdditionalFilter ); + } + break; + default: + list ($aCriteria, $xmlfile) = $oCases->getConditionCasesList( $sTypeList, $sUIDUserLogged, true, $aAdditionalFilter ); +} + /* $rs = ApplicationPeer::doSelectRS($aCriteria); $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); @@ -118,52 +120,52 @@ $rs = ApplicationPeer::doSelectRS($aCriteria); g::pr($aRows1);die;*/ /* GET , POST & $_SESSION Vars */ -if (! isset( $_GET['PROCESS_UID'] )) { - $oCase = new Cases(); - $rs = ApplicationPeer::doSelectRS( $aCriteria ); - $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - - $aProcess = Array (); - while ($rs->next()) { - $aRow = $rs->getRow(); - //g::pr($aRow); die; - if (! InAssocArray( $aRow, 'PRO_UID', $aRow['PRO_UID'] )) { - array_push( $aProcess, Array ('PRO_UID' => $aRow['PRO_UID'],'PRO_TITLE' => $aRow['APP_PRO_TITLE'] ) ); - } - } - - $_DBArray['_PROCESSES'] = array_merge( Array (Array ('PRO_UID' => 'char','PRO_TITLE' => 'char' ) ), $aProcess ); - $_SESSION['_DBArray'] = $_DBArray; -} else { - $_DBArray = $_SESSION['_DBArray']; -} - -/* Render page */ -$G_PUBLISH = new Publisher(); -$G_PUBLISH->ROWS_PER_PAGE = 12; - -if ($sTypeList == 'to_reassign') { - $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_ReassignBy', '', array ('REASSIGN_BY' => 1 ) ); -} - -$aData = Array ('PROCESS_FILTER' => $PRO_UID,'APP_STATUS_FILTER' => (isset( $_GET['APP_STATUS_FILTER'] ) ? $_GET['APP_STATUS_FILTER'] : '0') -); - -$G_PUBLISH->AddContent( 'propeltable', 'paged-table', $xmlfile, $aCriteria, $aData ); - -G::RenderPage( 'publish', 'blank' ); - -function InAssocArray ($a, $k, $v) -{ - foreach ($a as $item) { - if (isset( $item[$k] ) && $v == $item[$k]) - return true; - } - return false; -} - -?> +if (! isset( $_GET['PROCESS_UID'] )) { + $oCase = new Cases(); + $rs = ApplicationPeer::doSelectRS( $aCriteria ); + $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $aProcess = Array (); + while ($rs->next()) { + $aRow = $rs->getRow(); + //g::pr($aRow); die; + if (! InAssocArray( $aRow, 'PRO_UID', $aRow['PRO_UID'] )) { + array_push( $aProcess, Array ('PRO_UID' => $aRow['PRO_UID'],'PRO_TITLE' => $aRow['APP_PRO_TITLE'] ) ); + } + } + + $_DBArray['_PROCESSES'] = array_merge( Array (Array ('PRO_UID' => 'char','PRO_TITLE' => 'char' ) ), $aProcess ); + $_SESSION['_DBArray'] = $_DBArray; +} else { + $_DBArray = $_SESSION['_DBArray']; +} + +/* Render page */ +$G_PUBLISH = new Publisher(); +$G_PUBLISH->ROWS_PER_PAGE = 12; + +if ($sTypeList == 'to_reassign') { + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_ReassignBy', '', array ('REASSIGN_BY' => 1 ) ); +} + +$aData = Array ('PROCESS_FILTER' => $PRO_UID,'APP_STATUS_FILTER' => (isset( $_GET['APP_STATUS_FILTER'] ) ? $_GET['APP_STATUS_FILTER'] : '0') +); + +$G_PUBLISH->AddContent( 'propeltable', 'paged-table', $xmlfile, $aCriteria, $aData ); + +G::RenderPage( 'publish', 'blank' ); + +function InAssocArray ($a, $k, $v) +{ + foreach ($a as $item) { + if (isset( $item[$k] ) && $v == $item[$k]) { + return true; + } + } + return false; +} + +?> - + +. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ //we're looking for the type of view -function putTypeView () -{ - require_once 'classes/model/Configuration.php'; - $oConfiguration = new Configuration(); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( ConfigurationPeer::CFG_UID, 'StartNewCase' ); - $oCriteria->add( ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED'] ); - - if (ConfigurationPeer::doCount( $oCriteria )) { - $conf = ConfigurationPeer::doSelect( $oCriteria ); - return $conf[0]->getCfgValue(); - } else { - return 'dropdown'; - } -} - -$_GET['change'] = (isset( $_GET['change'] )) ? $_GET['change'] : putTypeView(); - -/* Permissions */ -switch ($RBAC->userCanAccess( 'PM_CASES' )) { - case - 2: - G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); - G::header( 'location: ../login/login' ); - die(); - break; - - case - 1: - G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); - G::header( 'location: ../login/login' ); - die(); - break; -} - -/* Includes */ -G::LoadClass( 'case' ); - +function putTypeView () +{ + require_once 'classes/model/Configuration.php'; + $oConfiguration = new Configuration(); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( ConfigurationPeer::CFG_UID, 'StartNewCase' ); + $oCriteria->add( ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED'] ); + + if (ConfigurationPeer::doCount( $oCriteria )) { + $conf = ConfigurationPeer::doSelect( $oCriteria ); + return $conf[0]->getCfgValue(); + } else { + return 'dropdown'; + } +} + +$_GET['change'] = (isset( $_GET['change'] )) ? $_GET['change'] : putTypeView(); + +/* Permissions */ +switch ($RBAC->userCanAccess( 'PM_CASES' )) { + case - 2: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; + case - 1: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; +} + +/* Includes */ +G::LoadClass( 'case' ); + /* GET , POST & $_SESSION Vars */ /* Menues */ - $G_MAIN_MENU = 'processmaker'; -$G_SUB_MENU = 'cases'; -$G_ID_MENU_SELECTED = 'CASES'; -$G_ID_SUB_MENU_SELECTED = 'CASES_DRAFT'; - -/* Prepare page before to show */ -$aFields = array (); -$oCase = new Cases(); -$bCanStart = $oCase->canStartCase( $_SESSION['USER_LOGGED'] ); -if ($bCanStart) { - $aFields['LANG'] = SYS_LANG; - $aFields['USER'] = $_SESSION['USER_LOGGED']; - $sXmlForm = 'cases/cases_New.xml'; + $G_MAIN_MENU = 'processmaker'; +$G_SUB_MENU = 'cases'; +$G_ID_MENU_SELECTED = 'CASES'; +$G_ID_SUB_MENU_SELECTED = 'CASES_DRAFT'; + +/* Prepare page before to show */ +$aFields = array (); +$oCase = new Cases(); +$bCanStart = $oCase->canStartCase( $_SESSION['USER_LOGGED'] ); +if ($bCanStart) { + $aFields['LANG'] = SYS_LANG; + $aFields['USER'] = $_SESSION['USER_LOGGED']; + $sXmlForm = 'cases/cases_New.xml'; //$_DBArray['NewCase'] = $oCase->getStartCases( $_SESSION['USER_LOGGED'] ); - $_DBArray['NewCase'] = $oCase->getStartCasesPerType( $_SESSION['USER_LOGGED'], $_GET['change'] ); - -} else { - $sXmlForm = 'cases/cases_CannotInitiateCase.xml'; -} - -if (isset( $_SESSION['G_MESSAGE'] ) && strlen( $_SESSION['G_MESSAGE'] ) > 0) { - $aMessage = array (); - $aMessage['MESSAGE'] = $_SESSION['G_MESSAGE']; + $_DBArray['NewCase'] = $oCase->getStartCasesPerType( $_SESSION['USER_LOGGED'], $_GET['change'] ); + +} else { + $sXmlForm = 'cases/cases_CannotInitiateCase.xml'; +} + +if (isset( $_SESSION['G_MESSAGE'] ) && strlen( $_SESSION['G_MESSAGE'] ) > 0) { + $aMessage = array (); + $aMessage['MESSAGE'] = $_SESSION['G_MESSAGE']; //$_SESSION['G_MESSAGE_TYPE']; - unset( $_SESSION['G_MESSAGE'] ); - unset( $_SESSION['G_MESSAGE_TYPE'] ); -} - + unset( $_SESSION['G_MESSAGE'] ); + unset( $_SESSION['G_MESSAGE_TYPE'] ); +} + //get the config parameter to show in dropdown or list -require_once 'classes/model/Configuration.php'; -$oConfiguration = new Configuration(); -$oCriteria = new Criteria( 'workflow' ); -$oCriteria->add( ConfigurationPeer::CFG_UID, 'StartNewCase' ); -$oCriteria->add( ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED'] ); - -if (ConfigurationPeer::doCount( $oCriteria ) == 0) { - $aData['CFG_UID'] = 'StartNewCase'; - $aData['OBJ_UID'] = ''; - $aData['CFG_VALUE'] = 'dropdown'; - $aData['PRO_UID'] = ''; - $aData['USR_UID'] = $_SESSION['USER_LOGGED']; - $aData['APP_UID'] = ''; - - $oConfig = new Configuration(); - $oConfig->create( $aData ); - $listType = 'dropdown'; -} else { - $oConfiguration = new Configuration(); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( ConfigurationPeer::CFG_UID, 'StartNewCase' ); - $oCriteria->add( ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED'] ); - $conf = ConfigurationPeer::doSelect( $oCriteria ); - - $listType = $conf[0]->getCfgValue(); -} -if (isset( $_GET['change'] )) { - $listType = $_GET['change']; - $aData['CFG_UID'] = 'StartNewCase'; - $aData['OBJ_UID'] = ''; - $aData['CFG_VALUE'] = $listType; - $aData['PRO_UID'] = ''; - $aData['USR_UID'] = $_SESSION['USER_LOGGED']; - $aData['APP_UID'] = ''; - - $oConfig = new Configuration(); - $oConfig->update( $aData ); -} - -/* Render page */ -$G_PUBLISH = new Publisher(); -$aFields['CHANGE_LINK'] = G::LoadTranslation( 'ID_CHANGE_VIEW' ); - -if (isset( $aMessage )) { - $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); -} -if ($listType == 'dropdown') - $G_PUBLISH->AddContent( 'xmlform', 'xmlform', $sXmlForm, '', $aFields, 'cases_Save' ); - -if ($listType == 'link') { - if ($bCanStart) - $sXmlForm = 'cases/cases_NewRadioGroup.xml'; - $G_PUBLISH->AddContent( 'xmlform', 'xmlform', $sXmlForm, '', $aFields, 'cases_Save' ); -} - -if ($listType == 'category') { - if ($bCanStart) - $sXmlForm = 'cases/cases_NewCategory.xml'; - $G_PUBLISH->AddContent( 'view', 'cases/cases_NewCategory' ); -} - -G::RenderPage( 'publish', 'blank' ); - +require_once 'classes/model/Configuration.php'; +$oConfiguration = new Configuration(); +$oCriteria = new Criteria( 'workflow' ); +$oCriteria->add( ConfigurationPeer::CFG_UID, 'StartNewCase' ); +$oCriteria->add( ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED'] ); + +if (ConfigurationPeer::doCount( $oCriteria ) == 0) { + $aData['CFG_UID'] = 'StartNewCase'; + $aData['OBJ_UID'] = ''; + $aData['CFG_VALUE'] = 'dropdown'; + $aData['PRO_UID'] = ''; + $aData['USR_UID'] = $_SESSION['USER_LOGGED']; + $aData['APP_UID'] = ''; + + $oConfig = new Configuration(); + $oConfig->create( $aData ); + $listType = 'dropdown'; +} else { + $oConfiguration = new Configuration(); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( ConfigurationPeer::CFG_UID, 'StartNewCase' ); + $oCriteria->add( ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED'] ); + $conf = ConfigurationPeer::doSelect( $oCriteria ); + + $listType = $conf[0]->getCfgValue(); +} +if (isset( $_GET['change'] )) { + $listType = $_GET['change']; + $aData['CFG_UID'] = 'StartNewCase'; + $aData['OBJ_UID'] = ''; + $aData['CFG_VALUE'] = $listType; + $aData['PRO_UID'] = ''; + $aData['USR_UID'] = $_SESSION['USER_LOGGED']; + $aData['APP_UID'] = ''; + + $oConfig = new Configuration(); + $oConfig->update( $aData ); +} + +/* Render page */ +$G_PUBLISH = new Publisher(); +$aFields['CHANGE_LINK'] = G::LoadTranslation( 'ID_CHANGE_VIEW' ); + +if (isset( $aMessage )) { + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); +} +if ($listType == 'dropdown') { + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', $sXmlForm, '', $aFields, 'cases_Save' ); +} + +if ($listType == 'link') { + if ($bCanStart) { + $sXmlForm = 'cases/cases_NewRadioGroup.xml'; + } + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', $sXmlForm, '', $aFields, 'cases_Save' ); +} + +if ($listType == 'category') { + if ($bCanStart) { + $sXmlForm = 'cases/cases_NewCategory.xml'; + } + $G_PUBLISH->AddContent( 'view', 'cases/cases_NewCategory' ); +} + +G::RenderPage( 'publish', 'blank' ); + ?> - + + +. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ -if (($RBAC_Response = $RBAC->userCanAccess( "PM_CASES" )) != 1) - return $RBAC_Response; +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ +if (($RBAC_Response = $RBAC->userCanAccess( "PM_CASES" )) != 1) { + return $RBAC_Response; +} //go to the next step -G::LoadClass( 'case' ); -$oCase = new Cases(); -$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] ); -$_SESSION['STEP_POSITION'] = $aNextStep['POSITION']; -G::header( 'location: ' . $aNextStep['PAGE'] ); - +G::LoadClass( 'case' ); +$oCase = new Cases(); +$aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] ); +$_SESSION['STEP_POSITION'] = $aNextStep['POSITION']; +G::header( 'location: ' . $aNextStep['PAGE'] ); + diff --git a/workflow/engine/methods/cases/cases_Open.php b/workflow/engine/methods/cases/cases_Open.php index 5e244c744..238862fac 100755 --- a/workflow/engine/methods/cases/cases_Open.php +++ b/workflow/engine/methods/cases/cases_Open.php @@ -1,203 +1,202 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ - -/* Permissions */ -if ($RBAC->userCanAccess( 'PM_CASES' ) != 1) { - switch ($RBAC->userCanAccess( 'PM_CASES' )) { - case - 2: - G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); - G::header( 'location: ../login/login' ); - break; - case - 1: - default: - G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); - G::header( 'location: ../login/login' ); - break; - } -} - -/* Includes */ -require_once 'classes/model/AppDelay.php'; -G::LoadClass( 'case' ); - -$oCase = new Cases(); - -//cleaning the case session data -Cases::clearCaseSessionData(); - -try { - //Loading data for a Jump request - if (! isset( $_GET['APP_UID'] ) && isset( $_GET['APP_NUMBER'] )) { - $_GET['APP_UID'] = $oCase->getApplicationUIDByNumber( $_GET['APP_NUMBER'] ); - $_GET['DEL_INDEX'] = $oCase->getCurrentDelegation( $_GET['APP_UID'], $_SESSION['USER_LOGGED'] ); - - //if the application doesn't exist - if (is_null( $_GET['APP_UID'] )) { - G::SendMessageText( G::LoadTranslation( 'ID_CASE_DOES_NOT_EXISTS' ), 'info' ); - G::header( 'location: casesListExtJs' ); - exit(); - } - - //if the application exists but the - if (is_null( $_GET['DEL_INDEX'] )) { - G::SendMessageText( G::LoadTranslation( 'ID_CASE_IS_CURRENTLY_WITH_ANOTHER_USER' ), 'info' ); - G::header( 'location: casesListExtJs' ); - exit(); - } - //wrong implemented, need refactored - //$participated = $oCase->userParticipatedInCase($_GET['APP_UID'], $_SESSION['USER_LOGGED']); ??????? - } - - $sAppUid = $_GET['APP_UID']; - $iDelIndex = $_GET['DEL_INDEX']; - $_action = isset( $_GET['action'] ) ? $_GET['action'] : ''; - - //loading application data - $aFields = $oCase->loadCase( $sAppUid, $iDelIndex ); - // g::pr($aFields); - // die; - - - switch ($aFields['APP_STATUS']) { - case 'DRAFT': - case 'TO_DO': - //check if the case is in pause, check a valid record in table APP_DELAY - if (AppDelay::isPaused( $sAppUid, $iDelIndex )) { - //the case is paused show only the resume - $_SESSION['APPLICATION'] = $sAppUid; - $_SESSION['INDEX'] = $iDelIndex; - $_SESSION['PROCESS'] = $aFields['PRO_UID']; - $_SESSION['TASK'] = - 1; - $_SESSION['STEP_POSITION'] = 0; - - require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php'); - exit(); - } - - /** - * these routine is to verify if the case was acceded from advaced search list - */ - if ($_action == 'search') { - //verify if the case is with teh current user - $c = new Criteria( 'workflow' ); - $c->add( AppDelegationPeer::APP_UID, $sAppUid ); - $c->addDescendingOrderByColumn( AppDelegationPeer::DEL_INDEX ); - $oDataset = AppDelegationPeer::doSelectRs( $c ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - $aData = $oDataset->getRow(); - - if ($aData['USR_UID'] != $_SESSION['USER_LOGGED'] && $aData['USR_UID'] != "") //distinct "" for selfservice -{ - //so we show just the resume - $_SESSION['alreadyDerivated'] = true; - //the case is paused show only the resume - $_SESSION['APPLICATION'] = $sAppUid; - $_SESSION['INDEX'] = $iDelIndex; - $_SESSION['PROCESS'] = $aFields['PRO_UID']; - $_SESSION['TASK'] = - 1; - $_SESSION['STEP_POSITION'] = 0; - - require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php'); - exit(); - } - } - - //proceed and try to open the case - $oAppDelegation = new AppDelegation(); - $aDelegation = $oAppDelegation->load( $sAppUid, $iDelIndex ); - - //if there are no user in the delegation row, this case is in selfservice - if ($aDelegation['USR_UID'] == "" /*&& $aDelegation['DEL_THREAD_STATUS'] == 'SELFSERVICE'*/ ) { - - $_SESSION['APPLICATION'] = $sAppUid; - $_SESSION['INDEX'] = $iDelIndex; - $_SESSION['PROCESS'] = $aFields['PRO_UID']; - $_SESSION['TASK'] = - 1; - $_SESSION['STEP_POSITION'] = 0; - $_SESSION['CURRENT_TASK'] = $aFields['TAS_UID']; - - //if the task is in the valid selfservice tasks for this user, then catch the case, else just view the resume - if ($oCase->isSelfService( $_SESSION['USER_LOGGED'], $aFields['TAS_UID'], $sAppUid )) { - require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_CatchSelfService.php'); - } else { - require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php'); - } - - exit(); - } - - //if the current users is in the AppDelegation row, then open the case - if (($aDelegation['USR_UID'] == $_SESSION['USER_LOGGED']) && $_action != 'sent') { - $_SESSION['APPLICATION'] = $sAppUid; - $_SESSION['INDEX'] = $iDelIndex; - - if (is_null( $aFields['DEL_INIT_DATE'] )) { - $oCase->setDelInitDate( $sAppUid, $iDelIndex ); - $aFields = $oCase->loadCase( $sAppUid, $iDelIndex ); - } - - $_SESSION['PROCESS'] = $aFields['PRO_UID']; - $_SESSION['TASK'] = $aFields['TAS_UID']; - $_SESSION['STEP_POSITION'] = 0; - - /* Redirect to next step */ - unset( $_SESSION['bNoShowSteps'] ); - $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] ); - $sPage = $aNextStep['PAGE']; - G::header( 'location: ' . $sPage ); - - } else { - //when the case have another user or current user doesnt have rights to this selfservice, - //just view the case Resume - - - $_SESSION['APPLICATION'] = $sAppUid; - $_SESSION['INDEX'] = $iDelIndex; - $_SESSION['PROCESS'] = $aFields['PRO_UID']; - $_SESSION['TASK'] = - 1; - $Fields = $oCase->loadCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'] ); - $_SESSION['CURRENT_TASK'] = $Fields['TAS_UID']; - $_SESSION['STEP_POSITION'] = 0; - require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php'); - } - break; - - default: //APP_STATUS <> DRAFT and TO_DO - $_SESSION['APPLICATION'] = $sAppUid; - $_SESSION['INDEX'] = $iDelIndex != "" ? $iDelIndex : $oCase->getCurrentDelegationCase( $_GET['APP_UID'] ); - $_SESSION['PROCESS'] = $aFields['PRO_UID']; - $_SESSION['TASK'] = - 1; - $_SESSION['STEP_POSITION'] = 0; - - require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php'); - } -} catch (Exception $e) { - $aMessage = array (); - $aMessage['MESSAGE'] = $e->getMessage(); - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); - G::RenderPage( 'publishBlank', 'blank' ); +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ + +/* Permissions */ +if ($RBAC->userCanAccess( 'PM_CASES' ) != 1) { + switch ($RBAC->userCanAccess( 'PM_CASES' )) { + case - 2: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + break; + case - 1: + default: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + break; + } +} + +/* Includes */ +require_once 'classes/model/AppDelay.php'; +G::LoadClass( 'case' ); + +$oCase = new Cases(); + +//cleaning the case session data +Cases::clearCaseSessionData(); + +try { + //Loading data for a Jump request + if (! isset( $_GET['APP_UID'] ) && isset( $_GET['APP_NUMBER'] )) { + $_GET['APP_UID'] = $oCase->getApplicationUIDByNumber( $_GET['APP_NUMBER'] ); + $_GET['DEL_INDEX'] = $oCase->getCurrentDelegation( $_GET['APP_UID'], $_SESSION['USER_LOGGED'] ); + + //if the application doesn't exist + if (is_null( $_GET['APP_UID'] )) { + G::SendMessageText( G::LoadTranslation( 'ID_CASE_DOES_NOT_EXISTS' ), 'info' ); + G::header( 'location: casesListExtJs' ); + exit(); + } + + //if the application exists but the + if (is_null( $_GET['DEL_INDEX'] )) { + G::SendMessageText( G::LoadTranslation( 'ID_CASE_IS_CURRENTLY_WITH_ANOTHER_USER' ), 'info' ); + G::header( 'location: casesListExtJs' ); + exit(); + } + //wrong implemented, need refactored + //$participated = $oCase->userParticipatedInCase($_GET['APP_UID'], $_SESSION['USER_LOGGED']); ??????? + } + + $sAppUid = $_GET['APP_UID']; + $iDelIndex = $_GET['DEL_INDEX']; + $_action = isset( $_GET['action'] ) ? $_GET['action'] : ''; + + //loading application data + $aFields = $oCase->loadCase( $sAppUid, $iDelIndex ); + // g::pr($aFields); + // die; + + + switch ($aFields['APP_STATUS']) { + case 'DRAFT': + case 'TO_DO': + //check if the case is in pause, check a valid record in table APP_DELAY + if (AppDelay::isPaused( $sAppUid, $iDelIndex )) { + //the case is paused show only the resume + $_SESSION['APPLICATION'] = $sAppUid; + $_SESSION['INDEX'] = $iDelIndex; + $_SESSION['PROCESS'] = $aFields['PRO_UID']; + $_SESSION['TASK'] = - 1; + $_SESSION['STEP_POSITION'] = 0; + + require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php'); + exit(); + } + + /** + * these routine is to verify if the case was acceded from advaced search list + */ + if ($_action == 'search') { + //verify if the case is with teh current user + $c = new Criteria( 'workflow' ); + $c->add( AppDelegationPeer::APP_UID, $sAppUid ); + $c->addDescendingOrderByColumn( AppDelegationPeer::DEL_INDEX ); + $oDataset = AppDelegationPeer::doSelectRs( $c ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aData = $oDataset->getRow(); + + if ($aData['USR_UID'] != $_SESSION['USER_LOGGED'] && $aData['USR_UID'] != "") { + //distinct "" for selfservice + //so we show just the resume + $_SESSION['alreadyDerivated'] = true; + //the case is paused show only the resume + $_SESSION['APPLICATION'] = $sAppUid; + $_SESSION['INDEX'] = $iDelIndex; + $_SESSION['PROCESS'] = $aFields['PRO_UID']; + $_SESSION['TASK'] = - 1; + $_SESSION['STEP_POSITION'] = 0; + + require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php'); + exit(); + } + } + + //proceed and try to open the case + $oAppDelegation = new AppDelegation(); + $aDelegation = $oAppDelegation->load( $sAppUid, $iDelIndex ); + + //if there are no user in the delegation row, this case is in selfservice + if ($aDelegation['USR_UID'] == "" /*&& $aDelegation['DEL_THREAD_STATUS'] == 'SELFSERVICE'*/ ) { + + $_SESSION['APPLICATION'] = $sAppUid; + $_SESSION['INDEX'] = $iDelIndex; + $_SESSION['PROCESS'] = $aFields['PRO_UID']; + $_SESSION['TASK'] = - 1; + $_SESSION['STEP_POSITION'] = 0; + $_SESSION['CURRENT_TASK'] = $aFields['TAS_UID']; + + //if the task is in the valid selfservice tasks for this user, then catch the case, else just view the resume + if ($oCase->isSelfService( $_SESSION['USER_LOGGED'], $aFields['TAS_UID'], $sAppUid )) { + require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_CatchSelfService.php'); + } else { + require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php'); + } + + exit(); + } + + //if the current users is in the AppDelegation row, then open the case + if (($aDelegation['USR_UID'] == $_SESSION['USER_LOGGED']) && $_action != 'sent') { + $_SESSION['APPLICATION'] = $sAppUid; + $_SESSION['INDEX'] = $iDelIndex; + + if (is_null( $aFields['DEL_INIT_DATE'] )) { + $oCase->setDelInitDate( $sAppUid, $iDelIndex ); + $aFields = $oCase->loadCase( $sAppUid, $iDelIndex ); + } + + $_SESSION['PROCESS'] = $aFields['PRO_UID']; + $_SESSION['TASK'] = $aFields['TAS_UID']; + $_SESSION['STEP_POSITION'] = 0; + + /* Redirect to next step */ + unset( $_SESSION['bNoShowSteps'] ); + $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] ); + $sPage = $aNextStep['PAGE']; + G::header( 'location: ' . $sPage ); + + } else { + //when the case have another user or current user doesnt have rights to this selfservice, + //just view the case Resume + + + $_SESSION['APPLICATION'] = $sAppUid; + $_SESSION['INDEX'] = $iDelIndex; + $_SESSION['PROCESS'] = $aFields['PRO_UID']; + $_SESSION['TASK'] = - 1; + $Fields = $oCase->loadCase( $_SESSION['APPLICATION'], $_SESSION['INDEX'] ); + $_SESSION['CURRENT_TASK'] = $Fields['TAS_UID']; + $_SESSION['STEP_POSITION'] = 0; + require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php'); + } + break; + default: //APP_STATUS <> DRAFT and TO_DO + $_SESSION['APPLICATION'] = $sAppUid; + $_SESSION['INDEX'] = $iDelIndex != "" ? $iDelIndex : $oCase->getCurrentDelegationCase( $_GET['APP_UID'] ); + $_SESSION['PROCESS'] = $aFields['PRO_UID']; + $_SESSION['TASK'] = - 1; + $_SESSION['STEP_POSITION'] = 0; + + require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php'); + } +} catch (Exception $e) { + $aMessage = array (); + $aMessage['MESSAGE'] = $e->getMessage(); + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); + G::RenderPage( 'publishBlank', 'blank' ); } diff --git a/workflow/engine/methods/cases/cases_OpenToRevise.php b/workflow/engine/methods/cases/cases_OpenToRevise.php index 6b7f49276..cefc8461d 100755 --- a/workflow/engine/methods/cases/cases_OpenToRevise.php +++ b/workflow/engine/methods/cases/cases_OpenToRevise.php @@ -1,75 +1,76 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ -/* Permissions */ - -if ($RBAC->userCanAccess( 'PM_SUPERVISOR' ) != 1) - switch ($RBAC->userCanAccess( 'PM_SUPERVISOR' )) { - case - 2: - G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); - G::header( 'location: ../login/login' ); - die(); - break; - default: - G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); - G::header( 'location: ../login/login' ); - die(); - break; - } - - /* Includes */ -G::LoadClass( 'case' ); - -/* GET , POST & $_SESSION Vars */ -if (isset( $_SESSION['APPLICATION'] )) { - unset( $_SESSION['APPLICATION'] ); -} -if (isset( $_SESSION['PROCESS'] )) { - unset( $_SESSION['PROCESS'] ); -} -if (isset( $_SESSION['INDEX'] )) { - unset( $_SESSION['INDEX'] ); -} -if (isset( $_SESSION['STEP_POSITION'] )) { - unset( $_SESSION['STEP_POSITION'] ); -} - -/* Process the info */ -$oCase = new Cases(); -$sAppUid = $_GET['APP_UID']; -$iDelIndex = $_GET['DEL_INDEX']; - -$_SESSION['APPLICATION'] = $_GET['APP_UID']; -$_SESSION['INDEX'] = $_GET['DEL_INDEX']; - -$aFields = $oCase->loadCase( $sAppUid, $iDelIndex ); - -$_SESSION['PROCESS'] = $aFields['PRO_UID']; -$_SESSION['TASK'] = $aFields['TAS_UID']; -$_SESSION['STEP_POSITION'] = 0; - -/* Redirect to next step */ -$aNextStep = $oCase->getNextSupervisorStep( $_SESSION['PROCESS'], 0 ); +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ +/* Permissions */ + +if ($RBAC->userCanAccess( 'PM_SUPERVISOR' ) != 1) { + switch ($RBAC->userCanAccess( 'PM_SUPERVISOR' )) { + case - 2: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; + default: + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); + break; + } +} + + /* Includes */ +G::LoadClass( 'case' ); + +/* GET , POST & $_SESSION Vars */ +if (isset( $_SESSION['APPLICATION'] )) { + unset( $_SESSION['APPLICATION'] ); +} +if (isset( $_SESSION['PROCESS'] )) { + unset( $_SESSION['PROCESS'] ); +} +if (isset( $_SESSION['INDEX'] )) { + unset( $_SESSION['INDEX'] ); +} +if (isset( $_SESSION['STEP_POSITION'] )) { + unset( $_SESSION['STEP_POSITION'] ); +} + +/* Process the info */ +$oCase = new Cases(); +$sAppUid = $_GET['APP_UID']; +$iDelIndex = $_GET['DEL_INDEX']; + +$_SESSION['APPLICATION'] = $_GET['APP_UID']; +$_SESSION['INDEX'] = $_GET['DEL_INDEX']; + +$aFields = $oCase->loadCase( $sAppUid, $iDelIndex ); + +$_SESSION['PROCESS'] = $aFields['PRO_UID']; +$_SESSION['TASK'] = $aFields['TAS_UID']; +$_SESSION['STEP_POSITION'] = 0; + +/* Redirect to next step */ +$aNextStep = $oCase->getNextSupervisorStep( $_SESSION['PROCESS'], 0 ); $sPage = "cases_StepToRevise?type=DYNAFORM&PRO_UID=" . $aFields['PRO_UID'] . "&DYN_UID=" . $aNextStep['UID'] . "&APP_UID=$sAppUid&DEL_INDEX=$iDelIndex&position=1"; //$aNextStep['PAGE']; -G::header( 'location: ' . $sPage ); - +G::header( 'location: ' . $sPage ); + diff --git a/workflow/engine/methods/cases/cases_PrintView.php b/workflow/engine/methods/cases/cases_PrintView.php index 51779daad..623adc87c 100755 --- a/workflow/engine/methods/cases/cases_PrintView.php +++ b/workflow/engine/methods/cases/cases_PrintView.php @@ -1,96 +1,96 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ -try { - - require_once 'classes/model/Dynaform.php'; - require_once 'classes/model/Process.php'; - - $currentDynUid = ''; - if (isset( $_GET['DYNUIDPRINT'] ) && $_GET['DYNUIDPRINT'] != '') { - $currentDynUid = $_GET['DYNUIDPRINT']; - } elseif (isset( $_SESSION['DYN_UID_PRINT'] )) { - $currentDynUid = $_SESSION['DYN_UID_PRINT']; - } elseif (isset( $_SESSION['CURRENT_DYN_UID'] )) { - $currentDynUid = $_SESSION['CURRENT_DYN_UID']; - } - - $oDynaform = new Dynaform(); - $aDyn = $oDynaform->load( $currentDynUid ); - - G::LoadClass( 'case' ); - $oCase = new Cases(); - - if (isset( $_SESSION['APPLICATION'] )) { - $Fields = $oCase->loadCase( $_SESSION['APPLICATION'] ); - $Fields['APP_DATA'] = array_merge( $Fields['APP_DATA'], G::getSystemConstants() ); - } else { - $Fields['APP_DATA'] = Array (); - } - - $G_MAIN_MENU = 'processmaker'; - $G_ID_MENU_SELECTED = 'USERS'; - $G_PUBLISH = new Publisher(); - - $idProcess = (isset( $Fields['APP_DATA']['PROCESS'] )) ? $Fields['APP_DATA']['PROCESS'] : $_SESSION['PROCESS']; - $oProcess = new Process(); - $aProcessFieds = $oProcess->load( $idProcess ); - $sProcess = $oProcess->getProTitle(); - - $noShowTitle = 0; - if (isset( $aProcessFieds['PRO_SHOW_MESSAGE'] )) { - $noShowTitle = $aProcessFieds['PRO_SHOW_MESSAGE']; - } +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ +try { + + require_once 'classes/model/Dynaform.php'; + require_once 'classes/model/Process.php'; + + $currentDynUid = ''; + if (isset( $_GET['DYNUIDPRINT'] ) && $_GET['DYNUIDPRINT'] != '') { + $currentDynUid = $_GET['DYNUIDPRINT']; + } elseif (isset( $_SESSION['DYN_UID_PRINT'] )) { + $currentDynUid = $_SESSION['DYN_UID_PRINT']; + } elseif (isset( $_SESSION['CURRENT_DYN_UID'] )) { + $currentDynUid = $_SESSION['CURRENT_DYN_UID']; + } + + $oDynaform = new Dynaform(); + $aDyn = $oDynaform->load( $currentDynUid ); + + G::LoadClass( 'case' ); + $oCase = new Cases(); + + if (isset( $_SESSION['APPLICATION'] )) { + $Fields = $oCase->loadCase( $_SESSION['APPLICATION'] ); + $Fields['APP_DATA'] = array_merge( $Fields['APP_DATA'], G::getSystemConstants() ); + } else { + $Fields['APP_DATA'] = Array (); + } + + $G_MAIN_MENU = 'processmaker'; + $G_ID_MENU_SELECTED = 'USERS'; + $G_PUBLISH = new Publisher(); + + $idProcess = (isset( $Fields['APP_DATA']['PROCESS'] )) ? $Fields['APP_DATA']['PROCESS'] : $_SESSION['PROCESS']; + $oProcess = new Process(); + $aProcessFieds = $oProcess->load( $idProcess ); + $sProcess = $oProcess->getProTitle(); + + $noShowTitle = 0; + if (isset( $aProcessFieds['PRO_SHOW_MESSAGE'] )) { + $noShowTitle = $aProcessFieds['PRO_SHOW_MESSAGE']; + } //Add content content step - Start - if (isset( $_SESSION['APPLICATION'] )) { - $array['CASE'] = G::LoadTranslation( 'ID_CASE' ); - $array['USER'] = G::LoadTranslation( 'ID_USER' ); - $array['WORKSPACE'] = G::LoadTranslation( 'ID_WORKSPACE' ); - $array['APP_NUMBER'] = $Fields['APP_NUMBER']; - $array['APP_TITLE'] = $Fields['TITLE']; - $array['USR_USERNAME'] = $Fields['APP_DATA']['USR_USERNAME']; - $array['USER_ENV'] = $Fields['APP_DATA']['SYS_SYS']; - $array['DATEPRINT'] = date( 'Y-m-d H:m:s' ); - } - $array['APP_PROCESS'] = $sProcess; - - if (isset( $Fields['TITLE'] ) && strlen( $Fields['TITLE'] ) > 0) { - $array['TITLE'] = G::LoadTranslation( 'ID_TITLE' ); - } else { - $array['TITLE'] = ''; - } - $array['PROCESS'] = G::LoadTranslation( 'ID_PROCESS' ); - $array['DATELABEL'] = G::LoadTranslation( 'DATE_LABEL' ); - - $aDyn['DYN_UID'] = $currentDynUid; - if ($noShowTitle == 0) { - $G_PUBLISH->AddContent( 'smarty', 'cases/cases_PrintViewTitle', '', '', $array ); - } - $G_PUBLISH->AddContent( 'dynaform', 'xmlform', $aDyn['PRO_UID'] . '/' . $aDyn['DYN_UID'], '', $Fields['APP_DATA'], '', '', 'view' ); - G::RenderPage( 'publish', 'blank' ); -} catch (Exception $oException) { - die( $oException->getMessage() ); -} + if (isset( $_SESSION['APPLICATION'] )) { + $array['CASE'] = G::LoadTranslation( 'ID_CASE' ); + $array['USER'] = G::LoadTranslation( 'ID_USER' ); + $array['WORKSPACE'] = G::LoadTranslation( 'ID_WORKSPACE' ); + $array['APP_NUMBER'] = $Fields['APP_NUMBER']; + $array['APP_TITLE'] = $Fields['TITLE']; + $array['USR_USERNAME'] = $Fields['APP_DATA']['USR_USERNAME']; + $array['USER_ENV'] = $Fields['APP_DATA']['SYS_SYS']; + $array['DATEPRINT'] = date( 'Y-m-d H:m:s' ); + } + $array['APP_PROCESS'] = $sProcess; + + if (isset( $Fields['TITLE'] ) && strlen( $Fields['TITLE'] ) > 0) { + $array['TITLE'] = G::LoadTranslation( 'ID_TITLE' ); + } else { + $array['TITLE'] = ''; + } + $array['PROCESS'] = G::LoadTranslation( 'ID_PROCESS' ); + $array['DATELABEL'] = G::LoadTranslation( 'DATE_LABEL' ); + + $aDyn['DYN_UID'] = $currentDynUid; + if ($noShowTitle == 0) { + $G_PUBLISH->AddContent( 'smarty', 'cases/cases_PrintViewTitle', '', '', $array ); + } + $G_PUBLISH->AddContent( 'dynaform', 'xmlform', $aDyn['PRO_UID'] . '/' . $aDyn['DYN_UID'], '', $Fields['APP_DATA'], '', '', 'view' ); + G::RenderPage( 'publish', 'blank' ); +} catch (Exception $oException) { + die( $oException->getMessage() ); +} ?> - + + + 'APP_UID' -),array ('FLD_NAME' => 'CON_NAME' -),array ('FLD_NAME' => 'CON_ADDR' -),array ('FLD_NAME' => '_cedula' -) -); - +$pmTableFields = array (array ('FLD_NAME' => 'APP_UID' +),array ('FLD_NAME' => 'CON_NAME' +),array ('FLD_NAME' => 'CON_ADDR' +),array ('FLD_NAME' => '_cedula' +) +); + // setting the data to assemble the table -$aData = array (); -$aData['ADD_TAB_NAME'] = $pmTableName; +$aData = array (); +$aData['ADD_TAB_NAME'] = $pmTableName; // creating the objects to create the table and records -$oFields = new Fields(); -$oAdditionalTables = new AdditionalTables(); - -$sAddTabUid = $oAdditionalTables->create( $aData, $pmTableFields ); - -foreach ($pmTableFields as $iRow => $aRow) { - $pmTableFields[$iRow]['FLD_NAME'] = strtoupper( $aRow['FLD_NAME'] ); - $pmTableFields[$iRow]['FLD_DESCRIPTION'] = isset( $aRow['FLD_DESCRIPTION'] ) ? $aRow['FLD_DESCRIPTION'] : $aRow['FLD_NAME']; - $pmTableFields[$iRow]['FLD_TYPE'] = isset( $aRow['FLD_TYPE'] ) ? $aRow['FLD_TYPE'] : 'VARCHAR'; - $pmTableFields[$iRow]['FLD_SIZE'] = isset( $aRow['FLD_SIZE'] ) ? $aRow['FLD_SIZE'] : '32'; - $pmTableFields[$iRow]['FLD_NULL'] = isset( $aRow['FLD_NULL'] ) ? $aRow['FLD_NULL'] : 'off'; - $pmTableFields[$iRow]['FLD_AUTO_INCREMENT'] = isset( $aRow['FLD_AUTO_INCREMENT'] ) ? $aRow['FLD_AUTO_INCREMENT'] : 'off'; - $pmTableFields[$iRow]['FLD_KEY'] = isset( $aRow['FLD_KEY'] ) ? $aRow['FLD_KEY'] : 'off'; - $pmTableFields[$iRow]['FLD_FOREIGN_KEY'] = isset( $aRow['FLD_FOREIGN_KEY'] ) ? $aRow['FLD_FOREIGN_KEY'] : 'off'; - $pmTableFields[$iRow]['FLD_FOREIGN_KEY_TABLE'] = isset( $aRow['FLD_FOREIGN_KEY_TABLE'] ) ? $aRow['FLD_FOREIGN_KEY_TABLE'] : ''; -} - -foreach ($pmTableFields as $iRow => $aRow) { - - $oFields->create( array ('FLD_INDEX' => $iRow + 1,'ADD_TAB_UID' => $sAddTabUid,'FLD_NAME' => $aRow['FLD_NAME'],'FLD_DESCRIPTION' => isset( $aRow['FLD_DESCRIPTION'] ) ? $aRow['FLD_DESCRIPTION'] : '','FLD_TYPE' => isset( $aRow['FLD_TYPE'] ) ? $aRow['FLD_TYPE'] : 'VARCHAR','FLD_SIZE' => isset( $aRow['FLD_SIZE'] ) ? $aRow['FLD_SIZE'] : '32','FLD_NULL' => ($aRow['FLD_NULL'] == 'on' ? 1 : 0),'FLD_AUTO_INCREMENT' => ($aRow['FLD_AUTO_INCREMENT'] == 'on' ? 1 : 0),'FLD_KEY' => ($aRow['FLD_KEY'] == 'on' ? 1 : 0),'FLD_FOREIGN_KEY' => ($aRow['FLD_FOREIGN_KEY'] == 'on' ? 1 : 0),'FLD_FOREIGN_KEY_TABLE' => isset( $aRow['FLD_FOREIGN_KEY_TABLE'] ) ? $aRow['FLD_FOREIGN_KEY_TABLE'] : '' - ) ); - - $aFields[] = array ('sType' => isset( $aRow['FLD_TYPE'] ) ? $aRow['FLD_TYPE'] : 'VARCHAR','iSize' => isset( $aRow['FLD_SIZE'] ) ? $aRow['FLD_SIZE'] : '32','sFieldName' => $aRow['FLD_NAME'],'bNull' => ($aRow['FLD_NULL'] == 'on' ? 1 : 0),'bAI' => ($aRow['FLD_AUTO_INCREMENT'] == 'on' ? 1 : 0),'bPrimaryKey' => ($aRow['FLD_KEY'] == 'on' ? 1 : 0) - ); -} - -$oAdditionalTables->createTable( strtoupper( $pmTableName ), 'wf', $aFields ); -$oAdditionalTables->createPropelClasses( strtoupper( $pmTableName ), $pmTableName, $pmTableFields, $sAddTabUid ); - -require_once ("classes/model/Application.php"); -require_once ("classes/model/AdditionalTables.php"); -require_once ("classes/model/Fields.php"); - -$Criteria = new Criteria( 'workflow' ); -$Criteria->addSelectColumn( ApplicationPeer::APP_UID ); -$Criteria->addSelectColumn( ApplicationPeer::APP_DATA ); - +$oFields = new Fields(); +$oAdditionalTables = new AdditionalTables(); + +$sAddTabUid = $oAdditionalTables->create( $aData, $pmTableFields ); + +foreach ($pmTableFields as $iRow => $aRow) { + $pmTableFields[$iRow]['FLD_NAME'] = strtoupper( $aRow['FLD_NAME'] ); + $pmTableFields[$iRow]['FLD_DESCRIPTION'] = isset( $aRow['FLD_DESCRIPTION'] ) ? $aRow['FLD_DESCRIPTION'] : $aRow['FLD_NAME']; + $pmTableFields[$iRow]['FLD_TYPE'] = isset( $aRow['FLD_TYPE'] ) ? $aRow['FLD_TYPE'] : 'VARCHAR'; + $pmTableFields[$iRow]['FLD_SIZE'] = isset( $aRow['FLD_SIZE'] ) ? $aRow['FLD_SIZE'] : '32'; + $pmTableFields[$iRow]['FLD_NULL'] = isset( $aRow['FLD_NULL'] ) ? $aRow['FLD_NULL'] : 'off'; + $pmTableFields[$iRow]['FLD_AUTO_INCREMENT'] = isset( $aRow['FLD_AUTO_INCREMENT'] ) ? $aRow['FLD_AUTO_INCREMENT'] : 'off'; + $pmTableFields[$iRow]['FLD_KEY'] = isset( $aRow['FLD_KEY'] ) ? $aRow['FLD_KEY'] : 'off'; + $pmTableFields[$iRow]['FLD_FOREIGN_KEY'] = isset( $aRow['FLD_FOREIGN_KEY'] ) ? $aRow['FLD_FOREIGN_KEY'] : 'off'; + $pmTableFields[$iRow]['FLD_FOREIGN_KEY_TABLE'] = isset( $aRow['FLD_FOREIGN_KEY_TABLE'] ) ? $aRow['FLD_FOREIGN_KEY_TABLE'] : ''; +} + +foreach ($pmTableFields as $iRow => $aRow) { + + $oFields->create( array ('FLD_INDEX' => $iRow + 1,'ADD_TAB_UID' => $sAddTabUid,'FLD_NAME' => $aRow['FLD_NAME'],'FLD_DESCRIPTION' => isset( $aRow['FLD_DESCRIPTION'] ) ? $aRow['FLD_DESCRIPTION'] : '','FLD_TYPE' => isset( $aRow['FLD_TYPE'] ) ? $aRow['FLD_TYPE'] : 'VARCHAR','FLD_SIZE' => isset( $aRow['FLD_SIZE'] ) ? $aRow['FLD_SIZE'] : '32','FLD_NULL' => ($aRow['FLD_NULL'] == 'on' ? 1 : 0),'FLD_AUTO_INCREMENT' => ($aRow['FLD_AUTO_INCREMENT'] == 'on' ? 1 : 0),'FLD_KEY' => ($aRow['FLD_KEY'] == 'on' ? 1 : 0),'FLD_FOREIGN_KEY' => ($aRow['FLD_FOREIGN_KEY'] == 'on' ? 1 : 0),'FLD_FOREIGN_KEY_TABLE' => isset( $aRow['FLD_FOREIGN_KEY_TABLE'] ) ? $aRow['FLD_FOREIGN_KEY_TABLE'] : '') ); + + $aFields[] = array ('sType' => isset( $aRow['FLD_TYPE'] ) ? $aRow['FLD_TYPE'] : 'VARCHAR','iSize' => isset( $aRow['FLD_SIZE'] ) ? $aRow['FLD_SIZE'] : '32','sFieldName' => $aRow['FLD_NAME'],'bNull' => ($aRow['FLD_NULL'] == 'on' ? 1 : 0),'bAI' => ($aRow['FLD_AUTO_INCREMENT'] == 'on' ? 1 : 0),'bPrimaryKey' => ($aRow['FLD_KEY'] == 'on' ? 1 : 0)); +} + +$oAdditionalTables->createTable( strtoupper( $pmTableName ), 'wf', $aFields ); +$oAdditionalTables->createPropelClasses( strtoupper( $pmTableName ), $pmTableName, $pmTableFields, $sAddTabUid ); + +require_once ("classes/model/Application.php"); +require_once ("classes/model/AdditionalTables.php"); +require_once ("classes/model/Fields.php"); + +$Criteria = new Criteria( 'workflow' ); +$Criteria->addSelectColumn( ApplicationPeer::APP_UID ); +$Criteria->addSelectColumn( ApplicationPeer::APP_DATA ); + // $Criteria->add (AppCacheViewPeer::DEL_THREAD_STATUS, 'OPEN'); -$oDataset = ApplicationPeer::doSelectRS( $Criteria ); -$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); -$oDataset->next(); -$aProcesses = array (); -$i = 0; -while ($aRow = $oDataset->getRow()) { - $appuid = $aRow['APP_UID']; - $data = unserialize( $aRow['APP_DATA'] ); - $cedula = '234' . rand( 1000, 999999 ); - $nombre = 'nombre ' . rand( 1000, 999999 ); - $direccion = 'direccion ' . rand( 1000, 999999 ); - if (isset( $data['_cedula'] )) { - $cedula = $data['_cedula']; - $nombre = isset( $data['_nombre'] ) ? $data['_nombre'] : ''; - $direccion = isset( $data['_direccion'] ) ? $data['_direccion'] : ''; - print "$i $appuid $cedula
"; - } +$oDataset = ApplicationPeer::doSelectRS( $Criteria ); +$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); +$oDataset->next(); +$aProcesses = array (); +$i = 0; +while ($aRow = $oDataset->getRow()) { + $appuid = $aRow['APP_UID']; + $data = unserialize( $aRow['APP_DATA'] ); + $cedula = '234' . rand( 1000, 999999 ); + $nombre = 'nombre ' . rand( 1000, 999999 ); + $direccion = 'direccion ' . rand( 1000, 999999 ); + if (isset( $data['_cedula'] )) { + $cedula = $data['_cedula']; + $nombre = isset( $data['_nombre'] ) ? $data['_nombre'] : ''; + $direccion = isset( $data['_direccion'] ) ? $data['_direccion'] : ''; + print "$i $appuid $cedula
"; + } // print_r ( $aRow); - $sql = "insert CONTENDERS VALUES ( '$appuid', '$nombre', '$direccion', '$cedula' )"; - - $con = Propel::getConnection( 'workflow' ); - $stmt = $con->createStatement(); - $rs = $stmt->executeQuery( $sql, ResultSet::FETCHMODE_ASSOC ); - - $i ++; + $sql = "insert CONTENDERS VALUES ( '$appuid', '$nombre', '$direccion', '$cedula' )"; + + $con = Propel::getConnection( 'workflow' ); + $stmt = $con->createStatement(); + $rs = $stmt->executeQuery( $sql, ResultSet::FETCHMODE_ASSOC ); + + $i ++; // if ( $i == 100 ) die; /* if ( strpos ( $aRow['APP_DATA'], 'cedula' ) !== false ) { - print_r ( $aRow ); - print "
"; + print_r ( $aRow ); + print "
"; $i++; if ( $i == 10 ) die; - } -*/ - $oDataset->next(); -} -print "--$i--"; - + } + */ + $oDataset->next(); +} +print "--$i--"; + From 9e9f4be8e6696fdefb9f6f54d92b69126cf4f87e Mon Sep 17 00:00:00 2001 From: norahmollo Date: Fri, 19 Oct 2012 18:50:57 +0000 Subject: [PATCH 3/4] CODE STYLE Format Change format --- workflow/engine/classes/model/ReportTable.php | 458 +++++---- workflow/engine/classes/model/Route.php | 427 ++++---- workflow/engine/classes/model/Stage.php | 393 ++++---- .../engine/classes/model/StepSupervisor.php | 459 +++++---- .../triggers/class.pmSugarFunctions.php | 929 +++++++++--------- 5 files changed, 1342 insertions(+), 1324 deletions(-) diff --git a/workflow/engine/classes/model/ReportTable.php b/workflow/engine/classes/model/ReportTable.php index 98bdda7f5..2f44f7b53 100755 --- a/workflow/engine/classes/model/ReportTable.php +++ b/workflow/engine/classes/model/ReportTable.php @@ -1,231 +1,227 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -require_once 'classes/model/Content.php'; -require_once 'classes/model/om/BaseReportTable.php'; - - -/** - * Skeleton subclass for representing a row from the 'REPORT_TABLE' table. - * - * - * - * You should add additional methods to this class to meet the - * application requirements. This class will only be generated as - * long as it does not already exist in the output directory. - * - * @package workflow.engine.classes.model - */ -class ReportTable extends BaseReportTable { - /** - * This value goes in the content table - * @var string - */ - protected $rep_tab_title = ''; - - /** - * Get the rep_tab_title column value. - * @return string - */ - public function getRepTabTitle() { - if ( $this->getRepTabUid() == "" ) { - throw ( new Exception( "Error in getRepTabTitle, the getRepTabUid() can't be blank") ); - } - $lang = defined ( 'SYS_LANG' ) ? SYS_LANG : 'en'; - $this->rep_tab_title = Content::load ( 'REP_TAB_TITLE', '', $this->getRepTabUid(), $lang ); - return $this->rep_tab_title; - } - - /** - * Set the rep_tab_title column value. - * - * @param string $v new value - * @return void - */ - public function setRepTabTitle($v) - { - if ( $this->getRepTabUid() == "" ) { - throw ( new Exception( "Error in setRepTabTitle, the setRepTabUid() can't be blank") ); - } - $v=isset($v)?((string)$v):''; - $lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en'; - if ($this->rep_tab_title !== $v || $v==="") { - $this->rep_tab_title = $v; - $res = Content::addContent( 'REP_TAB_TITLE', '', $this->getRepTabUid(), $lang, $this->rep_tab_title ); - return $res; - } - return 0; - } - - public function load($RepTabUid) - { - try { - $oRow = ReportTablePeer::retrieveByPK( $RepTabUid ); - if (!is_null($oRow)) - { - $aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME); - $this->fromArray($aFields, BasePeer::TYPE_FIELDNAME); - $this->setNew(false); - $this->setRepTabTitle($aFields['REP_TAB_TITLE']=$this->getRepTabTitle()); - return $aFields; - } - else { - //throw( new Exception( "The row '$RepTabUid' in table ReportTable doesn't exist!" )); - return array(); - } - } - catch (Exception $oError) { - throw($oError); - } - } - public function create($aData) - { - $con = Propel::getConnection(ReportTablePeer::DATABASE_NAME); - try - { - $con->begin(); - if ( isset ( $aData['REP_TAB_UID'] ) && $aData['REP_TAB_UID']== '' ) - unset ( $aData['REP_TAB_UID'] ); - if ( !isset ( $aData['REP_TAB_UID'] ) ) - $this->setRepTabUid(G::generateUniqueID()); - else - $this->setRepTabUid($aData['REP_TAB_UID'] ); - - $this->setProUid($aData['PRO_UID']); - $this->setRepTabName($aData['REP_TAB_NAME']); - $this->setRepTabType($aData['REP_TAB_TYPE']); - if ( !isset ( $aData['REP_TAB_GRID'] ) ) - $this->setRepTabGrid(""); - else - $this->setRepTabGrid( $aData['REP_TAB_GRID'] ); - if ( !isset ( $aData['REP_TAB_CONNECTION'] ) ) - $this->setRepTabConnection("report"); - else - $this->setRepTabConnection( $aData['REP_TAB_CONNECTION'] ); - $this->setRepTabCreateDate(date('Y-m-d H:i:s')); - $this->setRepTabStatus('ACTIVE'); - - if($this->validate()) - { - if ( !isset ( $aData['REP_TAB_TITLE'] ) ) - $this->setRepTabTitle(""); - else - $this->setRepTabTitle( $aData['REP_TAB_TITLE'] ); - - $result=$this->save(); - $con->commit(); - return $result; - } - else - { - $con->rollback(); - throw(new Exception("Failed Validation in class ".get_class($this).".")); - } - } - catch(Exception $e) - { - $con->rollback(); - throw($e); - } - } - public function update($fields) - { - $con = Propel::getConnection(ReportTablePeer::DATABASE_NAME); - try - { - $con->begin(); - $this->load($fields['REP_TAB_UID']); - $this->fromArray($fields,BasePeer::TYPE_FIELDNAME); - - $sDataBase = 'database_' . strtolower(DB_ADAPTER); - if(G::LoadSystemExist($sDataBase)){ - G::LoadSystem($sDataBase); - $oDataBase = new database(); - $oValidate = $oDataBase->getValidate($this->validate()); - } else { - $oValidate = $this->validate(); - } - // if($this->validate()) - if($oValidate) - { - $contentResult=0; - if (array_key_exists("REP_TAB_TITLE", $fields)) $contentResult+=$this->setRepTabTitle($fields["REP_TAB_TITLE"]); - $result=$this->save(); - $result=($result==0)?($contentResult>0?1:0):$result; - $con->commit(); - return $result; - } - else - { - $con->rollback(); - $validationE=new Exception("Failed Validation in class ".get_class($this)."."); - $validationE->aValidationFailures = $this->getValidationFailures(); - throw($validationE); - } - } - catch(Exception $e) - { - $con->rollback(); - throw($e); - } - } - public function remove($RepTabUid) - { - $con = Propel::getConnection(ReportTablePeer::DATABASE_NAME); - try - { - $con->begin(); - $oRepTab = ReportTablePeer::retrieveByPK( $RepTabUid ); - if (!is_null($oRepTab)) { - Content::removeContent( 'REP_TAB_TITLE', '', $this->getRepTabUid()); - $result = $oRepTab->delete(); - $con->commit(); - } - return $result; - } - catch(Exception $e) - { - $con->rollback(); - throw($e); - } - } - - function reportTableExists ( $RepTabUid ) { - $con = Propel::getConnection(ReportTablePeer::DATABASE_NAME); - try { - $oRepTabUid = ReportTablePeer::retrieveByPk( $RepTabUid ); - if (is_object($oRepTabUid) && get_class ($oRepTabUid) == 'ReportTable' ) { - return true; - } - else { - return false; - } - } - catch (Exception $oError) { - throw($oError); - } - } -} // ReportTable +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + */ + +require_once 'classes/model/Content.php'; +require_once 'classes/model/om/BaseReportTable.php'; + +/** + * Skeleton subclass for representing a row from the 'REPORT_TABLE' table. + * + * + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + * + * @package workflow.engine.classes.model + */ +class ReportTable extends BaseReportTable +{ + /** + * This value goes in the content table + * + * @var string + */ + protected $rep_tab_title = ''; + + /** + * Get the rep_tab_title column value. + * + * @return string + */ + public function getRepTabTitle () + { + if ($this->getRepTabUid() == "") { + throw (new Exception( "Error in getRepTabTitle, the getRepTabUid() can't be blank" )); + } + $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en'; + $this->rep_tab_title = Content::load( 'REP_TAB_TITLE', '', $this->getRepTabUid(), $lang ); + return $this->rep_tab_title; + } + + /** + * Set the rep_tab_title column value. + * + * @param string $v new value + * @return void + */ + public function setRepTabTitle ($v) + { + if ($this->getRepTabUid() == "") { + throw (new Exception( "Error in setRepTabTitle, the setRepTabUid() can't be blank" )); + } + $v = isset( $v ) ? ((string) $v) : ''; + $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en'; + if ($this->rep_tab_title !== $v || $v === "") { + $this->rep_tab_title = $v; + $res = Content::addContent( 'REP_TAB_TITLE', '', $this->getRepTabUid(), $lang, $this->rep_tab_title ); + return $res; + } + return 0; + } + + public function load ($RepTabUid) + { + try { + $oRow = ReportTablePeer::retrieveByPK( $RepTabUid ); + if (! is_null( $oRow )) { + $aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME ); + $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME ); + $this->setNew( false ); + $this->setRepTabTitle( $aFields['REP_TAB_TITLE'] = $this->getRepTabTitle() ); + return $aFields; + } else { + //throw( new Exception( "The row '$RepTabUid' in table ReportTable doesn't exist!" )); + return array (); + } + } catch (Exception $oError) { + throw ($oError); + } + } + + public function create ($aData) + { + $con = Propel::getConnection( ReportTablePeer::DATABASE_NAME ); + try { + $con->begin(); + if (isset( $aData['REP_TAB_UID'] ) && $aData['REP_TAB_UID'] == '') { + unset( $aData['REP_TAB_UID'] ); + } + if (! isset( $aData['REP_TAB_UID'] )) { + $this->setRepTabUid( G::generateUniqueID() ); + } else { + $this->setRepTabUid( $aData['REP_TAB_UID'] ); + } + + $this->setProUid( $aData['PRO_UID'] ); + $this->setRepTabName( $aData['REP_TAB_NAME'] ); + $this->setRepTabType( $aData['REP_TAB_TYPE'] ); + if (! isset( $aData['REP_TAB_GRID'] )) { + $this->setRepTabGrid( "" ); + } else { + $this->setRepTabGrid( $aData['REP_TAB_GRID'] ); + } + if (! isset( $aData['REP_TAB_CONNECTION'] )) { + $this->setRepTabConnection( "report" ); + } else { + $this->setRepTabConnection( $aData['REP_TAB_CONNECTION'] ); + } + $this->setRepTabCreateDate( date( 'Y-m-d H:i:s' ) ); + $this->setRepTabStatus( 'ACTIVE' ); + + if ($this->validate()) { + if (! isset( $aData['REP_TAB_TITLE'] )) { + $this->setRepTabTitle( "" ); + } else { + $this->setRepTabTitle( $aData['REP_TAB_TITLE'] ); + } + $result = $this->save(); + $con->commit(); + return $result; + } else { + $con->rollback(); + throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." )); + } + } catch (Exception $e) { + $con->rollback(); + throw ($e); + } + } + + public function update ($fields) + { + $con = Propel::getConnection( ReportTablePeer::DATABASE_NAME ); + try { + $con->begin(); + $this->load( $fields['REP_TAB_UID'] ); + $this->fromArray( $fields, BasePeer::TYPE_FIELDNAME ); + + $sDataBase = 'database_' . strtolower( DB_ADAPTER ); + if (G::LoadSystemExist( $sDataBase )) { + G::LoadSystem( $sDataBase ); + $oDataBase = new database(); + $oValidate = $oDataBase->getValidate( $this->validate() ); + } else { + $oValidate = $this->validate(); + } + // if($this->validate()) + if ($oValidate) { + $contentResult = 0; + if (array_key_exists( "REP_TAB_TITLE", $fields )) { + $contentResult += $this->setRepTabTitle( $fields["REP_TAB_TITLE"] ); + } + $result = $this->save(); + $result = ($result == 0) ? ($contentResult > 0 ? 1 : 0) : $result; + $con->commit(); + return $result; + } else { + $con->rollback(); + $validationE = new Exception( "Failed Validation in class " . get_class( $this ) . "." ); + $validationE->aValidationFailures = $this->getValidationFailures(); + throw ($validationE); + } + } catch (Exception $e) { + $con->rollback(); + throw ($e); + } + } + + public function remove ($RepTabUid) + { + $con = Propel::getConnection( ReportTablePeer::DATABASE_NAME ); + try { + $con->begin(); + $oRepTab = ReportTablePeer::retrieveByPK( $RepTabUid ); + if (! is_null( $oRepTab )) { + Content::removeContent( 'REP_TAB_TITLE', '', $this->getRepTabUid() ); + $result = $oRepTab->delete(); + $con->commit(); + } + return $result; + } catch (Exception $e) { + $con->rollback(); + throw ($e); + } + } + + public function reportTableExists ($RepTabUid) + { + $con = Propel::getConnection( ReportTablePeer::DATABASE_NAME ); + try { + $oRepTabUid = ReportTablePeer::retrieveByPk( $RepTabUid ); + if (is_object( $oRepTabUid ) && get_class( $oRepTabUid ) == 'ReportTable') { + return true; + } else { + return false; + } + } catch (Exception $oError) { + throw ($oError); + } + } +} +// ReportTable + diff --git a/workflow/engine/classes/model/Route.php b/workflow/engine/classes/model/Route.php index c73134b21..2e94c8dcf 100755 --- a/workflow/engine/classes/model/Route.php +++ b/workflow/engine/classes/model/Route.php @@ -1,216 +1,217 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -require_once 'classes/model/om/BaseRoute.php'; -require_once 'classes/model/Content.php'; - -/** - * Skeleton subclass for representing a row from the 'ROUTE' table. - * - * - * - * You should add additional methods to this class to meet the - * application requirements. This class will only be generated as - * long as it does not already exist in the output directory. - * - * @package workflow.engine.classes.model - */ -class Route extends BaseRoute { - - /* +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + */ + +require_once 'classes/model/om/BaseRoute.php'; +require_once 'classes/model/Content.php'; + +/** + * Skeleton subclass for representing a row from the 'ROUTE' table. + * + * + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + * + * @package workflow.engine.classes.model + */ +class Route extends BaseRoute +{ + + /* * Load the application document registry * @param string $sRouUid * @return variant - */ - public function load($sRouUid) - { - try { - $oRoute = RoutePeer::retrieveByPK($sRouUid); - if (!is_null($oRoute)) - { - $aFields = $oRoute->toArray(BasePeer::TYPE_FIELDNAME); - $this->fromArray($aFields, BasePeer::TYPE_FIELDNAME); - return $aFields; - } - else { - throw(new Exception('This row doesn\'t exist!')); - } - } - catch (Exception $oError) { - throw($oError); - } - } - - /** - * Create the application document registry - * @param array $aData - * @return string - **/ - public function create($aData) - { - $oConnection = Propel::getConnection(RoutePeer::DATABASE_NAME); - try { - $sRouteUID = G::generateUniqueID(); - $aData['ROU_UID'] = $sRouteUID; - $oRoute = new Route(); - - // validating default values - $aData['ROU_TO_LAST_USER'] = $this->validateValue(isset($aData['ROU_TO_LAST_USER']) ? $aData['ROU_TO_LAST_USER'] : '', array('TRUE', 'FALSE'), 'FALSE'); - $aData['ROU_OPTIONAL'] = $this->validateValue(isset($aData['ROU_OPTIONAL']) ? $aData['ROU_OPTIONAL'] : '', array('TRUE', 'FALSE'), 'FALSE'); - $aData['ROU_SEND_EMAIL'] = $this->validateValue(isset($aData['ROU_SEND_EMAIL']) ? $aData['ROU_SEND_EMAIL']: '', array('TRUE', 'FALSE'), 'TRUE'); - - $oRoute->fromArray($aData, BasePeer::TYPE_FIELDNAME); - - if ($oRoute->validate()) { - $oConnection->begin(); - $iResult = $oRoute->save(); - $oConnection->commit(); - return $sRouteUID; - } - else { - $sMessage = ''; - $aValidationFailures = $oRoute->getValidationFailures(); - foreach($aValidationFailures as $oValidationFailure) { - $sMessage .= $oValidationFailure->getMessage() . '
'; - } - throw(new Exception('The registry cannot be created!
'.$sMessage)); - } - } - catch (Exception $oError) { - $oConnection->rollback(); - throw($oError); - } - } - - /** - * Update the application document registry - * @param array $aData - * @return string - **/ - public function update($aData) - { - $oConnection = Propel::getConnection(RoutePeer::DATABASE_NAME); - try { - $oRoute = RoutePeer::retrieveByPK($aData['ROU_UID']); - if (!is_null($oRoute)) - { - // validating default values - if (isset($aData['ROU_TO_LAST_USER'])) { - $aData['ROU_TO_LAST_USER'] = $this->validateValue($aData['ROU_TO_LAST_USER'], array('TRUE', 'FALSE'), 'FALSE'); - } - if (isset($aData['ROU_OPTIONAL'])) { - $aData['ROU_OPTIONAL'] = $this->validateValue($aData['ROU_OPTIONAL'], array('TRUE', 'FALSE'), 'FALSE'); - } - if (isset($aData['ROU_SEND_EMAIL'])) { - $aData['ROU_SEND_EMAIL'] = $this->validateValue($aData['ROU_SEND_EMAIL'], array('TRUE', 'FALSE'), 'TRUE'); - } - - $oRoute->fromArray($aData, BasePeer::TYPE_FIELDNAME); - if ($oRoute->validate()) { - $oConnection->begin(); - $iResult = $oRoute->save(); - $oConnection->commit(); - return $iResult; - } - else { - $sMessage = ''; - $aValidationFailures = $oRoute->getValidationFailures(); - foreach($aValidationFailures as $oValidationFailure) { - $sMessage .= $oValidationFailure->getMessage() . '
'; - } - throw(new Exception('The ROUTE tables cannot be updated!
'.$sMessage)); - } - } - else { - throw(new Exception( "The row " . $aData['ROU_UID'] . " doesn't exist!" )); - } - } - catch (Exception $oError) { - $oConnection->rollback(); - throw($oError); - } - } - - /** - * Remove the application document registry - * @param array $aData - * @return string - **/ - public function remove($sRouUid) - { - $oConnection = Propel::getConnection(RoutePeer::DATABASE_NAME); - try { - $oRoute = RoutePeer::retrieveByPK($sRouUid); - if (!is_null($oRoute)) - { - $oConnection->begin(); - $iResult = $oRoute->delete(); - $oConnection->commit(); - return $iResult; - } - else { - throw(new Exception('This row doesn\'t exist!')); - } - } - catch (Exception $oError) { - $oConnection->rollback(); - throw($oError); - } - } - - function routeExists ( $sRouUid ) { - $con = Propel::getConnection(RoutePeer::DATABASE_NAME); - try { - $oRouUid = RoutePeer::retrieveByPk( $sRouUid ); - if (is_object($oRouUid) && get_class ($oRouUid) == 'Route' ) { - return true; - } - else { - return false; - } - } - catch (Exception $oError) { - throw($oError); - } - } - - /** - * Validate value for a variable that only accepts some determinated values - * - * @param $value string - value to test - * @param $validValues array - list of valid values - * @param $default string default value, if the tested value is not valid the default value is returned - * @return the tested and accepted value - */ - function validateValue($value, $validValues, $default) - { - if (!in_array($value, $validValues)) { - $value = $default; - } - - return $value; - } -} // Route + */ + public function load ($sRouUid) + { + try { + $oRoute = RoutePeer::retrieveByPK( $sRouUid ); + if (! is_null( $oRoute )) { + $aFields = $oRoute->toArray( BasePeer::TYPE_FIELDNAME ); + $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME ); + return $aFields; + } else { + throw (new Exception( 'This row doesn\'t exist!' )); + } + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * Create the application document registry + * + * @param array $aData + * @return string + * + */ + public function create ($aData) + { + $oConnection = Propel::getConnection( RoutePeer::DATABASE_NAME ); + try { + $sRouteUID = G::generateUniqueID(); + $aData['ROU_UID'] = $sRouteUID; + $oRoute = new Route(); + + // validating default values + $aData['ROU_TO_LAST_USER'] = $this->validateValue( isset( $aData['ROU_TO_LAST_USER'] ) ? $aData['ROU_TO_LAST_USER'] : '', array ('TRUE','FALSE' + ), 'FALSE' ); + $aData['ROU_OPTIONAL'] = $this->validateValue( isset( $aData['ROU_OPTIONAL'] ) ? $aData['ROU_OPTIONAL'] : '', array ('TRUE','FALSE' + ), 'FALSE' ); + $aData['ROU_SEND_EMAIL'] = $this->validateValue( isset( $aData['ROU_SEND_EMAIL'] ) ? $aData['ROU_SEND_EMAIL'] : '', array ('TRUE','FALSE' + ), 'TRUE' ); + + $oRoute->fromArray( $aData, BasePeer::TYPE_FIELDNAME ); + + if ($oRoute->validate()) { + $oConnection->begin(); + $iResult = $oRoute->save(); + $oConnection->commit(); + return $sRouteUID; + } else { + $sMessage = ''; + $aValidationFailures = $oRoute->getValidationFailures(); + foreach ($aValidationFailures as $oValidationFailure) { + $sMessage .= $oValidationFailure->getMessage() . '
'; + } + throw (new Exception( 'The registry cannot be created!
' . $sMessage )); + } + } catch (Exception $oError) { + $oConnection->rollback(); + throw ($oError); + } + } + /** + * Update the application document registry + * + * @param array $aData + * @return string + * + */ + public function update ($aData) + { + $oConnection = Propel::getConnection( RoutePeer::DATABASE_NAME ); + try { + $oRoute = RoutePeer::retrieveByPK( $aData['ROU_UID'] ); + if (! is_null( $oRoute )) { + // validating default values + if (isset( $aData['ROU_TO_LAST_USER'] )) { + $aData['ROU_TO_LAST_USER'] = $this->validateValue( $aData['ROU_TO_LAST_USER'], array ('TRUE','FALSE' + ), 'FALSE' ); + } + if (isset( $aData['ROU_OPTIONAL'] )) { + $aData['ROU_OPTIONAL'] = $this->validateValue( $aData['ROU_OPTIONAL'], array ('TRUE','FALSE' + ), 'FALSE' ); + } + if (isset( $aData['ROU_SEND_EMAIL'] )) { + $aData['ROU_SEND_EMAIL'] = $this->validateValue( $aData['ROU_SEND_EMAIL'], array ('TRUE','FALSE' + ), 'TRUE' ); + } + + $oRoute->fromArray( $aData, BasePeer::TYPE_FIELDNAME ); + if ($oRoute->validate()) { + $oConnection->begin(); + $iResult = $oRoute->save(); + $oConnection->commit(); + return $iResult; + } else { + $sMessage = ''; + $aValidationFailures = $oRoute->getValidationFailures(); + foreach ($aValidationFailures as $oValidationFailure) { + $sMessage .= $oValidationFailure->getMessage() . '
'; + } + throw (new Exception( 'The ROUTE tables cannot be updated!
' . $sMessage )); + } + } else { + throw (new Exception( "The row " . $aData['ROU_UID'] . " doesn't exist!" )); + } + } catch (Exception $oError) { + $oConnection->rollback(); + throw ($oError); + } + } + + /** + * Remove the application document registry + * + * @param array $aData + * @return string + * + */ + public function remove ($sRouUid) + { + $oConnection = Propel::getConnection( RoutePeer::DATABASE_NAME ); + try { + $oRoute = RoutePeer::retrieveByPK( $sRouUid ); + if (! is_null( $oRoute )) { + $oConnection->begin(); + $iResult = $oRoute->delete(); + $oConnection->commit(); + return $iResult; + } else { + throw (new Exception( 'This row doesn\'t exist!' )); + } + } catch (Exception $oError) { + $oConnection->rollback(); + throw ($oError); + } + } + + public function routeExists ($sRouUid) + { + $con = Propel::getConnection( RoutePeer::DATABASE_NAME ); + try { + $oRouUid = RoutePeer::retrieveByPk( $sRouUid ); + if (is_object( $oRouUid ) && get_class( $oRouUid ) == 'Route') { + return true; + } else { + return false; + } + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * Validate value for a variable that only accepts some determinated values + * + * @param $value string - value to test + * @param $validValues array - list of valid values + * @param $default string default value, if the tested value is not valid the default value is returned + * @return the tested and accepted value + */ + public function validateValue ($value, $validValues, $default) + { + if (! in_array( $value, $validValues )) { + $value = $default; + } + return $value; + } +} +// Route + diff --git a/workflow/engine/classes/model/Stage.php b/workflow/engine/classes/model/Stage.php index f9dddfa2e..f43c1a34e 100755 --- a/workflow/engine/classes/model/Stage.php +++ b/workflow/engine/classes/model/Stage.php @@ -1,200 +1,193 @@ -getStgUid() == "" ) { - throw ( new Exception( "Error in getStgTitle, the getStgUid() can't be blank") ); - } - $lang = defined ( 'SYS_LANG' ) ? SYS_LANG : 'en'; - $this->stg_title = Content::load ( 'STG_TITLE', '', $this->getStgUid(), $lang ); - return $this->stg_title; - } - - /** - * Set the stg_title column value. - * - * @param string $v new value - * @return void - */ - public function setStgTitle($v) - { - if ( $this->getStgUid() == "" ) { - throw ( new Exception( "Error in setStgTitle, the setStgUid() can't be blank") ); - } - $v=isset($v)?((string)$v):''; - $lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en'; - if ($this->stg_title !== $v || $v==="") { - $this->stg_title = $v; - $res = Content::addContent( 'STG_TITLE', '', $this->getStgUid(), $lang, $this->stg_title ); - return $res; - } - return 0; - } - - public function load($StgUid) - { - try { - $oRow = StagePeer::retrieveByPK( $StgUid ); - if (!is_null($oRow)) - { - $aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME); - $this->fromArray($aFields, BasePeer::TYPE_FIELDNAME); - $this->setNew(false); - $this->setStgTitle($aFields['STG_TITLE'] = $this->getStgTitle()); - return $aFields; - } - else { - throw( new Exception( "The row '$StgUid' in table Stage doesn't exist!" )); - } - } - catch (Exception $oError) { - throw($oError); - } - } - - public function create($aData) { - $oConnection = Propel::getConnection(StagePeer::DATABASE_NAME); - try { - if ( isset ( $aData['STG_UID'] ) && $aData['STG_UID']== '' ) - unset ( $aData['STG_UID'] ); - if ( !isset ( $aData['STG_UID'] ) ) - $aData['STG_UID'] = G::generateUniqueID(); - $oStage = new Stage(); - $oStage->fromArray($aData, BasePeer::TYPE_FIELDNAME); - $oStage->setStgTitle($aData['STG_TITLE']); - if ($oStage->validate()) { - $oConnection->begin(); - $iResult = $oStage->save(); - $oConnection->commit(); - return $aData['STG_UID']; - } - else { - $sMessage = ''; - $aValidationFailures = $oStage->getValidationFailures(); - foreach($aValidationFailures as $oValidationFailure) { - $sMessage .= $oValidationFailure->getMessage() . '
'; - } - throw(new Exception('The registry cannot be created!
'.$sMessage)); - } - } - catch (Exception $oError) { - $oConnection->rollback(); - throw($oError); - } - } - - public function update($fields) - { - $con = Propel::getConnection(StagePeer::DATABASE_NAME); - try - { - $con->begin(); - $this->load($fields['STG_UID']); - $this->fromArray($fields, BasePeer::TYPE_FIELDNAME); - if($this->validate()) - { - $contentResult=0; - if (array_key_exists("STG_TITLE", $fields)) $contentResult+=$this->setStgTitle($fields["STG_TITLE"]); - $result=$this->save(); - $result=($result==0)?($contentResult>0?1:0):$result; - $con->commit(); - return $result; - } - else - { - $con->rollback(); - $validationE=new Exception("Failed Validation in class ".get_class($this)."."); - $validationE->aValidationFailures = $this->getValidationFailures(); - throw($validationE); - } - } - catch(Exception $e) - { - $con->rollback(); - throw($e); - } - } - - public function remove($StgUid) - { - $con = Propel::getConnection(StagePeer::DATABASE_NAME); - try - { - $con->begin(); - $oStage = StagePeer::retrieveByPK( $StgUid ); - if (!is_null($oStage)) { - Content::removeContent( 'STG_TITLE', '', $this->getStgUid()); - $result = $oStage->delete(); - $con->commit(); - } - return $result; - } - catch(Exception $e) - { - $con->rollback(); - throw($e); - } - } - - function reorderPositions($sProcessUID, $iIndex) { - try { - $oCriteria = new Criteria('workflow'); - $oCriteria->add(StagePeer::PRO_UID, $sProcessUID); - $oCriteria->add(StagePeer::STG_INDEX, $iIndex, '>'); - $oDataset = StagePeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - while ($aRow = $oDataset->getRow()) { - $this->update(array('STG_UID' => $aRow['STG_UID'], - 'PRO_UID' => $aRow['PRO_UID'], - 'STG_POSX' => $aRow['STG_POSX'], - 'STG_POSY' => $aRow['STG_POSY'], - 'STG_INDEX' => $aRow['STG_INDEX'] - 1)); - $oDataset->next(); - } - } - catch (Exception $oException) { - throw $Exception; - } - } - - function Exists ( $sUid ) { - try { - $oObj = StagePeer::retrieveByPk($sUid); - return (is_object($oObj) && get_class($oObj) == 'Stage'); - } - catch (Exception $oError) { - throw($oError); - } - } -} // Stage +getStgUid() == "") { + throw (new Exception( "Error in getStgTitle, the getStgUid() can't be blank" )); + } + $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en'; + $this->stg_title = Content::load( 'STG_TITLE', '', $this->getStgUid(), $lang ); + return $this->stg_title; + } + + /** + * Set the stg_title column value. + * + * @param string $v new value + * @return void + */ + public function setStgTitle ($v) + { + if ($this->getStgUid() == "") { + throw (new Exception( "Error in setStgTitle, the setStgUid() can't be blank" )); + } + $v = isset( $v ) ? ((string) $v) : ''; + $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en'; + if ($this->stg_title !== $v || $v === "") { + $this->stg_title = $v; + $res = Content::addContent( 'STG_TITLE', '', $this->getStgUid(), $lang, $this->stg_title ); + return $res; + } + return 0; + } + + public function load ($StgUid) + { + try { + $oRow = StagePeer::retrieveByPK( $StgUid ); + if (! is_null( $oRow )) { + $aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME ); + $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME ); + $this->setNew( false ); + $this->setStgTitle( $aFields['STG_TITLE'] = $this->getStgTitle() ); + return $aFields; + } else { + throw (new Exception( "The row '$StgUid' in table Stage doesn't exist!" )); + } + } catch (Exception $oError) { + throw ($oError); + } + } + + public function create ($aData) + { + $oConnection = Propel::getConnection( StagePeer::DATABASE_NAME ); + try { + if (isset( $aData['STG_UID'] ) && $aData['STG_UID'] == '') { + unset( $aData['STG_UID'] ); + } + if (! isset( $aData['STG_UID'] )) { + $aData['STG_UID'] = G::generateUniqueID(); + } + $oStage = new Stage(); + $oStage->fromArray( $aData, BasePeer::TYPE_FIELDNAME ); + $oStage->setStgTitle( $aData['STG_TITLE'] ); + if ($oStage->validate()) { + $oConnection->begin(); + $iResult = $oStage->save(); + $oConnection->commit(); + return $aData['STG_UID']; + } else { + $sMessage = ''; + $aValidationFailures = $oStage->getValidationFailures(); + foreach ($aValidationFailures as $oValidationFailure) { + $sMessage .= $oValidationFailure->getMessage() . '
'; + } + throw (new Exception( 'The registry cannot be created!
' . $sMessage )); + } + } catch (Exception $oError) { + $oConnection->rollback(); + throw ($oError); + } + } + + public function update ($fields) + { + $con = Propel::getConnection( StagePeer::DATABASE_NAME ); + try { + $con->begin(); + $this->load( $fields['STG_UID'] ); + $this->fromArray( $fields, BasePeer::TYPE_FIELDNAME ); + if ($this->validate()) { + $contentResult = 0; + if (array_key_exists( "STG_TITLE", $fields )) { + $contentResult += $this->setStgTitle( $fields["STG_TITLE"] ); + } + $result = $this->save(); + $result = ($result == 0) ? ($contentResult > 0 ? 1 : 0) : $result; + $con->commit(); + return $result; + } else { + $con->rollback(); + $validationE = new Exception( "Failed Validation in class " . get_class( $this ) . "." ); + $validationE->aValidationFailures = $this->getValidationFailures(); + throw ($validationE); + } + } catch (Exception $e) { + $con->rollback(); + throw ($e); + } + } + + public function remove ($StgUid) + { + $con = Propel::getConnection( StagePeer::DATABASE_NAME ); + try { + $con->begin(); + $oStage = StagePeer::retrieveByPK( $StgUid ); + if (! is_null( $oStage )) { + Content::removeContent( 'STG_TITLE', '', $this->getStgUid() ); + $result = $oStage->delete(); + $con->commit(); + } + return $result; + } catch (Exception $e) { + $con->rollback(); + throw ($e); + } + } + + public function reorderPositions ($sProcessUID, $iIndex) + { + try { + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( StagePeer::PRO_UID, $sProcessUID ); + $oCriteria->add( StagePeer::STG_INDEX, $iIndex, '>' ); + $oDataset = StagePeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + while ($aRow = $oDataset->getRow()) { + $this->update( array ('STG_UID' => $aRow['STG_UID'],'PRO_UID' => $aRow['PRO_UID'],'STG_POSX' => $aRow['STG_POSX'],'STG_POSY' => $aRow['STG_POSY'],'STG_INDEX' => $aRow['STG_INDEX'] - 1 + ) ); + $oDataset->next(); + } + } catch (Exception $oException) { + throw $Exception; + } + } + + public function Exists ($sUid) + { + try { + $oObj = StagePeer::retrieveByPk( $sUid ); + return (is_object( $oObj ) && get_class( $oObj ) == 'Stage'); + } catch (Exception $oError) { + throw ($oError); + } + } +} +// Stage + diff --git a/workflow/engine/classes/model/StepSupervisor.php b/workflow/engine/classes/model/StepSupervisor.php index a69e165c6..2c741740b 100755 --- a/workflow/engine/classes/model/StepSupervisor.php +++ b/workflow/engine/classes/model/StepSupervisor.php @@ -1,230 +1,229 @@ -toArray(BasePeer::TYPE_FIELDNAME); - $this->fromArray($aFields,BasePeer::TYPE_FIELDNAME); - $this->setNew(false); - return $aFields; - } - else { - throw( new Exception( "The row '$Uid' in table StepSupervisor doesn't exist!" )); - } - } - catch (Exception $oError) { - throw($oError); - } - } - - function Exists ( $Uid ) { - try { - $oPro = StepSupervisorPeer::retrieveByPk( $Uid ); - if (is_object($oPro) && get_class ($oPro) == 'StepSupervisor' ) { - return true; - } - else { - return false; - } - } - catch (Exception $oError) { - throw($oError); - } - } - - /** - * Create the step supervisor registry - * @param array $aData - * @return boolean - **/ - public function create($aData) - { - $oConnection = Propel::getConnection(StepSupervisorPeer::DATABASE_NAME); - try { - if ( isset ( $aData['STEP_UID'] ) && $aData['STEP_UID']== '' ) - unset ( $aData['STEP_UID'] ); - if ( !isset ( $aData['STEP_UID'] ) ) - $aData['STEP_UID'] = G::generateUniqueID(); - $oStepSupervisor = new StepSupervisor(); - $oStepSupervisor->fromArray($aData, BasePeer::TYPE_FIELDNAME); - if ($oStepSupervisor->validate()) { - $oConnection->begin(); - $iResult = $oStepSupervisor->save(); - $oConnection->commit(); - return true; - } - else { - $sMessage = ''; - $aValidationFailures = $oStepSupervisor->getValidationFailures(); - foreach($aValidationFailures as $oValidationFailure) { - $sMessage .= $oValidationFailure->getMessage() . '
'; - } - throw(new Exception('The registry cannot be created!
'.$sMessage)); - } - } - catch (Exception $oError) { - $oConnection->rollback(); - throw($oError); - } - } - - /** - * Update the step supervisor registry - * @param array $aData - * @return integer - **/ - public function update($aData) - { - $oConnection = Propel::getConnection(StepSupervisorPeer::DATABASE_NAME); - try { - $oStepSupervisor = StepSupervisorPeer::retrieveByPK($aData['STEP_UID']); - if (!is_null($oStepSupervisor)) - { - $oStepSupervisor->fromArray($aData, BasePeer::TYPE_FIELDNAME); - if ($oStepSupervisor->validate()) { - $oConnection->begin(); - $iResult = $oStepSupervisor->save(); - $oConnection->commit(); - return $iResult; - } - else { - $sMessage = ''; - $aValidationFailures = $oStepSupervisor->getValidationFailures(); - foreach($aValidationFailures as $oValidationFailure) { - $sMessage .= $oValidationFailure->getMessage() . '
'; - } - throw(new Exception('The registry cannot be updated!
'.$sMessage)); - } - } - else { - throw(new Exception('This row doesn\'t exist!')); - } - } - catch (Exception $oError) { - $oConnection->rollback(); - throw($oError); - } - } - - /** - * Remove the step supervisor registry - * @param string $sStepUID - * @return integer - **/ - public function remove($sStepUID) - { - $oConnection = Propel::getConnection(StepSupervisorPeer::DATABASE_NAME); - try { - $oConnection->begin(); - $this->setStepUid($sStepUID); - $iResult = $this->delete(); - $oConnection->commit(); - return $iResult; - } - catch (Exception $oError) { - $oConnection->rollback(); - throw($oError); - } - } - - /** - * Get the next position for a atep - * @param string $sProcessUID - * @return integer - **/ - function getNextPosition($sProcessUID, $sType) { - try { - $oCriteria = new Criteria('workflow'); - $oCriteria->addSelectColumn('(COUNT(*) + 1) AS POSITION'); - $oCriteria->add(StepSupervisorPeer::PRO_UID, $sProcessUID); - $oCriteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, $sType); - $oDataset = StepSupervisorPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - $aRow = $oDataset->getRow(); - return (int)$aRow['POSITION']; - } - catch (Exception $oException) { - throw $Exception; - } - } - - /** - * Reorder the steps positions - * @param string $sProcessUID - * @param string $iPosition - **/ - function reorderPositions($sProcessUID, $iPosition, $sType) { - try { - $oCriteria = new Criteria('workflow'); - $oCriteria->add(StepSupervisorPeer::PRO_UID, $sProcessUID); - $oCriteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, $sType); - $oCriteria->add(StepSupervisorPeer::STEP_POSITION, $iPosition, '>'); - $oDataset = StepSupervisorPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next();var_dump(StepSupervisorPeer::doCount($oCriteria)); - while ($aRow = $oDataset->getRow()) {var_dump($aRow);echo "\n"; - $this->update(array('STEP_UID' => $aRow['STEP_UID'], - 'PRO_UID' => $aRow['PRO_UID'], - 'STEP_TYPE_OBJ' => $aRow['STEP_TYPE_OBJ'], - 'STEP_UID_OBJ' => $aRow['STEP_UID_OBJ'], - 'STEP_POSITION' => $aRow['STEP_POSITION'] - 1)); - $oDataset->next(); - } - } - catch (Exception $oException) { - throw $Exception; - } - } - - - function removeByObject($sType, $sObjUid) { - try { - $oCriteria = new Criteria('workflow'); - $oCriteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, $sType); - $oCriteria->add(StepSupervisorPeer::STEP_UID_OBJ, $sObjUid); - StepSupervisorPeer::doDelete($oCriteria); - } - catch(Exception $e) { - throw($e); - } - } - -function loadInfo($sObjUID){ - - $oCriteria = new Criteria('workflow'); - $oCriteria->add(StepSupervisorPeer::STEP_UID_OBJ, $sObjUID); - $oDataset = StepSupervisorPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - $aRow = $oDataset->getRow(); - return($aRow); - - - } - - -} // StepSupervisor +toArray( BasePeer::TYPE_FIELDNAME ); + $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME ); + $this->setNew( false ); + return $aFields; + } else { + throw (new Exception( "The row '$Uid' in table StepSupervisor doesn't exist!" )); + } + } catch (Exception $oError) { + throw ($oError); + } + } + + public function Exists ($Uid) + { + try { + $oPro = StepSupervisorPeer::retrieveByPk( $Uid ); + if (is_object( $oPro ) && get_class( $oPro ) == 'StepSupervisor') { + return true; + } else { + return false; + } + } catch (Exception $oError) { + throw ($oError); + } + } + + /** + * Create the step supervisor registry + * + * @param array $aData + * @return boolean + * + */ + public function create ($aData) + { + $oConnection = Propel::getConnection( StepSupervisorPeer::DATABASE_NAME ); + try { + if (isset( $aData['STEP_UID'] ) && $aData['STEP_UID'] == '') { + unset( $aData['STEP_UID'] ); + } + if (! isset( $aData['STEP_UID'] )) { + $aData['STEP_UID'] = G::generateUniqueID(); + } + $oStepSupervisor = new StepSupervisor(); + $oStepSupervisor->fromArray( $aData, BasePeer::TYPE_FIELDNAME ); + if ($oStepSupervisor->validate()) { + $oConnection->begin(); + $iResult = $oStepSupervisor->save(); + $oConnection->commit(); + return true; + } else { + $sMessage = ''; + $aValidationFailures = $oStepSupervisor->getValidationFailures(); + foreach ($aValidationFailures as $oValidationFailure) { + $sMessage .= $oValidationFailure->getMessage() . '
'; + } + throw (new Exception( 'The registry cannot be created!
' . $sMessage )); + } + } catch (Exception $oError) { + $oConnection->rollback(); + throw ($oError); + } + } + + /** + * Update the step supervisor registry + * + * @param array $aData + * @return integer + * + */ + public function update ($aData) + { + $oConnection = Propel::getConnection( StepSupervisorPeer::DATABASE_NAME ); + try { + $oStepSupervisor = StepSupervisorPeer::retrieveByPK( $aData['STEP_UID'] ); + if (! is_null( $oStepSupervisor )) { + $oStepSupervisor->fromArray( $aData, BasePeer::TYPE_FIELDNAME ); + if ($oStepSupervisor->validate()) { + $oConnection->begin(); + $iResult = $oStepSupervisor->save(); + $oConnection->commit(); + return $iResult; + } else { + $sMessage = ''; + $aValidationFailures = $oStepSupervisor->getValidationFailures(); + foreach ($aValidationFailures as $oValidationFailure) { + $sMessage .= $oValidationFailure->getMessage() . '
'; + } + throw (new Exception( 'The registry cannot be updated!
' . $sMessage )); + } + } else { + throw (new Exception( 'This row doesn\'t exist!' )); + } + } catch (Exception $oError) { + $oConnection->rollback(); + throw ($oError); + } + } + + /** + * Remove the step supervisor registry + * + * @param string $sStepUID + * @return integer + * + */ + public function remove ($sStepUID) + { + $oConnection = Propel::getConnection( StepSupervisorPeer::DATABASE_NAME ); + try { + $oConnection->begin(); + $this->setStepUid( $sStepUID ); + $iResult = $this->delete(); + $oConnection->commit(); + return $iResult; + } catch (Exception $oError) { + $oConnection->rollback(); + throw ($oError); + } + } + + /** + * Get the next position for a atep + * + * @param string $sProcessUID + * @return integer + * + */ + public function getNextPosition ($sProcessUID, $sType) + { + try { + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->addSelectColumn( '(COUNT(*) + 1) AS POSITION' ); + $oCriteria->add( StepSupervisorPeer::PRO_UID, $sProcessUID ); + $oCriteria->add( StepSupervisorPeer::STEP_TYPE_OBJ, $sType ); + $oDataset = StepSupervisorPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aRow = $oDataset->getRow(); + return (int) $aRow['POSITION']; + } catch (Exception $oException) { + throw $Exception; + } + } + + /** + * Reorder the steps positions + * + * @param string $sProcessUID + * @param string $iPosition + * + */ + public function reorderPositions ($sProcessUID, $iPosition, $sType) + { + try { + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( StepSupervisorPeer::PRO_UID, $sProcessUID ); + $oCriteria->add( StepSupervisorPeer::STEP_TYPE_OBJ, $sType ); + $oCriteria->add( StepSupervisorPeer::STEP_POSITION, $iPosition, '>' ); + $oDataset = StepSupervisorPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + var_dump( StepSupervisorPeer::doCount( $oCriteria ) ); + while ($aRow = $oDataset->getRow()) { + var_dump( $aRow ); + echo "\n"; + $this->update( array ('STEP_UID' => $aRow['STEP_UID'],'PRO_UID' => $aRow['PRO_UID'],'STEP_TYPE_OBJ' => $aRow['STEP_TYPE_OBJ'],'STEP_UID_OBJ' => $aRow['STEP_UID_OBJ'],'STEP_POSITION' => $aRow['STEP_POSITION'] - 1 + ) ); + $oDataset->next(); + } + } catch (Exception $oException) { + throw $Exception; + } + } + + public function removeByObject ($sType, $sObjUid) + { + try { + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( StepSupervisorPeer::STEP_TYPE_OBJ, $sType ); + $oCriteria->add( StepSupervisorPeer::STEP_UID_OBJ, $sObjUid ); + StepSupervisorPeer::doDelete( $oCriteria ); + } catch (Exception $e) { + throw ($e); + } + } + + public function loadInfo ($sObjUID) + { + + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( StepSupervisorPeer::STEP_UID_OBJ, $sObjUID ); + $oDataset = StepSupervisorPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aRow = $oDataset->getRow(); + return ($aRow); + } +} +// StepSupervisor + diff --git a/workflow/engine/classes/triggers/class.pmSugarFunctions.php b/workflow/engine/classes/triggers/class.pmSugarFunctions.php index 94d0ea1ea..577fb443a 100755 --- a/workflow/engine/classes/triggers/class.pmSugarFunctions.php +++ b/workflow/engine/classes/triggers/class.pmSugarFunctions.php @@ -1,12 +1,13 @@ - 1); - - //Apply proxy settings - $sysConf = System::getSystemConfiguration(); - if ($sysConf['proxy_host'] != '') { - $options['proxy_host'] = $sysConf['proxy_host']; - if ($sysConf['proxy_port'] != '') { - $options['proxy_port'] = $sysConf['proxy_port']; - } - if ($sysConf['proxy_user'] != '') { - $options['proxy_login'] = $sysConf['proxy_user']; - } - if ($sysConf['proxy_pass'] != '') { - $options['proxy_password'] = $sysConf['proxy_pass']; - } - } - - return $options; -} - -/** - * This collection of triggers allows to interact by getting and sending information to SugarCRM - * @class pmSugar - * @name Sugar CRM Triggers - * @icon /images/triggers/icon_SugarCRM.gif - * @className class.pmSugar.pmFunctions.php - */ - -function sugarLogin($sugarSoap, $user, $password) { - $client = new SoapClient ( $sugarSoap, getSoapClientOptions() ); - $auth_array = array ('user_auth' => array ('user_name' => $user, 'password' => md5 ( $password ), 'version' => '1.0' ) ); - $login_results = $client->__SoapCall ( 'login', $auth_array ); - - $session_id = $login_results->id; - $user_guid = $client->__SoapCall ( 'get_user_id', array ($session_id ) ); - return $session_id; -} - -function objectToArray($object) { - if (! is_object ( $object ) && ! is_array ( $object )) { - return $object; - } - if (is_object ( $object )) { - $object = get_object_vars ( $object ); - } - return array_map ( "objectToArray", $object ); -} - -/** - * @method - * - * Gets SugarCRM entry using get_entry web service. - * - * @name GetSugarEntry - * @label Get SugarCRM Entry - * - * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl [^] - * @param string | $user | User - * @param string | $password | Password - * @param string | $module | The name of the module from which to retrieve records. - * @param string | $id | The SugarBean’s ID. - * @param string | $selectedFields | Optional. The list of fields to be returned in the results. - * @param string | $linkNameToFieldsArray | A list of link names and the fields to be returned for each link name. - * @param string | $resultType=array | Result type (array or object) - * - * @return array/object | $sugarEntries | Sugar Entries (array or object) - * - */ - -function GetSugarEntry($sugarSoap, $user, $password, $module, $id, $selectFields, $linkNameToFieldsArray, $resultType = 'array') { - $sessionId = sugarLogin ( $sugarSoap, $user, $password ); - $client = new SoapClient ( $sugarSoap, getSoapClientOptions() ); - $request_array = array ('session' => $sessionId, 'module_name' => $module, 'id' => $id, - 'select_fields' => $select_fields, 'link_name_to_fields_array' => $linkNameToFieldsArray); - $sugarEntry = $client->__SoapCall ( 'get_entry', $request_array ); - - if($resultType == 'array'){ - $sugarEntry = objectToArray ( $sugarEntry ); - } - - return $sugarEntry; -} - -/** - * @method - * - * Gets SugarCRM entries from the indicated module. - * - * @name GetSugarEntries - * @label Get SugarCRM Entries - * - * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl - * @param string | $user | User - * @param string | $password | Password - * @param string | $module | Module - * @param string | $query | Query - * @param string | $orderBy | Order By - * @param string | $selectedFields | Selected Fields - * @param string | $maxResults=50 | Max Results - * @param string | $resultType=array | Result type (array or object) - * - * @return array/object | $sugarEntries | Sugar Entries (array or object) - * - */ - -function GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") { - $sessionId = sugarLogin ( $sugarSoap, $user, $password ); - $client = new SoapClient ( $sugarSoap, getSoapClientOptions() ); - $request_array = array ('session' => $sessionId, 'module_name' => $module, 'query' => $query, 'order_by' => $orderBy, 'offset'=>"", 'select_fields'=>"", 'max_result'=>$maxResults ); - $sugarEntriesO = $client->__SoapCall ( 'get_entry_list', $request_array ); - - switch($resultType){ - case 'array':$sugarEntries = objectToArray ( $sugarEntriesO ); break; - case 'object':$sugarEntries = $sugarEntriesO; break; - default: $sugarEntries = objectToArray ( $sugarEntries ); - } - - return $sugarEntries; - -} -/** - * @method - * - * Gets SugarCRM entries from the Calls module - * - * @name GetSugarCalls - * @label Gets SugarCRM entries from the Calls module - * - * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl - * @param string | $user | User - * @param string | $password | Password - * @param string | $query | Query - * @param string | $orderBy | Order By - * @param string | $selectedFields | Selected Fields - * @param string | $maxResults=50 | Max Results - * @param string | $resultType=array | Result type (array or object) - * - * @return array/object | $sugarCalls | Sugar Calls (array or object) - * - */ - -function GetSugarCalls($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") { - $module="Calls"; - return GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType); -} -/** - * @method - * - * Gets SugarCRM entries from the Leads module. - * - * @name GetSugarLeads - * @label Gets SugarCRM entries from the Leads module. - * - * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl - * @param string | $user | User - * @param string | $password | Password - * @param string | $query | Query - * @param string | $orderBy | Order By - * @param string | $selectedFields | Selected Fields - * @param string | $maxResults=50 | Max Results - * @param string | $resultType=array | Result type (array or object) - * - * @return array/object | $sugarLeads | Sugar Leads (array or object) - * - */ - -function GetSugarLeads($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") { - $module="Leads"; - return GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType); -} -/** - * @method - * - * Gets SugarCRM entries from the Contacts module. - * - * @name GetSugarContacts - * @label Gets SugarCRM entries from the Contacts module. - * - * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl - * @param string | $user | User - * @param string | $password | Password - * @param string | $query | Query - * @param string | $orderBy | Order By - * @param string | $selectedFields | Selected Fields - * @param string | $maxResults=50 | Max Results - * @param string | $resultType=array | Result type (array or object) - * - * @return array/object | $sugarContacts | Sugar Contacts (array or object) - * - */ - -function GetSugarContacts($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") { - $module="Contacts"; - return GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType); -} -/** - * @method - * - * Gets SugarCRM entries from the Opportunities module. - * - * @name GetSugarOpportunities - * @label Gets SugarCRM entries from the Opportunities module. - * - * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl - * @param string | $user | User - * @param string | $password | Password - * @param string | $query | Query - * @param string | $orderBy | Order By - * @param string | $selectedFields | Selected Fields - * @param string | $maxResults=50 | Max Results - * @param string | $resultType=array | Result type (array or object) - * - * @return array/object | $sugarAccount | Sugar Opportunities (array or object) - * - */ - -function GetSugarOpportunities($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") { - $module="Opportunities"; - return GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType); -} - -/** - * @method - * - * Gets SugarCRM entries from the Account module. - * - * @name GetSugarAccount - * @label Gets SugarCRM entries from the Account module. - * - * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl - * @param string | $user | User - * @param string | $password | Password - * @param string | $query | Query - * @param string | $orderBy | Order By - * @param string | $selectedFields | Selected Fields - * @param string | $maxResults=50 | Max Results - * @param string | $resultType=array | Result type (array or object) - * - * @return array/object | $sugarAccount | Sugar Opportunities (array or object) - * - */ - -function GetSugarAccount($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType="array") { - $module="Accounts"; - return GetSugarEntries($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType); -} - - -/** - * @method - * - * Creates SugarCRM entries from the Account module. - * - * @name CreateSugarAccount - * - * @label Creates SugarCRM entries from the Account module. - * - * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl - * @param string | $user | User - * @param string | $password | Password - * @param string | $name | Account name - * @param string | $resultType=array | Result type (array or object) - * - * @return array/object | $sugarAccount | Sugar Opportunities (array or object) - * - */ -function CreateSugarAccount($sugarSoap, $user, $password, $name, $resultType="array") { - - $module = "Accounts"; - $sessionId = sugarLogin ( $sugarSoap, $user, $password ); - $client = new SoapClient ( $sugarSoap, getSoapClientOptions() ); - $request_array = array ('session' => $sessionId, 'module_name' => $module, 'name_value_list' => array( - array("name" => 'name', "value" => $name ) - ) ); - $sugarEntriesO = $client->__SoapCall ( 'set_entry', $request_array ); - $account_id = $sugarEntriesO ->id; - - switch($resultType){ - case 'array':$sugarEntries = objectToArray ( $sugarEntriesO );break; - case 'object':$sugarEntries = $sugarEntries ;break; - default: $sugarEntries = objectToArray ( $sugarEntries ); - } - //return $sugarEntries; - return $account_id; -} - -/** - * @method - * - * Creates SugarCRM entries from the Account module - * - * @name CreateSugarContact - * - * @label Creates SugarCRM entries from the Account module - * - * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl - * @param string | $user | User - * @param string | $password | Password - * @param string | $first_name | First Name - * @param string | $last_name | Last Name - * @param string | $email | Email - * @param string | $title | Title - * @param string | $phone | Phone Work - * @param string | $account_id | Valid id account - * @param string | $resultType=array | Result type (array or object) - * - * @return array/object | $sugarContact | Sugar Opportunities (array or object) - * - */ -function CreateSugarContact($sugarSoap, $user, $password, $first_name, $last_name, $email, $title, $phone, $account_id, $resultType="array") { - - $module = "Contacts"; -/* $aValue = array( + + +function getSoapClientOptions () +{ + $options = array ('trace' => 1); + + //Apply proxy settings + $sysConf = System::getSystemConfiguration(); + if ($sysConf['proxy_host'] != '') { + $options['proxy_host'] = $sysConf['proxy_host']; + if ($sysConf['proxy_port'] != '') { + $options['proxy_port'] = $sysConf['proxy_port']; + } + if ($sysConf['proxy_user'] != '') { + $options['proxy_login'] = $sysConf['proxy_user']; + } + if ($sysConf['proxy_pass'] != '') { + $options['proxy_password'] = $sysConf['proxy_pass']; + } + } + + return $options; +} + +/** + * This collection of triggers allows to interact by getting and sending information to SugarCRM + * @class pmSugar + * + * @name Sugar CRM Triggers + * @icon /images/triggers/icon_SugarCRM.gif + * @className class.pmSugar.pmFunctions.php + */ + +function sugarLogin ($sugarSoap, $user, $password) +{ + $client = new SoapClient( $sugarSoap, getSoapClientOptions() ); + $auth_array = array ('user_auth' => array ('user_name' => $user,'password' => md5( $password ),'version' => '1.0') ); + $login_results = $client->__SoapCall( 'login', $auth_array ); + $session_id = $login_results->id; + $user_guid = $client->__SoapCall( 'get_user_id', array ($session_id) ); + return $session_id; +} + +function objectToArray ($object) +{ + if (! is_object( $object ) && ! is_array( $object )) { + return $object; + } + if (is_object( $object )) { + $object = get_object_vars( $object ); + } + return array_map( "objectToArray", $object ); +} + +/** + * + * @method Gets SugarCRM entry using get_entry web service. + * + * @name GetSugarEntry + * @label Get SugarCRM Entry + * + * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl [^] + * @param string | $user | User + * @param string | $password | Password + * @param string | $module | The name of the module from which to retrieve records. + * @param string | $id | The SugarBean’s ID. + * @param string | $selectedFields | Optional. The list of fields to be returned in the results. + * @param string | $linkNameToFieldsArray | A list of link names and the fields to be returned for each link name. + * @param string | $resultType=array | Result type (array or object) + * + * @return array/object | $sugarEntries | Sugar Entries (array or object) + * + */ + +function GetSugarEntry ($sugarSoap, $user, $password, $module, $id, $selectFields, $linkNameToFieldsArray, $resultType = 'array') +{ + $sessionId = sugarLogin( $sugarSoap, $user, $password ); + $client = new SoapClient( $sugarSoap, getSoapClientOptions() ); + $request_array = array ('session' => $sessionId,'module_name' => $module,'id' => $id,'select_fields' => $select_fields,'link_name_to_fields_array' => $linkNameToFieldsArray); + $sugarEntry = $client->__SoapCall( 'get_entry', $request_array ); + + if ($resultType == 'array') { + $sugarEntry = objectToArray( $sugarEntry ); + } + + return $sugarEntry; +} + +/** + * + * @method Gets SugarCRM entries from the indicated module. + * + * @name GetSugarEntries + * @label Get SugarCRM Entries + * + * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl + * @param string | $user | User + * @param string | $password | Password + * @param string | $module | Module + * @param string | $query | Query + * @param string | $orderBy | Order By + * @param string | $selectedFields | Selected Fields + * @param string | $maxResults=50 | Max Results + * @param string | $resultType=array | Result type (array or object) + * + * @return array/object | $sugarEntries | Sugar Entries (array or object) + * + */ + +function GetSugarEntries ($sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array") +{ + $sessionId = sugarLogin( $sugarSoap, $user, $password ); + $client = new SoapClient( $sugarSoap, getSoapClientOptions() ); + $request_array = array ('session' => $sessionId,'module_name' => $module,'query' => $query,'order_by' => $orderBy,'offset' => "",'select_fields' => "",'max_result' => $maxResults); + $sugarEntriesO = $client->__SoapCall( 'get_entry_list', $request_array ); + + switch ($resultType) { + case 'array': + $sugarEntries = objectToArray( $sugarEntriesO ); + break; + case 'object': + $sugarEntries = $sugarEntriesO; + break; + default: + $sugarEntries = objectToArray( $sugarEntries ); + } + + return $sugarEntries; + +} + +/** + * + * @method Gets SugarCRM entries from the Calls module + * + * @name GetSugarCalls + * @label Gets SugarCRM entries from the Calls module + * + * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl + * @param string | $user | User + * @param string | $password | Password + * @param string | $query | Query + * @param string | $orderBy | Order By + * @param string | $selectedFields | Selected Fields + * @param string | $maxResults=50 | Max Results + * @param string | $resultType=array | Result type (array or object) + * + * @return array/object | $sugarCalls | Sugar Calls (array or object) + * + */ + +function GetSugarCalls ($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array") +{ + $module = "Calls"; + return GetSugarEntries( $sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType ); +} + +/** + * + * @method Gets SugarCRM entries from the Leads module. + * + * @name GetSugarLeads + * @label Gets SugarCRM entries from the Leads module. + * + * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl + * @param string | $user | User + * @param string | $password | Password + * @param string | $query | Query + * @param string | $orderBy | Order By + * @param string | $selectedFields | Selected Fields + * @param string | $maxResults=50 | Max Results + * @param string | $resultType=array | Result type (array or object) + * + * @return array/object | $sugarLeads | Sugar Leads (array or object) + * + */ + +function GetSugarLeads ($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array") +{ + $module = "Leads"; + return GetSugarEntries( $sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType ); +} + +/** + * + * @method Gets SugarCRM entries from the Contacts module. + * + * @name GetSugarContacts + * @label Gets SugarCRM entries from the Contacts module. + * + * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl + * @param string | $user | User + * @param string | $password | Password + * @param string | $query | Query + * @param string | $orderBy | Order By + * @param string | $selectedFields | Selected Fields + * @param string | $maxResults=50 | Max Results + * @param string | $resultType=array | Result type (array or object) + * + * @return array/object | $sugarContacts | Sugar Contacts (array or object) + * + */ + +function GetSugarContacts ($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array") +{ + $module = "Contacts"; + return GetSugarEntries( $sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType ); +} + +/** + * + * @method Gets SugarCRM entries from the Opportunities module. + * + * @name GetSugarOpportunities + * @label Gets SugarCRM entries from the Opportunities module. + * + * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl + * @param string | $user | User + * @param string | $password | Password + * @param string | $query | Query + * @param string | $orderBy | Order By + * @param string | $selectedFields | Selected Fields + * @param string | $maxResults=50 | Max Results + * @param string | $resultType=array | Result type (array or object) + * + * @return array/object | $sugarAccount | Sugar Opportunities (array or object) + * + */ + +function GetSugarOpportunities ($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array") +{ + $module = "Opportunities"; + return GetSugarEntries( $sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType ); +} + +/** + * + * @method Gets SugarCRM entries from the Account module. + * + * @name GetSugarAccount + * @label Gets SugarCRM entries from the Account module. + * + * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl + * @param string | $user | User + * @param string | $password | Password + * @param string | $query | Query + * @param string | $orderBy | Order By + * @param string | $selectedFields | Selected Fields + * @param string | $maxResults=50 | Max Results + * @param string | $resultType=array | Result type (array or object) + * + * @return array/object | $sugarAccount | Sugar Opportunities (array or object) + * + */ + +function GetSugarAccount ($sugarSoap, $user, $password, $query, $orderBy, $selectedFields, $maxResults, $resultType = "array") +{ + $module = "Accounts"; + return GetSugarEntries( $sugarSoap, $user, $password, $module, $query, $orderBy, $selectedFields, $maxResults, $resultType ); +} + +/** + * + * @method Creates SugarCRM entries from the Account module. + * + * @name CreateSugarAccount + * + * @label Creates SugarCRM entries from the Account module. + * + * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl + * @param string | $user | User + * @param string | $password | Password + * @param string | $name | Account name + * @param string | $resultType=array | Result type (array or object) + * + * @return array/object | $sugarAccount | Sugar Opportunities (array or object) + * + */ +function CreateSugarAccount ($sugarSoap, $user, $password, $name, $resultType = "array") +{ + + $module = "Accounts"; + $sessionId = sugarLogin( $sugarSoap, $user, $password ); + $client = new SoapClient( $sugarSoap, getSoapClientOptions() ); + $request_array = array ('session' => $sessionId,'module_name' => $module,'name_value_list' => array (array ("name" => 'name',"value" => $name))); + $sugarEntriesO = $client->__SoapCall( 'set_entry', $request_array ); + $account_id = $sugarEntriesO->id; + + switch ($resultType) { + case 'array': + $sugarEntries = objectToArray( $sugarEntriesO ); + break; + case 'object': + $sugarEntries = $sugarEntries; + break; + default: + $sugarEntries = objectToArray( $sugarEntries ); + } + //return $sugarEntries; + return $account_id; +} + +/** + * + * @method Creates SugarCRM entries from the Account module + * + * @name CreateSugarContact + * + * @label Creates SugarCRM entries from the Account module + * + * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl + * @param string | $user | User + * @param string | $password | Password + * @param string | $first_name | First Name + * @param string | $last_name | Last Name + * @param string | $email | Email + * @param string | $title | Title + * @param string | $phone | Phone Work + * @param string | $account_id | Valid id account + * @param string | $resultType=array | Result type (array or object) + * + * @return array/object | $sugarContact | Sugar Opportunities (array or object) + * + */ +function CreateSugarContact ($sugarSoap, $user, $password, $first_name, $last_name, $email, $title, $phone, $account_id, $resultType = "array") +{ + $module = "Contacts"; + /* $aValue = array( array("name" => 'id', "value" => G::generateUniqueID()), array("name" => 'first_name', "value" => $first_name), array("name" => 'last_name', "value" => $last_name), ); -*/ - $sessionId = sugarLogin ( $sugarSoap, $user, $password ); - $client = new SoapClient ( $sugarSoap, getSoapClientOptions() ); - - $request_array = array ('session' => $sessionId, 'module_name' => $module, array( - array("name" => 'first_name',"value" => $first_name), - array("name" => 'last_name',"value" => $last_name), - array("name" => 'email1',"value" => $email), - array("name" => 'title',"value" => $title), - array("name" => 'phone_work',"value" => $phone), - // array("name" => 'account_id',"value" => '8cd10a60-101f-4363-1e0b-4cfd4106bd7e') - array("name" => 'account_id',"value" => $account_id) - )); - - $sugarEntriesO = $client->__SoapCall ( 'set_entry', $request_array ); - - switch($resultType){ - case 'array':$sugarEntries = objectToArray ( $sugarEntriesO ); break; - case 'object':$sugarEntries = $sugarEntries; break; - default: $sugarEntries = objectToArray ( $sugarEntries ); - } - return $sugarEntries; -} - - -/** - * @method - * - * Creates SugarCRM entries from the Opportunities module. - * - * @name CreateSugarOpportunity - - * @label Creates SugarCRM entries from the Opportunities module. - * - * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl - * @param string | $user | User - * @param string | $password | Password - * @param string | $name | Name - * @param string | $account_id | Valid id account - * @param string | $amount | Amount - * @param string | $date_closed | Date Closed - * @param string | $sales_stage | Prospecting, Qualification, Needs Analysis, Value Proposition, Id. Decision Makers, Perception Analysis, Proposal/Price Quote, Negotiation/Review, Closed Won, Closed Lost - * @param string | $resultType=array | Result type (array or object) - * - * @return array/object | $sugarOpportunity | Sugar Opportunities (array or object) - * - */ -function CreateSugarOpportunity($sugarSoap, $user, $password, $name,$account_id,$amount, $date_closed, $sales_stage,$resultType="array") { -// * @param string | $account_id | Account Id - $module = "Opportunities"; - - /* $aValue = array( + */ + $sessionId = sugarLogin( $sugarSoap, $user, $password ); + $client = new SoapClient( $sugarSoap, getSoapClientOptions() ); + + $request_array = array ('session' => $sessionId,'module_name' => $module,array (array ("name" => 'first_name',"value" => $first_name + ),array ("name" => 'last_name',"value" => $last_name + ),array ("name" => 'email1',"value" => $email + ),array ("name" => 'title',"value" => $title + ),array ("name" => 'phone_work',"value" => $phone + ), + // array("name" => 'account_id',"value" => '8cd10a60-101f-4363-1e0b-4cfd4106bd7e') + array ("name" => 'account_id',"value" => $account_id + ))); + + $sugarEntriesO = $client->__SoapCall( 'set_entry', $request_array ); + + switch ($resultType) { + case 'array': + $sugarEntries = objectToArray( $sugarEntriesO ); + break; + case 'object': + $sugarEntries = $sugarEntries; + break; + default: + $sugarEntries = objectToArray( $sugarEntries ); + } + return $sugarEntries; +} + +/** + * + * @method Creates SugarCRM entries from the Opportunities module. + * + * @name CreateSugarOpportunity + * + * @label Creates SugarCRM entries from the Opportunities module. + * + * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl + * @param string | $user | User + * @param string | $password | Password + * @param string | $name | Name + * @param string | $account_id | Valid id account + * @param string | $amount | Amount + * @param string | $date_closed | Date Closed + * @param string | $sales_stage | Prospecting, Qualification, Needs Analysis, Value Proposition, Id. Decision Makers, Perception Analysis, Proposal/Price Quote, Negotiation/Review, Closed Won, Closed Lost + * @param string | $resultType=array | Result type (array or object) + * + * @return array/object | $sugarOpportunity | Sugar Opportunities (array or object) + * + */ +function CreateSugarOpportunity ($sugarSoap, $user, $password, $name, $account_id, $amount, $date_closed, $sales_stage, $resultType = "array") +{ + // * @param string | $account_id | Account Id + $module = "Opportunities"; + + /* $aValue = array( array("name" => 'id', "value" => G::generateUniqueID()), array("name" => 'name', "value" => $name), array("name" => 'account_name', "value" => $account_name), array("name" => 'amount', "value" => $amount), array("name" => 'date_closed', "value" => $date_closed), array("name" => 'sales_stage', "value" => $sales_stage) - );*/ - - $sessionId = sugarLogin ( $sugarSoap, $user, $password ); - $client = new SoapClient ( $sugarSoap, getSoapClientOptions() ); - - $request_array = array ('session' => $sessionId, 'module_name' => $module, 'name_value_list' =>array( - array('name' => 'name','value' => $name), - array("name" => 'account_id',"value" => $account_id), - array('name' => 'amount','value' => $amount), - array('name' => 'date_closed','value' => $date_closed), - array('name' => 'sales_stage','value' => $sales_stage), - )); - - $sugarEntriesO = $client->__SoapCall ( 'set_entry', $request_array ); - - switch($resultType){ - case 'array':$sugarEntries = objectToArray ( $sugarEntriesO ); break; - case 'object':$sugarEntries = $sugarEntries; break; - default: $sugarEntries = objectToArray ( $sugarEntries ); - } - return $sugarEntries; -} - - - -/** - * @method - * - * Creates SugarCRM entries from the Account module - * - * @name CreateSugarLeads - * - * @label Creates SugarCRM entries from the Account module - * - * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl - * @param string | $user | User - * @param string | $password | Password - * @param string | $first_name | First Name - * @param string | $last_name | Last Name - * @param string | $email | Email - * @param string | $title | Title - * @param string | $phone | Phone Work - * @param string | $account_id | Valid id account - * @param string | $resultType=array | Result type (array or object) - * - * @return array/object | $sugarContact | Sugar Opportunities (array or object) - * - */ -function CreateSugarLeads($sugarSoap, $user, $password, $first_name, $last_name, $email, $title, $phone, $account_id, $resultType="array") { - - $module = "Leads"; - $sessionId = sugarLogin ( $sugarSoap, $user, $password ); - $client = new SoapClient ( $sugarSoap, getSoapClientOptions() ); - - $request_array = array ('session' => $sessionId, 'module_name' => $module, array( - array("name" => 'first_name',"value" => $first_name), - array("name" => 'last_name',"value" => $last_name), - array("name" => 'email1',"value" => $email), - array("name" => 'title',"value" => $title), - array("name" => 'phone_work',"value" => $phone), - // array("name" => 'account_id',"value" => '8cd10a60-101f-4363-1e0b-4cfd4106bd7e') - array("name" => 'account_id',"value" => $account_id) - )); - - $sugarEntriesO = $client->__SoapCall ( 'set_entry', $request_array ); - - switch($resultType){ - case 'array':$sugarEntries = objectToArray ( $sugarEntriesO ); break; - case 'object':$sugarEntries = $sugarEntries; break; - default: $sugarEntries = objectToArray ( $sugarEntries ); - } - return $sugarEntries; -} \ No newline at end of file + );*/ + + $sessionId = sugarLogin( $sugarSoap, $user, $password ); + $client = new SoapClient( $sugarSoap, getSoapClientOptions() ); + + $request_array = array ('session' => $sessionId,'module_name' => $module,'name_value_list' => array (array ('name' => 'name','value' => $name + ),array ("name" => 'account_id',"value" => $account_id + ),array ('name' => 'amount','value' => $amount + ),array ('name' => 'date_closed','value' => $date_closed + ),array ('name' => 'sales_stage','value' => $sales_stage + ) + ) + ); + + $sugarEntriesO = $client->__SoapCall( 'set_entry', $request_array ); + + switch ($resultType) { + case 'array': + $sugarEntries = objectToArray( $sugarEntriesO ); + break; + case 'object': + $sugarEntries = $sugarEntries; + break; + default: + $sugarEntries = objectToArray( $sugarEntries ); + } + return $sugarEntries; +} + +/** + * + * @method Creates SugarCRM entries from the Account module + * + * @name CreateSugarLeads + * + * @label Creates SugarCRM entries from the Account module + * + * @param string | $sugarSoap | Sugar SOAP URL | http://www.example.com/sugar/soap.php?wsdl + * @param string | $user | User + * @param string | $password | Password + * @param string | $first_name | First Name + * @param string | $last_name | Last Name + * @param string | $email | Email + * @param string | $title | Title + * @param string | $phone | Phone Work + * @param string | $account_id | Valid id account + * @param string | $resultType=array | Result type (array or object) + * + * @return array/object | $sugarContact | Sugar Opportunities (array or object) + * + */ +function CreateSugarLeads ($sugarSoap, $user, $password, $first_name, $last_name, $email, $title, $phone, $account_id, $resultType = "array") +{ + + $module = "Leads"; + $sessionId = sugarLogin( $sugarSoap, $user, $password ); + $client = new SoapClient( $sugarSoap, getSoapClientOptions() ); + + $request_array = array ('session' => $sessionId,'module_name' => $module,array (array ("name" => 'first_name',"value" => $first_name + ),array ("name" => 'last_name',"value" => $last_name + ),array ("name" => 'email1',"value" => $email + ),array ("name" => 'title',"value" => $title + ),array ("name" => 'phone_work',"value" => $phone + ), + // array("name" => 'account_id',"value" => '8cd10a60-101f-4363-1e0b-4cfd4106bd7e') + array ("name" => 'account_id',"value" => $account_id + ) + ) + ); + + $sugarEntriesO = $client->__SoapCall( 'set_entry', $request_array ); + + switch ($resultType) { + case 'array': + $sugarEntries = objectToArray( $sugarEntriesO ); + break; + case 'object': + $sugarEntries = $sugarEntries; + break; + default: + $sugarEntries = objectToArray( $sugarEntries ); + } + return $sugarEntries; +} + From e0a5ab219c57e9df311c6013bbf505a1d6a819b3 Mon Sep 17 00:00:00 2001 From: Fernando Ontiveros Date: Fri, 19 Oct 2012 14:58:02 -0400 Subject: [PATCH 4/4] CODE STYLE removing old install scripts (maborak) --- workflow/engine/methods/install/install.js | 675 ------------------ workflow/engine/methods/install/install.php | 209 ------ .../engine/methods/install/installServer.php | 380 ---------- 3 files changed, 1264 deletions(-) delete mode 100755 workflow/engine/methods/install/install.js delete mode 100755 workflow/engine/methods/install/install.php delete mode 100755 workflow/engine/methods/install/installServer.php diff --git a/workflow/engine/methods/install/install.js b/workflow/engine/methods/install/install.js deleted file mode 100755 index 06bc22167..000000000 --- a/workflow/engine/methods/install/install.js +++ /dev/null @@ -1,675 +0,0 @@ -var installer=function() -{ - this.make=function(options) - { - this.options={ - target:inst.elements.content, - vdef:{ - wf:'wf_workflow', - rb:'rb_workflow', - rp:'rp_workflow' - } - }.concat(options || {}); - this.html(); - this.check(); - }; - this.html=function() - { - this.titleBar = document.createElement("div"); - this.titleBar.className="app_grid_headerBar___gray"; - leimnud.dom.setStyle(this.titleBar,{ - height:"auto", - textAlign:"right" - }); - this.options.target.appendChild(this.titleBar); - - this.options.button0 = document.createElement("input"); - this.options.button0.type="button"; - this.options.button0.value="Test"; - this.titleBar.appendChild(this.options.button0); - - this.options.button1 = document.createElement("input"); - this.options.button1.type="button"; - this.options.button1.value="Install"; - this.titleBar.appendChild(this.options.button1); - - this.options.button2 = document.createElement("input"); - this.options.button2.type="button"; - this.options.button2.value="Reset"; - this.titleBar.appendChild(this.options.button2); - - this.options.phpinfo = document.createElement("input"); - this.options.phpinfo.type="button"; - this.options.phpinfo.style.fontWeight="bold"; - this.options.phpinfo.value="phpinfo()"; - this.titleBar.appendChild(this.options.phpinfo); - this.options.phpinfo.onmouseup=this.showPhpinfo; - - - this.options.button1.disabled=true; - this.options.button0.onmouseup=this.check; - this.options.button1.onmouseup=function(){inst.selectTab(1);}.extend(this); - this.options.button2.onmouseup=this.reset; - - this.buttonFun(this.options.button0); - this.buttonFun(this.options.button1); - this.buttonFun(this.options.button2); - this.buttonFun(this.options.phpinfo); - - - - //this.phpVersion = - this.table = $(document.createElement("table")); -/* this.table.setStyle({ - cellpadding:23 - });*/ - this.table.className="inst_table"; - - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{innerHTML:"Requirements",className:"app_grid_title___gray title",colSpan:4}) - ); - - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{innerHTML:"PHP Version > 5.1.0",className:"inst_td0",colSpan:2}), - this.phpVersion = new DOM('td',{innerHTML:'Loading...',className:"inst_td1",colSpan:2}) - ); - - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{innerHTML:"MySQL",className:"inst_td0",colSpan:2}), - this.mysqlVersion = new DOM('td',{innerHTML:'Loading...',className:"inst_td1",colSpan:2}) - ); - - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{innerHTML:"Maximum amount of memory a script may consume (memory_limit) >= 40M",className:"inst_td0",colSpan:2}), - this.checkMemory = new DOM('td',{innerHTML:'Loading...',className:"inst_td1",colSpan:2}) - ); - - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{innerHTML:"Directory "+this.options.path_trunk+"config/
permissions: writable",className:"inst_td0",colSpan:2}), - this.checkPI = new DOM('td',{innerHTML:'Loading...',className:"inst_td1",colSpan:2}) - ); - - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{innerHTML:"Directory "+this.options.path_trunk+"content/languages/
permissions: writable",className:"inst_td0",colSpan:2}), - this.checkDL = new DOM('td',{innerHTML:'Loading...',className:"inst_td1",colSpan:2}) - ); - - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{innerHTML:"File "+this.options.path_trunk+"js/labels/
permissions: writable",className:"inst_td0",colSpan:2}), - this.checkDLJ = new DOM('td',{innerHTML:'Loading...',className:"inst_td1",colSpan:2}) - ); - - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{innerHTML:"File "+this.options.path_trunk+"plugins/
permissions: writable",className:"inst_td0",colSpan:2}), - this.checkPL = new DOM('td',{innerHTML:'Loading...',className:"inst_td1",colSpan:2}) - ); - - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{innerHTML:"File "+this.options.path_trunk+"xmlform/
permissions: writable",className:"inst_td0",colSpan:2}), - this.checkXF = new DOM('td',{innerHTML:'Loading...',className:"inst_td1",colSpan:2}) - ); - - /* Database */ - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{innerHTML:"Database",className:"app_grid_title___gray title",colSpan:2}), - new DOM('td',{className:"app_grid_title___gray title",colSpan:2}).append( - this.select_ao_db = new select({data:[ - {value:1,text:"Advanced options by default"}, - {value:2,text:"Change Advanced options"} - ], - style:{width:"100%",border:"1px solid #919B9C"}, - properties:{onchange:function(){ - if(this.select_ao_db.selected().value==1) - { - this.ed_advanced_options({ - sta:"disabled", - act:'usr', - def:true - }); - this.ao_db_wf.passed().value=this.options.vdef.wf; - this.ao_db_rb.passed().value=this.options.vdef.rb; - this.ao_db_rp.passed().value=this.options.vdef.rp; - this.ao_db_drop.checked=false; - } - else - { - this.ed_advanced_options({ - act:'usr', - sta:"enabled" - }); - this.ao_db_wf.focus(); - } - }.extend(this)} - }) - ) - ); - - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{innerHTML:"Database server Hostname",className:"inst_td0"},{width:"30%"}), - new DOM('td',{className:"inst_td1"},{width:"30%"}).append( -// this.databaseHostname =new DOM("input",{value:'localhost',type:"text",onkeyup:this.submit,className:"inputNormal"}) - this.databaseHostname = new input({label:'localhost',properties:{onkeyup:this.submit},style:{width:"100%"}}) - ), - new DOM('td',{innerHTML:"Workflow Database:",className:"inst_td0"},{width:"20%"}), - new DOM('td',{className:"inst_td1"},{width:"20%"}).append( - this.ao_db_wf = new input({label:this.options.vdef.wf,properties:{onkeyup:this.submit},style:{width:"100%"},maxlength:16}).passed().disable() - ) - - ); - - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{innerHTML:"Username",className:"inst_td0"},{width:"30%"}), - new DOM('td',{className:"inst_td1"},{width:"30%"}).append( -// this.databaseUsername =new DOM("input",{value:'root',type:"text",onkeyup:this.submit,className:"inputNormal"}) - this.databaseUsername = new input({label:'root',properties:{onkeyup:this.submit},style:{width:"100%"}}) - ), - new DOM('td',{innerHTML:"Rbac Database:",className:"inst_td0"},{width:"20%"}), - new DOM('td',{className:"inst_td1"},{width:"20%"}).append( - this.ao_db_rb = new input({label:this.options.vdef.rb,properties:{onkeyup:this.submit},style:{width:"100%"},maxlength:16}).passed().disable() - ) - - ); - - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{innerHTML:"Password",className:"inst_td0"},{width:"30%"}), - new DOM('td',{className:"inst_td1"},{width:"30%"}).append( -// this.databasePassword =new DOM("input",{type:"text",onkeyup:this.submit,className:"inputNormal"}) - this.databasePassword = new input({properties:{type:'password',onkeyup:this.submit},style:{width:"100%"}}) - ), - new DOM('td',{innerHTML:"Report Database:",className:"inst_td0"},{width:"20%"}), - new DOM('td',{className:"inst_td1"},{width:"20%"}).append( - this.ao_db_rp = new input({label:this.options.vdef.rp,properties:{onkeyup:this.submit},style:{width:"100%"},maxlength:16}).passed().disable() - ) - - ); - - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{innerHTML:"Database Access",className:"inst_td0"},{width:"30%"}), - this.databaseGrant = new DOM('td',{className:"inst_td1"},{width:"30%"}), - - new DOM('td',{innerHTML:"DROP DATABASE IF EXISTS",className:"inst_td0"},{width:"20%"}), - new DOM('td',{className:"inst_td0"},{width:"20%",textAlign:'left'}).append( - this.ao_db_drop = new input({ - properties:{type:'checkbox',disabled:true,className:''},style:{border:"1px solid #666"} - }) - ) - ); - - var tr = this.table.insertRow(-1); - $(tr).append( - this.databaseStatus = new DOM('td',{innerHTML:"
",className:"tdNormal",colSpan:4},{height:50}) - ); - - /* Database End */ - - - - /* Directories Begin */ - - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{innerHTML:"Processmaker Configuration",className:"app_grid_title___gray title",colSpan:2}), - new DOM('td',{className:"app_grid_title___gray title",colSpan:2}).append( - - this.select_ao_pm = new select({data:[ - {value:1,text:"Advanced options by default"}, - {value:2,text:"Change Advanced options"} - ], - style:{width:"100%",border:"1px solid #919B9C"}, - properties:{onchange:function(){ - if(this.select_ao_pm.selected().value==1) - { - this.ed_advanced_options({ - act:'pm', - sta:"disabled", - def:true - }); - this.ao_admin.passed().value="admin"; - this.ao_admin_pass1.passed().value="admin"; - this.ao_admin_pass2.passed().value="admin"; - - } - else - { - this.ed_advanced_options({ - act:'pm', - sta:"enabled" - }); - this.ao_admin.focus(); - } - }.extend(this)} - }) - ) - ); - - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{innerHTML:"Workflow Data Directory (permissions: writable): ",className:"inst_td0"},{width:"30%"}), - new DOM('td',{className:"inst_td1"},{width:"30%"}).append( - this.workflowData = new input({label:this.options.path_data,properties:{onkeyup:this.submit},style:{width:"100%"},maxlength:200}) - ), - new DOM('td',{innerHTML:"Username (Default: admin):",className:"inst_td0"},{width:"20%"}), - new DOM('td',{className:"inst_td1"},{width:"20%"}).append( - this.ao_admin = new input({label:'admin',properties:{onkeyup:this.submit},style:{width:"100%"}}).passed().disable() - ) - - ); - - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{innerHTML:"",className:"inst_td0"},{width:"30%"}), - new DOM('td',{className:"inst_td1"},{width:"30%"}).append( - this.compiled = new input({label:this.options.path_compiled,properties:{onkeyup:this.submit},style:{width:"100%", display:'none'},maxlength:200}) - ), - new DOM('td',{innerHTML:"Username (Default: admin):",className:"inst_td0"},{width:"20%"}), - new DOM('td',{className:"inst_td1"},{width:"20%"}).append( - this.ao_admin_pass1 = new input({label:'admin',properties:{onkeyup:this.submit,type:'password'},style:{width:"100%"}}).passed().disable() - ) - ); - - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{className:"inst_td0",colSpan:2}), - new DOM('td',{innerHTML:"Re-type Password:",className:"inst_td0"},{width:"20%"}), - new DOM('td',{className:"inst_td1"},{width:"20%"}).append( - this.ao_admin_pass2 = new input({label:'admin',properties:{onkeyup:this.submit,type:'password'},style:{width:"100%"}}).passed().disable() - ) - ); - - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{innerHTML:"HeartBeat Configuration
Heartbeat is an anonymous statistics collector for ProcessMaker. It runs in the background and if you have internet enabled, it will periodically send anonymous information to ProcessMaker servers.
No sensitive or private information is collected.

The information collected will allow us to keep improving our software to offer everyone a better user experience
",className:"app_grid_title___gray title",colSpan:4}) - ); - this.heartBeatTitle=tr; - - var tr = this.table.insertRow(-1); - $(tr).append( - - this.heartBeat = - - new DOM('td',{innerHTML:"Enable HeartBeat",className:"inst_td0"},{width:"20%"}), - new DOM('td',{className:"inst_td0",colSpan:2},{textAlign:'left'}).append( - this.ao_hb_status = new input({ - properties:{type:'checkbox',disabled:false,checked:true,className:''},style:{border:"1px solid #666"} - }) - ) - ); - - - this.heartBeatRow=tr; - - - //alert(this.options.availableProcess); - //alert(this.options.availableProcess.length); - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{innerHTML:"Available Processes (auto install)",className:"app_grid_title___gray title",colSpan:4}) - ); - this.availableProcessTitle=tr; - - var tr = this.table.insertRow(-1); - $(tr).append( - this.availableProcess = new DOM('td',{innerHTML:'Loading...',className:"inst_td1",colSpan:2}) - ); - this.availableProcessRow=tr; - - var tr = this.table.insertRow(-1); - $(tr).append( - new DOM('td',{innerHTML:"Available Plugins (auto install)",className:"app_grid_title___gray title",colSpan:4}) - ); - this.availablePluginsTitle=tr; - - var tr = this.table.insertRow(-1); - $(tr).append( - this.availablePlugins = new DOM('td',{innerHTML:'Loading...',className:"inst_td1",colSpan:2}) - ); - this.availablePluginsRow=tr; - - - leimnud.dom.setStyle([this.workflowData,this.compiled],{ - textAlign:"left" - }); - this.options.target.appendChild(this.table); - }; - this.formData=function() - { - //alert(this.databaseExe.value.eplace("\\","/")) - return { - mysqlH :escape(this.databaseHostname.value), - mysqlU :escape(this.databaseUsername.value), - mysqlP :escape(this.databasePassword.value), -// port :this.port.value, - path_data:this.workflowData.value, - path_compiled:this.compiled.value, - ao_admin :escape(this.ao_admin.value), - ao_admin_pass1 :escape(this.ao_admin_pass1.value), - ao_admin_pass2 :escape(this.ao_admin_pass2.value), - ao_db_wf :this.ao_db_wf.value, - ao_db_rb :this.ao_db_rb.value, - ao_db_rp :this.ao_db_rp.value, - ao_db :parseInt(this.select_ao_db.selected().value), - ao_pm :parseInt(this.select_ao_pm.selected().value), - ao_db_drop :this.ao_db_drop.checked, - heartbeatEnabled :this.ao_hb_status.checked - }; - }; - this.check=function() - { - inst.loader.show(); - this.disabled(true); - this.ed_advanced_options({sta:'disabled',act:'all'}); - var r = new leimnud.module.rpc.xmlhttp({ - url :this.options.server, - method :"POST", - args :"action=check&data="+this.formData().toJSONString() - }); - r.callback=function(rpc) - { - try - { - this.cstatus = rpc.xmlhttp.responseText.parseJSON(); - } - catch(e) - { - this.cstatus={ - ao_db_wf:false, - ao_db_rb:false, - ao_db_rp:false - }; - } - this.phpVersion.className = (!this.cstatus.phpVersion)?"inst_td1 tdFailed":"inst_td1 tdOk"; - this.phpVersion.innerHTML = (!this.cstatus.phpVersion)?"FAILED":"PASSED"; - - this.mysqlVersion.className = (!this.cstatus.mysqlVersion)?"inst_td1 tdFailed":"inst_td1 tdOk"; - this.mysqlVersion.innerHTML = (!this.cstatus.mysqlVersion)?"FAILED":"PASSED"; - - this.checkMemory.className = (!this.cstatus.checkMemory)?"inst_td1 tdFailed":"inst_td1 tdOk"; - this.checkMemory.innerHTML = (!this.cstatus.checkMemory)?"FAILED":"PASSED"; - -// this.checkmqgpc.className = (!this.cstatus.checkmqgpc)?"inst_td1 tdFailed":"inst_td1 tdOk"; -// this.checkmqgpc.innerHTML = (!this.cstatus.checkmqgpc)?"FAILED":"PASSED"; - - this.checkPI.className = (!this.cstatus.checkPI)?"inst_td1 tdFailed":"inst_td1 tdOk"; - this.checkPI.innerHTML = (!this.cstatus.checkPI)?"FAILED":"PASSED"; - - this.checkDL.className = (!this.cstatus.checkDL)?"inst_td1 tdFailed":"inst_td1 tdOk"; - this.checkDL.innerHTML = (!this.cstatus.checkDL)?"FAILED":"PASSED"; - - this.checkDLJ.className = (!this.cstatus.checkDLJ)?"inst_td1 tdFailed":"inst_td1 tdOk"; - this.checkDLJ.innerHTML = (!this.cstatus.checkDLJ)?"FAILED":"PASSED"; - - this.checkPL.className = (!this.cstatus.checkPL)?"inst_td1 tdFailed":"inst_td1 tdOk"; - this.checkPL.innerHTML = (!this.cstatus.checkPL)?"FAILED":"PASSED"; - - this.checkXF.className = (!this.cstatus.checkXF)?"inst_td1 tdFailed":"inst_td1 tdOk"; - this.checkXF.innerHTML = (!this.cstatus.checkXF)?"FAILED":"PASSED"; - - this.databaseHostname[(!this.cstatus.mysqlConnection)?"failed":"passed"](); - this.databaseUsername[(!this.cstatus.mysqlConnection)?"failed":"passed"](); - this.databasePassword[(!this.cstatus.mysqlConnection)?"failed":"passed"](); - - this.databaseGrant.className = (!this.cstatus.grantPriv && this.select_ao_db.selected().value==1)?"inst_td1 tdFailed":"inst_td1 tdOk"; - this.databaseGrant.innerHTML = (!this.cstatus.grantPriv)?"FAILED":((this.cstatus.grantPriv==1)?'ALL PRIVILEGES':'USAGE'); - - this.databaseStatus.className = (!this.cstatus.grantPriv || !this.cstatus.mysqlConnection)?"tdFailed":"tdOk"; - this.databaseStatus.innerHTML = this.cstatus.databaseMessage; - - this.workflowData[(!this.cstatus.path_data)?"failed":"passed"](); - this.compiled[(!this.cstatus.path_compiled)?"failed":"passed"](); - - - this.ao_db_wf[((!this.cstatus.ao_db_wf['status'])?"failed":"passed")](); - this.ao_db_rb[((!this.cstatus.ao_db_rb['status'])?"failed":"passed")](); - this.ao_db_rp[((!this.cstatus.ao_db_rp['status'])?"failed":"passed")](); - - this.ao_admin[(!this.cstatus.ao_admin && this.select_ao_pm.selected().value==2)?"failed":"passed"](); - this.ao_admin_pass1[(!this.cstatus.ao_admin_pass && this.select_ao_pm.selected().value==2)?"failed":"passed"](); - this.ao_admin_pass2[(!this.cstatus.ao_admin_pass && this.select_ao_pm.selected().value==2)?"failed":"passed"](); - - if(this.cstatus.ao_db_wf['status'] && this.cstatus.ao_db_rb['status'] && this.cstatus.ao_db_rp['status'] && this.cstatus.ao_admin && this.cstatus.ao_admin_pass && this.cstatus.checkMemory && this.cstatus.checkPI && this.cstatus.checkDL && this.cstatus.checkDLJ && this.cstatus.checkPL && this.cstatus.checkXF && this.cstatus.phpVersion && this.cstatus.mysqlVersion && this.cstatus.mysqlConnection && this.cstatus.grantPriv && this.cstatus.path_data && this.cstatus.path_compiled) - { - this.options.button0.disabled=true; - this.options.button1.disabled=false; - this.disabled(true); - } - else - { - this.options.button0.disabled=false; - this.options.button1.disabled=true; - this.disabled(false); - try { - this.compiled.focus(); - } catch(err) {} - this.ed_advanced_options({sta:((this.select_ao_db.selected().value==2)?'enabled':'disabled'),act:'usr'}); - this.ed_advanced_options({sta:((this.select_ao_pm.selected().value==2)?'enabled':'disabled'),act:'pm'}); - } - this.buttonFun(this.options.button0); - this.buttonFun(this.options.button1); - - this.ao_db_wf.title=this.cstatus.ao_db_wf.message; - this.ao_db_rb.title=this.cstatus.ao_db_rb.message; - this.ao_db_rp.title=this.cstatus.ao_db_rp.message; - - this.ao_admin.title=(this.cstatus.ao_admin)?'Username invalid':'PASSED'; - - - //*Autoinstall Process and Plugins. By JHL - // March 11th. 2009 - // To enable the way of aoutoinstall process and/or plugins - // at same time of initial PM setup - if(this.cstatus.availableProcess.length>0){ - this.availableProcess.className = "inst_td1 tdOk"; - this.availableProcess.innerHTML=""; - for(i_process=0;i_process"; - } - }else{ - //Hide entire Group - this.availableProcessTitle.style.display="none"; - this.availableProcessRow.style.display="none"; - } - - if(this.cstatus.availablePlugins.length>0){ - this.availablePlugins.className = "inst_td1 tdOk"; - this.availablePlugins.innerHTML=""; - for(i_plugin=0;i_plugin"; - } - }else{ - //Hide entire Group - this.availablePluginsTitle.style.display="none"; - this.availablePluginsRow.style.display="none"; - } - //End Autoinstall - - inst.loader.hide(); - }.extend(this); - r.make(); - }; - this.reset=function() - { - this.options.button1.disabled=true; - this.buttonFun(this.options.button1); - this.disabled(false); - }; - this.disabled=function(dis) - { - this.databaseHostname[(dis===true)?'disable':'enable'](); - this.databaseUsername[(dis===true)?'disable':'enable'](); - this.databasePassword[(dis===true)?'disable':'enable'](); - this.workflowData[(dis===true)?'disable':'enable'](); - this.compiled[(dis===true)?'disable':'enable'](); - if(this.compiled.disabled===false) - { - try { - this.compiled.focus(); - } catch(err) {} - } - this.options.button0.disabled=dis; - this.buttonFun(this.options.button0); - }; - this.ed_advanced_options=function(options) - { - options = { - sta:"disabled", - act:"all", - def:false - }.concat(options || {}); - - if(options.act=='pm' || options.act=="all") - { - this.ao_admin[(options.sta=="disabled")?'disable':'enable'](); - this.ao_admin_pass1[(options.sta=="disabled")?'disable':'enable'](); - this.ao_admin_pass2[(options.sta=="disabled")?'disable':'enable'](); - } - if(options.act=='usr' || options.act=="all") - { - this.ao_db_wf[(options.sta=="disabled")?'disable':'enable'](); - this.ao_db_rb[(options.sta=="disabled")?'disable':'enable'](); - this.ao_db_rp[(options.sta=="disabled")?'disable':'enable'](); - this.ao_db_drop.disabled=(options.sta=="disabled")?true:false; - } - }; - this.submit=function(evt) - { - var evt = (window.event)?window.event:evt; - var key = (evt.which)?evt.which:evt.keyCode; - if(key==13) - { - this.check(); - } - return false; - }; - this.install=function() - { - this.values = this.formData(); - inst.clearContent(); - inst.loader.show(); - this.options.button2.disabled=true; - this.options.button1.disabled=true; - var r = new leimnud.module.rpc.xmlhttp({ - url :this.options.server, - method :"POST", - args :"action=install&data="+this.values.toJSONString() - }); - r.callback=this.installation; - r.make(); - }; - this.installation=function(rpc) - { -/* var r = new leimnud.module.rpc.xmlhttp({ - url :"/sysworkflow/en/classic/tools/updateTranslation", - method :"GET" - }); - r.callback=function(rpc) - {*/ - inst.loader.hide(); - this.table = document.createElement("table"); - this.table.className="inst_table"; - - var success = (rpc.xmlhttp.status == 200); - - var tr = this.table.insertRow(-1); - var tdtitle = tr.insertCell(0); - tdtitle.innerHTML="Status"; - tdtitle.className="app_grid_title___gray title"; - - var tr = this.table.insertRow(-1); - var td0 = tr.insertCell(0); - td0.innerHTML=(success) ? "Success" : "Failed (Check log below)"; - td0.className=(success) ? "tdOk" : "tdFailed"; - this.options.target.appendChild(this.table); - - if (success) { - - var tr = this.table.insertRow(-1); - var tdS = tr.insertCell(0); - tdS.colSpan = 2; - tdS.innerHTML="

"; - tdS.className="tdNormal"; - - - this.options.buttong = document.createElement("input"); - this.options.buttong.type="button"; - this.options.buttong.value="Finish Installation"; - this.options.buttong.onmouseup=function() - { - window.location = "/sysworkflow/en/classic/login/login"; - }.extend(this); - tdS.appendChild(this.options.buttong); - this.buttonFun(this.options.buttong); - tdS.appendChild(document.createElement("br")); - tdS.appendChild(document.createElement("br")); - - } - - var tr = this.table.insertRow(-1); - var tdtitle = tr.insertCell(0); - tdtitle.innerHTML="Installation Log"; - tdtitle.className="app_grid_title___gray title"; - - var tr = this.table.insertRow(-1); - var td0 = tr.insertCell(0); - var pre = document.createElement('pre'); - pre.style.overflow='scroll'; - pre.style.width=(this.options.target.clientWidth-10)+"px"; - pre.style.height=((this.options.target.clientHeight-this.table.clientHeight)-15)+'px'; - pre.innerHTML=rpc.xmlhttp.responseText; - td0.appendChild(pre); -// }.extend(this); -// r.make(); - }; - this.buttonFun=function(but) - { - if(but.disabled==true) - { - but.className="app_grid_title___gray button buttonDisabled"; - but.onmouseover=function(){ this.className="app_grid_title___gray button buttonDisabled"}; - but.onmouseout=function(){ this.className="app_grid_title___gray button buttonDisabled"}; - but.onblur=function(){ this.className="app_grid_title___gray button buttonDisabled"}; - } - else - { - but.className="app_grid_title___gray button"; - but.onmouseover=function(){ this.className="app_grid_title___gray button buttonHover"}; - but.onmouseout=function(){ this.className="app_grid_title___gray button"}; - but.onblur=function(){ this.className="app_grid_title___gray button"}; - } - }; - this.showPhpinfo=function() - { - var panel = new leimnud.module.panel(); - panel.options={ - title:"PHP info", - position:{center:true}, - size:{w:700,h:document.body.clientHeight-50}, - fx:{modal:true} - }; - panel.make(); - var r = new leimnud.module.rpc.xmlhttp({ - url :"install.php", - method :"POST", - args :"phpinfo=true" - }); - r.callback=function(rpc) - { - panel.addContent(rpc.xmlhttp.responseText); - }; - r.make(); - }; - this.expand(this); -} diff --git a/workflow/engine/methods/install/install.php b/workflow/engine/methods/install/install.php deleted file mode 100755 index fb06977a8..000000000 --- a/workflow/engine/methods/install/install.php +++ /dev/null @@ -1,209 +0,0 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ - -/** - * Default home page view - * - * @author MaBoRaK - * @version 0.1 - */ -if ($_POST && isset( $_POST['phpinfo'] )) { - phpinfo(); - die(); -} -echo ''; -?> - - - - -Processmaker Installer - - - - - - - - - - - - - diff --git a/workflow/engine/methods/install/installServer.php b/workflow/engine/methods/install/installServer.php deleted file mode 100755 index 9ced71355..000000000 --- a/workflow/engine/methods/install/installServer.php +++ /dev/null @@ -1,380 +0,0 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ - -$isWindows = PHP_OS == 'WINNT' ? true : false; - -$oJSON = new Services_JSON(); -$action = $_POST['action']; -$dataClient = $oJSON->decode( stripslashes( $_POST['data'] ) ); -function find_SQL_Version ($my = 'mysql', $infExe = null) -{ - if (PHP_OS == "WINNT" && ! $infExe) { - return false; - } - $output = shell_exec( $my . ' -V' ); - preg_match( '@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version ); - return $version[0]; -} - -if ($action === "check") { - /* TODO: Check if this space is required */ - print " "; - G::LoadClass( 'Installer' ); - $inst = new Installer(); - $siteName = "workflow"; - $p1 = (isset( $dataClient->ao_admin_pass1 )) ? $dataClient->ao_admin_pass1 : 'admin'; - $p2 = (isset( $dataClient->ao_admin_pass2 )) ? $dataClient->ao_admin_pass2 : 'admin'; - $s = $inst->create_site( Array ('name' => 'workflow','path_data' => $dataClient->path_data,'path_compiled' => $dataClient->path_compiled,'admin' => Array ('username' => (isset( $dataClient->ao_admin )) ? $dataClient->ao_admin : 'admin','password' => $p1 - ),'advanced' => Array ('ao_db' => (isset( $dataClient->ao_db ) && $dataClient->ao_db === 2) ? false : true,'ao_db_drop' => (isset( $dataClient->ao_db_drop ) && $dataClient->ao_db_drop === true) ? true : false,'ao_db_wf' => (isset( $dataClient->ao_db_wf )) ? $dataClient->ao_db_wf : 'wf_' . $siteName,'ao_db_rb' => (isset( $dataClient->ao_db_rb )) ? $dataClient->ao_db_rb : 'rb_' . $siteName,'ao_db_rp' => (isset( $dataClient->ao_db_rp )) ? $dataClient->ao_db_rp : 'rp_' . $siteName - ),'database' => Array ('hostname' => $dataClient->mysqlH,'username' => $dataClient->mysqlU,'password' => $dataClient->mysqlP - ) - ) ); - $data = null; - $data->phpVersion = (version_compare( PHP_VERSION, "5.1.0", ">" )) ? true : false; - if (trim( $dataClient->mysqlH ) == '' || trim( $dataClient->mysqlU ) == '') { - $con = array ('connection' => false,'grant' => false,'message' => 'Please complete the input fields (Hostname/Username)' - ); - } - $data->mysqlConnection = $s['result']['database']['connection']; - $data->grantPriv = $s['result']['database']['grant']; - $data->databaseMessage = $s['result']['database']['message']; - $data->mysqlVersion = $s['result']['database']['version']; - $data->path_data = $s['result']['path_data']; - $data->path_compiled = true; - $data->checkMemory = (((int) ini_get( "memory_limit" )) >= 40) ? true : false; - #$data->checkmqgpc =(get_magic_quotes_gpc())?false:true; - $data->checkPI = $inst->is_dir_writable( PATH_CORE . "config/" ); - $data->checkDL = $inst->is_dir_writable( PATH_CORE . "content/languages/" ); - $data->checkDLJ = $inst->is_dir_writable( PATH_CORE . "js/labels/" ); - $data->checkPL = $inst->is_dir_writable( PATH_CORE . "plugins/" ); - $data->checkXF = $inst->is_dir_writable( PATH_CORE . "xmlform/" ); - $data->ao_db_wf = $s['result']['database']['ao']['ao_db_wf']; - $data->ao_db_rb = $s['result']['database']['ao']['ao_db_rb']; - $data->ao_db_rp = $s['result']['database']['ao']['ao_db_rp']; - - $data->ao_admin = $s['result']['admin']['username']; - $data->ao_admin_pass = ($p1 !== $p2) ? false : true; - - //*Autoinstall Process and Plugins. By JHL - // March 11th. 2009 - // To enable the way of aoutoinstall process and/or plugins - // at same time of initial PM setup - - - //Get Available autoinstall process - $data->availableProcess = $inst->getDirectoryFiles( PATH_OUTTRUNK . "autoinstall", "pm" ); - - //Get Available autoinstall plugins - $data->availablePlugins = $inst->getDirectoryFiles( PATH_OUTTRUNK . "autoinstall", "tar" ); - - //End autoinstall - - - $data->microtime = microtime( true ); - echo $oJSON->encode( $data ); -} elseif ($action === "install") { - /* - * Installation with SIMPLE POST - * - * Data necessary for the POST: - * - * - * action=install - * data= {"mysqlE":"Path/to/mysql.exe", - * "mysqlH":"Mysqlhostname", - * "mysqlU":"mysqlUsername", - * "mysqlP":"mysqlPassword", - * "path_data":"/path/to/workflow_data/", - * "path_compiled":"/path/to/compiled/", - * "heartbeatEnabled":"1"} - * - *-------------------------------------------------------------------------------------------------------------- - * - * Steps to install. - * 1) This data is required: - * $HOSTNAME - * $USERNAME - * $PASSWORD - * $PATH_TO_WORKFLOW_DATA - * $PATH_TO_COMPILED DATA - * 2) create $PATH_TO_WORKFLOW_DATA - * 3) create $PATH_TO_COMPILED_DATA - * 4) Create the site workflow - * - * 4.1 Create user (mysql) wf_workflow , password: sample - * 4.1.1 Create database wf_workflow with user wf_workflow - * 4.1.2 Give all priviledges to database wf_workflow for user wf_workflow - * 4.1.3 Dump file processmaker/workflow/engine/data/mysql/schema.sql - * 4.1.4 Dump file processmaker/workflow/engine/data/mysql/insert.sql - * - * 4.2 Create user (mysql) wf_rbac, password: sample - * 4.2.1 Create database wf_rbac with user wf_rbac - * 4.2.2 Give all priviledges to databse wf_rbac for user wf_rbac - * 4.2.3 Dump file processmaker/rbac/engine/data/mysql/schema.sql - * 4.2.4 Dump file processmaker/rbac/engine/data/mysql/insert.sql - * - * 4.3 Create configuratoin file and directories to site workflow - * - * 4.3.1 Create directories: - * - * $PATH_TO_WORKFLOW_DATA./sites/workflow/ - * $PATH_TO_WORKFLOW_DATA./sites/workflow/cutomFunctions/ - * $PATH_TO_WORKFLOW_DATA./sites/workflow/rtfs/ - * $PATH_TO_WORKFLOW_DATA./sites/workflow/xmlforms/ - * $PATH_TO_WORKFLOW_DATA./sites/workflow/processesImages/ - * $PATH_TO_WORKFLOW_DATA./sites/workflow/files/ - * 4.3.2 Create file. - * - * $PATH_TO_WORKFLOW_DATA./sites/workflow/db.php - * - * with these contents replacing $HOSTNAME. - * - - - * 4.4 Create file workflow/engine/config/paths_installed.php with these contents. - * - * - - * Restarting: - * $PATH_TO_WORKFLOW_DATA - * $PATH_TO_COMPILED DATA - * - * 4.2 Update translation from this url (background) - * - * http://ProcessmakerHostname/sysworkflow/en/classic/tools/updateTranslation - * - * - * - * - *5) Auto install processes and plugins - *5.1 Install processes - *5.2 Install plugins - * */ - - $report = null; - - try { - - require_once 'Log.php'; - - $sp = "/"; - $dir_data = $dataClient->path_data; - - $dir_data = (substr( $dir_data, - 1 ) == $sp) ? $dir_data : $dir_data . "/"; - $dir_compiled = $dir_data . "compiled/"; - $dir_log = "{$dir_data}log/"; - global $isWindows; - - @mkdir( $dir_data . "sites", 0777, true ); - @mkdir( $dir_compiled, 0777, true ); - @mkdir( $dir_log, 0777, true ); - - $logFilename = "{$dir_log}install.log"; - $displayLog = Log::singleton( 'display', '', 'INSTALLER', array ('lineFormat' => "%{message}" - ) ); - $fileLog = Log::singleton( 'file', $logFilename, 'INSTALLER' ); - - global $logger; - $logger = Log::singleton( 'composite' ); - $logger->addChild( $displayLog ); - - $create_db = "create-db.sql"; - $schema = "schema.sql"; - - G::LoadClass( 'Installer' ); - - /* Create default workspace called workflow */ - $inst = new Installer(); - $siteName = "workflow"; - $p1 = (isset( $dataClient->ao_admin_pass1 )) ? $dataClient->ao_admin_pass1 : 'admin'; - $p2 = (isset( $dataClient->ao_admin_pass2 )) ? $dataClient->ao_admin_pass2 : 'admin'; - - $s = $inst->create_site( Array ('name' => 'workflow','path_data' => $dataClient->path_data,'path_compiled' => $dataClient->path_compiled,'admin' => Array ('username' => (isset( $dataClient->ao_admin )) ? $dataClient->ao_admin : 'admin','password' => $p1 - ),'advanced' => Array ('ao_db' => (isset( $dataClient->ao_db ) && $dataClient->ao_db === 2) ? false : true,'ao_db_drop' => (isset( $dataClient->ao_db_drop ) && $dataClient->ao_db_drop === true) ? true : false,'ao_db_wf' => (isset( $dataClient->ao_db_wf )) ? $dataClient->ao_db_wf : 'wf_' . $siteName,'ao_db_rb' => (isset( $dataClient->ao_db_rb )) ? $dataClient->ao_db_rb : 'rb_' . $siteName,'ao_db_rp' => (isset( $dataClient->ao_db_rp )) ? $dataClient->ao_db_rp : 'rp_' . $siteName - ),'database' => Array ('hostname' => $dataClient->mysqlH,'username' => $dataClient->mysqlU,'password' => $dataClient->mysqlP - ) - ), true ); - if ($s['created']) { - $report = $inst->report; - } else { - /* On a failed install, $inst->report is blank because the - * installation didnt occured at all. So we use the test report - * instead. - */ - $report = $s['result']; - } - $installError = (! $s['created']); - } catch (Exception $e) { - $installError = ($e->getMessage() ? $e->getMessage() : true); - } - - if ($installError) { - header( 'HTTP', true, 500 ); - } - - /* Status is used in the Windows installer, do not change this */ - print_r( "Status: " . (($installError) ? 'FAILED' : 'SUCCESS') . "\n\n" ); - - /* Try to open the file log, if it fails, set it to NULL, so we don't try to - * write to it again afterwards. If it succeeds, add to the logger. - * Only open the log after writing status, otherwise a warning can be issued - * which will affect the Windows installer. - */ - if (! $fileLog->open()) { - $fileLog = null; - $displayLog->log( "Failed to create file log in $logFilename" ); - } else { - $logger->addChild( $fileLog ); - $fileLog->log( " ** Starting installation ** " ); - $fileLog->log( "Status: " . (($installError) ? 'FAILED' : 'SUCCESS') ); - $displayLog->log( "This log is also available in $logFilename" ); - } - - $installArgs = (array) $dataClient; - $hiddenFields = array ('mysqlP','ao_admin_pass1','ao_admin_pass2'); - foreach ($installArgs as $arg => $param) { - if (in_array( $arg, $hiddenFields )) { - $installArgs[$arg] = "********"; - } - } - - $logger->log( "Installation arguments\n" . neat_r( array ($installArgs) ) ); - - if (isset( $report )) { - $logger->log( "Installation report\n" . neat_r( array ($report ) ) ); - } else { - $logger->log( "** Installation crashed **" ); - } - - if (is_string( $installError )) { - $logger->log( "Error message: $installError" ); - } - - if ($installError) { - $logger->log( "Installation ending with errors" ); - die(); - } - - $sh = md5( filemtime( PATH_GULLIVER . "/class.g.php" ) ); - $h = G::encrypt( $dataClient->mysqlH . $sh . $dataClient->mysqlU . $sh . $dataClient->mysqlP . $sh . $inst->cc_status, $sh ); - $db_text = ""; - $fp = fopen( FILE_PATHS_INSTALLED, "w" ); - fputs( $fp, $db_text, strlen( $db_text ) ); - fclose( $fp ); - - /* Update languages */ - $update = file_get_contents( "http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . "/sysworkflow/en/classic/tools/updateTranslation" ); - $logger->log( "Update language => " . ((! $update) ? $update : "OK") ); - - /* Heartbeat Enable/Disable */ - if (! isset( $dataClient->heartbeatEnabled )) { - $dataClient->heartbeatEnabled = true; - } - $update = file_get_contents( "http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . "/sysworkflow/en/classic/install/heartbeatStatus?status=" . $dataClient->heartbeatEnabled ); - $logger->log( "Heartbeat Status => " . str_replace( "
", "\n", $update ) ); - - /* Autoinstall Process */ - $update = file_get_contents( "http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . "/sysworkflow/en/classic/install/autoinstallProcesses" ); - if (trim( str_replace( "
", "", $update ) ) == "") { - $update = "Nothing to do."; - } - $logger->log( "Process AutoInstall => " . str_replace( "
", "\n", $update ) ); - - /* Autoinstall Plugins */ - $update = file_get_contents( "http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . "/sysworkflow/en/classic/install/autoinstallPlugins" ); - if (trim( str_replace( "
", "", $update ) ) == "") { - $update = "Nothing to do."; - } - $logger->log( "Plugin AutoInstall => " . str_replace( "
", "\n", $update ) ); - $logger->log( "Installation finished successfuly" ); -} - -/* - neat_r works like print_r but with much less visual clutter. - By Jake Lodwick. Copy freely. -*/ -function neat_r ($arr, $return = false) -{ - $out = array (); - $oldtab = " "; - $newtab = " "; - - $lines = explode( "\n", print_r( $arr, true ) ); - - foreach ($lines as $line) { - - //remove numeric indexes like "[0] =>" unless the value is an array - //if (substr($line, -5) != "Array") { - $line = preg_replace( "/^(\s*)\[[0-9]+\] => /", "$1", $line, 1 ); - //} - - - //garbage symbols - foreach (array ("Array" => "","[" => "","]" => "" - ) as - //" =>" => ":", - $old => $new) { - $out = str_replace( $old, $new, $out ); - } - - //garbage lines - if (in_array( trim( $line ), array ("Array","(",")","" - ) )) { - continue; - } - - //indents - $indent = ""; - $indents = floor( (substr_count( $line, $oldtab ) - 1) / 2 ); - if ($indents > 0) { - for ($i = 0; $i < $indents; $i ++) { - $indent .= $newtab; - } - } - - $out[] = $indent . trim( $line ); - } - - $out = implode( "\n", $out ); - if ($return == true) { - return $out; - } - - return $out; -} -