diff --git a/workflow/engine/methods/triggers/triggersProperties.php b/workflow/engine/methods/triggers/triggersProperties.php index 075b44544..f767c1cda 100755 --- a/workflow/engine/methods/triggers/triggersProperties.php +++ b/workflow/engine/methods/triggers/triggersProperties.php @@ -1,44 +1,42 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ -if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Response; -require_once('classes/model/Triggers.php'); - -if (isset($_GET['TRI_UID'])) -{ - $oTrigger = new Triggers(); - $aFields = $oTrigger->load($_GET['TRI_UID']); -} -else -{ - $aFields['PRO_UID'] = $_GET['PRO_UID']; - //$aFields['PRO_UID'] = (isset($_SESSION['PROCESS']) ? $_SESSION['PROCESS'] : ''); - $aFields['TRI_TYPE'] = 'SCRIPT'; -} - -G::LoadClass('xmlfield_InputPM'); -$G_PUBLISH = new Publisher(); -$G_PUBLISH->AddContent('xmlform', 'xmlform', 'triggers/triggersProperties', '', $aFields, '../triggers/triggers_Save'); -G::RenderPage('publish', 'raw'); -?> \ No newline at end of file +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ +if (($RBAC_Response = $RBAC->userCanAccess( "PM_FACTORY" )) != 1) { + return $RBAC_Response; +} +require_once ('classes/model/Triggers.php'); + +if (isset( $_GET['TRI_UID'] )) { + $oTrigger = new Triggers(); + $aFields = $oTrigger->load( $_GET['TRI_UID'] ); +} else { + $aFields['PRO_UID'] = $_GET['PRO_UID']; + //$aFields['PRO_UID'] = (isset($_SESSION['PROCESS']) ? $_SESSION['PROCESS'] : ''); + $aFields['TRI_TYPE'] = 'SCRIPT'; +} + +G::LoadClass( 'xmlfield_InputPM' ); +$G_PUBLISH = new Publisher(); +$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'triggers/triggersProperties', '', $aFields, '../triggers/triggers_Save' ); +G::RenderPage( 'publish', 'raw' ); + diff --git a/workflow/engine/methods/triggers/triggersTree.php b/workflow/engine/methods/triggers/triggersTree.php index 2df8be752..0daa04272 100755 --- a/workflow/engine/methods/triggers/triggersTree.php +++ b/workflow/engine/methods/triggers/triggersTree.php @@ -12,32 +12,29 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 . + * along with this program. If not, see . * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * */ -if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Response; -require_once('classes/model/Triggers.php'); -require_once('classes/model/Process.php'); +if (($RBAC_Response = $RBAC->userCanAccess( "PM_FACTORY" )) != 1) { + return $RBAC_Response; +} +require_once ('classes/model/Triggers.php'); +require_once ('classes/model/Process.php'); +$sProcessUID = $_GET['PRO_UID']; +$oProcess = new Process(); +$aFields = $oProcess->load( $sProcessUID ); -$sProcessUID=$_GET['PRO_UID']; +$_SESSION['PROCESS'] = $sProcessUID; +$G_PUBLISH = new Publisher(); +$G_PUBLISH->AddContent( 'view', 'triggers/triggersTree' ); +G::RenderPage( 'publish', 'raw' ); - $oProcess = new Process ( ); - $aFields = $oProcess->load ( $sProcessUID ); - - $_SESSION['PROCESS'] = $sProcessUID; - - - $G_PUBLISH = new Publisher ( ); - $G_PUBLISH->AddContent ( 'view', 'triggers/triggersTree' ); - G::RenderPage('publish', 'raw'); -?> \ No newline at end of file diff --git a/workflow/engine/methods/triggers/triggers_Ajax.php b/workflow/engine/methods/triggers/triggers_Ajax.php index b9452bf85..2baed8f27 100755 --- a/workflow/engine/methods/triggers/triggers_Ajax.php +++ b/workflow/engine/methods/triggers/triggers_Ajax.php @@ -1,90 +1,74 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -/** - * Triggers Ajax Request HAndler - * - * @author Erik A.O. - * @date Apr 29th, 2010 - */ - -$request = isset($_POST['request'])? $_POST['request']: ''; - - -switch($request){ - case 'verifyDependencies': - require_once 'classes/model/Triggers.php'; - - if( !isset($_POST['TRI_UID']) ) { - throw new Exception('Missing trigger ID for the request [verifyDependencies]'); - exit(0); - } - - $oTrigger = new Triggers; - $oResult = $oTrigger->verifyDependecies($_POST['TRI_UID']); - $oResult->passed = false; - if($oResult->code == 0){ - $oResult->passed = true; - $oResult->message = G::LoadTranslation('ID_TRIGGERS_VALIDATION'); //"No Dependencies were found for this trigger in Events definitions\n"; - } else { - $oResult->message = ''; - foreach($oResult->dependencies as $Object=>$aDeps){ - $nDeps = count($aDeps); - $message = str_replace('{N}', $nDeps, G::LoadTranslation('ID_TRIGGERS_VALIDATION_ERR2')); - $message = str_replace('{Object}', $Object, $message); - $oResult->message .= $message . "\n"; - foreach($aDeps as $dep){ - if( substr($Object, -1) == 's') $Object = substr($Object, 0, strlen($Object)-1); - $message = str_replace('{Object}', $Object, G::LoadTranslation('ID_TRIGGERS_VALIDATION_ERR3')); - $message = str_replace('{Description}', '"'.$dep['DESCRIPTION'].'"', $message); - $oResult->message .= $message . "\n"; - } - $oResult->message .= "\n"; - } - } - $oResult->success = true; - //print_r($oResult); - print G::json_encode($oResult); - break; - default: echo 'default'; -} - - - - - - - - - - - - - - - - - - +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ + +/** + * Triggers Ajax Request HAndler + * + * @author Erik A.O. + * @date Apr 29th, 2010 + */ + +$request = isset( $_POST['request'] ) ? $_POST['request'] : ''; + +switch ($request) { + case 'verifyDependencies': + require_once 'classes/model/Triggers.php'; + + if (! isset( $_POST['TRI_UID'] )) { + throw new Exception( 'Missing trigger ID for the request [verifyDependencies]' ); + exit( 0 ); + } + + $oTrigger = new Triggers(); + $oResult = $oTrigger->verifyDependecies( $_POST['TRI_UID'] ); + $oResult->passed = false; + if ($oResult->code == 0) { + $oResult->passed = true; + $oResult->message = G::LoadTranslation( 'ID_TRIGGERS_VALIDATION' ); //"No Dependencies were found for this trigger in Events definitions\n"; + } else { + $oResult->message = ''; + foreach ($oResult->dependencies as $Object => $aDeps) { + $nDeps = count( $aDeps ); + $message = str_replace( '{N}', $nDeps, G::LoadTranslation( 'ID_TRIGGERS_VALIDATION_ERR2' ) ); + $message = str_replace( '{Object}', $Object, $message ); + $oResult->message .= $message . "\n"; + foreach ($aDeps as $dep) { + if (substr( $Object, - 1 ) == 's') { + $Object = substr( $Object, 0, strlen( $Object ) - 1 ); + } + $message = str_replace( '{Object}', $Object, G::LoadTranslation( 'ID_TRIGGERS_VALIDATION_ERR3' ) ); + $message = str_replace( '{Description}', '"' . $dep['DESCRIPTION'] . '"', $message ); + $oResult->message .= $message . "\n"; + } + $oResult->message .= "\n"; + } + } + $oResult->success = true; + //print_r($oResult); + print G::json_encode( $oResult ); + break; + default: + echo 'default'; +} + diff --git a/workflow/engine/methods/triggers/triggers_CreateWizard.php b/workflow/engine/methods/triggers/triggers_CreateWizard.php index d19326253..b9c474b0b 100755 --- a/workflow/engine/methods/triggers/triggers_CreateWizard.php +++ b/workflow/engine/methods/triggers/triggers_CreateWizard.php @@ -12,81 +12,84 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 . + * along with this program. If not, see . * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * */ -if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Response; -require_once('classes/model/Triggers.php'); - -$G_PUBLISH = new Publisher ( ); -$G_PUBLISH->AddContent ( 'view', 'triggers/triggers_CreateWizard', '', '', $_GET, '' ); -G::RenderPage('publish', 'raw'); +if (($RBAC_Response = $RBAC->userCanAccess( "PM_FACTORY" )) != 1) { + return $RBAC_Response; +} +require_once ('classes/model/Triggers.php'); +$G_PUBLISH = new Publisher(); +$G_PUBLISH->AddContent( 'view', 'triggers/triggers_CreateWizard', '', '', $_GET, '' ); +G::RenderPage( 'publish', 'raw' ); ?> + \ No newline at end of file + + + diff --git a/workflow/engine/methods/triggers/triggers_Delete.php b/workflow/engine/methods/triggers/triggers_Delete.php index 37433fad2..bfc1f4def 100755 --- a/workflow/engine/methods/triggers/triggers_Delete.php +++ b/workflow/engine/methods/triggers/triggers_Delete.php @@ -1,10 +1,10 @@ . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * along with this program. If not, see . + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * */ -if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Response; -try{ -require_once('classes/model/Triggers.php'); - -$oTrigger = new Triggers(); -$triggerObj=$oTrigger->load($_POST['TRI_UID']); - - -$oTrigger->remove($_POST['TRI_UID']); -require_once('classes/model/StepTrigger.php'); -$oStepTrigger = new StepTrigger(); -$oStepTrigger->removeTrigger($_POST['TRI_UID']); - -$result->success = true; -$result->msg = G::LoadTranslation('ID_TRIGGERS_REMOVED'); - +if (($RBAC_Response = $RBAC->userCanAccess( "PM_FACTORY" )) != 1) { + return $RBAC_Response; } -catch (Exception $e) { +try { + require_once ('classes/model/Triggers.php'); + + $oTrigger = new Triggers(); + $triggerObj = $oTrigger->load( $_POST['TRI_UID'] ); + + $oTrigger->remove( $_POST['TRI_UID'] ); + require_once ('classes/model/StepTrigger.php'); + $oStepTrigger = new StepTrigger(); + $oStepTrigger->removeTrigger( $_POST['TRI_UID'] ); + + $result->success = true; + $result->msg = G::LoadTranslation( 'ID_TRIGGERS_REMOVED' ); + +} catch (Exception $e) { $result->success = false; $result->msg = $e->getMessage(); - } -print G::json_encode($result); +} +print G::json_encode( $result ); -?> \ No newline at end of file diff --git a/workflow/engine/methods/triggers/triggers_Edit.php b/workflow/engine/methods/triggers/triggers_Edit.php index 8f7ebf0c4..ddbea6e5b 100755 --- a/workflow/engine/methods/triggers/triggers_Edit.php +++ b/workflow/engine/methods/triggers/triggers_Edit.php @@ -12,62 +12,60 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 . + * along with this program. If not, see . * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * */ -if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Response; -require_once('classes/model/Triggers.php'); +if (($RBAC_Response = $RBAC->userCanAccess( "PM_FACTORY" )) != 1) { + return $RBAC_Response; +} +require_once ('classes/model/Triggers.php'); -if (isset($_GET['TRI_UID'])) -{ - $oTrigger = new Triggers(); - // check if its necessary bypass the wizard editor - if (isset($_GET['BYPASS'])&&$_GET['BYPASS']=='1'){ - $editWizardSource = true; - } else { - $editWizardSource = false; - } - $aFields = $oTrigger->load($_GET['TRI_UID']); - $aTriggerData = unserialize($aFields['TRI_PARAM']); - // if trigger has been created with the wizard the TRI_PARAM field cant be empty - if($aFields['TRI_PARAM']!=''&&!$editWizardSource){ - $aTriggerData = unserialize($aFields['TRI_PARAM']); - // if the trigger has been modified manually, it cant be edited with the wizard. - if (md5($aFields['TRI_WEBBOT'])==$aTriggerData['hash']){ - $triUid = $_GET['TRI_UID']; - $_GET = $aTriggerData['params']; - $_GET['TRI_UID'] = $triUid; - require_once('triggers_EditWizard.php'); - die; - } else { - // custom trigger edit - $xmlform = 'triggers/triggers_Edit'; - $xmlform_action = '../triggers/triggers_Save'; - } - }else{ +if (isset( $_GET['TRI_UID'] )) { + $oTrigger = new Triggers(); + // check if its necessary bypass the wizard editor + if (isset( $_GET['BYPASS'] ) && $_GET['BYPASS'] == '1') { + $editWizardSource = true; + } else { + $editWizardSource = false; + } + $aFields = $oTrigger->load( $_GET['TRI_UID'] ); + $aTriggerData = unserialize( $aFields['TRI_PARAM'] ); + // if trigger has been created with the wizard the TRI_PARAM field cant be empty + if ($aFields['TRI_PARAM'] != '' && ! $editWizardSource) { + $aTriggerData = unserialize( $aFields['TRI_PARAM'] ); + // if the trigger has been modified manually, it cant be edited with the wizard. + if (md5( $aFields['TRI_WEBBOT'] ) == $aTriggerData['hash']) { + $triUid = $_GET['TRI_UID']; + $_GET = $aTriggerData['params']; + $_GET['TRI_UID'] = $triUid; + require_once ('triggers_EditWizard.php'); + die(); + } else { // custom trigger edit $xmlform = 'triggers/triggers_Edit'; $xmlform_action = '../triggers/triggers_Save'; } -} -else -{ - //if its a new trigger - $aFields['PRO_UID'] = $_GET['PRO_UID']; - $aFields['TRI_TYPE'] = 'SCRIPT'; - $xmlform = 'triggers/triggersProperties'; + } else { + // custom trigger edit + $xmlform = 'triggers/triggers_Edit'; $xmlform_action = '../triggers/triggers_Save'; + } +} else { + //if its a new trigger + $aFields['PRO_UID'] = $_GET['PRO_UID']; + $aFields['TRI_TYPE'] = 'SCRIPT'; + $xmlform = 'triggers/triggersProperties'; + $xmlform_action = '../triggers/triggers_Save'; } -G::LoadClass('xmlfield_InputPM'); +G::LoadClass( 'xmlfield_InputPM' ); $G_PUBLISH = new Publisher(); -$G_PUBLISH->AddContent('xmlform', 'xmlform', $xmlform , '', $aFields, $xmlform_action); -G::RenderPage('publish', 'raw'); -?> \ No newline at end of file +$G_PUBLISH->AddContent( 'xmlform', 'xmlform', $xmlform, '', $aFields, $xmlform_action ); +G::RenderPage( 'publish', 'raw' ); + diff --git a/workflow/engine/methods/triggers/triggers_EditCustom.php b/workflow/engine/methods/triggers/triggers_EditCustom.php index 62a0ae8be..fa6aa8ab2 100755 --- a/workflow/engine/methods/triggers/triggers_EditCustom.php +++ b/workflow/engine/methods/triggers/triggers_EditCustom.php @@ -12,29 +12,30 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 . + * along with this program. If not, see . * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * */ -if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Response; -require_once('classes/model/Triggers.php'); - - $aFields['PRO_UID'] = $_GET['PRO_UID']; - $aFields['TRI_TYPE'] = 'SCRIPT'; -if(isset($_GET['TRI_UID'])&&($_GET['TRI_UID']!="")){ - $oTrigger = new Triggers(); - $aFields = $oTrigger->load($_GET['TRI_UID']); +if (($RBAC_Response = $RBAC->userCanAccess( "PM_FACTORY" )) != 1) { + return $RBAC_Response; } - $xmlform = 'triggers/triggersCustom'; +require_once ('classes/model/Triggers.php'); -G::LoadClass('xmlfield_InputPM'); +$aFields['PRO_UID'] = $_GET['PRO_UID']; +$aFields['TRI_TYPE'] = 'SCRIPT'; +if (isset( $_GET['TRI_UID'] ) && ($_GET['TRI_UID'] != "")) { + $oTrigger = new Triggers(); + $aFields = $oTrigger->load( $_GET['TRI_UID'] ); +} +$xmlform = 'triggers/triggersCustom'; + +G::LoadClass( 'xmlfield_InputPM' ); $G_PUBLISH = new Publisher(); -$G_PUBLISH->AddContent('xmlform', 'xmlform', $xmlform , '', $aFields, '../triggers/triggers_Save'); -G::RenderPage('publish', 'raw'); -?> \ No newline at end of file +$G_PUBLISH->AddContent( 'xmlform', 'xmlform', $xmlform, '', $aFields, '../triggers/triggers_Save' ); +G::RenderPage( 'publish', 'raw' ); + diff --git a/workflow/engine/methods/triggers/triggers_EditWizard.php b/workflow/engine/methods/triggers/triggers_EditWizard.php index def592b00..5df3e57fc 100755 --- a/workflow/engine/methods/triggers/triggers_EditWizard.php +++ b/workflow/engine/methods/triggers/triggers_EditWizard.php @@ -12,26 +12,29 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 . + * along with this program. If not, see . * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * */ // this script calls the template that constructs the wizard form for a trigger -if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Response; -if (!class_exists('Triggers')){ - require_once('classes/model/Triggers.php'); + +if (($RBAC_Response = $RBAC->userCanAccess( "PM_FACTORY" )) != 1) { + return $RBAC_Response; } -$G_PUBLISH = new Publisher ( ); -$G_PUBLISH->AddContent ( 'view', 'triggers/triggers_EditWizard', '', '', $_GET, '' ); -G::RenderPage('publish', 'raw'); +if (! class_exists( 'Triggers' )) { + require_once ('classes/model/Triggers.php'); +} +$G_PUBLISH = new Publisher(); +$G_PUBLISH->AddContent( 'view', 'triggers/triggers_EditWizard', '', '', $_GET, '' ); +G::RenderPage( 'publish', 'raw' ); + ?> @@ -92,4 +95,5 @@ var insertFormVar = function(sFieldName, sValue) { _oVarsPanel_.remove(); }; - \ No newline at end of file + + diff --git a/workflow/engine/methods/triggers/triggers_Save.php b/workflow/engine/methods/triggers/triggers_Save.php index 33f080792..8e66b72fe 100755 --- a/workflow/engine/methods/triggers/triggers_Save.php +++ b/workflow/engine/methods/triggers/triggers_Save.php @@ -1,10 +1,10 @@ . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * along with this program. If not, see . + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * */ - -if (($RBAC_Response=$RBAC->userCanAccess("PM_FACTORY"))!=1) return $RBAC_Response; -require_once('classes/model/Triggers.php'); -require_once('classes/model/Content.php'); -if( isset($_POST['function']) ) - $sfunction = $_POST['function']; //for old processmap -else if( isset($_POST['functions']) ) - $sfunction = $_POST['functions']; //for extjs +if (($RBAC_Response = $RBAC->userCanAccess( "PM_FACTORY" )) != 1) { + return $RBAC_Response; +} +require_once ('classes/model/Triggers.php'); +require_once ('classes/model/Content.php'); -if(isset($sfunction) && $sfunction=='lookforNameTrigger'){ - $snameTrigger=urldecode($_POST['NAMETRIGGER']); - $sPRO_UID=urldecode($_POST['proUid']); - - $oCriteria = new Criteria('workflow'); - $oCriteria->addSelectColumn ( TriggersPeer::TRI_UID ); - $oCriteria->add(TriggersPeer::PRO_UID, $sPRO_UID); - $oDataset = TriggersPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $flag=true; +if (isset( $_POST['function'] )) { + $sfunction = $_POST['function']; //for old processmap +} elseif (isset( $_POST['functions'] )) { + $sfunction = $_POST['functions']; //for extjs +} + +if (isset( $sfunction ) && $sfunction == 'lookforNameTrigger') { + $snameTrigger = urldecode( $_POST['NAMETRIGGER'] ); + $sPRO_UID = urldecode( $_POST['proUid'] ); + + $oCriteria = new Criteria( 'workflow' ); + $oCriteria->addSelectColumn( TriggersPeer::TRI_UID ); + $oCriteria->add( TriggersPeer::PRO_UID, $sPRO_UID ); + $oDataset = TriggersPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $flag = true; while ($oDataset->next() && $flag) { - $aRow = $oDataset->getRow(); - - $oCriteria1 = new Criteria('workflow'); - $oCriteria1->addSelectColumn('COUNT(*) AS TRIGGERS'); - $oCriteria1->add(ContentPeer::CON_CATEGORY, 'TRI_TITLE'); - $oCriteria1->add(ContentPeer::CON_ID, $aRow['TRI_UID']); - $oCriteria1->add(ContentPeer::CON_VALUE, $snameTrigger); - $oCriteria1->add(ContentPeer::CON_LANG, SYS_LANG); - $oDataset1 = ContentPeer::doSelectRS($oCriteria1); - $oDataset1->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset1->next(); - $aRow1 = $oDataset1->getRow(); + $aRow = $oDataset->getRow(); + + $oCriteria1 = new Criteria( 'workflow' ); + $oCriteria1->addSelectColumn( 'COUNT(*) AS TRIGGERS' ); + $oCriteria1->add( ContentPeer::CON_CATEGORY, 'TRI_TITLE' ); + $oCriteria1->add( ContentPeer::CON_ID, $aRow['TRI_UID'] ); + $oCriteria1->add( ContentPeer::CON_VALUE, $snameTrigger ); + $oCriteria1->add( ContentPeer::CON_LANG, SYS_LANG ); + $oDataset1 = ContentPeer::doSelectRS( $oCriteria1 ); + $oDataset1->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset1->next(); + $aRow1 = $oDataset1->getRow(); + + if ($aRow1['TRIGGERS']) { + $flag = false; + } - if($aRow1['TRIGGERS']) $flag=false; - - } print $flag; - //print'krlos';return ; + //print'krlos';return ; } else { - try { - $oTrigger = new Triggers(); - - G::LoadClass('processMap'); - $oProcessMap = new processMap(new DBConnection); - if(isset ($_POST['form'])) - $value = $_POST['form']; - else - $value = $_POST; - - if ($value['TRI_UID'] != '') - { - $oTrigger->load($value['TRI_UID']); - } - else - { - $oTrigger->create($value); - $value['TRI_UID']=$oTrigger->getTriUid(); - } - //print_r($_POST['form']);die; - $oTrigger->update($value); + try { + $oTrigger = new Triggers(); - if(!isset($_POST['mode'])) - $oProcessMap->triggersList($value['PRO_UID']); + G::LoadClass( 'processMap' ); + $oProcessMap = new processMap( new DBConnection() ); + if (isset( $_POST['form'] )) { + $value = $_POST['form']; + } else { + $value = $_POST; + } - $result->success = true; - $result->msg = G::LoadTranslation('ID_TRIGGERS_SAVED'); - } catch (Exception $e) { + if ($value['TRI_UID'] != '') { + $oTrigger->load( $value['TRI_UID'] ); + } else { + $oTrigger->create( $value ); + $value['TRI_UID'] = $oTrigger->getTriUid(); + } + //print_r($_POST['form']);die; + $oTrigger->update( $value ); + + if (! isset( $_POST['mode'] )) { + $oProcessMap->triggersList( $value['PRO_UID'] ); + } + $result->success = true; + $result->msg = G::LoadTranslation( 'ID_TRIGGERS_SAVED' ); + } catch (Exception $e) { $result->success = false; $result->msg = $e->getMessage(); - } - print G::json_encode($result); + } + print G::json_encode( $result ); } -?> \ No newline at end of file + diff --git a/workflow/engine/methods/triggers/triggers_WizardSave.php b/workflow/engine/methods/triggers/triggers_WizardSave.php index ddae320be..33f0b0ee4 100755 --- a/workflow/engine/methods/triggers/triggers_WizardSave.php +++ b/workflow/engine/methods/triggers/triggers_WizardSave.php @@ -1,99 +1,97 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -if (($RBAC_Response = $RBAC->userCanAccess ( "PM_FACTORY" )) != 1) - return $RBAC_Response; -require_once ('classes/model/Triggers.php'); -$oTrigger = new Triggers ( ); - -G::LoadClass('processMap'); -$oProcessMap = new processMap(new DBConnection); - -$aDataTriggers = $_POST; - -$aInfoFunction = explode ( ",", $aDataTriggers ['ALLFUNCTION'] ); - -$sPMfunction = " -/*************************************************** - * - * Generated by ProcessMaker Trigger Wizard - * Library: " . $aDataTriggers ['LIBRARY_NAME'] . " - * Method: " . $aDataTriggers ['PMFUNTION_LABEL'] . " - * Date: " . date ( "Y-m-d H:i:s" ) . " - * - * ProcessMaker " . date ( "Y" ) . " - * - ****************************************************/ - -"; - -$methodParamsFinal = array (); -//Generate params to send -foreach ( $aInfoFunction as $k => $v ) { - if ($v != '') { - - $sOptionTrigger = trim ( str_replace ( "$", "", $v ) ); - if (strstr ( $sOptionTrigger, "=" )) { - $aOptionParameters = explode ( "=", $sOptionTrigger ); - $sOptionTrigger = trim ( $aOptionParameters [0] ); - } - if ($aDataTriggers [$sOptionTrigger] != '') { - - if ((strstr ( $aDataTriggers [$sOptionTrigger], "@@" ))) { - $option = trim($aDataTriggers [$sOptionTrigger]); - } else { - $aDataTriggers [$sOptionTrigger] =(strstr($aDataTriggers[$sOptionTrigger],'array'))? -str_replace("'", '"', $aDataTriggers[$sOptionTrigger]):str_replace("'", "\'", $aDataTriggers [$sOptionTrigger]); - $option = (is_numeric($aDataTriggers [$sOptionTrigger]))?trim($aDataTriggers [$sOptionTrigger]): - (strstr($aDataTriggers [$sOptionTrigger],"array") )?trim($aDataTriggers [$sOptionTrigger]):"'" . trim($aDataTriggers [$sOptionTrigger]) . "'"; - } - } else { - $option = "''"; - } - $methodParamsFinal [] = $option; - - } - -} -//G::pr($methodParamsFinal);die; -$sPMfunction .= (isset ( $aDataTriggers ['TRI_ANSWER'] ) && $aDataTriggers ['TRI_ANSWER'] != '') ? $aDataTriggers ['TRI_ANSWER'] . " = " : ""; -$sPMfunction .= $aDataTriggers ['PMFUNTION_NAME'] . " (" . implode ( ",", $methodParamsFinal ) . ");"; - -//Create Trigger -$aDataTriggers ['TRI_WEBBOT'] = $sPMfunction; -$aDataTriggersParams = array(); -$aDataTriggersParams['hash'] = md5 ($sPMfunction); -$aDataTriggersParams['params'] = $aDataTriggers; - -$aDataTriggers ['TRI_PARAM'] = serialize($aDataTriggersParams); -$oTrigger->create ( $aDataTriggers ); - -//Update Info -$aDataTriggers ['TRI_UID'] = $oTrigger->getTriUid (); -$oTrigger->update ( $aDataTriggers ); - -//Update Trigger Array -$oProcessMap->triggersList($aDataTriggers['PRO_UID']); -?> +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ + +if (($RBAC_Response = $RBAC->userCanAccess( "PM_FACTORY" )) != 1) { + return $RBAC_Response; +} +require_once ('classes/model/Triggers.php'); +$oTrigger = new Triggers(); + +G::LoadClass( 'processMap' ); +$oProcessMap = new processMap( new DBConnection() ); + +$aDataTriggers = $_POST; + +$aInfoFunction = explode( ",", $aDataTriggers['ALLFUNCTION'] ); + +$sPMfunction = " +/*************************************************** + * + * Generated by ProcessMaker Trigger Wizard + * Library: " . $aDataTriggers['LIBRARY_NAME'] . " + * Method: " . $aDataTriggers['PMFUNTION_LABEL'] . " + * Date: " . date( "Y-m-d H:i:s" ) . " + * + * ProcessMaker " . date( "Y" ) . " + * + ****************************************************/ + +"; + +$methodParamsFinal = array (); +//Generate params to send +foreach ($aInfoFunction as $k => $v) { + if ($v != '') { + + $sOptionTrigger = trim( str_replace( "$", "", $v ) ); + if (strstr( $sOptionTrigger, "=" )) { + $aOptionParameters = explode( "=", $sOptionTrigger ); + $sOptionTrigger = trim( $aOptionParameters[0] ); + } + if ($aDataTriggers[$sOptionTrigger] != '') { + + if ((strstr( $aDataTriggers[$sOptionTrigger], "@@" ))) { + $option = trim( $aDataTriggers[$sOptionTrigger] ); + } else { + $aDataTriggers[$sOptionTrigger] = (strstr( $aDataTriggers[$sOptionTrigger], 'array' )) ? str_replace( "'", '"', $aDataTriggers[$sOptionTrigger] ) : str_replace( "'", "\'", $aDataTriggers[$sOptionTrigger] ); + $option = (is_numeric( $aDataTriggers[$sOptionTrigger] )) ? trim( $aDataTriggers[$sOptionTrigger] ) : (strstr( $aDataTriggers[$sOptionTrigger], "array" )) ? trim( $aDataTriggers[$sOptionTrigger] ) : "'" . trim( $aDataTriggers[$sOptionTrigger] ) . "'"; + } + } else { + $option = "''"; + } + $methodParamsFinal[] = $option; + + } + +} +//G::pr($methodParamsFinal);die; +$sPMfunction .= (isset( $aDataTriggers['TRI_ANSWER'] ) && $aDataTriggers['TRI_ANSWER'] != '') ? $aDataTriggers['TRI_ANSWER'] . " = " : ""; +$sPMfunction .= $aDataTriggers['PMFUNTION_NAME'] . " (" . implode( ",", $methodParamsFinal ) . ");"; + +//Create Trigger +$aDataTriggers['TRI_WEBBOT'] = $sPMfunction; +$aDataTriggersParams = array (); +$aDataTriggersParams['hash'] = md5( $sPMfunction ); +$aDataTriggersParams['params'] = $aDataTriggers; + +$aDataTriggers['TRI_PARAM'] = serialize( $aDataTriggersParams ); +$oTrigger->create( $aDataTriggers ); + +//Update Info +$aDataTriggers['TRI_UID'] = $oTrigger->getTriUid(); +$oTrigger->update( $aDataTriggers ); + +//Update Trigger Array +$oProcessMap->triggersList( $aDataTriggers['PRO_UID'] ); + diff --git a/workflow/engine/methods/triggers/triggers_WizardUpdate.php b/workflow/engine/methods/triggers/triggers_WizardUpdate.php index a8538965a..d466bf217 100755 --- a/workflow/engine/methods/triggers/triggers_WizardUpdate.php +++ b/workflow/engine/methods/triggers/triggers_WizardUpdate.php @@ -12,41 +12,41 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 . + * along with this program. If not, see . * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * */ -if (($RBAC_Response = $RBAC->userCanAccess ( "PM_FACTORY" )) != 1) - return $RBAC_Response; -if (!class_exists('Triggers')){ +if (($RBAC_Response = $RBAC->userCanAccess( "PM_FACTORY" )) != 1) { + return $RBAC_Response; +} +if (! class_exists( 'Triggers' )) { require_once ('classes/model/Triggers.php'); } -$oTrigger = new Triggers ( ); +$oTrigger = new Triggers(); -G::LoadClass('processMap'); -$oProcessMap = new processMap(new DBConnection); +G::LoadClass( 'processMap' ); +$oProcessMap = new processMap( new DBConnection() ); $aDataTriggers = $_POST; $triUid = $_POST['TRI_UID']; -$aInfoFunction = explode ( ",", $aDataTriggers ['ALLFUNCTION'] ); +$aInfoFunction = explode( ",", $aDataTriggers['ALLFUNCTION'] ); $sPMfunction = " /*************************************************** * * Generated by ProcessMaker Trigger Wizard - * Library: " . $aDataTriggers ['LIBRARY_NAME'] . " - * Method: " . $aDataTriggers ['PMFUNTION_LABEL'] . " - * Date: " . date ( "Y-m-d H:i:s" ) . " + * Library: " . $aDataTriggers['LIBRARY_NAME'] . " + * Method: " . $aDataTriggers['PMFUNTION_LABEL'] . " + * Date: " . date( "Y-m-d H:i:s" ) . " * - * ProcessMaker " . date ( "Y" ) . " + * ProcessMaker " . date( "Y" ) . " * ****************************************************/ @@ -54,53 +54,51 @@ $sPMfunction = " $methodParamsFinal = array (); //Generate params to send -foreach ( $aInfoFunction as $k => $v ) { - if ($v != '') { +foreach ($aInfoFunction as $k => $v) { + if ($v != '') { - $sOptionTrigger = trim ( str_replace ( "$", "", $v ) ); - if (strstr ( $sOptionTrigger, "=" )) { - $aOptionParameters = explode ( "=", $sOptionTrigger ); - $sOptionTrigger = trim ( $aOptionParameters [0] ); - } - if ($aDataTriggers [$sOptionTrigger] != '') { + $sOptionTrigger = trim( str_replace( "$", "", $v ) ); + if (strstr( $sOptionTrigger, "=" )) { + $aOptionParameters = explode( "=", $sOptionTrigger ); + $sOptionTrigger = trim( $aOptionParameters[0] ); + } + if ($aDataTriggers[$sOptionTrigger] != '') { - if ((strstr ( $aDataTriggers [$sOptionTrigger], "@@" ))) { - $option = $aDataTriggers [$sOptionTrigger]; - } else { - - $aDataTriggers [$sOptionTrigger] =(strstr($aDataTriggers[$sOptionTrigger],'array'))? - str_replace("'", '"', $aDataTriggers[$sOptionTrigger]):str_replace("'", "\'", $aDataTriggers [$sOptionTrigger]); + if ((strstr( $aDataTriggers[$sOptionTrigger], "@@" ))) { + $option = $aDataTriggers[$sOptionTrigger]; + } else { - $option = (is_numeric($aDataTriggers [$sOptionTrigger]))?trim($aDataTriggers [$sOptionTrigger]): - (strstr($aDataTriggers [$sOptionTrigger],"array") )?trim($aDataTriggers [$sOptionTrigger]):"'" . trim($aDataTriggers [$sOptionTrigger]) . "'"; - } - } else { - $option = "' '"; - } - $methodParamsFinal [] = $option; + $aDataTriggers[$sOptionTrigger] = (strstr( $aDataTriggers[$sOptionTrigger], 'array' )) ? str_replace( "'", '"', $aDataTriggers[$sOptionTrigger] ) : str_replace( "'", "\'", $aDataTriggers[$sOptionTrigger] ); - } + $option = (is_numeric( $aDataTriggers[$sOptionTrigger] )) ? trim( $aDataTriggers[$sOptionTrigger] ) : (strstr( $aDataTriggers[$sOptionTrigger], "array" )) ? trim( $aDataTriggers[$sOptionTrigger] ) : "'" . trim( $aDataTriggers[$sOptionTrigger] ) . "'"; + } + } else { + $option = "' '"; + } + $methodParamsFinal[] = $option; + + } } -$sPMfunction .= (isset ( $aDataTriggers ['TRI_ANSWER'] ) && $aDataTriggers ['TRI_ANSWER'] != '') ? $aDataTriggers ['TRI_ANSWER'] . " = " : ""; -$sPMfunction .= $aDataTriggers ['PMFUNTION_NAME'] . " (" . implode ( ",", $methodParamsFinal ) . ");"; +$sPMfunction .= (isset( $aDataTriggers['TRI_ANSWER'] ) && $aDataTriggers['TRI_ANSWER'] != '') ? $aDataTriggers['TRI_ANSWER'] . " = " : ""; +$sPMfunction .= $aDataTriggers['PMFUNTION_NAME'] . " (" . implode( ",", $methodParamsFinal ) . ");"; //Create Trigger -$aDataTriggers ['TRI_WEBBOT'] = $sPMfunction; -$aDataTriggersParams = array(); -$aDataTriggersParams['hash'] = md5 ($sPMfunction); +$aDataTriggers['TRI_WEBBOT'] = $sPMfunction; +$aDataTriggersParams = array (); +$aDataTriggersParams['hash'] = md5( $sPMfunction ); $aDataTriggersParams['params'] = $aDataTriggers; -$aDataTriggers ['TRI_PARAM'] = serialize($aDataTriggersParams); +$aDataTriggers['TRI_PARAM'] = serialize( $aDataTriggersParams ); //$oTrigger->create ( $aDataTriggers ); -$aDataTriggerLoaded = $oTrigger->load($triUid); +$aDataTriggerLoaded = $oTrigger->load( $triUid ); //var_dump($aDataTriggerLoaded); //die; //Update Info -$aDataTriggers ['TRI_UID'] = $oTrigger->getTriUid (); -$oTrigger->update ( $aDataTriggers ); +$aDataTriggers['TRI_UID'] = $oTrigger->getTriUid(); +$oTrigger->update( $aDataTriggers ); //Update Trigger Array -$oProcessMap->triggersList($aDataTriggers['PRO_UID']); -?> +$oProcessMap->triggersList( $aDataTriggers['PRO_UID'] ); +