public function getUnpublishedEventsBySource(SS_HTTPRequest $request) { try { $query_string = $request->getVars(); $summit_id = intval($request->param('SUMMIT_ID')); $source = strtolower(Convert::raw2sql($request->param('Source'))); $valid_sources = array('tracks', 'presentations', 'events'); if (!in_array($source, $valid_sources)) { return $this->validationError(array('invalid requested source')); } $search_term = isset($query_string['search_term']) ? Convert::raw2sql($query_string['search_term']) : null; $track_list_id = isset($query_string['track_list_id']) ? Convert::raw2sql($query_string['track_list_id']) : null; $event_type_id = isset($query_string['event_type_id']) ? Convert::raw2sql($query_string['event_type_id']) : null; $page = isset($query_string['page']) ? intval($query_string['page']) : 1; $page_size = isset($query_string['page_size']) ? intval($query_string['page_size']) : 10; $order = isset($query_string['order']) ? Convert::raw2sql($query_string['order']) : null; $expand = isset($query_string['expand']) ? Convert::raw2sql($query_string['expand']) : null; switch ($source) { case 'tracks': list($page, $page_size, $count, $data) = $this->summitpresentation_repository->getUnpublishedBySummitAndTrackList($summit_id, $track_list_id, $search_term, $page, $page_size, $order); break; case 'presentations': list($page, $page_size, $count, $data) = $this->summitpresentation_repository->getUnpublishedBySummit($summit_id, null, $search_term, $page, $page_size, $order); break; case 'events': list($page, $page_size, $count, $data) = $this->summitevent_repository->getUnpublishedBySummit($summit_id, $event_type_id, $search_term, $page, $page_size, $order); break; } $events = array(); foreach ($data as $e) { $entry = array('id' => $e->ID, 'title' => $e->Title, 'description' => $e->Description, 'type_id' => $e->TypeID); if ($e instanceof Presentation) { $speakers = array(); if (!empty($expand) && strstr($expand, 'speakers') !== false) { foreach ($e->Speakers() as $s) { array_push($speakers, array('id' => $s->ID, 'name' => $s->getName())); } $entry['speakers'] = $speakers; } else { foreach ($e->Speakers() as $s) { array_push($speakers, $s->ID); } $entry['speakers_id'] = $speakers; } $entry['moderator_id'] = $e->ModeratorID; $entry['track_id'] = $e->CategoryID; $entry['level'] = $e->Level; } array_push($events, $entry); } return $this->ok(array('data' => $events, 'page' => $page, 'page_size' => $page_size, 'total_pages' => ceil($count / $page_size))); } catch (Exception $ex) { SS_Log::log($ex->getMessage(), SS_Log::ERR); return $this->serverError(); } }
/** * @param int $presentation_id * @return void */ public function removePresentation($presentation_id) { $this->tx_manager->transaction(function () use($presentation_id) { $presentation = $this->presentation_repository->getById($presentation_id); if (is_null($presentation)) { throw new NotFoundEntityException(sprintf('presentation id %s', $presentation_id)); } if (!$presentation->canDelete()) { throw new EntityValidationException('you cant delete this presentation!'); } $this->presentation_repository->delete($presentation); }); }