File:  [LON-CAPA] / loncom / interface / londocs.pm
Revision 1.34: download - view: text, annotated - select for diffs
Sun Oct 20 18:42:53 2002 UTC (21 years, 8 months ago) by www
Branches: MAIN
CVS tags: HEAD
Bug 112

    1: # The LearningOnline Network
    2: # Documents
    3: #
    4: # $Id: londocs.pm,v 1.34 2002/10/20 18:42:53 www Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   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.
   14: #
   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: 
   29: package Apache::londocs;
   30: 
   31: use strict;
   32: use Apache::Constants qw(:common :http);
   33: use Apache::lonnet;
   34: use Apache::loncommon;
   35: use Apache::lonratedt;
   36: use Apache::lonratsrv;
   37: use Apache::lonxml;
   38: use GDBM_File;
   39: 
   40: my $iconpath;
   41: 
   42: my %hash;
   43: 
   44: my $hashtied;
   45: my %alreadyseen=();
   46: 
   47: # Mapread read maps into lonratedt::global arrays 
   48: # @order and @resources, determines status
   49: # sets @order - pointer to resources in right order
   50: # sets @resources - array with the resources with correct idx
   51: #
   52: 
   53: sub mapread {
   54:     my ($coursenum,$coursedom,$map)=@_;
   55:     return
   56:       &Apache::lonratedt::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
   57:                                 $map);
   58: }
   59: 
   60: sub storemap {
   61:     my ($coursenum,$coursedom,$map)=@_;
   62:     return
   63:       &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
   64:                                 $map,1);
   65: }
   66: 
   67: sub editor {
   68:     my ($r,$coursenum,$coursedom,$folder,$allowed)=@_;
   69:     if ($ENV{'form.foldername'}) {
   70: 	$r->print('<h3>Folder: '.$ENV{'form.foldername'}.'</h3>');
   71:     }
   72:     my $errtext='';
   73:     my $fatal=0;
   74:     ($errtext,$fatal)=
   75:           &mapread($coursenum,$coursedom,$folder.'.sequence');
   76:     if ($#Apache::lonratedt::order<1) {
   77:        	$Apache::lonratedt::order[0]=1;
   78:         $Apache::lonratedt::resources[1]='';
   79:     }
   80:     if ($fatal) {
   81: 	   $r->print('<p><font color="red">'.$errtext.'</font></p>');
   82:     } else {
   83: # ------------------------------------------------------------ Process commands
   84: # ---------------- if they are for this folder and user allowed to make changes
   85: 	if (($allowed) && ($ENV{'form.folder'} eq $folder)) {
   86: # upload a file, if present
   87:            if (($ENV{'form.uploaddoc.filename'}) &&
   88:                ($ENV{'form.cmd'}=~/^upload_(\w+)/)) {
   89: 	    if ($folder=~/^$1/) {
   90: # this is for a course, not a user, so set coursedoc flag
   91: # probably the only place in the system where this should be "1"
   92: 	      my $url=&Apache::lonnet::userfileupload('uploaddoc',1);
   93:               my $ext='false';
   94:               if ($url=~/^http\:\/\//) { $ext='true'; }
   95:               $url=~s/\:/\&colon;/g;
   96: 	      my $comment=$ENV{'form.comment'};
   97:               $comment=~s/\</\&lt\;/g;
   98:               $comment=~s/\>/\&gt\;/g;
   99:               $comment=~s/\:/\&colon;/g;
  100:               if ($folder=~/^supplemental/) {
  101: 		  $comment=time.'___&&&___'.$ENV{'user.name'}.'___&&&___'.
  102: 		      $ENV{'user.domain'}.'___&&&___'.$comment;
  103:               }
  104:               my $newidx=$#Apache::lonratedt::resources+1;
  105:               $Apache::lonratedt::resources[$newidx]=
  106:                   $comment.':'.$url.':'.$ext.':normal:res';
  107:               $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=
  108:                                                               $newidx;       
  109:  	      &storemap($coursenum,$coursedom,$folder.'.sequence');
  110: 	     }
  111:             }
  112: 	    if ($ENV{'form.cmd'}) {
  113:                 my ($cmd,$idx)=split(/\_/,$ENV{'form.cmd'});
  114:                 if ($cmd eq 'del') {
  115: 		    for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) {
  116:                         $Apache::lonratedt::order[$i]=
  117:                           $Apache::lonratedt::order[$i+1];
  118:                     }
  119:                     $#Apache::lonratedt::order--;
  120:                 } elsif ($cmd eq 'up') {
  121:                     my $i=$Apache::lonratedt::order[$idx-1];
  122:                     $Apache::lonratedt::order[$idx-1]=
  123: 			$Apache::lonratedt::order[$idx];
  124:                     $Apache::lonratedt::order[$idx]=$i;
  125:                 } elsif ($cmd eq 'down') {
  126:                     my $i=$Apache::lonratedt::order[$idx+1];
  127:                     $Apache::lonratedt::order[$idx+1]=
  128: 			$Apache::lonratedt::order[$idx];
  129:                     $Apache::lonratedt::order[$idx]=$i;
  130:                 }
  131: # Store the changed version
  132: 		&storemap($coursenum,$coursedom,$folder.'.sequence');
  133:             }
  134: # Group import/search
  135: 	    if ($ENV{'form.importdetail'}) {
  136:                foreach (split(/\&/,$ENV{'form.importdetail'})) {
  137:                   if (defined($_)) {
  138: 	             my ($name,$url)=split(/\=/,$_);
  139:                      $name=&Apache::lonnet::unescape($name);
  140:                      $url=&Apache::lonnet::unescape($url);
  141:                      if ($url) {
  142: 	                my $idx=$#Apache::lonratedt::resources+1;
  143:                         $Apache::lonratedt::order
  144:                            [$#Apache::lonratedt::order+1]=$idx;
  145:                         my $ext='false';
  146:                         if ($url=~/^http\:\/\//) { $ext='true'; }
  147:                         $url=~s/\:/\&colon;/g;
  148:                         $Apache::lonratedt::resources[$idx]=
  149:                            $name.':'.$url.':'.$ext.':normal:res';
  150: 	             }
  151:                  }
  152: 	      }
  153: # Store the changed version
  154: 		&storemap($coursenum,$coursedom,$folder.'.sequence');
  155:             }
  156:        }
  157: # ---------------------------------------------------------------- End commands
  158: # ---------------------------------------------------------------- Print screen
  159:         my $idx=0;
  160:         $r->print('<table>');
  161:         foreach (@Apache::lonratedt::order) {
  162:            my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]);
  163:            unless ($name) {  $name=(split(/\//,$url))[-1]; }
  164:            unless ($name) { $name='EMPTY'; }
  165:            $r->print(&entryline($idx,$name,$url,$folder,$allowed));
  166:            $idx++;
  167:         }
  168:         $r->print('</table>');
  169:     }
  170: }
  171: 
  172: # --------------------------------------------------------------- An entry line
  173: 
  174: sub entryline {
  175:     my ($index,$title,$url,$folder,$allowed)=@_;
  176:     my $line='<tr>';
  177: # Edit commands
  178:     if ($allowed) {
  179:        $line.=(<<END);
  180: <td><table border='0' cellspacing='0' cellpadding='0'>
  181: <tr><td><a href='/adm/coursedocs?folder=$folder&cmd=up_$index'>
  182: <img src="${iconpath}move_up.gif" alt='UP' border='0' /></a></td></tr>
  183: <tr><td><a href='/adm/coursedocs?folder=$folder&cmd=down_$index'>
  184: <img src="${iconpath}move_down.gif" alt='DOWN' border='0' /></a></td></tr>
  185: </table></td><td>
  186: <a href='/adm/coursedocs?folder=$folder&cmd=del_$index'>Remove</td>
  187: END
  188:     }
  189: # Figure out what kind of a resource this is
  190:     my ($extension)=($url=~/\.(\w+)$/);
  191:     my $uploaded=($url=~/^\/*uploaded\//);
  192:     my $icon='unknown';
  193:     if (-e "/home/httpd/html/adm/lonIcons/$extension.gif") {
  194: 	$icon=$extension;
  195:     }
  196:     my $isfolder=0;
  197:     if ($uploaded) {
  198:        if ($extension eq 'sequence') {
  199: 	  $icon='folder_closed';
  200:           $url=~/\/(\w+)\.sequence/;
  201:           $url='/adm/coursedocs?folder='.$1;
  202:           $isfolder=1;
  203:        } else {
  204: 	  $url=&Apache::lonnet::tokenwrapper($url);
  205:        } 
  206:     }
  207:     $url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//;
  208: # Title
  209:     $title=&Apache::lonnet::unescape($title);
  210:     my $foldertitle=$title;
  211:     if ($title=~
  212:  /^(\d+)\_\_\_\&\&\&\_\_\_(\w+)\_\_\_\&\&\&\_\_\_(\w+)\_\_\_\&\&\&\_\_\_(.*)$/
  213: 	) { 
  214:             $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
  215:             $title='<i>'.localtime($1).'</i> '.
  216:                 &Apache::loncommon::plainname($2,$3).': <br>'.
  217: 		$foldertitle;
  218: 	}
  219:     if ($isfolder) { $url.='&foldername='.$foldertitle; }
  220:     $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'" target="cat_'.$folder.
  221: '"><img src="/adm/lonIcons/'.
  222:         $icon.'.gif" border="0"></a></td>'.
  223:         "<td bgcolor='#FFFFBB'><a href='$url' target='cat_$folder'>$title</a></td></tr>";
  224:     return $line;
  225: }
  226: 
  227: # ---------------------------------------------------------------- tie the hash
  228: 
  229: sub tiehash {
  230:     $hashtied=0;
  231:     if ($ENV{'request.course.fn'}) {
  232:         if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
  233:             &GDBM_READER(),0640)) {
  234:                 $hashtied=1;
  235:         }
  236:     }    
  237: }
  238: 
  239: sub untiehash {
  240:     if ($hashtied) { untie %hash; }
  241:     $hashtied=0;
  242: }
  243: 
  244: # --------------------------------------------------------------- check on this
  245: 
  246: sub checkonthis {
  247:     my ($r,$url,$level,$title)=@_;
  248:     $alreadyseen{$url}=1;
  249:     $r->rflush();
  250:     if ($url) {
  251:        $r->print('<br />');
  252:        for (my $i=0;$i<=$level*5;$i++) {
  253:            $r->print('&nbsp;');
  254:        }
  255:        $r->print('<a href="'.$url.'" target="cat">'.
  256: 		 ($title?$title:$url).'</a> ');
  257:        if ($url=~/^\/res\//) {
  258: 	  my $result=&Apache::lonnet::repcopy(
  259:                               &Apache::lonnet::filelocation('',$url));
  260:           if ($result==OK) {
  261:              $r->print('<font color="green">ok</font>');
  262:              $r->rflush();
  263:              &Apache::lonnet::countacc($url);
  264:              $url=~/\.(\w+)$/;
  265:              if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
  266: 		 $r->print('<br />');
  267:                  $r->rflush();
  268:                  my $default='';
  269:                  if ($1=~/(problem|exam|quiz|assess|survey|form|library)/) {
  270:                     $default=&Apache::lonnet::getfile(
  271:                     '/home/httpd/html/res/adm/includes/default_homework.lcpm');
  272:                  }
  273:                  for (my $i=0;$i<=$level*5;$i++) {
  274:                      $r->print('&nbsp;');
  275:                  }
  276:                  $r->print('- Rendering: ');
  277:                  &Apache::lonxml::xmlparse($r,'web',
  278:                    &Apache::lonnet::getfile(
  279:                     &Apache::lonnet::filelocation('',$url)),$default);
  280:                  if (($Apache::lonxml::errorcount) ||
  281:                      ($Apache::lonxml::warningcount)) {
  282: 		     if ($Apache::lonxml::errorcount) {
  283:                         $r->print('<font color="red"><b>'.
  284: 			  $Apache::lonxml::errorcount.' error(s)</b></font> ');
  285:                      }
  286: 		     if ($Apache::lonxml::warningcount) {
  287:                         $r->print('<font color="blue">'.
  288: 			  $Apache::lonxml::warningcount.' warning(s)</font>');
  289:                      }
  290:                  } else {
  291:                      $r->print('<font color="green">ok</font>');
  292:                  }
  293:                  $r->rflush();
  294:              }
  295: 	     my $dependencies=
  296:                 &Apache::lonnet::metadata($url,'dependencies');
  297:              foreach (split(/\,/,$dependencies)) {
  298: 		 if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {
  299:                     &checkonthis($r,$_,$level+1);
  300:                  }
  301:              }
  302:           } elsif ($result==HTTP_SERVICE_UNAVAILABLE) {
  303:              $r->print('<font color="red"><b>connection down</b></font>');
  304:           } elsif ($result==HTTP_NOT_FOUND) {
  305:              $r->print('<font color="red"><b>not found</b></font>');
  306:           } else {
  307:              $r->print('<font color="red"><b>access denied</b></font>');
  308:           }
  309:       }
  310:    }
  311: }
  312: 
  313: # ================================================================ Main Handler
  314: sub handler {
  315:     my $r = shift;
  316:     $r->content_type('text/html');
  317:     $r->send_http_header;
  318:     return OK if $r->header_only;
  319: 
  320:   
  321:   if ($ENV{'form.verify'}) {
  322:  
  323:    my $loaderror=&Apache::lonnet::overloaderror($r);
  324:    if ($loaderror) { return $loaderror; }
  325: 
  326:    $r->print('<html><head><title>Verify Content</title></head>'.
  327:               &Apache::loncommon::bodytag('Verify Course Documents'));
  328:    $hashtied=0;
  329:    undef %alreadyseen;
  330:    %alreadyseen=();
  331:    &tiehash();
  332:    foreach (keys %hash) {
  333:        if (($_=~/^src\_(.+)$/) && (!$alreadyseen{$hash{$_}})) {
  334:            &checkonthis($r,$hash{$_},0,$hash{'title_'.$1});
  335:        }
  336:    }
  337:    &untiehash();
  338:   } elsif ($ENV{'form.versions'}) {
  339:     $r->print('<html><head><title>Check Versions</title></head>'.
  340:               &Apache::loncommon::bodytag('Check Course Document Versions'));
  341:    $hashtied=0;
  342:    &tiehash();
  343:    my %changes=&Apache::lonnet::dump
  344:     ('versionupdate',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  345:                      $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  346:    my $firstkey=(keys %changes)[0];
  347:    unless ($firstkey=~/^error\:/) {
  348:        unless ($ENV{'form.timerange'}) {
  349: 	   $ENV{'form.timerange'}=604800;
  350:        }
  351:        my $seltext='during the last '.$ENV{'form.timerange'}.' seconds';
  352:        my $startsel='';
  353:        my $monthsel='';
  354:        my $weeksel='';
  355:        my $daysel='';
  356:        if ($ENV{'form.timerange'}==-1) {
  357: 	   $seltext='since start of course';
  358:            $startsel='selected';
  359:            $ENV{'form.timerange'}=time;
  360:        }
  361:        my $starttime=time-$ENV{'form.timerange'};
  362:        if ($ENV{'form.timerange'}==2592000) {
  363:            $seltext='during the last month ('.localtime($starttime).')';
  364:            $monthsel='selected';
  365:        } elsif ($ENV{'form.timerange'}==604800) {
  366:            $seltext='during the last week ('.localtime($starttime).')';
  367:            $weeksel='selected';
  368:        } elsif ($ENV{'form.timerange'}==86400) {
  369:            $seltext='since yesterday ('.localtime($starttime).')';
  370:            $daysel='selected';
  371:        }
  372:  
  373:        $r->print(<<ENDHEADERS);
  374: <form action="/adm/coursedocs" method="post">
  375: <select name="timerange">
  376: <option value="-1" $startsel>Since Start of Course</option>
  377: <option value="2592000" $monthsel>Last Month</option>
  378: <option value="604800" $weeksel>Last Week</option>
  379: <option value="86400" $daysel>Since Yesterday</option>
  380: </select>
  381: <input type="submit" name="versions" value="Display" />
  382: </form>
  383: <h3>Content changed $seltext</h3>
  384: <table border="2">
  385: <tr>
  386: <th>File</th><th>Modification Date</th>
  387: <th>Version</th><th>Differences</th></tr>
  388: ENDHEADERS
  389:        foreach (keys %changes) {
  390: 	  if ($changes{$_}>$starttime) {
  391: 	     my ($root,$extension)=($_=~/^(.*)\.(\w+)$/);
  392:              my $currentversion=&Apache::lonnet::getversion($_);
  393:              my $linkurl=&Apache::lonnet::clutter($_);
  394:              $r->print(
  395:                  '<tr><td><a href="'.$linkurl.'" target="cat">'.$linkurl.
  396:                  '</a></td><td>'.
  397:                  localtime($changes{$_}).'</td><td>'.$currentversion.'</td>'.
  398: 		       '<td>');
  399:              my $lastold=1;
  400:              for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
  401:                  my $url=$root.'.'.$prevvers.'.'.$extension;
  402:                  if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
  403:                                                              $starttime) {
  404:                      $lastold=$prevvers;
  405:                  }
  406:              }
  407:             for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
  408:                  my $url=$root.'.'.$prevvers.'.'.$extension;
  409:                  $r->print('<a href="'.&Apache::lonnet::clutter($url).
  410:                    '">Version '.$prevvers.' ('.
  411:                  localtime(&Apache::lonnet::metadata($url,'lastrevisiondate')).
  412:                  ')</a>');
  413:                  if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
  414:                     $r->print(' <a href="/adm/diff?filename='.
  415:                             &Apache::lonnet::clutter($root.'.'.$extension).
  416:                             '&versionone='.$prevvers.
  417: 			     '">Diffs</a>');
  418:                  }
  419:                  $r->print('<br />');
  420:              }
  421:              $r->print('</td></tr>');
  422:           }
  423:        }
  424:        $r->print('</table>');
  425:    } else {
  426:        $r->print('<p>No content modifications yet.</p>');
  427:    }
  428:    &untiehash();
  429:   } else {
  430: # is this a standard course?
  431: 
  432:     my $standard=($ENV{'request.course.uri'}=~/^\/uploaded\//);
  433:     my $forcestandard;
  434:     my $forcesupplement;
  435:     my $script='';
  436:     my $allowed;
  437:     my $events='';
  438:     my $showdoc=0;
  439:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
  440:        ['folder','foldername']);
  441:     if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
  442:        $showdoc=$1;
  443:     }
  444:     unless ($showdoc) { # got called from remote
  445:        $forcestandard=($ENV{'form.folder'}=~/^default_/);
  446:        $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
  447: 
  448: # does this user have privileges to post, etc?
  449:        $allowed=&Apache::lonnet::allowed('srm',$ENV{'request.course.id'});
  450:        if ($allowed) { 
  451:          &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
  452:          $script=&Apache::lonratedt::editscript('simple'); 
  453:        }
  454:     } else { # got called in sequence from course
  455:        $allowed=0;
  456:        $script='</script>'.&Apache::lonxml::registerurl(1,undef).'<script>';
  457:        $events='onLoad="'.&Apache::lonxml::loadevents.
  458:            '" onUnload="'.&Apache::lonxml::unloadevents.'"';
  459:     }
  460: 
  461: # get course data
  462:     my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
  463:     my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
  464: 
  465: # get personal data
  466:  
  467:     my $uname=$ENV{'user.name'};
  468:     my $udom=$ENV{'user.domain'};
  469:     my $plainname=&Apache::lonnet::escape(
  470:                      &Apache::loncommon::plainname($uname,$udom));
  471: 
  472: # graphics settings
  473: 
  474:     $iconpath = $r->dir_config('lonIconsURL') . "/";
  475: 
  476:     my $now=time;
  477: 
  478: # print screen
  479:     $r->print(<<ENDDOCUMENT);
  480: <html>
  481: <head>
  482: <title>The LearningOnline Network with CAPA</title>
  483: <script>
  484: $script
  485: </script>
  486: ENDDOCUMENT
  487:    if ($allowed) {
  488:     $r->print(<<ENDNEWSCRIPT);
  489: <script>
  490: function makenewfolder(targetform,folderseq) {
  491:     var foldername=prompt('Name of New Folder','New Folder');
  492:     if (foldername) {
  493: 	targetform.importdetail.value=foldername+"="+folderseq;
  494:         targetform.submit();
  495:     }
  496: }
  497: 
  498: function makenewext(targetname) {
  499:     this.document.forms.extimport.useform.value=targetname;
  500:     window.open('/adm/rat/extpickframe.html');
  501: }
  502: 
  503: function makesmppage() {
  504:     var title=prompt('Listed Title for the Page');
  505:     this.document.forms.newsmppg.importdetail.value=
  506: 	title+'=/adm/$udom/$uname/$now/smppg';
  507:     this.document.forms.newsmppg.submit();
  508: }
  509: 
  510: function makebulboard() {
  511:     var title=prompt('Listed Title for the Bulletin Board');
  512:     this.document.forms.newbul.importdetail.value=
  513: 	title+'=/adm/$udom/$uname/$now/bulletinboard';
  514:     this.document.forms.newbul.submit();
  515: }
  516: 
  517: function finishpick() {
  518:     var title=this.document.forms.extimport.title.value;
  519:     var url=this.document.forms.extimport.url.value;
  520:     var form=this.document.forms.extimport.useform.value;
  521:     eval
  522:      ('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+
  523:     '";this.document.forms.'+form+'.submit();');
  524: }
  525: </script>
  526: ENDNEWSCRIPT
  527:   }
  528: # -------------------------------------------------------------------- Body tag
  529:   $r->print('</head>'.
  530:             &Apache::loncommon::bodytag('Course Documents','',$events));
  531:   unless ($showdoc) {
  532:     if ($allowed) {
  533:        $r->print(<<ENDCOURSEVERIFY);
  534: <form action="/adm/coursedocs" method="post" name="courseverify">
  535: <input type="submit" name="verify" value="Verify Content" />
  536: <input type="submit" name="versions" value="Check Resource Versions" />
  537: </form>
  538: ENDCOURSEVERIFY
  539:     }
  540: # --------------------------------------------------------- Standard documents
  541:     $r->print('<table>');
  542:     if (($standard) && ($allowed) && (!$forcesupplement)) {
  543:        $r->print('<tr><td bgcolor="#FFFFBB"><h2>Main Course Documents</h2>');
  544:        my $folder=$ENV{'form.folder'};
  545:        unless ($folder=~/^default/) { $folder='default'; }
  546:        &editor($r,$coursenum,$coursedom,$folder,$allowed);
  547:        my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
  548:                      '.sequence';
  549:        $r->print(<<ENDFORM);
  550: <table cellspacing=2><tr>
  551: <th bgcolor="#DDDDDD">Upload a new main course document</th>
  552: <th bgcolor="#DDDDDD">Import a published document</th>
  553: <th bgcolor="#DDDDDD">Special documents</th>
  554: </tr>
  555: <tr><td bgcolor="#DDDDDD">
  556: File:<br />
  557: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
  558: <input type="file" name="uploaddoc" size="50">
  559: <br />
  560: Title:<br /> 
  561: <input type="text" size="50" name="comment">
  562: <input type="hidden" name="folder" value="$folder">
  563: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
  564: <input type="hidden" name="cmd" value="upload_default">
  565: <input type="submit" value="Upload Document">
  566: </form>
  567: </td>
  568: <td bgcolor="#DDDDDD">
  569: <form action="/adm/coursedocs" method="post" name="simpleedit">
  570: <input type="hidden" name="folder" value="$folder">
  571: <input type=hidden name="importdetail" value="">
  572: <input type=button onClick=
  573: "javascript:groupsearch()" value="Search">
  574: <input type=button onClick=
  575: "javascript:groupimport();" value="Import">
  576: </form>
  577: </td><td bgcolor="#DDDDDD">
  578: <form action="/adm/coursedocs" method="post" name="newfolder">
  579: <input type="hidden" name="folder" value="$folder">
  580: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
  581: <input type=hidden name="importdetail" value="">
  582: <input name="newfolder" type="button"
  583: onClick="javascript:makenewfolder(this.form,'$folderseq');"
  584: value="New Folder" />
  585: </form>
  586: <form action="/adm/coursedocs" method="post" name="newext">
  587: <input type="hidden" name="folder" value="$folder">
  588: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
  589: <input type=hidden name="importdetail" value="">
  590: <input name="newext" type="button" onClick="javascript:makenewext('newext');"
  591: value="External Resource" />
  592: </form>
  593: <form action="/adm/coursedocs" method="post" name="newsyl">
  594: <input type="hidden" name="folder" value="$folder">
  595: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
  596: <input type=hidden name="importdetail" 
  597: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
  598: <input name="newsyl" type="submit" value="Syllabus" />
  599: </form>
  600: <form action="/adm/coursedocs" method="post" name="newnav">
  601: <input type="hidden" name="folder" value="$folder">
  602: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
  603: <input type=hidden name="importdetail" 
  604: value="Navigate Content=/adm/navmaps">
  605: <input name="newnav" type="submit" value="Navigate Content" />
  606: </form>
  607: <form action="/adm/coursedocs" method="post" name="newsmppg">
  608: <input type="hidden" name="folder" value="$folder">
  609: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
  610: <input type=hidden name="importdetail" value="">
  611: <input name="newsmppg" type="button" value="Simple Page"
  612: onClick="javascript:makesmppage();" />
  613: </form>
  614: <form action="/adm/coursedocs" method="post" name="newbul">
  615: <input type="hidden" name="folder" value="$folder">
  616: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
  617: <input type=hidden name="importdetail" value="">
  618: <input name="newbulletin" type="button" value="Bulletin Board"
  619: onClick="javascript:makebulboard();" />
  620: </form>
  621: <form action="/adm/coursedocs" method="post" name="newaboutme">
  622: <input type="hidden" name="folder" value="$folder">
  623: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
  624: <input type=hidden name="importdetail" 
  625: value="$plainname=/adm/$udom/$uname/aboutme">
  626: <input name="newaboutme" type="submit" value="My Personal Info" />
  627: </form>
  628: </td></tr>
  629: </table>
  630: ENDFORM
  631:        $r->print('</td></tr>');
  632:     }
  633: # ----------------------------------------------------- Supplemental documents
  634:     if (!$forcestandard) {
  635:        $r->print(
  636:   '<tr><td bgcolor="#BBFFFF"><h2>Supplemental Course Documents</h2>');
  637:        my $folder=$ENV{'form.folder'};
  638:        unless ($folder=~/supplemental/) { $folder='supplemental'; }
  639:        &editor($r,$coursenum,$coursedom,$folder,$allowed);
  640:        if ($allowed) {
  641:        my $folderseq=
  642:                   '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
  643:                      '.sequence';
  644: 
  645:           $r->print(<<ENDSUPFORM);
  646: <table cellspacing=2><tr>
  647: <th bgcolor="#DDDDDD">Upload a new supplemental course document</th>
  648: <th bgcolor="#DDDDDD">Import a published document</th>
  649: <th bgcolor="#DDDDDD">Special documents</th>
  650: </tr>
  651: <tr><td bgcolor="#DDDDDD">
  652: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
  653: <input type="file" name="uploaddoc" size="50">
  654: <br />Comment:<br />
  655: <textarea cols=50 rows=4 name='comment'>
  656: </textarea>
  657: <input type="hidden" name="folder" value="$folder">
  658: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
  659: <input type="hidden" name="cmd" value="upload_supplemental">
  660: <input type="submit" value="Upload Document">
  661: </form>
  662: </td>
  663: <td bgcolor="#DDDDDD">
  664: <form action="/adm/coursedocs" method="post" name="simpleedit">
  665: <input type="hidden" name="folder" value="$folder">
  666: <input type=hidden name="importdetail" value="">
  667: <input type=button onClick=
  668: "javascript:groupsearch()" value="Search">
  669: <input type=button onClick=
  670: "javascript:groupimport();" value="Import">
  671: </form>
  672: </td><td bgcolor="#DDDDDD">
  673: <form action="/adm/coursedocs" method="post" name="supnewfolder">
  674: <input type="hidden" name="folder" value="$folder">
  675: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
  676: <input type=hidden name="importdetail" value="">
  677: <input name="newfolder" type="button"
  678: onClick="javascript:makenewfolder(this.form,'$folderseq');"
  679: value="New Folder" />
  680: </form>
  681: <form action="/adm/coursedocs" method="post" name="supnewext">
  682: <input type="hidden" name="folder" value="$folder">
  683: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
  684: <input type=hidden name="importdetail" value="">
  685: <input name="newext" type="button" 
  686: onClick="javascript:makenewext('supnewext');"
  687: value="External Resource" />
  688: </form>
  689: <form action="/adm/coursedocs" method="post" name="supnewsyl">
  690: <input type="hidden" name="folder" value="$folder">
  691: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
  692: <input type=hidden name="importdetail" 
  693: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
  694: <input name="newsyl" type="submit" value="Syllabus" />
  695: </form>
  696: <form action="/adm/coursedocs" method="post" name="subnewaboutme">
  697: <input type="hidden" name="folder" value="$folder">
  698: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
  699: <input type=hidden name="importdetail" 
  700: value="$plainname=/adm/$udom/$uname/aboutme">
  701: <input name="newaboutme" type="submit" value="My Personal Info" />
  702: </form>
  703: </td></tr>
  704: </table></td></tr>
  705: ENDSUPFORM
  706:        }
  707:     }
  708:     if ($allowed) {
  709: 	$r->print('<form name="extimport"><input type="hidden" name="title"><input type="hidden" name="url"><input type="hidden" name="useform"></form>');
  710:     }
  711:     $r->print('</table>');
  712:   } else {
  713: # -------------------------------------------------------- This is showdoc mode
  714:       $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>".
  715:          &entryline(0,"Click to download or use your browser's Save Link function",$showdoc).'</table></p>');
  716:   }
  717:  }
  718:  $r->print('</body></html>');
  719:  return OK;
  720: } 
  721: 
  722: 1;
  723: __END__

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