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 : '')); } } }
public function loadUserAttributes(Application_Model_Models_User $user) { $attributes = array(); if ($user->getId()) { $select = $this->getDbTable()->getAdapter()->select()->from('user_attributes', array('attribute', 'value'))->where('user_id = ?', $user->getId()); $data = $this->getDbTable()->getAdapter()->fetchPairs($select); if (!is_null($data)) { $attributes = $data; } } return $user->setAttributes($attributes); }
protected function _renderPhoto() { if (isset($this->_options[0])) { $imgSize = $this->_options[0]; } else { $imgSize = 'small'; } $imgNameSlug = md5($this->_user->getId() . $this->_user->getEmail()) . '.png'; $userpic = 'media/' . self::USERPIC_FOLDER . '/' . $imgSize . '/' . $imgNameSlug; $this->_view->userpic = file_exists($this->_websiteHelper->getPath() . $userpic) ? $userpic : null; $this->_view->imgNameSlug = $imgNameSlug; $this->_view->user = $this->_user; $this->_view->imgSize = $imgSize; $this->_view->editableMode = $this->_editableMode; return $this->_view->render('user-photo.phtml'); }
protected function _sendTmembersignupMail(Application_Model_Models_User $user) { switch ($this->_options['recipient']) { case self::RECIPIENT_MEMBER: $this->_mailer->setMailToLabel($user->getFullName())->setMailTo($user->getEmail())->setSubject(isset($this->_options['subject']) ? $this->_options['subject'] : $this->_translator->translate('Welcome!')); break; case self::RECIPIENT_SUPERADMIN: $superAdmin = Application_Model_Mappers_UserMapper::getInstance()->findByRole(Tools_Security_Acl::ROLE_SUPERADMIN); $this->_mailer->setMailToLabel($superAdmin->getFullName())->setMailTo($superAdmin->getEmail())->setSubject(isset($this->_options['subject']) ? $this->_options['subject'] : $this->_translator->translate('New user is registered!')); break; } if (($mailBody = $this->_prepareEmailBody()) == false) { $mailBody = $this->_options['message']; } $this->_entityParser->objectToDictionary($user); if (!isset($this->_options['from'])) { $this->_options['from'] = Application_Model_Mappers_UserMapper::getInstance()->findByRole(Tools_Security_Acl::ROLE_SUPERADMIN)->getEmail(); } return $this->_mailer->setMailFrom($this->_options['from'])->setBody($this->_entityParser->parse($mailBody))->send(); }
public function indexAction() { $this->_helper->page->doCanonicalRedirect('go'); //if logged in user trys to go to the login page - redirect him to the main page if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_PAGE_PROTECTED)) { $this->_redirect($this->_helper->website->getUrl()); } $loginForm = new Application_Form_Login(); if ($this->getRequest()->isPost()) { if ($loginForm->isValid($this->getRequest()->getParams())) { $authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Registry::get('dbAdapter'), 'user', 'email', 'password', 'MD5(?)'); $authAdapter->setIdentity($loginForm->getValue('email')); $authAdapter->setCredential($loginForm->getValue('password')); $authResult = $authAdapter->authenticate(); if ($authResult->isValid()) { $authUserData = $authAdapter->getResultRowObject(null, 'password'); if (null !== $authUserData) { $user = new Application_Model_Models_User((array) $authUserData); $user->setLastLogin(date(Tools_System_Tools::DATE_MYSQL)); $user->setIpaddress($_SERVER['REMOTE_ADDR']); $this->_helper->session->setCurrentUser($user); Application_Model_Mappers_UserMapper::getInstance()->save($user); unset($user); $this->_helper->cache->clean(); if ($authUserData->role_id == Tools_Security_Acl::ROLE_MEMBER) { $this->_memberRedirect(); } if (isset($this->_helper->session->redirectUserTo)) { $this->_redirect($this->_helper->website->getUrl() . $this->_helper->session->redirectUserTo, array('exit' => true)); } $this->_redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $this->_helper->website->getUrl()); } } $signInType = $this->getRequest()->getParam('singintype'); if ($signInType && $signInType == Tools_Security_Acl::ROLE_MEMBER) { $this->_memberRedirect(false); } $this->_checkRedirect(false, array('email' => 'There is no user with such login and password.')); } else { $this->_checkRedirect(false, array('email' => 'Login should be a valid email address')); } } else { //getting available system translations $this->view->languages = $this->_helper->language->getLanguages(); //getting messages $errorMessages = $this->_helper->flashMessenger->getMessages(); if (!empty($errorMessages)) { foreach ($errorMessages as $message) { foreach ($message as $elementName => $msg) { $loginForm->getElement($elementName)->setAttribs(array('class' => 'notvalid', 'title' => $msg)); } } } $this->view->messages = $this->_helper->flashMessenger->getMessages(); //unset url redirect set from any login widget unset($this->_helper->session->redirectUserTo); $loginForm->removeDecorator('HtmlTag'); $loginForm->setElementDecorators(array('ViewHelper', 'Errors', 'Label', array('HtmlTag', array('tag' => 'p')))); $this->view->loginForm = $loginForm; } }