Annotation of loncom/interface/londocs.pm, revision 1.106

1.1       www         1: # The LearningOnline Network
1.2       www         2: # Documents
1.1       www         3: #
1.106   ! www         4: # $Id: londocs.pm,v 1.105 2004/02/12 19:20:40 albertel Exp $
1.1       www         5: #
1.3       www         6: # Copyright Michigan State University Board of Trustees
1.1       www         7: #
1.3       www         8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
1.1       www         9: #
1.3       www        10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
1.1       www        14: #
1.3       www        15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
                     28: 
1.2       www        29: package Apache::londocs;
1.1       www        30: 
                     31: use strict;
1.28      www        32: use Apache::Constants qw(:common :http);
1.4       www        33: use Apache::lonnet;
                     34: use Apache::loncommon;
1.7       www        35: use Apache::lonratedt;
                     36: use Apache::lonratsrv;
1.15      www        37: use Apache::lonxml;
1.74      www        38: use Apache::loncreatecourse;
1.38      www        39: use HTML::Entities;
1.27      www        40: use GDBM_File;
1.81      www        41: use Apache::lonlocal;
1.7       www        42: 
1.8       www        43: my $iconpath;
1.7       www        44: 
1.27      www        45: my %hash;
                     46: 
                     47: my $hashtied;
1.29      www        48: my %alreadyseen=();
1.27      www        49: 
1.40      www        50: my $hadchanges;
                     51: 
1.47      www        52: # Available help topics
                     53: 
                     54: my %help=();
                     55: 
1.7       www        56: # Mapread read maps into lonratedt::global arrays 
1.10      www        57: # @order and @resources, determines status
1.7       www        58: # sets @order - pointer to resources in right order
                     59: # sets @resources - array with the resources with correct idx
                     60: #
                     61: 
                     62: sub mapread {
                     63:     my ($coursenum,$coursedom,$map)=@_;
                     64:     return
                     65:       &Apache::lonratedt::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
                     66:                                 $map);
                     67: }
                     68: 
                     69: sub storemap {
                     70:     my ($coursenum,$coursedom,$map)=@_;
1.104     albertel   71:     my ($outtext,$errtext)=
1.7       www        72:       &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.15      www        73:                                 $map,1);
1.104     albertel   74:     if ($errtext) { return ($errtext,2); }
                     75:     
                     76:     $hadchanges=1;
                     77:     return ($errtext,0);
1.7       www        78: }
                     79: 
1.74      www        80: # ----------------------------------------- Return hash with valid author names
                     81: 
                     82: sub authorhosts {
                     83:     my %outhash=();
                     84:     my $home=0;
                     85:     my $other=0;
                     86:     foreach (keys %ENV) {
                     87: 	if ($_=~/^user\.role\.(au|ca)\.(.+)$/) {
                     88: 	    my $role=$1;
                     89: 	    my $realm=$2;
                     90: 	    my ($start,$end)=split(/\./,$ENV{$_});
                     91: 	    if (($start) && ($start>time)) { next; }
                     92: 	    if (($end) && (time>$end)) { next; }
                     93: 	    my $ca; my $cd;
                     94: 	    if ($1 eq 'au') {
                     95: 		$ca=$ENV{'user.name'};
                     96: 		$cd=$ENV{'user.domain'};
                     97: 	    } else {
                     98: 		($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/);
                     99: 	    }
                    100: 	    if (&Apache::lonnet::homeserver($ca,$cd) eq 
                    101: 		$Apache::lonnet::perlvar{'lonHostID'}) {
                    102: 		$home++;
                    103: 		$outhash{'home_'.$ca.'@'.$cd}=1;
                    104: 	    } else {
                    105: 		$outhash{'otherhome_'.$ca.'@'.$cd}=
                    106: 		    &Apache::lonnet::homeserver($ca,$cd);
                    107: 		$other++;
                    108: 	    }
                    109: 	}
                    110:     }
                    111:     return ($home,$other,%outhash);
                    112: }
                    113: # ------------------------------------------------------ Generate "dump" button
                    114: 
                    115: sub dumpbutton {
                    116:     my ($home,$other,%outhash)=&authorhosts();
                    117:     if ($home+$other==0) { return ''; }
                    118:     my $output='</td><td bgcolor="#DDDDCC">';
                    119:     if ($home) {
                    120: 	return '</td><td bgcolor="#DDDDCC">'.
1.81      www       121: 	    '<input type="submit" name="dumpcourse" value="'.
                    122: 	    &mt('Dump Course DOCS to Construction Space').'" />';
1.74      www       123:     } else {
                    124: 	return'</td><td bgcolor="#DDDDCC">'.
1.81      www       125:      &mt('Dump Course DOCS to Construction Space: available on other servers');
1.74      www       126:     }
                    127: }
                    128: 
                    129: # -------------------------------------------------------- Actually dump course
                    130: 
                    131: sub dumpcourse {
1.75      www       132:     my $r=shift;
                    133:     $r->print('<html><head><title>Dump DOCS</title></head>'.
1.76      www       134:         &Apache::loncommon::bodytag('Dump Course DOCS to Construction Space').
                    135: 	      '<form name="dumpdoc" method="post">');
1.74      www       136:     my ($home,$other,%outhash)=&authorhosts();
1.75      www       137:     unless ($home) { return ''; }
1.76      www       138:     my $origcrsid=$ENV{'request.course.id'};
                    139:     my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
                    140:     if (($ENV{'form.authorspace'}) && ($ENV{'form.authorfolder'}=~/\w/)) {
                    141: # Do the dumping
1.75      www       142: 	unless ($outhash{'home_'.$ENV{'form.authorspace'}}) { return ''; }
                    143: 	my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'});
1.87      www       144: 	$r->print('<h3>'.&mt('Copying Files').'</h3>');
1.76      www       145: 	my $title=$ENV{'form.authorfolder'};
1.79      www       146: 	$title=~s/[^\w\/]+/\_/g;
                    147: 	my %replacehash=();
                    148: 	foreach (keys %ENV) {
                    149: 	    if ($_=~/^form\.namefor\_(.+)/) {
                    150: 		$replacehash{$1}=$ENV{$_};
                    151: 	    }
                    152: 	}
                    153: 	my $crs='/uploaded/'.$ENV{'request.course.id'}.'/';
                    154: 	$crs=~s/\_/\//g;
                    155: 	foreach (keys %replacehash) {
                    156: 	    my $newfilename=$title.'/'.$replacehash{$_};
                    157: 	    $newfilename=~s/[^\w\/\.]+/\_/g;
                    158: 	    my @dirs=split(/\//,$newfilename);
                    159: 	    my $path='/home/'.$ca.'/public_html';
                    160: 	    my $makepath=$path;
                    161: 	    my $fail=0;
                    162: 	    for (my $i=0;$i<$#dirs;$i++) {
                    163: 		$makepath.='/'.$dirs[$i];
                    164: 		unless (-e $makepath) { 
                    165: 		    unless(mkdir($makepath,0777)) { $fail=1; } 
                    166: 		}
                    167: 	    }
                    168: 	    $r->print('<br /><tt>'.$_.'</tt> => <tt>'.$newfilename.'</tt>: ');
                    169: 	    if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
                    170: 		if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
                    171: 		    print $fh &Apache::loncreatecourse::rewritefile(
                    172:          &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_),
                    173: 				     (%replacehash,$crs => '')
                    174: 								    );
                    175: 		} else {
                    176: 		    print $fh
                    177:          &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_);
                    178: 		       }
                    179: 		$fh->close();
                    180: 	    } else {
                    181: 		$fail=1;
                    182: 	    }
                    183: 	    if ($fail) {
                    184: 		$r->print('<font color="red">fail</font>');
                    185: 	    } else {
                    186: 		$r->print('<font color="green">ok</font>');
                    187: 	    }
                    188: 	}
1.76      www       189:     } else {
                    190: # Input form
                    191: 	unless ($home==1) {
                    192: 	    $r->print(
1.81      www       193: 		      '<h3>'.&mt('Select the Construction Space').'</h3><select name="authorspace">');
1.76      www       194: 	}
                    195: 	foreach (sort keys %outhash) {
                    196: 	    if ($_=~/^home_(.+)$/) {
                    197: 		if ($home==1) {
                    198: 		    $r->print(
                    199: 		  '<input type="hidden" name="authorspace" value="'.$1.'" />');
                    200: 		} else {
                    201: 		    $r->print('<option value="'.$1.'">'.$_.'</option>');
                    202: 		}
                    203: 	    }
                    204: 	}
                    205: 	unless ($home==1) {
                    206: 	    $r->print('</select>');
                    207: 	}
                    208: 	my $title=$origcrsdata{'description'};
                    209: 	$title=~s/\s+/\_/gs;
                    210: 	$title=~s/\W//gs;
1.81      www       211: 	$r->print('<h3>'.&mt('Folder in Construction Space').'</h3><input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
1.76      www       212: 	&tiehash();
1.81      www       213: 	$r->print('<h3>'.&mt('Filenames in Construction Space').'</h3><table border="2"><tr><th>'.&mt('Internal Filename').'</th><th>'.&mt('Title').'</th><th>'.&mt('Save as ...').'</th></tr>');
1.76      www       214: 	foreach (&Apache::loncreatecourse::crsdirlist($origcrsid,'userfiles')) {
1.78      www       215: 	    $r->print('<tr><td>'.$_.'</td>');
                    216: 	    my ($ext)=($_=~/\.(\w+)$/);
                    217: 	    my $title=$hash{'title_'.$hash{
                    218: 		'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}};
                    219: 	    $r->print('<td>'.($title?$title:'&nbsp;').'</td>');
                    220: 	    unless ($title) {
                    221: 		$title=$_;
                    222: 	    }
                    223: 	    $title=~s/\.(\w+)$//;
                    224: 	    $title=~s/\W+/\_/gs;
                    225: 	    $title.='.'.$ext;
1.79      www       226: 	    $r->print("\n<td><input type='text' size='60' name='namefor_".$_."' value='".$title."' /></td></tr>\n");
1.76      www       227: 	}
1.78      www       228: 	$r->print("</table>\n");
1.76      www       229: 	&untiehash();
                    230: 	$r->print(
1.81      www       231:   '<p><input type="submit" name="dumpcourse" value="'.&mt('Dump Course DOCS').'" /></p></form>');
1.75      www       232:     }
1.74      www       233: }
1.76      www       234: 
1.74      www       235: 
1.73      bowersj2  236: # Imports the given (name, url) resources into the course
                    237: # coursenum, coursedom, and folder must precede the list
                    238: sub group_import {
                    239:     my $coursenum = shift;
                    240:     my $coursedom = shift;
                    241:     my $folder = shift;
                    242:     while (@_) {
                    243: 	my $name = shift;
                    244: 	my $url = shift;
                    245: 	if ($url) {
                    246: 	    my $idx = $#Apache::lonratedt::resources + 1;
                    247: 	    $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=$idx;
                    248: 	    my $ext = 'false';
                    249: 	    if ($url=~/^http:\/\//) { $ext = 'true'; }
                    250: 	    $url =~ s/:/\&colon;/g;
                    251: 	    $name =~ s/:/\&colon;/g;
                    252: 	    $Apache::lonratedt::resources[$idx] = 
                    253: 		join ':', ($name, $url, $ext, 'normal', 'res');
                    254: 	}
                    255:     }
1.104     albertel  256:     return &storemap($coursenum, $coursedom, $folder.'.sequence');
1.73      bowersj2  257: }
                    258: 
1.7       www       259: sub editor {
                    260:     my ($r,$coursenum,$coursedom,$folder,$allowed)=@_;
1.17      www       261:     if ($ENV{'form.foldername'}) {
                    262: 	$r->print('<h3>Folder: '.$ENV{'form.foldername'}.'</h3>');
                    263:     }
1.10      www       264:     my $errtext='';
                    265:     my $fatal=0;
                    266:     ($errtext,$fatal)=
1.7       www       267:           &mapread($coursenum,$coursedom,$folder.'.sequence');
1.17      www       268:     if ($#Apache::lonratedt::order<1) {
                    269:        	$Apache::lonratedt::order[0]=1;
                    270:         $Apache::lonratedt::resources[1]='';
                    271:     }
1.7       www       272:     if ($fatal) {
                    273: 	   $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    274:     } else {
                    275: # ------------------------------------------------------------ Process commands
1.16      www       276: # ---------------- if they are for this folder and user allowed to make changes
                    277: 	if (($allowed) && ($ENV{'form.folder'} eq $folder)) {
1.10      www       278: # upload a file, if present
                    279:            if (($ENV{'form.uploaddoc.filename'}) &&
                    280:                ($ENV{'form.cmd'}=~/^upload_(\w+)/)) {
                    281: 	    if ($folder=~/^$1/) {
                    282: # this is for a course, not a user, so set coursedoc flag
                    283: # probably the only place in the system where this should be "1"
                    284: 	      my $url=&Apache::lonnet::userfileupload('uploaddoc',1);
                    285:               my $ext='false';
                    286:               if ($url=~/^http\:\/\//) { $ext='true'; }
                    287:               $url=~s/\:/\&colon;/g;
                    288: 	      my $comment=$ENV{'form.comment'};
                    289:               $comment=~s/\</\&lt\;/g;
                    290:               $comment=~s/\>/\&gt\;/g;
                    291:               $comment=~s/\:/\&colon;/g;
1.17      www       292:               if ($folder=~/^supplemental/) {
                    293: 		  $comment=time.'___&&&___'.$ENV{'user.name'}.'___&&&___'.
                    294: 		      $ENV{'user.domain'}.'___&&&___'.$comment;
                    295:               }
1.10      www       296:               my $newidx=$#Apache::lonratedt::resources+1;
                    297:               $Apache::lonratedt::resources[$newidx]=
                    298:                   $comment.':'.$url.':'.$ext.':normal:res';
                    299:               $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=
                    300:                                                               $newidx;       
1.104     albertel  301: 
                    302: 	      ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.sequence');
                    303: 	      if ($fatal) {
                    304: 		  $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    305: 		  return;
                    306: 	      }
1.10      www       307: 	     }
                    308:             }
1.8       www       309: 	    if ($ENV{'form.cmd'}) {
1.10      www       310:                 my ($cmd,$idx)=split(/\_/,$ENV{'form.cmd'});
                    311:                 if ($cmd eq 'del') {
                    312: 		    for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) {
                    313:                         $Apache::lonratedt::order[$i]=
                    314:                           $Apache::lonratedt::order[$i+1];
                    315:                     }
                    316:                     $#Apache::lonratedt::order--;
                    317:                 } elsif ($cmd eq 'up') {
1.38      www       318: 		  if (($idx) && (defined($Apache::lonratedt::order[$idx-1]))) {
1.10      www       319:                     my $i=$Apache::lonratedt::order[$idx-1];
                    320:                     $Apache::lonratedt::order[$idx-1]=
                    321: 			$Apache::lonratedt::order[$idx];
                    322:                     $Apache::lonratedt::order[$idx]=$i;
1.38      www       323: 		   }
1.10      www       324:                 } elsif ($cmd eq 'down') {
1.38      www       325: 		   if (defined($Apache::lonratedt::order[$idx+1])) {
1.10      www       326:                     my $i=$Apache::lonratedt::order[$idx+1];
                    327:                     $Apache::lonratedt::order[$idx+1]=
                    328: 			$Apache::lonratedt::order[$idx];
                    329:                     $Apache::lonratedt::order[$idx]=$i;
1.38      www       330: 		   }
1.36      www       331:                 } elsif ($cmd eq 'rename') {
                    332:                     my ($rtitle,@rrest)=split(/\:/,
                    333:                        $Apache::lonratedt::resources[
                    334: 				       $Apache::lonratedt::order[$idx]]);
1.38      www       335:                     my $comment=
                    336:                      &HTML::Entities::decode($ENV{'form.title'});
1.36      www       337:                     $comment=~s/\</\&lt\;/g;
                    338:                     $comment=~s/\>/\&gt\;/g;
                    339:                     $comment=~s/\:/\&colon;/g;
                    340:                     $Apache::lonratedt::resources[
                    341: 				       $Apache::lonratedt::order[$idx]]=
                    342:                              $comment.':'.join(':',@rrest);
                    343:                     
1.10      www       344:                 }
                    345: # Store the changed version
1.104     albertel  346: 		($errtext,$fatal)=&storemap($coursenum,$coursedom,
                    347: 					    $folder.'.sequence');
                    348: 		if ($fatal) {
                    349: 		    $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    350: 		    return;
                    351: 		}
1.8       www       352:             }
1.11      www       353: # Group import/search
                    354: 	    if ($ENV{'form.importdetail'}) {
1.73      bowersj2  355: 		my @imports;
                    356: 		foreach (split(/\&/,$ENV{'form.importdetail'})) {
                    357: 		    if (defined($_)) {
                    358: 			my ($name,$url)=split(/\=/,$_);
                    359: 			$name=&Apache::lonnet::unescape($name);
                    360: 			$url=&Apache::lonnet::unescape($url);
                    361: 			push @imports, $name, $url;
                    362: 		    }
                    363: 		}
1.11      www       364: # Store the changed version
1.104     albertel  365: 		($errtext,$fatal)=group_import($coursenum, $coursedom, $folder,
                    366: 					       @imports);
                    367: 		if ($fatal) {
                    368: 		    $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    369: 		    return;
                    370: 		}
1.11      www       371:             }
1.53      www       372: # Loading a complete map
                    373: 	   if (($ENV{'form.importmap'}) && ($ENV{'form.loadmap'})) {
1.104     albertel  374: 	       foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$ENV{'form.importmap'}))) {
1.53      www       375:                    my $idx=$#Apache::lonratedt::resources;
                    376:                    $idx++;
                    377:                    $Apache::lonratedt::resources[$idx]=$_;
                    378:                    $Apache::lonratedt::order
1.104     albertel  379: 		       [$#Apache::lonratedt::order+1]=$idx;
                    380: 	       }
1.53      www       381: 
                    382: # Store the changed version
1.104     albertel  383: 	       ($errtext,$fatal)=&storemap($coursenum,$coursedom,
                    384: 					   $folder.'.sequence');
                    385: 	       if ($fatal) {
                    386: 		   $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    387: 		   return;
                    388: 	       }
1.53      www       389:            }
1.16      www       390:        }
                    391: # ---------------------------------------------------------------- End commands
1.7       www       392: # ---------------------------------------------------------------- Print screen
1.10      www       393:         my $idx=0;
                    394:         $r->print('<table>');
                    395:         foreach (@Apache::lonratedt::order) {
                    396:            my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]);
                    397:            unless ($name) {  $name=(split(/\//,$url))[-1]; }
1.106   ! www       398:            unless ($name) { next; }
1.50      www       399:            $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_));
1.10      www       400:            $idx++;
                    401:         }
                    402:         $r->print('</table>');
1.7       www       403:     }
                    404: }
1.1       www       405: 
1.8       www       406: # --------------------------------------------------------------- An entry line
                    407: 
                    408: sub entryline {
1.50      www       409:     my ($index,$title,$url,$folder,$allowed,$residx)=@_;
1.38      www       410:     $title=~s/\&colon\;/\:/g;
                    411:     $title=&HTML::Entities::encode(&HTML::Entities::decode(
                    412:      &Apache::lonnet::unescape($title)),'\"\<\>\&\'');
                    413:     my $renametitle=$title;
                    414:     my $foldertitle=$title;
                    415:     if ($title=~
                    416:  /^(\d+)\_\_\_\&amp\;\&amp\;\&amp\;\_\_\_(\w+)\_\_\_\&amp\;\&amp\;\&amp\;\_\_\_(\w+)\_\_\_\&amp\;\&amp\;\&amp\;\_\_\_(.*)$/
                    417: 	) { 
                    418:             $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
                    419:             $renametitle=$4;
1.85      www       420:             $title='<i>'.&Apache::lonlocal::locallocaltime($1).'</i> '.
1.87      www       421:                 &Apache::loncommon::plainname($2,$3).': <br />'.
1.38      www       422: 		$foldertitle;
                    423: 	}
                    424:     $renametitle=~s/\&quot\;/\\\"/g;
1.8       www       425:     my $line='<tr>';
                    426: # Edit commands
1.90      www       427:      if ($allowed) {
                    428: 	 my %lt=('up' => 'Move Up',
                    429: 		 'dw' => 'Move Down',
                    430: 		 'rm' => 'Remove',
                    431: 		 'rn' => 'Rename');
                    432:       $line.=(<<END);
1.54      www       433: <td><table border='0' cellspacing='2' cellpadding='0'>
                    434: <tr><td bgcolor="#DDDDDD">
                    435: <a href='/adm/coursedocs?folder=$folder&cmd=up_$index'>
1.90      www       436: <img src="${iconpath}move_up.gif" alt='$lt{'up'}' border='0' /></a></td></tr>
1.54      www       437: <tr><td bgcolor="#DDDDDD">
                    438: <a href='/adm/coursedocs?folder=$folder&cmd=down_$index'>
1.90      www       439: <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' border='0' /></a></td></tr>
1.54      www       440: </table></td><td bgcolor="#DDDDDD">
                    441: <a href='javascript:removeres("$folder","$index","$renametitle");'>
1.90      www       442: <font size="-2" color="#990000">$lt{'rm'}</font></a>
1.38      www       443: <a href='javascript:changename("$folder","$index","$renametitle");'>
1.90      www       444: <font size="-2" color="#009900">$lt{'rn'}</font></a></td>
1.8       www       445: END
                    446:     }
1.16      www       447: # Figure out what kind of a resource this is
                    448:     my ($extension)=($url=~/\.(\w+)$/);
                    449:     my $uploaded=($url=~/^\/*uploaded\//);
1.97      albertel  450:     my $icon=&Apache::loncommon::icon($url);
1.17      www       451:     my $isfolder=0;
1.16      www       452:     if ($uploaded) {
                    453:        if ($extension eq 'sequence') {
1.97      albertel  454: 	  $icon=$iconpath.'/folder_closed.gif';
1.16      www       455:           $url=~/\/(\w+)\.sequence/;
                    456:           $url='/adm/coursedocs?folder='.$1;
1.17      www       457:           $isfolder=1;
1.16      www       458:        } else {
                    459: 	  $url=&Apache::lonnet::tokenwrapper($url);
                    460:        } 
                    461:     }
1.18      www       462:     $url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//;
1.71      www       463:     if (($residx) && ($folder!~/supplemental/)) {
1.50      www       464:        $url.=(($url=~/\?/)?'&':'?').'symb='.
                    465:        &Apache::lonnet::escape(&Apache::lonnet::symbclean(
                    466:           &Apache::lonnet::declutter('uploaded/'.
                    467:            $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.'/'.
                    468:            $ENV{'course.'.$ENV{'request.course.id'}.'.num'}.'/'.$folder.
                    469:            '.sequence').
                    470:            '___'.$residx.'___'.
                    471: 	   &Apache::lonnet::declutter($url)));
                    472:     }
1.48      www       473:     if ($isfolder) { $url.='&foldername='.
                    474:        &Apache::lonnet::escape($foldertitle); }
1.23      www       475:     $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'" target="cat_'.$folder.
1.97      albertel  476: 	'"><img src="'.$icon.'" border="0"></a></td>'.
1.23      www       477:         "<td bgcolor='#FFFFBB'><a href='$url' target='cat_$folder'>$title</a></td></tr>";
1.8       www       478:     return $line;
                    479: }
                    480: 
1.27      www       481: # ---------------------------------------------------------------- tie the hash
                    482: 
                    483: sub tiehash {
                    484:     $hashtied=0;
                    485:     if ($ENV{'request.course.fn'}) {
                    486:         if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
                    487:             &GDBM_READER(),0640)) {
                    488:                 $hashtied=1;
                    489:         }
                    490:     }    
                    491: }
                    492: 
                    493: sub untiehash {
                    494:     if ($hashtied) { untie %hash; }
                    495:     $hashtied=0;
                    496: }
                    497: 
1.29      www       498: # --------------------------------------------------------------- check on this
                    499: 
                    500: sub checkonthis {
                    501:     my ($r,$url,$level,$title)=@_;
                    502:     $alreadyseen{$url}=1;
                    503:     $r->rflush();
1.41      www       504:     if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
1.29      www       505:        $r->print('<br />');
                    506:        for (my $i=0;$i<=$level*5;$i++) {
                    507:            $r->print('&nbsp;');
                    508:        }
                    509:        $r->print('<a href="'.$url.'" target="cat">'.
                    510: 		 ($title?$title:$url).'</a> ');
                    511:        if ($url=~/^\/res\//) {
                    512: 	  my $result=&Apache::lonnet::repcopy(
                    513:                               &Apache::lonnet::filelocation('',$url));
                    514:           if ($result==OK) {
1.87      www       515:              $r->print('<font color="green">'.&mt('ok').'</font>');
1.29      www       516:              $r->rflush();
1.34      www       517:              &Apache::lonnet::countacc($url);
                    518:              $url=~/\.(\w+)$/;
                    519:              if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
                    520: 		 $r->print('<br />');
                    521:                  $r->rflush();
                    522:                  for (my $i=0;$i<=$level*5;$i++) {
                    523:                      $r->print('&nbsp;');
                    524:                  }
1.84      www       525:                  $r->print('- '.&mt('Rendering').': ');
1.69      albertel  526:                  my $oldpath=$ENV{'request.filename'};
                    527:                  $ENV{'request.filename'}=&Apache::lonnet::filelocation('',$url);
1.34      www       528:                  &Apache::lonxml::xmlparse($r,'web',
                    529:                    &Apache::lonnet::getfile(
1.35      albertel  530:                     &Apache::lonnet::filelocation('',$url)));
1.94      www       531: 		 undef($Apache::lonhomework::parsing_a_problem);
1.69      albertel  532: 		 $ENV{'request.filename'}=$oldpath;
1.34      www       533:                  if (($Apache::lonxml::errorcount) ||
                    534:                      ($Apache::lonxml::warningcount)) {
                    535: 		     if ($Apache::lonxml::errorcount) {
1.98      www       536:                         $r->print('<img src="/adm/lonMisc/bomb.gif" /><font color="red"><b>'.
1.87      www       537: 			  $Apache::lonxml::errorcount.' '.
                    538: 				  &mt('error(s)').'</b></font> ');
1.34      www       539:                      }
                    540: 		     if ($Apache::lonxml::warningcount) {
                    541:                         $r->print('<font color="blue">'.
1.84      www       542: 			  $Apache::lonxml::warningcount.' '.
                    543: 				  &mt('warning(s)').'</font>');
1.34      www       544:                      }
                    545:                  } else {
1.87      www       546:                      $r->print('<font color="green">'.&mt('ok').'</font>');
1.34      www       547:                  }
                    548:                  $r->rflush();
                    549:              }
1.29      www       550: 	     my $dependencies=
                    551:                 &Apache::lonnet::metadata($url,'dependencies');
                    552:              foreach (split(/\,/,$dependencies)) {
                    553: 		 if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {
                    554:                     &checkonthis($r,$_,$level+1);
                    555:                  }
                    556:              }
                    557:           } elsif ($result==HTTP_SERVICE_UNAVAILABLE) {
1.84      www       558:              $r->print('<font color="red"><b>'.&mt('connection down').'</b></font>');
1.29      www       559:           } elsif ($result==HTTP_NOT_FOUND) {
1.100     www       560: 	      unless ($url=~/\$/) {
                    561: 		  $r->print('<font color="red"><b>'.&mt('not found').'</b></font>');
                    562: 	      } else {
                    563: 		  $r->print('<font color="yellow"><b>'.&mt('unable to verify variable URL').'</b></font>');
                    564: 	      }
1.29      www       565:           } else {
1.84      www       566:              $r->print('<font color="red"><b>'.&mt('access denied').'</b></font>');
1.29      www       567:           }
                    568:       }
                    569:    }
                    570: }
                    571: 
1.1       www       572: 
1.75      www       573: #
                    574: # -------------------------------------------------------------- Verify Content
                    575: # 
                    576: sub verifycontent {
                    577:    my $r=shift; 
1.26      www       578:    my $loaderror=&Apache::lonnet::overloaderror($r);
                    579:    if ($loaderror) { return $loaderror; }
                    580: 
                    581:    $r->print('<html><head><title>Verify Content</title></head>'.
                    582:               &Apache::loncommon::bodytag('Verify Course Documents'));
1.27      www       583:    $hashtied=0;
1.30      www       584:    undef %alreadyseen;
                    585:    %alreadyseen=();
1.27      www       586:    &tiehash();
                    587:    foreach (keys %hash) {
1.28      www       588:        if (($_=~/^src\_(.+)$/) && (!$alreadyseen{$hash{$_}})) {
1.29      www       589:            &checkonthis($r,$hash{$_},0,$hash{'title_'.$1});
1.27      www       590:        }
                    591:    }
                    592:    &untiehash();
1.81      www       593:    $r->print('<h1>'.&mt('Done').'.</h1>');
1.75      www       594: }
                    595: 
                    596: # -------------------------------------------------------------- Check Versions
                    597: 
                    598: sub checkversions {
                    599:     my $r=shift;
1.89      www       600:     $r->print('<html><head><title>Check Versions</title></head>'.
1.26      www       601:               &Apache::loncommon::bodytag('Check Course Document Versions'));
1.89      www       602:     my $header='';
                    603:     my $startsel='';
                    604:     my $monthsel='';
                    605:     my $weeksel='';
                    606:     my $daysel='';
                    607:     my $allsel='';
                    608:     my %changes=();
                    609:     my $starttime=0;
1.91      www       610:     my $haschanged=0;
1.92      www       611:     my %setversions=&Apache::lonnet::dump('resourceversions',
                    612: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
                    613: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
                    614: 
                    615:     $hashtied=0;
                    616:     &tiehash();
                    617:     my %newsetversions=();
1.91      www       618:     if ($ENV{'form.setmostrecent'}) {
                    619: 	$haschanged=1;
1.92      www       620: 	foreach (keys %hash) {
                    621: 	    if ($_=~/^ids\_(\/res\/.+)$/) {
1.93      www       622: 		$newsetversions{$1}='mostrecent';
1.92      www       623: 	    }
                    624: 	}
1.91      www       625:     } elsif ($ENV{'form.setcurrent'}) {
                    626: 	$haschanged=1;
1.92      www       627: 	foreach (keys %hash) {
                    628: 	    if ($_=~/^ids\_(\/res\/.+)$/) {
1.93      www       629: 		my $getvers=&Apache::lonnet::getversion($1);
                    630: 		if ($getvers>0) {
                    631: 		    $newsetversions{$1}=$getvers;
                    632: 		}
1.92      www       633: 	    }
                    634: 	}
1.91      www       635:     } elsif ($ENV{'form.setversions'}) {
                    636: 	$haschanged=1;
1.92      www       637: 	foreach (keys %ENV) {
                    638: 	    if ($_=~/^form\.set_version_(.+)$/) {
                    639: 		my $src=$1;
                    640: 		&Apache::lonnet::logthis('Found: '.$1.' '.$ENV{$_});
                    641: 		if (($ENV{$_}) && ($ENV{$_} ne $setversions{$src})) {
                    642: 		    $newsetversions{$src}=$ENV{$_};
                    643: 		}
                    644: 	    }
                    645: 	}
1.91      www       646:     }
                    647:     if ($haschanged) {
1.92      www       648:         if (&Apache::lonnet::put('resourceversions',\%newsetversions,
                    649: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
                    650: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.num'}) eq 'ok') {		
                    651: 	    $r->print('<h1>'.&mt('Your Version Settings have been Stored').'</h1>');
                    652: 	} else {
                    653: 	    $r->print('<h1><font color="red">'.&mt('An Error Occured while Attempting to Store your Version Settings').'</font></h1>');
                    654: 	}
1.91      www       655: 	&changewarning($r,'');
                    656:     }
1.89      www       657:     if ($ENV{'form.timerange'} eq 'all') {
                    658: # show all documents
                    659: 	$header=&mt('All Documents in Course');
1.91      www       660: 	$allsel=1;
1.90      www       661: 	foreach (keys %hash) {
                    662: 	    if ($_=~/^ids\_(\/res\/.+)$/) {
                    663: 		my $src=$1;
                    664: 		$changes{$src}=1;
                    665: 	    }
                    666: 	}
1.89      www       667:     } else {
                    668: # show documents which changed
                    669: 	%changes=&Apache::lonnet::dump
                    670: 	 ('versionupdate',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1.30      www       671:                      $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.89      www       672: 	my $firstkey=(keys %changes)[0];
                    673: 	unless ($firstkey=~/^error\:/) {
                    674: 	    unless ($ENV{'form.timerange'}) {
                    675: 		$ENV{'form.timerange'}=604800;
                    676: 	    }
                    677: 	    my $seltext=&mt('during the last').' '.$ENV{'form.timerange'}.' '
                    678: 		.&mt('seconds');
                    679: 	    if ($ENV{'form.timerange'}==-1) {
                    680: 		$seltext='since start of course';
                    681: 		$startsel='selected';
                    682: 		$ENV{'form.timerange'}=time;
                    683: 	    }
                    684: 	    $starttime=time-$ENV{'form.timerange'};
                    685: 	    if ($ENV{'form.timerange'}==2592000) {
                    686: 		$seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
                    687: 		$monthsel='selected';
                    688: 	    } elsif ($ENV{'form.timerange'}==604800) {
                    689: 		$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
                    690: 		$weeksel='selected';
                    691: 	    } elsif ($ENV{'form.timerange'}==86400) {
                    692: 		$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
                    693: 		$daysel='selected';
                    694: 	    }
                    695: 	    $header=&mt('Content changed').' '.$seltext;
                    696: 	} else {
                    697: 	    $header=&mt('No content modifications yet.');
                    698: 	}
                    699:     }
1.92      www       700:     %setversions=&Apache::lonnet::dump('resourceversions',
                    701: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
                    702: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.89      www       703:     my %lt=&Apache::lonlocal::texthash
1.88      www       704: 	      ('st' => 'Version changes since start of Course',
                    705: 	       'lm' => 'Version changes since last Month',
                    706: 	       'lw' => 'Version changes since last Week',
                    707: 	       'sy' => 'Version changes since Yesterday',
1.91      www       708:                'al' => 'All Resources (possibly large output)',
1.88      www       709: 	       'sd' => 'Display',
1.84      www       710: 	       'fi' => 'File',
                    711: 	       'md' => 'Modification Date',
1.87      www       712:                'mr' => 'Most recently published Version',
                    713: 	       've' => 'Version used in Course',
1.91      www       714:                'vu' => 'Set Version to be used in Course',
                    715: 'sv' => 'Set Versions to be used in Course according to Selections below',
                    716: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
                    717: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.84      www       718: 	       'di' => 'Differences');
1.89      www       719:     $r->print(<<ENDHEADERS);
1.31      www       720: <form action="/adm/coursedocs" method="post">
1.91      www       721: <input type="hidden" name="versions" value="1" />
                    722: <input type="submit" name="setmostrecent" value="$lt{'sm'}" />
                    723: <input type="submit" name="setcurrent" value="$lt{'sc'}" /><hr />
1.31      www       724: <select name="timerange">
1.88      www       725: <option value='all' $allsel>$lt{'al'}</option>
1.84      www       726: <option value="-1" $startsel>$lt{'st'}</option>
                    727: <option value="2592000" $monthsel>$lt{'lm'}</option>
                    728: <option value="604800" $weeksel>$lt{'lw'}</option>
                    729: <option value="86400" $daysel>$lt{'sy'}</option>
1.31      www       730: </select>
1.91      www       731: <input type="submit" name="display" value="$lt{'sd'}" />
1.89      www       732: <h3>$header</h3>
1.91      www       733: <input type="submit" name="setversions" value="$lt{'sv'}" />
1.103     matthew   734: <table border="0">
1.31      www       735: ENDHEADERS
1.91      www       736:     foreach (sort keys %changes) {
1.89      www       737: 	if ($changes{$_}>$starttime) {
                    738: 	    my ($root,$extension)=($_=~/^(.*)\.(\w+)$/);
                    739: 	    my $currentversion=&Apache::lonnet::getversion($_);
1.93      www       740: 	    if ($currentversion<0) {
                    741: 		$currentversion=&mt('Could not be determined.');
                    742: 	    }
1.89      www       743: 	    my $linkurl=&Apache::lonnet::clutter($_);
                    744: 	    $r->print(
1.103     matthew   745: 		      '<tr><td colspan="5"><br /><br /><font size="+1"><b>'.
1.91      www       746: 		      &Apache::lonnet::gettitle($linkurl).
1.103     matthew   747:                       '</b></font></td></tr>'.
                    748:                       '<tr><td>&nbsp;&nbsp;&nbsp;</td>'.
                    749:                       '<td colspan="4">'.
                    750:                       '<a href="'.$linkurl.'" target="cat">'.$linkurl.
                    751: 		      '</a></td></tr>'.
                    752:                       '<tr><td></td>'.
                    753:                       '<td title="'.$lt{'md'}.'">'.
1.102     matthew   754: 		      &Apache::lonlocal::locallocaltime(
                    755:                            &Apache::lonnet::metadata($root.'.'.$extension,
                    756:                                                      'lastrevisiondate')
                    757:                                                         ).
1.103     matthew   758:                       '</td>'.
                    759:                       '<td title="'.$lt{'mr'}.'"><nobr>Most Recent: '.
                    760:                       '<font size="+1">'.$currentversion.'</font>'.
                    761:                       '</nobr></td>'.
                    762:                       '<td title="'.$lt{'ve'}.'"><nobr>In Course: '.
                    763:                       '<font size="+1">');
1.87      www       764: # Used in course
1.89      www       765: 	    my $usedversion=$hash{'version_'.$linkurl};
1.93      www       766: 	    if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.89      www       767: 		$r->print($usedversion);
                    768: 	    } else {
                    769: 		$r->print($currentversion);
                    770: 	    }
1.103     matthew   771: 	    $r->print('</font></nobr></td><td title="'.$lt{'vu'}.'">'.
                    772:                       '<nobr>Use: ');
1.87      www       773: # Set version
1.92      www       774: 	    $r->print(&Apache::loncommon::select_form($setversions{$linkurl},
1.89      www       775: 						      'set_version_'.$linkurl,
                    776: 						      ('' => '',
1.93      www       777: 						       'mostrecent' => 'most recent',
1.89      www       778: 						       map {$_,$_} (1..$currentversion))));
1.103     matthew   779: 	    $r->print('</nobr></td></tr><tr><td></td>');
1.89      www       780: 	    my $lastold=1;
                    781: 	    for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
                    782: 		my $url=$root.'.'.$prevvers.'.'.$extension;
                    783: 		if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
                    784: 		    $starttime) {
                    785: 		    $lastold=$prevvers;
                    786: 		}
                    787: 	    }
1.103     matthew   788:             # 
                    789:             # Code to figure out how many version entries should go in
                    790:             # each of the four columns
                    791:             my $entries_per_col = 0;
                    792:             my $num_entries = ($currentversion-$lastold);
                    793:             if ($num_entries % 4 == 0) {
                    794:                 $entries_per_col = $num_entries/4;
                    795:             } else {
                    796:                 $entries_per_col = $num_entries/4 + 1;
                    797:             }
                    798:             my $entries_count = 0;
                    799:             $r->print('<td valign="top"><font size="-2">'); 
                    800:             my $cols_output = 1;
1.32      www       801:             for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
1.89      www       802: 		my $url=$root.'.'.$prevvers.'.'.$extension;
1.103     matthew   803: 		$r->print('<nobr><a href="'.&Apache::lonnet::clutter($url).
1.91      www       804: 			  '">'.&mt('Version').' '.$prevvers.'</a> ('.
1.103     matthew   805: 			  &Apache::lonlocal::locallocaltime(
                    806:                                 &Apache::lonnet::metadata($url,
                    807:                                                           'lastrevisiondate')
                    808:                                                             ).
1.91      www       809: 			  ')');
1.89      www       810: 		if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
1.33      www       811:                     $r->print(' <a href="/adm/diff?filename='.
1.89      www       812: 			      &Apache::lonnet::clutter($root.'.'.$extension).
                    813: 			      '&versionone='.$prevvers.
                    814: 			      '">'.&mt('Diffs').'</a>');
                    815: 		}
1.103     matthew   816: 		$r->print('</nobr><br />');
                    817:                 if (++$entries_count % $entries_per_col == 0) {
                    818:                     $r->print('</font></td>');
                    819:                     if ($cols_output != 4) {
                    820:                         $r->print('<td valign="top"><font size="-2">');
                    821:                         $cols_output++;
                    822:                     }
                    823:                 }
1.89      www       824: 	    }
1.103     matthew   825:             while($cols_output++ < 4) {
                    826:                 $r->print('</font></td><td><font>')
                    827:             }
                    828: 	    $r->print('</font></td></tr>'."\n");
1.89      www       829: 	}
                    830:     }
1.92      www       831:     $r->print('</table></form>');
1.89      www       832:     $r->print('<h1>'.&mt('Done').'.</h1>');
                    833: 
                    834:     &untiehash();
1.75      www       835: }
                    836: 
1.91      www       837: sub changewarning {
                    838:     my ($r,$postexec)=@_;
                    839:     $r->print(
                    840: '<script>function reinit(tf) { tf.submit();'.$postexec.' }</script>'. 
                    841: '<form method="post" action="/adm/roles" target="loncapaclient">'.
                    842: '<input type="hidden" name="orgurl" value="/adm/coursedocs" /><input type="hidden" name="selectrole" value="1" /><h3><font color="red">'.
                    843: &mt('Changes will become active for your current session after').
                    844: ' <input type="hidden" name="'.
                    845: $ENV{'request.role'}.'" value="1" /><input type="button" value="'.
                    846: &mt('re-initializing course').'" onClick="reinit(this.form)"/>'.&mt(', or the next time you log in.').
                    847: $help{'Caching'}.'</font></h3></form>');
                    848: }
                    849: 
1.75      www       850: # ================================================================ Main Handler
                    851: sub handler {
                    852:     my $r = shift;
1.82      www       853:     &Apache::loncommon::content_type($r,'text/html');
1.75      www       854:     $r->send_http_header;
                    855:     return OK if $r->header_only;
                    856: 
                    857: # --------------------------------------------- Initialize help topics for this
                    858:   foreach ('Adding_Course_Doc','Main_Course_Documents',
                    859:            'Adding_External_Resource','Navigate_Content',
                    860:            'Adding_Folders','Docs_Overview', 'Load_Map',
                    861:            'Supplemental', 'Score_Upload_Form',
                    862:            'Importing_LON-CAPA_Resource','Uploading_From_Harddrive') {
                    863:       $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);
                    864:   }
                    865:     # Composite help files
                    866:     $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
                    867: 		    'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
                    868:     $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
                    869: 		    'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
1.86      albertel  870:     $help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
                    871: 		    'Option_Response_Simple');
1.75      www       872:     $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
                    873: 		    'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
                    874:     $help{'My Personal Info'} = &Apache::loncommon::help_open_topic(
                    875: 		  'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
                    876:     $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
                    877:  
                    878:   if ($ENV{'form.verify'}) {
                    879:       &verifycontent($r);
                    880:   } elsif ($ENV{'form.versions'}) {
                    881:       &checkversions($r);
                    882:   } elsif ($ENV{'form.dumpcourse'}) {
                    883:       &dumpcourse($r);
1.26      www       884:   } else {
1.7       www       885: # is this a standard course?
                    886: 
                    887:     my $standard=($ENV{'request.course.uri'}=~/^\/uploaded\//);
1.15      www       888:     my $forcestandard;
                    889:     my $forcesupplement;
                    890:     my $script='';
                    891:     my $allowed;
                    892:     my $events='';
1.19      www       893:     my $showdoc=0;
1.15      www       894:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.21      www       895:        ['folder','foldername']);
                    896:     if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
                    897:        $showdoc=$1;
                    898:     }
                    899:     unless ($showdoc) { # got called from remote
1.15      www       900:        $forcestandard=($ENV{'form.folder'}=~/^default_/);
                    901:        $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
1.7       www       902: 
1.4       www       903: # does this user have privileges to post, etc?
1.77      www       904:        $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
1.15      www       905:        if ($allowed) { 
                    906:          &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
                    907:          $script=&Apache::lonratedt::editscript('simple'); 
                    908:        }
                    909:     } else { # got called in sequence from course
                    910:        $allowed=0;
1.49      www       911:        $script='</script>'.&Apache::lonmenu::registerurl(1,undef).'<script>';
                    912:        $events='onLoad="'.&Apache::lonmenu::loadevents.
                    913:            '" onUnload="'.&Apache::lonmenu::unloadevents.'"';
1.3       www       914:     }
1.4       www       915: 
                    916: # get course data
                    917:     my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
                    918:     my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
                    919: 
1.14      www       920: # get personal data
                    921:  
                    922:     my $uname=$ENV{'user.name'};
                    923:     my $udom=$ENV{'user.domain'};
                    924:     my $plainname=&Apache::lonnet::escape(
                    925:                      &Apache::loncommon::plainname($uname,$udom));
                    926: 
1.8       www       927: # graphics settings
1.4       www       928: 
1.8       www       929:     $iconpath = $r->dir_config('lonIconsURL') . "/";
                    930: 
1.22      www       931:     my $now=time;
1.64      www       932: 
1.4       www       933: # print screen
1.1       www       934:     $r->print(<<ENDDOCUMENT);
                    935: <html>
                    936: <head>
                    937: <title>The LearningOnline Network with CAPA</title>
1.16      www       938: <script>
                    939: $script
1.20      www       940: </script>
1.19      www       941: ENDDOCUMENT
                    942:    if ($allowed) {
                    943:     $r->print(<<ENDNEWSCRIPT);
1.20      www       944: <script>
1.16      www       945: function makenewfolder(targetform,folderseq) {
                    946:     var foldername=prompt('Name of New Folder','New Folder');
                    947:     if (foldername) {
                    948: 	targetform.importdetail.value=foldername+"="+folderseq;
                    949:         targetform.submit();
                    950:     }
                    951: }
                    952: 
1.18      www       953: function makenewext(targetname) {
                    954:     this.document.forms.extimport.useform.value=targetname;
                    955:     window.open('/adm/rat/extpickframe.html');
                    956: }
                    957: 
1.62      www       958: function makeexamupload() {
                    959:    var title=prompt('Listed Title for the Uploaded Score');
                    960:    if (title) { 
                    961:     this.document.forms.newexamupload.importdetail.value=
                    962: 	title+'=/res/lib/templates/examupload.problem';
                    963:     this.document.forms.newexamupload.submit();
                    964:    }
                    965: }
                    966: 
1.22      www       967: function makesmppage() {
1.38      www       968:    var title=prompt('Listed Title for the Page');
                    969:    if (title) { 
1.22      www       970:     this.document.forms.newsmppg.importdetail.value=
                    971: 	title+'=/adm/$udom/$uname/$now/smppg';
                    972:     this.document.forms.newsmppg.submit();
1.38      www       973:    }
1.22      www       974: }
                    975: 
1.55      www       976: function makesmpproblem() {
                    977:    var title=prompt('Listed Title for the Problem');
                    978:    if (title) { 
                    979:     this.document.forms.newsmpproblem.importdetail.value=
1.63      www       980: 	title+'=/res/lib/templates/simpleproblem.problem';
1.55      www       981:     this.document.forms.newsmpproblem.submit();
                    982:    }
                    983: }
                    984: 
1.22      www       985: function makebulboard() {
1.38      www       986:    var title=prompt('Listed Title for the Bulletin Board');
                    987:    if (title) {
1.22      www       988:     this.document.forms.newbul.importdetail.value=
                    989: 	title+'=/adm/$udom/$uname/$now/bulletinboard';
                    990:     this.document.forms.newbul.submit();
1.38      www       991:    }
1.22      www       992: }
                    993: 
1.101     www       994: function makeabout() {
                    995:    var user=prompt("Enter user\@domain for User's 'About Me' Page");
                    996:    if (user) {
                    997:        var comp=new Array();
                    998:        comp=user.split('\@');
                    999:        if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
                   1000: 	   if ((comp[0]) && (comp[1])) {
                   1001: 	       this.document.forms.newaboutsomeone.importdetail.value=
                   1002: 		   'About '+user+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
                   1003: 	       this.document.forms.newaboutsomeone.submit();
                   1004: 	   }
                   1005:        }
                   1006:    }
                   1007: }
                   1008: 
1.18      www      1009: function finishpick() {
                   1010:     var title=this.document.forms.extimport.title.value;
                   1011:     var url=this.document.forms.extimport.url.value;
                   1012:     var form=this.document.forms.extimport.useform.value;
                   1013:     eval
                   1014:      ('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+
                   1015:     '";this.document.forms.'+form+'.submit();');
1.16      www      1016: }
1.36      www      1017: 
                   1018: function changename(folder,index,oldtitle) {
                   1019:     var title=prompt('New Title',oldtitle);
                   1020:     if (title) {
                   1021: 	this.document.forms.renameform.title.value=title;
                   1022: 	this.document.forms.renameform.cmd.value='rename_'+index;
1.54      www      1023: 	this.document.forms.renameform.folder.value=folder;
                   1024:         this.document.forms.renameform.submit();
                   1025:     }
                   1026: }
                   1027: 
                   1028: function removeres(folder,index,oldtitle) {
1.106   ! www      1029:     if (confirm('Remove "'+oldtitle+'"?')) {
1.54      www      1030: 	this.document.forms.renameform.cmd.value='del_'+index;
1.36      www      1031: 	this.document.forms.renameform.folder.value=folder;
                   1032:         this.document.forms.renameform.submit();
                   1033:     }
                   1034: }
1.16      www      1035: </script>
1.42      www      1036: 
                   1037: ENDNEWSCRIPT
                   1038:   }
                   1039: # -------------------------------------------------------------------- Body tag
                   1040:   $r->print('</head>'.
1.72      www      1041:             &Apache::loncommon::bodytag('Course Documents','',$events,
1.99      www      1042: 					'','',$showdoc).
                   1043: 	    &Apache::loncommon::help_open_faq(273).
                   1044: 	    &Apache::loncommon::help_open_bug('RAT'));
1.42      www      1045:   unless ($showdoc) {
1.81      www      1046: # -----------------------------------------------------------------------------
                   1047:        my %lt=&Apache::lonlocal::texthash(
                   1048:                 'uplm' => 'Upload a new main course document',
                   1049:                 'upls' => 'Upload a new supplemental course document',
                   1050:                 'impp' => 'Import a published document',
                   1051:                 'spec' => 'Special documents',
                   1052:                 'upld' => 'Upload Document',
                   1053:                 'srch' => 'Search',
                   1054:                 'impo' => 'Import',
                   1055:                 'selm' => 'Select Map',
                   1056:                 'load' => 'Load Map',
                   1057:                 'newf' => 'New Folder',
                   1058:                 'extr' => 'External Resource',
                   1059:                 'syll' => 'Syllabus',
                   1060:                 'navc' => 'Navigate Contents',
                   1061:                 'sipa' => 'Simple Page',
                   1062:                 'sipr' => 'Simple Problem',
                   1063:                 'scuf' => 'Score Upload Form',
                   1064:                 'bull' => 'Bulletin Board',
1.96      sakharuk 1065:                 'mypi' => 'My Personal Info',
1.101     www      1066: 		'abou' => 'About User',
1.96      sakharuk 1067:                 'file' =>  'File',
                   1068:                 'title' => 'Title',
                   1069:                 'comment' => 'Comment' 
1.81      www      1070: 					  );
                   1071: # -----------------------------------------------------------------------------
1.42      www      1072:     if ($allowed) {
1.74      www      1073:        my $dumpbut=&dumpbutton();
1.88      www      1074:        my %lt=&Apache::lonlocal::texthash(
                   1075: 					 'vc' => 'Verify Content',
                   1076: 					 'cv' => 'Check/Set Resource Versions',
                   1077: 					  );
1.42      www      1078:        $r->print(<<ENDCOURSEVERIFY);
1.36      www      1079: <form name="renameform" method="post" action="/adm/coursedocs">
                   1080: <input type="hidden" name="title" />
                   1081: <input type="hidden" name="cmd" />
                   1082: <input type="hidden" name="folder" />
                   1083: </form>
1.39      www      1084: <form name="simpleedit" method="post" action="/adm/coursedocs">
                   1085: <input type=hidden name="importdetail" value="">
                   1086: <input type="hidden" name="folder" />
                   1087: </form>
1.26      www      1088: <form action="/adm/coursedocs" method="post" name="courseverify">
1.74      www      1089: <table bgcolor="#AAAAAA" width="100%" cellspacing="4" cellpadding="4">
                   1090: <tr><td bgcolor="#DDDDCC">
1.88      www      1091: <input type="submit" name="verify" value="$lt{'vc'}" />
1.74      www      1092: </td><td bgcolor="#DDDDCC">
1.88      www      1093: <input type="submit" name="versions" value="$lt{'cv'}" />
1.74      www      1094: $dumpbut
                   1095: </td></tr></table>
1.25      www      1096: </form>
                   1097: ENDCOURSEVERIFY
1.74      www      1098:        $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
1.96      sakharuk 1099: 		     &mt('Editing the Table of Contents for your Course')));
1.25      www      1100:     }
1.17      www      1101: # --------------------------------------------------------- Standard documents
1.43      www      1102:     $r->print('<table border=2 cellspacing=4 cellpadding=4>');
1.7       www      1103:     if (($standard) && ($allowed) && (!$forcesupplement)) {
1.81      www      1104:        $r->print('<tr><td bgcolor="#BBBBBB"><h2>'.&mt('Main Course Documents').
1.47      www      1105:   ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>');
1.7       www      1106:        my $folder=$ENV{'form.folder'};
1.10      www      1107:        unless ($folder=~/^default/) { $folder='default'; }
1.51      www      1108:        my $postexec='';
                   1109:        if ($folder eq 'default') {
                   1110: 	   $r->print('<script>this.window.name="loncapaclient";</script>');
                   1111:        } else {
                   1112:            $postexec='self.close();';
                   1113:        }
1.40      www      1114:        $hadchanges=0;
1.7       www      1115:        &editor($r,$coursenum,$coursedom,$folder,$allowed);
1.40      www      1116:        if ($hadchanges) {
1.91      www      1117: 	   &changewarning($r,$postexec);
1.40      www      1118:        }
1.16      www      1119:        my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
                   1120:                      '.sequence';
1.8       www      1121:        $r->print(<<ENDFORM);
1.43      www      1122: <table cellspacing=4 cellpadding=4><tr>
1.81      www      1123: <th bgcolor="#DDDDDD">$lt{'uplm'}</th>
                   1124: <th bgcolor="#DDDDDD">$lt{'impp'}</th>
                   1125: <th bgcolor="#DDDDDD">$lt{'spec'}</th>
1.11      www      1126: </tr>
1.16      www      1127: <tr><td bgcolor="#DDDDDD">
1.96      sakharuk 1128: $lt{'file'}:<br />
1.10      www      1129: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.59      www      1130: <input type="file" name="uploaddoc" size="40">
1.8       www      1131: <br />
1.96      sakharuk 1132: $lt{'title'}:<br />
1.11      www      1133: <input type="text" size="50" name="comment">
1.8       www      1134: <input type="hidden" name="folder" value="$folder">
1.17      www      1135: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.10      www      1136: <input type="hidden" name="cmd" value="upload_default">
1.81      www      1137: <input type="submit" value="$lt{'upld'}">
1.59      www      1138: <nobr>
1.60      albertel 1139:  $help{'Uploading_From_Harddrive'}
1.58      albertel 1140: </nobr>
1.60      albertel 1141: </form>
1.11      www      1142: </td>
1.16      www      1143: <td bgcolor="#DDDDDD">
1.39      www      1144: <form action="/adm/coursedocs" method="post" name="simpleeditdefault">
1.53      www      1145: <input type="hidden" name="folder" value="$folder">
                   1146: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.11      www      1147: <input type=button onClick=
1.81      www      1148: "javascript:document.forms.simpleedit.folder.value='$folder';groupsearch()" value="$lt{'srch'}">
1.58      albertel 1149: <nobr>
1.11      www      1150: <input type=button onClick=
1.81      www      1151: "javascript:document.forms.simpleedit.folder.value='$folder';groupimport();" value="$lt{'impo'}">
1.58      albertel 1152: $help{'Importing_LON-CAPA_Resource'}
                   1153: </nobr>
1.59      www      1154: <p>
                   1155: <hr />
1.68      bowersj2 1156: <input type="text" size="20" name="importmap"><br />
                   1157: <nobr><input type=button 
1.52      www      1158: onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
1.81      www      1159: value="$lt{'selm'}"> <input type="submit" name="loadmap" value="$lt{'load'}">
1.68      bowersj2 1160: $help{'Load_Map'}</nobr>
1.59      www      1161: </p>
1.52      www      1162: </form>
1.16      www      1163: </td><td bgcolor="#DDDDDD">
1.11      www      1164: <form action="/adm/coursedocs" method="post" name="newfolder">
1.16      www      1165: <input type="hidden" name="folder" value="$folder">
1.17      www      1166: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.13      www      1167: <input type=hidden name="importdetail" value="">
1.58      albertel 1168: <nobr>
1.16      www      1169: <input name="newfolder" type="button"
                   1170: onClick="javascript:makenewfolder(this.form,'$folderseq');"
1.81      www      1171: value="$lt{'newf'}" />$help{'Adding_Folders'}
1.58      albertel 1172: </nobr>
1.11      www      1173: </form>
                   1174: <form action="/adm/coursedocs" method="post" name="newext">
1.16      www      1175: <input type="hidden" name="folder" value="$folder">
1.17      www      1176: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.13      www      1177: <input type=hidden name="importdetail" value="">
1.58      albertel 1178: <nobr>
1.18      www      1179: <input name="newext" type="button" onClick="javascript:makenewext('newext');"
1.81      www      1180: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
1.58      albertel 1181: </nobr>
1.11      www      1182: </form>
                   1183: <form action="/adm/coursedocs" method="post" name="newsyl">
1.16      www      1184: <input type="hidden" name="folder" value="$folder">
1.17      www      1185: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.14      www      1186: <input type=hidden name="importdetail" 
                   1187: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
1.58      albertel 1188: <nobr>
1.81      www      1189: <input name="newsyl" type="submit" value="$lt{'syll'}" /> 
1.65      bowersj2 1190:  $help{'Syllabus'}
1.58      albertel 1191: </nobr>
                   1192: </form>
1.17      www      1193: <form action="/adm/coursedocs" method="post" name="newnav">
1.20      www      1194: <input type="hidden" name="folder" value="$folder">
                   1195: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.15      www      1196: <input type=hidden name="importdetail" 
                   1197: value="Navigate Content=/adm/navmaps">
1.58      albertel 1198: <nobr>
1.81      www      1199: <input name="newnav" type="submit" value="$lt{'navc'}" />
1.47      www      1200: $help{'Navigate_Content'}
1.58      albertel 1201: </nobr>
1.22      www      1202: </form>
                   1203: <form action="/adm/coursedocs" method="post" name="newsmppg">
                   1204: <input type="hidden" name="folder" value="$folder">
                   1205: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                   1206: <input type=hidden name="importdetail" value="">
1.58      albertel 1207: <nobr>
1.81      www      1208: <input name="newsmppg" type="button" value="$lt{'sipa'}"
1.65      bowersj2 1209: onClick="javascript:makesmppage();" /> $help{'Simple Page'}
1.58      albertel 1210: </nobr>
1.55      www      1211: </form>
                   1212: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
                   1213: <input type="hidden" name="folder" value="$folder">
                   1214: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                   1215: <input type=hidden name="importdetail" value="">
1.58      albertel 1216: <nobr>
1.81      www      1217: <input name="newsmpproblem" type="button" value="$lt{'sipr'}"
1.65      bowersj2 1218: onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
1.62      www      1219: </nobr>
                   1220: </form>
                   1221: <form action="/adm/coursedocs" method="post" name="newexamupload">
                   1222: <input type="hidden" name="folder" value="$folder">
                   1223: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                   1224: <input type=hidden name="importdetail" value="">
                   1225: <nobr>
1.81      www      1226: <input name="newexamupload" type="button" value="$lt{'scuf'}"
1.62      www      1227: onClick="javascript:makeexamupload();" />
1.66      bowersj2 1228: $help{'Score_Upload_Form'}
1.58      albertel 1229: </nobr>
1.22      www      1230: </form>
                   1231: <form action="/adm/coursedocs" method="post" name="newbul">
                   1232: <input type="hidden" name="folder" value="$folder">
                   1233: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                   1234: <input type=hidden name="importdetail" value="">
1.58      albertel 1235: <nobr>
1.81      www      1236: <input name="newbulletin" type="button" value="$lt{'bull'}"
1.22      www      1237: onClick="javascript:makebulboard();" />
1.65      bowersj2 1238: $help{'Bulletin Board'}
1.58      albertel 1239: </nobr>
                   1240: </form>
1.12      www      1241: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.16      www      1242: <input type="hidden" name="folder" value="$folder">
1.17      www      1243: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.14      www      1244: <input type=hidden name="importdetail" 
                   1245: value="$plainname=/adm/$udom/$uname/aboutme">
1.58      albertel 1246: <nobr>
1.81      www      1247: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
1.65      bowersj2 1248: $help{'My Personal Info'}
1.101     www      1249: </nobr>
                   1250: </form>
                   1251: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
                   1252: <input type="hidden" name="folder" value="$folder">
                   1253: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                   1254: <input type=hidden name="importdetail" value="">
                   1255: <nobr>
                   1256: <input name="newaboutsomeone" type="button" value="$lt{'abou'}" 
                   1257: onClick="javascript:makeabout();" />
1.58      albertel 1258: </nobr>
                   1259: </form>
1.11      www      1260: </td></tr>
                   1261: </table>
1.8       www      1262: ENDFORM
1.24      www      1263:        $r->print('</td></tr>');
1.7       www      1264:     }
                   1265: # ----------------------------------------------------- Supplemental documents
                   1266:     if (!$forcestandard) {
1.24      www      1267:        $r->print(
1.81      www      1268:   '<tr><td bgcolor="#BBBBBB"><h2>'.&mt('Supplemental Course Documents').
1.47      www      1269:   ($allowed?' '.$help{'Supplemental'}:'').'</h2>');
1.7       www      1270:        my $folder=$ENV{'form.folder'};
1.10      www      1271:        unless ($folder=~/supplemental/) { $folder='supplemental'; }
1.7       www      1272:        &editor($r,$coursenum,$coursedom,$folder,$allowed);
1.8       www      1273:        if ($allowed) {
1.17      www      1274:        my $folderseq=
                   1275:                   '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
                   1276:                      '.sequence';
                   1277: 
1.8       www      1278:           $r->print(<<ENDSUPFORM);
1.43      www      1279: <table cellspacing=4 cellpadding=4><tr>
1.81      www      1280: <th bgcolor="#DDDDDD">$lt{'upls'}</th>
                   1281: <th bgcolor="#DDDDDD">$lt{'spec'}</th>
1.17      www      1282: </tr>
                   1283: <tr><td bgcolor="#DDDDDD">
1.10      www      1284: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.59      www      1285: <input type="file" name="uploaddoc" size="40">
1.96      sakharuk 1286: <br />$lt{'comment'}:<br />
1.4       www      1287: <textarea cols=50 rows=4 name='comment'>
                   1288: </textarea>
1.8       www      1289: <input type="hidden" name="folder" value="$folder">
1.17      www      1290: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.10      www      1291: <input type="hidden" name="cmd" value="upload_supplemental">
1.58      albertel 1292: <nobr>
1.81      www      1293: <input type="submit" value="$lt{'upld'}">
1.58      albertel 1294:  $help{'Uploading_From_Harddrive'}
                   1295: </nobr>
                   1296: </form>
1.17      www      1297: </td>
                   1298: <td bgcolor="#DDDDDD">
1.18      www      1299: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.17      www      1300: <input type="hidden" name="folder" value="$folder">
                   1301: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                   1302: <input type=hidden name="importdetail" value="">
1.58      albertel 1303: <nobr>
1.17      www      1304: <input name="newfolder" type="button"
                   1305: onClick="javascript:makenewfolder(this.form,'$folderseq');"
1.81      www      1306: value="$lt{'newf'}" /> $help{'Adding_Folders'}
1.58      albertel 1307: </nobr>
1.17      www      1308: </form>
1.18      www      1309: <form action="/adm/coursedocs" method="post" name="supnewext">
1.17      www      1310: <input type="hidden" name="folder" value="$folder">
                   1311: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                   1312: <input type=hidden name="importdetail" value="">
1.58      albertel 1313: <nobr>
1.18      www      1314: <input name="newext" type="button" 
                   1315: onClick="javascript:makenewext('supnewext');"
1.81      www      1316: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
1.58      albertel 1317: </nobr>
1.17      www      1318: </form>
1.18      www      1319: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.17      www      1320: <input type="hidden" name="folder" value="$folder">
                   1321: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                   1322: <input type=hidden name="importdetail" 
                   1323: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
1.58      albertel 1324: <nobr>
1.81      www      1325: <input name="newsyl" type="submit" value="$lt{'syll'}" />
1.65      bowersj2 1326: $help{'Syllabus'}
1.58      albertel 1327: </nobr>
                   1328: </form>
1.18      www      1329: <form action="/adm/coursedocs" method="post" name="subnewaboutme">
1.17      www      1330: <input type="hidden" name="folder" value="$folder">
                   1331: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                   1332: <input type=hidden name="importdetail" 
                   1333: value="$plainname=/adm/$udom/$uname/aboutme">
1.58      albertel 1334: <nobr>
1.81      www      1335: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
1.65      bowersj2 1336: $help{'My Personal Info'}
1.58      albertel 1337: </nobr>
                   1338: </form>
1.17      www      1339: </td></tr>
1.24      www      1340: </table></td></tr>
1.8       www      1341: ENDSUPFORM
                   1342:        }
1.7       www      1343:     }
1.18      www      1344:     if ($allowed) {
                   1345: 	$r->print('<form name="extimport"><input type="hidden" name="title"><input type="hidden" name="url"><input type="hidden" name="useform"></form>');
                   1346:     }
1.24      www      1347:     $r->print('</table>');
1.19      www      1348:   } else {
                   1349: # -------------------------------------------------------- This is showdoc mode
1.81      www      1350:       $r->print("<h1>".&mt('Uploaded Document').'</h1><p>'.
                   1351: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><p><table>".
                   1352:          &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table></p>');
1.19      www      1353:   }
1.26      www      1354:  }
1.95      www      1355:  $r->print('</body></html>');
1.26      www      1356:  return OK;
1.1       www      1357: } 
                   1358: 
                   1359: 1;
                   1360: __END__

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