iconfig.php 6.92 KB
Newer Older
1
<?php
2
/**
3
 * ownCloud
4
 *
5
6
 * @author Bart Visscher
 * @copyright 2013 Bart Visscher bartv@thisnet.nl
7
 *
8
9
10
11
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
 * License as published by the Free Software Foundation; either
 * 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
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
 *
18
19
 * You should have received a copy of the GNU Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
Morris Jobke's avatar
Morris Jobke committed
20
 *
21
 */
22
23
24
25
26
27
28

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

Morris Jobke's avatar
Morris Jobke committed
29
30
// 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
31
32
33
34
35
36
namespace OCP;

/**
 * Access to all the configuration options ownCloud offers
 */
interface IConfig {
37
38
39
40
41
42
43
44
	/**
	 * 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);

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

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

62
63
64
65
66
67
68
	/**
	 * Delete a system wide defined value
	 *
	 * @param string $key the key of the value, under which it was saved
	 */
	public function deleteSystemValue($key);

69
70
71
72
73
74
75
	/**
	 * 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);
76
77

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

87
88
89
90
91
92
93
94
95
96
	/**
	 * 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);

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

107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
	/**
	 * 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();

134
135
136
137
138
139
140
141
	/**
	 * 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);

142
143
144
145
146
147
148
	/**
	 * Removes all keys in appconfig belonging to the app
	 *
	 * @param string $appName the appName the configs are stored under
	 */
	public function deleteAppValues($appName);

149
150

	/**
151
	 * Set a user defined value
152
	 *
153
154
	 * @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
155
156
	 * @param string $key the key under which the value is being stored
	 * @param string $value the value that you want to store
157
158
	 * @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
159
	 */
160
	public function setUserValue($userId, $appName, $key, $value, $preCondition = null);
161
162
163

	/**
	 * Shortcut for getting a user defined value
164
	 *
165
166
	 * @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
167
	 * @param string $key the key under which the value is being stored
168
	 * @param string $default the default value to be returned if the value isn't set
169
	 * @return string
170
	 */
171
	public function getUserValue($userId, $appName, $key, $default = '');
172

173
174
175
	/**
	 * Fetches a mapped list of userId -> value, for a specified app and key and a list of user IDs.
	 *
176
177
178
	 * @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
179
180
181
182
	 * @return array Mapped values: userId => value
	 */
	public function getUserValueForUsers($appName, $key, $userIds);

183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
	/**
	 * 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
200
201
202
203
204
205
206

	/**
	 * Delete all user values
	 *
	 * @param string $userId the userId of the user that we want to remove all values from
	 */
	public function deleteAllUserValues($userId);
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223

	/**
	 * 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);
224
}