1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Joas Schilling <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @copyright Copyright (c) 2018, ownCloud GmbH |
6
|
|
|
* @license AGPL-3.0 |
7
|
|
|
* |
8
|
|
|
* This code is free software: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
10
|
|
|
* as published by the Free Software Foundation. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
19
|
|
|
* |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace OCA\Testing; |
23
|
|
|
|
24
|
|
|
use OCP\IConfig; |
25
|
|
|
use OCP\IRequest; |
26
|
|
|
|
27
|
|
|
class Config { |
28
|
|
|
|
29
|
|
|
/** @var IConfig */ |
30
|
|
|
private $config; |
31
|
|
|
|
32
|
|
|
/** @var IRequest */ |
33
|
|
|
private $request; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param IConfig $config |
37
|
|
|
* @param IRequest $request |
38
|
|
|
*/ |
39
|
|
|
public function __construct(IConfig $config, IRequest $request) { |
40
|
|
|
$this->config = $config; |
41
|
|
|
$this->request = $request; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param array $parameters |
46
|
|
|
* @return \OC_OCS_Result |
47
|
|
|
*/ |
48
|
|
|
public function setAppValue($parameters) { |
49
|
|
|
$app = $parameters['appid']; |
50
|
|
|
$configKey = $parameters['configkey']; |
51
|
|
|
|
52
|
|
|
$value = $this->request->getParam('value'); |
53
|
|
|
$this->config->setAppValue($app, $configKey, $value); |
54
|
|
|
|
55
|
|
|
return new \OC_OCS_Result(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param array $parameters |
60
|
|
|
* @return \OC_OCS_Result |
61
|
|
|
*/ |
62
|
|
|
public function deleteAppValue($parameters) { |
63
|
|
|
$app = $parameters['appid']; |
64
|
|
|
$configKey = $parameters['configkey']; |
65
|
|
|
|
66
|
|
|
$this->config->deleteAppValue($app, $configKey); |
67
|
|
|
|
68
|
|
|
return new \OC_OCS_Result(); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return \OC_OCS_Result |
73
|
|
|
*/ |
74
|
|
View Code Duplication |
public function setAppValues() { |
75
|
|
|
$values = $this->request->getParam('values'); |
76
|
|
|
|
77
|
|
|
if (is_array($values)) { |
78
|
|
|
foreach ($values as $appEntry) { |
79
|
|
|
if (is_array($appEntry)) { |
80
|
|
|
$this->config->setAppValue( |
81
|
|
|
$appEntry['appid'], |
82
|
|
|
$appEntry['configkey'], |
83
|
|
|
$appEntry['value']); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
return new \OC_OCS_Result(); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return \OC_OCS_Result |
93
|
|
|
*/ |
94
|
|
View Code Duplication |
public function deleteAppValues() { |
95
|
|
|
$values = $this->request->getParam('values'); |
96
|
|
|
|
97
|
|
|
if (is_array($values)) { |
98
|
|
|
foreach ($values as $appEntry) { |
99
|
|
|
if (is_array($appEntry)) { |
100
|
|
|
$this->config->deleteAppValue( |
101
|
|
|
$appEntry['appid'], |
102
|
|
|
$appEntry['configkey'] |
103
|
|
|
); |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
return new \OC_OCS_Result(); |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|