示例#1
0
 public function addMember($quizid, User $user, $score, $start, $end, $timetaken)
 {
     //this should be called at start of quiz and fail if user already exists
     //record should be updated at end of quiz with score etc
     $quser = \ORM::for_table('users')->where('name', $user->getName())->find_one();
     $userid = $quser->id();
     $quizuser = \ORM::for_table('quiz_users')->create();
     $quizuser->set(array('quiz_id' => $quizid, 'user_id' => $userid, 'score' => $score, 'start_time' => $start, 'date_submitted' => $end, 'time_taken' => $timetaken));
     $quizuser->save();
     return true;
 }
示例#2
0
 /**
  * @param User $user
  * @return User $user
  * @throws RegisterException
  */
 public function registerUser(User $user)
 {
     $name = $user->getName();
     $email = $user->getEmail();
     $password = $user->getPassword();
     $userexists = \ORM::for_table('users')->where_any_is(array(array('name' => $name), array('email' => $email)))->find_one();
     if ($userexists) {
         throw new RegisterException();
     } else {
         //register a new user
         $newuser = \ORM::for_table('users')->create();
         $newuser->set('name', $name);
         $newuser->set('email', $email);
         $newuser->set('pass', $password);
         $newuser->save();
         $user->setId($newuser->id());
         return $user;
     }
 }
示例#3
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;
 }
示例#4
0
 function __construct($email, $name)
 {
     parent::__construct($email, $name);
 }