/**
  * Loads the sessions from remote. Update only. Remote is authoritative
  * @param  array $sessions The session data from the API	 
  */
 protected function loadSessions($sessions)
 {
     $i = 0;
     foreach ($sessions as $sessionData) {
         $record = VideoPresentation::get_by_sched_id($sessionData['id']);
         if (!$record) {
             $this->writeOut("No presentation with Sched ID " . $sessionData['id'] . " exists. Creating.");
             $record = VideoPresentation::create();
         } else {
             $this->writeOut("Found existing presentation with Sched ID " . $sessionData['id']);
         }
         $presentation = $this->loadIntoPresentation($record, $sessionData);
         $presentation->write();
         $i++;
     }
     $this->writeOut("Loaded {$i} presentations.");
 }
 public function handleSchedUpdate(SS_HTTPRequest $r)
 {
     if (!Member::currentUser()) {
         return $this->httpError(403);
     }
     $schedID = $r->param('SchedID');
     $presentation = VideoPresentation::get_by_event_key($schedID);
     if (!$presentation) {
         $presentation = VideoPresentation::create(array('event_key' => $schedID));
     }
     // Only allow one writeable property here
     if ($youTube = $r->postVar('youtubeid')) {
         $presentation->YouTubeID = $youTube;
         $presentation->write();
         return new SS_HTTPResponse("OK", 200);
     }
     return $this->httpError(400, "You must provide a youtubeid parameter in the POST request");
 }