/** * Used by the track chair app to allow chairs to add a presentation to a group list. **/ public function assignToGroupList() { // Check permissions of user on talk if ($this->CanAssign()) { $GroupList = SummitSelectedPresentationList::get()->filter(array('CategoryID' => $this->CategoryID, 'ListType' => 'Group'))->first(); // See if the presentation has already been assigned $AlreadyAssigned = $GroupList->SummitSelectedPresentations('PresentationID = ' . $this->ID); if ($AlreadyAssigned->count() == 0) { // Find the higest order value assigned up to this point $HighestOrderInList = $GroupList->SummitSelectedPresentations()->sort('Order DESC')->first()->Order; $SelectedPresentation = new SummitSelectedPresentation(); $SelectedPresentation->SummitSelectedPresentationListID = $GroupList->ID; $SelectedPresentation->PresentationID = $this->ID; $SelectedPresentation->MemberID = Member::currentUser()->ID; // Place at bottom of list $SelectedPresentation->Order = $HighestOrderInList + 1; $SelectedPresentation->write(); } } }
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); }
/** * Used by the track chair app to allow chairs to add a presentation to a group list. **/ public function assignToGroupList() { // Check permissions of user on talk if ($this->owner->canAssign()) { $groupList = SummitSelectedPresentationList::get()->filter(array('CategoryID' => $this->owner->CategoryID, 'ListType' => 'Group'))->first(); // See if the presentation has already been assigned $alreadyAssigned = $groupList->SummitSelectedPresentations()->filter('PresentationID', $this->owner->ID)->exists(); if (!$alreadyAssigned) { // Find the higest order value assigned up to this point $highestOrderInList = $groupList->SummitSelectedPresentations()->sort('Order DESC')->first()->Order; $selectedPresentation = new SummitSelectedPresentation(); $selectedPresentation->SummitSelectedPresentationListID = $groupList->ID; $selectedPresentation->PresentationID = $this->owner->ID; $selectedPresentation->MemberID = Member::currentUser()->ID; // Place at bottom of list $selectedPresentation->Order = $highestOrderInList + 1; $selectedPresentation->Collection = SummitSelectedPresentation::COLLECTION_SELECTED; $selectedPresentation->write(); } } }