You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IConfig.php 9.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bart Visscher <bartv@thisnet.nl>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  9. * @author Lukas Reschke <lukas@statuscode.ch>
  10. * @author Morris Jobke <hey@morrisjobke.de>
  11. * @author Robin Appelman <robin@icewind.nl>
  12. * @author Roeland Jago Douma <roeland@famdouma.nl>
  13. * @author Thomas Müller <thomas.mueller@tmit.eu>
  14. *
  15. * @license AGPL-3.0
  16. *
  17. * This code is free software: you can redistribute it and/or modify
  18. * it under the terms of the GNU Affero General Public License, version 3,
  19. * as published by the Free Software Foundation.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU Affero General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU Affero General Public License, version 3,
  27. * along with this program. If not, see <http://www.gnu.org/licenses/>
  28. *
  29. */
  30. // use OCP namespace for all classes that are considered public.
  31. // This means that they should be used by apps instead of the internal Nextcloud classes
  32. namespace OCP;
  33. /**
  34. * Access to all the configuration options Nextcloud offers.
  35. * @since 6.0.0
  36. */
  37. interface IConfig {
  38. /**
  39. * @since 8.2.0
  40. */
  41. public const SENSITIVE_VALUE = '***REMOVED SENSITIVE VALUE***';
  42. /**
  43. * Sets and deletes system wide values
  44. *
  45. * @param array $configs Associative array with `key => value` pairs
  46. * If value is null, the config key will be deleted
  47. * @throws HintException if config file is read-only
  48. * @since 8.0.0
  49. */
  50. public function setSystemValues(array $configs);
  51. /**
  52. * Sets a new system wide value
  53. *
  54. * @param string $key the key of the value, under which will be saved
  55. * @param mixed $value the value that should be stored
  56. * @throws HintException if config file is read-only
  57. * @since 8.0.0
  58. */
  59. public function setSystemValue($key, $value);
  60. /**
  61. * Looks up a system wide defined value
  62. *
  63. * @param string $key the key of the value, under which it was saved
  64. * @param mixed $default the default value to be returned if the value isn't set
  65. * @return mixed the value or $default
  66. * @since 6.0.0 - parameter $default was added in 7.0.0
  67. */
  68. public function getSystemValue($key, $default = '');
  69. /**
  70. * Looks up a boolean system wide defined value
  71. *
  72. * @param string $key the key of the value, under which it was saved
  73. * @param bool $default the default value to be returned if the value isn't set
  74. * @return bool the value or $default
  75. * @since 16.0.0
  76. */
  77. public function getSystemValueBool(string $key, bool $default = false): bool;
  78. /**
  79. * Looks up an integer system wide defined value
  80. *
  81. * @param string $key the key of the value, under which it was saved
  82. * @param int $default the default value to be returned if the value isn't set
  83. * @return int the value or $default
  84. * @since 16.0.0
  85. */
  86. public function getSystemValueInt(string $key, int $default = 0): int;
  87. /**
  88. * Looks up a string system wide defined value
  89. *
  90. * @param string $key the key of the value, under which it was saved
  91. * @param string $default the default value to be returned if the value isn't set
  92. * @return string the value or $default
  93. * @since 16.0.0
  94. */
  95. public function getSystemValueString(string $key, string $default = ''): string;
  96. /**
  97. * Looks up a system wide defined value and filters out sensitive data
  98. *
  99. * @param string $key the key of the value, under which it was saved
  100. * @param mixed $default the default value to be returned if the value isn't set
  101. * @return mixed the value or $default
  102. * @since 8.2.0
  103. */
  104. public function getFilteredSystemValue($key, $default = '');
  105. /**
  106. * Delete a system wide defined value
  107. *
  108. * @param string $key the key of the value, under which it was saved
  109. * @since 8.0.0
  110. */
  111. public function deleteSystemValue($key);
  112. /**
  113. * Get all keys stored for an app
  114. *
  115. * @param string $appName the appName that we stored the value under
  116. * @return string[] the keys stored for the app
  117. * @since 8.0.0
  118. * @deprecated 29.0.0 Use {@see IAppConfig} directly
  119. */
  120. public function getAppKeys($appName);
  121. /**
  122. * Writes a new app wide value
  123. *
  124. * @param string $appName the appName that we want to store the value under
  125. * @param string|float|int $key the key of the value, under which will be saved
  126. * @param string $value the value that should be stored
  127. * @return void
  128. * @since 6.0.0
  129. * @deprecated 29.0.0 Use {@see IAppConfig} directly
  130. */
  131. public function setAppValue($appName, $key, $value);
  132. /**
  133. * Looks up an app wide defined value
  134. *
  135. * @param string $appName the appName that we stored the value under
  136. * @param string $key the key of the value, under which it was saved
  137. * @param string $default the default value to be returned if the value isn't set
  138. *
  139. * @return string the saved value
  140. * @since 6.0.0 - parameter $default was added in 7.0.0
  141. * @deprecated 29.0.0 Use {@see IAppConfig} directly
  142. */
  143. public function getAppValue($appName, $key, $default = '');
  144. /**
  145. * Delete an app wide defined value
  146. *
  147. * @param string $appName the appName that we stored the value under
  148. * @param string $key the key of the value, under which it was saved
  149. * @since 8.0.0
  150. * @deprecated 29.0.0 Use {@see IAppConfig} directly
  151. */
  152. public function deleteAppValue($appName, $key);
  153. /**
  154. * Removes all keys in appconfig belonging to the app
  155. *
  156. * @param string $appName the appName the configs are stored under
  157. * @since 8.0.0
  158. * @deprecated 29.0.0 Use {@see IAppConfig} directly
  159. */
  160. public function deleteAppValues($appName);
  161. /**
  162. * Set a user defined value
  163. *
  164. * @param string $userId the userId of the user that we want to store the value under
  165. * @param string $appName the appName that we want to store the value under
  166. * @param string $key the key under which the value is being stored
  167. * @param string $value the value that you want to store
  168. * @param string $preCondition only update if the config value was previously the value passed as $preCondition
  169. * @throws \OCP\PreConditionNotMetException if a precondition is specified and is not met
  170. * @throws \UnexpectedValueException when trying to store an unexpected value
  171. * @since 6.0.0 - parameter $precondition was added in 8.0.0
  172. */
  173. public function setUserValue($userId, $appName, $key, $value, $preCondition = null);
  174. /**
  175. * Shortcut for getting a user defined value
  176. *
  177. * @param ?string $userId the userId of the user that we want to store the value under
  178. * @param string $appName the appName that we stored the value under
  179. * @param string $key the key under which the value is being stored
  180. * @param mixed $default the default value to be returned if the value isn't set
  181. * @return string
  182. * @since 6.0.0 - parameter $default was added in 7.0.0
  183. */
  184. public function getUserValue($userId, $appName, $key, $default = '');
  185. /**
  186. * Fetches a mapped list of userId -> value, for a specified app and key and a list of user IDs.
  187. *
  188. * @param string $appName app to get the value for
  189. * @param string $key the key to get the value for
  190. * @param array $userIds the user IDs to fetch the values for
  191. * @return array Mapped values: userId => value
  192. * @since 8.0.0
  193. */
  194. public function getUserValueForUsers($appName, $key, $userIds);
  195. /**
  196. * Get the keys of all stored by an app for the user
  197. *
  198. * @param string $userId the userId of the user that we want to store the value under
  199. * @param string $appName the appName that we stored the value under
  200. * @return string[]
  201. * @since 8.0.0
  202. */
  203. public function getUserKeys($userId, $appName);
  204. /**
  205. * Get all user configs sorted by app of one user
  206. *
  207. * @param string $userId the userId of the user that we want to get all values from
  208. * @psalm-return array<string, array<string, string>>
  209. * @return array[] - 2 dimensional array with the following structure:
  210. * [ $appId =>
  211. * [ $key => $value ]
  212. * ]
  213. * @since 24.0.0
  214. */
  215. public function getAllUserValues(string $userId): array;
  216. /**
  217. * Delete a user value
  218. *
  219. * @param string $userId the userId of the user that we want to store the value under
  220. * @param string $appName the appName that we stored the value under
  221. * @param string $key the key under which the value is being stored
  222. * @since 8.0.0
  223. */
  224. public function deleteUserValue($userId, $appName, $key);
  225. /**
  226. * Delete all user values
  227. *
  228. * @param string $userId the userId of the user that we want to remove all values from
  229. * @since 8.0.0
  230. */
  231. public function deleteAllUserValues($userId);
  232. /**
  233. * Delete all user related values of one app
  234. *
  235. * @param string $appName the appName of the app that we want to remove all values from
  236. * @since 8.0.0
  237. */
  238. public function deleteAppFromAllUsers($appName);
  239. /**
  240. * Determines the users that have the given value set for a specific app-key-pair
  241. *
  242. * @param string $appName the app to get the user for
  243. * @param string $key the key to get the user for
  244. * @param string $value the value to get the user for
  245. * @return array of user IDs
  246. * @since 8.0.0
  247. */
  248. public function getUsersForUserValue($appName, $key, $value);
  249. }