summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Controller/Taskstatus.php62
-rw-r--r--app/Template/board/task_menu.php6
-rw-r--r--app/Template/task_status/close.php2
-rw-r--r--app/Template/task_status/open.php6
4 files changed, 38 insertions, 38 deletions
diff --git a/app/Controller/Taskstatus.php b/app/Controller/Taskstatus.php
index a47d9da3..9260b658 100644
--- a/app/Controller/Taskstatus.php
+++ b/app/Controller/Taskstatus.php
@@ -18,62 +18,58 @@ class Taskstatus extends Base
public function close()
{
$task = $this->getTask();
+ $this->changeStatus($task, 'close', t('Task closed successfully.'), t('Unable to close this task.'));
+ $this->renderTemplate($task, 'task_status/close');
+ }
+
+ /**
+ * Open a task
+ *
+ * @access public
+ */
+ public function open()
+ {
+ $task = $this->getTask();
$redirect = $this->request->getStringParam('redirect');
+ $this->changeStatus($task, 'open', t('Task opened successfully.'), t('Unable to open this task.'));
+ $this->renderTemplate($task, 'task_status/open');
+ }
+
+ private function changeStatus(array $task, $method, $success_message, $failure_message)
+ {
if ($this->request->getStringParam('confirmation') === 'yes') {
$this->checkCSRFParam();
- if ($this->taskStatus->close($task['id'])) {
- $this->session->flash(t('Task closed successfully.'));
+ if ($this->taskStatus->$method($task['id'])) {
+ $this->session->flash($success_message);
} else {
- $this->session->flashError(t('Unable to close this task.'));
+ $this->session->flashError($failure_message);
}
- if ($redirect === 'board') {
+ if ($this->request->getStringParam('redirect') === 'board') {
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
}
$this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])));
}
+ }
+
+ private function renderTemplate(array $task, $template)
+ {
+ $redirect = $this->request->getStringParam('redirect');
if ($this->request->isAjax()) {
- $this->response->html($this->template->render('task_status/close', array(
+ $this->response->html($this->template->render($template, array(
'task' => $task,
'redirect' => $redirect,
)));
}
- $this->response->html($this->taskLayout('task_status/close', array(
+ $this->response->html($this->taskLayout($template, array(
'task' => $task,
'redirect' => $redirect,
)));
}
-
- /**
- * Open a task
- *
- * @access public
- */
- public function open()
- {
- $task = $this->getTask();
-
- if ($this->request->getStringParam('confirmation') === 'yes') {
-
- $this->checkCSRFParam();
-
- if ($this->taskStatus->open($task['id'])) {
- $this->session->flash(t('Task opened successfully.'));
- } else {
- $this->session->flashError(t('Unable to open this task.'));
- }
-
- $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])));
- }
-
- $this->response->html($this->taskLayout('task_status/open', array(
- 'task' => $task,
- )));
- }
}
diff --git a/app/Template/board/task_menu.php b/app/Template/board/task_menu.php
index 1434a1a0..3eb35705 100644
--- a/app/Template/board/task_menu.php
+++ b/app/Template/board/task_menu.php
@@ -8,6 +8,10 @@
<li><i class="fa fa-comment-o fa-fw"></i>&nbsp;<?= $this->url->link(t('Add a comment'), 'comment', 'create', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li>
<li><i class="fa fa-code-fork fa-fw"></i>&nbsp;<?= $this->url->link(t('Add a link'), 'tasklink', 'create', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li>
<li><i class="fa fa-camera fa-fw"></i>&nbsp;<?= $this->url->link(t('Add a screenshot'), 'board', 'screenshot', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li>
- <li><i class="fa fa-close fa-fw"></i>&nbsp;<?= $this->url->link(t('Close this task'), 'taskstatus', 'close', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'redirect' => 'board'), false, 'popover') ?></li>
+ <?php if ($task['is_active'] == 1): ?>
+ <li><i class="fa fa-close fa-fw"></i>&nbsp;<?= $this->url->link(t('Close this task'), 'taskstatus', 'close', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'redirect' => 'board'), false, 'popover') ?></li>
+ <?php else: ?>
+ <li><i class="fa fa-check-square-o fa-fw"></i>&nbsp;<?= $this->url->link(t('Open this task'), 'taskstatus', 'open', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'redirect' => 'board'), false, 'popover') ?></li>
+ <?php endif ?>
</ul>
</span> \ No newline at end of file
diff --git a/app/Template/task_status/close.php b/app/Template/task_status/close.php
index 4de3dcb2..d32863bd 100644
--- a/app/Template/task_status/close.php
+++ b/app/Template/task_status/close.php
@@ -4,7 +4,7 @@
<div class="confirm">
<p class="alert alert-info">
- <?= t('Do you really want to close the task "%s" as well as all subtasks?', $this->e($task['title'])) ?>
+ <?= t('Do you really want to close the task "%s" as well as all subtasks?', $task['title']) ?>
</p>
<div class="form-actions">
diff --git a/app/Template/task_status/open.php b/app/Template/task_status/open.php
index 0043fdae..615b2464 100644
--- a/app/Template/task_status/open.php
+++ b/app/Template/task_status/open.php
@@ -4,12 +4,12 @@
<div class="confirm">
<p class="alert alert-info">
- <?= t('Do you really want to open this task: "%s"?', $this->e($task['title'])) ?>
+ <?= t('Do you really want to open this task: "%s"?', $task['title']) ?>
</p>
<div class="form-actions">
- <?= $this->url->link(t('Yes'), 'taskstatus', 'open', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'confirmation' => 'yes'), true, 'btn btn-red') ?>
+ <?= $this->url->link(t('Yes'), 'taskstatus', 'open', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'confirmation' => 'yes', 'redirect' => $redirect), true, 'btn btn-red') ?>
<?= t('or') ?>
- <?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
+ <?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?>
</div>
</div> \ No newline at end of file