1
0

config.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. /**
  3. * @author Bart Visscher <bartv@thisnet.nl>
  4. * @author Björn Schießle <schiessle@owncloud.com>
  5. * @author Guillaume AMAT <guillaume.amat@informatique-libre.com>
  6. * @author Joas Schilling <nickvergessen@owncloud.com>
  7. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  8. * @author Lukas Reschke <lukas@owncloud.com>
  9. * @author Matthias Rieber <matthias@zu-con.org>
  10. * @author Morris Jobke <hey@morrisjobke.de>
  11. * @author Owen Winkler <a_github@midnightcircus.com>
  12. * @author Robin Appelman <icewind@owncloud.com>
  13. * @author Roeland Jago Douma <roeland@famdouma.nl>
  14. * @author Thomas Müller <thomas.mueller@tmit.eu>
  15. * @author Vincent Petry <pvince81@owncloud.com>
  16. *
  17. * @copyright Copyright (c) 2015, ownCloud, Inc.
  18. * @license AGPL-3.0
  19. *
  20. * This code is free software: you can redistribute it and/or modify
  21. * it under the terms of the GNU Affero General Public License, version 3,
  22. * as published by the Free Software Foundation.
  23. *
  24. * This program is distributed in the hope that it will be useful,
  25. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. * GNU Affero General Public License for more details.
  28. *
  29. * You should have received a copy of the GNU Affero General Public License, version 3,
  30. * along with this program. If not, see <http://www.gnu.org/licenses/>
  31. *
  32. */
  33. // Set the content type to Javascript
  34. header("Content-type: text/javascript");
  35. // Disallow caching
  36. header("Cache-Control: no-cache, must-revalidate");
  37. header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
  38. // Enable l10n support
  39. $l = \OC::$server->getL10N('core');
  40. // Enable OC_Defaults support
  41. $defaults = new OC_Defaults();
  42. // Get the config
  43. $apps_paths = array();
  44. foreach(OC_App::getEnabledApps() as $app) {
  45. $apps_paths[$app] = OC_App::getAppWebPath($app);
  46. }
  47. $value = \OCP\Config::getAppValue('core', 'shareapi_default_expire_date', 'no');
  48. $defaultExpireDateEnabled = ($value === 'yes') ? true :false;
  49. $defaultExpireDate = $enforceDefaultExpireDate = null;
  50. if ($defaultExpireDateEnabled) {
  51. $defaultExpireDate = (int)\OCP\Config::getAppValue('core', 'shareapi_expire_after_n_days', '7');
  52. $value = \OCP\Config::getAppValue('core', 'shareapi_enforce_expire_date', 'no');
  53. $enforceDefaultExpireDate = ($value === 'yes') ? true : false;
  54. }
  55. $array = array(
  56. "oc_debug" => (defined('DEBUG') && DEBUG) ? 'true' : 'false',
  57. "oc_isadmin" => OC_User::isAdminUser(OC_User::getUser()) ? 'true' : 'false',
  58. "oc_webroot" => "\"".OC::$WEBROOT."\"",
  59. "oc_appswebroots" => str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution
  60. "datepickerFormatDate" => json_encode($l->getDateFormat()),
  61. "dayNames" => json_encode(
  62. array(
  63. (string)$l->t('Sunday'),
  64. (string)$l->t('Monday'),
  65. (string)$l->t('Tuesday'),
  66. (string)$l->t('Wednesday'),
  67. (string)$l->t('Thursday'),
  68. (string)$l->t('Friday'),
  69. (string)$l->t('Saturday')
  70. )
  71. ),
  72. "monthNames" => json_encode(
  73. array(
  74. (string)$l->t('January'),
  75. (string)$l->t('February'),
  76. (string)$l->t('March'),
  77. (string)$l->t('April'),
  78. (string)$l->t('May'),
  79. (string)$l->t('June'),
  80. (string)$l->t('July'),
  81. (string)$l->t('August'),
  82. (string)$l->t('September'),
  83. (string)$l->t('October'),
  84. (string)$l->t('November'),
  85. (string)$l->t('December')
  86. )
  87. ),
  88. "firstDay" => json_encode($l->getFirstWeekDay()) ,
  89. "oc_config" => json_encode(
  90. array(
  91. 'session_lifetime' => min(\OCP\Config::getSystemValue('session_lifetime', ini_get('session.gc_maxlifetime')), ini_get('session.gc_maxlifetime')),
  92. 'session_keepalive' => \OCP\Config::getSystemValue('session_keepalive', true),
  93. 'version' => implode('.', OC_Util::getVersion()),
  94. 'versionstring' => OC_Util::getVersionString(),
  95. 'enable_avatars' => \OC::$server->getConfig()->getSystemValue('enable_avatars', true),
  96. )
  97. ),
  98. "oc_appconfig" => json_encode(
  99. array("core" => array(
  100. 'defaultExpireDateEnabled' => $defaultExpireDateEnabled,
  101. 'defaultExpireDate' => $defaultExpireDate,
  102. 'defaultExpireDateEnforced' => $enforceDefaultExpireDate,
  103. 'enforcePasswordForPublicLink' => \OCP\Util::isPublicLinkPasswordRequired(),
  104. 'sharingDisabledForUser' => \OCP\Util::isSharingDisabledForUser(),
  105. 'resharingAllowed' => \OCP\Share::isResharingAllowed(),
  106. )
  107. )
  108. ),
  109. "oc_defaults" => json_encode(
  110. array(
  111. 'entity' => $defaults->getEntity(),
  112. 'name' => $defaults->getName(),
  113. 'title' => $defaults->getTitle(),
  114. 'baseUrl' => $defaults->getBaseUrl(),
  115. 'syncClientUrl' => $defaults->getSyncClientUrl(),
  116. 'docBaseUrl' => $defaults->getDocBaseUrl(),
  117. 'slogan' => $defaults->getSlogan(),
  118. 'logoClaim' => $defaults->getLogoClaim(),
  119. 'shortFooter' => $defaults->getShortFooter(),
  120. 'longFooter' => $defaults->getLongFooter()
  121. )
  122. )
  123. );
  124. // Allow hooks to modify the output values
  125. OC_Hook::emit('\OCP\Config', 'js', array('array' => &$array));
  126. // Echo it
  127. foreach ($array as $setting => $value) {
  128. echo("var ". $setting ."=".$value.";\n");
  129. }