[LON-CAPA-cvs] cvs: loncom /interface portfolio.pm

banghart lon-capa-cvs@mail.lon-capa.org
Fri, 10 Sep 2004 20:14:45 -0000


banghart		Fri Sep 10 16:14:45 2004 EDT

  Modified files:              
    /loncom/interface	portfolio.pm 
  Log:
  	Removed Fixme, hoping this is a better way to handle
  	the no_such_dir condition.
  
  
Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.42 loncom/interface/portfolio.pm:1.43
--- loncom/interface/portfolio.pm:1.42	Fri Sep 10 14:05:15 2004
+++ loncom/interface/portfolio.pm	Fri Sep 10 16:14:45 2004
@@ -350,15 +350,6 @@
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['selectfile','currentpath',
 					     'currentfile']);
-	# make sure there is a portfolio directory off /userfiles
-	# Fixme -- Do this in a better way -- offload it to the LOND routine
-	my @dir_list=&Apache::lonnet::dirlist('/',
-					    $ENV{'user.domain'},
-					    $ENV{'user.name'},$portfolio_root);
-	if ($dir_list[0] eq 'no_such_dir'){
-	     &Apache::lonnet::mkdiruserfile($ENV{'user.name'},
-	     $ENV{'user.domain'},'portfolio');
-	}
 	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>'.
@@ -385,10 +376,26 @@
 	if ($ENV{'form.currentpath'}) {
 	    $current_path = $ENV{'form.currentpath'};
 	}
-	@dir_list=&Apache::lonnet::dirlist($current_path,
+	my @dir_list=&Apache::lonnet::dirlist($current_path,
 					    $ENV{'user.domain'},
 					    $ENV{'user.name'},$portfolio_root);
-    
+    if (@dir_list[0] eq 'no_such_dir'){
+        # two main reasons for this: 1) never been here, so directory structure not created
+        #                            2) back-button navigation after deleting a directory
+        if ($current_path eq '/'){
+	        &Apache::lonnet::mkdiruserfile($ENV{'user.name'},
+	        $ENV{'user.domain'},'portfolio');
+        }else{ # some directory that snuck in
+            # get rid of the directory from the recent pulldown, just in case
+            &Apache::lonhtmlcommon::remove_recent('portfolio',[$current_path]);
+            $current_path = '/'; # force it back to the root        
+        }
+        # now grab the directory list again, for the first time
+    	@dir_list=&Apache::lonnet::dirlist($current_path,
+				    $ENV{'user.domain'},
+				    $ENV{'user.name'},$portfolio_root);
+        
+    }
 	# need to know if directory is empty so it can be removed if desired
 	my $is_empty=(@dir_list == 2);
 	&display_directory($r,$current_path,$is_empty,\@dir_list);