iconfig.php 7.19 KB
Newer Older
1
<?php
2
/**
Jenkins for ownCloud's avatar
Jenkins for ownCloud committed
3
4
5
6
7
8
9
 * @author Bart Visscher <bartv@thisnet.nl>
 * @author Joas Schilling <nickvergessen@owncloud.com>
 * @author Jörn Friedrich Dreyer <jfd@butonic.de>
 * @author Lukas Reschke <lukas@owncloud.com>
 * @author Morris Jobke <hey@morrisjobke.de>
 * @author Robin Appelman <icewind@owncloud.com>
 * @author Thomas Müller <thomas.mueller@tmit.eu>
10
 *
Jenkins for ownCloud's avatar
Jenkins for ownCloud committed
11
12
 * @copyright Copyright (c) 2015, ownCloud, Inc.
 * @license AGPL-3.0
13
 *
Jenkins for ownCloud's avatar
Jenkins for ownCloud committed
14
15
16
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
17
 *
Jenkins for ownCloud's avatar
Jenkins for ownCloud committed
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Jenkins for ownCloud's avatar
Jenkins for ownCloud committed
20
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
22
 *
Jenkins for ownCloud's avatar
Jenkins for ownCloud committed
23
24
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
Morris Jobke's avatar
Morris Jobke committed
25
 *
26
 */
27
28
29
30
31
32
33

/**
 * Public interface of ownCloud for apps to use.
 * Config interface
 *
 */

Morris Jobke's avatar
Morris Jobke committed
34
35
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
36
37
38
39
40
41
namespace OCP;

/**
 * Access to all the configuration options ownCloud offers
 */
interface IConfig {
42
43
44
45
46
47
48
49
	/**
	 * Sets and deletes system wide values
	 *
	 * @param array $configs Associative array with `key => value` pairs
	 *                       If value is null, the config key will be deleted
	 */
	public function setSystemValues(array $configs);

50
	/**
Thomas Müller's avatar
Thomas Müller committed
51
	 * Sets a new system wide value
52
	 *
53
	 * @param string $key the key of the value, under which will be saved
54
	 * @param mixed $value the value that should be stored
55
	 */
Lukas Reschke's avatar
Lukas Reschke committed
56
	public function setSystemValue($key, $value);
57
58

	/**
Thomas Müller's avatar
Thomas Müller committed
59
	 * Looks up a system wide defined value
60
	 *
61
	 * @param string $key the key of the value, under which it was saved
Lukas Reschke's avatar
Lukas Reschke committed
62
	 * @param mixed $default the default value to be returned if the value isn't set
63
	 * @return mixed the value or $default
64
	 */
65
	public function getSystemValue($key, $default = '');
66

67
68
69
70
71
72
73
	/**
	 * Delete a system wide defined value
	 *
	 * @param string $key the key of the value, under which it was saved
	 */
	public function deleteSystemValue($key);

74
75
76
77
78
79
80
	/**
	 * Get all keys stored for an app
	 *
	 * @param string $appName the appName that we stored the value under
	 * @return string[] the keys stored for the app
	 */
	public function getAppKeys($appName);
81
82

	/**
Thomas Müller's avatar
Thomas Müller committed
83
	 * Writes a new app wide value
84
	 *
85
	 * @param string $appName the appName that we want to store the value under
86
87
	 * @param string $key the key of the value, under which will be saved
	 * @param string $value the value that should be stored
88
	 * @return void
89
	 */
90
	public function setAppValue($appName, $key, $value);
91

92
93
94
95
96
97
98
99
100
101
	/**
	 * Checks if a key is set in the apps config
	 *
	 * @param string $appName the appName tto look a key up
	 * @param string $key the key to look up
	 * @return bool
	 * @since 8.1.0
	 */
	public function hasAppKey($appName, $key);

102
	/**
Thomas Müller's avatar
Thomas Müller committed
103
	 * Looks up an app wide defined value
104
	 *
105
	 * @param string $appName the appName that we stored the value under
106
	 * @param string $key the key of the value, under which it was saved
107
	 * @param string $default the default value to be returned if the value isn't set
108
109
	 * @return string the saved value
	 */
110
	public function getAppValue($appName, $key, $default = '');
111

112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
	/**
	 * Get all app values that are stored
	 *
	 * @param string $appName the appName
	 * @return array with key - value pair as they are saved previously
	 * @since 8.1.0
	 */
	public function getAppValuesByApp($appName);

	/**
	 * Get all app values that use the same key
	 *
	 * @param string $key the appName
	 * @return array with key - value pair as they are saved previously with the
	 * 	             app name as key
	 * @since 8.1.0
	 */
	public function getAppValuesByKey($key);

	/**
	 * Get all apps that have at least one value saved
	 *
	 * @return array containing app names
	 * @since 8.1.0
	 */
	public function getApps();

139
140
141
142
143
144
145
146
	/**
	 * Delete an app wide defined value
	 *
	 * @param string $appName the appName that we stored the value under
	 * @param string $key the key of the value, under which it was saved
	 */
	public function deleteAppValue($appName, $key);

147
148
149
150
151
152
153
	/**
	 * Removes all keys in appconfig belonging to the app
	 *
	 * @param string $appName the appName the configs are stored under
	 */
	public function deleteAppValues($appName);

154
155

	/**
156
	 * Set a user defined value
157
	 *
158
159
	 * @param string $userId the userId of the user that we want to store the value under
	 * @param string $appName the appName that we want to store the value under
160
161
	 * @param string $key the key under which the value is being stored
	 * @param string $value the value that you want to store
162
163
	 * @param string $preCondition only update if the config value was previously the value passed as $preCondition
	 * @throws \OCP\PreConditionNotMetException if a precondition is specified and is not met
164
	 */
165
	public function setUserValue($userId, $appName, $key, $value, $preCondition = null);
166
167
168

	/**
	 * Shortcut for getting a user defined value
169
	 *
170
171
	 * @param string $userId the userId of the user that we want to store the value under
	 * @param string $appName the appName that we stored the value under
172
	 * @param string $key the key under which the value is being stored
173
	 * @param string $default the default value to be returned if the value isn't set
174
	 * @return string
175
	 */
176
	public function getUserValue($userId, $appName, $key, $default = '');
177

178
179
180
	/**
	 * Fetches a mapped list of userId -> value, for a specified app and key and a list of user IDs.
	 *
181
182
183
	 * @param string $appName app to get the value for
	 * @param string $key the key to get the value for
	 * @param array $userIds the user IDs to fetch the values for
184
185
186
187
	 * @return array Mapped values: userId => value
	 */
	public function getUserValueForUsers($appName, $key, $userIds);

188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
	/**
	 * Get the keys of all stored by an app for the user
	 *
	 * @param string $userId the userId of the user that we want to store the value under
	 * @param string $appName the appName that we stored the value under
	 * @return string[]
	 */
	public function getUserKeys($userId, $appName);

	/**
	 * Delete a user value
	 *
	 * @param string $userId the userId of the user that we want to store the value under
	 * @param string $appName the appName that we stored the value under
	 * @param string $key the key under which the value is being stored
	 */
	public function deleteUserValue($userId, $appName, $key);
Morris Jobke's avatar
Morris Jobke committed
205
206
207
208
209
210
211

	/**
	 * Delete all user values
	 *
	 * @param string $userId the userId of the user that we want to remove all values from
	 */
	public function deleteAllUserValues($userId);
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228

	/**
	 * Delete all user related values of one app
	 *
	 * @param string $appName the appName of the app that we want to remove all values from
	 */
	public function deleteAppFromAllUsers($appName);

	/**
	 * Determines the users that have the given value set for a specific app-key-pair
	 *
	 * @param string $appName the app to get the user for
	 * @param string $key the key to get the user for
	 * @param string $value the value to get the user for
	 * @return array of user IDs
	 */
	public function getUsersForUserValue($appName, $key, $value);
229
}