Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan-Hendrik Willms
Stud.IP
Commits
89fceb4f
Commit
89fceb4f
authored
3 years ago
by
Jan-Hendrik Willms
Browse files
Options
Downloads
Patches
Plain Diff
re #448
parent
3e7e8848
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/filesystem/FileManager.php
+23
-10
23 additions, 10 deletions
lib/filesystem/FileManager.php
lib/filesystem/MessageFolder.php
+19
-0
19 additions, 0 deletions
lib/filesystem/MessageFolder.php
with
42 additions
and
10 deletions
lib/filesystem/FileManager.php
+
23
−
10
View file @
89fceb4f
...
...
@@ -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
]
,
];
}
...
...
This diff is collapsed.
Click to expand it.
lib/filesystem/MessageFolder.php
+
19
−
0
View file @
89fceb4f
...
...
@@ -238,6 +238,25 @@ class MessageFolder extends StandardFolder implements FolderType
{
}
/**
* This method handles file upload validation.
*
* @param array $uploaded_file The uploaded file that shall be validated.
* @param string $user_id The user who wishes to upload a file
* in this MessageFolder.
*
* @return string|null An error message on failure, null on success.
*/
public
function
validateUpload
(
FileType
$newfile
,
$user_id
)
{
$status
=
$GLOBALS
[
'perm'
]
->
get_perm
(
$user_id
);
return
$this
->
getValidationMessages
(
FileManager
::
loadUploadTypeConfig
(
'attachments'
,
$status
),
$newfile
);
}
/**
* Handles the deletion of a file inside this folder.
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment