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

1.1       www         1: # The LearningOnline Network
1.2       www         2: # Documents
1.1       www         3: #
1.27    ! www         4: # $Id: londocs.pm,v 1.26 2002/10/11 18:06:32 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;
                     32: use Apache::Constants qw(:common);
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.27    ! www        38: use GDBM_File;
1.7       www        39: 
1.8       www        40: my $iconpath;
1.7       www        41: 
1.27    ! www        42: my %hash;
        !            43: 
        !            44: my $hashtied;
        !            45: 
1.7       www        46: # Mapread read maps into lonratedt::global arrays 
1.10      www        47: # @order and @resources, determines status
1.7       www        48: # sets @order - pointer to resources in right order
                     49: # sets @resources - array with the resources with correct idx
                     50: #
                     51: 
                     52: sub mapread {
                     53:     my ($coursenum,$coursedom,$map)=@_;
                     54:     return
                     55:       &Apache::lonratedt::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
                     56:                                 $map);
                     57: }
                     58: 
                     59: sub storemap {
                     60:     my ($coursenum,$coursedom,$map)=@_;
                     61:     return
                     62:       &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.15      www        63:                                 $map,1);
1.7       www        64: }
                     65: 
                     66: sub editor {
                     67:     my ($r,$coursenum,$coursedom,$folder,$allowed)=@_;
1.17      www        68:     if ($ENV{'form.foldername'}) {
                     69: 	$r->print('<h3>Folder: '.$ENV{'form.foldername'}.'</h3>');
                     70:     }
1.10      www        71:     my $errtext='';
                     72:     my $fatal=0;
                     73:     ($errtext,$fatal)=
1.7       www        74:           &mapread($coursenum,$coursedom,$folder.'.sequence');
1.17      www        75:     if ($#Apache::lonratedt::order<1) {
                     76:        	$Apache::lonratedt::order[0]=1;
                     77:         $Apache::lonratedt::resources[1]='';
                     78:     }
1.7       www        79:     if ($fatal) {
                     80: 	   $r->print('<p><font color="red">'.$errtext.'</font></p>');
                     81:     } else {
                     82: # ------------------------------------------------------------ Process commands
1.16      www        83: # ---------------- if they are for this folder and user allowed to make changes
                     84: 	if (($allowed) && ($ENV{'form.folder'} eq $folder)) {
1.10      www        85: # upload a file, if present
                     86:            if (($ENV{'form.uploaddoc.filename'}) &&
                     87:                ($ENV{'form.cmd'}=~/^upload_(\w+)/)) {
                     88: 	    if ($folder=~/^$1/) {
                     89: # this is for a course, not a user, so set coursedoc flag
                     90: # probably the only place in the system where this should be "1"
                     91: 	      my $url=&Apache::lonnet::userfileupload('uploaddoc',1);
                     92:               my $ext='false';
                     93:               if ($url=~/^http\:\/\//) { $ext='true'; }
                     94:               $url=~s/\:/\&colon;/g;
                     95: 	      my $comment=$ENV{'form.comment'};
                     96:               $comment=~s/\</\&lt\;/g;
                     97:               $comment=~s/\>/\&gt\;/g;
                     98:               $comment=~s/\:/\&colon;/g;
1.17      www        99:               if ($folder=~/^supplemental/) {
                    100: 		  $comment=time.'___&&&___'.$ENV{'user.name'}.'___&&&___'.
                    101: 		      $ENV{'user.domain'}.'___&&&___'.$comment;
                    102:               }
1.10      www       103:               my $newidx=$#Apache::lonratedt::resources+1;
                    104:               $Apache::lonratedt::resources[$newidx]=
                    105:                   $comment.':'.$url.':'.$ext.':normal:res';
                    106:               $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=
                    107:                                                               $newidx;       
                    108:  	      &storemap($coursenum,$coursedom,$folder.'.sequence');
                    109: 	     }
                    110:             }
1.8       www       111: 	    if ($ENV{'form.cmd'}) {
1.10      www       112:                 my ($cmd,$idx)=split(/\_/,$ENV{'form.cmd'});
                    113:                 if ($cmd eq 'del') {
                    114: 		    for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) {
                    115:                         $Apache::lonratedt::order[$i]=
                    116:                           $Apache::lonratedt::order[$i+1];
                    117:                     }
                    118:                     $#Apache::lonratedt::order--;
                    119:                 } elsif ($cmd eq 'up') {
                    120:                     my $i=$Apache::lonratedt::order[$idx-1];
                    121:                     $Apache::lonratedt::order[$idx-1]=
                    122: 			$Apache::lonratedt::order[$idx];
                    123:                     $Apache::lonratedt::order[$idx]=$i;
                    124:                 } elsif ($cmd eq 'down') {
                    125:                     my $i=$Apache::lonratedt::order[$idx+1];
                    126:                     $Apache::lonratedt::order[$idx+1]=
                    127: 			$Apache::lonratedt::order[$idx];
                    128:                     $Apache::lonratedt::order[$idx]=$i;
                    129:                 }
                    130: # Store the changed version
                    131: 		&storemap($coursenum,$coursedom,$folder.'.sequence');
1.8       www       132:             }
1.11      www       133: # Group import/search
                    134: 	    if ($ENV{'form.importdetail'}) {
                    135:                foreach (split(/\&/,$ENV{'form.importdetail'})) {
                    136:                   if (defined($_)) {
                    137: 	             my ($name,$url)=split(/\=/,$_);
                    138:                      $name=&Apache::lonnet::unescape($name);
                    139:                      $url=&Apache::lonnet::unescape($url);
                    140:                      if ($url) {
                    141: 	                my $idx=$#Apache::lonratedt::resources+1;
                    142:                         $Apache::lonratedt::order
                    143:                            [$#Apache::lonratedt::order+1]=$idx;
                    144:                         my $ext='false';
                    145:                         if ($url=~/^http\:\/\//) { $ext='true'; }
                    146:                         $url=~s/\:/\&colon;/g;
                    147:                         $Apache::lonratedt::resources[$idx]=
                    148:                            $name.':'.$url.':'.$ext.':normal:res';
                    149: 	             }
                    150:                  }
                    151: 	      }
                    152: # Store the changed version
                    153: 		&storemap($coursenum,$coursedom,$folder.'.sequence');
                    154:             }
1.16      www       155:        }
                    156: # ---------------------------------------------------------------- End commands
1.7       www       157: # ---------------------------------------------------------------- Print screen
1.10      www       158:         my $idx=0;
                    159:         $r->print('<table>');
                    160:         foreach (@Apache::lonratedt::order) {
                    161:            my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]);
                    162:            unless ($name) {  $name=(split(/\//,$url))[-1]; }
                    163:            unless ($name) { $name='EMPTY'; }
                    164:            $r->print(&entryline($idx,$name,$url,$folder,$allowed));
                    165:            $idx++;
                    166:         }
                    167:         $r->print('</table>');
1.7       www       168:     }
                    169: }
1.1       www       170: 
1.8       www       171: # --------------------------------------------------------------- An entry line
                    172: 
                    173: sub entryline {
                    174:     my ($index,$title,$url,$folder,$allowed)=@_;
                    175:     my $line='<tr>';
                    176: # Edit commands
                    177:     if ($allowed) {
                    178:        $line.=(<<END);
                    179: <td><table border='0' cellspacing='0' cellpadding='0'>
                    180: <tr><td><a href='/adm/coursedocs?folder=$folder&cmd=up_$index'>
                    181: <img src="${iconpath}move_up.gif" alt='UP' border='0' /></a></td></tr>
                    182: <tr><td><a href='/adm/coursedocs?folder=$folder&cmd=down_$index'>
                    183: <img src="${iconpath}move_down.gif" alt='DOWN' border='0' /></a></td></tr>
                    184: </table></td><td>
                    185: <a href='/adm/coursedocs?folder=$folder&cmd=del_$index'>Remove</td>
                    186: END
                    187:     }
1.16      www       188: # Figure out what kind of a resource this is
                    189:     my ($extension)=($url=~/\.(\w+)$/);
                    190:     my $uploaded=($url=~/^\/*uploaded\//);
                    191:     my $icon='unknown';
                    192:     if (-e "/home/httpd/html/adm/lonIcons/$extension.gif") {
                    193: 	$icon=$extension;
1.10      www       194:     }
1.17      www       195:     my $isfolder=0;
1.16      www       196:     if ($uploaded) {
                    197:        if ($extension eq 'sequence') {
                    198: 	  $icon='folder_closed';
                    199:           $url=~/\/(\w+)\.sequence/;
                    200:           $url='/adm/coursedocs?folder='.$1;
1.17      www       201:           $isfolder=1;
1.16      www       202:        } else {
                    203: 	  $url=&Apache::lonnet::tokenwrapper($url);
                    204:        } 
                    205:     }
1.18      www       206:     $url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//;
1.8       www       207: # Title
                    208:     $title=&Apache::lonnet::unescape($title);
1.17      www       209:     my $foldertitle=$title;
1.8       www       210:     if ($title=~
                    211:  /^(\d+)\_\_\_\&\&\&\_\_\_(\w+)\_\_\_\&\&\&\_\_\_(\w+)\_\_\_\&\&\&\_\_\_(.*)$/
1.17      www       212: 	) { 
                    213:             $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
                    214:             $title='<i>'.localtime($1).'</i> '.
                    215:                 &Apache::loncommon::plainname($2,$3).': <br>'.
                    216: 		$foldertitle;
1.8       www       217: 	}
1.17      www       218:     if ($isfolder) { $url.='&foldername='.$foldertitle; }
1.23      www       219:     $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'" target="cat_'.$folder.
                    220: '"><img src="/adm/lonIcons/'.
1.17      www       221:         $icon.'.gif" border="0"></a></td>'.
1.23      www       222:         "<td bgcolor='#FFFFBB'><a href='$url' target='cat_$folder'>$title</a></td></tr>";
1.8       www       223:     return $line;
                    224: }
                    225: 
1.27    ! www       226: # ---------------------------------------------------------------- tie the hash
        !           227: 
        !           228: sub tiehash {
        !           229:     $hashtied=0;
        !           230:     if ($ENV{'request.course.fn'}) {
        !           231:         if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
        !           232:             &GDBM_READER(),0640)) {
        !           233:                 $hashtied=1;
        !           234:         }
        !           235:     }    
        !           236: }
        !           237: 
        !           238: sub untiehash {
        !           239:     if ($hashtied) { untie %hash; }
        !           240:     $hashtied=0;
        !           241: }
        !           242: 
1.8       www       243: # ================================================================ Main Handler
1.1       www       244: sub handler {
                    245:     my $r = shift;
                    246:     $r->content_type('text/html');
                    247:     $r->send_http_header;
                    248:     return OK if $r->header_only;
                    249: 
1.27    ! www       250:   
1.26      www       251:   if ($ENV{'form.verify'}) {
                    252:  
                    253:    my $loaderror=&Apache::lonnet::overloaderror($r);
                    254:    if ($loaderror) { return $loaderror; }
                    255: 
                    256:    $r->print('<html><head><title>Verify Content</title></head>'.
                    257:               &Apache::loncommon::bodytag('Verify Course Documents'));
1.27    ! www       258:    $hashtied=0;
        !           259:    &tiehash();
        !           260:    foreach (keys %hash) {
        !           261:        if ($_=~/^src\_(.+)$/) {
        !           262:            my $resid=$1;
        !           263:            $r->rflush();
        !           264: 	   if ($hash{$_}) {
        !           265:                my $fn=$hash{$_};
        !           266:                $r->print('<br /><a href="'.$fn.'" target="cat">'.
        !           267: 		 ($hash{'title_'.$resid}?$hash{'title_'.$resid}:$fn).'</a> ');
        !           268:  	       if ($fn=~/^\/res\//) {
        !           269: 		   my $result=&Apache::lonnet::repcopy($fn);
        !           270:                    if ($result eq OK) {
        !           271:                        $r->print('<font color="green">ok</font>');
        !           272:                        $r->rflush();
        !           273: 		       my $dependencies=
        !           274:                           &Apache::lonnet::metadata($_,'dependencies');
        !           275:                        $r->print('Dependencies: '.$dependencies.'<br>');
        !           276:                    } elsif ($result eq HTTP_SERVICE_UNAVAILABLE) {
        !           277:                        $r->print(
        !           278:                          '<font color="red"><b>connection down</b></font>');
        !           279:                    } elsif ($result eq HTTP_NOT_FOUND) {
        !           280:                        $r->print('<font color="red"><b>not found</b></font>');
        !           281:                    } else {
        !           282:                        $r->print(
        !           283:                              '<font color="red"><b>access denied</b></font>');
        !           284:                    }
        !           285:                }
        !           286:            }
        !           287:        }
        !           288:    }
        !           289:    &untiehash();
1.26      www       290:   } elsif ($ENV{'form.versions'}) {
                    291:     $r->print('<html><head><title>Check Versions</title></head>'.
                    292:               &Apache::loncommon::bodytag('Check Course Document Versions'));
1.27    ! www       293:    $hashtied=0;
        !           294:    &tiehash();
1.26      www       295: 
1.27    ! www       296:    &untiehash();
1.26      www       297:   } else {
1.7       www       298: # is this a standard course?
                    299: 
                    300:     my $standard=($ENV{'request.course.uri'}=~/^\/uploaded\//);
1.15      www       301:     my $forcestandard;
                    302:     my $forcesupplement;
                    303:     my $script='';
                    304:     my $allowed;
                    305:     my $events='';
1.19      www       306:     my $showdoc=0;
1.15      www       307:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.21      www       308:        ['folder','foldername']);
                    309:     if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
                    310:        $showdoc=$1;
                    311:     }
                    312:     unless ($showdoc) { # got called from remote
1.15      www       313:        $forcestandard=($ENV{'form.folder'}=~/^default_/);
                    314:        $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
1.7       www       315: 
1.4       www       316: # does this user have privileges to post, etc?
1.15      www       317:        $allowed=&Apache::lonnet::allowed('srm',$ENV{'request.course.id'});
                    318:        if ($allowed) { 
                    319:          &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
                    320:          $script=&Apache::lonratedt::editscript('simple'); 
                    321:        }
                    322:     } else { # got called in sequence from course
                    323:        $allowed=0;
1.21      www       324:        $script='</script>'.&Apache::lonxml::registerurl(1,undef).'<script>';
1.15      www       325:        $events='onLoad="'.&Apache::lonxml::loadevents.
                    326:            '" onUnload="'.&Apache::lonxml::unloadevents.'"';
1.3       www       327:     }
1.4       www       328: 
                    329: # get course data
                    330:     my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
                    331:     my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
                    332: 
1.14      www       333: # get personal data
                    334:  
                    335:     my $uname=$ENV{'user.name'};
                    336:     my $udom=$ENV{'user.domain'};
                    337:     my $plainname=&Apache::lonnet::escape(
                    338:                      &Apache::loncommon::plainname($uname,$udom));
                    339: 
1.8       www       340: # graphics settings
1.4       www       341: 
1.8       www       342:     $iconpath = $r->dir_config('lonIconsURL') . "/";
                    343: 
1.22      www       344:     my $now=time;
                    345: 
1.4       www       346: # print screen
1.1       www       347:     $r->print(<<ENDDOCUMENT);
                    348: <html>
                    349: <head>
                    350: <title>The LearningOnline Network with CAPA</title>
1.16      www       351: <script>
                    352: $script
1.20      www       353: </script>
1.19      www       354: ENDDOCUMENT
                    355:    if ($allowed) {
                    356:     $r->print(<<ENDNEWSCRIPT);
1.20      www       357: <script>
1.16      www       358: function makenewfolder(targetform,folderseq) {
                    359:     var foldername=prompt('Name of New Folder','New Folder');
                    360:     if (foldername) {
                    361: 	targetform.importdetail.value=foldername+"="+folderseq;
                    362:         targetform.submit();
                    363:     }
                    364: }
                    365: 
1.18      www       366: function makenewext(targetname) {
                    367:     this.document.forms.extimport.useform.value=targetname;
                    368:     window.open('/adm/rat/extpickframe.html');
                    369: }
                    370: 
1.22      www       371: function makesmppage() {
                    372:     var title=prompt('Listed Title for the Page');
                    373:     this.document.forms.newsmppg.importdetail.value=
                    374: 	title+'=/adm/$udom/$uname/$now/smppg';
                    375:     this.document.forms.newsmppg.submit();
                    376: }
                    377: 
                    378: function makebulboard() {
                    379:     var title=prompt('Listed Title for the Bulletin Board');
                    380:     this.document.forms.newbul.importdetail.value=
                    381: 	title+'=/adm/$udom/$uname/$now/bulletinboard';
                    382:     this.document.forms.newbul.submit();
                    383: }
                    384: 
1.18      www       385: function finishpick() {
                    386:     var title=this.document.forms.extimport.title.value;
                    387:     var url=this.document.forms.extimport.url.value;
                    388:     var form=this.document.forms.extimport.useform.value;
                    389:     eval
                    390:      ('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+
                    391:     '";this.document.forms.'+form+'.submit();');
1.16      www       392: }
                    393: </script>
1.19      www       394: ENDNEWSCRIPT
                    395:   }
                    396: # -------------------------------------------------------------------- Body tag
1.20      www       397:   $r->print('</head>'.
                    398:             &Apache::loncommon::bodytag('Course Documents','',$events));
1.19      www       399:   unless ($showdoc) {
1.25      www       400:     if ($allowed) {
                    401:        $r->print(<<ENDCOURSEVERIFY);
1.26      www       402: <form action="/adm/coursedocs" method="post" name="courseverify">
1.25      www       403: <input type="submit" name="verify" value="Verify Content" />
                    404: <input type="submit" name="versions" value="Check Resource Versions" />
                    405: </form>
                    406: ENDCOURSEVERIFY
                    407:     }
1.17      www       408: # --------------------------------------------------------- Standard documents
1.24      www       409:     $r->print('<table>');
1.7       www       410:     if (($standard) && ($allowed) && (!$forcesupplement)) {
1.24      www       411:        $r->print('<tr><td bgcolor="#FFFFBB"><h2>Main Course Documents</h2>');
1.7       www       412:        my $folder=$ENV{'form.folder'};
1.10      www       413:        unless ($folder=~/^default/) { $folder='default'; }
1.7       www       414:        &editor($r,$coursenum,$coursedom,$folder,$allowed);
1.16      www       415:        my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
                    416:                      '.sequence';
1.8       www       417:        $r->print(<<ENDFORM);
1.16      www       418: <table cellspacing=2><tr>
                    419: <th bgcolor="#DDDDDD">Upload a new main course document</th>
                    420: <th bgcolor="#DDDDDD">Import a published document</th>
                    421: <th bgcolor="#DDDDDD">Special documents</th>
1.11      www       422: </tr>
1.16      www       423: <tr><td bgcolor="#DDDDDD">
1.11      www       424: File:<br />
1.10      www       425: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.8       www       426: <input type="file" name="uploaddoc" size="50">
                    427: <br />
1.11      www       428: Title:<br /> 
                    429: <input type="text" size="50" name="comment">
1.8       www       430: <input type="hidden" name="folder" value="$folder">
1.17      www       431: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.10      www       432: <input type="hidden" name="cmd" value="upload_default">
1.8       www       433: <input type="submit" value="Upload Document">
                    434: </form>
1.11      www       435: </td>
1.16      www       436: <td bgcolor="#DDDDDD">
1.11      www       437: <form action="/adm/coursedocs" method="post" name="simpleedit">
1.16      www       438: <input type="hidden" name="folder" value="$folder">
1.11      www       439: <input type=hidden name="importdetail" value="">
                    440: <input type=button onClick=
1.16      www       441: "javascript:groupsearch()" value="Search">
1.11      www       442: <input type=button onClick=
1.16      www       443: "javascript:groupimport();" value="Import">
1.11      www       444: </form>
1.16      www       445: </td><td bgcolor="#DDDDDD">
1.11      www       446: <form action="/adm/coursedocs" method="post" name="newfolder">
1.16      www       447: <input type="hidden" name="folder" value="$folder">
1.17      www       448: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.13      www       449: <input type=hidden name="importdetail" value="">
1.16      www       450: <input name="newfolder" type="button"
                    451: onClick="javascript:makenewfolder(this.form,'$folderseq');"
1.11      www       452: value="New Folder" />
                    453: </form>
                    454: <form action="/adm/coursedocs" method="post" name="newext">
1.16      www       455: <input type="hidden" name="folder" value="$folder">
1.17      www       456: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.13      www       457: <input type=hidden name="importdetail" value="">
1.18      www       458: <input name="newext" type="button" onClick="javascript:makenewext('newext');"
1.11      www       459: value="External Resource" />
                    460: </form>
                    461: <form action="/adm/coursedocs" method="post" name="newsyl">
1.16      www       462: <input type="hidden" name="folder" value="$folder">
1.17      www       463: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.14      www       464: <input type=hidden name="importdetail" 
                    465: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
                    466: <input name="newsyl" type="submit" value="Syllabus" />
1.15      www       467: </form>
1.17      www       468: <form action="/adm/coursedocs" method="post" name="newnav">
1.20      www       469: <input type="hidden" name="folder" value="$folder">
                    470: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.15      www       471: <input type=hidden name="importdetail" 
                    472: value="Navigate Content=/adm/navmaps">
1.20      www       473: <input name="newnav" type="submit" value="Navigate Content" />
1.22      www       474: </form>
                    475: <form action="/adm/coursedocs" method="post" name="newsmppg">
                    476: <input type="hidden" name="folder" value="$folder">
                    477: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                    478: <input type=hidden name="importdetail" value="">
                    479: <input name="newsmppg" type="button" value="Simple Page"
                    480: onClick="javascript:makesmppage();" />
                    481: </form>
                    482: <form action="/adm/coursedocs" method="post" name="newbul">
                    483: <input type="hidden" name="folder" value="$folder">
                    484: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                    485: <input type=hidden name="importdetail" value="">
                    486: <input name="newbulletin" type="button" value="Bulletin Board"
                    487: onClick="javascript:makebulboard();" />
1.12      www       488: </form>
                    489: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.16      www       490: <input type="hidden" name="folder" value="$folder">
1.17      www       491: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.14      www       492: <input type=hidden name="importdetail" 
                    493: value="$plainname=/adm/$udom/$uname/aboutme">
1.16      www       494: <input name="newaboutme" type="submit" value="My Personal Info" />
1.11      www       495: </form>
                    496: </td></tr>
                    497: </table>
1.8       www       498: ENDFORM
1.24      www       499:        $r->print('</td></tr>');
1.7       www       500:     }
                    501: # ----------------------------------------------------- Supplemental documents
                    502:     if (!$forcestandard) {
1.24      www       503:        $r->print(
                    504:   '<tr><td bgcolor="#BBFFFF"><h2>Supplemental Course Documents</h2>');
1.7       www       505:        my $folder=$ENV{'form.folder'};
1.10      www       506:        unless ($folder=~/supplemental/) { $folder='supplemental'; }
1.7       www       507:        &editor($r,$coursenum,$coursedom,$folder,$allowed);
1.8       www       508:        if ($allowed) {
1.17      www       509:        my $folderseq=
                    510:                   '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
                    511:                      '.sequence';
                    512: 
1.8       www       513:           $r->print(<<ENDSUPFORM);
1.17      www       514: <table cellspacing=2><tr>
                    515: <th bgcolor="#DDDDDD">Upload a new supplemental course document</th>
                    516: <th bgcolor="#DDDDDD">Import a published document</th>
                    517: <th bgcolor="#DDDDDD">Special documents</th>
                    518: </tr>
                    519: <tr><td bgcolor="#DDDDDD">
1.10      www       520: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.4       www       521: <input type="file" name="uploaddoc" size="50">
                    522: <br />Comment:<br />
                    523: <textarea cols=50 rows=4 name='comment'>
                    524: </textarea>
1.8       www       525: <input type="hidden" name="folder" value="$folder">
1.17      www       526: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.10      www       527: <input type="hidden" name="cmd" value="upload_supplemental">
1.3       www       528: <input type="submit" value="Upload Document">
                    529: </form>
1.17      www       530: </td>
                    531: <td bgcolor="#DDDDDD">
                    532: <form action="/adm/coursedocs" method="post" name="simpleedit">
                    533: <input type="hidden" name="folder" value="$folder">
                    534: <input type=hidden name="importdetail" value="">
                    535: <input type=button onClick=
                    536: "javascript:groupsearch()" value="Search">
                    537: <input type=button onClick=
                    538: "javascript:groupimport();" value="Import">
                    539: </form>
                    540: </td><td bgcolor="#DDDDDD">
1.18      www       541: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.17      www       542: <input type="hidden" name="folder" value="$folder">
                    543: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                    544: <input type=hidden name="importdetail" value="">
                    545: <input name="newfolder" type="button"
                    546: onClick="javascript:makenewfolder(this.form,'$folderseq');"
                    547: value="New Folder" />
                    548: </form>
1.18      www       549: <form action="/adm/coursedocs" method="post" name="supnewext">
1.17      www       550: <input type="hidden" name="folder" value="$folder">
                    551: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                    552: <input type=hidden name="importdetail" value="">
1.18      www       553: <input name="newext" type="button" 
                    554: onClick="javascript:makenewext('supnewext');"
1.17      www       555: value="External Resource" />
                    556: </form>
1.18      www       557: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.17      www       558: <input type="hidden" name="folder" value="$folder">
                    559: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                    560: <input type=hidden name="importdetail" 
                    561: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
                    562: <input name="newsyl" type="submit" value="Syllabus" />
                    563: </form>
1.18      www       564: <form action="/adm/coursedocs" method="post" name="subnewaboutme">
1.17      www       565: <input type="hidden" name="folder" value="$folder">
                    566: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
                    567: <input type=hidden name="importdetail" 
                    568: value="$plainname=/adm/$udom/$uname/aboutme">
                    569: <input name="newaboutme" type="submit" value="My Personal Info" />
                    570: </form>
                    571: </td></tr>
1.24      www       572: </table></td></tr>
1.8       www       573: ENDSUPFORM
                    574:        }
1.7       www       575:     }
1.18      www       576:     if ($allowed) {
                    577: 	$r->print('<form name="extimport"><input type="hidden" name="title"><input type="hidden" name="url"><input type="hidden" name="useform"></form>');
                    578:     }
1.24      www       579:     $r->print('</table>');
1.19      www       580:   } else {
                    581: # -------------------------------------------------------- This is showdoc mode
                    582:       $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       583:          &entryline(0,"Click to download or use your browser's Save Link function",$showdoc).'</table></p>');
1.19      www       584:   }
1.26      www       585:  }
                    586:  $r->print('</body></html>');
                    587:  return OK;
1.1       www       588: } 
                    589: 
                    590: 1;
                    591: __END__

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