Add public view for tasks

This commit is contained in:
Frédéric Guillot 2014-09-08 23:19:40 +02:00
parent 8c6df9ef0c
commit e383c069f1
16 changed files with 243 additions and 176 deletions

View File

@ -140,20 +140,28 @@ abstract class Base
* Application not found page (404 error)
*
* @access public
* @param boolean $no_layout Display the layout or not
*/
public function notfound()
public function notfound($no_layout = false)
{
$this->response->html($this->template->layout('app_notfound', array('title' => t('Page not found'))));
$this->response->html($this->template->layout('app_notfound', array(
'title' => t('Page not found'),
'no_layout' => $no_layout,
)));
}
/**
* Application forbidden page
*
* @access public
* @param boolean $no_layout Display the layout or not
*/
public function forbidden()
public function forbidden($no_layout = false)
{
$this->response->html($this->template->layout('app_forbidden', array('title' => t('Access Forbidden'))));
$this->response->html($this->template->layout('app_forbidden', array(
'title' => t('Access Forbidden'),
'no_layout' => $no_layout,
)));
}
/**

View File

@ -167,7 +167,7 @@ class Board extends Base
// Token verification
if (! $project) {
$this->response->text('Not Authorized', 401);
$this->forbidden(true);
}
// Display the board with a specific layout

View File

@ -25,25 +25,15 @@ class Comment extends Base
}
if (! $this->acl->isAdminUser() && $comment['user_id'] != $this->acl->getUserId()) {
$this->forbidden();
$this->response->html($this->template->layout('comment_forbidden', array(
'menu' => 'tasks',
'title' => t('Access Forbidden')
)));
}
return $comment;
}
/**
* Forbidden page for comments
*
* @access public
*/
public function forbidden()
{
$this->response->html($this->template->layout('comment_forbidden', array(
'menu' => 'tasks',
'title' => t('Access Forbidden')
)));
}
/**
* Add comment form
*

View File

@ -46,6 +46,39 @@ class Task extends Base
$this->response->text('FAILED');
}
/**
* Public access (display a task)
*
* @access public
*/
public function readonly()
{
$project = $this->project->getByToken($this->request->getStringParam('token'));
// Token verification
if (! $project) {
$this->forbidden(true);
}
$task = $this->task->getById($this->request->getIntegerParam('task_id'), true);
if (! $task) {
$this->notfound(true);
}
$this->response->html($this->template->layout('task_public', array(
'project' => $project,
'comments' => $this->comment->getAll($task['id']),
'subtasks' => $this->subTask->getAll($task['id']),
'task' => $task,
'columns_list' => $this->board->getColumnsList($task['project_id']),
'colors_list' => $this->task->getColors(),
'title' => $task['title'],
'no_layout' => true,
'auto_refresh' => true,
)));
}
/**
* Show a task
*
@ -56,6 +89,7 @@ class Task extends Base
$task = $this->getTask();
$this->response->html($this->taskLayout('task_show', array(
'project' => $this->project->getById($task['project_id']),
'files' => $this->file->getAll($task['id']),
'comments' => $this->comment->getAll($task['id']),
'subtasks' => $this->subTask->getAll($task['id']),

View File

@ -18,7 +18,7 @@ class Acl extends Base
*/
private $public_actions = array(
'user' => array('login', 'check', 'google', 'github'),
'task' => array('add'),
'task' => array('add', 'readonly'),
'board' => array('readonly'),
);

View File

@ -21,7 +21,7 @@
<?php foreach ($column['tasks'] as $task): ?>
<div class="task-board task-<?= $task['color_id'] ?>">
<?= Helper\template('board_task', array('task' => $task, 'categories' => $categories, 'not_editable' => true)) ?>
<?= Helper\template('board_task', array('task' => $task, 'categories' => $categories, 'not_editable' => true, 'project' => $project)) ?>
</div>
<?php endforeach ?>

View File

@ -1,6 +1,6 @@
<?php if (isset($not_editable)): ?>
#<?= $task['id'] ?> -
<a href="?controller=task&amp;action=readonly&amp;task_id=<?= $task['id'] ?>&amp;token=<?= $project['token'] ?>">#<?= $task['id'] ?></a> -
<span class="task-board-user">
<?php if (! empty($task['owner_id'])): ?>
@ -15,7 +15,9 @@
<?php endif ?>
<div class="task-board-title">
<?= Helper\escape($task['title']) ?>
<a href="?controller=task&amp;action=readonly&amp;task_id=<?= $task['id'] ?>&amp;token=<?= $project['token'] ?>">
<?= Helper\escape($task['title']) ?>
</a>
</div>
<?php else: ?>
@ -73,7 +75,11 @@
<?php endif ?>
<?php if (! empty($task['description'])): ?>
<a class="task-description-popover" href="?controller=task&amp;action=description&amp;task_id=<?= $task['id'] ?>"><i class="fa fa-file-text-o" title="<?= t('Description') ?>" data-href="?controller=task&amp;action=description&amp;task_id=<?= $task['id'] ?>"></i></a>
<?php if (! isset($not_editable)): ?>
<a class="task-description-popover" href="?controller=task&amp;action=description&amp;task_id=<?= $task['id'] ?>"><i class="fa fa-file-text-o" title="<?= t('Description') ?>" data-href="?controller=task&amp;action=description&amp;task_id=<?= $task['id'] ?>"></i></a>
<?php else: ?>
<i class="fa fa-file-text-o" title="<?= t('Description') ?>"></i>
<?php endif ?>
<?php endif ?>
</div>
</div>

View File

@ -9,7 +9,7 @@
<?php if (! isset($preview)): ?>
<ul class="comment-actions">
<li><a href="#comment-<?= $comment['id'] ?>"><?= t('link') ?></a></li>
<?php if (Helper\is_admin() || Helper\is_current_user($comment['user_id'])): ?>
<?php if ((! isset($not_editable) || ! $not_editable) && (Helper\is_admin() || Helper\is_current_user($comment['user_id']))): ?>
<li>
<a href="?controller=comment&amp;action=confirm&amp;task_id=<?= $task['id'] ?>&amp;comment_id=<?= $comment['id'] ?>"><?= t('remove') ?></a>
</li>

View File

@ -30,7 +30,7 @@
<?php endif ?>
</head>
<body>
<?php if (isset($no_layout)): ?>
<?php if (isset($no_layout) && $no_layout): ?>
<?= $content_for_layout ?>
<?php else: ?>
<header>

View File

@ -1,60 +1,70 @@
<div class="page-header">
<h2><?= t('Sub-Tasks') ?></h2>
<?php if (! empty($subtasks)): ?>
<div id="subtasks" class="task-show-section">
<div class="page-header">
<h2><?= t('Sub-Tasks') ?></h2>
</div>
<?php
$total_spent = 0;
$total_estimated = 0;
$total_remaining = 0;
?>
<table class="subtasks-table">
<tr>
<th width="40%"><?= t('Title') ?></th>
<th><?= t('Status') ?></th>
<th><?= t('Assignee') ?></th>
<th><?= t('Time tracking') ?></th>
<?php if (! isset($not_editable)): ?>
<th><?= t('Actions') ?></th>
<?php endif ?>
</tr>
<?php foreach ($subtasks as $subtask): ?>
<tr>
<td><?= Helper\escape($subtask['title']) ?></td>
<td><?= Helper\escape($subtask['status_name']) ?></td>
<td>
<?php if (! empty($subtask['username'])): ?>
<?= Helper\escape($subtask['name'] ?: $subtask['username']) ?>
<?php endif ?>
</td>
<td>
<?php if (! empty($subtask['time_spent'])): ?>
<strong><?= Helper\escape($subtask['time_spent']).'h' ?></strong> <?= t('spent') ?>
<?php endif ?>
<?php if (! empty($subtask['time_estimated'])): ?>
<strong><?= Helper\escape($subtask['time_estimated']).'h' ?></strong> <?= t('estimated') ?>
<?php endif ?>
</td>
<?php if (! isset($not_editable)): ?>
<td>
<a href="?controller=subtask&amp;action=edit&amp;task_id=<?= $task['id'] ?>&amp;subtask_id=<?= $subtask['id'] ?>"><?= t('Edit') ?></a>
<?= t('or') ?>
<a href="?controller=subtask&amp;action=confirm&amp;task_id=<?= $task['id'] ?>&amp;subtask_id=<?= $subtask['id'] ?>"><?= t('Remove') ?></a>
</td>
<?php endif ?>
</tr>
<?php
$total_estimated += $subtask['time_estimated'];
$total_spent += $subtask['time_spent'];
$total_remaining = $total_estimated - $total_spent;
?>
<?php endforeach ?>
</table>
<div class="subtasks-time-tracking">
<h4><?= t('Time tracking') ?></h4>
<ul>
<li><?= t('Estimate:') ?> <strong><?= Helper\escape($total_estimated) ?></strong> <?= t('hours') ?></li>
<li><?= t('Spent:') ?> <strong><?= Helper\escape($total_spent) ?></strong> <?= t('hours') ?></li>
<li><?= t('Remaining:') ?> <strong><?= Helper\escape($total_remaining > 0 ? $total_remaining : 0) ?></strong> <?= t('hours') ?></li>
</ul>
</div>
</div>
<?php
$total_spent = 0;
$total_estimated = 0;
$total_remaining = 0;
?>
<table class="subtasks-table">
<tr>
<th width="40%"><?= t('Title') ?></th>
<th><?= t('Status') ?></th>
<th><?= t('Assignee') ?></th>
<th><?= t('Time tracking') ?></th>
<th><?= t('Actions') ?></th>
</tr>
<?php foreach ($subtasks as $subtask): ?>
<tr>
<td><?= Helper\escape($subtask['title']) ?></td>
<td><?= Helper\escape($subtask['status_name']) ?></td>
<td>
<?php if (! empty($subtask['username'])): ?>
<?= Helper\escape($subtask['name'] ?: $subtask['username']) ?>
<?php endif ?>
</td>
<td>
<?php if (! empty($subtask['time_spent'])): ?>
<strong><?= Helper\escape($subtask['time_spent']).'h' ?></strong> <?= t('spent') ?>
<?php endif ?>
<?php if (! empty($subtask['time_estimated'])): ?>
<strong><?= Helper\escape($subtask['time_estimated']).'h' ?></strong> <?= t('estimated') ?>
<?php endif ?>
</td>
<td>
<a href="?controller=subtask&amp;action=edit&amp;task_id=<?= $task['id'] ?>&amp;subtask_id=<?= $subtask['id'] ?>"><?= t('Edit') ?></a>
<?= t('or') ?>
<a href="?controller=subtask&amp;action=confirm&amp;task_id=<?= $task['id'] ?>&amp;subtask_id=<?= $subtask['id'] ?>"><?= t('Remove') ?></a>
</td>
</tr>
<?php
$total_estimated += $subtask['time_estimated'];
$total_spent += $subtask['time_spent'];
$total_remaining = $total_estimated - $total_spent;
?>
<?php endforeach ?>
</table>
<div class="subtasks-time-tracking">
<h4><?= t('Time tracking') ?></h4>
<ul>
<li><?= t('Estimate:') ?> <strong><?= Helper\escape($total_estimated) ?></strong> <?= t('hours') ?></li>
<li><?= t('Spent:') ?> <strong><?= Helper\escape($total_spent) ?></strong> <?= t('hours') ?></li>
<li><?= t('Remaining:') ?> <strong><?= Helper\escape($total_remaining > 0 ? $total_remaining : 0) ?></strong> <?= t('hours') ?></li>
</ul>
</div>
<?php endif ?>

View File

@ -0,0 +1,15 @@
<?php if (! empty($comments)): ?>
<div id="comments" class="task-show-section">
<div class="page-header">
<h2><?= t('Comments') ?></h2>
</div>
<?php foreach ($comments as $comment): ?>
<?= Helper\template('comment_show', array(
'comment' => $comment,
'task' => $task,
'not_editable' => isset($not_editable) && $not_editable,
)) ?>
<?php endforeach ?>
</div>
<?php endif ?>

View File

@ -0,0 +1,63 @@
<div class="task-<?= $task['color_id'] ?> task-show-details">
<h2><?= Helper\escape($task['title']) ?></h2>
<?php if ($task['score']): ?>
<span class="task-score"><?= Helper\escape($task['score']) ?></span>
<?php endif ?>
<ul>
<li>
<?= dt('Created on %B %e, %Y at %k:%M %p', $task['date_creation']) ?>
</li>
<?php if ($task['date_modification']): ?>
<li>
<?= dt('Last modified on %B %e, %Y at %k:%M %p', $task['date_modification']) ?>
</li>
<?php endif ?>
<?php if ($task['date_completed']): ?>
<li>
<?= dt('Completed on %B %e, %Y at %k:%M %p', $task['date_completed']) ?>
</li>
<?php endif ?>
<?php if ($task['date_due']): ?>
<li>
<strong><?= dt('Must be done before %B %e, %Y', $task['date_due']) ?></strong>
</li>
<?php endif ?>
<?php if ($task['creator_username']): ?>
<li>
<?= t('Created by %s', $task['creator_name'] ?: $task['creator_username']) ?>
</li>
<?php endif ?>
<li>
<strong>
<?php if ($task['assignee_username']): ?>
<?= t('Assigned to %s', $task['assignee_name'] ?: $task['assignee_username']) ?>
<?php else: ?>
<?= t('There is nobody assigned') ?>
<?php endif ?>
</strong>
</li>
<li>
<?= t('Column on the board:') ?>
<strong><?= Helper\escape($task['column_title']) ?></strong>
(<?= Helper\escape($task['project_name']) ?>)
</li>
<li><?= t('Task position:').' '.Helper\escape($task['position']) ?></li>
<?php if ($task['category_name']): ?>
<li>
<?= t('Category:') ?> <strong><?= Helper\escape($task['category_name']) ?></strong>
</li>
<?php endif ?>
<li>
<?php if ($task['is_active'] == 1): ?>
<?= t('Status is open') ?>
<?php else: ?>
<?= t('Status is closed') ?>
<?php endif ?>
</li>
<?php if ($project['is_public']): ?>
<li>
<a href="?controller=task&amp;action=readonly&amp;task_id=<?= $task['id'] ?>&amp;token=<?= $project['token'] ?>" target="_blank"><?= t('Public link') ?></a>
</li>
<?php endif ?>
</ul>
</div>

View File

@ -0,0 +1,11 @@
<section id="main" class="public-task">
<?= Helper\template('task_details', array('task' => $task, 'project' => $project)) ?>
<?= Helper\template('task_show_description', array('task' => $task)) ?>
<?= Helper\template('subtask_show', array('task' => $task, 'subtasks' => $subtasks, 'not_editable' => true)) ?>
<?= Helper\template('task_comments', array('task' => $task, 'comments' => $comments, 'not_editable' => true)) ?>
</section>

View File

@ -1,75 +1,9 @@
<div class="task-<?= $task['color_id'] ?> task-show-details">
<h2><?= Helper\escape($task['title']) ?></h2>
<?php if ($task['score']): ?>
<span class="task-score"><?= Helper\escape($task['score']) ?></span>
<?php endif ?>
<ul>
<li>
<?= dt('Created on %B %e, %Y at %k:%M %p', $task['date_creation']) ?>
</li>
<?php if ($task['date_modification']): ?>
<li>
<?= dt('Last modified on %B %e, %Y at %k:%M %p', $task['date_modification']) ?>
</li>
<?php endif ?>
<?php if ($task['date_completed']): ?>
<li>
<?= dt('Completed on %B %e, %Y at %k:%M %p', $task['date_completed']) ?>
</li>
<?php endif ?>
<?php if ($task['date_due']): ?>
<li>
<strong><?= dt('Must be done before %B %e, %Y', $task['date_due']) ?></strong>
</li>
<?php endif ?>
<?php if ($task['creator_username']): ?>
<li>
<?= t('Created by %s', $task['creator_name'] ?: $task['creator_username']) ?>
</li>
<?php endif ?>
<li>
<strong>
<?php if ($task['assignee_username']): ?>
<?= t('Assigned to %s', $task['assignee_name'] ?: $task['assignee_username']) ?>
<?php else: ?>
<?= t('There is nobody assigned') ?>
<?php endif ?>
</strong>
</li>
<li>
<?= t('Column on the board:') ?>
<strong><?= Helper\escape($task['column_title']) ?></strong>
(<?= Helper\escape($task['project_name']) ?>)
</li>
<li><?= t('Task position:').' '.Helper\escape($task['position']) ?></li>
<?php if ($task['category_name']): ?>
<li>
<?= t('Category:') ?> <strong><?= Helper\escape($task['category_name']) ?></strong>
</li>
<?php endif ?>
<li>
<?php if ($task['is_active'] == 1): ?>
<?= t('Status is open') ?>
<?php else: ?>
<?= t('Status is closed') ?>
<?php endif ?>
</li>
</ul>
</div>
<?= Helper\template('task_details', array('task' => $task, 'project' => $project)) ?>
<?php if (! empty($task['description'])): ?>
<div id="description" class="task-show-section">
<div class="page-header">
<h2><?= t('Description') ?></h2>
</div>
<article class="markdown task-show-description">
<?= Helper\parse($task['description']) ?: t('There is no description.') ?>
</article>
</div>
<?php endif ?>
<?= Helper\template('task_show_description', array('task' => $task)) ?>
<?= Helper\template('subtask_show', array('task' => $task, 'subtasks' => $subtasks)) ?>
<?php if (! empty($files)): ?>
<div id="attachments" class="task-show-section">
@ -77,25 +11,4 @@
</div>
<?php endif ?>
<?php if (! empty($subtasks)): ?>
<div id="subtasks" class="task-show-section">
<?= Helper\template('subtask_show', array('task' => $task, 'subtasks' => $subtasks)) ?>
</div>
<?php endif ?>
<?php if (! empty($comments)): ?>
<div id="comments" class="task-show-section">
<div class="page-header">
<h2><?= t('Comments') ?></h2>
</div>
<?php foreach ($comments as $comment): ?>
<?= Helper\template('comment_show', array(
'comment' => $comment,
'task' => $task,
)) ?>
<?php endforeach ?>
</div>
<?php endif ?>
<?= Helper\template('task_comments', array('task' => $task, 'comments' => $comments)) ?>

View File

@ -0,0 +1,11 @@
<?php if (! empty($task['description'])): ?>
<div id="description" class="task-show-section">
<div class="page-header">
<h2><?= t('Description') ?></h2>
</div>
<article class="markdown task-show-description">
<?= Helper\parse($task['description']) ?: t('There is no description.') ?>
</article>
</div>
<?php endif ?>

View File

@ -552,6 +552,12 @@ a.filter-on {
margin-top: 5px;
}
.public-task {
max-width: 700px;
margin: 0 auto;
margin-top: 5px;
}
#board th a {
text-decoration: none;
font-size: 150%;