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.

config.php 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?php
  2. /**
  3. * @author Bart Visscher <bartv@thisnet.nl>
  4. * @author Frank Karlitschek <frank@owncloud.org>
  5. * @author Georg Ehrke <georg@owncloud.com>
  6. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  7. * @author Lukas Reschke <lukas@owncloud.com>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Robin Appelman <icewind@owncloud.com>
  10. * @author Thomas Müller <thomas.mueller@tmit.eu>
  11. *
  12. * @copyright Copyright (c) 2016, ownCloud, Inc.
  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 Class
  31. *
  32. */
  33. /**
  34. * Use OCP namespace for all classes that are considered public.
  35. *
  36. * Classes that use this namespace are for use by apps, and not for use by internal
  37. * OC classes
  38. */
  39. namespace OCP;
  40. /**
  41. * This class provides functions to read and write configuration data.
  42. * configuration can be on a system, application or user level
  43. * @deprecated 8.0.0 use methods of \OCP\IConfig
  44. */
  45. class Config {
  46. /**
  47. * Gets a value from config.php
  48. * @param string $key key
  49. * @param mixed $default = null default value
  50. * @return mixed the value or $default
  51. * @deprecated 8.0.0 use method getSystemValue of \OCP\IConfig
  52. *
  53. * This function gets the value from config.php. If it does not exist,
  54. * $default will be returned.
  55. */
  56. public static function getSystemValue( $key, $default = null ) {
  57. return \OC::$server->getConfig()->getSystemValue( $key, $default );
  58. }
  59. /**
  60. * Sets a value
  61. * @param string $key key
  62. * @param mixed $value value
  63. * @return bool
  64. * @deprecated 8.0.0 use method setSystemValue of \OCP\IConfig
  65. *
  66. * This function sets the value and writes the config.php. If the file can
  67. * not be written, false will be returned.
  68. */
  69. public static function setSystemValue( $key, $value ) {
  70. try {
  71. \OC::$server->getConfig()->setSystemValue( $key, $value );
  72. } catch (\Exception $e) {
  73. return false;
  74. }
  75. return true;
  76. }
  77. /**
  78. * Deletes a value from config.php
  79. * @param string $key key
  80. * @deprecated 8.0.0 use method deleteSystemValue of \OCP\IConfig
  81. *
  82. * This function deletes the value from config.php.
  83. */
  84. public static function deleteSystemValue( $key ) {
  85. \OC::$server->getConfig()->deleteSystemValue( $key );
  86. }
  87. /**
  88. * Gets the config value
  89. * @param string $app app
  90. * @param string $key key
  91. * @param string $default = null, default value if the key does not exist
  92. * @return string the value or $default
  93. * @deprecated 8.0.0 use method getAppValue of \OCP\IConfig
  94. *
  95. * This function gets a value from the appconfig table. If the key does
  96. * not exist the default value will be returned
  97. */
  98. public static function getAppValue( $app, $key, $default = null ) {
  99. return \OC::$server->getConfig()->getAppValue( $app, $key, $default );
  100. }
  101. /**
  102. * Sets a value in the appconfig
  103. * @param string $app app
  104. * @param string $key key
  105. * @param string $value value
  106. * @return boolean true/false
  107. * @deprecated 8.0.0 use method setAppValue of \OCP\IConfig
  108. *
  109. * Sets a value. If the key did not exist before it will be created.
  110. */
  111. public static function setAppValue( $app, $key, $value ) {
  112. try {
  113. \OC::$server->getConfig()->setAppValue( $app, $key, $value );
  114. } catch (\Exception $e) {
  115. return false;
  116. }
  117. return true;
  118. }
  119. /**
  120. * Gets the preference
  121. * @param string $user user
  122. * @param string $app app
  123. * @param string $key key
  124. * @param string $default = null, default value if the key does not exist
  125. * @return string the value or $default
  126. * @deprecated 8.0.0 use method getUserValue of \OCP\IConfig
  127. *
  128. * This function gets a value from the preferences table. If the key does
  129. * not exist the default value will be returned
  130. */
  131. public static function getUserValue( $user, $app, $key, $default = null ) {
  132. return \OC::$server->getConfig()->getUserValue( $user, $app, $key, $default );
  133. }
  134. /**
  135. * Sets a value in the preferences
  136. * @param string $user user
  137. * @param string $app app
  138. * @param string $key key
  139. * @param string $value value
  140. * @return bool
  141. * @deprecated 8.0.0 use method setUserValue of \OCP\IConfig
  142. *
  143. * Adds a value to the preferences. If the key did not exist before, it
  144. * will be added automagically.
  145. */
  146. public static function setUserValue( $user, $app, $key, $value ) {
  147. try {
  148. \OC::$server->getConfig()->setUserValue( $user, $app, $key, $value );
  149. } catch (\Exception $e) {
  150. return false;
  151. }
  152. return true;
  153. }
  154. }