BUG 9319 "Problema con el Case Label" SOLVED

- By changing the "Case Label", this is not updated in the APP_CACHE_VIEW table
- Solved problem to changing the "Case Label", now is updated in the APP_CACHE_VIEW table
- Improvement in file, compliance with the standard PSR2

Note:
- When you change the "Case Title" of a task, affecting every case,
  if it is the current task of the case (otherwise it would not affect
  the APP_CACHE_VIEW table)
- If a task is saved empty the "Case Title" the APP_TITLE take the value
  #APP_NUMBER (all cases are in the task, this in APP_CACHE_VIEW table)
This commit is contained in:
Victor Saisa Lopez
2012-07-03 18:20:20 -04:00
parent dff24f4996
commit 167bab6b6e
5 changed files with 2599 additions and 2191 deletions

View File

@@ -12,22 +12,32 @@ if (!defined('SYS_LANG')) {
} }
if (!defined('PATH_HOME')) { if (!defined('PATH_HOME')) {
if ( !defined('PATH_SEP') ) { if (!defined('PATH_SEP')) {
define('PATH_SEP', ( substr(PHP_OS, 0, 3) == 'WIN' ) ? '\\' : '/'); define('PATH_SEP', (substr(PHP_OS, 0, 3) == 'WIN') ? '\\' : '/');
} }
$docuroot = explode(PATH_SEP, str_replace('engine' . PATH_SEP . 'methods' . PATH_SEP . 'services', '', dirname(__FILE__)));
$pathServices = 'engine' . PATH_SEP . 'methods' . PATH_SEP . 'services';
$docuroot = explode(PATH_SEP, str_replace($pathServices, '', dirname(__FILE__)));
array_pop($docuroot); array_pop($docuroot);
array_pop($docuroot); array_pop($docuroot);
$pathhome = implode(PATH_SEP, $docuroot) . PATH_SEP;
$pathHome = implode(PATH_SEP, $docuroot) . PATH_SEP;
//try to find automatically the trunk directory where are placed the RBAC and Gulliver directories //try to find automatically the trunk directory where are placed the RBAC and Gulliver directories
//in a normal installation you don't need to change it. //in a normal installation you don't need to change it.
array_pop($docuroot);
$pathTrunk = implode(PATH_SEP, $docuroot) . PATH_SEP ;
array_pop($docuroot);
$pathOutTrunk = implode( PATH_SEP, $docuroot) . PATH_SEP ;
// to do: check previous algorith for Windows $pathTrunk = "c:/home/";
define('PATH_HOME', $pathhome); array_pop($docuroot);
$pathTrunk = implode(PATH_SEP, $docuroot) . PATH_SEP;
array_pop($docuroot);
$pathOutTrunk = implode(PATH_SEP, $docuroot) . PATH_SEP;
//to do: check previous algorith for Windows $pathTrunk = "c:/home/";
define('PATH_HOME', $pathHome);
define('PATH_TRUNK', $pathTrunk); define('PATH_TRUNK', $pathTrunk);
define('PATH_OUTTRUNK', $pathOutTrunk); define('PATH_OUTTRUNK', $pathOutTrunk);
@@ -57,23 +67,27 @@ if (!defined('PATH_HOME')) {
require_once ( "creole/Creole.php" ); require_once ( "creole/Creole.php" );
} }
require_once 'classes/model/AppDelegation.php'; require_once ("classes/model/Configuration.php");
require_once 'classes/model/Event.php'; require_once ("classes/model/AppCacheView.php");
require_once 'classes/model/AppEvent.php'; require_once ("classes/model/AppDelegation.php");
require_once 'classes/model/CaseScheduler.php'; require_once ("classes/model/Event.php");
//G::loadClass('pmScript'); require_once ("classes/model/AppEvent.php");
require_once ("classes/model/CaseScheduler.php");
//G::loadClass("pmScript");
//default values //default values
$bCronIsRunning = false; $bCronIsRunning = false;
$sLastExecution = ''; $sLastExecution = '';
if ( file_exists(PATH_DATA . 'cron') ) {
$aAux = unserialize( trim( @file_get_contents(PATH_DATA . 'cron')) ); if (file_exists(PATH_DATA . 'cron')) {
$bCronIsRunning = (boolean)$aAux['bCronIsRunning']; $arrayAux = unserialize(trim(@file_get_contents(PATH_DATA . 'cron')));
$sLastExecution = $aAux['sLastExecution']; $bCronIsRunning = (boolean)($arrayAux['bCronIsRunning']);
} $sLastExecution = $arrayAux['sLastExecution'];
else { } else {
//if not exists the file, just create a new one with current date //if not exists the file, just create a new one with current date
@file_put_contents(PATH_DATA . 'cron', serialize(array('bCronIsRunning' => '1', 'sLastExecution' => date('Y-m-d H:i:s')))); $arrayAux = array('bCronIsRunning' => '1', 'sLastExecution' => date('Y-m-d H:i:s'));
@file_put_contents(PATH_DATA . 'cron', serialize($arrayAux));
} }
if (!defined('SYS_SYS')) { if (!defined('SYS_SYS')) {
@@ -81,37 +95,37 @@ if (!defined('SYS_SYS')) {
$sNow = $argv[2]; $sNow = $argv[2];
$sFilter = ''; $sFilter = '';
for($i=3; $i<count($argv); $i++){ for ($i = 3; $i < count($argv); $i++) {
$sFilter .= ' '.$argv[$i]; $sFilter .= ' ' . $argv[$i];
} }
$oDirectory = dir(PATH_DB); $oDirectory = dir(PATH_DB);
if (is_dir(PATH_DB . $sObject)) { if (is_dir(PATH_DB . $sObject)) {
saveLog ( 'main', 'action', "checking folder " . PATH_DB . $sObject ); saveLog('main', 'action', "checking folder " . PATH_DB . $sObject);
if (file_exists(PATH_DB . $sObject . PATH_SEP . 'db.php')) {
if (file_exists(PATH_DB . $sObject . PATH_SEP . 'db.php')) {
define('SYS_SYS', $sObject); define('SYS_SYS', $sObject);
include_once(PATH_HOME.'engine'.PATH_SEP.'config'.PATH_SEP.'paths_installed.php'); include_once (PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths_installed.php');
include_once(PATH_HOME.'engine'.PATH_SEP.'config'.PATH_SEP.'paths.php'); include_once (PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php');
//***************** PM Paths DATA ************************** //***************** PM Paths DATA **************************
define( 'PATH_DATA_SITE', PATH_DATA . 'sites/' . SYS_SYS . '/'); define('PATH_DATA_SITE', PATH_DATA . 'sites/' . SYS_SYS . '/');
define( 'PATH_DOCUMENT', PATH_DATA_SITE . 'files/' ); define('PATH_DOCUMENT', PATH_DATA_SITE . 'files/');
define( 'PATH_DATA_MAILTEMPLATES', PATH_DATA_SITE . 'mailTemplates/' ); define('PATH_DATA_MAILTEMPLATES', PATH_DATA_SITE . 'mailTemplates/');
define( 'PATH_DATA_PUBLIC', PATH_DATA_SITE . 'public/' ); define('PATH_DATA_PUBLIC', PATH_DATA_SITE . 'public/');
define( 'PATH_DATA_REPORTS', PATH_DATA_SITE . 'reports/' ); define('PATH_DATA_REPORTS', PATH_DATA_SITE . 'reports/');
define( 'PATH_DYNAFORM', PATH_DATA_SITE . 'xmlForms/' ); define('PATH_DYNAFORM', PATH_DATA_SITE . 'xmlForms/');
define( 'PATH_IMAGES_ENVIRONMENT_FILES', PATH_DATA_SITE . 'usersFiles'.PATH_SEP); define('PATH_IMAGES_ENVIRONMENT_FILES', PATH_DATA_SITE . 'usersFiles' . PATH_SEP);
define( 'PATH_IMAGES_ENVIRONMENT_USERS', PATH_DATA_SITE . 'usersPhotographies'.PATH_SEP); define('PATH_IMAGES_ENVIRONMENT_USERS', PATH_DATA_SITE . 'usersPhotographies' . PATH_SEP);
if(is_file(PATH_DATA_SITE.PATH_SEP.'.server_info')){ if (is_file(PATH_DATA_SITE.PATH_SEP . '.server_info')) {
$SERVER_INFO = file_get_contents(PATH_DATA_SITE.PATH_SEP.'.server_info'); $SERVER_INFO = file_get_contents(PATH_DATA_SITE.PATH_SEP.'.server_info');
$SERVER_INFO = unserialize($SERVER_INFO); $SERVER_INFO = unserialize($SERVER_INFO);
//print_r($SERVER_INFO);
define( 'SERVER_NAME', $SERVER_INFO ['SERVER_NAME']); define('SERVER_NAME', $SERVER_INFO ['SERVER_NAME']);
define( 'SERVER_PORT', $SERVER_INFO ['SERVER_PORT']); define('SERVER_PORT', $SERVER_INFO ['SERVER_PORT']);
} else { } else {
eprintln("WARNING! No server info found!", 'red'); eprintln("WARNING! No server info found!", 'red');
} }
@@ -127,9 +141,15 @@ if (!defined('SYS_SYS')) {
$sContent = str_replace(");", ';', $sContent); $sContent = str_replace(");", ';', $sContent);
eval($sContent); eval($sContent);
$dsn = $DB_ADAPTER . '://' . $DB_USER . ':' . $DB_PASS . '@' . $DB_HOST . '/' . $DB_NAME; $dsn = $DB_ADAPTER . '://' . $DB_USER . ':' . $DB_PASS . '@' . $DB_HOST . '/' . $DB_NAME;
$dsnRbac = $DB_ADAPTER . '://' . $DB_RBAC_USER . ':' . $DB_RBAC_PASS . '@' . $DB_RBAC_HOST . '/' . $DB_RBAC_NAME;
$dsnRp = $DB_ADAPTER . '://' . $DB_REPORT_USER . ':' . $DB_REPORT_PASS . '@' . $DB_REPORT_HOST . '/' . $DB_REPORT_NAME; $dsnRbac = $DB_ADAPTER . '://' . $DB_RBAC_USER . ':' . $DB_RBAC_PASS . '@' . $DB_RBAC_HOST . '/';
$dsnRbac = $dsnRbac . $DB_RBAC_NAME;
$dsnRp = $DB_ADAPTER . '://' . $DB_REPORT_USER . ':' . $DB_REPORT_PASS . '@' . $DB_REPORT_HOST . '/';
$dsnRp = $dsnRp . $DB_REPORT_NAME;
switch ($DB_ADAPTER) { switch ($DB_ADAPTER) {
case 'mysql': case 'mysql':
$dsn .= '?encoding=utf8'; $dsn .= '?encoding=utf8';
@@ -142,6 +162,7 @@ if (!defined('SYS_SYS')) {
default: default:
break; break;
} }
$pro['datasources']['workflow']['connection'] = $dsn; $pro['datasources']['workflow']['connection'] = $dsn;
$pro['datasources']['workflow']['adapter'] = $DB_ADAPTER; $pro['datasources']['workflow']['adapter'] = $DB_ADAPTER;
$pro['datasources']['rbac']['connection'] = $dsnRbac; $pro['datasources']['rbac']['connection'] = $dsnRbac;
@@ -150,34 +171,41 @@ if (!defined('SYS_SYS')) {
$pro['datasources']['rp']['adapter'] = $DB_ADAPTER; $pro['datasources']['rp']['adapter'] = $DB_ADAPTER;
//$pro['datasources']['dbarray']['connection'] = 'dbarray://user:pass@localhost/pm_os'; //$pro['datasources']['dbarray']['connection'] = 'dbarray://user:pass@localhost/pm_os';
//$pro['datasources']['dbarray']['adapter'] = 'dbarray'; //$pro['datasources']['dbarray']['adapter'] = 'dbarray';
$oFile = fopen(PATH_CORE . 'config/_databases_.php', 'w'); $oFile = fopen(PATH_CORE . 'config/_databases_.php', 'w');
fwrite($oFile, '<?php global $pro;return $pro; ?>'); fwrite($oFile, '<?php global $pro;return $pro; ?>');
fclose($oFile); fclose($oFile);
Propel::init(PATH_CORE . 'config/_databases_.php'); Propel::init(PATH_CORE . 'config/_databases_.php');
//Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection'); //Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection');
eprintln("Processing workspace: " . $sObject, 'green'); eprintln("Processing workspace: " . $sObject, "green");
try{
try {
processWorkspace(); processWorkspace();
}catch(Exception $e){ } catch (Exception $e) {
echo $e->getMessage(); echo $e->getMessage();
eprintln("Probelm in workspace: " . $sObject.' it was omitted.', 'red');
eprintln("Probelm in workspace: " . $sObject . " it was omitted.", "red");
} }
eprintln(); eprintln();
} }
} }
unlink(PATH_CORE . 'config/_databases_.php'); unlink(PATH_CORE . 'config/_databases_.php');
} } else {
else {
processWorkspace(); processWorkspace();
} }
//finally update the file //finally update the file
@file_put_contents(PATH_DATA . 'cron', serialize(array('bCronIsRunning' => '0', 'sLastExecution' => date('Y-m-d H:i:s')))); $arrayAux = array('bCronIsRunning' => '0', 'sLastExecution' => date('Y-m-d H:i:s'));
@file_put_contents(PATH_DATA . 'cron', serialize($arrayAux));
function processWorkspace()
function processWorkspace() { {
global $sLastExecution; global $sLastExecution;
try { try {
resendEmails(); resendEmails();
unpauseApplications(); unpauseApplications();
@@ -185,63 +213,80 @@ function processWorkspace() {
executePlugins(); executePlugins();
executeEvents($sLastExecution); executeEvents($sLastExecution);
executeScheduledCases(); executeScheduledCases();
} executeUpdateAppTitle();
catch (Exception $oError) { } catch (Exception $oError) {
saveLog ("main", "error", "Error processing workspace : " . $oError->getMessage() . "\n" ); saveLog("main", "error", "Error processing workspace : " . $oError->getMessage() . "\n");
} }
} }
function resendEmails() { function resendEmails()
{
global $sFilter; global $sFilter;
if($sFilter!='' && strpos($sFilter, 'emails') === false) return false;
if ($sFilter != '' && strpos($sFilter, 'emails') === false) {
return false;
}
setExecutionMessage("Resending emails"); setExecutionMessage("Resending emails");
try { try {
G::LoadClass('spool'); G::LoadClass('spool');
$oSpool = new spoolRun(); $oSpool = new spoolRun();
$oSpool->resendEmails(); $oSpool->resendEmails();
saveLog('resendEmails', 'action', 'Resending Emails', "c"); saveLog('resendEmails', 'action', 'Resending Emails', "c");
$aSpoolWarnings = $oSpool->getWarnings(); $aSpoolWarnings = $oSpool->getWarnings();
if( $aSpoolWarnings !== false ) {
foreach($aSpoolWarnings as $sWarning){ if ( $aSpoolWarnings !== false ) {
foreach ($aSpoolWarnings as $sWarning) {
print('MAIL SPOOL WARNING: ' . $sWarning."\n"); print('MAIL SPOOL WARNING: ' . $sWarning."\n");
saveLog('resendEmails', 'warning', 'MAIL SPOOL WARNING: ' . $sWarning); saveLog('resendEmails', 'warning', 'MAIL SPOOL WARNING: ' . $sWarning);
} }
} }
setExecutionResultMessage('DONE'); setExecutionResultMessage('DONE');
} } catch (Exception $oError) {
catch (Exception $oError) {
setExecutionResultMessage('WITH ERRORS', 'error'); setExecutionResultMessage('WITH ERRORS', 'error');
eprintln(" '-".$oError->getMessage(), 'red'); eprintln(" '-".$oError->getMessage(), 'red');
saveLog('resendEmails', 'error', 'Error Resending Emails: ' . $oError->getMessage()); saveLog('resendEmails', 'error', 'Error Resending Emails: ' . $oError->getMessage());
} }
} }
function unpauseApplications() { function unpauseApplications()
{
global $sFilter; global $sFilter;
global $sNow; global $sNow;
if($sFilter!='' && strpos($sFilter, 'unpause') === false) return false;
if ($sFilter != '' && strpos($sFilter, 'unpause') === false) {
return false;
}
setExecutionMessage("Unpausing applications"); setExecutionMessage("Unpausing applications");
try { try {
G::LoadClass('case'); G::LoadClass('case');
$oCases = new Cases(); $oCases = new Cases();
$oCases->ThrowUnpauseDaemon($sNow); $oCases->ThrowUnpauseDaemon($sNow);
setExecutionResultMessage('DONE'); setExecutionResultMessage('DONE');
saveLog('unpauseApplications', 'action', 'Unpausing Applications'); saveLog('unpauseApplications', 'action', 'Unpausing Applications');
} } catch (Exception $oError) {
catch (Exception $oError) {
setExecutionResultMessage('WITH ERRORS', 'error'); setExecutionResultMessage('WITH ERRORS', 'error');
eprintln(" '-".$oError->getMessage(), 'red'); eprintln(" '-".$oError->getMessage(), 'red');
saveLog('unpauseApplications', 'error', 'Error Unpausing Applications: ' . $oError->getMessage()); saveLog('unpauseApplications', 'error', 'Error Unpausing Applications: ' . $oError->getMessage());
} }
} }
function executePlugins(){ function executePlugins()
{
global $sFilter; global $sFilter;
if($sFilter!='' && strpos($sFilter, 'plugins') === false) return false;
if ($sFilter!='' && strpos($sFilter, 'plugins') === false) {
return false;
}
$pathCronPlugins = PATH_CORE.'bin'.PATH_SEP.'plugins'.PATH_SEP; $pathCronPlugins = PATH_CORE.'bin'.PATH_SEP.'plugins'.PATH_SEP;
@@ -250,14 +295,16 @@ function executePlugins(){
return false; return false;
} }
if ($handle = opendir( $pathCronPlugins )) { if ($handle = opendir($pathCronPlugins)) {
while ( false !== ($file = readdir($handle))) { while (false !== ($file = readdir($handle))) {
if ( strpos($file, '.php',1) && is_file($pathCronPlugins . $file) ) { if (strpos($file, '.php',1) && is_file($pathCronPlugins . $file)) {
$filename = str_replace('.php' , '', $file) ; $filename = str_replace('.php' , '', $file);
$className = $filename . 'ClassCron'; $className = $filename . 'ClassCron';
include_once ( $pathCronPlugins . $file ); //$filename. ".php" include_once ( $pathCronPlugins . $file ); //$filename. ".php"
$oPlugin = new $className(); $oPlugin = new $className();
if (method_exists($oPlugin, 'executeCron')) { if (method_exists($oPlugin, 'executeCron')) {
$oPlugin->executeCron(); $oPlugin->executeCron();
setExecutionMessage("Executing Plugins"); setExecutionMessage("Executing Plugins");
@@ -267,120 +314,190 @@ function executePlugins(){
} }
} }
} }
function calculateDuration() {
function calculateDuration()
{
global $sFilter; global $sFilter;
if($sFilter!='' && strpos($sFilter, 'calculate') === false) return false;
if ($sFilter != '' && strpos($sFilter, 'calculate') === false) {
return false;
}
setExecutionMessage("Calculating Duration"); setExecutionMessage("Calculating Duration");
try { try {
$oAppDelegation = new AppDelegation(); $oAppDelegation = new AppDelegation();
$oAppDelegation->calculateDuration(); $oAppDelegation->calculateDuration();
setExecutionResultMessage('DONE'); setExecutionResultMessage('DONE');
saveLog('calculateDuration', 'action', 'Calculating Duration'); saveLog('calculateDuration', 'action', 'Calculating Duration');
} } catch (Exception $oError) {
catch (Exception $oError) {
setExecutionResultMessage('WITH ERRORS', 'error'); setExecutionResultMessage('WITH ERRORS', 'error');
eprintln(" '-".$oError->getMessage(), 'red'); eprintln(" '-".$oError->getMessage(), 'red');
saveLog('calculateDuration', 'error', 'Error Calculating Duration: ' . $oError->getMessage()); saveLog('calculateDuration', 'error', 'Error Calculating Duration: ' . $oError->getMessage());
} }
} }
function executeEvents($sLastExecution, $sNow=null) { function executeEvents($sLastExecution, $sNow=null)
{
global $sFilter; global $sFilter;
global $sNow; global $sNow;
$log = array(); $log = array();
if($sFilter!='' && strpos($sFilter, 'events') === false) return false; if ($sFilter != '' && strpos($sFilter, 'events') === false) {
return false;
}
setExecutionMessage("Executing events"); setExecutionMessage("Executing events");
setExecutionResultMessage('PROCESSING'); setExecutionResultMessage('PROCESSING');
try { try {
$oAppEvent = new AppEvent(); $oAppEvent = new AppEvent();
saveLog('executeEvents', 'action', "Executing Events $sLastExecution, $sNow "); saveLog('executeEvents', 'action', "Executing Events $sLastExecution, $sNow ");
$n = $oAppEvent->executeEvents($sNow, false, $log); $n = $oAppEvent->executeEvents($sNow, false, $log);
foreach ($log as $value) { foreach ($log as $value) {
saveLog('executeEvents', 'action', "Execute Events : $value, $sNow "); saveLog('executeEvents', 'action', "Execute Events : $value, $sNow ");
} }
setExecutionMessage("|- End Execution events"); setExecutionMessage("|- End Execution events");
setExecutionResultMessage("Processed $n"); setExecutionResultMessage("Processed $n");
//saveLog('executeEvents', 'action', $res ); //saveLog('executeEvents', 'action', $res );
} } catch (Exception $oError) {
catch (Exception $oError) {
setExecutionResultMessage('WITH ERRORS', 'error'); setExecutionResultMessage('WITH ERRORS', 'error');
eprintln(" '-".$oError->getMessage(), 'red'); eprintln(" '-".$oError->getMessage(), 'red');
saveLog('calculateAlertsDueDate', 'Error', 'Error Executing Events: ' . $oError->getMessage()); saveLog('calculateAlertsDueDate', 'Error', 'Error Executing Events: ' . $oError->getMessage());
} }
} }
function executeScheduledCases($sNow=null){ function executeScheduledCases($sNow=null)
try{ {
try {
global $sFilter; global $sFilter;
global $sNow; global $sNow;
$log = array(); $log = array();
if($sFilter!='' && strpos($sFilter, 'scheduler') === false) return false; if ($sFilter != '' && strpos($sFilter, 'scheduler') === false) {
return false;
}
setExecutionMessage("Executing the scheduled starting cases"); setExecutionMessage("Executing the scheduled starting cases");
setExecutionResultMessage('PROCESSING'); setExecutionResultMessage('PROCESSING');
$sNow = isset($sNow)? $sNow: date('Y-m-d H:i:s'); $sNow = isset($sNow)? $sNow : date('Y-m-d H:i:s');
$oCaseScheduler = new CaseScheduler;
$oCaseScheduler = new CaseScheduler();
$oCaseScheduler->caseSchedulerCron($sNow, $log); $oCaseScheduler->caseSchedulerCron($sNow, $log);
foreach ($log as $value) { foreach ($log as $value) {
saveLog('executeScheduledCases', 'action', "OK Case# $value"); saveLog('executeScheduledCases', 'action', "OK Case# $value");
} }
setExecutionResultMessage('DONE'); setExecutionResultMessage('DONE');
} catch(Exception $oError){ } catch (Exception $oError) {
setExecutionResultMessage('WITH ERRORS', 'error'); setExecutionResultMessage('WITH ERRORS', 'error');
eprintln(" '-".$oError->getMessage(), 'red'); eprintln(" '-".$oError->getMessage(), 'red');
} }
} }
function saveLog($sSource, $sType, $sDescription) { function executeUpdateAppTitle()
{
try {
$criteriaConf = new Criteria("workflow");
$criteriaConf->addSelectColumn(ConfigurationPeer::OBJ_UID);
$criteriaConf->addSelectColumn(ConfigurationPeer::CFG_VALUE);
$criteriaConf->add(ConfigurationPeer::CFG_UID, "TAS_APP_TITLE_UPDATE");
$rsCriteriaConf = ConfigurationPeer::doSelectRS($criteriaConf);
$rsCriteriaConf->setFetchmode(ResultSet::FETCHMODE_ASSOC);
setExecutionMessage("Update case labels");
saveLog("updateCaseLabels", "action", "Update case labels", "c");
while ($rsCriteriaConf->next()) {
$row = $rsCriteriaConf->getRow();
$taskUid = $row["OBJ_UID"];
$lang = $row["CFG_VALUE"];
//Update case labels
$appcv = new AppCacheView();
$appcv->appTitleByTaskCaseLabelUpdate($taskUid, $lang);
//Delete record
$criteria = new Criteria("workflow");
$criteria->add(ConfigurationPeer::CFG_UID, "TAS_APP_TITLE_UPDATE");
$criteria->add(ConfigurationPeer::OBJ_UID, $taskUid);
$criteria->add(ConfigurationPeer::CFG_VALUE, $lang);
$numRowDeleted = ConfigurationPeer::doDelete($criteria);
saveLog("updateCaseLabels", "action", "OK Task $taskUid");
}
setExecutionResultMessage("DONE");
} catch (Exception $e) {
setExecutionResultMessage("WITH ERRORS", "error");
eprintln(" '-" . $e->getMessage(), "red");
saveLog("updateCaseLabels", "error", "Error updating case labels: " . $e->getMessage());
}
}
function saveLog($sSource, $sType, $sDescription)
{
try { try {
global $isDebug; global $isDebug;
if ( $isDebug )
print date('H:i:s') ." ($sSource) $sType $sDescription <br>\n"; if ($isDebug) {
print date('H:i:s') ." ($sSource) $sType $sDescription <br />\n";
}
@fwrite($oFile, date('Y-m-d H:i:s') . '(' . $sSource . ') ' . $sDescription . "\n"); @fwrite($oFile, date('Y-m-d H:i:s') . '(' . $sSource . ') ' . $sDescription . "\n");
G::verifyPath(PATH_DATA . 'log' . PATH_SEP, true); G::verifyPath(PATH_DATA . 'log' . PATH_SEP, true);
if ($sType == 'action') { if ($sType == 'action') {
$oFile = @fopen(PATH_DATA . 'log' . PATH_SEP . 'cron.log', 'a+'); $oFile = @fopen(PATH_DATA . 'log' . PATH_SEP . 'cron.log', 'a+');
} } else {
else {
$oFile = @fopen(PATH_DATA . 'log' . PATH_SEP . 'cronError.log', 'a+'); $oFile = @fopen(PATH_DATA . 'log' . PATH_SEP . 'cronError.log', 'a+');
} }
@fwrite($oFile, date('Y-m-d H:i:s') . '(' . $sSource . ') ' . $sDescription . "\n"); @fwrite($oFile, date('Y-m-d H:i:s') . '(' . $sSource . ') ' . $sDescription . "\n");
@fclose($oFile); @fclose($oFile);
} } catch (Exception $oError) {
catch (Exception $oError) {
//CONTINUE //CONTINUE
} }
} }
function setExecutionMessage($m)
function setExecutionMessage($m){ {
$len = strlen($m); $len = strlen($m);
$linesize = 60; $linesize = 60;
$rOffset = $linesize - $len; $rOffset = $linesize - $len;
eprint("* $m"); eprint("* $m");
for($i=0; $i<$rOffset; $i++) eprint('.');
for ($i = 0; $i < $rOffset; $i++) {
eprint('.');
}
} }
function setExecutionResultMessage($m, $t=''){ function setExecutionResultMessage($m, $t='')
$c='green'; {
if($t=='error') $c = 'red'; $c = 'green';
if($t=='info') $c = 'yellow';
if ($t == 'error') {
$c = 'red';
}
if ($t == 'info') {
$c = 'yellow';
}
eprintln("[$m]", $c); eprintln("[$m]", $c);
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,29 +1,4 @@
<?php <?php
/**
* Task.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
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
require_once 'classes/model/om/BaseTask.php'; require_once 'classes/model/om/BaseTask.php';
require_once 'classes/model/Content.php'; require_once 'classes/model/Content.php';
@@ -39,25 +14,30 @@ require_once 'classes/model/Content.php';
* *
* @package workflow.engine.classes.model * @package workflow.engine.classes.model
*/ */
class Task extends BaseTask { class Task extends BaseTask
{
/** /**
* This value goes in the content table * This value goes in the content table
* @var string * @var string
*/ */
protected $tas_title = ''; protected $tas_title = '';
/** /**
* Get the tas_title column value. * Get the tas_title column value.
* @return string * @return string
*/ */
public function getTasTitle() public function getTasTitle()
{ {
if ( $this->getTasUid() == "" ) { if ($this->getTasUid() == "") {
throw ( new Exception( "Error in getTasTitle, the getTasUid() can't be blank") ); throw (new Exception("Error in getTasTitle, the getTasUid() can't be blank"));
} }
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
$this->tas_title = Content::load ( 'TAS_TITLE', '', $this->getTasUid(), $lang ); $lang = defined('SYS_LANG')? SYS_LANG : 'en';
$this->tas_title = Content::load('TAS_TITLE', '', $this->getTasUid(), $lang);
return $this->tas_title; return $this->tas_title;
} }
/** /**
* Set the tas_title column value. * Set the tas_title column value.
* *
@@ -66,37 +46,46 @@ class Task extends BaseTask {
*/ */
public function setTasTitle($v) public function setTasTitle($v)
{ {
if ( $this->getTasUid() == "" ) { if ($this->getTasUid() == "") {
throw ( new Exception( "Error in setTasTitle, the getTasUid() can't be blank") ); throw (new Exception("Error in setTasTitle, the getTasUid() can't be blank"));
} }
$v=isset($v)?((string)$v):'';
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en'; $v = isset($v)? ((string)$v) : '';
if ($this->tas_title !== $v || $v==="") { $lang = defined('SYS_LANG')? SYS_LANG : 'en';
if ($this->tas_title !== $v || $v === "") {
$this->tas_title = $v; $this->tas_title = $v;
$res = Content::addContent( 'TAS_TITLE', '', $this->getTasUid(), $lang, $this->tas_title ); $res = Content::addContent('TAS_TITLE', '', $this->getTasUid(), $lang, $this->tas_title);
return $res; return $res;
} }
return 0; return 0;
} }
/** /**
* This value goes in the content table * This value goes in the content table
* @var string * @var string
*/ */
protected $tas_description = ''; protected $tas_description = '';
/** /**
* Get the tas_description column value. * Get the tas_description column value.
* @return string * @return string
*/ */
public function getTasDescription() public function getTasDescription()
{ {
if ( $this->getTasUid() == "" ) { if ($this->getTasUid() == "") {
throw ( new Exception( "Error in getTasDescription, the getTasUid() can't be blank") ); throw (new Exception( "Error in getTasDescription, the getTasUid() can't be blank"));
} }
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
$this->tas_description = Content::load ( 'TAS_DESCRIPTION', '', $this->getTasUid(), $lang ); $lang = defined('SYS_LANG')? SYS_LANG : 'en';
$this->tas_description = Content::load('TAS_DESCRIPTION', '', $this->getTasUid(), $lang);
return $this->tas_description; return $this->tas_description;
} }
/** /**
* Set the tas_description column value. * Set the tas_description column value.
* *
@@ -105,37 +94,46 @@ class Task extends BaseTask {
*/ */
public function setTasDescription($v) public function setTasDescription($v)
{ {
if ( $this->getTasUid() == "" ) { if ($this->getTasUid() == "") {
throw ( new Exception( "Error in setTasDescription, the getTasUid() can't be blank") ); throw (new Exception("Error in setTasDescription, the getTasUid() can't be blank"));
} }
$v=isset($v)?((string)$v):'';
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en'; $v = isset($v)? ((string)$v) : '';
if ($this->tas_description !== $v || $v==="") { $lang = defined('SYS_LANG')? SYS_LANG : 'en';
if ($this->tas_description !== $v || $v === "") {
$this->tas_description = $v; $this->tas_description = $v;
$res = Content::addContent( 'TAS_DESCRIPTION', '', $this->getTasUid(), $lang, $this->tas_description ); $res = Content::addContent('TAS_DESCRIPTION', '', $this->getTasUid(), $lang, $this->tas_description);
return $res; return $res;
} }
return 0; return 0;
} }
/** /**
* This value goes in the content table * This value goes in the content table
* @var string * @var string
*/ */
protected $tas_def_title = ''; protected $tas_def_title = '';
/** /**
* Get the tas_def_title column value. * Get the tas_def_title column value.
* @return string * @return string
*/ */
public function getTasDefTitle() public function getTasDefTitle()
{ {
if ( $this->getTasUid() == "" ) { if ($this->getTasUid() == "") {
throw ( new Exception( "Error in getTasDefTitle, the getTasUid() can't be blank") ); throw (new Exception( "Error in getTasDefTitle, the getTasUid() can't be blank"));
} }
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
$this->tas_def_title = Content::load ( 'TAS_DEF_TITLE', '', $this->getTasUid(), $lang ); $lang = defined('SYS_LANG')? SYS_LANG : 'en';
$this->tas_def_title = Content::load('TAS_DEF_TITLE', '', $this->getTasUid(), $lang);
return $this->tas_def_title; return $this->tas_def_title;
} }
/** /**
* Set the tas_def_title column value. * Set the tas_def_title column value.
* *
@@ -144,37 +142,46 @@ class Task extends BaseTask {
*/ */
public function setTasDefTitle($v) public function setTasDefTitle($v)
{ {
if ( $this->getTasUid() == "" ) { if ($this->getTasUid() == "") {
throw ( new Exception( "Error in setTasDefTitle, the getTasUid() can't be blank") ); throw (new Exception("Error in setTasDefTitle, the getTasUid() can't be blank"));
} }
$v=isset($v)?((string)$v):'';
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en'; $v = isset($v)? ((string)$v) : '';
if ($this->tas_def_title !== $v || $v==="") { $lang = defined('SYS_LANG')? SYS_LANG : 'en';
if ($this->tas_def_title !== $v || $v === "") {
$this->tas_def_title = $v; $this->tas_def_title = $v;
$res = Content::addContent( 'TAS_DEF_TITLE', '', $this->getTasUid(), $lang, $this->tas_def_title ); $res = Content::addContent('TAS_DEF_TITLE', '', $this->getTasUid(), $lang, $this->tas_def_title);
return $res; return $res;
} }
return 0; return 0;
} }
/** /**
* This value goes in the content table * This value goes in the content table
* @var string * @var string
*/ */
protected $tas_def_description = ''; protected $tas_def_description = '';
/** /**
* Get the tas_def_description column value. * Get the tas_def_description column value.
* @return string * @return string
*/ */
public function getTasDefDescription() public function getTasDefDescription()
{ {
if ( $this->getTasUid() == "" ) { if ($this->getTasUid() == "") {
throw ( new Exception( "Error in getTasDefDescription, the getTasUid() can't be blank") ); throw (new Exception( "Error in getTasDefDescription, the getTasUid() can't be blank"));
} }
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
$this->tas_def_description = Content::load ( 'TAS_DEF_DESCRIPTION', '', $this->getTasUid(), $lang ); $lang = defined('SYS_LANG')? SYS_LANG : 'en';
$this->tas_def_description = Content::load('TAS_DEF_DESCRIPTION', '', $this->getTasUid(), $lang);
return $this->tas_def_description; return $this->tas_def_description;
} }
/** /**
* Set the tas_def_description column value. * Set the tas_def_description column value.
* *
@@ -183,37 +190,45 @@ class Task extends BaseTask {
*/ */
public function setTasDefDescription($v) public function setTasDefDescription($v)
{ {
if ( $this->getTasUid() == "" ) { if ($this->getTasUid() == "") {
throw ( new Exception( "Error in setTasDefDescription, the getTasUid() can't be blank") ); throw (new Exception("Error in setTasDefDescription, the getTasUid() can't be blank"));
} }
$v=isset($v)?((string)$v):'';
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en'; $v = isset($v)? ((string)$v) : '';
if ($this->tas_def_description !== $v || $v==="") { $lang = defined('SYS_LANG')? SYS_LANG : 'en';
if ($this->tas_def_description !== $v || $v === "") {
$this->tas_def_description = $v; $this->tas_def_description = $v;
$res = Content::addContent( 'TAS_DEF_DESCRIPTION', '', $this->getTasUid(), $lang, $this->tas_def_description ); $res = Content::addContent('TAS_DEF_DESCRIPTION', '', $this->getTasUid(), $lang, $v);
return $res; return $res;
} }
return 0; return 0;
} }
/** /**
* This value goes in the content table * This value goes in the content table
* @var string * @var string
*/ */
protected $tas_def_proc_code = ''; protected $tas_def_proc_code = '';
/** /**
* Get the tas_def_proc_code column value. * Get the tas_def_proc_code column value.
* @return string * @return string
*/ */
public function getTasDefProcCode() public function getTasDefProcCode()
{ {
if ( $this->getTasUid() == "" ) { if ($this->getTasUid() == "") {
throw ( new Exception( "Error in getTasDefProcCode, the getTasUid() can't be blank") ); throw (new Exception( "Error in getTasDefProcCode, the getTasUid() can't be blank"));
} }
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
$this->tas_def_proc_code = Content::load ( 'TAS_DEF_PROC_CODE', '', $this->getTasUid(), $lang ); $lang = defined('SYS_LANG')? SYS_LANG : 'en';
$this->tas_def_proc_code = Content::load('TAS_DEF_PROC_CODE', '', $this->getTasUid(), $lang);
return $this->tas_def_proc_code; return $this->tas_def_proc_code;
} }
/** /**
* Set the tas_def_proc_code column value. * Set the tas_def_proc_code column value.
* *
@@ -222,35 +237,43 @@ class Task extends BaseTask {
*/ */
public function setTasDefProcCode($v) public function setTasDefProcCode($v)
{ {
if ( $this->getTasUid() == "" ) { if ($this->getTasUid() == "") {
throw ( new Exception( "Error in setTasDefProcCode, the getTasUid() can't be blank") ); throw (new Exception("Error in setTasDefProcCode, the getTasUid() can't be blank"));
} }
$v=isset($v)?((string)$v):'';
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en'; $v = isset($v)? ((string)$v) : '';
if ($this->tas_def_proc_code !== $v || $v==="") { $lang = defined('SYS_LANG')? SYS_LANG : 'en';
if ($this->tas_def_proc_code !== $v || $v === "") {
$this->tas_def_proc_code = $v; $this->tas_def_proc_code = $v;
$res = Content::addContent( 'TAS_DEF_PROC_CODE', '', $this->getTasUid(), $lang, $this->tas_def_proc_code ); $res = Content::addContent('TAS_DEF_PROC_CODE', '', $this->getTasUid(), $lang, $this->tas_def_proc_code);
return $res; return $res;
} }
return 0; return 0;
} }
/** /**
* This value goes in the content table * This value goes in the content table
* @var string * @var string
*/ */
protected $tas_def_message = ''; protected $tas_def_message = '';
/** /**
* Get the tas_def_message column value. * Get the tas_def_message column value.
* @return string * @return string
*/ */
public function getTasDefMessage() public function getTasDefMessage()
{ {
if ( $this->getTasUid() == "" ) { if ($this->getTasUid() == "") {
throw ( new Exception( "Error in getTasDefMessage, the getTasUid() can't be blank") ); throw (new Exception( "Error in getTasDefMessage, the getTasUid() can't be blank"));
} }
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
$this->tas_def_message = Content::load ( 'TAS_DEF_MESSAGE', '', $this->getTasUid(), $lang ); $lang = defined('SYS_LANG')? SYS_LANG : 'en';
$this->tas_def_message = Content::load('TAS_DEF_MESSAGE', '', $this->getTasUid(), $lang);
return $this->tas_def_message; return $this->tas_def_message;
} }
@@ -262,17 +285,20 @@ class Task extends BaseTask {
*/ */
public function setTasDefMessage($v) public function setTasDefMessage($v)
{ {
if ( $this->getTasUid() == "" ) { if ($this->getTasUid() == "") {
throw ( new Exception( "Error in setTasDefMessage, the getTasUid() can't be blank") ); throw (new Exception("Error in setTasDefMessage, the getTasUid() can't be blank"));
} }
$v=isset($v)?((string)$v):''; $v = isset($v)? ((string)$v) : '';
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en'; $lang = defined('SYS_LANG')? SYS_LANG : 'en';
if ($this->tas_def_message !== $v || $v==="") {
if ($this->tas_def_message !== $v || $v === "") {
$this->tas_def_message = $v; $this->tas_def_message = $v;
$res = Content::addContent( 'TAS_DEF_MESSAGE', '', $this->getTasUid(), $lang, $this->tas_def_message ); $res = Content::addContent('TAS_DEF_MESSAGE', '', $this->getTasUid(), $lang, $this->tas_def_message);
return $res; return $res;
} }
return 0; return 0;
} }
@@ -288,14 +314,15 @@ class Task extends BaseTask {
*/ */
public function getTasDefSubjectMessage() public function getTasDefSubjectMessage()
{ {
if ( $this->getTasUid() == "" ) { if ($this->getTasUid() == "") {
throw ( new Exception( "Error in getTasDefSubjectMessage, the getTasUid() can't be blank") ); throw (new Exception("Error in getTasDefSubjectMessage, the getTasUid() can't be blank"));
}
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
$this->tas_def_subject_message = Content::load ( 'TAS_DEF_SUBJECT_MESSAGE', '', $this->getTasUid(), $lang );
return $this->tas_def_subject_message;
} }
$lang = defined('SYS_LANG')? SYS_LANG : 'en';
$this->tas_def_subject_message = Content::load('TAS_DEF_SUBJECT_MESSAGE', '', $this->getTasUid(), $lang);
return $this->tas_def_subject_message;
}
/** /**
* Set the tas_def_subject_message column value. * Set the tas_def_subject_message column value.
@@ -305,19 +332,21 @@ class Task extends BaseTask {
*/ */
public function setTasDefSubjectMessage($v) public function setTasDefSubjectMessage($v)
{ {
if ( $this->getTasUid() == "" ) { if ($this->getTasUid() == "") {
throw ( new Exception( "Error in setTasDefSubjectMessage, the getTasUid() can't be blank") ); throw (new Exception( "Error in setTasDefSubjectMessage, the getTasUid() can't be blank"));
} }
$v = isset($v)? ((string)$v) : '';
$lang = defined ( 'SYS_LANG') ? SYS_LANG : 'en';
if ($this->tas_def_subject_message !== $v || $v==="") { $v = isset($v)? ((string)$v) : '';
$lang = defined('SYS_LANG')? SYS_LANG : 'en';
if ($this->tas_def_subject_message !== $v || $v === "") {
$this->tas_def_subject_message = $v; $this->tas_def_subject_message = $v;
$res = Content::addContent( 'TAS_DEF_SUBJECT_MESSAGE', '', $this->getTasUid(), $lang, $this->tas_def_subject_message ); $res = Content::addContent('TAS_DEF_SUBJECT_MESSAGE', '', $this->getTasUid(), $lang, $v);
return $res; return $res;
} }
return 0; return 0;
} }
@@ -327,11 +356,11 @@ class Task extends BaseTask {
* @param array $aData with new values * @param array $aData with new values
* @return void * @return void
*/ */
function create($aData) public function create($aData)
{ {
$con = Propel::getConnection(TaskPeer::DATABASE_NAME); $con = Propel::getConnection(TaskPeer::DATABASE_NAME);
try
{ try {
$sTaskUID = G::generateUniqueID(); $sTaskUID = G::generateUniqueID();
$con->begin(); $con->begin();
$this->setProUid($aData['PRO_UID']); $this->setProUid($aData['PRO_UID']);
@@ -369,8 +398,8 @@ class Task extends BaseTask {
$this->setTasPosy(""); $this->setTasPosy("");
$this->setTasColor(""); $this->setTasColor("");
$this->fromArray($aData,BasePeer::TYPE_FIELDNAME); $this->fromArray($aData,BasePeer::TYPE_FIELDNAME);
if($this->validate())
{ if ($this->validate()) {
$this->setTasTitle((isset($aData['TAS_TITLE']) ? $aData['TAS_TITLE']: '')); $this->setTasTitle((isset($aData['TAS_TITLE']) ? $aData['TAS_TITLE']: ''));
$this->setTasDescription(""); $this->setTasDescription("");
$this->setTasDefTitle(""); $this->setTasDefTitle("");
@@ -380,25 +409,24 @@ class Task extends BaseTask {
$this->setTasDefSubjectMessage(""); $this->setTasDefSubjectMessage("");
$this->save(); $this->save();
$con->commit(); $con->commit();
return $sTaskUID; return $sTaskUID;
} } else {
else
{
$con->rollback(); $con->rollback();
$e=new Exception("Failed Validation in class ".get_class($this)."."); $e = new Exception("Failed Validation in class " . get_class($this) . ".");
$e->aValidationFailures=$this->getValidationFailures(); $e->aValidationFailures=$this->getValidationFailures();
throw($e);
throw ($e);
} }
} } catch (Exception $e) {
catch(Exception $e)
{
$con->rollback(); $con->rollback();
throw($e);
throw ($e);
} }
} }
public function kgetassigType($pro_uid, $tas){ public function kgetassigType($pro_uid, $tas)
{
$k = new Criteria(); $k = new Criteria();
$k->clearSelectColumns(); $k->clearSelectColumns();
$k->addSelectColumn(TaskPeer::TAS_UID); $k->addSelectColumn(TaskPeer::TAS_UID);
@@ -418,15 +446,16 @@ public function kgetassigType($pro_uid, $tas){
try { try {
$oRow = TaskPeer::retrieveByPK($TasUid); $oRow = TaskPeer::retrieveByPK($TasUid);
if (!is_null($oRow)) if (!is_null($oRow)) {
{
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME); $aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME); //Populating an object from of the array //Populating attributes $this->fromArray($aFields, BasePeer::TYPE_FIELDNAME); //Populating an object from of the array
//Populating attributes
$this->setNew(false); $this->setNew(false);
/////// ///////
//Create new records for TASK in CONTENT for the current language, this if is necesary //Populating others attributes //Create new records for TASK in CONTENT for the current language, this if is necesary
//Populating others attributes
$this->setTasUid($TasUid); $this->setTasUid($TasUid);
$aFields["TAS_TITLE"] = $this->getTasTitle(); $aFields["TAS_TITLE"] = $this->getTasTitle();
@@ -439,64 +468,92 @@ public function kgetassigType($pro_uid, $tas){
/////// ///////
return $aFields; return $aFields;
} else {
throw (new Exception("The row '" . $TasUid . "' in table TASK doesn't exist!"));
} }
else { } catch (Exception $oError) {
throw(new Exception("The row '" . $TasUid . "' in table TASK doesn't exist!")); throw ($oError);
}
}
catch (Exception $oError) {
throw($oError);
} }
} }
function update($fields) public function update($fields)
{ {
ini_set("max_execution_time", 0);
require_once ("classes/model/AppCacheView.php"); require_once ("classes/model/AppCacheView.php");
require_once ("classes/model/Configuration.php");
$con = Propel::getConnection(TaskPeer::DATABASE_NAME); $con = Propel::getConnection(TaskPeer::DATABASE_NAME);
try
{ try {
$con->begin(); $con->begin();
$this->load($fields['TAS_UID']); $this->load($fields["TAS_UID"]);
$this->fromArray($fields,BasePeer::TYPE_FIELDNAME); $this->fromArray($fields, BasePeer::TYPE_FIELDNAME);
if($this->validate())
{
$contentResult=0;
if (array_key_exists("TAS_TITLE", $fields)) $contentResult+=$this->setTasTitle($fields["TAS_TITLE"]);
if (array_key_exists("TAS_DESCRIPTION", $fields)) $contentResult+=$this->setTasDescription($fields["TAS_DESCRIPTION"]);
if (array_key_exists("TAS_DEF_TITLE", $fields)) $contentResult+=$this->setTasDefTitle($fields["TAS_DEF_TITLE"]);
if (array_key_exists("TAS_DEF_DESCRIPTION", $fields)) $contentResult+=$this->setTasDefDescription($fields["TAS_DEF_DESCRIPTION"]);
if (array_key_exists("TAS_DEF_PROC_CODE", $fields)) $contentResult+=$this->setTasDefProcCode($fields["TAS_DEF_PROC_CODE"]);
if (array_key_exists("TAS_DEF_MESSAGE", $fields)) $contentResult+=$this->setTasDefMessage(trim($fields["TAS_DEF_MESSAGE"]));
if (array_key_exists("TAS_DEF_SUBJECT_MESSAGE", $fields)) $contentResult+=$this->setTasDefSubjectMessage(trim($fields["TAS_DEF_SUBJECT_MESSAGE"]));
if (array_key_exists("TAS_CALENDAR", $fields)) $contentResult+=$this->setTasCalendar($fields['TAS_UID'],$fields["TAS_CALENDAR"]);
$result=$this->save();
$result=($result==0)?($contentResult>0?1:0):$result;
$con->commit();
if ($result == 1 && array_key_exists("TAS_DEF_TITLE", $fields)) { if ($this->validate()) {
//Get cases $taskDefTitlePrevious = null;
$criteriaAPPCV = new Criteria("workflow");
$criteriaAPPCV->setDistinct();
$criteriaAPPCV->addSelectColumn(AppCacheViewPeer::APP_UID);
$criteriaAPPCV->add(AppCacheViewPeer::TAS_UID, $fields["TAS_UID"]);
$rsCriteriaAPPCV = AppCacheViewPeer::doSelectRS($criteriaAPPCV);
$rsCriteriaAPPCV->setFetchmode(ResultSet::FETCHMODE_ASSOC);
while ($rsCriteriaAPPCV->next()) {
$row = $rsCriteriaAPPCV->getRow();
$appcv_application_uid = $row["APP_UID"];
//Get DEL_INDEX_MAX
$criteria = new Criteria("workflow"); $criteria = new Criteria("workflow");
$criteria->addAsColumn("DEL_INDEX_MAX", "MAX(" . AppCacheViewPeer::DEL_INDEX . ")"); $criteria->addSelectColumn(ContentPeer::CON_VALUE);
$criteria->add(AppCacheViewPeer::APP_UID, $appcv_application_uid); $criteria->add(ContentPeer::CON_CATEGORY, "TAS_DEF_TITLE");
$criteria->add(ContentPeer::CON_ID, $fields["TAS_UID"]);
$criteria->add(ContentPeer::CON_LANG, SYS_LANG);
$rsCriteria = ContentPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$taskDefTitlePrevious = $row["CON_VALUE"];
}
$contentResult = 0;
if (array_key_exists("TAS_TITLE", $fields)) {
$contentResult += $this->setTasTitle($fields["TAS_TITLE"]);
}
if (array_key_exists("TAS_DESCRIPTION", $fields)) {
$contentResult += $this->setTasDescription($fields["TAS_DESCRIPTION"]);
}
if (array_key_exists("TAS_DEF_TITLE", $fields)) {
$contentResult += $this->setTasDefTitle($fields["TAS_DEF_TITLE"]);
}
if (array_key_exists("TAS_DEF_DESCRIPTION", $fields)) {
$contentResult += $this->setTasDefDescription($fields["TAS_DEF_DESCRIPTION"]);
}
if (array_key_exists("TAS_DEF_PROC_CODE", $fields)) {
$contentResult += $this->setTasDefProcCode($fields["TAS_DEF_PROC_CODE"]);
}
if (array_key_exists("TAS_DEF_MESSAGE", $fields)) {
$contentResult += $this->setTasDefMessage(trim($fields["TAS_DEF_MESSAGE"]));
}
if (array_key_exists("TAS_DEF_SUBJECT_MESSAGE", $fields)) {
$contentResult += $this->setTasDefSubjectMessage(trim($fields["TAS_DEF_SUBJECT_MESSAGE"]));
}
if (array_key_exists("TAS_CALENDAR", $fields)) {
$contentResult += $this->setTasCalendar($fields['TAS_UID'],$fields["TAS_CALENDAR"]);
}
$result = $this->save();
$result = ($result == 0)? (($contentResult > 0)? 1 : 0) : $result;
$con->commit();
if ($result == 1 &&
array_key_exists("TAS_DEF_TITLE", $fields) &&
$fields["TAS_DEF_TITLE"] != $taskDefTitlePrevious
) {
$criteria = new Criteria("workflow");
$criteria->addAsColumn("APPCV_NUM_ROWS", "COUNT(DISTINCT " . AppCacheViewPeer::APP_UID . ")");
$criteria->add(AppCacheViewPeer::DEL_THREAD_STATUS, "OPEN");
$criteria->add(AppCacheViewPeer::TAS_UID, $fields["TAS_UID"]);
$rsCriteria = AppCacheViewPeer::doSelectRS($criteria); $rsCriteria = AppCacheViewPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
@@ -504,67 +561,64 @@ public function kgetassigType($pro_uid, $tas){
$rsCriteria->next(); $rsCriteria->next();
$row = $rsCriteria->getRow(); $row = $rsCriteria->getRow();
$appcvDelIndexMax = $row["DEL_INDEX_MAX"]; $appcvNumRows = intval($row["APPCV_NUM_ROWS"]);
//Current task? if ($appcvNumRows <= 1000) {
$appcv = new AppCacheView();
$appcv->appTitleByTaskCaseLabelUpdate($fields["TAS_UID"], SYS_LANG);
$result = 2;
} else {
//Delete record
$criteria = new Criteria("workflow"); $criteria = new Criteria("workflow");
$criteria->addSelectColumn(AppCacheViewPeer::APP_UID); $criteria->add(ConfigurationPeer::CFG_UID, "TAS_APP_TITLE_UPDATE");
$criteria->add(AppCacheViewPeer::APP_UID, $appcv_application_uid); $criteria->add(ConfigurationPeer::OBJ_UID, $fields["TAS_UID"]);
$criteria->add(AppCacheViewPeer::DEL_INDEX, $appcvDelIndexMax); $criteria->add(ConfigurationPeer::CFG_VALUE, SYS_LANG);
$criteria->add(AppCacheViewPeer::TAS_UID, $fields["TAS_UID"]);
$rsCriteria = AppCacheViewPeer::doSelectRS($criteria); $numRowDeleted = ConfigurationPeer::doDelete($criteria);
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
if ($rsCriteria->next()) { //Insert record
$appTitle = $fields["TAS_DEF_TITLE"]; $conf = new Configuration();
$app = new Application(); $conf->create(
$arrayAppField = $app->Load($appcv_application_uid); array(
"CFG_UID" => "TAS_APP_TITLE_UPDATE",
"OBJ_UID" => $fields["TAS_UID"],
"CFG_VALUE" => SYS_LANG,
"PRO_UID" => "",
"USR_UID" => "",
"APP_UID" => ""
)
);
$appTitle = (!empty($appTitle))? $appTitle : "#" . $arrayAppField["APP_NUMBER"]; $result = 3;
$appTitleNew = G::replaceDataField($appTitle, unserialize($arrayAppField["APP_DATA"]));
if (isset($arrayAppField["APP_TITLE"]) && $arrayAppField["APP_TITLE"] != $appTitleNew) {
//Updating the value in content, where...
$criteria1 = new Criteria("workflow");
$criteria1->add(ContentPeer::CON_CATEGORY, "APP_TITLE");
$criteria1->add(ContentPeer::CON_ID, $appcv_application_uid);
$criteria1->add(ContentPeer::CON_LANG, SYS_LANG);
//Update set
$criteria2 = new Criteria("workflow");
$criteria2->add(ContentPeer::CON_VALUE, $appTitleNew);
BasePeer::doUpdate($criteria1, $criteria2, Propel::getConnection("workflow"));
}
}
} }
} }
return $result; return $result;
} } else {
else
{
$con->rollback(); $con->rollback();
throw(new Exception("Failed Validation in class ".get_class($this)."."));
throw (new Exception("Failed Validation in class " . get_class($this) . "."));
} }
} } catch (Exception $e) {
catch(Exception $e)
{
$con->rollback(); $con->rollback();
throw($e);
throw ($e);
} }
} }
function remove($TasUid)
public function remove($TasUid)
{ {
$oConnection = Propel::getConnection(TaskPeer::DATABASE_NAME); $oConnection = Propel::getConnection(TaskPeer::DATABASE_NAME);
try { try {
$oTask = TaskPeer::retrieveByPK($TasUid); $oTask = TaskPeer::retrieveByPK($TasUid);
if (!is_null($oTask))
{ if (!is_null($oTask)) {
$oConnection->begin(); $oConnection->begin();
Content::removeContent('TAS_TITLE', '', $oTask->getTasUid()); Content::removeContent('TAS_TITLE', '', $oTask->getTasUid());
Content::removeContent('TAS_DESCRIPTION', '', $oTask->getTasUid()); Content::removeContent('TAS_DESCRIPTION', '', $oTask->getTasUid());
Content::removeContent('TAS_DEF_TITLE', '', $oTask->getTasUid()); Content::removeContent('TAS_DEF_TITLE', '', $oTask->getTasUid());
@@ -572,17 +626,18 @@ public function kgetassigType($pro_uid, $tas){
Content::removeContent('TAS_DEF_PROC_CODE', '', $oTask->getTasUid()); Content::removeContent('TAS_DEF_PROC_CODE', '', $oTask->getTasUid());
Content::removeContent('TAS_DEF_MESSAGE', '', $oTask->getTasUid()); Content::removeContent('TAS_DEF_MESSAGE', '', $oTask->getTasUid());
Content::removeContent('TAS_DEF_SUBJECT_MESSAGE', '', $oTask->getTasUid()); Content::removeContent('TAS_DEF_SUBJECT_MESSAGE', '', $oTask->getTasUid());
$iResult = $oTask->delete(); $iResult = $oTask->delete();
$oConnection->commit(); $oConnection->commit();
return $iResult; return $iResult;
} else {
throw (new Exception( "The row '" . $TasUid . "' in table TASK doesn't exist!"));
} }
else { } catch (Exception $oError) {
throw( new Exception( "The row '" . $TasUid . "' in table TASK doesn't exist!" ));
}
}
catch (Exception $oError) {
$oConnection->rollback(); $oConnection->rollback();
throw($oError);
throw ($oError);
} }
} }
@@ -591,20 +646,20 @@ public function kgetassigType($pro_uid, $tas){
* *
* @param string $sProUid the uid of the Prolication * @param string $sProUid the uid of the Prolication
*/ */
public function taskExists($TasUid)
function taskExists ( $TasUid ) { {
$con = Propel::getConnection(TaskPeer::DATABASE_NAME); $con = Propel::getConnection(TaskPeer::DATABASE_NAME);
try { try {
$oPro = TaskPeer::retrieveByPk( $TasUid ); $oPro = TaskPeer::retrieveByPk($TasUid);
if ( is_object($oPro) && get_class ($oPro) == 'Task' ) {
if (is_object($oPro) && get_class($oPro) == 'Task') {
return true; return true;
} } else {
else {
return false; return false;
} }
} } catch (Exception $oError) {
catch (Exception $oError) { throw ($oError);
throw($oError);
} }
} }
@@ -614,52 +669,56 @@ public function kgetassigType($pro_uid, $tas){
* @param array $aData with new values * @param array $aData with new values
* @return void * @return void
*/ */
function createRow($aData) public function createRow($aData)
{ {
$con = Propel::getConnection(TaskPeer::DATABASE_NAME); $con = Propel::getConnection(TaskPeer::DATABASE_NAME);
try
{ try {
$con->begin(); $con->begin();
$this->fromArray($aData,BasePeer::TYPE_FIELDNAME); $this->fromArray($aData,BasePeer::TYPE_FIELDNAME);
if($this->validate())
{ if ($this->validate()) {
$this->setTasTitle((isset($aData['TAS_TITLE']) ? $aData['TAS_TITLE']: '')); $this->setTasTitle((isset($aData['TAS_TITLE'])? $aData['TAS_TITLE'] : ''));
$this->setTasDescription((isset($aData['TAS_DESCRIPTION']) ? $aData['TAS_DESCRIPTION']: '')); $this->setTasDescription((isset($aData['TAS_DESCRIPTION'])? $aData['TAS_DESCRIPTION'] : ''));
$this->setTasDefTitle((isset($aData['TAS_DEF_TITLE']) ? $aData['TAS_DEF_TITLE']: '')); $this->setTasDefTitle((isset($aData['TAS_DEF_TITLE'])? $aData['TAS_DEF_TITLE'] : ''));
$this->setTasDefDescription((isset($aData['TAS_DEF_DESCRIPTION']) ? $aData['TAS_DEF_DESCRIPTION']: '')); $this->setTasDefDescription((isset($aData['TAS_DEF_DESCRIPTION'])? $aData['TAS_DEF_DESCRIPTION'] : ''));
$this->setTasDefProcCode((isset($aData['TAS_DEF_DESCRIPTION']) ? $aData['TAS_DEF_DESCRIPTION']: '')); $this->setTasDefProcCode((isset($aData['TAS_DEF_DESCRIPTION'])? $aData['TAS_DEF_DESCRIPTION'] : ''));
$this->setTasDefMessage((isset($aData['TAS_DEF_MESSAGE']) ? $aData['TAS_DEF_MESSAGE']: '')); $this->setTasDefMessage((isset($aData['TAS_DEF_MESSAGE'])? $aData['TAS_DEF_MESSAGE'] : ''));
$this->setTasDefSubjectMessage((isset($aData['TAS_DEF_SUBJECT_MESSAGE']) ? $aData['TAS_DEF_SUBJECT_MESSAGE']: ''));
$strAux = isset($aData['TAS_DEF_SUBJECT_MESSAGE'])? $aData['TAS_DEF_SUBJECT_MESSAGE'] : '';
$this->setTasDefSubjectMessage($strAux);
$this->save(); $this->save();
$con->commit(); $con->commit();
return; return;
} } else {
else
{
$con->rollback(); $con->rollback();
$e=new Exception("Failed Validation in class ".get_class($this)."."); $e = new Exception("Failed Validation in class " . get_class($this) . ".");
$e->aValidationFailures=$this->getValidationFailures(); $e->aValidationFailures=$this->getValidationFailures();
throw($e);
throw ($e);
} }
} } catch (Exception $e) {
catch(Exception $e)
{
$con->rollback(); $con->rollback();
throw($e); throw ($e);
} }
} }
function setTasCalendar($taskUid,$calendarUid){
//Save Calendar ID for this process
G::LoadClass("calendar");
$calendarObj=new Calendar();
$calendarObj->assignCalendarTo($taskUid,$calendarUid,'TASK');
}
function getDelegatedTaskData($TAS_UID, $APP_UID, $DEL_INDEX) public function setTasCalendar($taskUid, $calendarUid)
{ {
require_once 'classes/model/AppDelegation.php'; //Save Calendar ID for this process
require_once 'classes/model/Task.php'; G::LoadClass("calendar");
$calendarObj = new Calendar();
$calendarObj->assignCalendarTo($taskUid, $calendarUid, 'TASK');
}
public function getDelegatedTaskData($TAS_UID, $APP_UID, $DEL_INDEX)
{
require_once ('classes/model/AppDelegation.php');
require_once ('classes/model/Task.php');
$oTask = new Task(); $oTask = new Task();
$aFields = $oTask->load($TAS_UID); $aFields = $oTask->load($TAS_UID);
@@ -672,9 +731,22 @@ public function kgetassigType($pro_uid, $tas){
$taskData = $oDataset->getRow(); $taskData = $oDataset->getRow();
$iDiff = strtotime($taskData['DEL_FINISH_DATE']) - strtotime($taskData['DEL_INIT_DATE']); $iDiff = strtotime($taskData['DEL_FINISH_DATE']) - strtotime($taskData['DEL_INIT_DATE']);
$aFields['INIT_DATE'] = ($taskData['DEL_INIT_DATE'] != null ? $taskData['DEL_INIT_DATE'] : G::LoadTranslation('ID_CASE_NOT_YET_STARTED'));
$aFields['DUE_DATE'] = ($taskData['DEL_TASK_DUE_DATE'] != null ? $taskData['DEL_TASK_DUE_DATE'] : G::LoadTranslation('ID_NOT_FINISHED')); $aFields['INIT_DATE'] = (
$aFields['FINISH'] = ($taskData['DEL_FINISH_DATE'] != null ? $taskData['DEL_FINISH_DATE'] : G::LoadTranslation('ID_NOT_FINISHED')); $taskData['DEL_INIT_DATE'] != null ?
$taskData['DEL_INIT_DATE'] : G::LoadTranslation('ID_CASE_NOT_YET_STARTED')
);
$aFields['DUE_DATE'] = (
$taskData['DEL_TASK_DUE_DATE'] != null ?
$taskData['DEL_TASK_DUE_DATE'] : G::LoadTranslation('ID_NOT_FINISHED')
);
$aFields['FINISH'] = (
$taskData['DEL_FINISH_DATE'] != null ?
$taskData['DEL_FINISH_DATE'] : G::LoadTranslation('ID_NOT_FINISHED')
);
$aFields['DURATION'] = ($taskData['DEL_FINISH_DATE'] != null ? (int) ($iDiff / 3600) . ' ' . ((int) ($iDiff / 3600) == 1 ? G::LoadTranslation('ID_HOUR') : G::LoadTranslation('ID_HOURS')) . ' ' . (int) (($iDiff % 3600) / 60) . ' ' . ((int) (($iDiff % 3600) / 60) == 1 ? G::LoadTranslation('ID_MINUTE') : G::LoadTranslation('ID_MINUTES')) . ' ' . (int) (($iDiff % 3600) % 60) . ' ' . ((int) (($iDiff % 3600) % 60) == 1 ? G::LoadTranslation('ID_SECOND') : G::LoadTranslation('ID_SECONDS')) : G::LoadTranslation('ID_NOT_FINISHED')); $aFields['DURATION'] = ($taskData['DEL_FINISH_DATE'] != null ? (int) ($iDiff / 3600) . ' ' . ((int) ($iDiff / 3600) == 1 ? G::LoadTranslation('ID_HOUR') : G::LoadTranslation('ID_HOURS')) . ' ' . (int) (($iDiff % 3600) / 60) . ' ' . ((int) (($iDiff % 3600) / 60) == 1 ? G::LoadTranslation('ID_MINUTE') : G::LoadTranslation('ID_MINUTES')) . ' ' . (int) (($iDiff % 3600) % 60) . ' ' . ((int) (($iDiff % 3600) % 60) == 1 ? G::LoadTranslation('ID_SECOND') : G::LoadTranslation('ID_SECONDS')) : G::LoadTranslation('ID_NOT_FINISHED'));
return $aFields; return $aFields;
@@ -682,20 +754,26 @@ public function kgetassigType($pro_uid, $tas){
//Added by qennix //Added by qennix
//Gets Starting Event of current task //Gets Starting Event of current task
function getStartingEvent(){ public function getStartingEvent()
require_once 'classes/model/Event.php'; {
require_once ('classes/model/Event.php');
$oCriteria = new Criteria('workflow'); $oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn(EventPeer::EVN_UID); $oCriteria->addSelectColumn(EventPeer::EVN_UID);
$oCriteria->add(EventPeer::EVN_TAS_UID_TO,$this->tas_uid); $oCriteria->add(EventPeer::EVN_TAS_UID_TO, $this->tas_uid);
//$oCriteria->add(EventPeer::EVN_TYPE,'bpmnEventMessageStart'); //$oCriteria->add(EventPeer::EVN_TYPE, 'bpmnEventMessageStart');
$oDataset = EventPeer::doSelectRS($oCriteria); $oDataset = EventPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
if ($oDataset->next()){
if ($oDataset->next()) {
$row = $oDataset->getRow(); $row = $oDataset->getRow();
$event_uid = $row['EVN_UID']; $event_uid = $row['EVN_UID'];
}else{ } else {
$event_uid = ''; $event_uid = '';
} }
return $event_uid; return $event_uid;
} }
} // Task }
//Task

View File

@@ -199,27 +199,6 @@ var saveTaskData = function(oForm, iForm, iType)
return false; return false;
} }
//Panel processing //iForm = 6 //Case Labels
var pnlProcessing;
pnlProcessing = new leimnud.module.panel();
pnlProcessing.options = {
//title: "",
//theme: this.options.theme,
limit: true,
size: {w: 250, h: 110},
position: {x: 50, y: 50, center: true},
control: {close: false, resize: false},
statusBar: true,
fx:{shadow: true, modal: true}
};
pnlProcessing.make();
//pnlProcessing.loader.show();
pnlProcessing.addContent("<div style=\"margin-left: 1em; padding: 0.80em 0 1em 4em; background: url(/images/classic/loader_B.gif) no-repeat left top;\">" + _("ID_PROCESSING") + "</div>");
//Set AJAX //Set AJAX
var sParameters = "function=saveTaskData"; var sParameters = "function=saveTaskData";
@@ -230,8 +209,7 @@ var saveTaskData = function(oForm, iForm, iType)
}); });
oRPC.callback = function (rpc) { oRPC.callback = function (rpc) {
//pnlProcessing.loader.hide(); var res = rpc.xmlhttp.responseText.parseJSON();
pnlProcessing.remove();
if (oTaskData.TAS_TITLE) { if (oTaskData.TAS_TITLE) {
Pm.data.db.task[getField("INDEX").value].label = Pm.data.db.task[getField("INDEX").value].object.elements.label.innerHTML = oTaskData.TAS_TITLE.replace(re2, "&amp;"); Pm.data.db.task[getField("INDEX").value].label = Pm.data.db.task[getField("INDEX").value].object.elements.label.innerHTML = oTaskData.TAS_TITLE.replace(re2, "&amp;");
@@ -243,9 +221,21 @@ var saveTaskData = function(oForm, iForm, iType)
} }
try { try {
new leimnud.module.app.info().make({ var option = {
label: changesSavedLabel label: changesSavedLabel
}); }
switch (res.status) {
case "CRONCL":
option = {
label: changesSavedLabel + "<br /><br />" + _("APP_TITLE_CASE_LABEL_UPDATE"),
width: 350,
height: 175
}
break;
}
new leimnud.module.app.info().make(option);
} }
catch (e) { catch (e) {
//No show confirmation //No show confirmation

View File

@@ -1,29 +1,7 @@
<?php <?php
/**
* tasks_Ajax.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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
try { try {
global $RBAC; global $RBAC;
switch ($RBAC->userCanAccess('PM_FACTORY')) { switch ($RBAC->userCanAccess('PM_FACTORY')) {
case -2: case -2:
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels'); G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels');
@@ -39,14 +17,19 @@ try {
$oJSON = new Services_JSON(); $oJSON = new Services_JSON();
$aData = get_object_vars($oJSON->decode($_POST['oData'])); $aData = get_object_vars($oJSON->decode($_POST['oData']));
if(isset($_POST['function']))
if (isset($_POST['function'])) {
$sAction = $_POST['function']; $sAction = $_POST['function'];
else } else {
$sAction = $_POST['functions']; $sAction = $_POST['functions'];
}
switch ($sAction) { switch ($sAction) {
case 'saveTaskData': case "saveTaskData":
require_once 'classes/model/Task.php'; require_once ("classes/model/Task.php");
$response = array();
$oTask = new Task(); $oTask = new Task();
/** /**
@@ -54,7 +37,8 @@ try {
* that why the char "&" can't be passed by XmlHttpRequest directly * that why the char "&" can't be passed by XmlHttpRequest directly
* @autor erik <erik@colosa.com> * @autor erik <erik@colosa.com>
*/ */
foreach($aData as $k=>$v) {
foreach ($aData as $k => $v) {
$aData[$k] = str_replace('@amp@', '&', $v); $aData[$k] = str_replace('@amp@', '&', $v);
} }
@@ -64,24 +48,34 @@ try {
$aData['TAS_SEND_LAST_EMAIL'] = 'FALSE'; $aData['TAS_SEND_LAST_EMAIL'] = 'FALSE';
} }
// Additional configuration //Additional configuration
if (isset($aData['TAS_DEF_MESSAGE_TYPE']) && isset($aData['TAS_DEF_MESSAGE_TEMPLATE'])) { if (isset($aData['TAS_DEF_MESSAGE_TYPE']) && isset($aData['TAS_DEF_MESSAGE_TEMPLATE'])) {
G::loadClass('configuration'); G::LoadClass('configuration');
$oConf = new Configurations;
$oConf->aConfig = Array( $oConf = new Configurations();
$oConf->aConfig = array(
'TAS_DEF_MESSAGE_TYPE' => $aData['TAS_DEF_MESSAGE_TYPE'], 'TAS_DEF_MESSAGE_TYPE' => $aData['TAS_DEF_MESSAGE_TYPE'],
'TAS_DEF_MESSAGE_TEMPLATE'=> $aData['TAS_DEF_MESSAGE_TEMPLATE'] 'TAS_DEF_MESSAGE_TEMPLATE' => $aData['TAS_DEF_MESSAGE_TEMPLATE']
); );
$oConf->saveConfig('TAS_EXTRA_PROPERTIES', $aData['TAS_UID'], '', ''); $oConf->saveConfig('TAS_EXTRA_PROPERTIES', $aData['TAS_UID'], '', '');
unset($aData['TAS_DEF_MESSAGE_TYPE']); unset($aData['TAS_DEF_MESSAGE_TYPE']);
unset($aData['TAS_DEF_MESSAGE_TEMPLATE']); unset($aData['TAS_DEF_MESSAGE_TEMPLATE']);
} }
$oTask->update($aData); $result = $oTask->update($aData);
$response["status"] = "OK";
if ($result == 3) {
$response["status"] = "CRONCL";
}
echo G::json_encode($response);
break; break;
} }
} } catch (Exception $oException) {
catch (Exception $oException) {
die($oException->getMessage()); die($oException->getMessage());
} }
?>