예제 #1
0
 public function executeRegister()
 {
     if ($this->getRequest()->getMethod() != sfRequest::POST) {
         return sfView::SUCCESS;
     }
     $user = new SfGuardUser();
     $user->setUsername($this->getRequestParameter('username'));
     $user->setPassword($this->getRequestParameter('password'));
     $user->setIsActive(false);
     $profile = new UserProfile();
     $profile->setEmail($this->getRequestParameter('email'));
     $profile->setFirstName($this->getRequestParameter('first_name'));
     $profile->setLastName($this->getRequestParameter('last_name'));
     $profile->setGender($this->getRequestParameter('gender') ? $this->getRequestParameter('gender') : null);
     $profile->setBirthday($this->getRequestParameter('birthday') ? $this->getRequestParameter('birthday') : null);
     $user->addUserProfile($profile);
     $user->save();
     $this->getRequest()->setAttribute('email', $profile->getEmail());
     $this->getRequest()->setAttribute('full_name', $profile->getFullName());
     $this->getRequest()->setAttribute('activation_key', $profile->getConfirmation());
     $raw_email = $this->sendEmail('mail', 'register');
     $this->logMessage($raw_email, 'debug');
     $this->setFlash('info', 'We sent a confirmation email to your email address.');
     $this->forward('site', 'message');
 }