Exemplo n.º 1
0
 private function trackChairDetails()
 {
     if (!Member::currentUser()) {
         return $this->httpError(403);
     }
     $data = array('categories' => NULL);
     $TrackChair = SummitTrackChair::get()->filter('MemberID', Member::currentUserID());
     if ($TrackChair->count()) {
         $chair = $TrackChair->first();
         $data['first_name'] = $chair->Member()->FirstName;
         $data['last_name'] = $chair->Member()->Surname;
         foreach ($chair->Categories() as $c) {
             $data['categories'][] = $c->toJSON();
         }
     }
     if (Permission::check('ADMIN')) {
         $data['is_admin'] = TRUE;
         $data['categories'] = [];
         $summit = Summit::get_active();
         foreach ($summit->Categories()->filter('ChairVisible', TRUE) as $c) {
             $data['categories'][] = $c->toJSON();
         }
     } else {
         $data['is_admin'] = FALSE;
     }
     return $data;
 }
 /**
  * @param $member
  * @param $category_id
  * @throws ValidationException
  * @throws null
  */
 public static function addChair($member, $category_id)
 {
     $priorChair = SummitTrackChair::get()->filter('MemberID', $member->ID)->first();
     $category = PresentationCategory::get()->byID($category_id);
     if (!$priorChair) {
         $chair = new self();
         $chair->MemberID = $member->ID;
         $chair->write();
         $chair->Categories()->add($category);
         //Find or create the 'track-chairs' group
         if (!($Group = Group::get()->filter('Code', 'track-chairs')->first())) {
             $Group = new Group();
             $Group->Code = "track-chairs";
             $Group->Title = "Track Chairs";
             $Group->Write();
             $member->Groups()->add($Group);
         }
         //Add member to the group
         $member->Groups()->add($Group);
         return $chair->ID;
     } else {
         $priorChair->Categories()->add($category);
         $priorChair->Member()->addToGroupByCode('track-chairs');
         return $priorChair->ID;
     }
 }
Exemplo n.º 3
0
 function trackChairCheck()
 {
     $member = Member::currentUser();
     $chair = new SummitTrackChair();
     if ($member) {
         $chair = SummitTrackChair::get()->filter(array('MemberID' => $member->ID, 'SummitID' => Summit::get_active()->ID));
     }
     if ($chair->exists() || Permission::check('ADMIN')) {
         return true;
     }
 }
Exemplo n.º 4
0
 public function handleDeleteChair(SS_HTTPRequest $r)
 {
     parse_str($r->getBody(), $vars);
     if (!isset($vars['chairID']) || !isset($vars['categoryID'])) {
         return $this->httpError(400, 'You must provide a chairID and categoryID param');
     }
     $category = PresentationCategory::get()->byID($vars['categoryID']);
     $chair = SummitTrackChair::get()->byID($vars['chairID']);
     if (!$category) {
         return $this->httpError(404, 'Category not found');
     }
     if (!$chair) {
         return $this->httpError(404, 'Chair not found');
     }
     $category->TrackChairs()->remove($chair);
     return new SS_HTTPResponse("Chair {$chair->Member()->getName()} removed from {$category->Title}", 200);
 }