/**
  * @param SS_HTTPRequest $r
  */
 public function presentations(SS_HTTPRequest $r)
 {
     $data = [];
     $speaker = null;
     $key = $r->getVar('key');
     if ($key) {
         $username = PresentationSpeaker::hash_to_username($key);
         $speaker = PresentationSpeaker::get()->filter('Member.Email', $username)->first();
     } elseif ($speakerID = Session::get('UploadMedia.SpeakerID')) {
         $speaker = PresentationSpeaker::get()->byID($speakerID);
     }
     // Speaker not found
     if (!$speaker) {
         return $this->httpError(404, 'Sorry, that does not appear to be a valid token.');
     }
     Session::set('UploadMedia.SpeakerID', $speaker->ID);
     $mostRecentSummit = Summit::get_most_recent();
     $presentations = $speaker->PublishedPresentations($mostRecentSummit->ID);
     // No presentations
     if (!$presentations->exists()) {
         return $this->httpError(404, 'Sorry, it does not appear that you have any presentations.');
     }
     // IF there's only one presentation with no media, go ahead and forward to it's page
     if ($presentations->count() == 1) {
         $slide = $presentations->first()->MaterialType('PresentationSlide');
         if (!$slide) {
             $presentationID = $presentations->first()->ID;
             return $this->redirect(Controller::join_links($this->Link(), '/presentation/', $presentationID, 'upload'));
         }
     }
     $data['Speaker'] = $speaker;
     $data['Presentations'] = $presentations;
     return $this->customise($data);
 }
Пример #2
0
 /**
  * @param SS_HTTPRequest $r
  */
 public function emailattendees(SS_HTTPRequest $r)
 {
     $startTime = microtime(true);
     $summit = Summit::get_most_recent();
     $confirm = $r->getVar('confirm');
     $limit = $r->getVar('limit');
     $attendees = $summit->Attendees();
     $totalBeforeLimit = $attendees->count();
     $chunkSize = 100;
     $offset = 0;
     $appliedLimit = $confirm ? $chunkSize : ($limit ?: 50);
     $attendees = $attendees->limit($appliedLimit);
     while ($offset < $totalBeforeLimit) {
         echo "----- new chunk ({$offset}) ----" . $this->br();
         foreach ($attendees->limit($chunkSize, $offset) as $attendee) {
             if (!EmailValidator::validEmail($attendee->Member()->Email)) {
                 echo $attendee->Member()->Email . " is not a valid email. Skipping" . $this->br();
                 continue;
             }
             $to = $attendee->Member()->Email;
             $subject = "Rate OpenStack Summit sessions from {$summit->Title}";
             $email = EmailFactory::getInstance()->buildEmail('*****@*****.**', $to, $subject);
             $email->setUserTemplate("rate-summit-sessions-austin");
             $email->populateTemplate(['Name' => $attendee->Member()->FirstName]);
             if ($confirm) {
                 $email->send();
             } else {
                 //echo $email->debug();
             }
             echo 'Email sent to ' . $to . ' (' . $attendee->Member()->getName() . ')' . $this->br();
         }
         echo "---- end chunk ({$offset}) ----" . $this->br();
         $offset += $chunkSize;
     }
     echo $this->br(3) . "Sent a sample of {$appliedLimit} emails out of {$totalBeforeLimit} total" . $this->br();
     $endTime = microtime(true);
     echo "Elapsed time: " . $endTime - $startTime . $this->br();
 }