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 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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 Hasso Tepper <hasso@zone.ee>
  7. * @author Joas Schilling <nickvergessen@owncloud.com>
  8. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  9. * @author Lukas Reschke <lukas@owncloud.com>
  10. * @author Matthias Rieber <matthias@zu-con.org>
  11. * @author Morris Jobke <hey@morrisjobke.de>
  12. * @author Owen Winkler <a_github@midnightcircus.com>
  13. * @author Robin Appelman <icewind@owncloud.com>
  14. * @author Roeland Jago Douma <rullzer@owncloud.com>
  15. * @author Thomas Müller <thomas.mueller@tmit.eu>
  16. * @author Vincent Petry <pvince81@owncloud.com>
  17. *
  18. * @copyright Copyright (c) 2015, ownCloud, Inc.
  19. * @license AGPL-3.0
  20. *
  21. * This code is free software: you can redistribute it and/or modify
  22. * it under the terms of the GNU Affero General Public License, version 3,
  23. * as published by the Free Software Foundation.
  24. *
  25. * This program is distributed in the hope that it will be useful,
  26. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28. * GNU Affero General Public License for more details.
  29. *
  30. * You should have received a copy of the GNU Affero General Public License, version 3,
  31. * along with this program. If not, see <http://www.gnu.org/licenses/>
  32. *
  33. */
  34. // Set the content type to Javascript
  35. header("Content-type: text/javascript");
  36. // Disallow caching
  37. header("Cache-Control: no-cache, must-revalidate");
  38. header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
  39. // Enable l10n support
  40. $l = \OC::$server->getL10N('core');
  41. // Enable OC_Defaults support
  42. $defaults = new OC_Defaults();
  43. // Get the config
  44. $apps_paths = array();
  45. foreach(OC_App::getEnabledApps() as $app) {
  46. $apps_paths[$app] = OC_App::getAppWebPath($app);
  47. }
  48. $config = \OC::$server->getConfig();
  49. $value = $config->getAppValue('core', 'shareapi_default_expire_date', 'no');
  50. $defaultExpireDateEnabled = ($value === 'yes') ? true :false;
  51. $defaultExpireDate = $enforceDefaultExpireDate = null;
  52. if ($defaultExpireDateEnabled) {
  53. $defaultExpireDate = (int) $config->getAppValue('core', 'shareapi_expire_after_n_days', '7');
  54. $value = $config->getAppValue('core', 'shareapi_enforce_expire_date', 'no');
  55. $enforceDefaultExpireDate = ($value === 'yes') ? true : false;
  56. }
  57. $outgoingServer2serverShareEnabled = $config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes';
  58. $array = array(
  59. "oc_debug" => $config->getSystemValue('debug', false) ? 'true' : 'false',
  60. "oc_isadmin" => OC_User::isAdminUser(OC_User::getUser()) ? 'true' : 'false',
  61. "oc_webroot" => "\"".OC::$WEBROOT."\"",
  62. "oc_appswebroots" => str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution
  63. "datepickerFormatDate" => json_encode($l->getDateFormat()),
  64. "dayNames" => json_encode(
  65. array(
  66. (string)$l->t('Sunday'),
  67. (string)$l->t('Monday'),
  68. (string)$l->t('Tuesday'),
  69. (string)$l->t('Wednesday'),
  70. (string)$l->t('Thursday'),
  71. (string)$l->t('Friday'),
  72. (string)$l->t('Saturday')
  73. )
  74. ),
  75. "dayNamesShort" => json_encode(
  76. array(
  77. (string)$l->t('Sun.'),
  78. (string)$l->t('Mon.'),
  79. (string)$l->t('Tue.'),
  80. (string)$l->t('Wed.'),
  81. (string)$l->t('Thu.'),
  82. (string)$l->t('Fri.'),
  83. (string)$l->t('Sat.')
  84. )
  85. ),
  86. "dayNamesMin" => json_encode(
  87. array(
  88. (string)$l->t('Su'),
  89. (string)$l->t('Mo'),
  90. (string)$l->t('Tu'),
  91. (string)$l->t('We'),
  92. (string)$l->t('Th'),
  93. (string)$l->t('Fr'),
  94. (string)$l->t('Sa')
  95. )
  96. ),
  97. "monthNames" => json_encode(
  98. array(
  99. (string)$l->t('January'),
  100. (string)$l->t('February'),
  101. (string)$l->t('March'),
  102. (string)$l->t('April'),
  103. (string)$l->t('May'),
  104. (string)$l->t('June'),
  105. (string)$l->t('July'),
  106. (string)$l->t('August'),
  107. (string)$l->t('September'),
  108. (string)$l->t('October'),
  109. (string)$l->t('November'),
  110. (string)$l->t('December')
  111. )
  112. ),
  113. "monthNamesShort" => json_encode(
  114. array(
  115. (string)$l->t('Jan.'),
  116. (string)$l->t('Feb.'),
  117. (string)$l->t('Mar.'),
  118. (string)$l->t('Apr.'),
  119. (string)$l->t('May.'),
  120. (string)$l->t('Jun.'),
  121. (string)$l->t('Jul.'),
  122. (string)$l->t('Aug.'),
  123. (string)$l->t('Sep.'),
  124. (string)$l->t('Oct.'),
  125. (string)$l->t('Nov.'),
  126. (string)$l->t('Dec.')
  127. )
  128. ),
  129. "firstDay" => json_encode($l->getFirstWeekDay()) ,
  130. "oc_config" => json_encode(
  131. array(
  132. 'session_lifetime' => min(\OCP\Config::getSystemValue('session_lifetime', OC::$server->getIniWrapper()->getNumeric('session.gc_maxlifetime')), OC::$server->getIniWrapper()->getNumeric('session.gc_maxlifetime')),
  133. 'session_keepalive' => \OCP\Config::getSystemValue('session_keepalive', true),
  134. 'version' => implode('.', \OCP\Util::getVersion()),
  135. 'versionstring' => OC_Util::getVersionString(),
  136. 'enable_avatars' => \OC::$server->getConfig()->getSystemValue('enable_avatars', true),
  137. 'lost_password_link'=> \OC::$server->getConfig()->getSystemValue('lost_password_link', null),
  138. 'modRewriteWorking' => (getenv('front_controller_active') === 'true'),
  139. )
  140. ),
  141. "oc_appconfig" => json_encode(
  142. array("core" => array(
  143. 'defaultExpireDateEnabled' => $defaultExpireDateEnabled,
  144. 'defaultExpireDate' => $defaultExpireDate,
  145. 'defaultExpireDateEnforced' => $enforceDefaultExpireDate,
  146. 'enforcePasswordForPublicLink' => \OCP\Util::isPublicLinkPasswordRequired(),
  147. 'sharingDisabledForUser' => \OCP\Util::isSharingDisabledForUser(),
  148. 'resharingAllowed' => \OCP\Share::isResharingAllowed(),
  149. 'remoteShareAllowed' => $outgoingServer2serverShareEnabled,
  150. 'federatedCloudShareDoc' => \OC::$server->getURLGenerator()->linkToDocs('user-sharing-federated')
  151. )
  152. )
  153. ),
  154. "oc_defaults" => json_encode(
  155. array(
  156. 'entity' => $defaults->getEntity(),
  157. 'name' => $defaults->getName(),
  158. 'title' => $defaults->getTitle(),
  159. 'baseUrl' => $defaults->getBaseUrl(),
  160. 'syncClientUrl' => $defaults->getSyncClientUrl(),
  161. 'docBaseUrl' => $defaults->getDocBaseUrl(),
  162. 'slogan' => $defaults->getSlogan(),
  163. 'logoClaim' => $defaults->getLogoClaim(),
  164. 'shortFooter' => $defaults->getShortFooter(),
  165. 'longFooter' => $defaults->getLongFooter(),
  166. 'folder' => OC_Util::getTheme(),
  167. )
  168. )
  169. );
  170. // Allow hooks to modify the output values
  171. OC_Hook::emit('\OCP\Config', 'js', array('array' => &$array));
  172. // Echo it
  173. foreach ($array as $setting => $value) {
  174. echo("var ". $setting ."=".$value.";\n");
  175. }