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 | |
parent | 8159cc99a64cfe563dccea6821348764fc40fb85 (diff) |
Display a page not found when the data is not in the dabase anymore
-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 | ||||
-rw-r--r-- | locales/fr_FR/translations.php | 2 | ||||
-rw-r--r-- | locales/pl_PL/translations.php | 4 | ||||
-rw-r--r-- | templates/app_notfound.php | 9 | ||||
-rw-r--r-- | templates/user_forbidden.php | 1 |
9 files changed, 70 insertions, 9 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') ))); diff --git a/locales/fr_FR/translations.php b/locales/fr_FR/translations.php index 6d7f70ce..97e26212 100644 --- a/locales/fr_FR/translations.php +++ b/locales/fr_FR/translations.php @@ -184,4 +184,6 @@ return array( 'Change assignee' => 'Changer la personne assignée', 'Change assignee for the task "%s"' => 'Changer la personne assignée pour la tâche « %s »', 'Timezone' => 'Fuseau horaire', + 'Sorry, I didn\'t found this information in my database!' => 'Désolé, je n\'ai pas trouvé cette information dans ma base de données !', + 'Page not found' => 'Page introuvable', ); diff --git a/locales/pl_PL/translations.php b/locales/pl_PL/translations.php index 99fd8297..915ff412 100644 --- a/locales/pl_PL/translations.php +++ b/locales/pl_PL/translations.php @@ -183,5 +183,7 @@ return array( 'There is no column in your project!' => 'Brak kolumnt w Twoim projekcie', 'Change assignee' => 'Zmień odpowiedzialną osobę', 'Change assignee for the task "%s"' => 'Zmień odpowiedzialną osobę dla zadania "%s"', - 'Timezone' => 'Strefa czasowa' + 'Timezone' => 'Strefa czasowa', + //'Sorry, I didn\'t found this information in my database!' => '', + //'Page not found' => '', ); diff --git a/templates/app_notfound.php b/templates/app_notfound.php new file mode 100644 index 00000000..734d16a4 --- /dev/null +++ b/templates/app_notfound.php @@ -0,0 +1,9 @@ +<section id="main"> + <div class="page-header"> + <h2><?= t('Page not found') ?></h2> + </div> + + <p class="alert alert-error"> + <?= t('Sorry, I didn\'t found this information in my database!') ?> + </p> +</section>
\ No newline at end of file diff --git a/templates/user_forbidden.php b/templates/user_forbidden.php index bb71d9b1..853159ba 100644 --- a/templates/user_forbidden.php +++ b/templates/user_forbidden.php @@ -6,5 +6,4 @@ <p class="alert alert-error"> <?= t('Only administrators can access to this page.') ?> </p> - </section>
\ No newline at end of file |