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:
File diff suppressed because it is too large
Load Diff
@@ -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() {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
|
||||
@@ -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 ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user