summaryrefslogtreecommitdiff
path: root/plugins/KanboardSearchPlugin/Controller/AdvancedSearchController.php
blob: 73930fecb58dfcd516ce69c24af4aba6163424a0 (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
<?php

namespace Kanboard\Plugin\KanboardSearchPlugin\Controller;


use Kanboard\Controller\BaseController;


class AdvancedSearchController extends BaseController
{
    /**
     * Display the ASF settings page
     *
     * @access public
     */
    public function index()
    {
        $this->response->html($this->helper->layout->config('KanboardSearchPlugin:config/advanced-search-filter', array(
            'db_size' => $this->configModel->getDatabaseSize(),
            'db_version' => $this->db->getDriver()->getDatabaseVersion(),
            'user_agent' => $this->request->getServerVariable('HTTP_USER_AGENT'),
            'title' => t('Settings').' &gt; '.t('Advanced Search Filter'),
        )));
    }

    /**
     * Save settings
     *
     */
    public function save()
    {
        $values =  $this->request->getValues();
        $redirect = $this->request->getStringParam('redirect', 'index');
        switch ($redirect) {
            case 'index':
                $values += array(
                    'comment_search' => 0,
                    'title_search' => 0,
                    'description_search' => 0,
                    'subtask_search' => 0,
                    'attachment_search' => 0
                    );
                break;
        }

        if ($this->configModel->save($values)) {
            $this->languageModel->loadCurrentLanguage();
            $this->flash->success(t('Settings saved successfully.'));
        } else {
            $this->flash->failure(t('Unable to save your settings.'));
        }
        $this->response->redirect($this->helper->url->to('AdvancedSearchController', 'index', array('plugin' => 'KanboardSearchPlugin')));
    }
}