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

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

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