Display a page not found when the data is not in the dabase anymore

This commit is contained in:
Frédéric Guillot 2014-02-24 19:07:25 -05:00
parent 8159cc99a6
commit 565290fbf9
9 changed files with 70 additions and 9 deletions

View File

@ -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'))));
}
}

View File

@ -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();

View File

@ -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')
)));

View File

@ -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')
)));

View File

@ -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')
)));

View File

@ -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',
);

View File

@ -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' => '',
);

View File

@ -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>

View File

@ -6,5 +6,4 @@
<p class="alert alert-error">
<?= t('Only administrators can access to this page.') ?>
</p>
</section>