/** * @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; } }
/** * @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 ProjectIDMissingException * @throws ProjectSecuriyAccessDeniedException */ public static function structure() { global $project_security; if ($_GET['project_id']) { if ($project_security->is_access(1, false) == true) { $project = new Project($_GET['project_id']); $project_structure_array = $project->get_project_tree(); $template = new HTMLTemplate("project/structure.html"); if (is_array($project_structure_array) and count($project_structure_array) >= 1) { $result = array(); $counter = 0; foreach ($project_structure_array as $key => $value) { $project = new Project($value['id']); $project_security = new ProjectSecurity($value['id']); $project_owner = new User($project->get_owner_id()); $paramquery['username'] = $_GET['username']; $paramquery['session_id'] = $_GET['session_id']; $paramquery['nav'] = "project"; $paramquery['run'] = "detail"; $paramquery['project_id'] = $value['id']; $params = http_build_query($paramquery, '', '&'); $result[$counter]['link'] = $params; $result[$counter]['name'] = $project->get_name(); $result[$counter]['status'] = $project->get_current_status_name(); $result[$counter]['template'] = $project->get_template_name(); $result[$counter]['owner'] = $project_owner->get_full_name(false); $involved_array = $project_security->list_involved_users(); if (is_array($involved_array) and count($involved_array) >= 1) { foreach ($involved_array as $involved_key => $involved_value) { $involved_user = new User($involved_value); if ($result[$counter]['involved'] == "") { $result[$counter]['involved'] = $involved_user->get_full_name(false); } else { $result[$counter]['involved'] .= ", " . $involved_user->get_full_name(false); } } } else { $result[$counter]['involved'] = ""; } $subproject_paramquery = $_GET; $subproject_paramquery['run'] = "new_subproject"; $subproject_paramquery['id'] = $value['id']; unset($subproject_paramquery['nextpage']); $subproject_params = http_build_query($subproject_paramquery, '', '&'); $result[$counter]['add_subproject'] = $subproject_params; $result[$counter]['padding'] = $value['layer']; $counter++; } $template->set_var("structure", $result); } $template->output(); } else { throw new ProjectSecurityAccessDeniedException(); } } else { throw new ProjectIDMissingException(); } }