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

Commit 494120b

Browse files
author
Jamie Snape
committed
Move all settings to database and ensure settings are cast to the correct type
1 parent 48b2593 commit 494120b

File tree

50 files changed

+562
-426
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+562
-426
lines changed

core/AppController.php

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ public function preDispatch()
6363
Zend_Registry::set('webroot', $this->view->webroot);
6464
Zend_Registry::set('coreWebroot', $this->view->coreWebroot);
6565

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

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

8385
// log in when testing
8486
$testingUserId = $this->getParam('testingUserId');
85-
if (Zend_Registry::get('configGlobal')->environment == 'testing' && isset($testingUserId)
87+
if (Zend_Registry::get('configGlobal')->get('environment', 'production') === 'testing' && isset($testingUserId)
8688
) {
8789
$user = new Zend_Session_Namespace('Auth_User_Testing');
8890

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

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

196-
$this->view->lang = Zend_Registry::get('configGlobal')->application->lang;
198+
if ((int) Zend_Registry::get('configGlobal')->get('internationalization', 0) === 1) {
199+
$this->view->lang = $settingModel->getValueByNameWithDefault('language', 'en');
200+
} else {
201+
$this->view->lang = 'en';
202+
}
197203

198204
$this->view->isStartingGuide = $this->isStartingGuide();
199205
$this->view->isDynamicHelp = $this->isDynamicHelp();
@@ -205,7 +211,7 @@ public function preDispatch()
205211
'logged' => $this->logged,
206212
'needToLog' => false,
207213
'currentUri' => $this->getRequest()->REQUEST_URI,
208-
'lang' => Zend_Registry::get('configGlobal')->application->lang,
214+
'lang' => $this->view->lang,
209215
'dynamichelp' => $this->isDynamicHelp(),
210216
'dynamichelpAnimate' => $this->isDynamicHelp() && isset($_GET['first']),
211217
'startingGuide' => $this->isStartingGuide(),
@@ -336,7 +342,7 @@ public function preDispatch()
336342
}
337343

338344
// If there is an outbound HTTP proxy configured on this server, set it up here
339-
$httpProxy = Zend_Registry::get('configGlobal')->httpproxy;
345+
$httpProxy = Zend_Registry::get('configGlobal')->get('http_proxy', false);
340346
if ($httpProxy) {
341347
$opts = array('http' => array('proxy' => $httpProxy));
342348
stream_context_set_default($opts);
@@ -351,15 +357,18 @@ public function preDispatch()
351357
public function isDynamicHelp()
352358
{
353359
try {
354-
$dynamichelp = Zend_Registry::get('configGlobal')->dynamichelp;
355-
if ($dynamichelp && $this->userSession != null) {
360+
/** @var SettingModel $settingModel */
361+
$settingModel = MidasLoader::loadModel('Setting');
362+
$dynamicHelp = $settingModel->getValueByNameWithDefault('dynamic_help', 0);
363+
364+
if ($dynamicHelp && $this->userSession != null) {
356365
$userDao = $this->userSession->Dao;
357366
if ($userDao != null && $userDao instanceof UserDao) {
358367
return $userDao->getDynamichelp() == 1;
359368
}
360369
}
361370

362-
return $dynamichelp == 1;
371+
return $dynamicHelp == 1;
363372
} catch (Zend_Exception $exc) {
364373
$this->getLogger()->warn($exc->getMessage());
365374

@@ -404,7 +413,7 @@ public function getServerURL()
404413
*/
405414
public function isTestingEnv()
406415
{
407-
return Zend_Registry::get('configGlobal')->environment == 'testing';
416+
return Zend_Registry::get('configGlobal')->get('environment', 'production') === 'testing';
408417
}
409418

410419
/**
@@ -474,7 +483,7 @@ public function postDispatch()
474483
{
475484
parent::postDispatch();
476485
$this->view->json = JsonComponent::encode($this->view->json);
477-
if (Zend_Registry::get('configGlobal')->environment != 'testing') {
486+
if (Zend_Registry::get('configGlobal')->get('environment', 'production') !== 'testing') {
478487
header('Content-Type: text/html; charset=UTF-8');
479488
}
480489
if ($this->progressDao != null) {

0 commit comments

Comments
 (0)