Skip to content
Snippets Groups Projects
Commit 1b7fd5e6 authored by Gerhard Killesreiter's avatar Gerhard Killesreiter
Browse files

#54913, problem with checking filesize during uploading if user belongs into...

#54913, problem with checking filesize during uploading if user belongs into more than one role, patch by dopry
parent f005101a
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -285,16 +285,22 @@ function _upload_validate(&$node) {
$error['usersize']++;
}
}
if ($error['extension'] == count($user->roles) && $user->uid != 1) {
$user_roles = count($user->roles);
$valid = TRUE;
if ($error['extension'] == $user_roles) {
form_set_error('upload', t('The selected file %name can not be attached to this post, because it is only possible to attach files with the following extensions: %files-allowed.', array('%name' => theme('placeholder', $file->filename), '%files-allowed' => theme('placeholder', $extensions))));
$valid = FALSE;
}
elseif ($error['uploadsize'] == count($user->roles) && $user->uid != 1) {
elseif ($error['uploadsize'] == $user_roles) {
form_set_error('upload', t('The selected file %name can not be attached to this post, because it exceeded the maximum filesize of %maxsize.', array('%name' => theme('placeholder', $file->filename), '%maxsize' => theme('placeholder', format_size($uploadsize)))));
$valid = FALSE;
}
elseif ($error['usersize'] == count($user->roles) && $user->uid != 1) {
elseif ($error['usersize'] == $user_roles) {
form_set_error('upload', t('The selected file %name can not be attached to this post, because the disk quota of %quota has been reached.', array('%name' => theme('placeholder', $file->filename), '%quota' => theme('placeholder', format_size($usersize)))));
$valid = FALSE;
}
if (count($error)) {
if (!$valid) {
unset($node->files[$fid], $_SESSION['file_previews'][$fid]);
file_delete($file->filepath);
}
......
......@@ -285,16 +285,22 @@ function _upload_validate(&$node) {
$error['usersize']++;
}
}
if ($error['extension'] == count($user->roles) && $user->uid != 1) {
$user_roles = count($user->roles);
$valid = TRUE;
if ($error['extension'] == $user_roles) {
form_set_error('upload', t('The selected file %name can not be attached to this post, because it is only possible to attach files with the following extensions: %files-allowed.', array('%name' => theme('placeholder', $file->filename), '%files-allowed' => theme('placeholder', $extensions))));
$valid = FALSE;
}
elseif ($error['uploadsize'] == count($user->roles) && $user->uid != 1) {
elseif ($error['uploadsize'] == $user_roles) {
form_set_error('upload', t('The selected file %name can not be attached to this post, because it exceeded the maximum filesize of %maxsize.', array('%name' => theme('placeholder', $file->filename), '%maxsize' => theme('placeholder', format_size($uploadsize)))));
$valid = FALSE;
}
elseif ($error['usersize'] == count($user->roles) && $user->uid != 1) {
elseif ($error['usersize'] == $user_roles) {
form_set_error('upload', t('The selected file %name can not be attached to this post, because the disk quota of %quota has been reached.', array('%name' => theme('placeholder', $file->filename), '%quota' => theme('placeholder', format_size($usersize)))));
$valid = FALSE;
}
if (count($error)) {
if (!$valid) {
unset($node->files[$fid], $_SESSION['file_previews'][$fid]);
file_delete($file->filepath);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment