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, $current_mode, $field_name) = @_;
37: my $anchor = '<a href="/adm/portfolio?selectfile='.$filename.'¤tpath='.$current_path.'&mode='.$current_mode.'&fieldname='.$field_name.'">'.$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="hidden" name="mode" value="'.$ENV{"form.mode"}.'" />'.
52: '<input type="submit" name="storeupl" value="Upload" />'.
53: '</form>';
54: $r->print($displayOut);
55: $r->print('</td></tr><tr><td bgcolor="#ccddaa" align="center">');
56: $displayOut = '<form method="post">';
57: $displayOut .= '<input name="newdir" type="input" />'.
58: '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.
59: '<input type="hidden" name="action" value="'.$ENV{"form.action"}.'" />'.
60: '<input type="hidden" name="fieldname" value="'.$ENV{"form.fieldname"}.'" />'.
61: '<input type="hidden" name="mode" value="'.$ENV{"form.mode"}.'" />'.
62: '<input type="submit" name="createdir" value="'.&mt("Create Directory").'" />'.
63: '</form>';
64: $r->print($displayOut);
65: $r->print('</td></tr></table>');
66: my @tree = split (/\//,$current_path);
67: $r->print('<font size="+2">'.&make_anchor('portfolio','/',$ENV{"form.mode"},$ENV{"form.fieldname"}).'/');
68: if (@tree > 1){
69: my $newCurrentPath = '';
70: for (my $i = 1; $i< @tree; $i++){
71: $newCurrentPath .= $tree[$i].'/';
72: $r->print(&make_anchor($tree[$i],'/'.$newCurrentPath, $ENV{"form.mode"},$ENV{"form.fieldname"}).'/');
73: }
74: }
75: $r->print('</font>');
76: &Apache::lonhtmlcommon::store_recent('portfolio',$current_path,$current_path);
77: $r->print('<br /><form method=post action="/adm/portfolio?mode='.$ENV{"form.mode"}.'&fieldname='.$ENV{"form.fieldname"}.'">'.
78: &Apache::lonhtmlcommon::select_recent('portfolio','currentpath',
79: 'this.form.submit();'));
80: $r->print("</form>");
81: }
82: sub display_directory {
83: my ($r,$current_path,$is_empty,$dir_list)=@_;
84: my $iconpath= $r->dir_config('lonIconsURL') . "/";
85: my $display_out;
86: my %locked_files=&Apache::lonnet::dump('file_permissions',
87: $ENV{'user.domain'},$ENV{'user.name'});
88: my $locked_file;
89: foreach my $key (keys %locked_files) {
90: $locked_file .= $locked_files{$key}.':';
91: }
92: if ($is_empty && ($current_path ne '/')) {
93: $display_out = '<form method="post" action="/adm/portfolio">'.
94: '<input type="hidden" name="action" value="deletedir" />'.
95: '<input type="submit" name="deletedir" value="'.&mt("Delete Directory").'" />'.
96: '<input type="hidden" name="selectfile" value="" />'.
97: '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.
98: '</form>';
99:
100: $r->print($display_out);
101: return;
102: }
103: $r->print('<table border="0" cellspacing="2" cellpadding="2">'.
104: '<tr><th>Actions</th><th> </th><th>Name</th><th>Size</th><th>Last Modified</th></tr>');
105: my $href_location="/uploaded/$ENV{'user.domain'}/$ENV{'user.name'}/portfolio$current_path";
106: foreach my $line (sort
107: {
108: my ($afile)=split('&',$a,2);
109: my ($bfile)=split('&',$b,2);
110: return (lc($afile) cmp lc($bfile));
111: } (@$dir_list)) {
112: #$strip holds directory/file name
113: #$dom
114: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16);
115: if ($Apache::lonhomework::results{"resource.$ENV{'user.domain'}.$ENV{'user.name'}.$filename"}eq'true'){
116: &Apache::lonnet::logthis("found submitted file");
117: &Apache::lonnet::logthis("resource.$ENV{'user.domain'}.$ENV{'user.name'}.$filename");
118: } else {
119: &Apache::lonnet::logthis("$filename not found submitted file");
120: &Apache::lonnet::logthis("resource.$ENV{'user.domain'}.$ENV{'user.name'}.$filename");
121: }
122: if (($filename ne '.') && ($filename ne '..')) {
123: if ($dirptr&$testdir) {
124: $r->print('<tr bgcolor="#FFAA99"><td><img src="'.$iconpath.'folder_closed.gif"></td>');
125: $r->print('<td>Go to ...</td>');
126: $r->print('<td>'.&make_anchor($filename.'/',$current_path.$filename.'/',$ENV{'form.mode'},$ENV{"form.fieldname"}).'</td>');
127: $r->print('</tr>');
128: } else {
129: $r->print('<tr bgcolor="#CCCCFF">');
130: $r->print('<td>
131: <form method="post" action="/adm/portfolio">
132: <select name="action">
133: <option value=""></option>
134: <option value="delete">'.&mt("Delete").'</option>
135: <option value="rename">'.&mt("Rename").'</option>
136: </select>
137: <input type="submit" name="doit" value="Go" />
138: <input type="hidden" name="selectfile" value="'.$filename.'" />
139: <input type="hidden" name="currentpath" value="'.$current_path.'" />
140: </form>
141: </td>');
142: $r->print('<td><img src="'.$iconpath.'unknown.gif"></td>');
143: $r->print('<td><a href="'.$href_location.$filename.'">'.
144: $filename.'</a></td>');
145: $r->print('<td>'.$size.'</td>');
146: $r->print('<td>'.&Apache::lonlocal::locallocaltime($mtime).'</td>');
147: $r->print('</tr>');
148: }
149: }
150: }
151: # <tr bgcolor="#FFAA99"> pink bg
152: # <tr bgcolor="#CCCCFF"> blue bg
153: # $r->print(&display_directory($current_path, $currentFile, @dir_list));
154: # $r->print('</td>><td>');
155: # $r->print(&display_actions($current_path, $currentFile, $isEmpty));
156: $r->print('</table></form>');
157: }
158: sub display_file_select {
159: my ($r,$current_path,$is_empty,$dir_list)=@_;
160: my $iconpath= $r->dir_config('lonIconsURL') . "/";
161: my $display_out;
162: my %checked_files = &Apache::lonnet::files_in_path($ENV{'user.name'}, $ENV{'form.currentpath'});
163: if ($is_empty && ($current_path ne '/')) {
164: $display_out = '<form method="post" action="/adm/portfolio">'.
165: '<input type="hidden" name="action" value="deletedir" />'.
166: '<input type="submit" name="deletedir" value="'.&mt("Delete Directory").'" />'.
167: '<input type="hidden" name="selectfile" value="" />'.
168: '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.
169:
170: '</form>';
171:
172: $r->print($display_out);
173: return;
174: }
175: $r->print('<table border="0" cellspacing="2" cellpadding="2">'.
176: '<tr><th>Select</th><th> </th><th>Name</th><th>Size</th><th>Last Modified</th></tr>');
177: my $href_location="/uploaded/$ENV{'user.domain'}/$ENV{'user.name'}/portfolio$current_path";
178: $r->print('<form method="post" name="checkselect" action="/adm/portfolio">');
179: foreach my $line (sort
180: {
181: my ($afile)=split('&',$a,2);
182: my ($bfile)=split('&',$b,2);
183: return (lc($afile) cmp lc($bfile));
184: } (@$dir_list)) {
185: #$strip holds directory/file name
186: #$dom
187: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16);
188: if (($filename ne '.') && ($filename ne '..')) {
189: if ($dirptr&$testdir) {
190: $r->print('<tr bgcolor="#FFAA99"><td><img src="'.$iconpath.'folder_closed.gif"></td>');
191: $r->print('<td>Go to ...</td>');
192: $r->print('<td>'.&make_anchor($filename.'/',$current_path.$filename.'/',$ENV{'form.mode'},$ENV{"form.fieldname"}).'</td>');
193: $r->print('</tr>');
194: } else {
195: $r->print('<tr bgcolor="#CCCCFF">');
196: $r->print('<td>
197: <input type="checkbox" name="selectedfile" value="'.$filename.'" >
198: </td>');
199: $r->print('<td><img src="'.$iconpath.'unknown.gif"></td>');
200: $r->print('<td><a href="'.$href_location.$filename.'">'.
201: $filename.'</a></td>');
202: $r->print('<td>'.$size.'</td>');
203: $r->print('<td>'.&Apache::lonlocal::locallocaltime($mtime).'</td>');
204: $r->print('</tr>');
205: }
206: }
207: }
208: $r->print('</table>
209: <input type="hidden" name="continue" value="true">
210: <input type="hidden" name="fieldname" value="'.$ENV{'form.fieldname'}.'">
211: <input type="hidden" name="mode" value="selectfile">
212: <input type="submit" name="submit" value="Select checked files, and continue selecting." /><br />
213: <input type="button" name="doit" onClick= "finishSelect();" value="Select checked files, and close window" />
214: <input type="hidden" name="currentpath" value="'.$current_path.'" />
215: </form>');
216: }
217:
218: sub open_form {
219: my ($r)=@_;
220: $r->print('<form method="post" action="/adm/portfolio">');
221: $r->print('<input type="hidden" name="action" value="'.
222: $ENV{'form.action'}.'" />');
223: $r->print('<input type="hidden" name="confirmed" value="1" />');
224: $r->print('<input type="hidden" name="selectfile" value="'.
225: $ENV{'form.selectfile'}.'" />');
226: $r->print('<input type="hidden" name="currentpath" value="'.
227: $ENV{'form.currentpath'}.'" />');
228: }
229:
230: sub close_form {
231: my ($r)=@_;
232: $r->print('<p><input type="submit" value="'.&mt('Continue').
233: '" /></p></form>');
234: $r->print('<form action="/adm/portfolio" method="POST">
235: <p>
236: <input type="hidden" name="currentpath" value="'.
237: $ENV{'form.currentpath'}.'" />
238: <input type="submit" value="'.&mt('Cancel').'" />
239: </p></form>');
240:
241: }
242:
243: sub display_file {
244: my ($path,$filename)=@_;
245: if (!defined($path)) { $path=$ENV{'form.currentpath'}; }
246: if (!defined($filename)) { $filename=$ENV{'form.selectfile'}; }
247: return '<tt>'.$path.$filename.'</tt>';
248: }
249:
250: sub done {
251: return ('<h3><a href="/adm/portfolio?currentpath='.
252: $ENV{'form.currentpath'}.
253: '&fieldname='.$ENV{'form.fieldname'}.
254: '&mode='.$ENV{'form.mode'}.
255: '">'.&mt('Done').'</a></h3>');
256: }
257:
258: sub delete {
259: my ($r)=@_;
260: my @check;
261: my $file_name = $ENV{'form.currentpath'}.$ENV{'form.selectfile'};
262: if (&Apache::lonnet::is_locked($file_name,$ENV{'user.domain'},$ENV{'user.name'} ) eq 'true') {
263: $r->print ("The file is locked and cannot be deleted.<br />");
264: $r->print(&done());
265: } else {
266: &open_form($r);
267: $r->print('<p>'.&mt('Delete').' '.&display_file().'?</p>');
268: &close_form($r);
269: }
270: }
271:
272: sub delete_confirmed {
273: my ($r)=@_;
274: my $result=&Apache::lonnet::removeuserfile($ENV{'user.name'},
275: $ENV{'user.domain'},'portfolio'.
276: $ENV{'form.currentpath'}.
277: $ENV{'form.selectfile'});
278: if ($result ne 'ok') {
279: $r->print('<font color="red"> An error occured ('.$result.
280: ') while trying to delete '.&display_file().'</font><br />');
281: }
282: $r->print(&done());
283: }
284:
285: sub delete_dir {
286: my ($r)=@_;
287: &open_form($r);
288: $r->print('<p>'.&mt('Delete').' '.&display_file().'?</p>');
289: &close_form($r);
290: }
291:
292: sub delete_dir_confirmed {
293: my ($r)=@_;
294: my $directory_name = $ENV{'form.currentpath'};
295: $directory_name =~ m/\/$/;
296: $directory_name = $`;
297: my $result=&Apache::lonnet::removeuserfile($ENV{'user.name'},
298: $ENV{'user.domain'},'portfolio'.
299: $directory_name);
300:
301: if ($result ne 'ok') {
302: $r->print('<font color="red"> An error occured (dir) ('.$result.
303: ') while trying to delete '.$directory_name.'</font><br />');
304: } else {
305: # now remove from recent
306: # $r->print('<br /> removing '.$directory_name.'<br /');
307: &Apache::lonhtmlcommon::remove_recent('portfolio',[$directory_name.'/']);
308: my @dirs = split m!/!, $directory_name;
309:
310: # $directory_name =~ m/^(\/*\/)(\/*.)$/;
311: $directory_name='/';
312: for (my $i=1; $i < (@dirs - 1); $i ++){
313: $directory_name .= $dirs[$i].'/';
314: }
315: $ENV{'form.currentpath'} = $directory_name;
316: }
317: $r->print(&done());
318: }
319:
320: sub rename {
321: my ($r)=@_;
322: my $file_name = $ENV{'form.currentpath'}.$ENV{'form.selectfile'};
323: if (&Apache::lonnet::is_locked($file_name,$ENV{'user.domain'},$ENV{'user.name'}) eq 'true') {
324: $r->print ("The file is locked and cannot be renamed.<br />");
325: $r->print(&done());
326: } else {
327: &open_form($r);
328: $r->print('<p>'.&mt('Rename').' '.&display_file().' to
329: <input name="filenewname" type="input" size="50" />?</p>');
330: &close_form($r);
331: }
332: }
333:
334: sub rename_confirmed {
335: my ($r)=@_;
336: my $filenewname=&Apache::lonnet::clean_filename($ENV{'form.filenewname'});
337: if ($filenewname eq '') {
338: $r->print('<font color="red">'.
339: &mt("Error: no valid filename was provided to rename to.").
340: '</font><br />');
341: $r->print(&done());
342: return;
343: }
344: my $result=
345: &Apache::lonnet::renameuserfile($ENV{'user.name'},$ENV{'user.domain'},
346: 'portfolio'.$ENV{'form.currentpath'}.$ENV{'form.selectfile'},
347: 'portfolio'.$ENV{'form.currentpath'}.$filenewname);
348: if ($result ne 'ok') {
349: $r->print('<font color="red"> An errror occured ('.$result.
350: ') while trying to rename '.&display_file().' to '.
351: &display_file(undef,$filenewname).'</font><br />');
352: }
353: $r->print(&done());
354: }
355: sub select_files {
356: my ($r)=@_;
357: if ($ENV{'form.continue'} eq 'true') {
358: # here we update the selections for the currentpath
359: # eventually, have to handle removing those not checked, but . . .
360: my @items=&Apache::loncommon::get_env_multiple('form.selectedfile');
361: &Apache::lonnet::save_selected_files($ENV{'user.name'}, $ENV{'form.currentpath'}, @items);
362: }
363: my $java_script =(<<ENDSMP);
364: <script language='javascript'>
365: function finishSelect() {
366: fileList = "";
367: for (i=0;i<document.forms.checkselect.length;i++) {
368: if (document.forms.checkselect[i].checked){
369: fileList = fileList + document.forms.checkselect.currentpath.value + document.forms.checkselect[i].value + "," ;
370: }
371: }
372: opener.document.forms.lonhomework.
373: ENDSMP
374: $java_script .= $ENV{'form.fieldname'};
375: $java_script .= (<<ENDSMP);
376: .value=fileList;
377: self.close();
378: }
379: </script>
380: ENDSMP
381: $r->print($java_script);
382: $r->print("<h1>Select portfolio files</h1>
383: Check as many as you wish in response to the essay problem.<br />");
384: $r->print("<strong>Files selected:</strong><br />");
385: foreach (&Apache::lonnet::files_not_in_path($ENV{'user.name'}, $ENV{'form.currentpath'})) {
386: $r->print($_."<br />");
387: }
388: }
389: sub upload {
390: my ($r)=@_;
391: my $fname=$ENV{'form.uploaddoc.filename'};
392: my $filesize = (length($ENV{'form.uploaddoc'})) / 1000; #express in k (1024?)
393: my $disk_quota = 20000; # expressed in k
394: $fname=&Apache::lonnet::clean_filename($fname);
395: my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'},
396: $ENV{'user.name'}).
397: '/userfiles/portfolio';
398: # Fixme --- Move the checking for existing file to LOND error return
399: my @dir_list=&Apache::lonnet::dirlist($ENV{'form.currentpath'},
400: $ENV{'user.domain'},
401: $ENV{'user.name'},$portfolio_root);
402: my $found_file = 0;
403: foreach my $line (@dir_list) {
404: my ($filename)=split(/\&/,$line,2);
405: if ($filename eq $fname){
406: $found_file = 1;
407: }
408: }
409: my $current_disk_usage = &Apache::lonnet::diskusage($ENV{'user.domain'}, $ENV{'user.name'},$portfolio_root);
410: if (($current_disk_usage + $filesize) > $disk_quota){
411: $r->print('<font color="red">Unable to upload <strong>'.$fname.' (size = '.$filesize.' kilobytes</strong>. Disk quota will be exceeded.'.
412: '<br />Disk quota is '.$disk_quota.' kilobytes. Your current disk usage is '.$current_disk_usage.' kilobytes.');
413: }
414: elsif ($found_file){
415: $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>'.
416: '<br />To upload, rename or delete existing '.$fname.' in '.$ENV{'form.currentpath'});
417: } else {
418: my $result=&Apache::lonnet::userfileupload('uploaddoc','',
419: 'portfolio'.$ENV{'form.currentpath'});
420: if ($result !~ m|^/uploaded/|) {
421: $r->print('<font color="red"> An errror occured ('.$result.
422: ') while trying to upload '.&display_file().'</font><br />');
423: }
424: }
425: $r->print(&done());
426: }
427:
428: sub createdir {
429: my ($r)=@_;
430: my $newdir=&Apache::lonnet::clean_filename($ENV{'form.newdir'});
431: if ($newdir eq '') {
432: $r->print('<font color="red">'.
433: &mt("Error: no directory name was provided.").
434: '</font><br />');
435: $r->print(&done());
436: return;
437: }
438: my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'},
439: $ENV{'user.name'}).
440: '/userfiles/portfolio';
441: my @dir_list=&Apache::lonnet::dirlist($ENV{'form.currentpath'},
442: $ENV{'user.domain'},
443: $ENV{'user.name'},$portfolio_root);
444: my $found_file = 0;
445: foreach my $line (@dir_list) {
446: my ($filename)=split(/\&/,$line,2);
447: if ($filename eq $newdir){
448: $found_file = 1;
449: }
450: }
451: if ($found_file){
452: $r->print('<font color="red"> Unable to create a directory named <strong>'.$newdir.
453: ' </strong>a file or directory by that name already exists.</font><br />');
454: } else {
455: my $result=&Apache::lonnet::mkdiruserfile($ENV{'user.name'},
456: $ENV{'user.domain'},'portfolio'.$ENV{'form.currentpath'}.$newdir);
457: if ($result ne 'ok') {
458: $r->print('<font color="red"> An errror occured ('.$result.
459: ') while trying to create a new directory '.&display_file().'</font><br />');
460: }
461: }
462: $r->print(&done());
463: }
464:
465: sub handler {
466: # this handles file management
467: my $r = shift;
468: my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'},
469: $ENV{'user.name'}).
470: '/userfiles/portfolio';
471: &Apache::loncommon::no_cache($r);
472: &Apache::loncommon::content_type($r,'text/html');
473: $r->send_http_header;
474: # Give the LON-CAPA page header
475: $r->print('<html><head><title>'.
476: &mt('Portfolio Manager').
477: "</title></head>\n".
478: &Apache::loncommon::bodytag('Portfolio Manager'));
479: $r->rflush();
480: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
481: ['selectfile','currentpath',
482: 'currentfile','action','fieldname','mode']);
483: if (($ENV{'form.storeupl'} eq 'Upload') & (!$ENV{'form.uploaddoc.filename'})){
484: $r->print('<font color="red"> No file was selected to upload.'.
485: 'To upload a file, click <strong>Browse...</strong>'.
486: ', select a file, then click <strong>Upload</strong>,</font>');
487: }
488: if ($ENV{'form.uploaddoc.filename'}) {
489: &upload($r);
490: } elsif ($ENV{'form.action'} eq 'delete' && $ENV{'form.confirmed'}) {
491: &delete_confirmed($r);
492: } elsif ($ENV{'form.action'} eq 'delete') {
493: &delete($r);
494: } elsif ($ENV{'form.action'} eq 'deletedir' && $ENV{'form.confirmed'}) {
495: &delete_dir_confirmed($r);
496: } elsif ($ENV{'form.action'} eq 'deletedir'){
497: &delete_dir($r);
498: } elsif ($ENV{'form.action'} eq 'rename' && $ENV{'form.confirmed'}) {
499: &rename_confirmed($r);
500: } elsif ($ENV{'form.action'} eq 'rename') {
501: &rename($r);
502: } elsif ($ENV{'form.createdir'}) {
503: &createdir($r);
504: } else {
505: my $current_path='/';
506: if ($ENV{'form.currentpath'}) {
507: $current_path = $ENV{'form.currentpath'};
508: }
509: my @dir_list=&Apache::lonnet::dirlist($current_path,
510: $ENV{'user.domain'},
511: $ENV{'user.name'},$portfolio_root);
512: if ($dir_list[0] eq 'no_such_dir'){
513: # two main reasons for this:
514: # 1) never been here, so directory structure not created
515: # 2) back-button navigation after deleting a directory
516: if ($current_path eq '/'){
517: &Apache::lonnet::mkdiruserfile($ENV{'user.name'},
518: $ENV{'user.domain'},'portfolio');
519: } else {
520: # some directory that snuck in get rid of the directory
521: # from the recent pulldown, just in case
522: &Apache::lonhtmlcommon::remove_recent('portfolio',
523: [$current_path]);
524: $current_path = '/'; # force it back to the root
525: }
526: # now grab the directory list again, for the first time
527: @dir_list=&Apache::lonnet::dirlist($current_path,
528: $ENV{'user.domain'},
529: $ENV{'user.name'},$portfolio_root);
530: }
531: # need to know if directory is empty so it can be removed if desired
532: my $is_empty=(@dir_list == 2);
533: &display_common($r,$current_path,$is_empty,\@dir_list);
534: if ($ENV{"form.mode"} eq 'selectfile'){
535: &select_files($r);
536: &display_file_select($r,$current_path,$is_empty,\@dir_list);
537: } else {
538: &display_directory($r,$current_path,$is_empty,\@dir_list);
539: }
540: $r->print("</body>\n</html>\n");
541: return OK;
542: }
543: }
544: 1;
545: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>