--- loncom/interface/portfolio.pm	2004/10/25 13:04:58	1.51
+++ loncom/interface/portfolio.pm	2004/11/10 05:57:53	1.56
@@ -72,7 +72,6 @@ sub display_common {
     }
     $r->print('</font>');
     &Apache::lonhtmlcommon::store_recent('portfolio',$current_path,$current_path);
-    #Fixme -- remove from recent those paths that are deleted
     $r->print('<br /><form method=post action="/adm/portfolio">'.
 	      &Apache::lonhtmlcommon::select_recent('portfolio','currentpath',
 						    'this.form.submit();'));
@@ -82,6 +81,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 = '<form method="post" action="/adm/portfolio">'.
         '<input type="hidden" name="action" value="deletedir" />'.
@@ -105,6 +110,13 @@ 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('<tr bgcolor="#FFAA99"><td><img src="'.$iconpath.'folder_closed.gif"></td>');
@@ -237,9 +249,16 @@ sub done {
 
 sub delete {
     my ($r)=@_;
-    &open_form($r);
-    $r->print('<p>'.&mt('Delete').' '.&display_file().'?</p>');
-    &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.<br />");
+        $r->print(&done());
+    } else {
+        &open_form($r);
+        $r->print('<p>'.&mt('Delete').' '.&display_file().'?</p>');
+        &close_form($r);
+    }
 } 
 
 sub delete_confirmed {
@@ -292,10 +311,16 @@ sub delete_dir_confirmed {
 
 sub rename {
     my ($r)=@_;
-    &open_form($r);
-    $r->print('<p>'.&mt('Rename').' '.&display_file().' to 
-               <input name="filenewname" type="input" size="50" />?</p>');
-    &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.<br />");
+        $r->print(&done());
+    } else {
+        &open_form($r);
+        $r->print('<p>'.&mt('Rename').' '.&display_file().' to 
+                   <input name="filenewname" type="input" size="50" />?</p>');
+        &close_form($r);
+    }
 }
 
 sub rename_confirmed {
@@ -327,7 +352,7 @@ sub select_files {
             fileList = "";
             for (i=0;i<document.forms.checkselect.length;i++) { 
                 if (document.forms.checkselect[i].checked){
-                    fileList = fileList + document.forms.checkselect[i].value + "," ;
+                    fileList = fileList + document.forms.checkselect.currentpath.value + document.forms.checkselect[i].value + "," ;
                 }
             }
             opener.document.forms.lonhomework.
@@ -436,7 +461,7 @@ sub handler {
     $r->rflush();
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['selectfile','currentpath',
-					     'currentfile','action','fieldname']);
+					     'currentfile','action','fieldname','mode']);
 	if (($ENV{'form.storeupl'} eq 'Upload') & (!$ENV{'form.uploaddoc.filename'})){
    	    $r->print('<font color="red"> No file was selected to upload.'.
    	            'To upload a file, click <strong>Browse...</strong>'.