public function signupAction() { $this->_helper->viewRenderer->setNoRender(true); if ($this->getRequest()->isPost()) { $signupForm = new Application_Form_Signup(); if ($signupForm->isValid($this->getRequest()->getParams())) { //save new user $user = new Application_Model_Models_User($signupForm->getValues()); $user->registerObserver(new Tools_Mail_Watchdog(array('trigger' => Tools_Mail_SystemMailWatchdog::TRIGGER_SIGNUP))); $user->setRoleId(Tools_Security_Acl::ROLE_MEMBER); if (isset($this->_helper->session->refererUrl)) { $user->setReferer($this->_helper->session->refererUrl); } $signupResult = Application_Model_Mappers_UserMapper::getInstance()->save($user); if (!$user->getId()) { $user->setId($signupResult); } //send mails by notifying mail observer about successful sign-up, $user->notifyObservers(); //redirect to signup landing page $signupLandingPage = Tools_Page_Tools::getLandingPage(Application_Model_Models_Page::OPT_SIGNUPLAND); if ($signupLandingPage instanceof Application_Model_Models_Page) { $this->_redirect($this->_helper->website->getUrl() . $signupLandingPage->getUrl()); exit; } else { $this->_redirect($this->_helper->website->getUrl()); } } else { $this->_helper->flashMessenger->addMessage(Tools_Content_Tools::proccessFormMessagesIntoHtml($signupForm->getMessages(), get_class($signupForm))); $signupPageUrl = $this->_helper->session->signupPageUrl; unset($this->_helper->session->signupPageUrl); $this->_redirect($this->_helper->website->getUrl() . ($signupPageUrl ? $signupPageUrl : '')); } } }
private function _memberRedirect($success = true) { $landingPage = $success ? Tools_Page_Tools::getLandingPage(Application_Model_Models_Page::OPT_MEMLAND) : Tools_Page_Tools::getLandingPage(Application_Model_Models_Page::OPT_ERRLAND); if ($landingPage instanceof Application_Model_Models_Page) { $this->redirect($this->_helper->website->getUrl() . $landingPage->getUrl(), array('exit' => true)); } }
public function indexAction() { $page = null; $pageContent = null; $currentUser = $this->_helper->session->getCurrentUser(); // tracking referer if (!isset($this->_helper->session->refererUrl)) { $refererUrl = $this->getRequest()->getHeader('referer'); $currentUser->setReferer($refererUrl); $this->_helper->session->setCurrentUser($currentUser); $this->_helper->session->refererUrl = $refererUrl; } // Getting requested url. If url is not specified - get index.html $pageUrl = filter_var($this->getRequest()->getParam('page', Helpers_Action_Website::DEFAULT_PAGE), FILTER_SANITIZE_STRING); // Trying to do canonical redirects $this->_helper->page->doCanonicalRedirect($pageUrl); //Check if 301 redirect is present for requested page then do it $this->_helper->page->do301Redirect($pageUrl); // Loading page data using url from request. First checking cache, if no cache // loading from the database and save result to the cache $pageCacheKey = md5($pageUrl); if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_CACHE_PAGE)) { $page = $this->_helper->cache->load($pageCacheKey, 'pagedata_'); } // page is not in cache if ($page === null) { $page = Application_Model_Mappers_PageMapper::getInstance()->findByUrl($pageUrl); } // page found if ($page instanceof Application_Model_Models_Page) { $cacheTag = preg_replace('/[^\\w\\d_]/', '', $page->getTemplateId()); $this->_helper->cache->save($pageCacheKey, $page, 'pagedata_', array($cacheTag, 'pageid_' . $page->getId())); } // If page doesn't exists in the system - show 404 page if ($page === null) { //show 404 page and exit $page = Application_Model_Mappers_PageMapper::getInstance()->find404Page(); if (!$page instanceof Application_Model_Models_Page) { $this->view->websiteUrl = $this->_helper->website->getUrl(); $this->view->adminPanel = $this->_helper->admin->renderAdminPanel($this->_helper->session->getCurrentUser()->getRoleId()); $this->_helper->response->notFound($this->view->render('index/404page.phtml')); exit; } $this->getResponse()->setHeader('HTTP/1.1', '404 Not Found'); $this->getResponse()->setHeader('Status', '404 File not found'); } //if requested page is not allowed - redirect to the signup landing page if (!Tools_Security_Acl::isAllowed($page)) { $signupLanding = Tools_Page_Tools::getLandingPage(Application_Model_Models_Page::OPT_SIGNUPLAND); $this->_helper->redirector->gotoUrl($signupLanding instanceof Application_Model_Models_Page ? $this->_helper->website->getUrl() . $signupLanding->getUrl() : $this->_helper->website->getUrl()); } // Mobile switch if ((bool) $this->_config->getConfig('enableMobileTemplates')) { if ($this->_request->isGet() && $this->_request->has('mobileSwitch')) { $showMobile = filter_var($this->_request->getParam('mobileSwitch'), FILTER_SANITIZE_NUMBER_INT); if (!is_null($showMobile)) { $this->_helper->session->mobileSwitch = (bool) $showMobile; } } if (!isset($showMobile) && isset($this->_helper->session->mobileSwitch)) { $showMobile = $this->_helper->session->mobileSwitch; } else { $showMobile = $this->_helper->mobile->isMobile(); } // Mobile detect if ($showMobile === true) { $mobileTemplate = Application_Model_Mappers_TemplateMapper::getInstance()->find('mobile_' . $page->getTemplateId()); if (null !== $mobileTemplate) { $page->setTemplateId($mobileTemplate->getName())->setContent($mobileTemplate->getContent()); } unset($mobileTemplate); } } $pageData = $page->toArray(); //Parsing page content and saving it to the cache if ($pageContent === null) { $themeData = Zend_Registry::get('theme'); $parserOptions = array('websiteUrl' => $this->_helper->website->getUrl(), 'websitePath' => $this->_helper->website->getPath(), 'currentTheme' => $this->_config->getConfig('currentTheme'), 'themePath' => $themeData['path']); $parser = new Tools_Content_Parser($page->getContent(), $pageData, $parserOptions); $pageContent = $parser->parse(); unset($parser); unset($themeData); //$this->_helper->cache->save($page->getUrl(), $pageContent, 'page_'); } $pageContent = $this->_pageRunkSculptingDemand($page, $pageContent); // Finalize page generation routine $this->_complete($pageContent, $pageData, $parserOptions); }