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) * Application not found page (404 error)
* *
* @access public * @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 * Application forbidden page
* *
* @access public * @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 // Token verification
if (! $project) { if (! $project) {
$this->response->text('Not Authorized', 401); $this->forbidden(true);
} }
// Display the board with a specific layout // 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()) { 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; 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 * Add comment form
* *

View File

@@ -46,6 +46,39 @@ class Task extends Base
$this->response->text('FAILED'); $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 * Show a task
* *
@@ -56,6 +89,7 @@ class Task extends Base
$task = $this->getTask(); $task = $this->getTask();
$this->response->html($this->taskLayout('task_show', array( $this->response->html($this->taskLayout('task_show', array(
'project' => $this->project->getById($task['project_id']),
'files' => $this->file->getAll($task['id']), 'files' => $this->file->getAll($task['id']),
'comments' => $this->comment->getAll($task['id']), 'comments' => $this->comment->getAll($task['id']),
'subtasks' => $this->subTask->getAll($task['id']), 'subtasks' => $this->subTask->getAll($task['id']),

View File

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

View File

@@ -21,7 +21,7 @@
<?php foreach ($column['tasks'] as $task): ?> <?php foreach ($column['tasks'] as $task): ?>
<div class="task-board task-<?= $task['color_id'] ?>"> <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> </div>
<?php endforeach ?> <?php endforeach ?>

View File

@@ -1,6 +1,6 @@
<?php if (isset($not_editable)): ?> <?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"> <span class="task-board-user">
<?php if (! empty($task['owner_id'])): ?> <?php if (! empty($task['owner_id'])): ?>
@@ -15,7 +15,9 @@
<?php endif ?> <?php endif ?>
<div class="task-board-title"> <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> </div>
<?php else: ?> <?php else: ?>
@@ -73,7 +75,11 @@
<?php endif ?> <?php endif ?>
<?php if (! empty($task['description'])): ?> <?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 ?> <?php endif ?>
</div> </div>
</div> </div>

View File

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

View File

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

View File

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

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; margin-top: 5px;
} }
.public-task {
max-width: 700px;
margin: 0 auto;
margin-top: 5px;
}
#board th a { #board th a {
text-decoration: none; text-decoration: none;
font-size: 150%; font-size: 150%;