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

Commit

Permalink
Store default asset store id in database
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Snape committed Dec 12, 2014
1 parent c22cd88 commit a4c1a86
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 0 additions & 2 deletions core/configs/application.ini
Expand Up @@ -11,8 +11,6 @@ application.description =
application.lang = "en"
; session lifetime (minutes)
session.lifetime = "20"
; default asset store
defaultassetstore.id =
; default time zone
default.timezone = "America/New_York"
; default license
Expand Down
4 changes: 2 additions & 2 deletions core/controllers/AdminController.php
Expand Up @@ -23,7 +23,7 @@
*/
class AdminController extends AppController
{
public $_models = array('Assetstore', 'Bitstream', 'Item', 'ItemRevision', 'Folder', 'License');
public $_models = array('Assetstore', 'Bitstream', 'Item', 'ItemRevision', 'Folder', 'License', 'Setting');
public $_daos = array();
public $_components = array('Upgrade', 'Utility', 'MIDAS2Migration');
public $_forms = array('Admin', 'Assetstore', 'Migrate');
Expand Down Expand Up @@ -187,7 +187,7 @@ public function indexAction()
if (!$defaultSet) {
foreach ($assetstores as $key => $assetstore) {
$assetstores[$key]->default = true;
$config->global->defaultassetstore->id = $assetstores[$key]->getKey();
$this->Setting->setConfig('default_assetstore', $assetstores[$key]->getKey());

$writer = new Zend_Config_Writer_Ini();
$writer->setConfig($config);
Expand Down
5 changes: 3 additions & 2 deletions core/controllers/InstallController.php
Expand Up @@ -23,7 +23,7 @@
*/
class InstallController extends AppController
{
public $_models = array('User', 'Assetstore');
public $_models = array('User', 'Assetstore', 'Setting');
public $_daos = array('Assetstore');
public $_components = array('Random', 'Utility');
public $_forms = array('Install');
Expand Down Expand Up @@ -268,14 +268,15 @@ public function step3Action()
$config->global->application->lang = $form->getValue('lang');
$config->global->application->name = $form->getValue('name');
$config->global->default->timezone = $form->getValue('timezone');
$config->global->defaultassetstore->id = $assetstores[0]->getKey();
$config->global->environment = 'production';

$writer = new Zend_Config_Writer_Ini();
$writer->setConfig($config);
$writer->setFilename(APPLICATION_CONFIG);
$writer->write();

$this->Setting->setConfig('default_assetstore', $assetstores[0]->getKey());

$this->redirect('/admin#tabs-modules');
}
}
Expand Down
5 changes: 4 additions & 1 deletion modules/demo/controllers/components/DemoComponent.php
Expand Up @@ -80,9 +80,12 @@ public function reset()
$assetstoreDao->setType(MIDAS_ASSETSTORE_LOCAL);
$assetstoreModel->save($assetstoreDao);

/** @var SettingModel $settingModel */
$settingModel = MidasLoader::loadModel('Setting');
$settingModel->setConfig('default_assetstore', $assetstoreDao->getKey());

$options = array('allowModifications' => true);
$config = new Zend_Config_Ini(CORE_CONFIGS_PATH.'/application.ini', null, $options);
$config->global->defaultassetstore->id = $assetstoreDao->getKey();
$config->global->dynamichelp = 1;
$config->global->environment = 'production';
$config->global->application->name = 'Midas Platform - Demo';
Expand Down

0 comments on commit a4c1a86

Please sign in to comment.