@@ -30,21 +30,21 @@ |
||
| 30 | 30 | |
| 31 | 31 | class FinishRememberedLoginCommand extends ALoginCommand { |
| 32 | 32 | |
| 33 | - /** @var Session */ |
|
| 34 | - private $userSession; |
|
| 35 | - /** @var IConfig */ |
|
| 36 | - private $config; |
|
| 37 | - |
|
| 38 | - public function __construct(Session $userSession, IConfig $config) { |
|
| 39 | - $this->userSession = $userSession; |
|
| 40 | - $this->config = $config; |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - public function process(LoginData $loginData): LoginResult { |
|
| 44 | - if ($loginData->isRememberLogin() && $this->config->getSystemValue('auto_logout', false) === false) { |
|
| 45 | - $this->userSession->createRememberMeToken($loginData->getUser()); |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - return $this->processNextOrFinishSuccessfully($loginData); |
|
| 49 | - } |
|
| 33 | + /** @var Session */ |
|
| 34 | + private $userSession; |
|
| 35 | + /** @var IConfig */ |
|
| 36 | + private $config; |
|
| 37 | + |
|
| 38 | + public function __construct(Session $userSession, IConfig $config) { |
|
| 39 | + $this->userSession = $userSession; |
|
| 40 | + $this->config = $config; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + public function process(LoginData $loginData): LoginResult { |
|
| 44 | + if ($loginData->isRememberLogin() && $this->config->getSystemValue('auto_logout', false) === false) { |
|
| 45 | + $this->userSession->createRememberMeToken($loginData->getUser()); |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + return $this->processNextOrFinishSuccessfully($loginData); |
|
| 49 | + } |
|
| 50 | 50 | } |
@@ -53,310 +53,310 @@ |
||
| 53 | 53 | use OCP\Support\Subscription\IRegistry; |
| 54 | 54 | |
| 55 | 55 | class TemplateLayout extends \OC_Template { |
| 56 | - private static $versionHash = ''; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @var \OCP\IConfig |
|
| 60 | - */ |
|
| 61 | - private $config; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * @param string $renderAs |
|
| 65 | - * @param string $appId application id |
|
| 66 | - */ |
|
| 67 | - public function __construct($renderAs, $appId = '') { |
|
| 68 | - |
|
| 69 | - // yes - should be injected .... |
|
| 70 | - $this->config = \OC::$server->getConfig(); |
|
| 71 | - |
|
| 72 | - if (\OCP\Util::isIE()) { |
|
| 73 | - \OC_Util::addStyle('ie'); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - // Decide which page we show |
|
| 77 | - if ($renderAs === 'user') { |
|
| 78 | - parent::__construct('core', 'layout.user'); |
|
| 79 | - if (in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
| 80 | - $this->assign('bodyid', 'body-settings'); |
|
| 81 | - } else { |
|
| 82 | - $this->assign('bodyid', 'body-user'); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - // Add navigation entry |
|
| 86 | - $this->assign('application', ''); |
|
| 87 | - $this->assign('appid', $appId); |
|
| 88 | - $navigation = \OC::$server->getNavigationManager()->getAll(); |
|
| 89 | - $this->assign('navigation', $navigation); |
|
| 90 | - $settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings'); |
|
| 91 | - $this->assign('settingsnavigation', $settingsNavigation); |
|
| 92 | - foreach ($navigation as $entry) { |
|
| 93 | - if ($entry['active']) { |
|
| 94 | - $this->assign('application', $entry['name']); |
|
| 95 | - break; |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - foreach ($settingsNavigation as $entry) { |
|
| 100 | - if ($entry['active']) { |
|
| 101 | - $this->assign('application', $entry['name']); |
|
| 102 | - break; |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - $userDisplayName = \OC_User::getDisplayName(); |
|
| 106 | - $this->assign('user_displayname', $userDisplayName); |
|
| 107 | - $this->assign('user_uid', \OC_User::getUser()); |
|
| 108 | - |
|
| 109 | - if (\OC_User::getUser() === false) { |
|
| 110 | - $this->assign('userAvatarSet', false); |
|
| 111 | - } else { |
|
| 112 | - $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists()); |
|
| 113 | - $this->assign('userAvatarVersion', $this->config->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0)); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - // check if app menu icons should be inverted |
|
| 117 | - try { |
|
| 118 | - /** @var \OCA\Theming\Util $util */ |
|
| 119 | - $util = \OC::$server->query(\OCA\Theming\Util::class); |
|
| 120 | - $this->assign('themingInvertMenu', $util->invertTextColor(\OC::$server->getThemingDefaults()->getColorPrimary())); |
|
| 121 | - } catch (\OCP\AppFramework\QueryException $e) { |
|
| 122 | - $this->assign('themingInvertMenu', false); |
|
| 123 | - } catch (\OCP\AutoloadNotAllowedException $e) { |
|
| 124 | - $this->assign('themingInvertMenu', false); |
|
| 125 | - } |
|
| 126 | - } elseif ($renderAs === 'error') { |
|
| 127 | - parent::__construct('core', 'layout.guest', '', false); |
|
| 128 | - $this->assign('bodyid', 'body-login'); |
|
| 129 | - $this->assign('user_displayname', ''); |
|
| 130 | - $this->assign('user_uid', ''); |
|
| 131 | - } elseif ($renderAs === 'guest') { |
|
| 132 | - parent::__construct('core', 'layout.guest'); |
|
| 133 | - \OC_Util::addStyle('guest'); |
|
| 134 | - $this->assign('bodyid', 'body-login'); |
|
| 135 | - |
|
| 136 | - $userDisplayName = \OC_User::getDisplayName(); |
|
| 137 | - $this->assign('user_displayname', $userDisplayName); |
|
| 138 | - $this->assign('user_uid', \OC_User::getUser()); |
|
| 139 | - } elseif ($renderAs === 'public') { |
|
| 140 | - parent::__construct('core', 'layout.public'); |
|
| 141 | - $this->assign('appid', $appId); |
|
| 142 | - $this->assign('bodyid', 'body-public'); |
|
| 143 | - |
|
| 144 | - /** @var IRegistry $subscription */ |
|
| 145 | - $subscription = \OC::$server->query(IRegistry::class); |
|
| 146 | - $showSimpleSignup = $this->config->getSystemValueBool('simpleSignUpLink.shown', true); |
|
| 147 | - if ($showSimpleSignup && $subscription->delegateHasValidSubscription()) { |
|
| 148 | - $showSimpleSignup = false; |
|
| 149 | - } |
|
| 150 | - $this->assign('showSimpleSignUpLink', $showSimpleSignup); |
|
| 151 | - } else { |
|
| 152 | - parent::__construct('core', 'layout.base'); |
|
| 153 | - } |
|
| 154 | - // Send the language and the locale to our layouts |
|
| 155 | - $lang = \OC::$server->getL10NFactory()->findLanguage(); |
|
| 156 | - $locale = \OC::$server->getL10NFactory()->findLocale($lang); |
|
| 157 | - |
|
| 158 | - $lang = str_replace('_', '-', $lang); |
|
| 159 | - $this->assign('language', $lang); |
|
| 160 | - $this->assign('locale', $locale); |
|
| 161 | - |
|
| 162 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 163 | - if (empty(self::$versionHash)) { |
|
| 164 | - $v = \OC_App::getAppVersions(); |
|
| 165 | - $v['core'] = implode('.', \OCP\Util::getVersion()); |
|
| 166 | - self::$versionHash = substr(md5(implode(',', $v)), 0, 8); |
|
| 167 | - } |
|
| 168 | - } else { |
|
| 169 | - self::$versionHash = md5('not installed'); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - // Add the js files |
|
| 173 | - $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); |
|
| 174 | - $this->assign('jsfiles', []); |
|
| 175 | - if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { |
|
| 176 | - if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { |
|
| 177 | - $jsConfigHelper = new JSConfigHelper( |
|
| 178 | - \OC::$server->getL10N('lib'), |
|
| 179 | - \OC::$server->query(Defaults::class), |
|
| 180 | - \OC::$server->getAppManager(), |
|
| 181 | - \OC::$server->getSession(), |
|
| 182 | - \OC::$server->getUserSession()->getUser(), |
|
| 183 | - $this->config, |
|
| 184 | - \OC::$server->getGroupManager(), |
|
| 185 | - \OC::$server->getIniWrapper(), |
|
| 186 | - \OC::$server->getURLGenerator(), |
|
| 187 | - \OC::$server->getCapabilitiesManager(), |
|
| 188 | - \OC::$server->query(IInitialStateService::class) |
|
| 189 | - ); |
|
| 190 | - $this->assign('inline_ocjs', $jsConfigHelper->getConfig()); |
|
| 191 | - } else { |
|
| 192 | - $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
|
| 193 | - } |
|
| 194 | - } |
|
| 195 | - foreach ($jsFiles as $info) { |
|
| 196 | - $web = $info[1]; |
|
| 197 | - $file = $info[2]; |
|
| 198 | - $this->append('jsfiles', $web.'/'.$file . $this->getVersionHashSuffix()); |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - try { |
|
| 202 | - $pathInfo = \OC::$server->getRequest()->getPathInfo(); |
|
| 203 | - } catch (\Exception $e) { |
|
| 204 | - $pathInfo = ''; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - // Do not initialise scss appdata until we have a fully installed instance |
|
| 208 | - // Do not load scss for update, errors, installation or login page |
|
| 209 | - if (\OC::$server->getSystemConfig()->getValue('installed', false) |
|
| 210 | - && !\OCP\Util::needUpgrade() |
|
| 211 | - && $pathInfo !== '' |
|
| 212 | - && !preg_match('/^\/login/', $pathInfo) |
|
| 213 | - && $renderAs !== 'error' |
|
| 214 | - ) { |
|
| 215 | - $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); |
|
| 216 | - } else { |
|
| 217 | - // If we ignore the scss compiler, |
|
| 218 | - // we need to load the guest css fallback |
|
| 219 | - \OC_Util::addStyle('guest'); |
|
| 220 | - $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false); |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - $this->assign('cssfiles', []); |
|
| 224 | - $this->assign('printcssfiles', []); |
|
| 225 | - $this->assign('versionHash', self::$versionHash); |
|
| 226 | - foreach ($cssFiles as $info) { |
|
| 227 | - $web = $info[1]; |
|
| 228 | - $file = $info[2]; |
|
| 229 | - |
|
| 230 | - if (substr($file, -strlen('print.css')) === 'print.css') { |
|
| 231 | - $this->append('printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix()); |
|
| 232 | - } else { |
|
| 233 | - $suffix = $this->getVersionHashSuffix($web, $file); |
|
| 234 | - |
|
| 235 | - if (strpos($file, '?v=') == false) { |
|
| 236 | - $this->append('cssfiles', $web.'/'.$file . $suffix); |
|
| 237 | - } else { |
|
| 238 | - $this->append('cssfiles', $web.'/'.$file . '-' . substr($suffix, 3)); |
|
| 239 | - } |
|
| 240 | - } |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - /** @var InitialStateService $initialState */ |
|
| 244 | - $initialState = \OC::$server->query(InitialStateService::class); |
|
| 245 | - $this->assign('initialStates', $initialState->getInitialStates()); |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - /** |
|
| 249 | - * @param string $path |
|
| 250 | - * @param string $file |
|
| 251 | - * @return string |
|
| 252 | - */ |
|
| 253 | - protected function getVersionHashSuffix($path = false, $file = false) { |
|
| 254 | - if ($this->config->getSystemValue('debug', false)) { |
|
| 255 | - // allows chrome workspace mapping in debug mode |
|
| 256 | - return ""; |
|
| 257 | - } |
|
| 258 | - $themingSuffix = ''; |
|
| 259 | - $v = []; |
|
| 260 | - |
|
| 261 | - if ($this->config->getSystemValue('installed', false)) { |
|
| 262 | - if (\OC::$server->getAppManager()->isInstalled('theming')) { |
|
| 263 | - $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
| 264 | - } |
|
| 265 | - $v = \OC_App::getAppVersions(); |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - // Try the webroot path for a match |
|
| 269 | - if ($path !== false && $path !== '') { |
|
| 270 | - $appName = $this->getAppNamefromPath($path); |
|
| 271 | - if (array_key_exists($appName, $v)) { |
|
| 272 | - $appVersion = $v[$appName]; |
|
| 273 | - return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
| 274 | - } |
|
| 275 | - } |
|
| 276 | - // fallback to the file path instead |
|
| 277 | - if ($file !== false && $file !== '') { |
|
| 278 | - $appName = $this->getAppNamefromPath($file); |
|
| 279 | - if (array_key_exists($appName, $v)) { |
|
| 280 | - $appVersion = $v[$appName]; |
|
| 281 | - return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
| 282 | - } |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - return '?v=' . self::$versionHash . $themingSuffix; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - /** |
|
| 289 | - * @param array $styles |
|
| 290 | - * @return array |
|
| 291 | - */ |
|
| 292 | - public static function findStylesheetFiles($styles, $compileScss = true) { |
|
| 293 | - // Read the selected theme from the config file |
|
| 294 | - $theme = \OC_Util::getTheme(); |
|
| 295 | - |
|
| 296 | - if ($compileScss) { |
|
| 297 | - $SCSSCacher = \OC::$server->query(SCSSCacher::class); |
|
| 298 | - } else { |
|
| 299 | - $SCSSCacher = null; |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - $locator = new \OC\Template\CSSResourceLocator( |
|
| 303 | - \OC::$server->getLogger(), |
|
| 304 | - $theme, |
|
| 305 | - [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
| 306 | - [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
| 307 | - $SCSSCacher |
|
| 308 | - ); |
|
| 309 | - $locator->find($styles); |
|
| 310 | - return $locator->getResources(); |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - /** |
|
| 314 | - * @param string $path |
|
| 315 | - * @return string|boolean |
|
| 316 | - */ |
|
| 317 | - public function getAppNamefromPath($path) { |
|
| 318 | - if ($path !== '' && is_string($path)) { |
|
| 319 | - $pathParts = explode('/', $path); |
|
| 320 | - if ($pathParts[0] === 'css') { |
|
| 321 | - // This is a scss request |
|
| 322 | - return $pathParts[1]; |
|
| 323 | - } |
|
| 324 | - return end($pathParts); |
|
| 325 | - } |
|
| 326 | - return false; |
|
| 327 | - } |
|
| 328 | - |
|
| 329 | - /** |
|
| 330 | - * @param array $scripts |
|
| 331 | - * @return array |
|
| 332 | - */ |
|
| 333 | - public static function findJavascriptFiles($scripts) { |
|
| 334 | - // Read the selected theme from the config file |
|
| 335 | - $theme = \OC_Util::getTheme(); |
|
| 336 | - |
|
| 337 | - $locator = new \OC\Template\JSResourceLocator( |
|
| 338 | - \OC::$server->getLogger(), |
|
| 339 | - $theme, |
|
| 340 | - [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
| 341 | - [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
| 342 | - \OC::$server->query(JSCombiner::class) |
|
| 343 | - ); |
|
| 344 | - $locator->find($scripts); |
|
| 345 | - return $locator->getResources(); |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - /** |
|
| 349 | - * Converts the absolute file path to a relative path from \OC::$SERVERROOT |
|
| 350 | - * @param string $filePath Absolute path |
|
| 351 | - * @return string Relative path |
|
| 352 | - * @throws \Exception If $filePath is not under \OC::$SERVERROOT |
|
| 353 | - */ |
|
| 354 | - public static function convertToRelativePath($filePath) { |
|
| 355 | - $relativePath = explode(\OC::$SERVERROOT, $filePath); |
|
| 356 | - if (count($relativePath) !== 2) { |
|
| 357 | - throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - return $relativePath[1]; |
|
| 361 | - } |
|
| 56 | + private static $versionHash = ''; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @var \OCP\IConfig |
|
| 60 | + */ |
|
| 61 | + private $config; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * @param string $renderAs |
|
| 65 | + * @param string $appId application id |
|
| 66 | + */ |
|
| 67 | + public function __construct($renderAs, $appId = '') { |
|
| 68 | + |
|
| 69 | + // yes - should be injected .... |
|
| 70 | + $this->config = \OC::$server->getConfig(); |
|
| 71 | + |
|
| 72 | + if (\OCP\Util::isIE()) { |
|
| 73 | + \OC_Util::addStyle('ie'); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + // Decide which page we show |
|
| 77 | + if ($renderAs === 'user') { |
|
| 78 | + parent::__construct('core', 'layout.user'); |
|
| 79 | + if (in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
| 80 | + $this->assign('bodyid', 'body-settings'); |
|
| 81 | + } else { |
|
| 82 | + $this->assign('bodyid', 'body-user'); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + // Add navigation entry |
|
| 86 | + $this->assign('application', ''); |
|
| 87 | + $this->assign('appid', $appId); |
|
| 88 | + $navigation = \OC::$server->getNavigationManager()->getAll(); |
|
| 89 | + $this->assign('navigation', $navigation); |
|
| 90 | + $settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings'); |
|
| 91 | + $this->assign('settingsnavigation', $settingsNavigation); |
|
| 92 | + foreach ($navigation as $entry) { |
|
| 93 | + if ($entry['active']) { |
|
| 94 | + $this->assign('application', $entry['name']); |
|
| 95 | + break; |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + foreach ($settingsNavigation as $entry) { |
|
| 100 | + if ($entry['active']) { |
|
| 101 | + $this->assign('application', $entry['name']); |
|
| 102 | + break; |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + $userDisplayName = \OC_User::getDisplayName(); |
|
| 106 | + $this->assign('user_displayname', $userDisplayName); |
|
| 107 | + $this->assign('user_uid', \OC_User::getUser()); |
|
| 108 | + |
|
| 109 | + if (\OC_User::getUser() === false) { |
|
| 110 | + $this->assign('userAvatarSet', false); |
|
| 111 | + } else { |
|
| 112 | + $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists()); |
|
| 113 | + $this->assign('userAvatarVersion', $this->config->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0)); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + // check if app menu icons should be inverted |
|
| 117 | + try { |
|
| 118 | + /** @var \OCA\Theming\Util $util */ |
|
| 119 | + $util = \OC::$server->query(\OCA\Theming\Util::class); |
|
| 120 | + $this->assign('themingInvertMenu', $util->invertTextColor(\OC::$server->getThemingDefaults()->getColorPrimary())); |
|
| 121 | + } catch (\OCP\AppFramework\QueryException $e) { |
|
| 122 | + $this->assign('themingInvertMenu', false); |
|
| 123 | + } catch (\OCP\AutoloadNotAllowedException $e) { |
|
| 124 | + $this->assign('themingInvertMenu', false); |
|
| 125 | + } |
|
| 126 | + } elseif ($renderAs === 'error') { |
|
| 127 | + parent::__construct('core', 'layout.guest', '', false); |
|
| 128 | + $this->assign('bodyid', 'body-login'); |
|
| 129 | + $this->assign('user_displayname', ''); |
|
| 130 | + $this->assign('user_uid', ''); |
|
| 131 | + } elseif ($renderAs === 'guest') { |
|
| 132 | + parent::__construct('core', 'layout.guest'); |
|
| 133 | + \OC_Util::addStyle('guest'); |
|
| 134 | + $this->assign('bodyid', 'body-login'); |
|
| 135 | + |
|
| 136 | + $userDisplayName = \OC_User::getDisplayName(); |
|
| 137 | + $this->assign('user_displayname', $userDisplayName); |
|
| 138 | + $this->assign('user_uid', \OC_User::getUser()); |
|
| 139 | + } elseif ($renderAs === 'public') { |
|
| 140 | + parent::__construct('core', 'layout.public'); |
|
| 141 | + $this->assign('appid', $appId); |
|
| 142 | + $this->assign('bodyid', 'body-public'); |
|
| 143 | + |
|
| 144 | + /** @var IRegistry $subscription */ |
|
| 145 | + $subscription = \OC::$server->query(IRegistry::class); |
|
| 146 | + $showSimpleSignup = $this->config->getSystemValueBool('simpleSignUpLink.shown', true); |
|
| 147 | + if ($showSimpleSignup && $subscription->delegateHasValidSubscription()) { |
|
| 148 | + $showSimpleSignup = false; |
|
| 149 | + } |
|
| 150 | + $this->assign('showSimpleSignUpLink', $showSimpleSignup); |
|
| 151 | + } else { |
|
| 152 | + parent::__construct('core', 'layout.base'); |
|
| 153 | + } |
|
| 154 | + // Send the language and the locale to our layouts |
|
| 155 | + $lang = \OC::$server->getL10NFactory()->findLanguage(); |
|
| 156 | + $locale = \OC::$server->getL10NFactory()->findLocale($lang); |
|
| 157 | + |
|
| 158 | + $lang = str_replace('_', '-', $lang); |
|
| 159 | + $this->assign('language', $lang); |
|
| 160 | + $this->assign('locale', $locale); |
|
| 161 | + |
|
| 162 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 163 | + if (empty(self::$versionHash)) { |
|
| 164 | + $v = \OC_App::getAppVersions(); |
|
| 165 | + $v['core'] = implode('.', \OCP\Util::getVersion()); |
|
| 166 | + self::$versionHash = substr(md5(implode(',', $v)), 0, 8); |
|
| 167 | + } |
|
| 168 | + } else { |
|
| 169 | + self::$versionHash = md5('not installed'); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + // Add the js files |
|
| 173 | + $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); |
|
| 174 | + $this->assign('jsfiles', []); |
|
| 175 | + if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { |
|
| 176 | + if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { |
|
| 177 | + $jsConfigHelper = new JSConfigHelper( |
|
| 178 | + \OC::$server->getL10N('lib'), |
|
| 179 | + \OC::$server->query(Defaults::class), |
|
| 180 | + \OC::$server->getAppManager(), |
|
| 181 | + \OC::$server->getSession(), |
|
| 182 | + \OC::$server->getUserSession()->getUser(), |
|
| 183 | + $this->config, |
|
| 184 | + \OC::$server->getGroupManager(), |
|
| 185 | + \OC::$server->getIniWrapper(), |
|
| 186 | + \OC::$server->getURLGenerator(), |
|
| 187 | + \OC::$server->getCapabilitiesManager(), |
|
| 188 | + \OC::$server->query(IInitialStateService::class) |
|
| 189 | + ); |
|
| 190 | + $this->assign('inline_ocjs', $jsConfigHelper->getConfig()); |
|
| 191 | + } else { |
|
| 192 | + $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | + foreach ($jsFiles as $info) { |
|
| 196 | + $web = $info[1]; |
|
| 197 | + $file = $info[2]; |
|
| 198 | + $this->append('jsfiles', $web.'/'.$file . $this->getVersionHashSuffix()); |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + try { |
|
| 202 | + $pathInfo = \OC::$server->getRequest()->getPathInfo(); |
|
| 203 | + } catch (\Exception $e) { |
|
| 204 | + $pathInfo = ''; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + // Do not initialise scss appdata until we have a fully installed instance |
|
| 208 | + // Do not load scss for update, errors, installation or login page |
|
| 209 | + if (\OC::$server->getSystemConfig()->getValue('installed', false) |
|
| 210 | + && !\OCP\Util::needUpgrade() |
|
| 211 | + && $pathInfo !== '' |
|
| 212 | + && !preg_match('/^\/login/', $pathInfo) |
|
| 213 | + && $renderAs !== 'error' |
|
| 214 | + ) { |
|
| 215 | + $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); |
|
| 216 | + } else { |
|
| 217 | + // If we ignore the scss compiler, |
|
| 218 | + // we need to load the guest css fallback |
|
| 219 | + \OC_Util::addStyle('guest'); |
|
| 220 | + $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false); |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + $this->assign('cssfiles', []); |
|
| 224 | + $this->assign('printcssfiles', []); |
|
| 225 | + $this->assign('versionHash', self::$versionHash); |
|
| 226 | + foreach ($cssFiles as $info) { |
|
| 227 | + $web = $info[1]; |
|
| 228 | + $file = $info[2]; |
|
| 229 | + |
|
| 230 | + if (substr($file, -strlen('print.css')) === 'print.css') { |
|
| 231 | + $this->append('printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix()); |
|
| 232 | + } else { |
|
| 233 | + $suffix = $this->getVersionHashSuffix($web, $file); |
|
| 234 | + |
|
| 235 | + if (strpos($file, '?v=') == false) { |
|
| 236 | + $this->append('cssfiles', $web.'/'.$file . $suffix); |
|
| 237 | + } else { |
|
| 238 | + $this->append('cssfiles', $web.'/'.$file . '-' . substr($suffix, 3)); |
|
| 239 | + } |
|
| 240 | + } |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + /** @var InitialStateService $initialState */ |
|
| 244 | + $initialState = \OC::$server->query(InitialStateService::class); |
|
| 245 | + $this->assign('initialStates', $initialState->getInitialStates()); |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + /** |
|
| 249 | + * @param string $path |
|
| 250 | + * @param string $file |
|
| 251 | + * @return string |
|
| 252 | + */ |
|
| 253 | + protected function getVersionHashSuffix($path = false, $file = false) { |
|
| 254 | + if ($this->config->getSystemValue('debug', false)) { |
|
| 255 | + // allows chrome workspace mapping in debug mode |
|
| 256 | + return ""; |
|
| 257 | + } |
|
| 258 | + $themingSuffix = ''; |
|
| 259 | + $v = []; |
|
| 260 | + |
|
| 261 | + if ($this->config->getSystemValue('installed', false)) { |
|
| 262 | + if (\OC::$server->getAppManager()->isInstalled('theming')) { |
|
| 263 | + $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
| 264 | + } |
|
| 265 | + $v = \OC_App::getAppVersions(); |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + // Try the webroot path for a match |
|
| 269 | + if ($path !== false && $path !== '') { |
|
| 270 | + $appName = $this->getAppNamefromPath($path); |
|
| 271 | + if (array_key_exists($appName, $v)) { |
|
| 272 | + $appVersion = $v[$appName]; |
|
| 273 | + return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
| 274 | + } |
|
| 275 | + } |
|
| 276 | + // fallback to the file path instead |
|
| 277 | + if ($file !== false && $file !== '') { |
|
| 278 | + $appName = $this->getAppNamefromPath($file); |
|
| 279 | + if (array_key_exists($appName, $v)) { |
|
| 280 | + $appVersion = $v[$appName]; |
|
| 281 | + return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + return '?v=' . self::$versionHash . $themingSuffix; |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + /** |
|
| 289 | + * @param array $styles |
|
| 290 | + * @return array |
|
| 291 | + */ |
|
| 292 | + public static function findStylesheetFiles($styles, $compileScss = true) { |
|
| 293 | + // Read the selected theme from the config file |
|
| 294 | + $theme = \OC_Util::getTheme(); |
|
| 295 | + |
|
| 296 | + if ($compileScss) { |
|
| 297 | + $SCSSCacher = \OC::$server->query(SCSSCacher::class); |
|
| 298 | + } else { |
|
| 299 | + $SCSSCacher = null; |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + $locator = new \OC\Template\CSSResourceLocator( |
|
| 303 | + \OC::$server->getLogger(), |
|
| 304 | + $theme, |
|
| 305 | + [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
| 306 | + [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
| 307 | + $SCSSCacher |
|
| 308 | + ); |
|
| 309 | + $locator->find($styles); |
|
| 310 | + return $locator->getResources(); |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + /** |
|
| 314 | + * @param string $path |
|
| 315 | + * @return string|boolean |
|
| 316 | + */ |
|
| 317 | + public function getAppNamefromPath($path) { |
|
| 318 | + if ($path !== '' && is_string($path)) { |
|
| 319 | + $pathParts = explode('/', $path); |
|
| 320 | + if ($pathParts[0] === 'css') { |
|
| 321 | + // This is a scss request |
|
| 322 | + return $pathParts[1]; |
|
| 323 | + } |
|
| 324 | + return end($pathParts); |
|
| 325 | + } |
|
| 326 | + return false; |
|
| 327 | + } |
|
| 328 | + |
|
| 329 | + /** |
|
| 330 | + * @param array $scripts |
|
| 331 | + * @return array |
|
| 332 | + */ |
|
| 333 | + public static function findJavascriptFiles($scripts) { |
|
| 334 | + // Read the selected theme from the config file |
|
| 335 | + $theme = \OC_Util::getTheme(); |
|
| 336 | + |
|
| 337 | + $locator = new \OC\Template\JSResourceLocator( |
|
| 338 | + \OC::$server->getLogger(), |
|
| 339 | + $theme, |
|
| 340 | + [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
| 341 | + [ \OC::$SERVERROOT => \OC::$WEBROOT ], |
|
| 342 | + \OC::$server->query(JSCombiner::class) |
|
| 343 | + ); |
|
| 344 | + $locator->find($scripts); |
|
| 345 | + return $locator->getResources(); |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + /** |
|
| 349 | + * Converts the absolute file path to a relative path from \OC::$SERVERROOT |
|
| 350 | + * @param string $filePath Absolute path |
|
| 351 | + * @return string Relative path |
|
| 352 | + * @throws \Exception If $filePath is not under \OC::$SERVERROOT |
|
| 353 | + */ |
|
| 354 | + public static function convertToRelativePath($filePath) { |
|
| 355 | + $relativePath = explode(\OC::$SERVERROOT, $filePath); |
|
| 356 | + if (count($relativePath) !== 2) { |
|
| 357 | + throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + return $relativePath[1]; |
|
| 361 | + } |
|
| 362 | 362 | } |
@@ -46,277 +46,277 @@ |
||
| 46 | 46 | |
| 47 | 47 | class JSConfigHelper { |
| 48 | 48 | |
| 49 | - /** @var IL10N */ |
|
| 50 | - private $l; |
|
| 51 | - |
|
| 52 | - /** @var Defaults */ |
|
| 53 | - private $defaults; |
|
| 54 | - |
|
| 55 | - /** @var IAppManager */ |
|
| 56 | - private $appManager; |
|
| 57 | - |
|
| 58 | - /** @var ISession */ |
|
| 59 | - private $session; |
|
| 60 | - |
|
| 61 | - /** @var IUser|null */ |
|
| 62 | - private $currentUser; |
|
| 63 | - |
|
| 64 | - /** @var IConfig */ |
|
| 65 | - private $config; |
|
| 66 | - |
|
| 67 | - /** @var IGroupManager */ |
|
| 68 | - private $groupManager; |
|
| 69 | - |
|
| 70 | - /** @var IniGetWrapper */ |
|
| 71 | - private $iniWrapper; |
|
| 72 | - |
|
| 73 | - /** @var IURLGenerator */ |
|
| 74 | - private $urlGenerator; |
|
| 75 | - |
|
| 76 | - /** @var CapabilitiesManager */ |
|
| 77 | - private $capabilitiesManager; |
|
| 78 | - |
|
| 79 | - /** @var IInitialStateService */ |
|
| 80 | - private $initialStateService; |
|
| 81 | - |
|
| 82 | - /** @var array user back-ends excluded from password verification */ |
|
| 83 | - private $excludedUserBackEnds = ['user_saml' => true, 'user_globalsiteselector' => true]; |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * @param IL10N $l |
|
| 87 | - * @param Defaults $defaults |
|
| 88 | - * @param IAppManager $appManager |
|
| 89 | - * @param ISession $session |
|
| 90 | - * @param IUser|null $currentUser |
|
| 91 | - * @param IConfig $config |
|
| 92 | - * @param IGroupManager $groupManager |
|
| 93 | - * @param IniGetWrapper $iniWrapper |
|
| 94 | - * @param IURLGenerator $urlGenerator |
|
| 95 | - * @param CapabilitiesManager $capabilitiesManager |
|
| 96 | - */ |
|
| 97 | - public function __construct(IL10N $l, |
|
| 98 | - Defaults $defaults, |
|
| 99 | - IAppManager $appManager, |
|
| 100 | - ISession $session, |
|
| 101 | - $currentUser, |
|
| 102 | - IConfig $config, |
|
| 103 | - IGroupManager $groupManager, |
|
| 104 | - IniGetWrapper $iniWrapper, |
|
| 105 | - IURLGenerator $urlGenerator, |
|
| 106 | - CapabilitiesManager $capabilitiesManager, |
|
| 107 | - IInitialStateService $initialStateService) { |
|
| 108 | - $this->l = $l; |
|
| 109 | - $this->defaults = $defaults; |
|
| 110 | - $this->appManager = $appManager; |
|
| 111 | - $this->session = $session; |
|
| 112 | - $this->currentUser = $currentUser; |
|
| 113 | - $this->config = $config; |
|
| 114 | - $this->groupManager = $groupManager; |
|
| 115 | - $this->iniWrapper = $iniWrapper; |
|
| 116 | - $this->urlGenerator = $urlGenerator; |
|
| 117 | - $this->capabilitiesManager = $capabilitiesManager; |
|
| 118 | - $this->initialStateService = $initialStateService; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - public function getConfig() { |
|
| 122 | - $userBackendAllowsPasswordConfirmation = true; |
|
| 123 | - if ($this->currentUser !== null) { |
|
| 124 | - $uid = $this->currentUser->getUID(); |
|
| 125 | - |
|
| 126 | - $backend = $this->currentUser->getBackend(); |
|
| 127 | - if ($backend instanceof IPasswordConfirmationBackend) { |
|
| 128 | - $userBackendAllowsPasswordConfirmation = $backend->canConfirmPassword($uid); |
|
| 129 | - } elseif (isset($this->excludedUserBackEnds[$this->currentUser->getBackendClassName()])) { |
|
| 130 | - $userBackendAllowsPasswordConfirmation = false; |
|
| 131 | - } |
|
| 132 | - } else { |
|
| 133 | - $uid = null; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - // Get the config |
|
| 137 | - $apps_paths = []; |
|
| 138 | - |
|
| 139 | - if ($this->currentUser === null) { |
|
| 140 | - $apps = $this->appManager->getInstalledApps(); |
|
| 141 | - } else { |
|
| 142 | - $apps = $this->appManager->getEnabledAppsForUser($this->currentUser); |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - foreach ($apps as $app) { |
|
| 146 | - $apps_paths[$app] = \OC_App::getAppWebPath($app); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - |
|
| 150 | - $enableLinkPasswordByDefault = $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'); |
|
| 151 | - $enableLinkPasswordByDefault = $enableLinkPasswordByDefault === 'yes'; |
|
| 152 | - $defaultExpireDateEnabled = $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no') === 'yes'; |
|
| 153 | - $defaultExpireDate = $enforceDefaultExpireDate = null; |
|
| 154 | - if ($defaultExpireDateEnabled) { |
|
| 155 | - $defaultExpireDate = (int)$this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'); |
|
| 156 | - $enforceDefaultExpireDate = $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no') === 'yes'; |
|
| 157 | - } |
|
| 158 | - $outgoingServer2serverShareEnabled = $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes'; |
|
| 159 | - |
|
| 160 | - $defaultInternalExpireDateEnabled = $this->config->getAppValue('core', 'shareapi_default_internal_expire_date', 'no') === 'yes'; |
|
| 161 | - $defaultInternalExpireDate = $defaultInternalExpireDateEnforced = null; |
|
| 162 | - if ($defaultInternalExpireDateEnabled) { |
|
| 163 | - $defaultInternalExpireDate = (int)$this->config->getAppValue('core', 'shareapi_internal_expire_after_n_days', '7'); |
|
| 164 | - $defaultInternalExpireDateEnforced = $this->config->getAppValue('core', 'shareapi_internal_enforce_expire_date', 'no') === 'yes'; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - $countOfDataLocation = 0; |
|
| 168 | - $dataLocation = str_replace(\OC::$SERVERROOT . '/', '', $this->config->getSystemValue('datadirectory', ''), $countOfDataLocation); |
|
| 169 | - if ($countOfDataLocation !== 1 || !$this->groupManager->isAdmin($uid)) { |
|
| 170 | - $dataLocation = false; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - if ($this->currentUser instanceof IUser) { |
|
| 174 | - $lastConfirmTimestamp = $this->session->get('last-password-confirm'); |
|
| 175 | - if (!is_int($lastConfirmTimestamp)) { |
|
| 176 | - $lastConfirmTimestamp = 0; |
|
| 177 | - } |
|
| 178 | - } else { |
|
| 179 | - $lastConfirmTimestamp = 0; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - $capabilities = $this->capabilitiesManager->getCapabilities(); |
|
| 183 | - |
|
| 184 | - $config = [ |
|
| 185 | - 'session_lifetime' => min($this->config->getSystemValue('session_lifetime', $this->iniWrapper->getNumeric('session.gc_maxlifetime')), $this->iniWrapper->getNumeric('session.gc_maxlifetime')), |
|
| 186 | - 'session_keepalive' => $this->config->getSystemValue('session_keepalive', true), |
|
| 187 | - 'auto_logout' => $this->config->getSystemValue('auto_logout', false), |
|
| 188 | - 'version' => implode('.', \OCP\Util::getVersion()), |
|
| 189 | - 'versionstring' => \OC_Util::getVersionString(), |
|
| 190 | - 'enable_avatars' => true, // here for legacy reasons - to not crash existing code that relies on this value |
|
| 191 | - 'lost_password_link' => $this->config->getSystemValue('lost_password_link', null), |
|
| 192 | - 'modRewriteWorking' => $this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true', |
|
| 193 | - 'sharing.maxAutocompleteResults' => (int)$this->config->getSystemValue('sharing.maxAutocompleteResults', 0), |
|
| 194 | - 'sharing.minSearchStringLength' => (int)$this->config->getSystemValue('sharing.minSearchStringLength', 0), |
|
| 195 | - 'blacklist_files_regex' => \OCP\Files\FileInfo::BLACKLIST_FILES_REGEX, |
|
| 196 | - ]; |
|
| 197 | - |
|
| 198 | - $array = [ |
|
| 199 | - "_oc_debug" => $this->config->getSystemValue('debug', false) ? 'true' : 'false', |
|
| 200 | - "_oc_isadmin" => $this->groupManager->isAdmin($uid) ? 'true' : 'false', |
|
| 201 | - "backendAllowsPasswordConfirmation" => $userBackendAllowsPasswordConfirmation ? 'true' : 'false', |
|
| 202 | - "oc_dataURL" => is_string($dataLocation) ? "\"" . $dataLocation . "\"" : 'false', |
|
| 203 | - "_oc_webroot" => "\"" . \OC::$WEBROOT . "\"", |
|
| 204 | - "_oc_appswebroots" => str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution |
|
| 205 | - "datepickerFormatDate" => json_encode($this->l->l('jsdate', null)), |
|
| 206 | - 'nc_lastLogin' => $lastConfirmTimestamp, |
|
| 207 | - 'nc_pageLoad' => time(), |
|
| 208 | - "dayNames" => json_encode([ |
|
| 209 | - (string)$this->l->t('Sunday'), |
|
| 210 | - (string)$this->l->t('Monday'), |
|
| 211 | - (string)$this->l->t('Tuesday'), |
|
| 212 | - (string)$this->l->t('Wednesday'), |
|
| 213 | - (string)$this->l->t('Thursday'), |
|
| 214 | - (string)$this->l->t('Friday'), |
|
| 215 | - (string)$this->l->t('Saturday') |
|
| 216 | - ]), |
|
| 217 | - "dayNamesShort" => json_encode([ |
|
| 218 | - (string)$this->l->t('Sun.'), |
|
| 219 | - (string)$this->l->t('Mon.'), |
|
| 220 | - (string)$this->l->t('Tue.'), |
|
| 221 | - (string)$this->l->t('Wed.'), |
|
| 222 | - (string)$this->l->t('Thu.'), |
|
| 223 | - (string)$this->l->t('Fri.'), |
|
| 224 | - (string)$this->l->t('Sat.') |
|
| 225 | - ]), |
|
| 226 | - "dayNamesMin" => json_encode([ |
|
| 227 | - (string)$this->l->t('Su'), |
|
| 228 | - (string)$this->l->t('Mo'), |
|
| 229 | - (string)$this->l->t('Tu'), |
|
| 230 | - (string)$this->l->t('We'), |
|
| 231 | - (string)$this->l->t('Th'), |
|
| 232 | - (string)$this->l->t('Fr'), |
|
| 233 | - (string)$this->l->t('Sa') |
|
| 234 | - ]), |
|
| 235 | - "monthNames" => json_encode([ |
|
| 236 | - (string)$this->l->t('January'), |
|
| 237 | - (string)$this->l->t('February'), |
|
| 238 | - (string)$this->l->t('March'), |
|
| 239 | - (string)$this->l->t('April'), |
|
| 240 | - (string)$this->l->t('May'), |
|
| 241 | - (string)$this->l->t('June'), |
|
| 242 | - (string)$this->l->t('July'), |
|
| 243 | - (string)$this->l->t('August'), |
|
| 244 | - (string)$this->l->t('September'), |
|
| 245 | - (string)$this->l->t('October'), |
|
| 246 | - (string)$this->l->t('November'), |
|
| 247 | - (string)$this->l->t('December') |
|
| 248 | - ]), |
|
| 249 | - "monthNamesShort" => json_encode([ |
|
| 250 | - (string)$this->l->t('Jan.'), |
|
| 251 | - (string)$this->l->t('Feb.'), |
|
| 252 | - (string)$this->l->t('Mar.'), |
|
| 253 | - (string)$this->l->t('Apr.'), |
|
| 254 | - (string)$this->l->t('May.'), |
|
| 255 | - (string)$this->l->t('Jun.'), |
|
| 256 | - (string)$this->l->t('Jul.'), |
|
| 257 | - (string)$this->l->t('Aug.'), |
|
| 258 | - (string)$this->l->t('Sep.'), |
|
| 259 | - (string)$this->l->t('Oct.'), |
|
| 260 | - (string)$this->l->t('Nov.'), |
|
| 261 | - (string)$this->l->t('Dec.') |
|
| 262 | - ]), |
|
| 263 | - "firstDay" => json_encode($this->l->l('firstday', null)), |
|
| 264 | - "_oc_config" => json_encode($config), |
|
| 265 | - "oc_appconfig" => json_encode([ |
|
| 266 | - 'core' => [ |
|
| 267 | - 'defaultExpireDateEnabled' => $defaultExpireDateEnabled, |
|
| 268 | - 'defaultExpireDate' => $defaultExpireDate, |
|
| 269 | - 'defaultExpireDateEnforced' => $enforceDefaultExpireDate, |
|
| 270 | - 'enforcePasswordForPublicLink' => \OCP\Util::isPublicLinkPasswordRequired(), |
|
| 271 | - 'enableLinkPasswordByDefault' => $enableLinkPasswordByDefault, |
|
| 272 | - 'sharingDisabledForUser' => \OCP\Util::isSharingDisabledForUser(), |
|
| 273 | - 'resharingAllowed' => \OC\Share\Share::isResharingAllowed(), |
|
| 274 | - 'remoteShareAllowed' => $outgoingServer2serverShareEnabled, |
|
| 275 | - 'federatedCloudShareDoc' => $this->urlGenerator->linkToDocs('user-sharing-federated'), |
|
| 276 | - 'allowGroupSharing' => \OC::$server->getShareManager()->allowGroupSharing(), |
|
| 277 | - 'defaultInternalExpireDateEnabled' => $defaultInternalExpireDateEnabled, |
|
| 278 | - 'defaultInternalExpireDate' => $defaultInternalExpireDate, |
|
| 279 | - 'defaultInternalExpireDateEnforced' => $defaultInternalExpireDateEnforced, |
|
| 280 | - ] |
|
| 281 | - ]), |
|
| 282 | - "_theme" => json_encode([ |
|
| 283 | - 'entity' => $this->defaults->getEntity(), |
|
| 284 | - 'name' => $this->defaults->getName(), |
|
| 285 | - 'title' => $this->defaults->getTitle(), |
|
| 286 | - 'baseUrl' => $this->defaults->getBaseUrl(), |
|
| 287 | - 'syncClientUrl' => $this->defaults->getSyncClientUrl(), |
|
| 288 | - 'docBaseUrl' => $this->defaults->getDocBaseUrl(), |
|
| 289 | - 'docPlaceholderUrl' => $this->defaults->buildDocLinkToKey('PLACEHOLDER'), |
|
| 290 | - 'slogan' => $this->defaults->getSlogan(), |
|
| 291 | - 'logoClaim' => '', |
|
| 292 | - 'shortFooter' => $this->defaults->getShortFooter(), |
|
| 293 | - 'longFooter' => $this->defaults->getLongFooter(), |
|
| 294 | - 'folder' => \OC_Util::getTheme(), |
|
| 295 | - ]), |
|
| 296 | - "_oc_capabilities" => json_encode($capabilities), |
|
| 297 | - ]; |
|
| 298 | - |
|
| 299 | - if ($this->currentUser !== null) { |
|
| 300 | - $array['oc_userconfig'] = json_encode([ |
|
| 301 | - 'avatar' => [ |
|
| 302 | - 'version' => (int)$this->config->getUserValue($uid, 'avatar', 'version', 0), |
|
| 303 | - 'generated' => $this->config->getUserValue($uid, 'avatar', 'generated', 'true') === 'true', |
|
| 304 | - ] |
|
| 305 | - ]); |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - $this->initialStateService->provideInitialState('core', 'config', $config); |
|
| 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 | - } |
|
| 49 | + /** @var IL10N */ |
|
| 50 | + private $l; |
|
| 51 | + |
|
| 52 | + /** @var Defaults */ |
|
| 53 | + private $defaults; |
|
| 54 | + |
|
| 55 | + /** @var IAppManager */ |
|
| 56 | + private $appManager; |
|
| 57 | + |
|
| 58 | + /** @var ISession */ |
|
| 59 | + private $session; |
|
| 60 | + |
|
| 61 | + /** @var IUser|null */ |
|
| 62 | + private $currentUser; |
|
| 63 | + |
|
| 64 | + /** @var IConfig */ |
|
| 65 | + private $config; |
|
| 66 | + |
|
| 67 | + /** @var IGroupManager */ |
|
| 68 | + private $groupManager; |
|
| 69 | + |
|
| 70 | + /** @var IniGetWrapper */ |
|
| 71 | + private $iniWrapper; |
|
| 72 | + |
|
| 73 | + /** @var IURLGenerator */ |
|
| 74 | + private $urlGenerator; |
|
| 75 | + |
|
| 76 | + /** @var CapabilitiesManager */ |
|
| 77 | + private $capabilitiesManager; |
|
| 78 | + |
|
| 79 | + /** @var IInitialStateService */ |
|
| 80 | + private $initialStateService; |
|
| 81 | + |
|
| 82 | + /** @var array user back-ends excluded from password verification */ |
|
| 83 | + private $excludedUserBackEnds = ['user_saml' => true, 'user_globalsiteselector' => true]; |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @param IL10N $l |
|
| 87 | + * @param Defaults $defaults |
|
| 88 | + * @param IAppManager $appManager |
|
| 89 | + * @param ISession $session |
|
| 90 | + * @param IUser|null $currentUser |
|
| 91 | + * @param IConfig $config |
|
| 92 | + * @param IGroupManager $groupManager |
|
| 93 | + * @param IniGetWrapper $iniWrapper |
|
| 94 | + * @param IURLGenerator $urlGenerator |
|
| 95 | + * @param CapabilitiesManager $capabilitiesManager |
|
| 96 | + */ |
|
| 97 | + public function __construct(IL10N $l, |
|
| 98 | + Defaults $defaults, |
|
| 99 | + IAppManager $appManager, |
|
| 100 | + ISession $session, |
|
| 101 | + $currentUser, |
|
| 102 | + IConfig $config, |
|
| 103 | + IGroupManager $groupManager, |
|
| 104 | + IniGetWrapper $iniWrapper, |
|
| 105 | + IURLGenerator $urlGenerator, |
|
| 106 | + CapabilitiesManager $capabilitiesManager, |
|
| 107 | + IInitialStateService $initialStateService) { |
|
| 108 | + $this->l = $l; |
|
| 109 | + $this->defaults = $defaults; |
|
| 110 | + $this->appManager = $appManager; |
|
| 111 | + $this->session = $session; |
|
| 112 | + $this->currentUser = $currentUser; |
|
| 113 | + $this->config = $config; |
|
| 114 | + $this->groupManager = $groupManager; |
|
| 115 | + $this->iniWrapper = $iniWrapper; |
|
| 116 | + $this->urlGenerator = $urlGenerator; |
|
| 117 | + $this->capabilitiesManager = $capabilitiesManager; |
|
| 118 | + $this->initialStateService = $initialStateService; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + public function getConfig() { |
|
| 122 | + $userBackendAllowsPasswordConfirmation = true; |
|
| 123 | + if ($this->currentUser !== null) { |
|
| 124 | + $uid = $this->currentUser->getUID(); |
|
| 125 | + |
|
| 126 | + $backend = $this->currentUser->getBackend(); |
|
| 127 | + if ($backend instanceof IPasswordConfirmationBackend) { |
|
| 128 | + $userBackendAllowsPasswordConfirmation = $backend->canConfirmPassword($uid); |
|
| 129 | + } elseif (isset($this->excludedUserBackEnds[$this->currentUser->getBackendClassName()])) { |
|
| 130 | + $userBackendAllowsPasswordConfirmation = false; |
|
| 131 | + } |
|
| 132 | + } else { |
|
| 133 | + $uid = null; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + // Get the config |
|
| 137 | + $apps_paths = []; |
|
| 138 | + |
|
| 139 | + if ($this->currentUser === null) { |
|
| 140 | + $apps = $this->appManager->getInstalledApps(); |
|
| 141 | + } else { |
|
| 142 | + $apps = $this->appManager->getEnabledAppsForUser($this->currentUser); |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + foreach ($apps as $app) { |
|
| 146 | + $apps_paths[$app] = \OC_App::getAppWebPath($app); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + |
|
| 150 | + $enableLinkPasswordByDefault = $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'); |
|
| 151 | + $enableLinkPasswordByDefault = $enableLinkPasswordByDefault === 'yes'; |
|
| 152 | + $defaultExpireDateEnabled = $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no') === 'yes'; |
|
| 153 | + $defaultExpireDate = $enforceDefaultExpireDate = null; |
|
| 154 | + if ($defaultExpireDateEnabled) { |
|
| 155 | + $defaultExpireDate = (int)$this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'); |
|
| 156 | + $enforceDefaultExpireDate = $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no') === 'yes'; |
|
| 157 | + } |
|
| 158 | + $outgoingServer2serverShareEnabled = $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes'; |
|
| 159 | + |
|
| 160 | + $defaultInternalExpireDateEnabled = $this->config->getAppValue('core', 'shareapi_default_internal_expire_date', 'no') === 'yes'; |
|
| 161 | + $defaultInternalExpireDate = $defaultInternalExpireDateEnforced = null; |
|
| 162 | + if ($defaultInternalExpireDateEnabled) { |
|
| 163 | + $defaultInternalExpireDate = (int)$this->config->getAppValue('core', 'shareapi_internal_expire_after_n_days', '7'); |
|
| 164 | + $defaultInternalExpireDateEnforced = $this->config->getAppValue('core', 'shareapi_internal_enforce_expire_date', 'no') === 'yes'; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + $countOfDataLocation = 0; |
|
| 168 | + $dataLocation = str_replace(\OC::$SERVERROOT . '/', '', $this->config->getSystemValue('datadirectory', ''), $countOfDataLocation); |
|
| 169 | + if ($countOfDataLocation !== 1 || !$this->groupManager->isAdmin($uid)) { |
|
| 170 | + $dataLocation = false; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + if ($this->currentUser instanceof IUser) { |
|
| 174 | + $lastConfirmTimestamp = $this->session->get('last-password-confirm'); |
|
| 175 | + if (!is_int($lastConfirmTimestamp)) { |
|
| 176 | + $lastConfirmTimestamp = 0; |
|
| 177 | + } |
|
| 178 | + } else { |
|
| 179 | + $lastConfirmTimestamp = 0; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + $capabilities = $this->capabilitiesManager->getCapabilities(); |
|
| 183 | + |
|
| 184 | + $config = [ |
|
| 185 | + 'session_lifetime' => min($this->config->getSystemValue('session_lifetime', $this->iniWrapper->getNumeric('session.gc_maxlifetime')), $this->iniWrapper->getNumeric('session.gc_maxlifetime')), |
|
| 186 | + 'session_keepalive' => $this->config->getSystemValue('session_keepalive', true), |
|
| 187 | + 'auto_logout' => $this->config->getSystemValue('auto_logout', false), |
|
| 188 | + 'version' => implode('.', \OCP\Util::getVersion()), |
|
| 189 | + 'versionstring' => \OC_Util::getVersionString(), |
|
| 190 | + 'enable_avatars' => true, // here for legacy reasons - to not crash existing code that relies on this value |
|
| 191 | + 'lost_password_link' => $this->config->getSystemValue('lost_password_link', null), |
|
| 192 | + 'modRewriteWorking' => $this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true', |
|
| 193 | + 'sharing.maxAutocompleteResults' => (int)$this->config->getSystemValue('sharing.maxAutocompleteResults', 0), |
|
| 194 | + 'sharing.minSearchStringLength' => (int)$this->config->getSystemValue('sharing.minSearchStringLength', 0), |
|
| 195 | + 'blacklist_files_regex' => \OCP\Files\FileInfo::BLACKLIST_FILES_REGEX, |
|
| 196 | + ]; |
|
| 197 | + |
|
| 198 | + $array = [ |
|
| 199 | + "_oc_debug" => $this->config->getSystemValue('debug', false) ? 'true' : 'false', |
|
| 200 | + "_oc_isadmin" => $this->groupManager->isAdmin($uid) ? 'true' : 'false', |
|
| 201 | + "backendAllowsPasswordConfirmation" => $userBackendAllowsPasswordConfirmation ? 'true' : 'false', |
|
| 202 | + "oc_dataURL" => is_string($dataLocation) ? "\"" . $dataLocation . "\"" : 'false', |
|
| 203 | + "_oc_webroot" => "\"" . \OC::$WEBROOT . "\"", |
|
| 204 | + "_oc_appswebroots" => str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution |
|
| 205 | + "datepickerFormatDate" => json_encode($this->l->l('jsdate', null)), |
|
| 206 | + 'nc_lastLogin' => $lastConfirmTimestamp, |
|
| 207 | + 'nc_pageLoad' => time(), |
|
| 208 | + "dayNames" => json_encode([ |
|
| 209 | + (string)$this->l->t('Sunday'), |
|
| 210 | + (string)$this->l->t('Monday'), |
|
| 211 | + (string)$this->l->t('Tuesday'), |
|
| 212 | + (string)$this->l->t('Wednesday'), |
|
| 213 | + (string)$this->l->t('Thursday'), |
|
| 214 | + (string)$this->l->t('Friday'), |
|
| 215 | + (string)$this->l->t('Saturday') |
|
| 216 | + ]), |
|
| 217 | + "dayNamesShort" => json_encode([ |
|
| 218 | + (string)$this->l->t('Sun.'), |
|
| 219 | + (string)$this->l->t('Mon.'), |
|
| 220 | + (string)$this->l->t('Tue.'), |
|
| 221 | + (string)$this->l->t('Wed.'), |
|
| 222 | + (string)$this->l->t('Thu.'), |
|
| 223 | + (string)$this->l->t('Fri.'), |
|
| 224 | + (string)$this->l->t('Sat.') |
|
| 225 | + ]), |
|
| 226 | + "dayNamesMin" => json_encode([ |
|
| 227 | + (string)$this->l->t('Su'), |
|
| 228 | + (string)$this->l->t('Mo'), |
|
| 229 | + (string)$this->l->t('Tu'), |
|
| 230 | + (string)$this->l->t('We'), |
|
| 231 | + (string)$this->l->t('Th'), |
|
| 232 | + (string)$this->l->t('Fr'), |
|
| 233 | + (string)$this->l->t('Sa') |
|
| 234 | + ]), |
|
| 235 | + "monthNames" => json_encode([ |
|
| 236 | + (string)$this->l->t('January'), |
|
| 237 | + (string)$this->l->t('February'), |
|
| 238 | + (string)$this->l->t('March'), |
|
| 239 | + (string)$this->l->t('April'), |
|
| 240 | + (string)$this->l->t('May'), |
|
| 241 | + (string)$this->l->t('June'), |
|
| 242 | + (string)$this->l->t('July'), |
|
| 243 | + (string)$this->l->t('August'), |
|
| 244 | + (string)$this->l->t('September'), |
|
| 245 | + (string)$this->l->t('October'), |
|
| 246 | + (string)$this->l->t('November'), |
|
| 247 | + (string)$this->l->t('December') |
|
| 248 | + ]), |
|
| 249 | + "monthNamesShort" => json_encode([ |
|
| 250 | + (string)$this->l->t('Jan.'), |
|
| 251 | + (string)$this->l->t('Feb.'), |
|
| 252 | + (string)$this->l->t('Mar.'), |
|
| 253 | + (string)$this->l->t('Apr.'), |
|
| 254 | + (string)$this->l->t('May.'), |
|
| 255 | + (string)$this->l->t('Jun.'), |
|
| 256 | + (string)$this->l->t('Jul.'), |
|
| 257 | + (string)$this->l->t('Aug.'), |
|
| 258 | + (string)$this->l->t('Sep.'), |
|
| 259 | + (string)$this->l->t('Oct.'), |
|
| 260 | + (string)$this->l->t('Nov.'), |
|
| 261 | + (string)$this->l->t('Dec.') |
|
| 262 | + ]), |
|
| 263 | + "firstDay" => json_encode($this->l->l('firstday', null)), |
|
| 264 | + "_oc_config" => json_encode($config), |
|
| 265 | + "oc_appconfig" => json_encode([ |
|
| 266 | + 'core' => [ |
|
| 267 | + 'defaultExpireDateEnabled' => $defaultExpireDateEnabled, |
|
| 268 | + 'defaultExpireDate' => $defaultExpireDate, |
|
| 269 | + 'defaultExpireDateEnforced' => $enforceDefaultExpireDate, |
|
| 270 | + 'enforcePasswordForPublicLink' => \OCP\Util::isPublicLinkPasswordRequired(), |
|
| 271 | + 'enableLinkPasswordByDefault' => $enableLinkPasswordByDefault, |
|
| 272 | + 'sharingDisabledForUser' => \OCP\Util::isSharingDisabledForUser(), |
|
| 273 | + 'resharingAllowed' => \OC\Share\Share::isResharingAllowed(), |
|
| 274 | + 'remoteShareAllowed' => $outgoingServer2serverShareEnabled, |
|
| 275 | + 'federatedCloudShareDoc' => $this->urlGenerator->linkToDocs('user-sharing-federated'), |
|
| 276 | + 'allowGroupSharing' => \OC::$server->getShareManager()->allowGroupSharing(), |
|
| 277 | + 'defaultInternalExpireDateEnabled' => $defaultInternalExpireDateEnabled, |
|
| 278 | + 'defaultInternalExpireDate' => $defaultInternalExpireDate, |
|
| 279 | + 'defaultInternalExpireDateEnforced' => $defaultInternalExpireDateEnforced, |
|
| 280 | + ] |
|
| 281 | + ]), |
|
| 282 | + "_theme" => json_encode([ |
|
| 283 | + 'entity' => $this->defaults->getEntity(), |
|
| 284 | + 'name' => $this->defaults->getName(), |
|
| 285 | + 'title' => $this->defaults->getTitle(), |
|
| 286 | + 'baseUrl' => $this->defaults->getBaseUrl(), |
|
| 287 | + 'syncClientUrl' => $this->defaults->getSyncClientUrl(), |
|
| 288 | + 'docBaseUrl' => $this->defaults->getDocBaseUrl(), |
|
| 289 | + 'docPlaceholderUrl' => $this->defaults->buildDocLinkToKey('PLACEHOLDER'), |
|
| 290 | + 'slogan' => $this->defaults->getSlogan(), |
|
| 291 | + 'logoClaim' => '', |
|
| 292 | + 'shortFooter' => $this->defaults->getShortFooter(), |
|
| 293 | + 'longFooter' => $this->defaults->getLongFooter(), |
|
| 294 | + 'folder' => \OC_Util::getTheme(), |
|
| 295 | + ]), |
|
| 296 | + "_oc_capabilities" => json_encode($capabilities), |
|
| 297 | + ]; |
|
| 298 | + |
|
| 299 | + if ($this->currentUser !== null) { |
|
| 300 | + $array['oc_userconfig'] = json_encode([ |
|
| 301 | + 'avatar' => [ |
|
| 302 | + 'version' => (int)$this->config->getUserValue($uid, 'avatar', 'version', 0), |
|
| 303 | + 'generated' => $this->config->getUserValue($uid, 'avatar', 'generated', 'true') === 'true', |
|
| 304 | + ] |
|
| 305 | + ]); |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + $this->initialStateService->provideInitialState('core', 'config', $config); |
|
| 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 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | $defaultExpireDateEnabled = $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no') === 'yes'; |
| 153 | 153 | $defaultExpireDate = $enforceDefaultExpireDate = null; |
| 154 | 154 | if ($defaultExpireDateEnabled) { |
| 155 | - $defaultExpireDate = (int)$this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'); |
|
| 155 | + $defaultExpireDate = (int) $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'); |
|
| 156 | 156 | $enforceDefaultExpireDate = $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no') === 'yes'; |
| 157 | 157 | } |
| 158 | 158 | $outgoingServer2serverShareEnabled = $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes'; |
@@ -160,12 +160,12 @@ discard block |
||
| 160 | 160 | $defaultInternalExpireDateEnabled = $this->config->getAppValue('core', 'shareapi_default_internal_expire_date', 'no') === 'yes'; |
| 161 | 161 | $defaultInternalExpireDate = $defaultInternalExpireDateEnforced = null; |
| 162 | 162 | if ($defaultInternalExpireDateEnabled) { |
| 163 | - $defaultInternalExpireDate = (int)$this->config->getAppValue('core', 'shareapi_internal_expire_after_n_days', '7'); |
|
| 163 | + $defaultInternalExpireDate = (int) $this->config->getAppValue('core', 'shareapi_internal_expire_after_n_days', '7'); |
|
| 164 | 164 | $defaultInternalExpireDateEnforced = $this->config->getAppValue('core', 'shareapi_internal_enforce_expire_date', 'no') === 'yes'; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | $countOfDataLocation = 0; |
| 168 | - $dataLocation = str_replace(\OC::$SERVERROOT . '/', '', $this->config->getSystemValue('datadirectory', ''), $countOfDataLocation); |
|
| 168 | + $dataLocation = str_replace(\OC::$SERVERROOT.'/', '', $this->config->getSystemValue('datadirectory', ''), $countOfDataLocation); |
|
| 169 | 169 | if ($countOfDataLocation !== 1 || !$this->groupManager->isAdmin($uid)) { |
| 170 | 170 | $dataLocation = false; |
| 171 | 171 | } |
@@ -190,8 +190,8 @@ discard block |
||
| 190 | 190 | 'enable_avatars' => true, // here for legacy reasons - to not crash existing code that relies on this value |
| 191 | 191 | 'lost_password_link' => $this->config->getSystemValue('lost_password_link', null), |
| 192 | 192 | 'modRewriteWorking' => $this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true', |
| 193 | - 'sharing.maxAutocompleteResults' => (int)$this->config->getSystemValue('sharing.maxAutocompleteResults', 0), |
|
| 194 | - 'sharing.minSearchStringLength' => (int)$this->config->getSystemValue('sharing.minSearchStringLength', 0), |
|
| 193 | + 'sharing.maxAutocompleteResults' => (int) $this->config->getSystemValue('sharing.maxAutocompleteResults', 0), |
|
| 194 | + 'sharing.minSearchStringLength' => (int) $this->config->getSystemValue('sharing.minSearchStringLength', 0), |
|
| 195 | 195 | 'blacklist_files_regex' => \OCP\Files\FileInfo::BLACKLIST_FILES_REGEX, |
| 196 | 196 | ]; |
| 197 | 197 | |
@@ -199,66 +199,66 @@ discard block |
||
| 199 | 199 | "_oc_debug" => $this->config->getSystemValue('debug', false) ? 'true' : 'false', |
| 200 | 200 | "_oc_isadmin" => $this->groupManager->isAdmin($uid) ? 'true' : 'false', |
| 201 | 201 | "backendAllowsPasswordConfirmation" => $userBackendAllowsPasswordConfirmation ? 'true' : 'false', |
| 202 | - "oc_dataURL" => is_string($dataLocation) ? "\"" . $dataLocation . "\"" : 'false', |
|
| 203 | - "_oc_webroot" => "\"" . \OC::$WEBROOT . "\"", |
|
| 202 | + "oc_dataURL" => is_string($dataLocation) ? "\"".$dataLocation."\"" : 'false', |
|
| 203 | + "_oc_webroot" => "\"".\OC::$WEBROOT."\"", |
|
| 204 | 204 | "_oc_appswebroots" => str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution |
| 205 | 205 | "datepickerFormatDate" => json_encode($this->l->l('jsdate', null)), |
| 206 | 206 | 'nc_lastLogin' => $lastConfirmTimestamp, |
| 207 | 207 | 'nc_pageLoad' => time(), |
| 208 | 208 | "dayNames" => json_encode([ |
| 209 | - (string)$this->l->t('Sunday'), |
|
| 210 | - (string)$this->l->t('Monday'), |
|
| 211 | - (string)$this->l->t('Tuesday'), |
|
| 212 | - (string)$this->l->t('Wednesday'), |
|
| 213 | - (string)$this->l->t('Thursday'), |
|
| 214 | - (string)$this->l->t('Friday'), |
|
| 215 | - (string)$this->l->t('Saturday') |
|
| 209 | + (string) $this->l->t('Sunday'), |
|
| 210 | + (string) $this->l->t('Monday'), |
|
| 211 | + (string) $this->l->t('Tuesday'), |
|
| 212 | + (string) $this->l->t('Wednesday'), |
|
| 213 | + (string) $this->l->t('Thursday'), |
|
| 214 | + (string) $this->l->t('Friday'), |
|
| 215 | + (string) $this->l->t('Saturday') |
|
| 216 | 216 | ]), |
| 217 | 217 | "dayNamesShort" => json_encode([ |
| 218 | - (string)$this->l->t('Sun.'), |
|
| 219 | - (string)$this->l->t('Mon.'), |
|
| 220 | - (string)$this->l->t('Tue.'), |
|
| 221 | - (string)$this->l->t('Wed.'), |
|
| 222 | - (string)$this->l->t('Thu.'), |
|
| 223 | - (string)$this->l->t('Fri.'), |
|
| 224 | - (string)$this->l->t('Sat.') |
|
| 218 | + (string) $this->l->t('Sun.'), |
|
| 219 | + (string) $this->l->t('Mon.'), |
|
| 220 | + (string) $this->l->t('Tue.'), |
|
| 221 | + (string) $this->l->t('Wed.'), |
|
| 222 | + (string) $this->l->t('Thu.'), |
|
| 223 | + (string) $this->l->t('Fri.'), |
|
| 224 | + (string) $this->l->t('Sat.') |
|
| 225 | 225 | ]), |
| 226 | 226 | "dayNamesMin" => json_encode([ |
| 227 | - (string)$this->l->t('Su'), |
|
| 228 | - (string)$this->l->t('Mo'), |
|
| 229 | - (string)$this->l->t('Tu'), |
|
| 230 | - (string)$this->l->t('We'), |
|
| 231 | - (string)$this->l->t('Th'), |
|
| 232 | - (string)$this->l->t('Fr'), |
|
| 233 | - (string)$this->l->t('Sa') |
|
| 227 | + (string) $this->l->t('Su'), |
|
| 228 | + (string) $this->l->t('Mo'), |
|
| 229 | + (string) $this->l->t('Tu'), |
|
| 230 | + (string) $this->l->t('We'), |
|
| 231 | + (string) $this->l->t('Th'), |
|
| 232 | + (string) $this->l->t('Fr'), |
|
| 233 | + (string) $this->l->t('Sa') |
|
| 234 | 234 | ]), |
| 235 | 235 | "monthNames" => json_encode([ |
| 236 | - (string)$this->l->t('January'), |
|
| 237 | - (string)$this->l->t('February'), |
|
| 238 | - (string)$this->l->t('March'), |
|
| 239 | - (string)$this->l->t('April'), |
|
| 240 | - (string)$this->l->t('May'), |
|
| 241 | - (string)$this->l->t('June'), |
|
| 242 | - (string)$this->l->t('July'), |
|
| 243 | - (string)$this->l->t('August'), |
|
| 244 | - (string)$this->l->t('September'), |
|
| 245 | - (string)$this->l->t('October'), |
|
| 246 | - (string)$this->l->t('November'), |
|
| 247 | - (string)$this->l->t('December') |
|
| 236 | + (string) $this->l->t('January'), |
|
| 237 | + (string) $this->l->t('February'), |
|
| 238 | + (string) $this->l->t('March'), |
|
| 239 | + (string) $this->l->t('April'), |
|
| 240 | + (string) $this->l->t('May'), |
|
| 241 | + (string) $this->l->t('June'), |
|
| 242 | + (string) $this->l->t('July'), |
|
| 243 | + (string) $this->l->t('August'), |
|
| 244 | + (string) $this->l->t('September'), |
|
| 245 | + (string) $this->l->t('October'), |
|
| 246 | + (string) $this->l->t('November'), |
|
| 247 | + (string) $this->l->t('December') |
|
| 248 | 248 | ]), |
| 249 | 249 | "monthNamesShort" => json_encode([ |
| 250 | - (string)$this->l->t('Jan.'), |
|
| 251 | - (string)$this->l->t('Feb.'), |
|
| 252 | - (string)$this->l->t('Mar.'), |
|
| 253 | - (string)$this->l->t('Apr.'), |
|
| 254 | - (string)$this->l->t('May.'), |
|
| 255 | - (string)$this->l->t('Jun.'), |
|
| 256 | - (string)$this->l->t('Jul.'), |
|
| 257 | - (string)$this->l->t('Aug.'), |
|
| 258 | - (string)$this->l->t('Sep.'), |
|
| 259 | - (string)$this->l->t('Oct.'), |
|
| 260 | - (string)$this->l->t('Nov.'), |
|
| 261 | - (string)$this->l->t('Dec.') |
|
| 250 | + (string) $this->l->t('Jan.'), |
|
| 251 | + (string) $this->l->t('Feb.'), |
|
| 252 | + (string) $this->l->t('Mar.'), |
|
| 253 | + (string) $this->l->t('Apr.'), |
|
| 254 | + (string) $this->l->t('May.'), |
|
| 255 | + (string) $this->l->t('Jun.'), |
|
| 256 | + (string) $this->l->t('Jul.'), |
|
| 257 | + (string) $this->l->t('Aug.'), |
|
| 258 | + (string) $this->l->t('Sep.'), |
|
| 259 | + (string) $this->l->t('Oct.'), |
|
| 260 | + (string) $this->l->t('Nov.'), |
|
| 261 | + (string) $this->l->t('Dec.') |
|
| 262 | 262 | ]), |
| 263 | 263 | "firstDay" => json_encode($this->l->l('firstday', null)), |
| 264 | 264 | "_oc_config" => json_encode($config), |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | if ($this->currentUser !== null) { |
| 300 | 300 | $array['oc_userconfig'] = json_encode([ |
| 301 | 301 | 'avatar' => [ |
| 302 | - 'version' => (int)$this->config->getUserValue($uid, 'avatar', 'version', 0), |
|
| 302 | + 'version' => (int) $this->config->getUserValue($uid, 'avatar', 'version', 0), |
|
| 303 | 303 | 'generated' => $this->config->getUserValue($uid, 'avatar', 'generated', 'true') === 'true', |
| 304 | 304 | ] |
| 305 | 305 | ]); |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | |
| 315 | 315 | // Echo it |
| 316 | 316 | foreach ($array as $setting => $value) { |
| 317 | - $result .= 'var '. $setting . '='. $value . ';' . PHP_EOL; |
|
| 317 | + $result .= 'var '.$setting.'='.$value.';'.PHP_EOL; |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | return $result; |