summaryrefslogtreecommitdiff
path: root/app/Controller/ProjectStatusController.php
blob: 4fdbb6eab96a31468cb3991f5f7312b148a69f2e (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php

namespace Kanboard\Controller;

/**
 * Class ProjectStatusController
 *
 * @package Kanboard\Controller
 * @author  Frederic Guillot
 */
class ProjectStatusController extends BaseController
{
    /**
     * Enable a project (confirmation dialog box)
     */
    public function confirmEnable()
    {
        $project = $this->getProject();

        $this->response->html($this->template->render('project_status/enable', array(
            'project' => $project,
        )));
    }

    /**
     * Enable the project
     */
    public function enable()
    {
        $project = $this->getProject();
        $this->checkCSRFParam();

        if ($this->projectModel->enable($project['id'])) {
            $this->flash->success(t('Project activated successfully.'));
        } else {
            $this->flash->failure(t('Unable to activate this project.'));
        }

        $this->response->redirect($this->helper->url->to('ProjectViewController', 'show', array('project_id' => $project['id'])), true);
    }

    /**
     * Disable a project (confirmation dialog box)
     */
    public function confirmDisable()
    {
        $project = $this->getProject();

        $this->response->html($this->template->render('project_status/disable', array(
            'project' => $project,
        )));
    }

    /**
     * Disable a project
     */
    public function disable()
    {
        $project = $this->getProject();
        $this->checkCSRFParam();

        if ($this->projectModel->disable($project['id'])) {
            $this->flash->success(t('Project disabled successfully.'));
        } else {
            $this->flash->failure(t('Unable to disable this project.'));
        }

        $this->response->redirect($this->helper->url->to('ProjectViewController', 'show', array('project_id' => $project['id'])), true);
    }

    /**
     * Remove a project (confirmation dialog box)
     */
    public function confirmRemove()
    {
        $project = $this->getProject();

        $this->response->html($this->template->render('project_status/remove', array(
            'project' => $project,
            'title' => t('Remove project')
        )));
    }

    /**
     * Remove a project
     */
    public function remove()
    {
        $project = $this->getProject();
        $this->checkCSRFParam();

        if ($this->projectModel->remove($project['id'])) {
            $this->flash->success(t('Project removed successfully.'));
        } else {
            $this->flash->failure(t('Unable to remove this project.'));
        }

        $this->response->redirect($this->helper->url->to('ProjectListController', 'show'));
    }
}