Beispiel #1
0
 public static function search()
 {
     global $user, $session;
     if ($_GET['nextpage']) {
         if ($_GET['page'] or $_GET['sortvalue'] or $_GET['sortmethod']) {
             $name = $session->read_value("SEARCH_PROJECT_NAME");
             $organisation_unit_array = $session->read_value("SEARCH_PROJECT_ORGANISATION_UNIT_ARRAY");
             $template_array = $session->read_value("SEARCH_PROJECT_TEMPLATE_ARRAY");
         } else {
             if ($_GET['nextpage'] == "1") {
                 $name = $_POST['string'];
                 $session->delete_value("SEARCH_PROJECT_NAME");
                 $session->delete_value("SEARCH_PROJECT_ORGANISATION_UNIT_ARRAY");
                 $session->delete_value("SEARCH_PROJECT_TEMPLATE_ARRAY");
             } else {
                 $name = $_POST['string'];
                 $organisation_unit_array = $session->read_value("SEARCH_PROJECT_ORGANISATION_UNIT_ARRAY");
                 $template_array = $session->read_value("SEARCH_PROJECT_TEMPLATE_ARRAY");
             }
         }
         $no_error = true;
     } else {
         $no_error = false;
     }
     if ($no_error == false) {
         $template = new HTMLTemplate("project/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;
         $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'] = "";
                 $result[$counter]['content'] = $project_template_cat->get_name();
                 $result[$counter]['selected'] = "";
                 $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);
                         $result[$counter]['value'] = $sub_value;
                         $result[$counter]['content'] = " " . $project_sub_template->get_name();
                         $result[$counter]['selected'] = "";
                         $counter++;
                     }
                 }
                 unset($project_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'];
                 $project_template = new ProjectTemplate($_POST['template']);
                 $search_template_name = $project_template->get_name();
             }
         } else {
             if (count($template_array) == 1) {
                 $project_template = new ProjectTemplate($template_array[0]);
                 $search_template_name = $project_template->get_name();
             } else {
                 $search_template_name = "All";
             }
         }
         $session->write_value("SEARCH_PROJECT_NAME", $name, true);
         $session->write_value("SEARCH_PROJECT_ORGANISATION_UNIT_ARRAY", $organisation_unit_array, true);
         $session->write_value("SEARCH_PROJECT_TEMPLATE_ARRAY", $template_array, true);
         /* --------------- */
         $argument_array = array();
         $argument_array[0][0] = "name";
         $argument_array[0][1] = $name;
         $argument_array[1][0] = "template_array";
         $argument_array[1][1] = $template_array;
         $argument_array[2][0] = "organisation_unit_array";
         $argument_array[2][1] = $organisation_unit_array;
         $list = new List_IO("ProjectSearch", "ajax.php?nav=project", "search_project_list_projects", "search_project_count_projects", $argument_array, "ProjectSearch");
         $list->add_column("", "symbol", false, "16px");
         $list->add_column(Language::get_message("ProjectGeneralListColumnName", "general"), "name", true, null);
         $list->add_column(Language::get_message("ProjectGeneralListColumnOrganisationUnit", "general"), "organisation_unit", true, null);
         $list->add_column(Language::get_message("ProjectGeneralListColumnDateTime", "general"), "datetime", true, null);
         $list->add_column(Language::get_message("ProjectGeneralListColumnTemplate", "general"), "template", true, null);
         $list->add_column(Language::get_message("ProjectGeneralListColumnStatus", "general"), "status", true, null);
         $template = new HTMLTemplate("project/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();
     }
 }
 public static function create()
 {
     if ($_GET['nextpage'] == 1) {
         $page_1_passed = true;
     } else {
         $page_1_passed = false;
         $error = "";
     }
     if ($page_1_passed == false) {
         $template = new HTMLTemplate("project/admin/project_template/add.html");
         $paramquery = $_GET;
         $paramquery['nextpage'] = "1";
         $params = http_build_query($paramquery, '', '&');
         $template->set_var("params", $params);
         if ($error) {
             $template->set_var("error", $error);
         } else {
             $template->set_var("error", "");
         }
         $folder = Folder::get_instance(constant("OLDL_FOLDER_ID"));
         $data_entity_array = $folder->get_children();
         if (is_array($data_entity_array)) {
             $result = array();
             $counter = 0;
             foreach ($data_entity_array as $key => $value) {
                 if (($file_id = File::get_file_id_by_data_entity_id($value)) != null) {
                     $file = File::get_instance($file_id);
                     $result[$counter]['value'] = $value;
                     $result[$counter]['content'] = $file->get_name();
                     $counter++;
                 }
             }
             $template->set_var("file", $result);
         }
         $category_array = ProjectTemplateCat::list_entries();
         if (is_array($category_array)) {
             $result = array();
             $counter = 0;
             foreach ($category_array as $key => $value) {
                 $project_template_cat = new ProjectTemplateCat($value);
                 $result[$counter]['value'] = $value;
                 $result[$counter]['content'] = $project_template_cat->get_name();
                 $counter++;
             }
             $template->set_var("category", $result);
         }
         $template->output();
     } else {
         $project_template = new ProjectTemplate(null);
         if ($_POST['parent'] == "1") {
             $parent = true;
         } else {
             $parent = false;
         }
         $paramquery = $_GET;
         unset($paramquery['action']);
         unset($paramquery['nextpage']);
         $params = http_build_query($paramquery, '', '&');
         if ($project_template->create($_POST['data_entity_id'], $_POST['category_id'], $parent)) {
             Common_IO::step_proceed($params, "Add Project Template", "Operation Successful", null);
         } else {
             Common_IO::step_proceed($params, "Add Project Template", "Operation Failed", null);
         }
     }
 }
 /**
  * @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 .= "&nbsp;";
                         }
                         $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'] = "&nbsp;" . $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'] = "&nbsp;" . $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 ProjectTemplateCategoryIDMissingException
  */
 public static function edit()
 {
     if ($_GET['id']) {
         $project_template_cat = new ProjectTemplateCat($_GET['id']);
         if ($_GET['nextpage'] == 1) {
             $page_1_passed = true;
             if ($_POST['name']) {
                 if (ProjectTemplateCat::exist_name($_POST['name']) == true and $project_template_cat->get_name() != $_POST['name']) {
                     $page_1_passed = false;
                     $error = "This name already exists";
                 }
             } else {
                 $page_1_passed = false;
                 $error = "You must enter a name";
             }
         } else {
             $page_1_passed = false;
             $error = "";
         }
         if ($page_1_passed == false) {
             $template = new HTMLTemplate("project/admin/project_template_cat/edit.html");
             $paramquery = $_GET;
             $paramquery['nextpage'] = "1";
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("params", $params);
             if ($error) {
                 $template->set_var("error", $error);
             } else {
                 $template->set_var("error", "");
             }
             if ($_POST['name']) {
                 $template->set_var("name", $_POST['name']);
             } else {
                 $template->set_var("name", $project_template_cat->get_name());
             }
             $template->output();
         } else {
             $paramquery = $_GET;
             unset($paramquery['nextpage']);
             unset($paramquery['action']);
             $params = http_build_query($paramquery);
             if ($project_template_cat->set_name($_POST['name'])) {
                 Common_IO::step_proceed($params, "Edit Project Template Category", "Operation Successful", null);
             } else {
                 Common_IO::step_proceed($params, "Edit Project Tempalte Category", "Operation Failed", null);
             }
         }
     } else {
         throw new ProjectTemplateCategoryIDMissingException();
     }
 }