diff --git a/modules/upload.module b/modules/upload.module index a5f624ab68489841f8cd5ecf532b4e9e47073f1e..000c5ae15a9f11f5b3cf55510476594671b212ed 100644 --- a/modules/upload.module +++ b/modules/upload.module @@ -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); } diff --git a/modules/upload/upload.module b/modules/upload/upload.module index a5f624ab68489841f8cd5ecf532b4e9e47073f1e..000c5ae15a9f11f5b3cf55510476594671b212ed 100644 --- a/modules/upload/upload.module +++ b/modules/upload/upload.module @@ -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); }