function _file_validate_size in Album Photos 6.2
Same name and namespace in other branches
- 7.3 photos_swfu/photos_swfu.module \_file_validate_size()
File
- photos_swfu/
photos_swfu.module, line 198
Code
function _file_validate_size($file, $file_limit = 0, $user_limit = 0, $ac = false) {
if (!$ac) {
$ac = $GLOBALS['user'];
}
$errors = array();
if ($ac->uid != 1) {
if ($file_limit && $file->filesize > $file_limit) {
$errors[] = t('The file is %filesize exceeding the maximum file size of %maxsize.', array(
'%filesize' => format_size($file->filesize),
'%maxsize' => format_size($file_limit),
));
}
$total_size = file_space_used($ac->uid) + $file->filesize;
if ($user_limit && $total_size > $user_limit) {
$errors[] = t('The file is %filesize which would exceed your disk quota of %quota.', array(
'%filesize' => format_size($file->filesize),
'%quota' => format_size($user_limit),
));
}
}
return $errors;
}