You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

config.php 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. $config = \OC::$server->getConfig();
  48. $value = $config->getAppValue('core', 'shareapi_default_expire_date', 'no');
  49. $defaultExpireDateEnabled = ($value === 'yes') ? true :false;
  50. $defaultExpireDate = $enforceDefaultExpireDate = null;
  51. if ($defaultExpireDateEnabled) {
  52. $defaultExpireDate = (int) $config->getAppValue('core', 'shareapi_expire_after_n_days', '7');
  53. $value = $config->getAppValue('core', 'shareapi_enforce_expire_date', 'no');
  54. $enforceDefaultExpireDate = ($value === 'yes') ? true : false;
  55. }
  56. $outgoingServer2serverShareEnabled = $config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes';
  57. $array = array(
  58. "oc_debug" => (defined('DEBUG') && DEBUG) ? 'true' : 'false',
  59. "oc_isadmin" => OC_User::isAdminUser(OC_User::getUser()) ? 'true' : 'false',
  60. "oc_webroot" => "\"".OC::$WEBROOT."\"",
  61. "oc_appswebroots" => str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution
  62. "datepickerFormatDate" => json_encode($l->getDateFormat()),
  63. "dayNames" => json_encode(
  64. array(
  65. (string)$l->t('Sunday'),
  66. (string)$l->t('Monday'),
  67. (string)$l->t('Tuesday'),
  68. (string)$l->t('Wednesday'),
  69. (string)$l->t('Thursday'),
  70. (string)$l->t('Friday'),
  71. (string)$l->t('Saturday')
  72. )
  73. ),
  74. "monthNames" => json_encode(
  75. array(
  76. (string)$l->t('January'),
  77. (string)$l->t('February'),
  78. (string)$l->t('March'),
  79. (string)$l->t('April'),
  80. (string)$l->t('May'),
  81. (string)$l->t('June'),
  82. (string)$l->t('July'),
  83. (string)$l->t('August'),
  84. (string)$l->t('September'),
  85. (string)$l->t('October'),
  86. (string)$l->t('November'),
  87. (string)$l->t('December')
  88. )
  89. ),
  90. "firstDay" => json_encode($l->getFirstWeekDay()) ,
  91. "oc_config" => json_encode(
  92. array(
  93. 'session_lifetime' => min(\OCP\Config::getSystemValue('session_lifetime', ini_get('session.gc_maxlifetime')), ini_get('session.gc_maxlifetime')),
  94. 'session_keepalive' => \OCP\Config::getSystemValue('session_keepalive', true),
  95. 'version' => implode('.', OC_Util::getVersion()),
  96. 'versionstring' => OC_Util::getVersionString(),
  97. 'enable_avatars' => \OC::$server->getConfig()->getSystemValue('enable_avatars', true),
  98. )
  99. ),
  100. "oc_appconfig" => json_encode(
  101. array("core" => array(
  102. 'defaultExpireDateEnabled' => $defaultExpireDateEnabled,
  103. 'defaultExpireDate' => $defaultExpireDate,
  104. 'defaultExpireDateEnforced' => $enforceDefaultExpireDate,
  105. 'enforcePasswordForPublicLink' => \OCP\Util::isPublicLinkPasswordRequired(),
  106. 'sharingDisabledForUser' => \OCP\Util::isSharingDisabledForUser(),
  107. 'resharingAllowed' => \OCP\Share::isResharingAllowed(),
  108. 'remoteShareAllowed' => $outgoingServer2serverShareEnabled,
  109. 'federatedCloudShareDoc' => \OC::$server->getURLGenerator()->linkToDocs('user-sharing-federated')
  110. )
  111. )
  112. ),
  113. "oc_defaults" => json_encode(
  114. array(
  115. 'entity' => $defaults->getEntity(),
  116. 'name' => $defaults->getName(),
  117. 'title' => $defaults->getTitle(),
  118. 'baseUrl' => $defaults->getBaseUrl(),
  119. 'syncClientUrl' => $defaults->getSyncClientUrl(),
  120. 'docBaseUrl' => $defaults->getDocBaseUrl(),
  121. 'slogan' => $defaults->getSlogan(),
  122. 'logoClaim' => $defaults->getLogoClaim(),
  123. 'shortFooter' => $defaults->getShortFooter(),
  124. 'longFooter' => $defaults->getLongFooter()
  125. )
  126. )
  127. );
  128. // Allow hooks to modify the output values
  129. OC_Hook::emit('\OCP\Config', 'js', array('array' => &$array));
  130. // Echo it
  131. foreach ($array as $setting => $value) {
  132. echo("var ". $setting ."=".$value.";\n");
  133. }