1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* ownCloud - Tasks |
4
|
|
|
* |
5
|
|
|
* @author Raimund Schlüßler |
6
|
|
|
* @copyright 2015 Raimund Schlüßler [email protected] |
7
|
|
|
* |
8
|
|
|
* This library is free software; you can redistribute it and/or |
9
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
10
|
|
|
* License as published by the Free Software Foundation; either |
11
|
|
|
* version 3 of the License, or any later version. |
12
|
|
|
* |
13
|
|
|
* This library is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
17
|
|
|
* |
18
|
|
|
* You should have received a copy of the GNU Affero General Public |
19
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
20
|
|
|
* |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
namespace OCA\Tasks\Service; |
24
|
|
|
|
25
|
|
|
use OCP\IConfig; |
26
|
|
|
|
27
|
|
|
class SettingsService { |
28
|
|
|
|
29
|
|
|
private $userId; |
30
|
|
|
private $settings; |
31
|
|
|
private $appName; |
32
|
|
|
|
33
|
|
|
public function __construct($userId, IConfig $settings, $appName) { |
34
|
|
|
$this->userId = $userId; |
35
|
|
|
$this->settings = $settings; |
36
|
|
|
$this->appName = $appName; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* get the current settings |
41
|
|
|
* |
42
|
|
|
* @return array |
43
|
|
|
*/ |
44
|
|
|
public function get() { |
45
|
|
|
$settings = array( |
46
|
|
|
array( |
47
|
|
|
'id' => 'various', |
48
|
|
|
'showHidden' => (int)$this->settings->getUserValue($this->userId, $this->appName,'various_showHidden'), |
49
|
|
|
'startOfWeek' => (int)$this->settings->getUserValue($this->userId, $this->appName,'various_startOfWeek'), |
50
|
|
|
'userID' => $this->userId |
51
|
|
|
) |
52
|
|
|
); |
53
|
|
|
return $settings; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* set setting of type to new value |
58
|
|
|
* |
59
|
|
|
* @param $setting |
60
|
|
|
* @param $type |
61
|
|
|
* @param $value |
62
|
|
|
* @return bool |
63
|
|
|
*/ |
64
|
|
|
public function set($setting, $type, $value) { |
65
|
|
|
$this->settings->setUserValue($this->userId, $this->appName, $type.'_'.$setting, $value); |
66
|
|
|
return true; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|