@@ -47,286 +47,286 @@ |
||
| 47 | 47 | |
| 48 | 48 | class JSConfigHelper { |
| 49 | 49 | |
| 50 | - /** @var IL10N */ |
|
| 51 | - private $l; |
|
| 52 | - |
|
| 53 | - /** @var Defaults */ |
|
| 54 | - private $defaults; |
|
| 55 | - |
|
| 56 | - /** @var IAppManager */ |
|
| 57 | - private $appManager; |
|
| 58 | - |
|
| 59 | - /** @var ISession */ |
|
| 60 | - private $session; |
|
| 61 | - |
|
| 62 | - /** @var IUser|null */ |
|
| 63 | - private $currentUser; |
|
| 64 | - |
|
| 65 | - /** @var IConfig */ |
|
| 66 | - private $config; |
|
| 67 | - |
|
| 68 | - /** @var IGroupManager */ |
|
| 69 | - private $groupManager; |
|
| 70 | - |
|
| 71 | - /** @var IniGetWrapper */ |
|
| 72 | - private $iniWrapper; |
|
| 73 | - |
|
| 74 | - /** @var IURLGenerator */ |
|
| 75 | - private $urlGenerator; |
|
| 76 | - |
|
| 77 | - /** @var CapabilitiesManager */ |
|
| 78 | - private $capabilitiesManager; |
|
| 79 | - |
|
| 80 | - /** @var IInitialStateService */ |
|
| 81 | - private $initialStateService; |
|
| 82 | - |
|
| 83 | - /** @var array user back-ends excluded from password verification */ |
|
| 84 | - private $excludedUserBackEnds = ['user_saml' => true, 'user_globalsiteselector' => true]; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * @param IL10N $l |
|
| 88 | - * @param Defaults $defaults |
|
| 89 | - * @param IAppManager $appManager |
|
| 90 | - * @param ISession $session |
|
| 91 | - * @param IUser|null $currentUser |
|
| 92 | - * @param IConfig $config |
|
| 93 | - * @param IGroupManager $groupManager |
|
| 94 | - * @param IniGetWrapper $iniWrapper |
|
| 95 | - * @param IURLGenerator $urlGenerator |
|
| 96 | - * @param CapabilitiesManager $capabilitiesManager |
|
| 97 | - */ |
|
| 98 | - public function __construct(IL10N $l, |
|
| 99 | - Defaults $defaults, |
|
| 100 | - IAppManager $appManager, |
|
| 101 | - ISession $session, |
|
| 102 | - $currentUser, |
|
| 103 | - IConfig $config, |
|
| 104 | - IGroupManager $groupManager, |
|
| 105 | - IniGetWrapper $iniWrapper, |
|
| 106 | - IURLGenerator $urlGenerator, |
|
| 107 | - CapabilitiesManager $capabilitiesManager, |
|
| 108 | - IInitialStateService $initialStateService) { |
|
| 109 | - $this->l = $l; |
|
| 110 | - $this->defaults = $defaults; |
|
| 111 | - $this->appManager = $appManager; |
|
| 112 | - $this->session = $session; |
|
| 113 | - $this->currentUser = $currentUser; |
|
| 114 | - $this->config = $config; |
|
| 115 | - $this->groupManager = $groupManager; |
|
| 116 | - $this->iniWrapper = $iniWrapper; |
|
| 117 | - $this->urlGenerator = $urlGenerator; |
|
| 118 | - $this->capabilitiesManager = $capabilitiesManager; |
|
| 119 | - $this->initialStateService = $initialStateService; |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - public function getConfig() { |
|
| 123 | - $userBackendAllowsPasswordConfirmation = true; |
|
| 124 | - if ($this->currentUser !== null) { |
|
| 125 | - $uid = $this->currentUser->getUID(); |
|
| 126 | - |
|
| 127 | - $backend = $this->currentUser->getBackend(); |
|
| 128 | - if ($backend instanceof IPasswordConfirmationBackend) { |
|
| 129 | - $userBackendAllowsPasswordConfirmation = $backend->canConfirmPassword($uid); |
|
| 130 | - } elseif (isset($this->excludedUserBackEnds[$this->currentUser->getBackendClassName()])) { |
|
| 131 | - $userBackendAllowsPasswordConfirmation = false; |
|
| 132 | - } |
|
| 133 | - } else { |
|
| 134 | - $uid = null; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - // Get the config |
|
| 138 | - $apps_paths = []; |
|
| 139 | - |
|
| 140 | - if ($this->currentUser === null) { |
|
| 141 | - $apps = $this->appManager->getInstalledApps(); |
|
| 142 | - } else { |
|
| 143 | - $apps = $this->appManager->getEnabledAppsForUser($this->currentUser); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - foreach ($apps as $app) { |
|
| 147 | - $apps_paths[$app] = \OC_App::getAppWebPath($app); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - |
|
| 151 | - $enableLinkPasswordByDefault = $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'); |
|
| 152 | - $enableLinkPasswordByDefault = $enableLinkPasswordByDefault === 'yes'; |
|
| 153 | - $defaultExpireDateEnabled = $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no') === 'yes'; |
|
| 154 | - $defaultExpireDate = $enforceDefaultExpireDate = null; |
|
| 155 | - if ($defaultExpireDateEnabled) { |
|
| 156 | - $defaultExpireDate = (int)$this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'); |
|
| 157 | - $enforceDefaultExpireDate = $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no') === 'yes'; |
|
| 158 | - } |
|
| 159 | - $outgoingServer2serverShareEnabled = $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes'; |
|
| 160 | - |
|
| 161 | - $defaultInternalExpireDateEnabled = $this->config->getAppValue('core', 'shareapi_default_internal_expire_date', 'no') === 'yes'; |
|
| 162 | - $defaultInternalExpireDate = $defaultInternalExpireDateEnforced = null; |
|
| 163 | - if ($defaultInternalExpireDateEnabled) { |
|
| 164 | - $defaultInternalExpireDate = (int)$this->config->getAppValue('core', 'shareapi_internal_expire_after_n_days', '7'); |
|
| 165 | - $defaultInternalExpireDateEnforced = $this->config->getAppValue('core', 'shareapi_enforce_internal_expire_date', 'no') === 'yes'; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - $defaultRemoteExpireDateEnabled = $this->config->getAppValue('core', 'shareapi_default_remote_expire_date', 'no') === 'yes'; |
|
| 169 | - $defaultRemoteExpireDate = $defaultRemoteExpireDateEnforced = null; |
|
| 170 | - if ($defaultRemoteExpireDateEnabled) { |
|
| 171 | - $defaultRemoteExpireDate = (int)$this->config->getAppValue('core', 'shareapi_remote_expire_after_n_days', '7'); |
|
| 172 | - $defaultRemoteExpireDateEnforced = $this->config->getAppValue('core', 'shareapi_enforce_remote_expire_date', 'no') === 'yes'; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - $countOfDataLocation = 0; |
|
| 176 | - $dataLocation = str_replace(\OC::$SERVERROOT . '/', '', $this->config->getSystemValue('datadirectory', ''), $countOfDataLocation); |
|
| 177 | - if ($countOfDataLocation !== 1 || $uid === null || !$this->groupManager->isAdmin($uid)) { |
|
| 178 | - $dataLocation = false; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - if ($this->currentUser instanceof IUser) { |
|
| 182 | - $lastConfirmTimestamp = $this->session->get('last-password-confirm'); |
|
| 183 | - if (!is_int($lastConfirmTimestamp)) { |
|
| 184 | - $lastConfirmTimestamp = 0; |
|
| 185 | - } |
|
| 186 | - } else { |
|
| 187 | - $lastConfirmTimestamp = 0; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - $capabilities = $this->capabilitiesManager->getCapabilities(); |
|
| 191 | - |
|
| 192 | - $config = [ |
|
| 193 | - 'session_lifetime' => min($this->config->getSystemValue('session_lifetime', $this->iniWrapper->getNumeric('session.gc_maxlifetime')), $this->iniWrapper->getNumeric('session.gc_maxlifetime')), |
|
| 194 | - 'session_keepalive' => $this->config->getSystemValue('session_keepalive', true), |
|
| 195 | - 'auto_logout' => $this->config->getSystemValue('auto_logout', false), |
|
| 196 | - 'version' => implode('.', \OCP\Util::getVersion()), |
|
| 197 | - 'versionstring' => \OC_Util::getVersionString(), |
|
| 198 | - 'enable_avatars' => true, // here for legacy reasons - to not crash existing code that relies on this value |
|
| 199 | - 'lost_password_link' => $this->config->getSystemValue('lost_password_link', null), |
|
| 200 | - 'modRewriteWorking' => $this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true', |
|
| 201 | - 'sharing.maxAutocompleteResults' => max(0, $this->config->getSystemValueInt('sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT)), |
|
| 202 | - 'sharing.minSearchStringLength' => $this->config->getSystemValueInt('sharing.minSearchStringLength', 0), |
|
| 203 | - 'blacklist_files_regex' => \OCP\Files\FileInfo::BLACKLIST_FILES_REGEX, |
|
| 204 | - ]; |
|
| 205 | - |
|
| 206 | - $array = [ |
|
| 207 | - "_oc_debug" => $this->config->getSystemValue('debug', false) ? 'true' : 'false', |
|
| 208 | - "_oc_isadmin" => $uid !== null && $this->groupManager->isAdmin($uid) ? 'true' : 'false', |
|
| 209 | - "backendAllowsPasswordConfirmation" => $userBackendAllowsPasswordConfirmation ? 'true' : 'false', |
|
| 210 | - "oc_dataURL" => is_string($dataLocation) ? "\"" . $dataLocation . "\"" : 'false', |
|
| 211 | - "_oc_webroot" => "\"" . \OC::$WEBROOT . "\"", |
|
| 212 | - "_oc_appswebroots" => str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution |
|
| 213 | - "datepickerFormatDate" => json_encode($this->l->l('jsdate', null)), |
|
| 214 | - 'nc_lastLogin' => $lastConfirmTimestamp, |
|
| 215 | - 'nc_pageLoad' => time(), |
|
| 216 | - "dayNames" => json_encode([ |
|
| 217 | - $this->l->t('Sunday'), |
|
| 218 | - $this->l->t('Monday'), |
|
| 219 | - $this->l->t('Tuesday'), |
|
| 220 | - $this->l->t('Wednesday'), |
|
| 221 | - $this->l->t('Thursday'), |
|
| 222 | - $this->l->t('Friday'), |
|
| 223 | - $this->l->t('Saturday') |
|
| 224 | - ]), |
|
| 225 | - "dayNamesShort" => json_encode([ |
|
| 226 | - $this->l->t('Sun.'), |
|
| 227 | - $this->l->t('Mon.'), |
|
| 228 | - $this->l->t('Tue.'), |
|
| 229 | - $this->l->t('Wed.'), |
|
| 230 | - $this->l->t('Thu.'), |
|
| 231 | - $this->l->t('Fri.'), |
|
| 232 | - $this->l->t('Sat.') |
|
| 233 | - ]), |
|
| 234 | - "dayNamesMin" => json_encode([ |
|
| 235 | - $this->l->t('Su'), |
|
| 236 | - $this->l->t('Mo'), |
|
| 237 | - $this->l->t('Tu'), |
|
| 238 | - $this->l->t('We'), |
|
| 239 | - $this->l->t('Th'), |
|
| 240 | - $this->l->t('Fr'), |
|
| 241 | - $this->l->t('Sa') |
|
| 242 | - ]), |
|
| 243 | - "monthNames" => json_encode([ |
|
| 244 | - $this->l->t('January'), |
|
| 245 | - $this->l->t('February'), |
|
| 246 | - $this->l->t('March'), |
|
| 247 | - $this->l->t('April'), |
|
| 248 | - $this->l->t('May'), |
|
| 249 | - $this->l->t('June'), |
|
| 250 | - $this->l->t('July'), |
|
| 251 | - $this->l->t('August'), |
|
| 252 | - $this->l->t('September'), |
|
| 253 | - $this->l->t('October'), |
|
| 254 | - $this->l->t('November'), |
|
| 255 | - $this->l->t('December') |
|
| 256 | - ]), |
|
| 257 | - "monthNamesShort" => json_encode([ |
|
| 258 | - $this->l->t('Jan.'), |
|
| 259 | - $this->l->t('Feb.'), |
|
| 260 | - $this->l->t('Mar.'), |
|
| 261 | - $this->l->t('Apr.'), |
|
| 262 | - $this->l->t('May.'), |
|
| 263 | - $this->l->t('Jun.'), |
|
| 264 | - $this->l->t('Jul.'), |
|
| 265 | - $this->l->t('Aug.'), |
|
| 266 | - $this->l->t('Sep.'), |
|
| 267 | - $this->l->t('Oct.'), |
|
| 268 | - $this->l->t('Nov.'), |
|
| 269 | - $this->l->t('Dec.') |
|
| 270 | - ]), |
|
| 271 | - "firstDay" => json_encode($this->l->l('firstday', null)), |
|
| 272 | - "_oc_config" => json_encode($config), |
|
| 273 | - "oc_appconfig" => json_encode([ |
|
| 274 | - 'core' => [ |
|
| 275 | - 'defaultExpireDateEnabled' => $defaultExpireDateEnabled, |
|
| 276 | - 'defaultExpireDate' => $defaultExpireDate, |
|
| 277 | - 'defaultExpireDateEnforced' => $enforceDefaultExpireDate, |
|
| 278 | - 'enforcePasswordForPublicLink' => \OCP\Util::isPublicLinkPasswordRequired(), |
|
| 279 | - 'enableLinkPasswordByDefault' => $enableLinkPasswordByDefault, |
|
| 280 | - 'sharingDisabledForUser' => \OCP\Util::isSharingDisabledForUser(), |
|
| 281 | - 'resharingAllowed' => \OC\Share\Share::isResharingAllowed(), |
|
| 282 | - 'remoteShareAllowed' => $outgoingServer2serverShareEnabled, |
|
| 283 | - 'federatedCloudShareDoc' => $this->urlGenerator->linkToDocs('user-sharing-federated'), |
|
| 284 | - 'allowGroupSharing' => \OC::$server->getShareManager()->allowGroupSharing(), |
|
| 285 | - 'defaultInternalExpireDateEnabled' => $defaultInternalExpireDateEnabled, |
|
| 286 | - 'defaultInternalExpireDate' => $defaultInternalExpireDate, |
|
| 287 | - 'defaultInternalExpireDateEnforced' => $defaultInternalExpireDateEnforced, |
|
| 288 | - 'defaultRemoteExpireDateEnabled' => $defaultRemoteExpireDateEnabled, |
|
| 289 | - 'defaultRemoteExpireDate' => $defaultRemoteExpireDate, |
|
| 290 | - 'defaultRemoteExpireDateEnforced' => $defaultRemoteExpireDateEnforced, |
|
| 291 | - ] |
|
| 292 | - ]), |
|
| 293 | - "_theme" => json_encode([ |
|
| 294 | - 'entity' => $this->defaults->getEntity(), |
|
| 295 | - 'name' => $this->defaults->getName(), |
|
| 296 | - 'productName' => $this->defaults->getProductName(), |
|
| 297 | - 'title' => $this->defaults->getTitle(), |
|
| 298 | - 'baseUrl' => $this->defaults->getBaseUrl(), |
|
| 299 | - 'syncClientUrl' => $this->defaults->getSyncClientUrl(), |
|
| 300 | - 'docBaseUrl' => $this->defaults->getDocBaseUrl(), |
|
| 301 | - 'docPlaceholderUrl' => $this->defaults->buildDocLinkToKey('PLACEHOLDER'), |
|
| 302 | - 'slogan' => $this->defaults->getSlogan(), |
|
| 303 | - 'logoClaim' => '', |
|
| 304 | - 'folder' => \OC_Util::getTheme(), |
|
| 305 | - ]), |
|
| 306 | - ]; |
|
| 307 | - |
|
| 308 | - if ($this->currentUser !== null) { |
|
| 309 | - $array['oc_userconfig'] = json_encode([ |
|
| 310 | - 'avatar' => [ |
|
| 311 | - 'version' => (int)$this->config->getUserValue($uid, 'avatar', 'version', 0), |
|
| 312 | - 'generated' => $this->config->getUserValue($uid, 'avatar', 'generated', 'true') === 'true', |
|
| 313 | - ] |
|
| 314 | - ]); |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - $this->initialStateService->provideInitialState('core', 'config', $config); |
|
| 318 | - $this->initialStateService->provideInitialState('core', 'capabilities', $capabilities); |
|
| 319 | - |
|
| 320 | - // Allow hooks to modify the output values |
|
| 321 | - \OC_Hook::emit('\OCP\Config', 'js', ['array' => &$array]); |
|
| 322 | - |
|
| 323 | - $result = ''; |
|
| 324 | - |
|
| 325 | - // Echo it |
|
| 326 | - foreach ($array as $setting => $value) { |
|
| 327 | - $result .= 'var '. $setting . '='. $value . ';' . PHP_EOL; |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - return $result; |
|
| 331 | - } |
|
| 50 | + /** @var IL10N */ |
|
| 51 | + private $l; |
|
| 52 | + |
|
| 53 | + /** @var Defaults */ |
|
| 54 | + private $defaults; |
|
| 55 | + |
|
| 56 | + /** @var IAppManager */ |
|
| 57 | + private $appManager; |
|
| 58 | + |
|
| 59 | + /** @var ISession */ |
|
| 60 | + private $session; |
|
| 61 | + |
|
| 62 | + /** @var IUser|null */ |
|
| 63 | + private $currentUser; |
|
| 64 | + |
|
| 65 | + /** @var IConfig */ |
|
| 66 | + private $config; |
|
| 67 | + |
|
| 68 | + /** @var IGroupManager */ |
|
| 69 | + private $groupManager; |
|
| 70 | + |
|
| 71 | + /** @var IniGetWrapper */ |
|
| 72 | + private $iniWrapper; |
|
| 73 | + |
|
| 74 | + /** @var IURLGenerator */ |
|
| 75 | + private $urlGenerator; |
|
| 76 | + |
|
| 77 | + /** @var CapabilitiesManager */ |
|
| 78 | + private $capabilitiesManager; |
|
| 79 | + |
|
| 80 | + /** @var IInitialStateService */ |
|
| 81 | + private $initialStateService; |
|
| 82 | + |
|
| 83 | + /** @var array user back-ends excluded from password verification */ |
|
| 84 | + private $excludedUserBackEnds = ['user_saml' => true, 'user_globalsiteselector' => true]; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * @param IL10N $l |
|
| 88 | + * @param Defaults $defaults |
|
| 89 | + * @param IAppManager $appManager |
|
| 90 | + * @param ISession $session |
|
| 91 | + * @param IUser|null $currentUser |
|
| 92 | + * @param IConfig $config |
|
| 93 | + * @param IGroupManager $groupManager |
|
| 94 | + * @param IniGetWrapper $iniWrapper |
|
| 95 | + * @param IURLGenerator $urlGenerator |
|
| 96 | + * @param CapabilitiesManager $capabilitiesManager |
|
| 97 | + */ |
|
| 98 | + public function __construct(IL10N $l, |
|
| 99 | + Defaults $defaults, |
|
| 100 | + IAppManager $appManager, |
|
| 101 | + ISession $session, |
|
| 102 | + $currentUser, |
|
| 103 | + IConfig $config, |
|
| 104 | + IGroupManager $groupManager, |
|
| 105 | + IniGetWrapper $iniWrapper, |
|
| 106 | + IURLGenerator $urlGenerator, |
|
| 107 | + CapabilitiesManager $capabilitiesManager, |
|
| 108 | + IInitialStateService $initialStateService) { |
|
| 109 | + $this->l = $l; |
|
| 110 | + $this->defaults = $defaults; |
|
| 111 | + $this->appManager = $appManager; |
|
| 112 | + $this->session = $session; |
|
| 113 | + $this->currentUser = $currentUser; |
|
| 114 | + $this->config = $config; |
|
| 115 | + $this->groupManager = $groupManager; |
|
| 116 | + $this->iniWrapper = $iniWrapper; |
|
| 117 | + $this->urlGenerator = $urlGenerator; |
|
| 118 | + $this->capabilitiesManager = $capabilitiesManager; |
|
| 119 | + $this->initialStateService = $initialStateService; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + public function getConfig() { |
|
| 123 | + $userBackendAllowsPasswordConfirmation = true; |
|
| 124 | + if ($this->currentUser !== null) { |
|
| 125 | + $uid = $this->currentUser->getUID(); |
|
| 126 | + |
|
| 127 | + $backend = $this->currentUser->getBackend(); |
|
| 128 | + if ($backend instanceof IPasswordConfirmationBackend) { |
|
| 129 | + $userBackendAllowsPasswordConfirmation = $backend->canConfirmPassword($uid); |
|
| 130 | + } elseif (isset($this->excludedUserBackEnds[$this->currentUser->getBackendClassName()])) { |
|
| 131 | + $userBackendAllowsPasswordConfirmation = false; |
|
| 132 | + } |
|
| 133 | + } else { |
|
| 134 | + $uid = null; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + // Get the config |
|
| 138 | + $apps_paths = []; |
|
| 139 | + |
|
| 140 | + if ($this->currentUser === null) { |
|
| 141 | + $apps = $this->appManager->getInstalledApps(); |
|
| 142 | + } else { |
|
| 143 | + $apps = $this->appManager->getEnabledAppsForUser($this->currentUser); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + foreach ($apps as $app) { |
|
| 147 | + $apps_paths[$app] = \OC_App::getAppWebPath($app); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + |
|
| 151 | + $enableLinkPasswordByDefault = $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'); |
|
| 152 | + $enableLinkPasswordByDefault = $enableLinkPasswordByDefault === 'yes'; |
|
| 153 | + $defaultExpireDateEnabled = $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no') === 'yes'; |
|
| 154 | + $defaultExpireDate = $enforceDefaultExpireDate = null; |
|
| 155 | + if ($defaultExpireDateEnabled) { |
|
| 156 | + $defaultExpireDate = (int)$this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'); |
|
| 157 | + $enforceDefaultExpireDate = $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no') === 'yes'; |
|
| 158 | + } |
|
| 159 | + $outgoingServer2serverShareEnabled = $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes'; |
|
| 160 | + |
|
| 161 | + $defaultInternalExpireDateEnabled = $this->config->getAppValue('core', 'shareapi_default_internal_expire_date', 'no') === 'yes'; |
|
| 162 | + $defaultInternalExpireDate = $defaultInternalExpireDateEnforced = null; |
|
| 163 | + if ($defaultInternalExpireDateEnabled) { |
|
| 164 | + $defaultInternalExpireDate = (int)$this->config->getAppValue('core', 'shareapi_internal_expire_after_n_days', '7'); |
|
| 165 | + $defaultInternalExpireDateEnforced = $this->config->getAppValue('core', 'shareapi_enforce_internal_expire_date', 'no') === 'yes'; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + $defaultRemoteExpireDateEnabled = $this->config->getAppValue('core', 'shareapi_default_remote_expire_date', 'no') === 'yes'; |
|
| 169 | + $defaultRemoteExpireDate = $defaultRemoteExpireDateEnforced = null; |
|
| 170 | + if ($defaultRemoteExpireDateEnabled) { |
|
| 171 | + $defaultRemoteExpireDate = (int)$this->config->getAppValue('core', 'shareapi_remote_expire_after_n_days', '7'); |
|
| 172 | + $defaultRemoteExpireDateEnforced = $this->config->getAppValue('core', 'shareapi_enforce_remote_expire_date', 'no') === 'yes'; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + $countOfDataLocation = 0; |
|
| 176 | + $dataLocation = str_replace(\OC::$SERVERROOT . '/', '', $this->config->getSystemValue('datadirectory', ''), $countOfDataLocation); |
|
| 177 | + if ($countOfDataLocation !== 1 || $uid === null || !$this->groupManager->isAdmin($uid)) { |
|
| 178 | + $dataLocation = false; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + if ($this->currentUser instanceof IUser) { |
|
| 182 | + $lastConfirmTimestamp = $this->session->get('last-password-confirm'); |
|
| 183 | + if (!is_int($lastConfirmTimestamp)) { |
|
| 184 | + $lastConfirmTimestamp = 0; |
|
| 185 | + } |
|
| 186 | + } else { |
|
| 187 | + $lastConfirmTimestamp = 0; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + $capabilities = $this->capabilitiesManager->getCapabilities(); |
|
| 191 | + |
|
| 192 | + $config = [ |
|
| 193 | + 'session_lifetime' => min($this->config->getSystemValue('session_lifetime', $this->iniWrapper->getNumeric('session.gc_maxlifetime')), $this->iniWrapper->getNumeric('session.gc_maxlifetime')), |
|
| 194 | + 'session_keepalive' => $this->config->getSystemValue('session_keepalive', true), |
|
| 195 | + 'auto_logout' => $this->config->getSystemValue('auto_logout', false), |
|
| 196 | + 'version' => implode('.', \OCP\Util::getVersion()), |
|
| 197 | + 'versionstring' => \OC_Util::getVersionString(), |
|
| 198 | + 'enable_avatars' => true, // here for legacy reasons - to not crash existing code that relies on this value |
|
| 199 | + 'lost_password_link' => $this->config->getSystemValue('lost_password_link', null), |
|
| 200 | + 'modRewriteWorking' => $this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true', |
|
| 201 | + 'sharing.maxAutocompleteResults' => max(0, $this->config->getSystemValueInt('sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT)), |
|
| 202 | + 'sharing.minSearchStringLength' => $this->config->getSystemValueInt('sharing.minSearchStringLength', 0), |
|
| 203 | + 'blacklist_files_regex' => \OCP\Files\FileInfo::BLACKLIST_FILES_REGEX, |
|
| 204 | + ]; |
|
| 205 | + |
|
| 206 | + $array = [ |
|
| 207 | + "_oc_debug" => $this->config->getSystemValue('debug', false) ? 'true' : 'false', |
|
| 208 | + "_oc_isadmin" => $uid !== null && $this->groupManager->isAdmin($uid) ? 'true' : 'false', |
|
| 209 | + "backendAllowsPasswordConfirmation" => $userBackendAllowsPasswordConfirmation ? 'true' : 'false', |
|
| 210 | + "oc_dataURL" => is_string($dataLocation) ? "\"" . $dataLocation . "\"" : 'false', |
|
| 211 | + "_oc_webroot" => "\"" . \OC::$WEBROOT . "\"", |
|
| 212 | + "_oc_appswebroots" => str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution |
|
| 213 | + "datepickerFormatDate" => json_encode($this->l->l('jsdate', null)), |
|
| 214 | + 'nc_lastLogin' => $lastConfirmTimestamp, |
|
| 215 | + 'nc_pageLoad' => time(), |
|
| 216 | + "dayNames" => json_encode([ |
|
| 217 | + $this->l->t('Sunday'), |
|
| 218 | + $this->l->t('Monday'), |
|
| 219 | + $this->l->t('Tuesday'), |
|
| 220 | + $this->l->t('Wednesday'), |
|
| 221 | + $this->l->t('Thursday'), |
|
| 222 | + $this->l->t('Friday'), |
|
| 223 | + $this->l->t('Saturday') |
|
| 224 | + ]), |
|
| 225 | + "dayNamesShort" => json_encode([ |
|
| 226 | + $this->l->t('Sun.'), |
|
| 227 | + $this->l->t('Mon.'), |
|
| 228 | + $this->l->t('Tue.'), |
|
| 229 | + $this->l->t('Wed.'), |
|
| 230 | + $this->l->t('Thu.'), |
|
| 231 | + $this->l->t('Fri.'), |
|
| 232 | + $this->l->t('Sat.') |
|
| 233 | + ]), |
|
| 234 | + "dayNamesMin" => json_encode([ |
|
| 235 | + $this->l->t('Su'), |
|
| 236 | + $this->l->t('Mo'), |
|
| 237 | + $this->l->t('Tu'), |
|
| 238 | + $this->l->t('We'), |
|
| 239 | + $this->l->t('Th'), |
|
| 240 | + $this->l->t('Fr'), |
|
| 241 | + $this->l->t('Sa') |
|
| 242 | + ]), |
|
| 243 | + "monthNames" => json_encode([ |
|
| 244 | + $this->l->t('January'), |
|
| 245 | + $this->l->t('February'), |
|
| 246 | + $this->l->t('March'), |
|
| 247 | + $this->l->t('April'), |
|
| 248 | + $this->l->t('May'), |
|
| 249 | + $this->l->t('June'), |
|
| 250 | + $this->l->t('July'), |
|
| 251 | + $this->l->t('August'), |
|
| 252 | + $this->l->t('September'), |
|
| 253 | + $this->l->t('October'), |
|
| 254 | + $this->l->t('November'), |
|
| 255 | + $this->l->t('December') |
|
| 256 | + ]), |
|
| 257 | + "monthNamesShort" => json_encode([ |
|
| 258 | + $this->l->t('Jan.'), |
|
| 259 | + $this->l->t('Feb.'), |
|
| 260 | + $this->l->t('Mar.'), |
|
| 261 | + $this->l->t('Apr.'), |
|
| 262 | + $this->l->t('May.'), |
|
| 263 | + $this->l->t('Jun.'), |
|
| 264 | + $this->l->t('Jul.'), |
|
| 265 | + $this->l->t('Aug.'), |
|
| 266 | + $this->l->t('Sep.'), |
|
| 267 | + $this->l->t('Oct.'), |
|
| 268 | + $this->l->t('Nov.'), |
|
| 269 | + $this->l->t('Dec.') |
|
| 270 | + ]), |
|
| 271 | + "firstDay" => json_encode($this->l->l('firstday', null)), |
|
| 272 | + "_oc_config" => json_encode($config), |
|
| 273 | + "oc_appconfig" => json_encode([ |
|
| 274 | + 'core' => [ |
|
| 275 | + 'defaultExpireDateEnabled' => $defaultExpireDateEnabled, |
|
| 276 | + 'defaultExpireDate' => $defaultExpireDate, |
|
| 277 | + 'defaultExpireDateEnforced' => $enforceDefaultExpireDate, |
|
| 278 | + 'enforcePasswordForPublicLink' => \OCP\Util::isPublicLinkPasswordRequired(), |
|
| 279 | + 'enableLinkPasswordByDefault' => $enableLinkPasswordByDefault, |
|
| 280 | + 'sharingDisabledForUser' => \OCP\Util::isSharingDisabledForUser(), |
|
| 281 | + 'resharingAllowed' => \OC\Share\Share::isResharingAllowed(), |
|
| 282 | + 'remoteShareAllowed' => $outgoingServer2serverShareEnabled, |
|
| 283 | + 'federatedCloudShareDoc' => $this->urlGenerator->linkToDocs('user-sharing-federated'), |
|
| 284 | + 'allowGroupSharing' => \OC::$server->getShareManager()->allowGroupSharing(), |
|
| 285 | + 'defaultInternalExpireDateEnabled' => $defaultInternalExpireDateEnabled, |
|
| 286 | + 'defaultInternalExpireDate' => $defaultInternalExpireDate, |
|
| 287 | + 'defaultInternalExpireDateEnforced' => $defaultInternalExpireDateEnforced, |
|
| 288 | + 'defaultRemoteExpireDateEnabled' => $defaultRemoteExpireDateEnabled, |
|
| 289 | + 'defaultRemoteExpireDate' => $defaultRemoteExpireDate, |
|
| 290 | + 'defaultRemoteExpireDateEnforced' => $defaultRemoteExpireDateEnforced, |
|
| 291 | + ] |
|
| 292 | + ]), |
|
| 293 | + "_theme" => json_encode([ |
|
| 294 | + 'entity' => $this->defaults->getEntity(), |
|
| 295 | + 'name' => $this->defaults->getName(), |
|
| 296 | + 'productName' => $this->defaults->getProductName(), |
|
| 297 | + 'title' => $this->defaults->getTitle(), |
|
| 298 | + 'baseUrl' => $this->defaults->getBaseUrl(), |
|
| 299 | + 'syncClientUrl' => $this->defaults->getSyncClientUrl(), |
|
| 300 | + 'docBaseUrl' => $this->defaults->getDocBaseUrl(), |
|
| 301 | + 'docPlaceholderUrl' => $this->defaults->buildDocLinkToKey('PLACEHOLDER'), |
|
| 302 | + 'slogan' => $this->defaults->getSlogan(), |
|
| 303 | + 'logoClaim' => '', |
|
| 304 | + 'folder' => \OC_Util::getTheme(), |
|
| 305 | + ]), |
|
| 306 | + ]; |
|
| 307 | + |
|
| 308 | + if ($this->currentUser !== null) { |
|
| 309 | + $array['oc_userconfig'] = json_encode([ |
|
| 310 | + 'avatar' => [ |
|
| 311 | + 'version' => (int)$this->config->getUserValue($uid, 'avatar', 'version', 0), |
|
| 312 | + 'generated' => $this->config->getUserValue($uid, 'avatar', 'generated', 'true') === 'true', |
|
| 313 | + ] |
|
| 314 | + ]); |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + $this->initialStateService->provideInitialState('core', 'config', $config); |
|
| 318 | + $this->initialStateService->provideInitialState('core', 'capabilities', $capabilities); |
|
| 319 | + |
|
| 320 | + // Allow hooks to modify the output values |
|
| 321 | + \OC_Hook::emit('\OCP\Config', 'js', ['array' => &$array]); |
|
| 322 | + |
|
| 323 | + $result = ''; |
|
| 324 | + |
|
| 325 | + // Echo it |
|
| 326 | + foreach ($array as $setting => $value) { |
|
| 327 | + $result .= 'var '. $setting . '='. $value . ';' . PHP_EOL; |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + return $result; |
|
| 331 | + } |
|
| 332 | 332 | } |