IConfig.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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 system wide defined value and filters out sensitive data
  72. *
  73. * @param string $key the key of the value, under which it was saved
  74. * @param mixed $default the default value to be returned if the value isn't set
  75. * @return mixed the value or $default
  76. * @since 8.2.0
  77. */
  78. public function getFilteredSystemValue($key, $default = '');
  79. /**
  80. * Delete a system wide defined value
  81. *
  82. * @param string $key the key of the value, under which it was saved
  83. * @since 8.0.0
  84. */
  85. public function deleteSystemValue($key);
  86. /**
  87. * Get all keys stored for an app
  88. *
  89. * @param string $appName the appName that we stored the value under
  90. * @return string[] the keys stored for the app
  91. * @since 8.0.0
  92. */
  93. public function getAppKeys($appName);
  94. /**
  95. * Writes a new app wide value
  96. *
  97. * @param string $appName the appName that we want to store the value under
  98. * @param string|float|int $key the key of the value, under which will be saved
  99. * @param string $value the value that should be stored
  100. * @return void
  101. * @since 6.0.0
  102. */
  103. public function setAppValue($appName, $key, $value);
  104. /**
  105. * Looks up an app wide defined value
  106. *
  107. * @param string $appName the appName that we stored the value under
  108. * @param string $key the key of the value, under which it was saved
  109. * @param string $default the default value to be returned if the value isn't set
  110. * @return string the saved value
  111. * @since 6.0.0 - parameter $default was added in 7.0.0
  112. */
  113. public function getAppValue($appName, $key, $default = '');
  114. /**
  115. * Delete an app wide defined value
  116. *
  117. * @param string $appName the appName that we stored the value under
  118. * @param string $key the key of the value, under which it was saved
  119. * @since 8.0.0
  120. */
  121. public function deleteAppValue($appName, $key);
  122. /**
  123. * Removes all keys in appconfig belonging to the app
  124. *
  125. * @param string $appName the appName the configs are stored under
  126. * @since 8.0.0
  127. */
  128. public function deleteAppValues($appName);
  129. /**
  130. * Set a user defined value
  131. *
  132. * @param string $userId the userId of the user that we want to store the value under
  133. * @param string $appName the appName that we want to store the value under
  134. * @param string $key the key under which the value is being stored
  135. * @param string $value the value that you want to store
  136. * @param string $preCondition only update if the config value was previously the value passed as $preCondition
  137. * @throws \OCP\PreConditionNotMetException if a precondition is specified and is not met
  138. * @throws \UnexpectedValueException when trying to store an unexpected value
  139. * @since 6.0.0 - parameter $precondition was added in 8.0.0
  140. */
  141. public function setUserValue($userId, $appName, $key, $value, $preCondition = null);
  142. /**
  143. * Shortcut for getting a user defined value
  144. *
  145. * @param string $userId the userId of the user that we want to store the value under
  146. * @param string $appName the appName that we stored the value under
  147. * @param string $key the key under which the value is being stored
  148. * @param mixed $default the default value to be returned if the value isn't set
  149. * @return string
  150. * @since 6.0.0 - parameter $default was added in 7.0.0
  151. */
  152. public function getUserValue($userId, $appName, $key, $default = '');
  153. /**
  154. * Fetches a mapped list of userId -> value, for a specified app and key and a list of user IDs.
  155. *
  156. * @param string $appName app to get the value for
  157. * @param string $key the key to get the value for
  158. * @param array $userIds the user IDs to fetch the values for
  159. * @return array Mapped values: userId => value
  160. * @since 8.0.0
  161. */
  162. public function getUserValueForUsers($appName, $key, $userIds);
  163. /**
  164. * Get the keys of all stored by an app for the user
  165. *
  166. * @param string $userId the userId of the user that we want to store the value under
  167. * @param string $appName the appName that we stored the value under
  168. * @return string[]
  169. * @since 8.0.0
  170. */
  171. public function getUserKeys($userId, $appName);
  172. /**
  173. * Delete a user value
  174. *
  175. * @param string $userId the userId of the user that we want to store the value under
  176. * @param string $appName the appName that we stored the value under
  177. * @param string $key the key under which the value is being stored
  178. * @since 8.0.0
  179. */
  180. public function deleteUserValue($userId, $appName, $key);
  181. /**
  182. * Delete all user values
  183. *
  184. * @param string $userId the userId of the user that we want to remove all values from
  185. * @since 8.0.0
  186. */
  187. public function deleteAllUserValues($userId);
  188. /**
  189. * Delete all user related values of one app
  190. *
  191. * @param string $appName the appName of the app that we want to remove all values from
  192. * @since 8.0.0
  193. */
  194. public function deleteAppFromAllUsers($appName);
  195. /**
  196. * Determines the users that have the given value set for a specific app-key-pair
  197. *
  198. * @param string $appName the app to get the user for
  199. * @param string $key the key to get the user for
  200. * @param string $value the value to get the user for
  201. * @return array of user IDs
  202. * @since 8.0.0
  203. */
  204. public function getUsersForUserValue($appName, $key, $value);
  205. }