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

Commit

Permalink
Merge pull request #120 from jamiesnape/module-model
Browse files Browse the repository at this point in the history
Move core and module version information and settings to database
  • Loading branch information
jamiesnape committed Sep 14, 2015
2 parents e874fbe + e339363 commit 04e315f
Show file tree
Hide file tree
Showing 82 changed files with 2,584 additions and 855 deletions.
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"ext-json": "*",
"erusev/parsedown-extra": "~0.7",
"francodacosta/phmagick": "0.4.*@dev",
"intervention/image": "~2.2",
"intervention/image": "~2.3",
"ircmaxell/random-lib": "~1.1",
"leafo/scssphp": "~0.1",
"leafo/scssphp": "~0.2",
"maennchen/zipstream-php": "~0.3",
"moontoast/math": "~1.1",
"ramsey/uuid": "~2.8",
Expand All @@ -28,15 +28,15 @@
"require-dev": {
"ext-curl": "*",
"ext-xdebug": "*",
"fabpot/php-cs-fixer": "~1.8",
"fabpot/php-cs-fixer": "~1.10",
"jokkedk/zfdebug": "~1.6",
"phpcheckstyle/phpcheckstyle": "V0.14.1",
"phpunit/dbunit": "~1.3",
"phpunit/dbunit": "~1.4",
"phpunit/phpcov": "~2.0",
"phpunit/phpunit": "~4.6",
"phpunit/phpunit": "~4.8",
"satooshi/php-coveralls": "~0.6",
"sensiolabs/security-checker": "~2.0",
"symfony/console": "~2.6"
"sensiolabs/security-checker": "~3.0",
"symfony/console": "~2.7"
},
"suggest": {
"ext-fileinfo": "*",
Expand Down
47 changes: 30 additions & 17 deletions core/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ 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
$this->view->version = '3.2.8';
if (isset(Zend_Registry::get('configDatabase')->version)) {
$this->view->version = Zend_Registry::get('configDatabase')->version;
}
$version = UtilityComponent::getCurrentModuleVersion('core');
$this->view->version = $version !== false ? $version : '3.4.x';

require_once BASE_PATH.'/core/models/dao/UserDao.php';
require_once BASE_PATH.'/core/models/dao/ItemDao.php';
Expand All @@ -84,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 @@ -96,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 @@ -127,7 +127,10 @@ public function preDispatch()
if ($userDao != false) {
// authenticate valid users in the appropriate method for the
// current application version
if (version_compare(Zend_Registry::get('configDatabase')->version, '3.2.12', '>=')) {
if ($version === false) {
throw new Zend_Exception('Core version is undefined.');
}
if (version_compare($version, '3.2.12', '>=')) {
$auth = $userModel->hashExists($tmp[1]);
} else {
$auth = $userModel->legacyAuthenticate($userDao, '', '', $tmp[1]);
Expand Down Expand Up @@ -192,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 @@ -204,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 @@ -335,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 @@ -350,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 @@ -403,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 @@ -473,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 Expand Up @@ -604,6 +614,9 @@ protected function t($text)
/** @var MetadataModel */
public $Metadata;

/** @var ModuleModel */
public $Module;

/** @var NewUserInvitationModel */
public $NewUserInvitation;

Expand Down
Loading

0 comments on commit 04e315f

Please sign in to comment.