Commit 20898757 authored by Ruslan Kabalin's avatar Ruslan Kabalin
Browse files

get_max_upload_size function is added


Signed-off-by: default avatarRuslan Kabalin <ruslan.kabalin@luns.net.uk>
parent 98bb3e58
......@@ -108,11 +108,7 @@ function pieform_element_filebrowser(Pieform $form, $element) {
}
}
if ($config['upload']) {
$maxuploadsize = min(get_real_size(ini_get('post_max_size')), get_real_size(ini_get('upload_max_filesize')));
if (!$institution && !$group) {
$userquotaremaining = $USER->get('quota') - $USER->get('quotaused');
$maxuploadsize = min($maxuploadsize, $userquotaremaining);
}
$maxuploadsize = get_max_upload_size(!$institution && !$group);
$maxuploadsize = display_size($maxuploadsize);
$smarty->assign('maxuploadsize', $maxuploadsize);
}
......
......@@ -2101,6 +2101,22 @@ function get_real_size($size=0) {
throw new SystemException('get_real_size called without valid size');
}
/**
* Determines maximum upload size based on quota and PHP settings.
*
* @param bool $is_user whether upload size should be evaluated for user (quota is considered)
* @return integer
*/
function get_max_upload_size($is_user) {
global $USER;
$maxuploadsize = min(get_real_size(ini_get('post_max_size')), get_real_size(ini_get('upload_max_filesize')));
if ($is_user) {
$userquotaremaining = $USER->get('quota') - $USER->get('quotaused');
$maxuploadsize = min($maxuploadsize, $userquotaremaining);
}
return $maxuploadsize;
}
/**
* Converts bytes into display form
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment