config.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. * @brief 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. configuration can be on a system, application or user level
  36. */
  37. class Config {
  38. /**
  39. * @brief Gets a value from config.php
  40. * @param string $key key
  41. * @param string $default = null default value
  42. * @return string the value or $default
  43. *
  44. * This function gets the value from config.php. If it does not exist,
  45. * $default will be returned.
  46. */
  47. public static function getSystemValue( $key, $default = null ) {
  48. return(\OC_Config::getValue( $key, $default ));
  49. }
  50. /**
  51. * @brief Sets a value
  52. * @param string $key key
  53. * @param string $value value
  54. * @return bool
  55. *
  56. * This function sets the value and writes the config.php. If the file can
  57. * not be written, false will be returned.
  58. */
  59. public static function setSystemValue( $key, $value ) {
  60. return(\OC_Config::setValue( $key, $value ));
  61. }
  62. /**
  63. * @brief Gets the config value
  64. * @param string $app app
  65. * @param string $key key
  66. * @param string $default = null, default value if the key does not exist
  67. * @return string the value or $default
  68. *
  69. * This function gets a value from the appconfig table. If the key does
  70. * not exist the default value will be returned
  71. */
  72. public static function getAppValue( $app, $key, $default = null ) {
  73. return(\OC_Appconfig::getValue( $app, $key, $default ));
  74. }
  75. /**
  76. * @brief sets a value in the appconfig
  77. * @param string $app app
  78. * @param string $key key
  79. * @param string $value value
  80. * @return string true/false
  81. *
  82. * Sets a value. If the key did not exist before it will be created.
  83. */
  84. public static function setAppValue( $app, $key, $value ) {
  85. return(\OC_Appconfig::setValue( $app, $key, $value ));
  86. }
  87. /**
  88. * @brief Gets the preference
  89. * @param string $user user
  90. * @param string $app app
  91. * @param string $key key
  92. * @param string $default = null, default value if the key does not exist
  93. * @return string the value or $default
  94. *
  95. * This function gets a value from the preferences table. If the key does
  96. * not exist the default value will be returned
  97. */
  98. public static function getUserValue( $user, $app, $key, $default = null ) {
  99. return(\OC_Preferences::getValue( $user, $app, $key, $default ));
  100. }
  101. /**
  102. * @brief sets a value in the preferences
  103. * @param string $user user
  104. * @param string $app app
  105. * @param string $key key
  106. * @param string $value value
  107. * @returns bool
  108. *
  109. * Adds a value to the preferences. If the key did not exist before, it
  110. * will be added automagically.
  111. */
  112. public static function setUserValue( $user, $app, $key, $value ) {
  113. return(\OC_Preferences::setValue( $user, $app, $key, $value ));
  114. }
  115. }