/** * @todo IMPORTANT: remove bad dependency, replace with JS */ public static function add_organisation_unit() { if ($_GET['id']) { if ($_GET['nextpage'] == 1) { if (is_numeric($_POST['ou'])) { $organisation_unit = new OrganisationUnit($_POST['ou']); if ($organisation_unit->is_group_in_organisation_unit($_GET['id']) == true) { $page_1_passed = false; $error = "This organisation-unit is already member of the group."; } else { $page_1_passed = true; } } else { $page_1_passed = false; $error = "You must select an organisation unit."; } } elseif ($_GET['nextpage'] > 1) { $page_1_passed = true; } else { $page_1_passed = false; $error = ""; } if ($page_1_passed == false) { $template = new HTMLTemplate("base/user/admin/group/add_organisation_unit.html"); $paramquery = $_GET; $paramquery['nextpage'] = "1"; $params = http_build_query($paramquery, '', '&'); $template->set_var("params", $params); $template->set_var("error", $error); $organisation_unit_array = OrganisationUnit::list_entries(); $result = array(); $counter = 0; foreach ($organisation_unit_array as $key => $value) { $organisation_unit = new OrganisationUnit($value); $result[$counter]['value'] = $value; $result[$counter]['content'] = $organisation_unit->get_name(); $counter++; } $template->set_var("option", $result); $template->output(); } else { $organisation_unit = new OrganisationUnit($_POST['ou']); $paramquery = $_GET; $paramquery['action'] = "detail"; unset($paramquery['nextpage']); $params = http_build_query($paramquery, '', '&'); if ($organisation_unit->create_group_in_organisation_unit($_GET['id'])) { Common_IO::step_proceed($params, "Add Organisation Unit", "Operation Successful", null); } else { Common_IO::step_proceed($params, "Add Organisation Unit", "Operation Failed", null); } } } else { throw new GroupIDMissingException(); } }