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 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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. /**
  31. * Public interface of ownCloud for apps to use.
  32. * Config interface
  33. *
  34. */
  35. // use OCP namespace for all classes that are considered public.
  36. // This means that they should be used by apps instead of the internal ownCloud classes
  37. namespace OCP;
  38. /**
  39. * Access to all the configuration options ownCloud offers
  40. * @since 6.0.0
  41. */
  42. interface IConfig {
  43. /**
  44. * @since 8.2.0
  45. */
  46. public const SENSITIVE_VALUE = '***REMOVED SENSITIVE VALUE***';
  47. /**
  48. * Sets and deletes system wide values
  49. *
  50. * @param array $configs Associative array with `key => value` pairs
  51. * If value is null, the config key will be deleted
  52. * @since 8.0.0
  53. */
  54. public function setSystemValues(array $configs);
  55. /**
  56. * Sets a new system wide value
  57. *
  58. * @param string $key the key of the value, under which will be saved
  59. * @param mixed $value the value that should be stored
  60. * @since 8.0.0
  61. */
  62. public function setSystemValue($key, $value);
  63. /**
  64. * Looks up a system wide defined value
  65. *
  66. * @param string $key the key of the value, under which it was saved
  67. * @param mixed $default the default value to be returned if the value isn't set
  68. * @return mixed the value or $default
  69. * @since 6.0.0 - parameter $default was added in 7.0.0
  70. */
  71. public function getSystemValue($key, $default = '');
  72. /**
  73. * Looks up a boolean system wide defined value
  74. *
  75. * @param string $key the key of the value, under which it was saved
  76. * @param bool $default the default value to be returned if the value isn't set
  77. * @return bool the value or $default
  78. * @since 16.0.0
  79. */
  80. public function getSystemValueBool(string $key, bool $default = false): bool;
  81. /**
  82. * Looks up an integer system wide defined value
  83. *
  84. * @param string $key the key of the value, under which it was saved
  85. * @param int $default the default value to be returned if the value isn't set
  86. * @return int the value or $default
  87. * @since 16.0.0
  88. */
  89. public function getSystemValueInt(string $key, int $default = 0): int;
  90. /**
  91. * Looks up a string system wide defined value
  92. *
  93. * @param string $key the key of the value, under which it was saved
  94. * @param string $default the default value to be returned if the value isn't set
  95. * @return string the value or $default
  96. * @since 16.0.0
  97. */
  98. public function getSystemValueString(string $key, string $default = ''): string;
  99. /**
  100. * Looks up a system wide defined value and filters out sensitive data
  101. *
  102. * @param string $key the key of the value, under which it was saved
  103. * @param mixed $default the default value to be returned if the value isn't set
  104. * @return mixed the value or $default
  105. * @since 8.2.0
  106. */
  107. public function getFilteredSystemValue($key, $default = '');
  108. /**
  109. * Delete a system wide defined value
  110. *
  111. * @param string $key the key of the value, under which it was saved
  112. * @since 8.0.0
  113. */
  114. public function deleteSystemValue($key);
  115. /**
  116. * Get all keys stored for an app
  117. *
  118. * @param string $appName the appName that we stored the value under
  119. * @return string[] the keys stored for the app
  120. * @since 8.0.0
  121. */
  122. public function getAppKeys($appName);
  123. /**
  124. * Writes a new app wide value
  125. *
  126. * @param string $appName the appName that we want to store the value under
  127. * @param string|float|int $key the key of the value, under which will be saved
  128. * @param string $value the value that should be stored
  129. * @return void
  130. * @since 6.0.0
  131. */
  132. public function setAppValue($appName, $key, $value);
  133. /**
  134. * Looks up an app wide defined value
  135. *
  136. * @param string $appName the appName that we stored the value under
  137. * @param string $key the key of the value, under which it was saved
  138. * @param string $default the default value to be returned if the value isn't set
  139. * @return string the saved value
  140. * @since 6.0.0 - parameter $default was added in 7.0.0
  141. */
  142. public function getAppValue($appName, $key, $default = '');
  143. /**
  144. * Delete an app wide defined value
  145. *
  146. * @param string $appName the appName that we stored the value under
  147. * @param string $key the key of the value, under which it was saved
  148. * @since 8.0.0
  149. */
  150. public function deleteAppValue($appName, $key);
  151. /**
  152. * Removes all keys in appconfig belonging to the app
  153. *
  154. * @param string $appName the appName the configs are stored under
  155. * @since 8.0.0
  156. */
  157. public function deleteAppValues($appName);
  158. /**
  159. * Set a user defined value
  160. *
  161. * @param string $userId the userId of the user that we want to store the value under
  162. * @param string $appName the appName that we want to store the value under
  163. * @param string $key the key under which the value is being stored
  164. * @param string $value the value that you want to store
  165. * @param string $preCondition only update if the config value was previously the value passed as $preCondition
  166. * @throws \OCP\PreConditionNotMetException if a precondition is specified and is not met
  167. * @throws \UnexpectedValueException when trying to store an unexpected value
  168. * @since 6.0.0 - parameter $precondition was added in 8.0.0
  169. */
  170. public function setUserValue($userId, $appName, $key, $value, $preCondition = null);
  171. /**
  172. * Shortcut for getting a user defined value
  173. *
  174. * @param string $userId the userId of the user that we want to store the value under
  175. * @param string $appName the appName that we stored the value under
  176. * @param string $key the key under which the value is being stored
  177. * @param mixed $default the default value to be returned if the value isn't set
  178. * @return string
  179. * @since 6.0.0 - parameter $default was added in 7.0.0
  180. */
  181. public function getUserValue($userId, $appName, $key, $default = '');
  182. /**
  183. * Fetches a mapped list of userId -> value, for a specified app and key and a list of user IDs.
  184. *
  185. * @param string $appName app to get the value for
  186. * @param string $key the key to get the value for
  187. * @param array $userIds the user IDs to fetch the values for
  188. * @return array Mapped values: userId => value
  189. * @since 8.0.0
  190. */
  191. public function getUserValueForUsers($appName, $key, $userIds);
  192. /**
  193. * Get the keys of all stored by an app for the user
  194. *
  195. * @param string $userId the userId of the user that we want to store the value under
  196. * @param string $appName the appName that we stored the value under
  197. * @return string[]
  198. * @since 8.0.0
  199. */
  200. public function getUserKeys($userId, $appName);
  201. /**
  202. * Delete a user value
  203. *
  204. * @param string $userId the userId of the user that we want to store the value under
  205. * @param string $appName the appName that we stored the value under
  206. * @param string $key the key under which the value is being stored
  207. * @since 8.0.0
  208. */
  209. public function deleteUserValue($userId, $appName, $key);
  210. /**
  211. * Delete all user values
  212. *
  213. * @param string $userId the userId of the user that we want to remove all values from
  214. * @since 8.0.0
  215. */
  216. public function deleteAllUserValues($userId);
  217. /**
  218. * Delete all user related values of one app
  219. *
  220. * @param string $appName the appName of the app that we want to remove all values from
  221. * @since 8.0.0
  222. */
  223. public function deleteAppFromAllUsers($appName);
  224. /**
  225. * Determines the users that have the given value set for a specific app-key-pair
  226. *
  227. * @param string $appName the app to get the user for
  228. * @param string $key the key to get the user for
  229. * @param string $value the value to get the user for
  230. * @return array of user IDs
  231. * @since 8.0.0
  232. */
  233. public function getUsersForUserValue($appName, $key, $value);
  234. }