Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
20898757
Commit
20898757
authored
Sep 10, 2010
by
Ruslan Kabalin
Browse files
get_max_upload_size function is added
Signed-off-by:
Ruslan Kabalin
<
ruslan.kabalin@luns.net.uk
>
parent
98bb3e58
Changes
2
Hide whitespace changes
Inline
Side-by-side
htdocs/artefact/file/form/elements/filebrowser.php
View file @
20898757
...
...
@@ -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
);
}
...
...
htdocs/lib/mahara.php
View file @
20898757
...
...
@@ -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
*
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment