Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
Move all settings to database and ensure settings are cast to the cor…
Browse files Browse the repository at this point in the history
…rect type
  • Loading branch information
Jamie Snape committed Sep 14, 2015
1 parent 48b2593 commit 494120b
Show file tree
Hide file tree
Showing 50 changed files with 562 additions and 426 deletions.
33 changes: 21 additions & 12 deletions core/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ public function preDispatch()
Zend_Registry::set('webroot', $this->view->webroot);
Zend_Registry::set('coreWebroot', $this->view->coreWebroot);

$this->view->title = Zend_Registry::get('configGlobal')->application->name;
$this->view->metaDescription = Zend_Registry::get('configGlobal')->application->description;
/** @var SettingModel $settingModel */
$settingModel = MidasLoader::loadModel('Setting');
$this->view->title = $settingModel->getValueByNameWithDefault('title', 'Midas Platform - Digital Archiving System');
$this->view->metaDescription = $settingModel->getValueByNameWithDefault('description', '');

// Set the version
$version = UtilityComponent::getCurrentModuleVersion('core');
Expand All @@ -82,7 +84,7 @@ public function preDispatch()

// log in when testing
$testingUserId = $this->getParam('testingUserId');
if (Zend_Registry::get('configGlobal')->environment == 'testing' && isset($testingUserId)
if (Zend_Registry::get('configGlobal')->get('environment', 'production') === 'testing' && isset($testingUserId)
) {
$user = new Zend_Session_Namespace('Auth_User_Testing');

Expand All @@ -94,7 +96,7 @@ public function preDispatch()
}
} else {
$user = new Zend_Session_Namespace('Auth_User');
$user->setExpirationSeconds(60 * Zend_Registry::get('configGlobal')->session->lifetime);
$user->setExpirationSeconds(60 * (int) Zend_Registry::get('configGlobal')->get('session_lifetime', 20));
}

/** @var Zend_Controller_Request_Http $request */
Expand Down Expand Up @@ -193,7 +195,11 @@ public function preDispatch()
// init notifier
Zend_Registry::set('notifier', new MIDAS_Notifier($this->logged, $this->userSession));

$this->view->lang = Zend_Registry::get('configGlobal')->application->lang;
if ((int) Zend_Registry::get('configGlobal')->get('internationalization', 0) === 1) {
$this->view->lang = $settingModel->getValueByNameWithDefault('language', 'en');
} else {
$this->view->lang = 'en';
}

$this->view->isStartingGuide = $this->isStartingGuide();
$this->view->isDynamicHelp = $this->isDynamicHelp();
Expand All @@ -205,7 +211,7 @@ public function preDispatch()
'logged' => $this->logged,
'needToLog' => false,
'currentUri' => $this->getRequest()->REQUEST_URI,
'lang' => Zend_Registry::get('configGlobal')->application->lang,
'lang' => $this->view->lang,
'dynamichelp' => $this->isDynamicHelp(),
'dynamichelpAnimate' => $this->isDynamicHelp() && isset($_GET['first']),
'startingGuide' => $this->isStartingGuide(),
Expand Down Expand Up @@ -336,7 +342,7 @@ public function preDispatch()
}

// If there is an outbound HTTP proxy configured on this server, set it up here
$httpProxy = Zend_Registry::get('configGlobal')->httpproxy;
$httpProxy = Zend_Registry::get('configGlobal')->get('http_proxy', false);
if ($httpProxy) {
$opts = array('http' => array('proxy' => $httpProxy));
stream_context_set_default($opts);
Expand All @@ -351,15 +357,18 @@ public function preDispatch()
public function isDynamicHelp()
{
try {
$dynamichelp = Zend_Registry::get('configGlobal')->dynamichelp;
if ($dynamichelp && $this->userSession != null) {
/** @var SettingModel $settingModel */
$settingModel = MidasLoader::loadModel('Setting');
$dynamicHelp = $settingModel->getValueByNameWithDefault('dynamic_help', 0);

if ($dynamicHelp && $this->userSession != null) {
$userDao = $this->userSession->Dao;
if ($userDao != null && $userDao instanceof UserDao) {
return $userDao->getDynamichelp() == 1;
}
}

return $dynamichelp == 1;
return $dynamicHelp == 1;
} catch (Zend_Exception $exc) {
$this->getLogger()->warn($exc->getMessage());

Expand Down Expand Up @@ -404,7 +413,7 @@ public function getServerURL()
*/
public function isTestingEnv()
{
return Zend_Registry::get('configGlobal')->environment == 'testing';
return Zend_Registry::get('configGlobal')->get('environment', 'production') === 'testing';
}

/**
Expand Down Expand Up @@ -474,7 +483,7 @@ public function postDispatch()
{
parent::postDispatch();
$this->view->json = JsonComponent::encode($this->view->json);
if (Zend_Registry::get('configGlobal')->environment != 'testing') {
if (Zend_Registry::get('configGlobal')->get('environment', 'production') !== 'testing') {
header('Content-Type: text/html; charset=UTF-8');
}
if ($this->progressDao != null) {
Expand Down
Loading

0 comments on commit 494120b

Please sign in to comment.