/** * * @param User_Form_Registration $form */ public function userAdd(User_Form_Registration $form) { $user = $form->getData(); $username = $user['username']; $email = $user['email']; $password = sha1($user['password']); $realName = $user['realName']; $avatar = pathinfo($user['avatar']['tmp_name'], PATHINFO_BASENAME); $hash = sha1($email . (microtime(true) . rand(1, 99999))); $this->renderer->hash = $hash; $emailText = $this->renderer->render('/register/mail.phtml'); $userNew = new User_Model_Mapper_User(); $userNew->setUsername($username); $userNew->setEmail($email); $userNew->setPassword($password); $userNew->setRealName($realName); $userNew->setLastVisit(); $userNew->setRegDate(); $userNew->setAvatar($avatar); $userNew->setHash($hash); $userNew->save(); $mail = new Zend_Mail(); $mail->setBodyHtml($emailText); $mail->setFrom('*****@*****.**', 'Administrator'); $mail->addTo($email, $username); $mail->setSubject('Test activation link'); $mail->send(); }
public function connectAction() { $form = new User_Form_Login(); if( $this->getRequest()->isPost() ) { if( $form->isValid( $this->getRequest()->getPost() ) ){ $user = new User_Model_User(); $user->setLogin($form->getValue('login') ); $user->setPassword($form->getValue('password') ); $userMapper = new User_Model_Mapper_User(); if( $id = $userMapper->login( $user ) ){ $this->addSystemSuccess('connexion'); $this->_redirect( $this->_helper->url->url( array(), 'userList' )); } else { $this->addSystemError('Echec connexion'); } } else { $this->addSystemError('echec connexion'); } } $this->view->form = $form; }