Exemplo n.º 1
0
 /**
  * Action: add to favorites
  */
 public function action_favorite()
 {
     $this->history = false;
     // Load event
     $event_id = (int) $this->request->param('id');
     $event = Model_Event::factory($event_id);
     if (!$event->loaded()) {
         throw new Model_Exception($event, $event_id);
     }
     Permission::required($event, Model_Event::PERMISSION_FAVORITE, self::$user);
     if (Security::csrf_valid()) {
         $event->add_favorite(self::$user);
         NewsfeedItem_Events::favorite(self::$user, $event);
     }
     // Ajax requests show event day
     if ($this->_request_type === Controller::REQUEST_AJAX) {
         $this->response->body(new View_Event_Day($event));
         return;
     }
     $this->request->redirect(Route::model($event));
 }