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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <?php
  2. /**
  3. * @author Bart Visscher <bartv@thisnet.nl>
  4. * @author Björn Schießle <schiessle@owncloud.com>
  5. * @author Clark Tomlinson <fallen013@gmail.com>
  6. * @author Guillaume AMAT <guillaume.amat@informatique-libre.com>
  7. * @author Hasso Tepper <hasso@zone.ee>
  8. * @author Joas Schilling <nickvergessen@owncloud.com>
  9. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  10. * @author Lukas Reschke <lukas@owncloud.com>
  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 Vincent Chan <plus.vincchan@gmail.com>
  16. * @author Vincent Petry <pvince81@owncloud.com>
  17. *
  18. * @copyright Copyright (c) 2016, 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. $countOfDataLocation = 0;
  59. $dataLocation = str_replace(OC::$SERVERROOT .'/', '', $config->getSystemValue('datadirectory', ''), $countOfDataLocation);
  60. if($countOfDataLocation !== 1 || !OC_User::isAdminUser(OC_User::getUser())){
  61. $dataLocation = false;
  62. }
  63. $array = array(
  64. "oc_debug" => $config->getSystemValue('debug', false) ? 'true' : 'false',
  65. "oc_isadmin" => OC_User::isAdminUser(OC_User::getUser()) ? 'true' : 'false',
  66. "oc_dataURL" => is_string($dataLocation) ? "\"".$dataLocation."\"" : 'false',
  67. "oc_webroot" => "\"".OC::$WEBROOT."\"",
  68. "oc_appswebroots" => str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution
  69. "datepickerFormatDate" => json_encode($l->l('jsdate', null)),
  70. "dayNames" => json_encode(
  71. array(
  72. (string)$l->t('Sunday'),
  73. (string)$l->t('Monday'),
  74. (string)$l->t('Tuesday'),
  75. (string)$l->t('Wednesday'),
  76. (string)$l->t('Thursday'),
  77. (string)$l->t('Friday'),
  78. (string)$l->t('Saturday')
  79. )
  80. ),
  81. "dayNamesShort" => json_encode(
  82. array(
  83. (string)$l->t('Sun.'),
  84. (string)$l->t('Mon.'),
  85. (string)$l->t('Tue.'),
  86. (string)$l->t('Wed.'),
  87. (string)$l->t('Thu.'),
  88. (string)$l->t('Fri.'),
  89. (string)$l->t('Sat.')
  90. )
  91. ),
  92. "dayNamesMin" => json_encode(
  93. array(
  94. (string)$l->t('Su'),
  95. (string)$l->t('Mo'),
  96. (string)$l->t('Tu'),
  97. (string)$l->t('We'),
  98. (string)$l->t('Th'),
  99. (string)$l->t('Fr'),
  100. (string)$l->t('Sa')
  101. )
  102. ),
  103. "monthNames" => json_encode(
  104. array(
  105. (string)$l->t('January'),
  106. (string)$l->t('February'),
  107. (string)$l->t('March'),
  108. (string)$l->t('April'),
  109. (string)$l->t('May'),
  110. (string)$l->t('June'),
  111. (string)$l->t('July'),
  112. (string)$l->t('August'),
  113. (string)$l->t('September'),
  114. (string)$l->t('October'),
  115. (string)$l->t('November'),
  116. (string)$l->t('December')
  117. )
  118. ),
  119. "monthNamesShort" => json_encode(
  120. array(
  121. (string)$l->t('Jan.'),
  122. (string)$l->t('Feb.'),
  123. (string)$l->t('Mar.'),
  124. (string)$l->t('Apr.'),
  125. (string)$l->t('May.'),
  126. (string)$l->t('Jun.'),
  127. (string)$l->t('Jul.'),
  128. (string)$l->t('Aug.'),
  129. (string)$l->t('Sep.'),
  130. (string)$l->t('Oct.'),
  131. (string)$l->t('Nov.'),
  132. (string)$l->t('Dec.')
  133. )
  134. ),
  135. "firstDay" => json_encode($l->l('firstday', null)) ,
  136. "oc_config" => json_encode(
  137. array(
  138. 'session_lifetime' => min(\OCP\Config::getSystemValue('session_lifetime', OC::$server->getIniWrapper()->getNumeric('session.gc_maxlifetime')), OC::$server->getIniWrapper()->getNumeric('session.gc_maxlifetime')),
  139. 'session_keepalive' => \OCP\Config::getSystemValue('session_keepalive', true),
  140. 'version' => implode('.', \OCP\Util::getVersion()),
  141. 'versionstring' => OC_Util::getVersionString(),
  142. 'enable_avatars' => \OC::$server->getConfig()->getSystemValue('enable_avatars', true) === true,
  143. 'lost_password_link'=> \OC::$server->getConfig()->getSystemValue('lost_password_link', null),
  144. 'modRewriteWorking' => (getenv('front_controller_active') === 'true'),
  145. )
  146. ),
  147. "oc_appconfig" => json_encode(
  148. array("core" => array(
  149. 'defaultExpireDateEnabled' => $defaultExpireDateEnabled,
  150. 'defaultExpireDate' => $defaultExpireDate,
  151. 'defaultExpireDateEnforced' => $enforceDefaultExpireDate,
  152. 'enforcePasswordForPublicLink' => \OCP\Util::isPublicLinkPasswordRequired(),
  153. 'sharingDisabledForUser' => \OCP\Util::isSharingDisabledForUser(),
  154. 'resharingAllowed' => \OCP\Share::isResharingAllowed(),
  155. 'remoteShareAllowed' => $outgoingServer2serverShareEnabled,
  156. 'federatedCloudShareDoc' => \OC::$server->getURLGenerator()->linkToDocs('user-sharing-federated'),
  157. 'allowGroupSharing' => \OC::$server->getShareManager()->allowGroupSharing()
  158. )
  159. )
  160. ),
  161. "oc_defaults" => json_encode(
  162. array(
  163. 'entity' => $defaults->getEntity(),
  164. 'name' => $defaults->getName(),
  165. 'title' => $defaults->getTitle(),
  166. 'baseUrl' => $defaults->getBaseUrl(),
  167. 'syncClientUrl' => $defaults->getSyncClientUrl(),
  168. 'docBaseUrl' => $defaults->getDocBaseUrl(),
  169. 'docPlaceholderUrl' => $defaults->buildDocLinkToKey('PLACEHOLDER'),
  170. 'slogan' => $defaults->getSlogan(),
  171. 'logoClaim' => $defaults->getLogoClaim(),
  172. 'shortFooter' => $defaults->getShortFooter(),
  173. 'longFooter' => $defaults->getLongFooter(),
  174. 'folder' => OC_Util::getTheme(),
  175. )
  176. )
  177. );
  178. // Allow hooks to modify the output values
  179. OC_Hook::emit('\OCP\Config', 'js', array('array' => &$array));
  180. // Echo it
  181. foreach ($array as $setting => $value) {
  182. echo("var ". $setting ."=".$value.";\n");
  183. }