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

1.1       www         1: # The LearningOnline Network
1.2       www         2: # Documents
1.1       www         3: #
1.79    ! www         4: # $Id: londocs.pm,v 1.78 2003/09/15 15:24:18 www 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.7       www        41: 
1.8       www        42: my $iconpath;
1.7       www        43: 
1.27      www        44: my %hash;
                     45: 
                     46: my $hashtied;
1.29      www        47: my %alreadyseen=();
1.27      www        48: 
1.40      www        49: my $hadchanges;
                     50: 
1.47      www        51: # Available help topics
                     52: 
                     53: my %help=();
                     54: 
1.7       www        55: # Mapread read maps into lonratedt::global arrays 
1.10      www        56: # @order and @resources, determines status
1.7       www        57: # sets @order - pointer to resources in right order
                     58: # sets @resources - array with the resources with correct idx
                     59: #
                     60: 
                     61: sub mapread {
                     62:     my ($coursenum,$coursedom,$map)=@_;
                     63:     return
                     64:       &Apache::lonratedt::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
                     65:                                 $map);
                     66: }
                     67: 
                     68: sub storemap {
                     69:     my ($coursenum,$coursedom,$map)=@_;
1.40      www        70:     $hadchanges=1;
1.7       www        71:     return
                     72:       &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.15      www        73:                                 $map,1);
1.7       www        74: }
                     75: 
1.74      www        76: # ----------------------------------------- Return hash with valid author names
                     77: 
                     78: sub authorhosts {
                     79:     my %outhash=();
                     80:     my $home=0;
                     81:     my $other=0;
                     82:     foreach (keys %ENV) {
                     83: 	if ($_=~/^user\.role\.(au|ca)\.(.+)$/) {
                     84: 	    my $role=$1;
                     85: 	    my $realm=$2;
                     86: 	    my ($start,$end)=split(/\./,$ENV{$_});
                     87: 	    if (($start) && ($start>time)) { next; }
                     88: 	    if (($end) && (time>$end)) { next; }
                     89: 	    my $ca; my $cd;
                     90: 	    if ($1 eq 'au') {
                     91: 		$ca=$ENV{'user.name'};
                     92: 		$cd=$ENV{'user.domain'};
                     93: 	    } else {
                     94: 		($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/);
                     95: 	    }
                     96: 	    if (&Apache::lonnet::homeserver($ca,$cd) eq 
                     97: 		$Apache::lonnet::perlvar{'lonHostID'}) {
                     98: 		$home++;
                     99: 		$outhash{'home_'.$ca.'@'.$cd}=1;
                    100: 	    } else {
                    101: 		$outhash{'otherhome_'.$ca.'@'.$cd}=
                    102: 		    &Apache::lonnet::homeserver($ca,$cd);
                    103: 		$other++;
                    104: 	    }
                    105: 	}
                    106:     }
                    107:     return ($home,$other,%outhash);
                    108: }
                    109: # ------------------------------------------------------ Generate "dump" button
                    110: 
                    111: sub dumpbutton {
                    112:     my ($home,$other,%outhash)=&authorhosts();
                    113:     if ($home+$other==0) { return ''; }
                    114:     my $output='</td><td bgcolor="#DDDDCC">';
                    115:     if ($home) {
                    116: 	return '</td><td bgcolor="#DDDDCC">'.
                    117: 	    '<input type="submit" name="dumpcourse" value="Dump Course DOCS to Construction Space" />';
                    118:     } else {
                    119: 	return'</td><td bgcolor="#DDDDCC">'.
                    120:       'Dump Course DOCS to Construction Space: available on other servers';
                    121:     }
                    122: }
                    123: 
                    124: # -------------------------------------------------------- Actually dump course
                    125: 
                    126: sub dumpcourse {
1.75      www       127:     my $r=shift;
                    128:     $r->print('<html><head><title>Dump DOCS</title></head>'.
1.76      www       129:         &Apache::loncommon::bodytag('Dump Course DOCS to Construction Space').
                    130: 	      '<form name="dumpdoc" method="post">');
1.74      www       131:     my ($home,$other,%outhash)=&authorhosts();
1.75      www       132:     unless ($home) { return ''; }
1.76      www       133:     my $origcrsid=$ENV{'request.course.id'};
                    134:     my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
                    135:     if (($ENV{'form.authorspace'}) && ($ENV{'form.authorfolder'}=~/\w/)) {
                    136: # Do the dumping
1.75      www       137: 	unless ($outhash{'home_'.$ENV{'form.authorspace'}}) { return ''; }
                    138: 	my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'});
1.79    ! www       139: 	$r->print('<h3>Copying Files</h3>');
1.76      www       140: 	my $title=$ENV{'form.authorfolder'};
1.79    ! www       141: 	$title=~s/[^\w\/]+/\_/g;
        !           142: 	my %replacehash=();
        !           143: 	foreach (keys %ENV) {
        !           144: 	    if ($_=~/^form\.namefor\_(.+)/) {
        !           145: 		$replacehash{$1}=$ENV{$_};
        !           146: 	    }
        !           147: 	}
        !           148: 	my $crs='/uploaded/'.$ENV{'request.course.id'}.'/';
        !           149: 	$crs=~s/\_/\//g;
        !           150: 	foreach (keys %replacehash) {
        !           151: 	    my $newfilename=$title.'/'.$replacehash{$_};
        !           152: 	    $newfilename=~s/[^\w\/\.]+/\_/g;
        !           153: 	    my @dirs=split(/\//,$newfilename);
        !           154: 	    my $path='/home/'.$ca.'/public_html';
        !           155: 	    my $makepath=$path;
        !           156: 	    my $fail=0;
        !           157: 	    for (my $i=0;$i<$#dirs;$i++) {
        !           158: 		$makepath.='/'.$dirs[$i];
        !           159: 		unless (-e $makepath) { 
        !           160: 		    unless(mkdir($makepath,0777)) { $fail=1; } 
        !           161: 		}
        !           162: 	    }
        !           163: 	    $r->print('<br /><tt>'.$_.'</tt> => <tt>'.$newfilename.'</tt>: ');
        !           164: 	    if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
        !           165: 		if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
        !           166: 		    print $fh &Apache::loncreatecourse::rewritefile(
        !           167:          &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_),
        !           168: 				     (%replacehash,$crs => '')
        !           169: 								    );
        !           170: 		} else {
        !           171: 		    print $fh
        !           172:          &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_);
        !           173: 		       }
        !           174: 		$fh->close();
        !           175: 	    } else {
        !           176: 		$fail=1;
        !           177: 	    }
        !           178: 	    if ($fail) {
        !           179: 		$r->print('<font color="red">fail</font>');
        !           180: 	    } else {
        !           181: 		$r->print('<font color="green">ok</font>');
        !           182: 	    }
        !           183: 	}
1.76      www       184:     } else {
                    185: # Input form
                    186: 	unless ($home==1) {
                    187: 	    $r->print(
                    188: 		      '<h3>Select the Construction Space</h3><select name="authorspace">');
                    189: 	}
                    190: 	foreach (sort keys %outhash) {
                    191: 	    if ($_=~/^home_(.+)$/) {
                    192: 		if ($home==1) {
                    193: 		    $r->print(
                    194: 		  '<input type="hidden" name="authorspace" value="'.$1.'" />');
                    195: 		} else {
                    196: 		    $r->print('<option value="'.$1.'">'.$_.'</option>');
                    197: 		}
                    198: 	    }
                    199: 	}
                    200: 	unless ($home==1) {
                    201: 	    $r->print('</select>');
                    202: 	}
                    203: 	my $title=$origcrsdata{'description'};
                    204: 	$title=~s/\s+/\_/gs;
                    205: 	$title=~s/\W//gs;
                    206: 	$r->print('<h3>Folder in Construction Space</h3><input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
                    207: 	&tiehash();
1.78      www       208: 	$r->print('<h3>Filenames in Construction Space</h3><table border="2"><tr><th>Internal Filename</th><th>Title</th><th>Save as ...</th></tr>');
1.76      www       209: 	foreach (&Apache::loncreatecourse::crsdirlist($origcrsid,'userfiles')) {
1.78      www       210: 	    $r->print('<tr><td>'.$_.'</td>');
                    211: 	    my ($ext)=($_=~/\.(\w+)$/);
                    212: 	    my $title=$hash{'title_'.$hash{
                    213: 		'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}};
                    214: 	    $r->print('<td>'.($title?$title:'&nbsp;').'</td>');
                    215: 	    unless ($title) {
                    216: 		$title=$_;
                    217: 	    }
                    218: 	    $title=~s/\.(\w+)$//;
                    219: 	    $title=~s/\W+/\_/gs;
                    220: 	    $title.='.'.$ext;
1.79    ! www       221: 	    $r->print("\n<td><input type='text' size='60' name='namefor_".$_."' value='".$title."' /></td></tr>\n");
1.76      www       222: 	}
1.78      www       223: 	$r->print("</table>\n");
1.76      www       224: 	&untiehash();
                    225: 	$r->print(
1.78      www       226:   '<p><input type="submit" name="dumpcourse" value="Dump Course DOCS" /></p></form>');
1.75      www       227:     }
1.74      www       228: }
1.76      www       229: 
1.74      www       230: 
1.73      bowersj2  231: # Imports the given (name, url) resources into the course
                    232: # coursenum, coursedom, and folder must precede the list
                    233: sub group_import {
                    234:     my $coursenum = shift;
                    235:     my $coursedom = shift;
                    236:     my $folder = shift;
                    237:     while (@_) {
                    238: 	my $name = shift;
                    239: 	my $url = shift;
                    240: 	if ($url) {
                    241: 	    my $idx = $#Apache::lonratedt::resources + 1;
                    242: 	    $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=$idx;
                    243: 	    my $ext = 'false';
                    244: 	    if ($url=~/^http:\/\//) { $ext = 'true'; }
                    245: 	    $url =~ s/:/\&colon;/g;
                    246: 	    $name =~ s/:/\&colon;/g;
                    247: 	    $Apache::lonratedt::resources[$idx] = 
                    248: 		join ':', ($name, $url, $ext, 'normal', 'res');
                    249: 	}
                    250:     }
                    251:     &storemap($coursenum, $coursedom, $folder);
                    252: }
                    253: 
1.7       www       254: sub editor {
                    255:     my ($r,$coursenum,$coursedom,$folder,$allowed)=@_;
1.17      www       256:     if ($ENV{'form.foldername'}) {
                    257: 	$r->print('<h3>Folder: '.$ENV{'form.foldername'}.'</h3>');
                    258:     }
1.10      www       259:     my $errtext='';
                    260:     my $fatal=0;
                    261:     ($errtext,$fatal)=
1.7       www       262:           &mapread($coursenum,$coursedom,$folder.'.sequence');
1.17      www       263:     if ($#Apache::lonratedt::order<1) {
                    264:        	$Apache::lonratedt::order[0]=1;
                    265:         $Apache::lonratedt::resources[1]='';
                    266:     }
1.7       www       267:     if ($fatal) {
                    268: 	   $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    269:     } else {
                    270: # ------------------------------------------------------------ Process commands
1.16      www       271: # ---------------- if they are for this folder and user allowed to make changes
                    272: 	if (($allowed) && ($ENV{'form.folder'} eq $folder)) {
1.10      www       273: # upload a file, if present
                    274:            if (($ENV{'form.uploaddoc.filename'}) &&
                    275:                ($ENV{'form.cmd'}=~/^upload_(\w+)/)) {
                    276: 	    if ($folder=~/^$1/) {
                    277: # this is for a course, not a user, so set coursedoc flag
                    278: # probably the only place in the system where this should be "1"
                    279: 	      my $url=&Apache::lonnet::userfileupload('uploaddoc',1);
                    280:               my $ext='false';
                    281:               if ($url=~/^http\:\/\//) { $ext='true'; }
                    282:               $url=~s/\:/\&colon;/g;
                    283: 	      my $comment=$ENV{'form.comment'};
                    284:               $comment=~s/\</\&lt\;/g;
                    285:               $comment=~s/\>/\&gt\;/g;
                    286:               $comment=~s/\:/\&colon;/g;
1.17      www       287:               if ($folder=~/^supplemental/) {
                    288: 		  $comment=time.'___&&&___'.$ENV{'user.name'}.'___&&&___'.
                    289: 		      $ENV{'user.domain'}.'___&&&___'.$comment;
                    290:               }
1.10      www       291:               my $newidx=$#Apache::lonratedt::resources+1;
                    292:               $Apache::lonratedt::resources[$newidx]=
                    293:                   $comment.':'.$url.':'.$ext.':normal:res';
                    294:               $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=
                    295:                                                               $newidx;       
                    296:  	      &storemap($coursenum,$coursedom,$folder.'.sequence');
                    297: 	     }
                    298:             }
1.8       www       299: 	    if ($ENV{'form.cmd'}) {
1.10      www       300:                 my ($cmd,$idx)=split(/\_/,$ENV{'form.cmd'});
                    301:                 if ($cmd eq 'del') {
                    302: 		    for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) {
                    303:                         $Apache::lonratedt::order[$i]=
                    304:                           $Apache::lonratedt::order[$i+1];
                    305:                     }
                    306:                     $#Apache::lonratedt::order--;
                    307:                 } elsif ($cmd eq 'up') {
1.38      www       308: 		  if (($idx) && (defined($Apache::lonratedt::order[$idx-1]))) {
1.10      www       309:                     my $i=$Apache::lonratedt::order[$idx-1];
                    310:                     $Apache::lonratedt::order[$idx-1]=
                    311: 			$Apache::lonratedt::order[$idx];
                    312:                     $Apache::lonratedt::order[$idx]=$i;
1.38      www       313: 		   }
1.10      www       314:                 } elsif ($cmd eq 'down') {
1.38      www       315: 		   if (defined($Apache::lonratedt::order[$idx+1])) {
1.10      www       316:                     my $i=$Apache::lonratedt::order[$idx+1];
                    317:                     $Apache::lonratedt::order[$idx+1]=
                    318: 			$Apache::lonratedt::order[$idx];
                    319:                     $Apache::lonratedt::order[$idx]=$i;
1.38      www       320: 		   }
1.36      www       321:                 } elsif ($cmd eq 'rename') {
                    322:                     my ($rtitle,@rrest)=split(/\:/,
                    323:                        $Apache::lonratedt::resources[
                    324: 				       $Apache::lonratedt::order[$idx]]);
1.38      www       325:                     my $comment=
                    326:                      &HTML::Entities::decode($ENV{'form.title'});
1.36      www       327:                     $comment=~s/\</\&lt\;/g;
                    328:                     $comment=~s/\>/\&gt\;/g;
                    329:                     $comment=~s/\:/\&colon;/g;
                    330:                     $Apache::lonratedt::resources[
                    331: 				       $Apache::lonratedt::order[$idx]]=
                    332:                              $comment.':'.join(':',@rrest);
                    333:                     
1.10      www       334:                 }
                    335: # Store the changed version
                    336: 		&storemap($coursenum,$coursedom,$folder.'.sequence');
1.8       www       337:             }
1.11      www       338: # Group import/search
                    339: 	    if ($ENV{'form.importdetail'}) {
1.73      bowersj2  340: 		my @imports;
                    341: 		foreach (split(/\&/,$ENV{'form.importdetail'})) {
                    342: 		    if (defined($_)) {
                    343: 			my ($name,$url)=split(/\=/,$_);
                    344: 			$name=&Apache::lonnet::unescape($name);
                    345: 			$url=&Apache::lonnet::unescape($url);
                    346: 			push @imports, $name, $url;
                    347: 		    }
                    348: 		}
1.11      www       349: # Store the changed version
1.73      bowersj2  350: 		group_import($coursenum, $coursedom, $folder, @imports);
1.11      www       351:             }
1.53      www       352: # Loading a complete map
                    353: 	   if (($ENV{'form.importmap'}) && ($ENV{'form.loadmap'})) {
                    354:               foreach
                    355: (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$ENV{'form.importmap'}))) {
                    356:                    my $idx=$#Apache::lonratedt::resources;
                    357:                    $idx++;
                    358:                    $Apache::lonratedt::resources[$idx]=$_;
                    359:                    $Apache::lonratedt::order
                    360:                             [$#Apache::lonratedt::order+1]=$idx;
                    361:                 }
                    362: 
                    363: # Store the changed version
                    364: 		&storemap($coursenum,$coursedom,$folder.'.sequence');
                    365:            }
1.16      www       366:        }
                    367: # ---------------------------------------------------------------- End commands
1.7       www       368: # ---------------------------------------------------------------- Print screen
1.10      www       369:         my $idx=0;
                    370:         $r->print('<table>');
                    371:         foreach (@Apache::lonratedt::order) {
                    372:            my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]);
                    373:            unless ($name) {  $name=(split(/\//,$url))[-1]; }
1.37      www       374:            unless ($name) { $name='NO RESOURCE'; $url='/adm/notfound.html'; }
1.50      www       375:            $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_));
1.10      www       376:            $idx++;
                    377:         }
                    378:         $r->print('</table>');
1.7       www       379:     }
                    380: }
1.1       www       381: 
1.8       www       382: # --------------------------------------------------------------- An entry line
                    383: 
                    384: sub entryline {
1.50      www       385:     my ($index,$title,$url,$folder,$allowed,$residx)=@_;
1.38      www       386:     $title=~s/\&colon\;/\:/g;
                    387:     $title=&HTML::Entities::encode(&HTML::Entities::decode(
                    388:      &Apache::lonnet::unescape($title)),'\"\<\>\&\'');
                    389:     my $renametitle=$title;
                    390:     my $foldertitle=$title;
                    391:     if ($title=~
                    392:  /^(\d+)\_\_\_\&amp\;\&amp\;\&amp\;\_\_\_(\w+)\_\_\_\&amp\;\&amp\;\&amp\;\_\_\_(\w+)\_\_\_\&amp\;\&amp\;\&amp\;\_\_\_(.*)$/
                    393: 	) { 
                    394:             $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
                    395:             $renametitle=$4;
                    396:             $title='<i>'.localtime($1).'</i> '.
                    397:                 &Apache::loncommon::plainname($2,$3).': <br>'.
                    398: 		$foldertitle;
                    399: 	}
                    400:     $renametitle=~s/\&quot\;/\\\"/g;
1.8       www       401:     my $line='<tr>';
                    402: # Edit commands
                    403:     if ($allowed) {
                    404:        $line.=(<<END);
1.54      www       405: <td><table border='0' cellspacing='2' cellpadding='0'>
                    406: <tr><td bgcolor="#DDDDDD">
                    407: <a href='/adm/coursedocs?folder=$folder&cmd=up_$index'>
1.8       www       408: <img src="${iconpath}move_up.gif" alt='UP' border='0' /></a></td></tr>
1.54      www       409: <tr><td bgcolor="#DDDDDD">
                    410: <a href='/adm/coursedocs?folder=$folder&cmd=down_$index'>
1.8       www       411: <img src="${iconpath}move_down.gif" alt='DOWN' border='0' /></a></td></tr>
1.54      www       412: </table></td><td bgcolor="#DDDDDD">
                    413: <a href='javascript:removeres("$folder","$index","$renametitle");'>
                    414: <font size="-2" color="#990000">Remove</font></a>
1.38      www       415: <a href='javascript:changename("$folder","$index","$renametitle");'>
1.54      www       416: <font size="-2" color="#009900">Rename</font></a></td>
1.8       www       417: END
                    418:     }
1.16      www       419: # Figure out what kind of a resource this is
                    420:     my ($extension)=($url=~/\.(\w+)$/);
                    421:     my $uploaded=($url=~/^\/*uploaded\//);
                    422:     my $icon='unknown';
                    423:     if (-e "/home/httpd/html/adm/lonIcons/$extension.gif") {
                    424: 	$icon=$extension;
1.10      www       425:     }
1.17      www       426:     my $isfolder=0;
1.16      www       427:     if ($uploaded) {
                    428:        if ($extension eq 'sequence') {
                    429: 	  $icon='folder_closed';
                    430:           $url=~/\/(\w+)\.sequence/;
                    431:           $url='/adm/coursedocs?folder='.$1;
1.17      www       432:           $isfolder=1;
1.16      www       433:        } else {
                    434: 	  $url=&Apache::lonnet::tokenwrapper($url);
                    435:        } 
                    436:     }
1.18      www       437:     $url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//;
1.71      www       438:     if (($residx) && ($folder!~/supplemental/)) {
1.50      www       439:        $url.=(($url=~/\?/)?'&':'?').'symb='.
                    440:        &Apache::lonnet::escape(&Apache::lonnet::symbclean(
                    441:           &Apache::lonnet::declutter('uploaded/'.
                    442:            $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.'/'.
                    443:            $ENV{'course.'.$ENV{'request.course.id'}.'.num'}.'/'.$folder.
                    444:            '.sequence').
                    445:            '___'.$residx.'___'.
                    446: 	   &Apache::lonnet::declutter($url)));
                    447:     }
1.48      www       448:     if ($isfolder) { $url.='&foldername='.
                    449:        &Apache::lonnet::escape($foldertitle); }
1.23      www       450:     $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'" target="cat_'.$folder.
                    451: '"><img src="/adm/lonIcons/'.
1.17      www       452:         $icon.'.gif" border="0"></a></td>'.
1.23      www       453:         "<td bgcolor='#FFFFBB'><a href='$url' target='cat_$folder'>$title</a></td></tr>";
1.8       www       454:     return $line;
                    455: }
                    456: 
1.27      www       457: # ---------------------------------------------------------------- tie the hash
                    458: 
                    459: sub tiehash {
                    460:     $hashtied=0;
                    461:     if ($ENV{'request.course.fn'}) {
                    462:         if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
                    463:             &GDBM_READER(),0640)) {
                    464:                 $hashtied=1;
                    465:         }
                    466:     }    
                    467: }
                    468: 
                    469: sub untiehash {
                    470:     if ($hashtied) { untie %hash; }
                    471:     $hashtied=0;
                    472: }
                    473: 
1.29      www       474: # --------------------------------------------------------------- check on this
                    475: 
                    476: sub checkonthis {
                    477:     my ($r,$url,$level,$title)=@_;
                    478:     $alreadyseen{$url}=1;
                    479:     $r->rflush();
1.41      www       480:     if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
1.29      www       481:        $r->print('<br />');
                    482:        for (my $i=0;$i<=$level*5;$i++) {
                    483:            $r->print('&nbsp;');
                    484:        }
                    485:        $r->print('<a href="'.$url.'" target="cat">'.
                    486: 		 ($title?$title:$url).'</a> ');
                    487:        if ($url=~/^\/res\//) {
                    488: 	  my $result=&Apache::lonnet::repcopy(
                    489:                               &Apache::lonnet::filelocation('',$url));
                    490:           if ($result==OK) {
                    491:              $r->print('<font color="green">ok</font>');
                    492:              $r->rflush();
1.34      www       493:              &Apache::lonnet::countacc($url);
                    494:              $url=~/\.(\w+)$/;
                    495:              if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
                    496: 		 $r->print('<br />');
                    497:                  $r->rflush();
                    498:                  for (my $i=0;$i<=$level*5;$i++) {
                    499:                      $r->print('&nbsp;');
                    500:                  }
                    501:                  $r->print('- Rendering: ');
1.69      albertel  502:                  my $oldpath=$ENV{'request.filename'};
                    503:                  $ENV{'request.filename'}=&Apache::lonnet::filelocation('',$url);
1.34      www       504:                  &Apache::lonxml::xmlparse($r,'web',
                    505:                    &Apache::lonnet::getfile(
1.35      albertel  506:                     &Apache::lonnet::filelocation('',$url)));
1.69      albertel  507: 		 $ENV{'request.filename'}=$oldpath;
1.34      www       508:                  if (($Apache::lonxml::errorcount) ||
                    509:                      ($Apache::lonxml::warningcount)) {
                    510: 		     if ($Apache::lonxml::errorcount) {
                    511:                         $r->print('<font color="red"><b>'.
                    512: 			  $Apache::lonxml::errorcount.' error(s)</b></font> ');
                    513:                      }
                    514: 		     if ($Apache::lonxml::warningcount) {
                    515:                         $r->print('<font color="blue">'.
                    516: 			  $Apache::lonxml::warningcount.' warning(s)</font>');
                    517:                      }
                    518:                  } else {
                    519:                      $r->print('<font color="green">ok</font>');
                    520:                  }
                    521:                  $r->rflush();
                    522:              }
1.29      www       523: 	     my $dependencies=
                    524:                 &Apache::lonnet::metadata($url,'dependencies');
                    525:              foreach (split(/\,/,$dependencies)) {
                    526: 		 if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {
                    527:                     &checkonthis($r,$_,$level+1);
                    528:                  }
                    529:              }
                    530:           } elsif ($result==HTTP_SERVICE_UNAVAILABLE) {
                    531:              $r->print('<font color="red"><b>connection down</b></font>');
                    532:           } elsif ($result==HTTP_NOT_FOUND) {
                    533:              $r->print('<font color="red"><b>not found</b></font>');
                    534:           } else {
                    535:              $r->print('<font color="red"><b>access denied</b></font>');
                    536:           }
                    537:       }
                    538:    }
                    539: }
                    540: 
1.1       www       541: 
1.75      www       542: #
                    543: # -------------------------------------------------------------- Verify Content
                    544: # 
                    545: sub verifycontent {
                    546:    my $r=shift; 
1.26      www       547:    my $loaderror=&Apache::lonnet::overloaderror($r);
                    548:    if ($loaderror) { return $loaderror; }
                    549: 
                    550:    $r->print('<html><head><title>Verify Content</title></head>'.
                    551:               &Apache::loncommon::bodytag('Verify Course Documents'));
1.27      www       552:    $hashtied=0;
1.30      www       553:    undef %alreadyseen;
                    554:    %alreadyseen=();
1.27      www       555:    &tiehash();
                    556:    foreach (keys %hash) {
1.28      www       557:        if (($_=~/^src\_(.+)$/) && (!$alreadyseen{$hash{$_}})) {
1.29      www       558:            &checkonthis($r,$hash{$_},0,$hash{'title_'.$1});
1.27      www       559:        }
                    560:    }
                    561:    &untiehash();
1.70      www       562:    $r->print('<h1>Done.</h1>');
1.75      www       563: }
                    564: 
                    565: # -------------------------------------------------------------- Check Versions
                    566: 
                    567: sub checkversions {
                    568:     my $r=shift;
                    569:    $r->print('<html><head><title>Check Versions</title></head>'.
1.26      www       570:               &Apache::loncommon::bodytag('Check Course Document Versions'));
1.27      www       571:    $hashtied=0;
                    572:    &tiehash();
1.30      www       573:    my %changes=&Apache::lonnet::dump
                    574:     ('versionupdate',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
                    575:                      $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.31      www       576:    my $firstkey=(keys %changes)[0];
                    577:    unless ($firstkey=~/^error\:/) {
                    578:        unless ($ENV{'form.timerange'}) {
                    579: 	   $ENV{'form.timerange'}=604800;
                    580:        }
                    581:        my $seltext='during the last '.$ENV{'form.timerange'}.' seconds';
                    582:        my $startsel='';
                    583:        my $monthsel='';
                    584:        my $weeksel='';
                    585:        my $daysel='';
                    586:        if ($ENV{'form.timerange'}==-1) {
                    587: 	   $seltext='since start of course';
                    588:            $startsel='selected';
1.32      www       589:            $ENV{'form.timerange'}=time;
                    590:        }
                    591:        my $starttime=time-$ENV{'form.timerange'};
                    592:        if ($ENV{'form.timerange'}==2592000) {
                    593:            $seltext='during the last month ('.localtime($starttime).')';
1.31      www       594:            $monthsel='selected';
                    595:        } elsif ($ENV{'form.timerange'}==604800) {
1.32      www       596:            $seltext='during the last week ('.localtime($starttime).')';
1.31      www       597:            $weeksel='selected';
                    598:        } elsif ($ENV{'form.timerange'}==86400) {
1.32      www       599:            $seltext='since yesterday ('.localtime($starttime).')';
1.31      www       600:            $daysel='selected';
                    601:        }
1.75      www       602: 
1.31      www       603:        $r->print(<<ENDHEADERS);
                    604: <form action="/adm/coursedocs" method="post">
                    605: <select name="timerange">
                    606: <option value="-1" $startsel>Since Start of Course</option>
                    607: <option value="2592000" $monthsel>Last Month</option>
                    608: <option value="604800" $weeksel>Last Week</option>
                    609: <option value="86400" $daysel>Since Yesterday</option>
                    610: </select>
                    611: <input type="submit" name="versions" value="Display" />
                    612: </form>
1.32      www       613: <h3>Content changed $seltext</h3>
1.31      www       614: <table border="2">
                    615: <tr>
                    616: <th>File</th><th>Modification Date</th>
                    617: <th>Version</th><th>Differences</th></tr>
                    618: ENDHEADERS
                    619:        foreach (keys %changes) {
1.32      www       620: 	  if ($changes{$_}>$starttime) {
                    621: 	     my ($root,$extension)=($_=~/^(.*)\.(\w+)$/);
                    622:              my $currentversion=&Apache::lonnet::getversion($_);
                    623:              my $linkurl=&Apache::lonnet::clutter($_);
                    624:              $r->print(
                    625:                  '<tr><td><a href="'.$linkurl.'" target="cat">'.$linkurl.
                    626:                  '</a></td><td>'.
                    627:                  localtime($changes{$_}).'</td><td>'.$currentversion.'</td>'.
                    628: 		       '<td>');
                    629:              my $lastold=1;
                    630:              for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
                    631:                  my $url=$root.'.'.$prevvers.'.'.$extension;
                    632:                  if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
                    633:                                                              $starttime) {
                    634:                      $lastold=$prevvers;
                    635:                  }
                    636:              }
                    637:             for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
                    638:                  my $url=$root.'.'.$prevvers.'.'.$extension;
                    639:                  $r->print('<a href="'.&Apache::lonnet::clutter($url).
                    640:                    '">Version '.$prevvers.' ('.
                    641:                  localtime(&Apache::lonnet::metadata($url,'lastrevisiondate')).
1.33      www       642:                  ')</a>');
                    643:                  if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
                    644:                     $r->print(' <a href="/adm/diff?filename='.
                    645:                             &Apache::lonnet::clutter($root.'.'.$extension).
                    646:                             '&versionone='.$prevvers.
                    647: 			     '">Diffs</a>');
                    648:                  }
                    649:                  $r->print('<br />');
1.32      www       650:              }
                    651:              $r->print('</td></tr>');
                    652:           }
1.31      www       653:        }
                    654:        $r->print('</table>');
1.70      www       655:        $r->print('<h1>Done.</h1>');
1.31      www       656:    } else {
                    657:        $r->print('<p>No content modifications yet.</p>');
1.30      www       658:    }
1.27      www       659:    &untiehash();
1.75      www       660: }
                    661: 
                    662: # ================================================================ Main Handler
                    663: sub handler {
                    664:     my $r = shift;
                    665:     $r->content_type('text/html');
                    666:     $r->send_http_header;
                    667:     return OK if $r->header_only;
                    668: 
                    669: # --------------------------------------------- Initialize help topics for this
                    670:   foreach ('Adding_Course_Doc','Main_Course_Documents',
                    671:            'Adding_External_Resource','Navigate_Content',
                    672:            'Adding_Folders','Docs_Overview', 'Load_Map',
                    673:            'Supplemental', 'Score_Upload_Form',
                    674:            'Importing_LON-CAPA_Resource','Uploading_From_Harddrive') {
                    675:       $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);
                    676:   }
                    677:     # Composite help files
                    678:     $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
                    679: 		    'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
                    680:     $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
                    681: 		    'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
                    682:     $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
                    683: 		    'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
                    684:     $help{'My Personal Info'} = &Apache::loncommon::help_open_topic(
                    685: 		  'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
                    686:     $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
                    687:  
                    688:   if ($ENV{'form.verify'}) {
                    689:       &verifycontent($r);
                    690:   } elsif ($ENV{'form.versions'}) {
                    691:       &checkversions($r);
                    692:   } elsif ($ENV{'form.dumpcourse'}) {
                    693:       &dumpcourse($r);
1.26      www       694:   } else {
1.7       www       695: # is this a standard course?
                    696: 
                    697:     my $standard=($ENV{'request.course.uri'}=~/^\/uploaded\//);
1.15      www       698:     my $forcestandard;
                    699:     my $forcesupplement;
                    700:     my $script='';
                    701:     my $allowed;
                    702:     my $events='';
1.19      www       703:     my $showdoc=0;
1.15      www       704:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.21      www       705:        ['folder','foldername']);
                    706:     if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
                    707:        $showdoc=$1;
                    708:     }
                    709:     unless ($showdoc) { # got called from remote
1.15      www       710:        $forcestandard=($ENV{'form.folder'}=~/^default_/);
                    711:        $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
1.7       www       712: 
1.4       www       713: # does this user have privileges to post, etc?
1.77      www       714:        $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
1.15      www       715:        if ($allowed) { 
                    716:          &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
                    717:          $script=&Apache::lonratedt::editscript('simple'); 
                    718:        }
                    719:     } else { # got called in sequence from course
                    720:        $allowed=0;
1.49      www       721:        $script='</script>'.&Apache::lonmenu::registerurl(1,undef).'<script>';
                    722:        $events='onLoad="'.&Apache::lonmenu::loadevents.
                    723:            '" onUnload="'.&Apache::lonmenu::unloadevents.'"';
1.3       www       724:     }
1.4       www       725: 
                    726: # get course data
                    727:     my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
                    728:     my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
                    729: 
1.14      www       730: # get personal data
                    731:  
                    732:     my $uname=$ENV{'user.name'};
                    733:     my $udom=$ENV{'user.domain'};
                    734:     my $plainname=&Apache::lonnet::escape(
                    735:                      &Apache::loncommon::plainname($uname,$udom));
                    736: 
1.8       www       737: # graphics settings
1.4       www       738: 
1.8       www       739:     $iconpath = $r->dir_config('lonIconsURL') . "/";
                    740: 
1.22      www       741:     my $now=time;
1.64      www       742: 
1.4       www       743: # print screen
1.1       www       744:     $r->print(<<ENDDOCUMENT);
                    745: <html>
                    746: <head>
                    747: <title>The LearningOnline Network with CAPA</title>
1.16      www       748: <script>
                    749: $script
1.20      www       750: </script>
1.19      www       751: ENDDOCUMENT
                    752:    if ($allowed) {
                    753:     $r->print(<<ENDNEWSCRIPT);
1.20      www       754: <script>
1.16      www       755: function makenewfolder(targetform,folderseq) {
                    756:     var foldername=prompt('Name of New Folder','New Folder');
                    757:     if (foldername) {
                    758: 	targetform.importdetail.value=foldername+"="+folderseq;
                    759:         targetform.submit();
                    760:     }
                    761: }
                    762: 
1.18      www       763: function makenewext(targetname) {
                    764:     this.document.forms.extimport.useform.value=targetname;
                    765:     window.open('/adm/rat/extpickframe.html');
                    766: }
                    767: 
1.62      www       768: function makeexamupload() {
                    769:    var title=prompt('Listed Title for the Uploaded Score');
                    770:    if (title) { 
                    771:     this.document.forms.newexamupload.importdetail.value=
                    772: 	title+'=/res/lib/templates/examupload.problem';
                    773:     this.document.forms.newexamupload.submit();
                    774:    }
                    775: }
                    776: 
1.22      www       777: function makesmppage() {
1.38      www       778:    var title=prompt('Listed Title for the Page');
                    779:    if (title) { 
1.22      www       780:     this.document.forms.newsmppg.importdetail.value=
                    781: 	title+'=/adm/$udom/$uname/$now/smppg';
                    782:     this.document.forms.newsmppg.submit();
1.38      www       783:    }
1.22      www       784: }
                    785: 
1.55      www       786: function makesmpproblem() {
                    787:    var title=prompt('Listed Title for the Problem');
                    788:    if (title) { 
                    789:     this.document.forms.newsmpproblem.importdetail.value=
1.63      www       790: 	title+'=/res/lib/templates/simpleproblem.problem';
1.55      www       791:     this.document.forms.newsmpproblem.submit();
                    792:    }
                    793: }
                    794: 
1.22      www       795: function makebulboard() {
1.38      www       796:    var title=prompt('Listed Title for the Bulletin Board');
                    797:    if (title) {
1.22      www       798:     this.document.forms.newbul.importdetail.value=
                    799: 	title+'=/adm/$udom/$uname/$now/bulletinboard';
                    800:     this.document.forms.newbul.submit();
1.38      www       801:    }
1.22      www       802: }
                    803: 
1.18      www       804: function finishpick() {
                    805:     var title=this.document.forms.extimport.title.value;
                    806:     var url=this.document.forms.extimport.url.value;
                    807:     var form=this.document.forms.extimport.useform.value;
                    808:     eval
                    809:      ('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+
                    810:     '";this.document.forms.'+form+'.submit();');
1.16      www       811: }
1.36      www       812: 
                    813: function changename(folder,index,oldtitle) {
                    814:     var title=prompt('New Title',oldtitle);
                    815:     if (title) {
                    816: 	this.document.forms.renameform.title.value=title;
                    817: 	this.document.forms.renameform.cmd.value='rename_'+index;
1.54      www       818: 	this.document.forms.renameform.folder.value=folder;
                    819:         this.document.forms.renameform.submit();
                    820:     }
                    821: }
                    822: 
                    823: function removeres(folder,index,oldtitle) {
1.57      www       824:     if ((oldtitle=='NO RESOURCE') || (confirm('Remove "'+oldtitle+'"?'))) {
1.54      www       825: 	this.document.forms.renameform.cmd.value='del_'+index;
1.36      www       826: 	this.document.forms.renameform.folder.value=folder;
                    827:         this.document.forms.renameform.submit();
                    828:     }
                    829: }
1.16      www       830: </script>
1.42      www       831: 
                    832: ENDNEWSCRIPT
                    833:   }
                    834: # -------------------------------------------------------------------- Body tag
                    835:   $r->print('</head>'.
1.72      www       836:             &Apache::loncommon::bodytag('Course Documents','',$events,
                    837: 					'','',$showdoc));
1.42      www       838:   unless ($showdoc) {
                    839:     if ($allowed) {
1.74      www       840:        my $dumpbut=&dumpbutton();
1.42      www       841:        $r->print(<<ENDCOURSEVERIFY);
1.36      www       842: <form name="renameform" method="post" action="/adm/coursedocs">
                    843: <input type="hidden" name="title" />
                    844: <input type="hidden" name="cmd" />
                    845: <input type="hidden" name="folder" />
                    846: </form>
1.39      www       847: <form name="simpleedit" method="post" action="/adm/coursedocs">
                    848: <input type=hidden name="importdetail" value="">
                    849: <input type="hidden" name="folder" />
                    850: </form>
1.26      www       851: <form action="/adm/coursedocs" method="post" name="courseverify">
1.74      www       852: <table bgcolor="#AAAAAA" width="100%" cellspacing="4" cellpadding="4">
                    853: <tr><td bgcolor="#DDDDCC">
1.25      www       854: <input type="submit" name="verify" value="Verify Content" />
1.74      www       855: </td><td bgcolor="#DDDDCC">
1.25      www       856: <input type="submit" name="versions" value="Check Resource Versions" />
1.74      www       857: $dumpbut
                    858: </td></tr></table>
1.25      www       859: </form>
                    860: ENDCOURSEVERIFY
1.74      www       861:        $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
                    862: 		     'Editing the Table of Contents for your Course'));
1.25      www       863:     }
1.17      www       864: # --------------------------------------------------------- Standard documents
1.43      www       865:     $r->print('<table border=2 cellspacing=4 cellpadding=4>');
1.7       www       866:     if (($standard) && ($allowed) && (!$forcesupplement)) {
1.47      www       867:        $r->print('<tr><td bgcolor="#BBBBBB"><h2>Main Course Documents'.
                    868:   ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>');
1.7       www       869:        my $folder=$ENV{'form.folder'};
1.10      www       870:        unless ($folder=~/^default/) { $folder='default'; }
1.51      www       871:        my $postexec='';
                    872:        if ($folder eq 'default') {
                    873: 	   $r->print('<script>this.window.name="loncapaclient";</script>');
                    874:        } else {
                    875:            $postexec='self.close();';
                    876:        }
1.40      www       877:        $hadchanges=0;
1.7       www       878:        &editor($r,$coursenum,$coursedom,$folder,$allowed);
1.40      www       879:        if ($hadchanges) {
1.51      www       880: 	   $r->print(
                    881: '<script>function reinit(tf) { tf.submit();'.$postexec.' }</script>'. 
                    882: '<form method="post" action="/adm/roles" target="loncapaclient">'.
                    883: '<input type="hidden" name="orgurl" value="/adm/coursedocs" /><input type="hidden" name="selectrole" value="1" /><h3><font color="red">Changes will become active for your current session after <input type="hidden" name="'.
1.67      www       884: $ENV{'request.role'}.'" value="1" /><input type="button" value="re-initializing course" onClick="reinit(this.form)"/>, or the next time you log in.'.
                    885: $help{'Caching'}.'</font></h3></form>');
1.40      www       886:        }
1.16      www       887:        my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
                    888:                      '.sequence';
1.47      www       889: 
1.8       www       890:        $r->print(<<ENDFORM);
1.43      www       891: <table cellspacing=4 cellpadding=4><tr>
1.16      www       892: <th bgcolor="#DDDDDD">Upload a new main course document</th>
                    893: <th bgcolor="#DDDDDD">Import a published document</th>
                    894: <th bgcolor="#DDDDDD">Special documents</th>
1.11      www       895: </tr>
1.16      www       896: <tr><td bgcolor="#DDDDDD">
1.11      www       897: File:<br />
1.10      www       898: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.59      www       899: <input type="file" name="uploaddoc" size="40">
1.8       www       900: <br />
1.58      albertel  901: Title:<br />
1.11      www       902: <input type="text" size="50" name="comment">
1.8       www       903: <input type="hidden" name="folder" value="$folder">
1.17      www       904: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.10      www       905: <input type="hidden" name="cmd" value="upload_default">
1.8       www       906: <input type="submit" value="Upload Document">
1.59      www       907: <nobr>
1.60      albertel  908:  $help{'Uploading_From_Harddrive'}
1.58      albertel  909: </nobr>
1.60      albertel  910: </form>
1.11      www       911: </td>
1.16      www       912: <td bgcolor="#DDDDDD">
1.39      www       913: <form action="/adm/coursedocs" method="post" name="simpleeditdefault">
1.53      www       914: <input type="hidden" name="folder" value="$folder">
                    915: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.11      www       916: <input type=button onClick=
1.39      www       917: "javascript:document.forms.simpleedit.folder.value='$folder';groupsearch()" value="Search">
1.58      albertel  918: <nobr>
1.11      www       919: <input type=button onClick=
1.39      www       920: "javascript:document.forms.simpleedit.folder.value='$folder';groupimport();" value="Import">
1.58      albertel  921: $help{'Importing_LON-CAPA_Resource'}
                    922: </nobr>
1.59      www       923: <p>
                    924: <hr />
1.68      bowersj2  925: <input type="text" size="20" name="importmap"><br />
                    926: <nobr><input type=button 
1.52      www       927: onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
1.68      bowersj2  928: value="Select Map"> <input type="submit" name="loadmap" value="Load Map">
                    929: $help{'Load_Map'}</nobr>
1.59      www       930: </p>
1.52      www       931: </form>
1.16      www       932: </td><td bgcolor="#DDDDDD">
1.11      www       933: <form action="/adm/coursedocs" method="post" name="newfolder">
1.16      www       934: <input type="hidden" name="folder" value="$folder">
1.17      www       935: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.13      www       936: <input type=hidden name="importdetail" value="">
1.58      albertel  937: <nobr>
1.16      www       938: <input name="newfolder" type="button"
                    939: onClick="javascript:makenewfolder(this.form,'$folderseq');"
1.58      albertel  940: value="New Folder" />$help{'Adding_Folders'}
                    941: </nobr>
1.11      www       942: </form>
                    943: <form action="/adm/coursedocs" method="post" name="newext">
1.16      www       944: <input type="hidden" name="folder" value="$folder">
1.17      www       945: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.13      www       946: <input type=hidden name="importdetail" value="">
1.58      albertel  947: <nobr>
1.18      www       948: <input name="newext" type="button" onClick="javascript:makenewext('newext');"
1.47      www       949: value="External Resource" /> $help{'Adding_External_Resource'}
1.58      albertel  950: </nobr>
1.11      www       951: </form>
                    952: <form action="/adm/coursedocs" method="post" name="newsyl">
1.16      www       953: <input type="hidden" name="folder" value="$folder">
1.17      www       954: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.14      www       955: <input type=hidden name="importdetail" 
                    956: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
1.58      albertel  957: <nobr>
1.47      www       958: <input name="newsyl" type="submit" value="Syllabus" /> 
1.65      bowersj2  959:  $help{'Syllabus'}
1.58      albertel  960: </nobr>
                    961: </form>
1.17      www       962: <form action="/adm/coursedocs" method="post" name="newnav">
1.20      www       963: <input type="hidden" name="folder" value="$folder">
                    964: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.15      www       965: <input type=hidden name="importdetail" 
                    966: value="Navigate Content=/adm/navmaps">
1.58      albertel  967: <nobr>
1.20      www       968: <input name="newnav" type="submit" value="Navigate Content" />
1.47      www       969: $help{'Navigate_Content'}
1.58      albertel  970: </nobr>
1.22      www       971: </form>
                    972: <form action="/adm/coursedocs" method="post" name="newsmppg">
                    973: <input type="hidden" name="folder" value="$folder">
                    974: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                    975: <input type=hidden name="importdetail" value="">
1.58      albertel  976: <nobr>
1.22      www       977: <input name="newsmppg" type="button" value="Simple Page"
1.65      bowersj2  978: onClick="javascript:makesmppage();" /> $help{'Simple Page'}
1.58      albertel  979: </nobr>
1.55      www       980: </form>
                    981: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
                    982: <input type="hidden" name="folder" value="$folder">
                    983: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                    984: <input type=hidden name="importdetail" value="">
1.58      albertel  985: <nobr>
1.55      www       986: <input name="newsmpproblem" type="button" value="Simple Problem"
1.65      bowersj2  987: onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
1.62      www       988: </nobr>
                    989: </form>
                    990: <form action="/adm/coursedocs" method="post" name="newexamupload">
                    991: <input type="hidden" name="folder" value="$folder">
                    992: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                    993: <input type=hidden name="importdetail" value="">
                    994: <nobr>
                    995: <input name="newexamupload" type="button" value="Score Upload Form"
                    996: onClick="javascript:makeexamupload();" />
1.66      bowersj2  997: $help{'Score_Upload_Form'}
1.58      albertel  998: </nobr>
1.22      www       999: </form>
                   1000: <form action="/adm/coursedocs" method="post" name="newbul">
                   1001: <input type="hidden" name="folder" value="$folder">
                   1002: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                   1003: <input type=hidden name="importdetail" value="">
1.58      albertel 1004: <nobr>
1.22      www      1005: <input name="newbulletin" type="button" value="Bulletin Board"
                   1006: onClick="javascript:makebulboard();" />
1.65      bowersj2 1007: $help{'Bulletin Board'}
1.58      albertel 1008: </nobr>
                   1009: </form>
1.12      www      1010: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.16      www      1011: <input type="hidden" name="folder" value="$folder">
1.17      www      1012: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.14      www      1013: <input type=hidden name="importdetail" 
                   1014: value="$plainname=/adm/$udom/$uname/aboutme">
1.58      albertel 1015: <nobr>
1.16      www      1016: <input name="newaboutme" type="submit" value="My Personal Info" />
1.65      bowersj2 1017: $help{'My Personal Info'}
1.58      albertel 1018: </nobr>
                   1019: </form>
1.11      www      1020: </td></tr>
                   1021: </table>
1.8       www      1022: ENDFORM
1.24      www      1023:        $r->print('</td></tr>');
1.7       www      1024:     }
                   1025: # ----------------------------------------------------- Supplemental documents
                   1026:     if (!$forcestandard) {
1.24      www      1027:        $r->print(
1.47      www      1028:   '<tr><td bgcolor="#BBBBBB"><h2>Supplemental Course Documents'.
                   1029:   ($allowed?' '.$help{'Supplemental'}:'').'</h2>');
1.7       www      1030:        my $folder=$ENV{'form.folder'};
1.10      www      1031:        unless ($folder=~/supplemental/) { $folder='supplemental'; }
1.7       www      1032:        &editor($r,$coursenum,$coursedom,$folder,$allowed);
1.8       www      1033:        if ($allowed) {
1.17      www      1034:        my $folderseq=
                   1035:                   '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
                   1036:                      '.sequence';
                   1037: 
1.8       www      1038:           $r->print(<<ENDSUPFORM);
1.43      www      1039: <table cellspacing=4 cellpadding=4><tr>
1.17      www      1040: <th bgcolor="#DDDDDD">Upload a new supplemental course document</th>
                   1041: <th bgcolor="#DDDDDD">Import a published document</th>
                   1042: <th bgcolor="#DDDDDD">Special documents</th>
                   1043: </tr>
                   1044: <tr><td bgcolor="#DDDDDD">
1.10      www      1045: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.59      www      1046: <input type="file" name="uploaddoc" size="40">
1.4       www      1047: <br />Comment:<br />
                   1048: <textarea cols=50 rows=4 name='comment'>
                   1049: </textarea>
1.8       www      1050: <input type="hidden" name="folder" value="$folder">
1.17      www      1051: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.10      www      1052: <input type="hidden" name="cmd" value="upload_supplemental">
1.58      albertel 1053: <nobr>
1.3       www      1054: <input type="submit" value="Upload Document">
1.58      albertel 1055:  $help{'Uploading_From_Harddrive'}
                   1056: </nobr>
                   1057: </form>
1.17      www      1058: </td>
                   1059: <td bgcolor="#DDDDDD">
1.39      www      1060: <form action="/adm/coursedocs" method="post" name="simpleeditsupplement">
1.53      www      1061: <input type="hidden" name="folder" value="$folder">
                   1062: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.17      www      1063: <input type=hidden name="importdetail" value="">
                   1064: <input type=button onClick=
1.39      www      1065: "javascript:document.forms.simpleedit.folder.value='$folder';groupsearch()" value="Search">
1.17      www      1066: <input type=button onClick=
1.47      www      1067: "javascript:document.forms.simpleedit.folder.value='$folder';groupimport();" value="Import">$help{'Importing_LON-CAPA_Resource'}
1.59      www      1068: <p>
                   1069: <hr />
1.53      www      1070: <input type="text" size="20" name="importmap">
                   1071: <input type=button 
                   1072: onClick="javascript:openbrowser('simpleeditsupplement','importmap','sequence,page','')"
1.61      www      1073: value="Select Map"><input type="submit" name="loadmap" value="Load Map">
1.59      www      1074: </p>
1.17      www      1075: </form>
                   1076: </td><td bgcolor="#DDDDDD">
1.18      www      1077: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.17      www      1078: <input type="hidden" name="folder" value="$folder">
                   1079: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                   1080: <input type=hidden name="importdetail" value="">
1.58      albertel 1081: <nobr>
1.17      www      1082: <input name="newfolder" type="button"
                   1083: onClick="javascript:makenewfolder(this.form,'$folderseq');"
1.47      www      1084: value="New Folder" /> $help{'Adding_Folders'}
1.58      albertel 1085: </nobr>
1.17      www      1086: </form>
1.18      www      1087: <form action="/adm/coursedocs" method="post" name="supnewext">
1.17      www      1088: <input type="hidden" name="folder" value="$folder">
                   1089: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                   1090: <input type=hidden name="importdetail" value="">
1.58      albertel 1091: <nobr>
1.18      www      1092: <input name="newext" type="button" 
                   1093: onClick="javascript:makenewext('supnewext');"
1.47      www      1094: value="External Resource" /> $help{'Adding_External_Resource'}
1.58      albertel 1095: </nobr>
1.17      www      1096: </form>
1.18      www      1097: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.17      www      1098: <input type="hidden" name="folder" value="$folder">
                   1099: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                   1100: <input type=hidden name="importdetail" 
                   1101: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
1.58      albertel 1102: <nobr>
1.17      www      1103: <input name="newsyl" type="submit" value="Syllabus" />
1.65      bowersj2 1104: $help{'Syllabus'}
1.58      albertel 1105: </nobr>
                   1106: </form>
1.18      www      1107: <form action="/adm/coursedocs" method="post" name="subnewaboutme">
1.17      www      1108: <input type="hidden" name="folder" value="$folder">
                   1109: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                   1110: <input type=hidden name="importdetail" 
                   1111: value="$plainname=/adm/$udom/$uname/aboutme">
1.58      albertel 1112: <nobr>
1.17      www      1113: <input name="newaboutme" type="submit" value="My Personal Info" />
1.65      bowersj2 1114: $help{'My Personal Info'}
1.58      albertel 1115: </nobr>
                   1116: </form>
1.17      www      1117: </td></tr>
1.24      www      1118: </table></td></tr>
1.8       www      1119: ENDSUPFORM
                   1120:        }
1.7       www      1121:     }
1.18      www      1122:     if ($allowed) {
                   1123: 	$r->print('<form name="extimport"><input type="hidden" name="title"><input type="hidden" name="url"><input type="hidden" name="useform"></form>');
                   1124:     }
1.24      www      1125:     $r->print('</table>');
1.19      www      1126:   } else {
                   1127: # -------------------------------------------------------- This is showdoc mode
                   1128:       $r->print("<h1>Uploaded Document</h1><p>It is recommended that you use an up-to-date virus scanner before handling this file.</p><p><table>".
1.21      www      1129:          &entryline(0,"Click to download or use your browser's Save Link function",$showdoc).'</table></p>');
1.19      www      1130:   }
1.26      www      1131:  }
                   1132:  $r->print('</body></html>');
                   1133:  return OK;
1.1       www      1134: } 
                   1135: 
                   1136: 1;
                   1137: __END__

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