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
* @package workflow-engine-bin
*/
ini_set('display_errors', 1);
error_reporting(E_ALL);
ini_set('memory_limit', '256M');//set enough memory for the script
ini_set ( 'display_errors', 1 );
error_reporting ( E_ALL );
ini_set ( 'memory_limit', '256M' ); // set enough memory for the script
if (!defined('SYS_LANG')) {
define('SYS_LANG', 'en');
if (! defined ( 'SYS_LANG' )) {
define ( 'SYS_LANG', 'en' );
}
if (!defined('PATH_HOME')) {
if ( !defined('PATH_SEP') ) {
define('PATH_SEP', ( substr(PHP_OS, 0, 3) == 'WIN' ) ? '\\' : '/');
if (! defined ( 'PATH_HOME' )) {
if (! defined ( 'PATH_SEP' )) {
define ( 'PATH_SEP', (substr ( PHP_OS, 0, 3 ) == 'WIN') ? '\\' : '/' );
}
$docuroot = explode(PATH_SEP, str_replace('engine' . PATH_SEP . 'methods' . PATH_SEP . 'services', '', dirname(__FILE__)));
array_pop($docuroot);
array_pop($docuroot);
$pathhome = implode(PATH_SEP, $docuroot) . PATH_SEP;
//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.
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_OUTTRUNK', $pathOutTrunk);
$docuroot = explode ( PATH_SEP, str_replace ( 'engine' . PATH_SEP . 'methods' . PATH_SEP . 'services', '', dirname ( __FILE__ ) ) );
array_pop ( $docuroot );
array_pop ( $docuroot );
$pathhome = implode ( PATH_SEP, $docuroot ) . PATH_SEP;
// 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.
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_OUTTRUNK', $pathOutTrunk );
require_once (PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php');
G::LoadThirdParty('pear/json','class.json');
G::LoadThirdParty('smarty/libs','Smarty.class');
G::LoadSystem('error');
G::LoadSystem('dbconnection');
G::LoadSystem('dbsession');
G::LoadSystem('dbrecordset');
G::LoadSystem('dbtable');
G::LoadSystem('rbac' );
G::LoadSystem('publisher');
G::LoadSystem('templatePower');
G::LoadSystem('xmlDocument');
G::LoadSystem('xmlform');
G::LoadSystem('xmlformExtension');
G::LoadSystem('form');
G::LoadSystem('menu');
G::LoadSystem("xmlMenu");
G::LoadSystem('dvEditor');
G::LoadSystem('table');
G::LoadSystem('pagedTable');
require_once ( "propel/Propel.php" );
require_once ( "creole/Creole.php" );
G::LoadThirdParty ( 'pear/json', 'class.json' );
G::LoadThirdParty ( 'smarty/libs', 'Smarty.class' );
G::LoadSystem ( 'error' );
G::LoadSystem ( 'dbconnection' );
G::LoadSystem ( 'dbsession' );
G::LoadSystem ( 'dbrecordset' );
G::LoadSystem ( 'dbtable' );
G::LoadSystem ( 'rbac' );
G::LoadSystem ( 'publisher' );
G::LoadSystem ( 'templatePower' );
G::LoadSystem ( 'xmlDocument' );
G::LoadSystem ( 'xmlform' );
G::LoadSystem ( 'xmlformExtension' );
G::LoadSystem ( 'form' );
G::LoadSystem ( 'menu' );
G::LoadSystem ( "xmlMenu" );
G::LoadSystem ( 'dvEditor' );
G::LoadSystem ( 'table' );
G::LoadSystem ( 'pagedTable' );
G::LoadSystem ( 'system' );
require_once ("propel/Propel.php");
require_once ("creole/Creole.php");
}
require_once 'classes/model/AppDelegation.php';
require_once 'classes/model/Event.php';
require_once 'classes/model/AppEvent.php';
require_once 'classes/model/CaseScheduler.php';
//G::loadClass('pmScript');
// G::loadClass('pmScript');
// //default values
// //default values
// $bCronIsRunning = false;
// $sLastExecution = '';
// if ( file_exists(PATH_DATA . 'cron') ) {
// $aAux = unserialize( trim( @file_get_contents(PATH_DATA . 'cron')) );
// $bCronIsRunning = (boolean)$aAux['bCronIsRunning'];
// $sLastExecution = $aAux['sLastExecution'];
// $aAux = unserialize( trim( @file_get_contents(PATH_DATA . 'cron')) );
// $bCronIsRunning = (boolean)$aAux['bCronIsRunning'];
// $sLastExecution = $aAux['sLastExecution'];
// }
// else {
// //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'))));
// //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'))));
// }
print "PATH_HOME: " . PATH_HOME . "\n";
print "PATH_DB: " . PATH_DB . "\n";
print "PATH_CORE: " . PATH_CORE . "\n";
//define the site name (instance name)
if (!defined('SYS_SYS')) {
$sObject = $argv[1];
$sNow = '';//$argv[2];
// define the site name (instance name)
if (! defined ( 'SYS_SYS' )) {
$sObject = $argv [1];
$sNow = ''; // $argv[2];
$sFilter = '';
for($i=3; $i<count($argv); $i++){
$sFilter .= ' '.$argv[$i];
for($i = 3; $i < count ( $argv ); $i ++) {
$sFilter .= ' ' . $argv [$i];
}
$oDirectory = dir(PATH_DB);
if (is_dir(PATH_DB . $sObject)) {
$oDirectory = dir ( PATH_DB );
if (is_dir ( PATH_DB . $sObject )) {
saveLog ( 'main', 'action', "checking folder " . PATH_DB . $sObject );
if (file_exists(PATH_DB . $sObject . PATH_SEP . 'db.php')) {
define('SYS_SYS', $sObject);
if (file_exists ( PATH_DB . $sObject . PATH_SEP . 'db.php' )) {
//****************************************
//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']);
define ( 'SYS_SYS', $sObject );
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 "MEMCACHED_ENABLED: " . MEMCACHED_ENABLED . "\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.php');
//***************** PM Paths DATA **************************
define( 'PATH_DATA_SITE', PATH_DATA . 'sites/' . SYS_SYS . '/');
define( 'PATH_DOCUMENT', PATH_DATA_SITE . 'files/' );
define( 'PATH_DATA_MAILTEMPLATES', PATH_DATA_SITE . 'mailTemplates/' );
define( 'PATH_DATA_PUBLIC', PATH_DATA_SITE . 'public/' );
define( 'PATH_DATA_REPORTS', PATH_DATA_SITE . 'reports/' );
define( 'PATH_DYNAFORM', PATH_DATA_SITE . 'xmlForms/' );
define( 'PATH_IMAGES_ENVIRONMENT_FILES', PATH_DATA_SITE . 'usersFiles'.PATH_SEP);
define( 'PATH_IMAGES_ENVIRONMENT_USERS', PATH_DATA_SITE . 'usersPhotographies'.PATH_SEP);
//server info file
if(is_file(PATH_DATA_SITE.PATH_SEP.'.server_info')){
$SERVER_INFO = file_get_contents(PATH_DATA_SITE.PATH_SEP.'.server_info');
$SERVER_INFO = unserialize($SERVER_INFO);
//print_r($SERVER_INFO);
define( 'SERVER_NAME', $SERVER_INFO ['SERVER_NAME']);
define( 'SERVER_PORT', $SERVER_INFO ['SERVER_PORT']);
} else {
eprintln("WARNING! No server info found!", 'red');
// ****************************************
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');
// ***************** PM Paths DATA **************************
define ( 'PATH_DATA_SITE', PATH_DATA . 'sites/' . SYS_SYS . '/' );
define ( 'PATH_DOCUMENT', PATH_DATA_SITE . 'files/' );
define ( 'PATH_DATA_MAILTEMPLATES', PATH_DATA_SITE . 'mailTemplates/' );
define ( 'PATH_DATA_PUBLIC', PATH_DATA_SITE . 'public/' );
define ( 'PATH_DATA_REPORTS', PATH_DATA_SITE . 'reports/' );
define ( 'PATH_DYNAFORM', PATH_DATA_SITE . 'xmlForms/' );
define ( 'PATH_IMAGES_ENVIRONMENT_FILES', PATH_DATA_SITE . 'usersFiles' . PATH_SEP );
define ( 'PATH_IMAGES_ENVIRONMENT_USERS', PATH_DATA_SITE . 'usersPhotographies' . PATH_SEP );
// server info file
if (is_file ( PATH_DATA_SITE . PATH_SEP . '.server_info' )) {
$SERVER_INFO = file_get_contents ( PATH_DATA_SITE . PATH_SEP . '.server_info' );
$SERVER_INFO = unserialize ( $SERVER_INFO );
// print_r($SERVER_INFO);
define ( 'SERVER_NAME', $SERVER_INFO ['SERVER_NAME'] );
define ( 'SERVER_PORT', $SERVER_INFO ['SERVER_PORT'] );
}
else {
eprintln ( "WARNING! No server info found!", 'red' );
}
//read db configuration
$sContent = file_get_contents(PATH_DB . $sObject . PATH_SEP . 'db.php');
$sContent = str_replace('<?php', '', $sContent);
$sContent = str_replace('<?', '', $sContent);
$sContent = str_replace('?>', '', $sContent);
$sContent = str_replace('define', '', $sContent);
$sContent = str_replace("('", "$", $sContent);
$sContent = str_replace("',", '=', $sContent);
$sContent = str_replace(");", ';', $sContent);
eval($sContent);
// read db configuration
$sContent = file_get_contents ( PATH_DB . $sObject . PATH_SEP . 'db.php' );
$sContent = str_replace ( '<?php', '', $sContent );
$sContent = str_replace ( '<?', '', $sContent );
$sContent = str_replace ( '?>', '', $sContent );
$sContent = str_replace ( 'define', '', $sContent );
$sContent = str_replace ( "('", "$", $sContent );
$sContent = str_replace ( "',", '=', $sContent );
$sContent = str_replace ( ");", ';', $sContent );
eval ( $sContent );
$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;
switch ($DB_ADAPTER) {
case 'mysql':
$dsn .= '?encoding=utf8';
case 'mysql' :
$dsn .= '?encoding=utf8';
$dsnRbac .= '?encoding=utf8';
break;
case 'mssql':
//$dsn .= '?sendStringAsUnicode=false';
//$dsnRbac .= '?sendStringAsUnicode=false';
break;
default:
break;
break;
case 'mssql' :
// $dsn .= '?sendStringAsUnicode=false';
// $dsnRbac .= '?sendStringAsUnicode=false';
break;
default :
break;
}
//initialize db
$pro['datasources']['workflow']['connection'] = $dsn;
$pro['datasources']['workflow']['adapter'] = $DB_ADAPTER;
$pro['datasources']['rbac']['connection'] = $dsnRbac;
$pro['datasources']['rbac']['adapter'] = $DB_ADAPTER;
$pro['datasources']['rp']['connection'] = $dsnRp;
$pro['datasources']['rp']['adapter'] = $DB_ADAPTER;
//$pro['datasources']['dbarray']['connection'] = 'dbarray://user:pass@localhost/pm_os';
//$pro['datasources']['dbarray']['adapter'] = 'dbarray';
$oFile = fopen(PATH_CORE . 'config/_databases_.php', 'w');
fwrite($oFile, '<?php global $pro;return $pro; ?>');
fclose($oFile);
Propel::init(PATH_CORE . 'config/_databases_.php');
//Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection');
eprintln("Processing workspace: " . $sObject, 'green');
try{
processWorkspace();
}catch(Exception $e){
echo $e->getMessage();
eprintln("Probelm in workspace: " . $sObject.' it was omitted.', 'red');
// initialize db
$pro ['datasources'] ['workflow'] ['connection'] = $dsn;
$pro ['datasources'] ['workflow'] ['adapter'] = $DB_ADAPTER;
$pro ['datasources'] ['rbac'] ['connection'] = $dsnRbac;
$pro ['datasources'] ['rbac'] ['adapter'] = $DB_ADAPTER;
$pro ['datasources'] ['rp'] ['connection'] = $dsnRp;
$pro ['datasources'] ['rp'] ['adapter'] = $DB_ADAPTER;
// $pro['datasources']['dbarray']['connection'] =
// 'dbarray://user:pass@localhost/pm_os';
// $pro['datasources']['dbarray']['adapter'] = 'dbarray';
$oFile = fopen ( PATH_CORE . 'config/_databases_.php', 'w' );
fwrite ( $oFile, '<?php global $pro;return $pro; ?>' );
fclose ( $oFile );
Propel::init ( PATH_CORE . 'config/_databases_.php' );
// Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection');
eprintln ( "Processing workspace: " . $sObject, 'green' );
try {
processWorkspace ();
}
eprintln();
unlink(PATH_CORE . 'config/_databases_.php');
catch ( Exception $e ) {
echo $e->getMessage ();
eprintln ( "Probelm in workspace: " . $sObject . ' it was omitted.', 'red' );
}
eprintln ();
unlink ( PATH_CORE . 'config/_databases_.php' );
}
}
}
else {
processWorkspace();
processWorkspace ();
}
//finally update the file
//@file_put_contents(PATH_DATA . 'cron', serialize(array('bCronIsRunning' => '0', 'sLastExecution' => date('Y-m-d H:i:s'))));
// finally update the file
// @file_put_contents(PATH_DATA . 'cron', serialize(array('bCronIsRunning' =>
// '0', 'sLastExecution' => date('Y-m-d H:i:s'))));
function processWorkspace() {
global $sLastExecution;
G::LoadClass('AppSolr');
try {
$oAppSolr = new AppSolr();
if ($oAppSolr->isSolrEnabled()) {
$oAppSolr->reindexAllApplications();
//$data = $ApplicationSolrIndex->getAppGridData($start, $limit, $action, $filter, $search, $process, $user, $status, $type, $dateFrom, $dateTo, $callback, $dir, $sort);
//$result = G::json_encode($data);
}
if ($solrConf = System::solrEnv () !== false) {
G::LoadClass ( 'AppSolr' );
$oAppSolr = new AppSolr ( $solrConf ['solr_enabled'], $solrConf ['solr_host'], $solrConf ['solr_instance'] );
$oAppSolr->reindexAllApplications ();
}
else {
print "Incomplete Solr configuration.";
}
}
catch (Exception $oError) {
saveLog ("main", "error", "Error processing workspace : " . $oError->getMessage() . "\n" );
catch ( Exception $oError ) {
saveLog ( "main", "error", "Error processing workspace : " . $oError->getMessage () . "\n" );
}
}
function saveLog($sSource, $sType, $sDescription) {
try {
global $isDebug;
if ( $isDebug )
print date('H:i:s') ." ($sSource) $sType $sDescription <br>\n";
@fwrite($oFile, date('Y-m-d H:i:s') . '(' . $sSource . ') ' . $sDescription . "\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" );
G::verifyPath(PATH_DATA . 'log' . PATH_SEP, true);
G::verifyPath ( PATH_DATA . 'log' . PATH_SEP, true );
if ($sType == 'action') {
$oFile = @fopen(PATH_DATA . 'log' . PATH_SEP . 'cron.log', 'a+');
$oFile = @fopen ( PATH_DATA . 'log' . PATH_SEP . 'cron.log', 'a+' );
}
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");
@fclose($oFile);
@fwrite ( $oFile, date ( 'Y-m-d H:i:s' ) . '(' . $sSource . ') ' . $sDescription . "\n" );
@fclose ( $oFile );
}
catch (Exception $oError) {
//CONTINUE
catch ( Exception $oError ) {
// CONTINUE
}
}
function setExecutionMessage($m){
$len = strlen($m);
function setExecutionMessage($m) {
$len = strlen ( $m );
$linesize = 60;
$rOffset = $linesize - $len;
eprint("* $m");
for($i=0; $i<$rOffset; $i++) eprint('.');
eprint ( "* $m" );
for($i = 0; $i < $rOffset; $i ++)
eprint ( '.' );
}
function setExecutionResultMessage($m, $t=''){
$c='green';
if($t=='error') $c = 'red';
if($t=='info') $c = 'yellow';
eprintln("[$m]", $c);
function setExecutionResultMessage($m, $t = '') {
$c = 'green';
if ($t == 'error')
$c = 'red';
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/AppSolrQueue.php";
require_once "classes/model/AppSolrQueue.php";
require_once PATH_DATA_SITE . "/solr.php";
class InvalidIndexSearchTextException extends Exception {
// Redefine the exception so message isn't optional
@@ -33,11 +32,11 @@ class AppSolr {
private $solrHost = "";
private $solrInstance = "";
function __construct() {
function __construct($SolrEnabled, $SolrHost, $SolrInstance) {
// define solr availability
$this->solrIsEnabled = SOLR_ENABLED;
$this->solrHost = SOLR_HOST;
$this->solrInstance = SOLR_INSTANCE;
$this->solrIsEnabled = $SolrEnabled;
$this->solrHost = $SolrHost;
$this->solrInstance = $SolrInstance;
}
public function isSolrEnabled() {

View File

@@ -67,6 +67,16 @@ G::LoadClass('pmScript');
*/
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
* @param string $sUIDUser
@@ -833,9 +843,7 @@ class Cases {
*/
function updateCase($sAppUid, $Fields = array()) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try {
$aApplicationFields = $Fields['APP_DATA'];
$Fields['APP_UID'] = $sAppUid;
@@ -890,7 +898,7 @@ class Cases {
//now update the priority in appdelegation table, using the defined variable in task
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->clearSelectColumns();
$c->addSelectColumn(TaskPeer::TAS_PRIORITY_VARIABLE);
@@ -909,22 +917,19 @@ class Cases {
$x = unserialize($Fields['APP_DATA']);
if (isset($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;
$array = array();
$array['APP_UID'] = $sAppUid;
$array['DEL_INDEX'] = $DEL_INDEX;
$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);
}
}
}
//Update Solr Index
$appSolr->updateApplicationSearchIndex($sAppUid);
if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sAppUid);
return $Fields;
}
@@ -942,9 +947,7 @@ class Cases {
*/
function removeCase($sAppUid) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try {
$oApplication = new Application();
$oAppDelegation = new AppDelegation();
@@ -1001,7 +1004,8 @@ class Cases {
$result = $oApp->remove($sAppUid);
//delete application from index
$appSolr->deleteApplicationSearchIndex($sAppUid);
if($this->appSolr != null)
$this->appSolr->deleteApplicationSearchIndex($sAppUid);
return $result;
} catch (exception $e) {
@@ -1019,15 +1023,14 @@ class Cases {
*/
function setDelInitDate($sAppUid, $iDelIndex) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try {
$oAppDel = AppDelegationPeer::retrieveByPk($sAppUid, $iDelIndex);
$oAppDel->setDelInitDate("now");
$oAppDel->save();
//update searchindex
$appSolr->updateApplicationSearchIndex($sAppUid);
if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sAppUid);
} catch (exception $e) {
throw ($e);
}
@@ -1044,17 +1047,15 @@ class Cases {
*/
function setCatchUser($sAppUid, $iDelIndex, $usrId) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try {
$oAppDel = AppDelegationPeer::retrieveByPk($sAppUid, $iDelIndex);
$oAppDel->setDelInitDate("now");
$oAppDel->setUsrUid($usrId);
$oAppDel->save();
//update searchindex
$appSolr->updateApplicationSearchIndex($sAppUid);
//update searchindex
if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sAppUid);
} catch (exception $e) {
throw ($e);
}
@@ -1460,14 +1461,13 @@ class Cases {
*/
function newAppDelegation($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sPrevious, $iPriority, $sDelType, $iAppThreadIndex = 1, $nextDel=null) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try {
$appDel = new AppDelegation();
$result = $appDel->createAppDelegation($sProUid, $sAppUid, $sTasUid, $sUsrUid, $iAppThreadIndex, $iPriority, false, $sPrevious, $nextDel);
//update searchindex
$appSolr->updateApplicationSearchIndex($sAppUid);
//update searchindex
if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sAppUid);
return $result;
}
catch (exception $e) {
@@ -1487,9 +1487,7 @@ class Cases {
*/
function updateAppDelegation($sAppUid, $iDelIndex, $iAppThreadIndex) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try {
$appDelegation = new AppDelegation();
$aData = array();
@@ -1499,7 +1497,8 @@ class Cases {
$appDelegation->update($aData);
//update searchindex
$appSolr->updateApplicationSearchIndex($sAppUid);
if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sAppUid);
return true;
} catch (exception $e) {
@@ -1576,9 +1575,6 @@ class Cases {
*/
function updateAppThread($sAppUid, $iAppThreadIndex, $iNewDelIndex) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try {
/// updating the DEL_INDEX value in the APP_THREAD
$con = Propel::getConnection('workflow');
@@ -1598,8 +1594,9 @@ class Cases {
$aData['DEL_INDEX'] = $iNewDelIndex;
$appThread->update($aData);
*/
//update searchindex
$appSolr->updateApplicationSearchIndex($sAppUid);
//update searchindex
if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sAppUid);
return $iNewDelIndex;
}
@@ -1618,9 +1615,6 @@ class Cases {
*/
function closeAppThread($sAppUid, $iAppThreadIndex) {
// //initialize solrindex object called from other functions
// G::LoadClass('AppSolr');
// $appSolr = new AppSolr();
try {
$appThread = new AppThread();
$aData = array();
@@ -1629,8 +1623,6 @@ class Cases {
$aData['APP_THREAD_STATUS'] = 'CLOSED';
$appThread->update($aData);
// //update searchindex
// $appSolr->updateApplicationSearchIndex($sAppUid);
return true;
} catch (exception $e) {
throw ($e);
@@ -1646,9 +1638,6 @@ class Cases {
*/
function closeAllThreads($sAppUid) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try {
//Execute('UPDATE APP_DELEGATION SET DEL_THREAD_STATUS="CLOSED" WHERE APP_UID="$sAppUid" AND DEL_THREAD_STATUS="OPEN"');
$c = new Criteria();
@@ -1666,8 +1655,9 @@ class Cases {
throw (new PropelException('The row cannot be created!', new PropelException($msg)));
}
}
//update searchindex
$appSolr->updateApplicationSearchIndex($sAppUid);
//update searchindex
if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sAppUid);
} catch (exception $e) {
throw ($e);
}
@@ -1685,14 +1675,12 @@ class Cases {
*/
function newAppThread($sAppUid, $iNewDelIndex, $iAppParent) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try {
$appThread = new AppThread();
$result = $appThread->createAppThread($sAppUid, $iNewDelIndex, $iAppParent);
//update searchindex
$appSolr->updateApplicationSearchIndex($sAppUid);
//update searchindex
if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sAppUid);
return $result;
} catch (exception $e) {
throw ($e);
@@ -1708,9 +1696,6 @@ class Cases {
*/
function closeAllDelegations($sAppUid) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try {
//Execute('UPDATE APP_DELEGATION SET DEL_THREAD_STATUS="CLOSED" WHERE APP_UID="$sAppUid" AND DEL_THREAD_STATUS="OPEN"');
$c = new Criteria();
@@ -1728,8 +1713,9 @@ class Cases {
throw (new PropelException('The row cannot be created!', new PropelException($msg)));
}
}
//update searchindex
$appSolr->updateApplicationSearchIndex($sAppUid);
//update searchindex
if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sAppUid);
} catch (exception $e) {
throw ($e);
}
@@ -1745,10 +1731,6 @@ class Cases {
*/
function CloseCurrentDelegation($sAppUid, $iDelIndex) {
//called from other functions
// //initialize solrindex object
// G::LoadClass('AppSolr');
// $appSolr = new AppSolr();
try {
//Execute('UPDATE APP_DELEGATION SET DEL_THREAD_STATUS="CLOSED" WHERE APP_UID="$sAppUid" AND DEL_THREAD_STATUS="OPEN"');
$c = new Criteria();
@@ -1770,8 +1752,6 @@ class Cases {
throw (new PropelException('The row cannot be created!', new PropelException($msg)));
}
}
// //update searchindex
// $appSolr->updateApplicationSearchIndex($sAppUid);
} catch (exception $e) {
throw ($e);
@@ -1789,9 +1769,6 @@ class Cases {
*/
function ReactivateCurrentDelegation($sAppUid, $iDelegation) {
// //initialize solrindex object called from other function
// G::LoadClass('AppSolr');
// $appSolr = new AppSolr();
try {
$c = new Criteria();
$c->add(AppDelegationPeer::APP_UID, $sAppUid);
@@ -1810,8 +1787,6 @@ class Cases {
throw (new PropelException('The row cannot be created!', new PropelException($msg)));
}
}
// //update searchindex
// $appSolr->updateApplicationSearchIndex($sAppUid);
} catch (exception $e) {
throw ($e);
}
@@ -1829,9 +1804,6 @@ class Cases {
function startCase($sTasUid, $sUsrUid, $isSubprocess=false) {
if ($sTasUid != '') {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
try {
$this->Task = new Task;
@@ -1874,8 +1846,9 @@ class Cases {
G::LoadClass('derivation');
$oDerivation = new Derivation();
$oDerivation->setTasLastAssigned($sTasUid, $sUsrUid);
//update searchindex
$appSolr->updateApplicationSearchIndex($sAppUid);
//update searchindex
if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sAppUid);
} catch (exception $e) {
throw ($e);
}
@@ -3422,9 +3395,6 @@ class Cases {
*/
function pauseCase($sApplicationUID, $iDelegation, $sUserUID, $sUnpauseDate = null) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
$this->CloseCurrentDelegation($sApplicationUID, $iDelegation);
$oApplication = new Application();
@@ -3454,8 +3424,9 @@ class Cases {
$oAppDelay = new AppDelay();
$oAppDelay->create($aData);
//update searchindex
$appSolr->updateApplicationSearchIndex($sApplicationUID);
//update searchindex
if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sApplicationUID);
}
/*
@@ -3516,8 +3487,9 @@ class Cases {
$oAppDelay = new AppDelay();
$aFieldsDelay = $oAppDelay->update($aData);
//update searchindex
$appSolr->updateApplicationSearchIndex($sApplicationUID);
//update searchindex
if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sApplicationUID);
}
/*
@@ -3531,9 +3503,6 @@ class Cases {
*/
function cancelCase($sApplicationUID, $iIndex, $user_logged) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
$oApplication = new Application();
$aFields = $oApplication->load($sApplicationUID);
@@ -3592,8 +3561,9 @@ class Cases {
$oDerivation->verifyIsCaseChild($sApplicationUID);
}
//update searchindex
$appSolr->updateApplicationSearchIndex($sApplicationUID);
//update searchindex
if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sApplicationUID);
}
/*
@@ -3607,9 +3577,6 @@ class Cases {
*/
function reactivateCase($sApplicationUID, $iIndex, $user_logged) {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
$oApplication = new Application();
$aFields = $oApplication->load((isset($_POST['sApplicationUID']) ? $_POST['sApplicationUID'] : $_SESSION['APPLICATION']));
@@ -3645,8 +3612,9 @@ class Cases {
$stmt = $con->createStatement();
$rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
//update searchindex
$appSolr->updateApplicationSearchIndex($sApplicationUID);
//update searchindex
if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sApplicationUID);
}
/*
@@ -3662,9 +3630,6 @@ class Cases {
*/
function reassignCase($sApplicationUID, $iDelegation, $sUserUID, $newUserUID, $sType = 'REASSIGN') {
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
$this->CloseCurrentDelegation($sApplicationUID, $iDelegation);
$oAppDelegation = new AppDelegation();
@@ -3699,8 +3664,9 @@ class Cases {
$oAppDelay = new AppDelay();
$oAppDelay->create($aData);
//update searchindex
$appSolr->updateApplicationSearchIndex($sApplicationUID);
//update searchindex
if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($sApplicationUID);
return true;
}
@@ -5153,9 +5119,6 @@ class Cases {
*/
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
$Fields = $this->loadCase($sApplication);
@@ -5174,8 +5137,6 @@ class Cases {
$aData['TAS_UID'] = $sTask;
$this->updateCase($sApplication, $aData);
// //update searchindex
// $appSolr->updateApplicationSearchIndex($sApplication);
}
/*
@@ -5528,9 +5489,6 @@ class Cases {
}
function discriminateCases($aData){
//initialize solrindex object
G::LoadClass('AppSolr');
$appSolr = new AppSolr();
$siblingThreadData = $this->GetAllOpenDelegation($aData);
foreach($siblingThreadData as $thread => $threadData)
@@ -5538,8 +5496,9 @@ class Cases {
$this->closeAppThread ( $aData['APP_UID'], $threadData['DEL_INDEX']); //Close Sibling AppThreads
$this->CloseCurrentDelegation ($aData['APP_UID'], $threadData['DEL_INDEX']); //Close Sibling AppDelegations
//update searchindex
$appSolr->updateApplicationSearchIndex($aData['APP_UID']);
//update searchindex
if($this->appSolr != null)
$this->appSolr->updateApplicationSearchIndex($aData['APP_UID']);
}
}
@@ -5656,48 +5615,4 @@ class Cases {
$response['array']=$rows;
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;
}
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(
'debug' => 0,
'debug_sql' => 0,
'debug_time' => 0,
'debug_calendar' => 0,
'wsdl_cache' => 1,
'memory_limit' => '100M',
'time_zone' => 'America/La_Paz',
'memcached' => 0,
'memcached_server' => '',
'default_skin' => 'classic',
'default_lang' => 'en'
'debug' => 0,
'debug_sql' => 0,
'debug_time' => 0,
'debug_calendar' => 0,
'wsdl_cache' => 1,
'memory_limit' => '100M',
'time_zone' => 'America/La_Paz',
'memcached' => 0,
'memcached_server' =>'',
'default_skin' => 'classic',
'default_lang' => 'en'
);
// read the global env.ini configuration file
if ($readGlobalIniFile && ($globalConf = @parse_ini_file($globalIniFile)) !== false) {
$config = array_merge($config, $globalConf);
if (empty($iniFile) || !file_exists($iniFile)) {
return $config;
}
/* Read the env.ini */
$ini_contents = parse_ini_file($iniFile, false);
// Workspace environment configuration
if ($readWsIniFile && ($wsConf = @parse_ini_file($wsIniFile)) !== false) {
$config = array_merge($config, $wsConf);
if ($ini_contents !== false) {
$config = array_merge($config, $ini_contents);
}
// 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;
$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;
}
@@ -1121,4 +1071,23 @@ class System {
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

View File

@@ -40,7 +40,7 @@ class Entity_Base {
protected function validateRequiredFields($requiredFields = array()) {
foreach ( $requiredFields as $k => $field ) {
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 ();
}
}

View File

@@ -1,44 +1,46 @@
<?php
<?php
// getting the extJs parameters
$callback = isset($_POST['callback']) ? $_POST['callback'] : 'stcCallback1001';
$dir = isset($_POST['dir']) ? $_POST['dir'] : 'DESC';
$sort = isset($_POST['sort']) ? $_POST['sort'] : '';
$start = isset($_POST['start']) ? $_POST['start'] : '0';
$limit = isset($_POST['limit']) ? $_POST['limit'] : '25';
$filter = isset($_POST['filter']) ? $_POST['filter'] : '';
$search = isset($_POST['search']) ? $_POST['search'] : '';
$process = isset($_POST['process']) ? $_POST['process'] : '';
$user = isset($_POST['user']) ? $_POST['user'] : '';
$status = isset($_POST['status']) ? strtoupper($_POST['status']) : '';
$action = isset($_GET['action']) ? $_GET['action'] : (isset($_POST['action']) ? $_POST['action'] : 'todo');
$type = isset($_GET['type']) ? $_GET['type'] : (isset($_POST['type']) ? $_POST['type'] : 'extjs');
$user = isset($_POST['user']) ? $_POST['user'] : '';
$dateFrom = isset($_POST['dateFrom'])? substr($_POST['dateFrom'],0,10) : '';
$dateTo = isset($_POST['dateTo']) ? substr($_POST['dateTo'],0,10) : '';
// getting the extJs parameters
$callback = isset ( $_POST ['callback'] ) ? $_POST ['callback'] : 'stcCallback1001';
$dir = isset ( $_POST ['dir'] ) ? $_POST ['dir'] : 'DESC';
$sort = isset ( $_POST ['sort'] ) ? $_POST ['sort'] : '';
$start = isset ( $_POST ['start'] ) ? $_POST ['start'] : '0';
$limit = isset ( $_POST ['limit'] ) ? $_POST ['limit'] : '25';
$filter = isset ( $_POST ['filter'] ) ? $_POST ['filter'] : '';
$search = isset ( $_POST ['search'] ) ? $_POST ['search'] : '';
$process = isset ( $_POST ['process'] ) ? $_POST ['process'] : '';
$user = isset ( $_POST ['user'] ) ? $_POST ['user'] : '';
$status = isset ( $_POST ['status'] ) ? strtoupper ( $_POST ['status'] ) : '';
$action = isset ( $_GET ['action'] ) ? $_GET ['action'] : (isset ( $_POST ['action'] ) ? $_POST ['action'] : 'todo');
$type = isset ( $_GET ['type'] ) ? $_GET ['type'] : (isset ( $_POST ['type'] ) ? $_POST ['type'] : 'extjs');
$user = isset ( $_POST ['user'] ) ? $_POST ['user'] : '';
$dateFrom = isset ( $_POST ['dateFrom'] ) ? substr ( $_POST ['dateFrom'], 0, 10 ) : '';
$dateTo = isset ( $_POST ['dateTo'] ) ? substr ( $_POST ['dateTo'], 0, 10 ) : '';
try {
$result ="";
try {
$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');
$ApplicationSolrIndex = new AppSolr();
$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;
$data = $ApplicationSolrIndex->getAppGridData ( $userUid, $start, $limit, $action, $filter, $search, $process, $user, $status, $type, $dateFrom, $dateTo, $callback, $dir, $sort );
$result = G::json_encode ( $data );
}
catch ( Exception $e ) {
$msg = array ( 'error' => $e->getMessage() );
print G::json_encode( $msg ) ;
}
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 ) {
$msg = array (
'error' => $e->getMessage ()
);
print G::json_encode ( $msg );
}