예제 #1
0
 public function getLastWatchedEpisode()
 {
     if (null == $this->lastWatchedEpisode) {
         $this->lastWatchedEpisode = Episodes::findFirst('id = "' . $this->getWatchList()->currentEpisode_id . '"');
     }
     return $this->lastWatchedEpisode;
 }
 public function deleteAction($id)
 {
     $auth = $this->session->get('auth');
     if ($auth) {
         $id = $this->filter->sanitize($id, array('int'));
         $episode = Episodes::findFirst('id=' . $id);
         if (!$episode) {
             $this->flash->error('Episode not found');
             return $this->response->redirect('episodes/');
         }
         if (!$episode->delete()) {
             foreach ($episode->getMessages() as $message) {
                 $this->flash->error((string) $message);
             }
             return $this->response->redirect('episodes/');
         } else {
             $this->flash->success('Episode deleted successfully');
             return $this->response->redirect('episodes/');
         }
     }
 }