summaryrefslogtreecommitdiff
path: root/plugins/Boardcustomizer/Controller/SettingsController.php
blob: e98ffbde31ccf10e8cf1d9d24e980362b91a785e (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
<?php

namespace Kanboard\Plugin\BoardCustomizer\Controller;

use Kanboard\Controller\BaseController;

class SettingsController extends BaseController
{

    public function showSettings()
    {
        $user = $this->getUser();

        $options = [
            t('Board: only show first column header') => 'boardcustomizer_onlyfirstcolumnheaders',
            t('Board: top selection without scollbar') => 'boardcustomizer_topnavhiddenscrollbar',
            t('Card: material design') => 'boardcustomizer_materialcard',
            t('Card: white background') => 'boardcustomizer_whitebackground',
            t('Card: hide owner name') => 'boardcustomizer_hideownername',
            t('Card: hide category') => 'boardcustomizer_hidecategory',
            t('Card: hide tags') => 'boardcustomizer_hidetags',
            t('Card: hide all footer icons') => 'boardcustomizer_hidefooter',
            t('Card: hide task priority') => 'boardcustomizer_hidetaskpriority',
            t('Card: hide task age') => 'boardcustomizer_hidetaskage',
            t('Card: hide reference') => 'boardcustomizer_hidereference',
            t('Card: hide score') => 'boardcustomizer_hidescore',
            t('Card: hide time estimated') => 'boardcustomizer_hidetimeestimated',
            t('Card: hide task date') => 'boardcustomizer_hidetaskdate'
        ];

        // additional options is other plugin is installed
        $pluginFGroupAssign = PLUGINS_DIR . DIRECTORY_SEPARATOR . basename('Group_assign');
        if (file_exists($pluginFGroupAssign)) {
            $plugin_groupassign = [
                t('Card: hide group labels') => 'boardcustomizer_groupassign_hidecardlabels'
            ];
            $options = array_merge($options, $plugin_groupassign);
        }

        $this->response->html($this->helper->layout->user('boardcustomizer:user/settings', [
            'title'   => t('My display settings'),
            'user'    => $user,
            'options' => $options,
        ]));
    }

    public function disable()
    {
        $user = $this->getUser();
        $key = $this->request->getStringParam('key');
        $this->userMetadataModel->remove($user['id'], $key);
        return $this->response->redirect($this->helper->url->to('SettingsController', 'showSettings', ['plugin' => 'boardcustomizer']), true);
    }

    public function enable()
    {
        $user = $this->getUser();
        $key = $this->request->getStringParam('key');
        $this->userMetadataModel->save($user['id'], [$key => true]);
        return $this->response->redirect($this->helper->url->to('SettingsController', 'showSettings', ['plugin' => 'boardcustomizer']), true);
    }
}