Ejemplo n.º 1
0
 public function executeReactivate(sfRequest $request)
 {
     $user = sfGuardUser::getUserByUsername($request->getParameter('username'));
     if (!$user || $user->getIsActive()) {
         return;
     }
     try {
         // Create the mailer and message objects
         $mailer = $this->getMailer();
         // Render message parts
         $profile = $user->getProfile();
         $profile->setValidate('n' . self::createGuid());
         $profile->save();
         $mailContext = array('name' => $profile->getFullname(), 'validate' => $profile->getValidate());
         $message = Swift_Message::newInstance();
         $from = sfConfig::get('app_sfApplyPlugin_from');
         $message->setFrom($from['email'], $from['fullname']);
         $message->setTo($profile->getEmail(), $profile->getUser()->getUsername());
         $message->setSubject(sfConfig::get('app_sfApplyPlugin_apply_subject', "Активация аккаунта на сайте " . $request->getHost()));
         $message->setBody($this->getPartial('sfApply/sendValidateNew', $mailContext), 'text/html');
         $message->addPart($this->getPartial('sfApply/sendValidateNewText', $mailContext), 'text/plain');
         $mailer->send($message);
         return 'After';
     } catch (Exception $e) {
         $mailer->disconnect();
         $profile = $this->form->getObject();
         $user = $profile->getUser();
         $user->delete();
         // You could re-throw $e here if you want to
         // make it available for debugging purposes
         return 'MailerError';
     }
 }