} else { $response = "Error"; } } else { if (isset($_GET['batchid'])) { $batch = Batch::get_by_id($_GET['batchid']); if (BatchUser::userExists($loggeduser->id, $_GET['batchid'])) { $object = BatchUser::getUser($loggeduser->id, $_GET['batchid']); $object->delete(); $response = "success"; $notification = new Notification(); $notification->fromuserid = $loggeduser->id; $notification->itemid = $object->id; $notification->itemtype = "message"; $notification->title = "Opted Out"; $admins = BatchUser::getAdmins($batch->id); foreach ($admins as $admin) { $notification->touserid = $admin->userid; $notification->create(); } } 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();