1<?php
2
3namespace Kanboard\Controller;
4
5/**
6 * User Status Controller
7 *
8 * @package  Kanboard\Controller
9 * @author   Frederic Guillot
10 */
11class UserStatusController extends BaseController
12{
13    /**
14     * Confirm remove a user
15     *
16     * @access public
17     */
18    public function confirmRemove()
19    {
20        $user = $this->getUser();
21
22        $this->response->html($this->helper->layout->user('user_status/remove', array(
23            'user' => $user,
24        )));
25    }
26
27    /**
28     * Remove a user
29     *
30     * @access public
31     */
32    public function remove()
33    {
34        $user = $this->getUser();
35        $this->checkCSRFParam();
36
37        if ($this->userModel->remove($user['id'])) {
38            $this->flash->success(t('User removed successfully.'));
39        } else {
40            $this->flash->failure(t('Unable to remove this user.'));
41        }
42
43        $this->response->redirect($this->helper->url->to('UserListController', 'show'));
44    }
45
46    /**
47     * Confirm enable a user
48     *
49     * @access public
50     */
51    public function confirmEnable()
52    {
53        $user = $this->getUser();
54
55        $this->response->html($this->helper->layout->user('user_status/enable', array(
56            'user' => $user,
57        )));
58    }
59
60    /**
61     * Enable a user
62     *
63     * @access public
64     */
65    public function enable()
66    {
67        $user = $this->getUser();
68        $this->checkCSRFParam();
69
70        if ($this->userModel->enable($user['id'])) {
71            $this->flash->success(t('User activated successfully.'));
72        } else {
73            $this->flash->failure(t('Unable to enable this user.'));
74        }
75
76        $this->response->redirect($this->helper->url->to('UserListController', 'show'));
77    }
78
79    /**
80     * Confirm disable a user
81     *
82     * @access public
83     */
84    public function confirmDisable()
85    {
86        $user = $this->getUser();
87
88        $this->response->html($this->helper->layout->user('user_status/disable', array(
89            'user' => $user,
90        )));
91    }
92
93    /**
94     * Disable a user
95     *
96     * @access public
97     */
98    public function disable()
99    {
100        $user = $this->getUser();
101        $this->checkCSRFParam();
102
103        if ($this->userModel->disable($user['id'])) {
104            $this->flash->success(t('User disabled successfully.'));
105        } else {
106            $this->flash->failure(t('Unable to disable this user.'));
107        }
108
109        $this->response->redirect($this->helper->url->to('UserListController', 'show'));
110    }
111}
112