require_once "../initialize.php"; $response = ""; $loggeduser = User::get_by_id($session->user_id); if (isset($_GET['schoolid']) || isset($_GET['batchid']) || isset($_GET['sectionid'])) { if (isset($_GET['schoolid'])) { $school = School::get_by_id($_GET['schoolid']); if (SchoolUser::userExists($loggeduser->id, $school->id)) { $object = SchoolUser::getUser($loggeduser->id, $school->id); $object->delete(); $response = "success"; $notification = new Notification(); $notification->fromuserid = $loggeduser->id; $notification->itemid = $object->id; $notification->itemtype = "message"; $notification->title = "Opted Out"; $admins = SchoolUser::getAdmins($school->id); foreach ($admins as $admin) { $notification->touserid = $admin->userid; $notification->create(); } } 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();