public function init() { /* * If no users are installed then go to the installer page. */ $allUsers = Model_DbTable_User::getAllUsers(); if (count($allUsers) < 1) { $this->_helper->_redirector->goToRouteAndExit(array('controller' => 'install', 'action' => 'index')); } /* * Handle the current user and login redirection. * All pages except /user/login are redirected to /user/login if the * user is not logged in. */ $currentUser = new Zend_Session_Namespace('currentUser'); $requestParameters = $this->getRequest()->getParams(); if ($requestParameters['controller'] != 'user' && $requestParameters['action'] != 'login') { if ($currentUser->username == null) { $this->_helper->_redirector->goToRouteAndExit(array('controller' => 'user', 'action' => 'login')); } else { $this->view->currentUser = $currentUser; SoftLayer_SoapClient::setAuthenticationUser($currentUser->username, $currentUser->apiKey); } } /* * Set common view elements. */ $this->view->translate = Zend_Registry::get('Zend_Translate'); $this->view->baseUrl = $this->getRequest()->getBaseUrl(); }
public function init() { /* * Handle the current user and login redirection. * All pages except /user/login are redirected to /user/login if the * user is not logged in. */ $currentUser = new Zend_Session_Namespace('currentUser'); $requestParameters = $this->getRequest()->getParams(); if ($requestParameters['controller'] != 'user' && $requestParameters['action'] != 'login') { if ($currentUser->username == null) { $this->_helper->_redirector->goToRouteAndExit(array('controller' => 'user', 'action' => 'login')); } else { $this->view->currentUser = $currentUser; SoftLayer_SoapClient::setAuthenticationUser($currentUser->username, $currentUser->apiKey); } } /* * Only admin users can view pages from the admin controller. */ if (!$currentUser->isAdmin) { $this->_helper->_redirector->goToRouteAndExit(array('controller' => 'index', 'action' => 'index')); } /* * Set common view elements. */ $this->view->translate = Zend_Registry::get('Zend_Translate'); $this->view->baseUrl = $this->getRequest()->getBaseUrl(); }