File:  [LON-CAPA] / loncom / interface / portfolio.pm
Revision 1.52: download - view: text, annotated - select for diffs
Mon Oct 25 17:00:25 2004 UTC (19 years, 8 months ago) by banghart
Branches: MAIN
CVS tags: HEAD
	Added 'mode' to list of QUERY_STRING fields to process

    1: # Copyright Michigan State University Board of Trustees
    2: #
    3: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    4: #
    5: # LON-CAPA is free software; you can redistribute it and/or modify
    6: # it under the terms of the GNU General Public License as published by
    7: # the Free Software Foundation; either version 2 of the License, or 
    8: # (at your option) any later version.
    9: #
   10: # LON-CAPA is distributed in the hope that it will be useful,
   11: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   12: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13: # GNU General Public License for more details.
   14: #
   15: # You should have received a copy of the GNU General Public License
   16: # along with LON-CAPA; if not, write to the Free Software
   17: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   18: #
   19: # /home/httpd/html/adm/gpl.txt
   20: #
   21: # http://www.lon-capa.org/
   22: #
   23: 
   24: package Apache::portfolio;
   25: use strict;
   26: use Apache::Constants qw(:common :http);
   27: use Apache::loncommon;
   28: use Apache::lonnet;
   29: use Apache::lontexconvert;
   30: use Apache::lonfeedback;
   31: use Apache::lonlocal;
   32: 
   33: # receives a file name and path stub from username/userfiles/portfolio/
   34: # returns an anchor tag consisting encoding filename and currentpath
   35: sub make_anchor {
   36:     my ($filename, $current_path) = @_;
   37:     my $anchor = '<a href="/adm/portfolio?selectfile='.$filename.'&currentpath='.$current_path.'">'.$filename.'</a>';
   38:     return $anchor;
   39: }
   40: my $dirptr=16384;
   41: sub display_common {
   42:     my ($r,$current_path,$is_empty,$dir_list)=@_;
   43:     my $iconpath= $r->dir_config('lonIconsURL') . "/";
   44:     $r->print('<table border="0" cellspacing="2" cellpadding="2"><tr valign="middle">');
   45:     $r->print('<td bgcolor="#ccddaa" align="center">');
   46:     my $displayOut = '<form method="post" enctype="multipart/form-data">';
   47:     $displayOut .= '<input name="uploaddoc" type="file" />'.
   48:         '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.
   49:         '<input type="hidden" name="action" value="'.$ENV{"form.action"}.'" />'.
   50:         '<input type="hidden" name="fieldname" value="'.$ENV{"form.fieldname"}.'" />'.
   51:         '<input type="submit" name="storeupl" value="Upload" />'.
   52:         '</form>';
   53:     $r->print($displayOut);
   54:     $r->print('</td></tr><tr><td bgcolor="#ccddaa" align="center">');
   55:     $displayOut = '<form method="post">';
   56:     $displayOut .= '<input name="newdir" type="input" />'.
   57:         '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.
   58:         '<input type="hidden" name="action" value="'.$ENV{"form.action"}.'" />'.
   59:         '<input type="hidden" name="fieldname" value="'.$ENV{"form.fieldname"}.'" />'.
   60:         '<input type="submit" name="createdir" value="'.&mt("Create Directory").'" />'.
   61:         '</form>';
   62:     $r->print($displayOut);
   63:     $r->print('</td></tr></table>');
   64:     my @tree = split (/\//,$current_path);
   65:     $r->print('<font size="+2">'.&make_anchor('portfolio','/').'/');
   66:     if (@tree > 1){
   67:         my $newCurrentPath = '';
   68:         for (my $i = 1; $i< @tree; $i++){
   69:             $newCurrentPath .= $tree[$i].'/';
   70:             $r->print(&make_anchor($tree[$i],'/'.$newCurrentPath).'/');
   71:         }
   72:     }
   73:     $r->print('</font>');
   74:     &Apache::lonhtmlcommon::store_recent('portfolio',$current_path,$current_path);
   75:     #Fixme -- remove from recent those paths that are deleted
   76:     $r->print('<br /><form method=post action="/adm/portfolio">'.
   77: 	      &Apache::lonhtmlcommon::select_recent('portfolio','currentpath',
   78: 						    'this.form.submit();'));
   79:     $r->print("</form>");
   80: }
   81: sub display_directory {
   82:     my ($r,$current_path,$is_empty,$dir_list)=@_;
   83:     my $iconpath= $r->dir_config('lonIconsURL') . "/";
   84:     my $display_out;
   85:     if ($is_empty && ($current_path ne '/')) {
   86:         $display_out = '<form method="post" action="/adm/portfolio">'.
   87:         '<input type="hidden" name="action" value="deletedir" />'.
   88:         '<input type="submit" name="deletedir" value="'.&mt("Delete Directory").'" />'.
   89:         '<input type="hidden" name="selectfile" value="" />'.
   90:         '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.
   91:         '</form>';
   92:         
   93:         $r->print($display_out);
   94: 	return;
   95:     }
   96:     $r->print('<table border="0" cellspacing="2" cellpadding="2">'.
   97:             '<tr><th>Actions</th><th>&nbsp;</th><th>Name</th><th>Size</th><th>Last Modified</th></tr>');
   98:     my $href_location="/uploaded/$ENV{'user.domain'}/$ENV{'user.name'}/portfolio$current_path";
   99:     foreach my $line (sort 
  100: 		      { 
  101: 			  my ($afile)=split('&',$a,2);
  102: 			  my ($bfile)=split('&',$b,2);
  103: 			  return (lc($afile) cmp lc($bfile));
  104: 		      } (@$dir_list)) {
  105:     	#$strip holds directory/file name
  106:     	#$dom 
  107:     	my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); 
  108:     	if (($filename ne '.') && ($filename ne '..')) {
  109:             if ($dirptr&$testdir) {
  110:                 $r->print('<tr bgcolor="#FFAA99"><td><img src="'.$iconpath.'folder_closed.gif"></td>');
  111:                 $r->print('<td>Go to ...</td>');
  112:                 $r->print('<td>'.&make_anchor($filename.'/',$current_path.$filename.'/').'</td>'); 
  113:                 $r->print('</tr>'); 
  114:             } else {
  115:                 $r->print('<tr bgcolor="#CCCCFF">');
  116:                 $r->print('<td>
  117:                     <form method="post" action="/adm/portfolio">
  118:                     <select name="action">
  119:                         <option value=""></option>
  120:                         <option value="delete">'.&mt("Delete").'</option>
  121:                         <option value="rename">'.&mt("Rename").'</option>
  122:                     </select>
  123:                     <input type="submit" name="doit" value="Go" />
  124:                     <input type="hidden" name="selectfile" value="'.$filename.'" />
  125:                     <input type="hidden" name="currentpath" value="'.$current_path.'" />
  126:                     </form>
  127:                     </td>');
  128:                 $r->print('<td><img src="'.$iconpath.'unknown.gif"></td>');
  129:                 $r->print('<td><a href="'.$href_location.$filename.'">'.
  130: 			    $filename.'</a></td>'); 
  131:                 $r->print('<td>'.$size.'</td>');
  132:                 $r->print('<td>'.&Apache::lonlocal::locallocaltime($mtime).'</td>');
  133:                 $r->print('</tr>'); 
  134:             }
  135:         }
  136:     }
  137: #   <tr bgcolor="#FFAA99"> pink bg 
  138: #   <tr bgcolor="#CCCCFF"> blue bg            
  139: #   $r->print(&display_directory($current_path, $currentFile, @dir_list));
  140: #    $r->print('</td>><td>');
  141: #   $r->print(&display_actions($current_path, $currentFile, $isEmpty));
  142:     $r->print('</table></form>');
  143: }
  144: sub display_file_select {
  145:     my ($r,$current_path,$is_empty,$dir_list)=@_;
  146:     my $iconpath= $r->dir_config('lonIconsURL') . "/";
  147:     my $display_out;
  148:     if ($is_empty && ($current_path ne '/')) {
  149:         $display_out = '<form method="post" action="/adm/portfolio">'.
  150:         '<input type="hidden" name="action" value="deletedir" />'.
  151:         '<input type="submit" name="deletedir" value="'.&mt("Delete Directory").'" />'.
  152:         '<input type="hidden" name="selectfile" value="" />'.
  153:         '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.
  154: 
  155:         '</form>';
  156:         
  157:         $r->print($display_out);
  158: 	return;
  159:     }
  160:     $r->print('<table border="0" cellspacing="2" cellpadding="2">'.
  161:             '<tr><th>Select</th><th>&nbsp;</th><th>Name</th><th>Size</th><th>Last Modified</th></tr>');
  162:     my $href_location="/uploaded/$ENV{'user.domain'}/$ENV{'user.name'}/portfolio$current_path";
  163:     $r->print('<form method="post" name="checkselect" action="/adm/portfolio">');
  164:     foreach my $line (sort 
  165: 		      { 
  166: 			  my ($afile)=split('&',$a,2);
  167: 			  my ($bfile)=split('&',$b,2);
  168: 			  return (lc($afile) cmp lc($bfile));
  169: 		      } (@$dir_list)) {
  170:     	#$strip holds directory/file name
  171:     	#$dom 
  172:     	my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); 
  173:     	if (($filename ne '.') && ($filename ne '..')) {
  174:             if ($dirptr&$testdir) {
  175:                 $r->print('<tr bgcolor="#FFAA99"><td><img src="'.$iconpath.'folder_closed.gif"></td>');
  176:                 $r->print('<td>Go to ...</td>');
  177:                 $r->print('<td>'.&make_anchor($filename.'/',$current_path.$filename.'/').'</td>'); 
  178:                 $r->print('</tr>'); 
  179:             } else {
  180:                 $r->print('<tr bgcolor="#CCCCFF">');
  181:                 $r->print('<td>
  182:                         <input type="checkbox" name="selectedfile" value="'.$filename.'" >
  183:                     </td>');
  184:                 $r->print('<td><img src="'.$iconpath.'unknown.gif"></td>');
  185:                 $r->print('<td><a href="'.$href_location.$filename.'">'.
  186: 			    $filename.'</a></td>'); 
  187:                 $r->print('<td>'.$size.'</td>');
  188:                 $r->print('<td>'.&Apache::lonlocal::locallocaltime($mtime).'</td>');
  189:                 $r->print('</tr>'); 
  190:             }
  191:         }
  192:     }
  193:     $r->print('</table>
  194:             <input type="button" name="doit" onClick= "finishSelect();" value="Select checked files, and close window" />
  195:             <input type="hidden" name="currentpath" value="'.$current_path.'" />
  196:     </form>');
  197: }
  198: 
  199: sub open_form {
  200:     my ($r)=@_;
  201:     $r->print('<form method="post" action="/adm/portfolio">');
  202:     $r->print('<input type="hidden" name="action" value="'.
  203: 	      $ENV{'form.action'}.'" />');
  204:     $r->print('<input type="hidden" name="confirmed" value="1" />');
  205:     $r->print('<input type="hidden" name="selectfile" value="'.
  206: 	      $ENV{'form.selectfile'}.'" />');
  207:     $r->print('<input type="hidden" name="currentpath" value="'.
  208: 	      $ENV{'form.currentpath'}.'" />');
  209: }
  210: 
  211: sub close_form {
  212:     my ($r)=@_;
  213:     $r->print('<p><input type="submit" value="'.&mt('Continue').
  214: 	      '" /></p></form>');
  215:     $r->print('<form action="/adm/portfolio" method="POST">
  216:                <p>
  217:               <input type="hidden" name="currentpath" value="'.
  218: 	      $ENV{'form.currentpath'}.'" />
  219:                  <input type="submit" value="'.&mt('Cancel').'" />
  220:                </p></form>');
  221: 
  222: }
  223: 
  224: sub display_file {
  225:     my ($path,$filename)=@_;
  226:     if (!defined($path)) { $path=$ENV{'form.currentpath'}; }
  227:     if (!defined($filename)) { $filename=$ENV{'form.selectfile'}; }
  228:     return '<tt>'.$path.$filename.'</tt>';
  229: }
  230: 
  231: sub done {
  232:     return ('<h3><a href="/adm/portfolio?currentpath='.
  233: 	    $ENV{'form.currentpath'}.
  234: 	    '&fieldname='.$ENV{'form.fieldname'}.
  235: 	    '">'.&mt('Done').'</a></h3>');
  236: }
  237: 
  238: sub delete {
  239:     my ($r)=@_;
  240:     &open_form($r);
  241:     $r->print('<p>'.&mt('Delete').' '.&display_file().'?</p>');
  242:     &close_form($r);
  243: } 
  244: 
  245: sub delete_confirmed {
  246:     my ($r)=@_;
  247:     my $result=&Apache::lonnet::removeuserfile($ENV{'user.name'},
  248: 					       $ENV{'user.domain'},'portfolio'.
  249: 					       $ENV{'form.currentpath'}.
  250: 					       $ENV{'form.selectfile'});
  251:     if ($result ne 'ok') {
  252: 	$r->print('<font color="red"> An error occured ('.$result.
  253: 		  ') while trying to delete '.&display_file().'</font><br />');
  254:     }
  255:     $r->print(&done());
  256: }
  257: 
  258: sub delete_dir {
  259:     my ($r)=@_;
  260:     &open_form($r);
  261:     $r->print('<p>'.&mt('Delete').' '.&display_file().'?</p>');
  262:     &close_form($r);
  263: } 
  264: 
  265: sub delete_dir_confirmed {
  266:     my ($r)=@_;
  267:     my $directory_name = $ENV{'form.currentpath'};
  268:     $directory_name =~ m/\/$/;
  269:     $directory_name = $`;
  270:     my $result=&Apache::lonnet::removeuserfile($ENV{'user.name'},
  271: 					       $ENV{'user.domain'},'portfolio'.
  272: 					       $directory_name);
  273: 					       
  274:     if ($result ne 'ok') {
  275: 	$r->print('<font color="red"> An error occured (dir) ('.$result.
  276: 		  ') while trying to delete '.$directory_name.'</font><br />');
  277:     } else {
  278:         # now remove from recent
  279: #        $r->print('<br /> removing '.$directory_name.'<br /');
  280:         &Apache::lonhtmlcommon::remove_recent('portfolio',[$directory_name.'/']);
  281:         my @dirs = split m!/!, $directory_name;
  282:         
  283: #        $directory_name =~ m/^(\/*\/)(\/*.)$/;
  284:         $directory_name='/';
  285:         for (my $i=1; $i < (@dirs - 1); $i ++){
  286:             $directory_name .= $dirs[$i].'/';
  287:         }
  288:         $ENV{'form.currentpath'} = $directory_name;
  289:     }
  290:     $r->print(&done());
  291: }
  292: 
  293: sub rename {
  294:     my ($r)=@_;
  295:     &open_form($r);
  296:     $r->print('<p>'.&mt('Rename').' '.&display_file().' to 
  297:                <input name="filenewname" type="input" size="50" />?</p>');
  298:     &close_form($r);
  299: }
  300: 
  301: sub rename_confirmed {
  302:     my ($r)=@_;
  303:     my $filenewname=&Apache::lonnet::clean_filename($ENV{'form.filenewname'});
  304:     if ($filenewname eq '') {
  305: 	$r->print('<font color="red">'.
  306: 		  &mt("Error: no valid filename was provided to rename to.").
  307: 		  '</font><br />');
  308: 	$r->print(&done());
  309: 	return;
  310:     } 
  311:     my $result=
  312: 	&Apache::lonnet::renameuserfile($ENV{'user.name'},$ENV{'user.domain'},
  313:             'portfolio'.$ENV{'form.currentpath'}.$ENV{'form.selectfile'},
  314:             'portfolio'.$ENV{'form.currentpath'}.$ENV{'form.filenewname'});
  315:     if ($result ne 'ok') {
  316: 	$r->print('<font color="red"> An errror occured ('.$result.
  317: 		  ') while trying to rename '.&display_file().' to '.
  318: 		  &display_file(undef,$filenewname).'</font><br />');
  319:     }
  320:     $r->print(&done());
  321: }
  322: sub select_files {
  323:     my ($r)=@_;
  324:     my $java_script =(<<ENDSMP);
  325:         <script language='javascript'>
  326:         function finishSelect() {
  327:             fileList = "";
  328:             for (i=0;i<document.forms.checkselect.length;i++) { 
  329:                 if (document.forms.checkselect[i].checked){
  330:                     fileList = fileList + document.forms.checkselect[i].value + "," ;
  331:                 }
  332:             }
  333:             opener.document.forms.lonhomework.
  334: ENDSMP
  335:     $java_script .= $ENV{'form.fieldname'};
  336:     $java_script .= (<<ENDSMP);
  337:         .value=fileList;
  338:             self.close();
  339:         }
  340:         </script>
  341: ENDSMP
  342:     $r->print($java_script);
  343:     $r->print("<h1>Select portfolio files</h1>
  344:                 Check as many as you wish in response to the essay problem.<br />");
  345: }
  346: sub upload {
  347:     my ($r)=@_;
  348:     my $fname=$ENV{'form.uploaddoc.filename'};
  349:     my $filesize = (length($ENV{'form.uploaddoc'})) / 1000; #express in k (1024?)
  350:     my $disk_quota = 20000; # expressed in k
  351:     $fname=&Apache::lonnet::clean_filename($fname);
  352:     my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'},
  353: 						 $ENV{'user.name'}).
  354: 						'/userfiles/portfolio';
  355:     # Fixme --- Move the checking for existing file to LOND error return
  356:     my @dir_list=&Apache::lonnet::dirlist($ENV{'form.currentpath'},
  357: 					  $ENV{'user.domain'},
  358: 					  $ENV{'user.name'},$portfolio_root);
  359:     my $found_file = 0;
  360:     foreach my $line (@dir_list) {
  361:         my ($filename)=split(/\&/,$line,2);
  362:         if ($filename eq $fname){
  363:             $found_file = 1;
  364:         }
  365:     }
  366:     my $current_disk_usage = &Apache::lonnet::diskusage($ENV{'user.domain'}, $ENV{'user.name'},$portfolio_root);
  367:     if (($current_disk_usage + $filesize) > $disk_quota){
  368:         $r->print('<font color="red">Unable to upload <strong>'.$fname.' (size = '.$filesize.' kilobytes</strong>. Disk quota will be exceeded.'.
  369:                   '<br />Disk quota is '.$disk_quota.' kilobytes. Your current disk usage is '.$current_disk_usage.' kilobytes.');
  370:     } 
  371:     elsif ($found_file){   
  372:         $r->print('<font color="red">Unable to upload <strong>'.$fname.'</strong>, a file by that name was found in <strong>'.$ENV{'form.currentpath'}.'</strong></font>'.
  373:                   '<br />To upload, rename or delete existing '.$fname.' in '.$ENV{'form.currentpath'});
  374:     } else {
  375:         my $result=&Apache::lonnet::userfileupload('uploaddoc','',
  376: 	        	 'portfolio'.$ENV{'form.currentpath'});
  377:         if ($result !~ m|^/uploaded/|) {
  378:             $r->print('<font color="red"> An errror occured ('.$result.
  379: 	              ') while trying to upload '.&display_file().'</font><br />');
  380:         }
  381:     }
  382:     $r->print(&done());
  383: }
  384: 
  385: sub createdir {
  386:     my ($r)=@_;
  387:     my $newdir=&Apache::lonnet::clean_filename($ENV{'form.newdir'});
  388:     if ($newdir eq '') {
  389:     	$r->print('<font color="red">'.
  390: 	    	  &mt("Error: no directory name was provided.").
  391: 		      '</font><br />');
  392: 	    $r->print(&done());
  393: 	    return;
  394:     } 
  395:     my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'},
  396: 						 $ENV{'user.name'}).
  397: 						'/userfiles/portfolio';
  398:     my @dir_list=&Apache::lonnet::dirlist($ENV{'form.currentpath'},
  399: 					  $ENV{'user.domain'},
  400: 					  $ENV{'user.name'},$portfolio_root);
  401:     my $found_file = 0;
  402:     foreach my $line (@dir_list) {
  403:         my ($filename)=split(/\&/,$line,2);
  404:         if ($filename eq $newdir){
  405:             $found_file = 1;
  406:         }
  407:     }
  408:     if ($found_file){
  409:     	    $r->print('<font color="red"> Unable to create a directory named <strong>'.$newdir.
  410:     	            ' </strong>a file or directory by that name already exists.</font><br />');
  411:     } else {
  412:         my $result=&Apache::lonnet::mkdiruserfile($ENV{'user.name'},
  413: 	         $ENV{'user.domain'},'portfolio'.$ENV{'form.currentpath'}.$newdir);
  414:         if ($result ne 'ok') {
  415:     	    $r->print('<font color="red"> An errror occured ('.$result.
  416: 	    	      ') while trying to create a new directory '.&display_file().'</font><br />');
  417:         }
  418:     }
  419:     $r->print(&done());
  420: }
  421: 
  422: sub handler {
  423:     # this handles file management
  424:     my $r = shift;
  425:     my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'},
  426: 							 $ENV{'user.name'}).
  427: 							'/userfiles/portfolio';
  428:     &Apache::loncommon::no_cache($r);
  429:     &Apache::loncommon::content_type($r,'text/html');
  430:     $r->send_http_header;
  431:     # Give the LON-CAPA page header
  432:     $r->print('<html><head><title>'.
  433:               &mt('Portfolio Manager').
  434:               "</title></head>\n".
  435:               &Apache::loncommon::bodytag('Portfolio Manager'));
  436:     $r->rflush();
  437:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
  438:                                             ['selectfile','currentpath',
  439: 					     'currentfile','action','fieldname','mode']);
  440: 	if (($ENV{'form.storeupl'} eq 'Upload') & (!$ENV{'form.uploaddoc.filename'})){
  441:    	    $r->print('<font color="red"> No file was selected to upload.'.
  442:    	            'To upload a file, click <strong>Browse...</strong>'.
  443:    	            ', select a file, then click <strong>Upload</strong>,</font>');
  444: 	}
  445:     if ($ENV{'form.uploaddoc.filename'}) {
  446: 	&upload($r);
  447:     } elsif ($ENV{'form.action'} eq 'delete' && $ENV{'form.confirmed'}) {
  448: 	&delete_confirmed($r);
  449:     } elsif ($ENV{'form.action'} eq 'delete') {
  450: 	&delete($r);
  451:     } elsif ($ENV{'form.action'} eq 'deletedir' && $ENV{'form.confirmed'}) {
  452: 	&delete_dir_confirmed($r);
  453:     } elsif ($ENV{'form.action'} eq 'deletedir'){
  454: 	&delete_dir($r);
  455:     } elsif ($ENV{'form.action'} eq 'rename' && $ENV{'form.confirmed'}) {
  456: 	&rename_confirmed($r);
  457:     } elsif ($ENV{'form.action'} eq 'rename') {
  458: 	&rename($r);
  459:     } elsif ($ENV{'form.createdir'}) {
  460: 	&createdir($r);
  461:     } else {
  462: 	my $current_path='/';
  463: 	if ($ENV{'form.currentpath'}) {
  464: 	    $current_path = $ENV{'form.currentpath'};
  465: 	}
  466: 	my @dir_list=&Apache::lonnet::dirlist($current_path,
  467: 					    $ENV{'user.domain'},
  468: 					    $ENV{'user.name'},$portfolio_root);
  469: 	if ($dir_list[0] eq 'no_such_dir'){
  470: 	    # two main reasons for this:
  471:             #    1) never been here, so directory structure not created
  472: 	    #    2) back-button navigation after deleting a directory
  473: 	    if ($current_path eq '/'){
  474: 	        &Apache::lonnet::mkdiruserfile($ENV{'user.name'},
  475: 					       $ENV{'user.domain'},'portfolio');
  476: 	    } else {
  477:                 # some directory that snuck in get rid of the directory
  478:                 # from the recent pulldown, just in case
  479: 		&Apache::lonhtmlcommon::remove_recent('portfolio',
  480: 						      [$current_path]);
  481: 		$current_path = '/'; # force it back to the root        
  482: 	    }
  483: 	    # now grab the directory list again, for the first time
  484: 	    @dir_list=&Apache::lonnet::dirlist($current_path,
  485: 					    $ENV{'user.domain'},
  486: 					    $ENV{'user.name'},$portfolio_root);
  487:         }
  488: 	# need to know if directory is empty so it can be removed if desired
  489: 	my $is_empty=(@dir_list == 2);
  490: 	&display_common($r,$current_path,$is_empty,\@dir_list);
  491: 	if ($ENV{"form.mode"} eq 'selectfile'){
  492: 	    &select_files($r);
  493:             &display_file_select($r,$current_path,$is_empty,\@dir_list);
  494: 	} else {
  495: 	    &display_directory($r,$current_path,$is_empty,\@dir_list);
  496: 	}
  497: 	$r->print("</body>\n</html>\n");
  498: 	return OK;
  499:     }
  500: }
  501: 1;
  502: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>