Beispiel #1
0
 /**
  * @see ProjectInterface::delete()
  * @return bool
  * @throws ProjectDeleteException
  * @throws ProjectDeleteContainsSubProjectsException
  * @throws ProjectDeleteFolderException
  * @throws ProjectDeleteItemException
  * @throws ProjectDeleteLinkException
  * @throws ProjectDeleteLogException
  * @throws ProjectDeletePermissionException
  * @throws ProjectDeleteStatusException
  * @throws ProjectDeleteTaskException
  */
 public function delete()
 {
     global $transaction;
     if ($this->project_id) {
         $transaction_id = $transaction->begin();
         array_push(self::$project_delete_array, $this->project_id);
         if ($this->exist_subproject() == true) {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
                 throw new ProjectDeleteContainsSubProjectsException();
             }
         }
         $tmp_project_id = $this->project_id;
         // Permissions
         $project_permission_array = ProjectPermission::list_entries_by_project_id($tmp_project_id);
         if (is_array($project_permission_array) and count($project_permission_array) >= 1) {
             foreach ($project_permission_array as $key => $value) {
                 try {
                     $project_permission = ProjectPermission::get_instance($value);
                     $project_permission->delete();
                 } catch (ProjectPermissionException $e) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new ProjectDeletePermissionException();
                 }
             }
         }
         // Log Entries
         $project_log_array = ProjectLog::list_entries_by_project_id($tmp_project_id);
         if (is_array($project_log_array) and count($project_log_array) >= 1) {
             foreach ($project_log_array as $key => $value) {
                 $project_log = new ProjectLog($value);
                 try {
                     $project_log->delete();
                 } catch (ProjectLogDeleteException $e) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new ProjectDeleteLogException();
                 }
             }
         }
         // Project Status
         $project_has_project_status_array = ProjectHasProjectStatus_Access::list_entries_by_project_id($tmp_project_id);
         if (is_array($project_has_project_status_array) and count($project_has_project_status_array) >= 1) {
             foreach ($project_has_project_status_array as $key => $value) {
                 $project_has_project_status = new ProjectHasProjectStatus_Access($value);
                 try {
                     $project_has_project_status->delete();
                 } catch (ProjectStatusDeleteException $e) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new ProjectDeleteStatusException();
                 }
             }
         }
         // Project Links
         $project_link_array = ProjectLink_Access::list_entries_by_project_id($tmp_project_id);
         if (is_array($project_link_array) and count($project_link_array) >= 1) {
             foreach ($project_link_array as $key => $value) {
                 $project_link = new ProjectLink_Access($value);
                 if ($project_link->delete() == false) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new ProjectDeleteLinkException();
                 }
             }
         }
         // Linked Items
         $project_item = new ProjectItem($tmp_project_id);
         $item_array = $project_item->get_project_items();
         if (is_array($item_array) and count($item_array) >= 1) {
             foreach ($item_array as $item_key => $item_value) {
                 $project_item = new ProjectItem($tmp_project_id);
                 $project_item->set_item_id($item_value);
                 if ($project_item->unlink_item() == false) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new ProjectDeleteItemException();
                 }
             }
         }
         // Project Tasks
         $project_task_array = ProjectTask::list_tasks($tmp_project_id);
         if (is_array($project_task_array) and count($project_task_array) >= 1) {
             foreach ($project_task_array as $key => $value) {
                 $project_task = new ProjectTask($value);
                 if ($project_task->delete() == false) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new ProjectDeleteTaskException();
                 }
             }
         }
         // Extension Links
         if (ProjectHasExtensionRun_Access::delete_by_project_id($tmp_project_id) == false) {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             throw new ProjectDeleteException("Extension delete failed");
         }
         // Project DB Entry
         if ($this->project->delete() == false) {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             throw new ProjectDeleteException("Database delete failed");
         } else {
             $this->__destruct();
             $project_folder_id = ProjectFolder::get_folder_by_project_id($tmp_project_id);
             $project_folder = new ProjectFolder($project_folder_id);
             if ($project_folder->delete(true, true) == false) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 throw new ProjectDeleteFolderException();
             } else {
                 if ($transaction_id != null) {
                     $transaction->commit($transaction_id);
                 }
                 return true;
             }
         }
     } else {
         throw new ProjectDeleteException("Project ID was missing.");
     }
 }
Beispiel #2
0
 /**
  * @throws ProjectIDMissingException
  * @throws ProjectSecuriyAccessDeniedException
  */
 public static function calendar_view()
 {
     global $project_security;
     if ($_GET['project_id']) {
         if ($project_security->is_access(1, false) == true) {
             $project_task_array = ProjectTask::list_tasks($_GET['project_id']);
             $calendar_array = array();
             $counter = 0;
             if (is_array($project_task_array) and count($project_task_array) >= 1) {
                 foreach ($project_task_array as $key => $value) {
                     $project_task = new ProjectTask($value);
                     if ($project_task->get_start_time()) {
                         $start_time = $project_task->get_start_time();
                     } else {
                         $start_time = "00:00:00";
                     }
                     if ($project_task->get_uf_end_time() > 0) {
                         $end_time = $project_task->get_end_time();
                     } else {
                         $end_time = "23:59:59";
                     }
                     $paramquery = $_GET;
                     $paramquery['run'] = "task_detail";
                     $paramquery['id'] = $value;
                     $params = http_build_query($paramquery, '', '&');
                     $calendar_array[$counter]['name'] = $project_task->get_name();
                     $calendar_array[$counter]['start_date'] = $project_task->get_start_date();
                     $calendar_array[$counter]['start_time'] = $start_time;
                     $calendar_array[$counter]['end_date'] = $project_task->get_end_date();
                     $calendar_array[$counter]['end_time'] = $end_time;
                     $calendar_array[$counter]['color'] = "4284d3";
                     $calendar_array[$counter]['link'] = $params;
                     $calendar_array[$counter]['id'] = $value;
                     $calendar_array[$counter]['serial_id'] = 0;
                     $counter++;
                 }
             }
             $template = new HTMLTemplate("project/tasks/calendar_view.html");
             $table_view_paramquery = $_GET;
             $table_view_paramquery['show'] = "table";
             $table_view_params = http_build_query($table_view_paramquery, '', '&');
             $template->set_var("table_view_params", $table_view_params);
             $gantt_view_paramquery = $_GET;
             $gantt_view_paramquery['show'] = "gantt";
             $gantt_view_params = http_build_query($gantt_view_paramquery, '', '&');
             $template->set_var("gantt_view_params", $gantt_view_params);
             $cal_view_paramquery = $_GET;
             $cal_view_paramquery['show'] = "cal";
             $cal_view_params = http_build_query($cal_view_paramquery, '', '&');
             $template->set_var("cal_view_params", $cal_view_params);
             require_once "core/modules/organiser/io/organiser_library.io.php";
             $organiser_library_io = new OrganiserLibraryIO(31);
             $organiser_library_io->set_calendar_array($calendar_array);
             $template->set_var("content", $organiser_library_io->get_content());
             $template->output();
         } else {
             throw new ProjectSecuriyAccessDeniedException();
         }
     } else {
         throw new ProjectIDMissingException();
     }
 }