- There are not way to set the proxy to use - Added settings for the proxy in ProcessMaker
3651 lines
114 KiB
PHP
Executable File
3651 lines
114 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* class.processes.php
|
|
* @package workflow.engine.ProcessMaker
|
|
*
|
|
* ProcessMaker Open Source Edition
|
|
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
* License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* 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;
|
|
}
|
|
|
|
|
|
/*
|
|
* 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;
|
|
}
|
|
}
|
|
}
|
|
|
|
// 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']);
|
|
// 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();
|
|
//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();
|
|
//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 ) {
|
|
$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'] ])){
|
|
/*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);
|
|
}
|
|
} #@!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;
|
|
}
|
|
#@!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();
|
|
//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();
|
|
//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);
|
|
//$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);
|
|
|
|
// 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,"");
|
|
}
|
|
} #@!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);
|
|
}
|
|
} #@!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);
|
|
} #@!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);
|
|
}
|
|
} #@!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);
|
|
|
|
//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 ) {
|
|
//$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);
|
|
//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) );
|
|
$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 ) );
|
|
$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) );
|
|
$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 ) );
|
|
$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 ) );
|
|
$bytesSaved += fwrite( $fp, $fsHtmlContent ); //writing the size of xml file
|
|
$bytesSaved += fwrite( $fp, $htmlContent ); //writing the htmlfile
|
|
}
|
|
}
|
|
/**
|
|
* By <erik@colosa.com>
|
|
* 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;
|
|
//if this process have any mailfile
|
|
if ( is_dir( $MAILS_ROOT_PATH ) ) {
|
|
|
|
//get mail files list from this directory
|
|
$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;
|
|
}
|
|
//$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
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 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
|
|
$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;
|
|
}
|
|
//$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
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
// 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);
|
|
|
|
//$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");
|
|
$fsData = intval( fread ( $fp, 9)); //reading the size of $oData
|
|
$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 ) ) {
|
|
$fsXmlGuid = intval( $sIdentifier ); //reading the size of $filename
|
|
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;
|
|
$XmlContent = fread( $fp, $fsXmlContent ); //reading string $XmlContent
|
|
unset($XmlContent);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
$oData = null;
|
|
}
|
|
fclose ( $fp);
|
|
return $oData;
|
|
}
|
|
|
|
// import process related functions
|
|
|
|
/**
|
|
* function checkExistingGroups
|
|
* @author gustavo cruz gustavo-at-colosa.com
|
|
* @param $sGroupList array of a group list
|
|
* @return $existingGroupList array of existing groups or null
|
|
* @desc checkExistingGroups check if any of the groups listed in the parameter
|
|
* array exist and wich are those, that is the result $sFilteredGroups array.
|
|
*/
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//return $sGroupList;
|
|
if (isset($existingGroupList))
|
|
return $existingGroupList;
|
|
else
|
|
return null;
|
|
|
|
}
|
|
|
|
/**
|
|
* function renameExistingGroups
|
|
* @author gustavo cruz gustavo-at-colosa.com
|
|
* @param $sGroupList array of a group list
|
|
* @return $renamedGroupList array of existing groups
|
|
* @desc 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.
|
|
*/
|
|
|
|
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
|
|
* @author gustavo cruz gustavo-at-colosa.com
|
|
* @param $sGroupList array of a group list
|
|
* @return $mergedGroupList array of existing groups
|
|
* @desc 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.
|
|
*/
|
|
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
|
|
* @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
|
|
* @desc 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.
|
|
*/
|
|
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']){
|
|
// merging the user id to match the merged group
|
|
$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;
|
|
}
|
|
}
|
|
|
|
// end of import process related functions
|
|
|
|
/**
|
|
* disable all previous process with the parent $sProUid
|
|
* @param $sProUid process uid
|
|
* @return void
|
|
*/
|
|
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");
|
|
$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 ) ) {
|
|
$sIdentifier = fread ( $fp, 9); //reading the size of $filename
|
|
if ( is_numeric( $sIdentifier ) ) {
|
|
$fsXmlGuid = intval( $sIdentifier ); //reading the size of $filename
|
|
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'])){
|
|
$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);
|
|
|
|
//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);
|
|
}
|
|
|
|
}
|
|
|
|
#here we verify if is adynaform or a html
|
|
$aAux = explode(' ', $XmlContent);
|
|
$ext = (strpos($aAux[0], '<?xml') !== false ? '.xml' : '.html');
|
|
|
|
$sFileName = $path . $newXmlGuid . $ext;
|
|
$bytesSaved = @file_put_contents ( $sFileName, $XmlContent );
|
|
//if ( $bytesSaved != $fsXmlContent ) throw ( new Exception ('Error writing dynaform file in directory : ' . $path ) );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//now mailTemplates and public files
|
|
$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 ) ) {
|
|
$fsFileName = intval( $sIdentifier ); //reading the size of $filename
|
|
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 ) {
|
|
$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 ) ) {
|
|
$sIdentifier = fread ( $fp, 9); //reading the size of $filename
|
|
if ( is_numeric( $sIdentifier ) ) {
|
|
$fsFileName = intval( $sIdentifier ); //reading the size of $filename
|
|
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 ) {
|
|
$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 {
|
|
//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();
|
|
|
|
//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();
|
|
}
|
|
|
|
//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();
|
|
}
|
|
|
|
//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();
|
|
}
|
|
|
|
//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();
|
|
}
|
|
|
|
//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();
|
|
}
|
|
|
|
//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();
|
|
}
|
|
|
|
//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();
|
|
}
|
|
|
|
//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();
|
|
}
|
|
|
|
//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();
|
|
}
|
|
|
|
//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();
|
|
}
|
|
|
|
//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();
|
|
}
|
|
|
|
//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();
|
|
}
|
|
|
|
//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();
|
|
}
|
|
|
|
//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();
|
|
}
|
|
|
|
//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();
|
|
}
|
|
|
|
//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'] );
|
|
|
|
// (*) Creating process dependencies
|
|
// creating the process category
|
|
$this->createProcessCategoryRow(isset($oData->processCategory) ? $oData->processCategory : null);
|
|
|
|
// create the process
|
|
$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);
|
|
|
|
/*if(!isset($oData->gateways)){
|
|
//Adding gateway information while importing processes from older version
|
|
//Making compatible with old export process
|
|
$oRoutes = $oData->routes;
|
|
for($i=0;$i<count($oRoutes);$i++){
|
|
$routeUID = $aRoutesUID[$i];
|
|
$routeType = $oRoutes[$i]['ROU_TYPE'];
|
|
$sTaskUID = $oRoutes[$i]['TAS_UID'];
|
|
$sNextTask = $oRoutes[$i]['ROU_NEXT_TASK'];
|
|
if($routeType != 'SEQUENTIAL')
|
|
{
|
|
$oProcessMap = new processMap();
|
|
$sGatewayUID = $oProcessMap->saveNewGateway($oData->process['PRO_UID'], $sTaskUID, $sNextTask, $routeType );
|
|
|
|
//Updating Route table (GAT_UID column) after inserting Gateway data into GATEWAY table
|
|
$aData = array('ROU_UID'=>$routeUID,'GAT_UID'=>$sGatewayUID);
|
|
$oRoute = new Route();
|
|
$oRoute->update($aData);
|
|
}
|
|
}
|
|
}
|
|
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());
|
|
|
|
// 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 = '';
|
|
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->message ) );
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
}//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;
|
|
|
|
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;
|
|
}
|
|
|
|
}//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;
|
|
}
|
|
}
|
|
}
|