--- loncom/interface/portfolio.pm 2004/11/26 00:17:37 1.59
+++ loncom/interface/portfolio.pm 2005/02/17 08:29:43 1.75
@@ -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'});
if ($is_empty && ($current_path ne '/')) {
$display_out = '
'.
''.
@@ -184,6 +174,7 @@ sub display_file_select {
#$strip holds directory/file name
#$dom
my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16);
+ $filename =~ s/\s+$//;
if (($filename ne '.') && ($filename ne '..')) {
if ($dirptr&$testdir) {
$r->print('
');
@@ -192,9 +183,11 @@ sub display_file_select {
$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());
}
@@ -314,7 +335,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());
@@ -345,14 +366,35 @@ 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 {
my ($r)=@_;
- my $java_script =(<
function finishSelect() {
- fileList = "";
+ENDSMP
+ $javascript .= 'fileList = "'.$java_files.'";';
+ $javascript .= (<
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: ");
+ foreach (&Apache::lonnet::files_not_in_path($ENV{'user.name'}, $ENV{'form.currentpath'})) {
+ $r->print($_." ");
+ }
}
sub upload {
my ($r)=@_;
@@ -392,7 +438,7 @@ sub upload {
}
}
my $current_disk_usage = &Apache::lonnet::diskusage($ENV{'user.domain'}, $ENV{'user.name'},$portfolio_root);
- if (($current_disk_usage + $filesize) > $disk_quota){
+ 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.');
}
@@ -444,6 +490,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());
}
@@ -453,23 +502,37 @@ sub handler {
my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'},
$ENV{'user.name'}).
'/userfiles/portfolio';
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['selectfile','currentpath','meta',
+ 'currentfile','action','fieldname','mode','rename']);
&Apache::loncommon::no_cache($r);
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
# Give the LON-CAPA page header
- $r->print(''.
+ my $html=&Apache::lonxml::xmlbegin();
+ $r->print($html.''.
&mt('Portfolio Manager').
- "\n".
- &Apache::loncommon::bodytag('Portfolio Manager'));
+ "\n");
+ if ($ENV{"form.mode"} eq 'selectfile'){
+ $r->print(&Apache::loncommon::bodytag('Portfolio Manager',undef,undef,1));
+ } else {
+ $r->print(&Apache::loncommon::bodytag('Portfolio Manager'));
+ }
$r->rflush();
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['selectfile','currentpath',
- 'currentfile','action','fieldname','mode']);
if (($ENV{'form.storeupl'} eq 'Upload') & (!$ENV{'form.uploaddoc.filename'})){
$r->print(' No file was selected to upload.'.
'To upload a file, click Browse...'.
', select a file, then click Upload,');
}
+ if ($ENV{'form.meta'}) {
+ &open_form($r);
+# $r->print(&edit_meta_data($r, $ENV{'form.currentpath'}.$ENV{'form.selectfile'}));
+ $r->print('Edit the meta data ');
+ &close_form($r);
+ }
+ if ($ENV{'form.store'}) {
+ }
+
if ($ENV{'form.uploaddoc.filename'}) {
&upload($r);
} elsif ($ENV{'form.action'} eq 'delete' && $ENV{'form.confirmed'}) {
@@ -482,7 +545,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);