From 78d88d27e198927bc7de86652716261187510a77 Mon Sep 17 00:00:00 2001 From: Eike Foken Date: Mon, 8 Aug 2011 01:16:19 +0200 Subject: [PATCH] Implement project deletion + some clean-up --- application/controllers/projects.php | 38 +++++++++++++++++++++------- application/views/project/detail.php | 4 +-- application/views/project/list.php | 2 +- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/application/controllers/projects.php b/application/controllers/projects.php index b08ab52..d3f8f10 100644 --- a/application/controllers/projects.php +++ b/application/controllers/projects.php @@ -37,7 +37,17 @@ class Projects extends MY_Controller { } /** - * Create a new project. + * Shows a list of all projects. + */ + public function index() { + $projects = $this->project->getAll(); + + $tpl['projects'] = $projects; + $this->load->view('project/list', $tpl); + } + + /** + * Allows users to create a new project. */ public function create() { $this->load->library('form_validation'); @@ -98,18 +108,16 @@ class Projects extends MY_Controller { } } - public function index() { - $projects = $this->project->getAll(); - - $tpl['projects'] = $projects; - $this->load->view('project/list', $tpl); - } - + /** + * Shows the project details + * + * @param integer $prj_id The ID of the project to show + */ public function detail($prj_id) { $project = $this->project->getById($prj_id); if (!$project) { $this->messages->add('Das Projekt konnte nicht geladen werden.', 'error'); - redirect('/projects/', 301); + redirect('projects', 301); } $this->session->set_userdata('active_project', $prj_id); @@ -121,4 +129,16 @@ class Projects extends MY_Controller { $this->load->view('project/detail', $tpl); } + /** + * Allows users to delete a project. + * + * @param unknown_type $projectId + */ + public function delete($projectId) { + $this->project->delete($projectId); + $this->session->unset_userdata('active_project'); + $this->messages->add("Das Projekt wurde gelöscht.", 'notice'); + redirect('projects'); + } + } diff --git a/application/views/project/detail.php b/application/views/project/detail.php index bf068e1..51f58e7 100644 --- a/application/views/project/detail.php +++ b/application/views/project/detail.php @@ -8,7 +8,7 @@

Versuche

- +
@@ -50,7 +50,7 @@
-
Versuch
+
diff --git a/application/views/project/list.php b/application/views/project/list.php index 682467e..7509673 100644 --- a/application/views/project/list.php +++ b/application/views/project/list.php @@ -25,7 +25,7 @@ - +
Versuch Erfolgreich abgeschlossenErgebnisse anzeigen | EntfernenErgebnisse anzeigen |