1
0

config.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Frank Karlitschek
  6. * @copyright 2012 Frank Karlitschek frank@owncloud.org
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * Public interface of ownCloud for apps to use.
  24. * Config Class
  25. *
  26. */
  27. /**
  28. * Use OCP namespace for all classes that are considered public.
  29. *
  30. * Classes that use this namespace are for use by apps, and not for use by internal
  31. * OC classes
  32. */
  33. namespace OCP;
  34. /**
  35. * This class provides functions to read and write configuration data.
  36. * configuration can be on a system, application or user level
  37. * @deprecated use methods of \OCP\IConfig
  38. */
  39. class Config {
  40. /**
  41. * Gets a value from config.php
  42. * @param string $key key
  43. * @param mixed $default = null default value
  44. * @return mixed the value or $default
  45. * @deprecated use method getSystemValue of \OCP\IConfig
  46. *
  47. * This function gets the value from config.php. If it does not exist,
  48. * $default will be returned.
  49. */
  50. public static function getSystemValue( $key, $default = null ) {
  51. return \OC::$server->getConfig()->getSystemValue( $key, $default );
  52. }
  53. /**
  54. * Sets a value
  55. * @param string $key key
  56. * @param mixed $value value
  57. * @return bool
  58. * @deprecated use method setSystemValue of \OCP\IConfig
  59. *
  60. * This function sets the value and writes the config.php. If the file can
  61. * not be written, false will be returned.
  62. */
  63. public static function setSystemValue( $key, $value ) {
  64. try {
  65. \OC::$server->getConfig()->setSystemValue( $key, $value );
  66. } catch (\Exception $e) {
  67. return false;
  68. }
  69. return true;
  70. }
  71. /**
  72. * Deletes a value from config.php
  73. * @param string $key key
  74. * @deprecated use method deleteSystemValue of \OCP\IConfig
  75. *
  76. * This function deletes the value from config.php.
  77. */
  78. public static function deleteSystemValue( $key ) {
  79. \OC::$server->getConfig()->deleteSystemValue( $key );
  80. }
  81. /**
  82. * Gets the config value
  83. * @param string $app app
  84. * @param string $key key
  85. * @param string $default = null, default value if the key does not exist
  86. * @return string the value or $default
  87. * @deprecated use method getAppValue of \OCP\IConfig
  88. *
  89. * This function gets a value from the appconfig table. If the key does
  90. * not exist the default value will be returned
  91. */
  92. public static function getAppValue( $app, $key, $default = null ) {
  93. return \OC::$server->getConfig()->getAppValue( $app, $key, $default );
  94. }
  95. /**
  96. * Sets a value in the appconfig
  97. * @param string $app app
  98. * @param string $key key
  99. * @param string $value value
  100. * @return boolean true/false
  101. * @deprecated use method setAppValue of \OCP\IConfig
  102. *
  103. * Sets a value. If the key did not exist before it will be created.
  104. */
  105. public static function setAppValue( $app, $key, $value ) {
  106. try {
  107. \OC::$server->getConfig()->setAppValue( $app, $key, $value );
  108. } catch (\Exception $e) {
  109. return false;
  110. }
  111. return true;
  112. }
  113. /**
  114. * Gets the preference
  115. * @param string $user user
  116. * @param string $app app
  117. * @param string $key key
  118. * @param string $default = null, default value if the key does not exist
  119. * @return string the value or $default
  120. * @deprecated use method getUserValue of \OCP\IConfig
  121. *
  122. * This function gets a value from the preferences table. If the key does
  123. * not exist the default value will be returned
  124. */
  125. public static function getUserValue( $user, $app, $key, $default = null ) {
  126. return \OC::$server->getConfig()->getUserValue( $user, $app, $key, $default );
  127. }
  128. /**
  129. * Sets a value in the preferences
  130. * @param string $user user
  131. * @param string $app app
  132. * @param string $key key
  133. * @param string $value value
  134. * @return bool
  135. * @deprecated use method setUserValue of \OCP\IConfig
  136. *
  137. * Adds a value to the preferences. If the key did not exist before, it
  138. * will be added automagically.
  139. */
  140. public static function setUserValue( $user, $app, $key, $value ) {
  141. try {
  142. \OC::$server->getConfig()->setUserValue( $user, $app, $key, $value );
  143. } catch (\Exception $e) {
  144. return false;
  145. }
  146. return true;
  147. }
  148. }