config.php 6.9 KB

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