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

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

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