Example #1
0
 /**
  * 
  * @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();
 }
Example #2
0
	 /**
	*adduserAction
          *
          * @return void
          */
     public function adduserAction()
	 {
		$form = new User_Form_Adduser();
		if( $this->getRequest()->isPost() ){
			if( $form->isValid( $this->getRequest()->getPost() ) ){
				$user = new User_Model_User();
				$user->populate( $form->getValues() );
				$userMapper = new User_Model_Mapper_User();
				if( $id = $userMapper->save( $user ) ){
					$this->addSystemSuccess('Utilisateur créé');
					//$form->reset();
					$this->_redirect( $this->_helper->url->url( array('id' => $id), 'userById' ));
				} else {
					$this->addSystemError('Echec de la création');
				}
			} else {
				$this->addSystemError('Le formulaire contient 
				des erreurs');
			}
		}
		$this->view->form = $form;
	 }