This repository has been archived by the owner on Jun 30, 2023. It is now read-only.
/
OfflineController.php
76 lines (64 loc) · 2.27 KB
/
OfflineController.php
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
<?php
namespace Kanboard\Plugin\OfflineKanboardPlugin\Controller;
use Kanboard\Controller\BaseController;
class OfflineController extends BaseController
{
/**
* Display the Offline settings page
*
* @access public
*/
public function index()
{
$this->response->html($this->helper->layout->config('OfflineKanboardPlugin:config/offline-settings-page', array(
'title' => t('Settings') . ' > ' . t('Offline settings'),
)));
}
public function js()
{
$check_connection = $this->configModel->get('check_connection');
$checkOnLoad = ($check_connection == 1) ? 'true' : 'false';
$store_remake = $this->configModel->get('store_remake');
$requests = ($store_remake == 1) ? 'true' : 'false';
$snake_game = $this->configModel->get('snake_game');
$snake = ($snake_game == 1) ? 'true' : 'false';
$initialDelay = $this->configModel->get('initialDelay');
$delay = $this->configModel->get('delay');
$data = 'Offline.options = {
checkOnLoad: ' . $checkOnLoad . ',
requests: ' . $requests . ',
reconnect: {
initialDelay:' . $initialDelay . ',
delay: ' . $delay . '
},
game: ' . $snake . '
};';
$this->response->js($data, 200);
}
/**
* Save settings
*
*/
public function save()
{
$values = $this->request->getValues();
$redirect = $this->request->getStringParam('redirect', 'index');
switch ($redirect) {
case 'index':
$values += array(
'snake_game' => 0,
'check_connection' => 0,
'store_remake' => 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('OfflineController', 'index',
array('plugin' => 'OfflineKanboardPlugin')));
}
}