@@ -36,75 +36,75 @@ |
||
36 | 36 | |
37 | 37 | class Security implements ISettings { |
38 | 38 | |
39 | - /** @var IManager */ |
|
40 | - private $manager; |
|
39 | + /** @var IManager */ |
|
40 | + private $manager; |
|
41 | 41 | |
42 | - /** @var IUserManager */ |
|
43 | - private $userManager; |
|
42 | + /** @var IUserManager */ |
|
43 | + private $userManager; |
|
44 | 44 | |
45 | - /** @var MandatoryTwoFactor */ |
|
46 | - private $mandatoryTwoFactor; |
|
45 | + /** @var MandatoryTwoFactor */ |
|
46 | + private $mandatoryTwoFactor; |
|
47 | 47 | |
48 | - /** @var IInitialState */ |
|
49 | - private $initialState; |
|
48 | + /** @var IInitialState */ |
|
49 | + private $initialState; |
|
50 | 50 | |
51 | - public function __construct(IManager $manager, |
|
52 | - IUserManager $userManager, |
|
53 | - MandatoryTwoFactor $mandatoryTwoFactor, |
|
54 | - IInitialState $initialState) { |
|
55 | - $this->manager = $manager; |
|
56 | - $this->userManager = $userManager; |
|
57 | - $this->mandatoryTwoFactor = $mandatoryTwoFactor; |
|
58 | - $this->initialState = $initialState; |
|
59 | - } |
|
51 | + public function __construct(IManager $manager, |
|
52 | + IUserManager $userManager, |
|
53 | + MandatoryTwoFactor $mandatoryTwoFactor, |
|
54 | + IInitialState $initialState) { |
|
55 | + $this->manager = $manager; |
|
56 | + $this->userManager = $userManager; |
|
57 | + $this->mandatoryTwoFactor = $mandatoryTwoFactor; |
|
58 | + $this->initialState = $initialState; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @return TemplateResponse |
|
63 | - */ |
|
64 | - public function getForm(): TemplateResponse { |
|
65 | - $encryptionModules = $this->manager->getEncryptionModules(); |
|
66 | - $defaultEncryptionModuleId = $this->manager->getDefaultEncryptionModuleId(); |
|
67 | - $encryptionModuleList = []; |
|
68 | - foreach ($encryptionModules as $module) { |
|
69 | - $encryptionModuleList[$module['id']]['displayName'] = $module['displayName']; |
|
70 | - $encryptionModuleList[$module['id']]['default'] = false; |
|
71 | - if ($module['id'] === $defaultEncryptionModuleId) { |
|
72 | - $encryptionModuleList[$module['id']]['default'] = true; |
|
73 | - } |
|
74 | - } |
|
61 | + /** |
|
62 | + * @return TemplateResponse |
|
63 | + */ |
|
64 | + public function getForm(): TemplateResponse { |
|
65 | + $encryptionModules = $this->manager->getEncryptionModules(); |
|
66 | + $defaultEncryptionModuleId = $this->manager->getDefaultEncryptionModuleId(); |
|
67 | + $encryptionModuleList = []; |
|
68 | + foreach ($encryptionModules as $module) { |
|
69 | + $encryptionModuleList[$module['id']]['displayName'] = $module['displayName']; |
|
70 | + $encryptionModuleList[$module['id']]['default'] = false; |
|
71 | + if ($module['id'] === $defaultEncryptionModuleId) { |
|
72 | + $encryptionModuleList[$module['id']]['default'] = true; |
|
73 | + } |
|
74 | + } |
|
75 | 75 | |
76 | - $this->initialState->provideInitialState( |
|
77 | - 'mandatory2FAState', |
|
78 | - $this->mandatoryTwoFactor->getState() |
|
79 | - ); |
|
76 | + $this->initialState->provideInitialState( |
|
77 | + 'mandatory2FAState', |
|
78 | + $this->mandatoryTwoFactor->getState() |
|
79 | + ); |
|
80 | 80 | |
81 | - $parameters = [ |
|
82 | - // Encryption API |
|
83 | - 'encryptionEnabled' => $this->manager->isEnabled(), |
|
84 | - 'encryptionReady' => $this->manager->isReady(), |
|
85 | - 'externalBackendsEnabled' => count($this->userManager->getBackends()) > 1, |
|
86 | - // Modules |
|
87 | - 'encryptionModules' => $encryptionModuleList, |
|
88 | - ]; |
|
81 | + $parameters = [ |
|
82 | + // Encryption API |
|
83 | + 'encryptionEnabled' => $this->manager->isEnabled(), |
|
84 | + 'encryptionReady' => $this->manager->isReady(), |
|
85 | + 'externalBackendsEnabled' => count($this->userManager->getBackends()) > 1, |
|
86 | + // Modules |
|
87 | + 'encryptionModules' => $encryptionModuleList, |
|
88 | + ]; |
|
89 | 89 | |
90 | - return new TemplateResponse('settings', 'settings/admin/security', $parameters, ''); |
|
91 | - } |
|
90 | + return new TemplateResponse('settings', 'settings/admin/security', $parameters, ''); |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * @return string the section ID, e.g. 'sharing' |
|
95 | - */ |
|
96 | - public function getSection(): string { |
|
97 | - return 'security'; |
|
98 | - } |
|
93 | + /** |
|
94 | + * @return string the section ID, e.g. 'sharing' |
|
95 | + */ |
|
96 | + public function getSection(): string { |
|
97 | + return 'security'; |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * @return int whether the form should be rather on the top or bottom of |
|
102 | - * the admin section. The forms are arranged in ascending order of the |
|
103 | - * priority values. It is required to return a value between 0 and 100. |
|
104 | - * |
|
105 | - * E.g.: 70 |
|
106 | - */ |
|
107 | - public function getPriority(): int { |
|
108 | - return 10; |
|
109 | - } |
|
100 | + /** |
|
101 | + * @return int whether the form should be rather on the top or bottom of |
|
102 | + * the admin section. The forms are arranged in ascending order of the |
|
103 | + * priority values. It is required to return a value between 0 and 100. |
|
104 | + * |
|
105 | + * E.g.: 70 |
|
106 | + */ |
|
107 | + public function getPriority(): int { |
|
108 | + return 10; |
|
109 | + } |
|
110 | 110 | } |
@@ -35,33 +35,33 @@ |
||
35 | 35 | |
36 | 36 | class Personal implements ISettings { |
37 | 37 | |
38 | - /** @var IConfig */ |
|
39 | - private $config; |
|
40 | - /** @var IInitialState */ |
|
41 | - private $initialState; |
|
42 | - /** @var string */ |
|
43 | - private $userId; |
|
38 | + /** @var IConfig */ |
|
39 | + private $config; |
|
40 | + /** @var IInitialState */ |
|
41 | + private $initialState; |
|
42 | + /** @var string */ |
|
43 | + private $userId; |
|
44 | 44 | |
45 | - public function __construct(IConfig $config, IInitialState $initialState, string $userId) { |
|
46 | - $this->config = $config; |
|
47 | - $this->initialState = $initialState; |
|
48 | - $this->userId = $userId; |
|
49 | - } |
|
45 | + public function __construct(IConfig $config, IInitialState $initialState, string $userId) { |
|
46 | + $this->config = $config; |
|
47 | + $this->initialState = $initialState; |
|
48 | + $this->userId = $userId; |
|
49 | + } |
|
50 | 50 | |
51 | - public function getForm(): TemplateResponse { |
|
52 | - $defaultAcceptSystemConfig = $this->config->getSystemValueBool('sharing.enable_share_accept', false) ? 'no' : 'yes'; |
|
53 | - $acceptDefault = $this->config->getUserValue($this->userId, Application::APP_ID, 'default_accept', $defaultAcceptSystemConfig) === 'yes'; |
|
54 | - $enforceAccept = $this->config->getSystemValueBool('sharing.force_share_accept', false); |
|
55 | - $this->initialState->provideInitialState('accept_default', $acceptDefault); |
|
56 | - $this->initialState->provideInitialState('enforce_accept', $enforceAccept); |
|
57 | - return new TemplateResponse('files_sharing', 'Settings/personal'); |
|
58 | - } |
|
51 | + public function getForm(): TemplateResponse { |
|
52 | + $defaultAcceptSystemConfig = $this->config->getSystemValueBool('sharing.enable_share_accept', false) ? 'no' : 'yes'; |
|
53 | + $acceptDefault = $this->config->getUserValue($this->userId, Application::APP_ID, 'default_accept', $defaultAcceptSystemConfig) === 'yes'; |
|
54 | + $enforceAccept = $this->config->getSystemValueBool('sharing.force_share_accept', false); |
|
55 | + $this->initialState->provideInitialState('accept_default', $acceptDefault); |
|
56 | + $this->initialState->provideInitialState('enforce_accept', $enforceAccept); |
|
57 | + return new TemplateResponse('files_sharing', 'Settings/personal'); |
|
58 | + } |
|
59 | 59 | |
60 | - public function getSection(): string { |
|
61 | - return 'sharing'; |
|
62 | - } |
|
60 | + public function getSection(): string { |
|
61 | + return 'sharing'; |
|
62 | + } |
|
63 | 63 | |
64 | - public function getPriority(): int { |
|
65 | - return 90; |
|
66 | - } |
|
64 | + public function getPriority(): int { |
|
65 | + return 90; |
|
66 | + } |
|
67 | 67 | } |
@@ -28,11 +28,11 @@ |
||
28 | 28 | use OCP\WorkflowEngine\IManager; |
29 | 29 | |
30 | 30 | class Personal extends ASettings { |
31 | - public function getScope(): int { |
|
32 | - return IManager::SCOPE_USER; |
|
33 | - } |
|
31 | + public function getScope(): int { |
|
32 | + return IManager::SCOPE_USER; |
|
33 | + } |
|
34 | 34 | |
35 | - public function getSection(): ?string { |
|
36 | - return $this->manager->isUserScopeEnabled() ? 'workflow' : null; |
|
37 | - } |
|
35 | + public function getSection(): ?string { |
|
36 | + return $this->manager->isUserScopeEnabled() ? 'workflow' : null; |
|
37 | + } |
|
38 | 38 | } |
@@ -42,148 +42,148 @@ |
||
42 | 42 | use OCP\WorkflowEngine\ISpecificOperation; |
43 | 43 | |
44 | 44 | abstract class ASettings implements ISettings { |
45 | - /** @var IL10N */ |
|
46 | - private $l10n; |
|
47 | - |
|
48 | - /** @var string */ |
|
49 | - private $appName; |
|
50 | - |
|
51 | - /** @var IEventDispatcher */ |
|
52 | - private $eventDispatcher; |
|
53 | - |
|
54 | - /** @var Manager */ |
|
55 | - protected $manager; |
|
56 | - |
|
57 | - /** @var IInitialState */ |
|
58 | - private $initialStateService; |
|
59 | - |
|
60 | - /** @var IConfig */ |
|
61 | - private $config; |
|
62 | - |
|
63 | - public function __construct( |
|
64 | - string $appName, |
|
65 | - IL10N $l, |
|
66 | - IEventDispatcher $eventDispatcher, |
|
67 | - Manager $manager, |
|
68 | - IInitialState $initialStateService, |
|
69 | - IConfig $config |
|
70 | - ) { |
|
71 | - $this->appName = $appName; |
|
72 | - $this->l10n = $l; |
|
73 | - $this->eventDispatcher = $eventDispatcher; |
|
74 | - $this->manager = $manager; |
|
75 | - $this->initialStateService = $initialStateService; |
|
76 | - $this->config = $config; |
|
77 | - } |
|
78 | - |
|
79 | - abstract public function getScope(): int; |
|
80 | - |
|
81 | - /** |
|
82 | - * @return TemplateResponse |
|
83 | - */ |
|
84 | - public function getForm(): TemplateResponse { |
|
85 | - // @deprecated in 20.0.0: retire this one in favor of the typed event |
|
86 | - $this->eventDispatcher->dispatch( |
|
87 | - 'OCP\WorkflowEngine::loadAdditionalSettingScripts', |
|
88 | - new LoadSettingsScriptsEvent() |
|
89 | - ); |
|
90 | - $this->eventDispatcher->dispatchTyped(new LoadSettingsScriptsEvent()); |
|
91 | - |
|
92 | - $entities = $this->manager->getEntitiesList(); |
|
93 | - $this->initialStateService->provideInitialState( |
|
94 | - 'entities', |
|
95 | - $this->entitiesToArray($entities) |
|
96 | - ); |
|
97 | - |
|
98 | - $operators = $this->manager->getOperatorList(); |
|
99 | - $this->initialStateService->provideInitialState( |
|
100 | - 'operators', |
|
101 | - $this->operatorsToArray($operators) |
|
102 | - ); |
|
103 | - |
|
104 | - $checks = $this->manager->getCheckList(); |
|
105 | - $this->initialStateService->provideInitialState( |
|
106 | - 'checks', |
|
107 | - $this->checksToArray($checks) |
|
108 | - ); |
|
109 | - |
|
110 | - $this->initialStateService->provideInitialState( |
|
111 | - 'scope', |
|
112 | - $this->getScope() |
|
113 | - ); |
|
114 | - |
|
115 | - $this->initialStateService->provideInitialState( |
|
116 | - 'appstoreenabled', |
|
117 | - $this->config->getSystemValueBool('appstoreenabled', true) |
|
118 | - ); |
|
119 | - |
|
120 | - return new TemplateResponse(Application::APP_ID, 'settings', [], 'blank'); |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * @return string the section ID, e.g. 'sharing' |
|
125 | - */ |
|
126 | - public function getSection(): ?string { |
|
127 | - return 'workflow'; |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * @return int whether the form should be rather on the top or bottom of |
|
132 | - * the admin section. The forms are arranged in ascending order of the |
|
133 | - * priority values. It is required to return a value between 0 and 100. |
|
134 | - * |
|
135 | - * E.g.: 70 |
|
136 | - */ |
|
137 | - public function getPriority(): int { |
|
138 | - return 0; |
|
139 | - } |
|
140 | - |
|
141 | - private function entitiesToArray(array $entities) { |
|
142 | - return array_map(function (IEntity $entity) { |
|
143 | - $events = array_map(function (IEntityEvent $entityEvent) { |
|
144 | - return [ |
|
145 | - 'eventName' => $entityEvent->getEventName(), |
|
146 | - 'displayName' => $entityEvent->getDisplayName() |
|
147 | - ]; |
|
148 | - }, $entity->getEvents()); |
|
149 | - |
|
150 | - return [ |
|
151 | - 'id' => get_class($entity), |
|
152 | - 'icon' => $entity->getIcon(), |
|
153 | - 'name' => $entity->getName(), |
|
154 | - 'events' => $events, |
|
155 | - ]; |
|
156 | - }, $entities); |
|
157 | - } |
|
158 | - |
|
159 | - private function operatorsToArray(array $operators) { |
|
160 | - $operators = array_filter($operators, function (IOperation $operator) { |
|
161 | - return $operator->isAvailableForScope($this->getScope()); |
|
162 | - }); |
|
163 | - |
|
164 | - return array_map(function (IOperation $operator) { |
|
165 | - return [ |
|
166 | - 'id' => get_class($operator), |
|
167 | - 'icon' => $operator->getIcon(), |
|
168 | - 'name' => $operator->getDisplayName(), |
|
169 | - 'description' => $operator->getDescription(), |
|
170 | - 'fixedEntity' => $operator instanceof ISpecificOperation ? $operator->getEntityId() : '', |
|
171 | - 'isComplex' => $operator instanceof IComplexOperation, |
|
172 | - 'triggerHint' => $operator instanceof IComplexOperation ? $operator->getTriggerHint() : '', |
|
173 | - ]; |
|
174 | - }, $operators); |
|
175 | - } |
|
176 | - |
|
177 | - private function checksToArray(array $checks) { |
|
178 | - $checks = array_filter($checks, function (ICheck $check) { |
|
179 | - return $check->isAvailableForScope($this->getScope()); |
|
180 | - }); |
|
181 | - |
|
182 | - return array_map(function (ICheck $check) { |
|
183 | - return [ |
|
184 | - 'id' => get_class($check), |
|
185 | - 'supportedEntities' => $check->supportedEntities(), |
|
186 | - ]; |
|
187 | - }, $checks); |
|
188 | - } |
|
45 | + /** @var IL10N */ |
|
46 | + private $l10n; |
|
47 | + |
|
48 | + /** @var string */ |
|
49 | + private $appName; |
|
50 | + |
|
51 | + /** @var IEventDispatcher */ |
|
52 | + private $eventDispatcher; |
|
53 | + |
|
54 | + /** @var Manager */ |
|
55 | + protected $manager; |
|
56 | + |
|
57 | + /** @var IInitialState */ |
|
58 | + private $initialStateService; |
|
59 | + |
|
60 | + /** @var IConfig */ |
|
61 | + private $config; |
|
62 | + |
|
63 | + public function __construct( |
|
64 | + string $appName, |
|
65 | + IL10N $l, |
|
66 | + IEventDispatcher $eventDispatcher, |
|
67 | + Manager $manager, |
|
68 | + IInitialState $initialStateService, |
|
69 | + IConfig $config |
|
70 | + ) { |
|
71 | + $this->appName = $appName; |
|
72 | + $this->l10n = $l; |
|
73 | + $this->eventDispatcher = $eventDispatcher; |
|
74 | + $this->manager = $manager; |
|
75 | + $this->initialStateService = $initialStateService; |
|
76 | + $this->config = $config; |
|
77 | + } |
|
78 | + |
|
79 | + abstract public function getScope(): int; |
|
80 | + |
|
81 | + /** |
|
82 | + * @return TemplateResponse |
|
83 | + */ |
|
84 | + public function getForm(): TemplateResponse { |
|
85 | + // @deprecated in 20.0.0: retire this one in favor of the typed event |
|
86 | + $this->eventDispatcher->dispatch( |
|
87 | + 'OCP\WorkflowEngine::loadAdditionalSettingScripts', |
|
88 | + new LoadSettingsScriptsEvent() |
|
89 | + ); |
|
90 | + $this->eventDispatcher->dispatchTyped(new LoadSettingsScriptsEvent()); |
|
91 | + |
|
92 | + $entities = $this->manager->getEntitiesList(); |
|
93 | + $this->initialStateService->provideInitialState( |
|
94 | + 'entities', |
|
95 | + $this->entitiesToArray($entities) |
|
96 | + ); |
|
97 | + |
|
98 | + $operators = $this->manager->getOperatorList(); |
|
99 | + $this->initialStateService->provideInitialState( |
|
100 | + 'operators', |
|
101 | + $this->operatorsToArray($operators) |
|
102 | + ); |
|
103 | + |
|
104 | + $checks = $this->manager->getCheckList(); |
|
105 | + $this->initialStateService->provideInitialState( |
|
106 | + 'checks', |
|
107 | + $this->checksToArray($checks) |
|
108 | + ); |
|
109 | + |
|
110 | + $this->initialStateService->provideInitialState( |
|
111 | + 'scope', |
|
112 | + $this->getScope() |
|
113 | + ); |
|
114 | + |
|
115 | + $this->initialStateService->provideInitialState( |
|
116 | + 'appstoreenabled', |
|
117 | + $this->config->getSystemValueBool('appstoreenabled', true) |
|
118 | + ); |
|
119 | + |
|
120 | + return new TemplateResponse(Application::APP_ID, 'settings', [], 'blank'); |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * @return string the section ID, e.g. 'sharing' |
|
125 | + */ |
|
126 | + public function getSection(): ?string { |
|
127 | + return 'workflow'; |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * @return int whether the form should be rather on the top or bottom of |
|
132 | + * the admin section. The forms are arranged in ascending order of the |
|
133 | + * priority values. It is required to return a value between 0 and 100. |
|
134 | + * |
|
135 | + * E.g.: 70 |
|
136 | + */ |
|
137 | + public function getPriority(): int { |
|
138 | + return 0; |
|
139 | + } |
|
140 | + |
|
141 | + private function entitiesToArray(array $entities) { |
|
142 | + return array_map(function (IEntity $entity) { |
|
143 | + $events = array_map(function (IEntityEvent $entityEvent) { |
|
144 | + return [ |
|
145 | + 'eventName' => $entityEvent->getEventName(), |
|
146 | + 'displayName' => $entityEvent->getDisplayName() |
|
147 | + ]; |
|
148 | + }, $entity->getEvents()); |
|
149 | + |
|
150 | + return [ |
|
151 | + 'id' => get_class($entity), |
|
152 | + 'icon' => $entity->getIcon(), |
|
153 | + 'name' => $entity->getName(), |
|
154 | + 'events' => $events, |
|
155 | + ]; |
|
156 | + }, $entities); |
|
157 | + } |
|
158 | + |
|
159 | + private function operatorsToArray(array $operators) { |
|
160 | + $operators = array_filter($operators, function (IOperation $operator) { |
|
161 | + return $operator->isAvailableForScope($this->getScope()); |
|
162 | + }); |
|
163 | + |
|
164 | + return array_map(function (IOperation $operator) { |
|
165 | + return [ |
|
166 | + 'id' => get_class($operator), |
|
167 | + 'icon' => $operator->getIcon(), |
|
168 | + 'name' => $operator->getDisplayName(), |
|
169 | + 'description' => $operator->getDescription(), |
|
170 | + 'fixedEntity' => $operator instanceof ISpecificOperation ? $operator->getEntityId() : '', |
|
171 | + 'isComplex' => $operator instanceof IComplexOperation, |
|
172 | + 'triggerHint' => $operator instanceof IComplexOperation ? $operator->getTriggerHint() : '', |
|
173 | + ]; |
|
174 | + }, $operators); |
|
175 | + } |
|
176 | + |
|
177 | + private function checksToArray(array $checks) { |
|
178 | + $checks = array_filter($checks, function (ICheck $check) { |
|
179 | + return $check->isAvailableForScope($this->getScope()); |
|
180 | + }); |
|
181 | + |
|
182 | + return array_map(function (ICheck $check) { |
|
183 | + return [ |
|
184 | + 'id' => get_class($check), |
|
185 | + 'supportedEntities' => $check->supportedEntities(), |
|
186 | + ]; |
|
187 | + }, $checks); |
|
188 | + } |
|
189 | 189 | } |
@@ -37,86 +37,86 @@ |
||
37 | 37 | |
38 | 38 | class Personal implements ISettings { |
39 | 39 | |
40 | - /** @var string */ |
|
41 | - protected $appName; |
|
42 | - |
|
43 | - /** @var IConfig */ |
|
44 | - private $config; |
|
45 | - |
|
46 | - /** @var IUserSession */ |
|
47 | - private $userSession; |
|
48 | - |
|
49 | - /** @var IL10N */ |
|
50 | - private $l; |
|
51 | - |
|
52 | - /** @var IURLGenerator */ |
|
53 | - private $urlGenerator; |
|
54 | - |
|
55 | - /** @var AccessibilityProvider */ |
|
56 | - private $accessibilityProvider; |
|
57 | - |
|
58 | - /** @var IInitialState */ |
|
59 | - private $initialStateService; |
|
60 | - |
|
61 | - public function __construct(string $appName, |
|
62 | - IConfig $config, |
|
63 | - IUserSession $userSession, |
|
64 | - IL10N $l, |
|
65 | - IURLGenerator $urlGenerator, |
|
66 | - AccessibilityProvider $accessibilityProvider, |
|
67 | - IInitialState $initialStateService) { |
|
68 | - $this->appName = $appName; |
|
69 | - $this->config = $config; |
|
70 | - $this->userSession = $userSession; |
|
71 | - $this->l = $l; |
|
72 | - $this->urlGenerator = $urlGenerator; |
|
73 | - $this->accessibilityProvider = $accessibilityProvider; |
|
74 | - $this->initialStateService = $initialStateService; |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
79 | - * @since 9.1 |
|
80 | - */ |
|
81 | - public function getForm(): TemplateResponse { |
|
82 | - Util::addScript('accessibility', 'accessibility'); |
|
83 | - Util::addStyle('accessibility', 'style'); |
|
84 | - |
|
85 | - $availableConfig = [ |
|
86 | - 'themes' => $this->accessibilityProvider->getThemes(), |
|
87 | - 'fonts' => $this->accessibilityProvider->getFonts(), |
|
88 | - 'highcontrast' => $this->accessibilityProvider->getHighContrast() |
|
89 | - ]; |
|
90 | - |
|
91 | - $userConfig = [ |
|
92 | - 'highcontrast' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'highcontrast', false), |
|
93 | - 'theme' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false), |
|
94 | - 'font' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'font', false) |
|
95 | - ]; |
|
96 | - |
|
97 | - $this->initialStateService->provideInitialState('available-config', $availableConfig); |
|
98 | - $this->initialStateService->provideInitialState('user-config', $userConfig); |
|
99 | - |
|
100 | - return new TemplateResponse($this->appName, 'settings-personal'); |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * @return string the section ID, e.g. 'sharing' |
|
105 | - * @since 9.1 |
|
106 | - */ |
|
107 | - public function getSection(): string { |
|
108 | - return $this->appName; |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * @return int whether the form should be rather on the top or bottom of |
|
113 | - * the admin section. The forms are arranged in ascending order of the |
|
114 | - * priority values. It is required to return a value between 0 and 100. |
|
115 | - * |
|
116 | - * E.g.: 70 |
|
117 | - * @since 9.1 |
|
118 | - */ |
|
119 | - public function getPriority(): int { |
|
120 | - return 40; |
|
121 | - } |
|
40 | + /** @var string */ |
|
41 | + protected $appName; |
|
42 | + |
|
43 | + /** @var IConfig */ |
|
44 | + private $config; |
|
45 | + |
|
46 | + /** @var IUserSession */ |
|
47 | + private $userSession; |
|
48 | + |
|
49 | + /** @var IL10N */ |
|
50 | + private $l; |
|
51 | + |
|
52 | + /** @var IURLGenerator */ |
|
53 | + private $urlGenerator; |
|
54 | + |
|
55 | + /** @var AccessibilityProvider */ |
|
56 | + private $accessibilityProvider; |
|
57 | + |
|
58 | + /** @var IInitialState */ |
|
59 | + private $initialStateService; |
|
60 | + |
|
61 | + public function __construct(string $appName, |
|
62 | + IConfig $config, |
|
63 | + IUserSession $userSession, |
|
64 | + IL10N $l, |
|
65 | + IURLGenerator $urlGenerator, |
|
66 | + AccessibilityProvider $accessibilityProvider, |
|
67 | + IInitialState $initialStateService) { |
|
68 | + $this->appName = $appName; |
|
69 | + $this->config = $config; |
|
70 | + $this->userSession = $userSession; |
|
71 | + $this->l = $l; |
|
72 | + $this->urlGenerator = $urlGenerator; |
|
73 | + $this->accessibilityProvider = $accessibilityProvider; |
|
74 | + $this->initialStateService = $initialStateService; |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
79 | + * @since 9.1 |
|
80 | + */ |
|
81 | + public function getForm(): TemplateResponse { |
|
82 | + Util::addScript('accessibility', 'accessibility'); |
|
83 | + Util::addStyle('accessibility', 'style'); |
|
84 | + |
|
85 | + $availableConfig = [ |
|
86 | + 'themes' => $this->accessibilityProvider->getThemes(), |
|
87 | + 'fonts' => $this->accessibilityProvider->getFonts(), |
|
88 | + 'highcontrast' => $this->accessibilityProvider->getHighContrast() |
|
89 | + ]; |
|
90 | + |
|
91 | + $userConfig = [ |
|
92 | + 'highcontrast' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'highcontrast', false), |
|
93 | + 'theme' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false), |
|
94 | + 'font' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'font', false) |
|
95 | + ]; |
|
96 | + |
|
97 | + $this->initialStateService->provideInitialState('available-config', $availableConfig); |
|
98 | + $this->initialStateService->provideInitialState('user-config', $userConfig); |
|
99 | + |
|
100 | + return new TemplateResponse($this->appName, 'settings-personal'); |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * @return string the section ID, e.g. 'sharing' |
|
105 | + * @since 9.1 |
|
106 | + */ |
|
107 | + public function getSection(): string { |
|
108 | + return $this->appName; |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * @return int whether the form should be rather on the top or bottom of |
|
113 | + * the admin section. The forms are arranged in ascending order of the |
|
114 | + * priority values. It is required to return a value between 0 and 100. |
|
115 | + * |
|
116 | + * E.g.: 70 |
|
117 | + * @since 9.1 |
|
118 | + */ |
|
119 | + public function getPriority(): int { |
|
120 | + return 40; |
|
121 | + } |
|
122 | 122 | } |