config.php 3.6 KB

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