diff --git a/application/controllers/InstallController.php b/application/controllers/InstallController.php index c5745e9..09d3fd5 100644 --- a/application/controllers/InstallController.php +++ b/application/controllers/InstallController.php @@ -204,8 +204,7 @@ class InstallController extends Msd_Controller_Action $form->getElement('pass_confirm')->getValidator('Identical')->setToken($postData['pass']); if ($form->isValid($postData)) { $ini = new Msd_Ini(); - $ini->set('name', $postData['user'], 'user'); - $ini->set('pass', md5($postData['pass']), 'user'); + $ini->set('user[\'' . $postData['user'] . '\']', md5($postData['pass']), 'users'); $ini->saveFile(APPLICATION_PATH . '/configs/users.ini'); $redirectUrl = $this->view->url(array('controller' => 'install', 'action' => 'step4'), null, true); $this->_response->setRedirect($redirectUrl); diff --git a/library/Msd/Action/Helper/AssignConfigAndLanguage.php b/library/Msd/Action/Helper/AssignConfigAndLanguage.php index a7b00a4..bfb9673 100644 --- a/library/Msd/Action/Helper/AssignConfigAndLanguage.php +++ b/library/Msd/Action/Helper/AssignConfigAndLanguage.php @@ -39,15 +39,26 @@ class Msd_Action_Helper_AssignConfigAndLanguage extends Zend_Controller_Action_H $view = $this->getView(); $config = Msd_Registry::getConfig(); if ($config->getParam('configFile', 'defaultConfig.ini') == 'defaultConfig.ini') { - $redirectUrl = $view->serverUrl() . $view->url( - array( - 'controller' => 'install', - 'action' => 'index', - null, - true) - ); - $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); - $redirector->gotoUrl($redirectUrl); + $configFiles = Msd_File::getConfigNames(); + if (isset($configFiles[0])) { + // we do have saved configurations - load the first one + $config->load($configFiles[0]); + Msd_Registry::setConfig($config); + $dynamicConfig = Msd_Registry::getDynamicConfig(); + $dynamicConfig->setParam('configFile', $configFiles[0]); + Msd_Registry::setDynamicConfig($dynamicConfig); + } else { + // nothing found -> redirect to installation + $redirectUrl = $view->serverUrl() . $view->url( + array( + 'controller' => 'install', + 'action' => 'index', + null, + true) + ); + $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); + $redirector->gotoUrl($redirectUrl); + } } $view->config = $config; $view->dynamicConfig = Msd_Registry::getDynamicConfig(); diff --git a/library/Msd/Auth/Adapter/Ini.php b/library/Msd/Auth/Adapter/Ini.php index 4057e1a..cd664ed 100644 --- a/library/Msd/Auth/Adapter/Ini.php +++ b/library/Msd/Auth/Adapter/Ini.php @@ -65,7 +65,7 @@ class Msd_Auth_Adapter_Ini implements Zend_Auth_Adapter_Interface */ public function setUsername($username) { - $this->_username = (string) $username; + $this->_username = (string)$username; } /** @@ -77,7 +77,7 @@ class Msd_Auth_Adapter_Ini implements Zend_Auth_Adapter_Interface */ public function setPassword($password) { - $this->_password = (string) $password; + $this->_password = (string)$password; } /** @@ -96,14 +96,11 @@ class Msd_Auth_Adapter_Ini implements Zend_Auth_Adapter_Interface } $authResult = false; - foreach ($this->_users as $userId => $user) { - if ( - $this->_username == $user['name'] && - md5($this->_password) == $user['pass'] - ) { + foreach ($this->_users['users']['user'] as $name => $pass) { + if ($this->_username == $name && md5($this->_password) == $pass) { $authResult = array( - 'id' => $userId, - 'name' => $user['name'], + 'id' => $name, + 'name' => $name, ); } } diff --git a/library/Msd/User.php b/library/Msd/User.php index 6b59891..5eae2c2 100644 --- a/library/Msd/User.php +++ b/library/Msd/User.php @@ -156,15 +156,11 @@ class Msd_User return self::NO_USER_FILE; } - $usersConfig = new Msd_Ini($this->_usersFile); - $users = $usersConfig->get('user'); - + $usersConfig = new Msd_Ini($this->_usersFile); + $users = $usersConfig->get('users'); $hasValidUser = false; - foreach ($users as $user) { - if (isset($user['name']) && isset($user['pass'])) { - $hasValidUser = true; - break; - } + if (!empty($users)) { + $hasValidUser = true; } if (!$hasValidUser) { return self::NO_VALID_USER;