--- loncom/interface/portfolio.pm 2005/02/17 08:29:43 1.75
+++ loncom/interface/portfolio.pm 2005/02/21 02:20:12 1.77
@@ -83,7 +83,14 @@ sub display_directory {
my ($r,$current_path,$is_empty,$dir_list)=@_;
my $iconpath= $r->dir_config('lonIconsURL') . "/";
my $display_out;
+ my $select_mode;
+ my $checked_files;
my %locked_files = &Apache::lonnet::get_marked_as_readonly_hash ($ENV{'user.domain'},$ENV{'user.name'});
+ if ($ENV{"form.mode"} eq 'selectfile'){
+ &select_files($r);
+ $checked_files =&Apache::lonnet::files_in_path($ENV{'user.name'},$ENV{'form.currentpath'});
+ $select_mode = 'true';
+ }
if ($is_empty && ($current_path ne '/')) {
$display_out = '
');
+ }
}
sub open_form {
@@ -253,11 +223,15 @@ sub display_file {
}
sub done {
+ my ($message)=@_;
+ unless (defined $message) {
+ $message='Done';
+ }
return ('');
+ '">'.&mt($message).'');
}
sub delete {
@@ -268,7 +242,7 @@ sub delete {
if (&Apache::lonnet::is_locked($file_name,$ENV{'user.domain'},$ENV{'user.name'} ) eq 'true') {
$r->print ("The file is locked and cannot be deleted.
");
- $r->print(&done());
+ $r->print(&done('Back'));
} else {
if (scalar(@files)) {
&open_form($r);
@@ -431,29 +405,43 @@ sub upload {
$ENV{'user.domain'},
$ENV{'user.name'},$portfolio_root);
my $found_file = 0;
+ my $locked_file = 0;
foreach my $line (@dir_list) {
- my ($filename)=split(/\&/,$line,2);
- if ($filename eq $fname){
+ my ($file_name)=split(/\&/,$line,2);
+ if ($file_name eq $fname){
$found_file = 1;
+ if (&Apache::lonnet::is_locked($ENV{'form.currentpath'}.$file_name,$ENV{'user.domain'},$ENV{'user.name'} ) eq 'true') {
+ $locked_file = 1;
+ }
}
}
my $current_disk_usage = &Apache::lonnet::diskusage($ENV{'user.domain'}, $ENV{'user.name'},$portfolio_root);
if ((($current_disk_usage/1000) + $filesize) > $disk_quota){
$r->print('Unable to upload '.$fname.' (size = '.$filesize.' kilobytes. Disk quota will be exceeded.'.
'
Disk quota is '.$disk_quota.' kilobytes. Your current disk usage is '.$current_disk_usage.' kilobytes.');
+ $r->print(&done('Back'));
}
- elsif ($found_file){
- $r->print('Unable to upload '.$fname.', a file by that name was found in '.$ENV{'form.currentpath'}.''.
- '
To upload, rename or delete existing '.$fname.' in '.$ENV{'form.currentpath'});
+ elsif ($found_file){
+ if ($locked_file){
+ $r->print('Unable to upload '.$fname.', a locked file by that name was found in portfolio'.$ENV{'form.currentpath'}.''.
+ '
You will be able to rename or delete existing '.$fname.' after a grade has been assigned.');
+ $r->print(&done('Back'));
+ } else {
+ $r->print('Unable to upload '.$fname.', a file by that name was found in portfolio'.$ENV{'form.currentpath'}.''.
+ '
To upload, rename or delete existing '.$fname.' in portfolio'.$ENV{'form.currentpath'});
+ $r->print(&done('Back'));
+ }
} else {
my $result=&Apache::lonnet::userfileupload('uploaddoc','',
'portfolio'.$ENV{'form.currentpath'});
if ($result !~ m|^/uploaded/|) {
$r->print(' An errror occured ('.$result.
') while trying to upload '.&display_file().'
');
+ $r->print(&done('Back'));
+ } else {
+ $r->print(&done());
}
}
- $r->print(&done());
}
sub createdir {
@@ -581,12 +569,7 @@ sub handler {
# need to know if directory is empty so it can be removed if desired
my $is_empty=(@dir_list == 2);
&display_common($r,$current_path,$is_empty,\@dir_list);
- if ($ENV{"form.mode"} eq 'selectfile'){
- &select_files($r);
- &display_file_select($r,$current_path,$is_empty,\@dir_list);
- } else {
- &display_directory($r,$current_path,$is_empty,\@dir_list);
- }
+ &display_directory($r,$current_path,$is_empty,\@dir_list);
$r->print("