--- loncom/interface/portfolio.pm 2004/09/08 20:34:28 1.39 +++ loncom/interface/portfolio.pm 2004/09/10 21:33:48 1.46 @@ -74,7 +74,7 @@ sub display_directory { &Apache::lonhtmlcommon::select_recent('portfolio','currentpath', 'this.form.submit();')); $r->print(""); - if ($is_empty) { + if ($is_empty && ($current_path ne '/')) { $displayOut = '
'. ''. ''. @@ -211,6 +211,9 @@ sub delete_dir_confirmed { $r->print(' An error occured (dir) ('.$result. ') while trying to delete '.$directory_name.'
'); } else { + # now remove from recent +# $r->print('
removing '.$directory_name.'
print(' No file was selected to upload.'. + 'To upload a file, click Browse...'. + ', select a file, then click Upload,'); } if ($ENV{'form.uploaddoc.filename'}) { &upload($r); @@ -377,10 +376,28 @@ sub handler { 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);