From 14c64af8c5465405bef67a3d8e083739c59d0564 Mon Sep 17 00:00:00 2001 From: Fernando Ontiveros Date: Mon, 22 Oct 2012 05:57:53 -0400 Subject: [PATCH] CODE STYLE class/model/ files --- .../engine/classes/model/AdditionalTables.php | 44 +- .../classes/model/AdditionalTablesPeer.php | 9 +- .../engine/classes/model/AppCacheView.php | 78 +- .../engine/classes/model/AppCacheViewPeer.php | 9 +- workflow/engine/classes/model/AppDelay.php | 190 +-- .../engine/classes/model/AppDelayPeer.php | 7 +- .../engine/classes/model/AppDelegation.php | 22 +- .../classes/model/AppDelegationPeer.php | 19 +- workflow/engine/classes/model/AppDocument.php | 3 +- .../engine/classes/model/AppDocumentPeer.php | 19 +- workflow/engine/classes/model/AppEvent.php | 11 +- .../engine/classes/model/AppEventPeer.php | 7 +- workflow/engine/classes/model/AppFolder.php | 1072 ++++++------ .../engine/classes/model/AppFolderPeer.php | 7 +- workflow/engine/classes/model/AppHistory.php | 96 +- .../engine/classes/model/AppHistoryPeer.php | 7 +- workflow/engine/classes/model/AppMessage.php | 1 - .../engine/classes/model/AppMessagePeer.php | 19 +- workflow/engine/classes/model/AppNotes.php | 476 +++--- .../engine/classes/model/AppNotesPeer.php | 7 +- workflow/engine/classes/model/AppOwner.php | 19 +- .../engine/classes/model/AppOwnerPeer.php | 19 +- .../engine/classes/model/AppSolrQueue.php | 150 +- .../engine/classes/model/AppSolrQueuePeer.php | 7 +- workflow/engine/classes/model/AppThread.php | 170 +- .../engine/classes/model/AppThreadPeer.php | 19 +- .../engine/classes/model/ApplicationPeer.php | 19 +- .../classes/model/CalendarAssignments.php | 7 +- .../classes/model/CalendarAssignmentsPeer.php | 7 +- .../classes/model/CalendarBusinessHours.php | 162 +- .../model/CalendarBusinessHoursPeer.php | 7 +- .../classes/model/CalendarDefinition.php | 824 +++++---- .../classes/model/CalendarDefinitionPeer.php | 7 +- .../engine/classes/model/CalendarHolidays.php | 169 +- .../classes/model/CalendarHolidaysPeer.php | 7 +- .../engine/classes/model/CaseScheduler.php | 1482 ++++++++--------- .../classes/model/CaseSchedulerPeer.php | 7 +- workflow/engine/classes/model/CaseTracker.php | 4 +- .../classes/model/CaseTrackerObject.php | 7 +- .../classes/model/CaseTrackerObjectPeer.php | 7 +- .../engine/classes/model/CaseTrackerPeer.php | 7 +- .../engine/classes/model/Configuration.php | 178 +- .../classes/model/ConfigurationPeer.php | 19 +- workflow/engine/classes/model/Content.php | 890 +++++----- workflow/engine/classes/model/ContentPeer.php | 19 +- 45 files changed, 3066 insertions(+), 3250 deletions(-) diff --git a/workflow/engine/classes/model/AdditionalTables.php b/workflow/engine/classes/model/AdditionalTables.php index b4682b6fd..417d73ccb 100755 --- a/workflow/engine/classes/model/AdditionalTables.php +++ b/workflow/engine/classes/model/AdditionalTables.php @@ -20,7 +20,6 @@ require_once 'classes/model/om/BaseAdditionalTables.php'; */ class AdditionalTables extends BaseAdditionalTables { - public $fields = array(); public $primaryKeys = array(); @@ -28,7 +27,7 @@ class AdditionalTables extends BaseAdditionalTables * Function load * access public */ - public function load($sUID, $bFields=false) + public function load($sUID, $bFields = false) { $oAdditionalTables = AdditionalTablesPeer::retrieveByPK($sUID); @@ -82,7 +81,7 @@ class AdditionalTables extends BaseAdditionalTables return $this->fields; } - public function getPrimaryKeys($type='complete') + public function getPrimaryKeys($type = 'complete') { $this->primaryKeys = array(); foreach ($this->fields as $field) { @@ -136,7 +135,7 @@ class AdditionalTables extends BaseAdditionalTables /** * Create & Update function */ - public function create($aData, $aFields=array()) + public function create($aData, $aFields = array()) { if (!isset($aData['ADD_TAB_UID']) || (isset($aData['ADD_TAB_UID']) && $aData['ADD_TAB_UID'] == '')) { $aData['ADD_TAB_UID'] = G::generateUniqueID(); @@ -177,7 +176,7 @@ class AdditionalTables extends BaseAdditionalTables } } - public function update($aData, $aFields=array()) + public function update($aData, $aFields = array()) { $oConnection = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME); try { @@ -188,16 +187,6 @@ class AdditionalTables extends BaseAdditionalTables $oConnection->begin(); $iResult = $oAdditionalTables->save(); $oConnection->commit(); - /* * * DEPRECATED - require_once 'classes/model/ShadowTable.php'; - $oShadowTable = new ShadowTable(); - $oShadowTable->create(array('ADD_TAB_UID' => $aData['ADD_TAB_UID'], - 'SHD_ACTION' => 'ALTER', - 'SHD_DETAILS' => serialize($aFields), - 'USR_UID' => (isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : ''), - 'APP_UID' => '', - 'SHD_DATE' => date('Y-m-d H:i:s'))); - return $iResult; */ } else { $sMessage = ''; $aValidationFailures = $oAdditionalTables->getValidationFailures(); @@ -320,7 +309,7 @@ class AdditionalTables extends BaseAdditionalTables } } - public function getAllData($sUID, $start=null, $limit=null, $keyOrderUppercase=true) + public function getAllData($sUID, $start = null, $limit = null, $keyOrderUppercase = true) { $addTab = new AdditionalTables(); $aData = $addTab->load($sUID, true); @@ -429,7 +418,7 @@ class AdditionalTables extends BaseAdditionalTables } } if ($oClass->validate()) { - $iResult = $oClass->save(); + $iResult = $oClass->save(); if ($keysAutoIncrement == 1 && $aFields[$keyUIDAutoIncrement] == '' && isset($_SESSION['APPLICATION']) && $_SESSION['APPLICATION'] != '') { G::LoadClass('case'); $oCaseKeyAuto = new Cases(); @@ -437,7 +426,7 @@ class AdditionalTables extends BaseAdditionalTables $aFields = $oCaseKeyAuto->loadCase($_SESSION['APPLICATION']); $aFields['APP_DATA'][$keyUIDAutoIncrement] = $newId; if (isset($_POST['form'])) { - $_POST['form'][$keyUIDAutoIncrement] = $newId; + $_POST['form'][$keyUIDAutoIncrement] = $newId; } $oCaseKeyAuto->updateCase($_SESSION['APPLICATION'], $aFields); } @@ -568,7 +557,7 @@ class AdditionalTables extends BaseAdditionalTables * @param string $sGrid * @return number */ - public function populateReportTable($tableName, $sConnection='rp', $type='NORMAL', $processUid='', $gridKey='') + public function populateReportTable($tableName, $sConnection = 'rp', $type = 'NORMAL', $processUid = '', $gridKey = '') { require_once "classes/model/Application.php"; @@ -727,7 +716,7 @@ class AdditionalTables extends BaseAdditionalTables } } - public function getTableVars($uid, $bWhitType=false) + public function getTableVars($uid, $bWhitType = false) { require_once 'classes/model/Fields.php'; try { @@ -761,7 +750,7 @@ class AdditionalTables extends BaseAdditionalTables } } - public function getAll($start=0, $limit=20, $filter='', $process=null) + public function getAll($start = 0, $limit = 20, $filter = '', $process = null) { $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(AdditionalTablesPeer::ADD_TAB_UID); @@ -839,14 +828,6 @@ class AdditionalTables extends BaseAdditionalTables } } - // // fltering by proces title - // if(isset($filter['process'])) { - // foreach ($addTables as $i => $addTable) { - // if (strpos($addTable['PRO_TITLE'], $filter['process']) === false) - // unset($addTables[$i]); - // } - // } - return array('rows' => $addTables, 'count' => $count); } @@ -856,7 +837,7 @@ class AdditionalTables extends BaseAdditionalTables * Don't use this method, it was left only for backward compatibility * for some external plugins that still is using it */ - public function createPropelClasses($sTableName, $sClassName, $aFields, $sAddTabUid, $connection='workflow') + public function createPropelClasses($sTableName, $sClassName, $aFields, $sAddTabUid, $connection = 'workflow') { try { /* $aUID = array('FLD_NAME' => 'PM_UNIQUE_ID', @@ -1257,5 +1238,4 @@ class AdditionalTables extends BaseAdditionalTables } } } -// AdditionalTables - \ No newline at end of file + diff --git a/workflow/engine/classes/model/AdditionalTablesPeer.php b/workflow/engine/classes/model/AdditionalTablesPeer.php index 84b335e90..11e9ddeff 100755 --- a/workflow/engine/classes/model/AdditionalTablesPeer.php +++ b/workflow/engine/classes/model/AdditionalTablesPeer.php @@ -14,14 +14,15 @@ /** * Skeleton subclass for performing query and update operations on the 'ADDITIONAL_TABLES' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as * long as it does not already exist in the output directory. - * + * * @package workflow.engine.classes.model */ -class AdditionalTablesPeer extends BaseAdditionalTablesPeer { +class AdditionalTablesPeer extends BaseAdditionalTablesPeer +{ +} -} // AdditionalTablesPeer diff --git a/workflow/engine/classes/model/AppCacheView.php b/workflow/engine/classes/model/AppCacheView.php index ea6795387..21287c419 100755 --- a/workflow/engine/classes/model/AppCacheView.php +++ b/workflow/engine/classes/model/AppCacheView.php @@ -34,7 +34,7 @@ class AppCacheView extends BaseAppCacheView public $confCasesList; public $pathToAppCacheFiles; - public function getAllCounters($aTypes, $userUid, $processSummary=false) + public function getAllCounters($aTypes, $userUid, $processSummary = false) { $aResult = array(); @@ -248,7 +248,7 @@ class AppCacheView extends BaseAppCacheView * @param string $sUIDUser * @return $rows */ - public function getSelfServiceTasks($userUid='') + public function getSelfServiceTasks($userUid = '') { $rows[] = array(); $tasks = array(); @@ -304,7 +304,8 @@ class AppCacheView extends BaseAppCacheView return $tasks; } - public function getSelfServiceCasesByEvaluate($userUid) { + public function getSelfServiceCasesByEvaluate($userUid) + { $cases = array(); //check groups assigned to SelfService task @@ -327,34 +328,34 @@ class AppCacheView extends BaseAppCacheView $rs->next(); if ($rs->getRecordCount() > 0) { - if (!class_exists('Cases')) { - G::loadClass('case'); - } - $caseInstance = new Cases(); - while ($row = $rs->getRow()) { - $tasGroupVariable = str_replace(array('@', '#'), '', $row['TAS_GROUP_VARIABLE']); - $c2 = new Criteria(); - $c2->clearSelectColumns(); - $c2->addSelectColumn(AppDelegationPeer::APP_UID); - $c2->add(AppDelegationPeer::TAS_UID, $row['TAS_UID']); - $c2->add(AppDelegationPeer::USR_UID, ''); - $c2->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN'); - $rs2 = AppDelegationPeer::doSelectRS($c2); - $rs2->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $rs2->next(); - while ($row2 = $rs2->getRow()) { - $caseData = $caseInstance->LoadCase($row2['APP_UID']); - if (isset($caseData['APP_DATA'][$tasGroupVariable])) { - if (trim($caseData['APP_DATA'][$tasGroupVariable]) != '') { - if (in_array(trim($caseData['APP_DATA'][$tasGroupVariable]), $aGroups)) { - $cases[] = $row2['APP_UID']; - } + if (!class_exists('Cases')) { + G::loadClass('case'); + } + $caseInstance = new Cases(); + while ($row = $rs->getRow()) { + $tasGroupVariable = str_replace(array('@', '#'), '', $row['TAS_GROUP_VARIABLE']); + $c2 = new Criteria(); + $c2->clearSelectColumns(); + $c2->addSelectColumn(AppDelegationPeer::APP_UID); + $c2->add(AppDelegationPeer::TAS_UID, $row['TAS_UID']); + $c2->add(AppDelegationPeer::USR_UID, ''); + $c2->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN'); + $rs2 = AppDelegationPeer::doSelectRS($c2); + $rs2->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $rs2->next(); + while ($row2 = $rs2->getRow()) { + $caseData = $caseInstance->LoadCase($row2['APP_UID']); + if (isset($caseData['APP_DATA'][$tasGroupVariable])) { + if (trim($caseData['APP_DATA'][$tasGroupVariable]) != '') { + if (in_array(trim($caseData['APP_DATA'][$tasGroupVariable]), $aGroups)) { + $cases[] = $row2['APP_UID']; + } + } } - } - $rs2->next(); - } - $rs->next(); - } + $rs2->next(); + } + $rs->next(); + } } return $cases; } @@ -853,7 +854,7 @@ class AppCacheView extends BaseAppCacheView * @param Boolean $doCount * @return Criteria */ - public function getGeneralCases($doCount='false') + public function getGeneralCases($doCount = 'false') { if ($doCount && !isset($this->confCasesList['PMTable']) && !empty($this->confCasesList['PMTable'])) { $oCriteria = new Criteria('workflow'); @@ -1021,7 +1022,7 @@ class AppCacheView extends BaseAppCacheView return $row[0]; } - public function checkGrantsForUser($root=false) + public function checkGrantsForUser($root = false) { try { if ($root) { @@ -1144,7 +1145,7 @@ class AppCacheView extends BaseAppCacheView * Insert an app delegatiojn trigger * @return void */ - public function triggerAppDelegationInsert($lang, $recreate=false) + public function triggerAppDelegationInsert($lang, $recreate = false) { $con = Propel::getConnection("workflow"); $stmt = $con->createStatement(); @@ -1191,7 +1192,7 @@ class AppCacheView extends BaseAppCacheView * update the App Delegation triggers * @return void */ - public function triggerAppDelegationUpdate($lang, $recreate=false) + public function triggerAppDelegationUpdate($lang, $recreate = false) { $con = Propel::getConnection("workflow"); $stmt = $con->createStatement(); @@ -1238,7 +1239,7 @@ class AppCacheView extends BaseAppCacheView * update the Application triggers * @return void */ - public function triggerApplicationUpdate($lang, $recreate=false) + public function triggerApplicationUpdate($lang, $recreate = false) { $con = Propel::getConnection("workflow"); $stmt = $con->createStatement(); @@ -1283,7 +1284,7 @@ class AppCacheView extends BaseAppCacheView * update the Application triggers * @return void */ - public function triggerApplicationDelete($lang, $recreate=false) + public function triggerApplicationDelete($lang, $recreate = false) { $con = Propel::getConnection("workflow"); $stmt = $con->createStatement(); @@ -1324,7 +1325,7 @@ class AppCacheView extends BaseAppCacheView return 'exists'; } - public function triggerContentUpdate($lang, $recreate=false) + public function triggerContentUpdate($lang, $recreate = false) { $cnn = Propel::getConnection("workflow"); $stmt = $cnn->createStatement(); @@ -1456,7 +1457,7 @@ class AppCacheView extends BaseAppCacheView return $aRows; } - public function appTitleByTaskCaseLabelUpdate($taskUid, $lang, $cron=0) + public function appTitleByTaskCaseLabelUpdate($taskUid, $lang, $cron = 0) { $taskDefTitle = null; @@ -1537,5 +1538,4 @@ class AppCacheView extends BaseAppCacheView } } } -//AppCacheView diff --git a/workflow/engine/classes/model/AppCacheViewPeer.php b/workflow/engine/classes/model/AppCacheViewPeer.php index d67856e8a..e503051c3 100755 --- a/workflow/engine/classes/model/AppCacheViewPeer.php +++ b/workflow/engine/classes/model/AppCacheViewPeer.php @@ -14,14 +14,15 @@ /** * Skeleton subclass for performing query and update operations on the 'APP_CACHE_VIEW' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as * long as it does not already exist in the output directory. - * + * * @package workflow.engine.classes.model */ -class AppCacheViewPeer extends BaseAppCacheViewPeer { +class AppCacheViewPeer extends BaseAppCacheViewPeer +{ +} -} // AppCacheViewPeer diff --git a/workflow/engine/classes/model/AppDelay.php b/workflow/engine/classes/model/AppDelay.php index 4f0feaf5c..4d4d27806 100755 --- a/workflow/engine/classes/model/AppDelay.php +++ b/workflow/engine/classes/model/AppDelay.php @@ -18,105 +18,105 @@ require_once 'classes/model/om/BaseAppDelay.php'; * /** * @package workflow.engine.classes.model */ -class AppDelay extends BaseAppDelay { - /** - * Create the application delay registry - * @param array $aData - * @return string - **/ - public function create($aData) - { - $oConnection = Propel::getConnection(AppDelayPeer::DATABASE_NAME); - try { - if ( isset ( $aData['APP_DELAY_UID'] ) && $aData['APP_DELAY_UID']== '' ) - unset ( $aData['APP_DELAY_UID'] ); - if ( !isset ( $aData['APP_DELAY_UID'] ) ) - $aData['APP_DELAY_UID'] = G::generateUniqueID(); - $oAppDelay = new AppDelay(); - $oAppDelay->fromArray($aData, BasePeer::TYPE_FIELDNAME); - if ($oAppDelay->validate()) { - $oConnection->begin(); - $iResult = $oAppDelay->save(); - $oConnection->commit(); - return $aData['APP_DELAY_UID']; - } - else { - $sMessage = ''; - $aValidationFailures = $oAppDelay->getValidationFailures(); - foreach($aValidationFailures as $oValidationFailure) { - $sMessage .= $oValidationFailure->getMessage() . '
'; +class AppDelay extends BaseAppDelay +{ + /** + * Create the application delay registry + * @param array $aData + * @return string + **/ + public function create($aData) + { + $oConnection = Propel::getConnection(AppDelayPeer::DATABASE_NAME); + try { + if ( isset ( $aData['APP_DELAY_UID'] ) && $aData['APP_DELAY_UID']== '' ) { + unset ( $aData['APP_DELAY_UID'] ); + } + if ( !isset ( $aData['APP_DELAY_UID'] ) ) { + $aData['APP_DELAY_UID'] = G::generateUniqueID(); + } + $oAppDelay = new AppDelay(); + $oAppDelay->fromArray($aData, BasePeer::TYPE_FIELDNAME); + if ($oAppDelay->validate()) { + $oConnection->begin(); + $iResult = $oAppDelay->save(); + $oConnection->commit(); + return $aData['APP_DELAY_UID']; + } else { + $sMessage = ''; + $aValidationFailures = $oAppDelay->getValidationFailures(); + foreach ($aValidationFailures as $oValidationFailure) { + $sMessage .= $oValidationFailure->getMessage() . '
'; + } + throw(new Exception('The registry cannot be created!
'.$sMessage)); + } + } catch (Exception $oError) { + $oConnection->rollback(); + throw($oError); } - throw(new Exception('The registry cannot be created!
'.$sMessage)); - } } - catch (Exception $oError) { - $oConnection->rollback(); - throw($oError); - } - } - /** - * Update the application delay registry - * @param array $aData - * @return string - **/ - public function update($aData) - { - $oConnection = Propel::getConnection(AppDelayPeer::DATABASE_NAME); - try { - $oAppDelay = AppDelayPeer::retrieveByPK($aData['APP_DELAY_UID']); - if (!is_null($oAppDelay)) - { - $oAppDelay->fromArray($aData, BasePeer::TYPE_FIELDNAME); - if ($oAppDelay->validate()) { - $oConnection->begin(); - $iResult = $oAppDelay->save(); - $oConnection->commit(); - return $iResult; + /** + * Update the application delay registry + * @param array $aData + * @return string + **/ + public function update($aData) + { + $oConnection = Propel::getConnection(AppDelayPeer::DATABASE_NAME); + try { + $oAppDelay = AppDelayPeer::retrieveByPK($aData['APP_DELAY_UID']); + if (!is_null($oAppDelay)) { + $oAppDelay->fromArray($aData, BasePeer::TYPE_FIELDNAME); + if ($oAppDelay->validate()) { + $oConnection->begin(); + $iResult = $oAppDelay->save(); + $oConnection->commit(); + return $iResult; + } else { + $sMessage = ''; + $aValidationFailures = $oAppDelay->getValidationFailures(); + foreach ($aValidationFailures as $oValidationFailure) { + $sMessage .= $oValidationFailure->getMessage() . '
'; + } + throw(new Exception('The registry cannot be updated!
'.$sMessage)); + } + } else { + throw(new Exception('This row doesn\'t exist!')); + } + } catch (Exception $oError) { + $oConnection->rollback(); + throw($oError); } - else { - $sMessage = ''; - $aValidationFailures = $oAppDelay->getValidationFailures(); - foreach($aValidationFailures as $oValidationFailure) { - $sMessage .= $oValidationFailure->getMessage() . '
'; - } - throw(new Exception('The registry cannot be updated!
'.$sMessage)); + } + + public function isPaused($appUid, $delIndex) + { + $oCriteria = new Criteria('workflow'); + $oCriteria->add(AppDelayPeer::APP_UID, $appUid); + $oCriteria->add(AppDelayPeer::APP_DEL_INDEX, $delIndex); + $oCriteria->add(AppDelayPeer::APP_TYPE, 'PAUSE'); + $oCriteria->add(AppDelayPeer::APP_DISABLE_ACTION_USER, null); + $oCriteria->add( + $oCriteria->getNewCriterion( + AppDelayPeer::APP_DISABLE_ACTION_USER, + null, + Criteria::ISNULL + )->addOr( + $oCriteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0) + ) + ); + $oDataset = AppDelayPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $oDataset->next(); + $aRow = $oDataset->getRow(); + + if ( $aRow ) { + return true; + } else { + return false; } - } - else { - throw(new Exception('This row doesn\'t exist!')); - } - } - catch (Exception $oError) { - $oConnection->rollback(); - throw($oError); - } - } - function isPaused($appUid, $delIndex){ - $oCriteria = new Criteria('workflow'); - $oCriteria->add(AppDelayPeer::APP_UID, $appUid); - $oCriteria->add(AppDelayPeer::APP_DEL_INDEX, $delIndex); - $oCriteria->add(AppDelayPeer::APP_TYPE, 'PAUSE'); - $oCriteria->add(AppDelayPeer::APP_DISABLE_ACTION_USER, null); - $oCriteria->add( - $oCriteria->getNewCriterion( - AppDelayPeer::APP_DISABLE_ACTION_USER, - null, - Criteria::ISNULL - )->addOr( - $oCriteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0) - ) - ); - $oDataset = AppDelayPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - $aRow = $oDataset->getRow(); + } +} - if( $aRow ) - return true; - else - return false; - - } -} // AppDelay \ No newline at end of file diff --git a/workflow/engine/classes/model/AppDelayPeer.php b/workflow/engine/classes/model/AppDelayPeer.php index 85e8cb126..947700a7f 100755 --- a/workflow/engine/classes/model/AppDelayPeer.php +++ b/workflow/engine/classes/model/AppDelayPeer.php @@ -14,7 +14,7 @@ /** * Skeleton subclass for performing query and update operations on the 'APP_DELAY' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -22,6 +22,7 @@ * * @package workflow.engine.classes.model */ -class AppDelayPeer extends BaseAppDelayPeer { +class AppDelayPeer extends BaseAppDelayPeer +{ +} -} // AppDelayPeer diff --git a/workflow/engine/classes/model/AppDelegation.php b/workflow/engine/classes/model/AppDelegation.php index 3f1c85164..6d83ba57e 100755 --- a/workflow/engine/classes/model/AppDelegation.php +++ b/workflow/engine/classes/model/AppDelegation.php @@ -56,9 +56,8 @@ class AppDelegation extends BaseAppDelegation * @param $isSubprocess is a subprocess inside a process? * @return delegation index of the application delegation. */ - function createAppDelegation ($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sAppThread, $iPriority = 3, $isSubprocess = false, $sPrevious = -1, $sNextTasParam = null) + public function createAppDelegation ($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sAppThread, $iPriority = 3, $isSubprocess = false, $sPrevious = -1, $sNextTasParam = null) { - if (! isset( $sProUid ) || strlen( $sProUid ) == 0) { throw (new Exception( 'Column "PRO_UID" cannot be null.' )); } @@ -159,7 +158,7 @@ class AppDelegation extends BaseAppDelegation * @return array $Fields the fields */ - function Load ($AppUid, $sDelIndex) + public function Load ($AppUid, $sDelIndex) { $con = Propel::getConnection( AppDelegationPeer::DATABASE_NAME ); try { @@ -213,7 +212,7 @@ class AppDelegation extends BaseAppDelegation } } - function remove ($sApplicationUID, $iDelegationIndex) + public function remove ($sApplicationUID, $iDelegationIndex) { $oConnection = Propel::getConnection( StepTriggerPeer::DATABASE_NAME ); try { @@ -232,7 +231,7 @@ class AppDelegation extends BaseAppDelegation // TasTypeDay = 1 => working days // TasTypeDay = 2 => calendar days - function calculateDueDate ($sNextTasParam) + public function calculateDueDate ($sNextTasParam) { //Get Task properties $task = TaskPeer::retrieveByPK( $this->getTasUid() ); @@ -272,7 +271,7 @@ class AppDelegation extends BaseAppDelegation return $iDueDate; } - function getDiffDate ($date1, $date2) + public function getDiffDate ($date1, $date2) { return ($date1 - $date2) / (24 * 60 * 60); //days return ($date1 - $date2) / 3600; @@ -445,23 +444,15 @@ class AppDelegation extends BaseAppDelegation //and finally save the record $RES = $oAppDel->save(); - //print "$iDelegateDate $iInitDate $iDueDate $iFinishDate $isStarted $isFinished $isDelayed$queueDuration $delDuration " . - // "$delayDuration$overduePercentage" . $row['DEL_INDEX'] . " $RES "; - - - //UPDATE APP_DELEGATION SET DEL_DELAYED = 0 - //where - // APP_OVERDUE_PERCENTAGE < 0 $rs->next(); $row = $rs->getRow(); - } } catch (Exception $oError) { error_log( $oError->getMessage() ); } } - function getLastDeleration ($APP_UID) + public function getLastDeleration ($APP_UID) { $c = new Criteria( 'workflow' ); $c->addSelectColumn( AppDelegationPeer::APP_UID ); @@ -486,5 +477,4 @@ class AppDelegation extends BaseAppDelegation return $rs->getRow(); } } -// AppDelegation diff --git a/workflow/engine/classes/model/AppDelegationPeer.php b/workflow/engine/classes/model/AppDelegationPeer.php index b5275fde3..fdce86b80 100755 --- a/workflow/engine/classes/model/AppDelegationPeer.php +++ b/workflow/engine/classes/model/AppDelegationPeer.php @@ -2,10 +2,10 @@ /** * AppDelegationPeer.php * @package workflow.engine.classes.model - * + * * ProcessMaker Open Source Edition * Copyright (C) 2004 - 2011 Colosa Inc. - * + * * 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 @@ -15,13 +15,13 @@ * 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 . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * + * */ // include base peer class @@ -34,7 +34,7 @@ /** * Skeleton subclass for performing query and update operations on the 'APP_DELEGATION' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -42,6 +42,7 @@ * /** * @package workflow.engine.classes.model */ -class AppDelegationPeer extends BaseAppDelegationPeer { +class AppDelegationPeer extends BaseAppDelegationPeer +{ +} -} // AppDelegationPeer diff --git a/workflow/engine/classes/model/AppDocument.php b/workflow/engine/classes/model/AppDocument.php index 1f171ead2..7e4f493b2 100755 --- a/workflow/engine/classes/model/AppDocument.php +++ b/workflow/engine/classes/model/AppDocument.php @@ -578,7 +578,7 @@ class AppDocument extends BaseAppDocument return $res; } - function getObject ($APP_UID, $DEL_INDEX, $STEP_UID_OBJ, $APP_DOC_TYPE) + public function getObject ($APP_UID, $DEL_INDEX, $STEP_UID_OBJ, $APP_DOC_TYPE) { $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( AppDocumentPeer::APP_UID, $APP_UID ); @@ -617,5 +617,4 @@ class AppDocument extends BaseAppDocument return $documents; } } -// AppDocument diff --git a/workflow/engine/classes/model/AppDocumentPeer.php b/workflow/engine/classes/model/AppDocumentPeer.php index d199dc61b..e5b329b35 100755 --- a/workflow/engine/classes/model/AppDocumentPeer.php +++ b/workflow/engine/classes/model/AppDocumentPeer.php @@ -2,10 +2,10 @@ /** * AppDocumentPeer.php * @package workflow.engine.classes.model - * + * * ProcessMaker Open Source Edition * Copyright (C) 2004 - 2011 Colosa Inc. - * + * * 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 @@ -15,13 +15,13 @@ * 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 . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * + * */ // include base peer class @@ -34,7 +34,7 @@ /** * Skeleton subclass for performing query and update operations on the 'APP_DOCUMENT' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -42,6 +42,7 @@ * * @package workflow.engine.classes.model */ -class AppDocumentPeer extends BaseAppDocumentPeer { +class AppDocumentPeer extends BaseAppDocumentPeer +{ +} -} // AppDocumentPeer diff --git a/workflow/engine/classes/model/AppEvent.php b/workflow/engine/classes/model/AppEvent.php index 54a10b25e..28dd25975 100755 --- a/workflow/engine/classes/model/AppEvent.php +++ b/workflow/engine/classes/model/AppEvent.php @@ -37,7 +37,7 @@ class AppEvent extends BaseAppEvent } } - function create ($aData) + public function create ($aData) { $oConnection = Propel::getConnection( AppEventPeer::DATABASE_NAME ); try { @@ -62,7 +62,7 @@ class AppEvent extends BaseAppEvent } } - function update ($aData) + public function update ($aData) { $oConnection = Propel::getConnection( AppEventPeer::DATABASE_NAME ); try { @@ -91,7 +91,7 @@ class AppEvent extends BaseAppEvent } } - function remove ($sApplicationUID, $iDelegation, $sEvnUid) + public function remove ($sApplicationUID, $iDelegation, $sEvnUid) { $oConnection = Propel::getConnection( AppEventPeer::DATABASE_NAME ); try { @@ -110,7 +110,7 @@ class AppEvent extends BaseAppEvent } } - function getAppEventsCriteria ($sProcessUid = '', $sStatus = '', $EVN_ACTION = '') + public function getAppEventsCriteria ($sProcessUid = '', $sStatus = '', $EVN_ACTION = '') { try { require_once 'classes/model/Event.php'; @@ -347,12 +347,11 @@ class AppEvent extends BaseAppEvent } } - function close ($APP_UID, $DEL_INDEX) + public function close ($APP_UID, $DEL_INDEX) { $aRow = $this->load( $APP_UID, $DEL_INDEX ); $aRow['APP_EVN_STATUS'] = 'CLOSE'; $this->update( $aRow ); } } -// AppEvent diff --git a/workflow/engine/classes/model/AppEventPeer.php b/workflow/engine/classes/model/AppEventPeer.php index 0ade8e736..e9dd7dbb7 100755 --- a/workflow/engine/classes/model/AppEventPeer.php +++ b/workflow/engine/classes/model/AppEventPeer.php @@ -14,7 +14,7 @@ /** * Skeleton subclass for performing query and update operations on the 'APP_EVENT' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -22,6 +22,7 @@ * * @package workflow.engine.classes.model */ -class AppEventPeer extends BaseAppEventPeer { +class AppEventPeer extends BaseAppEventPeer +{ +} -} // AppEventPeer diff --git a/workflow/engine/classes/model/AppFolder.php b/workflow/engine/classes/model/AppFolder.php index 11299b741..04e814eb7 100755 --- a/workflow/engine/classes/model/AppFolder.php +++ b/workflow/engine/classes/model/AppFolder.php @@ -1,557 +1,553 @@ -|number - */ - function createFolder ($folderName, $folderParent = "/", $action = "createifnotexists") - { - $validActions = array ("createifnotexists","create","update" - ); - if (! in_array( $action, $validActions )) { - $action = "createifnotexists"; - } - +|number + */ + public function createFolder ($folderName, $folderParent = "/", $action = "createifnotexists") + { + $validActions = array ("createifnotexists","create","update"); + if (! in_array( $action, $validActions )) { + $action = "createifnotexists"; + } + //Clean Folder and Parent names (delete spaces...) - $folderName = trim( $folderName ); - $folderParent = trim( $folderParent ); + $folderName = trim( $folderName ); + $folderParent = trim( $folderParent ); //Try to Load the folder (Foldername+FolderParent) - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( AppFolderPeer::FOLDER_NAME, $folderName ); - $oCriteria->add( AppFolderPeer::FOLDER_PARENT_UID, $folderParent ); - $oDataset = AppFolderPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - if ($aRow = $oDataset->getRow()) { + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( AppFolderPeer::FOLDER_NAME, $folderName ); + $oCriteria->add( AppFolderPeer::FOLDER_PARENT_UID, $folderParent ); + $oDataset = AppFolderPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + if ($aRow = $oDataset->getRow()) { //Folder exist, then return the ID - $response['success'] = false; - $response['message'] = $response['error'] = "Can't create folder
A folder with same name already exist.
$folderName"; - $response['folderUID'] = $aRow['FOLDER_UID']; + $response['success'] = false; + $response['message'] = $response['error'] = "Can't create folder
A folder with same name already exist.
$folderName"; + $response['folderUID'] = $aRow['FOLDER_UID']; //return ($aRow ['FOLDER_UID']); - return ($response); - } else { + return ($response); + } else { //Folder doesn't exist. Create and return the ID - $folderUID = G::GenerateUniqueID(); - $tr = new AppFolder(); - $tr->setFolderUid( $folderUID ); - $tr->setFolderParentUid( $folderParent ); - $tr->setFolderName( $folderName ); - $tr->setFolderCreateDate( 'now' ); - $tr->setFolderUpdateDate( 'now' ); - if ($tr->validate()) { + $folderUID = G::GenerateUniqueID(); + $tr = new AppFolder(); + $tr->setFolderUid( $folderUID ); + $tr->setFolderParentUid( $folderParent ); + $tr->setFolderName( $folderName ); + $tr->setFolderCreateDate( 'now' ); + $tr->setFolderUpdateDate( 'now' ); + if ($tr->validate()) { // we save it, since we get no validation errors, or do whatever else you like. - $res = $tr->save(); - $response['success'] = true; - $response['message'] = "Folder successfully created.
$folderName"; - $response['folderUID'] = $folderUID; - return ($response); + $res = $tr->save(); + $response['success'] = true; + $response['message'] = "Folder successfully created.
$folderName"; + $response['folderUID'] = $folderUID; + return ($response); //return $folderUID; - } else { + } else { // Something went wrong. We can now get the validationFailures and handle them. - $msg = ''; - $validationFailuresArray = $tr->getValidationFailures(); - foreach ($validationFailuresArray as $objValidationFailure) { - $msg .= $objValidationFailure->getMessage() . "
"; - } - $response['success'] = false; - $response['message'] = $response['error'] = "Can't create folder \n A \n " . $msg; - return ($response); - } - } - } - - /** - * - * @param string $folderPath - * @param strin(32) $sessionID - * @return string Last Folder ID generated - */ - function createFromPath ($folderPath, $sessionID = "") - { - if ($sessionID == "") { - $sessionID = $_SESSION['APPLICATION']; - //Get current Application Fields - } - - $oApplication = new Application(); - $appFields = $oApplication->Load( $sessionID ); - $folderPathParsed = G::replaceDataField( $folderPath, $appFields ); - $folderPathParsed = G::replaceDataField( $folderPath, unserialize( $appFields['APP_DATA'] ) ); - $folderPathParsedArray = explode( "/", $folderPathParsed ); - $folderRoot = "/"; //Always starting from Root - foreach ($folderPathParsedArray as $folderName) { - if (trim( $folderName ) != "") { - $response = $this->createFolder( $folderName, $folderRoot ); - $folderRoot = $response['folderUID']; - } - } - return $folderRoot != "/" ? $folderRoot : ""; - } - - /** - * - * @param string $fileTags - * @param string(32) $sessionID Application ID - * @return string - */ - function parseTags ($fileTags, $sessionID = "") - { - - if ($sessionID == "") { - $sessionID = $_SESSION['APPLICATION']; + $msg = ''; + $validationFailuresArray = $tr->getValidationFailures(); + foreach ($validationFailuresArray as $objValidationFailure) { + $msg .= $objValidationFailure->getMessage() . "
"; + } + $response['success'] = false; + $response['message'] = $response['error'] = "Can't create folder \n A \n " . $msg; + return ($response); + } + } + } + + /** + * + * @param string $folderPath + * @param strin(32) $sessionID + * @return string Last Folder ID generated + */ + public function createFromPath ($folderPath, $sessionID = "") + { + if ($sessionID == "") { + $sessionID = $_SESSION['APPLICATION']; //Get current Application Fields - } - - $oApplication = new Application(); - $appFields = $oApplication->Load( $sessionID ); - $fileTagsParsed = G::replaceDataField( $fileTags, $appFields ); - $fileTagsParsed = G::replaceDataField( $fileTags, unserialize( $appFields['APP_DATA'] ) ); - return $fileTagsParsed; - } - - /** - * - * @param string(32) $folderID - * @return multitype: - */ - function getFolderList ($folderID, $limit = 0, $start = 0) - { - $Criteria = new Criteria( 'workflow' ); - $Criteria->clearSelectColumns()->clearOrderByColumns(); - $Criteria->addSelectColumn( AppFolderPeer::FOLDER_UID ); - $Criteria->addSelectColumn( AppFolderPeer::FOLDER_PARENT_UID ); - $Criteria->addSelectColumn( AppFolderPeer::FOLDER_NAME ); - $Criteria->addSelectColumn( AppFolderPeer::FOLDER_CREATE_DATE ); - $Criteria->addSelectColumn( AppFolderPeer::FOLDER_UPDATE_DATE ); - $Criteria->add( appFolderPeer::FOLDER_PARENT_UID, $folderID, CRITERIA::EQUAL ); - $Criteria->addAscendingOrderByColumn( AppFolderPeer::FOLDER_NAME ); - - $response['totalFoldersCount'] = AppFolderPeer::doCount( $Criteria ); - $response['folders'] = array (); - - if ($limit != 0) { - $Criteria->setLimit( $limit ); - $Criteria->setOffset( $start ); - } - - $rs = appFolderPeer::doSelectRS( $Criteria ); - $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $rs->next(); - $folderResult = array (); - while (is_array( $row = $rs->getRow() )) { - $response['folders'][] = $row; - $rs->next(); - } - return ($response); - } - - /** - * - * @param string(32) $folderUid - * @return array - */ - function load ($folderUid) - { - $tr = AppFolderPeer::retrieveByPK( $folderUid ); - if ((is_object( $tr ) && get_class( $tr ) == 'AppFolder')) { - $fields['FOLDER_UID'] = $tr->getFolderUid(); - $fields['FOLDER_PARENT_UID'] = $tr->getFolderParentUid(); - $fields['FOLDER_NAME'] = $tr->getFolderName(); - $fields['FOLDER_CREATE_DATE'] = $tr->getFolderCreateDate(); - $fields['FOLDER_UPDATE_DATE'] = $tr->getFolderUpdateDate(); - } elseif ($folderUid == "/") { - $fields['FOLDER_UID'] = "/"; - $fields['FOLDER_PARENT_UID'] = ""; - $fields['FOLDER_NAME'] = "/"; - $fields['FOLDER_CREATE_DATE'] = ""; - $fields['FOLDER_UPDATE_DATE'] = ""; - } else { + } + + $oApplication = new Application(); + $appFields = $oApplication->Load( $sessionID ); + $folderPathParsed = G::replaceDataField( $folderPath, $appFields ); + $folderPathParsed = G::replaceDataField( $folderPath, unserialize( $appFields['APP_DATA'] ) ); + $folderPathParsedArray = explode( "/", $folderPathParsed ); + $folderRoot = "/"; //Always starting from Root + foreach ($folderPathParsedArray as $folderName) { + if (trim( $folderName ) != "") { + $response = $this->createFolder( $folderName, $folderRoot ); + $folderRoot = $response['folderUID']; + } + } + return $folderRoot != "/" ? $folderRoot : ""; + } + + /** + * + * @param string $fileTags + * @param string(32) $sessionID Application ID + * @return string + */ + public function parseTags ($fileTags, $sessionID = "") + { + + if ($sessionID == "") { + $sessionID = $_SESSION['APPLICATION']; + //Get current Application Fields + } + + $oApplication = new Application(); + $appFields = $oApplication->Load( $sessionID ); + $fileTagsParsed = G::replaceDataField( $fileTags, $appFields ); + $fileTagsParsed = G::replaceDataField( $fileTags, unserialize( $appFields['APP_DATA'] ) ); + return $fileTagsParsed; + } + + /** + * + * @param string(32) $folderID + * @return multitype: + */ + public function getFolderList ($folderID, $limit = 0, $start = 0) + { + $Criteria = new Criteria( 'workflow' ); + $Criteria->clearSelectColumns()->clearOrderByColumns(); + $Criteria->addSelectColumn( AppFolderPeer::FOLDER_UID ); + $Criteria->addSelectColumn( AppFolderPeer::FOLDER_PARENT_UID ); + $Criteria->addSelectColumn( AppFolderPeer::FOLDER_NAME ); + $Criteria->addSelectColumn( AppFolderPeer::FOLDER_CREATE_DATE ); + $Criteria->addSelectColumn( AppFolderPeer::FOLDER_UPDATE_DATE ); + $Criteria->add( appFolderPeer::FOLDER_PARENT_UID, $folderID, CRITERIA::EQUAL ); + $Criteria->addAscendingOrderByColumn( AppFolderPeer::FOLDER_NAME ); + + $response['totalFoldersCount'] = AppFolderPeer::doCount( $Criteria ); + $response['folders'] = array (); + + if ($limit != 0) { + $Criteria->setLimit( $limit ); + $Criteria->setOffset( $start ); + } + + $rs = appFolderPeer::doSelectRS( $Criteria ); + $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $rs->next(); + $folderResult = array (); + while (is_array( $row = $rs->getRow() )) { + $response['folders'][] = $row; + $rs->next(); + } + return ($response); + } + + /** + * + * @param string(32) $folderUid + * @return array + */ + public function load ($folderUid) + { + $tr = AppFolderPeer::retrieveByPK( $folderUid ); + if ((is_object( $tr ) && get_class( $tr ) == 'AppFolder')) { + $fields['FOLDER_UID'] = $tr->getFolderUid(); + $fields['FOLDER_PARENT_UID'] = $tr->getFolderParentUid(); + $fields['FOLDER_NAME'] = $tr->getFolderName(); + $fields['FOLDER_CREATE_DATE'] = $tr->getFolderCreateDate(); + $fields['FOLDER_UPDATE_DATE'] = $tr->getFolderUpdateDate(); + } elseif ($folderUid == "/") { + $fields['FOLDER_UID'] = "/"; + $fields['FOLDER_PARENT_UID'] = ""; + $fields['FOLDER_NAME'] = "/"; + $fields['FOLDER_CREATE_DATE'] = ""; + $fields['FOLDER_UPDATE_DATE'] = ""; + } else { // $fields = array (); - $fields['FOLDER_UID'] = "/"; - $fields['FOLDER_PARENT_UID'] = ""; - $fields['FOLDER_NAME'] = "root"; - $fields['FOLDER_CREATE_DATE'] = ""; - $fields['FOLDER_UPDATE_DATE'] = ""; - } - return $fields; - } - - function getFolderStructure ($folderId) - { - $folderObj = $this->load( $folderId ); - $folderArray[$folderObj['FOLDER_UID']] = array ("NAME" => $folderObj['FOLDER_NAME'],"PARENT" => $folderObj['FOLDER_PARENT_UID'] - ); - $folderArray['PATH_ARRAY'][] = $folderObj['FOLDER_NAME']; - - while ($folderObj['FOLDER_PARENT_UID'] != "") { - $folderObj = $this->load( $folderObj['FOLDER_PARENT_UID'] ); - $folderArray[$folderObj['FOLDER_UID']] = array ("NAME" => $folderObj['FOLDER_NAME'],"PARENT" => $folderObj['FOLDER_PARENT_UID']); - $folderArray['PATH_ARRAY'][] = $folderObj['FOLDER_NAME']; - } - - $folderArray['PATH'] = str_replace( "//", "/", implode( "/", array_reverse( $folderArray['PATH_ARRAY'] ) ) ); - return $folderArray; - } - - function getFolderContent ($folderID, $docIdFilter = array(), $keyword = null, $searchType = null, $limit = 0, $start = 0, $user = '', $onlyActive = false) - { - require_once ("classes/model/AppDocument.php"); - require_once ("classes/model/InputDocument.php"); - require_once ("classes/model/OutputDocument.php"); - require_once ("classes/model/Users.php"); - - G::LoadClass( 'case' ); - $oCase = new Cases(); - G::LoadClass( 'process' ); - $oProcess = new Process(); - - $oAppDocument = new AppDocument(); - $oCriteria = new Criteria(); - - if ((is_array( $docIdFilter )) && (count( $docIdFilter ) > 0)) { + $fields['FOLDER_UID'] = "/"; + $fields['FOLDER_PARENT_UID'] = ""; + $fields['FOLDER_NAME'] = "root"; + $fields['FOLDER_CREATE_DATE'] = ""; + $fields['FOLDER_UPDATE_DATE'] = ""; + } + return $fields; + } + + public function getFolderStructure ($folderId) + { + $folderObj = $this->load( $folderId ); + $folderArray[$folderObj['FOLDER_UID']] = array ("NAME" => $folderObj['FOLDER_NAME'],"PARENT" => $folderObj['FOLDER_PARENT_UID'] + ); + $folderArray['PATH_ARRAY'][] = $folderObj['FOLDER_NAME']; + + while ($folderObj['FOLDER_PARENT_UID'] != "") { + $folderObj = $this->load( $folderObj['FOLDER_PARENT_UID'] ); + $folderArray[$folderObj['FOLDER_UID']] = array ("NAME" => $folderObj['FOLDER_NAME'],"PARENT" => $folderObj['FOLDER_PARENT_UID']); + $folderArray['PATH_ARRAY'][] = $folderObj['FOLDER_NAME']; + } + + $folderArray['PATH'] = str_replace( "//", "/", implode( "/", array_reverse( $folderArray['PATH_ARRAY'] ) ) ); + return $folderArray; + } + + public function getFolderContent ($folderID, $docIdFilter = array(), $keyword = null, $searchType = null, $limit = 0, $start = 0, $user = '', $onlyActive = false) + { + require_once ("classes/model/AppDocument.php"); + require_once ("classes/model/InputDocument.php"); + require_once ("classes/model/OutputDocument.php"); + require_once ("classes/model/Users.php"); + + G::LoadClass( 'case' ); + $oCase = new Cases(); + G::LoadClass( 'process' ); + $oProcess = new Process(); + + $oAppDocument = new AppDocument(); + $oCriteria = new Criteria(); + + if ((is_array( $docIdFilter )) && (count( $docIdFilter ) > 0)) { //Search by App Doc UID no matter what Folder it is - $oCriteria->add( AppDocumentPeer::APP_DOC_UID, $docIdFilter, CRITERIA::IN ); - } elseif ($folderID != null) { - if ($folderID == "/") { - $oCriteria->add( AppDocumentPeer::FOLDER_UID, array ('root','',null), CRITERIA::IN ); - } else { - $oCriteria->add( AppDocumentPeer::FOLDER_UID, $folderID ); - } - } elseif ($searchType == "TAG") { - $oCriteria->add( AppDocumentPeer::APP_DOC_TAGS, "%" . $keyword . "%", CRITERIA::LIKE ); - } - - if ($user != '') { - require_once ("classes/model/AppDelegation.php"); - $criteria = new Criteria(); - $criteria->addSelectColumn( AppDelegationPeer::APP_UID ); - $criteria->setDistinct(); - - $conditions = array (); - $conditions[] = array (AppDelegationPeer::APP_UID,AppDocumentPeer::APP_UID); - $conditions[] = array (AppDelegationPeer::DEL_INDEX,AppDocumentPeer::DEL_INDEX); - - $criteria->addJoinMC( $conditions, Criteria::LEFT_JOIN ); - - $criteria->add( AppDelegationPeer::USR_UID, $user ); - - $rs2 = AppDocumentPeer::doSelectRS( $criteria ); - - $rs2->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $data = array (); - while ($rs2->next()) { - $row = $rs2->getRow(); - $data[] = $row['APP_UID']; - } - $oCriteria->add( AppDocumentPeer::APP_UID, $data, CRITERIA::IN ); - } - if ($onlyActive) { - $oCriteria->add( AppDocumentPeer::APP_DOC_STATUS, 'ACTIVE' ); - } - - $oCase->verifyTable(); - - $oCriteria->addAscendingOrderByColumn( AppDocumentPeer::APP_DOC_INDEX ); - $oCriteria->addDescendingOrderByColumn( AppDocumentPeer::DOC_VERSION ); - - $response['totalDocumentsCount'] = AppDocumentPeer::doCount( $oCriteria ); - $response['documents'] = array (); - - $oCriteria->setLimit( $limit ); - $oCriteria->setOffset( $start ); - - $rs = AppDocumentPeer::doSelectRS( $oCriteria ); - $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $rs->next(); - $filesResult = array (); - while (is_array( $row = $rs->getRow() )) { + $oCriteria->add( AppDocumentPeer::APP_DOC_UID, $docIdFilter, CRITERIA::IN ); + } elseif ($folderID != null) { + if ($folderID == "/") { + $oCriteria->add( AppDocumentPeer::FOLDER_UID, array ('root','',null), CRITERIA::IN ); + } else { + $oCriteria->add( AppDocumentPeer::FOLDER_UID, $folderID ); + } + } elseif ($searchType == "TAG") { + $oCriteria->add( AppDocumentPeer::APP_DOC_TAGS, "%" . $keyword . "%", CRITERIA::LIKE ); + } + + if ($user != '') { + require_once ("classes/model/AppDelegation.php"); + $criteria = new Criteria(); + $criteria->addSelectColumn( AppDelegationPeer::APP_UID ); + $criteria->setDistinct(); + + $conditions = array (); + $conditions[] = array (AppDelegationPeer::APP_UID,AppDocumentPeer::APP_UID); + $conditions[] = array (AppDelegationPeer::DEL_INDEX,AppDocumentPeer::DEL_INDEX); + + $criteria->addJoinMC( $conditions, Criteria::LEFT_JOIN ); + + $criteria->add( AppDelegationPeer::USR_UID, $user ); + + $rs2 = AppDocumentPeer::doSelectRS( $criteria ); + + $rs2->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $data = array (); + while ($rs2->next()) { + $row = $rs2->getRow(); + $data[] = $row['APP_UID']; + } + $oCriteria->add( AppDocumentPeer::APP_UID, $data, CRITERIA::IN ); + } + if ($onlyActive) { + $oCriteria->add( AppDocumentPeer::APP_DOC_STATUS, 'ACTIVE' ); + } + + $oCase->verifyTable(); + + $oCriteria->addAscendingOrderByColumn( AppDocumentPeer::APP_DOC_INDEX ); + $oCriteria->addDescendingOrderByColumn( AppDocumentPeer::DOC_VERSION ); + + $response['totalDocumentsCount'] = AppDocumentPeer::doCount( $oCriteria ); + $response['documents'] = array (); + + $oCriteria->setLimit( $limit ); + $oCriteria->setOffset( $start ); + + $rs = AppDocumentPeer::doSelectRS( $oCriteria ); + $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $rs->next(); + $filesResult = array (); + while (is_array( $row = $rs->getRow() )) { //**** start get Doc Info - $oApp = new Application(); - if (($oApp->exists( $row['APP_UID'] )) || ($row['APP_UID'] == "00000000000000000000000000000000")) { + $oApp = new Application(); + if (($oApp->exists( $row['APP_UID'] )) || ($row['APP_UID'] == "00000000000000000000000000000000")) { //$completeInfo = array("APP_DOC_FILENAME" => $row ["APP_DOC_UID"],"APP_DOC_UID"=>$row ['APP_UID']); - $completeInfo = $this->getCompleteDocumentInfo( $row['APP_UID'], $row['APP_DOC_UID'], $row['DOC_VERSION'], $row['DOC_UID'], $row['USR_UID'] ); - $oAppDocument = new AppDocument(); - $lastVersion = $oAppDocument->getLastAppDocVersion( $row['APP_DOC_UID'], $row['APP_UID'] ); + $completeInfo = $this->getCompleteDocumentInfo( $row['APP_UID'], $row['APP_DOC_UID'], $row['DOC_VERSION'], $row['DOC_UID'], $row['USR_UID'] ); + $oAppDocument = new AppDocument(); + $lastVersion = $oAppDocument->getLastAppDocVersion( $row['APP_DOC_UID'], $row['APP_UID'] ); //$filesResult [] = $completeInfo; - if ($completeInfo['APP_DOC_STATUS'] != "DELETED") { - if ((in_array( $row['APP_DOC_UID'], $completeInfo['INPUT_DOCUMENTS'] )) || (in_array( $row['APP_DOC_UID'], $completeInfo['OUTPUT_DOCUMENTS'] )) || (in_array( $completeInfo['USR_UID'], array ($_SESSION['USER_LOGGED'],'-1') ))) { - if (count( $docIdFilter ) > 0) { - if (in_array( $row['APP_DOC_UID'], $docIdFilter )) { - $response['documents'][] = $completeInfo; - } - } elseif ($lastVersion == $row['DOC_VERSION']) { + if ($completeInfo['APP_DOC_STATUS'] != "DELETED") { + if ((in_array( $row['APP_DOC_UID'], $completeInfo['INPUT_DOCUMENTS'] )) || (in_array( $row['APP_DOC_UID'], $completeInfo['OUTPUT_DOCUMENTS'] )) || (in_array( $completeInfo['USR_UID'], array ($_SESSION['USER_LOGGED'],'-1') ))) { + if (count( $docIdFilter ) > 0) { + if (in_array( $row['APP_DOC_UID'], $docIdFilter )) { + $response['documents'][] = $completeInfo; + } + } elseif ($lastVersion == $row['DOC_VERSION']) { //Only Last Document version - if ($searchType == "ALL") { // If search in name of docs is active then filter - if ((stripos( $completeInfo['APP_DOC_FILENAME'], $keyword ) !== false) || (stripos( $completeInfo['APP_DOC_TAGS'], $keyword ) !== false)) { - $response['documents'][] = $completeInfo; - } - } else { + if ($searchType == "ALL") { + // If search in name of docs is active then filter + if ((stripos( $completeInfo['APP_DOC_FILENAME'], $keyword ) !== false) || (stripos( $completeInfo['APP_DOC_TAGS'], $keyword ) !== false)) { + $response['documents'][] = $completeInfo; + } + } else { //No search filter active - $response['documents'][] = $completeInfo; - } - } - } - } - } - $rs->next(); - } - return ($response); - } - - function getCompleteDocumentInfo ($appUid, $appDocUid, $docVersion, $docUid, $usrId) - { - require_once ("classes/model/AppDocument.php"); - require_once ("classes/model/InputDocument.php"); - require_once ("classes/model/OutputDocument.php"); - require_once ("classes/model/Users.php"); + $response['documents'][] = $completeInfo; + } + } + } + } + } + $rs->next(); + } + return ($response); + } + + public function getCompleteDocumentInfo ($appUid, $appDocUid, $docVersion, $docUid, $usrId) + { + require_once ("classes/model/AppDocument.php"); + require_once ("classes/model/InputDocument.php"); + require_once ("classes/model/OutputDocument.php"); + require_once ("classes/model/Users.php"); //**** start get Doc Info - $oApp = new Application(); - $oAppDocument = new AppDocument(); - G::LoadClass( 'case' ); - $oCase = new Cases(); - G::LoadClass( 'process' ); - $oProcess = new Process(); - if (($oApp->exists( $appUid )) || ($appUid == "00000000000000000000000000000000")) { - if ($appUid == "00000000000000000000000000000000") { //External Files - $row1 = $oAppDocument->load( $appDocUid, $docVersion ); - $row2 = array ('PRO_TITLE' => G::LoadTranslation( 'ID_NOT_PROCESS_RELATED' )); - $row3 = array ('APP_TITLE' => G::LoadTranslation( 'ID_NOT_PROCESS_RELATED' )); - } else { - $row1 = $oAppDocument->load( $appDocUid, $docVersion ); - $row2 = $oCase->loadCase( $appUid ); - $row3 = $oProcess->Load( $row2['PRO_UID'] ); - } - $lastVersion = $oAppDocument->getLastAppDocVersion( $appDocUid, $appUid ); - - switch ($row1['APP_DOC_TYPE']) { - case "OUTPUT": - $oOutputDocument = new OutputDocument(); - $row4 = $oOutputDocument->load( $docUid ); - $versioningEnabled = false; //$row4['OUT_DOC_VERSIONING']; //Only enabled for Input or Attached documents. Need to study the best way for Output docs. - switch ($row4['OUT_DOC_GENERATE']) { - case "PDF": - $downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=pdf" . "&random=" . rand(); - $downloadLink1 = ""; - $downloadLabel = ".pdf"; - $downloadLabel1 = ""; - break; - case "DOC": - $downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=doc" . "&random=" . rand(); - $downloadLink1 = ""; - $downloadLabel = ".doc"; - $downloadLabel1 = ""; - break; - case "BOTH": - $downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=pdf" . "&random=" . rand(); - $downloadLink1 = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=doc" . "&random=" . rand(); - $downloadLabel = ".pdf"; - $downloadLabel1 = ".doc"; - break; - } - - break; - case "INPUT": - $oInputDocument = new InputDocument(); - if ($docUid != - 1) { - if ($oInputDocument->InputExists( $docUid )) { - $row4 = $oInputDocument->load( $docUid ); - $versioningEnabled = $row4['INP_DOC_VERSIONING']; - } else { - $row4 = array (); - $versioningEnabled = false; - } - $downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion; - $downloadLink1 = ""; - $downloadLabel = G::LoadTranslation( 'ID_DOWNLOAD' ); - $downloadLabel1 = ""; - } else { - $row4 = array (); - $versioningEnabled = false; - $downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion; - $downloadLink1 = ""; - $downloadLabel = G::LoadTranslation( 'ID_DOWNLOAD' ); - $downloadLabel1 = ""; - } - - /////// - if (! empty( $row1["APP_DOC_PLUGIN"] )) { - $pluginRegistry = &PMPluginRegistry::getSingleton(); - $pluginName = $row1["APP_DOC_PLUGIN"]; - $fieldValue = ""; - - if (file_exists( PATH_PLUGINS . $pluginName . ".php" )) { - $pluginDetail = $pluginRegistry->getPluginDetails( $pluginName . ".php" ); - - if ($pluginDetail) { - if ($pluginDetail->enabled) { - require_once (PATH_PLUGINS . $pluginName . ".php"); - $pluginNameClass = $pluginName . "Plugin"; - $objPluginClass = new $pluginNameClass( $pluginName ); - - if (isset( $objPluginClass->sMethodGetUrlDownload ) && ! empty( $objPluginClass->sMethodGetUrlDownload )) { - if (file_exists( PATH_PLUGINS . $pluginName . PATH_SEP . "class." . $pluginName . ".php" )) { - require_once (PATH_PLUGINS . $pluginName . PATH_SEP . "class." . $pluginName . ".php"); - $pluginNameClass = $pluginName . "Class"; - $objClass = new $pluginNameClass(); - - if (method_exists( $objClass, $objPluginClass->sMethodGetUrlDownload )) { - eval( "\$url = \$objClass->" . $objPluginClass->sMethodGetUrlDownload . "(\"" . $row1["APP_DOC_UID"] . "\");" ); - $downloadLink = $url; - $fieldValue = $row1["APP_DOC_PLUGIN"]; - } - } - } - } - } - } - $row1["APP_DOC_PLUGIN"] = $fieldValue; - } - break; - - default: - $row4 = array (); - $versioningEnabled = false; - $downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion; - $downloadLink1 = ""; - $downloadLabel = G::LoadTranslation( 'ID_DOWNLOAD' ); - $downloadLabel1 = ""; - break; - } - $oUser = new Users(); - if (($usrId != "-1") && ($oUser->userExists( $usrId ))) { - $row5 = $oUser->load( $usrId ); - } else { - $row5['USR_USERNAME'] = "***"; - } - - //Labels/Links - $row6 = array (); - $row6['DELETE_LABEL'] = G::LoadTranslation( 'ID_DELETE' ); - $row6['DOWNLOAD_LABEL'] = $downloadLabel; - $row6['DOWNLOAD_LINK'] = $downloadLink; - $row6['DOWNLOAD_LABEL1'] = $downloadLabel1; - $row6['DOWNLOAD_LINK1'] = $downloadLink1; - //if(($docVersion>1)&&($row1['APP_DOC_TYPE']!="OUTPUT")){ - if (($docVersion > 1)) { - $row6['VERSIONHISTORY_LABEL'] = G::LoadTranslation( 'ID_VERSION_HISTORY' ); - } - if ($versioningEnabled) { - $row6['NEWVERSION_LABEL'] = G::LoadTranslation( 'ID_NEW_VERSION' ); - } - $row6['APP_DOC_UID_VERSION'] = $appDocUid . "_" . $docVersion; - - if ($appUid == "00000000000000000000000000000000") { + $oApp = new Application(); + $oAppDocument = new AppDocument(); + G::LoadClass( 'case' ); + $oCase = new Cases(); + G::LoadClass( 'process' ); + $oProcess = new Process(); + if (($oApp->exists( $appUid )) || ($appUid == "00000000000000000000000000000000")) { + if ($appUid == "00000000000000000000000000000000") { //External Files - $row1['APP_DOC_TYPE'] = G::LoadTranslation( 'ID_EXTERNAL_FILE' ); - } + $row1 = $oAppDocument->load( $appDocUid, $docVersion ); + $row2 = array ('PRO_TITLE' => G::LoadTranslation( 'ID_NOT_PROCESS_RELATED' )); + $row3 = array ('APP_TITLE' => G::LoadTranslation( 'ID_NOT_PROCESS_RELATED' )); + } else { + $row1 = $oAppDocument->load( $appDocUid, $docVersion ); + $row2 = $oCase->loadCase( $appUid ); + $row3 = $oProcess->Load( $row2['PRO_UID'] ); + } + $lastVersion = $oAppDocument->getLastAppDocVersion( $appDocUid, $appUid ); + + switch ($row1['APP_DOC_TYPE']) { + case "OUTPUT": + $oOutputDocument = new OutputDocument(); + $row4 = $oOutputDocument->load( $docUid ); + $versioningEnabled = false; //$row4['OUT_DOC_VERSIONING']; //Only enabled for Input or Attached documents. Need to study the best way for Output docs. + switch ($row4['OUT_DOC_GENERATE']) { + case "PDF": + $downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=pdf" . "&random=" . rand(); + $downloadLink1 = ""; + $downloadLabel = ".pdf"; + $downloadLabel1 = ""; + break; + case "DOC": + $downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=doc" . "&random=" . rand(); + $downloadLink1 = ""; + $downloadLabel = ".doc"; + $downloadLabel1 = ""; + break; + case "BOTH": + $downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=pdf" . "&random=" . rand(); + $downloadLink1 = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=doc" . "&random=" . rand(); + $downloadLabel = ".pdf"; + $downloadLabel1 = ".doc"; + break; + } + + break; + case "INPUT": + $oInputDocument = new InputDocument(); + if ($docUid != - 1) { + if ($oInputDocument->InputExists( $docUid )) { + $row4 = $oInputDocument->load( $docUid ); + $versioningEnabled = $row4['INP_DOC_VERSIONING']; + } else { + $row4 = array (); + $versioningEnabled = false; + } + $downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion; + $downloadLink1 = ""; + $downloadLabel = G::LoadTranslation( 'ID_DOWNLOAD' ); + $downloadLabel1 = ""; + } else { + $row4 = array (); + $versioningEnabled = false; + $downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion; + $downloadLink1 = ""; + $downloadLabel = G::LoadTranslation( 'ID_DOWNLOAD' ); + $downloadLabel1 = ""; + } + + if (! empty( $row1["APP_DOC_PLUGIN"] )) { + $pluginRegistry = &PMPluginRegistry::getSingleton(); + $pluginName = $row1["APP_DOC_PLUGIN"]; + $fieldValue = ""; + + if (file_exists( PATH_PLUGINS . $pluginName . ".php" )) { + $pluginDetail = $pluginRegistry->getPluginDetails( $pluginName . ".php" ); + + if ($pluginDetail) { + if ($pluginDetail->enabled) { + require_once (PATH_PLUGINS . $pluginName . ".php"); + $pluginNameClass = $pluginName . "Plugin"; + $objPluginClass = new $pluginNameClass( $pluginName ); + + if (isset( $objPluginClass->sMethodGetUrlDownload ) && ! empty( $objPluginClass->sMethodGetUrlDownload )) { + if (file_exists( PATH_PLUGINS . $pluginName . PATH_SEP . "class." . $pluginName . ".php" )) { + require_once (PATH_PLUGINS . $pluginName . PATH_SEP . "class." . $pluginName . ".php"); + $pluginNameClass = $pluginName . "Class"; + $objClass = new $pluginNameClass(); + + if (method_exists( $objClass, $objPluginClass->sMethodGetUrlDownload )) { + eval( "\$url = \$objClass->" . $objPluginClass->sMethodGetUrlDownload . "(\"" . $row1["APP_DOC_UID"] . "\");" ); + $downloadLink = $url; + $fieldValue = $row1["APP_DOC_PLUGIN"]; + } + } + } + } + } + } + $row1["APP_DOC_PLUGIN"] = $fieldValue; + } + break; + default: + $row4 = array (); + $versioningEnabled = false; + $downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion; + $downloadLink1 = ""; + $downloadLabel = G::LoadTranslation( 'ID_DOWNLOAD' ); + $downloadLabel1 = ""; + break; + } + $oUser = new Users(); + if (($usrId != "-1") && ($oUser->userExists( $usrId ))) { + $row5 = $oUser->load( $usrId ); + } else { + $row5['USR_USERNAME'] = "***"; + } + + //Labels/Links + $row6 = array (); + $row6['DELETE_LABEL'] = G::LoadTranslation( 'ID_DELETE' ); + $row6['DOWNLOAD_LABEL'] = $downloadLabel; + $row6['DOWNLOAD_LINK'] = $downloadLink; + $row6['DOWNLOAD_LABEL1'] = $downloadLabel1; + $row6['DOWNLOAD_LINK1'] = $downloadLink1; + //if(($docVersion>1)&&($row1['APP_DOC_TYPE']!="OUTPUT")){ + if (($docVersion > 1)) { + $row6['VERSIONHISTORY_LABEL'] = G::LoadTranslation( 'ID_VERSION_HISTORY' ); + } + if ($versioningEnabled) { + $row6['NEWVERSION_LABEL'] = G::LoadTranslation( 'ID_NEW_VERSION' ); + } + $row6['APP_DOC_UID_VERSION'] = $appDocUid . "_" . $docVersion; + + if ($appUid == "00000000000000000000000000000000") { + //External Files + $row1['APP_DOC_TYPE'] = G::LoadTranslation( 'ID_EXTERNAL_FILE' ); + } //**** End get docinfo - $infoMerged = array_merge( $row1, $row2, $row3, $row4, $row5, $row6 ); - //krumo($infoMerged); - //**************************************************************************************************** - $sUserUID = $_SESSION['USER_LOGGED']; - $aObjectPermissions = array (); - if (isset( $infoMerged['PRO_UID'] )) { - $aObjectPermissions = $oCase->getAllObjects( $infoMerged['PRO_UID'], $infoMerged['APP_UID'], '', $sUserUID ); - } - - if (! is_array( $aObjectPermissions )) { - $aObjectPermissions = array ('DYNAFORMS' => array (- 1), - 'INPUT_DOCUMENTS' => array (- 1), - 'OUTPUT_DOCUMENTS' => array (- 1) - ); - } - if (! isset( $aObjectPermissions['DYNAFORMS'] )) { - $aObjectPermissions['DYNAFORMS'] = array (- 1); - } else { - if (! is_array( $aObjectPermissions['DYNAFORMS'] )) { - $aObjectPermissions['DYNAFORMS'] = array (- 1); - } - } - if (! isset( $aObjectPermissions['INPUT_DOCUMENTS'] )) { - $aObjectPermissions['INPUT_DOCUMENTS'] = array (- 1); - } else { - if (! is_array( $aObjectPermissions['INPUT_DOCUMENTS'] )) { - $aObjectPermissions['INPUT_DOCUMENTS'] = array (- 1); - } - } - if (! isset( $aObjectPermissions['OUTPUT_DOCUMENTS'] )) { - $aObjectPermissions['OUTPUT_DOCUMENTS'] = array (- 1); - } else { - if (! is_array( $aObjectPermissions['OUTPUT_DOCUMENTS'] )) { - $aObjectPermissions['OUTPUT_DOCUMENTS'] = array (- 1); - } - } - //**************************************************************************************************** - return array_merge( $infoMerged, $aObjectPermissions ); - } - } - - function getFolderChilds ($folderID, $folderArray) - { - $folderList = $this->getFolderList( $folderID ); - $foldersList = array (); - foreach ($folderList as $key => $folderObj) { - $foldersList[$folderObj['FOLDER_UID']] = $folderObj['FOLDER_NAME']; - $foldersList = array_merge( $foldersList, $this->getFolderChilds( $folderObj['FOLDER_UID'], $folderArray ) ); - } - return (array_merge( $folderArray, $foldersList )); - } - - function getFolderTags ($rootFolder) - { - $folderArray[$rootFolder] = $rootFolder; - $foldersToProcess = $this->getFolderChilds( $rootFolder, $folderArray ); - $tagsInfo = array (); - - foreach ($foldersToProcess as $folderkey => $foldername) { - $filesList = $this->getFolderContent( $folderkey ); - - foreach ($filesList as $key => $fileInfo) { - $fileTags = explode( ",", $fileInfo['APP_DOC_TAGS'] ); - foreach ($fileTags as $key1 => $tag) { - if (! (isset( $tagsInfo[$tag] ))) - $tagsInfo[$tag] = 0; - $tagsInfo[$tag] ++; - } - } - } - return $tagsInfo; - - } - - function remove ($FolderUid, $rootfolder) - { - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( AppFolderPeer::FOLDER_UID, $FolderUid ); - AppFolderPeer::doDelete( $oCriteria ); - } -} -// AppFolder - + $infoMerged = array_merge( $row1, $row2, $row3, $row4, $row5, $row6 ); + + $sUserUID = $_SESSION['USER_LOGGED']; + $aObjectPermissions = array (); + if (isset( $infoMerged['PRO_UID'] )) { + $aObjectPermissions = $oCase->getAllObjects( $infoMerged['PRO_UID'], $infoMerged['APP_UID'], '', $sUserUID ); + } + + if (! is_array( $aObjectPermissions )) { + $aObjectPermissions = array ('DYNAFORMS' => array (- 1), + 'INPUT_DOCUMENTS' => array (- 1), + 'OUTPUT_DOCUMENTS' => array (- 1) + ); + } + if (! isset( $aObjectPermissions['DYNAFORMS'] )) { + $aObjectPermissions['DYNAFORMS'] = array (- 1); + } else { + if (! is_array( $aObjectPermissions['DYNAFORMS'] )) { + $aObjectPermissions['DYNAFORMS'] = array (- 1); + } + } + if (! isset( $aObjectPermissions['INPUT_DOCUMENTS'] )) { + $aObjectPermissions['INPUT_DOCUMENTS'] = array (- 1); + } else { + if (! is_array( $aObjectPermissions['INPUT_DOCUMENTS'] )) { + $aObjectPermissions['INPUT_DOCUMENTS'] = array (- 1); + } + } + if (! isset( $aObjectPermissions['OUTPUT_DOCUMENTS'] )) { + $aObjectPermissions['OUTPUT_DOCUMENTS'] = array (- 1); + } else { + if (! is_array( $aObjectPermissions['OUTPUT_DOCUMENTS'] )) { + $aObjectPermissions['OUTPUT_DOCUMENTS'] = array (- 1); + } + } + return array_merge( $infoMerged, $aObjectPermissions ); + } + } + + public function getFolderChilds ($folderID, $folderArray) + { + $folderList = $this->getFolderList( $folderID ); + $foldersList = array (); + foreach ($folderList as $key => $folderObj) { + $foldersList[$folderObj['FOLDER_UID']] = $folderObj['FOLDER_NAME']; + $foldersList = array_merge( $foldersList, $this->getFolderChilds( $folderObj['FOLDER_UID'], $folderArray ) ); + } + return (array_merge( $folderArray, $foldersList )); + } + + public function getFolderTags ($rootFolder) + { + $folderArray[$rootFolder] = $rootFolder; + $foldersToProcess = $this->getFolderChilds( $rootFolder, $folderArray ); + $tagsInfo = array (); + + foreach ($foldersToProcess as $folderkey => $foldername) { + $filesList = $this->getFolderContent( $folderkey ); + + foreach ($filesList as $key => $fileInfo) { + $fileTags = explode( ",", $fileInfo['APP_DOC_TAGS'] ); + foreach ($fileTags as $key1 => $tag) { + if (! (isset( $tagsInfo[$tag] ))) { + $tagsInfo[$tag] = 0; + } + $tagsInfo[$tag] ++; + } + } + } + return $tagsInfo; + } + + public function remove ($FolderUid, $rootfolder) + { + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( AppFolderPeer::FOLDER_UID, $FolderUid ); + AppFolderPeer::doDelete( $oCriteria ); + } +} + diff --git a/workflow/engine/classes/model/AppFolderPeer.php b/workflow/engine/classes/model/AppFolderPeer.php index ed8002466..73fe14494 100755 --- a/workflow/engine/classes/model/AppFolderPeer.php +++ b/workflow/engine/classes/model/AppFolderPeer.php @@ -14,7 +14,7 @@ /** * Skeleton subclass for performing query and update operations on the 'APP_FOLDER' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -22,6 +22,7 @@ * * @package workflow.engine.classes.model */ -class AppFolderPeer extends BaseAppFolderPeer { +class AppFolderPeer extends BaseAppFolderPeer +{ +} -} // AppFolderPeer diff --git a/workflow/engine/classes/model/AppHistory.php b/workflow/engine/classes/model/AppHistory.php index c363b19df..ab69b1e17 100755 --- a/workflow/engine/classes/model/AppHistory.php +++ b/workflow/engine/classes/model/AppHistory.php @@ -18,10 +18,10 @@ require_once 'classes/model/om/BaseAppHistory.php'; * * @package workflow.engine.classes.model */ -class AppHistory extends BaseAppHistory { - - function insertHistory($aData){ - +class AppHistory extends BaseAppHistory +{ + public function insertHistory($aData) + { $this->setAppUid($aData['APP_UID']); $this->setDelIndex($aData['DEL_INDEX']); $this->setProUid($aData['PRO_UID']); @@ -32,28 +32,20 @@ class AppHistory extends BaseAppHistory { $this->setHistoryDate($aData['APP_UPDATE_DATE']); $this->setHistoryData($aData['APP_DATA']); - if ($this->validate() ) { - $res = $this->save(); - } - else { - // Something went wrong. We can now get the validationFailures and handle them. - $msg = ''; - $validationFailuresArray = $this->getValidationFailures(); - foreach($validationFailuresArray as $objValidationFailure) { - $msg .= $objValidationFailure->getMessage() . "
"; - } - krumo($msg); - //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); - } - - - - - + $res = $this->save(); + } else { + // Something went wrong. We can now get the validationFailures and handle them. + $msg = ''; + $validationFailuresArray = $this->getValidationFailures(); + foreach ($validationFailuresArray as $objValidationFailure) { + $msg .= $objValidationFailure->getMessage() . "
"; + } + } } - function getDynaformHistory($PRO_UID,$TAS_UID,$APP_UID,$DYN_UID=""){ + public function getDynaformHistory($PRO_UID, $TAS_UID, $APP_UID, $DYN_UID = "") + { G::LoadClass('case'); $oCase = new Cases(); @@ -62,37 +54,30 @@ class AppHistory extends BaseAppHistory { $aObjectPermissions = $oCase->getAllObjects($PRO_UID, $APP_UID, $TAS_UID, $_SESSION['USER_LOGGED']); if (!is_array($aObjectPermissions)) { - $aObjectPermissions = array('DYNAFORMS' => array(-1), 'INPUT_DOCUMENTS' => array(-1), 'OUTPUT_DOCUMENTS' => array(-1)); + $aObjectPermissions = array('DYNAFORMS' => array(-1), 'INPUT_DOCUMENTS' => array(-1), 'OUTPUT_DOCUMENTS' => array(-1)); } if (!isset($aObjectPermissions['DYNAFORMS'])) { - $aObjectPermissions['DYNAFORMS'] = array(-1); - } - else { - if (!is_array($aObjectPermissions['DYNAFORMS'])) { $aObjectPermissions['DYNAFORMS'] = array(-1); - } + } else { + if (!is_array($aObjectPermissions['DYNAFORMS'])) { + $aObjectPermissions['DYNAFORMS'] = array(-1); + } } if (!isset($aObjectPermissions['INPUT_DOCUMENTS'])) { - $aObjectPermissions['INPUT_DOCUMENTS'] = array(-1); - } - else { - if (!is_array($aObjectPermissions['INPUT_DOCUMENTS'])) { $aObjectPermissions['INPUT_DOCUMENTS'] = array(-1); - } + } else { + if (!is_array($aObjectPermissions['INPUT_DOCUMENTS'])) { + $aObjectPermissions['INPUT_DOCUMENTS'] = array(-1); + } } if (!isset($aObjectPermissions['OUTPUT_DOCUMENTS'])) { - $aObjectPermissions['OUTPUT_DOCUMENTS'] = array(-1); - } - else { - if (!is_array($aObjectPermissions['OUTPUT_DOCUMENTS'])) { $aObjectPermissions['OUTPUT_DOCUMENTS'] = array(-1); - } + } else { + if (!is_array($aObjectPermissions['OUTPUT_DOCUMENTS'])) { + $aObjectPermissions['OUTPUT_DOCUMENTS'] = array(-1); + } } - - - - $c = new Criteria('workflow'); $c->addSelectColumn(AppHistoryPeer::APP_UID); $c->addSelectColumn(AppHistoryPeer::DEL_INDEX); @@ -108,12 +93,11 @@ class AppHistory extends BaseAppHistory { $c->addAsColumn('USR_NAME', "CONCAT(USR_LASTNAME, ' ', USR_FIRSTNAME)"); $c->addJoin(AppHistoryPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN); - //WHERE $c->add(AppHistoryPeer::DYN_UID, $aObjectPermissions['DYNAFORMS'], Criteria::IN); $c->add(AppHistoryPeer::PRO_UID, $PRO_UID); $c->add(AppHistoryPeer::APP_UID, $APP_UID); - if((isset($DYN_UID))&&($DYN_UID!="")){ + if ((isset($DYN_UID))&&($DYN_UID!="")) { $c->add(AppHistoryPeer::DYN_UID, $DYN_UID); } @@ -121,7 +105,6 @@ class AppHistory extends BaseAppHistory { $c->clearOrderByColumns(); $c->addDescendingOrderByColumn(AppHistoryPeer::HISTORY_DATE); - //Execute $oDataset = AppHistoryPeer::doSelectRS($c); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); @@ -129,38 +112,37 @@ class AppHistory extends BaseAppHistory { $aDynHistory = array(); $aDynHistory[] = array( - 'DYN_TITLE' => 'char' + 'DYN_TITLE' => 'char' ); while ($aRow = $oDataset->getRow()) { - $o = new Dynaform(); $o->setDynUid($aRow['DYN_UID']); $aRow['DYN_TITLE'] = $o->getDynTitle(); $changedValues=unserialize($aRow['HISTORY_DATA']); $html=""; $sw_add=false; - foreach($changedValues as $key =>$value){ - if(($value!=NULL)&&(!is_array($value))){ + foreach ($changedValues as $key => $value) { + if (($value!=null) && (!is_array($value))) { $sw_add=true; $html.=""; $html.=""; $html.=""; $html.=""; } - if(is_array($value)){ + if (is_array($value)) { $html.=""; $html.=""; $html.="
$key: $value
$key (grid): "; $html.=""; - foreach($value as $key1 =>$value1){ + foreach ($value as $key1 => $value1) { $html.=""; $html.=""; $html.=""; @@ -182,7 +163,7 @@ class AppHistory extends BaseAppHistory { $aRow['FIELDS'] = $html; - if($sw_add){ + if ($sw_add) { $aDynHistory[] = $aRow; } $oDataset->next(); @@ -196,7 +177,6 @@ class AppHistory extends BaseAppHistory { $oCriteria->setDBArrayTable('DynaformsHistory'); $oCriteria->addDescendingOrderByColumn(AppHistoryPeer::HISTORY_DATE); return $oCriteria; - } +} -} // AppHistory diff --git a/workflow/engine/classes/model/AppHistoryPeer.php b/workflow/engine/classes/model/AppHistoryPeer.php index a72252fb0..f20ec1597 100755 --- a/workflow/engine/classes/model/AppHistoryPeer.php +++ b/workflow/engine/classes/model/AppHistoryPeer.php @@ -14,7 +14,7 @@ /** * Skeleton subclass for performing query and update operations on the 'APP_HISTORY' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -22,6 +22,7 @@ * * @package workflow.engine.classes.model */ -class AppHistoryPeer extends BaseAppHistoryPeer { +class AppHistoryPeer extends BaseAppHistoryPeer +{ +} -} // AppHistoryPeer diff --git a/workflow/engine/classes/model/AppMessage.php b/workflow/engine/classes/model/AppMessage.php index a1a31a3ea..03b88fcf0 100755 --- a/workflow/engine/classes/model/AppMessage.php +++ b/workflow/engine/classes/model/AppMessage.php @@ -121,5 +121,4 @@ class AppMessage extends BaseAppMessage } } } -// AppMessage diff --git a/workflow/engine/classes/model/AppMessagePeer.php b/workflow/engine/classes/model/AppMessagePeer.php index 848a68aec..a113f98b1 100755 --- a/workflow/engine/classes/model/AppMessagePeer.php +++ b/workflow/engine/classes/model/AppMessagePeer.php @@ -2,10 +2,10 @@ /** * AppMessagePeer.php * @package workflow.engine.classes.model - * + * * ProcessMaker Open Source Edition * Copyright (C) 2004 - 2011 Colosa Inc. - * + * * 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 @@ -15,13 +15,13 @@ * 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 . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * + * */ // include base peer class @@ -34,7 +34,7 @@ /** * Skeleton subclass for performing query and update operations on the 'APP_MESSAGE' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -42,6 +42,7 @@ * * @package workflow.engine.classes.model */ -class AppMessagePeer extends BaseAppMessagePeer { +class AppMessagePeer extends BaseAppMessagePeer +{ +} -} // AppMessagePeer diff --git a/workflow/engine/classes/model/AppNotes.php b/workflow/engine/classes/model/AppNotes.php index 2edfbf31b..182e2e54a 100755 --- a/workflow/engine/classes/model/AppNotes.php +++ b/workflow/engine/classes/model/AppNotes.php @@ -1,251 +1,233 @@ -clearSelectColumns(); - - $Criteria->addSelectColumn( AppNotesPeer::APP_UID ); - $Criteria->addSelectColumn( AppNotesPeer::USR_UID ); - $Criteria->addSelectColumn( AppNotesPeer::NOTE_DATE ); - $Criteria->addSelectColumn( AppNotesPeer::NOTE_CONTENT ); - $Criteria->addSelectColumn( AppNotesPeer::NOTE_TYPE ); - $Criteria->addSelectColumn( AppNotesPeer::NOTE_AVAILABILITY ); - $Criteria->addSelectColumn( AppNotesPeer::NOTE_ORIGIN_OBJ ); - $Criteria->addSelectColumn( AppNotesPeer::NOTE_AFFECTED_OBJ1 ); - $Criteria->addSelectColumn( AppNotesPeer::NOTE_AFFECTED_OBJ2 ); - $Criteria->addSelectColumn( AppNotesPeer::NOTE_RECIPIENTS ); - $Criteria->addSelectColumn( UsersPeer::USR_USERNAME ); - $Criteria->addSelectColumn( UsersPeer::USR_FIRSTNAME ); - $Criteria->addSelectColumn( UsersPeer::USR_LASTNAME ); - $Criteria->addSelectColumn( UsersPeer::USR_EMAIL ); - - $Criteria->addJoin( AppNotesPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN ); - - $Criteria->add( appNotesPeer::APP_UID, $appUid, CRITERIA::EQUAL ); - - if ($usrUid != '') { - $Criteria->add( appNotesPeer::USR_UID, $usrUid, CRITERIA::EQUAL ); - } - - $Criteria->addDescendingOrderByColumn( AppNotesPeer::NOTE_DATE ); - - $response = array (); - $totalCount = AppNotesPeer::doCount( $Criteria ); - $response['totalCount'] = $totalCount; - $response['notes'] = array (); - - if ($start != '') { - $Criteria->setLimit( $limit ); - $Criteria->setOffset( $start ); - } - - $oDataset = appNotesPeer::doSelectRS( $Criteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - - while ($aRow = $oDataset->getRow()) { - $aRow['NOTE_CONTENT'] = stripslashes( $aRow['NOTE_CONTENT'] ); - $response['notes'][] = $aRow; - $oDataset->next(); - } - - $result['criteria'] = $Criteria; - $result['array'] = $response; - - return $result; - } - - public function postNewNote ($appUid, $usrUid, $noteContent, $notify = true, $noteAvalibility = "PUBLIC", $noteRecipients = "", $noteType = "USER", $noteDate = "now") - { - $this->setAppUid( $appUid ); - $this->setUsrUid( $usrUid ); - $this->setNoteDate( $noteDate ); - $this->setNoteContent( $noteContent ); - $this->setNoteType( $noteType ); - $this->setNoteAvailability( $noteAvalibility ); - $this->setNoteOriginObj( '' ); - $this->setNoteAffectedObj1( '' ); - $this->setNoteAffectedObj2( '' ); - $this->setNoteRecipients( $noteRecipients ); - - if ($this->validate()) { +clearSelectColumns(); + + $Criteria->addSelectColumn( AppNotesPeer::APP_UID ); + $Criteria->addSelectColumn( AppNotesPeer::USR_UID ); + $Criteria->addSelectColumn( AppNotesPeer::NOTE_DATE ); + $Criteria->addSelectColumn( AppNotesPeer::NOTE_CONTENT ); + $Criteria->addSelectColumn( AppNotesPeer::NOTE_TYPE ); + $Criteria->addSelectColumn( AppNotesPeer::NOTE_AVAILABILITY ); + $Criteria->addSelectColumn( AppNotesPeer::NOTE_ORIGIN_OBJ ); + $Criteria->addSelectColumn( AppNotesPeer::NOTE_AFFECTED_OBJ1 ); + $Criteria->addSelectColumn( AppNotesPeer::NOTE_AFFECTED_OBJ2 ); + $Criteria->addSelectColumn( AppNotesPeer::NOTE_RECIPIENTS ); + $Criteria->addSelectColumn( UsersPeer::USR_USERNAME ); + $Criteria->addSelectColumn( UsersPeer::USR_FIRSTNAME ); + $Criteria->addSelectColumn( UsersPeer::USR_LASTNAME ); + $Criteria->addSelectColumn( UsersPeer::USR_EMAIL ); + + $Criteria->addJoin( AppNotesPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN ); + + $Criteria->add( appNotesPeer::APP_UID, $appUid, CRITERIA::EQUAL ); + + if ($usrUid != '') { + $Criteria->add( appNotesPeer::USR_UID, $usrUid, CRITERIA::EQUAL ); + } + + $Criteria->addDescendingOrderByColumn( AppNotesPeer::NOTE_DATE ); + + $response = array (); + $totalCount = AppNotesPeer::doCount( $Criteria ); + $response['totalCount'] = $totalCount; + $response['notes'] = array (); + + if ($start != '') { + $Criteria->setLimit( $limit ); + $Criteria->setOffset( $start ); + } + + $oDataset = appNotesPeer::doSelectRS( $Criteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + + while ($aRow = $oDataset->getRow()) { + $aRow['NOTE_CONTENT'] = stripslashes( $aRow['NOTE_CONTENT'] ); + $response['notes'][] = $aRow; + $oDataset->next(); + } + + $result['criteria'] = $Criteria; + $result['array'] = $response; + + return $result; + } + + public function postNewNote ($appUid, $usrUid, $noteContent, $notify = true, $noteAvalibility = "PUBLIC", $noteRecipients = "", $noteType = "USER", $noteDate = "now") + { + $this->setAppUid( $appUid ); + $this->setUsrUid( $usrUid ); + $this->setNoteDate( $noteDate ); + $this->setNoteContent( $noteContent ); + $this->setNoteType( $noteType ); + $this->setNoteAvailability( $noteAvalibility ); + $this->setNoteOriginObj( '' ); + $this->setNoteAffectedObj1( '' ); + $this->setNoteAffectedObj2( '' ); + $this->setNoteRecipients( $noteRecipients ); + + if ($this->validate()) { // we save it, since we get no validation errors, or do whatever else you like. - $res = $this->save(); - $msg = ''; - } else { + $res = $this->save(); + $msg = ''; + } else { // Something went wrong. We can now get the validationFailures and handle them. - $msg = ''; - $validationFailuresArray = $this->getValidationFailures(); - foreach ($validationFailuresArray as $objValidationFailure) { - $msg .= $objValidationFailure->getMessage() . "
"; - } - //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); - } - if ($msg != "") { - $response['success'] = 'failure'; - $response['message'] = $msg; - } else { - $response['success'] = 'success'; - $response['message'] = 'Saved...'; - } - - if ($notify) { - if ($noteRecipients == "") { - $noteRecipientsA = array (); - G::LoadClass( 'case' ); - $oCase = new Cases(); - $p = $oCase->getUsersParticipatedInCase( $appUid ); - foreach ($p['array'] as $key => $userParticipated) { - $noteRecipientsA[] = $key; - } - $noteRecipients = implode( ",", $noteRecipientsA ); - } - - $this->sendNoteNotification( $appUid, $usrUid, $noteContent, $noteRecipients ); - } - - return $response; - } - - public function sendNoteNotification ($appUid, $usrUid, $noteContent, $noteRecipients, $sFrom = "") - { - try { - require_once ('classes/model/Configuration.php'); - $oConfiguration = new Configuration(); - $sDelimiter = DBAdapter::getStringDelimiter(); - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->add( ConfigurationPeer::CFG_UID, 'Emails' ); - $oCriteria->add( ConfigurationPeer::OBJ_UID, '' ); - $oCriteria->add( ConfigurationPeer::PRO_UID, '' ); - $oCriteria->add( ConfigurationPeer::USR_UID, '' ); - $oCriteria->add( ConfigurationPeer::APP_UID, '' ); - if (ConfigurationPeer::doCount( $oCriteria ) == 0) { - $oConfiguration->create( array ('CFG_UID' => 'Emails','OBJ_UID' => '','CFG_VALUE' => '','PRO_UID' => '','USR_UID' => '','APP_UID' => '') ); - $aConfiguration = array (); - } else { - $aConfiguration = $oConfiguration->load( 'Emails', '', '', '', '' ); - if ($aConfiguration['CFG_VALUE'] != '') { - $aConfiguration = unserialize( $aConfiguration['CFG_VALUE'] ); - $passwd = $aConfiguration['MESS_PASSWORD']; - $passwdDec = G::decrypt( $passwd, 'EMAILENCRYPT' ); - $auxPass = explode( 'hash:', $passwdDec ); - if (count( $auxPass ) > 1) { - if (count( $auxPass ) == 2) { - $passwd = $auxPass[1]; - } else { - array_shift( $auxPass ); - $passwd = implode( '', $auxPass ); - } - } - $aConfiguration['MESS_PASSWORD'] = $passwd; - } else { - $aConfiguration = array (); - } - } - - if (! isset( $aConfiguration['MESS_ENABLED'] ) || $aConfiguration['MESS_ENABLED'] != '1') { - return false; - } - - $oUser = new Users(); - $aUser = $oUser->load( $usrUid ); - $authorName = ((($aUser['USR_FIRSTNAME'] != '') || ($aUser['USR_LASTNAME'] != '')) ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>'; - - G::LoadClass( 'case' ); - $oCase = new Cases(); - $aFields = $oCase->loadCase( $appUid ); - $configNoteNotification['subject'] = G::LoadTranslation( 'ID_MESSAGE_SUBJECT_NOTE_NOTIFICATION' ) . " @#APP_TITLE "; - $configNoteNotification['body'] = G::LoadTranslation( 'ID_CASE' ) . ": @#APP_TITLE
" . G::LoadTranslation( 'ID_AUTHOR' ) . ": $authorName

$noteContent"; - - if ($sFrom == '') { - $sFrom = '"ProcessMaker"'; - } - - $hasEmailFrom = preg_match( '/(.+)@(.+)\.(.+)/', $sFrom, $match ); - - if (! $hasEmailFrom || strpos( $sFrom, $aConfiguration['MESS_ACCOUNT'] ) === false) { - if (($aConfiguration['MESS_ENGINE'] != 'MAIL') && ($aConfiguration['MESS_ACCOUNT'] != '')) { - $sFrom .= ' <' . $aConfiguration['MESS_ACCOUNT'] . '>'; - } else { - if (($aConfiguration['MESS_ENGINE'] == 'MAIL')) { - $sFrom .= ' '; - } else { - if ($aConfiguration['MESS_SERVER'] != '') { - if (($sAux = @gethostbyaddr( $aConfiguration['MESS_SERVER'] ))) { - $sFrom .= ' '; - } else { - $sFrom .= ' '; - } - } else { - $sFrom .= ' '; - } - } - } - } - - $sSubject = G::replaceDataField( $configNoteNotification['subject'], $aFields ); - - //erik: new behaviour for messages - //G::loadClass('configuration'); - //$oConf = new Configurations; - //$oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', ''); - //$conf = $oConf->aConfig; - /* - if( isset($conf['TAS_DEF_MESSAGE_TYPE']) && isset($conf['TAS_DEF_MESSAGE_TEMPLATE']) - && $conf['TAS_DEF_MESSAGE_TYPE'] == 'template' && $conf['TAS_DEF_MESSAGE_TEMPLATE'] != '') { - - $pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $aTaskInfo['PRO_UID'] . PATH_SEP; - $fileTemplate = $pathEmail . $conf['TAS_DEF_MESSAGE_TEMPLATE']; - - if ( ! file_exists ( $fileTemplate ) ) { - throw new Exception("Template file '$fileTemplate' does not exist."); + $msg = ''; + $validationFailuresArray = $this->getValidationFailures(); + foreach ($validationFailuresArray as $objValidationFailure) { + $msg .= $objValidationFailure->getMessage() . "
"; + } + //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); + } + if ($msg != "") { + $response['success'] = 'failure'; + $response['message'] = $msg; + } else { + $response['success'] = 'success'; + $response['message'] = 'Saved...'; + } + + if ($notify) { + if ($noteRecipients == "") { + $noteRecipientsA = array (); + G::LoadClass( 'case' ); + $oCase = new Cases(); + $p = $oCase->getUsersParticipatedInCase( $appUid ); + foreach ($p['array'] as $key => $userParticipated) { + $noteRecipientsA[] = $key; + } + $noteRecipients = implode( ",", $noteRecipientsA ); + } + + $this->sendNoteNotification( $appUid, $usrUid, $noteContent, $noteRecipients ); + } + + return $response; + } + + public function sendNoteNotification ($appUid, $usrUid, $noteContent, $noteRecipients, $sFrom = "") + { + try { + require_once ('classes/model/Configuration.php'); + $oConfiguration = new Configuration(); + $sDelimiter = DBAdapter::getStringDelimiter(); + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->add( ConfigurationPeer::CFG_UID, 'Emails' ); + $oCriteria->add( ConfigurationPeer::OBJ_UID, '' ); + $oCriteria->add( ConfigurationPeer::PRO_UID, '' ); + $oCriteria->add( ConfigurationPeer::USR_UID, '' ); + $oCriteria->add( ConfigurationPeer::APP_UID, '' ); + if (ConfigurationPeer::doCount( $oCriteria ) == 0) { + $oConfiguration->create( array ('CFG_UID' => 'Emails','OBJ_UID' => '','CFG_VALUE' => '','PRO_UID' => '','USR_UID' => '','APP_UID' => '') ); + $aConfiguration = array (); + } else { + $aConfiguration = $oConfiguration->load( 'Emails', '', '', '', '' ); + if ($aConfiguration['CFG_VALUE'] != '') { + $aConfiguration = unserialize( $aConfiguration['CFG_VALUE'] ); + $passwd = $aConfiguration['MESS_PASSWORD']; + $passwdDec = G::decrypt( $passwd, 'EMAILENCRYPT' ); + $auxPass = explode( 'hash:', $passwdDec ); + if (count( $auxPass ) > 1) { + if (count( $auxPass ) == 2) { + $passwd = $auxPass[1]; + } else { + array_shift( $auxPass ); + $passwd = implode( '', $auxPass ); + } + } + $aConfiguration['MESS_PASSWORD'] = $passwd; + } else { + $aConfiguration = array (); + } + } + + if (! isset( $aConfiguration['MESS_ENABLED'] ) || $aConfiguration['MESS_ENABLED'] != '1') { + return false; + } + + $oUser = new Users(); + $aUser = $oUser->load( $usrUid ); + $authorName = ((($aUser['USR_FIRSTNAME'] != '') || ($aUser['USR_LASTNAME'] != '')) ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>'; + + G::LoadClass( 'case' ); + $oCase = new Cases(); + $aFields = $oCase->loadCase( $appUid ); + $configNoteNotification['subject'] = G::LoadTranslation( 'ID_MESSAGE_SUBJECT_NOTE_NOTIFICATION' ) . " @#APP_TITLE "; + $configNoteNotification['body'] = G::LoadTranslation( 'ID_CASE' ) . ": @#APP_TITLE
" . G::LoadTranslation( 'ID_AUTHOR' ) . ": $authorName

$noteContent"; + + if ($sFrom == '') { + $sFrom = '"ProcessMaker"'; + } + + $hasEmailFrom = preg_match( '/(.+)@(.+)\.(.+)/', $sFrom, $match ); + + if (! $hasEmailFrom || strpos( $sFrom, $aConfiguration['MESS_ACCOUNT'] ) === false) { + if (($aConfiguration['MESS_ENGINE'] != 'MAIL') && ($aConfiguration['MESS_ACCOUNT'] != '')) { + $sFrom .= ' <' . $aConfiguration['MESS_ACCOUNT'] . '>'; + } else { + if (($aConfiguration['MESS_ENGINE'] == 'MAIL')) { + $sFrom .= ' '; + } else { + if ($aConfiguration['MESS_SERVER'] != '') { + if (($sAux = @gethostbyaddr( $aConfiguration['MESS_SERVER'] ))) { + $sFrom .= ' '; + } else { + $sFrom .= ' '; + } + } else { + $sFrom .= ' '; + } + } + } + } + + $sSubject = G::replaceDataField( $configNoteNotification['subject'], $aFields ); + + $sBody = nl2br( G::replaceDataField( $configNoteNotification['body'], $aFields ) ); + + G::LoadClass( 'spool' ); + $oUser = new Users(); + $recipientsArray = explode( ",", $noteRecipients ); + + foreach ($recipientsArray as $recipientUid) { + + $aUser = $oUser->load( $recipientUid ); + + $sTo = ((($aUser['USR_FIRSTNAME'] != '') || ($aUser['USR_LASTNAME'] != '')) ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>'; + $oSpool = new spoolRun(); + $oSpool->setConfig( array ('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'],'MESS_SERVER' => $aConfiguration['MESS_SERVER'],'MESS_PORT' => $aConfiguration['MESS_PORT'],'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'],'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'],'SMTPAuth' => $aConfiguration['MESS_RAUTH'] == '1' ? true : false,'SMTPSecure' => isset( $aConfiguration['SMTPSecure'] ) ? $aConfiguration['SMTPSecure'] : '') ); + $oSpool->create( array ('msg_uid' => '','app_uid' => $appUid,'del_index' => 1,'app_msg_type' => 'DERIVATION','app_msg_subject' => $sSubject,'app_msg_from' => $sFrom,'app_msg_to' => $sTo,'app_msg_body' => $sBody,'app_msg_cc' => '','app_msg_bcc' => '','app_msg_attach' => '','app_msg_template' => '','app_msg_status' => 'pending') ); + if (($aConfiguration['MESS_BACKGROUND'] == '') || ($aConfiguration['MESS_TRY_SEND_INMEDIATLY'] == '1')) { + $oSpool->sendMail(); + } + } - $sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields); - } else {*/ - $sBody = nl2br( G::replaceDataField( $configNoteNotification['body'], $aFields ) ); - /*}*/ - G::LoadClass( 'spool' ); - $oUser = new Users(); - $recipientsArray = explode( ",", $noteRecipients ); - - foreach ($recipientsArray as $recipientUid) { - - $aUser = $oUser->load( $recipientUid ); - - $sTo = ((($aUser['USR_FIRSTNAME'] != '') || ($aUser['USR_LASTNAME'] != '')) ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>'; - $oSpool = new spoolRun(); - $oSpool->setConfig( array ('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'],'MESS_SERVER' => $aConfiguration['MESS_SERVER'],'MESS_PORT' => $aConfiguration['MESS_PORT'],'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'],'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'],'SMTPAuth' => $aConfiguration['MESS_RAUTH'] == '1' ? true : false,'SMTPSecure' => isset( $aConfiguration['SMTPSecure'] ) ? $aConfiguration['SMTPSecure'] : '') ); - $oSpool->create( array ('msg_uid' => '','app_uid' => $appUid,'del_index' => 1,'app_msg_type' => 'DERIVATION','app_msg_subject' => $sSubject,'app_msg_from' => $sFrom,'app_msg_to' => $sTo,'app_msg_body' => $sBody,'app_msg_cc' => '','app_msg_bcc' => '','app_msg_attach' => '','app_msg_template' => '','app_msg_status' => 'pending') ); - if (($aConfiguration['MESS_BACKGROUND'] == '') || ($aConfiguration['MESS_TRY_SEND_INMEDIATLY'] == '1')) { - $oSpool->sendMail(); - } - - } //Send derivation notification - End - } catch (Exception $oException) { - throw $oException; - } - } -} - + } catch (Exception $oException) { + throw $oException; + } + } +} + diff --git a/workflow/engine/classes/model/AppNotesPeer.php b/workflow/engine/classes/model/AppNotesPeer.php index 66af0ff2a..5641493a3 100755 --- a/workflow/engine/classes/model/AppNotesPeer.php +++ b/workflow/engine/classes/model/AppNotesPeer.php @@ -10,7 +10,7 @@ /** * Skeleton subclass for performing query and update operations on the 'APP_NOTES' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -18,6 +18,7 @@ * * @package classes.model */ -class AppNotesPeer extends BaseAppNotesPeer { +class AppNotesPeer extends BaseAppNotesPeer +{ +} -} // AppNotesPeer diff --git a/workflow/engine/classes/model/AppOwner.php b/workflow/engine/classes/model/AppOwner.php index ae4d4c5d4..afb1b3c5d 100755 --- a/workflow/engine/classes/model/AppOwner.php +++ b/workflow/engine/classes/model/AppOwner.php @@ -2,10 +2,10 @@ /** * AppOwner.php * @package workflow.engine.classes.model - * + * * ProcessMaker Open Source Edition * Copyright (C) 2004 - 2011 Colosa Inc. - * + * * 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 @@ -15,13 +15,13 @@ * 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 . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * + * */ require_once 'classes/model/om/BaseAppOwner.php'; @@ -30,7 +30,7 @@ require_once 'classes/model/om/BaseAppOwner.php'; /** * Skeleton subclass for representing a row from the 'APP_OWNER' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -38,6 +38,7 @@ require_once 'classes/model/om/BaseAppOwner.php'; * * @package workflow.engine.classes.model */ -class AppOwner extends BaseAppOwner { +class AppOwner extends BaseAppOwner +{ +} -} // AppOwner diff --git a/workflow/engine/classes/model/AppOwnerPeer.php b/workflow/engine/classes/model/AppOwnerPeer.php index 6b46cbd73..3724aead0 100755 --- a/workflow/engine/classes/model/AppOwnerPeer.php +++ b/workflow/engine/classes/model/AppOwnerPeer.php @@ -2,10 +2,10 @@ /** * AppOwnerPeer.php * @package workflow.engine.classes.model - * + * * ProcessMaker Open Source Edition * Copyright (C) 2004 - 2011 Colosa Inc. - * + * * 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 @@ -15,13 +15,13 @@ * 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 . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * + * */ // include base peer class @@ -34,7 +34,7 @@ /** * Skeleton subclass for performing query and update operations on the 'APP_OWNER' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -42,6 +42,7 @@ * * @package workflow.engine.classes.model */ -class AppOwnerPeer extends BaseAppOwnerPeer { +class AppOwnerPeer extends BaseAppOwnerPeer +{ +} -} // AppOwnerPeer diff --git a/workflow/engine/classes/model/AppSolrQueue.php b/workflow/engine/classes/model/AppSolrQueue.php index f8d0445fd..834adf91c 100644 --- a/workflow/engine/classes/model/AppSolrQueue.php +++ b/workflow/engine/classes/model/AppSolrQueue.php @@ -7,7 +7,7 @@ require_once 'classes/entities/AppSolrQueue.php'; /** * Skeleton subclass for representing a row from the 'APP_SOLR_QUEUE' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -15,112 +15,100 @@ require_once 'classes/entities/AppSolrQueue.php'; * * @package classes.model */ -class AppSolrQueue extends BaseAppSolrQueue { - - public function exists($sAppUid) - { - try { - $oRow = AppSolrQueuePeer::retrieveByPK( $sAppUid ); - if (!is_null($oRow)) - { - return true; - } - else { - return false; - } - } - catch (Exception $oError) { - return false; - } +class AppSolrQueue extends BaseAppSolrQueue +{ + public function exists($sAppUid) + { + try { + $oRow = AppSolrQueuePeer::retrieveByPK( $sAppUid ); + if (!is_null($oRow)) { + return true; + } else { + return false; + } + } catch (Exception $oError) { + return false; + } } - public function createUpdate($sAppUid, $iUpdated) - { - $con = Propel::getConnection(AppSolrQueuePeer::DATABASE_NAME); - try - { - if($this->exists($sAppUid)){ + public function createUpdate($sAppUid, $iUpdated) + { + $con = Propel::getConnection(AppSolrQueuePeer::DATABASE_NAME); + try { + if ($this->exists($sAppUid)) { $con->begin(); //update record //$oRow = AppSolrQueuePeer::retrieveByPK( $sAppUid ); - //$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME); - //$this->fromArray($aFields,BasePeer::TYPE_FIELDNAME); + //$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME); + //$this->fromArray($aFields,BasePeer::TYPE_FIELDNAME); $this->setNew(false); //set field $this->setAppUid($sAppUid); $this->setAppUpdated($iUpdated); - if($this->validate()) - { - $result=$this->save(); - } - else - { - $con->rollback(); - throw(new Exception("Failed Validation in class ".get_class($this).".")); + if ($this->validate()) { + $result=$this->save(); + } else { + $con->rollback(); + throw(new Exception("Failed Validation in class ".get_class($this).".")); } - $con->commit(); - return $result; - }else{ + $con->commit(); + return $result; + } else { //create record //set values $this->setAppUid($sAppUid); $this->setAppUpdated($iUpdated); - if($this->validate()) - { - $result=$this->save(); - } - else - { - $e=new Exception("Failed Validation in class ".get_class($this)."."); - //$e->aValidationFailures=$this->getValidationFailures(); - throw($e); - } - $con->commit(); - return $result; - } - } - catch(Exception $e) - { - $con->rollback(); - throw($e); - } + if ($this->validate()) { + $result=$this->save(); + } else { + $e=new Exception("Failed Validation in class ".get_class($this)."."); + //$e->aValidationFailures=$this->getValidationFailures(); + throw($e); + } + $con->commit(); + return $result; + } + } catch (Exception $e) { + $con->rollback(); + throw($e); + } } - + /** * Returns the list of updated applications * array of Entity_AppSolrQueue */ - public function getListUpdatedApplications(){ - $updatedApplications = array(); - try - { - $c = new Criteria(); - - $c->addSelectColumn(AppSolrQueuePeer::APP_UID); - $c->addSelectColumn(AppSolrQueuePeer::APP_UPDATED); - - //"WHERE + public function getListUpdatedApplications() + { + $updatedApplications = array(); + try { + $c = new Criteria(); + + $c->addSelectColumn(AppSolrQueuePeer::APP_UID); + $c->addSelectColumn(AppSolrQueuePeer::APP_UPDATED); + + //"WHERE $c->add(AppSolrQueuePeer::APP_UPDATED, 0, Criteria::NOT_EQUAL); - - $rs = AppSolrQueuePeer::doSelectRS($c); - $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); - //echo $c->toString(); - $rs->next(); - $row = $rs->getRow(); - + + $rs = AppSolrQueuePeer::doSelectRS($c); + $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); + //echo $c->toString(); + $rs->next(); + $row = $rs->getRow(); + while (is_array($row)) { $appSolrQueue = Entity_AppSolrQueue::createEmpty(); $appSolrQueue->appUid = $row['APP_UID']; $appSolrQueue->appUpdated = $row['APP_UPDATED']; - $updatedApplications[] = $appSolrQueue; - $rs->next(); - $row = $rs->getRow(); + $updatedApplications[] = $appSolrQueue; + $rs->next(); + $row = $rs->getRow(); } - return $updatedApplications; - }catch(Exception $e){ - $con->rollback(); + } catch (Exception $e) { + $con->rollback(); throw($e); } } -} // AppSolrQueue +} + diff --git a/workflow/engine/classes/model/AppSolrQueuePeer.php b/workflow/engine/classes/model/AppSolrQueuePeer.php index cf47a3f95..389e764ad 100644 --- a/workflow/engine/classes/model/AppSolrQueuePeer.php +++ b/workflow/engine/classes/model/AppSolrQueuePeer.php @@ -10,7 +10,7 @@ /** * Skeleton subclass for performing query and update operations on the 'APP_SOLR_QUEUE' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -18,6 +18,7 @@ * * @package classes.model */ -class AppSolrQueuePeer extends BaseAppSolrQueuePeer { +class AppSolrQueuePeer extends BaseAppSolrQueuePeer +{ +} -} // AppSolrQueuePeer diff --git a/workflow/engine/classes/model/AppThread.php b/workflow/engine/classes/model/AppThread.php index 5ce05ebb8..beb7946bc 100755 --- a/workflow/engine/classes/model/AppThread.php +++ b/workflow/engine/classes/model/AppThread.php @@ -2,10 +2,10 @@ /** * AppThread.php * @package workflow.engine.classes.model - * + * * ProcessMaker Open Source Edition * Copyright (C) 2004 - 2011 Colosa Inc. - * + * * 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 @@ -15,13 +15,13 @@ * 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 . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * + * */ require_once 'classes/model/om/BaseAppThread.php'; @@ -30,7 +30,7 @@ require_once 'classes/model/om/BaseAppThread.php'; /** * Skeleton subclass for representing a row from the 'APP_THREAD' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -38,85 +38,81 @@ require_once 'classes/model/om/BaseAppThread.php'; * * @package workflow.engine.classes.model */ -class AppThread extends BaseAppThread { - - function createAppThread ( $sAppUid, $iDelIndex, $iParent ) { - if (!isset($sAppUid) || strlen($sAppUid ) == 0 ) { - throw ( new Exception ( 'Column "APP_UID" cannot be null.' ) ); - } - - if (!isset($iDelIndex) || strlen($iDelIndex ) == 0 ) { - throw ( new Exception ( 'Column "DEL_INDEX" cannot be null.' ) ); - } - - if (!isset($iParent) || strlen($iDelIndex ) == 0 ) { - throw ( new Exception ( 'Column "APP_THREAD_INDEX" cannot be null.' ) ); - } - - $c = new Criteria (); - $c->clearSelectColumns(); - $c->addSelectColumn ( 'MAX(' . AppThreadPeer::APP_THREAD_INDEX . ') ' ); - $c->add ( AppThreadPeer::APP_UID, $sAppUid ); - $rs = AppThreadPeer::doSelectRS ( $c ); - $rs->next(); - $row = $rs->getRow(); - $iAppThreadIndex = $row[0] + 1; - - $this->setAppUid ( $sAppUid ); - $this->setAppThreadIndex ( $iAppThreadIndex ); - $this->setAppThreadParent ( $iParent ); - $this->setAppThreadStatus ( 'OPEN' ); - $this->setDelIndex ( $iDelIndex ); - - if ($this->validate() ) { - try { - $res = $this->save(); - } - catch ( PropelException $e ) { - throw ( $e ); - } - } - else { - // Something went wrong. We can now get the validationFailures and handle them. - $msg = ''; - $validationFailuresArray = $this->getValidationFailures(); - foreach($validationFailuresArray as $objValidationFailure) { - $msg .= $objValidationFailure->getMessage(); - } - throw ( new Exception ( 'Failed Data validation. ' . $msg ) ); - } - return $iAppThreadIndex; - } - - public function update($aData) - { - $con = Propel::getConnection( AppThreadPeer::DATABASE_NAME ); - try { - $con->begin(); - $oApp = AppThreadPeer::retrieveByPK( $aData['APP_UID'], $aData['APP_THREAD_INDEX'] ); - if (is_object($oApp) && get_class ($oApp) == 'AppThread' ) { - $oApp->fromArray( $aData, BasePeer::TYPE_FIELDNAME ); - if ($oApp->validate()) { - $res = $oApp->save(); - $con->commit(); - return $res; +class AppThread extends BaseAppThread +{ + public function createAppThread ($sAppUid, $iDelIndex, $iParent) + { + if (!isset($sAppUid) || strlen($sAppUid ) == 0 ) { + throw ( new Exception ( 'Column "APP_UID" cannot be null.' ) ); } - else { - $msg = ''; - foreach($this->getValidationFailures() as $objValidationFailure) - $msg .= $objValidationFailure->getMessage() . "
"; - - throw ( new PropelException ( 'The AppThread row cannot be created!', new PropelException ( $msg ) ) ); - } - } - else { - $con->rollback(); - throw(new Exception( "This AppThread row doesn't exist!" )); - } - } - catch (Exception $oError) { - throw($oError); - } - } -} // AppThread + if (!isset($iDelIndex) || strlen($iDelIndex ) == 0 ) { + throw ( new Exception ( 'Column "DEL_INDEX" cannot be null.' ) ); + } + + if (!isset($iParent) || strlen($iDelIndex ) == 0 ) { + throw ( new Exception ( 'Column "APP_THREAD_INDEX" cannot be null.' ) ); + } + + $c = new Criteria (); + $c->clearSelectColumns(); + $c->addSelectColumn ( 'MAX(' . AppThreadPeer::APP_THREAD_INDEX . ') ' ); + $c->add ( AppThreadPeer::APP_UID, $sAppUid ); + $rs = AppThreadPeer::doSelectRS ( $c ); + $rs->next(); + $row = $rs->getRow(); + $iAppThreadIndex = $row[0] + 1; + + $this->setAppUid ( $sAppUid ); + $this->setAppThreadIndex ( $iAppThreadIndex ); + $this->setAppThreadParent ( $iParent ); + $this->setAppThreadStatus ( 'OPEN' ); + $this->setDelIndex ( $iDelIndex ); + + if ($this->validate() ) { + try { + $res = $this->save(); + } catch ( PropelException $e ) { + throw ( $e ); + } + } else { + // Something went wrong. We can now get the validationFailures and handle them. + $msg = ''; + $validationFailuresArray = $this->getValidationFailures(); + foreach ($validationFailuresArray as $objValidationFailure) { + $msg .= $objValidationFailure->getMessage(); + } + throw ( new Exception ( 'Failed Data validation. ' . $msg ) ); + } + return $iAppThreadIndex; + } + + public function update($aData) + { + $con = Propel::getConnection( AppThreadPeer::DATABASE_NAME ); + try { + $con->begin(); + $oApp = AppThreadPeer::retrieveByPK( $aData['APP_UID'], $aData['APP_THREAD_INDEX'] ); + if (is_object($oApp) && get_class ($oApp) == 'AppThread' ) { + $oApp->fromArray( $aData, BasePeer::TYPE_FIELDNAME ); + if ($oApp->validate()) { + $res = $oApp->save(); + $con->commit(); + return $res; + } else { + $msg = ''; + foreach ($this->getValidationFailures() as $objValidationFailure) { + $msg .= $objValidationFailure->getMessage() . "
"; + } + throw ( new PropelException ( 'The AppThread row cannot be created!', new PropelException ( $msg ) ) ); + } + } else { + $con->rollback(); + throw(new Exception( "This AppThread row doesn't exist!" )); + } + } catch (Exception $oError) { + throw($oError); + } + } +} + diff --git a/workflow/engine/classes/model/AppThreadPeer.php b/workflow/engine/classes/model/AppThreadPeer.php index 6820a1e65..bb5483c79 100755 --- a/workflow/engine/classes/model/AppThreadPeer.php +++ b/workflow/engine/classes/model/AppThreadPeer.php @@ -2,10 +2,10 @@ /** * AppThreadPeer.php * @package workflow.engine.classes.model - * + * * ProcessMaker Open Source Edition * Copyright (C) 2004 - 2011 Colosa Inc. - * + * * 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 @@ -15,13 +15,13 @@ * 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 . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * + * */ // include base peer class @@ -34,7 +34,7 @@ /** * Skeleton subclass for performing query and update operations on the 'APP_THREAD' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -42,6 +42,7 @@ * * @package workflow.engine.classes.model */ -class AppThreadPeer extends BaseAppThreadPeer { +class AppThreadPeer extends BaseAppThreadPeer +{ +} -} // AppThreadPeer diff --git a/workflow/engine/classes/model/ApplicationPeer.php b/workflow/engine/classes/model/ApplicationPeer.php index 44f602f02..c4d029fa4 100755 --- a/workflow/engine/classes/model/ApplicationPeer.php +++ b/workflow/engine/classes/model/ApplicationPeer.php @@ -2,10 +2,10 @@ /** * ApplicationPeer.php * @package workflow.engine.classes.model - * + * * ProcessMaker Open Source Edition * Copyright (C) 2004 - 2011 Colosa Inc. - * + * * 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 @@ -15,13 +15,13 @@ * 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 . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * + * */ // include base peer class @@ -34,7 +34,7 @@ /** * Skeleton subclass for performing query and update operations on the 'APPLICATION' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -42,6 +42,7 @@ * * @package workflow.engine.classes.model */ -class ApplicationPeer extends BaseApplicationPeer { +class ApplicationPeer extends BaseApplicationPeer +{ +} -} // ApplicationPeer diff --git a/workflow/engine/classes/model/CalendarAssignments.php b/workflow/engine/classes/model/CalendarAssignments.php index 05d416d14..47479d3ec 100755 --- a/workflow/engine/classes/model/CalendarAssignments.php +++ b/workflow/engine/classes/model/CalendarAssignments.php @@ -10,7 +10,7 @@ require_once 'classes/model/om/BaseCalendarAssignments.php'; /** * Skeleton subclass for representing a row from the 'CALENDAR_ASSIGNMENTS' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -18,6 +18,7 @@ require_once 'classes/model/om/BaseCalendarAssignments.php'; * * @package workflow.engine.classes.model */ -class CalendarAssignments extends BaseCalendarAssignments { +class CalendarAssignments extends BaseCalendarAssignments +{ +} -} // CalendarAssignments diff --git a/workflow/engine/classes/model/CalendarAssignmentsPeer.php b/workflow/engine/classes/model/CalendarAssignmentsPeer.php index e0da33600..a0126bc7a 100755 --- a/workflow/engine/classes/model/CalendarAssignmentsPeer.php +++ b/workflow/engine/classes/model/CalendarAssignmentsPeer.php @@ -14,7 +14,7 @@ /** * Skeleton subclass for performing query and update operations on the 'CALENDAR_ASSIGNMENTS' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -22,6 +22,7 @@ * * @package workflow.engine.classes.model */ -class CalendarAssignmentsPeer extends BaseCalendarAssignmentsPeer { +class CalendarAssignmentsPeer extends BaseCalendarAssignmentsPeer +{ +} -} // CalendarAssignmentsPeer diff --git a/workflow/engine/classes/model/CalendarBusinessHours.php b/workflow/engine/classes/model/CalendarBusinessHours.php index ab66fec4d..44ea4b247 100755 --- a/workflow/engine/classes/model/CalendarBusinessHours.php +++ b/workflow/engine/classes/model/CalendarBusinessHours.php @@ -10,7 +10,7 @@ require_once 'classes/model/om/BaseCalendarBusinessHours.php'; /** * Skeleton subclass for representing a row from the 'CALENDAR_BUSINESS_HOURS' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -18,94 +18,84 @@ require_once 'classes/model/om/BaseCalendarBusinessHours.php'; * * @package workflow.engine.classes.model */ -class CalendarBusinessHours extends BaseCalendarBusinessHours { - function getCalendarBusinessHours($CalendarUid){ - $Criteria = new Criteria('workflow'); - $Criteria->clearSelectColumns ( ); - - $Criteria->addSelectColumn ( CalendarBusinessHoursPeer::CALENDAR_UID ); - $Criteria->addSelectColumn ( CalendarBusinessHoursPeer::CALENDAR_BUSINESS_DAY ); - $Criteria->addSelectColumn ( CalendarBusinessHoursPeer::CALENDAR_BUSINESS_START ); - $Criteria->addSelectColumn ( CalendarBusinessHoursPeer::CALENDAR_BUSINESS_END ); - - - - $Criteria->add ( CalendarBusinessHoursPeer::CALENDAR_UID, $CalendarUid , CRITERIA::EQUAL ); - $Criteria->addDescendingOrderByColumn ( CalendarBusinessHoursPeer::CALENDAR_BUSINESS_DAY ); - $Criteria->addAscendingOrderByColumn ( CalendarBusinessHoursPeer::CALENDAR_BUSINESS_START ); - //$Criteria->addDescendingOrderByColumn ( CalendarBusinessHoursPeer::CALENDAR_BUSINESS_START ); - - $rs = CalendarBusinessHoursPeer::doSelectRS($Criteria); - $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $rs->next(); - $row = $rs->getRow(); - - $fields=array(); - $count=0; +class CalendarBusinessHours extends BaseCalendarBusinessHours +{ + public function getCalendarBusinessHours($CalendarUid) + { + $Criteria = new Criteria('workflow'); + $Criteria->clearSelectColumns ( ); - while (is_array($row)) { - $count++; - $fields[$count] = $row; + $Criteria->addSelectColumn ( CalendarBusinessHoursPeer::CALENDAR_UID ); + $Criteria->addSelectColumn ( CalendarBusinessHoursPeer::CALENDAR_BUSINESS_DAY ); + $Criteria->addSelectColumn ( CalendarBusinessHoursPeer::CALENDAR_BUSINESS_START ); + $Criteria->addSelectColumn ( CalendarBusinessHoursPeer::CALENDAR_BUSINESS_END ); + + $Criteria->add ( CalendarBusinessHoursPeer::CALENDAR_UID, $CalendarUid , CRITERIA::EQUAL ); + $Criteria->addDescendingOrderByColumn ( CalendarBusinessHoursPeer::CALENDAR_BUSINESS_DAY ); + $Criteria->addAscendingOrderByColumn ( CalendarBusinessHoursPeer::CALENDAR_BUSINESS_START ); + + $rs = CalendarBusinessHoursPeer::doSelectRS($Criteria); + $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); $rs->next(); $row = $rs->getRow(); - } - return $fields; - } - function deleteAllCalendarBusinessHours($CalendarUid){ - $toDelete=$this->getCalendarBusinessHours($CalendarUid); - foreach($toDelete as $key => $businessHoursInfo){ - $CalendarUid = $businessHoursInfo['CALENDAR_UID']; - $CalendarBusinessDay = $businessHoursInfo['CALENDAR_BUSINESS_DAY']; - $CalendarBusinessStart = $businessHoursInfo['CALENDAR_BUSINESS_START']; - $CalendarBusinessEnd = $businessHoursInfo['CALENDAR_BUSINESS_END']; - //if exists the row in the database propel will update it, otherwise will insert. - $tr = CalendarBusinessHoursPeer::retrieveByPK ( $CalendarUid,$CalendarBusinessDay, $CalendarBusinessStart,$CalendarBusinessEnd ); - if ( ( is_object ( $tr ) && get_class ($tr) == 'CalendarBusinessHours' ) ) { - $tr->delete(); - } + $fields=array(); + $count=0; + while (is_array($row)) { + $count++; + $fields[$count] = $row; + $rs->next(); + $row = $rs->getRow(); + } + return $fields; } - - } - function saveCalendarBusinessHours($aData){ - $CalendarUid = $aData['CALENDAR_UID']; - $CalendarBusinessDay = $aData['CALENDAR_BUSINESS_DAY']; - $CalendarBusinessStart = $aData['CALENDAR_BUSINESS_START']; - $CalendarBusinessEnd = $aData['CALENDAR_BUSINESS_END']; - - //if exists the row in the database propel will update it, otherwise will insert. - $tr = CalendarBusinessHoursPeer::retrieveByPK ( $CalendarUid,$CalendarBusinessDay, $CalendarBusinessStart,$CalendarBusinessEnd ); - if ( ! ( is_object ( $tr ) && get_class ($tr) == 'CalendarBusinessHours' ) ) { - $tr = new CalendarBusinessHours(); - } - $tr->setCalendarUid( $CalendarUid ); - $tr->setCalendarBusinessDay( $CalendarBusinessDay ); - $tr->setCalendarBusinessStart( $CalendarBusinessStart ); - $tr->setCalendarBusinessEnd( $CalendarBusinessEnd ); - - - if ($tr->validate() ) { - // we save it, since we get no validation errors, or do whatever else you like. - $res = $tr->save(); - } - else { - // Something went wrong. We can now get the validationFailures and handle them. - $msg = $CalendarBusinessDay.'
'; - $validationFailuresArray = $tr->getValidationFailures(); - foreach($validationFailuresArray as $objValidationFailure) { - $msg .= $objValidationFailure->getMessage() . "
"; - } - //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); - G::SendTemporalMessage($msg); - } - - //return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => ''); - - //to do: uniform coderror structures for all classes - - //if ( $res['codError'] < 0 ) { - // G::SendMessageText ( $res['message'] , 'error' ); - //} - } + public function deleteAllCalendarBusinessHours($CalendarUid) + { + $toDelete = $this->getCalendarBusinessHours($CalendarUid); + foreach ($toDelete as $key => $businessHoursInfo) { + $CalendarUid = $businessHoursInfo['CALENDAR_UID']; + $CalendarBusinessDay = $businessHoursInfo['CALENDAR_BUSINESS_DAY']; + $CalendarBusinessStart = $businessHoursInfo['CALENDAR_BUSINESS_START']; + $CalendarBusinessEnd = $businessHoursInfo['CALENDAR_BUSINESS_END']; + //if exists the row in the database propel will update it, otherwise will insert. + $tr = CalendarBusinessHoursPeer::retrieveByPK ( $CalendarUid,$CalendarBusinessDay, $CalendarBusinessStart,$CalendarBusinessEnd ); + if (( is_object ( $tr ) && get_class ($tr) == 'CalendarBusinessHours' ) ) { + $tr->delete(); + } + } + } + + public function saveCalendarBusinessHours($aData) + { + $CalendarUid = $aData['CALENDAR_UID']; + $CalendarBusinessDay = $aData['CALENDAR_BUSINESS_DAY']; + $CalendarBusinessStart = $aData['CALENDAR_BUSINESS_START']; + $CalendarBusinessEnd = $aData['CALENDAR_BUSINESS_END']; + + //if exists the row in the database propel will update it, otherwise will insert. + $tr = CalendarBusinessHoursPeer::retrieveByPK ( $CalendarUid,$CalendarBusinessDay, $CalendarBusinessStart,$CalendarBusinessEnd ); + if ( ! ( is_object ( $tr ) && get_class ($tr) == 'CalendarBusinessHours' ) ) { + $tr = new CalendarBusinessHours(); + } + + $tr->setCalendarUid( $CalendarUid ); + $tr->setCalendarBusinessDay( $CalendarBusinessDay ); + $tr->setCalendarBusinessStart( $CalendarBusinessStart ); + $tr->setCalendarBusinessEnd( $CalendarBusinessEnd ); + + if ($tr->validate() ) { + // we save it, since we get no validation errors, or do whatever else you like. + $res = $tr->save(); + } else { + // Something went wrong. We can now get the validationFailures and handle them. + $msg = $CalendarBusinessDay.'
'; + $validationFailuresArray = $tr->getValidationFailures(); + foreach ($validationFailuresArray as $objValidationFailure) { + $msg .= $objValidationFailure->getMessage() . "
"; + } + //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); + G::SendTemporalMessage($msg); + } + } +} -} // CalendarBusinessHours diff --git a/workflow/engine/classes/model/CalendarBusinessHoursPeer.php b/workflow/engine/classes/model/CalendarBusinessHoursPeer.php index 039489174..ef9f678d0 100755 --- a/workflow/engine/classes/model/CalendarBusinessHoursPeer.php +++ b/workflow/engine/classes/model/CalendarBusinessHoursPeer.php @@ -14,7 +14,7 @@ /** * Skeleton subclass for performing query and update operations on the 'CALENDAR_BUSINESS_HOURS' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -22,6 +22,7 @@ * * @package workflow.engine.classes.model */ -class CalendarBusinessHoursPeer extends BaseCalendarBusinessHoursPeer { +class CalendarBusinessHoursPeer extends BaseCalendarBusinessHoursPeer +{ +} -} // CalendarBusinessHoursPeer diff --git a/workflow/engine/classes/model/CalendarDefinition.php b/workflow/engine/classes/model/CalendarDefinition.php index a64308a18..cea5801dc 100755 --- a/workflow/engine/classes/model/CalendarDefinition.php +++ b/workflow/engine/classes/model/CalendarDefinition.php @@ -1,455 +1,447 @@ -clearSelectColumns(); - - $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID ); - $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_NAME ); - $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_CREATE_DATE ); - $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE ); - $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_DESCRIPTION ); - $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_STATUS ); - // $Criteria->addAsColumn('DELETABLE', "IF (CALENDAR_UID <> '00000000000000000000000000000001', '".G::LoadTranslation('ID_DELETE')."','') "); - $Criteria->addAsColumn( 'DELETABLE', "CASE WHEN CALENDAR_UID <> '00000000000000000000000000000001' THEN '" . G::LoadTranslation( 'ID_DELETE' ) . "' ELSE '' END " ); - // Note: This list doesn't show deleted items (STATUS = DELETED) - if ($onlyActive) { - // Show only active. Used on assignment lists - $Criteria->add( calendarDefinitionPeer::CALENDAR_STATUS, "ACTIVE", CRITERIA::EQUAL ); - } else { +clearSelectColumns(); + + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_NAME ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_CREATE_DATE ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_DESCRIPTION ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_STATUS ); + // $Criteria->addAsColumn('DELETABLE', "IF (CALENDAR_UID <> '00000000000000000000000000000001', '".G::LoadTranslation('ID_DELETE')."','') "); + $Criteria->addAsColumn( 'DELETABLE', "CASE WHEN CALENDAR_UID <> '00000000000000000000000000000001' THEN '" . G::LoadTranslation( 'ID_DELETE' ) . "' ELSE '' END " ); + // Note: This list doesn't show deleted items (STATUS = DELETED) + if ($onlyActive) { + // Show only active. Used on assignment lists + $Criteria->add( calendarDefinitionPeer::CALENDAR_STATUS, "ACTIVE", CRITERIA::EQUAL ); + } else { // Show Active and Inactive calendars. USed in main list - $Criteria->add( calendarDefinitionPeer::CALENDAR_STATUS, array ("ACTIVE","INACTIVE"), CRITERIA::IN ); - } - - $Criteria->add( calendarDefinitionPeer::CALENDAR_UID, "xx", CRITERIA::NOT_EQUAL ); - - if (! $arrayMode) { - return $Criteria; - } else { - $oDataset = calendarDefinitionPeer::doSelectRS( $Criteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - $calendarA = array (0 => 'dummy'); - $calendarCount = 0; - while (is_array( $aRow = $oDataset->getRow() )) { - $calendarCount ++; - $calendarA[$calendarCount] = $aRow; - $oDataset->next(); - } - $return['criteria'] = $Criteria; - $return['array'] = $calendarA; - return $return; - } - } + $Criteria->add( calendarDefinitionPeer::CALENDAR_STATUS, array ("ACTIVE","INACTIVE"), CRITERIA::IN ); + } + + $Criteria->add( calendarDefinitionPeer::CALENDAR_UID, "xx", CRITERIA::NOT_EQUAL ); + + if (! $arrayMode) { + return $Criteria; + } else { + $oDataset = calendarDefinitionPeer::doSelectRS( $Criteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $calendarA = array (0 => 'dummy'); + $calendarCount = 0; + while (is_array( $aRow = $oDataset->getRow() )) { + $calendarCount ++; + $calendarA[$calendarCount] = $aRow; + $oDataset->next(); + } + $return['criteria'] = $Criteria; + $return['array'] = $calendarA; + return $return; + } + } + //Added by qennix //Gets criteria for listing - public function getCalendarCriterias ($filter, $start, $limit) - { - $Criteria = new Criteria( 'workflow' ); - $Criteria->clearSelectColumns(); - $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID ); - if ($filter != '') { - $Criteria->add( $Criteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_NAME, '%' . $filter . '%', Criteria::LIKE )->addOr( $Criteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_DESCRIPTION, '%' . $filter . '%', Criteria::LIKE ) ) ); - } - $Criteria->add( CalendarDefinitionPeer::CALENDAR_STATUS, 'DELETED', Criteria::NOT_EQUAL ); - - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID ); - $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_NAME ); - $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_CREATE_DATE ); - $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE ); - $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_DESCRIPTION ); - $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_STATUS ); - if ($filter != '') { - $oCriteria->add( $oCriteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_NAME, '%' . $filter . '%', Criteria::LIKE )->addOr( $oCriteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_DESCRIPTION, '%' . $filter . '%', Criteria::LIKE ) ) ); - } - $oCriteria->add( CalendarDefinitionPeer::CALENDAR_STATUS, 'DELETED', Criteria::NOT_EQUAL ); - $oCriteria->setLimit( $limit ); - $oCriteria->setOffset( $start ); - - $criterias = array (); - $criterias['COUNTER'] = $Criteria; - $criterias['LIST'] = $oCriteria; - return $criterias; - } - - public function getCalendarInfo ($CalendarUid) - { + public function getCalendarCriterias ($filter, $start, $limit) + { + $Criteria = new Criteria( 'workflow' ); + $Criteria->clearSelectColumns(); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID ); + if ($filter != '') { + $Criteria->add( $Criteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_NAME, '%' . $filter . '%', Criteria::LIKE )->addOr( $Criteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_DESCRIPTION, '%' . $filter . '%', Criteria::LIKE ) ) ); + } + $Criteria->add( CalendarDefinitionPeer::CALENDAR_STATUS, 'DELETED', Criteria::NOT_EQUAL ); + + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID ); + $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_NAME ); + $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_CREATE_DATE ); + $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE ); + $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_DESCRIPTION ); + $oCriteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_STATUS ); + if ($filter != '') { + $oCriteria->add( $oCriteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_NAME, '%' . $filter . '%', Criteria::LIKE )->addOr( $oCriteria->getNewCriterion( CalendarDefinitionPeer::CALENDAR_DESCRIPTION, '%' . $filter . '%', Criteria::LIKE ) ) ); + } + $oCriteria->add( CalendarDefinitionPeer::CALENDAR_STATUS, 'DELETED', Criteria::NOT_EQUAL ); + $oCriteria->setLimit( $limit ); + $oCriteria->setOffset( $start ); + + $criterias = array (); + $criterias['COUNTER'] = $Criteria; + $criterias['LIST'] = $oCriteria; + return $criterias; + } + + public function getCalendarInfo ($CalendarUid) + { //if exists the row in the database propel will update it, otherwise will insert. - $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid ); - - $defaultCalendar['CALENDAR_UID'] = "00000000000000000000000000000001"; - $defaultCalendar['CALENDAR_NAME'] = "Default"; - $defaultCalendar['CALENDAR_CREATE_DATE'] = date( "Y-m-d" ); - $defaultCalendar['CALENDAR_UPDATE_DATE'] = date( "Y-m-d" ); - $defaultCalendar['CALENDAR_DESCRIPTION'] = "Default"; - $defaultCalendar['CALENDAR_STATUS'] = "ACTIVE"; - $defaultCalendar['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; - $defaultCalendar['CALENDAR_WORK_DAYS'] = explode( "|", "1|2|3|4|5" ); - $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_DAY'] = 7; - $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_START'] = "09:00"; - $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_END'] = "17:00"; - $defaultCalendar['HOLIDAY'] = array (); - - if ((is_object( $tr ) && get_class( $tr ) == 'CalendarDefinition')) { - $fields['CALENDAR_UID'] = $tr->getCalendarUid(); - $fields['CALENDAR_NAME'] = $tr->getCalendarName(); - $fields['CALENDAR_CREATE_DATE'] = $tr->getCalendarCreateDate(); - $fields['CALENDAR_UPDATE_DATE'] = $tr->getCalendarUpdateDate(); - $fields['CALENDAR_DESCRIPTION'] = $tr->getCalendarDescription(); - $fields['CALENDAR_STATUS'] = $tr->getCalendarStatus(); - $fields['CALENDAR_WORK_DAYS'] = $tr->getCalendarWorkDays(); - $fields['CALENDAR_WORK_DAYS_A'] = explode( "|", $tr->getCalendarWorkDays() ); - } else { - $fields = $defaultCalendar; - $this->saveCalendarInfo( $fields ); - $fields['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; - $fields['CALENDAR_WORK_DAYS_A'] = explode( "|", "1|2|3|4|5" ); - $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid ); - } - $CalendarBusinessHoursObj = new CalendarBusinessHours(); - $CalendarBusinessHours = $CalendarBusinessHoursObj->getCalendarBusinessHours( $CalendarUid ); - $fields['BUSINESS_DAY'] = $CalendarBusinessHours; - $CalendarHolidaysObj = new CalendarHolidays(); - $CalendarHolidays = $CalendarHolidaysObj->getCalendarHolidays( $CalendarUid ); - $fields['HOLIDAY'] = $CalendarHolidays; - $fields = $this->validateCalendarInfo( $fields, $defaultCalendar ); + $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid ); + + $defaultCalendar['CALENDAR_UID'] = "00000000000000000000000000000001"; + $defaultCalendar['CALENDAR_NAME'] = "Default"; + $defaultCalendar['CALENDAR_CREATE_DATE'] = date( "Y-m-d" ); + $defaultCalendar['CALENDAR_UPDATE_DATE'] = date( "Y-m-d" ); + $defaultCalendar['CALENDAR_DESCRIPTION'] = "Default"; + $defaultCalendar['CALENDAR_STATUS'] = "ACTIVE"; + $defaultCalendar['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; + $defaultCalendar['CALENDAR_WORK_DAYS'] = explode( "|", "1|2|3|4|5" ); + $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_DAY'] = 7; + $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_START'] = "09:00"; + $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_END'] = "17:00"; + $defaultCalendar['HOLIDAY'] = array (); + + if ((is_object( $tr ) && get_class( $tr ) == 'CalendarDefinition')) { + $fields['CALENDAR_UID'] = $tr->getCalendarUid(); + $fields['CALENDAR_NAME'] = $tr->getCalendarName(); + $fields['CALENDAR_CREATE_DATE'] = $tr->getCalendarCreateDate(); + $fields['CALENDAR_UPDATE_DATE'] = $tr->getCalendarUpdateDate(); + $fields['CALENDAR_DESCRIPTION'] = $tr->getCalendarDescription(); + $fields['CALENDAR_STATUS'] = $tr->getCalendarStatus(); + $fields['CALENDAR_WORK_DAYS'] = $tr->getCalendarWorkDays(); + $fields['CALENDAR_WORK_DAYS_A'] = explode( "|", $tr->getCalendarWorkDays() ); + } else { + $fields = $defaultCalendar; + $this->saveCalendarInfo( $fields ); + $fields['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; + $fields['CALENDAR_WORK_DAYS_A'] = explode( "|", "1|2|3|4|5" ); + $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid ); + } + $CalendarBusinessHoursObj = new CalendarBusinessHours(); + $CalendarBusinessHours = $CalendarBusinessHoursObj->getCalendarBusinessHours( $CalendarUid ); + $fields['BUSINESS_DAY'] = $CalendarBusinessHours; + $CalendarHolidaysObj = new CalendarHolidays(); + $CalendarHolidays = $CalendarHolidaysObj->getCalendarHolidays( $CalendarUid ); + $fields['HOLIDAY'] = $CalendarHolidays; + $fields = $this->validateCalendarInfo( $fields, $defaultCalendar ); //******************** - return $fields; - } + return $fields; + } + //for edit - public function getCalendarInfoE ($CalendarUid) - { + public function getCalendarInfoE ($CalendarUid) + { //if exists the row in the database propel will update it, otherwise will insert. - $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid ); - $defaultCalendar['CALENDAR_UID'] = "00000000000000000000000000000001"; - $defaultCalendar['CALENDAR_NAME'] = "Default"; - $defaultCalendar['CALENDAR_CREATE_DATE'] = date( "Y-m-d" ); - $defaultCalendar['CALENDAR_UPDATE_DATE'] = date( "Y-m-d" ); - $defaultCalendar['CALENDAR_DESCRIPTION'] = "Default"; - $defaultCalendar['CALENDAR_STATUS'] = "ACTIVE"; - $defaultCalendar['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; - $defaultCalendar['CALENDAR_WORK_DAYS'] = explode( "|", "1|2|3|4|5" ); - $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_DAY'] = 7; - $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_START'] = "09:00"; - $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_END'] = "17:00"; - $defaultCalendar['HOLIDAY'] = array (); - - if ((is_object( $tr ) && get_class( $tr ) == 'CalendarDefinition')) { - $fields['CALENDAR_UID'] = $tr->getCalendarUid(); - $fields['CALENDAR_NAME'] = $tr->getCalendarName(); - $fields['CALENDAR_CREATE_DATE'] = $tr->getCalendarCreateDate(); - $fields['CALENDAR_UPDATE_DATE'] = $tr->getCalendarUpdateDate(); - $fields['CALENDAR_DESCRIPTION'] = $tr->getCalendarDescription(); - $fields['CALENDAR_STATUS'] = $tr->getCalendarStatus(); - $fields['CALENDAR_WORK_DAYS'] = $tr->getCalendarWorkDays(); - $fields['CALENDAR_WORK_DAYS_A'] = explode( "|", $tr->getCalendarWorkDays() ); - } else { - $fields = $defaultCalendar; - $this->saveCalendarInfo( $fields ); - $fields['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; - $fields['CALENDAR_WORK_DAYS_A'] = explode( "|", "1|2|3|4|5" ); - $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid ); - } - $CalendarBusinessHoursObj = new CalendarBusinessHours(); - $CalendarBusinessHours = $CalendarBusinessHoursObj->getCalendarBusinessHours( $CalendarUid ); - $fields['BUSINESS_DAY'] = $CalendarBusinessHours; - $CalendarHolidaysObj = new CalendarHolidays(); - $CalendarHolidays = $CalendarHolidaysObj->getCalendarHolidays( $CalendarUid ); - $fields['HOLIDAY'] = $CalendarHolidays; + $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid ); + $defaultCalendar['CALENDAR_UID'] = "00000000000000000000000000000001"; + $defaultCalendar['CALENDAR_NAME'] = "Default"; + $defaultCalendar['CALENDAR_CREATE_DATE'] = date( "Y-m-d" ); + $defaultCalendar['CALENDAR_UPDATE_DATE'] = date( "Y-m-d" ); + $defaultCalendar['CALENDAR_DESCRIPTION'] = "Default"; + $defaultCalendar['CALENDAR_STATUS'] = "ACTIVE"; + $defaultCalendar['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; + $defaultCalendar['CALENDAR_WORK_DAYS'] = explode( "|", "1|2|3|4|5" ); + $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_DAY'] = 7; + $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_START'] = "09:00"; + $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_END'] = "17:00"; + $defaultCalendar['HOLIDAY'] = array (); + + if ((is_object( $tr ) && get_class( $tr ) == 'CalendarDefinition')) { + $fields['CALENDAR_UID'] = $tr->getCalendarUid(); + $fields['CALENDAR_NAME'] = $tr->getCalendarName(); + $fields['CALENDAR_CREATE_DATE'] = $tr->getCalendarCreateDate(); + $fields['CALENDAR_UPDATE_DATE'] = $tr->getCalendarUpdateDate(); + $fields['CALENDAR_DESCRIPTION'] = $tr->getCalendarDescription(); + $fields['CALENDAR_STATUS'] = $tr->getCalendarStatus(); + $fields['CALENDAR_WORK_DAYS'] = $tr->getCalendarWorkDays(); + $fields['CALENDAR_WORK_DAYS_A'] = explode( "|", $tr->getCalendarWorkDays() ); + } else { + $fields = $defaultCalendar; + $this->saveCalendarInfo( $fields ); + $fields['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; + $fields['CALENDAR_WORK_DAYS_A'] = explode( "|", "1|2|3|4|5" ); + $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid ); + } + $CalendarBusinessHoursObj = new CalendarBusinessHours(); + $CalendarBusinessHours = $CalendarBusinessHoursObj->getCalendarBusinessHours( $CalendarUid ); + $fields['BUSINESS_DAY'] = $CalendarBusinessHours; + $CalendarHolidaysObj = new CalendarHolidays(); + $CalendarHolidays = $CalendarHolidaysObj->getCalendarHolidays( $CalendarUid ); + $fields['HOLIDAY'] = $CalendarHolidays; // $fields=$this->validateCalendarInfo($fields, $defaultCalendar); //******************** - return $fields; - } + return $fields; + } //end for edit - - public function validateCalendarInfo ($fields, $defaultCalendar) - { - try { + + public function validateCalendarInfo ($fields, $defaultCalendar) + { + try { //Validate if Working days are Correct //Minimun 3 ? - $workingDays = explode( "|", $fields['CALENDAR_WORK_DAYS'] ); - if (count( $workingDays ) < 3) { - throw (new Exception( "You must define at least 3 Working Days!" )); - } + $workingDays = explode( "|", $fields['CALENDAR_WORK_DAYS'] ); + if (count( $workingDays ) < 3) { + throw (new Exception( "You must define at least 3 Working Days!" )); + } //Validate that all Working Days have Bussines Hours - if (count( $fields['BUSINESS_DAY'] ) < 1) { - throw (new Exception( "You must define at least one Business Day for all days" )); - } - $workingDaysOK = array (); - foreach ($workingDays as $key => $day) { - $workingDaysOK[$day] = false; - } - $sw_all = false; - foreach ($fields['BUSINESS_DAY'] as $keyB => $businessHours) { - if (($businessHours['CALENDAR_BUSINESS_DAY'] == 7)) { - $sw_all = true; - } elseif ((in_array( $businessHours['CALENDAR_BUSINESS_DAY'], $workingDays ))) { - $workingDaysOK[$businessHours['CALENDAR_BUSINESS_DAY']] = true; - } - } - $sw_days = true; - - foreach ($workingDaysOK as $day => $sw_day) { - $sw_days = $sw_days && $sw_day; - } - if (! ($sw_all || $sw_days)) { - throw (new Exception( "Not all working days have their correspondent business day" )); - } + if (count( $fields['BUSINESS_DAY'] ) < 1) { + throw (new Exception( "You must define at least one Business Day for all days" )); + } + $workingDaysOK = array (); + foreach ($workingDays as $key => $day) { + $workingDaysOK[$day] = false; + } + $sw_all = false; + foreach ($fields['BUSINESS_DAY'] as $keyB => $businessHours) { + if (($businessHours['CALENDAR_BUSINESS_DAY'] == 7)) { + $sw_all = true; + } elseif ((in_array( $businessHours['CALENDAR_BUSINESS_DAY'], $workingDays ))) { + $workingDaysOK[$businessHours['CALENDAR_BUSINESS_DAY']] = true; + } + } + $sw_days = true; + + foreach ($workingDaysOK as $day => $sw_day) { + $sw_days = $sw_days && $sw_day; + } + if (! ($sw_all || $sw_days)) { + throw (new Exception( "Not all working days have their correspondent business day" )); + } //Validate Holidays - return $fields; - } catch (Exception $e) { + return $fields; + } catch (Exception $e) { //print $e->getMessage(); - $this->addCalendarLog( "!!!!!!! BAD CALENDAR DEFINITION. " . $e->getMessage() ); - $defaultCalendar['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; - $defaultCalendar['CALENDAR_WORK_DAYS_A'] = explode( "|", "1|2|3|4|5" ); - return $defaultCalendar; - } - - } - - public function saveCalendarInfo ($aData) - { - $CalendarUid = $aData['CALENDAR_UID']; - $CalendarName = $aData['CALENDAR_NAME']; - $CalendarDescription = $aData['CALENDAR_DESCRIPTION']; - $CalendarStatus = isset( $aData['CALENDAR_STATUS'] ) ? $aData['CALENDAR_STATUS'] : "INACTIVE"; - $defaultCalendars[] = '00000000000000000000000000000001'; - if (in_array( $aData['CALENDAR_UID'], $defaultCalendars )) { - $CalendarStatus = 'ACTIVE'; - $CalendarName = 'Default'; - } - $CalendarWorkDays = isset( $aData['CALENDAR_WORK_DAYS'] ) ? implode( "|", $aData['CALENDAR_WORK_DAYS'] ) : ""; - + $this->addCalendarLog( "!!!!!!! BAD CALENDAR DEFINITION. " . $e->getMessage() ); + $defaultCalendar['CALENDAR_WORK_DAYS'] = "1|2|3|4|5"; + $defaultCalendar['CALENDAR_WORK_DAYS_A'] = explode( "|", "1|2|3|4|5" ); + return $defaultCalendar; + } + + } + + public function saveCalendarInfo ($aData) + { + $CalendarUid = $aData['CALENDAR_UID']; + $CalendarName = $aData['CALENDAR_NAME']; + $CalendarDescription = $aData['CALENDAR_DESCRIPTION']; + $CalendarStatus = isset( $aData['CALENDAR_STATUS'] ) ? $aData['CALENDAR_STATUS'] : "INACTIVE"; + $defaultCalendars[] = '00000000000000000000000000000001'; + if (in_array( $aData['CALENDAR_UID'], $defaultCalendars )) { + $CalendarStatus = 'ACTIVE'; + $CalendarName = 'Default'; + } + $CalendarWorkDays = isset( $aData['CALENDAR_WORK_DAYS'] ) ? implode( "|", $aData['CALENDAR_WORK_DAYS'] ) : ""; + //if exists the row in the database propel will update it, otherwise will insert. - $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid ); - if (! (is_object( $tr ) && get_class( $tr ) == 'CalendarDefinition')) { - $tr = new CalendarDefinition(); - $tr->setCalendarCreateDate( 'now' ); - } - $tr->setCalendarUid( $CalendarUid ); - $tr->setCalendarName( $CalendarName ); - $tr->setCalendarUpdateDate( 'now' ); - $tr->setCalendarDescription( $CalendarDescription ); - $tr->setCalendarStatus( $CalendarStatus ); - $tr->setCalendarWorkDays( $CalendarWorkDays ); - - if ($tr->validate()) { + $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid ); + if (! (is_object( $tr ) && get_class( $tr ) == 'CalendarDefinition')) { + $tr = new CalendarDefinition(); + $tr->setCalendarCreateDate( 'now' ); + } + $tr->setCalendarUid( $CalendarUid ); + $tr->setCalendarName( $CalendarName ); + $tr->setCalendarUpdateDate( 'now' ); + $tr->setCalendarDescription( $CalendarDescription ); + $tr->setCalendarStatus( $CalendarStatus ); + $tr->setCalendarWorkDays( $CalendarWorkDays ); + + if ($tr->validate()) { // we save it, since we get no validation errors, or do whatever else you like. - $res = $tr->save(); + $res = $tr->save(); //Calendar Business Hours Save code. //First Delete all current records - $CalendarBusinessHoursObj = new CalendarBusinessHours(); - $CalendarBusinessHoursObj->deleteAllCalendarBusinessHours( $CalendarUid ); + $CalendarBusinessHoursObj = new CalendarBusinessHours(); + $CalendarBusinessHoursObj->deleteAllCalendarBusinessHours( $CalendarUid ); //Save all the sent records - foreach ($aData['BUSINESS_DAY'] as $key => $objData) { - $objData['CALENDAR_UID'] = $CalendarUid; - $CalendarBusinessHoursObj->saveCalendarBusinessHours( $objData ); - } + foreach ($aData['BUSINESS_DAY'] as $key => $objData) { + $objData['CALENDAR_UID'] = $CalendarUid; + $CalendarBusinessHoursObj->saveCalendarBusinessHours( $objData ); + } //Holiday Save code. //First Delete all current records - $CalendarHolidayObj = new CalendarHolidays(); - $CalendarHolidayObj->deleteAllCalendarHolidays( $CalendarUid ); + $CalendarHolidayObj = new CalendarHolidays(); + $CalendarHolidayObj->deleteAllCalendarHolidays( $CalendarUid ); //Save all the sent records - foreach ($aData['HOLIDAY'] as $key => $objData) { - if (($objData['CALENDAR_HOLIDAY_NAME'] != "") && ($objData['CALENDAR_HOLIDAY_START'] != "") && ($objData['CALENDAR_HOLIDAY_END'] != "")) { - $objData['CALENDAR_UID'] = $CalendarUid; - $CalendarHolidayObj->saveCalendarHolidays( $objData ); - } - } - } else { + foreach ($aData['HOLIDAY'] as $key => $objData) { + if (($objData['CALENDAR_HOLIDAY_NAME'] != "") && ($objData['CALENDAR_HOLIDAY_START'] != "") && ($objData['CALENDAR_HOLIDAY_END'] != "")) { + $objData['CALENDAR_UID'] = $CalendarUid; + $CalendarHolidayObj->saveCalendarHolidays( $objData ); + } + } + } else { // Something went wrong. We can now get the validationFailures and handle them. - $msg = ''; - $validationFailuresArray = $tr->getValidationFailures(); - foreach ($validationFailuresArray as $objValidationFailure) { - $msg .= $objValidationFailure->getMessage() . "
"; - } + $msg = ''; + $validationFailuresArray = $tr->getValidationFailures(); + foreach ($validationFailuresArray as $objValidationFailure) { + $msg .= $objValidationFailure->getMessage() . "
"; + } //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); - } - //return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => ''); - //to do: uniform coderror structures for all classes - //if ( $res['codError'] < 0 ) { - // G::SendMessageText ( $res['message'] , 'error' ); - //} - } - - public function deleteCalendar ($CalendarUid) - { + } + } + + public function deleteCalendar ($CalendarUid) + { //if exists the row in the database propel will update it, otherwise will insert. - $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid ); - - if (! (is_object( $tr ) && get_class( $tr ) == 'CalendarDefinition')) { + $tr = CalendarDefinitionPeer::retrieveByPK( $CalendarUid ); + + if (! (is_object( $tr ) && get_class( $tr ) == 'CalendarDefinition')) { // - return false; - } - - $defaultCalendars[] = '00000000000000000000000000000001'; - if (in_array( $tr->getCalendarUid(), $defaultCalendars )) { - return false; - } - - $tr->setCalendarStatus( 'DELETED' ); - $tr->setCalendarUpdateDate( 'now' ); - if ($tr->validate()) { + return false; + } + + $defaultCalendars[] = '00000000000000000000000000000001'; + if (in_array( $tr->getCalendarUid(), $defaultCalendars )) { + return false; + } + + $tr->setCalendarStatus( 'DELETED' ); + $tr->setCalendarUpdateDate( 'now' ); + if ($tr->validate()) { // we save it, since we get no validation errors, or do whatever else you like. - $res = $tr->save(); - } else { + $res = $tr->save(); + } else { // Something went wrong. We can now get the validationFailures and handle them. - $msg = ''; - $validationFailuresArray = $tr->getValidationFailures(); - foreach ($validationFailuresArray as $objValidationFailure) { - $msg .= $objValidationFailure->getMessage() . "
"; - } - G::SendMessage( "ERROR", $msg ); + $msg = ''; + $validationFailuresArray = $tr->getValidationFailures(); + foreach ($validationFailuresArray as $objValidationFailure) { + $msg .= $objValidationFailure->getMessage() . "
"; + } + G::SendMessage( "ERROR", $msg ); //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); - } - //return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => ''); - //to do: uniform coderror structures for all classes - //if ( $res['codError'] < 0 ) { - // G::SendMessageText ( $res['message'] , 'error' ); - //} - } - - public function getCalendarFor ($userUid, $proUid, $tasUid, $sw_validate = true) - { - $Criteria = new Criteria( 'workflow' ); + } + } + + public function getCalendarFor ($userUid, $proUid, $tasUid, $sw_validate = true) + { + $Criteria = new Criteria( 'workflow' ); //Default Calendar - $calendarUid = "00000000000000000000000000000001"; - $calendarOwner = "DEFAULT"; + $calendarUid = "00000000000000000000000000000001"; + $calendarOwner = "DEFAULT"; //Load User,Task and Process calendars (if exist) - $Criteria->addSelectColumn( CalendarAssignmentsPeer::CALENDAR_UID ); - $Criteria->addSelectColumn( CalendarAssignmentsPeer::OBJECT_UID ); - $Criteria->addSelectColumn( CalendarAssignmentsPeer::OBJECT_TYPE ); - $Criteria->add( CalendarAssignmentsPeer::OBJECT_UID, array ($userUid,$proUid,$tasUid), CRITERIA::IN ); - $oDataset = CalendarAssignmentsPeer::doSelectRS( $Criteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - $calendarArray = array (); - while (is_array( $aRow = $oDataset->getRow() )) { - if ($aRow['OBJECT_UID'] == $userUid) { - $calendarArray['USER'] = $aRow['CALENDAR_UID']; - } - if ($aRow['OBJECT_UID'] == $proUid) { - $calendarArray['PROCESS'] = $aRow['CALENDAR_UID']; - } - if ($aRow['OBJECT_UID'] == $tasUid) { - $calendarArray['TASK'] = $aRow['CALENDAR_UID']; - } - $oDataset->next(); - } - - if (isset( $calendarArray['USER'] )) { - $calendarUid = $calendarArray['USER']; - $calendarOwner = "USER"; - } elseif (isset( $calendarArray['PROCESS'] )) { - $calendarUid = $calendarArray['PROCESS']; - $calendarOwner = "PROCESS"; - } elseif (isset( $calendarArray['TASK'] )) { - $calendarUid = $calendarArray['TASK']; - $calendarOwner = "TASK"; - } - + $Criteria->addSelectColumn( CalendarAssignmentsPeer::CALENDAR_UID ); + $Criteria->addSelectColumn( CalendarAssignmentsPeer::OBJECT_UID ); + $Criteria->addSelectColumn( CalendarAssignmentsPeer::OBJECT_TYPE ); + $Criteria->add( CalendarAssignmentsPeer::OBJECT_UID, array ($userUid,$proUid,$tasUid), CRITERIA::IN ); + $oDataset = CalendarAssignmentsPeer::doSelectRS( $Criteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $calendarArray = array (); + while (is_array( $aRow = $oDataset->getRow() )) { + if ($aRow['OBJECT_UID'] == $userUid) { + $calendarArray['USER'] = $aRow['CALENDAR_UID']; + } + if ($aRow['OBJECT_UID'] == $proUid) { + $calendarArray['PROCESS'] = $aRow['CALENDAR_UID']; + } + if ($aRow['OBJECT_UID'] == $tasUid) { + $calendarArray['TASK'] = $aRow['CALENDAR_UID']; + } + $oDataset->next(); + } + + if (isset( $calendarArray['USER'] )) { + $calendarUid = $calendarArray['USER']; + $calendarOwner = "USER"; + } elseif (isset( $calendarArray['PROCESS'] )) { + $calendarUid = $calendarArray['PROCESS']; + $calendarOwner = "PROCESS"; + } elseif (isset( $calendarArray['TASK'] )) { + $calendarUid = $calendarArray['TASK']; + $calendarOwner = "TASK"; + } + //print "

$calendarUid

"; - if ($sw_validate) { - $calendarDefinition = $this->getCalendarInfo( $calendarUid ); - } else { - $calendarDefinition = $this->getCalendarInfoE( $calendarUid ); - } - $calendarDefinition['CALENDAR_APPLIED'] = $calendarOwner; - $this->addCalendarLog( "--=== Calendar Applied: " . $calendarDefinition['CALENDAR_NAME'] . " -> $calendarOwner" ); - return $calendarDefinition; - } - - public function assignCalendarTo ($objectUid, $calendarUid, $objectType) - { + if ($sw_validate) { + $calendarDefinition = $this->getCalendarInfo( $calendarUid ); + } else { + $calendarDefinition = $this->getCalendarInfoE( $calendarUid ); + } + $calendarDefinition['CALENDAR_APPLIED'] = $calendarOwner; + $this->addCalendarLog( "--=== Calendar Applied: " . $calendarDefinition['CALENDAR_NAME'] . " -> $calendarOwner" ); + return $calendarDefinition; + } + + public function assignCalendarTo ($objectUid, $calendarUid, $objectType) + { //if exists the row in the database propel will update it, otherwise will insert. - $tr = CalendarAssignmentsPeer::retrieveByPK( $objectUid ); - if ($calendarUid != "") { - if (! (is_object( $tr ) && get_class( $tr ) == 'CalendarAssignments')) { - $tr = new CalendarAssignments(); - } - $tr->setObjectUid( $objectUid ); - $tr->setCalendarUid( $calendarUid ); - $tr->setObjectType( $objectType ); - - if ($tr->validate()) { + $tr = CalendarAssignmentsPeer::retrieveByPK( $objectUid ); + if ($calendarUid != "") { + if (! (is_object( $tr ) && get_class( $tr ) == 'CalendarAssignments')) { + $tr = new CalendarAssignments(); + } + $tr->setObjectUid( $objectUid ); + $tr->setCalendarUid( $calendarUid ); + $tr->setObjectType( $objectType ); + + if ($tr->validate()) { // we save it, since we get no validation errors, or do whatever else you like. - $res = $tr->save(); - } else { + $res = $tr->save(); + } else { // Something went wrong. We can now get the validationFailures and handle them. - $msg = ''; - $validationFailuresArray = $tr->getValidationFailures(); - foreach ($validationFailuresArray as $objValidationFailure) { - $msg .= $objValidationFailure->getMessage() . "
"; - } + $msg = ''; + $validationFailuresArray = $tr->getValidationFailures(); + foreach ($validationFailuresArray as $objValidationFailure) { + $msg .= $objValidationFailure->getMessage() . "
"; + } //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); - } - } else { + } + } else { //Delete record - if ((is_object( $tr ) && get_class( $tr ) == 'CalendarAssignments')) { - $tr->delete(); - } - } - } + if ((is_object( $tr ) && get_class( $tr ) == 'CalendarAssignments')) { + $tr->delete(); + } + } + } + //Added by Qennix //Counts all users,task,process by calendar - public function getAllCounterByCalendar ($type) - { - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->addSelectColumn( CalendarAssignmentsPeer::CALENDAR_UID ); - $oCriteria->addSelectColumn( 'COUNT(*) AS CNT' ); - $oCriteria->addGroupByColumn( CalendarAssignmentsPeer::CALENDAR_UID ); - $oCriteria->add( CalendarAssignmentsPeer::OBJECT_TYPE, $type ); - $oDataset = CalendarAssignmentsPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $aCounter = Array (); - while ($oDataset->next()) { - $row = $oDataset->getRow(); - $aCounter[$row['CALENDAR_UID']] = $row['CNT']; - } - return $aCounter; - } - - public function loadByCalendarName ($calendarName) - { - $Criteria = new Criteria( 'workflow' ); - $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID ); - $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_NAME ); - $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_CREATE_DATE ); - $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE ); - $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_DESCRIPTION ); - $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_STATUS ); - $Criteria->add( calendarDefinitionPeer::CALENDAR_NAME, $calendarName, CRITERIA::EQUAL ); - $oDataset = calendarDefinitionPeer::doSelectRS( $Criteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - return $oDataset->getRow(); - } -} -// CalendarDefinition - + public function getAllCounterByCalendar ($type) + { + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->addSelectColumn( CalendarAssignmentsPeer::CALENDAR_UID ); + $oCriteria->addSelectColumn( 'COUNT(*) AS CNT' ); + $oCriteria->addGroupByColumn( CalendarAssignmentsPeer::CALENDAR_UID ); + $oCriteria->add( CalendarAssignmentsPeer::OBJECT_TYPE, $type ); + $oDataset = CalendarAssignmentsPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $aCounter = Array (); + while ($oDataset->next()) { + $row = $oDataset->getRow(); + $aCounter[$row['CALENDAR_UID']] = $row['CNT']; + } + return $aCounter; + } + + public function loadByCalendarName ($calendarName) + { + $Criteria = new Criteria( 'workflow' ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UID ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_NAME ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_CREATE_DATE ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_UPDATE_DATE ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_DESCRIPTION ); + $Criteria->addSelectColumn( CalendarDefinitionPeer::CALENDAR_STATUS ); + $Criteria->add( calendarDefinitionPeer::CALENDAR_NAME, $calendarName, CRITERIA::EQUAL ); + $oDataset = calendarDefinitionPeer::doSelectRS( $Criteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + return $oDataset->getRow(); + } +} + diff --git a/workflow/engine/classes/model/CalendarDefinitionPeer.php b/workflow/engine/classes/model/CalendarDefinitionPeer.php index 1de336a21..4a1121313 100755 --- a/workflow/engine/classes/model/CalendarDefinitionPeer.php +++ b/workflow/engine/classes/model/CalendarDefinitionPeer.php @@ -14,7 +14,7 @@ /** * Skeleton subclass for performing query and update operations on the 'CALENDAR_DEFINITION' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -22,6 +22,7 @@ * * @package workflow.engine.classes.model */ -class CalendarDefinitionPeer extends BaseCalendarDefinitionPeer { +class CalendarDefinitionPeer extends BaseCalendarDefinitionPeer +{ +} -} // CalendarDefinitionPeer diff --git a/workflow/engine/classes/model/CalendarHolidays.php b/workflow/engine/classes/model/CalendarHolidays.php index fdf5a4390..b55740de3 100755 --- a/workflow/engine/classes/model/CalendarHolidays.php +++ b/workflow/engine/classes/model/CalendarHolidays.php @@ -6,11 +6,10 @@ require_once 'classes/model/om/BaseCalendarHolidays.php'; - /** * Skeleton subclass for representing a row from the 'CALENDAR_HOLIDAYS' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -18,97 +17,87 @@ require_once 'classes/model/om/BaseCalendarHolidays.php'; * * @package workflow.engine.classes.model */ -class CalendarHolidays extends BaseCalendarHolidays { - function getCalendarHolidays($CalendarUid){ - $Criteria = new Criteria('workflow'); - $Criteria->clearSelectColumns ( ); - - $Criteria->addSelectColumn ( CalendarHolidaysPeer::CALENDAR_UID ); - $Criteria->addSelectColumn ( CalendarHolidaysPeer::CALENDAR_HOLIDAY_NAME ); - $Criteria->addSelectColumn ( CalendarHolidaysPeer::CALENDAR_HOLIDAY_START ); - $Criteria->addSelectColumn ( CalendarHolidaysPeer::CALENDAR_HOLIDAY_END ); - - - - $Criteria->add ( CalendarHolidaysPeer::CALENDAR_UID, $CalendarUid , CRITERIA::EQUAL ); - - $rs = CalendarHolidaysPeer::doSelectRS($Criteria); - $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $rs->next(); - $row = $rs->getRow(); - $fields=array(); - - $count=0; +class CalendarHolidays extends BaseCalendarHolidays +{ + public function getCalendarHolidays ($CalendarUid) + { + $Criteria = new Criteria('workflow'); + $Criteria->clearSelectColumns ( ); - while (is_array($row)) { - $count++; - $a=explode(" ",$row['CALENDAR_HOLIDAY_START']); - $row['CALENDAR_HOLIDAY_START']=$a[0]; - $a=explode(" ",$row['CALENDAR_HOLIDAY_END']); - $row['CALENDAR_HOLIDAY_END']=$a[0]; - $fields[$count] = $row; + $Criteria->addSelectColumn ( CalendarHolidaysPeer::CALENDAR_UID ); + $Criteria->addSelectColumn ( CalendarHolidaysPeer::CALENDAR_HOLIDAY_NAME ); + $Criteria->addSelectColumn ( CalendarHolidaysPeer::CALENDAR_HOLIDAY_START ); + $Criteria->addSelectColumn ( CalendarHolidaysPeer::CALENDAR_HOLIDAY_END ); + + $Criteria->add ( CalendarHolidaysPeer::CALENDAR_UID, $CalendarUid , CRITERIA::EQUAL ); + + $rs = CalendarHolidaysPeer::doSelectRS($Criteria); + $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); $rs->next(); $row = $rs->getRow(); - } - return $fields; - } -function deleteAllCalendarHolidays($CalendarUid){ - $toDelete=$this->getCalendarHolidays($CalendarUid); - foreach($toDelete as $key => $holidayInfo){ - $CalendarUid = $holidayInfo['CALENDAR_UID']; - $CalendarHolidayName = $holidayInfo['CALENDAR_HOLIDAY_NAME']; - $CalendarHolidayStart = $holidayInfo['CALENDAR_HOLIDAY_START']; - $CalendarHolidayEnd = $holidayInfo['CALENDAR_HOLIDAY_END']; - //if exists the row in the database propel will update it, otherwise will insert. - - $tr = CalendarHolidaysPeer::retrieveByPK ( $CalendarUid,$CalendarHolidayName ); - if ( ( is_object ( $tr ) && get_class ($tr) == 'CalendarHolidays' ) ) { - $tr->delete(); - } + $fields=array(); + $count=0; + while (is_array($row)) { + $count++; + $a=explode(" ",$row['CALENDAR_HOLIDAY_START']); + $row['CALENDAR_HOLIDAY_START']=$a[0]; + $a=explode(" ",$row['CALENDAR_HOLIDAY_END']); + $row['CALENDAR_HOLIDAY_END']=$a[0]; + $fields[$count] = $row; + $rs->next(); + $row = $rs->getRow(); + } + return $fields; } - - } - function saveCalendarHolidays($aData){ - - $CalendarUid = $aData['CALENDAR_UID']; - $CalendarHolidayName = $aData['CALENDAR_HOLIDAY_NAME']; - $CalendarHolidayStart = $aData['CALENDAR_HOLIDAY_START']; - $CalendarHolidayEnd = $aData['CALENDAR_HOLIDAY_END']; - - //if exists the row in the database propel will update it, otherwise will insert. - $tr = CalendarHolidaysPeer::retrieveByPK ( $CalendarUid,$CalendarHolidayName); - if ( ! ( is_object ( $tr ) && get_class ($tr) == 'CalendarHolidays' ) ) { - $tr = new CalendarHolidays(); - } - $tr->setCalendarUid( $CalendarUid ); - $tr->setCalendarHolidayName( $CalendarHolidayName ); - $tr->setCalendarHolidayStart( $CalendarHolidayStart ); - $tr->setCalendarHolidayEnd( $CalendarHolidayEnd ); - - - if ($tr->validate() ) { - // we save it, since we get no validation errors, or do whatever else you like. - $res = $tr->save(); - } - else { - // Something went wrong. We can now get the validationFailures and handle them. - $msg = ''; - $validationFailuresArray = $tr->getValidationFailures(); - foreach($validationFailuresArray as $objValidationFailure) { - $msg .= $objValidationFailure->getMessage() . "
"; - } - //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); - } - - - //return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => ''); - - //to do: uniform coderror structures for all classes - - //if ( $res['codError'] < 0 ) { - // G::SendMessageText ( $res['message'] , 'error' ); - //} - } + public function deleteAllCalendarHolidays($CalendarUid) + { + $toDelete=$this->getCalendarHolidays($CalendarUid); + foreach ($toDelete as $key => $holidayInfo) { + $CalendarUid = $holidayInfo['CALENDAR_UID']; + $CalendarHolidayName = $holidayInfo['CALENDAR_HOLIDAY_NAME']; + $CalendarHolidayStart = $holidayInfo['CALENDAR_HOLIDAY_START']; + $CalendarHolidayEnd = $holidayInfo['CALENDAR_HOLIDAY_END']; + //if exists the row in the database propel will update it, otherwise will insert. + + $tr = CalendarHolidaysPeer::retrieveByPK ( $CalendarUid,$CalendarHolidayName ); + if ( ( is_object ( $tr ) && get_class ($tr) == 'CalendarHolidays' ) ) { + $tr->delete(); + } + } + } + + public function saveCalendarHolidays($aData) + { + $CalendarUid = $aData['CALENDAR_UID']; + $CalendarHolidayName = $aData['CALENDAR_HOLIDAY_NAME']; + $CalendarHolidayStart = $aData['CALENDAR_HOLIDAY_START']; + $CalendarHolidayEnd = $aData['CALENDAR_HOLIDAY_END']; + + //if exists the row in the database propel will update it, otherwise will insert. + $tr = CalendarHolidaysPeer::retrieveByPK ( $CalendarUid,$CalendarHolidayName); + if ( ! ( is_object ( $tr ) && get_class ($tr) == 'CalendarHolidays' ) ) { + $tr = new CalendarHolidays(); + } + + $tr->setCalendarUid( $CalendarUid ); + $tr->setCalendarHolidayName( $CalendarHolidayName ); + $tr->setCalendarHolidayStart( $CalendarHolidayStart ); + $tr->setCalendarHolidayEnd( $CalendarHolidayEnd ); + + if ($tr->validate() ) { + $res = $tr->save(); + } else { + // Something went wrong. We can now get the validationFailures and handle them. + $msg = ''; + $validationFailuresArray = $tr->getValidationFailures(); + foreach ($validationFailuresArray as $objValidationFailure) { + $msg .= $objValidationFailure->getMessage() . "
"; + } + //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg ); + } + + //to do: uniform coderror structures for all classes + } +} -} // CalendarHolidays diff --git a/workflow/engine/classes/model/CalendarHolidaysPeer.php b/workflow/engine/classes/model/CalendarHolidaysPeer.php index 5203a8897..4a4a18f1a 100755 --- a/workflow/engine/classes/model/CalendarHolidaysPeer.php +++ b/workflow/engine/classes/model/CalendarHolidaysPeer.php @@ -14,7 +14,7 @@ /** * Skeleton subclass for performing query and update operations on the 'CALENDAR_HOLIDAYS' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -22,6 +22,7 @@ * * @package workflow.engine.classes.model */ -class CalendarHolidaysPeer extends BaseCalendarHolidaysPeer { +class CalendarHolidaysPeer extends BaseCalendarHolidaysPeer +{ +} -} // CalendarHolidaysPeer diff --git a/workflow/engine/classes/model/CaseScheduler.php b/workflow/engine/classes/model/CaseScheduler.php index 2843b9545..5f60e661d 100755 --- a/workflow/engine/classes/model/CaseScheduler.php +++ b/workflow/engine/classes/model/CaseScheduler.php @@ -1,807 +1,731 @@ -SchTimeNextRun === null) - $this->SchTimeNextRun = time(); - return $this->SchTimeNextRun; +require_once 'classes/model/om/BaseCaseScheduler.php'; + +require_once 'classes/model/Process.php'; +require_once 'classes/model/Task.php'; + +/** + * Skeleton subclass for representing a row from the 'CASE_SCHEDULER' table. + * + * + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + * + * @package workflow.engine.classes.model + */ +class CaseScheduler extends BaseCaseScheduler +{ + public function load ($SchUid) + { + try { + $oRow = CaseSchedulerPeer::retrieveByPK( $SchUid ); + if (! is_null( $oRow )) { + $aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME ); + $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME ); + $this->setNew( false ); + return $aFields; + } else { + throw (new Exception( "The row '" . $SchUid . "' in table CASE_SCHEDULER doesn't exist!" )); + } + } catch (Exception $oError) { + throw ($oError); + } } - public function setSchTimeNextRun($value) { - $this->SchTimeNextRun = $value; - } - public function getSchLastRunTime(){ - if($this->SchTimeNextRun === null) - $this->SchTimeNextRun = time(); - return $this->SchLastRunTime; - } - public function setSchLastRunTime($value){ - $this->SchLastRunTime = $value; - } - */ - - public function load ($SchUid) - { - try { - $oRow = CaseSchedulerPeer::retrieveByPK( $SchUid ); - if (! is_null( $oRow )) { - $aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME ); - $this->fromArray( $aFields, BasePeer::TYPE_FIELDNAME ); - $this->setNew( false ); - return $aFields; - } else { - throw (new Exception( "The row '" . $SchUid . "' in table CASE_SCHEDULER doesn't exist!" )); - } - } catch (Exception $oError) { - throw ($oError); - } - } - - public function create ($aData) - { - $con = Propel::getConnection( CaseSchedulerPeer::DATABASE_NAME ); - try { - $this->fromArray( $aData, BasePeer::TYPE_FIELDNAME ); - if ($this->validate()) { - $result = $this->save(); - } else { - $e = new Exception( "Failed Validation in class " . get_class( $this ) . "." ); - $e->aValidationFailures = $this->getValidationFailures(); - throw ($e); - } - $con->commit(); - return $result; - } catch (Exception $e) { - $con->rollback(); - throw ($e); - } - } - - public function update ($fields) - { - $con = Propel::getConnection( CaseSchedulerPeer::DATABASE_NAME ); - try { - $con->begin(); - $this->load( $fields['SCH_UID'] ); - $this->fromArray( $fields, BasePeer::TYPE_FIELDNAME ); - if ($this->validate()) { - $result = $this->save(); - $con->commit(); - return $result; - } else { - $con->rollback(); - throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." )); - } - } catch (Exception $e) { - $con->rollback(); - throw ($e); - } - } - - public function remove ($SchUid) - { - $con = Propel::getConnection( CaseSchedulerPeer::DATABASE_NAME ); - try { - $oCaseScheduler = CaseSchedulerPeer::retrieveByPK( $SchUid ); - if (! is_null( $oCaseScheduler )) { - $iResult = $oCaseScheduler->delete(); - $con->commit(); - return $iResult; - } else { - throw (new Exception( 'This row doesn\'t exist!' )); - } - /* - $con->begin(); - $this->setSchUid ( $SchUid ); - $result = $this->delete(); + + public function create ($aData) + { + $con = Propel::getConnection( CaseSchedulerPeer::DATABASE_NAME ); + try { + $this->fromArray( $aData, BasePeer::TYPE_FIELDNAME ); + if ($this->validate()) { + $result = $this->save(); + } else { + $e = new Exception( "Failed Validation in class " . get_class( $this ) . "." ); + $e->aValidationFailures = $this->getValidationFailures(); + throw ($e); + } $con->commit(); return $result; - */ - } catch (Exception $e) { - $con->rollback(); - throw ($e); - } - } - + } catch (Exception $e) { + $con->rollback(); + throw ($e); + } + } + + public function update ($fields) + { + $con = Propel::getConnection( CaseSchedulerPeer::DATABASE_NAME ); + try { + $con->begin(); + $this->load( $fields['SCH_UID'] ); + $this->fromArray( $fields, BasePeer::TYPE_FIELDNAME ); + if ($this->validate()) { + $result = $this->save(); + $con->commit(); + return $result; + } else { + $con->rollback(); + throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." )); + } + } catch (Exception $e) { + $con->rollback(); + throw ($e); + } + } + + public function remove ($SchUid) + { + $con = Propel::getConnection( CaseSchedulerPeer::DATABASE_NAME ); + try { + $oCaseScheduler = CaseSchedulerPeer::retrieveByPK( $SchUid ); + if (! is_null( $oCaseScheduler )) { + $iResult = $oCaseScheduler->delete(); + $con->commit(); + return $iResult; + } else { + throw (new Exception( 'This row doesn\'t exist!' )); + } + } catch (Exception $e) { + $con->rollback(); + throw ($e); + } + } + /* - * change Status of any Process - * @param string $sSchedulerUid - * @return boolean - */ - public function changeStatus ($sSchedulerUid = '') - { - $Fields = $this->Load( $sSchedulerUid ); - $Fields['SCH_LAST_STATE'] = $Fields['SCH_STATE']; - if ($Fields['SCH_STATE'] == 'ACTIVE') { - $Fields['SCH_STATE'] = 'INACTIVE'; - } else { - $Fields['SCH_STATE'] = 'ACTIVE'; - } - $this->Update( $Fields ); - } - - // SELECT A.SCH_UID, A.SCH_NAME, A.PRO_UID, B.CON_VALUE AS PROCESS, - // A.TAS_UID, B.CON_VALUE AS TASK, A.SCH_TIME_NEXT_RUN, A.SCH_LAST_RUN_TIME, A.SCH_STATE, A.SCH_LAST_STATE, - // A.USR_UID, A.SCH_OPTION - // SCH_START_TIME, SCH_START_DATE, SCH_DAYS_PERFORM_TASK, SCH_EVERY_DAYS, SCH_WEEK_DAYS - // SCH_START_DAY, SCH_MONTHS, SCH_END_DATE, SCH_REPEAT_EVERY, SCH_REPEAT_UNTIL, SCH_REPEAT_STOP_IF_RUNNING - // FROM CASE_SCHEDULER A LEFT JOIN CONTENT B ON A.PRO_UID= B.CON_ID AND B.CON_CATEGORY='PRO_TITLE' AND B.CON_LANG='en' - // LEFT JOIN CONTENT C ON A.TAS_UID= C.CON_ID AND C.CON_CATEGORY='TAS_TITLE' AND C.CON_LANG='en' - // - public function getAllCriteria () - { - $c = new Criteria( 'workflow' ); - $c->clearSelectColumns(); - $c->addSelectColumn( CaseSchedulerPeer::SCH_UID ); - $c->addSelectColumn( CaseSchedulerPeer::SCH_NAME ); - $c->addSelectColumn( CaseSchedulerPeer::SCH_DEL_USER_NAME ); - $c->addSelectColumn( CaseSchedulerPeer::SCH_DEL_USER_PASS ); - $c->addSelectColumn( CaseSchedulerPeer::SCH_DEL_USER_UID ); - $c->addSelectColumn( CaseSchedulerPeer::PRO_UID ); - $c->addSelectColumn( CaseSchedulerPeer::TAS_UID ); - $c->addSelectColumn( CaseSchedulerPeer::SCH_TIME_NEXT_RUN ); - $c->addSelectColumn( CaseSchedulerPeer::SCH_LAST_RUN_TIME ); - $c->addSelectColumn( CaseSchedulerPeer::SCH_STATE ); - $c->addSelectColumn( CaseSchedulerPeer::SCH_LAST_STATE ); - $c->addSelectColumn( CaseSchedulerPeer::USR_UID ); - $c->addSelectColumn( CaseSchedulerPeer::SCH_OPTION ); - $c->addSelectColumn( CaseSchedulerPeer::SCH_START_TIME ); - $c->addSelectColumn( CaseSchedulerPeer::SCH_START_DATE ); - $c->addSelectColumn( CaseSchedulerPeer::SCH_DAYS_PERFORM_TASK ); - $c->addSelectColumn( CaseSchedulerPeer::SCH_EVERY_DAYS ); - $c->addSelectColumn( CaseSchedulerPeer::SCH_WEEK_DAYS ); - $c->addSelectColumn( CaseSchedulerPeer::SCH_START_DAY ); - $c->addSelectColumn( CaseSchedulerPeer::SCH_MONTHS ); - $c->addSelectColumn( CaseSchedulerPeer::SCH_END_DATE ); - $c->addSelectColumn( CaseSchedulerPeer::SCH_REPEAT_EVERY ); - $c->addSelectColumn( CaseSchedulerPeer::SCH_REPEAT_UNTIL ); - $c->addSelectColumn( CaseSchedulerPeer::SCH_REPEAT_STOP_IF_RUNNING ); - $c->addSelectColumn( CaseSchedulerPeer::CASE_SH_PLUGIN_UID ); - - return $c; - - } - - public function getAll () - { - $oCriteria = $this->getAllCriteria(); - $oDataset = CaseSchedulerPeer::doSelectRS( $oCriteria ); - - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - $aRows = Array (); - while ($aRow = $oDataset->getRow()) { - $aRows[] = $aRow; - $oDataset->next(); - } - foreach ($aRows as $k => $aRow) { - $oProcess = new Process(); - $aProcessRow = $oProcess->load( $aRow['PRO_UID'] ); - - $oTask = new Task(); - $aTaskRow = $oTask->load( $aRow['TAS_UID'] ); - - $aRows[$k] = array_merge( $aRow, $aProcessRow, $aTaskRow ); - } - - return $aRows; - } - - /** - * function getAllByProcess - * Get All Scheduled Tasks for some process. - * - * @author gustavo cruz - * @param $pro_uid process uid - * @return $aRows a result set array - */ - public function getAllByProcess ($pro_uid) - { - - $oCriteria = $this->getAllCriteria(); - $oCriteria->add( CaseSchedulerPeer::PRO_UID, $pro_uid ); - $oDataset = CaseSchedulerPeer::doSelectRS( $oCriteria ); - - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - $aRows = Array (); - while ($aRow = $oDataset->getRow()) { - $aRows[] = $aRow; - $oDataset->next(); - } - foreach ($aRows as $k => $aRow) { - $oProcess = new Process(); - $aProcessRow = $oProcess->load( $aRow['PRO_UID'] ); - $oTask = new Task(); - $aTaskRow = $oTask->load( $aRow['TAS_UID'] ); - $aRows[$k] = array_merge( $aRow, $aProcessRow, $aTaskRow ); - } - return $aRows; - } - - public function getProcessDescription () - { - $c = new Criteria( 'workflow' ); - $c->clearSelectColumns(); - $c->addSelectColumn( ProcessPeer::PRO_UID ); - - $oDataset = ProcessPeer::doSelectRS( $c ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - $aRows = Array (); - while ($aRow = $oDataset->getRow()) { - $aRows[] = $aRow; - $oDataset->next(); - } - - foreach ($aRows as $k => $aRow) { - $oProcess = new Process(); - $aProcessRow = $oProcess->load( $aRow['PRO_UID'] ); - - $aRows[$k] = array_merge( $aRow, array ('PRO_TITLE' => $aProcessRow['PRO_TITLE'] - ) ); - } - return $aRows; - - } - - public function getTaskDescription () - { - $c = new Criteria( 'workflow' ); - $c->clearSelectColumns(); - $c->addSelectColumn( TaskPeer::TAS_UID ); - - $oDataset = TaskPeer::doSelectRS( $c ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - $aRows = Array (); - while ($aRow = $oDataset->getRow()) { - $aRows[] = $aRow; - $oDataset->next(); - } - foreach ($aRows as $k => $aRow) { - - $oTask = new Task(); - $aTaskRow = $oTask->load( $aRow['TAS_UID'] ); - - $aRows[$k] = array_merge( $aRow, array ('TAS_TITLE' => $aTaskRow['TAS_TITLE'] - ), array ('PRO_UID' => $aTaskRow['PRO_UID'] - ) ); - } - - // g::pr($aRows); die; - - - return $aRows; - - } - - public function caseSchedulerCron ($date, &$log = array(), $cron = 0) - { - G::LoadClass( 'dates' ); - require_once ('classes/model/LogCasesScheduler.php'); - $oDates = new dates(); - $nTime = strtotime( $date ); - $dCurrentDate = date( 'Y-m-d', $nTime ) . ' 00:00:00'; - $dNextDay = date( 'Y-m-d', strtotime( "$dCurrentDate" ) ) . ' 23:59:59'; - $oCriteria = $this->getAllCriteria(); - $oCriteria->addAnd( CaseSchedulerPeer::SCH_STATE, 'INACTIVE', Criteria::NOT_EQUAL ); - $oCriteria->addAnd( CaseSchedulerPeer::SCH_STATE, 'PROCESSED', Criteria::NOT_EQUAL ); - $oCriteria->add( CaseSchedulerPeer::SCH_TIME_NEXT_RUN, $dCurrentDate, Criteria::GREATER_EQUAL ); - $oCriteria->addAnd( CaseSchedulerPeer::SCH_TIME_NEXT_RUN, $dNextDay, Criteria::LESS_EQUAL ); - $oCriteria->add( CaseSchedulerPeer::SCH_END_DATE, null, Criteria::EQUAL ); - $oCriteria->addOr( CaseSchedulerPeer::SCH_END_DATE, $dCurrentDate, Criteria::GREATER_EQUAL ); - $oDataset = CaseSchedulerPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - $sValue = ''; - $sActualTime = ''; - $sDaysPerformTask = ''; - $sWeeks = ''; - $sStartDay = ''; - $sMonths = ''; - while ($aRow = $oDataset->getRow()) { - if ($cron == 1) { - $arrayCron = unserialize( trim( @file_get_contents( PATH_DATA . "cron" ) ) ); - $arrayCron["processcTimeStart"] = time(); - @file_put_contents( PATH_DATA . "cron", serialize( $arrayCron ) ); - } - - $sSchedulerUid = $aRow['SCH_UID']; - $sOption = $aRow['SCH_OPTION']; - switch ($sOption) { - case '1': - $sDaysPerformTask = $aRow['SCH_DAYS_PERFORM_TASK']; - $aDaysPerformTask = explode( '|', $sDaysPerformTask ); - $sValue = $aDaysPerformTask[0]; - if ($sValue != 1) { - $sDaysPerformTask = $aDaysPerformTask[1]; - } - break; - case '2': - $sDaysPerformTask = $aRow['SCH_EVERY_DAYS']; - $sWeeks = $aRow['SCH_WEEK_DAYS']; - break; - case '3': - $sStartDay = $aRow['SCH_START_DAY']; - $sMonths = $aRow['SCH_MONTHS']; - $aStartDay = explode( '|', $sStartDay ); - $sValue = $aStartDay[0]; - break; - case '4': - $aRow['SCH_STATE'] = 'PROCESSED'; - break; - case '5': - break; - - } - - $sActualTime = $aRow['SCH_TIME_NEXT_RUN']; - $sActualDataHour = date( 'H', strtotime( $aRow['SCH_TIME_NEXT_RUN'] ) ); - $sActualDataMinutes = date( 'i', strtotime( $aRow['SCH_TIME_NEXT_RUN'] ) ); - $dActualSysHour = date( 'H', $nTime ); - $dActualSysMinutes = date( 'i', $nTime ); - $sActualDataTime = strtotime( $aRow['SCH_TIME_NEXT_RUN'] ); - $sActualSysTime = strtotime( $nTime ); + * change Status of any Process + * @param string $sSchedulerUid + * @return boolean + */ + public function changeStatus ($sSchedulerUid = '') + { + $Fields = $this->Load( $sSchedulerUid ); + $Fields['SCH_LAST_STATE'] = $Fields['SCH_STATE']; + if ($Fields['SCH_STATE'] == 'ACTIVE') { + $Fields['SCH_STATE'] = 'INACTIVE'; + } else { + $Fields['SCH_STATE'] = 'ACTIVE'; + } + $this->Update( $Fields ); + } + + public function getAllCriteria () + { + $c = new Criteria( 'workflow' ); + $c->clearSelectColumns(); + $c->addSelectColumn( CaseSchedulerPeer::SCH_UID ); + $c->addSelectColumn( CaseSchedulerPeer::SCH_NAME ); + $c->addSelectColumn( CaseSchedulerPeer::SCH_DEL_USER_NAME ); + $c->addSelectColumn( CaseSchedulerPeer::SCH_DEL_USER_PASS ); + $c->addSelectColumn( CaseSchedulerPeer::SCH_DEL_USER_UID ); + $c->addSelectColumn( CaseSchedulerPeer::PRO_UID ); + $c->addSelectColumn( CaseSchedulerPeer::TAS_UID ); + $c->addSelectColumn( CaseSchedulerPeer::SCH_TIME_NEXT_RUN ); + $c->addSelectColumn( CaseSchedulerPeer::SCH_LAST_RUN_TIME ); + $c->addSelectColumn( CaseSchedulerPeer::SCH_STATE ); + $c->addSelectColumn( CaseSchedulerPeer::SCH_LAST_STATE ); + $c->addSelectColumn( CaseSchedulerPeer::USR_UID ); + $c->addSelectColumn( CaseSchedulerPeer::SCH_OPTION ); + $c->addSelectColumn( CaseSchedulerPeer::SCH_START_TIME ); + $c->addSelectColumn( CaseSchedulerPeer::SCH_START_DATE ); + $c->addSelectColumn( CaseSchedulerPeer::SCH_DAYS_PERFORM_TASK ); + $c->addSelectColumn( CaseSchedulerPeer::SCH_EVERY_DAYS ); + $c->addSelectColumn( CaseSchedulerPeer::SCH_WEEK_DAYS ); + $c->addSelectColumn( CaseSchedulerPeer::SCH_START_DAY ); + $c->addSelectColumn( CaseSchedulerPeer::SCH_MONTHS ); + $c->addSelectColumn( CaseSchedulerPeer::SCH_END_DATE ); + $c->addSelectColumn( CaseSchedulerPeer::SCH_REPEAT_EVERY ); + $c->addSelectColumn( CaseSchedulerPeer::SCH_REPEAT_UNTIL ); + $c->addSelectColumn( CaseSchedulerPeer::SCH_REPEAT_STOP_IF_RUNNING ); + $c->addSelectColumn( CaseSchedulerPeer::CASE_SH_PLUGIN_UID ); + + return $c; + } + + public function getAll () + { + $oCriteria = $this->getAllCriteria(); + $oDataset = CaseSchedulerPeer::doSelectRS( $oCriteria ); + + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aRows = Array (); + while ($aRow = $oDataset->getRow()) { + $aRows[] = $aRow; + $oDataset->next(); + } + foreach ($aRows as $k => $aRow) { + $oProcess = new Process(); + $aProcessRow = $oProcess->load( $aRow['PRO_UID'] ); + + $oTask = new Task(); + $aTaskRow = $oTask->load( $aRow['TAS_UID'] ); + + $aRows[$k] = array_merge( $aRow, $aProcessRow, $aTaskRow ); + } + + return $aRows; + } + + /** + * function getAllByProcess + * Get All Scheduled Tasks for some process. + * + * @author gustavo cruz + * @param $pro_uid process uid + * @return $aRows a result set array + */ + public function getAllByProcess ($pro_uid) + { + + $oCriteria = $this->getAllCriteria(); + $oCriteria->add( CaseSchedulerPeer::PRO_UID, $pro_uid ); + $oDataset = CaseSchedulerPeer::doSelectRS( $oCriteria ); + + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aRows = Array (); + while ($aRow = $oDataset->getRow()) { + $aRows[] = $aRow; + $oDataset->next(); + } + foreach ($aRows as $k => $aRow) { + $oProcess = new Process(); + $aProcessRow = $oProcess->load( $aRow['PRO_UID'] ); + $oTask = new Task(); + $aTaskRow = $oTask->load( $aRow['TAS_UID'] ); + $aRows[$k] = array_merge( $aRow, $aProcessRow, $aTaskRow ); + } + return $aRows; + } + + public function getProcessDescription () + { + $c = new Criteria( 'workflow' ); + $c->clearSelectColumns(); + $c->addSelectColumn( ProcessPeer::PRO_UID ); + + $oDataset = ProcessPeer::doSelectRS( $c ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aRows = Array (); + while ($aRow = $oDataset->getRow()) { + $aRows[] = $aRow; + $oDataset->next(); + } + + foreach ($aRows as $k => $aRow) { + $oProcess = new Process(); + $aProcessRow = $oProcess->load( $aRow['PRO_UID'] ); + + $aRows[$k] = array_merge( $aRow, array ('PRO_TITLE' => $aProcessRow['PRO_TITLE'] + ) ); + } + return $aRows; + + } + + public function getTaskDescription () + { + $c = new Criteria( 'workflow' ); + $c->clearSelectColumns(); + $c->addSelectColumn( TaskPeer::TAS_UID ); + + $oDataset = TaskPeer::doSelectRS( $c ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aRows = Array (); + while ($aRow = $oDataset->getRow()) { + $aRows[] = $aRow; + $oDataset->next(); + } + foreach ($aRows as $k => $aRow) { + + $oTask = new Task(); + $aTaskRow = $oTask->load( $aRow['TAS_UID'] ); + + $aRows[$k] = array_merge( $aRow, array ('TAS_TITLE' => $aTaskRow['TAS_TITLE'] + ), array ('PRO_UID' => $aTaskRow['PRO_UID'] + ) ); + } + return $aRows; + } + + public function caseSchedulerCron ($date, &$log = array(), $cron = 0) + { + G::LoadClass( 'dates' ); + require_once ('classes/model/LogCasesScheduler.php'); + $oDates = new dates(); + $nTime = strtotime( $date ); + $dCurrentDate = date( 'Y-m-d', $nTime ) . ' 00:00:00'; + $dNextDay = date( 'Y-m-d', strtotime( "$dCurrentDate" ) ) . ' 23:59:59'; + $oCriteria = $this->getAllCriteria(); + $oCriteria->addAnd( CaseSchedulerPeer::SCH_STATE, 'INACTIVE', Criteria::NOT_EQUAL ); + $oCriteria->addAnd( CaseSchedulerPeer::SCH_STATE, 'PROCESSED', Criteria::NOT_EQUAL ); + $oCriteria->add( CaseSchedulerPeer::SCH_TIME_NEXT_RUN, $dCurrentDate, Criteria::GREATER_EQUAL ); + $oCriteria->addAnd( CaseSchedulerPeer::SCH_TIME_NEXT_RUN, $dNextDay, Criteria::LESS_EQUAL ); + $oCriteria->add( CaseSchedulerPeer::SCH_END_DATE, null, Criteria::EQUAL ); + $oCriteria->addOr( CaseSchedulerPeer::SCH_END_DATE, $dCurrentDate, Criteria::GREATER_EQUAL ); + $oDataset = CaseSchedulerPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $sValue = ''; + $sActualTime = ''; + $sDaysPerformTask = ''; + $sWeeks = ''; + $sStartDay = ''; + $sMonths = ''; + while ($aRow = $oDataset->getRow()) { + if ($cron == 1) { + $arrayCron = unserialize( trim( @file_get_contents( PATH_DATA . "cron" ) ) ); + $arrayCron["processcTimeStart"] = time(); + @file_put_contents( PATH_DATA . "cron", serialize( $arrayCron ) ); + } + + $sSchedulerUid = $aRow['SCH_UID']; + $sOption = $aRow['SCH_OPTION']; + switch ($sOption) { + case '1': + $sDaysPerformTask = $aRow['SCH_DAYS_PERFORM_TASK']; + $aDaysPerformTask = explode( '|', $sDaysPerformTask ); + $sValue = $aDaysPerformTask[0]; + if ($sValue != 1) { + $sDaysPerformTask = $aDaysPerformTask[1]; + } + break; + case '2': + $sDaysPerformTask = $aRow['SCH_EVERY_DAYS']; + $sWeeks = $aRow['SCH_WEEK_DAYS']; + break; + case '3': + $sStartDay = $aRow['SCH_START_DAY']; + $sMonths = $aRow['SCH_MONTHS']; + $aStartDay = explode( '|', $sStartDay ); + $sValue = $aStartDay[0]; + break; + case '4': + $aRow['SCH_STATE'] = 'PROCESSED'; + break; + case '5': + break; + } + + $sActualTime = $aRow['SCH_TIME_NEXT_RUN']; + $sActualDataHour = date( 'H', strtotime( $aRow['SCH_TIME_NEXT_RUN'] ) ); + $sActualDataMinutes = date( 'i', strtotime( $aRow['SCH_TIME_NEXT_RUN'] ) ); + $dActualSysHour = date( 'H', $nTime ); + $dActualSysMinutes = date( 'i', $nTime ); + $sActualDataTime = strtotime( $aRow['SCH_TIME_NEXT_RUN'] ); + $sActualSysTime = strtotime( $nTime ); + // note added consider the posibility to encapsulate some in functionality in a class method or some funtions - if ($sActualDataHour < $dActualSysHour) { - $_PORT = (SERVER_PORT != '80') ? ':' . SERVER_PORT : ''; - $defaultEndpoint = 'http://' . SERVER_NAME . $_PORT . '/sys' . SYS_SYS . '/' . SYS_LANG . '/classic/services/wsdl2'; - println( " - Connecting webservice: $defaultEndpoint" ); - $user = $aRow["SCH_DEL_USER_NAME"]; - $pass = $aRow["SCH_DEL_USER_PASS"]; - $processId = $aRow["PRO_UID"]; - $taskId = $aRow["TAS_UID"]; - $client = new SoapClient( $defaultEndpoint ); - $params = array ('userid' => $user,'password' => 'md5:' . $pass); - $result = $client->__SoapCall( 'login', array ($params) ); - eprint( " - Logging as user $user............." ); - if ($result->status_code == 0) { - eprintln( "OK+", 'green' ); - $sessionId = $result->message; - $newCaseLog = new LogCasesScheduler(); - $newRouteLog = new LogCasesScheduler(); - $variables = Array (); - $params = array ('sessionId' => $sessionId,'processId' => $processId,'taskId' => $taskId,'variables' => $variables - ); - - $paramsLog = array ('PRO_UID' => $processId,'TAS_UID' => $taskId,'SCH_UID' => $sSchedulerUid,'USR_NAME' => $user,'RESULT' => '','EXEC_DATE' => date( 'Y-m-d' ),'EXEC_HOUR' => date( 'H:i:s' ),'WS_CREATE_CASE_STATUS' => '','WS_ROUTE_CASE_STATUS' => '' - ); - + if ($sActualDataHour < $dActualSysHour) { + $_PORT = (SERVER_PORT != '80') ? ':' . SERVER_PORT : ''; + $defaultEndpoint = 'http://' . SERVER_NAME . $_PORT . '/sys' . SYS_SYS . '/' . SYS_LANG . '/classic/services/wsdl2'; + println( " - Connecting webservice: $defaultEndpoint" ); + $user = $aRow["SCH_DEL_USER_NAME"]; + $pass = $aRow["SCH_DEL_USER_PASS"]; + $processId = $aRow["PRO_UID"]; + $taskId = $aRow["TAS_UID"]; + $client = new SoapClient( $defaultEndpoint ); + $params = array ('userid' => $user,'password' => 'md5:' . $pass); + $result = $client->__SoapCall( 'login', array ($params) ); + eprint( " - Logging as user $user............." ); + if ($result->status_code == 0) { + eprintln( "OK+", 'green' ); + $sessionId = $result->message; + $newCaseLog = new LogCasesScheduler(); + $newRouteLog = new LogCasesScheduler(); + $variables = Array (); + $params = array ('sessionId' => $sessionId,'processId' => $processId,'taskId' => $taskId,'variables' => $variables + ); + + $paramsLog = array ('PRO_UID' => $processId,'TAS_UID' => $taskId,'SCH_UID' => $sSchedulerUid,'USR_NAME' => $user,'RESULT' => '','EXEC_DATE' => date( 'Y-m-d' ),'EXEC_HOUR' => date( 'H:i:s' ),'WS_CREATE_CASE_STATUS' => '','WS_ROUTE_CASE_STATUS' => '' + ); + $sw_transfer_control_plugin = false; //This SW will be true only if a plugin is allowed to continue the action //If this Job was was registered to be performed by a plugin - if ((isset( $aRow['CASE_SH_PLUGIN_UID'] )) && ($aRow['CASE_SH_PLUGIN_UID'] != "")) { + if ((isset( $aRow['CASE_SH_PLUGIN_UID'] )) && ($aRow['CASE_SH_PLUGIN_UID'] != "")) { //Check if the plugin is active - $pluginParts = explode( "--", $aRow['CASE_SH_PLUGIN_UID'] ); - if (count( $pluginParts ) == 2) { + $pluginParts = explode( "--", $aRow['CASE_SH_PLUGIN_UID'] ); + if (count( $pluginParts ) == 2) { //***************** Plugins ************************** - G::LoadClass( 'plugin' ); + G::LoadClass( 'plugin' ); //here we are loading all plugins registered //the singleton has a list of enabled plugins - $sSerializedFile = PATH_DATA_SITE . 'plugin.singleton'; - $oPluginRegistry = & PMPluginRegistry::getSingleton(); - if (file_exists( $sSerializedFile )) { - $oPluginRegistry->unSerializeInstance( file_get_contents( $sSerializedFile ) ); - } - $oPluginRegistry = & PMPluginRegistry::getSingleton(); - $activePluginsForCaseScheduler = $oPluginRegistry->getCaseSchedulerPlugins(); - foreach ($activePluginsForCaseScheduler as $key => $caseSchedulerPlugin) { - if ((isset( $caseSchedulerPlugin->sNamespace )) && ($caseSchedulerPlugin->sNamespace == $pluginParts[0]) && (isset( $caseSchedulerPlugin->sActionId )) && ($caseSchedulerPlugin->sActionId == $pluginParts[1])) { - $sw_transfer_control_plugin = true; - $caseSchedulerSelected = $caseSchedulerPlugin; - } - } - - } - } + $sSerializedFile = PATH_DATA_SITE . 'plugin.singleton'; + $oPluginRegistry = & PMPluginRegistry::getSingleton(); + if (file_exists( $sSerializedFile )) { + $oPluginRegistry->unSerializeInstance( file_get_contents( $sSerializedFile ) ); + } + $oPluginRegistry = & PMPluginRegistry::getSingleton(); + $activePluginsForCaseScheduler = $oPluginRegistry->getCaseSchedulerPlugins(); + foreach ($activePluginsForCaseScheduler as $key => $caseSchedulerPlugin) { + if ((isset( $caseSchedulerPlugin->sNamespace )) && ($caseSchedulerPlugin->sNamespace == $pluginParts[0]) && (isset( $caseSchedulerPlugin->sActionId )) && ($caseSchedulerPlugin->sActionId == $pluginParts[1])) { + $sw_transfer_control_plugin = true; + $caseSchedulerSelected = $caseSchedulerPlugin; + } + } + + } + } + //If there is a trigger that is registered to do this then transfer control - - - if ((isset( $caseSchedulerSelected )) && (is_object( $caseSchedulerSelected ))) { - eprintln( " - Transfering control to a Plugin: " . $caseSchedulerSelected->sNamespace . "/" . $caseSchedulerSelected->sActionId, 'green' ); - - $oData['OBJ_SOAP'] = $client; - $oData['SCH_UID'] = $aRow['SCH_UID']; - $oData['params'] = $params; - $oData['sessionId'] = $sessionId; - $oData['userId'] = $user; - $paramsLogResultFromPlugin = $oPluginRegistry->executeMethod( $caseSchedulerSelected->sNamespace, $caseSchedulerSelected->sActionExecute, $oData ); - $paramsLog['WS_CREATE_CASE_STATUS'] = $paramsLogResultFromPlugin['WS_CREATE_CASE_STATUS']; - $paramsLog['WS_ROUTE_CASE_STATUS'] = $paramsLogResultFromPlugin['WS_ROUTE_CASE_STATUS']; - - $paramsLogResult = $paramsLogResultFromPlugin['paramsLogResult']; - $paramsRouteLogResult = $paramsLogResultFromPlugin['paramsRouteLogResult']; - } else { - eprint( " - Creating the new case............." ); - $result = $client->__SoapCall( 'NewCase', array ($params) ); - if ($result->status_code == 0) { - eprintln( "OK+ CASE #{$result->caseNumber} was created!", 'green' ); - - $caseId = $result->caseId; - $caseNumber = $result->caseNumber; - $log[] = $caseNumber . ' was created!, ProcessID: ' . $aRow['PRO_UID']; - $paramsLog['WS_CREATE_CASE_STATUS'] = "Case " . $caseNumber . " " . strip_tags( $result->message ); - $paramsLogResult = 'SUCCESS'; - $params = array ('sessionId' => $sessionId,'caseId' => $caseId,'delIndex' => "1"); - eprint( " - Routing the case #$caseNumber.............." ); - $result = $client->__SoapCall( 'RouteCase', array ($params) ); - - if ($result->status_code == 0) { - $paramsLog['WS_ROUTE_CASE_STATUS'] = strip_tags( $result->message ); - $retMsg = explode( "Debug", $paramsLog['WS_ROUTE_CASE_STATUS'] ); - $retMsg = $retMsg[0]; - eprintln( "OK+ $retMsg", 'green' ); - $paramsRouteLogResult = 'SUCCESS'; - } else { - $paramsLog['WS_ROUTE_CASE_STATUS'] = strip_tags( $result->message ); - eprintln( "FAILED-> {$paramsLog ['WS_ROUTE_CASE_STATUS']}", 'red' ); - $paramsRouteLogResult = 'FAILED'; - } - } else { - $paramsLog['WS_CREATE_CASE_STATUS'] = strip_tags( $result->message ); - $paramsLogResult = 'FAILED'; - - } - } - } else { - eprintln( $result->message, 'red' ); + if ((isset( $caseSchedulerSelected )) && (is_object( $caseSchedulerSelected ))) { + eprintln( " - Transfering control to a Plugin: " . $caseSchedulerSelected->sNamespace . "/" . $caseSchedulerSelected->sActionId, 'green' ); + $oData['OBJ_SOAP'] = $client; + $oData['SCH_UID'] = $aRow['SCH_UID']; + $oData['params'] = $params; + $oData['sessionId'] = $sessionId; + $oData['userId'] = $user; + $paramsLogResultFromPlugin = $oPluginRegistry->executeMethod( $caseSchedulerSelected->sNamespace, $caseSchedulerSelected->sActionExecute, $oData ); + $paramsLog['WS_CREATE_CASE_STATUS'] = $paramsLogResultFromPlugin['WS_CREATE_CASE_STATUS']; + $paramsLog['WS_ROUTE_CASE_STATUS'] = $paramsLogResultFromPlugin['WS_ROUTE_CASE_STATUS']; + + $paramsLogResult = $paramsLogResultFromPlugin['paramsLogResult']; + $paramsRouteLogResult = $paramsLogResultFromPlugin['paramsRouteLogResult']; + } else { + eprint( " - Creating the new case............." ); + $result = $client->__SoapCall( 'NewCase', array ($params) ); + if ($result->status_code == 0) { + eprintln( "OK+ CASE #{$result->caseNumber} was created!", 'green' ); + + $caseId = $result->caseId; + $caseNumber = $result->caseNumber; + $log[] = $caseNumber . ' was created!, ProcessID: ' . $aRow['PRO_UID']; + $paramsLog['WS_CREATE_CASE_STATUS'] = "Case " . $caseNumber . " " . strip_tags( $result->message ); + $paramsLogResult = 'SUCCESS'; + $params = array ('sessionId' => $sessionId,'caseId' => $caseId,'delIndex' => "1"); + eprint( " - Routing the case #$caseNumber.............." ); + $result = $client->__SoapCall( 'RouteCase', array ($params) ); + + if ($result->status_code == 0) { + $paramsLog['WS_ROUTE_CASE_STATUS'] = strip_tags( $result->message ); + $retMsg = explode( "Debug", $paramsLog['WS_ROUTE_CASE_STATUS'] ); + $retMsg = $retMsg[0]; + eprintln( "OK+ $retMsg", 'green' ); + $paramsRouteLogResult = 'SUCCESS'; + } else { + $paramsLog['WS_ROUTE_CASE_STATUS'] = strip_tags( $result->message ); + eprintln( "FAILED-> {$paramsLog ['WS_ROUTE_CASE_STATUS']}", 'red' ); + $paramsRouteLogResult = 'FAILED'; + } + } else { + $paramsLog['WS_CREATE_CASE_STATUS'] = strip_tags( $result->message ); + $paramsLogResult = 'FAILED'; + + } + } + } else { + eprintln( $result->message, 'red' ); // invalid user or bad password - } - if ($paramsLogResult == 'SUCCESS' && $paramsRouteLogResult == 'SUCCESS') { - $paramsLog['RESULT'] = 'SUCCESS'; - } else { - $paramsLog['RESULT'] = 'FAILED'; - } - - $newCaseLog->saveLogParameters( $paramsLog ); - $newCaseLog->save(); - - if ($sOption != '4' && $sOption != '5') { - $nSchLastRunTime = $sActualTime; - - $dEstimatedDate = $this->updateNextRun( $sOption, $sValue, $sActualTime, $sDaysPerformTask, $sWeeks, $sStartDay, $sMonths ); - - if ($aRow['SCH_END_DATE'] != '') { - if (date( "Y-m-d", strtotime( $dEstimatedDate ) ) > date( "Y-m-d", strtotime( $aRow['SCH_END_DATE'] ) )) { - $Fields = $this->Load( $sSchedulerUid ); - $Fields['SCH_LAST_STATE'] = $aRow['SCH_STATE']; - $Fields['SCH_STATE'] = 'PROCESSED'; - $this->Update( $Fields ); - } - } - - $nSchTimeNextRun = $dEstimatedDate; - $this->updateDate( $sSchedulerUid, $nSchTimeNextRun, $nSchLastRunTime ); - } elseif ($sOption != '5') { - $Fields = $this->Load( $sSchedulerUid ); - $Fields['SCH_LAST_STATE'] = $aRow['SCH_STATE']; - $Fields['SCH_LAST_RUN_TIME'] = $Fields['SCH_TIME_NEXT_RUN']; - $Fields['SCH_STATE'] = 'PROCESSED'; - $this->Update( $Fields ); - } else { - - } - } else if ($sActualDataHour == $dActualSysHour && $sActualDataMinutes <= $dActualSysMinutes) { - $_PORT = (isset( $_SERVER['SERVER_PORT'] ) && $_SERVER['SERVER_PORT'] != '80') ? ':' . $_SERVER['SERVER_PORT'] : ''; + } + if ($paramsLogResult == 'SUCCESS' && $paramsRouteLogResult == 'SUCCESS') { + $paramsLog['RESULT'] = 'SUCCESS'; + } else { + $paramsLog['RESULT'] = 'FAILED'; + } + + $newCaseLog->saveLogParameters( $paramsLog ); + $newCaseLog->save(); + + if ($sOption != '4' && $sOption != '5') { + $nSchLastRunTime = $sActualTime; + + $dEstimatedDate = $this->updateNextRun( $sOption, $sValue, $sActualTime, $sDaysPerformTask, $sWeeks, $sStartDay, $sMonths ); + + if ($aRow['SCH_END_DATE'] != '') { + if (date( "Y-m-d", strtotime( $dEstimatedDate ) ) > date( "Y-m-d", strtotime( $aRow['SCH_END_DATE'] ) )) { + $Fields = $this->Load( $sSchedulerUid ); + $Fields['SCH_LAST_STATE'] = $aRow['SCH_STATE']; + $Fields['SCH_STATE'] = 'PROCESSED'; + $this->Update( $Fields ); + } + } + + $nSchTimeNextRun = $dEstimatedDate; + $this->updateDate( $sSchedulerUid, $nSchTimeNextRun, $nSchLastRunTime ); + } elseif ($sOption != '5') { + $Fields = $this->Load( $sSchedulerUid ); + $Fields['SCH_LAST_STATE'] = $aRow['SCH_STATE']; + $Fields['SCH_LAST_RUN_TIME'] = $Fields['SCH_TIME_NEXT_RUN']; + $Fields['SCH_STATE'] = 'PROCESSED'; + $this->Update( $Fields ); + } else { + + } + } elseif ($sActualDataHour == $dActualSysHour && $sActualDataMinutes <= $dActualSysMinutes) { + $_PORT = (isset( $_SERVER['SERVER_PORT'] ) && $_SERVER['SERVER_PORT'] != '80') ? ':' . $_SERVER['SERVER_PORT'] : ''; //$defaultEndpoint = 'http://' . $_SERVER ['SERVER_NAME'] . ':' . $_PORT . '/sys' . SYS_SYS .'/'.SYS_LANG.'/classic/green/services/wsdl2'; - $defaultEndpoint = 'http://' . SERVER_NAME . $_PORT . '/sys' . SYS_SYS . '/' . SYS_LANG . '/classic/services/wsdl2'; - println( " - Connecting webservice: $defaultEndpoint" ); - $user = $aRow["SCH_DEL_USER_NAME"]; - $pass = $aRow["SCH_DEL_USER_PASS"]; - $processId = $aRow["PRO_UID"]; - $taskId = $aRow["TAS_UID"]; - $client = new SoapClient( $defaultEndpoint ); - $params = array ('userid' => $user,'password' => 'md5:' . $pass); - $result = $client->__SoapCall( 'login', array ($params) ); - eprint( " - Logging as user $user............." ); - if ($result->status_code == 0) { - eprintln( "OK+", 'green' ); - $sessionId = $result->message; - $newCaseLog = new LogCasesScheduler(); - $newRouteLog = new LogCasesScheduler(); - $variables = Array (); - $params = array ('sessionId' => $sessionId,'processId' => $processId,'taskId' => $taskId,'variables' => $variables - ); - - $paramsLog = array ('PRO_UID' => $processId,'TAS_UID' => $taskId,'SCH_UID' => $sSchedulerUid,'USR_NAME' => $user,'RESULT' => '','EXEC_DATE' => date( 'Y-m-d' ),'EXEC_HOUR' => date( 'H:i:s' ),'WS_CREATE_CASE_STATUS' => '','WS_ROUTE_CASE_STATUS' => '' - ); - - $result = $client->__SoapCall( 'NewCase', array ($params) ); - - eprint( " - Creating the new case............." ); - if ($result->status_code == 0) { - eprintln( "OK+ CASE #{$result->caseNumber} was created!", 'green' ); - $caseId = $result->caseId; - $caseNumber = $result->caseNumber; - $log[] = $caseNumber . ' was created!, ProcessID: ' . $aRow['PRO_UID']; - $paramsLog['WS_CREATE_CASE_STATUS'] = "Case " . $caseNumber . " " . strip_tags( $result->message ); - $paramsLogResult = 'SUCCESS'; - - $params = array ('sessionId' => $sessionId,'caseId' => $caseId,'delIndex' => "1" - ); - $result = $client->__SoapCall( 'RouteCase', array ($params - ) ); - eprint( " - Routing the case #$caseNumber.............." ); - if ($result->status_code == 0) { - $paramsLog['WS_ROUTE_CASE_STATUS'] = strip_tags( $result->message ); - $retMsg = explode( "Debug", $paramsLog['WS_ROUTE_CASE_STATUS'] ); - $retMsg = $retMsg[0]; - eprintln( "OK+ $retMsg", 'green' ); - $paramsRouteLogResult = 'SUCCESS'; - } else { - eprintln( "FAILED-> {$paramsLog ['WS_ROUTE_CASE_STATUS']}", 'red' ); - $paramsLog['WS_ROUTE_CASE_STATUS'] = strip_tags( $result->message ); - $paramsRouteLogResult = 'FAILED'; - } - - } else { - $paramsLog['WS_CREATE_CASE_STATUS'] = strip_tags( $result->message ); - eprintln( "FAILED->{$paramsLog ['WS_CREATE_CASE_STATUS']}", 'red' ); - $paramsLogResult = 'FAILED'; - - } - } else { + $defaultEndpoint = 'http://' . SERVER_NAME . $_PORT . '/sys' . SYS_SYS . '/' . SYS_LANG . '/classic/services/wsdl2'; + println( " - Connecting webservice: $defaultEndpoint" ); + $user = $aRow["SCH_DEL_USER_NAME"]; + $pass = $aRow["SCH_DEL_USER_PASS"]; + $processId = $aRow["PRO_UID"]; + $taskId = $aRow["TAS_UID"]; + $client = new SoapClient( $defaultEndpoint ); + $params = array ('userid' => $user,'password' => 'md5:' . $pass); + $result = $client->__SoapCall( 'login', array ($params) ); + eprint( " - Logging as user $user............." ); + if ($result->status_code == 0) { + eprintln( "OK+", 'green' ); + $sessionId = $result->message; + $newCaseLog = new LogCasesScheduler(); + $newRouteLog = new LogCasesScheduler(); + $variables = Array (); + $params = array ('sessionId' => $sessionId,'processId' => $processId,'taskId' => $taskId,'variables' => $variables + ); + + $paramsLog = array ('PRO_UID' => $processId,'TAS_UID' => $taskId,'SCH_UID' => $sSchedulerUid,'USR_NAME' => $user,'RESULT' => '','EXEC_DATE' => date( 'Y-m-d' ),'EXEC_HOUR' => date( 'H:i:s' ),'WS_CREATE_CASE_STATUS' => '','WS_ROUTE_CASE_STATUS' => '' + ); + + $result = $client->__SoapCall( 'NewCase', array ($params) ); + + eprint( " - Creating the new case............." ); + if ($result->status_code == 0) { + eprintln( "OK+ CASE #{$result->caseNumber} was created!", 'green' ); + $caseId = $result->caseId; + $caseNumber = $result->caseNumber; + $log[] = $caseNumber . ' was created!, ProcessID: ' . $aRow['PRO_UID']; + $paramsLog['WS_CREATE_CASE_STATUS'] = "Case " . $caseNumber . " " . strip_tags( $result->message ); + $paramsLogResult = 'SUCCESS'; + + $params = array ('sessionId' => $sessionId,'caseId' => $caseId,'delIndex' => "1" + ); + $result = $client->__SoapCall( 'RouteCase', array ($params + ) ); + eprint( " - Routing the case #$caseNumber.............." ); + if ($result->status_code == 0) { + $paramsLog['WS_ROUTE_CASE_STATUS'] = strip_tags( $result->message ); + $retMsg = explode( "Debug", $paramsLog['WS_ROUTE_CASE_STATUS'] ); + $retMsg = $retMsg[0]; + eprintln( "OK+ $retMsg", 'green' ); + $paramsRouteLogResult = 'SUCCESS'; + } else { + eprintln( "FAILED-> {$paramsLog ['WS_ROUTE_CASE_STATUS']}", 'red' ); + $paramsLog['WS_ROUTE_CASE_STATUS'] = strip_tags( $result->message ); + $paramsRouteLogResult = 'FAILED'; + } + + } else { + $paramsLog['WS_CREATE_CASE_STATUS'] = strip_tags( $result->message ); + eprintln( "FAILED->{$paramsLog ['WS_CREATE_CASE_STATUS']}", 'red' ); + $paramsLogResult = 'FAILED'; + } + } else { // invalid user or bad password - eprintln( $result->message, 'red' ); - } - if ($paramsLogResult == 'SUCCESS' && $paramsRouteLogResult == 'SUCCESS') { - $paramsLog['RESULT'] = 'SUCCESS'; - } else { - $paramsLog['RESULT'] = 'FAILED'; - } - - $newCaseLog->saveLogParameters( $paramsLog ); - $newCaseLog->save(); - - if ($sOption != '4' && $sOption != '5') { - $nSchLastRunTime = $sActualTime; - $dEstimatedDate = $this->updateNextRun( $sOption, $sValue, $sActualTime, $sDaysPerformTask, $sWeeks, $sStartDay, $sMonths ); - - if ($aRow['SCH_END_DATE'] != '') { - if (date( "Y-m-d", strtotime( $dEstimatedDate ) ) > date( "Y-m-d", strtotime( $aRow['SCH_END_DATE'] ) )) { - $Fields = $this->Load( $sSchedulerUid ); - $Fields['SCH_LAST_STATE'] = $aRow['SCH_STATE']; - $Fields['SCH_STATE'] = 'PROCESSED'; - $this->Update( $Fields ); - } - } - $nSchTimeNextRun = $dEstimatedDate; - $this->updateDate( $sSchedulerUid, $nSchTimeNextRun, $nSchLastRunTime ); - } elseif ($sOption != '5') { - $Fields = $this->Load( $sSchedulerUid ); - $Fields['SCH_LAST_STATE'] = $aRow['SCH_STATE']; - $Fields['SCH_LAST_RUN_TIME'] = $Fields['SCH_TIME_NEXT_RUN']; - $Fields['SCH_STATE'] = 'PROCESSED'; - $this->Update( $Fields ); - } else { - $nSchLastRunTime = $sActualTime; - $Fields = $this->Load( $sSchedulerUid ); - $Fields['SCH_LAST_RUN_TIME'] = $Fields['SCH_TIME_NEXT_RUN']; - - $nSchTimeNextRun = strtotime( $Fields['SCH_TIME_NEXT_RUN'] ); - $nextRun = $Fields['SCH_REPEAT_EVERY'] * 60 * 60; - $nSchTimeNextRun += $nextRun; - $nSchTimeNextRun = date( "Y-m-d H:i", $nSchTimeNextRun ); - - $this->updateDate( $sSchedulerUid, $nSchTimeNextRun, $nSchLastRunTime ); - } - } - - $oDataset->next(); - } - - } - - public function updateDate ($sSchedulerUid = '', $sSchTimeNextRun = '', $sSchLastRunTime = '') - { - $Fields = $this->Load( $sSchedulerUid ); - $Fields['SCH_TIME_NEXT_RUN'] = strtotime( $sSchTimeNextRun ); - $Fields['SCH_LAST_RUN_TIME'] = strtotime( $sSchLastRunTime ); - $this->Update( $Fields ); - } - - public function updateNextRun ($sOption, $sValue = '', $sActualTime = '', $sDaysPerformTask = '', $sWeeks = '', $sStartDay = '', $sMonths = '', $currentDate = '') - { - $nActualDate = $currentDate . " " . $sActualTime; - // date("Y-m-d H:i:s", $sActualTime); - // date("Y-m-d H:i:s", $sActualTime); - $dEstimatedDate = ''; - switch ($sOption) { - case '1': - switch ($sValue) { - case '1': - $dEstimatedDate = date( 'Y-m-d H:i:s', strtotime( "$nActualDate +1 day" ) ); - break; - case '2': - $nDayOfTheWeek = date( 'w', strtotime( $sActualTime ) ); - $nDayOfTheWeek = ($nDayOfTheWeek == 0) ? 7 : $nDayOfTheWeek; - - if ($nDayOfTheWeek >= 5) { - $dEstimatedDate = date( 'Y-m-d H:i:s', strtotime( "$nActualDate +3 day" ) ); - } else { - $dEstimatedDate = date( 'Y-m-d H:i:s', strtotime( "$nActualDate +1 day" ) ); - } - break; - case '3': - $dEstimatedDate = date( 'Y-m-d H:i:s', strtotime( "$nActualDate + " . $sDaysPerformTask . " day" ) ); - break; - } - break; - - case '2': - if (strlen( $sWeeks ) > 0) { + eprintln( $result->message, 'red' ); + } + if ($paramsLogResult == 'SUCCESS' && $paramsRouteLogResult == 'SUCCESS') { + $paramsLog['RESULT'] = 'SUCCESS'; + } else { + $paramsLog['RESULT'] = 'FAILED'; + } + + $newCaseLog->saveLogParameters( $paramsLog ); + $newCaseLog->save(); + + if ($sOption != '4' && $sOption != '5') { + $nSchLastRunTime = $sActualTime; + $dEstimatedDate = $this->updateNextRun( $sOption, $sValue, $sActualTime, $sDaysPerformTask, $sWeeks, $sStartDay, $sMonths ); + + if ($aRow['SCH_END_DATE'] != '') { + if (date( "Y-m-d", strtotime( $dEstimatedDate ) ) > date( "Y-m-d", strtotime( $aRow['SCH_END_DATE'] ) )) { + $Fields = $this->Load( $sSchedulerUid ); + $Fields['SCH_LAST_STATE'] = $aRow['SCH_STATE']; + $Fields['SCH_STATE'] = 'PROCESSED'; + $this->Update( $Fields ); + } + } + $nSchTimeNextRun = $dEstimatedDate; + $this->updateDate( $sSchedulerUid, $nSchTimeNextRun, $nSchLastRunTime ); + } elseif ($sOption != '5') { + $Fields = $this->Load( $sSchedulerUid ); + $Fields['SCH_LAST_STATE'] = $aRow['SCH_STATE']; + $Fields['SCH_LAST_RUN_TIME'] = $Fields['SCH_TIME_NEXT_RUN']; + $Fields['SCH_STATE'] = 'PROCESSED'; + $this->Update( $Fields ); + } else { + $nSchLastRunTime = $sActualTime; + $Fields = $this->Load( $sSchedulerUid ); + $Fields['SCH_LAST_RUN_TIME'] = $Fields['SCH_TIME_NEXT_RUN']; + + $nSchTimeNextRun = strtotime( $Fields['SCH_TIME_NEXT_RUN'] ); + $nextRun = $Fields['SCH_REPEAT_EVERY'] * 60 * 60; + $nSchTimeNextRun += $nextRun; + $nSchTimeNextRun = date( "Y-m-d H:i", $nSchTimeNextRun ); + + $this->updateDate( $sSchedulerUid, $nSchTimeNextRun, $nSchLastRunTime ); + } + } + $oDataset->next(); + } + } + + public function updateDate ($sSchedulerUid = '', $sSchTimeNextRun = '', $sSchLastRunTime = '') + { + $Fields = $this->Load( $sSchedulerUid ); + $Fields['SCH_TIME_NEXT_RUN'] = strtotime( $sSchTimeNextRun ); + $Fields['SCH_LAST_RUN_TIME'] = strtotime( $sSchLastRunTime ); + $this->Update( $Fields ); + } + + public function updateNextRun ($sOption, $sValue = '', $sActualTime = '', $sDaysPerformTask = '', $sWeeks = '', $sStartDay = '', $sMonths = '', $currentDate = '') + { + $nActualDate = $currentDate . " " . $sActualTime; + $dEstimatedDate = ''; + switch ($sOption) { + case '1': + switch ($sValue) { + case '1': + $dEstimatedDate = date( 'Y-m-d H:i:s', strtotime( "$nActualDate +1 day" ) ); + break; + case '2': + $nDayOfTheWeek = date( 'w', strtotime( $sActualTime ) ); + $nDayOfTheWeek = ($nDayOfTheWeek == 0) ? 7 : $nDayOfTheWeek; + + if ($nDayOfTheWeek >= 5) { + $dEstimatedDate = date( 'Y-m-d H:i:s', strtotime( "$nActualDate +3 day" ) ); + } else { + $dEstimatedDate = date( 'Y-m-d H:i:s', strtotime( "$nActualDate +1 day" ) ); + } + break; + case '3': + $dEstimatedDate = date( 'Y-m-d H:i:s', strtotime( "$nActualDate + " . $sDaysPerformTask . " day" ) ); + break; + } + break; + case '2': + if (strlen( $sWeeks ) > 0) { //die($sActualTime); - $nDayOfTheWeek = date( 'w', strtotime( $sActualTime ) ); + $nDayOfTheWeek = date( 'w', strtotime( $sActualTime ) ); //$nDayOfTheWeek = 1; //echo "*".$nDayOfTheWeek."*"; - $aWeeks = explode( '|', $sWeeks ); - $nFirstDay = $aWeeks[0]; - $aDaysWeek = array ('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'); - $nFirstDay = $nFirstDay - 1; + $aWeeks = explode( '|', $sWeeks ); + $nFirstDay = $aWeeks[0]; + $aDaysWeek = array ('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'); + $nFirstDay = $nFirstDay - 1; //echo "¨¨".$nFirstDay."¨¨"; - $nDayOfTheWeek = ($nDayOfTheWeek == 0) ? 7 : $nDayOfTheWeek; + $nDayOfTheWeek = ($nDayOfTheWeek == 0) ? 7 : $nDayOfTheWeek; //echo $nDayOfTheWeek; - $nSW = 0; - $nNextDay = 0; - foreach ($aWeeks as $value) { - if ($value > $nDayOfTheWeek) { - $nNextDay = $value - 1; - $nSW = 1; - break; - } - } - - //die; - if ($nSW == 1) { - $dEstimatedDate = date( 'Y-m-d', strtotime( "$nActualDate next " . $aDaysWeek[$nNextDay] ) ) . ' ' . date( 'H:i:s', strtotime( $sActualTime ) ); - //print_r($dEstimatedDate); - // die("03"); - } else { - $nEveryDays = $sDaysPerformTask; + $nSW = 0; + $nNextDay = 0; + foreach ($aWeeks as $value) { + if ($value > $nDayOfTheWeek) { + $nNextDay = $value - 1; + $nSW = 1; + break; + } + } + if ($nSW == 1) { + $dEstimatedDate = date( 'Y-m-d', strtotime( "$nActualDate next " . $aDaysWeek[$nNextDay] ) ) . ' ' . date( 'H:i:s', strtotime( $sActualTime ) ); + } else { + $nEveryDays = $sDaysPerformTask; // $nEveryDays = '1'; - if ($nFirstDay >= $nDayOfTheWeek || $nEveryDays == 1) { - $sTypeOperation = "next"; - } else { - $sTypeOperation = "last"; - } - - if ($nEveryDays == 1) { + if ($nFirstDay >= $nDayOfTheWeek || $nEveryDays == 1) { + $sTypeOperation = "next"; + } else { + $sTypeOperation = "last"; + } + + if ($nEveryDays == 1) { //echo "**** $nActualDate *" . $sTypeOperation . "* *" . $aDaysWeek[$nFirstDay] . '*****' . date('H:i:s', strtotime($sActualTime)). "**"; - $dEstimatedDate = date( 'Y-m-d', strtotime( "$nActualDate " . $sTypeOperation . " " . $aDaysWeek[$nFirstDay] ) ) . ' ' . date( 'H:i:s', strtotime( $sActualTime ) ); + $dEstimatedDate = date( 'Y-m-d', strtotime( "$nActualDate " . $sTypeOperation . " " . $aDaysWeek[$nFirstDay] ) ) . ' ' . date( 'H:i:s', strtotime( $sActualTime ) ); //echo "(date)*".$dEstimatedDate."*"; //die("01"); - } else { - $nEveryDays = 1; + } else { + $nEveryDays = 1; //$nActualDate = date('Y-m-d').' '.$sActualTime; - $nDataTmp = date( 'Y-m-d', strtotime( "$nActualDate + " . $nEveryDays . " Week" ) ); - //echo "$nActualDate + " . $nEveryDays . " Week "; - //echo "++"; - //echo strtotime( "+".$nEveryDays . " week"), "\n"; - //echo strtotime("$nActualDate +" . $nEveryDays . " Week "); - //echo "++"; - //echo $nDataTmp; - //echo "--"; - //echo $sTypeOperation; - //echo $nFirstDay; - //print_r ($aDaysWeek); - //$sTypeOperation = "next"; - $dEstimatedDate = date( 'Y-m-d', strtotime( "$nDataTmp " . $sTypeOperation . " " . $aDaysWeek[$nFirstDay] ) ) . ' ' . date( 'H:i:s', strtotime( $sActualTime ) ); - //echo (strtotime ("$nDataTmp " . $sTypeOperation . " " . $aDaysWeek[$nFirstDay])); - //echo "$nDataTmp " . $sTypeOperation . " " . $aDaysWeek[$nFirstDay]; - //echo $dEstimatedDate; - //echo "--"; - //echo date('Y-m-d', strtotime ("$nDataTmp " . $sTypeOperation . " " . $aDaysWeek[$nFirstDay])) . ' ' . date('H:i:s', strtotime($sActualTime)); - //die("02"); - } - //die("03"); - } - } - break; - case '3': - if (strlen( $sMonths ) > 0) { // Must have at least one selected month + $nDataTmp = date( 'Y-m-d', strtotime( "$nActualDate + " . $nEveryDays . " Week" ) ); + $dEstimatedDate = date( 'Y-m-d', strtotime( "$nDataTmp " . $sTypeOperation . " " . $aDaysWeek[$nFirstDay] ) ) . ' ' . date( 'H:i:s', strtotime( $sActualTime ) ); + } + } + } + break; + case '3': + if (strlen( $sMonths ) > 0) { + // Must have at least one selected month // Calculamos para la siguiente ejecucion, acorde a lo seleccionado - $aStartDay = explode( '|', $sStartDay ); - $nYear = date( "Y", strtotime( $sActualTime ) ); - $nCurrentMonth = date( "m", strtotime( $sActualTime ) ); - $nCurrentDay = date( "d", strtotime( $sActualTime ) ); - $aMonths = explode( '|', $sMonths ); - - $nSW = 0; - $nNextMonth = 0; - foreach ($aMonths as $value) { - if ($value > $nCurrentMonth) { - $nNextMonth = $value - 1; - $nSW = 1; - break; - } - } - - if ($nSW == 1) { // Mes encontrado - $nExecNextMonth = $nNextMonth; - } else { - $nExecNextMonth = $aMonths[0] - 1; - $nYear ++; - } - - switch ($sValue) { - case '1': - $nExecNextMonth ++; - $nCurrentDay = $aStartDay[1]; - $dEstimatedDate = date( 'Y-m-d', strtotime( "$nYear-$nExecNextMonth-$nCurrentDay" ) ) . ' ' . date( 'H:i:s', strtotime( $sActualTime ) ); - break; - case '2': - $aMontsShort = array ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); - $aWeeksShort = array ('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'); - $sNumDayWeek = $aStartDay[1]; - $sDayWeek = ($aStartDay[2] == 7 ? 0 : $aStartDay[2]); - switch ($sNumDayWeek) { - case '1': - $sDaysWeekOpt = "+0"; - break; - case '2': - $sDaysWeekOpt = "+1"; - break; - case '3': - $sDaysWeekOpt = "+2"; - break; - case '4': - $sDaysWeekOpt = "+3"; - break; - case '5': - $sDaysWeekOpt = "-1"; - $nExecNextMonth ++; - if ($nExecNextMonth >= 12) { - $nExecNextMonth = 0; - $nYear ++; - } - break; - } - $dEstimatedDate = date( 'Y-m-d', strtotime( $sDaysWeekOpt . ' week ' . $aWeeksShort[$sDayWeek - 1] . ' ' . $aMontsShort[$nExecNextMonth] . ' ' . $nYear ) ) . ' ' . date( 'H:i:s', strtotime( $sActualTime ) ); - // krumo($nExecNextMonth, $sDayWeek); - // krumo($sDaysWeekOpt . ' week ' . $aWeeksShort[$sDayWeek-1] . ' ' . $aMontsShort[$nExecNextMonth] . ' ' . $nYear); - break; - } - - } - break; - } - return $dEstimatedDate; - } - - public function Exists ($sUid) - { - try { - $oObj = CaseSchedulerPeer::retrieveByPk( $sUid ); - return (is_object( $oObj ) && get_class( $oObj ) == 'CaseScheduler'); - } catch (Exception $oError) { - throw ($oError); - } - } -} -// CaseScheduler + $aStartDay = explode( '|', $sStartDay ); + $nYear = date( "Y", strtotime( $sActualTime ) ); + $nCurrentMonth = date( "m", strtotime( $sActualTime ) ); + $nCurrentDay = date( "d", strtotime( $sActualTime ) ); + $aMonths = explode( '|', $sMonths ); + + $nSW = 0; + $nNextMonth = 0; + foreach ($aMonths as $value) { + if ($value > $nCurrentMonth) { + $nNextMonth = $value - 1; + $nSW = 1; + break; + } + } + + if ($nSW == 1) { + $nExecNextMonth = $nNextMonth; + } else { + $nExecNextMonth = $aMonths[0] - 1; + $nYear ++; + } + + switch ($sValue) { + case '1': + $nExecNextMonth ++; + $nCurrentDay = $aStartDay[1]; + $dEstimatedDate = date( 'Y-m-d', strtotime( "$nYear-$nExecNextMonth-$nCurrentDay" ) ) . ' ' . date( 'H:i:s', strtotime( $sActualTime ) ); + break; + case '2': + $aMontsShort = array ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); + $aWeeksShort = array ('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'); + $sNumDayWeek = $aStartDay[1]; + $sDayWeek = ($aStartDay[2] == 7 ? 0 : $aStartDay[2]); + switch ($sNumDayWeek) { + case '1': + $sDaysWeekOpt = "+0"; + break; + case '2': + $sDaysWeekOpt = "+1"; + break; + case '3': + $sDaysWeekOpt = "+2"; + break; + case '4': + $sDaysWeekOpt = "+3"; + break; + case '5': + $sDaysWeekOpt = "-1"; + $nExecNextMonth ++; + if ($nExecNextMonth >= 12) { + $nExecNextMonth = 0; + $nYear ++; + } + break; + } + $dEstimatedDate = date( 'Y-m-d', strtotime( $sDaysWeekOpt . ' week ' . $aWeeksShort[$sDayWeek - 1] . ' ' . $aMontsShort[$nExecNextMonth] . ' ' . $nYear ) ) . ' ' . date( 'H:i:s', strtotime( $sActualTime ) ); + break; + } + } + break; + } + return $dEstimatedDate; + } + + public function Exists ($sUid) + { + try { + $oObj = CaseSchedulerPeer::retrieveByPk( $sUid ); + return (is_object( $oObj ) && get_class( $oObj ) == 'CaseScheduler'); + } catch (Exception $oError) { + throw ($oError); + } + } +} diff --git a/workflow/engine/classes/model/CaseSchedulerPeer.php b/workflow/engine/classes/model/CaseSchedulerPeer.php index 0910bb1cf..99f987afa 100755 --- a/workflow/engine/classes/model/CaseSchedulerPeer.php +++ b/workflow/engine/classes/model/CaseSchedulerPeer.php @@ -14,7 +14,7 @@ /** * Skeleton subclass for performing query and update operations on the 'CASE_SCHEDULER' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -22,6 +22,7 @@ * * @package workflow.engine.classes.model */ -class CaseSchedulerPeer extends BaseCaseSchedulerPeer { +class CaseSchedulerPeer extends BaseCaseSchedulerPeer +{ +} -} // CaseSchedulerPeer diff --git a/workflow/engine/classes/model/CaseTracker.php b/workflow/engine/classes/model/CaseTracker.php index b439443f4..ca965cb58 100755 --- a/workflow/engine/classes/model/CaseTracker.php +++ b/workflow/engine/classes/model/CaseTracker.php @@ -20,7 +20,6 @@ require_once 'classes/model/om/BaseCaseTracker.php'; */ class CaseTracker extends BaseCaseTracker { - public function load ($sProcessUID) { try { @@ -110,7 +109,7 @@ class CaseTracker extends BaseCaseTracker } } - function caseTrackerExists ($sUid) + public function caseTrackerExists ($sUid) { try { $oObj = CaseTrackerPeer::retrieveByPk( $sUid ); @@ -120,5 +119,4 @@ class CaseTracker extends BaseCaseTracker } } } -// CaseTracker diff --git a/workflow/engine/classes/model/CaseTrackerObject.php b/workflow/engine/classes/model/CaseTrackerObject.php index aaebf2883..f21f08121 100755 --- a/workflow/engine/classes/model/CaseTrackerObject.php +++ b/workflow/engine/classes/model/CaseTrackerObject.php @@ -116,7 +116,7 @@ class CaseTrackerObject extends BaseCaseTrackerObject } } - function reorderPositions ($sProcessUID, $iPosition) + public function reorderPositions ($sProcessUID, $iPosition) { try { $oCriteria = new Criteria( 'workflow' ); @@ -135,7 +135,7 @@ class CaseTrackerObject extends BaseCaseTrackerObject } } - function caseTrackerObjectExists ($Uid) + public function caseTrackerObjectExists ($Uid) { try { $oObj = CaseTrackerObjectPeer::retrieveByPk( $Uid ); @@ -149,7 +149,7 @@ class CaseTrackerObject extends BaseCaseTrackerObject } } - function removeByObject ($sType, $sObjUid) + public function removeByObject ($sType, $sObjUid) { try { $oCriteria = new Criteria( 'workflow' ); @@ -161,5 +161,4 @@ class CaseTrackerObject extends BaseCaseTrackerObject } } } -// CaseTrackerObject diff --git a/workflow/engine/classes/model/CaseTrackerObjectPeer.php b/workflow/engine/classes/model/CaseTrackerObjectPeer.php index 7b386795b..6e03b8ecb 100755 --- a/workflow/engine/classes/model/CaseTrackerObjectPeer.php +++ b/workflow/engine/classes/model/CaseTrackerObjectPeer.php @@ -14,7 +14,7 @@ /** * Skeleton subclass for performing query and update operations on the 'CASE_TRACKER_OBJECT' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -22,6 +22,7 @@ * * @package workflow.engine.classes.model */ -class CaseTrackerObjectPeer extends BaseCaseTrackerObjectPeer { +class CaseTrackerObjectPeer extends BaseCaseTrackerObjectPeer +{ +} -} // CaseTrackerObjectPeer diff --git a/workflow/engine/classes/model/CaseTrackerPeer.php b/workflow/engine/classes/model/CaseTrackerPeer.php index 9bf9d0c81..b90759a47 100755 --- a/workflow/engine/classes/model/CaseTrackerPeer.php +++ b/workflow/engine/classes/model/CaseTrackerPeer.php @@ -14,7 +14,7 @@ /** * Skeleton subclass for performing query and update operations on the 'CASE_TRACKER' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -22,6 +22,7 @@ * * @package workflow.engine.classes.model */ -class CaseTrackerPeer extends BaseCaseTrackerPeer { +class CaseTrackerPeer extends BaseCaseTrackerPeer +{ +} -} // CaseTrackerPeer diff --git a/workflow/engine/classes/model/Configuration.php b/workflow/engine/classes/model/Configuration.php index 8836e4874..4b8d90a41 100755 --- a/workflow/engine/classes/model/Configuration.php +++ b/workflow/engine/classes/model/Configuration.php @@ -39,108 +39,96 @@ require_once 'classes/model/Content.php'; * * @package workflow.engine.classes.model */ -class Configuration extends BaseConfiguration { - public function create($aData) - { - $con = Propel::getConnection(ConfigurationPeer::DATABASE_NAME); - try +class Configuration extends BaseConfiguration +{ + public function create($aData) { - $con->begin(); - $this->setCfgUid($aData['CFG_UID']); - $this->setObjUid($aData['OBJ_UID']); - $this->setCfgValue(isset($aData['CFG_VALUE'])?$aData['CFG_VALUE']:''); - $this->setProUid($aData['PRO_UID']); - $this->setUsrUid($aData['USR_UID']); - $this->setAppUid($aData['APP_UID']); - if($this->validate()) - { - $result=$this->save(); - $con->commit(); - return $result; - } - else - { - $con->rollback(); - throw(new Exception("Failed Validation in class ".get_class($this).".")); - } + $con = Propel::getConnection(ConfigurationPeer::DATABASE_NAME); + try { + $con->begin(); + $this->setCfgUid($aData['CFG_UID']); + $this->setObjUid($aData['OBJ_UID']); + $this->setCfgValue(isset($aData['CFG_VALUE'])?$aData['CFG_VALUE']:''); + $this->setProUid($aData['PRO_UID']); + $this->setUsrUid($aData['USR_UID']); + $this->setAppUid($aData['APP_UID']); + if ($this->validate()) { + $result=$this->save(); + $con->commit(); + return $result; + } else { + $con->rollback(); + throw(new Exception("Failed Validation in class ".get_class($this).".")); + } + } catch (Exception $e) { + $con->rollback(); + throw($e); + } } - catch(Exception $e) + + public function load($CfgUid, $ObjUid = '', $ProUid = '', $UsrUid = '', $AppUid = '') { - $con->rollback(); - throw($e); + try { + $oRow = ConfigurationPeer::retrieveByPK( $CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid ); + if (!is_null($oRow)) { + $aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME); + $this->fromArray($aFields,BasePeer::TYPE_FIELDNAME); + $this->setNew(false); + return $aFields; + } else { + throw(new Exception( "The row '$CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid' in table Configuration doesn't exist!" )); + } + } catch (Exception $oError) { + throw($oError); + } } - } - public function load($CfgUid, $ObjUid='', $ProUid='', $UsrUid='', $AppUid='') - { - try { - $oRow = ConfigurationPeer::retrieveByPK( $CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid ); - if (!is_null($oRow)) - { - $aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME); - $this->fromArray($aFields,BasePeer::TYPE_FIELDNAME); - $this->setNew(false); - return $aFields; - } - else { - throw(new Exception( "The row '$CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid' in table Configuration doesn't exist!" )); - } - } - catch (Exception $oError) { - throw($oError); - } - } - public function update($fields) - { - $con = Propel::getConnection(ConfigurationPeer::DATABASE_NAME); - try + + public function update($fields) { - $con->begin(); - $this->load($fields['CFG_UID'], $fields['OBJ_UID'], $fields['PRO_UID'], $fields['USR_UID'], $fields['APP_UID']); - $this->fromArray($fields,BasePeer::TYPE_FIELDNAME); - if($this->validate()) - { - $contentResult=0; - $result=$this->save(); - $result=($result==0)?($contentResult>0?1:0):$result; - $con->commit(); - return $result; - } - else - { - $con->rollback(); - throw(new Exception("Failed Validation in class ".get_class($this).".")); - } + $con = Propel::getConnection(ConfigurationPeer::DATABASE_NAME); + try { + $con->begin(); + $this->load($fields['CFG_UID'], $fields['OBJ_UID'], $fields['PRO_UID'], $fields['USR_UID'], $fields['APP_UID']); + $this->fromArray($fields,BasePeer::TYPE_FIELDNAME); + if ($this->validate()) { + $contentResult=0; + $result=$this->save(); + $result=($result==0)?($contentResult>0?1:0):$result; + $con->commit(); + return $result; + } else { + $con->rollback(); + throw(new Exception("Failed Validation in class ".get_class($this).".")); + } + } catch (Exception $e) { + $con->rollback(); + throw($e); + } } - catch(Exception $e) + + public function remove($CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid) { - $con->rollback(); - throw($e); + $con = Propel::getConnection(ConfigurationPeer::DATABASE_NAME); + try { + $con->begin(); + $this->setCfgUid($CfgUid); + $this->setObjUid($ObjUid); + $this->setProUid($ProUid); + $this->setUsrUid($UsrUid); + $this->setAppUid($AppUid); + $result=$this->delete(); + $con->commit(); + return $result; + } catch (Exception $e) { + $con->rollback(); + throw($e); + } } - } - public function remove($CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid) - { - $con = Propel::getConnection(ConfigurationPeer::DATABASE_NAME); - try + + public function exists($CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid) { - $con->begin(); - $this->setCfgUid($CfgUid); - $this->setObjUid($ObjUid); - $this->setProUid($ProUid); - $this->setUsrUid($UsrUid); - $this->setAppUid($AppUid); - $result=$this->delete(); - $con->commit(); - return $result; + $oRow = ConfigurationPeer::retrieveByPK( $CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid ); + return (( get_class ($oRow) == 'Configuration' )&&(!is_null($oRow))); } - catch(Exception $e) - { - $con->rollback(); - throw($e); - } - } - public function exists($CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid) - { - $oRow = ConfigurationPeer::retrieveByPK( $CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid ); - return (( get_class ($oRow) == 'Configuration' )&&(!is_null($oRow))); - } -} // Configuration +} + diff --git a/workflow/engine/classes/model/ConfigurationPeer.php b/workflow/engine/classes/model/ConfigurationPeer.php index 5e6ebf5a4..e3d515134 100755 --- a/workflow/engine/classes/model/ConfigurationPeer.php +++ b/workflow/engine/classes/model/ConfigurationPeer.php @@ -2,10 +2,10 @@ /** * ConfigurationPeer.php * @package workflow.engine.classes.model - * + * * ProcessMaker Open Source Edition * Copyright (C) 2004 - 2011 Colosa Inc. - * + * * 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 @@ -15,13 +15,13 @@ * 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 . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * + * */ // include base peer class @@ -34,7 +34,7 @@ /** * Skeleton subclass for performing query and update operations on the 'CONFIGURATION' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -42,6 +42,7 @@ * * @package workflow.engine.classes.model */ -class ConfigurationPeer extends BaseConfigurationPeer { +class ConfigurationPeer extends BaseConfigurationPeer +{ +} -} // ConfigurationPeer diff --git a/workflow/engine/classes/model/Content.php b/workflow/engine/classes/model/Content.php index 654e3fb85..2e2df381a 100755 --- a/workflow/engine/classes/model/Content.php +++ b/workflow/engine/classes/model/Content.php @@ -1,107 +1,109 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -require_once 'classes/model/om/BaseContent.php'; - -/** - * Skeleton subclass for representing a row from the 'CONTENT' table. - * - * - * - * You should add additional methods to this class to meet the - * application requirements. This class will only be generated as - * long as it does not already exist in the output directory. - * - * @package workflow.engine.classes.model - */ -class Content extends BaseContent -{ - public $langs; - public $rowsProcessed; - public $rowsInserted; - public $rowsUnchanged; - public $rowsClustered; - public $langsAsoc; +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + */ + +require_once 'classes/model/om/BaseContent.php'; + +/** + * Skeleton subclass for representing a row from the 'CONTENT' table. + * + * + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + * + * @package workflow.engine.classes.model + */ +class Content extends BaseContent +{ + public $langs; + public $rowsProcessed; + public $rowsInserted; + public $rowsUnchanged; + public $rowsClustered; + public $langsAsoc; /* - * Load the content row specified by the parameters: - * @param string $sUID - * @return variant - */ - public function load ($ConCategory, $ConParent, $ConId, $ConLang) - { - $content = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $ConLang ); - if (is_null( $content )) { - //we dont find any value for this field and language in CONTENT table; - $ConValue = Content::autoLoadSave( $ConCategory, $ConParent, $ConId, $ConLang ); - } else { - //krumo($content); - $ConValue = $content->getConValue(); - if ($ConValue == "") { - //try to find a valid translation - $ConValue = Content::autoLoadSave( $ConCategory, $ConParent, $ConId, $ConLang ); - } - } - return $ConValue; - } + * Load the content row specified by the parameters: + * @param string $sUID + * @return variant + */ + public function load ($ConCategory, $ConParent, $ConId, $ConLang) + { + $content = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $ConLang ); + if (is_null( $content )) { + //we dont find any value for this field and language in CONTENT table; + $ConValue = Content::autoLoadSave( $ConCategory, $ConParent, $ConId, $ConLang ); + } else { + //krumo($content); + $ConValue = $content->getConValue(); + if ($ConValue == "") { + //try to find a valid translation + $ConValue = Content::autoLoadSave( $ConCategory, $ConParent, $ConId, $ConLang ); + } + } + return $ConValue; + } + /* - * Find a valid Lang for current Content. The most recent - * @param string $ConCategory - * @param string $ConParent - * @param string $ConId - * @return string - * - */ - public function getDefaultContentLang ($ConCategory, $ConParent, $ConId, $destConLang) - { - $Criteria = new Criteria( 'workflow' ); - $Criteria->clearSelectColumns()->clearOrderByColumns(); - - $Criteria->addSelectColumn( ContentPeer::CON_CATEGORY ); - $Criteria->addSelectColumn( ContentPeer::CON_PARENT ); - $Criteria->addSelectColumn( ContentPeer::CON_ID ); - $Criteria->addSelectColumn( ContentPeer::CON_LANG ); - $Criteria->addSelectColumn( ContentPeer::CON_VALUE ); - - $Criteria->add( ContentPeer::CON_CATEGORY, $ConCategory, CRITERIA::EQUAL ); - $Criteria->add( ContentPeer::CON_PARENT, $ConParent, CRITERIA::EQUAL ); - $Criteria->add( ContentPeer::CON_ID, $ConId, CRITERIA::EQUAL ); - $Criteria->add( ContentPeer::CON_LANG, $destConLang, CRITERIA::NOT_EQUAL ); - - $rs = ContentPeer::doSelectRS( $Criteria ); - $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $rs->next(); - - if (is_array( $row = $rs->getRow() )) { - $defaultLang = $row['CON_LANG']; - } else { - $defaultLang = ""; - } - return ($defaultLang); - } + * Find a valid Lang for current Content. The most recent + * @param string $ConCategory + * @param string $ConParent + * @param string $ConId + * @return string + * + */ + public function getDefaultContentLang ($ConCategory, $ConParent, $ConId, $destConLang) + { + $Criteria = new Criteria( 'workflow' ); + $Criteria->clearSelectColumns()->clearOrderByColumns(); + + $Criteria->addSelectColumn( ContentPeer::CON_CATEGORY ); + $Criteria->addSelectColumn( ContentPeer::CON_PARENT ); + $Criteria->addSelectColumn( ContentPeer::CON_ID ); + $Criteria->addSelectColumn( ContentPeer::CON_LANG ); + $Criteria->addSelectColumn( ContentPeer::CON_VALUE ); + + $Criteria->add( ContentPeer::CON_CATEGORY, $ConCategory, CRITERIA::EQUAL ); + $Criteria->add( ContentPeer::CON_PARENT, $ConParent, CRITERIA::EQUAL ); + $Criteria->add( ContentPeer::CON_ID, $ConId, CRITERIA::EQUAL ); + $Criteria->add( ContentPeer::CON_LANG, $destConLang, CRITERIA::NOT_EQUAL ); + + $rs = ContentPeer::doSelectRS( $Criteria ); + $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $rs->next(); + + if (is_array( $row = $rs->getRow() )) { + $defaultLang = $row['CON_LANG']; + } else { + $defaultLang = ""; + } + return ($defaultLang); + } + /* * Load the content row and the Save automatically the row for the destination language * @param string $ConCategory @@ -110,204 +112,204 @@ class Content extends BaseContent * @param string $destConLang * @return string * if the row doesn't exist, it will be created automatically, even the default 'en' language - */ - public function autoLoadSave ($ConCategory, $ConParent, $ConId, $destConLang) - { + */ + public function autoLoadSave ($ConCategory, $ConParent, $ConId, $destConLang) + { //search in 'en' language, the default language - $content = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, 'en' ); - - if ((is_null( $content )) || ($content->getConValue() == "")) { - $differentLang = Content::getDefaultContentLang( $ConCategory, $ConParent, $ConId, $destConLang ); - $content = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $differentLang ); - } - + $content = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, 'en' ); + + if ((is_null( $content )) || ($content->getConValue() == "")) { + $differentLang = Content::getDefaultContentLang( $ConCategory, $ConParent, $ConId, $destConLang ); + $content = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $differentLang ); + } + //to do: review if the $destConLang is a valid language/ - if (is_null( $content )) { - $ConValue = ''; + if (is_null( $content )) { + $ConValue = ''; //we dont find any value for this field and language in CONTENT table - } else { - $ConValue = $content->getConValue(); - } - - try { - $con = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $destConLang ); - if (is_null( $con )) { - $con = new Content(); - } - $con->setConCategory( $ConCategory ); - $con->setConParent( $ConParent ); - $con->setConId( $ConId ); - $con->setConLang( $destConLang ); - $con->setConValue( $ConValue ); - if ($con->validate()) { - $res = $con->save(); - } - } catch (Exception $e) { - throw ($e); - } - - return $ConValue; - } - + } else { + $ConValue = $content->getConValue(); + } + + try { + $con = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $destConLang ); + if (is_null( $con )) { + $con = new Content(); + } + $con->setConCategory( $ConCategory ); + $con->setConParent( $ConParent ); + $con->setConId( $ConId ); + $con->setConLang( $destConLang ); + $con->setConValue( $ConValue ); + if ($con->validate()) { + $res = $con->save(); + } + } catch (Exception $e) { + throw ($e); + } + + return $ConValue; + } + /* - * Insert a content row - * @param string $ConCategory - * @param string $ConParent - * @param string $ConId - * @param string $ConLang - * @param string $ConValue - * @return variant - */ - public function addContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) - { - try { - if ($ConLang != 'en') { - $baseLangContent = ContentPeer::retrieveByPk( $ConCategory, $ConParent, $ConId, 'en' ); - if ($baseLangContent === null) { - Content::addContent( $ConCategory, $ConParent, $ConId, 'en', $ConValue ); - } - } - - $con = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $ConLang ); - - if (is_null( $con )) { - $con = new Content(); - } else { - if ($con->getConParent() == $ConParent && $con->getConCategory() == $ConCategory && $con->getConValue() == $ConValue && $con->getConLang() == $ConLang && $con->getConId() == $ConId) { - return true; - } - } - $con->setConCategory( $ConCategory ); - if ($con->getConParent() != $ConParent) { - $con->setConParent( $ConParent ); - } - $con->setConId( $ConId ); - $con->setConLang( $ConLang ); - $con->setConValue( $ConValue ); - if ($con->validate()) { - $res = $con->save(); - return $res; - } else { - $e = new Exception( "Error in addcontent, the row $ConCategory, $ConParent, $ConId, $ConLang is not Valid" ); - throw ($e); - } - } catch (Exception $e) { - throw ($e); - } - } - + * Insert a content row + * @param string $ConCategory + * @param string $ConParent + * @param string $ConId + * @param string $ConLang + * @param string $ConValue + * @return variant + */ + public function addContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) + { + try { + if ($ConLang != 'en') { + $baseLangContent = ContentPeer::retrieveByPk( $ConCategory, $ConParent, $ConId, 'en' ); + if ($baseLangContent === null) { + Content::addContent( $ConCategory, $ConParent, $ConId, 'en', $ConValue ); + } + } + + $con = ContentPeer::retrieveByPK( $ConCategory, $ConParent, $ConId, $ConLang ); + + if (is_null( $con )) { + $con = new Content(); + } else { + if ($con->getConParent() == $ConParent && $con->getConCategory() == $ConCategory && $con->getConValue() == $ConValue && $con->getConLang() == $ConLang && $con->getConId() == $ConId) { + return true; + } + } + $con->setConCategory( $ConCategory ); + if ($con->getConParent() != $ConParent) { + $con->setConParent( $ConParent ); + } + $con->setConId( $ConId ); + $con->setConLang( $ConLang ); + $con->setConValue( $ConValue ); + if ($con->validate()) { + $res = $con->save(); + return $res; + } else { + $e = new Exception( "Error in addcontent, the row $ConCategory, $ConParent, $ConId, $ConLang is not Valid" ); + throw ($e); + } + } catch (Exception $e) { + throw ($e); + } + } + /* - * Insert a content row - * @param string $ConCategory - * @param string $ConParent - * @param string $ConId - * @param string $ConLang - * @param string $ConValue - * @return variant - */ - public function insertContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) - { - try { - $con = new Content(); - $con->setConCategory( $ConCategory ); - $con->setConParent( $ConParent ); - $con->setConId( $ConId ); - $con->setConLang( $ConLang ); - $con->setConValue( $ConValue ); - if ($con->validate()) { - $res = $con->save(); - return $res; - } else { - $e = new Exception( "Error in addcontent, the row $ConCategory, $ConParent, $ConId, $ConLang is not Valid" ); - throw ($e); - } - } catch (Exception $e) { - throw ($e); - } - } - + * Insert a content row + * @param string $ConCategory + * @param string $ConParent + * @param string $ConId + * @param string $ConLang + * @param string $ConValue + * @return variant + */ + public function insertContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) + { + try { + $con = new Content(); + $con->setConCategory( $ConCategory ); + $con->setConParent( $ConParent ); + $con->setConId( $ConId ); + $con->setConLang( $ConLang ); + $con->setConValue( $ConValue ); + if ($con->validate()) { + $res = $con->save(); + return $res; + } else { + $e = new Exception( "Error in addcontent, the row $ConCategory, $ConParent, $ConId, $ConLang is not Valid" ); + throw ($e); + } + } catch (Exception $e) { + throw ($e); + } + } + /* - * remove a content row - * @param string $ConCategory - * @param string $ConParent - * @param string $ConId - * @param string $ConLang - * @param string $ConValue - * @return variant - */ - public function removeContent ($ConCategory, $ConParent, $ConId) - { - try { - $c = new Criteria(); - $c->add( ContentPeer::CON_CATEGORY, $ConCategory ); - $c->add( ContentPeer::CON_PARENT, $ConParent ); - $c->add( ContentPeer::CON_ID, $ConId ); - $result = ContentPeer::doSelectRS( $c ); - $result->next(); - $row = $result->getRow(); - while (is_array( $row )) { - ContentPeer::doDelete( array ($ConCategory,$ConParent,$ConId,$row[3]) ); - $result->next(); - $row = $result->getRow(); - } - } catch (Exception $e) { - throw ($e); - } - - } - + * remove a content row + * @param string $ConCategory + * @param string $ConParent + * @param string $ConId + * @param string $ConLang + * @param string $ConValue + * @return variant + */ + public function removeContent ($ConCategory, $ConParent, $ConId) + { + try { + $c = new Criteria(); + $c->add( ContentPeer::CON_CATEGORY, $ConCategory ); + $c->add( ContentPeer::CON_PARENT, $ConParent ); + $c->add( ContentPeer::CON_ID, $ConId ); + $result = ContentPeer::doSelectRS( $c ); + $result->next(); + $row = $result->getRow(); + while (is_array( $row )) { + ContentPeer::doDelete( array ($ConCategory,$ConParent,$ConId,$row[3]) ); + $result->next(); + $row = $result->getRow(); + } + } catch (Exception $e) { + throw ($e); + } + + } + /* - * Reasons if the record already exists - * - * @param string $ConCategory - * @param string $ConParent - * @param string $ConId - * @param string $ConLang - * @param string $ConValue - * @return boolean true or false - */ - public function Exists ($ConCategory, $ConParent, $ConId, $ConLang) - { - try { - $oPro = ContentPeer::retrieveByPk( $ConCategory, $ConParent, $ConId, $ConLang ); - if (is_object( $oPro ) && get_class( $oPro ) == 'Content') { - return true; - } else { - return false; - } - } catch (Exception $oError) { - throw ($oError); - } - } - + * Reasons if the record already exists + * + * @param string $ConCategory + * @param string $ConParent + * @param string $ConId + * @param string $ConLang + * @param string $ConValue + * @return boolean true or false + */ + public function Exists ($ConCategory, $ConParent, $ConId, $ConLang) + { + try { + $oPro = ContentPeer::retrieveByPk( $ConCategory, $ConParent, $ConId, $ConLang ); + if (is_object( $oPro ) && get_class( $oPro ) == 'Content') { + return true; + } else { + return false; + } + } catch (Exception $oError) { + throw ($oError); + } + } + /* * Regenerate Table Content * * @param array $langs - */ - public function regenerateContent ($langs, $workSpace = SYS_SYS) - { + */ + public function regenerateContent ($langs, $workSpace = SYS_SYS) + { //Search the language - $key = array_search( 'en', $langs ); - if ($key === false) { - $key = array_search( SYS_LANG, $langs ); - if ($key === false) { - $key = '0'; - } - } - $this->langsAsoc = array (); - foreach ($langs as $key => $value) { - $this->langsAsoc[$value] = $value; - } - - $this->langs = $langs; - $this->rowsProcessed = 0; - $this->rowsInserted = 0; - $this->rowsUnchanged = 0; - $this->rowsClustered = 0; - + $key = array_search( 'en', $langs ); + if ($key === false) { + $key = array_search( SYS_LANG, $langs ); + if ($key === false) { + $key = '0'; + } + } + $this->langsAsoc = array (); + foreach ($langs as $key => $value) { + $this->langsAsoc[$value] = $value; + } + + $this->langs = $langs; + $this->rowsProcessed = 0; + $this->rowsInserted = 0; + $this->rowsUnchanged = 0; + $this->rowsClustered = 0; + //Creating table CONTENT_BACKUP - $oConnection = Propel::getConnection( 'workflow' ); + $oConnection = Propel::getConnection( 'workflow' ); $oStatement = $oConnection->prepareStatement( "CREATE TABLE IF NOT EXISTS `CONTENT_BACKUP` ( `CON_CATEGORY` VARCHAR(30) default '' NOT NULL, `CON_PARENT` VARCHAR(32) default '' NOT NULL, @@ -315,171 +317,171 @@ class Content extends BaseContent `CON_LANG` VARCHAR(10) default '' NOT NULL, `CON_VALUE` MEDIUMTEXT NOT NULL, CONSTRAINT CONTENT_BACKUP_PK PRIMARY KEY (CON_CATEGORY,CON_PARENT,CON_ID,CON_LANG) - )Engine=MyISAM DEFAULT CHARSET='utf8' COMMENT='Table for add content';" ); - $oStatement->executeQuery(); - - $con = Propel::getConnection( 'workflow' ); + )Engine=MyISAM DEFAULT CHARSET='utf8' COMMENT='Table for add content';" ); + $oStatement->executeQuery(); + + $con = Propel::getConnection( 'workflow' ); $sql = " SELECT DISTINCT CON_LANG - FROM CONTENT "; - $stmt = $con->createStatement(); - $rs = $stmt->executeQuery( $sql, ResultSet::FETCHMODE_ASSOC ); - while ($rs->next()) { - $row = $rs->getRow(); - $language = $row['CON_LANG']; - if (array_search( $row['CON_LANG'], $langs ) === false) { - Content::removeLanguageContent( $row['CON_LANG'] ); - } - } - + FROM CONTENT "; + $stmt = $con->createStatement(); + $rs = $stmt->executeQuery( $sql, ResultSet::FETCHMODE_ASSOC ); + while ($rs->next()) { + $row = $rs->getRow(); + $language = $row['CON_LANG']; + if (array_search( $row['CON_LANG'], $langs ) === false) { + Content::removeLanguageContent( $row['CON_LANG'] ); + } + } + $sql = " SELECT CON_ID, CON_CATEGORY, CON_LANG, CON_PARENT, CON_VALUE FROM CONTENT - ORDER BY CON_ID, CON_CATEGORY, CON_PARENT, CON_LANG"; - - G::LoadClass( "wsTools" ); - $workSpace = new workspaceTools( $workSpace ); - $workSpace->getDBInfo(); - - $link = mysql_pconnect( $workSpace->dbHost, $workSpace->dbUser, $workSpace->dbPass ) or die( "Could not connect" ); - - mysql_select_db( $workSpace->dbName, $link ); - mysql_query( "SET NAMES 'utf8';" ); - mysql_query( 'SET OPTION SQL_BIG_SELECTS=1' ); - $result = mysql_unbuffered_query( $sql, $link ); - $list = array (); - $default = array (); - $sw = array ('CON_ID' => '','CON_CATEGORY' => '','CON_PARENT' => '' - ); - while ($row = mysql_fetch_assoc( $result )) { - if ($sw['CON_ID'] == $row['CON_ID'] && $sw['CON_CATEGORY'] == $row['CON_CATEGORY'] && $sw['CON_PARENT'] == $row['CON_PARENT']) { - $list[] = $row; - } else { - $this->rowsClustered ++; - if (count( $langs ) != count( $list )) { - $this->checkLanguage( $list, $default ); - } else { - $this->rowsUnchanged = $this->rowsUnchanged + count( $langs ); - } - $sw = array (); - $sw['CON_ID'] = $row['CON_ID']; - $sw['CON_CATEGORY'] = $row['CON_CATEGORY']; - $sw['CON_LANG'] = $row['CON_LANG']; - $sw['CON_PARENT'] = $row['CON_PARENT']; - unset( $list ); - unset( $default ); - $list = array (); - $default = array (); - $list[] = $row; - } - if ($sw['CON_LANG'] == $langs[$key]) { - $default = $row; - } - $this->rowsProcessed ++; - } - if (count( $langs ) != count( $list )) { - $this->checkLanguage( $list, $default ); - } else { - $this->rowsUnchanged = $this->rowsUnchanged + count( $langs ); - } - mysql_free_result( $result ); - $total = $this->rowsProcessed + $this->rowsInserted; - $connection = Propel::getConnection( 'workflow' ); + ORDER BY CON_ID, CON_CATEGORY, CON_PARENT, CON_LANG"; + + G::LoadClass( "wsTools" ); + $workSpace = new workspaceTools( $workSpace ); + $workSpace->getDBInfo(); + + $link = mysql_pconnect( $workSpace->dbHost, $workSpace->dbUser, $workSpace->dbPass ) or die( "Could not connect" ); + + mysql_select_db( $workSpace->dbName, $link ); + mysql_query( "SET NAMES 'utf8';" ); + mysql_query( 'SET OPTION SQL_BIG_SELECTS=1' ); + $result = mysql_unbuffered_query( $sql, $link ); + $list = array (); + $default = array (); + $sw = array ('CON_ID' => '','CON_CATEGORY' => '','CON_PARENT' => '' + ); + while ($row = mysql_fetch_assoc( $result )) { + if ($sw['CON_ID'] == $row['CON_ID'] && $sw['CON_CATEGORY'] == $row['CON_CATEGORY'] && $sw['CON_PARENT'] == $row['CON_PARENT']) { + $list[] = $row; + } else { + $this->rowsClustered ++; + if (count( $langs ) != count( $list )) { + $this->checkLanguage( $list, $default ); + } else { + $this->rowsUnchanged = $this->rowsUnchanged + count( $langs ); + } + $sw = array (); + $sw['CON_ID'] = $row['CON_ID']; + $sw['CON_CATEGORY'] = $row['CON_CATEGORY']; + $sw['CON_LANG'] = $row['CON_LANG']; + $sw['CON_PARENT'] = $row['CON_PARENT']; + unset( $list ); + unset( $default ); + $list = array (); + $default = array (); + $list[] = $row; + } + if ($sw['CON_LANG'] == $langs[$key]) { + $default = $row; + } + $this->rowsProcessed ++; + } + if (count( $langs ) != count( $list )) { + $this->checkLanguage( $list, $default ); + } else { + $this->rowsUnchanged = $this->rowsUnchanged + count( $langs ); + } + mysql_free_result( $result ); + $total = $this->rowsProcessed + $this->rowsInserted; + $connection = Propel::getConnection( 'workflow' ); $statement = $connection->prepareStatement( "INSERT INTO CONTENT SELECT CON_CATEGORY, CON_PARENT, CON_ID , CON_LANG, CON_VALUE - FROM CONTENT_BACKUP" ); - $statement->executeQuery(); - - $statement = $connection->prepareStatement( "DROP TABLE CONTENT_BACKUP" ); - $statement->executeQuery(); - - if (! isset( $_SERVER['SERVER_NAME'] )) { - CLI::logging( "Rows Processed ---> $this->rowsProcessed ..... \n" ); - CLI::logging( "Rows Clustered ---> $this->rowsClustered ..... \n" ); - CLI::logging( "Rows Unchanged ---> $this->rowsUnchanged ..... \n" ); - CLI::logging( "Rows Inserted ---> $this->rowsInserted ..... \n" ); - CLI::logging( "Rows Total ---> $total ..... \n" ); - } - } - - public function checkLanguage ($content, $default) - { - if (count( $content ) > 0) { - $langs = $this->langs; - $langsAsoc = $this->langsAsoc; + FROM CONTENT_BACKUP" ); + $statement->executeQuery(); + + $statement = $connection->prepareStatement( "DROP TABLE CONTENT_BACKUP" ); + $statement->executeQuery(); + + if (! isset( $_SERVER['SERVER_NAME'] )) { + CLI::logging( "Rows Processed ---> $this->rowsProcessed ..... \n" ); + CLI::logging( "Rows Clustered ---> $this->rowsClustered ..... \n" ); + CLI::logging( "Rows Unchanged ---> $this->rowsUnchanged ..... \n" ); + CLI::logging( "Rows Inserted ---> $this->rowsInserted ..... \n" ); + CLI::logging( "Rows Total ---> $total ..... \n" ); + } + } + + public function checkLanguage ($content, $default) + { + if (count( $content ) > 0) { + $langs = $this->langs; + $langsAsoc = $this->langsAsoc; //Element default - $default = (count( $default ) > 0) ? $default : $content[0]; - foreach ($content as $key => $value) { - unset( $langsAsoc[$value['CON_LANG']] ); - } - foreach ($langsAsoc as $key => $value) { - $this->rowsInserted ++; - $this->fastInsertContent( $default['CON_CATEGORY'], $default['CON_PARENT'], $default['CON_ID'], $value, $default['CON_VALUE'] ); - } - } - } - - public function fastInsertContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) - { - $ConValue = mysql_real_escape_string( $ConValue ); - $connection = Propel::getConnection( 'workflow' ); + $default = (count( $default ) > 0) ? $default : $content[0]; + foreach ($content as $key => $value) { + unset( $langsAsoc[$value['CON_LANG']] ); + } + foreach ($langsAsoc as $key => $value) { + $this->rowsInserted ++; + $this->fastInsertContent( $default['CON_CATEGORY'], $default['CON_PARENT'], $default['CON_ID'], $value, $default['CON_VALUE'] ); + } + } + } + + public function fastInsertContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) + { + $ConValue = mysql_real_escape_string( $ConValue ); + $connection = Propel::getConnection( 'workflow' ); $statement = $connection->prepareStatement( "INSERT INTO CONTENT_BACKUP ( CON_CATEGORY, CON_PARENT, CON_ID , CON_LANG, CON_VALUE) - VALUES ('$ConCategory', '$ConParent', '$ConId', '$ConLang', '$ConValue');" ); - $statement->executeQuery(); - } - - public function removeLanguageContent ($lanId) - { - try { - $c = new Criteria(); - $c->addSelectColumn( ContentPeer::CON_CATEGORY ); - $c->addSelectColumn( ContentPeer::CON_PARENT ); - $c->addSelectColumn( ContentPeer::CON_ID ); - $c->addSelectColumn( ContentPeer::CON_LANG ); - - $c->add( ContentPeer::CON_LANG, $lanId ); - - $result = ContentPeer::doSelectRS( $c ); - $result->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $result->next(); - $row = $result->getRow(); - - while (is_array( $row )) { - $content = ContentPeer::retrieveByPK( $row['CON_CATEGORY'], $row['CON_PARENT'], $row['CON_ID'], $lanId ); - - if ($content !== null) { - $content->delete(); - } - $result->next(); - $row = $result->getRow(); - } - - } catch (Exception $e) { - throw ($e); - } - } + VALUES ('$ConCategory', '$ConParent', '$ConId', '$ConLang', '$ConValue');" ); + $statement->executeQuery(); + } + + public function removeLanguageContent ($lanId) + { + try { + $c = new Criteria(); + $c->addSelectColumn( ContentPeer::CON_CATEGORY ); + $c->addSelectColumn( ContentPeer::CON_PARENT ); + $c->addSelectColumn( ContentPeer::CON_ID ); + $c->addSelectColumn( ContentPeer::CON_LANG ); + + $c->add( ContentPeer::CON_LANG, $lanId ); + + $result = ContentPeer::doSelectRS( $c ); + $result->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $result->next(); + $row = $result->getRow(); + + while (is_array( $row )) { + $content = ContentPeer::retrieveByPK( $row['CON_CATEGORY'], $row['CON_PARENT'], $row['CON_ID'], $lanId ); + + if ($content !== null) { + $content->delete(); + } + $result->next(); + $row = $result->getRow(); + } + + } catch (Exception $e) { + throw ($e); + } + } + //Added by Enrique at Feb 9th,2011 //Gets all Role Names by Role - public function getAllContentsByRole ($sys_lang = SYS_LANG) - { - if (! isset( $sys_lang )) { - $sys_lang = 'en'; - } - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->clearSelectColumns(); - $oCriteria->addSelectColumn( ContentPeer::CON_ID ); - $oCriteria->addAsColumn( 'ROL_NAME', ContentPeer::CON_VALUE ); + public function getAllContentsByRole ($sys_lang = SYS_LANG) + { + if (! isset( $sys_lang )) { + $sys_lang = 'en'; + } + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->clearSelectColumns(); + $oCriteria->addSelectColumn( ContentPeer::CON_ID ); + $oCriteria->addAsColumn( 'ROL_NAME', ContentPeer::CON_VALUE ); //$oCriteria->addAsColumn('ROL_UID', ContentPeer::CON_ID); - $oCriteria->add( ContentPeer::CON_CATEGORY, 'ROL_NAME' ); - $oCriteria->add( ContentPeer::CON_LANG, $sys_lang ); - $oDataset = ContentPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $aRoles = Array (); - while ($oDataset->next()) { - $xRow = $oDataset->getRow(); - $aRoles[$xRow['CON_ID']] = $xRow['ROL_NAME']; - } - return $aRoles; - } -} -// Content - + $oCriteria->add( ContentPeer::CON_CATEGORY, 'ROL_NAME' ); + $oCriteria->add( ContentPeer::CON_LANG, $sys_lang ); + $oDataset = ContentPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $aRoles = Array (); + while ($oDataset->next()) { + $xRow = $oDataset->getRow(); + $aRoles[$xRow['CON_ID']] = $xRow['ROL_NAME']; + } + return $aRoles; + } +} + diff --git a/workflow/engine/classes/model/ContentPeer.php b/workflow/engine/classes/model/ContentPeer.php index c3549b32d..99dbb2945 100755 --- a/workflow/engine/classes/model/ContentPeer.php +++ b/workflow/engine/classes/model/ContentPeer.php @@ -2,10 +2,10 @@ /** * ContentPeer.php * @package workflow.engine.classes.model - * + * * ProcessMaker Open Source Edition * Copyright (C) 2004 - 2011 Colosa Inc. - * + * * 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 @@ -15,13 +15,13 @@ * 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 . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * + * */ // include base peer class @@ -34,7 +34,7 @@ /** * Skeleton subclass for performing query and update operations on the 'CONTENT' table. * - * + * * * You should add additional methods to this class to meet the * application requirements. This class will only be generated as @@ -42,6 +42,7 @@ * * @package workflow.engine.classes.model */ -class ContentPeer extends BaseContentPeer { +class ContentPeer extends BaseContentPeer +{ +} -} // ContentPeer
$key1"; - if(is_array($value1)){ + if (is_array($value1)) { $sw_add=true; $html.=""; - foreach($value1 as $key2 =>$value2){ + foreach ($value1 as $key2 => $value2) { $html.=""; $html.=""; $html.=""; @@ -170,7 +152,6 @@ class AppHistory extends BaseAppHistory { } $html.=""; $html.=""; - } $html.="
$key2$value2
"; $html.="