Beispiel #1
0
 /**
  * @param User $user
  * @return bool
  */
 public function sendConfirmationEmail(User $user)
 {
     // Build the message
     $this->message->setSubject('Welcome to Simple Quiz, please confirm your email address');
     $replacements = array();
     $confirmHash = sha1($user->getEmail() . mt_rand() . $user->getId());
     $replacements[$user->getEmail()] = array('{username}' => $user->getName(), '{hash}' => $confirmHash, '{sitename}' => Config::$siteurl);
     $this->decorator = new \Swift_Plugins_DecoratorPlugin($replacements);
     $this->instance->registerPlugin($this->decorator);
     $this->readFromFile('registerconfirm');
     $this->message->setTo(array($user->getEmail() => $user->getName()));
     // Send the message
     if ($this->instance->send($this->message) > 0) {
         $record = \ORM::for_table('users')->find_one($user->getId());
         $record->set('confirmhash', $confirmHash);
         $record->set_expr('hashstamp', 'now()');
         $record->save();
         return true;
     }
     return false;
 }