} else { $response = "Error"; } } else { if (isset($_GET['groupid'])) { $group = Group::get_by_id($_GET['groupid']); if (GroupUser::userExists($loggeduser->id, $_GET['groupid'])) { $object = GroupUser::getUser($loggeduser->id, $_GET['groupid']); $object->delete(); $response = "success"; $notification = new Notification(); $notification->fromuserid = $loggeduser->id; $notification->itemid = $object->id; $notification->itemtype = "message"; $notification->title = "Opted Out"; $admins = GroupUser::getAdmins($group->id); foreach ($admins as $admin) { $notification->touserid = $admin->userid; $notification->create(); } } else { $response = "Error"; } } } } } } $log = new Log($loggeduser->id, $clientip, "WEB", "JOINED"); $log->create(); } else {