public function loginAction() { $form = new Admin_Form_Login(); $form->setAction($this->baseUrl . '/public/index/login'); if ($this->_request->isPost() && $form->isValid($_POST)) { $uri = Digitalus_Filter_Post::get('uri'); $username = Digitalus_Filter_Post::get('adminUsername'); $password = Digitalus_Filter_Post::get('adminPassword'); $auth = new Digitalus_Auth($username, $password); $result = $auth->authenticate(); if (!$result) { $e = new Digitalus_View_Error(); $e->add($this->view->getTranslation('The username or password you entered was not correct.')); } else { $uri = Digitalus_Toolbox_Page::getHomePageName(); $this->_redirect($uri); } } # ---------------------------------------------------------------------------- # $this->page->content = array('label' => 'Auth', 'headline' => $this->view->getTranslation('Authorisation required'), 'content' => $this->view->partial('partials/login.phtml', array('form' => $form))); $this->page->defaultContent = $this->page->content; // load the view Digitalus_Builder::loadPage(null, 'load_view.xml', $this->page, $this->view); // render the page $this->view->page = $this->page; $this->view->layout()->page = $this->page->getParam('xhtml'); $this->renderScript('index/index.phtml'); }
protected function _setActive($item = null) { if (empty($item)) { $item = $this->getItem(); } $uri = new Digitalus_Uri(); $uriString = strtolower($uri->toString()); if (strtolower(Digitalus_Toolbox_Page::getCurrentPageName()) == strtolower($item->name) || empty($uriString) && strtolower(Digitalus_Toolbox_Page::getHomePageName($item)) == strtolower(Digitalus_Toolbox_Page::getUrl($item))) { $active = true; } else { $active = false; } $this->setActive($active); }
/** * validate the current user's request * * @param Zend_Controller_Request_Abstract $request */ public function preDispatch(Zend_Controller_Request_Abstract $request) { $this->_identity = Digitalus_Auth::getIdentity(); $this->_acl = new Digitalus_Acl(); $role = Model_Group::GUEST_ROLE; if (!empty($this->_identity)) { $role = $this->_identity->role; } $module = $request->module; $controller = $request->controller; $action = $request->action; if ($module != 'public' && $controller != 'public') { //go from more specific to less specific $moduleLevel = $module; $controllerLevel = $moduleLevel . '_' . $controller; $actionLevel = $controllerLevel . '_' . $action; if ($this->_acl->has($actionLevel)) { $resource = $actionLevel; } else { if ($this->_acl->has($controllerLevel)) { $resource = $controllerLevel; } else { $resource = $moduleLevel; } } if ($this->_acl->has($resource) && !$this->_acl->isAllowed($role, $resource)) { if (!$this->_identity || Model_Group::GUEST_ROLE == $role) { $request->setModuleName($this->_noAuth['admin']['module']); $request->setControllerName($this->_noAuth['admin']['controller']); $request->setActionName($this->_noAuth['admin']['action']); $request->setParam('authPage', 'login'); } else { $request->setModuleName($this->_noAcl['admin']['module']); $request->setControllerName($this->_noAcl['admin']['controller']); $request->setActionName($this->_noAcl['admin']['action']); $request->setParam('authPage', 'noauth'); } } } else { $resource = Digitalus_Toolbox_Page::getCurrentPageName(); // write pageName to registry when coming from a page if ('index' == $controller && 'index' == $action) { Zend_Registry::set('Digitalus_Page_Name', $resource); } $resource = strtolower(Digitalus_Toolbox_String::replaceUnderscore($resource)); // only check Acl if page is NOT homepage if (!empty($resource) && '' != $resource && Digitalus_Toolbox_Page::getHomePageName() != $resource) { if ($this->_acl->has($resource) && !$this->_acl->isAllowed($role, $resource)) { if (!$this->_identity || Model_Group::GUEST_ROLE != $role) { $request->setModuleName($this->_noAcl['public']['module']); $request->setControllerName($this->_noAcl['public']['controller']); $request->setActionName($this->_noAcl['public']['action']); $request->setParam('authPage', 'login'); } else { $request->setModuleName($this->_noAcl['public']['module']); $request->setControllerName($this->_noAcl['public']['controller']); $request->setActionName($this->_noAcl['public']['action']); $request->setParam('authPage', 'noauth'); } } } } }