@@ -27,28 +27,28 @@ |
||
| 27 | 27 | use OCP\Settings\ISettings; |
| 28 | 28 | |
| 29 | 29 | class ServerDevNotice implements ISettings { |
| 30 | - /** |
|
| 31 | - * @return TemplateResponse |
|
| 32 | - */ |
|
| 33 | - public function getForm() { |
|
| 34 | - return new TemplateResponse('settings', 'settings/personal/development.notice'); |
|
| 35 | - } |
|
| 30 | + /** |
|
| 31 | + * @return TemplateResponse |
|
| 32 | + */ |
|
| 33 | + public function getForm() { |
|
| 34 | + return new TemplateResponse('settings', 'settings/personal/development.notice'); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @return string the section ID, e.g. 'sharing' |
|
| 39 | - */ |
|
| 40 | - public function getSection() { |
|
| 41 | - return 'personal-info'; |
|
| 42 | - } |
|
| 37 | + /** |
|
| 38 | + * @return string the section ID, e.g. 'sharing' |
|
| 39 | + */ |
|
| 40 | + public function getSection() { |
|
| 41 | + return 'personal-info'; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @return int whether the form should be rather on the top or bottom of |
|
| 46 | - * the admin section. The forms are arranged in ascending order of the |
|
| 47 | - * priority values. It is required to return a value between 0 and 100. |
|
| 48 | - * |
|
| 49 | - * E.g.: 70 |
|
| 50 | - */ |
|
| 51 | - public function getPriority() { |
|
| 52 | - return 1000; |
|
| 53 | - } |
|
| 44 | + /** |
|
| 45 | + * @return int whether the form should be rather on the top or bottom of |
|
| 46 | + * the admin section. The forms are arranged in ascending order of the |
|
| 47 | + * priority values. It is required to return a value between 0 and 100. |
|
| 48 | + * |
|
| 49 | + * E.g.: 70 |
|
| 50 | + */ |
|
| 51 | + public function getPriority() { |
|
| 52 | + return 1000; |
|
| 53 | + } |
|
| 54 | 54 | } |
@@ -49,354 +49,354 @@ |
||
| 49 | 49 | use OCP\Util; |
| 50 | 50 | |
| 51 | 51 | class Manager implements IManager { |
| 52 | - /** @var ILogger */ |
|
| 53 | - private $log; |
|
| 54 | - /** @var IDBConnection */ |
|
| 55 | - private $dbc; |
|
| 56 | - /** @var IL10N */ |
|
| 57 | - private $l; |
|
| 58 | - /** @var IConfig */ |
|
| 59 | - private $config; |
|
| 60 | - /** @var EncryptionManager */ |
|
| 61 | - private $encryptionManager; |
|
| 62 | - /** @var IUserManager */ |
|
| 63 | - private $userManager; |
|
| 64 | - /** @var ILockingProvider */ |
|
| 65 | - private $lockingProvider; |
|
| 66 | - /** @var IRequest */ |
|
| 67 | - private $request; |
|
| 68 | - /** @var IURLGenerator */ |
|
| 69 | - private $url; |
|
| 70 | - /** @var AccountManager */ |
|
| 71 | - private $accountManager; |
|
| 72 | - /** @var IGroupManager */ |
|
| 73 | - private $groupManager; |
|
| 74 | - /** @var IFactory */ |
|
| 75 | - private $l10nFactory; |
|
| 76 | - /** @var IAppManager */ |
|
| 77 | - private $appManager; |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @param ILogger $log |
|
| 81 | - * @param IDBConnection $dbc |
|
| 82 | - * @param IL10N $l |
|
| 83 | - * @param IConfig $config |
|
| 84 | - * @param EncryptionManager $encryptionManager |
|
| 85 | - * @param IUserManager $userManager |
|
| 86 | - * @param ILockingProvider $lockingProvider |
|
| 87 | - * @param IRequest $request |
|
| 88 | - * @param IURLGenerator $url |
|
| 89 | - * @param AccountManager $accountManager |
|
| 90 | - * @param IGroupManager $groupManager |
|
| 91 | - * @param IFactory $l10nFactory |
|
| 92 | - * @param IAppManager $appManager |
|
| 93 | - */ |
|
| 94 | - public function __construct( |
|
| 95 | - ILogger $log, |
|
| 96 | - IDBConnection $dbc, |
|
| 97 | - IL10N $l, |
|
| 98 | - IConfig $config, |
|
| 99 | - EncryptionManager $encryptionManager, |
|
| 100 | - IUserManager $userManager, |
|
| 101 | - ILockingProvider $lockingProvider, |
|
| 102 | - IRequest $request, |
|
| 103 | - IURLGenerator $url, |
|
| 104 | - AccountManager $accountManager, |
|
| 105 | - IGroupManager $groupManager, |
|
| 106 | - IFactory $l10nFactory, |
|
| 107 | - IAppManager $appManager |
|
| 108 | - ) { |
|
| 109 | - $this->log = $log; |
|
| 110 | - $this->dbc = $dbc; |
|
| 111 | - $this->l = $l; |
|
| 112 | - $this->config = $config; |
|
| 113 | - $this->encryptionManager = $encryptionManager; |
|
| 114 | - $this->userManager = $userManager; |
|
| 115 | - $this->lockingProvider = $lockingProvider; |
|
| 116 | - $this->request = $request; |
|
| 117 | - $this->url = $url; |
|
| 118 | - $this->accountManager = $accountManager; |
|
| 119 | - $this->groupManager = $groupManager; |
|
| 120 | - $this->l10nFactory = $l10nFactory; |
|
| 121 | - $this->appManager = $appManager; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** @var array */ |
|
| 125 | - protected $sectionClasses = []; |
|
| 126 | - |
|
| 127 | - /** @var array */ |
|
| 128 | - protected $sections = []; |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * @param string $type 'admin' or 'personal' |
|
| 132 | - * @param string $section Class must implement OCP\Settings\ISection |
|
| 133 | - * @return void |
|
| 134 | - */ |
|
| 135 | - public function registerSection(string $type, string $section) { |
|
| 136 | - $this->sectionClasses[$section] = $type; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * @param string $type 'admin' or 'personal' |
|
| 141 | - * @return ISection[] |
|
| 142 | - */ |
|
| 143 | - protected function getSections(string $type): array { |
|
| 144 | - if (!isset($this->sections[$type])) { |
|
| 145 | - $this->sections[$type] = []; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - foreach ($this->sectionClasses as $class => $sectionType) { |
|
| 149 | - try { |
|
| 150 | - /** @var ISection $section */ |
|
| 151 | - $section = \OC::$server->query($class); |
|
| 152 | - } catch (QueryException $e) { |
|
| 153 | - $this->log->logException($e, ['level' => ILogger::INFO]); |
|
| 154 | - continue; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - if (!$section instanceof ISection) { |
|
| 158 | - $this->log->logException(new \InvalidArgumentException('Invalid settings section registered'), ['level' => ILogger::INFO]); |
|
| 159 | - continue; |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - $this->sections[$sectionType][$section->getID()] = $section; |
|
| 163 | - |
|
| 164 | - unset($this->sectionClasses[$class]); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - return $this->sections[$type]; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - /** @var array */ |
|
| 171 | - protected $settingClasses = []; |
|
| 172 | - |
|
| 173 | - /** @var array */ |
|
| 174 | - protected $settings = []; |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * @param string $type 'admin' or 'personal' |
|
| 178 | - * @param string $setting Class must implement OCP\Settings\ISetting |
|
| 179 | - * @return void |
|
| 180 | - */ |
|
| 181 | - public function registerSetting(string $type, string $setting) { |
|
| 182 | - $this->settingClasses[$setting] = $type; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * @param string $type 'admin' or 'personal' |
|
| 187 | - * @param string $section |
|
| 188 | - * @return ISettings[] |
|
| 189 | - */ |
|
| 190 | - protected function getSettings(string $type, string $section): array { |
|
| 191 | - if (!isset($this->settings[$type])) { |
|
| 192 | - $this->settings[$type] = []; |
|
| 193 | - } |
|
| 194 | - if (!isset($this->settings[$type][$section])) { |
|
| 195 | - $this->settings[$type][$section] = []; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - foreach ($this->settingClasses as $class => $settingsType) { |
|
| 199 | - try { |
|
| 200 | - /** @var ISettings $setting */ |
|
| 201 | - $setting = \OC::$server->query($class); |
|
| 202 | - } catch (QueryException $e) { |
|
| 203 | - $this->log->logException($e, ['level' => ILogger::INFO]); |
|
| 204 | - continue; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - if (!$setting instanceof ISettings) { |
|
| 208 | - $this->log->logException(new \InvalidArgumentException('Invalid settings setting registered'), ['level' => ILogger::INFO]); |
|
| 209 | - continue; |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - if (!isset($this->settings[$settingsType][$setting->getSection()])) { |
|
| 213 | - $this->settings[$settingsType][$setting->getSection()] = []; |
|
| 214 | - } |
|
| 215 | - $this->settings[$settingsType][$setting->getSection()][] = $setting; |
|
| 216 | - |
|
| 217 | - unset($this->settingClasses[$class]); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - return $this->settings[$type][$section]; |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * @inheritdoc |
|
| 225 | - */ |
|
| 226 | - public function getAdminSections(): array { |
|
| 227 | - // built-in sections |
|
| 228 | - $sections = [ |
|
| 229 | - 0 => [new Section('overview', $this->l->t('Overview'), 0, $this->url->imagePath('settings', 'admin.svg'))], |
|
| 230 | - 1 => [new Section('server', $this->l->t('Basic settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))], |
|
| 231 | - 5 => [new Section('sharing', $this->l->t('Sharing'), 0, $this->url->imagePath('core', 'actions/share.svg'))], |
|
| 232 | - 10 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('core', 'actions/password.svg'))], |
|
| 233 | - 45 => [new Section('encryption', $this->l->t('Encryption'), 0, $this->url->imagePath('core', 'actions/password.svg'))], |
|
| 234 | - 50 => [new Section('groupware', $this->l->t('Groupware'), 0, $this->url->imagePath('core', 'places/contacts-dark.svg'))], |
|
| 235 | - 98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))], |
|
| 236 | - ]; |
|
| 237 | - |
|
| 238 | - $appSections = $this->getSections('admin'); |
|
| 239 | - |
|
| 240 | - foreach ($appSections as $section) { |
|
| 241 | - /** @var ISection $section */ |
|
| 242 | - if (!isset($sections[$section->getPriority()])) { |
|
| 243 | - $sections[$section->getPriority()] = []; |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - $sections[$section->getPriority()][] = $section; |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - ksort($sections); |
|
| 250 | - |
|
| 251 | - return $sections; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - /** |
|
| 255 | - * @param string $section |
|
| 256 | - * @return ISection[] |
|
| 257 | - */ |
|
| 258 | - private function getBuiltInAdminSettings($section): array { |
|
| 259 | - $forms = []; |
|
| 260 | - |
|
| 261 | - if ($section === 'overview') { |
|
| 262 | - /** @var ISettings $form */ |
|
| 263 | - $form = new Admin\Overview($this->config); |
|
| 264 | - $forms[$form->getPriority()] = [$form]; |
|
| 265 | - } |
|
| 266 | - if ($section === 'server') { |
|
| 267 | - /** @var ISettings $form */ |
|
| 268 | - $form = new Admin\Server($this->dbc, $this->request, $this->config, $this->lockingProvider, $this->l); |
|
| 269 | - $forms[$form->getPriority()] = [$form]; |
|
| 270 | - $form = new Admin\Mail($this->config); |
|
| 271 | - $forms[$form->getPriority()] = [$form]; |
|
| 272 | - } |
|
| 273 | - if ($section === 'encryption') { |
|
| 274 | - /** @var ISettings $form */ |
|
| 275 | - $form = new Admin\Encryption($this->encryptionManager, $this->userManager); |
|
| 276 | - $forms[$form->getPriority()] = [$form]; |
|
| 277 | - } |
|
| 278 | - if ($section === 'sharing') { |
|
| 279 | - /** @var ISettings $form */ |
|
| 280 | - $form = new Admin\Sharing($this->config, $this->l); |
|
| 281 | - $forms[$form->getPriority()] = [$form]; |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - return $forms; |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - /** |
|
| 288 | - * @param string $section |
|
| 289 | - * @return ISection[] |
|
| 290 | - */ |
|
| 291 | - private function getBuiltInPersonalSettings($section): array { |
|
| 292 | - $forms = []; |
|
| 293 | - |
|
| 294 | - if ($section === 'personal-info') { |
|
| 295 | - /** @var ISettings $form */ |
|
| 296 | - $form = new Personal\PersonalInfo( |
|
| 297 | - $this->config, |
|
| 298 | - $this->userManager, |
|
| 299 | - $this->groupManager, |
|
| 300 | - $this->accountManager, |
|
| 301 | - $this->appManager, |
|
| 302 | - $this->l10nFactory, |
|
| 303 | - $this->l |
|
| 304 | - ); |
|
| 305 | - $forms[$form->getPriority()] = [$form]; |
|
| 306 | - $form = new Personal\ServerDevNotice(); |
|
| 307 | - $forms[$form->getPriority()] = [$form]; |
|
| 308 | - } |
|
| 309 | - if($section === 'security') { |
|
| 310 | - /** @var ISettings $form */ |
|
| 311 | - $form = new Personal\Security(); |
|
| 312 | - $forms[$form->getPriority()] = [$form]; |
|
| 313 | - } |
|
| 314 | - if ($section === 'additional') { |
|
| 315 | - /** @var ISettings $form */ |
|
| 316 | - $form = new Personal\Additional(); |
|
| 317 | - $forms[$form->getPriority()] = [$form]; |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - return $forms; |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - /** |
|
| 324 | - * @inheritdoc |
|
| 325 | - */ |
|
| 326 | - public function getAdminSettings($section): array { |
|
| 327 | - $settings = $this->getBuiltInAdminSettings($section); |
|
| 328 | - $appSettings = $this->getSettings('admin', $section); |
|
| 329 | - |
|
| 330 | - foreach ($appSettings as $setting) { |
|
| 331 | - if (!isset($settings[$setting->getPriority()])) { |
|
| 332 | - $settings[$setting->getPriority()] = []; |
|
| 333 | - } |
|
| 334 | - $settings[$setting->getPriority()][] = $setting; |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - ksort($settings); |
|
| 338 | - return $settings; |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - /** |
|
| 342 | - * @inheritdoc |
|
| 343 | - */ |
|
| 344 | - public function getPersonalSections(): array { |
|
| 345 | - $sections = [ |
|
| 346 | - 0 => [new Section('personal-info', $this->l->t('Personal info'), 0, $this->url->imagePath('core', 'actions/info.svg'))], |
|
| 347 | - 5 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('settings', 'password.svg'))], |
|
| 348 | - 15 => [new Section('sync-clients', $this->l->t('Mobile & desktop'), 0, $this->url->imagePath('core', 'clients/phone.svg'))], |
|
| 349 | - ]; |
|
| 350 | - |
|
| 351 | - $legacyForms = \OC_App::getForms('personal'); |
|
| 352 | - if(!empty($legacyForms) && $this->hasLegacyPersonalSettingsToRender($legacyForms)) { |
|
| 353 | - $sections[98] = [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))]; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - $appSections = $this->getSections('personal'); |
|
| 357 | - |
|
| 358 | - foreach ($appSections as $section) { |
|
| 359 | - /** @var ISection $section */ |
|
| 360 | - if (!isset($sections[$section->getPriority()])) { |
|
| 361 | - $sections[$section->getPriority()] = []; |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - $sections[$section->getPriority()][] = $section; |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - ksort($sections); |
|
| 368 | - |
|
| 369 | - return $sections; |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - /** |
|
| 373 | - * @param string[] $forms |
|
| 374 | - * @return bool |
|
| 375 | - */ |
|
| 376 | - private function hasLegacyPersonalSettingsToRender(array $forms): bool { |
|
| 377 | - foreach ($forms as $form) { |
|
| 378 | - if(trim($form) !== '') { |
|
| 379 | - return true; |
|
| 380 | - } |
|
| 381 | - } |
|
| 382 | - return false; |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - /** |
|
| 386 | - * @inheritdoc |
|
| 387 | - */ |
|
| 388 | - public function getPersonalSettings($section): array { |
|
| 389 | - $settings = $this->getBuiltInPersonalSettings($section); |
|
| 390 | - $appSettings = $this->getSettings('personal', $section); |
|
| 391 | - |
|
| 392 | - foreach ($appSettings as $setting) { |
|
| 393 | - if (!isset($settings[$setting->getPriority()])) { |
|
| 394 | - $settings[$setting->getPriority()] = []; |
|
| 395 | - } |
|
| 396 | - $settings[$setting->getPriority()][] = $setting; |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - ksort($settings); |
|
| 400 | - return $settings; |
|
| 401 | - } |
|
| 52 | + /** @var ILogger */ |
|
| 53 | + private $log; |
|
| 54 | + /** @var IDBConnection */ |
|
| 55 | + private $dbc; |
|
| 56 | + /** @var IL10N */ |
|
| 57 | + private $l; |
|
| 58 | + /** @var IConfig */ |
|
| 59 | + private $config; |
|
| 60 | + /** @var EncryptionManager */ |
|
| 61 | + private $encryptionManager; |
|
| 62 | + /** @var IUserManager */ |
|
| 63 | + private $userManager; |
|
| 64 | + /** @var ILockingProvider */ |
|
| 65 | + private $lockingProvider; |
|
| 66 | + /** @var IRequest */ |
|
| 67 | + private $request; |
|
| 68 | + /** @var IURLGenerator */ |
|
| 69 | + private $url; |
|
| 70 | + /** @var AccountManager */ |
|
| 71 | + private $accountManager; |
|
| 72 | + /** @var IGroupManager */ |
|
| 73 | + private $groupManager; |
|
| 74 | + /** @var IFactory */ |
|
| 75 | + private $l10nFactory; |
|
| 76 | + /** @var IAppManager */ |
|
| 77 | + private $appManager; |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @param ILogger $log |
|
| 81 | + * @param IDBConnection $dbc |
|
| 82 | + * @param IL10N $l |
|
| 83 | + * @param IConfig $config |
|
| 84 | + * @param EncryptionManager $encryptionManager |
|
| 85 | + * @param IUserManager $userManager |
|
| 86 | + * @param ILockingProvider $lockingProvider |
|
| 87 | + * @param IRequest $request |
|
| 88 | + * @param IURLGenerator $url |
|
| 89 | + * @param AccountManager $accountManager |
|
| 90 | + * @param IGroupManager $groupManager |
|
| 91 | + * @param IFactory $l10nFactory |
|
| 92 | + * @param IAppManager $appManager |
|
| 93 | + */ |
|
| 94 | + public function __construct( |
|
| 95 | + ILogger $log, |
|
| 96 | + IDBConnection $dbc, |
|
| 97 | + IL10N $l, |
|
| 98 | + IConfig $config, |
|
| 99 | + EncryptionManager $encryptionManager, |
|
| 100 | + IUserManager $userManager, |
|
| 101 | + ILockingProvider $lockingProvider, |
|
| 102 | + IRequest $request, |
|
| 103 | + IURLGenerator $url, |
|
| 104 | + AccountManager $accountManager, |
|
| 105 | + IGroupManager $groupManager, |
|
| 106 | + IFactory $l10nFactory, |
|
| 107 | + IAppManager $appManager |
|
| 108 | + ) { |
|
| 109 | + $this->log = $log; |
|
| 110 | + $this->dbc = $dbc; |
|
| 111 | + $this->l = $l; |
|
| 112 | + $this->config = $config; |
|
| 113 | + $this->encryptionManager = $encryptionManager; |
|
| 114 | + $this->userManager = $userManager; |
|
| 115 | + $this->lockingProvider = $lockingProvider; |
|
| 116 | + $this->request = $request; |
|
| 117 | + $this->url = $url; |
|
| 118 | + $this->accountManager = $accountManager; |
|
| 119 | + $this->groupManager = $groupManager; |
|
| 120 | + $this->l10nFactory = $l10nFactory; |
|
| 121 | + $this->appManager = $appManager; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** @var array */ |
|
| 125 | + protected $sectionClasses = []; |
|
| 126 | + |
|
| 127 | + /** @var array */ |
|
| 128 | + protected $sections = []; |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * @param string $type 'admin' or 'personal' |
|
| 132 | + * @param string $section Class must implement OCP\Settings\ISection |
|
| 133 | + * @return void |
|
| 134 | + */ |
|
| 135 | + public function registerSection(string $type, string $section) { |
|
| 136 | + $this->sectionClasses[$section] = $type; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * @param string $type 'admin' or 'personal' |
|
| 141 | + * @return ISection[] |
|
| 142 | + */ |
|
| 143 | + protected function getSections(string $type): array { |
|
| 144 | + if (!isset($this->sections[$type])) { |
|
| 145 | + $this->sections[$type] = []; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + foreach ($this->sectionClasses as $class => $sectionType) { |
|
| 149 | + try { |
|
| 150 | + /** @var ISection $section */ |
|
| 151 | + $section = \OC::$server->query($class); |
|
| 152 | + } catch (QueryException $e) { |
|
| 153 | + $this->log->logException($e, ['level' => ILogger::INFO]); |
|
| 154 | + continue; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + if (!$section instanceof ISection) { |
|
| 158 | + $this->log->logException(new \InvalidArgumentException('Invalid settings section registered'), ['level' => ILogger::INFO]); |
|
| 159 | + continue; |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + $this->sections[$sectionType][$section->getID()] = $section; |
|
| 163 | + |
|
| 164 | + unset($this->sectionClasses[$class]); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + return $this->sections[$type]; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + /** @var array */ |
|
| 171 | + protected $settingClasses = []; |
|
| 172 | + |
|
| 173 | + /** @var array */ |
|
| 174 | + protected $settings = []; |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * @param string $type 'admin' or 'personal' |
|
| 178 | + * @param string $setting Class must implement OCP\Settings\ISetting |
|
| 179 | + * @return void |
|
| 180 | + */ |
|
| 181 | + public function registerSetting(string $type, string $setting) { |
|
| 182 | + $this->settingClasses[$setting] = $type; |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * @param string $type 'admin' or 'personal' |
|
| 187 | + * @param string $section |
|
| 188 | + * @return ISettings[] |
|
| 189 | + */ |
|
| 190 | + protected function getSettings(string $type, string $section): array { |
|
| 191 | + if (!isset($this->settings[$type])) { |
|
| 192 | + $this->settings[$type] = []; |
|
| 193 | + } |
|
| 194 | + if (!isset($this->settings[$type][$section])) { |
|
| 195 | + $this->settings[$type][$section] = []; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + foreach ($this->settingClasses as $class => $settingsType) { |
|
| 199 | + try { |
|
| 200 | + /** @var ISettings $setting */ |
|
| 201 | + $setting = \OC::$server->query($class); |
|
| 202 | + } catch (QueryException $e) { |
|
| 203 | + $this->log->logException($e, ['level' => ILogger::INFO]); |
|
| 204 | + continue; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + if (!$setting instanceof ISettings) { |
|
| 208 | + $this->log->logException(new \InvalidArgumentException('Invalid settings setting registered'), ['level' => ILogger::INFO]); |
|
| 209 | + continue; |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + if (!isset($this->settings[$settingsType][$setting->getSection()])) { |
|
| 213 | + $this->settings[$settingsType][$setting->getSection()] = []; |
|
| 214 | + } |
|
| 215 | + $this->settings[$settingsType][$setting->getSection()][] = $setting; |
|
| 216 | + |
|
| 217 | + unset($this->settingClasses[$class]); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + return $this->settings[$type][$section]; |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * @inheritdoc |
|
| 225 | + */ |
|
| 226 | + public function getAdminSections(): array { |
|
| 227 | + // built-in sections |
|
| 228 | + $sections = [ |
|
| 229 | + 0 => [new Section('overview', $this->l->t('Overview'), 0, $this->url->imagePath('settings', 'admin.svg'))], |
|
| 230 | + 1 => [new Section('server', $this->l->t('Basic settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))], |
|
| 231 | + 5 => [new Section('sharing', $this->l->t('Sharing'), 0, $this->url->imagePath('core', 'actions/share.svg'))], |
|
| 232 | + 10 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('core', 'actions/password.svg'))], |
|
| 233 | + 45 => [new Section('encryption', $this->l->t('Encryption'), 0, $this->url->imagePath('core', 'actions/password.svg'))], |
|
| 234 | + 50 => [new Section('groupware', $this->l->t('Groupware'), 0, $this->url->imagePath('core', 'places/contacts-dark.svg'))], |
|
| 235 | + 98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))], |
|
| 236 | + ]; |
|
| 237 | + |
|
| 238 | + $appSections = $this->getSections('admin'); |
|
| 239 | + |
|
| 240 | + foreach ($appSections as $section) { |
|
| 241 | + /** @var ISection $section */ |
|
| 242 | + if (!isset($sections[$section->getPriority()])) { |
|
| 243 | + $sections[$section->getPriority()] = []; |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + $sections[$section->getPriority()][] = $section; |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + ksort($sections); |
|
| 250 | + |
|
| 251 | + return $sections; |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + /** |
|
| 255 | + * @param string $section |
|
| 256 | + * @return ISection[] |
|
| 257 | + */ |
|
| 258 | + private function getBuiltInAdminSettings($section): array { |
|
| 259 | + $forms = []; |
|
| 260 | + |
|
| 261 | + if ($section === 'overview') { |
|
| 262 | + /** @var ISettings $form */ |
|
| 263 | + $form = new Admin\Overview($this->config); |
|
| 264 | + $forms[$form->getPriority()] = [$form]; |
|
| 265 | + } |
|
| 266 | + if ($section === 'server') { |
|
| 267 | + /** @var ISettings $form */ |
|
| 268 | + $form = new Admin\Server($this->dbc, $this->request, $this->config, $this->lockingProvider, $this->l); |
|
| 269 | + $forms[$form->getPriority()] = [$form]; |
|
| 270 | + $form = new Admin\Mail($this->config); |
|
| 271 | + $forms[$form->getPriority()] = [$form]; |
|
| 272 | + } |
|
| 273 | + if ($section === 'encryption') { |
|
| 274 | + /** @var ISettings $form */ |
|
| 275 | + $form = new Admin\Encryption($this->encryptionManager, $this->userManager); |
|
| 276 | + $forms[$form->getPriority()] = [$form]; |
|
| 277 | + } |
|
| 278 | + if ($section === 'sharing') { |
|
| 279 | + /** @var ISettings $form */ |
|
| 280 | + $form = new Admin\Sharing($this->config, $this->l); |
|
| 281 | + $forms[$form->getPriority()] = [$form]; |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + return $forms; |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + /** |
|
| 288 | + * @param string $section |
|
| 289 | + * @return ISection[] |
|
| 290 | + */ |
|
| 291 | + private function getBuiltInPersonalSettings($section): array { |
|
| 292 | + $forms = []; |
|
| 293 | + |
|
| 294 | + if ($section === 'personal-info') { |
|
| 295 | + /** @var ISettings $form */ |
|
| 296 | + $form = new Personal\PersonalInfo( |
|
| 297 | + $this->config, |
|
| 298 | + $this->userManager, |
|
| 299 | + $this->groupManager, |
|
| 300 | + $this->accountManager, |
|
| 301 | + $this->appManager, |
|
| 302 | + $this->l10nFactory, |
|
| 303 | + $this->l |
|
| 304 | + ); |
|
| 305 | + $forms[$form->getPriority()] = [$form]; |
|
| 306 | + $form = new Personal\ServerDevNotice(); |
|
| 307 | + $forms[$form->getPriority()] = [$form]; |
|
| 308 | + } |
|
| 309 | + if($section === 'security') { |
|
| 310 | + /** @var ISettings $form */ |
|
| 311 | + $form = new Personal\Security(); |
|
| 312 | + $forms[$form->getPriority()] = [$form]; |
|
| 313 | + } |
|
| 314 | + if ($section === 'additional') { |
|
| 315 | + /** @var ISettings $form */ |
|
| 316 | + $form = new Personal\Additional(); |
|
| 317 | + $forms[$form->getPriority()] = [$form]; |
|
| 318 | + } |
|
| 319 | + |
|
| 320 | + return $forms; |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + /** |
|
| 324 | + * @inheritdoc |
|
| 325 | + */ |
|
| 326 | + public function getAdminSettings($section): array { |
|
| 327 | + $settings = $this->getBuiltInAdminSettings($section); |
|
| 328 | + $appSettings = $this->getSettings('admin', $section); |
|
| 329 | + |
|
| 330 | + foreach ($appSettings as $setting) { |
|
| 331 | + if (!isset($settings[$setting->getPriority()])) { |
|
| 332 | + $settings[$setting->getPriority()] = []; |
|
| 333 | + } |
|
| 334 | + $settings[$setting->getPriority()][] = $setting; |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + ksort($settings); |
|
| 338 | + return $settings; |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + /** |
|
| 342 | + * @inheritdoc |
|
| 343 | + */ |
|
| 344 | + public function getPersonalSections(): array { |
|
| 345 | + $sections = [ |
|
| 346 | + 0 => [new Section('personal-info', $this->l->t('Personal info'), 0, $this->url->imagePath('core', 'actions/info.svg'))], |
|
| 347 | + 5 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('settings', 'password.svg'))], |
|
| 348 | + 15 => [new Section('sync-clients', $this->l->t('Mobile & desktop'), 0, $this->url->imagePath('core', 'clients/phone.svg'))], |
|
| 349 | + ]; |
|
| 350 | + |
|
| 351 | + $legacyForms = \OC_App::getForms('personal'); |
|
| 352 | + if(!empty($legacyForms) && $this->hasLegacyPersonalSettingsToRender($legacyForms)) { |
|
| 353 | + $sections[98] = [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))]; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + $appSections = $this->getSections('personal'); |
|
| 357 | + |
|
| 358 | + foreach ($appSections as $section) { |
|
| 359 | + /** @var ISection $section */ |
|
| 360 | + if (!isset($sections[$section->getPriority()])) { |
|
| 361 | + $sections[$section->getPriority()] = []; |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + $sections[$section->getPriority()][] = $section; |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + ksort($sections); |
|
| 368 | + |
|
| 369 | + return $sections; |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + /** |
|
| 373 | + * @param string[] $forms |
|
| 374 | + * @return bool |
|
| 375 | + */ |
|
| 376 | + private function hasLegacyPersonalSettingsToRender(array $forms): bool { |
|
| 377 | + foreach ($forms as $form) { |
|
| 378 | + if(trim($form) !== '') { |
|
| 379 | + return true; |
|
| 380 | + } |
|
| 381 | + } |
|
| 382 | + return false; |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + /** |
|
| 386 | + * @inheritdoc |
|
| 387 | + */ |
|
| 388 | + public function getPersonalSettings($section): array { |
|
| 389 | + $settings = $this->getBuiltInPersonalSettings($section); |
|
| 390 | + $appSettings = $this->getSettings('personal', $section); |
|
| 391 | + |
|
| 392 | + foreach ($appSettings as $setting) { |
|
| 393 | + if (!isset($settings[$setting->getPriority()])) { |
|
| 394 | + $settings[$setting->getPriority()] = []; |
|
| 395 | + } |
|
| 396 | + $settings[$setting->getPriority()][] = $setting; |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + ksort($settings); |
|
| 400 | + return $settings; |
|
| 401 | + } |
|
| 402 | 402 | } |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | $form = new Personal\ServerDevNotice(); |
| 307 | 307 | $forms[$form->getPriority()] = [$form]; |
| 308 | 308 | } |
| 309 | - if($section === 'security') { |
|
| 309 | + if ($section === 'security') { |
|
| 310 | 310 | /** @var ISettings $form */ |
| 311 | 311 | $form = new Personal\Security(); |
| 312 | 312 | $forms[$form->getPriority()] = [$form]; |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | ]; |
| 350 | 350 | |
| 351 | 351 | $legacyForms = \OC_App::getForms('personal'); |
| 352 | - if(!empty($legacyForms) && $this->hasLegacyPersonalSettingsToRender($legacyForms)) { |
|
| 352 | + if (!empty($legacyForms) && $this->hasLegacyPersonalSettingsToRender($legacyForms)) { |
|
| 353 | 353 | $sections[98] = [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))]; |
| 354 | 354 | } |
| 355 | 355 | |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | */ |
| 376 | 376 | private function hasLegacyPersonalSettingsToRender(array $forms): bool { |
| 377 | 377 | foreach ($forms as $form) { |
| 378 | - if(trim($form) !== '') { |
|
| 378 | + if (trim($form) !== '') { |
|
| 379 | 379 | return true; |
| 380 | 380 | } |
| 381 | 381 | } |
@@ -1,66 +1,66 @@ |
||
| 1 | 1 | <div class="followupsection"> |
| 2 | 2 | <p> |
| 3 | 3 | <?php print_unescaped(str_replace( |
| 4 | - [ |
|
| 5 | - '{communityopen}', |
|
| 6 | - '{githubopen}', |
|
| 7 | - '{licenseopen}', |
|
| 8 | - '{linkclose}', |
|
| 9 | - ], |
|
| 10 | - [ |
|
| 11 | - '<a href="https://nextcloud.com/contribute" target="_blank" rel="noreferrer noopener">', |
|
| 12 | - '<a href="https://github.com/nextcloud" target="_blank" rel="noreferrer noopener">', |
|
| 13 | - '<a href="https://www.gnu.org/licenses/agpl-3.0.html" target="_blank" rel="noreferrer noopener">', |
|
| 14 | - '</a>', |
|
| 15 | - ], |
|
| 16 | - $l->t('Developed by the {communityopen}Nextcloud community{linkclose}, the {githubopen}source code{linkclose} is licensed under the {licenseopen}AGPL{linkclose}.') |
|
| 17 | - )); ?> |
|
| 4 | + [ |
|
| 5 | + '{communityopen}', |
|
| 6 | + '{githubopen}', |
|
| 7 | + '{licenseopen}', |
|
| 8 | + '{linkclose}', |
|
| 9 | + ], |
|
| 10 | + [ |
|
| 11 | + '<a href="https://nextcloud.com/contribute" target="_blank" rel="noreferrer noopener">', |
|
| 12 | + '<a href="https://github.com/nextcloud" target="_blank" rel="noreferrer noopener">', |
|
| 13 | + '<a href="https://www.gnu.org/licenses/agpl-3.0.html" target="_blank" rel="noreferrer noopener">', |
|
| 14 | + '</a>', |
|
| 15 | + ], |
|
| 16 | + $l->t('Developed by the {communityopen}Nextcloud community{linkclose}, the {githubopen}source code{linkclose} is licensed under the {licenseopen}AGPL{linkclose}.') |
|
| 17 | + )); ?> |
|
| 18 | 18 | </p> |
| 19 | 19 | |
| 20 | 20 | <p class="social-button"> |
| 21 | 21 | <?php print_unescaped(str_replace( |
| 22 | - [ |
|
| 23 | - '{googleimage}', |
|
| 24 | - '{facebookimage}', |
|
| 25 | - '{twitterimage}', |
|
| 26 | - '{rssimage}', |
|
| 27 | - '{mailimage}', |
|
| 28 | - '{googleopen}', |
|
| 29 | - '{facebookopen}', |
|
| 30 | - '{twitteropen}', |
|
| 31 | - '{rssopen}', |
|
| 32 | - '{newsletteropen}', |
|
| 33 | - '{linkclose}', |
|
| 34 | - '{googletext}', |
|
| 35 | - '{facebooktext}', |
|
| 36 | - '{twittertext}', |
|
| 37 | - '{rsstext}', |
|
| 38 | - '{mailtext}', |
|
| 39 | - ], |
|
| 40 | - [ |
|
| 41 | - image_path('core', 'googleplus.svg'), |
|
| 42 | - image_path('core', 'facebook.svg'), |
|
| 43 | - image_path('core', 'twitter.svg'), |
|
| 44 | - image_path('core', 'rss.svg'), |
|
| 45 | - image_path('core', 'mail.svg'), |
|
| 46 | - '<a target="_blank" rel="noreferrer noopener" href="https://plus.google.com/+Nextcloud">', |
|
| 47 | - '<a target="_blank" rel="noreferrer noopener" href="https://www.facebook.com/Nextclouders/">', |
|
| 48 | - '<a target="_blank" rel="noreferrer noopener" href="https://twitter.com/nextclouders">', |
|
| 49 | - '<a target="_blank" rel="noreferrer noopener" href="https://nextcloud.com/news/">', |
|
| 50 | - '<a target="_blank" rel="noreferrer noopener" href="https://newsletter.nextcloud.com/?p=subscribe&id=1">', |
|
| 51 | - '</a>', |
|
| 52 | - $l->t('Follow us on Google+'), |
|
| 53 | - $l->t('Like our Facebook page'), |
|
| 54 | - $l->t('Follow us on Twitter'), |
|
| 55 | - $l->t('Check out our blog'), |
|
| 56 | - $l->t('Subscribe to our newsletter'), |
|
| 22 | + [ |
|
| 23 | + '{googleimage}', |
|
| 24 | + '{facebookimage}', |
|
| 25 | + '{twitterimage}', |
|
| 26 | + '{rssimage}', |
|
| 27 | + '{mailimage}', |
|
| 28 | + '{googleopen}', |
|
| 29 | + '{facebookopen}', |
|
| 30 | + '{twitteropen}', |
|
| 31 | + '{rssopen}', |
|
| 32 | + '{newsletteropen}', |
|
| 33 | + '{linkclose}', |
|
| 34 | + '{googletext}', |
|
| 35 | + '{facebooktext}', |
|
| 36 | + '{twittertext}', |
|
| 37 | + '{rsstext}', |
|
| 38 | + '{mailtext}', |
|
| 39 | + ], |
|
| 40 | + [ |
|
| 41 | + image_path('core', 'googleplus.svg'), |
|
| 42 | + image_path('core', 'facebook.svg'), |
|
| 43 | + image_path('core', 'twitter.svg'), |
|
| 44 | + image_path('core', 'rss.svg'), |
|
| 45 | + image_path('core', 'mail.svg'), |
|
| 46 | + '<a target="_blank" rel="noreferrer noopener" href="https://plus.google.com/+Nextcloud">', |
|
| 47 | + '<a target="_blank" rel="noreferrer noopener" href="https://www.facebook.com/Nextclouders/">', |
|
| 48 | + '<a target="_blank" rel="noreferrer noopener" href="https://twitter.com/nextclouders">', |
|
| 49 | + '<a target="_blank" rel="noreferrer noopener" href="https://nextcloud.com/news/">', |
|
| 50 | + '<a target="_blank" rel="noreferrer noopener" href="https://newsletter.nextcloud.com/?p=subscribe&id=1">', |
|
| 51 | + '</a>', |
|
| 52 | + $l->t('Follow us on Google+'), |
|
| 53 | + $l->t('Like our Facebook page'), |
|
| 54 | + $l->t('Follow us on Twitter'), |
|
| 55 | + $l->t('Check out our blog'), |
|
| 56 | + $l->t('Subscribe to our newsletter'), |
|
| 57 | 57 | |
| 58 | - ], |
|
| 58 | + ], |
|
| 59 | 59 | '{googleopen}<img width="50" src="{googleimage}" title="{googletext}" alt="{googletext}">{linkclose} |
| 60 | 60 | {facebookopen}<img width="50" src="{facebookimage}" title="{facebooktext}" alt="{facebooktext}">{linkclose} |
| 61 | 61 | {twitteropen}<img width="50" src="{twitterimage}" title="{twittertext}" alt="{twittertext}">{linkclose} |
| 62 | 62 | {rssopen}<img class="img-circle" width="50" src="{rssimage}" title="{rsstext}" alt="{rsstext}">{linkclose} |
| 63 | 63 | {newsletteropen}<img width="50" src="{mailimage}" title="{mailtext}" alt="{mailtext}">{linkclose}' |
| 64 | - )); ?> |
|
| 64 | + )); ?> |
|
| 65 | 65 | </p> |
| 66 | 66 | </div> |
| 67 | 67 | \ No newline at end of file |