/** * @throws ProjectIDMissingException * @throws ProjectSecurityAccessDeniedException */ public static function move() { global $project_security, $user; if ($_GET['project_id']) { $project = new Project($_GET['project_id']); if ($user->get_user_id() == $project->get_owner_id() or $project_security->is_access(7, false) == true) { if ($_GET['nextpage'] == 1) { if (is_numeric($_POST['type'])) { $page_1_passed = true; } else { $page_1_passed = false; $error = "You must make a selection."; } } elseif ($_GET['nextpage'] > 1) { $page_1_passed = true; } else { $page_1_passed = false; $error = ""; } if ($page_1_passed == false) { $template = new HTMLTemplate("project/admin/move_page_1.html"); $paramquery = $_GET; $paramquery['nextpage'] = "1"; $params = http_build_query($paramquery, '', '&'); $template->set_var("params", $params); $template->set_var("error", $error); $template->output(); } else { if ($_POST['type'] == 1) { if ($_GET['nextpage'] == 2) { if (is_numeric($_POST['ou'])) { $page_2_passed = true; } else { $page_2_passed = false; $error = "You must select an organisation unit."; } } elseif ($_GET['nextpage'] > 3) { $page_2_passed = true; } else { $page_2_passed = false; $error = ""; } if ($page_2_passed == false) { $template = new HTMLTemplate("project/admin/move_page_2_ou.html"); $paramquery = $_GET; $paramquery['nextpage'] = "2"; $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->set_var("type", $_POST['type']); $template->output(); } else { $project = new Project($_GET['project_id']); $paramquery = $_GET; unset($paramquery['nextpage']); $paramquery['run'] = "admin"; $params = http_build_query($paramquery); if ($project->move_to_organisation_unit($_POST['ou'])) { Common_IO::step_proceed($params, "Move Project", "Operation Successful", null); } else { Common_IO::step_proceed($params, "Move Project", "Operation Failed", null); } } } else { if ($_GET['nextpage'] == 2) { if (is_numeric($_POST['project'])) { $page_2_passed = true; } else { $page_2_passed = false; $error = "You must select a project."; } } elseif ($_GET['nextpage'] > 3) { $page_2_passed = true; } else { $page_2_passed = false; $error = ""; } if ($page_2_passed == false) { $template = new HTMLTemplate("project/admin/move_page_2_project.html"); $paramquery = $_GET; $paramquery['nextpage'] = "2"; $params = http_build_query($paramquery, '', '&'); $template->set_var("params", $params); $template->set_var("error", $error); $result = array(); $counter = 0; $project = new Project(null); $project_array = $project->get_project_tree(); foreach ($project_array as $key => $value) { $project = new Project($value['id']); for ($i = 1; $i <= $value['layer']; $i++) { $pre_content .= " "; } $result[$counter]['value'] = $value['id']; $result[$counter]['content'] = $pre_content . "" . $project->get_name(); $counter++; unset($pre_content); } if (!$result) { $result[$counter]['value'] = "0"; $result[$counter]['content'] = "NO PROJECT FOUND!"; } $template->set_var("option", $result); $template->set_var("type", $_POST['type']); $template->output(); } else { $project = new Project($_GET['project_id']); $paramquery = $_GET; unset($paramquery['nextpage']); $paramquery['run'] = "admin"; $params = http_build_query($paramquery); if ($project->move_to_project($_POST['project'])) { Common_IO::step_proceed($params, "Move Project", "Operation Successful", null); } else { Common_IO::step_proceed($params, "Move Project", "Operation Failed", null); } } } } } else { throw new ProjectSecurityAccessDeniedException(); } } else { throw new ProjectIDMissingException(); } }
/** * @throws EquipmentTypeIDMissingException */ public static function add_organisation_unit() { if ($_GET['id']) { if ($_GET['nextpage'] == 1) { if (is_numeric($_POST['ou'])) { $equipment_type = new EquipmentType($_GET['id']); if ($equipment_type->is_organisation_unit($_POST['ou']) == true) { $page_1_passed = false; $error = "The organisation units is already connected with this equipment."; } 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("equipment/admin/equipment_type/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 { $equipment_type = new EquipmentType($_GET['id']); $paramquery = $_GET; $paramquery['action'] = "detail"; unset($paramquery['nextpage']); $params = http_build_query($paramquery, '', '&'); if ($equipment_type->add_organisation_unit($_POST['ou'])) { 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 EquipmentTypeIDMissingException(); } }
/** * @param string $get_array * @return string * @throws ProjectSecurityAccessDeniedException * @throws ProjectIDMissingException */ public static function get_project_admin_menu($get_array) { global $user; if ($get_array) { $_GET = unserialize($get_array); } if ($_GET['project_id']) { $project = new Project($_GET['project_id']); $project_security = new ProjectSecurity($_GET['project_id']); $project_owner = new User($project->get_owner_id()); $organisation_unit_id = $project->get_organisation_unit_id(); $parent_project_id = $project->get_project_toid(); if ($user->get_user_id() == $project->get_owner_id() or $project_security->is_access(2, false) == true or $project_security->is_access(3, false) == true or $project_security->is_access(4, false) == true or $project_security->is_access(5, false) == true or $project_security->is_access(6, false) == true or $project_security->is_access(7, false) == true) { if ($organisation_unit_id) { $organisation_unit = new OrganisationUnit($organisation_unit_id); $parent = $organisation_unit->get_name(); $parent_type = "Organisation Unit"; } else { $parent_project = new Project($parent_project_id); $parent = $parent_project->get_name(); $parent_type = "Project"; } $template = new HTMLTemplate("project/ajax/admin/menu.html"); $template->set_var("name", $project->get_name()); $template->set_var("owner", $project_owner->get_full_name(false)); $template->set_var("parent", $parent); $template->set_var("parent_type", $parent_type); if ($user->is_admin()) { $template->set_var("admin", true); } else { $template->set_var("admin", false); } if ($project_security->is_access(7, false) == true or $project->get_owner_id() == $user->get_user_id()) { $template->set_var("owner_permission", true); } else { $template->set_var("owner_permission", false); } if ($project_security->is_access(6, false) == true) { $template->set_var("delete", true); } else { $template->set_var("delete", false); } if ($project_security->is_access(3, false) == true) { $template->set_var("write", true); } else { $template->set_var("write", false); } if ($project->get_current_status_id() == 0) { $template->set_var("project_canceled", true); } else { $template->set_var("project_canceled", false); } if ($project->get_deleted() == true) { $template->set_var("project_deleted", true); } else { $template->set_var("project_deleted", false); } if ($project->get_quota() == 0) { $template->set_var("quota", "unlimited"); } else { $template->set_var("quota", Convert::convert_byte_1024($project->get_quota())); } $permission_paramquery = $_GET; $permission_paramquery['run'] = "admin_permission"; unset($permission_paramquery['nextpage']); unset($permission_paramquery['sure']); $permission_params = http_build_query($permission_paramquery, '', '&'); $template->set_var("permission_params", $permission_params); $rename_paramquery = $_GET; $rename_paramquery['run'] = "admin_rename"; unset($rename_paramquery['nextpage']); unset($rename_paramquery['sure']); $rename_params = http_build_query($rename_paramquery, '', '&'); $template->set_var("rename_params", $rename_params); $chown_paramquery = $_GET; $chown_paramquery['run'] = "admin_chown"; unset($chown_paramquery['nextpage']); unset($chown_paramquery['sure']); $chown_params = http_build_query($chown_paramquery, '', '&'); $template->set_var("chown_params", $chown_params); $move_paramquery = $_GET; $move_paramquery['run'] = "admin_move"; unset($move_paramquery['nextpage']); unset($move_paramquery['sure']); $move_params = http_build_query($move_paramquery, '', '&'); $template->set_var("move_params", $move_params); $chquota_paramquery = $_GET; $chquota_paramquery['run'] = "admin_quota"; unset($chquota_paramquery['nextpage']); unset($chquota_paramquery['sure']); $chquota_params = http_build_query($chquota_paramquery, '', '&'); $template->set_var("chquota_params", $chquota_params); return $template->get_string(); } else { throw new ProjectSecurityAccessDeniedException(); } } else { throw new ProjectIDMissingException(); } }
/** * @throws OrganisationUnitIDMissingException */ public static function list_groups() { if ($_GET['ou_id']) { $organisation_unit = new OrganisationUnit($_GET['ou_id']); $argument_array = array(); $argument_array[0] = "organisation_unit_id"; $argument_array[1] = $_GET['ou_id']; $list = new List_IO("OrganisationUnitListGroups", "ajax.php?nav=organisation_unit", "list_groups", "count_groups", $argument_array, "OrganisationUnitListGroups"); $list->add_column("", "symbol", false, "16px"); $list->add_column(Language::get_message("OrganisationUnitGeneralColoumnGroupName", "general"), "groupname", true, null, "OrganisationUnitListSortGroupname"); $template = new HTMLTemplate("organisation_unit/list_groups.html"); $template->set_var("TITLE", "(" . $organisation_unit->get_name() . ")"); $template->set_var("list", $list->get_list()); $template->output(); } else { throw new OrganisationUnitIDMissingException(); } }
/** * @todo permission check */ public static function search() { global $user, $session; if ($_GET['nextpage']) { if ($_GET['page'] or $_GET['sortvalue'] or $_GET['sortmethod']) { $name = $session->read_value("SEARCH_SAMPLE_NAME"); $organisation_unit_array = $session->read_value("SEARCH_SAMPLE_ORGANISATION_UNIT_ARRAY"); $template_array = $session->read_value("SEARCH_SAMPLE_TEMPLATE_ARRAY"); $in_id = $session->read_value("SEARCH_SAMPLE_IN_ID"); $in_name = $session->read_value("SEARCH_SAMPLE_IN_NAME"); } else { if ($_GET['nextpage'] == "1") { $name = $_POST['string']; $session->delete_value("SEARCH_SAMPLE_NAME"); $session->delete_value("SEARCH_SAMPLE_ORGANISATION_UNIT_ARRAY"); $session->delete_value("SEARCH_SAMPLE_TEMPLATE_ARRAY"); $session->delete_value("SEARCH_SAMPLE_IN_ID"); $session->delete_value("SEARCH_SAMPLE_IN_NAME"); } else { $name = $_POST['string']; $organisation_unit_array = $session->read_value("SEARCH_SAMPLE_ORGANISATION_UNIT_ARRAY"); $template_array = $session->read_value("SEARCH_SAMPLE_TEMPLATE_ARRAY"); $in_id = $session->read_value("SEARCH_SAMPLE_IN_ID"); $in_name = $session->read_value("SEARCH_SAMPLE_IN_NAME"); } } $no_error = true; } else { $no_error = false; } if ($no_error == false) { $template = new HTMLTemplate("sample/search/search.html"); $paramquery = $_GET; unset($paramquery['page']); $paramquery['nextpage'] = "1"; $params = http_build_query($paramquery, '', '&'); $template->set_var("params", $params); $template->set_var("error", ""); $result = array(); $counter = 0; $organisation_unit_array = OrganisationUnit::list_entries(); if (is_array($organisation_unit_array) and count($organisation_unit_array) >= 1) { foreach ($organisation_unit_array as $key => $value) { $organisation_unit = new OrganisationUnit($value); if ($organisation_unit->is_permission($user->get_user_id())) { $result[$counter]['value'] = $value; $result[$counter]['content'] = $organisation_unit->get_name(); $result[$counter]['selected'] = ""; $counter++; } } } if (!$result) { $result[$counter]['value'] = "0"; $result[$counter]['content'] = "NO ORGANISATION UNIT FOUND!"; } $template->set_var("organ_unit", $result); $result = array(); $counter = 0; $sample_template_array = SampleTemplateCat::list_entries(); if (is_array($sample_template_array)) { foreach ($sample_template_array as $key => $value) { $sample_template_cat = new SampleTemplateCat($value); $result[$counter]['value'] = ""; $result[$counter]['content'] = $sample_template_cat->get_name(); $result[$counter]['selected'] = ""; $counter++; $sample_template_sub_array = SampleTemplate::list_entries_by_cat_id($value); if (is_array($sample_template_sub_array)) { foreach ($sample_template_sub_array as $sub_key => $sub_value) { $sample_sub_template = new SampleTemplate($sub_value); $result[$counter]['value'] = $sub_value; $result[$counter]['content'] = " " . $sample_sub_template->get_name(); $result[$counter]['selected'] = ""; $counter++; } } unset($sample_template_sub_array); } } else { $result[$counter]['value'] = "0"; $result[$counter]['content'] = "NO TEMPLATES FOUND!"; } $template->set_var("template", $result); $template->output(); } else { if (!$organisation_unit_array) { if (!$_POST['organisation_unit']) { $organisation_unit_array = array(); $organisation_unit_array = OrganisationUnit::list_entries(); if (is_array($organisation_unit_array) and count($organisation_unit_array) >= 1) { foreach ($organisation_unit_array as $key => $value) { $organisation_unit = new OrganisationUnit($value); if ($organisation_unit->is_permission($user->get_user_id())) { array_push($organisation_unit_array, $value); } } } $search_organisation_unit_name = "All"; } else { $organisation_unit_array = array(); $organisation_unit_array[0] = $_POST['organisation_unit']; $organisation_unit = new OrganisationUnit($_POST['organisation_unit']); $search_organisation_unit_name = $organisation_unit->get_name(); } } else { if (count($organisation_unit_array) == 1) { $organisation_unit = new OrganisationUnit($organisation_unit_array[0]); $search_organisation_unit_name = $organisation_unit->get_name(); } else { $search_organisation_unit_name = "All"; } } if (!$template_array) { if (!$_POST['template']) { $template_array = null; $search_template_name = "All"; } else { $template_array = array(); $template_array[0] = $_POST['template']; $sample_template = new SampleTemplate($_POST['template']); $search_template_name = $sample_template->get_name(); } } if (!isset($in_id)) { if ($_POST['in_id'] == 1) { $in_id = true; } else { $in_id = false; } } if (!isset($in_name)) { if ($_POST['in_name'] == 1) { $in_name = true; } else { $in_name = false; } } $session->write_value("SEARCH_SAMPLE_NAME", $name, true); $session->write_value("SEARCH_SAMPLE_ORGANISATION_UNIT_ARRAY", $organisation_unit_array, true); $session->write_value("SEARCH_SAMPLE_TEMPLATE_ARRAY", $template_array, true); $session->write_value("SEARCH_SAMPLE_IN_ID", $in_id, true); $session->write_value("SEARCH_SAMPLE_IN_NAME", $in_name, true); /* --------------- */ $argument_array = array(); $argument_array[0][0] = "name"; $argument_array[0][1] = $name; $argument_array[1][0] = "organisation_unit_array"; $argument_array[1][1] = $organisation_unit_array; $argument_array[2][0] = "template_array"; $argument_array[2][1] = $template_array; $argument_array[3][0] = "in_id"; $argument_array[3][1] = $in_id; $argument_array[4][0] = "in_name"; $argument_array[4][1] = $in_name; $list = new List_IO("SampleSearch", "ajax.php?nav=sample", "search_sample_list_samples", "search_sample_count_samples", $argument_array, "SampleSearch"); $list->add_column("", "symbol", false, "16px"); $list->add_column(Language::get_message("SampleGeneralListColumnSampleID", "general"), "id", true, "11%"); $list->add_column(Language::get_message("SampleGeneralListColumnSampleName", "general"), "name", true, null); $list->add_column(Language::get_message("SampleGeneralListColumnDate", "general"), "datetime", true, null); $list->add_column(Language::get_message("SampleGeneralListColumnTypeTemplate", "general"), "template", true, null); $list->add_column(Language::get_message("SampleGeneralListColumnCurrentLocation", "general"), "location", true, null); $list->add_column(Language::get_message("SampleGeneralListColumnAvailable", "general"), "av", false, "16px"); $template = new HTMLTemplate("sample/search/search_result.html"); $paramquery = $_GET; $paramquery['nextpage'] = "2"; unset($paramquery['page']); unset($paramquery['sortvalue']); unset($paramquery['sortmethod']); $params = http_build_query($paramquery, '', '&'); $template->set_var("params", $params); $template->set_var("name", $name); $template->set_var("organisation_units", $search_organisation_unit_name); $template->set_var("templates", $search_template_name); $template->set_var("list", $list->get_list()); $template->output(); } }
/** * @param string $json_column_array * @param string $json_argument_array * @param string $get_array * @param string $css_page_id * @param string $css_row_sort_id * @param string $entries_per_page * @param string $page * @param string $sortvalue * @param string $sortmethod * @return string * @throws SampleIDMissingException * @throws SampleSecurityAccessDeniedException */ public static function list_organisation_unit_permissions($json_column_array, $json_argument_array, $get_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod) { global $user; if ($get_array) { $_GET = unserialize($get_array); } $argument_array = json_decode($json_argument_array); $sample_id = $argument_array[1]; if (is_numeric($sample_id)) { $sample = new Sample($sample_id); if ($sample->get_owner_id() == $user->get_user_id() or $user->is_admin() == true) { $list_request = new ListRequest_IO(); $list_request->set_column_array($json_column_array); if (!is_numeric($entries_per_page) or $entries_per_page < 1) { $entries_per_page = 20; } $list_array = Sample_Wrapper::list_sample_organisation_units($sample_id, $sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page); if (is_array($list_array) and count($list_array) >= 1) { foreach ($list_array as $key => $value) { $list_array[$key]['symbol'] = "<img src='images/icons/organisation_unit.png' alt='' style='border:0;' />"; if ($list_array[$key]['organisation_unit_id']) { $organisation_unit = new OrganisationUnit($list_array[$key]['organisation_unit_id']); } else { $organisation_unit = new OrganisationUnit(1); } $list_array[$key]['name'] = $organisation_unit->get_name(); $delete_paramquery = $_GET; $delete_paramquery['run'] = "admin_permission_ou_delete"; $delete_paramquery['id'] = $list_array[$key]['organisation_unit_id']; unset($delete_paramquery['sure']); $delete_params = http_build_query($delete_paramquery, '', '&'); $list_array[$key]['delete']['link'] = $delete_params; $list_array[$key]['delete']['content'] = "delete"; } } else { $list_request->empty_message("<span class='italic'>No results found!</span>"); } $list_request->set_array($list_array); return $list_request->get_page($page); } else { throw new SampleSecurityAccessDeniedException(); } } else { throw new SampleIDMissingException(); } }
/** * @param integer $page * @return string * @throws BaseAssistantRequestedPageNotExistsException */ public static function get_content($page) { global $session, $user; switch ($page) { case "0": $template = new HTMLTemplate("project/new_project_page_0.html"); return $template->get_string(); break; case "1": $template = new HTMLTemplate("project/new_project_page_1.html"); if ($session->read_value("PROJECT_TYPE") == 1 or $session->read_value("PROJECT_TYPE") == 2) { $project_organ_unit = $session->read_value("PROJECT_ORGANISATION_UNIT"); $template->set_var("organunit", true); $result = array(); $counter = 0; $organisation_unit_array = OrganisationUnit::list_entries(); if (is_array($organisation_unit_array) and count($organisation_unit_array) >= 1) { foreach ($organisation_unit_array as $key => $value) { $organisation_unit = new OrganisationUnit($value); if ($organisation_unit->is_permission($user->get_user_id()) and $organisation_unit->get_stores_data() == true) { $result[$counter]['value'] = $value; $result[$counter]['content'] = $organisation_unit->get_name(); if ($project_organ_unit == $value) { $result[$counter]['selected'] = "selected"; } else { $result[$counter]['selected'] = ""; } $result[$counter]['disabled'] = ""; $counter++; } } } if (!$result) { $result[$counter]['value'] = "0"; $result[$counter]['content'] = "NO ORGANISATION UNIT FOUND!"; $result[$counter]['selected'] = ""; $result[$counter]['disabled'] = "disabled='disabled'"; } $template->set_var("option", $result); } else { $project_toid = $session->read_value("PROJECT_TOID"); $template->set_var("organunit", false); $result = array(); $counter = 0; $project = new Project(null); $project_array = $project->get_project_tree(); if (is_array($project_array) and count($project_array) >= 1) { foreach ($project_array as $key => $value) { $project = new Project($value['id']); for ($i = 1; $i <= $value['layer']; $i++) { $pre_content .= " "; } $result[$counter]['value'] = $value['id']; $result[$counter]['content'] = $pre_content . "" . $project->get_name(); if ($project_toid == $value['id']) { $result[$counter]['selected'] = "selected"; } else { $result[$counter]['selected'] = ""; } $result[$counter]['disabled'] = ""; $counter++; unset($pre_content); } } else { $result[$counter]['value'] = "0"; $result[$counter]['content'] = "NO PROJECT FOUND!"; $result[$counter]['selected'] = ""; $result[$counter]['disabled'] = "disabled='disabled'"; } $template->set_var("option", $result); } return $template->get_string(); break; case "2": $project_name = $session->read_value("PROJECT_NAME"); $project_desc = $session->read_value("PROJECT_DESCRIPTION"); $template = new HTMLTemplate("project/new_project_page_2.html"); if ($project_name) { $template->set_var("project_name", $project_name); } else { $template->set_var("project_name", ""); } if ($project_desc) { $template->set_var("project_description", $project_desc); } else { $template->set_var("project_description", ""); } return $template->get_string(); break; case "3": $project_template = $session->read_value("PROJECT_TEMPLATE"); $template = new HTMLTemplate("project/new_project_page_3.html"); $result = array(); $counter = 0; $project_template_array = ProjectTemplateCat::list_entries(); if (is_array($project_template_array)) { foreach ($project_template_array as $key => $value) { $project_template_cat = new ProjectTemplateCat($value); $result[$counter]['value'] = "0"; $result[$counter]['content'] = $project_template_cat->get_name(); $result[$counter]['selected'] = ""; $result[$counter]['disabled'] = "disabled='disabled'"; $counter++; $project_template_sub_array = ProjectTemplate::list_entries_by_cat_id($value); if (is_array($project_template_sub_array)) { foreach ($project_template_sub_array as $sub_key => $sub_value) { $project_sub_template = new ProjectTemplate($sub_value); if (($session->read_value("PROJECT_TYPE") == 1 or $session->read_value("PROJECT_TYPE") == 3) and $project_sub_template->get_parent_template() == false) { $result[$counter]['value'] = $sub_value; $result[$counter]['content'] = " " . $project_sub_template->get_name(); if ($project_template == $sub_value) { $result[$counter]['selected'] = "selected"; } else { $result[$counter]['selected'] = ""; } $result[$counter]['disabled'] = ""; $counter++; } elseif (($session->read_value("PROJECT_TYPE") == 2 or $session->read_value("PROJECT_TYPE") == 4) and $project_sub_template->get_parent_template() == true) { $result[$counter]['value'] = $sub_value; $result[$counter]['content'] = " " . $project_sub_template->get_name(); if ($project_template == $sub_value) { $result[$counter]['selected'] = "selected"; } else { $result[$counter]['selected'] = ""; } $result[$counter]['disabled'] = ""; $counter++; } } } unset($project_template_sub_array); } } else { $result[$counter]['value'] = "0"; $result[$counter]['content'] = "NO TEMPLATES FOUND!"; $result[$counter]['selected'] = ""; $result[$counter]['disabled'] = "disabled='disabled'"; } $template->set_var("option", $result); return $template->get_string(); break; case "4": $project_template = $session->read_value("PROJECT_TEMPLATE"); $project_template_data_type = $session->read_value("PROJECT_TEMPLATE_DATA_TYPE"); $project_template_data_array = $session->read_value("PROJECT_TEMPLATE_DATA_ARRAY"); $project_template_obj = new ProjectTemplate($project_template); $required_array = $project_template_obj->get_required_requirements(); if (is_array($required_array) and count($required_array) >= 1) { $value_type_id = 0; $sample_count = 0; $is_value = false; $is_sample = false; foreach ($required_array as $key => $value) { if ($value['xml_element'] == "item") { if ($value['type'] == "value") { $is_value = true; } } if ($value['xml_element'] == "type" and !$value['close'] and $is_value == true) { $value_type_id = $value['id']; } } if ($is_value == true) { $template = new HTMLTemplate("project/new_project_page_4_value.html"); require_once "core/modules/data/io/value_form.io.php"; $value_form_io = new ValueFormIO(null, $value_type_id, null, $project_template_data_array); $value_form_io->set_field_class("ProjectCreateAssistantField"); $template->set_var("content", $value_form_io->get_content()); $template->set_var("project_template_data_type_id", $value_type_id); return $template->get_string(); } else { $template = new HTMLTemplate("project/new_project_page_4_error.html"); return $template->get_string(); } } else { $template = new HTMLTemplate("project/new_project_page_4_error.html"); return $template->get_string(); } break; case "5": $template = new HTMLTemplate("project/new_project_page_5.html"); $project_template = new ProjectTemplate($session->read_value("PROJECT_TEMPLATE")); $template->set_var("project_name", $session->read_value("PROJECT_NAME")); $template->set_var("project_template", $project_template->get_name()); $template->set_var("project_description", $session->read_value("PROJECT_DESCRIPTION")); $template->set_var("content", ""); return $template->get_string(); break; default: throw new BaseAssistantRequestedPageNotExistsException(); break; } }
/** * @todo search on read-only projects */ public static function search() { global $user, $session; if ($_GET['nextpage']) { if ($_GET['sortvalue'] and $_GET['sortmethod']) { if ($_GET['nextpage'] == "2" and $_POST['string']) { $string = $_POST['string']; $item_type_array = $session->read_value("SEARCH_DATA_ITEM_TYPE"); $project_id_array = $session->read_value("SEARCH_DATA_PROJECT_ID"); } else { $string = $session->read_value("SEARCH_DATA_STRING"); $item_type_array = $session->read_value("SEARCH_DATA_ITEM_TYPE"); $project_id_array = $session->read_value("SEARCH_DATA_PROJECT_ID"); } } else { if ($_GET['page']) { $string = $session->read_value("SEARCH_DATA_STRING"); $item_type_array = $session->read_value("SEARCH_DATA_ITEM_TYPE"); $project_id_array = $session->read_value("SEARCH_DATA_PROJECT_ID"); } else { if ($_GET['nextpage'] == "1") { $string = $_POST['string']; $session->delete_value("SEARCH_DATA_STRING"); $session->delete_value("SEARCH_DATA_ITEM_TYPE"); $session->delete_value("SEARCH_DATA_PROJECT_ID"); } else { $string = $_POST['string']; $item_type_array = $session->read_value("SEARCH_DATA_ITEM_TYPE"); $project_id_array = $session->read_value("SEARCH_DATA_PROJECT_ID"); } } } $no_error = true; } else { $no_error = false; } if ($no_error == false) { $template = new HTMLTemplate("project/search/data_search.html"); $template->set_var("error", ""); $paramquery = $_GET; unset($paramquery['page']); $paramquery['nextpage'] = "1"; $params = http_build_query($paramquery, '', '&'); $template->set_var("params", $params); $result = array(); $counter = 0; $project_array = Project::list_user_related_projects($user->get_user_id(), false); if (is_array($project_array) and count($project_array) >= 1) { foreach ($project_array as $key => $value) { $project = new Project($value); $organisation_unit = new OrganisationUnit($project->get_organisation_unit_id()); $result[$counter]['value'] = $value; $result[$counter]['content'] = $project->get_name() . " (" . $organisation_unit->get_name() . ")"; $result[$counter]['selected'] = ""; $counter++; } } $template->set_var("project_array", $result); $result = array(); $counter = 0; $item_type_array = Item::list_types(); if (is_array($item_type_array)) { foreach ($item_type_array as $key => $value) { if (class_exists($value)) { if ($value::get_sql_select_array($key) != null) { $result[$counter]['title'] = $value::get_generic_name($key, null); $result[$counter]['name'] = "item-" . $key; $result[$counter]['value'] = $key; $result[$counter]['checked'] = "checked='checked'"; $counter++; } } } } $template->set_var("item_type_array", $result); $template->output(); } else { if (!$project_id_array) { if ($_POST['project_id'] == 0) { $project_id_array = array(); $tmp_id_array = Project::list_user_related_projects($user->get_user_id(), false); if (is_array($tmp_id_array) and count($tmp_id_array) >= 1) { foreach ($tmp_id_array as $key => $value) { array_push($project_id_array, $value); } } } else { $project_id_array = array(); $project_id_array[0] = $_POST['project_id']; $project = new Project($_POST['project_id']); $search_name = $project->get_name(); } } else { if (count($project_id_array) == 1) { $project = new Project($project_id_array[0]); $search_name = $project->get_name(); } else { $search_name = "All"; } } if (!$item_type_array) { $item_type_array = array(); foreach ($_POST as $key => $value) { if (strpos($key, "item-") === 0) { array_push($item_type_array, $value); } } if (!$item_type_array) { $tmp_item_type_array = Item::list_types(); foreach ($tmp_item_type_array as $key => $value) { if (class_exists($value)) { if ($value::get_sql_select_array($key) != null) { array_push($item_type_array, $key); } } } } } $session->write_value("SEARCH_DATA_STRING", $string, true); $session->write_value("SEARCH_DATA_ITEM_TYPE", $item_type_array, true); $session->write_value("SEARCH_DATA_PROJECT_ID", $project_id_array, true); $argument_array = array(); $argument_array[0][0] = "string"; $argument_array[0][1] = $string; $argument_array[1][0] = "project_id_array"; $argument_array[1][1] = $project_id_array; $argument_array[2][0] = "item_type_array"; $argument_array[2][1] = $item_type_array; $list = new List_IO("ProjectDataSearch", "ajax.php?nav=project", "search_project_data_list_projects", "search_project_data_count_projects", $argument_array, "ProjectDataSearch"); $list->add_column("", "symbol", false, "16px"); $list->add_column(Language::get_message("ProjectGeneralListColumnName", "general"), "name", true, null); $list->add_column(Language::get_message("ProjectGeneralListColumnType", "general"), "type", false, null); $list->add_column(Language::get_message("ProjectGeneralListColumnDateTime", "general"), "datetime", true, null); $list->add_column(Language::get_message("ProjectGeneralListColumnProject", "general"), "project_name", true, null); $template = new HTMLTemplate("project/search/data_search_result.html"); $paramquery = $_GET; $paramquery['nextpage'] = "2"; $params = http_build_query($paramquery, '', '&'); $template->set_var("params", $params); $template->set_var("string", $string); $template->set_var("list", $list->get_list()); $template->output(); } }
/** * @see EventListenerInterface::listen_events() * @param object $event_object * @return bool */ public static function listen_events($event_object) { if ($event_object instanceof OrganisationUnitCreateEvent) { if ($event_object->get_stores_data() == true) { $organisation_unit_folder = new OrganisationUnitFolder(null); if ($organisation_unit_folder->create($event_object->get_organisation_unit_id()) == false) { return false; } } } if ($event_object instanceof OrganisationUnitPostDeleteEvent) { if ($event_object->get_stores_data() == true) { $folder_id = OrganisationUnitFolder::get_folder_by_organisation_unit_id($event_object->get_organisation_unit_id()); $organisation_unit_folder = new OrganisationUnitFolder($folder_id); if ($organisation_unit_folder->delete(true, true) == false) { return false; } } } if ($event_object instanceof OrganisationUnitRenameEvent) { $organisation_unit = new OrganisationUnit($event_object->get_organisation_unit_id()); $organisation_unit_folder = new OrganisationUnitFolder(self::get_folder_by_organisation_unit_id($event_object->get_organisation_unit_id())); if ($organisation_unit_folder->set_name($organisation_unit->get_name()) == false) { return false; } } if ($event_object instanceof OrganisationUnitChangeOwnerEvent) { $organisation_unit = new OrganisationUnit($event_object->get_organisation_unit_id()); $folder_id = self::get_folder_by_organisation_unit_id($event_object->get_organisation_unit_id()); if ($folder_id) { $organisation_unit_folder = new OrganisationUnitFolder($folder_id); if ($organisation_unit_folder->set_owner_id($organisation_unit->get_master_owner_id()) == false) { return false; } } } return true; }
/** * @throws EquipmentTypeIDMissingException */ public static function type_detail($type_id, $owner_id) { if (is_numeric($type_id)) { $equipment_type = new EquipmentType($type_id); $equipment_owner = new User($owner_id); $template = new HTMLTemplate("equipment/detail.html"); $template->set_var("name", $equipment_type->get_name()); $template->set_var("category", $equipment_type->get_cat_name()); if ($equipment_type->get_location_id() == null) { $template->set_var("location", "<span class='italic'>none</span>"); } else { $location = new Location($equipment_type->get_location_id()); $template->set_var("location", $location->get_name(true)); } $template->set_var("owner", $equipment_owner->get_full_name(false)); if ($equipment_type->get_description()) { $template->set_var("description", $equipment_type->get_description()); } else { $template->set_var("description", "<span class='italic'>none</span>"); } $user_array = $equipment_type->list_users(); $user_content_array = array(); $counter = 0; if (is_array($user_array) and count($user_array) >= 1) { foreach ($user_array as $key => $value) { $user = new User($value); $user_content_array[$counter]['username'] = $user->get_username(); $user_content_array[$counter]['fullname'] = $user->get_full_name(false); $counter++; } $template->set_var("no_user", false); } else { $template->set_var("no_user", true); } $template->set_var("user", $user_content_array); $ou_array = $equipment_type->list_organisation_units(); $ou_content_array = array(); $counter = 0; if (is_array($ou_array) and count($ou_array) >= 1) { foreach ($ou_array as $key => $value) { $organisation_unit = new OrganisationUnit($value); $ou_content_array[$counter]['name'] = $organisation_unit->get_name(); $counter++; } $template->set_var("no_ou", false); } else { $template->set_var("no_ou", true); } $template->set_var("ou", $ou_content_array); $template->output(); } else { throw new EquipmentTypeIDMissingException(); } }
/** * @param integer $page * @return string * @throws BaseAssistantRequestPageNotExistsException */ public static function get_content($page) { global $session, $user; switch ($page) { case "1": $sample_organ_unit = $session->read_value("SAMPLE_ORGANISATION_UNIT"); $template = new HTMLTemplate("sample/new_sample_page_1.html"); $result = array(); $counter = 0; $organisation_unit_array = OrganisationUnit::list_entries(); foreach ($organisation_unit_array as $key => $value) { $organisation_unit = new OrganisationUnit($value); if ($organisation_unit->is_permission($user->get_user_id()) and $organisation_unit->get_stores_data() == true) { $result[$counter]['value'] = $value; $result[$counter]['content'] = $organisation_unit->get_name(); if ($sample_organ_unit == $value) { $result[$counter]['selected'] = "selected"; } else { $result[$counter]['selected'] = ""; } $result[$counter]['disabled'] = ""; $counter++; } } if (!$result) { $result[$counter]['value'] = "0"; $result[$counter]['content'] = "NO ORGANISATION UNIT FOUND!"; $result[$counter]['selected'] = ""; $result[$counter]['disabled'] = "disabled='disabled'"; } $template->set_var("option", $result); return $template->get_string(); break; case "2": $sample_template = $session->read_value("SAMPLE_TEMPLATE"); $type_array = $session->read_value("SAMPLE_ITEM_TYPE_ARRAY"); $template = new HTMLTemplate("sample/new_sample_page_2.html"); if (!is_array($type_array) or count($type_array) == 0) { $type_array = null; } $result = array(); $counter = 0; $sample_template_array = SampleTemplate::list_entries(); if (is_array($sample_template_array)) { foreach ($sample_template_array as $key => $value) { if ($type_array == null or in_array($value, $type_array)) { $sample_sub_template = new SampleTemplate($value); $result[$counter]['value'] = $value; $result[$counter]['content'] = $sample_sub_template->get_name(); if ($sample_template == $value) { $result[$counter]['selected'] = "selected"; } else { $result[$counter]['selected'] = ""; } $result[$counter]['disabled'] = ""; $counter++; } } } else { $result[$counter]['value'] = "0"; $result[$counter]['content'] = "NO TEMPLATES FOUND!"; $result[$counter]['selected'] = ""; $result[$counter]['disabled'] = "disabled='disabled'"; } $template->set_var("option", $result); if ($session->is_value("ADD_ITEM_TEMP_KEYWORDS_" . $_GET['idk_unique_id']) == true) { $template->set_var("keywords", $session->read_value("ADD_ITEM_TEMP_KEYWORDS_" . $_GET['idk_unique_id'])); } else { $template->set_var("keywords", ""); } if ($session->is_value("ADD_ITEM_TEMP_DESCRIPTION_" . $_GET['idk_unique_id']) == true) { $template->set_var("description", $session->read_value("ADD_ITEM_TEMP_DESCRIPTION_" . $_GET['idk_unique_id'])); } else { $template->set_var("description", ""); } return $template->get_string(); break; case "3": $sample_template = $session->read_value("SAMPLE_TEMPLATE"); $sample_name = $session->read_value("SAMPLE_NAME"); $sample_manufacturer = $session->read_value("SAMPLE_MANUFACTURER_ID"); $sample_manufacturer_name = $session->read_value("SAMPLE_MANUFACTURER_NAME"); $sample_location = $session->read_value("SAMPLE_LOCATION"); $sample_expiry = $session->read_value("SAMPLE_EXPIRY"); $sample_expiry_warning = $session->read_value("SAMPLE_EXPIRY_WARNING"); $sample_description = $session->read_value("SAMPLE_DESCRIPTION"); $sample_template_obj = new SampleTemplate($sample_template); $information_fields = $sample_template_obj->get_information_fields(); $template = new HTMLTemplate("sample/new_sample_page_3.html"); if ($information_fields['manufacturer']['name'] and $information_fields['manufacturer']['requirement'] != "optional") { $template->set_var("check_manufacturer", true); } else { $template->set_var("check_manufacturer", false); } if ($information_fields['expiry']['name'] and $information_fields['expiry']['requirement'] != "optional") { $template->set_var("check_expiry", true); } else { $template->set_var("check_expiry", false); } if ($information_fields['location']['name'] and $information_fields['location']['requirement'] != "optional") { $template->set_var("check_location", true); } else { $template->set_var("check_location", false); } if ($sample_name) { $template->set_var("name", $sample_name); } else { $template->set_var("name", ""); } if ($information_fields['manufacturer']['name']) { require_once "core/modules/manufacturer/io/manufacturer.io.php"; $template->set_var("show_manufacturer", true); $template->set_var("manufacturer_html", ManufacturerIO::dialog()); } else { $template->set_var("show_manufacturer", false); $template->set_var("manufacturer_html", ""); } if ($information_fields['expiry']['name']) { $template->set_var("show_expiry", true); } else { $template->set_var("show_expiry", false); } if ($information_fields['location']['name']) { $template->set_var("show_location", true); $result = array(); $counter = 0; $sample_location_array = Location::list_entries(); if (is_array($sample_location_array) and count($sample_location_array) >= 1) { foreach ($sample_location_array as $key => $value) { $sample_location_obj = new Location($value); $result[$counter]['value'] = $value; $result[$counter]['content'] = $sample_location_obj->get_name(true); if ($sample_location == $value) { $result[$counter]['selected'] = "selected"; } else { $result[$counter]['selected'] = ""; } $counter++; } } else { $result[$counter]['value'] = "0"; $result[$counter]['content'] = "NO LOCATIONS FOUND!"; } $template->set_var("location", $result); } else { $template->set_var("show_location", false); } if ($sample_manufacturer) { $template->set_var("manufacturer", $sample_manufacturer); } else { $template->set_var("manufacturer", ""); } if ($sample_manufacturer_name) { $template->set_var("manufacturer_name", $sample_manufacturer_name); } else { $template->set_var("manufacturer_name", ""); } if ($sample_expiry) { $template->set_var("expiry", $sample_expiry); } else { $template->set_var("expiry", ""); } if ($sample_expiry_warning) { $template->set_var("expiry_warning", $sample_expiry_warning); } else { $template->set_var("expiry_warning", (int) Registry::get_value("sample_default_expiry_warning")); } if ($sample_description) { $template->set_var("desc", $sample_description); } else { $template->set_var("desc", ""); } return $template->get_string(); break; case "4": $sample_add_role = $session->read_value("SAMPLE_ADD_ROLE"); $sample_add_item_holder_class = $session->read_value("SAMPLE_ADD_ITEM_HOLDER_CLASS"); $sample_add_item_holder_id = $session->read_value("SAMPLE_ADD_ITEM_HOLDER_ID"); $sample_template = $session->read_value("SAMPLE_TEMPLATE"); $sample_template_data_type = $session->read_value("SAMPLE_TEMPLATE_DATA_TYPE"); $sample_template_data_type_id = $session->read_value("SAMPLE_TEMPLATE_DATA_TYPE_ID"); $sample_template_data_array = $session->read_value("SAMPLE_TEMPLATE_DATA_ARRAY"); $sample_template_obj = new SampleTemplate($sample_template); $required_array = $sample_template_obj->get_required_requirements(); if (is_array($required_array) and count($required_array) >= 1) { $value_type_id = 0; $sample_count = 0; $is_value = false; $is_sample = false; foreach ($required_array as $key => $value) { if ($value['xml_element'] == "item") { if ($value['type'] == "value") { $is_value = true; } elseif ($value['type'] == "parentsample") { $is_sample = true; $sample_count++; } } if ($value['xml_element'] == "type" and !$value['close'] and $is_value == true) { $value_type_id = $value['id']; } } if ($is_value == true xor $is_sample == true) { if ($is_value == true) { $template = new HTMLTemplate("sample/new_sample_page_4_value.html"); require_once "core/modules/data/io/value_form.io.php"; $value_form_io = new ValueFormIO(null, $value_type_id, null, $sample_template_data_array); $value_form_io->set_field_class("SampleCreateAssistantField"); $template->set_var("content", $value_form_io->get_content()); $template->set_var("template_data_type_id", $value_type_id); return $template->get_string(); } else { $template = new HTMLTemplate("sample/new_sample_page_4_sample.html"); if ($sample_count > 0) { $result = array(); if ($sample_add_role == "item" and is_numeric($sample_add_item_holder_id) and class_exists($sample_add_item_holder_class)) { $item_holder_list_sql = $sample_add_item_holder_class::get_item_list_sql($sample_add_item_holder_id); if ($item_holder_list_sql) { $sample_array = Sample::list_samples_by_item_sql_list($item_holder_list_sql); } else { $sample_array = Sample::list_user_related_samples($user->get_user_id()); } } else { $sample_array = Sample::list_user_related_samples($user->get_user_id()); } for ($i = 0; $i <= $sample_count - 1; $i++) { $result[$i]['id'] = $i + 1; if ($sample_template_data_type == "sample") { if ($sample_template_data_array['sample-' . $result[$i]['id'] . '']) { $selected_id = $sample_template_data_array['sample-' . $result[$i]['id'] . '']; } } if (is_array($sample_array) and count($sample_array) >= 1) { $counter = 0; foreach ($sample_array as $key => $value) { $sample = new Sample($value); $result[$i][$counter]['value'] = $value; $result[$i][$counter]['content'] = $sample->get_name(); if ($selected_id == $value) { $result[$i][$counter]['selected'] = "selected"; } else { $result[$i][$counter]['selected'] = ""; } $counter++; } } else { $result[$i][0]['value'] = 0; $result[$i][0]['content'] = "You have no samples"; $result[$i][0]['selected'] = ""; } unset($selected_id); } $template->set_var("sample", $result); } return $template->get_string(); } } else { $template = new HTMLTemplate("sample/new_sample_page_4_error.html"); return $template->get_string(); } } else { $template = new HTMLTemplate("sample/new_sample_page_4_error.html"); return $template->get_string(); } break; case "5": $sample_organ_unit = $session->read_value("SAMPLE_ORGANISATION_UNIT"); $sample_template = $session->read_value("SAMPLE_TEMPLATE"); $sample_name = $session->read_value("SAMPLE_NAME"); $sample_manufacturer = $session->read_value("SAMPLE_MANUFACTURER_ID"); $sample_manufacturer_name = $session->read_value("SAMPLE_MANUFACTURER_NAME"); $sample_location = $session->read_value("SAMPLE_LOCATION"); $sample_expiry = $session->read_value("SAMPLE_EXPIRY"); $sample_expiry_warning = $session->read_value("SAMPLE_EXPIRY_WARNING"); $sample_description = $session->read_value("SAMPLE_DESCRIPTION"); $template = new HTMLTemplate("sample/new_sample_page_5.html"); $organisation_unit = new OrganisationUnit($sample_organ_unit); $template->set_var("sample_organisation_unit", $organisation_unit->get_name()); $sample_template_obj = new SampleTemplate($sample_template); $template->set_var("sample_template", $sample_template_obj->get_name()); $template->set_var("sample_name", $sample_name); if ($sample_manufacturer) { $template->set_var("sample_manufacturer", $sample_manufacturer_name); } else { $template->set_var("sample_manufacturer", false); } if ($sample_location) { $sample_location_obj = new Location($sample_location); $template->set_var("sample_location", $sample_location_obj->get_name(true)); } else { $template->set_var("sample_location", false); } if ($sample_expiry) { $template->set_var("sample_date_of_expiry", $sample_expiry); } else { $template->set_var("sample_date_of_expiry", false); } if ($sample_desc) { $sample_desc_display = str_replace("\n", "<br />", $sample_desc); $template->set_var("sample_description", $sample_desc_display); } else { $template->set_var("sample_description", "<span class='italic'>None</span>"); } return $template->get_string(); break; default: throw new BaseAssistantRequestedPageNotExistsException(); break; } }
/** * @throws GroupIDMissingException */ public static function group_details() { if ($_GET['id']) { $group = new Group($_GET['id']); $template = new HTMLTemplate("base/user/group_details.html"); $template->set_var("name", $group->get_name()); $user_array = Group::list_group_releated_users($_GET['id']); $user_content_array = array(); $counter = 0; if (is_array($user_array) and count($user_array) >= 1) { foreach ($user_array as $key => $value) { $user = new User($value); $paramquery = $_GET; $paramquery['dialog'] = "user_detail"; $paramquery['id'] = $value; $params = http_build_query($paramquery, '', '&'); $user_content_array[$counter]['username'] = $user->get_username(); $user_content_array[$counter]['fullname'] = $user->get_full_name(false); $user_content_array[$counter]['params'] = $params; $counter++; } $template->set_var("no_user", false); } else { $template->set_var("no_user", true); } $template->set_var("user", $user_content_array); $organisation_unit_array = OrganisationUnit::list_entries_by_group_id($_GET['id']); $organisation_unit_content_array = array(); $counter = 0; if (is_array($organisation_unit_array) and count($organisation_unit_array) >= 1) { foreach ($organisation_unit_array as $key => $value) { $organisation_unit = new OrganisationUnit($value); $organisation_unit_content_array[$counter]['name'] = $organisation_unit->get_name(); $counter++; } $template->set_var("no_ou", false); } else { $template->set_var("no_ou", true); } $template->set_var("ou", $organisation_unit_content_array); $template->output(); } else { throw new GroupIDMissingException(); } }
/** * @throws OrganisationUnitIDMissingException */ public static function rename() { if ($_GET['id']) { $organisation_unit = new OrganisationUnit($_GET['id']); if ($_GET['nextpage'] == 1) { if ($_POST['name']) { if (OrganisationUnit::exist_name($_POST['name']) == true) { $page_1_passed = false; $error = "This name is already allocated."; } else { $page_1_passed = true; } } else { $page_1_passed = false; $error = "You must enter a name."; } } elseif ($_GET['nextpage'] > 1) { $page_1_passed = true; } else { $page_1_passed = false; $error = ""; } if ($page_1_passed == false) { $template = new HTMLTemplate("organisation_unit/admin/organisation_unit/rename.html"); $paramquery = $_GET; $paramquery['nextpage'] = "1"; $params = http_build_query($paramquery, '', '&'); $template->set_var("params", $params); $template->set_var("error", $error); if ($_POST['username']) { $template->set_var("name", $_POST['name']); } else { $template->set_var("name", $organisation_unit->get_name()); } $template->output(); } else { $paramquery = $_GET; $paramquery['action'] = "detail"; unset($paramquery['nextpage']); $params = http_build_query($paramquery, '', '&'); if ($organisation_unit->set_name($_POST['name'])) { Common_IO::step_proceed($params, "Rename User", "Operation Successful", null); } else { Common_IO::step_proceed($params, "Rename User", "Operation Failed", null); } } } else { throw new OrganisationUnitIDMissingException(); } }
/** * @throws SampleIDMissingException * @throws SampleSecurityAccessDeniedException */ public static function ou_permission_add() { global $user; if ($_GET['sample_id']) { $sample_id = $_GET['sample_id']; $sample = new Sample($sample_id); $sample_security = new SampleSecurity($sample_id); if ($sample->get_owner_id() == $user->get_user_id() or $user->is_admin() == true) { if ($_GET['nextpage'] == 1) { if (is_numeric($_POST['ou'])) { if ($sample_security->is_organisation_unit($_POST['ou']) == true) { $page_1_passed = false; $error = "This organisation unit was already added."; } 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("sample/int_admin/ou_permission_add.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 { $paramquery = $_GET; unset($paramquery['nextpage']); unset($paramquery['sure']); $paramquery['nav'] = "sample"; $paramquery['run'] = "admin_permission_ou"; $params = http_build_query($paramquery); if ($sample_security->create_organisation_unit($_POST['ou'])) { Common_IO::step_proceed($params, "Add Permission", "Operation Successful", null); } else { Common_IO::step_proceed($params, "Add Permission", "Operation Failed", null); } } } else { throw new SampleSecurityAccessDeniedException(); } } else { throw new SampleIDMissingException(); } }
/** * @param integer $id */ public static function get_children($id) { if (is_numeric($id) and $id != 0) { $return_array = array(); $organisation_unit = new OrganisationUnit($id); $organisation_unit_array = $organisation_unit->get_organisation_unit_children(); if (is_array($organisation_unit_array) and count($organisation_unit_array) >= 1) { $counter = 0; foreach ($organisation_unit_array as $key => $value) { $organisation_unit = new OrganisationUnit($value); $return_array[$counter][0] = -1; $return_array[$counter][1] = $value; $return_array[$counter][2] = $organisation_unit->get_name(); $return_array[$counter][3] = $organisation_unit->get_icon(); $return_array[$counter][4] = true; // Permission if ($organisation_unit->get_stores_data() == true) { $module_link_array = ModuleLink::list_links_by_type("ou_navigation"); if (is_array($module_link_array) and count($module_link_array) >= 1) { $paramquery['username'] = $_GET['username']; $paramquery['session_id'] = $_GET['session_id']; $module_link_array_key = 0; foreach ($module_link_array as $array_key => $array_value) { if ($array_value['array']['nav'] == $_GET['vnav']) { $module_link_array_key = $array_key; } } if (is_array($module_link_array[$module_link_array_key]['array']) and count($module_link_array[$module_link_array_key]['array']) >= 1) { foreach ($module_link_array[$module_link_array_key]['array'] as $array_key => $array_value) { if ($array_value == "%OU_ID%") { $paramquery['ou_id'] = $value; } else { $paramquery[$array_key] = $array_value; } } } $params = http_build_query($paramquery, '', '&'); $return_array[$counter][5] = true; $return_array[$counter][6] = $params; //link } else { $return_array[$counter][5] = true; $return_array[$counter][6] = ""; //link } } else { $return_array[$counter][5] = false; $return_array[$counter][6] = ""; } $return_array[$counter][7] = false; //open $counter++; } } echo json_encode($return_array); } }