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

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

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