--- loncom/interface/portfolio.pm 2004/10/25 13:04:58 1.51
+++ loncom/interface/portfolio.pm 2005/02/21 02:20:12 1.77
@@ -33,8 +33,8 @@ use Apache::lonlocal;
# receives a file name and path stub from username/userfiles/portfolio/
# returns an anchor tag consisting encoding filename and currentpath
sub make_anchor {
- my ($filename, $current_path) = @_;
- my $anchor = ''.$filename.'';
+ my ($filename, $current_path, $current_mode, $field_name) = @_;
+ my $anchor = ''.$filename.'';
return $anchor;
}
my $dirptr=16384;
@@ -48,6 +48,7 @@ sub display_common {
''.
''.
''.
+ ''.
''.
'';
$r->print($displayOut);
@@ -57,23 +58,23 @@ sub display_common {
''.
''.
''.
+ ''.
''.
'';
$r->print($displayOut);
$r->print('');
my @tree = split (/\//,$current_path);
- $r->print(''.&make_anchor('portfolio','/').'/');
+ $r->print(''.&make_anchor('portfolio','/',$ENV{"form.mode"},$ENV{"form.fieldname"}).'/');
if (@tree > 1){
my $newCurrentPath = '';
for (my $i = 1; $i< @tree; $i++){
$newCurrentPath .= $tree[$i].'/';
- $r->print(&make_anchor($tree[$i],'/'.$newCurrentPath).'/');
+ $r->print(&make_anchor($tree[$i],'/'.$newCurrentPath, $ENV{"form.mode"},$ENV{"form.fieldname"}).'/');
}
}
$r->print('');
&Apache::lonhtmlcommon::store_recent('portfolio',$current_path,$current_path);
- #Fixme -- remove from recent those paths that are deleted
- $r->print(' '.&mt('Delete').' '.&display_file().'? '.&mt('Delete').' '.&display_file(undef,\@files).'?
");
@@ -82,6 +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 display_file_select {
- my ($r,$current_path,$is_empty,$dir_list)=@_;
- my $iconpath= $r->dir_config('lonIconsURL') . "/";
- my $display_out;
- if ($is_empty && ($current_path ne '/')) {
- $display_out = ''.
+ if ($select_mode eq 'true') {
+ $r->print('
+
+
+
+ ');
+ }
}
sub open_form {
my ($r)=@_;
+ my @files=&Apache::loncommon::get_env_multiple('form.selectfile');
$r->print(''.
'
+
+
+
+ ');
+ $r->print('Select Name Size Last Modified '.
+ '
+ if ($select_mode eq 'true') {
+ $r->print(' ');
+ $r->print('Actions Name Size Last Modified ');
+ if ($select_mode eq 'true'){
+ $r->print(' ');
+ } else {
+ $r->print(' ');
} else {
$r->print('');
+ }
$r->print(' Go to ... ');
- $r->print(''.&make_anchor($filename.'/',$current_path.$filename.'/').' ');
+ $r->print(''.&make_anchor($filename.'/',$current_path.$filename.'/',$ENV{'form.mode'},$ENV{"form.fieldname"}).' ');
$r->print('');
- $r->print('
-
- ');
+ if ($select_mode eq 'true'){
+ $r->print('print("CHECKED");
+ }
+ $r->print('> ');
+ } else {
+ if (exists $locked_files{$current_path.$filename}){
+ $r->print('Locked ');
+ } else {
+ $r->print('
+ Rename
+ Meta
+ ');
+ }
+ }
$r->print('');
$r->print(' '.
$filename.' ');
@@ -190,20 +159,35 @@ sub display_file_select {
}
}
}
- $r->print('
- ');
+ ');
+ } else {
+ $r->print('
';
+ }
+ } elsif (ref($filename) eq "SCALAR") {
+ $display_file_text = ''.$path.$filename.'';
+ }
+ return $display_file_text;
}
sub done {
+ my ($message)=@_;
+ unless (defined $message) {
+ $message='Done';
+ }
return (''.&mt('Done').'
');
+ '&mode='.$ENV{'form.mode'}.
+ '">'.&mt($message).'');
}
sub delete {
my ($r)=@_;
- &open_form($r);
- $r->print('
");
+ $r->print(&done('Back'));
+ } else {
+ if (scalar(@files)) {
+ &open_form($r);
+ $r->print('
");
+ $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());
}
@@ -292,10 +309,16 @@ sub delete_dir_confirmed {
sub rename {
my ($r)=@_;
- &open_form($r);
- $r->print('
'.&mt('Rename').' '.&display_file().' to - ?
'); - &close_form($r); + 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.'.&mt('Rename').' '.&display_file().' to + ?
'); + &close_form($r); + } } sub rename_confirmed { @@ -311,37 +334,62 @@ sub rename_confirmed { my $result= &Apache::lonnet::renameuserfile($ENV{'user.name'},$ENV{'user.domain'}, 'portfolio'.$ENV{'form.currentpath'}.$ENV{'form.selectfile'}, - 'portfolio'.$ENV{'form.currentpath'}.$ENV{'form.filenewname'}); + 'portfolio'.$ENV{'form.currentpath'}.$filenewname); if ($result ne 'ok') { $r->print(' An errror occured ('.$result. ') while trying to rename '.&display_file().' to '. &display_file(undef,$filenewname).'