Example #1
0
 /**
  * @throws ProjectIDMissingException
  * @throws ProjectSecurityAccessDeniedException
  */
 public static function list_project_related_logs()
 {
     global $project_security;
     if ($_GET['project_id']) {
         if ($project_security->is_access(1, false) == true) {
             $template = new HTMLTemplate("project/log.html");
             $template->set_var("get_array", serialize($_GET));
             if ($project_security->is_access(3, false) == true) {
                 $template->set_var("write", true);
             } else {
                 $template->set_var("write", false);
             }
             $project_log_array = ProjectLog::list_entries_by_project_id($_GET['project_id']);
             $entry_count = count($project_log_array);
             $number_of_pages = ceil($entry_count / constant("PROJECT_LOG_ENTRIES_PER_PAGE"));
             $template->output();
         } else {
             throw new ProjectSecurityAccessDeniedException();
         }
     } else {
         throw new ProjectIDMissingException();
     }
 }
Example #2
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.");
     }
 }
Example #3
0
 /**
  * @param string $get_array
  * @param intger $page
  * @return integer
  * @throws ProjectSecurityAccessDeniedException
  * @throws ProjectIDMissingException
  */
 public static function get_list($get_array, $page)
 {
     global $project_security, $user;
     if ($get_array) {
         $_GET = unserialize($get_array);
     }
     if ($_GET['project_id']) {
         if ($project_security->is_access(1, false) == true) {
             $project_log_array = ProjectLog::list_entries_by_project_id($_GET['project_id']);
             if (!$page) {
                 $page = 1;
             }
             $entry_count = count($project_log_array);
             $number_of_pages = ceil($entry_count / constant("PROJECT_LOG_ENTRIES_PER_PAGE"));
             $template = new HTMLTemplate("project/ajax/log.html");
             $template->set_var("get_array", $get_array);
             $template->set_var("page", $page);
             $template->set_var("number_of_pages", $number_of_pages);
             if (is_array($project_log_array) and count($project_log_array) >= 1) {
                 $template->set_var("no_log", false);
                 $result = array();
                 $counter = 0;
                 if (count($project_log_array) < $page * PROJECT_LOG_ENTRIES_PER_PAGE) {
                     $max_for = count($project_log_array) % PROJECT_LOG_ENTRIES_PER_PAGE - 1;
                 } else {
                     $max_for = PROJECT_LOG_ENTRIES_PER_PAGE - 1;
                 }
                 for ($i = 0; $i <= $max_for; $i++) {
                     $entry = $page * PROJECT_LOG_ENTRIES_PER_PAGE + $i - PROJECT_LOG_ENTRIES_PER_PAGE;
                     // Erzeugt Entry-ID
                     $value = $project_log_array[$entry];
                     $project_log = new ProjectLog($value);
                     $user = new User($project_log->get_owner_id());
                     $result[$counter]['id'] = $value;
                     $result[$counter]['show_more'] = false;
                     $datetime_handler = new DatetimeHandler($project_log->get_datetime());
                     $result[$counter]['date'] = $datetime_handler->get_date();
                     $result[$counter]['time'] = $datetime_handler->get_time();
                     $result[$counter]['user'] = $user->get_full_name(false);
                     if (($content = $project_log->get_content()) != null) {
                         $content = str_replace("\n", "<br />", $content);
                         if (strlen($content) > 500) {
                             $content = substr($content, 0, 500) . "...";
                             $result[$counter]['show_more'] = true;
                         }
                         $result[$counter]['content'] = $content;
                     } else {
                         $result[$counter]['content'] = false;
                     }
                     $status_id = $project_log->get_status_id();
                     if ($status_id != null) {
                         $project_status = new ProjectStatus($status_id);
                         $result[$counter]['status'] = $project_status->get_name();
                     } else {
                         $result[$counter]['status'] = false;
                     }
                     if ($project_log->get_important() == true) {
                         $result[$counter]['important'] = true;
                     } else {
                         $result[$counter]['important'] = false;
                     }
                     $item_array = $project_log->list_items();
                     $number_of_items = count($item_array);
                     if ($number_of_items == 0) {
                         $result[$counter]['items'] = false;
                     } else {
                         if ($number_of_items == 1) {
                             $result[$counter]['items'] = $number_of_items . " Item was added";
                         } else {
                             $result[$counter]['items'] = $number_of_items . " Items were added";
                         }
                     }
                     $detail_paramquery = $_GET;
                     $detail_paramquery['run'] = "log_detail";
                     $detail_paramquery['id'] = $value;
                     $detail_params = http_build_query($detail_paramquery, '', '&#38;');
                     $result[$counter]['detail_params'] = $detail_params;
                     if ($user->is_admin()) {
                         $result[$counter]['delete'] = true;
                     } else {
                         $result[$counter]['delete'] = false;
                     }
                     $counter++;
                 }
                 $template->set_var("log_array", $result);
             } else {
                 $template->set_var("no_log", true);
             }
             if ($number_of_pages > 1) {
                 $pagebar = "<div id='ProjectLogActionSelect'></div><div class='ResultNextPageBar' id='ProjectLogPageBar'></div>";
                 $template->set_var("page_bar", $pagebar);
             } else {
                 $template->set_var("page_bar", "");
             }
             $template->output();
         } else {
             throw new ProjectSecurityAccessDeniedException();
         }
     } else {
         throw new ProjectIDMissingException();
     }
 }