Esempio n. 1
0
     } else {
         $response = "Error";
     }
 } else {
     if (isset($_GET['sectionid'])) {
         $section = Section::get_by_id($_GET['sectionid']);
         if (SectionUser::userExists($loggeduser->id, $_GET['sectionid'])) {
             $object = SectionUser::getUser($loggeduser->id, $_GET['sectionid']);
             $object->delete();
             $response = "success";
             $notification = new Notification();
             $notification->fromuserid = $loggeduser->id;
             $notification->itemid = $object->id;
             $notification->itemtype = "message";
             $notification->title = "Opted Out";
             $admins = SectionUser::getAdmins($section->id);
             foreach ($admins as $admin) {
                 $notification->touserid = $admin->userid;
                 $notification->create();
             }
         } else {
             $response = "Error";
         }
     } else {
         if (isset($_GET['clubid'])) {
             $club = Club::get_by_id($_GET['clubid']);
             if (ClubUser::userExists($loggeduser->id, $_GET['clubid'])) {
                 $object = ClubUser::getUser($loggeduser->id, $_GET['clubid']);
                 $object->delete();
                 $response = "success";
                 $notification = new Notification();