summaryrefslogtreecommitdiff
path: root/app/Helper/Subtask.php
blob: 4bb26e777bfa85399a45d192403f07d22276bd38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php

namespace Kanboard\Helper;

/**
 * Subtask helpers
 *
 * @package helper
 * @author  Frederic Guillot
 */
class Subtask extends \Kanboard\Core\Base
{
    /**
     * Get the link to toggle subtask status
     *
     * @access public
     * @param  array   $subtask
     * @param  string  $redirect
     * @return string
     */
    public function toggleStatus(array $subtask, $redirect)
    {
        if ($subtask['status'] == 0 && isset($this->sessionStorage->hasSubtaskInProgress) && $this->sessionStorage->hasSubtaskInProgress === true) {
            return $this->helper->url->link(
                trim($this->template->render('subtask/icons', array('subtask' => $subtask))) . $this->helper->e($subtask['title']),
                'subtask',
                'subtaskRestriction',
                array('task_id' => $subtask['task_id'], 'subtask_id' => $subtask['id'], 'redirect' => $redirect),
                false,
                'popover task-board-popover'
            );
        }

        return $this->helper->url->link(
            trim($this->template->render('subtask/icons', array('subtask' => $subtask))) . $this->helper->e($subtask['title']),
            'subtask',
            'toggleStatus',
            array('task_id' => $subtask['task_id'], 'subtask_id' => $subtask['id'], 'redirect' => $redirect)
        );
    }
}