/** * @todo IMPORTANT: remove bad dependency, replace with JS */ public static function delete_organisation_unit() { if ($_GET['id'] and $_GET['key']) { if ($_GET['sure'] != "true") { $template = new HTMLTemplate("base/user/admin/group/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_group_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 { throw new GroupIDMissingException(); } }
/** * @param integer $organisation_unit_id * @param integer $group_id * @return string * @throws BaseUserAccessDeniedException * @throws OrganisationUnitIDMissingException * @throws GroupIDMissingException */ public static function delete_group($organisation_unit_id, $group_id) { global $user; if ($user->is_admin()) { if (!is_numeric($organisation_unit_id)) { throw new OrganisationUnitIDMissingException(); } if (!is_numeric($group_id)) { throw new GroupIDMissingException(); } $organisation_unit = new OrganisationUnit($organisation_unit_id); if ($organisation_unit->delete_group_from_organisation_unit($group_id) == true) { return "1"; } else { return "0"; } } else { throw new BaseUserAccessDeniedException(); } }