summaryrefslogtreecommitdiff
path: root/app/Controller/UserStatus.php
blob: b8ee5c914b51fbc4a2724035c54f2688cf93fd07 (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
101
102
103
104
105
106
107
108
109
110
111
<?php

namespace Kanboard\Controller;

/**
 * User Status Controller
 *
 * @package  controller
 * @author   Frederic Guillot
 */
class UserStatus extends Base
{
    /**
     * Confirm remove a user
     *
     * @access public
     */
    public function confirmRemove()
    {
        $user = $this->getUser();

        $this->response->html($this->helper->layout->user('user_status/remove', array(
            'user' => $user,
        )));
    }

    /**
     * Remove a user
     *
     * @access public
     */
    public function remove()
    {
        $user = $this->getUser();
        $this->checkCSRFParam();

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

        $this->response->redirect($this->helper->url->to('user', 'index'));
    }

    /**
     * Confirm enable a user
     *
     * @access public
     */
    public function confirmEnable()
    {
        $user = $this->getUser();

        $this->response->html($this->helper->layout->user('user_status/enable', array(
            'user' => $user,
        )));
    }

    /**
     * Enable a user
     *
     * @access public
     */
    public function enable()
    {
        $user = $this->getUser();
        $this->checkCSRFParam();

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

        $this->response->redirect($this->helper->url->to('user', 'index'));
    }

    /**
     * Confirm disable a user
     *
     * @access public
     */
    public function confirmDisable()
    {
        $user = $this->getUser();

        $this->response->html($this->helper->layout->user('user_status/disable', array(
            'user' => $user,
        )));
    }

    /**
     * Disable a user
     *
     * @access public
     */
    public function disable()
    {
        $user = $this->getUser();
        $this->checkCSRFParam();

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

        $this->response->redirect($this->helper->url->to('user', 'index'));
    }
}