Skip to content

Commit

Permalink
making changes to default action
Browse files Browse the repository at this point in the history
reorders config file loading sequence o support custom code in config file.
  • Loading branch information
padams committed Jan 20, 2010
1 parent 561acbe commit 1b6052e
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 49 deletions.
118 changes: 70 additions & 48 deletions modules/base/classes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,16 @@ function owa_settings() {

function __construct() {

// include/load config file
$this->loadConfigFile();
// create configuration object
$this->config = owa_coreAPI::rawEntityFactory('base.configuration');
// load the default settings
$this->getDefaultConfig();
// include/load config file
$this->loadConfigFile();
// apply config constants
$this->applyConfigConstants();
// setup directory paths
$this->setupPaths();

// set default timezone
if (function_exists('date_default_timezone_set')) {
Expand Down Expand Up @@ -171,6 +173,14 @@ function applyConfigConstants() {
$this->set('base', 'do_not_fetch_config_from_db', OWA_CONFIG_DO_NOT_FETCH_FROM_DB);
}

if (defined('OWA_PUBLIC_URL')) {
$this->set('base', 'public_url', OWA_PUBLIC_URL);
}

if (defined('OWA_PUBLIC_PATH')) {
$this->set('base', 'public_path', OWA_PUBLIC_PATH);
}

}

function applyModuleOverrides($module, $config) {
Expand Down Expand Up @@ -525,12 +535,14 @@ function getDefaultConfig() {
'templates_dir' => OWA_BASE_DIR . '/templates/',
'plugin_dir' => OWA_BASE_DIR . '/plugins/',
'module_dir' => OWA_BASE_DIR . '/modules',
'public_path' => '',
'geolocation_lookup' => true,
'geolocation_service' => 'hostip',
'report_wrapper' => 'wrapper_default.tpl',
'do_not_fetch_config_from_db' => false,
'announce_visitors' => false,
'public_url' => '',
'base_url' => '',
'action_url' => '',
'images_url' => '',
'reporting_url' => '',
Expand Down Expand Up @@ -574,58 +586,16 @@ function getDefaultConfig() {
'start_page' => 'base.reportDashboard',
'default_action' => 'base.loginForm',
'capabilities' => array('admin' => array('view_reports',
'edit_settings',
'edit_sites',
'edit_users',
'edit_modules'),
'edit_settings',
'edit_sites',
'edit_users',
'edit_modules'),
'analyst' => array('view_reports'),
'viewer' => array('view_reports'),
'everyone' => array())

));

$base_url = "http";

if(isset($_SERVER['HTTPS'])):
$base_url .= 's';
endif;

$base_url .= '://'.$_SERVER['SERVER_NAME'];

if($_SERVER['SERVER_PORT'] != 80):
$base_url .= ':'.$_SERVER['SERVER_PORT'];
endif;

if (!defined('OWA_PUBLIC_URL')) {
define('OWA_PUBLIC_URL', '');
}

$config['base']['base_url'] = $base_url;
$config['base']['public_url'] = OWA_PUBLIC_URL;

if (defined('OWA_PUBLIC_PATH')):
$config['base']['public_path'] = OWA_PUBLIC_PATH;
else:
$config['base']['public_path'] = OWA_PATH.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR;
endif;

$config['base']['main_url'] = OWA_PUBLIC_URL.'index.php';
$config['base']['main_absolute_url'] = $config['base']['main_url'];
$config['base']['modules_url'] = OWA_PUBLIC_URL.'modules'.DIRECTORY_SEPARATOR;
$config['base']['action_url'] = OWA_PUBLIC_URL.'action.php';;
$config['base']['images_url'] = $config['base']['modules_url'];
$config['base']['images_absolute_url'] = $config['base']['modules_url'];
$config['base']['log_url'] = OWA_PUBLIC_URL.'log.php';


// Set cookie domain
if (!empty($_SERVER['HTTP_HOST'])):
$config['base']['cookie_domain'] = $_SERVER['HTTP_HOST'];
else:
$config['base']['cookie_domain'] = $_SERVER['SERVER_NAME'];
endif;


// set default values
$this->config->set('settings', $config);

Expand All @@ -634,6 +604,58 @@ function getDefaultConfig() {

}

function setupPaths() {

//build base url
$base_url = "http";

if(isset($_SERVER['HTTPS'])) {
$base_url .= 's';
}

$base_url .= '://'.$_SERVER['SERVER_NAME'];

if($_SERVER['SERVER_PORT'] != 80) {
$base_url .= ':'.$_SERVER['SERVER_PORT'];
}

// there is some plugin use case where this is needed i think. if not get rid of it.
if (!defined('OWA_PUBLIC_URL')) {
define('OWA_PUBLIC_URL', '');
}

// set base url
$this->set('base', 'base_url', $base_url);

//set public path if not defined in config file
$public_path = $this->get('base', 'public_path');

if (empty($public_path)) {
$public_path = OWA_PATH.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR;
$this->set('base','public_path', $public_path);
}

// set various paths
$public_url = $this->get('base', 'public_url');
$main_url = $public_url.'index.php';
$this->set('base','main_url', $main_url);
$this->set('base','main_absolute_url', $main_url);
$modules_url = $public_url.'modules'.DIRECTORY_SEPARATOR;
$this->set('base','modules_url', $modules_url);
$this->set('base','action_url',$public_url.'action.php');
$this->set('base','images_url', $modules_url);
$this->set('base','images_absolute_url',$modules_url);
$this->set('base','log_url',$public_url.'log.php');

// Set cookie domain
if (!empty($_SERVER['HTTP_HOST'])) {
$this->set('base','cookie_domain', $_SERVER['HTTP_HOST']);
} else {
$this->set('base','cookie_domain', $_SERVER['SERVER_NAME']);
}

}

function createConfigFile($config_values) {

if (file_exists(OWA_DIR.'owa-config.php')) {
Expand Down
2 changes: 1 addition & 1 deletion owa_coreAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ function handleRequest($caller_params = null, $action = '') {
$action = owa_coreAPI::getRequestParam('do');

if (empty($action)) {
$action = owa_coreAPI::getSetting('base', 'default_action');
$action = owa_coreAPI::getSetting('base', 'start_page');
}
}
}
Expand Down

0 comments on commit 1b6052e

Please sign in to comment.