config.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 Michael Gapczynski <GapczynskiM@gmail.com>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Robin McCorkell <rmccorkell@karoshi.org.uk>
  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. * This class is responsible for reading and writing config.php, the very basic
  29. * configuration file of ownCloud.
  30. *
  31. * @deprecated use \OC::$server->getConfig() to get an \OCP\Config instance
  32. */
  33. class OC_Config {
  34. /** @var \OC\Config */
  35. public static $object;
  36. /**
  37. * Lists all available config keys
  38. * @return array an array of key names
  39. *
  40. * This function returns all keys saved in config.php. Please note that it
  41. * does not return the values.
  42. */
  43. public static function getKeys() {
  44. return self::$object->getKeys();
  45. }
  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. *
  52. * This function gets the value from config.php. If it does not exist,
  53. * $default will be returned.
  54. */
  55. public static function getValue($key, $default = null) {
  56. return self::$object->getValue($key, $default);
  57. }
  58. /**
  59. * Sets a value
  60. * @param string $key key
  61. * @param mixed $value value
  62. *
  63. * This function sets the value and writes the config.php.
  64. *
  65. */
  66. public static function setValue($key, $value) {
  67. self::$object->setValue($key, $value);
  68. }
  69. /**
  70. * Sets and deletes values and writes the config.php
  71. *
  72. * @param array $configs Associative array with `key => value` pairs
  73. * If value is null, the config key will be deleted
  74. */
  75. public static function setValues(array $configs) {
  76. self::$object->setValues($configs);
  77. }
  78. /**
  79. * Removes a key from the config
  80. * @param string $key key
  81. *
  82. * This function removes a key from the config.php.
  83. */
  84. public static function deleteKey($key) {
  85. self::$object->deleteKey($key);
  86. }
  87. }