@@ -79,33 +79,6 @@ class UserConfig {
7979 'default ' => true ,
8080 'allowed ' => [true , false ],
8181 ],
82- [
83- // Whether to group images on recent files list or not
84- 'key ' => 'group_recent_files_images ' ,
85- 'default ' => false ,
86- 'allowed ' => [true , false ],
87- ],
88- [
89- // Which image mime types to group in the recent files list
90- 'key ' => 'recent_files_group_mimetypes ' ,
91- 'default ' => '' ,
92- 'allowed ' => [
93- 'image/png ' ,
94- 'image/jpeg ' ,
95- 'image/gif ' ,
96- 'image/webp ' ,
97- 'image/avif ' ,
98- 'image/heic ' ,
99- 'image/heif ' ,
100- ]
101- ],
102- [
103- // Time window in minutes to group files uploaded close together in the recent files list
104- 'key ' => 'recent_files_group_timespan_minutes ' ,
105- 'default ' => 2 ,
106- 'min ' => 1 ,
107- 'max ' => 999 ,
108- ],
10982 ];
11083 protected ?IUser $ user = null ;
11184
@@ -145,7 +118,7 @@ private function getAllowedConfigValues(string $key): array {
145118 * Get the default config value for a given key
146119 *
147120 * @param string $key a valid config key
148- * @return string|bool|int
121+ * @return string|bool
149122 */
150123 private function getDefaultConfigValue (string $ key ) {
151124 foreach (self ::ALLOWED_CONFIGS as $ config ) {
@@ -173,25 +146,7 @@ public function setConfig(string $key, $value): void {
173146 throw new \InvalidArgumentException ('Unknown config key ' );
174147 }
175148
176- if (is_string ($ value ) && str_starts_with ($ value , '[ ' ) && str_ends_with ($ value , '] ' )) {
177- $ value = json_decode ($ value , true ) ?? $ value ;
178- }
179-
180- $ config = $ this ->getConfigDefinition ($ key );
181-
182- if (isset ($ config ['min ' ], $ config ['max ' ])) {
183- if ((int )$ value < $ config ['min ' ] || (int )$ value > $ config ['max ' ]) {
184- throw new \InvalidArgumentException ('Invalid config value ' );
185- }
186- } elseif (is_array ($ value )) {
187- $ allowedValues = $ this ->getAllowedConfigValues ($ key );
188- foreach ($ value as $ v ) {
189- if (!in_array ($ v , $ allowedValues )) {
190- throw new \InvalidArgumentException ('Invalid config value ' );
191- }
192- }
193- $ value = json_encode ($ value );
194- } elseif (!in_array ($ value , $ this ->getAllowedConfigValues ($ key ))) {
149+ if (!in_array ($ value , $ this ->getAllowedConfigValues ($ key ))) {
195150 throw new \InvalidArgumentException ('Invalid config value ' );
196151 }
197152
@@ -219,27 +174,9 @@ public function getConfigs(): array {
219174 if (is_bool ($ this ->getDefaultConfigValue ($ key )) && is_string ($ value )) {
220175 return $ value === '1 ' ;
221176 }
222- if (is_string ($ value ) && str_starts_with ($ value , '[ ' ) && str_ends_with ($ value , '] ' )) {
223- $ value = json_decode ($ value , true ) ?? $ value ;
224- }
225177 return $ value ;
226178 }, $ this ->getAllowedConfigKeys ());
227179
228180 return array_combine ($ this ->getAllowedConfigKeys (), $ userConfigs );
229181 }
230-
231- /**
232- * Get the config definition for a given key
233- *
234- * @param string $key
235- * @return array
236- */
237- private function getConfigDefinition (string $ key ): array {
238- foreach (self ::ALLOWED_CONFIGS as $ config ) {
239- if ($ config ['key ' ] === $ key ) {
240- return $ config ;
241- }
242- }
243- return [];
244- }
245182}
0 commit comments