iconfig.php 6.8 KB

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