--- loncom/interface/portfolio.pm 2004/12/04 19:08:42 1.62
+++ loncom/interface/portfolio.pm 2004/12/16 21:19:46 1.68
@@ -83,12 +83,7 @@ sub display_directory {
my ($r,$current_path,$is_empty,$dir_list)=@_;
my $iconpath= $r->dir_config('lonIconsURL') . "/";
my $display_out;
- my %locked_files=&Apache::lonnet::dump('file_permissions',
- $ENV{'user.domain'},$ENV{'user.name'});
- my $locked_file;
- foreach my $key (keys %locked_files) {
- $locked_file .= $locked_files{$key}.':';
- }
+ my %locked_files = &Apache::lonnet::get_marked_as_readonly_hash ($ENV{'user.domain'},$ENV{'user.name'});
if ($is_empty && ($current_path ne '/')) {
$display_out = '
');
+ $r->print('
+
+
+
+ ');
}
sub display_file_select {
my ($r,$current_path,$is_empty,$dir_list)=@_;
my $iconpath= $r->dir_config('lonIconsURL') . "/";
my $display_out;
my $checked_files = &Apache::lonnet::files_in_path($ENV{'user.name'}, $ENV{'form.currentpath'});
- foreach my $key (keys %$checked_files) {
- &Apache::lonnet::logthis("a key is $key $$checked_files{$key} is the value");
- }
if ($is_empty && ($current_path ne '/')) {
$display_out = '
');
@@ -219,12 +208,15 @@ sub display_file_select {
sub open_form {
my ($r)=@_;
+ my @files=&Apache::loncommon::get_env_multiple('form.selectfile');
$r->print('
');
$r->print('');
$r->print('');
- $r->print('');
+ foreach (@files) {
+ $r->print('');
+ }
$r->print('');
}
@@ -244,9 +236,19 @@ sub close_form {
sub display_file {
my ($path,$filename)=@_;
+ my $display_file_text;
if (!defined($path)) { $path=$ENV{'form.currentpath'}; }
- if (!defined($filename)) { $filename=$ENV{'form.selectfile'}; }
- return ''.$path.$filename.'';
+ if (!defined($filename)) {
+ $filename=$ENV{'form.selectfile'};
+ $display_file_text = ''.$path.$filename.'';
+ } elsif (ref($filename) eq "ARRAY") {
+ foreach (@$filename) {
+ $display_file_text .= ''.$path.$_.' ';
+ }
+ } elsif (ref($filename) eq "SCALAR") {
+ $display_file_text = ''.$path.$filename.'';
+ }
+ return $display_file_text;
}
sub done {
@@ -261,25 +263,36 @@ sub delete {
my ($r)=@_;
my @check;
my $file_name = $ENV{'form.currentpath'}.$ENV{'form.selectfile'};
+ my @files=&Apache::loncommon::get_env_multiple('form.selectfile');
+
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());
} else {
- &open_form($r);
- $r->print('
');
+ &close_form($r);
+ } else {
+ $r->print("No file was checked to delete. ");
+ $r->print(&done());
+ }
}
}
sub delete_confirmed {
my ($r)=@_;
- my $result=&Apache::lonnet::removeuserfile($ENV{'user.name'},
+ my @files=&Apache::loncommon::get_env_multiple('form.selectfile');
+ my $result;
+ foreach my $delete_file (@files) {
+ $result=&Apache::lonnet::removeuserfile($ENV{'user.name'},
$ENV{'user.domain'},'portfolio'.
$ENV{'form.currentpath'}.
- $ENV{'form.selectfile'});
- if ($result ne 'ok') {
+ $delete_file);
+ if ($result ne 'ok') {
$r->print(' An error occured ('.$result.
- ') while trying to delete '.&display_file().' ');
+ ') while trying to delete '.&display_file(undef, $delete_file).' ');
+ }
}
$r->print(&done());
}
@@ -321,7 +334,7 @@ sub delete_dir_confirmed {
sub rename {
my ($r)=@_;
- my $file_name = $ENV{'form.currentpath'}.$ENV{'form.selectfile'};
+ my $file_name = $ENV{'form.currentpath'}.$ENV{'form.rename'};
if (&Apache::lonnet::is_locked($file_name,$ENV{'user.domain'},$ENV{'user.name'}) eq 'true') {
$r->print ("The file is locked and cannot be renamed. ");
$r->print(&done());
@@ -352,6 +365,9 @@ sub rename_confirmed {
') while trying to rename '.&display_file().' to '.
&display_file(undef,$filenewname).' ');
}
+ if ($filenewname ne $ENV{'form.filenewname'}) {
+ $r->print("The new file name was changed from: ".$ENV{'form.filenewname'}." to $filenewname ");
+ }
$r->print(&done());
}
sub select_files {
@@ -359,7 +375,7 @@ sub select_files {
if ($ENV{'form.continue'} eq 'true') {
# here we update the selections for the currentpath
# eventually, have to handle removing those not checked, but . . .
- my @items=&Apache::loncommon::get_env_multiple('form.selectedfile');
+ my @items=&Apache::loncommon::get_env_multiple('form.selectfile');
&Apache::lonnet::save_selected_files($ENV{'user.name'}, $ENV{'form.currentpath'}, @items);
} else {
if ($ENV{'form.currentpath'} eq '/') {
@@ -372,12 +388,12 @@ sub select_files {
if ($java_files) {
$java_files.=',';
}
- my $java_script =(<
function finishSelect() {
ENDSMP
- $java_script .= 'fileList = "'.$java_files.'";';
- $java_script .= (<
ENDSMP
- $r->print($java_script);
+ $r->print($javascript);
$r->print("
Select portfolio files
Check as many as you wish in response to the essay problem. ");
$r->print("Files selected from other directories: ");
@@ -473,6 +489,9 @@ sub createdir {
') while trying to create a new directory '.&display_file().' ');
}
}
+ if ($newdir ne $ENV{'form.newdir'}) {
+ $r->print("The new directory name was changed from: ".$ENV{'form.newdir'}." to $newdir ");
+ }
$r->print(&done());
}
@@ -493,7 +512,7 @@ sub handler {
$r->rflush();
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['selectfile','currentpath',
- 'currentfile','action','fieldname','mode']);
+ 'currentfile','action','fieldname','mode','rename']);
if (($ENV{'form.storeupl'} eq 'Upload') & (!$ENV{'form.uploaddoc.filename'})){
$r->print(' No file was selected to upload.'.
'To upload a file, click Browse...'.
@@ -511,7 +530,9 @@ sub handler {
&delete_dir($r);
} elsif ($ENV{'form.action'} eq 'rename' && $ENV{'form.confirmed'}) {
&rename_confirmed($r);
- } elsif ($ENV{'form.action'} eq 'rename') {
+ } elsif ($ENV{'form.rename'}) {
+ $ENV{'form.selectfile'} = $ENV{'form.rename'};
+ $ENV{'form.action'} = 'rename';
&rename($r);
} elsif ($ENV{'form.createdir'}) {
&createdir($r);