summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-09-08 23:19:40 +0200
committerFrédéric Guillot <fred@kanboard.net>2014-09-08 23:19:40 +0200
commite383c069f1aeba49ea9905f77a51bf663e614b0e (patch)
tree8164aa9e1fad104997e53c6e261bec991631dbbb /app
parent8c6df9ef0cea757d25cbbcc6fa7cee86d8739627 (diff)
Add public view for tasks
Diffstat (limited to 'app')
-rw-r--r--app/Controller/Base.php16
-rw-r--r--app/Controller/Board.php2
-rw-r--r--app/Controller/Comment.php18
-rw-r--r--app/Controller/Task.php34
-rw-r--r--app/Model/Acl.php2
-rw-r--r--app/Templates/board_public.php2
-rw-r--r--app/Templates/board_task.php12
-rw-r--r--app/Templates/comment_show.php2
-rw-r--r--app/Templates/layout.php2
-rw-r--r--app/Templates/subtask_show.php122
-rw-r--r--app/Templates/task_comments.php15
-rw-r--r--app/Templates/task_details.php63
-rw-r--r--app/Templates/task_public.php11
-rw-r--r--app/Templates/task_show.php95
-rw-r--r--app/Templates/task_show_description.php11
15 files changed, 234 insertions, 173 deletions
diff --git a/app/Controller/Base.php b/app/Controller/Base.php
index f9059d1e..2d7b0c18 100644
--- a/app/Controller/Base.php
+++ b/app/Controller/Base.php
@@ -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,
+ )));
}
/**
diff --git a/app/Controller/Board.php b/app/Controller/Board.php
index 4724cae5..71d94a29 100644
--- a/app/Controller/Board.php
+++ b/app/Controller/Board.php
@@ -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
diff --git a/app/Controller/Comment.php b/app/Controller/Comment.php
index a0a11fc8..a9032ed8 100644
--- a/app/Controller/Comment.php
+++ b/app/Controller/Comment.php
@@ -25,26 +25,16 @@ 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
*
* @access public
diff --git a/app/Controller/Task.php b/app/Controller/Task.php
index 7210be5f..97751947 100644
--- a/app/Controller/Task.php
+++ b/app/Controller/Task.php
@@ -47,6 +47,39 @@ class Task extends Base
}
/**
+ * 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
*
* @access public
@@ -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']),
diff --git a/app/Model/Acl.php b/app/Model/Acl.php
index 21c76329..4f7d1357 100644
--- a/app/Model/Acl.php
+++ b/app/Model/Acl.php
@@ -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'),
);
diff --git a/app/Templates/board_public.php b/app/Templates/board_public.php
index f90dc01b..85c90cfa 100644
--- a/app/Templates/board_public.php
+++ b/app/Templates/board_public.php
@@ -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 ?>
diff --git a/app/Templates/board_task.php b/app/Templates/board_task.php
index 40590a65..20947a02 100644
--- a/app/Templates/board_task.php
+++ b/app/Templates/board_task.php
@@ -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>
diff --git a/app/Templates/comment_show.php b/app/Templates/comment_show.php
index 08d77b29..181a69fa 100644
--- a/app/Templates/comment_show.php
+++ b/app/Templates/comment_show.php
@@ -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>
diff --git a/app/Templates/layout.php b/app/Templates/layout.php
index 30a4e091..99382ae1 100644
--- a/app/Templates/layout.php
+++ b/app/Templates/layout.php
@@ -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>
diff --git a/app/Templates/subtask_show.php b/app/Templates/subtask_show.php
index 968473af..ffabbff4 100644
--- a/app/Templates/subtask_show.php
+++ b/app/Templates/subtask_show.php
@@ -1,60 +1,70 @@
-<div class="page-header">
- <h2><?= t('Sub-Tasks') ?></h2>
-</div>
+<?php if (! empty($subtasks)): ?>
+<div id="subtasks" class="task-show-section">
-<?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') ?>
+ <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 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 ?>
- </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> \ No newline at end of file
+ </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 endif ?> \ No newline at end of file
diff --git a/app/Templates/task_comments.php b/app/Templates/task_comments.php
new file mode 100644
index 00000000..acd84952
--- /dev/null
+++ b/app/Templates/task_comments.php
@@ -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 ?> \ No newline at end of file
diff --git a/app/Templates/task_details.php b/app/Templates/task_details.php
new file mode 100644
index 00000000..018b88f3
--- /dev/null
+++ b/app/Templates/task_details.php
@@ -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>
diff --git a/app/Templates/task_public.php b/app/Templates/task_public.php
new file mode 100644
index 00000000..4578b720
--- /dev/null
+++ b/app/Templates/task_public.php
@@ -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> \ No newline at end of file
diff --git a/app/Templates/task_show.php b/app/Templates/task_show.php
index a152bf07..ece4c57c 100644
--- a/app/Templates/task_show.php
+++ b/app/Templates/task_show.php
@@ -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>
-
-<?php if (! empty($task['description'])): ?>
-<div id="description" class="task-show-section">
- <div class="page-header">
- <h2><?= t('Description') ?></h2>
- </div>
+<?= Helper\template('task_details', array('task' => $task, 'project' => $project)) ?>
- <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)) ?>
diff --git a/app/Templates/task_show_description.php b/app/Templates/task_show_description.php
new file mode 100644
index 00000000..2d90137f
--- /dev/null
+++ b/app/Templates/task_show_description.php
@@ -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 ?> \ No newline at end of file