aboutsummaryrefslogtreecommitdiff
path: root/lib/filesystem/FileManager.php
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+github@gmail.com>2021-12-09 13:01:06 +0100
committerJan-Hendrik Willms <tleilax+github@gmail.com>2021-12-09 13:01:28 +0100
commit89fceb4f1c2cc3f0229b3ba12cbed8cc658ae026 (patch)
treee1bd937732187275d0cd5f2e9804f9f0116a3a68 /lib/filesystem/FileManager.php
parent3e7e8848f7ba35c66aeb17fa65fb660d7747ee28 (diff)
re #448
Diffstat (limited to 'lib/filesystem/FileManager.php')
-rw-r--r--lib/filesystem/FileManager.php33
1 files changed, 23 insertions, 10 deletions
diff --git a/lib/filesystem/FileManager.php b/lib/filesystem/FileManager.php
index 6109776..b5c96bb 100644
--- a/lib/filesystem/FileManager.php
+++ b/lib/filesystem/FileManager.php
@@ -111,7 +111,7 @@ class FileManager
return 'file-generic';
}
- list($category, $type) = explode('/', $mime_type, 2);
+ [$category, $type] = explode('/', $mime_type, 2);
switch($category) {
case 'image':
@@ -1618,7 +1618,7 @@ class FileManager
$header_parts = explode(';', $disposition_header);
foreach ($header_parts as $part) {
$part = trim($part);
- list($key, $value) = explode('=', $part, 2);
+ [$key, $value] = explode('=', $part, 2);
if (mb_strtolower($key) === 'filename') {
$header['filename'] = trim($value, '"');
}
@@ -1725,10 +1725,10 @@ class FileManager
}
/**
- * returns config array for upload types and sizes
+ * returns config array for upload types and sizes for a given range id
*
- * @param $range_id string id of Course Institute User
- * @param null $user_id string
+ * @param string $range_id id of Course Institute User
+ * @param string|null $user_id Optional user id
* @return array
*/
public static function getUploadTypeConfig($range_id, $user_id = null)
@@ -1753,15 +1753,28 @@ class FileManager
$active_upload_type = 'attachments';
}
- if (!isset($GLOBALS['UPLOAD_TYPES'][$active_upload_type])) {
- $active_upload_type = 'default';
+ return self::loadUploadTypeConfig($active_upload_type, $status);
+ }
+
+ /**
+ * Loads the upload type configuration for a specific type and status.
+ *
+ * @param string $type
+ * @param string $status
+ *
+ * @return array{type: string, file_types: array, file_size: int}
+ */
+ public static function loadUploadTypeConfig(string $type, string $status): array
+ {
+ if (!isset($GLOBALS['UPLOAD_TYPES'][$type])) {
+ $type = 'default';
}
- $upload_type = $GLOBALS['UPLOAD_TYPES'][$active_upload_type];
+ $upload_type = $GLOBALS['UPLOAD_TYPES'][$type];
return [
- 'type' => $upload_type['type'],
+ 'type' => $upload_type['type'],
'file_types' => $upload_type['file_types'],
- 'file_size' => $upload_type['file_sizes'][$status]
+ 'file_size' => $upload_type['file_sizes'][$status],
];
}