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