/** * @param string $get_array * @param string $comment * @return string * @throws ProjectException * @throws ProjectSecurityAccessDeniedException * @throws ProjectIDMissingException */ public static function cancel_handler($get_array, $comment) { global $user; if ($get_array) { $_GET = unserialize($get_array); } if ($_GET['project_id']) { $project = new Project($_GET['project_id']); if ($project->get_current_status_id() == 0) { if ($user->is_admin() == true) { if ($project->mark_as_reactivated() == false) { throw new ProjectException(); } else { return "1"; } } else { throw new ProjectSecurityAccessDeniedException(); } } else { $project_security = new ProjectSecurity($_GET['project_id']); if ($project_security->is_access(3, false) == true) { if ($project->mark_as_canceled($comment) == false) { throw new ProjectException(); } else { return "1"; } } else { throw new ProjectSecurityAccessDeniedException(); } } } else { throw new ProjectIDMissingException(); } }
/** * @see ProjectInterface::list_user_related_projects() * @param integer $user_id * @param bool $analysis_only * @return array */ public static function list_user_related_projects($user_id, $analysis_only) { global $user; if ($user_id == null) { $user_id = $user->get_user_id(); } $return_array = array(); $project_array = Project_Access::list_root_entries(); if (is_array($project_array) and count($project_array) >= 1) { foreach ($project_array as $key => $value) { $project = new Project($value); $project_security = new ProjectSecurity($value); $project_security->set_user_id($user_id); if ($project_security->is_access(3, true) or $project_security->is_access(4, true) or $project_security->is_access(7, true)) { if ($project->get_deleted() == false) { array_push($return_array, $value); } } } return $return_array; } else { return null; } }
/** * @param string $json_column_array * @param string $json_argument_array * @param string $css_page_id * @param string $css_row_sort_id * @param string $entries_per_page * @param string $page * @param string $sortvalue * @param string $sortmethod * @return string * @throws ItemIDMissingException */ public static function list_projects_by_item_id($json_column_array, $json_argument_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod) { global $user; $argument_array = json_decode($json_argument_array); $item_id = $argument_array[0][1]; if (is_numeric($item_id)) { $list_request = new ListRequest_IO(); if (!is_numeric($entries_per_page) or $entries_per_page < 1) { $entries_per_page = 20; } if ($argument_array[2][1] == true) { $list_array = Project_Wrapper::list_projects_by_item_id($item_id, $user->is_admin(), $sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page); } else { $list_array = Project_Wrapper::list_projects_by_item_id($item_id, $user->is_admin(), $sortvalue, $sortmethod, 0, null); } $list_request->set_column_array($json_column_array); if (is_array($list_array) and count($list_array) >= 1) { foreach ($list_array as $key => $value) { $tmp_name = trim($list_array[$key]['name']); unset($list_array[$key]['name']); $list_array[$key]['name']['label'] = $tmp_name; $list_array[$key]['name']['content'] = $tmp_name; $tmp_template = trim($list_array[$key]['template']); unset($list_array[$key]['template']); $list_array[$key]['template']['label'] = $tmp_template; $list_array[$key]['template']['content'] = $tmp_template; $tmp_status = trim($list_array[$key]['status']); unset($list_array[$key]['status']); $list_array[$key]['status']['label'] = $tmp_status; $list_array[$key]['status']['content'] = $tmp_status; if ($list_array[$key]['deleted'] == "t") { $list_array[$key]['name']['content'] = "<span class='crossed'>" . $list_array[$key]['name']['content'] . "</span>"; $list_array[$key]['template']['content'] = "<span class='crossed'>" . $list_array[$key]['template']['content'] . "</span>"; $list_array[$key]['status']['content'] = "<span class='crossed'>" . $list_array[$key]['status']['content'] . "</span>"; } if ($argument_array[1][1] == true) { $column_array = json_decode($json_column_array); if (is_array($column_array) and count($column_array) >= 1) { foreach ($column_array as $row_key => $row_value) { if ($row_value[1] == "checkbox") { if ($row_value[4]) { $checkbox_class = $row_value[4]; break; } } } } if ($checkbox_class) { $list_array[$key]['checkbox'] = "<input type='checkbox' name='parent-project-" . $list_array[$key]['id'] . "' value='1' class='" . $checkbox_class . "' />"; } else { $list_array[$key]['checkbox'] = "<input type='checkbox' name='parent-project-" . $list_array[$key]['id'] . "' value='1' />"; } $list_array[$key]['symbol'] = "<img src='images/icons/project.png' alt='' style='border:0;' />"; } else { $project_id = $list_array[$key]['id']; $project_security = new ProjectSecurity($project_id); if ($project_security->is_access(1, false)) { $paramquery = array(); $paramquery['username'] = $_GET['username']; $paramquery['session_id'] = $_GET['session_id']; $paramquery['nav'] = "project"; $paramquery['run'] = "detail"; $paramquery['project_id'] = $project_id; $params = http_build_query($paramquery, '', '&'); $list_array[$key]['symbol']['link'] = $params; $list_array[$key]['symbol']['content'] = "<img src='images/icons/project.png' alt='' style='border:0;' />"; $list_array[$key]['name']['link'] = $params; } else { $list_array[$key]['symbol'] = "<img src='core/images/denied_overlay.php?image=images/icons/project.png' alt='N' border='0' />"; } } $datetime_handler = new DatetimeHandler($list_array[$key]['datetime']); $list_array[$key]['datetime'] = $datetime_handler->get_datetime(false); if ($list_array[$key]['owner']) { $user = new User($list_array[$key]['owner']); } else { $user = new User(1); } $list_array[$key]['owner'] = $user->get_full_name(true); } } else { $list_request->empty_message("<span class='italic'>No Projects found!</span>"); } $list_request->set_array($list_array); return $list_request->get_page($page); } else { throw new ItemIDMissingException(); } }
/** * @todo reactivate schedule after workflow integration */ public static function tab_header() { if ($_GET['project_id']) { $tab_io = new Tab_IO(); // Main Page $paramquery['username'] = $_GET['username']; $paramquery['session_id'] = $_GET['session_id']; $paramquery['nav'] = "project"; $paramquery['run'] = "detail"; $paramquery['project_id'] = $_GET['project_id']; $params = http_build_query($paramquery, '', '&'); unset($paramquery); $tab_io->add("main", Language::get_message("ProjectGeneralDetailTabMainPage", "general"), $params, false); // Log $paramquery['username'] = $_GET['username']; $paramquery['session_id'] = $_GET['session_id']; $paramquery['nav'] = "project"; $paramquery['run'] = "log"; $paramquery['project_id'] = $_GET['project_id']; $params = http_build_query($paramquery, '', '&'); unset($paramquery); $tab_io->add("log", Language::get_message("ProjectGeneralDetailTabLog", "general"), $params, false); // Structure $paramquery['username'] = $_GET['username']; $paramquery['session_id'] = $_GET['session_id']; $paramquery['nav'] = "project"; $paramquery['run'] = "structure"; $paramquery['project_id'] = $_GET['project_id']; $params = http_build_query($paramquery, '', '&'); unset($paramquery); $tab_io->add("structure", Language::get_message("ProjectGeneralDetailTabStructure", "general"), $params, false); // Schedule /* $paramquery['username'] = $_GET['username']; $paramquery['session_id'] = $_GET['session_id']; $paramquery['nav'] = "project"; $paramquery['run'] = "schedule"; $paramquery['project_id'] = $_GET['project_id']; $params = http_build_query($paramquery,'','&'); unset($paramquery); $tab_io->add("schedule", Language::get_message("ProjectGeneralDetailTabSchedule", "general"), $params, false); */ // Item Lister Dialogs $module_dialog_array = ModuleDialog::list_dialogs_by_type("item_list"); if (is_array($module_dialog_array) and count($module_dialog_array) >= 1) { foreach ($module_dialog_array as $key => $value) { $paramquery['username'] = $_GET['username']; $paramquery['session_id'] = $_GET['session_id']; $paramquery['nav'] = "project"; $paramquery['run'] = "item_list"; $paramquery['project_id'] = $_GET['project_id']; $paramquery['dialog'] = $value['internal_name']; $params = http_build_query($paramquery, '', '&'); $tab_io->add($value['internal_name'], Language::get_message($value['language_address'], "dialog"), $params, false); } } // Administration $project_security = new ProjectSecurity($_GET['project_id']); if ($project_security->is_access(2, false) or $project_security->is_access(3, false) or $project_security->is_access(4, false) or $project_security->is_access(5, false) or $project_security->is_access(6, false) or $project_security->is_access(7, false)) { $paramquery['username'] = $_GET['username']; $paramquery['session_id'] = $_GET['session_id']; $paramquery['nav'] = "project"; $paramquery['run'] = "admin"; $paramquery['project_id'] = $_GET['project_id']; unset($paramquery['dialog']); $params = http_build_query($paramquery, '', '&'); unset($paramquery); $tab_io->add("admin", Language::get_message("ProjectGeneralDetailTabAdministration", "general"), $params, false, false); } if ($_GET['run'] != "item_add" and $_GET['run'] != "item_list") { switch ($_GET['run']) { case "log": case "log_detail": case "log_add": $tab_io->activate("log"); break; case "structure": $tab_io->activate("structure"); break; case "add_task": case "task_delete": case "task_detail": case "schedule": case "show_tasks": case "task_edit_start": case "task_edit_end": $tab_io->activate("schedule"); break; case "admin": $tab_io->activate("admin"); break; default: if (strpos($_GET['run'], "admin_") === 0) { $tab_io->activate("admin"); } else { $tab_io->activate("main"); } break; } } else { if ($_GET['run'] == "item_list" and $_GET['dialog']) { $tab_io->activate($_GET['dialog']); } else { $tab_io->activate("main"); } } $tab_io->output(); } }
/** * @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); } }
/** * @param integer $folder_id */ function __construct($folder_id) { if (is_numeric($folder_id)) { parent::__construct($folder_id); $this->project_folder = new ProjectHasFolder_Access($folder_id); $this->project_id = $this->project_folder->get_project_id(); if ($this->project_id) { $project_security = new ProjectSecurity($this->project_id); if ($this->get_automatic == false) { $permission_bin = decbin($this->get_permission()); $permission_bin = str_pad($permission_bin, 16, "0", STR_PAD_LEFT); $permission_bin = strrev($permission_bin); } if ($this->read_access == false) { if ($this->get_automatic() == true) { if ($project_security->is_access(1, false) or $project_security->is_access(2, false)) { $this->read_access = true; } } else { if ($permission_bin[8] == "1" and ($project_security->is_access(1, false) or $project_security->is_access(2, false))) { $this->read_access = true; } } } if ($this->write_access == false) { if ($this->get_automatic() == true) { if ($project_security->is_access(3, false) or $project_security->is_access(4, false)) { $this->write_access = true; } } else { if ($permission_bin[9] == "1" and ($project_security->is_access(3, false) or $project_security->is_access(4, false))) { $this->write_access = true; } } } if ($this->delete_access == false) { if ($this->get_automatic() == true) { if ($project_security->is_access(5, false)) { $this->delete_access = true; } } else { if ($permission_bin[10] == "1" and $project_security->is_access(5, false)) { $this->delete_access = true; } } } if ($this->control_access == false) { if ($this->get_automatic() == true) { if ($project_security->is_access(7, false)) { $this->control_access = true; } } else { if ($permission_bin[11] == "1" and $project_security->is_access(7, false)) { $this->control_access = true; } } } } } else { parent::__construct(null); $this->project_folder = null; $this->project_id = null; } }