--- loncom/interface/portfolio.pm 2004/10/25 17:00:25 1.52 +++ loncom/interface/portfolio.pm 2004/11/26 00:17:37 1.59 @@ -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('
'. + $r->print('
'. &Apache::lonhtmlcommon::select_recent('portfolio','currentpath', 'this.form.submit();')); $r->print("
"); @@ -82,6 +83,12 @@ 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}.':'; + } if ($is_empty && ($current_path ne '/')) { $display_out = '
'. ''. @@ -105,11 +112,18 @@ sub display_directory { #$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); + if ($Apache::lonhomework::results{"resource.$ENV{'user.domain'}.$ENV{'user.name'}.$filename"}eq'true'){ + &Apache::lonnet::logthis("found submitted file"); + &Apache::lonnet::logthis("resource.$ENV{'user.domain'}.$ENV{'user.name'}.$filename"); + } else { + &Apache::lonnet::logthis("$filename not found submitted file"); + &Apache::lonnet::logthis("resource.$ENV{'user.domain'}.$ENV{'user.name'}.$filename"); + } if (($filename ne '.') && ($filename ne '..')) { if ($dirptr&$testdir) { $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(''); } else { $r->print(''); @@ -174,7 +188,7 @@ sub display_file_select { if ($dirptr&$testdir) { $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(''); } else { $r->print(''); @@ -232,14 +246,22 @@ sub done { return ('

'.&mt('Done').'

'); } sub delete { my ($r)=@_; - &open_form($r); - $r->print('

'.&mt('Delete').' '.&display_file().'?

'); - &close_form($r); + my @check; + my $file_name = $ENV{'form.currentpath'}.$ENV{'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('

'.&mt('Delete').' '.&display_file().'?

'); + &close_form($r); + } } sub delete_confirmed { @@ -292,10 +314,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.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 renamed.
"); + $r->print(&done()); + } else { + &open_form($r); + $r->print('

'.&mt('Rename').' '.&display_file().' to + ?

'); + &close_form($r); + } } sub rename_confirmed { @@ -311,7 +339,7 @@ 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 '. @@ -327,7 +355,7 @@ sub select_files { fileList = ""; for (i=0;i