/**
  * @param IPresentationSpeaker $speaker
  * @param string $email
  * @return ISpeakerRegistrationRequest
  */
 public function build(IPresentationSpeaker $speaker, $email)
 {
     $request = new SpeakerRegistrationRequest();
     $request->Email = $email;
     $request->IsConfirmed = false;
     $request->SpeakerID = $speaker->getIdentifier();
     $request->ProposerID = Member::currentUserID();
     $request->generateConfirmationToken();
     return $request;
 }
 /**
  * @param IPresentationSpeaker $speaker
  * @param string $email
  * @return ISpeakerRegistrationRequest
  */
 public function build(IPresentationSpeaker $speaker, $email)
 {
     $request = new SpeakerRegistrationRequest();
     $request->Email = $email;
     $request->IsConfirmed = false;
     $request->SpeakerID = $speaker->getIdentifier();
     $request->ProposerID = Member::currentUserID();
     $already_exists = false;
     do {
         $token = $request->generateConfirmationToken();
         $already_exists = $this->repository->existsConfirmationToken($token);
     } while ($already_exists);
     return $request;
 }
 /**
  * @param string $token
  * @return bool
  */
 public function existsConfirmationToken($token)
 {
     $token = SpeakerRegistrationRequest::HashConfirmationToken($token);
     return intval(DB::query("SELECT COUNT(ID) FROM  SpeakerRegistrationRequest WHERE ConfirmationHash = '{$token}' ;")->value()) > 0;
 }
 /**
  * @param string $email
  * @return IPresentationSpeaker
  */
 public function getByEmail($email)
 {
     $speaker = PresentationSpeaker::get()->filter(array('Member.Email' => $email))->first();
     if (is_null($speaker)) {
         $speaker = PresentationSpeaker::get()->filter(array('Member.SecondEmail' => $email))->first();
     }
     if (is_null($speaker)) {
         $speaker = PresentationSpeaker::get()->filter(array('Member.ThirdEmail' => $email))->first();
     }
     if (is_null($speaker)) {
         $registration_request = SpeakerRegistrationRequest::get()->filter(array('Email' => $email, 'IsConfirmed' => 0))->first();
         if (!is_null($registration_request)) {
             $speaker = $registration_request->Speaker();
         }
     }
     return $speaker;
 }