2010-12-02 23:34:41 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* events_EditAction.php
|
|
|
|
|
*
|
|
|
|
|
* ProcessMaker Open Source Edition
|
|
|
|
|
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-10-18 12:53:09 -04:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2010-12-02 23:34:41 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
2012-10-18 12:53:09 -04:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-12-02 23:34:41 +00:00
|
|
|
*
|
|
|
|
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
|
|
|
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
|
|
|
|
*/
|
|
|
|
|
global $RBAC;
|
|
|
|
|
global $_DBArray;
|
|
|
|
|
|
2012-10-18 12:53:09 -04:00
|
|
|
if ($RBAC->userCanAccess( 'PM_SETUP' ) != 1) {
|
|
|
|
|
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
|
|
|
|
|
G::header( 'location: ../login/login' );
|
|
|
|
|
die();
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-18 12:53:09 -04:00
|
|
|
if (isset( $_SESSION['EVN_UID'] )) {
|
|
|
|
|
$evnUid = $_SESSION['EVN_UID'];
|
|
|
|
|
unset( $_SESSION['EVN_UID'] );
|
|
|
|
|
} else {
|
|
|
|
|
$evnUid = $_GET['EVN_UID'];
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
require_once 'classes/model/Event.php';
|
|
|
|
|
require_once 'classes/model/Triggers.php';
|
2012-10-18 12:53:09 -04:00
|
|
|
$oEvent = new Event();
|
2010-12-02 23:34:41 +00:00
|
|
|
$oTrigger = new Triggers();
|
|
|
|
|
$aFields = $oEvent->load( $evnUid );
|
2012-10-18 12:53:09 -04:00
|
|
|
$parameters = unserialize( $oEvent->getEvnActionParameters() );
|
2010-12-02 23:34:41 +00:00
|
|
|
//g::pr($parameters); die;
|
2012-10-18 12:53:09 -04:00
|
|
|
$aTrigger = $oTrigger->load( $aFields['TRI_UID'] );
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2015-03-26 11:22:37 -04:00
|
|
|
$hash = G::encryptOld( $oTrigger->getTriWebbot() );
|
2010-12-02 23:34:41 +00:00
|
|
|
//var_dump($hash,$parameters->hash);die;
|
|
|
|
|
//if the hash is different, the script was edited , so we will show the trigger editor.
|
2012-10-18 12:53:09 -04:00
|
|
|
if ((isset( $parameters->hash ) && $hash != $parameters->hash) || $aFields['EVN_ACTION'] == 'EXECUTE_TRIGGER' || $aFields['EVN_ACTION'] == 'EXECUTE_CONDITIONAL_TRIGGER') {
|
|
|
|
|
$oTriggerParams = unserialize( $aTrigger['TRI_PARAM'] );
|
|
|
|
|
// check again a hash, this time to check the trigger itself integrity
|
|
|
|
|
if ($oTriggerParams['hash'] != $hash) {
|
|
|
|
|
// if has changed edit manually
|
|
|
|
|
$G_PUBLISH = new Publisher();
|
|
|
|
|
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'triggers/triggersNarrowEdit', '', $aTrigger, '../events/triggersSave' );
|
|
|
|
|
G::RenderPage( 'publish', 'raw' );
|
|
|
|
|
die();
|
|
|
|
|
} else {
|
|
|
|
|
// if not launch the wizard view.
|
|
|
|
|
$triUid = $aFields['TRI_UID'];
|
|
|
|
|
$_GET = $oTriggerParams['params'];
|
|
|
|
|
$_GET['TRI_UID'] = $triUid;
|
|
|
|
|
require_once (PATH_METHODS . 'triggers/triggers_EditWizard.php');
|
|
|
|
|
die();
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-18 12:53:09 -04:00
|
|
|
$aFields['EVN_MESSAGE_SUBJECT'] = (isset( $parameters->SUBJECT ) ? $parameters->SUBJECT : '');
|
|
|
|
|
|
|
|
|
|
if (isset( $parameters->TO )) {
|
|
|
|
|
$paramTO[] = Array ('id' => 'char','name' => 'char' );
|
|
|
|
|
|
|
|
|
|
//echo '<pre>';print_r($parameters->TO);
|
|
|
|
|
foreach ($parameters->TO as $item) {
|
|
|
|
|
$row = explode( '|', $item );
|
2013-05-28 19:42:44 +00:00
|
|
|
$row[1] = trim($row[1]);
|
|
|
|
|
|
2012-10-18 12:53:09 -04:00
|
|
|
switch ($row[0]) {
|
|
|
|
|
case 'usr':
|
|
|
|
|
require_once ('classes/model/Users.php');
|
|
|
|
|
$user = new Users();
|
|
|
|
|
if ($row[1] == '-1') {
|
|
|
|
|
$value = '(Current Task User)';
|
|
|
|
|
} else {
|
|
|
|
|
$rec = $user->load( $row[1] );
|
|
|
|
|
$value = $rec['USR_FIRSTNAME'] . ' ' . $rec['USR_LASTNAME'];
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'grp':
|
|
|
|
|
$group = new Groups();
|
|
|
|
|
$rec = $group->load( $row[1] );
|
|
|
|
|
$value = strip_tags( $rec->getGrpTitle() );
|
|
|
|
|
break;
|
|
|
|
|
case 'ext':
|
|
|
|
|
$value = htmlentities( $row[1] );
|
|
|
|
|
break;
|
|
|
|
|
case 'dyn':
|
|
|
|
|
$value = htmlentities( '@#' . $row[1] );
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
echo '->' . $row[0];
|
|
|
|
|
}
|
|
|
|
|
$paramTO[] = Array ('id' => replaceQuotes( $item ),'name' => $value
|
|
|
|
|
);
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
} else {
|
2012-10-18 12:53:09 -04:00
|
|
|
$paramTO[] = Array ('id' => 'char','name' => 'char'
|
|
|
|
|
);
|
|
|
|
|
$paramTO[] = Array ('id' => 'usr|-1','name' => '(Current Task User)'
|
|
|
|
|
);
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
$_DBArray['eventomsgto'] = $paramTO;
|
|
|
|
|
|
2012-10-18 12:53:09 -04:00
|
|
|
if (isset( $parameters->CC )) {
|
|
|
|
|
$paramCC[] = Array ('id' => 'char','name' => 'char' );
|
|
|
|
|
foreach ($parameters->CC as $item) {
|
|
|
|
|
$row = explode( '|', $item );
|
2013-05-28 19:42:44 +00:00
|
|
|
$row[1] = trim($row[1]);
|
|
|
|
|
|
2012-10-18 12:53:09 -04:00
|
|
|
switch ($row[0]) {
|
|
|
|
|
case 'usr':
|
|
|
|
|
require_once ('classes/model/Users.php');
|
|
|
|
|
$user = new Users();
|
|
|
|
|
|
|
|
|
|
if ($row[1] == '-1') {
|
|
|
|
|
$value = '(Current Task User)';
|
|
|
|
|
} else {
|
|
|
|
|
$rec = $user->load( $row[1] );
|
|
|
|
|
$value = $rec['USR_FIRSTNAME'] . ' ' . $rec['USR_LASTNAME'];
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'grp':
|
|
|
|
|
$group = new Groups();
|
|
|
|
|
$rec = $group->load( $row[1] );
|
|
|
|
|
$value = strip_tags( $rec->getGrpTitle() );
|
|
|
|
|
break;
|
|
|
|
|
case 'ext':
|
|
|
|
|
$value = htmlentities( $row[1] );
|
|
|
|
|
break;
|
|
|
|
|
case 'dyn':
|
|
|
|
|
$value = htmlentities( '@#' . $row[1] );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$paramCC[] = Array ('id' => replaceQuotes( $item ),'name' => $value
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$_DBArray['eventomsgcc'] = $paramCC;
|
|
|
|
|
|
2010-12-02 23:34:41 +00:00
|
|
|
} else {
|
2012-10-18 12:53:09 -04:00
|
|
|
$_DBArray['eventomsgcc'] = Array ();
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-18 12:53:09 -04:00
|
|
|
if (isset( $parameters->BCC )) {
|
|
|
|
|
$paramBCC[] = Array ('id' => 'char','name' => 'char' );
|
|
|
|
|
foreach ($parameters->BCC as $item) {
|
|
|
|
|
$row = explode( '|', $item );
|
2013-05-28 19:42:44 +00:00
|
|
|
$row[1] = trim($row[1]);
|
|
|
|
|
|
2012-10-18 12:53:09 -04:00
|
|
|
switch ($row[0]) {
|
|
|
|
|
case 'usr':
|
|
|
|
|
require_once ('classes/model/Users.php');
|
|
|
|
|
$user = new Users();
|
|
|
|
|
|
|
|
|
|
if ($row[1] == '-1') {
|
|
|
|
|
$value = '(Current Task User)';
|
|
|
|
|
} else {
|
|
|
|
|
$rec = $user->load( $row[1] );
|
|
|
|
|
$value = $rec['USR_FIRSTNAME'] . ' ' . $rec['USR_LASTNAME'];
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'grp':
|
|
|
|
|
$group = new Groups();
|
|
|
|
|
$rec = $group->load( $row[1] );
|
|
|
|
|
$value = strip_tags( $rec->getGrpTitle() );
|
|
|
|
|
break;
|
|
|
|
|
case 'ext':
|
|
|
|
|
$value = htmlentities( $row[1] );
|
|
|
|
|
break;
|
|
|
|
|
case 'dyn':
|
|
|
|
|
$value = htmlentities( '@#' . $row[1] );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$paramBCC[] = Array ('id' => replaceQuotes( $item ),'name' => $value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$_DBArray['eventomsgbcc'] = $paramBCC;
|
|
|
|
|
|
2010-12-02 23:34:41 +00:00
|
|
|
} else {
|
2012-10-18 12:53:09 -04:00
|
|
|
$_DBArray['eventomsgbcc'] = Array ();
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-18 12:53:09 -04:00
|
|
|
$aFields['EVN_MESSAGE_TO_TO'] = $paramTO;
|
|
|
|
|
$aFields['EVN_MESSAGE_TO_CC'] = (isset( $parameters->CC ) ? $paramCC : '');
|
|
|
|
|
$aFields['EVN_MESSAGE_TO_BCC'] = (isset( $parameters->BCC ) ? $paramBCC : '');
|
|
|
|
|
$aFields['EVN_MESSAGE_TEMPLATE'] = (isset( $parameters->TEMPLATE ) ? $parameters->TEMPLATE : '');
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-18 12:53:09 -04:00
|
|
|
$aTemplates = array ();
|
|
|
|
|
$aTemplates[] = array ('TEMPLATE1' => 'char','TEMPLATE2' => 'char');
|
2010-12-02 23:34:41 +00:00
|
|
|
$sDirectory = PATH_DATA_MAILTEMPLATES . $aFields['PRO_UID'] . PATH_SEP;
|
2012-10-18 12:53:09 -04:00
|
|
|
G::verifyPath( $sDirectory, true );
|
|
|
|
|
if (! file_exists( $sDirectory . 'alert_message.html' )) {
|
|
|
|
|
@copy( PATH_TPL . 'mails' . PATH_SEP . 'alert_message.html', $sDirectory . 'alert_message.html' );
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-18 12:53:09 -04:00
|
|
|
$oDirectory = dir( $sDirectory );
|
2010-12-02 23:34:41 +00:00
|
|
|
while ($sObject = $oDirectory->read()) {
|
2012-10-18 12:53:09 -04:00
|
|
|
if (($sObject !== '.') && ($sObject !== '..') && ($sObject !== 'alert_message.html')) {
|
|
|
|
|
$aTemplates[] = array ('TEMPLATE1' => $sObject,'TEMPLATE2' => $sObject);
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
$_DBArray['templates'] = $aTemplates;
|
|
|
|
|
|
2012-10-18 12:53:09 -04:00
|
|
|
$aTriggers[] = array ('TRI_UID' => 'char','TRI_TITLE' => 'char');
|
2010-12-02 23:34:41 +00:00
|
|
|
$oProcessMap = new ProcessMap();
|
2012-10-18 12:53:09 -04:00
|
|
|
$oDataset = TriggersPeer::doSelectRS( $oProcessMap->getTriggersCriteria( $aFields['PRO_UID'] ) );
|
|
|
|
|
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
2010-12-02 23:34:41 +00:00
|
|
|
$oDataset->next();
|
|
|
|
|
while ($aRow = $oDataset->getRow()) {
|
2012-10-18 12:53:09 -04:00
|
|
|
$aTriggers[] = array ('TRI_UID' => $aRow['TRI_UID'],'TRI_TITLE' => $aRow['TRI_TITLE'] );
|
|
|
|
|
$oDataset->next();
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
$_DBArray['triggers'] = $aTriggers;
|
|
|
|
|
|
|
|
|
|
$_SESSION['_DBArray'] = $_DBArray;
|
|
|
|
|
|
2014-02-12 15:10:04 -04:00
|
|
|
$aFields = array_merge($aFields, setLabels());
|
2010-12-02 23:34:41 +00:00
|
|
|
$G_PUBLISH = new Publisher();
|
2012-10-18 12:53:09 -04:00
|
|
|
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'events/eventsEditAction', '', $aFields, '../events/eventsSave' );
|
2010-12-02 23:34:41 +00:00
|
|
|
//$G_PUBLISH->AddContent('xmlform', 'xmlform', 'events/eventsEditAction', '', $aFields, '../events/eventsSave');
|
2012-10-18 12:53:09 -04:00
|
|
|
G::RenderPage( 'publish', 'raw' );
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-18 12:53:09 -04:00
|
|
|
function replaceQuotes ($aData)
|
|
|
|
|
{
|
|
|
|
|
return str_replace( '"', '"e;', $aData );
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-18 12:53:09 -04:00
|
|
|
|
2014-02-12 15:10:04 -04:00
|
|
|
function setLabels () {
|
|
|
|
|
$labels = array(
|
|
|
|
|
'LABEL_ADD' => G::LoadTranslation( 'ID_ADD' ),
|
|
|
|
|
'LABEL_ADD_CURRENT' => G::LoadTranslation( 'ID_EVENT_ADD_CURRENT' ),
|
|
|
|
|
'LABEL_ADD_USERS' => G::LoadTranslation( 'ID_EVENT_ADD_USERS' ),
|
|
|
|
|
'LABEL_REMOVED_SELECTED' => G::LoadTranslation( 'ID_EVENT_REMOVE_SELECTED' ),
|
|
|
|
|
'LABEL_ADD_DYNAVAR' => G::LoadTranslation( 'ID_EVENT_ADD_DYNAVAR' ),
|
2014-10-30 16:32:17 -04:00
|
|
|
'LABEL_ADD_GROUPS' => G::LoadTranslation( 'ID_EVENT_ADD_GROUP' )
|
2014-02-12 15:10:04 -04:00
|
|
|
);
|
|
|
|
|
return $labels;
|
|
|
|
|
}
|
|
|
|
|
|