/** * @param integer $organisation_unit_id * @param integer $user_id * @return string * @throws BaseUserAccessDeniedException * @throws OrganisationUnitIDMissingException */ public static function delete_member($organisation_unit_id, $user_id) { global $user; if ($user->is_admin()) { if (is_numeric($organisation_unit_id) and is_numeric($user_id)) { $organisation_unit = new OrganisationUnit($organisation_unit_id); if ($organisation_unit->delete_user_from_organisation_unit($user_id) == true) { return "1"; } else { return "0"; } } else { throw new OrganisationUnitIDMissingException(); } } else { throw new BaseUserAccessDeniedException(); } }
/** * @todo IMPORTANT: bad dependency, replace with JS * @throws UserIDMissingException */ public static function delete_organisation_unit() { if ($_GET['id']) { if ($_GET['key']) { if ($_GET['sure'] != "true") { $template = new HTMLTemplate("base/user/admin/user/delete_organisation_unit.html"); $paramquery = $_GET; $paramquery['sure'] = "true"; $params = http_build_query($paramquery); $template->set_var("yes_params", $params); $paramquery = $_GET; unset($paramquery['key']); $paramquery['action'] = "detail"; $params = http_build_query($paramquery); $template->set_var("no_params", $params); $template->output(); } else { $paramquery = $_GET; unset($paramquery['key']); unset($paramquery['sure']); $paramquery['action'] = "detail"; $params = http_build_query($paramquery); $organisation_unit = new OrganisationUnit($_GET['key']); if ($organisation_unit->delete_user_from_organisation_unit($_GET['id'])) { Common_IO::step_proceed($params, "Delete Organisation Unit", "Operation Successful", null); } else { Common_IO::step_proceed($params, "Delete Organisation Unit", "Operation Failed", null); } } } else { // Error } } else { throw new UserIDMissingException(); } }