diff options
author | Frédéric Guillot <contact@fredericguillot.com> | 2014-02-24 19:07:25 -0500 |
---|---|---|
committer | Frédéric Guillot <contact@fredericguillot.com> | 2014-02-24 19:07:25 -0500 |
commit | 565290fbf9e3727655921a969550167aa59a6e24 (patch) | |
tree | 0c3a98b1152e90eff86da26d9d9c8ec803dfdf95 /controllers | |
parent | 8159cc99a64cfe563dccea6821348764fc40fb85 (diff) |
Display a page not found when the data is not in the dabase anymore
Diffstat (limited to 'controllers')
-rw-r--r-- | controllers/base.php | 5 | ||||
-rw-r--r-- | controllers/board.php | 14 | ||||
-rw-r--r-- | controllers/project.php | 14 | ||||
-rw-r--r-- | controllers/task.php | 16 | ||||
-rw-r--r-- | controllers/user.php | 14 |
5 files changed, 56 insertions, 7 deletions
diff --git a/controllers/base.php b/controllers/base.php index c4a69bf0..c7e59b18 100644 --- a/controllers/base.php +++ b/controllers/base.php @@ -90,4 +90,9 @@ abstract class Base $this->session->flash(t('There is no active project, the first step is to create a new project.')); $this->response->redirect('?controller=project&action=create'); } + + public function notfound() + { + $this->response->html($this->template->layout('app_notfound', array('title' => t('Page not found')))); + } } diff --git a/controllers/board.php b/controllers/board.php index 832ab60f..29633a14 100644 --- a/controllers/board.php +++ b/controllers/board.php @@ -11,6 +11,8 @@ class Board extends Base $project = $this->project->get($task['project_id']); $projects = $this->project->getListByStatus(\Model\Project::ACTIVE); + if (! $project) $this->notfound(); + $this->response->html($this->template->layout('board_assign', array( 'errors' => array(), 'values' => $task, @@ -92,6 +94,9 @@ class Board extends Base { $projects = $this->project->getListByStatus(\Model\Project::ACTIVE); $project_id = $this->request->getIntegerParam('project_id'); + + if (! isset($projects[$project_id])) $this->notfound(); + $project_name = $projects[$project_id]; $this->response->html($this->template->layout('board_index', array( @@ -111,6 +116,9 @@ class Board extends Base $project_id = $this->request->getIntegerParam('project_id'); $project = $this->project->get($project_id); + + if (! $project) $this->notfound(); + $columns = $this->board->getColumnsList($project_id); $values = array(); @@ -135,6 +143,9 @@ class Board extends Base $project_id = $this->request->getIntegerParam('project_id'); $project = $this->project->get($project_id); + + if (! $project) $this->notfound(); + $columns = $this->board->getColumnsList($project_id); $data = $this->request->getValues(); $values = array(); @@ -173,6 +184,9 @@ class Board extends Base $project_id = $this->request->getIntegerParam('project_id'); $project = $this->project->get($project_id); + + if (! $project) $this->notfound(); + $columns = $this->board->getColumnsList($project_id); $data = $this->request->getValues(); $values = array(); diff --git a/controllers/project.php b/controllers/project.php index c44dd38d..1ad2e829 100644 --- a/controllers/project.php +++ b/controllers/project.php @@ -88,6 +88,11 @@ class Project extends Base $project = $this->project->get($this->request->getIntegerParam('project_id')); + if (! $project) { + $this->session->flashError(t('Project not found.')); + $this->response->redirect('?controller=project'); + } + $this->response->html($this->template->layout('project_edit', array( 'errors' => array(), 'values' => $project, @@ -128,8 +133,15 @@ class Project extends Base { $this->checkPermissions(); + $project = $this->project->get($this->request->getIntegerParam('project_id')); + + if (! $project) { + $this->session->flashError(t('Project not found.')); + $this->response->redirect('?controller=project'); + } + $this->response->html($this->template->layout('project_remove', array( - 'project' => $this->project->get($this->request->getIntegerParam('project_id')), + 'project' => $project, 'menu' => 'projects', 'title' => t('Remove project') ))); diff --git a/controllers/task.php b/controllers/task.php index bff29f8c..3aa486d5 100644 --- a/controllers/task.php +++ b/controllers/task.php @@ -44,6 +44,8 @@ class Task extends Base { $task = $this->task->getById($this->request->getIntegerParam('task_id'), true); + if (! $task) $this->notfound(); + $this->response->html($this->template->layout('task_show', array( 'task' => $task, 'columns_list' => $this->board->getColumnsList($task['project_id']), @@ -118,6 +120,8 @@ class Task extends Base { $task = $this->task->getById($this->request->getIntegerParam('task_id')); + if (! $task) $this->notfound(); + $this->response->html($this->template->layout('task_edit', array( 'errors' => array(), 'values' => $task, @@ -174,8 +178,12 @@ class Task extends Base // Confirmation dialog before to close a task public function confirmClose() { + $task = $this->task->getById($this->request->getIntegerParam('task_id')); + + if (! $task) $this->notfound(); + $this->response->html($this->template->layout('task_close', array( - 'task' => $this->task->getById($this->request->getIntegerParam('task_id')), + 'task' => $task, 'menu' => 'tasks', 'title' => t('Close a task') ))); @@ -198,8 +206,12 @@ class Task extends Base // Confirmation dialog before to open a task public function confirmOpen() { + $task = $this->task->getById($this->request->getIntegerParam('task_id')); + + if (! $task) $this->notfound(); + $this->response->html($this->template->layout('task_open', array( - 'task' => $this->task->getById($this->request->getIntegerParam('task_id')), + 'task' => $task, 'menu' => 'tasks', 'title' => t('Open a task') ))); diff --git a/controllers/user.php b/controllers/user.php index 0fdd9d1e..9f9781ef 100644 --- a/controllers/user.php +++ b/controllers/user.php @@ -112,11 +112,13 @@ class User extends Base { $user = $this->user->getById($this->request->getIntegerParam('user_id')); + if (! $user) $this->notfound(); + if (! $_SESSION['user']['is_admin'] && $_SESSION['user']['id'] != $user['id']) { - $this->response->redirect('?controller=user&action=forbidden'); + $this->forbidden(); } - if (! empty($user)) unset($user['password']); + unset($user['password']); $this->response->html($this->template->layout('user_edit', array( 'projects' => $this->project->getList(), @@ -138,7 +140,7 @@ class User extends Base else { if ($_SESSION['user']['id'] != $values['id']) { - $this->response->redirect('?controller=user&action=forbidden'); + $this->forbidden(); } if (isset($values['is_admin'])) { @@ -173,8 +175,12 @@ class User extends Base { $this->checkPermissions(); + $user = $this->user->getById($this->request->getIntegerParam('user_id')); + + if (! $user) $this->notfound(); + $this->response->html($this->template->layout('user_remove', array( - 'user' => $this->user->getById($this->request->getIntegerParam('user_id')), + 'user' => $user, 'menu' => 'users', 'title' => t('Remove user') ))); |