IConfig.php 8.3 KB

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