function PresentationPosition() { $Presentations = SummitSelectedPresentation::get()->filter(array('SummitSelectedPresentationListID' => $this->SummitSelectedPresentationList()->ID, 'Order:not' => 0))->sort('Order', 'ASC'); $PresentationPosition = 0; $counter = 1; if ($Presentations) { foreach ($Presentations as $Presentation) { if ($Presentation->ID == $this->ID) { $PresentationPosition = $counter; } $counter = $counter + 1; } } $Presentations = SummitSelectedPresentation::get()->filter(array('SummitSelectedPresentationListID' => $this->SummitSelectedPresentationList()->ID, 'Order' => 0))->sort('Order', 'ASC'); if ($Presentations) { foreach ($Presentations as $Presentation) { if ($Presentation->ID == $this->ID) { $PresentationPosition = $counter; } $counter = $counter + 1; } } return $PresentationPosition; }
public function JSONConfig() { return Convert::array2json(['baseURL' => $this->Link(), 'summitID' => Summit::get_active()->ID, 'pass_order' => SummitSelectedPresentation::config()->pass_order, 'userinfo' => ['name' => Member::currentUser()->getName(), 'email' => Member::currentUser()->Email, 'isAdmin' => Permission::check('ADMIN')]]); }
/** * @return mixed */ public function UnsortedPresentations() { return SummitSelectedPresentation::get()->filter(array('SummitSelectedPresentationListID' => $this->ID, 'Order' => 0))->sort('Order', 'ASC'); }
public function handleReorderList(SS_HTTPRequest $r) { $sortOrder = $r->postVar('sort_order'); $listID = $r->postVar('list_id'); $list = SummitSelectedPresentationList::get()->byId($listID); if (!$list->memberCanEdit()) { return new SS_HTTPResponse(null, 403); } if (is_array($sortOrder)) { foreach ($sortOrder as $key => $id) { $selection = SummitSelectedPresentation::get()->filter(array('PresentationID' => $id, 'SummitSelectedPresentationListID' => $listID)); // Add the selection if it's new if (!$selection->exists()) { $presentation = Presentation::get()->byId($id); if ($presentation->exists() && $presentation->CategoryID == $list->CategoryID) { $s = new SummitSelectedPresentation(); $s->SummitSelectedPresentationListID = $listID; $s->PresentationID = $presentation->ID; $s->MemberID = Member::currentUserID(); $s->Order = $key + 1; $s->write(); } } // Adjust the order if not if ($selection->exists()) { $s = $selection->first(); $s->Order = $key + 1; $s->write(); } } } return new SS_HTTPResponse(null, 200); }
public function SelectionStatus() { $Selections = SummitSelectedPresentation::get()->leftJoin('SummitSelectedPresentationList', 'SummitSelectedPresentation.SummitSelectedPresentationListID = SummitSelectedPresentationList.ID')->filter(array('PresentationID' => $this->ID, 'ListType' => 'Group')); // Error out if a talk has more than one selection if ($Selections && $Selections->count() > 1) { user_error('There cannot be more than one instance of this talk selected. Talk ID ' . $this->ID); } $Selection = NULL; if ($Selections) { $Selection = $Selections->first(); } // Error out if the category of presentation does not match category of selection if ($Selection && $this->CategoryID != $Selection->SummitSelectedPresentationList()->Category()->ID) { user_error('The selection category does not match the presentation category. Presentation ID ' . $this->ID); } if (!$Selection) { return 'unaccepted'; } elseif ($Selection->Order <= $this->Category()->SessionCount) { return 'accepted'; } else { return 'alternate'; } }
protected function getSelectedPresentation() { $memID = Member::currentUserID(); return SummitSelectedPresentation::get()->filter(['PresentationID' => $this->owner->ID, 'SummitSelectedPresentation.MemberID' => $memID, 'SummitSelectedPresentationList.ListType' => 'Individual'])->first(); }
/** * @param SS_HTTPRequest $r * @return SS_HTTPResponse * @throws ValidationException * @throws null */ public function handleReorderList(SS_HTTPRequest $r) { $vars = Convert::json2array($r->getBody()); $idList = $vars['order']; $listID = $vars['list_id']; $collection = $vars['collection']; $list = SummitSelectedPresentationList::get()->byId($listID); if (!$list->memberCanEdit()) { return $this->httpError(403, 'You cannot edit this list'); } $isTeam = $list->ListType === 'Group'; // Remove any presentations that are not in the list SummitSelectedPresentation::get()->filter(['SummitSelectedPresentationListID' => $listID, 'Collection' => $collection])->exclude(['PresentationID' => array_values($idList)])->removeAll(); if (is_array($idList)) { foreach ($idList as $order => $id) { $attributes = ['PresentationID' => $id, 'SummitSelectedPresentationListID' => $listID, 'Collection' => $collection]; $selection = SummitSelectedPresentation::get()->filter($attributes)->first(); if (!$selection) { $selection = SummitSelectedPresentation::create($attributes); if ($isTeam) { $presentation = Presentation::get()->byID($id); if ($presentation) { $presentation->addNotification('{member} added this presentation to the team list'); } } } $selection->Order = $order + 1; $selection->write(); } } return $this->ok(); }