BUG 0000 Change Solr configuration environment variables

Now the Solr configuration variables are read from the env.ini file that
is stored in the shared//sites/SYS_SYS/ folder.

The system class is used to get the environment variables using the
solrenv function.
This commit is contained in:
Herbert Saal Gutierrez
2012-05-15 17:41:12 -04:00
parent d4fcb868cd
commit 7e07db9348
6 changed files with 338 additions and 443 deletions

View File

@@ -3,253 +3,263 @@
* cron_single.php * cron_single.php
* @package workflow-engine-bin * @package workflow-engine-bin
*/ */
ini_set('display_errors', 1); ini_set ( 'display_errors', 1 );
error_reporting(E_ALL); error_reporting ( E_ALL );
ini_set('memory_limit', '256M');//set enough memory for the script ini_set ( 'memory_limit', '256M' ); // set enough memory for the script
if (!defined('SYS_LANG')) { if (! defined ( 'SYS_LANG' )) {
define('SYS_LANG', 'en'); define ( 'SYS_LANG', 'en' );
} }
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__))); $docuroot = explode ( PATH_SEP, str_replace ( 'engine' . PATH_SEP . 'methods' . PATH_SEP . 'services', '', 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
//in a normal installation you don't need to change it. // Gulliver directories
array_pop($docuroot); // in a normal installation you don't need to change it.
$pathTrunk = implode(PATH_SEP, $docuroot) . PATH_SEP ; array_pop ( $docuroot );
array_pop($docuroot); $pathTrunk = implode ( PATH_SEP, $docuroot ) . PATH_SEP;
$pathOutTrunk = implode( PATH_SEP, $docuroot) . PATH_SEP ; array_pop ( $docuroot );
// to do: check previous algorith for Windows $pathTrunk = "c:/home/"; $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_HOME', $pathhome );
define('PATH_OUTTRUNK', $pathOutTrunk); define ( 'PATH_TRUNK', $pathTrunk );
define ( 'PATH_OUTTRUNK', $pathOutTrunk );
require_once (PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php'); require_once (PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php');
G::LoadThirdParty('pear/json','class.json'); G::LoadThirdParty ( 'pear/json', 'class.json' );
G::LoadThirdParty('smarty/libs','Smarty.class'); G::LoadThirdParty ( 'smarty/libs', 'Smarty.class' );
G::LoadSystem('error'); G::LoadSystem ( 'error' );
G::LoadSystem('dbconnection'); G::LoadSystem ( 'dbconnection' );
G::LoadSystem('dbsession'); G::LoadSystem ( 'dbsession' );
G::LoadSystem('dbrecordset'); G::LoadSystem ( 'dbrecordset' );
G::LoadSystem('dbtable'); G::LoadSystem ( 'dbtable' );
G::LoadSystem('rbac' ); G::LoadSystem ( 'rbac' );
G::LoadSystem('publisher'); G::LoadSystem ( 'publisher' );
G::LoadSystem('templatePower'); G::LoadSystem ( 'templatePower' );
G::LoadSystem('xmlDocument'); G::LoadSystem ( 'xmlDocument' );
G::LoadSystem('xmlform'); G::LoadSystem ( 'xmlform' );
G::LoadSystem('xmlformExtension'); G::LoadSystem ( 'xmlformExtension' );
G::LoadSystem('form'); G::LoadSystem ( 'form' );
G::LoadSystem('menu'); G::LoadSystem ( 'menu' );
G::LoadSystem("xmlMenu"); G::LoadSystem ( "xmlMenu" );
G::LoadSystem('dvEditor'); G::LoadSystem ( 'dvEditor' );
G::LoadSystem('table'); G::LoadSystem ( 'table' );
G::LoadSystem('pagedTable'); G::LoadSystem ( 'pagedTable' );
require_once ( "propel/Propel.php" ); G::LoadSystem ( 'system' );
require_once ( "creole/Creole.php" ); require_once ("propel/Propel.php");
require_once ("creole/Creole.php");
} }
require_once 'classes/model/AppDelegation.php'; require_once 'classes/model/AppDelegation.php';
require_once 'classes/model/Event.php'; require_once 'classes/model/Event.php';
require_once 'classes/model/AppEvent.php'; require_once 'classes/model/AppEvent.php';
require_once 'classes/model/CaseScheduler.php'; require_once 'classes/model/CaseScheduler.php';
//G::loadClass('pmScript'); // G::loadClass('pmScript');
// //default values // //default values
// $bCronIsRunning = false; // $bCronIsRunning = false;
// $sLastExecution = ''; // $sLastExecution = '';
// if ( file_exists(PATH_DATA . 'cron') ) { // if ( file_exists(PATH_DATA . 'cron') ) {
// $aAux = unserialize( trim( @file_get_contents(PATH_DATA . 'cron')) ); // $aAux = unserialize( trim( @file_get_contents(PATH_DATA . 'cron')) );
// $bCronIsRunning = (boolean)$aAux['bCronIsRunning']; // $bCronIsRunning = (boolean)$aAux['bCronIsRunning'];
// $sLastExecution = $aAux['sLastExecution']; // $sLastExecution = $aAux['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')))); // @file_put_contents(PATH_DATA . 'cron', serialize(array('bCronIsRunning' =>
// '1', 'sLastExecution' => date('Y-m-d H:i:s'))));
// } // }
print "PATH_HOME: " . PATH_HOME . "\n"; print "PATH_HOME: " . PATH_HOME . "\n";
print "PATH_DB: " . PATH_DB . "\n"; print "PATH_DB: " . PATH_DB . "\n";
print "PATH_CORE: " . PATH_CORE . "\n"; print "PATH_CORE: " . PATH_CORE . "\n";
// define the site name (instance name)
//define the site name (instance name) if (! defined ( 'SYS_SYS' )) {
if (!defined('SYS_SYS')) { $sObject = $argv [1];
$sObject = $argv[1]; $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 );
//read initialize file
require_once PATH_HOME . 'engine' . PATH_SEP . 'classes' . PATH_SEP . 'class.system.php';
$config = System::getSystemConfiguration(PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'env.ini');
define ('MEMCACHED_ENABLED', $config['memcached']);
define ('MEMCACHED_SERVER', $config['memcached_server']);
define ('TIME_ZONE', $config['time_zone']);
date_default_timezone_set(TIME_ZONE); // ****************************************
// read initialize file
require_once PATH_HOME . 'engine' . PATH_SEP . 'classes' . PATH_SEP . 'class.system.php';
$config = System::getSystemConfiguration ( PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'env.ini' );
define ( 'MEMCACHED_ENABLED', $config ['memcached'] );
define ( 'MEMCACHED_SERVER', $config ['memcached_server'] );
define ( 'TIME_ZONE', $config ['time_zone'] );
date_default_timezone_set ( TIME_ZONE );
print "TIME_ZONE: " . TIME_ZONE . "\n"; print "TIME_ZONE: " . TIME_ZONE . "\n";
print "MEMCACHED_ENABLED: " . MEMCACHED_ENABLED . "\n"; print "MEMCACHED_ENABLED: " . MEMCACHED_ENABLED . "\n";
print "MEMCACHED_SERVER: " . MEMCACHED_SERVER . "\n"; print "MEMCACHED_SERVER: " . MEMCACHED_SERVER . "\n";
//**************************************** // ****************************************
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 );
//server info file // server info file
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); // 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 { }
eprintln("WARNING! No server info found!", 'red'); else {
eprintln ( "WARNING! No server info found!", 'red' );
} }
//read db configuration // read db configuration
$sContent = file_get_contents(PATH_DB . $sObject . PATH_SEP . 'db.php'); $sContent = file_get_contents ( PATH_DB . $sObject . PATH_SEP . 'db.php' );
$sContent = str_replace('<?php', '', $sContent); $sContent = str_replace ( '<?php', '', $sContent );
$sContent = str_replace('<?', '', $sContent); $sContent = str_replace ( '<?', '', $sContent );
$sContent = str_replace('?>', '', $sContent); $sContent = str_replace ( '?>', '', $sContent );
$sContent = str_replace('define', '', $sContent); $sContent = str_replace ( 'define', '', $sContent );
$sContent = str_replace("('", "$", $sContent); $sContent = str_replace ( "('", "$", $sContent );
$sContent = str_replace("',", '=', $sContent); $sContent = str_replace ( "',", '=', $sContent );
$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; $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; $dsnRp = $DB_ADAPTER . '://' . $DB_REPORT_USER . ':' . $DB_REPORT_PASS . '@' . $DB_REPORT_HOST . '/' . $DB_REPORT_NAME;
switch ($DB_ADAPTER) { switch ($DB_ADAPTER) {
case 'mysql': case 'mysql' :
$dsn .= '?encoding=utf8'; $dsn .= '?encoding=utf8';
$dsnRbac .= '?encoding=utf8'; $dsnRbac .= '?encoding=utf8';
break; break;
case 'mssql': case 'mssql' :
//$dsn .= '?sendStringAsUnicode=false'; // $dsn .= '?sendStringAsUnicode=false';
//$dsnRbac .= '?sendStringAsUnicode=false'; // $dsnRbac .= '?sendStringAsUnicode=false';
break; break;
default: default :
break; break;
} }
//initialize db // initialize db
$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;
$pro['datasources']['rbac']['adapter'] = $DB_ADAPTER; $pro ['datasources'] ['rbac'] ['adapter'] = $DB_ADAPTER;
$pro['datasources']['rp']['connection'] = $dsnRp; $pro ['datasources'] ['rp'] ['connection'] = $dsnRp;
$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'] =
//$pro['datasources']['dbarray']['adapter'] = 'dbarray'; // 'dbarray://user:pass@localhost/pm_os';
$oFile = fopen(PATH_CORE . 'config/_databases_.php', 'w'); // $pro['datasources']['dbarray']['adapter'] = 'dbarray';
fwrite($oFile, '<?php global $pro;return $pro; ?>'); $oFile = fopen ( PATH_CORE . 'config/_databases_.php', 'w' );
fclose($oFile); fwrite ( $oFile, '<?php global $pro;return $pro; ?>' );
Propel::init(PATH_CORE . 'config/_databases_.php'); fclose ( $oFile );
//Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection'); Propel::init ( PATH_CORE . 'config/_databases_.php' );
// Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection');
eprintln("Processing workspace: " . $sObject, 'green');
try{ eprintln ( "Processing workspace: " . $sObject, 'green' );
processWorkspace(); try {
}catch(Exception $e){ processWorkspace ();
echo $e->getMessage();
eprintln("Probelm in workspace: " . $sObject.' it was omitted.', 'red');
} }
eprintln(); catch ( Exception $e ) {
unlink(PATH_CORE . 'config/_databases_.php'); echo $e->getMessage ();
eprintln ( "Probelm in workspace: " . $sObject . ' it was omitted.', 'red' );
}
eprintln ();
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')))); // @file_put_contents(PATH_DATA . 'cron', serialize(array('bCronIsRunning' =>
// '0', 'sLastExecution' => date('Y-m-d H:i:s'))));
function processWorkspace() { function processWorkspace() {
global $sLastExecution; global $sLastExecution;
G::LoadClass('AppSolr');
try { try {
$oAppSolr = new AppSolr(); if ($solrConf = System::solrEnv () !== false) {
if ($oAppSolr->isSolrEnabled()) { G::LoadClass ( 'AppSolr' );
$oAppSolr->reindexAllApplications(); $oAppSolr = new AppSolr ( $solrConf ['solr_enabled'], $solrConf ['solr_host'], $solrConf ['solr_instance'] );
//$data = $ApplicationSolrIndex->getAppGridData($start, $limit, $action, $filter, $search, $process, $user, $status, $type, $dateFrom, $dateTo, $callback, $dir, $sort); $oAppSolr->reindexAllApplications ();
//$result = G::json_encode($data); }
} else {
print "Incomplete Solr configuration.";
}
} }
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 saveLog($sSource, $sType, $sDescription) { function saveLog($sSource, $sType, $sDescription) {
try { try {
global $isDebug; global $isDebug;
if ( $isDebug ) if ($isDebug)
print date('H:i:s') ." ($sSource) $sType $sDescription <br>\n"; 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'; $c = 'green';
if($t=='error') $c = 'red'; if ($t == 'error')
if($t=='info') $c = 'yellow'; $c = 'red';
eprintln("[$m]", $c); if ($t == 'info')
$c = 'yellow';
eprintln ( "[$m]", $c );
} }

View File

@@ -12,7 +12,6 @@ require_once "entities/SolrRequestData.php";
require_once "entities/SolrUpdateDocument.php"; require_once "entities/SolrUpdateDocument.php";
require_once "entities/AppSolrQueue.php"; require_once "entities/AppSolrQueue.php";
require_once "classes/model/AppSolrQueue.php"; require_once "classes/model/AppSolrQueue.php";
require_once PATH_DATA_SITE . "/solr.php";
class InvalidIndexSearchTextException extends Exception { class InvalidIndexSearchTextException extends Exception {
// Redefine the exception so message isn't optional // Redefine the exception so message isn't optional
@@ -33,11 +32,11 @@ class AppSolr {
private $solrHost = ""; private $solrHost = "";
private $solrInstance = ""; private $solrInstance = "";
function __construct() { function __construct($SolrEnabled, $SolrHost, $SolrInstance) {
// define solr availability // define solr availability
$this->solrIsEnabled = SOLR_ENABLED; $this->solrIsEnabled = $SolrEnabled;
$this->solrHost = SOLR_HOST; $this->solrHost = $SolrHost;
$this->solrInstance = SOLR_INSTANCE; $this->solrInstance = $SolrInstance;
} }
public function isSolrEnabled() { public function isSolrEnabled() {

View File

@@ -67,6 +67,16 @@ G::LoadClass('pmScript');
*/ */
class Cases { class Cases {
private $appSolr = null;
function __construct(){
//get Solr initialization variables
if(($solrConf = System::solrEnv()) !== false){
G::LoadClass('AppSolr');
$appSolr = new AppSolr($solrConf['solr_enabled'], $solrConf['solr_host'], $solrConf['solr_instance']);
}
}
/* /*
* Ask if an user can start a case * Ask if an user can start a case
* @param string $sUIDUser * @param string $sUIDUser
@@ -833,9 +843,7 @@ class Cases {
*/ */
function updateCase($sAppUid, $Fields = array()) { function updateCase($sAppUid, $Fields = array()) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try { try {
$aApplicationFields = $Fields['APP_DATA']; $aApplicationFields = $Fields['APP_DATA'];
$Fields['APP_UID'] = $sAppUid; $Fields['APP_UID'] = $sAppUid;
@@ -890,7 +898,7 @@ class Cases {
//now update the priority in appdelegation table, using the defined variable in task //now update the priority in appdelegation table, using the defined variable in task
if (trim($DEL_INDEX) != '' && trim($TAS_UID) != '') { if (trim($DEL_INDEX) != '' && trim($TAS_UID) != '') {
//optimized code to avoid load task content row. //optimized code to avoid load task content row.
$c = new Criteria(); $c = new Criteria();
$c->clearSelectColumns(); $c->clearSelectColumns();
$c->addSelectColumn(TaskPeer::TAS_PRIORITY_VARIABLE); $c->addSelectColumn(TaskPeer::TAS_PRIORITY_VARIABLE);
@@ -909,22 +917,19 @@ class Cases {
$x = unserialize($Fields['APP_DATA']); $x = unserialize($Fields['APP_DATA']);
if (isset($x[$VAR_PRI])) { if (isset($x[$VAR_PRI])) {
if (trim($x[$VAR_PRI]) != '') { if (trim($x[$VAR_PRI]) != '') {
$priority = 3;
if (is_numeric($x[$VAR_PRI])) {
$priority = ($x[$VAR_PRI] >= 1 && $x[$VAR_PRI] <= 5) ? $x[$VAR_PRI] : '3';
}
$oDel = new AppDelegation; $oDel = new AppDelegation;
$array = array(); $array = array();
$array['APP_UID'] = $sAppUid; $array['APP_UID'] = $sAppUid;
$array['DEL_INDEX'] = $DEL_INDEX; $array['DEL_INDEX'] = $DEL_INDEX;
$array['TAS_UID'] = $TAS_UID; $array['TAS_UID'] = $TAS_UID;
$array['DEL_PRIORITY'] = $priority; $array['DEL_PRIORITY'] = (isset($x[$VAR_PRI]) ? ($x[$VAR_PRI] >= 1 && $x[$VAR_PRI] <= 5 ? $x[$VAR_PRI] : '3') : '3');
$oDel->update($array); $oDel->update($array);
} }
} }
} }
//Update Solr Index //Update Solr Index
$appSolr->updateApplicationSearchIndex($sAppUid); if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sAppUid);
return $Fields; return $Fields;
} }
@@ -942,9 +947,7 @@ class Cases {
*/ */
function removeCase($sAppUid) { function removeCase($sAppUid) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try { try {
$oApplication = new Application(); $oApplication = new Application();
$oAppDelegation = new AppDelegation(); $oAppDelegation = new AppDelegation();
@@ -1001,7 +1004,8 @@ class Cases {
$result = $oApp->remove($sAppUid); $result = $oApp->remove($sAppUid);
//delete application from index //delete application from index
$appSolr->deleteApplicationSearchIndex($sAppUid); if($this->appSolr != null)
$this->appSolr->deleteApplicationSearchIndex($sAppUid);
return $result; return $result;
} catch (exception $e) { } catch (exception $e) {
@@ -1019,15 +1023,14 @@ class Cases {
*/ */
function setDelInitDate($sAppUid, $iDelIndex) { function setDelInitDate($sAppUid, $iDelIndex) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try { try {
$oAppDel = AppDelegationPeer::retrieveByPk($sAppUid, $iDelIndex); $oAppDel = AppDelegationPeer::retrieveByPk($sAppUid, $iDelIndex);
$oAppDel->setDelInitDate("now"); $oAppDel->setDelInitDate("now");
$oAppDel->save(); $oAppDel->save();
//update searchindex //update searchindex
$appSolr->updateApplicationSearchIndex($sAppUid); if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sAppUid);
} catch (exception $e) { } catch (exception $e) {
throw ($e); throw ($e);
} }
@@ -1044,17 +1047,15 @@ class Cases {
*/ */
function setCatchUser($sAppUid, $iDelIndex, $usrId) { function setCatchUser($sAppUid, $iDelIndex, $usrId) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try { try {
$oAppDel = AppDelegationPeer::retrieveByPk($sAppUid, $iDelIndex); $oAppDel = AppDelegationPeer::retrieveByPk($sAppUid, $iDelIndex);
$oAppDel->setDelInitDate("now"); $oAppDel->setDelInitDate("now");
$oAppDel->setUsrUid($usrId); $oAppDel->setUsrUid($usrId);
$oAppDel->save(); $oAppDel->save();
//update searchindex //update searchindex
$appSolr->updateApplicationSearchIndex($sAppUid); if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sAppUid);
} catch (exception $e) { } catch (exception $e) {
throw ($e); throw ($e);
} }
@@ -1460,14 +1461,13 @@ class Cases {
*/ */
function newAppDelegation($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sPrevious, $iPriority, $sDelType, $iAppThreadIndex = 1, $nextDel=null) { function newAppDelegation($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sPrevious, $iPriority, $sDelType, $iAppThreadIndex = 1, $nextDel=null) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try { try {
$appDel = new AppDelegation(); $appDel = new AppDelegation();
$result = $appDel->createAppDelegation($sProUid, $sAppUid, $sTasUid, $sUsrUid, $iAppThreadIndex, $iPriority, false, $sPrevious, $nextDel); $result = $appDel->createAppDelegation($sProUid, $sAppUid, $sTasUid, $sUsrUid, $iAppThreadIndex, $iPriority, false, $sPrevious, $nextDel);
//update searchindex //update searchindex
$appSolr->updateApplicationSearchIndex($sAppUid); if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sAppUid);
return $result; return $result;
} }
catch (exception $e) { catch (exception $e) {
@@ -1487,9 +1487,7 @@ class Cases {
*/ */
function updateAppDelegation($sAppUid, $iDelIndex, $iAppThreadIndex) { function updateAppDelegation($sAppUid, $iDelIndex, $iAppThreadIndex) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try { try {
$appDelegation = new AppDelegation(); $appDelegation = new AppDelegation();
$aData = array(); $aData = array();
@@ -1499,7 +1497,8 @@ class Cases {
$appDelegation->update($aData); $appDelegation->update($aData);
//update searchindex //update searchindex
$appSolr->updateApplicationSearchIndex($sAppUid); if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sAppUid);
return true; return true;
} catch (exception $e) { } catch (exception $e) {
@@ -1576,9 +1575,6 @@ class Cases {
*/ */
function updateAppThread($sAppUid, $iAppThreadIndex, $iNewDelIndex) { function updateAppThread($sAppUid, $iAppThreadIndex, $iNewDelIndex) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try { try {
/// updating the DEL_INDEX value in the APP_THREAD /// updating the DEL_INDEX value in the APP_THREAD
$con = Propel::getConnection('workflow'); $con = Propel::getConnection('workflow');
@@ -1598,8 +1594,9 @@ class Cases {
$aData['DEL_INDEX'] = $iNewDelIndex; $aData['DEL_INDEX'] = $iNewDelIndex;
$appThread->update($aData); $appThread->update($aData);
*/ */
//update searchindex //update searchindex
$appSolr->updateApplicationSearchIndex($sAppUid); if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sAppUid);
return $iNewDelIndex; return $iNewDelIndex;
} }
@@ -1618,9 +1615,6 @@ class Cases {
*/ */
function closeAppThread($sAppUid, $iAppThreadIndex) { function closeAppThread($sAppUid, $iAppThreadIndex) {
// //initialize solrindex object called from other functions
// G::LoadClass('AppSolr');
// $appSolr = new AppSolr();
try { try {
$appThread = new AppThread(); $appThread = new AppThread();
$aData = array(); $aData = array();
@@ -1629,8 +1623,6 @@ class Cases {
$aData['APP_THREAD_STATUS'] = 'CLOSED'; $aData['APP_THREAD_STATUS'] = 'CLOSED';
$appThread->update($aData); $appThread->update($aData);
// //update searchindex
// $appSolr->updateApplicationSearchIndex($sAppUid);
return true; return true;
} catch (exception $e) { } catch (exception $e) {
throw ($e); throw ($e);
@@ -1646,9 +1638,6 @@ class Cases {
*/ */
function closeAllThreads($sAppUid) { function closeAllThreads($sAppUid) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try { try {
//Execute('UPDATE APP_DELEGATION SET DEL_THREAD_STATUS="CLOSED" WHERE APP_UID="$sAppUid" AND DEL_THREAD_STATUS="OPEN"'); //Execute('UPDATE APP_DELEGATION SET DEL_THREAD_STATUS="CLOSED" WHERE APP_UID="$sAppUid" AND DEL_THREAD_STATUS="OPEN"');
$c = new Criteria(); $c = new Criteria();
@@ -1666,8 +1655,9 @@ class Cases {
throw (new PropelException('The row cannot be created!', new PropelException($msg))); throw (new PropelException('The row cannot be created!', new PropelException($msg)));
} }
} }
//update searchindex //update searchindex
$appSolr->updateApplicationSearchIndex($sAppUid); if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sAppUid);
} catch (exception $e) { } catch (exception $e) {
throw ($e); throw ($e);
} }
@@ -1685,14 +1675,12 @@ class Cases {
*/ */
function newAppThread($sAppUid, $iNewDelIndex, $iAppParent) { function newAppThread($sAppUid, $iNewDelIndex, $iAppParent) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try { try {
$appThread = new AppThread(); $appThread = new AppThread();
$result = $appThread->createAppThread($sAppUid, $iNewDelIndex, $iAppParent); $result = $appThread->createAppThread($sAppUid, $iNewDelIndex, $iAppParent);
//update searchindex //update searchindex
$appSolr->updateApplicationSearchIndex($sAppUid); if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sAppUid);
return $result; return $result;
} catch (exception $e) { } catch (exception $e) {
throw ($e); throw ($e);
@@ -1708,9 +1696,6 @@ class Cases {
*/ */
function closeAllDelegations($sAppUid) { function closeAllDelegations($sAppUid) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try { try {
//Execute('UPDATE APP_DELEGATION SET DEL_THREAD_STATUS="CLOSED" WHERE APP_UID="$sAppUid" AND DEL_THREAD_STATUS="OPEN"'); //Execute('UPDATE APP_DELEGATION SET DEL_THREAD_STATUS="CLOSED" WHERE APP_UID="$sAppUid" AND DEL_THREAD_STATUS="OPEN"');
$c = new Criteria(); $c = new Criteria();
@@ -1728,8 +1713,9 @@ class Cases {
throw (new PropelException('The row cannot be created!', new PropelException($msg))); throw (new PropelException('The row cannot be created!', new PropelException($msg)));
} }
} }
//update searchindex //update searchindex
$appSolr->updateApplicationSearchIndex($sAppUid); if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sAppUid);
} catch (exception $e) { } catch (exception $e) {
throw ($e); throw ($e);
} }
@@ -1745,10 +1731,6 @@ class Cases {
*/ */
function CloseCurrentDelegation($sAppUid, $iDelIndex) { function CloseCurrentDelegation($sAppUid, $iDelIndex) {
//called from other functions
// //initialize solrindex object
// G::LoadClass('AppSolr');
// $appSolr = new AppSolr();
try { try {
//Execute('UPDATE APP_DELEGATION SET DEL_THREAD_STATUS="CLOSED" WHERE APP_UID="$sAppUid" AND DEL_THREAD_STATUS="OPEN"'); //Execute('UPDATE APP_DELEGATION SET DEL_THREAD_STATUS="CLOSED" WHERE APP_UID="$sAppUid" AND DEL_THREAD_STATUS="OPEN"');
$c = new Criteria(); $c = new Criteria();
@@ -1770,8 +1752,6 @@ class Cases {
throw (new PropelException('The row cannot be created!', new PropelException($msg))); throw (new PropelException('The row cannot be created!', new PropelException($msg)));
} }
} }
// //update searchindex
// $appSolr->updateApplicationSearchIndex($sAppUid);
} catch (exception $e) { } catch (exception $e) {
throw ($e); throw ($e);
@@ -1789,9 +1769,6 @@ class Cases {
*/ */
function ReactivateCurrentDelegation($sAppUid, $iDelegation) { function ReactivateCurrentDelegation($sAppUid, $iDelegation) {
// //initialize solrindex object called from other function
// G::LoadClass('AppSolr');
// $appSolr = new AppSolr();
try { try {
$c = new Criteria(); $c = new Criteria();
$c->add(AppDelegationPeer::APP_UID, $sAppUid); $c->add(AppDelegationPeer::APP_UID, $sAppUid);
@@ -1810,8 +1787,6 @@ class Cases {
throw (new PropelException('The row cannot be created!', new PropelException($msg))); throw (new PropelException('The row cannot be created!', new PropelException($msg)));
} }
} }
// //update searchindex
// $appSolr->updateApplicationSearchIndex($sAppUid);
} catch (exception $e) { } catch (exception $e) {
throw ($e); throw ($e);
} }
@@ -1829,9 +1804,6 @@ class Cases {
function startCase($sTasUid, $sUsrUid, $isSubprocess=false) { function startCase($sTasUid, $sUsrUid, $isSubprocess=false) {
if ($sTasUid != '') { if ($sTasUid != '') {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try { try {
$this->Task = new Task; $this->Task = new Task;
@@ -1874,8 +1846,9 @@ class Cases {
G::LoadClass('derivation'); G::LoadClass('derivation');
$oDerivation = new Derivation(); $oDerivation = new Derivation();
$oDerivation->setTasLastAssigned($sTasUid, $sUsrUid); $oDerivation->setTasLastAssigned($sTasUid, $sUsrUid);
//update searchindex //update searchindex
$appSolr->updateApplicationSearchIndex($sAppUid); if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sAppUid);
} catch (exception $e) { } catch (exception $e) {
throw ($e); throw ($e);
} }
@@ -3422,9 +3395,6 @@ class Cases {
*/ */
function pauseCase($sApplicationUID, $iDelegation, $sUserUID, $sUnpauseDate = null) { function pauseCase($sApplicationUID, $iDelegation, $sUserUID, $sUnpauseDate = null) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
$this->CloseCurrentDelegation($sApplicationUID, $iDelegation); $this->CloseCurrentDelegation($sApplicationUID, $iDelegation);
$oApplication = new Application(); $oApplication = new Application();
@@ -3454,8 +3424,9 @@ class Cases {
$oAppDelay = new AppDelay(); $oAppDelay = new AppDelay();
$oAppDelay->create($aData); $oAppDelay->create($aData);
//update searchindex //update searchindex
$appSolr->updateApplicationSearchIndex($sApplicationUID); if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sApplicationUID);
} }
/* /*
@@ -3516,8 +3487,9 @@ class Cases {
$oAppDelay = new AppDelay(); $oAppDelay = new AppDelay();
$aFieldsDelay = $oAppDelay->update($aData); $aFieldsDelay = $oAppDelay->update($aData);
//update searchindex //update searchindex
$appSolr->updateApplicationSearchIndex($sApplicationUID); if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sApplicationUID);
} }
/* /*
@@ -3531,9 +3503,6 @@ class Cases {
*/ */
function cancelCase($sApplicationUID, $iIndex, $user_logged) { function cancelCase($sApplicationUID, $iIndex, $user_logged) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
$oApplication = new Application(); $oApplication = new Application();
$aFields = $oApplication->load($sApplicationUID); $aFields = $oApplication->load($sApplicationUID);
@@ -3592,8 +3561,9 @@ class Cases {
$oDerivation->verifyIsCaseChild($sApplicationUID); $oDerivation->verifyIsCaseChild($sApplicationUID);
} }
//update searchindex //update searchindex
$appSolr->updateApplicationSearchIndex($sApplicationUID); if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sApplicationUID);
} }
/* /*
@@ -3607,9 +3577,6 @@ class Cases {
*/ */
function reactivateCase($sApplicationUID, $iIndex, $user_logged) { function reactivateCase($sApplicationUID, $iIndex, $user_logged) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
$oApplication = new Application(); $oApplication = new Application();
$aFields = $oApplication->load((isset($_POST['sApplicationUID']) ? $_POST['sApplicationUID'] : $_SESSION['APPLICATION'])); $aFields = $oApplication->load((isset($_POST['sApplicationUID']) ? $_POST['sApplicationUID'] : $_SESSION['APPLICATION']));
@@ -3645,8 +3612,9 @@ class Cases {
$stmt = $con->createStatement(); $stmt = $con->createStatement();
$rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC); $rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
//update searchindex //update searchindex
$appSolr->updateApplicationSearchIndex($sApplicationUID); if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sApplicationUID);
} }
/* /*
@@ -3662,9 +3630,6 @@ class Cases {
*/ */
function reassignCase($sApplicationUID, $iDelegation, $sUserUID, $newUserUID, $sType = 'REASSIGN') { function reassignCase($sApplicationUID, $iDelegation, $sUserUID, $newUserUID, $sType = 'REASSIGN') {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
$this->CloseCurrentDelegation($sApplicationUID, $iDelegation); $this->CloseCurrentDelegation($sApplicationUID, $iDelegation);
$oAppDelegation = new AppDelegation(); $oAppDelegation = new AppDelegation();
@@ -3699,8 +3664,9 @@ class Cases {
$oAppDelay = new AppDelay(); $oAppDelay = new AppDelay();
$oAppDelay->create($aData); $oAppDelay->create($aData);
//update searchindex //update searchindex
$appSolr->updateApplicationSearchIndex($sApplicationUID); if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sApplicationUID);
return true; return true;
} }
@@ -5153,9 +5119,6 @@ class Cases {
*/ */
function executeTriggersAfterExternal($sProcess, $sTask, $sApplication, $iIndex, $iStepPosition, $aNewData = array()) { function executeTriggersAfterExternal($sProcess, $sTask, $sApplication, $iIndex, $iStepPosition, $aNewData = array()) {
// //initialize solrindex object UpdateCase añready calls the update
// G::LoadClass('AppSolr');
// $appSolr = new AppSolr();
//load the variables //load the variables
$Fields = $this->loadCase($sApplication); $Fields = $this->loadCase($sApplication);
@@ -5174,8 +5137,6 @@ class Cases {
$aData['TAS_UID'] = $sTask; $aData['TAS_UID'] = $sTask;
$this->updateCase($sApplication, $aData); $this->updateCase($sApplication, $aData);
// //update searchindex
// $appSolr->updateApplicationSearchIndex($sApplication);
} }
/* /*
@@ -5528,9 +5489,6 @@ class Cases {
} }
function discriminateCases($aData){ function discriminateCases($aData){
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
$siblingThreadData = $this->GetAllOpenDelegation($aData); $siblingThreadData = $this->GetAllOpenDelegation($aData);
foreach($siblingThreadData as $thread => $threadData) foreach($siblingThreadData as $thread => $threadData)
@@ -5538,8 +5496,9 @@ class Cases {
$this->closeAppThread ( $aData['APP_UID'], $threadData['DEL_INDEX']); //Close Sibling AppThreads $this->closeAppThread ( $aData['APP_UID'], $threadData['DEL_INDEX']); //Close Sibling AppThreads
$this->CloseCurrentDelegation ($aData['APP_UID'], $threadData['DEL_INDEX']); //Close Sibling AppDelegations $this->CloseCurrentDelegation ($aData['APP_UID'], $threadData['DEL_INDEX']); //Close Sibling AppDelegations
//update searchindex //update searchindex
$appSolr->updateApplicationSearchIndex($aData['APP_UID']); if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($aData['APP_UID']);
} }
} }
@@ -5656,48 +5615,4 @@ class Cases {
$response['array']=$rows; $response['array']=$rows;
return $response; return $response;
} }
function getCaseNotes($applicationID, $type = 'array',$userUid = '') {
require_once ( "classes/model/AppNotes.php" );
$appNotes = new AppNotes();
$appNotes = $appNotes->getNotesList($applicationID,$userUid);
$response = '';
if (is_array($appNotes)) {
switch ($type) {
case 'array':
$response = array();
foreach ($appNotes['array']['notes'] as $key => $value) {
$list = array();
$list['FULL_NAME'] = $value['USR_FIRSTNAME']." ".$value['USR_LASTNAME'];
foreach ($value as $keys => $value) {
if ($keys != 'USR_FIRSTNAME' && $keys != 'USR_LASTNAME' && $keys != 'USR_EMAIL') {
$list[$keys] = $value;
}
}
$response[$key+1] = $list;
}
break;
case 'object':
$response = new stdclass();
foreach ($appNotes['array']['notes'] as $key => $value) {
$response->$key->FULL_NAME = $value['USR_FIRSTNAME']." ".$value['USR_LASTNAME'];
foreach ($value as $keys => $value) {
if ($keys != 'USR_FIRSTNAME' && $keys != 'USR_LASTNAME' && $keys != 'USR_EMAIL') {
$response->$key->$keys = $value;
}
}
}
break;
case 'string':
$response = '';
foreach ($appNotes['array']['notes'] as $key => $value) {
$response .= $value['USR_FIRSTNAME']." ".$value['USR_LASTNAME']." "."(".$value['USR_USERNAME'].")".
" ".$value['NOTE_CONTENT']." "." (".$value['NOTE_DATE']." ) ".
" \n";
}
break;
}
}
return $response;
}
} }

View File

@@ -1008,85 +1008,35 @@ class System {
return $cities; return $cities;
} }
public static function getSystemConfiguration($globalIniFile = '', $wsIniFile = '') public static function getSystemConfiguration($iniFile='')
{ {
$readGlobalIniFile = false;
$readWsIniFile = false;
if (empty($globalIniFile)) {
$globalIniFile = PATH_CORE . 'config' . PATH_SEP . 'env.ini';
}
if (empty($wsIniFile)) {
if (defined('PATH_DB')) { // if we're on a valid workspace env.
$uriParts = explode('/', getenv("REQUEST_URI"));
if (substr($uriParts[1], 0, 3 ) == 'sys') {
$wsName = substr($uriParts[1], 3);
$wsIniFile = PATH_DB . $wsName . PATH_SEP . 'env.ini';
}
}
}
$readGlobalIniFile = file_exists($globalIniFile) ? true : false;
$readWsIniFile = file_exists($wsIniFile) ? true : false;
if (isset($_SESSION['PROCESSMAKER_ENV'])) {
$md5 = array();
if ($readGlobalIniFile)
$md5[] = md5_file($globalIniFile);
if ($readWsIniFile)
$md5[] = md5_file($wsIniFile);
$hash = implode('-', $md5);
if ($_SESSION['PROCESSMAKER_ENV_HASH'] === $hash) {
$_SESSION['PROCESSMAKER_ENV']['from_cache'] = 1;
return $_SESSION['PROCESSMAKER_ENV'];
}
}
// default configuration
$config = array( $config = array(
'debug' => 0, 'debug' => 0,
'debug_sql' => 0, 'debug_sql' => 0,
'debug_time' => 0, 'debug_time' => 0,
'debug_calendar' => 0, 'debug_calendar' => 0,
'wsdl_cache' => 1, 'wsdl_cache' => 1,
'memory_limit' => '100M', 'memory_limit' => '100M',
'time_zone' => 'America/La_Paz', 'time_zone' => 'America/La_Paz',
'memcached' => 0, 'memcached' => 0,
'memcached_server' => '', 'memcached_server' =>'',
'default_skin' => 'classic', 'default_skin' => 'classic',
'default_lang' => 'en' 'default_lang' => 'en'
); );
// read the global env.ini configuration file if (empty($iniFile) || !file_exists($iniFile)) {
if ($readGlobalIniFile && ($globalConf = @parse_ini_file($globalIniFile)) !== false) { return $config;
$config = array_merge($config, $globalConf);
} }
/* Read the env.ini */
$ini_contents = parse_ini_file($iniFile, false);
// Workspace environment configuration if ($ini_contents !== false) {
if ($readWsIniFile && ($wsConf = @parse_ini_file($wsIniFile)) !== false) { $config = array_merge($config, $ini_contents);
$config = array_merge($config, $wsConf);
} }
// validation debug config, only binary value is valid; debug = 1, to enable // validation debug config, ony accept bynary values, 1 to enable
$config['debug'] = $config['debug'] == 1 ? 1 : 0; $config['debug'] = $config['debug'] == 1 ? 1 : 0;
$md5 = array();
if ($readGlobalIniFile)
$md5[] = md5_file($globalIniFile);
if ($readWsIniFile)
$md5[] = md5_file($wsIniFile);
$hash = implode('-', $md5);
$_SESSION['PROCESSMAKER_ENV'] = $config;
$_SESSION['PROCESSMAKER_ENV_HASH'] = $hash;
return $config; return $config;
} }
@@ -1121,4 +1071,23 @@ class System {
return $result; return $result;
} }
function solrEnv()
{
$conf = System::getSystemConfiguration();
if (!isset($conf['solr_enabled']) || !isset($conf['solr_host']) || !isset($conf['solr_instance'])) {
return false;
}
if ($conf['solr_enabled']) {
return array(
'solr_enabled' => $conf['solr_enabled'],
'solr_host' => $conf['solr_host'],
'solr_instance' => $conf['solr_instance']
);
}
return false;
}
}// end System class }// end System class

View File

@@ -40,7 +40,7 @@ class Entity_Base {
protected function validateRequiredFields($requiredFields = array()) { protected function validateRequiredFields($requiredFields = array()) {
foreach ( $requiredFields as $k => $field ) { foreach ( $requiredFields as $k => $field ) {
if ($this->{$field} === NULL) { if ($this->{$field} === NULL) {
throw (new Zend_Exception ( "Field $field is required in " . get_class ( $this ) )); throw (new Exception ( "Field $field is required in " . get_class ( $this ) ));
die (); die ();
} }
} }

View File

@@ -1,44 +1,46 @@
<?php <?php
// getting the extJs parameters // getting the extJs parameters
$callback = isset($_POST['callback']) ? $_POST['callback'] : 'stcCallback1001'; $callback = isset ( $_POST ['callback'] ) ? $_POST ['callback'] : 'stcCallback1001';
$dir = isset($_POST['dir']) ? $_POST['dir'] : 'DESC'; $dir = isset ( $_POST ['dir'] ) ? $_POST ['dir'] : 'DESC';
$sort = isset($_POST['sort']) ? $_POST['sort'] : ''; $sort = isset ( $_POST ['sort'] ) ? $_POST ['sort'] : '';
$start = isset($_POST['start']) ? $_POST['start'] : '0'; $start = isset ( $_POST ['start'] ) ? $_POST ['start'] : '0';
$limit = isset($_POST['limit']) ? $_POST['limit'] : '25'; $limit = isset ( $_POST ['limit'] ) ? $_POST ['limit'] : '25';
$filter = isset($_POST['filter']) ? $_POST['filter'] : ''; $filter = isset ( $_POST ['filter'] ) ? $_POST ['filter'] : '';
$search = isset($_POST['search']) ? $_POST['search'] : ''; $search = isset ( $_POST ['search'] ) ? $_POST ['search'] : '';
$process = isset($_POST['process']) ? $_POST['process'] : ''; $process = isset ( $_POST ['process'] ) ? $_POST ['process'] : '';
$user = isset($_POST['user']) ? $_POST['user'] : ''; $user = isset ( $_POST ['user'] ) ? $_POST ['user'] : '';
$status = isset($_POST['status']) ? strtoupper($_POST['status']) : ''; $status = isset ( $_POST ['status'] ) ? strtoupper ( $_POST ['status'] ) : '';
$action = isset($_GET['action']) ? $_GET['action'] : (isset($_POST['action']) ? $_POST['action'] : 'todo'); $action = isset ( $_GET ['action'] ) ? $_GET ['action'] : (isset ( $_POST ['action'] ) ? $_POST ['action'] : 'todo');
$type = isset($_GET['type']) ? $_GET['type'] : (isset($_POST['type']) ? $_POST['type'] : 'extjs'); $type = isset ( $_GET ['type'] ) ? $_GET ['type'] : (isset ( $_POST ['type'] ) ? $_POST ['type'] : 'extjs');
$user = isset($_POST['user']) ? $_POST['user'] : ''; $user = isset ( $_POST ['user'] ) ? $_POST ['user'] : '';
$dateFrom = isset($_POST['dateFrom'])? substr($_POST['dateFrom'],0,10) : ''; $dateFrom = isset ( $_POST ['dateFrom'] ) ? substr ( $_POST ['dateFrom'], 0, 10 ) : '';
$dateTo = isset($_POST['dateTo']) ? substr($_POST['dateTo'],0,10) : ''; $dateTo = isset ( $_POST ['dateTo'] ) ? substr ( $_POST ['dateTo'], 0, 10 ) : '';
try { try {
$result =""; $result = "";
$userUid = (isset ( $_SESSION ['USER_LOGGED'] ) && $_SESSION ['USER_LOGGED'] != '') ? $_SESSION ['USER_LOGGED'] : null;
if ((($solrConf = System::solrEnv()) !== false) && $action != 'paused') {
G::LoadClass ( 'AppSolr' );
$ApplicationSolrIndex = new AppSolr ($solrConf['solr_enabled'], $solrConf['solr_host'], $solrConf['solr_instance']);
G::LoadClass('AppSolr'); $data = $ApplicationSolrIndex->getAppGridData ( $userUid, $start, $limit, $action, $filter, $search, $process, $user, $status, $type, $dateFrom, $dateTo, $callback, $dir, $sort );
$ApplicationSolrIndex = new AppSolr(); $result = G::json_encode ( $data );
$userUid = ( isset($_SESSION['USER_LOGGED'] ) && $_SESSION['USER_LOGGED'] != '' ) ? $_SESSION['USER_LOGGED'] : null;
if ($action != 'paused' && $ApplicationSolrIndex->isSolrEnabled()) {
$data = $ApplicationSolrIndex->getAppGridData($userUid, $start, $limit, $action, $filter, $search, $process, $user, $status, $type, $dateFrom, $dateTo, $callback, $dir, $sort);
$result = G::json_encode($data);
}
else{
G::LoadClass('applications');
$apps = new Applications();
$data = $apps->getAll($userUid, $start, $limit, $action, $filter, $search, $process, $user, $status, $type, $dateFrom, $dateTo, $callback, $dir, $sort);
$result = G::json_encode($data);
}
echo $result;
} }
catch ( Exception $e ) { else {
$msg = array ( 'error' => $e->getMessage() ); G::LoadClass ( 'applications' );
print G::json_encode( $msg ) ; $apps = new Applications ();
} $data = $apps->getAll ( $userUid, $start, $limit, $action, $filter, $search, $process, $user, $status, $type, $dateFrom, $dateTo, $callback, $dir, $sort );
$result = G::json_encode ( $data );
}
echo $result;
}
catch ( Exception $e ) {
$msg = array (
'error' => $e->getMessage ()
);
print G::json_encode ( $msg );
}