version 1.37, 2004/09/06 23:59:05
|
version 1.38, 2004/09/08 17:53:37
|
Line 376 sub rename_confirmed {
|
Line 376 sub rename_confirmed {
|
sub upload { |
sub upload { |
my ($r)=@_; |
my ($r)=@_; |
my $fname=$ENV{'form.uploaddoc.filename'}; |
my $fname=$ENV{'form.uploaddoc.filename'}; |
|
my $filesize = (length($ENV{'form.uploaddoc'})) / 1000; #express in k (1024?) |
|
my $disk_quota = 20000; # expressed in k |
$fname=&Apache::lonnet::clean_filename($fname); |
$fname=&Apache::lonnet::clean_filename($fname); |
my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'}, |
my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'}, |
$ENV{'user.name'}). |
$ENV{'user.name'}). |
'/userfiles/portfolio'; |
'/userfiles/portfolio'; |
|
# Fixme --- Move the checking for existing file to LOND error return |
my @dir_list=&Apache::lonnet::dirlist($ENV{'form.currentpath'}, |
my @dir_list=&Apache::lonnet::dirlist($ENV{'form.currentpath'}, |
$ENV{'user.domain'}, |
$ENV{'user.domain'}, |
$ENV{'user.name'},$portfolio_root); |
$ENV{'user.name'},$portfolio_root); |
Line 390 sub upload {
|
Line 393 sub upload {
|
$found_file = 1; |
$found_file = 1; |
} |
} |
} |
} |
$r->print('<br />'.&Apache::lonnet::diskusage($ENV{'user.domain'}, $ENV{'user.name'},$portfolio_root).'<br />'); |
my $current_disk_usage = &Apache::lonnet::diskusage($ENV{'user.domain'}, $ENV{'user.name'},$portfolio_root); |
if ($found_file){ |
if (($current_disk_usage + $filesize) > $disk_quota){ |
|
$r->print('<font color="red">Unable to upload <strong>'.$fname.' (size = '.$filesize.' kilobytes</strong>. Disk quota will be exceeded.'. |
|
'<br />Disk quota is '.$disk_quota.' kilobytes. Your current disk usage is '.$current_disk_usage.' kilobytes.'); |
|
} |
|
elsif ($found_file){ |
$r->print('<font color="red">Unable to upload <strong>'.$fname.'</strong>, a file by that name was found in <strong>'.$ENV{'form.currentpath'}.'</strong></font>'. |
$r->print('<font color="red">Unable to upload <strong>'.$fname.'</strong>, a file by that name was found in <strong>'.$ENV{'form.currentpath'}.'</strong></font>'. |
'<br />To upload, rename or delete existing '.$fname.' in '.$ENV{'form.currentpath'}); |
'<br />To upload, rename or delete existing '.$fname.' in '.$ENV{'form.currentpath'}); |
} else { |
} else { |
Line 461 sub handler {
|
Line 468 sub handler {
|
['selectfile','currentpath', |
['selectfile','currentpath', |
'currentfile']); |
'currentfile']); |
# make sure there is a portfolio directory off /userfiles |
# make sure there is a portfolio directory off /userfiles |
|
# Fixme -- Do this in a better way -- offload it to the LOND routine |
my @dir_list=&Apache::lonnet::dirlist('/', |
my @dir_list=&Apache::lonnet::dirlist('/', |
$ENV{'user.domain'}, |
$ENV{'user.domain'}, |
$ENV{'user.name'},$portfolio_root); |
$ENV{'user.name'},$portfolio_root); |
Line 489 sub handler {
|
Line 497 sub handler {
|
if ($ENV{'form.currentpath'}) { |
if ($ENV{'form.currentpath'}) { |
$current_path = $ENV{'form.currentpath'}; |
$current_path = $ENV{'form.currentpath'}; |
} |
} |
my @dir_list=&Apache::lonnet::dirlist($current_path, |
@dir_list=&Apache::lonnet::dirlist($current_path, |
$ENV{'user.domain'}, |
$ENV{'user.domain'}, |
$ENV{'user.name'},$portfolio_root); |
$ENV{'user.name'},$portfolio_root); |
|
|