Example #1
0
 /**
  * @see Item_WrapperInterface::count_fulltext_search()
  * @param string $string
  * @param array $item_type_array
  * @param integer $language_id
  * @return integer
  */
 public static function count_fulltext_search($string, $item_type_array, $language_id)
 {
     if (is_array($item_type_array) and count($item_type_array) >= 1) {
         $string = strtolower(trim($string));
         $string = str_replace("*", "%", $string);
         $string = str_replace(" ", "", $string);
         $join_sql = "";
         $where_sql = "";
         if (is_numeric($language_id)) {
             $language = new Language($language_id);
             $tsvector_language = $language->get_tsvector_name();
         } else {
             $tsvector_language = "english";
         }
         foreach ($item_type_array as $key => $value) {
             $handling_class = Item::get_handling_class_by_type($value);
             if (class_exists($handling_class)) {
                 $join_sql .= $handling_class::get_sql_join($value);
                 if (($return_where_sql = $handling_class::get_sql_fulltext_where($value)) != null) {
                     $return_where_sql = str_replace("{STRING}", $string, $return_where_sql);
                     $return_where_sql = str_replace("{LANGUAGE}", "english", $return_where_sql);
                     if ($where_sql == "") {
                         $where_sql .= $return_where_sql;
                     } else {
                         $where_sql .= " OR " . $return_where_sql;
                     }
                 }
             }
         }
         return Item_Wrapper_Access::count_fulltext_search($string, $select_sql_array, $join_sql, $where_sql);
     } else {
         return null;
     }
 }
Example #2
0
 /**
  * @see ProjectInterface::get_current_status_requirements()
  * @param bool $force_inherit
  * @param integer $status_id
  * @return array
  */
 public function get_current_status_requirements($force_inherit = false, $status_id = null)
 {
     global $runtime_data;
     if ($this->project_id and $this->project) {
         if ($status_id == null) {
             $status_id = $this->get_current_status_id();
         }
         if ($runtime_data->is_object_data($this, "PROJECT_" . $this->project_id . "_" . $status_id . "_CURRENT_STATUS_REQUIREMENTS") == true) {
             return $runtime_data->read_object_data($this, "PROJECT_" . $this->project_id . "_" . $status_id . "_CURRENT_STATUS_REQUIREMENTS");
         } else {
             $project_template = new ProjectTemplate($this->project->get_template_id());
             $status_attribute_array = $project_template->get_status_attributes($status_id);
             $requirements_array = $project_template->get_status_requirements($status_id);
             if ($status_attribute_array['requirement'] == "optional") {
                 $requirement_default = "optional";
             } else {
                 $requirement_default = "force";
             }
             $return_array = array();
             $parent_item_array = array();
             $counter = 0;
             $type_counter = 0;
             $category_counter = 0;
             $fulfilled_counter = 0;
             $filter_counter = 0;
             $sub_item_counter = 0;
             if (is_array($requirements_array) and count($requirements_array) >= 1) {
                 $project_item = new ProjectItem($this->project_id);
                 $item_array = $project_item->get_project_status_items_with_pos_id($status_id);
                 $item_type_array = Item::list_types();
                 foreach ($requirements_array as $key => $value) {
                     // ITEM
                     if ($value['xml_element'] == "item" and !$value['close']) {
                         $in_item = true;
                         $return_array[$counter]['element_type'] = "item";
                         $return_array[$counter]['display'] = true;
                         $return_array[$counter]['type'] = $value['type'];
                         $return_array[$counter]['name'] = $value['name'];
                         $return_array[$counter]['dialog'] = $value['dialog'];
                         $return_array[$counter]['handling_class'] = Item::get_handling_class_by_type($value['type']);
                         if ($value['requirement'] and $status_attribute_array['requirement'] != "optional") {
                             $return_array[$counter]['requirement'] = $value['requirement'];
                         } else {
                             $return_array[$counter]['requirement'] = $requirement_default;
                         }
                         if ($value['occurrence']) {
                             $return_array[$counter]['occurrence'] = $value['occurrence'];
                         } else {
                             $return_array[$counter]['occurrence'] = "once";
                         }
                         if (is_numeric($value['pos_id'])) {
                             $pos_id = $value['pos_id'];
                             $return_array[$counter]['pos_id'] = $value['pos_id'];
                         } else {
                             $pos_id = $counter;
                             $return_array[$counter]['pos_id'] = $counter;
                         }
                         if (is_array($item_array) and count($item_array) >= 1) {
                             $item_instance_array = array();
                             foreach ($item_array as $item_key => $item_value) {
                                 if (is_array($item_type_array) and count($item_type_array) >= 1) {
                                     foreach ($item_type_array as $item_type => $item_handling_class) {
                                         if (class_exists($item_handling_class)) {
                                             if ($item_handling_class::is_kind_of($item_type, $item_value['item_id']) == true and $item_value['pos_id'] == $pos_id and $item_value['pos_id'] !== null and $pos_id !== null) {
                                                 $item_instance = $item_handling_class::get_instance_by_item_id($item_value['item_id'], true);
                                                 $return_array[$counter]['fulfilled'][$fulfilled_counter]['item_id'] = $item_value['item_id'];
                                                 $return_array[$counter]['fulfilled'][$fulfilled_counter]['id'] = $item_instance->get_item_object_id();
                                                 $return_array[$counter]['fulfilled'][$fulfilled_counter]['name'] = $item_instance->get_item_object_name();
                                                 array_push($item_instance_array, $item_instance);
                                                 $fulfilled_counter++;
                                                 break;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         if ($value['inherit'] == "all" or $force_inherit == true) {
                             if (is_array($item_instance_array) and count($item_instance_array) >= 1 and $fulfilled_counter >= 1) {
                                 foreach ($item_instance_array as $object_key => $object_value) {
                                     if (is_object($object_value)) {
                                         if ($object_value instanceof ItemHolderInterface) {
                                             $return_array[$counter]['sub_items'][$object_key] = $object_value->get_item_add_information();
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     if ($value['xml_element'] == "item" and $value['close'] == "1") {
                         $counter++;
                         $type_counter = 0;
                         $category_counter = 0;
                         $fulfilled_counter = 0;
                         $sub_item_type_counter = 0;
                         $type = null;
                         $in_item = false;
                     }
                     // ITEMI
                     if ($value['xml_element'] == "itemi" and !$value['close']) {
                         if (is_numeric($value['parent_status']) and is_numeric($value['parent_pos_id']) and is_numeric($value['pos_id'])) {
                             $parent_requirement_array = $this->get_current_status_requirements(true, $value['parent_status']);
                             $parent_requirement_array = $parent_requirement_array[$value['parent_pos_id']];
                             $sub_item_array = $parent_requirement_array['sub_items'];
                             unset($parent_requirement_array['sub_items']);
                             if (!is_numeric($parent_item_array[$value['parent_status']])) {
                                 $return_array[$counter] = $parent_requirement_array;
                                 $return_array[$counter]['display'] = false;
                                 $parent_item_counter = $counter;
                                 $parent_item_array[$value['parent_status']] = $counter;
                             } else {
                                 $parent_item_counter = $parent_item_array[$value['parent_status']];
                             }
                             if (is_array($sub_item_array) and count($sub_item_array) >= 1) {
                                 foreach ($sub_item_array as $sub_item_key => $sub_item_value) {
                                     $return_array[$parent_item_counter]['sub_items'][$sub_item_key][$value['pos_id']] = $sub_item_value[$value['pos_id']];
                                     if ($value['takeover'] == "true") {
                                         $return_array[$parent_item_counter]['sub_items'][$sub_item_key][$value['pos_id']]['takeover'] = true;
                                     } else {
                                         $return_array[$parent_item_counter]['sub_items'][$sub_item_key][$value['pos_id']]['takeover'] = false;
                                     }
                                 }
                             }
                         } elseif ($in_item == true and is_array($item_instance_array) and count($item_instance_array) >= 1) {
                             foreach ($item_instance_array as $object_key => $object_value) {
                                 if (is_numeric($value['pos_id'])) {
                                     $pos_id = $value['pos_id'];
                                 } else {
                                     $pos_id = $sub_item_counter;
                                 }
                                 $return_array[$counter]['sub_items'][$object_key][$pos_id] = $object_value->get_item_add_information($pos_id);
                             }
                         }
                     }
                     // TYPE
                     if ($value['xml_element'] == "type" and !$value['close'] and $in_item = true and is_numeric($value['id'])) {
                         $return_array[$counter]['type_id'][$type_counter] = $value['id'];
                         $type_counter++;
                     }
                     // CATEGORY
                     if ($value['xml_element'] == "category" and !$value['close'] and $in_item = true and is_numeric($value['id'])) {
                         $return_array[$counter]['category_id'][$category_counter] = $value['id'];
                         $category_counter++;
                     }
                     // EXTENSION
                     if ($value['xml_element'] == "extension" and !$value['close']) {
                         $extension_id = Extension::get_id_by_identifier($value['identifier']);
                         $extension = new Extension($extension_id);
                         $return_array[$counter]['element_type'] = "extension";
                         $return_array[$counter]['name'] = $extension->get_name();
                         $return_array[$counter]['extension'] = $value['identifier'];
                         if ($value['requirement'] and $status_attribute_array['requirement'] != "optional") {
                             $return_array[$counter]['requirement'] = $value['requirement'];
                         } else {
                             $return_array[$counter]['requirement'] = $requirement_default;
                         }
                         if ($value['occurrence']) {
                             $return_array[$counter]['occurrence'] = $value['occurrence'];
                         } else {
                             $return_array[$counter]['occurrence'] = "once";
                         }
                         $return_array[$counter]['fulfilled'] = ProjectExtension::get_status($extension_id, $this->project_id);
                         $in_extension = true;
                     }
                     if ($value['xml_element'] == "extension" and $value['close'] == "1") {
                         $counter++;
                         $filter_counter = 0;
                         $in_extension = false;
                     }
                     // FILTER
                     if ($value['xml_element'] == "filter" and !$value['close'] and $in_extension == true and is_numeric($value['status'])) {
                         $return_array[$counter]['filter'][$filter_counter]['status'] = $value['status'];
                         if ($value['type']) {
                             $return_array[$counter]['filter'][$filter_counter]['type'] = $value['type'];
                         }
                         $filter_counter++;
                     }
                 }
             }
             if (is_array($return_array) and count($return_array) >= 1) {
                 foreach ($return_array as $key => $value) {
                     if (!$value['name'] and $value['type']) {
                         if ($return_array[$key]['handling_class']) {
                             $return_array[$key]['name'] = "Add " . $return_array[$key]['handling_class']::get_generic_name($value['type'], $value['type_id']);
                         }
                     }
                     if (is_array($value['sub_items']) and count($value['sub_items']) >= 1) {
                         foreach ($value['sub_items'] as $sub_item_key => $sub_item_value) {
                             if (!$sub_item_value['name'] and $sub_item_value['type']) {
                                 if ($return_array[$key]['sub_items'][$sub_item_key]['handling_class']) {
                                     $return_array[$key]['sub_items'][$sub_item_key]['name'] = "Add " . $return_array[$key]['sub_items'][$sub_item_key]['handling_class']::get_generic_name($sub_item_value['type'], $sub_item_value['type_id']);
                                 }
                             }
                         }
                     }
                 }
             }
             $runtime_data->write_object_data($this, "PROJECT_" . $this->project_id . "_" . $status_id . "_CURRENT_STATUS_REQUIREMENTS", $return_array);
             return $return_array;
         }
     } else {
         return null;
     }
 }
Example #3
0
 /**
  * @param string $alias
  * @throws BaseModuleDialogMethodNotFoundException
  * @throws BaseModuleDialogClassNotFoundException
  * @throws BaseModuleDialogFileNotFoundException
  * @throws BaseModuleDialogMissingException
  * @throws ProjectSecurityAccessDeniedException
  * @throws BaseModuleDialogNotFoundException
  * @throws ItemAddIOClassNotFoundException
  * @throws ItemAddIOFileNotFoundException
  * @throws ItemHandlerClassNotFoundException
  * @throws ItemPositionIDMissingException
  * @throws ItemParentIDMissingException
  * @throws ItemParentTypeMissingException
  * @throws ProjectStatusWithoutExtensionException
  * @throws BaseExtensionClassNotFoundException
  * @throws BaseExtensionFileNotFoundException
  * @throws BaseExtensionNotFoundException
  * @throws BaseExtensionMissingException
  */
 public static function io_handler($alias)
 {
     global $project_security, $session, $transaction;
     if (isset($_GET['project_id']) and is_numeric($_GET['project_id'])) {
         $project_security = new ProjectSecurity($_GET['project_id']);
         if ($_GET['run'] != "new_subproject") {
             require_once "io/project_common.io.php";
             ProjectCommon_IO::tab_header();
         }
     } else {
         $project_security = new ProjectSecurity(null);
     }
     if (isset($_GET['run'])) {
         switch ($_GET['run']) {
             case "new":
             case "new_subproject":
                 require_once "io/project.io.php";
                 ProjectIO::create();
                 break;
             case "myprojects":
             case "workon":
             case "accessdata":
             case "analyse":
                 require_once "io/project.io.php";
                 ProjectIO::list_user_related_projects(null);
                 break;
             case "userprojects":
                 require_once "io/project.io.php";
                 ProjectIO::list_user_related_projects($_GET['id']);
                 break;
             case "organ_unit":
                 require_once "io/project.io.php";
                 ProjectIO::list_organisation_unit_related_projects();
                 break;
             case "detail":
                 require_once "io/project.io.php";
                 ProjectIO::detail();
                 break;
             case "structure":
                 require_once "io/project.io.php";
                 ProjectIO::structure();
                 break;
                 // Project Log
             // Project Log
             case "log":
                 require_once "io/project_log.io.php";
                 ProjectLogIO::list_project_related_logs();
                 break;
                 // Tasks and Schedule
             // Tasks and Schedule
             case "add_task":
                 require_once "io/project_task.io.php";
                 ProjectTaskIO::add();
                 break;
             case "schedule":
             case "show_tasks":
                 require_once "io/project_task.io.php";
                 ProjectTaskIO::show();
                 break;
             case "task_detail":
                 require_once "io/project_task.io.php";
                 ProjectTaskIO::detail();
                 break;
             case "task_delete":
                 require_once "io/project_task.io.php";
                 ProjectTaskIO::delete();
                 break;
             case "task_edit_start":
                 require_once "io/project_task.io.php";
                 ProjectTaskIO::edit_start();
                 break;
             case "task_edit_end":
                 require_once "io/project_task.io.php";
                 ProjectTaskIO::edit_end();
                 break;
                 // Administration
             // Administration
             case "admin":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::menu();
                 break;
             case "admin_rename":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::rename();
                 break;
             case "admin_chown":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::chown();
                 break;
             case "admin_move":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::move();
                 break;
             case "admin_quota":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::quota();
                 break;
                 // Administration - Permission
             // Administration - Permission
             case "admin_permission":
                 require_once "io/project_admin.io.php";
                 $project_admin_io = new ProjectAdminIO();
                 ProjectAdminIO::permission();
                 break;
             case "admin_permission_add_user":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::permission_add_user();
                 break;
             case "admin_permission_add_group":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::permission_add_group();
                 break;
             case "admin_permission_add_ou":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::permission_add_organisation_unit();
                 break;
             case "admin_permission_edit":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::permission_edit();
                 break;
             case "admin_permission_delete":
                 require_once "io/project_admin.io.php";
                 ProjectAdminIO::permission_delete();
                 break;
                 // Item Lister
             // Item Lister
             case "item_list":
                 if ($project_security->is_access(1, false) == true) {
                     if ($_GET['dialog']) {
                         if ($_GET['dialog'] == "data") {
                             $path_stack_array = array();
                             $folder_id = ProjectFolder::get_folder_by_project_id($_GET['project_id']);
                             $folder = Folder::get_instance($folder_id);
                             $init_array = $folder->get_object_id_path();
                             foreach ($init_array as $key => $value) {
                                 $temp_array = array();
                                 $temp_array['virtual'] = false;
                                 $temp_array['id'] = $value;
                                 array_unshift($path_stack_array, $temp_array);
                             }
                             if (!$_GET['folder_id']) {
                                 $session->write_value("stack_array", $path_stack_array, true);
                             }
                         }
                         $module_dialog = ModuleDialog::get_by_type_and_internal_name("item_list", $_GET['dialog']);
                         if (file_exists($module_dialog['class_path'])) {
                             require_once $module_dialog['class_path'];
                             if (class_exists($module_dialog['class'])) {
                                 if (method_exists($module_dialog['class'], $module_dialog['method'])) {
                                     $module_dialog['class']::$module_dialog['method']("project", $_GET['project_id'], true);
                                 } else {
                                     throw new BaseModuleDialogMethodNotFoundException();
                                 }
                             } else {
                                 throw new BaseModuleDialogClassNotFoundException();
                             }
                         } else {
                             throw new BaseModuleDialogFileNotFoundException();
                         }
                     } else {
                         throw new BaseModuleDialogMissingException();
                     }
                 } else {
                     throw new ProjectSecurityAccessDeniedException();
                 }
                 break;
                 // Item Add
             // Item Add
             case "item_add":
             case "item_edit":
                 if ($project_security->is_access(3, false) == true) {
                     if ($_GET['dialog']) {
                         if ($_GET['run'] == "item_add") {
                             $module_dialog = ModuleDialog::get_by_type_and_internal_name("item_add", $_GET['dialog']);
                         } elseif ($_GET['run'] == "item_edit") {
                             $module_dialog = ModuleDialog::get_by_type_and_internal_name("item_edit", $_GET['dialog']);
                         }
                         if (is_array($module_dialog) and $module_dialog['class_path']) {
                             if (file_exists($module_dialog['class_path'])) {
                                 require_once $module_dialog['class_path'];
                                 if (class_exists($module_dialog['class'])) {
                                     if (method_exists($module_dialog['class'], $module_dialog['method'])) {
                                         $project = new Project($_GET['project_id']);
                                         $project_item = new ProjectItem($_GET['project_id']);
                                         $project_item->set_status_id($project->get_current_status_id());
                                         $project_item->set_gid($_GET['key']);
                                         $description_required = $project_item->is_description_required();
                                         $keywords_required = $project_item->is_keywords_required();
                                         if ($description_required and !$_POST['description'] and !$_GET['idk_unique_id'] or $keywords_required and !$_POST['keywords'] and !$_GET['idk_unique_id']) {
                                             require_once "core/modules/item/io/item.io.php";
                                             ItemIO::information(http_build_query($_GET), $description_required, $keywords_required);
                                         } else {
                                             $current_status_requirements = $project->get_current_status_requirements($project->get_current_status_id());
                                             if ($_GET['run'] == "item_add") {
                                                 $module_dialog['class']::$module_dialog['method']($current_status_requirements[$_GET['key']]['type_id'], $current_status_requirements[$_GET['key']]['category_id'], "Project", $_GET['project_id'], $_GET['key']);
                                             } elseif ($_GET['run'] == "item_edit") {
                                                 $module_dialog['class']::$module_dialog['method']($current_status_requirements[$_GET['key']]['fulfilled'][0]['item_id']);
                                             }
                                         }
                                     } else {
                                         throw new BaseModuleDialogMethodNotFoundException();
                                     }
                                 } else {
                                     throw new BaseModuleDialogClassNotFoundException();
                                 }
                             } else {
                                 throw new BaseModuleDialogFileNotFoundException();
                             }
                         } else {
                             throw new BaseModuleDialogNotFoundException();
                         }
                     } else {
                         throw new BaseModuleDialogMissingException();
                     }
                 } else {
                     throw new ProjectSecurityAccessDeniedException();
                 }
                 break;
                 // Sub Item Add and Edit
             // Sub Item Add and Edit
             case "sub_item_add":
             case "sub_item_edit":
                 if ($project_security->is_access(3, false) == true) {
                     if ($_GET['parent']) {
                         if (is_numeric($_GET['parent_id'])) {
                             if (is_numeric($_GET['key'])) {
                                 $item_handling_class = Item::get_handling_class_by_type($_GET['parent']);
                                 if (class_exists($item_handling_class)) {
                                     $item_io_handling_class = $item_handling_class::get_item_add_io_handling_class();
                                     if (file_exists("core/modules/" . $item_io_handling_class[0])) {
                                         require_once "core/modules/" . $item_io_handling_class[0];
                                         if (class_exists($item_io_handling_class[1])) {
                                             if ($_GET['run'] == "sub_item_add") {
                                                 $item_io_handling_class[1]::item_add_edit_handler("add");
                                             } elseif ($_GET['run'] == "sub_item_edit") {
                                                 $item_io_handling_class[1]::item_add_edit_handler("edit");
                                             }
                                         } else {
                                             throw new ItemAddIOClassNotFoundException();
                                         }
                                     } else {
                                         throw new ItemAddIOFileNotFoundException();
                                     }
                                 } else {
                                     throw new ItemHandlerClassNotFoundException();
                                 }
                             } else {
                                 throw new ItemPositionIDMissingException();
                             }
                         } else {
                             throw new ItemParentIDMissingException();
                         }
                     } else {
                         throw new ItemParentTypeMissingException();
                     }
                 } else {
                     throw new ProjectSecurityAccessDeniedException();
                 }
                 break;
                 // Extension
                 /**
                  * @todo type filter
                  */
             // Extension
             /**
              * @todo type filter
              */
             case "extension":
                 if ($_GET['extension']) {
                     $extension_id = Extension::get_id_by_identifier($_GET['extension']);
                     if ($extension_id) {
                         $extension = new Extension($extension_id);
                         $main_file = constant("EXTENSION_DIR") . "/" . $extension->get_folder() . "/" . $extension->get_main_file();
                         $main_class = $extension->get_class();
                         if (file_exists($main_file)) {
                             require_once $main_file;
                             if (class_exists($main_class)) {
                                 $project = new Project($_GET['project_id']);
                                 $project_item = new ProjectItem($_GET['project_id']);
                                 $project_status_requirements = $project->get_current_status_requirements();
                                 if (is_array($project_status_requirements) and count($project_status_requirements) >= 1) {
                                     foreach ($project_status_requirements as $key => $value) {
                                         if ($value['element_type'] == "extension" and $value['extension'] == $_GET['extension']) {
                                             if (is_array($value['filter']) and count($value['filter']) >= 1) {
                                                 $filter_array = $value['filter'];
                                             } else {
                                                 $filter_array = null;
                                             }
                                             break;
                                         }
                                     }
                                 } else {
                                     throw new ProjectStatusWithoutExtensionException();
                                 }
                                 if ($filter_array) {
                                     $item_array = array();
                                     foreach ($filter_array as $key => $value) {
                                         if (is_numeric($value['status'])) {
                                             $item_array = array_merge($item_array, $project_item->get_project_status_items($value['status'], true));
                                         }
                                     }
                                 } else {
                                     $item_array = $project_item->get_project_items(true);
                                 }
                                 $event_identifier = uniqid("", true);
                                 if ($session->is_value("PROJECT_EXTENSION_EVENT_IDENTIFIER_ARRAY")) {
                                     $project_extension_event_identifier_array = $session->read_value("PROJECT_EXTENSION_EVENT_IDENTIFIER_ARRAY");
                                     $project_extension_event_identifier_array[$event_identifier] = $_GET['project_id'];
                                 } else {
                                     $project_extension_event_identifier_array = array();
                                     $project_extension_event_identifier_array[$event_identifier] = $_GET['project_id'];
                                 }
                                 $session->write_value("PROJECT_EXTENSION_EVENT_IDENTIFIER_ARRAY", $project_extension_event_identifier_array);
                                 $main_class::set_event_identifier($event_identifier);
                                 $main_class::set_target_folder_id(ProjectStatusFolder::get_folder_by_project_id_and_project_status_id($_GET['project_id'], $project->get_current_status_id()));
                                 $main_class::push_data($item_array);
                             } else {
                                 throw new BaseExtensionClassNotFoundException();
                             }
                         } else {
                             throw new BaseExtensionFileNotFoundException();
                         }
                     } else {
                         throw new BaseExtensionNotFoundException();
                     }
                 } else {
                     throw new BaseExtensionMissingException();
                 }
                 break;
                 // Common Dialogs
             // Common Dialogs
             case "common_dialog":
                 require_once "core/modules/base/common.request.php";
                 CommonRequest::common_dialog();
                 break;
                 // Default
             // Default
             default:
                 require_once "io/project.io.php";
                 ProjectIO::list_user_related_projects(null);
                 break;
         }
     } else {
         require_once "io/project.io.php";
         ProjectIO::list_user_related_projects(null);
     }
 }
Example #4
0
 /**
  * @param string $alias
  * @throws SampleSecurityAccessDeniedException
  * @throws BaseModuleDialogMethodNotFoundException
  * @throws BaseModuleDialogClassNotFoundException
  * @throws BaseModuleDialogFileNotFoundException
  * @throws BaseModuleDialogMissingException
  * @throws BaseModuleDialogNotFoundException
  * @throws ItemAddIOClassNotFoundException
  * @throws ItemAddIOFileNotFoundException
  * @throws ItemHandlerClassNotFoundException
  * @throws ItemPositionIDMissingException
  * @throws ItemParentIDMissingException
  * @throws ItemParentTypeMissingException
  */
 public static function io_handler($alias)
 {
     global $sample_security, $session, $transaction;
     if ($_GET['sample_id']) {
         $sample_security = new SampleSecurity($_GET['sample_id']);
         require_once "io/sample_common.io.php";
         SampleCommon_IO::tab_header();
     } else {
         $sample_security = new SampleSecurity(null);
     }
     switch ($_GET['run']) {
         case "new":
         case "new_subsample":
             require_once "io/sample.io.php";
             SampleIO::create();
             break;
         case "clone":
             require_once "io/sample.io.php";
             SampleIO::clone_sample();
             break;
         case "organ_unit":
             require_once "io/sample.io.php";
             SampleIO::list_organisation_unit_related_samples();
             break;
         case "detail":
             require_once "io/sample.io.php";
             SampleIO::detail();
             break;
         case "move":
             require_once "io/sample.io.php";
             SampleIO::move();
             break;
         case "set_availability":
             require_once "io/sample.io.php";
             SampleIO::set_availability();
             break;
         case "location_history":
             require_once "io/sample.io.php";
             SampleIO::location_history();
             break;
             // Administration
         // Administration
         case "delete":
             require_once "io/sample_admin.io.php";
             SampleAdminIO::delete();
             break;
         case "rename":
             require_once "io/sample_admin.io.php";
             SampleAdminIO::rename();
             break;
         case "admin_permission_user":
             require_once "io/sample_admin.io.php";
             SampleAdminIO::user_permission();
             break;
         case "admin_permission_user_add":
             require_once "io/sample_admin.io.php";
             SampleAdminIO::user_permission_add();
             break;
         case "admin_permission_user_delete":
             require_once "io/sample_admin.io.php";
             SampleAdminIO::user_permission_delete();
             break;
         case "admin_permission_ou":
             require_once "io/sample_admin.io.php";
             SampleAdminIO::ou_permission();
             break;
         case "admin_permission_ou_add":
             require_once "io/sample_admin.io.php";
             SampleAdminIO::ou_permission_add();
             break;
         case "admin_permission_ou_delete":
             require_once "io/sample_admin.io.php";
             SampleAdminIO::ou_permission_delete();
             break;
             // Item Lister
         // Item Lister
         case "item_list":
             if ($sample_security->is_access(1, false) == true) {
                 if ($_GET['dialog']) {
                     if ($_GET['dialog'] == "data") {
                         $path_stack_array = array();
                         $folder_id = SampleFolder::get_folder_by_sample_id($_GET['sample_id']);
                         $folder = Folder::get_instance($folder_id);
                         $init_array = $folder->get_object_id_path();
                         foreach ($init_array as $key => $value) {
                             $temp_array = array();
                             $temp_array['virtual'] = false;
                             $temp_array['id'] = $value;
                             array_unshift($path_stack_array, $temp_array);
                         }
                         if (!$_GET['folder_id']) {
                             $session->write_value("stack_array", $path_stack_array, true);
                         }
                     }
                     $module_dialog = ModuleDialog::get_by_type_and_internal_name("item_list", $_GET['dialog']);
                     if (file_exists($module_dialog['class_path'])) {
                         require_once $module_dialog['class_path'];
                         if (class_exists($module_dialog['class'])) {
                             if (method_exists($module_dialog['class'], $module_dialog['method'])) {
                                 $module_dialog['class']::$module_dialog['method']("sample", $_GET['sample_id'], true, false);
                             } else {
                                 throw new BaseModuleDialogMethodNotFoundException();
                             }
                         } else {
                             throw new BaseModuleDialogClassNotFoundException();
                         }
                     } else {
                         throw new BaseModuleDialogFileNotFoundException();
                     }
                 } else {
                     throw new BaseModuleDialogMissingException();
                 }
             } else {
                 throw new SampleSecurityAccessDeniedException();
             }
             break;
         case "item_add":
         case "item_edit":
             if ($sample_security->is_access(2, false) == true) {
                 if ($_GET['dialog']) {
                     if ($_GET['run'] == "item_add") {
                         $module_dialog = ModuleDialog::get_by_type_and_internal_name("item_add", $_GET['dialog']);
                     } elseif ($_GET['run'] == "item_edit") {
                         $module_dialog = ModuleDialog::get_by_type_and_internal_name("item_edit", $_GET['dialog']);
                     }
                     if (is_array($module_dialog) and $module_dialog['class_path']) {
                         if (file_exists($module_dialog['class_path'])) {
                             require_once $module_dialog['class_path'];
                             if (class_exists($module_dialog['class'])) {
                                 if (method_exists($module_dialog['class'], $module_dialog['method'])) {
                                     $sample_item = new SampleItem($_GET['sample_id']);
                                     $sample_item->set_gid($_GET['key']);
                                     $description_required = $sample_item->is_description_required();
                                     $keywords_required = $sample_item->is_keywords_required();
                                     if ($description_required and !$_POST['description'] and !$_GET['idk_unique_id'] or $keywords_required and !$_POST['keywords'] and !$_GET['idk_unique_id']) {
                                         require_once "core/modules/item/io/item.io.php";
                                         ItemIO::information(http_build_query($_GET), $description_required, $keywords_required);
                                     } else {
                                         $sample = new Sample($_GET['sample_id']);
                                         $current_requirements = $sample->get_requirements();
                                         if ($_GET['run'] == "item_add") {
                                             $module_dialog['class']::$module_dialog['method']($current_requirements[$_GET['key']]['type_id'], $current_requirements[$_GET['key']]['category_id'], "Sample", $_GET['sample_id'], $_GET['key']);
                                         } elseif ($_GET['run'] == "item_edit") {
                                             $module_dialog['class']::$module_dialog['method']($current_requirements[$_GET['key']]['fulfilled'][0]['item_id']);
                                         }
                                     }
                                 } else {
                                     throw new BaseModuleDialogMethodNotFoundException();
                                 }
                             } else {
                                 throw new BaseModuleDialogClassNotFoundException();
                             }
                         } else {
                             throw new BaseModuleDialogFileNotFoundException();
                         }
                     } else {
                         throw new BaseModuleDialogNotFoundException();
                     }
                 } else {
                     throw new BaseModuleDialogMissingException();
                 }
             } else {
                 throw new SampleSecurityAccessDeniedException();
             }
             break;
             // Sub Item Add
         // Sub Item Add
         case "sub_item_add":
         case "sub_item_edit":
             if ($sample_security->is_access(2, false) == true) {
                 if ($_GET['parent']) {
                     if (is_numeric($_GET['parent_id'])) {
                         if (is_numeric($_GET['key'])) {
                             $item_handling_class = Item::get_handling_class_by_type($_GET['parent']);
                             if (class_exists($item_handling_class)) {
                                 $item_io_handling_class = $item_handling_class::get_item_add_io_handling_class();
                                 if (file_exists("core/modules/" . $item_io_handling_class[0])) {
                                     require_once "core/modules/" . $item_io_handling_class[0];
                                     if (class_exists($item_io_handling_class[1])) {
                                         if ($_GET['run'] == "sub_item_add") {
                                             $item_io_handling_class[1]::item_add_edit_handler("add");
                                         } else {
                                             $item_io_handling_class[1]::item_add_edit_handler("edit");
                                         }
                                     } else {
                                         throw new ItemAddIOClassNotFoundException();
                                     }
                                 } else {
                                     throw new ItemAddIOFileNotFoundException();
                                 }
                             } else {
                                 throw new ItemHandlerClassNotFoundException();
                             }
                         } else {
                             throw new ItemPositionIDMissingException();
                         }
                     } else {
                         throw new ItemParentIDMissingException();
                     }
                 } else {
                     throw new ItemParentTypeMissingException();
                 }
             } else {
                 throw new SampleSecurityAccessDeniedException();
             }
             break;
             // Parent Item Lister
         // Parent Item Lister
         case "parent_item_list":
             if ($sample_security->is_access(1, false) == true) {
                 if ($_GET['dialog']) {
                     $sample = new Sample($_GET['sample_id']);
                     $item_id = $sample->get_item_id();
                     $module_dialog = ModuleDialog::get_by_type_and_internal_name("parent_item_list", $_GET['dialog']);
                     if (file_exists($module_dialog['class_path'])) {
                         require_once $module_dialog['class_path'];
                         if (class_exists($module_dialog['class'])) {
                             if (method_exists($module_dialog['class'], $module_dialog['method'])) {
                                 $module_dialog['class']::$module_dialog['method']($item_id);
                             } else {
                                 throw new BaseModuleDialogMethodNotFoundException();
                             }
                         } else {
                             throw new BaseModuleDialogClassNotFoundException();
                         }
                     } else {
                         throw new BaseModuleDialogFileNotFoundException();
                     }
                 } else {
                     throw new BaseModuleDialogMissingException();
                 }
             } else {
                 throw new SampleSecurityAccessDeniedException();
             }
             break;
             // Common Dialogs
         // Common Dialogs
         case "common_dialog":
             require_once "core/modules/base/common.request.php";
             CommonRequest::common_dialog();
             break;
         default:
             require_once "io/sample.io.php";
             SampleIO::list_user_related_samples();
             break;
     }
 }
Example #5
0
 /**
  * @see SampleInterface::get_requirements()
  * @param boolean $get_fulfilled
  * @return array
  */
 public function get_requirements($get_fulfilled = true)
 {
     global $runtime_data;
     if ($this->sample_id and $this->sample) {
         if ($runtime_data->is_object_data($this, "SAMPLE_" . $this->sample_id . "_REQUIREMENT_ARRAY") == true) {
             return $runtime_data->read_object_data($this, "SAMPLE_" . $this->sample_id . "_REQUIREMENT_ARRAY");
         } else {
             $sample_template = new SampleTemplate($this->sample->get_template_id());
             $requirements_array = $sample_template->get_requirements();
             $return_array = array();
             $parent_item_array = array();
             $counter = 0;
             $type_counter = 0;
             $category_counter = 0;
             $fulfilled_counter = 0;
             $filter_counter = 0;
             $sub_item_counter = 0;
             if (is_array($requirements_array) and count($requirements_array) >= 1) {
                 if ($runtime_data->is_object_data($this, "SAMPLE_" . $this->sample_id . "_FULFILLED_ITEM_TYPE_ARRAY") == true) {
                     $item_type_array = $runtime_data->read_object_data($this, "SAMPLE_" . $this->sample_id . "_FULFILLED_ITEM_TYPE_ARRAY");
                 } else {
                     $item_type_array = Item::list_types();
                     $runtime_data->write_object_data($this, "SAMPLE_" . $this->sample_id . "_FULFILLED_ITEM_TYPE_ARRAY", $item_type_array);
                 }
                 if ($runtime_data->is_object_data($this, "SAMPLE_" . $this->sample_id . "_FULFILLED_ITEM_ARRAY") == true) {
                     $item_array = $runtime_data->read_object_data($this, "SAMPLE_" . $this->sample_id . "_FULFILLED_ITEM_ARRAY");
                 } else {
                     $sample_item = new SampleItem($this->sample_id);
                     $item_array = $sample_item->get_sample_items_with_pos_id();
                     $runtime_data->write_object_data($this, "SAMPLE_" . $this->sample_id . "_FULFILLED_ITEM_ARRAY", $item_array);
                 }
                 foreach ($requirements_array as $key => $value) {
                     if ($value['xml_element'] == "item" and !$value['close']) {
                         $in_item = true;
                         $return_array[$counter]['element_type'] = "item";
                         $return_array[$counter]['display'] = true;
                         $return_array[$counter]['type'] = $value['type'];
                         $return_array[$counter]['name'] = $value['name'];
                         $return_array[$counter]['dialog'] = $value['dialog'];
                         $return_array[$counter]['handling_class'] = Item::get_handling_class_by_type($value['type']);
                         $return_array[$counter]['requirement'] = $value['requirement'];
                         if ($value['occurrence']) {
                             $return_array[$counter]['occurrence'] = $value['occurrence'];
                         } else {
                             $return_array[$counter]['occurrence'] = "once";
                         }
                         if ($value['pos_id']) {
                             $pos_id = $value['pos_id'];
                             $return_array[$counter]['pos_id'] = $value['pos_id'];
                         } else {
                             $pos_id = $counter;
                             $return_array[$counter]['pos_id'] = $counter;
                         }
                         if ($value['type'] != "parentsample") {
                             if (is_array($item_array) and count($item_array) >= 1) {
                                 $item_instance_array = array();
                                 foreach ($item_array as $item_key => $item_value) {
                                     if (is_array($item_type_array) and count($item_type_array) >= 1) {
                                         foreach ($item_type_array as $item_type => $item_handling_class) {
                                             if (class_exists($item_handling_class)) {
                                                 if ($item_handling_class::is_kind_of($item_type, $item_value['item_id']) == true and $item_value['pos_id'] == $pos_id and $item_value['pos_id'] !== null and $pos_id !== null) {
                                                     $item_instance = $item_handling_class::get_instance_by_item_id($item_value['item_id'], true);
                                                     $return_array[$counter]['fulfilled'][$fulfilled_counter]['item_id'] = $item_value['item_id'];
                                                     $return_array[$counter]['fulfilled'][$fulfilled_counter]['id'] = $item_instance->get_item_object_id();
                                                     $return_array[$counter]['fulfilled'][$fulfilled_counter]['name'] = $item_instance->get_item_object_name();
                                                     $item_instance_array[$fulfilled_counter] = $item_instance;
                                                     $fulfilled_counter++;
                                                     break;
                                                 }
                                             }
                                         }
                                     }
                                 }
                                 if ($value['inherit'] == "all" or $force_inherit == true) {
                                     if (is_array($item_instance_array) and count($item_instance_array) >= 1 and $fulfilled_counter >= 1) {
                                         foreach ($item_instance_array as $object_key => $object_value) {
                                             if (is_object($object_value)) {
                                                 if ($object_value instanceof ItemHolderInterface) {
                                                     $return_array[$counter]['sub_items'][$object_key] = $object_value->get_item_add_information();
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         } else {
                             $parent_sample_array = SampleItem::list_sample_id_by_item_id_and_gid_and_parent($this->get_item_id(), $pos_id);
                             if (is_array($parent_sample_array) and count($parent_sample_array) >= 1) {
                                 foreach ($parent_sample_array as $parent_sample_key => $parent_sample_value) {
                                     $item_instance = new Sample($parent_sample_value);
                                     $return_array[$counter]['fulfilled'][$fulfilled_counter]['item_id'] = $item_instance->get_item_id();
                                     $return_array[$counter]['fulfilled'][$fulfilled_counter]['id'] = $parent_sample_value;
                                     $return_array[$counter]['fulfilled'][$fulfilled_counter]['name'] = $item_instance->get_item_object_name();
                                     $item_instance_array[$fulfilled_counter] = $item_instance;
                                     $fulfilled_counter++;
                                 }
                             }
                             if ($value['inherit'] == "all" or $force_inherit == true) {
                                 if (is_array($item_instance_array) and count($item_instance_array) >= 1 and $fulfilled_counter >= 1) {
                                     foreach ($item_instance_array as $object_key => $object_value) {
                                         if (is_object($object_value)) {
                                             if ($object_value instanceof ItemHolderInterface) {
                                                 $return_array[$counter]['sub_items'][$object_key] = $object_value->get_item_add_information();
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     // ITEMI
                     if ($value['xml_element'] == "itemi" and !$value['close']) {
                         if ($in_item == true and is_array($item_instance_array) and count($item_instance_array) >= 1) {
                             foreach ($item_instance_array as $object_key => $object_value) {
                                 if (is_numeric($value['pos_id'])) {
                                     $pos_id = $value['pos_id'];
                                 } else {
                                     $pos_id = $sub_item_counter;
                                 }
                                 $return_array[$counter]['sub_items'][$object_key][$pos_id] = $object_value->get_item_add_information($pos_id);
                             }
                         }
                     }
                     if ($value['xml_element'] == "item" and $value['close'] == "1") {
                         $counter++;
                         $type_counter = 0;
                         $category_counter = 0;
                         $fulfilled_counter = 0;
                         $in_item = false;
                     }
                     if ($value['xml_element'] == "type" and !$value['close'] and $in_item == true and $value['id']) {
                         $return_array[$counter]['type_id'][$type_counter] = $value['id'];
                         $type_counter++;
                     }
                     if ($value['xml_element'] == "category" and !$value['close'] and $in_item == true and $value['id']) {
                         $return_array[$counter]['category_id'][$category_counter] = $value['id'];
                         $category_counter++;
                     }
                 }
             }
             if (is_array($return_array) and count($return_array) >= 1) {
                 foreach ($return_array as $key => $value) {
                     if (!$value['name'] and $value['type']) {
                         if ($return_array[$key]['handling_class']) {
                             $return_array[$key]['name'] = "Add " . $return_array[$key]['handling_class']::get_generic_name($value['type'], $value['type_id']);
                         }
                     }
                     if (is_array($value['sub_items']) and count($value['sub_items']) >= 1) {
                         foreach ($value['sub_items'] as $sub_item_key => $sub_item_value) {
                             if (!$sub_item_value['name'] and $sub_item_value['type']) {
                                 if ($return_array[$key]['sub_items'][$sub_item_key]['handling_class']) {
                                     $return_array[$key]['sub_items'][$sub_item_key]['name'] = "Add " . $return_array[$key]['sub_items'][$sub_item_key]['handling_class']::get_generic_name($sub_item_value['type'], $sub_item_value['type_id']);
                                 }
                             }
                         }
                     }
                 }
             }
             $runtime_data->write_object_data($this, "SAMPLE_" . $this->sample_id . "_REQUIREMENT_ARRAY", $return_array);
             return $return_array;
         }
     } else {
         return null;
     }
 }
Example #6
0
 /**
  * @see Sample_WrapperInterface::count_data_search()
  * @param string $string
  * @param array $sample_id_array
  * @param array $item_type_array
  * @return integer
  */
 public static function count_data_search($string, $sample_id_array, $item_type_array)
 {
     if (is_array($item_type_array) and count($item_type_array) >= 1) {
         $string = strtolower(trim($string));
         $string = str_replace("*", "%", $string);
         $join_sql = "";
         $where_sql = "";
         foreach ($item_type_array as $key => $value) {
             $handling_class = Item::get_handling_class_by_type($value);
             if (class_exists($handling_class)) {
                 $join_sql .= $handling_class::get_sql_join($value);
                 if (($return_where_sql = $handling_class::get_sql_where($value)) != null) {
                     $return_where_sql = str_replace("{STRING}", $string, $return_where_sql);
                     if ($where_sql == "") {
                         $where_sql .= $return_where_sql;
                     } else {
                         $where_sql .= " OR " . $return_where_sql;
                     }
                 }
             }
         }
         return Sample_Wrapper_Access::count_data_search($string, $sample_id_array, $select_sql_array, $join_sql, $where_sql);
     } else {
         return null;
     }
 }
Example #7
0
 private function interpret($word)
 {
     switch ($word) {
         case "list":
             if (is_array($this->temp)) {
                 array_push($this->stack, "list");
                 $this->result = $this->temp;
                 unset($this->temp);
             }
             break;
         case "typeof":
             array_push($this->stack, "typeof");
             break;
         case "getName":
             $item_type_array = Item::list_types();
             if (is_array($this->result)) {
                 $new_result = array();
                 foreach ($this->result as $key => $value) {
                     if (is_array($item_type_array) and count($item_type_array) >= 1) {
                         foreach ($item_type_array as $item_type_key => $item_type_value) {
                             if (class_exists($item_type_value)) {
                                 if ($item_type_value::is_kind_of($item_type_key, $value)) {
                                     $instance = $item_type_value::get_instance_by_item_id($value);
                                     if (!in_array($instance->get_item_object_name(), $new_result)) {
                                         array_push($new_result, $instance->get_item_object_name());
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $this->result = $new_result;
             } else {
                 if (is_array($item_type_array) and count($item_type_array) >= 1) {
                     foreach ($item_type_array as $key => $value) {
                         if (class_exists($value)) {
                             if ($value::is_kind_of($key, $this->stack[count($this->stack) - 1])) {
                                 $instance = $value::get_instance_by_item_id($this->stack[count($this->stack) - 1]);
                                 $this->result = $instance->get_item_object_name();
                             }
                         }
                     }
                 }
             }
             break;
         case "parents":
             $item_type_array = Item::list_types();
             if (is_array($item_type_array) and count($item_type_array) >= 1) {
                 foreach ($item_type_array as $key => $value) {
                     if (class_exists($value)) {
                         if ($value::is_kind_of($key, $this->stack[count($this->stack) - 1])) {
                             $instance = $value::get_instance_by_item_id($this->stack[count($this->stack) - 1]);
                             $this->temp = $instance->get_item_parents();
                         }
                     }
                 }
             }
             break;
         default:
             if (is_numeric($word) or strpos(strtolower($word), "c") === 0) {
                 if ($this->stack[count($this->stack) - 1] == "typeof") {
                     if (strpos(strtolower($word), "c") === 0) {
                         $category_id = (int) str_replace("c", "", $word);
                         $type_id = null;
                     } else {
                         $category_id = null;
                         $type_id = $word;
                     }
                     $handling_class = $this->handling_class;
                     if (is_array($this->result) and count($this->result) >= 1) {
                         $new_result = array();
                         foreach ($this->result as $key => $value) {
                             if ($handling_class::is_type_or_category($category_id, $type_id, $value) == true) {
                                 array_push($new_result, $value);
                             }
                         }
                         $this->result = $new_result;
                     }
                 }
             } else {
                 $this->handling_class = Item::get_handling_class_by_type($word);
                 $handling_class = $this->handling_class;
                 if (class_exists($handling_class)) {
                     if (is_array($this->temp) and count($this->temp) >= 1) {
                         $new_temp = array();
                         foreach ($this->temp as $key => $value) {
                             if ($handling_class::is_kind_of($word, $value) == true) {
                                 array_push($new_temp, $value);
                             }
                         }
                         $this->temp = $new_temp;
                     } else {
                         // Too slow
                     }
                 }
             }
             break;
     }
     if (count($this->string_array) == 0) {
         return $this->result;
     } else {
         return $this->get_content(null, null, null, null);
     }
 }