/**
  * @see ProjectItemFactoryInterface::create()
  * @param integer $project_id
  * @param integer $item_id
  * @param integer $gid
  * @param string $keywords
  * @param string $description
  * @return bool
  */
 public static function create($project_id, $item_id, $gid, $keywords = null, $description = null, $parent_item_id = null, $status_id = null)
 {
     global $transaction;
     if ($transaction->is_in_transction() == true and is_numeric($project_id) and is_numeric($item_id)) {
         if (self::$project_instance_array[$project_id]) {
             $project = self::$project_instance_array[$project_id];
         } else {
             $project = new Project($project_id);
             self::$project_instance_array[$project_id] = $project;
         }
         $project_item = new ProjectItem($project_id);
         $project_item->set_gid($gid);
         if (!$status_id) {
             $project_item->set_status_id($project->get_current_status_id());
         } else {
             $project_item->set_status_id($status_id);
         }
         $project_item->set_parent_item_id($parent_item_id);
         if ($project_item->set_item_id($item_id) == false) {
             return false;
         }
         if ($project_item->link_item() == false) {
             return false;
         }
         $project_item->set_item_status();
         if (($class_name = $project_item->is_classified()) == true) {
             if ($project_item->set_class($class_name) == false) {
                 return false;
             }
         }
         $description_required = $project_item->is_description();
         $keywords_required = $project_item->is_keywords();
         if ($description_required == true xor $keywords_required == true) {
             if ($description_required == false and $keywords_required == true) {
                 $project_item->set_information(null, $keywords);
             } else {
                 $project_item->set_information($description, null);
             }
         } else {
             if ($description_required == true and $keywords_required == true) {
                 $project_item->set_information($description, $keywords);
             }
         }
         if ($project_item->create_log_entry() == false) {
             return false;
         } else {
             ProjectTask::check_over_time_tasks($project_id);
             return true;
         }
     } else {
         return false;
     }
 }
Example #2
0
 /**
  * @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();
     }
 }
Example #3
0
 /**
  * @param string $get_array
  * @return string
  * @throws ProjectIDMissingException
  */
 public static function get_project_menu($get_array)
 {
     global $project_security;
     if ($get_array) {
         $_GET = unserialize($get_array);
     }
     if ($_GET['project_id']) {
         $project = new Project($_GET['project_id']);
         $folder_id = ProjectStatusFolder::get_folder_by_project_id_and_project_status_id($_GET['project_id'], $project->get_current_status_id());
         $template = new HTMLTemplate("project/ajax/detail_menu.html");
         switch ($project->is_next_status_available()) {
             case 0:
                 if ($project->get_current_status_id() == 0) {
                     $template->set_var("proceed", 3);
                 } else {
                     $template->set_var("proceed", 4);
                 }
                 break;
             case 1:
                 if ($project_security->is_access(3, false) == true) {
                     if ($project->is_current_status_fulfilled()) {
                         $template->set_var("proceed", 1);
                     } else {
                         $template->set_var("proceed", 2);
                     }
                 }
                 break;
             case 2:
                 if ($project_security->is_access(3, false) == true) {
                     if ($project->is_current_status_fulfilled()) {
                         $template->set_var("proceed", 5);
                     } else {
                         $template->set_var("proceed", 6);
                     }
                 }
                 break;
             default:
                 $template->set_var("proceed", 7);
                 break;
         }
         $template->set_var("next_status_name", $project->get_next_status_name());
         if ($project_security->is_access(3, false) == true) {
             $project_template = new ProjectTemplate($project->get_template_id());
             $current_status_requirements = $project->get_current_status_requirements($project->get_current_status_id());
             $result = array();
             $counter = 0;
             if (is_array($current_status_requirements) and count($current_status_requirements) >= 1) {
                 foreach ($current_status_requirements as $key => $value) {
                     switch ($value['element_type']) {
                         case "item":
                             $paramquery = array();
                             $paramquery['username'] = $_GET['username'];
                             $paramquery['session_id'] = $_GET['session_id'];
                             $paramquery['nav'] = "project";
                             $paramquery['project_id'] = $_GET['project_id'];
                             require_once "core/modules/item/common/item_common.io.php";
                             $menu_element_array = ItemCommonIO::get_menu_element($value, $key, $counter, $paramquery, "Project", $_GET['project_id']);
                             $result = array_merge($result, $menu_element_array[0]);
                             $counter = $menu_element_array[1];
                             break;
                         case "extension":
                             $paramquery = array();
                             $paramquery['username'] = $_GET['username'];
                             $paramquery['session_id'] = $_GET['session_id'];
                             $paramquery['nav'] = "project";
                             $paramquery['run'] = "extension";
                             $paramquery['project_id'] = $_GET['project_id'];
                             $paramquery['extension'] = $value['extension'];
                             $paramquery['retrace'] = Retrace::create_retrace_string();
                             $params = http_build_query($paramquery, '', '&');
                             $result[$counter]['name'] = "Run " . $value['name'];
                             $result[$counter]['depends'] = false;
                             $result[$counter]['params'] = $params;
                             if ($value['fulfilled'] == 1) {
                                 if ($value['occurrence'] == "multiple") {
                                     $result[$counter]['type'] = "link";
                                     $result[$counter]['image'] = "add_extension_done";
                                 } else {
                                     $result[$counter]['type'] = false;
                                     $result[$counter]['image'] = "add_extension_done_na";
                                 }
                             } elseif ($value['fulfilled'] == 0) {
                                 if ($value['occurrence'] == "multiple") {
                                     $result[$counter]['type'] = "link";
                                     $result[$counter]['image'] = "add_extension_wait";
                                 } else {
                                     $result[$counter]['type'] = false;
                                     $result[$counter]['image'] = "add_extension_wait_na";
                                 }
                             } else {
                                 $result[$counter]['type'] = "link";
                                 $result[$counter]['image'] = "add_extension";
                             }
                             if ($value['requirement'] == "optional" and $value['fulfilled'] != 0) {
                                 $result[$counter]['name'] = $result[$counter]['name'] . " (optional)";
                             }
                             $counter++;
                             break;
                     }
                 }
             }
             if ($counter > 0) {
                 $template->set_var("status_action", $result);
             }
             $template->set_var("write", true);
         } else {
             $template->set_var("write", false);
         }
         $paramquery = array();
         $paramquery['username'] = $_GET['username'];
         $paramquery['session_id'] = $_GET['session_id'];
         $paramquery['nav'] = "project";
         $paramquery['run'] = "common_dialog";
         $paramquery['folder_id'] = ProjectFolder::get_supplementary_folder($_GET['project_id']);
         $paramquery['dialog'] = "file_add";
         $paramquery['retrace'] = Retrace::create_retrace_string();
         unset($paramquery['nextpage']);
         $supplementary_params = http_build_query($paramquery, '', '&');
         $template->set_var("supplementary_params", $supplementary_params);
         $log_paramquery = $_GET;
         $log_paramquery['run'] = "log_add";
         unset($log_paramquery['nextpage']);
         $log_params = http_build_query($log_paramquery, '', '&');
         $template->set_var("log_params", $log_params);
         $add_task_paramquery = $_GET;
         $add_task_paramquery['run'] = "add_task";
         unset($add_task_paramquery['nextpage']);
         $add_task_params = http_build_query($add_task_paramquery, '', '&');
         $template->set_var("add_task_params", $add_task_params);
         $show_tasks_paramquery = $_GET;
         $show_tasks_paramquery['run'] = "show_tasks";
         unset($show_tasks_paramquery['nextpage']);
         $show_tasks_params = http_build_query($show_tasks_paramquery, '', '&');
         $template->set_var("show_tasks_params", $show_tasks_params);
         $subproject_paramquery = $_GET;
         $subproject_paramquery['run'] = "new_subproject";
         unset($subproject_paramquery['nextpage']);
         $subproject_params = http_build_query($subproject_paramquery, '', '&');
         $template->set_var("add_subproject_params", $subproject_params);
         $template->output();
     } else {
         throw new ProjectIDMissingException();
     }
 }
Example #4
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 #5
0
 /**
  * @see ProjectTaskInterface::create_status_process()
  * @param integer $project_id
  * @param integer $user_id
  * @param string $comment
  * @param string $start_date
  * @param string $start_time
  * @param string $end_date
  * @param string $end_time
  * @param bool $whole_day
  * @param integer $end_status_id
  * @param bool $finalise
  * @param bool $auto_connect
  * @return integer
  * @throws ProjectTaskCreateException
  * @throws ProjectTaskCreateAttachException
  */
 public function create_status_process($project_id, $user_id, $comment, $start_date, $start_time, $end_date, $end_time, $whole_day, $end_status_id, $finalise, $auto_connect)
 {
     global $transaction;
     if (is_numeric($project_id) and is_numeric($user_id) and $end_date and ($end_time or $whole_day == true) and $end_status_id) {
         $transaction_id = $transaction->begin();
         $project = new Project($project_id);
         $project_task_point = new ProjectTaskPoint($project_id);
         $start_status_id = $project->get_current_status_id();
         if ($auto_connect == true) {
             // Get all autoconnected tasks of the project
             $task_array = ProjectTask_Access::list_auto_connected_entries_by_project_id($project_id);
             // Create Task
             $current_task_object = new ProjectTask_Access(null);
             $current_task_id = $current_task_object->create(1, $project_id, $user_id, $comment, $start_date, $start_time, $end_date, $end_time, $whole_day, true);
             if ($current_task_id) {
                 $current_task_type_object = new ProjectTaskStatusProcess_Access(null);
                 if ($current_task_type_object->create($current_task_id, $start_status_id, $end_status_id, $project_task_point->get_current_achieved_points(null), $finalise) == null) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new ProjectTaskCreateException("Could not create Status Task");
                 }
                 if (is_array($task_array) and count($task_array) >= 1) {
                     foreach ($task_array as $key => $value) {
                         $task_object = new ProjectTask_Access($value);
                         if ($task_object->get_type_id() == 1) {
                             $task_type_object = new ProjectTaskStatusProcess_Access($value);
                             $project_start_status_relation = new ProjectStatusRelation($project_id, $task_type_object->get_begin_status_id());
                             $project_end_status_relation = new ProjectStatusRelation($project_id, $task_type_object->get_end_status_id());
                             if ($project_end_status_relation->get_next() == $start_status_id) {
                                 // Case 1: End-status of an existing task will be start-status of the new task
                                 // Attach task directly
                                 $project_task_has_previous_task = new ProjectTaskHasPreviousTask_Access(null, null);
                                 if ($project_task_has_previous_task->create($current_task_id, $value) == null) {
                                     if ($transaction_id != null) {
                                         $transaction->rollback($transaction_id);
                                     }
                                     return null;
                                 }
                             } else {
                                 // Case 2: Start-status is inside an existing task
                                 // Case 2a: New task will be included after an existing task, existing task will be shortened
                                 // (e.g. include a task with the same begin like an existing task and choose a later status)
                                 $object_datetime_handler = new DatetimeHandler($task_object->get_end_date());
                                 $current_datetime_handler = new DatetimeHandler($end_date);
                                 if ($project_end_status_relation->is_less($end_status_id) and $current_datetime_handler->distance($object_datetime_handler) < 0) {
                                     // Check if interlinked
                                     $next_task_array = ProjectTaskHasPreviousTask_Access::list_tasks_by_previous_task_id($value);
                                     $connect_task = true;
                                     if (is_array($next_task_array) and count($next_task_array) >= 1) {
                                         foreach ($next_task_array as $next_key => $next_value) {
                                             $check_task_object = new ProjectTask_Access($next_value);
                                             if ($check_task_object->get_type_id() == 1) {
                                                 $check_task_type_object = new ProjectTaskStatusProcess_Access($value);
                                                 $check_project_start_status_relation = new ProjectStatusRelation($project_id, $check_task_type_object->get_begin_status_id());
                                                 $check_project_end_status_relation = new ProjectStatusRelation($project_id, $check_task_type_object->get_end_status_id());
                                                 if ($check_task_object->get_end_time() != null) {
                                                     $check_object_datetime_handler = new DatetimeHandler($check_task_object->get_end_date() . " " . $check_task_object->get_end_time());
                                                 } else {
                                                     $check_object_datetime_handler = new DatetimeHandler($check_task_object->get_end_date() . " 23:59:59");
                                                 }
                                                 if ($whole_day == false and $end_time) {
                                                     $check_current_datetime_handler = new DatetimeHandler($end_date . " " . $end_time);
                                                 } else {
                                                     $check_current_datetime_handler = new DatetimeHandler($end_date . " 23:59:59");
                                                 }
                                                 if ($check_project_end_status_relation->is_less($end_status_id) and $check_current_datetime_handler->distance($check_object_datetime_handler) < 0) {
                                                     $connect_task = false;
                                                 }
                                             }
                                         }
                                     }
                                     if ($connect_task == true) {
                                         if ($task_object->get_whole_day() == true) {
                                             $new_start_datetime_handler = new DatetimeHandler($task_object->get_end_date());
                                             $new_start_datetime_handler->add_day(1);
                                             if ($current_task_object->set_start_date($new_start_datetime_handler->get_formatted_string("Y-m-d")) == false) {
                                                 if ($transaction_id != null) {
                                                     $transaction->rollback($transaction_id);
                                                 }
                                                 throw new ProjectTaskCreateAttachException("Could not set start date (whole day)");
                                             }
                                         } else {
                                             $new_start_datetime_handler = new DatetimeHandler($task_object->get_end_date() . " " . $task_object->get_end_time());
                                             $new_start_datetime_handler->add_second(1);
                                             if ($current_task_object->set_start_date($new_start_datetime_handler->get_formatted_string("Y-m-d")) == false) {
                                                 if ($transaction_id != null) {
                                                     $transaction->rollback($transaction_id);
                                                 }
                                                 throw new ProjectTaskCreateAttachException("Could not set start date (time)");
                                             }
                                             if ($current_task_object->set_start_time($new_start_datetime_handler->get_formatted_string("H:i:s")) == false) {
                                                 if ($transaction_id != null) {
                                                     $transaction->rollback($transaction_id);
                                                 }
                                                 throw new ProjectTaskCreateAttachException("Could not set start time (time)");
                                             }
                                         }
                                         if ($current_task_type_object->set_begin_status_id($task_type_object->get_end_status_id()) == false) {
                                             if ($transaction_id != null) {
                                                 $transaction->rollback($transaction_id);
                                             }
                                             throw new ProjectTaskCreateAttachException("Could not set start status id");
                                         }
                                         // Change later tasks
                                         $next_task_array = ProjectTaskHasPreviousTask_Access::list_tasks_by_previous_task_id($value);
                                         if (is_array($next_task_array) and count($next_task_array) >= 1) {
                                             foreach ($next_task_array as $next_key => $next_value) {
                                                 $project_task_has_previous_task = new ProjectTaskHasPreviousTask_Access($next_value, $value);
                                                 if ($project_task_has_previous_task->set_previous_task_id($current_task_id) == null) {
                                                     if ($transaction_id != null) {
                                                         $transaction->rollback($transaction_id);
                                                     }
                                                     throw new ProjectTaskCreateAttachException("Could not set previous task id");
                                                 }
                                             }
                                         }
                                         // Connect Tasks
                                         $project_task_has_previous_task = new ProjectTaskHasPreviousTask_Access(null, null);
                                         if ($project_task_has_previous_task->create($current_task_id, $value) == null) {
                                             if ($transaction_id != null) {
                                                 $transaction->rollback($transaction_id);
                                             }
                                             throw new ProjectTaskCreateAttachException("Could not create task link");
                                         }
                                     }
                                 }
                                 // Case 2b: New task will be included before an existing task
                                 if (($project_start_status_relation->is_less($end_status_id) or $task_type_object->get_begin_status_id() == $end_status_id) and $project_end_status_relation->is_more($end_status_id) and $current_datetime_handler->distance($object_datetime_handler) >= 0) {
                                     // Change Date and Status
                                     if ($whole_day == true) {
                                         $new_end_datetime_handler = new DatetimeHandler($end_date);
                                         $new_end_datetime_handler->add_day(1);
                                         if ($task_object->set_start_date($new_end_datetime_handler->get_formatted_string("Y-m-d")) == false) {
                                             if ($transaction_id != null) {
                                                 $transaction->rollback($transaction_id);
                                             }
                                             throw new ProjectTaskCreateAttachException("Could not set start date (whole day)");
                                         }
                                     } else {
                                         $new_end_datetime_handler = new DatetimeHandler($end_date . " " . $end_time);
                                         $new_end_datetime_handler->add_second(1);
                                         if ($task_object->set_start_date($new_end_datetime_handler->get_formatted_string("Y-m-d")) == false) {
                                             if ($transaction_id != null) {
                                                 $transaction->rollback($transaction_id);
                                             }
                                             throw new ProjectTaskCreateAttachException("Could not set start date (time)");
                                         }
                                         if ($task_object->set_start_time($new_end_datetime_handler->get_formatted_string("H:i:s")) == false) {
                                             if ($transaction_id != null) {
                                                 $transaction->rollback($transaction_id);
                                             }
                                             throw new ProjectTaskCreateAttachException("Could not set start time (time)");
                                         }
                                     }
                                     if ($task_type_object->set_begin_status_id($end_status_id) == false) {
                                         if ($transaction_id != null) {
                                             $transaction->rollback($transaction_id);
                                         }
                                         throw new ProjectTaskCreateAttachException("Could not start status id");
                                     }
                                     // Change previous tasks
                                     $previous_task_array = ProjectTaskHasPreviousTask_Access::list_previous_tasks_by_task_id($value);
                                     if (is_array($previous_task_array) and count($previous_task_array) >= 1) {
                                         foreach ($previous_task_array as $previous_key => $previous_value) {
                                             $project_task_has_previous_task = new ProjectTaskHasPreviousTask_Access($value, $previous_value);
                                             if ($project_task_has_previous_task->set_task_id($current_task_id) == false) {
                                                 if ($transaction_id != null) {
                                                     $transaction->rollback($transaction_id);
                                                 }
                                                 throw new ProjectTaskCreateAttachException("Could not set previous task");
                                             }
                                         }
                                     }
                                     // Connect Tasks
                                     $project_task_has_previous_task = new ProjectTaskHasPreviousTask_Access(null, null);
                                     if ($project_task_has_previous_task->create($value, $current_task_id) == null) {
                                         if ($transaction_id != null) {
                                             $transaction->rollback($transaction_id);
                                         }
                                         throw new ProjectTaskCreateAttachException("Could not create task link");
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if ($transaction_id != null) {
                     $transaction->commit($transaction_id);
                 }
                 return $current_task_id;
             } else {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 throw new ProjectTaskCreateException("Could not create parent Task");
             }
         } else {
             $current_task_object = new ProjectTask_Access(null);
             if (($current_task_id = $current_task_object->create(1, $project_id, $user_id, $comment, $start_date, $start_time, $end_date, $end_time, $whole_day, false)) != null) {
                 $current_task_type_object = new ProjectTaskStatusProcess_Access(null);
                 if ($current_task_type_object->create($current_task_id, $start_status_id, $end_status_id, $project_task_point->get_current_achieved_points(), $finalise) != null) {
                     if ($transaction_id != null) {
                         $transaction->commit($transaction_id);
                     }
                     return $current_task_id;
                 } else {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new ProjectTaskCreateException("Could not create Status Task");
                 }
             } else {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 throw new ProjectTaskCreateException("Could not create parent Task");
             }
         }
     } else {
         throw new ProjectTaskCreateException("Information Missing");
     }
 }