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