version 1.1135, 2013/07/03 05:03:12
|
version 1.1136, 2013/07/09 00:17:22
|
Line 8568 Incoming parameters:
|
Line 8568 Incoming parameters:
|
1. user's username |
1. user's username |
2. user's domain |
2. user's domain |
3. quota name - portfolio, author, or course |
3. quota name - portfolio, author, or course |
(if no quota name provided, defaults to portfolio). |
(if no quota name provided, defaults to portfolio). |
|
4. crstype - official, unofficial or community, if quota name is |
|
course |
|
|
Returns: |
Returns: |
1. Disk quota (in Mb) assigned to student. |
1. Disk quota (in Mb) assigned to student. |
Line 8590 defined for the user's institutional sta
|
Line 8592 defined for the user's institutional sta
|
|
|
|
|
sub get_user_quota { |
sub get_user_quota { |
my ($uname,$udom,$quotaname) = @_; |
my ($uname,$udom,$quotaname,$crstype) = @_; |
my ($quota,$quotatype,$settingstatus,$defquota); |
my ($quota,$quotatype,$settingstatus,$defquota); |
if (!defined($udom)) { |
if (!defined($udom)) { |
$udom = $env{'user.domain'}; |
$udom = $env{'user.domain'}; |
Line 8641 sub get_user_quota {
|
Line 8643 sub get_user_quota {
|
if ($quota eq '' || wantarray) { |
if ($quota eq '' || wantarray) { |
if ($quotaname eq 'course') { |
if ($quotaname eq 'course') { |
my %domdefs = &Apache::lonnet::get_domain_defaults($udom); |
my %domdefs = &Apache::lonnet::get_domain_defaults($udom); |
$defquota = $domdefs{'uploadquota'}; |
if (($crstype eq 'official') || ($crstype eq 'unofficial') || ($crstype eq 'community')) { |
|
$defquota = $domdefs{$crstype.'quota'}; |
|
} |
|
if ($defquota eq '') { |
|
$defquota = 500; |
|
} |
} else { |
} else { |
($defquota,$settingstatus) = &default_quota($udom,$inststatus,$quotaname); |
($defquota,$settingstatus) = &default_quota($udom,$inststatus,$quotaname); |
} |
} |
Line 8763 sub default_quota {
|
Line 8770 sub default_quota {
|
|
|
=pod |
=pod |
|
|
=item * &excess_filesize_authorspace() |
=item * &excess_filesize_warning() |
|
|
Returns warning message if upload of file to authoring space, or copying |
Returns warning message if upload of file to authoring space, or copying |
of existing file within authoring space will cause quota to be exceeded. |
of existing file within authoring space will cause quota for the authoring |
|
space to be exceeded, |
|
|
|
Same, if upload of a file directly to a course/community via Course Editor |
|
will cause quota for uploaded content for the course to be exceeded. |
|
|
Inputs: 6 |
Inputs: 6 |
1. username |
1. username or coursenum |
2. domain |
2. domain |
3. directory path for top level of current authoring space |
3. context ('author' or 'course') |
4. filename of file for which action is being requested |
4. filename of file for which action is being requested |
5. filesize (kB) of file |
5. filesize (kB) of file |
6. action being taken: copy or upload. |
6. action being taken: copy or upload. |
Line 8781 Returns: 1 scalar: HTML to display conta
|
Line 8792 Returns: 1 scalar: HTML to display conta
|
|
|
=cut |
=cut |
|
|
sub excess_filesize_authorspace { |
sub excess_filesize_warning { |
my ($uname,$udom,$authorspace,$filename,$filesize,$action) = @_; |
my ($uname,$udom,$context,$filename,$filesize,$action) = @_; |
my $disk_quota = &Apache::loncommon::get_user_quota($uname,$udom,'author'); #expressed in MB |
my $current_disk_usage = 0; |
|
my $disk_quota = &get_user_quota($uname,$udom,$context); #expressed in MB |
|
if ($context eq 'author') { |
|
my $authorspace = $Apache::lonnet::perlvar{'lonDocRoot'}."/priv/$udom/$uname"; |
|
$current_disk_usage = &Apache::lonnet::diskusage($udom,$uname,$authorspace); |
|
} else { |
|
foreach my $subdir ('docs','supplemental') { |
|
$current_disk_usage += &Apache::lonnet::diskusage($udom,$uname,"userfiles/$subdir",1); |
|
} |
|
} |
$disk_quota = int($disk_quota * 1000); |
$disk_quota = int($disk_quota * 1000); |
my $current_disk_usage = &Apache::lonnet::diskusage($udom,$uname,$authorspace); |
|
if (($current_disk_usage + $filesize) > $disk_quota) { |
if (($current_disk_usage + $filesize) > $disk_quota) { |
return '<p><span class="LC_warning">'. |
return '<p><span class="LC_warning">'. |
&mt("Unable to $action [_1]. (size = [_2] kilobytes). Disk quota will be exceeded.", |
&mt("Unable to $action [_1]. (size = [_2] kilobytes). Disk quota will be exceeded.", |
Line 8800 sub excess_filesize_authorspace {
|
Line 8819 sub excess_filesize_authorspace {
|
############################################### |
############################################### |
|
|
|
|
|
|
|
|
sub get_secgrprole_info { |
sub get_secgrprole_info { |
my ($cdom,$cnum,$needroles,$type) = @_; |
my ($cdom,$cnum,$needroles,$type) = @_; |
my %sections_count = &get_sections($cdom,$cnum); |
my %sections_count = &get_sections($cdom,$cnum); |