File:  [LON-CAPA] / loncom / interface / londocs.pm
Revision 1.89: download - view: text, annotated - select for diffs
Tue Oct 28 00:31:02 2003 UTC (20 years, 8 months ago) by www
Branches: MAIN
CVS tags: HEAD
Work on screen to set resource versions.

    1: # The LearningOnline Network
    2: # Documents
    3: #
    4: # $Id: londocs.pm,v 1.89 2003/10/28 00:31:02 www Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: 
   29: package Apache::londocs;
   30: 
   31: use strict;
   32: use Apache::Constants qw(:common :http);
   33: use Apache::lonnet;
   34: use Apache::loncommon;
   35: use Apache::lonratedt;
   36: use Apache::lonratsrv;
   37: use Apache::lonxml;
   38: use Apache::loncreatecourse;
   39: use HTML::Entities;
   40: use GDBM_File;
   41: use Apache::lonlocal;
   42: 
   43: my $iconpath;
   44: 
   45: my %hash;
   46: 
   47: my $hashtied;
   48: my %alreadyseen=();
   49: 
   50: my $hadchanges;
   51: 
   52: # Available help topics
   53: 
   54: my %help=();
   55: 
   56: # Mapread read maps into lonratedt::global arrays 
   57: # @order and @resources, determines status
   58: # sets @order - pointer to resources in right order
   59: # sets @resources - array with the resources with correct idx
   60: #
   61: 
   62: sub mapread {
   63:     my ($coursenum,$coursedom,$map)=@_;
   64:     return
   65:       &Apache::lonratedt::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
   66:                                 $map);
   67: }
   68: 
   69: sub storemap {
   70:     my ($coursenum,$coursedom,$map)=@_;
   71:     $hadchanges=1;
   72:     return
   73:       &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
   74:                                 $map,1);
   75: }
   76: 
   77: # ----------------------------------------- Return hash with valid author names
   78: 
   79: sub authorhosts {
   80:     my %outhash=();
   81:     my $home=0;
   82:     my $other=0;
   83:     foreach (keys %ENV) {
   84: 	if ($_=~/^user\.role\.(au|ca)\.(.+)$/) {
   85: 	    my $role=$1;
   86: 	    my $realm=$2;
   87: 	    my ($start,$end)=split(/\./,$ENV{$_});
   88: 	    if (($start) && ($start>time)) { next; }
   89: 	    if (($end) && (time>$end)) { next; }
   90: 	    my $ca; my $cd;
   91: 	    if ($1 eq 'au') {
   92: 		$ca=$ENV{'user.name'};
   93: 		$cd=$ENV{'user.domain'};
   94: 	    } else {
   95: 		($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/);
   96: 	    }
   97: 	    if (&Apache::lonnet::homeserver($ca,$cd) eq 
   98: 		$Apache::lonnet::perlvar{'lonHostID'}) {
   99: 		$home++;
  100: 		$outhash{'home_'.$ca.'@'.$cd}=1;
  101: 	    } else {
  102: 		$outhash{'otherhome_'.$ca.'@'.$cd}=
  103: 		    &Apache::lonnet::homeserver($ca,$cd);
  104: 		$other++;
  105: 	    }
  106: 	}
  107:     }
  108:     return ($home,$other,%outhash);
  109: }
  110: # ------------------------------------------------------ Generate "dump" button
  111: 
  112: sub dumpbutton {
  113:     my ($home,$other,%outhash)=&authorhosts();
  114:     if ($home+$other==0) { return ''; }
  115:     my $output='</td><td bgcolor="#DDDDCC">';
  116:     if ($home) {
  117: 	return '</td><td bgcolor="#DDDDCC">'.
  118: 	    '<input type="submit" name="dumpcourse" value="'.
  119: 	    &mt('Dump Course DOCS to Construction Space').'" />';
  120:     } else {
  121: 	return'</td><td bgcolor="#DDDDCC">'.
  122:      &mt('Dump Course DOCS to Construction Space: available on other servers');
  123:     }
  124: }
  125: 
  126: # -------------------------------------------------------- Actually dump course
  127: 
  128: sub dumpcourse {
  129:     my $r=shift;
  130:     $r->print('<html><head><title>Dump DOCS</title></head>'.
  131:         &Apache::loncommon::bodytag('Dump Course DOCS to Construction Space').
  132: 	      '<form name="dumpdoc" method="post">');
  133:     my ($home,$other,%outhash)=&authorhosts();
  134:     unless ($home) { return ''; }
  135:     my $origcrsid=$ENV{'request.course.id'};
  136:     my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
  137:     if (($ENV{'form.authorspace'}) && ($ENV{'form.authorfolder'}=~/\w/)) {
  138: # Do the dumping
  139: 	unless ($outhash{'home_'.$ENV{'form.authorspace'}}) { return ''; }
  140: 	my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'});
  141: 	$r->print('<h3>'.&mt('Copying Files').'</h3>');
  142: 	my $title=$ENV{'form.authorfolder'};
  143: 	$title=~s/[^\w\/]+/\_/g;
  144: 	my %replacehash=();
  145: 	foreach (keys %ENV) {
  146: 	    if ($_=~/^form\.namefor\_(.+)/) {
  147: 		$replacehash{$1}=$ENV{$_};
  148: 	    }
  149: 	}
  150: 	my $crs='/uploaded/'.$ENV{'request.course.id'}.'/';
  151: 	$crs=~s/\_/\//g;
  152: 	foreach (keys %replacehash) {
  153: 	    my $newfilename=$title.'/'.$replacehash{$_};
  154: 	    $newfilename=~s/[^\w\/\.]+/\_/g;
  155: 	    my @dirs=split(/\//,$newfilename);
  156: 	    my $path='/home/'.$ca.'/public_html';
  157: 	    my $makepath=$path;
  158: 	    my $fail=0;
  159: 	    for (my $i=0;$i<$#dirs;$i++) {
  160: 		$makepath.='/'.$dirs[$i];
  161: 		unless (-e $makepath) { 
  162: 		    unless(mkdir($makepath,0777)) { $fail=1; } 
  163: 		}
  164: 	    }
  165: 	    $r->print('<br /><tt>'.$_.'</tt> => <tt>'.$newfilename.'</tt>: ');
  166: 	    if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
  167: 		if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
  168: 		    print $fh &Apache::loncreatecourse::rewritefile(
  169:          &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_),
  170: 				     (%replacehash,$crs => '')
  171: 								    );
  172: 		} else {
  173: 		    print $fh
  174:          &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_);
  175: 		       }
  176: 		$fh->close();
  177: 	    } else {
  178: 		$fail=1;
  179: 	    }
  180: 	    if ($fail) {
  181: 		$r->print('<font color="red">fail</font>');
  182: 	    } else {
  183: 		$r->print('<font color="green">ok</font>');
  184: 	    }
  185: 	}
  186:     } else {
  187: # Input form
  188: 	unless ($home==1) {
  189: 	    $r->print(
  190: 		      '<h3>'.&mt('Select the Construction Space').'</h3><select name="authorspace">');
  191: 	}
  192: 	foreach (sort keys %outhash) {
  193: 	    if ($_=~/^home_(.+)$/) {
  194: 		if ($home==1) {
  195: 		    $r->print(
  196: 		  '<input type="hidden" name="authorspace" value="'.$1.'" />');
  197: 		} else {
  198: 		    $r->print('<option value="'.$1.'">'.$_.'</option>');
  199: 		}
  200: 	    }
  201: 	}
  202: 	unless ($home==1) {
  203: 	    $r->print('</select>');
  204: 	}
  205: 	my $title=$origcrsdata{'description'};
  206: 	$title=~s/\s+/\_/gs;
  207: 	$title=~s/\W//gs;
  208: 	$r->print('<h3>'.&mt('Folder in Construction Space').'</h3><input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
  209: 	&tiehash();
  210: 	$r->print('<h3>'.&mt('Filenames in Construction Space').'</h3><table border="2"><tr><th>'.&mt('Internal Filename').'</th><th>'.&mt('Title').'</th><th>'.&mt('Save as ...').'</th></tr>');
  211: 	foreach (&Apache::loncreatecourse::crsdirlist($origcrsid,'userfiles')) {
  212: 	    $r->print('<tr><td>'.$_.'</td>');
  213: 	    my ($ext)=($_=~/\.(\w+)$/);
  214: 	    my $title=$hash{'title_'.$hash{
  215: 		'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}};
  216: 	    $r->print('<td>'.($title?$title:'&nbsp;').'</td>');
  217: 	    unless ($title) {
  218: 		$title=$_;
  219: 	    }
  220: 	    $title=~s/\.(\w+)$//;
  221: 	    $title=~s/\W+/\_/gs;
  222: 	    $title.='.'.$ext;
  223: 	    $r->print("\n<td><input type='text' size='60' name='namefor_".$_."' value='".$title."' /></td></tr>\n");
  224: 	}
  225: 	$r->print("</table>\n");
  226: 	&untiehash();
  227: 	$r->print(
  228:   '<p><input type="submit" name="dumpcourse" value="'.&mt('Dump Course DOCS').'" /></p></form>');
  229:     }
  230: }
  231: 
  232: 
  233: # Imports the given (name, url) resources into the course
  234: # coursenum, coursedom, and folder must precede the list
  235: sub group_import {
  236:     my $coursenum = shift;
  237:     my $coursedom = shift;
  238:     my $folder = shift;
  239:     while (@_) {
  240: 	my $name = shift;
  241: 	my $url = shift;
  242: 	if ($url) {
  243: 	    my $idx = $#Apache::lonratedt::resources + 1;
  244: 	    $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=$idx;
  245: 	    my $ext = 'false';
  246: 	    if ($url=~/^http:\/\//) { $ext = 'true'; }
  247: 	    $url =~ s/:/\&colon;/g;
  248: 	    $name =~ s/:/\&colon;/g;
  249: 	    $Apache::lonratedt::resources[$idx] = 
  250: 		join ':', ($name, $url, $ext, 'normal', 'res');
  251: 	}
  252:     }
  253:     &storemap($coursenum, $coursedom, $folder.'.sequence');
  254: }
  255: 
  256: sub editor {
  257:     my ($r,$coursenum,$coursedom,$folder,$allowed)=@_;
  258:     if ($ENV{'form.foldername'}) {
  259: 	$r->print('<h3>Folder: '.$ENV{'form.foldername'}.'</h3>');
  260:     }
  261:     my $errtext='';
  262:     my $fatal=0;
  263:     ($errtext,$fatal)=
  264:           &mapread($coursenum,$coursedom,$folder.'.sequence');
  265:     if ($#Apache::lonratedt::order<1) {
  266:        	$Apache::lonratedt::order[0]=1;
  267:         $Apache::lonratedt::resources[1]='';
  268:     }
  269:     if ($fatal) {
  270: 	   $r->print('<p><font color="red">'.$errtext.'</font></p>');
  271:     } else {
  272: # ------------------------------------------------------------ Process commands
  273: # ---------------- if they are for this folder and user allowed to make changes
  274: 	if (($allowed) && ($ENV{'form.folder'} eq $folder)) {
  275: # upload a file, if present
  276:            if (($ENV{'form.uploaddoc.filename'}) &&
  277:                ($ENV{'form.cmd'}=~/^upload_(\w+)/)) {
  278: 	    if ($folder=~/^$1/) {
  279: # this is for a course, not a user, so set coursedoc flag
  280: # probably the only place in the system where this should be "1"
  281: 	      my $url=&Apache::lonnet::userfileupload('uploaddoc',1);
  282:               my $ext='false';
  283:               if ($url=~/^http\:\/\//) { $ext='true'; }
  284:               $url=~s/\:/\&colon;/g;
  285: 	      my $comment=$ENV{'form.comment'};
  286:               $comment=~s/\</\&lt\;/g;
  287:               $comment=~s/\>/\&gt\;/g;
  288:               $comment=~s/\:/\&colon;/g;
  289:               if ($folder=~/^supplemental/) {
  290: 		  $comment=time.'___&&&___'.$ENV{'user.name'}.'___&&&___'.
  291: 		      $ENV{'user.domain'}.'___&&&___'.$comment;
  292:               }
  293:               my $newidx=$#Apache::lonratedt::resources+1;
  294:               $Apache::lonratedt::resources[$newidx]=
  295:                   $comment.':'.$url.':'.$ext.':normal:res';
  296:               $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=
  297:                                                               $newidx;       
  298:  	      &storemap($coursenum,$coursedom,$folder.'.sequence');
  299: 	     }
  300:             }
  301: 	    if ($ENV{'form.cmd'}) {
  302:                 my ($cmd,$idx)=split(/\_/,$ENV{'form.cmd'});
  303:                 if ($cmd eq 'del') {
  304: 		    for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) {
  305:                         $Apache::lonratedt::order[$i]=
  306:                           $Apache::lonratedt::order[$i+1];
  307:                     }
  308:                     $#Apache::lonratedt::order--;
  309:                 } elsif ($cmd eq 'up') {
  310: 		  if (($idx) && (defined($Apache::lonratedt::order[$idx-1]))) {
  311:                     my $i=$Apache::lonratedt::order[$idx-1];
  312:                     $Apache::lonratedt::order[$idx-1]=
  313: 			$Apache::lonratedt::order[$idx];
  314:                     $Apache::lonratedt::order[$idx]=$i;
  315: 		   }
  316:                 } elsif ($cmd eq 'down') {
  317: 		   if (defined($Apache::lonratedt::order[$idx+1])) {
  318:                     my $i=$Apache::lonratedt::order[$idx+1];
  319:                     $Apache::lonratedt::order[$idx+1]=
  320: 			$Apache::lonratedt::order[$idx];
  321:                     $Apache::lonratedt::order[$idx]=$i;
  322: 		   }
  323:                 } elsif ($cmd eq 'rename') {
  324:                     my ($rtitle,@rrest)=split(/\:/,
  325:                        $Apache::lonratedt::resources[
  326: 				       $Apache::lonratedt::order[$idx]]);
  327:                     my $comment=
  328:                      &HTML::Entities::decode($ENV{'form.title'});
  329:                     $comment=~s/\</\&lt\;/g;
  330:                     $comment=~s/\>/\&gt\;/g;
  331:                     $comment=~s/\:/\&colon;/g;
  332:                     $Apache::lonratedt::resources[
  333: 				       $Apache::lonratedt::order[$idx]]=
  334:                              $comment.':'.join(':',@rrest);
  335:                     
  336:                 }
  337: # Store the changed version
  338: 		&storemap($coursenum,$coursedom,$folder.'.sequence');
  339:             }
  340: # Group import/search
  341: 	    if ($ENV{'form.importdetail'}) {
  342: 		my @imports;
  343: 		foreach (split(/\&/,$ENV{'form.importdetail'})) {
  344: 		    if (defined($_)) {
  345: 			my ($name,$url)=split(/\=/,$_);
  346: 			$name=&Apache::lonnet::unescape($name);
  347: 			$url=&Apache::lonnet::unescape($url);
  348: 			push @imports, $name, $url;
  349: 		    }
  350: 		}
  351: # Store the changed version
  352: 		group_import($coursenum, $coursedom, $folder, @imports);
  353:             }
  354: # Loading a complete map
  355: 	   if (($ENV{'form.importmap'}) && ($ENV{'form.loadmap'})) {
  356:               foreach
  357: (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$ENV{'form.importmap'}))) {
  358:                    my $idx=$#Apache::lonratedt::resources;
  359:                    $idx++;
  360:                    $Apache::lonratedt::resources[$idx]=$_;
  361:                    $Apache::lonratedt::order
  362:                             [$#Apache::lonratedt::order+1]=$idx;
  363:                 }
  364: 
  365: # Store the changed version
  366: 		&storemap($coursenum,$coursedom,$folder.'.sequence');
  367:            }
  368:        }
  369: # ---------------------------------------------------------------- End commands
  370: # ---------------------------------------------------------------- Print screen
  371:         my $idx=0;
  372:         $r->print('<table>');
  373:         foreach (@Apache::lonratedt::order) {
  374:            my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]);
  375:            unless ($name) {  $name=(split(/\//,$url))[-1]; }
  376:            unless ($name) { $name='NO RESOURCE'; $url='/adm/notfound.html'; }
  377:            $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_));
  378:            $idx++;
  379:         }
  380:         $r->print('</table>');
  381:     }
  382: }
  383: 
  384: # --------------------------------------------------------------- An entry line
  385: 
  386: sub entryline {
  387:     my ($index,$title,$url,$folder,$allowed,$residx)=@_;
  388:     $title=~s/\&colon\;/\:/g;
  389:     $title=&HTML::Entities::encode(&HTML::Entities::decode(
  390:      &Apache::lonnet::unescape($title)),'\"\<\>\&\'');
  391:     my $renametitle=$title;
  392:     my $foldertitle=$title;
  393:     if ($title=~
  394:  /^(\d+)\_\_\_\&amp\;\&amp\;\&amp\;\_\_\_(\w+)\_\_\_\&amp\;\&amp\;\&amp\;\_\_\_(\w+)\_\_\_\&amp\;\&amp\;\&amp\;\_\_\_(.*)$/
  395: 	) { 
  396:             $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
  397:             $renametitle=$4;
  398:             $title='<i>'.&Apache::lonlocal::locallocaltime($1).'</i> '.
  399:                 &Apache::loncommon::plainname($2,$3).': <br />'.
  400: 		$foldertitle;
  401: 	}
  402:     $renametitle=~s/\&quot\;/\\\"/g;
  403:     my $line='<tr>';
  404: # Edit commands
  405:     if ($allowed) {
  406:        $line.=(<<END);
  407: <td><table border='0' cellspacing='2' cellpadding='0'>
  408: <tr><td bgcolor="#DDDDDD">
  409: <a href='/adm/coursedocs?folder=$folder&cmd=up_$index'>
  410: <img src="${iconpath}move_up.gif" alt='UP' border='0' /></a></td></tr>
  411: <tr><td bgcolor="#DDDDDD">
  412: <a href='/adm/coursedocs?folder=$folder&cmd=down_$index'>
  413: <img src="${iconpath}move_down.gif" alt='DOWN' border='0' /></a></td></tr>
  414: </table></td><td bgcolor="#DDDDDD">
  415: <a href='javascript:removeres("$folder","$index","$renametitle");'>
  416: <font size="-2" color="#990000">Remove</font></a>
  417: <a href='javascript:changename("$folder","$index","$renametitle");'>
  418: <font size="-2" color="#009900">Rename</font></a></td>
  419: END
  420:     }
  421: # Figure out what kind of a resource this is
  422:     my ($extension)=($url=~/\.(\w+)$/);
  423:     my $uploaded=($url=~/^\/*uploaded\//);
  424:     my $icon='unknown';
  425:     if (-e "/home/httpd/html/adm/lonIcons/$extension.gif") {
  426: 	$icon=$extension;
  427:     }
  428:     my $isfolder=0;
  429:     if ($uploaded) {
  430:        if ($extension eq 'sequence') {
  431: 	  $icon='folder_closed';
  432:           $url=~/\/(\w+)\.sequence/;
  433:           $url='/adm/coursedocs?folder='.$1;
  434:           $isfolder=1;
  435:        } else {
  436: 	  $url=&Apache::lonnet::tokenwrapper($url);
  437:        } 
  438:     }
  439:     $url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//;
  440:     if (($residx) && ($folder!~/supplemental/)) {
  441:        $url.=(($url=~/\?/)?'&':'?').'symb='.
  442:        &Apache::lonnet::escape(&Apache::lonnet::symbclean(
  443:           &Apache::lonnet::declutter('uploaded/'.
  444:            $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.'/'.
  445:            $ENV{'course.'.$ENV{'request.course.id'}.'.num'}.'/'.$folder.
  446:            '.sequence').
  447:            '___'.$residx.'___'.
  448: 	   &Apache::lonnet::declutter($url)));
  449:     }
  450:     if ($isfolder) { $url.='&foldername='.
  451:        &Apache::lonnet::escape($foldertitle); }
  452:     $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'" target="cat_'.$folder.
  453: '"><img src="/adm/lonIcons/'.
  454:         $icon.'.gif" border="0"></a></td>'.
  455:         "<td bgcolor='#FFFFBB'><a href='$url' target='cat_$folder'>$title</a></td></tr>";
  456:     return $line;
  457: }
  458: 
  459: # ---------------------------------------------------------------- tie the hash
  460: 
  461: sub tiehash {
  462:     $hashtied=0;
  463:     if ($ENV{'request.course.fn'}) {
  464:         if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
  465:             &GDBM_READER(),0640)) {
  466:                 $hashtied=1;
  467:         }
  468:     }    
  469: }
  470: 
  471: sub untiehash {
  472:     if ($hashtied) { untie %hash; }
  473:     $hashtied=0;
  474: }
  475: 
  476: # --------------------------------------------------------------- check on this
  477: 
  478: sub checkonthis {
  479:     my ($r,$url,$level,$title)=@_;
  480:     $alreadyseen{$url}=1;
  481:     $r->rflush();
  482:     if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
  483:        $r->print('<br />');
  484:        for (my $i=0;$i<=$level*5;$i++) {
  485:            $r->print('&nbsp;');
  486:        }
  487:        $r->print('<a href="'.$url.'" target="cat">'.
  488: 		 ($title?$title:$url).'</a> ');
  489:        if ($url=~/^\/res\//) {
  490: 	  my $result=&Apache::lonnet::repcopy(
  491:                               &Apache::lonnet::filelocation('',$url));
  492:           if ($result==OK) {
  493:              $r->print('<font color="green">'.&mt('ok').'</font>');
  494:              $r->rflush();
  495:              &Apache::lonnet::countacc($url);
  496:              $url=~/\.(\w+)$/;
  497:              if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
  498: 		 $r->print('<br />');
  499:                  $r->rflush();
  500:                  for (my $i=0;$i<=$level*5;$i++) {
  501:                      $r->print('&nbsp;');
  502:                  }
  503:                  $r->print('- '.&mt('Rendering').': ');
  504:                  my $oldpath=$ENV{'request.filename'};
  505:                  $ENV{'request.filename'}=&Apache::lonnet::filelocation('',$url);
  506:                  &Apache::lonxml::xmlparse($r,'web',
  507:                    &Apache::lonnet::getfile(
  508:                     &Apache::lonnet::filelocation('',$url)));
  509: 		 $ENV{'request.filename'}=$oldpath;
  510:                  if (($Apache::lonxml::errorcount) ||
  511:                      ($Apache::lonxml::warningcount)) {
  512: 		     if ($Apache::lonxml::errorcount) {
  513:                         $r->print('<font color="red"><b>'.
  514: 			  $Apache::lonxml::errorcount.' '.
  515: 				  &mt('error(s)').'</b></font> ');
  516:                      }
  517: 		     if ($Apache::lonxml::warningcount) {
  518:                         $r->print('<font color="blue">'.
  519: 			  $Apache::lonxml::warningcount.' '.
  520: 				  &mt('warning(s)').'</font>');
  521:                      }
  522:                  } else {
  523:                      $r->print('<font color="green">'.&mt('ok').'</font>');
  524:                  }
  525:                  $r->rflush();
  526:              }
  527: 	     my $dependencies=
  528:                 &Apache::lonnet::metadata($url,'dependencies');
  529:              foreach (split(/\,/,$dependencies)) {
  530: 		 if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {
  531:                     &checkonthis($r,$_,$level+1);
  532:                  }
  533:              }
  534:           } elsif ($result==HTTP_SERVICE_UNAVAILABLE) {
  535:              $r->print('<font color="red"><b>'.&mt('connection down').'</b></font>');
  536:           } elsif ($result==HTTP_NOT_FOUND) {
  537:              $r->print('<font color="red"><b>'.&mt('not found').'</b></font>');
  538:           } else {
  539:              $r->print('<font color="red"><b>'.&mt('access denied').'</b></font>');
  540:           }
  541:       }
  542:    }
  543: }
  544: 
  545: 
  546: #
  547: # -------------------------------------------------------------- Verify Content
  548: # 
  549: sub verifycontent {
  550:    my $r=shift; 
  551:    my $loaderror=&Apache::lonnet::overloaderror($r);
  552:    if ($loaderror) { return $loaderror; }
  553: 
  554:    $r->print('<html><head><title>Verify Content</title></head>'.
  555:               &Apache::loncommon::bodytag('Verify Course Documents'));
  556:    $hashtied=0;
  557:    undef %alreadyseen;
  558:    %alreadyseen=();
  559:    &tiehash();
  560:    foreach (keys %hash) {
  561:        if (($_=~/^src\_(.+)$/) && (!$alreadyseen{$hash{$_}})) {
  562:            &checkonthis($r,$hash{$_},0,$hash{'title_'.$1});
  563:        }
  564:    }
  565:    &untiehash();
  566:    $r->print('<h1>'.&mt('Done').'.</h1>');
  567: }
  568: 
  569: # -------------------------------------------------------------- Check Versions
  570: 
  571: sub checkversions {
  572:     my $r=shift;
  573:     $r->print('<html><head><title>Check Versions</title></head>'.
  574:               &Apache::loncommon::bodytag('Check Course Document Versions'));
  575:     $hashtied=0;
  576:     &tiehash();
  577:     my $header='';
  578:     my $startsel='';
  579:     my $monthsel='';
  580:     my $weeksel='';
  581:     my $daysel='';
  582:     my $allsel='';
  583:     my %changes=();
  584:     my $starttime=0;
  585:     if ($ENV{'form.timerange'} eq 'all') {
  586: # show all documents
  587: 	$header=&mt('All Documents in Course');
  588:     } else {
  589: # show documents which changed
  590: 	%changes=&Apache::lonnet::dump
  591: 	 ('versionupdate',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  592:                      $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  593: 	my $firstkey=(keys %changes)[0];
  594: 	unless ($firstkey=~/^error\:/) {
  595: 	    unless ($ENV{'form.timerange'}) {
  596: 		$ENV{'form.timerange'}=604800;
  597: 	    }
  598: 	    my $seltext=&mt('during the last').' '.$ENV{'form.timerange'}.' '
  599: 		.&mt('seconds');
  600: 	    if ($ENV{'form.timerange'}==-1) {
  601: 		$seltext='since start of course';
  602: 		$startsel='selected';
  603: 		$ENV{'form.timerange'}=time;
  604: 	    }
  605: 	    $starttime=time-$ENV{'form.timerange'};
  606: 	    if ($ENV{'form.timerange'}==2592000) {
  607: 		$seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
  608: 		$monthsel='selected';
  609: 	    } elsif ($ENV{'form.timerange'}==604800) {
  610: 		$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
  611: 		$weeksel='selected';
  612: 	    } elsif ($ENV{'form.timerange'}==86400) {
  613: 		$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
  614: 		$daysel='selected';
  615: 	    }
  616: 	    $header=&mt('Content changed').' '.$seltext;
  617: 	} else {
  618: 	    $header=&mt('No content modifications yet.');
  619: 	}
  620:     }
  621:     my %lt=&Apache::lonlocal::texthash
  622: 	      ('st' => 'Version changes since start of Course',
  623: 	       'lm' => 'Version changes since last Month',
  624: 	       'lw' => 'Version changes since last Week',
  625: 	       'sy' => 'Version changes since Yesterday',
  626:                'al' => 'All Resources',
  627: 	       'sd' => 'Display',
  628: 	       'fi' => 'File',
  629: 	       'md' => 'Modification Date',
  630:                'mr' => 'Most recently published Version',
  631: 	       've' => 'Version used in Course',
  632:                'vu' => 'Set Version to be used in Course', 
  633: 	       'di' => 'Differences');
  634:     $r->print(<<ENDHEADERS);
  635: <form action="/adm/coursedocs" method="post">
  636: <select name="timerange">
  637: <option value='all' $allsel>$lt{'al'}</option>
  638: <option value="-1" $startsel>$lt{'st'}</option>
  639: <option value="2592000" $monthsel>$lt{'lm'}</option>
  640: <option value="604800" $weeksel>$lt{'lw'}</option>
  641: <option value="86400" $daysel>$lt{'sy'}</option>
  642: </select>
  643: <input type="submit" name="versions" value="$lt{'sd'}" />
  644: </form>
  645: <h3>$header</h3>
  646: <table border="2">
  647: <tr>
  648: <th>$lt{'fi'}</th><th>$lt{'md'}</th><th>$lt{'mr'}</th>
  649: <th>$lt{'ve'}</th><th>$lt{'vu'}</th><th>$lt{'di'}</th></tr>
  650: ENDHEADERS
  651:     foreach (keys %changes) {
  652: 	if ($changes{$_}>$starttime) {
  653: 	    my ($root,$extension)=($_=~/^(.*)\.(\w+)$/);
  654: 	    my $currentversion=&Apache::lonnet::getversion($_);
  655: 	    my $linkurl=&Apache::lonnet::clutter($_);
  656: 	    $r->print(
  657: 		      '<tr><td><a href="'.$linkurl.'" target="cat">'.$linkurl.
  658: 		      '</a></td><td>'.
  659: 		      &Apache::lonlocal::locallocaltime($changes{$_}).
  660:                       '</td><td><font size="+2">'.
  661: 		      $currentversion.'</font></td><td><font size="+2">');
  662: # Used in course
  663: 	    my $usedversion=$hash{'version_'.$linkurl};
  664: 	    if ($usedversion) {
  665: 		$r->print($usedversion);
  666: 	    } else {
  667: 		$r->print($currentversion);
  668: 	    }
  669: 	    $r->print('</font></td><td>');
  670: # Set version
  671: 	    $r->print(&Apache::loncommon::select_form($usedversion,
  672: 						      'set_version_'.$linkurl,
  673: 						      ('' => '',
  674: 						       'current' => 'current',
  675: 						       map {$_,$_} (1..$currentversion))));
  676: 	    $r->print('</td><td>');
  677: 	    my $lastold=1;
  678: 	    for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
  679: 		my $url=$root.'.'.$prevvers.'.'.$extension;
  680: 		if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
  681: 		    $starttime) {
  682: 		    $lastold=$prevvers;
  683: 		}
  684: 	    }
  685:             for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
  686: 		my $url=$root.'.'.$prevvers.'.'.$extension;
  687: 		$r->print('<a href="'.&Apache::lonnet::clutter($url).
  688: 			  '">'.&mt('Version').' '.$prevvers.' ('.
  689: 			  &Apache::lonlocal::locallocaltime(&Apache::lonnet::metadata($url,'lastrevisiondate')).
  690: 			  ')</a>');
  691: 		if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
  692:                     $r->print(' <a href="/adm/diff?filename='.
  693: 			      &Apache::lonnet::clutter($root.'.'.$extension).
  694: 			      '&versionone='.$prevvers.
  695: 			      '">'.&mt('Diffs').'</a>');
  696: 		}
  697: 		$r->print('<br />');
  698: 	    }
  699: 	    $r->print('</td></tr>');
  700: 	}
  701:     }
  702:     $r->print('</table>');
  703:     $r->print('<h1>'.&mt('Done').'.</h1>');
  704: 
  705:     &untiehash();
  706: }
  707: 
  708: # ================================================================ Main Handler
  709: sub handler {
  710:     my $r = shift;
  711:     &Apache::loncommon::content_type($r,'text/html');
  712:     $r->send_http_header;
  713:     return OK if $r->header_only;
  714: 
  715:     &Apache::lonlocal::clearreroutetrans();
  716: # --------------------------------------------- Initialize help topics for this
  717:   foreach ('Adding_Course_Doc','Main_Course_Documents',
  718:            'Adding_External_Resource','Navigate_Content',
  719:            'Adding_Folders','Docs_Overview', 'Load_Map',
  720:            'Supplemental', 'Score_Upload_Form',
  721:            'Importing_LON-CAPA_Resource','Uploading_From_Harddrive') {
  722:       $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);
  723:   }
  724:     # Composite help files
  725:     $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
  726: 		    'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
  727:     $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
  728: 		    'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
  729:     $help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
  730: 		    'Option_Response_Simple');
  731:     $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
  732: 		    'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
  733:     $help{'My Personal Info'} = &Apache::loncommon::help_open_topic(
  734: 		  'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
  735:     $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
  736:  
  737:   if ($ENV{'form.verify'}) {
  738:       &verifycontent($r);
  739:   } elsif ($ENV{'form.versions'}) {
  740:       &checkversions($r);
  741:   } elsif ($ENV{'form.dumpcourse'}) {
  742:       &dumpcourse($r);
  743:   } else {
  744: # is this a standard course?
  745: 
  746:     my $standard=($ENV{'request.course.uri'}=~/^\/uploaded\//);
  747:     my $forcestandard;
  748:     my $forcesupplement;
  749:     my $script='';
  750:     my $allowed;
  751:     my $events='';
  752:     my $showdoc=0;
  753:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
  754:        ['folder','foldername']);
  755:     if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
  756:        $showdoc=$1;
  757:     }
  758:     unless ($showdoc) { # got called from remote
  759:        $forcestandard=($ENV{'form.folder'}=~/^default_/);
  760:        $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
  761: 
  762: # does this user have privileges to post, etc?
  763:        $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
  764:        if ($allowed) { 
  765:          &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
  766:          $script=&Apache::lonratedt::editscript('simple'); 
  767:        }
  768:     } else { # got called in sequence from course
  769:        $allowed=0;
  770:        $script='</script>'.&Apache::lonmenu::registerurl(1,undef).'<script>';
  771:        $events='onLoad="'.&Apache::lonmenu::loadevents.
  772:            '" onUnload="'.&Apache::lonmenu::unloadevents.'"';
  773:     }
  774: 
  775: # get course data
  776:     my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
  777:     my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
  778: 
  779: # get personal data
  780:  
  781:     my $uname=$ENV{'user.name'};
  782:     my $udom=$ENV{'user.domain'};
  783:     my $plainname=&Apache::lonnet::escape(
  784:                      &Apache::loncommon::plainname($uname,$udom));
  785: 
  786: # graphics settings
  787: 
  788:     $iconpath = $r->dir_config('lonIconsURL') . "/";
  789: 
  790:     my $now=time;
  791: 
  792: # print screen
  793:     $r->print(<<ENDDOCUMENT);
  794: <html>
  795: <head>
  796: <title>The LearningOnline Network with CAPA</title>
  797: <script>
  798: $script
  799: </script>
  800: ENDDOCUMENT
  801:    if ($allowed) {
  802:     $r->print(<<ENDNEWSCRIPT);
  803: <script>
  804: function makenewfolder(targetform,folderseq) {
  805:     var foldername=prompt('Name of New Folder','New Folder');
  806:     if (foldername) {
  807: 	targetform.importdetail.value=foldername+"="+folderseq;
  808:         targetform.submit();
  809:     }
  810: }
  811: 
  812: function makenewext(targetname) {
  813:     this.document.forms.extimport.useform.value=targetname;
  814:     window.open('/adm/rat/extpickframe.html');
  815: }
  816: 
  817: function makeexamupload() {
  818:    var title=prompt('Listed Title for the Uploaded Score');
  819:    if (title) { 
  820:     this.document.forms.newexamupload.importdetail.value=
  821: 	title+'=/res/lib/templates/examupload.problem';
  822:     this.document.forms.newexamupload.submit();
  823:    }
  824: }
  825: 
  826: function makesmppage() {
  827:    var title=prompt('Listed Title for the Page');
  828:    if (title) { 
  829:     this.document.forms.newsmppg.importdetail.value=
  830: 	title+'=/adm/$udom/$uname/$now/smppg';
  831:     this.document.forms.newsmppg.submit();
  832:    }
  833: }
  834: 
  835: function makesmpproblem() {
  836:    var title=prompt('Listed Title for the Problem');
  837:    if (title) { 
  838:     this.document.forms.newsmpproblem.importdetail.value=
  839: 	title+'=/res/lib/templates/simpleproblem.problem';
  840:     this.document.forms.newsmpproblem.submit();
  841:    }
  842: }
  843: 
  844: function makebulboard() {
  845:    var title=prompt('Listed Title for the Bulletin Board');
  846:    if (title) {
  847:     this.document.forms.newbul.importdetail.value=
  848: 	title+'=/adm/$udom/$uname/$now/bulletinboard';
  849:     this.document.forms.newbul.submit();
  850:    }
  851: }
  852: 
  853: function finishpick() {
  854:     var title=this.document.forms.extimport.title.value;
  855:     var url=this.document.forms.extimport.url.value;
  856:     var form=this.document.forms.extimport.useform.value;
  857:     eval
  858:      ('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+
  859:     '";this.document.forms.'+form+'.submit();');
  860: }
  861: 
  862: function changename(folder,index,oldtitle) {
  863:     var title=prompt('New Title',oldtitle);
  864:     if (title) {
  865: 	this.document.forms.renameform.title.value=title;
  866: 	this.document.forms.renameform.cmd.value='rename_'+index;
  867: 	this.document.forms.renameform.folder.value=folder;
  868:         this.document.forms.renameform.submit();
  869:     }
  870: }
  871: 
  872: function removeres(folder,index,oldtitle) {
  873:     if ((oldtitle=='NO RESOURCE') || (confirm('Remove "'+oldtitle+'"?'))) {
  874: 	this.document.forms.renameform.cmd.value='del_'+index;
  875: 	this.document.forms.renameform.folder.value=folder;
  876:         this.document.forms.renameform.submit();
  877:     }
  878: }
  879: </script>
  880: 
  881: ENDNEWSCRIPT
  882:   }
  883: # -------------------------------------------------------------------- Body tag
  884:   $r->print('</head>'.
  885:             &Apache::loncommon::bodytag('Course Documents','',$events,
  886: 					'','',$showdoc));
  887:   unless ($showdoc) {
  888: # -----------------------------------------------------------------------------
  889:        my %lt=&Apache::lonlocal::texthash(
  890:                 'uplm' => 'Upload a new main course document',
  891:                 'upls' => 'Upload a new supplemental course document',
  892:                 'impp' => 'Import a published document',
  893:                 'spec' => 'Special documents',
  894:                 'upld' => 'Upload Document',
  895:                 'srch' => 'Search',
  896:                 'impo' => 'Import',
  897:                 'selm' => 'Select Map',
  898:                 'load' => 'Load Map',
  899:                 'newf' => 'New Folder',
  900:                 'extr' => 'External Resource',
  901:                 'syll' => 'Syllabus',
  902:                 'navc' => 'Navigate Contents',
  903:                 'sipa' => 'Simple Page',
  904:                 'sipr' => 'Simple Problem',
  905:                 'scuf' => 'Score Upload Form',
  906:                 'bull' => 'Bulletin Board',
  907:                 'mypi' => 'My Personal Info'
  908: 					  );
  909: # -----------------------------------------------------------------------------
  910:     if ($allowed) {
  911:        my $dumpbut=&dumpbutton();
  912:        my %lt=&Apache::lonlocal::texthash(
  913: 					 'vc' => 'Verify Content',
  914: 					 'cv' => 'Check/Set Resource Versions',
  915: 					  );
  916:        $r->print(<<ENDCOURSEVERIFY);
  917: <form name="renameform" method="post" action="/adm/coursedocs">
  918: <input type="hidden" name="title" />
  919: <input type="hidden" name="cmd" />
  920: <input type="hidden" name="folder" />
  921: </form>
  922: <form name="simpleedit" method="post" action="/adm/coursedocs">
  923: <input type=hidden name="importdetail" value="">
  924: <input type="hidden" name="folder" />
  925: </form>
  926: <form action="/adm/coursedocs" method="post" name="courseverify">
  927: <table bgcolor="#AAAAAA" width="100%" cellspacing="4" cellpadding="4">
  928: <tr><td bgcolor="#DDDDCC">
  929: <input type="submit" name="verify" value="$lt{'vc'}" />
  930: </td><td bgcolor="#DDDDCC">
  931: <input type="submit" name="versions" value="$lt{'cv'}" />
  932: $dumpbut
  933: </td></tr></table>
  934: </form>
  935: ENDCOURSEVERIFY
  936:        $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
  937: 		     'Editing the Table of Contents for your Course'));
  938:     }
  939: # --------------------------------------------------------- Standard documents
  940:     $r->print('<table border=2 cellspacing=4 cellpadding=4>');
  941:     if (($standard) && ($allowed) && (!$forcesupplement)) {
  942:        $r->print('<tr><td bgcolor="#BBBBBB"><h2>'.&mt('Main Course Documents').
  943:   ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>');
  944:        my $folder=$ENV{'form.folder'};
  945:        unless ($folder=~/^default/) { $folder='default'; }
  946:        my $postexec='';
  947:        if ($folder eq 'default') {
  948: 	   $r->print('<script>this.window.name="loncapaclient";</script>');
  949:        } else {
  950:            $postexec='self.close();';
  951:        }
  952:        $hadchanges=0;
  953:        &editor($r,$coursenum,$coursedom,$folder,$allowed);
  954:        if ($hadchanges) {
  955: 	   $r->print(
  956: '<script>function reinit(tf) { tf.submit();'.$postexec.' }</script>'. 
  957: '<form method="post" action="/adm/roles" target="loncapaclient">'.
  958: '<input type="hidden" name="orgurl" value="/adm/coursedocs" /><input type="hidden" name="selectrole" value="1" /><h3><font color="red">'.
  959: &mt('Changes will become active for your current session after').
  960: ' <input type="hidden" name="'.
  961: $ENV{'request.role'}.'" value="1" /><input type="button" value="'.
  962: &mt('re-initializing course').'" onClick="reinit(this.form)"/>'.&mt(', or the next time you log in.').
  963: $help{'Caching'}.'</font></h3></form>');
  964:        }
  965:        my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
  966:                      '.sequence';
  967:        $r->print(<<ENDFORM);
  968: <table cellspacing=4 cellpadding=4><tr>
  969: <th bgcolor="#DDDDDD">$lt{'uplm'}</th>
  970: <th bgcolor="#DDDDDD">$lt{'impp'}</th>
  971: <th bgcolor="#DDDDDD">$lt{'spec'}</th>
  972: </tr>
  973: <tr><td bgcolor="#DDDDDD">
  974: File:<br />
  975: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
  976: <input type="file" name="uploaddoc" size="40">
  977: <br />
  978: Title:<br />
  979: <input type="text" size="50" name="comment">
  980: <input type="hidden" name="folder" value="$folder">
  981: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
  982: <input type="hidden" name="cmd" value="upload_default">
  983: <input type="submit" value="$lt{'upld'}">
  984: <nobr>
  985:  $help{'Uploading_From_Harddrive'}
  986: </nobr>
  987: </form>
  988: </td>
  989: <td bgcolor="#DDDDDD">
  990: <form action="/adm/coursedocs" method="post" name="simpleeditdefault">
  991: <input type="hidden" name="folder" value="$folder">
  992: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
  993: <input type=button onClick=
  994: "javascript:document.forms.simpleedit.folder.value='$folder';groupsearch()" value="$lt{'srch'}">
  995: <nobr>
  996: <input type=button onClick=
  997: "javascript:document.forms.simpleedit.folder.value='$folder';groupimport();" value="$lt{'impo'}">
  998: $help{'Importing_LON-CAPA_Resource'}
  999: </nobr>
 1000: <p>
 1001: <hr />
 1002: <input type="text" size="20" name="importmap"><br />
 1003: <nobr><input type=button 
 1004: onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
 1005: value="$lt{'selm'}"> <input type="submit" name="loadmap" value="$lt{'load'}">
 1006: $help{'Load_Map'}</nobr>
 1007: </p>
 1008: </form>
 1009: </td><td bgcolor="#DDDDDD">
 1010: <form action="/adm/coursedocs" method="post" name="newfolder">
 1011: <input type="hidden" name="folder" value="$folder">
 1012: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
 1013: <input type=hidden name="importdetail" value="">
 1014: <nobr>
 1015: <input name="newfolder" type="button"
 1016: onClick="javascript:makenewfolder(this.form,'$folderseq');"
 1017: value="$lt{'newf'}" />$help{'Adding_Folders'}
 1018: </nobr>
 1019: </form>
 1020: <form action="/adm/coursedocs" method="post" name="newext">
 1021: <input type="hidden" name="folder" value="$folder">
 1022: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
 1023: <input type=hidden name="importdetail" value="">
 1024: <nobr>
 1025: <input name="newext" type="button" onClick="javascript:makenewext('newext');"
 1026: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
 1027: </nobr>
 1028: </form>
 1029: <form action="/adm/coursedocs" method="post" name="newsyl">
 1030: <input type="hidden" name="folder" value="$folder">
 1031: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
 1032: <input type=hidden name="importdetail" 
 1033: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
 1034: <nobr>
 1035: <input name="newsyl" type="submit" value="$lt{'syll'}" /> 
 1036:  $help{'Syllabus'}
 1037: </nobr>
 1038: </form>
 1039: <form action="/adm/coursedocs" method="post" name="newnav">
 1040: <input type="hidden" name="folder" value="$folder">
 1041: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
 1042: <input type=hidden name="importdetail" 
 1043: value="Navigate Content=/adm/navmaps">
 1044: <nobr>
 1045: <input name="newnav" type="submit" value="$lt{'navc'}" />
 1046: $help{'Navigate_Content'}
 1047: </nobr>
 1048: </form>
 1049: <form action="/adm/coursedocs" method="post" name="newsmppg">
 1050: <input type="hidden" name="folder" value="$folder">
 1051: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
 1052: <input type=hidden name="importdetail" value="">
 1053: <nobr>
 1054: <input name="newsmppg" type="button" value="$lt{'sipa'}"
 1055: onClick="javascript:makesmppage();" /> $help{'Simple Page'}
 1056: </nobr>
 1057: </form>
 1058: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
 1059: <input type="hidden" name="folder" value="$folder">
 1060: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
 1061: <input type=hidden name="importdetail" value="">
 1062: <nobr>
 1063: <input name="newsmpproblem" type="button" value="$lt{'sipr'}"
 1064: onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
 1065: </nobr>
 1066: </form>
 1067: <form action="/adm/coursedocs" method="post" name="newexamupload">
 1068: <input type="hidden" name="folder" value="$folder">
 1069: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
 1070: <input type=hidden name="importdetail" value="">
 1071: <nobr>
 1072: <input name="newexamupload" type="button" value="$lt{'scuf'}"
 1073: onClick="javascript:makeexamupload();" />
 1074: $help{'Score_Upload_Form'}
 1075: </nobr>
 1076: </form>
 1077: <form action="/adm/coursedocs" method="post" name="newbul">
 1078: <input type="hidden" name="folder" value="$folder">
 1079: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
 1080: <input type=hidden name="importdetail" value="">
 1081: <nobr>
 1082: <input name="newbulletin" type="button" value="$lt{'bull'}"
 1083: onClick="javascript:makebulboard();" />
 1084: $help{'Bulletin Board'}
 1085: </nobr>
 1086: </form>
 1087: <form action="/adm/coursedocs" method="post" name="newaboutme">
 1088: <input type="hidden" name="folder" value="$folder">
 1089: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
 1090: <input type=hidden name="importdetail" 
 1091: value="$plainname=/adm/$udom/$uname/aboutme">
 1092: <nobr>
 1093: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
 1094: $help{'My Personal Info'}
 1095: </nobr>
 1096: </form>
 1097: </td></tr>
 1098: </table>
 1099: ENDFORM
 1100:        $r->print('</td></tr>');
 1101:     }
 1102: # ----------------------------------------------------- Supplemental documents
 1103:     if (!$forcestandard) {
 1104:        $r->print(
 1105:   '<tr><td bgcolor="#BBBBBB"><h2>'.&mt('Supplemental Course Documents').
 1106:   ($allowed?' '.$help{'Supplemental'}:'').'</h2>');
 1107:        my $folder=$ENV{'form.folder'};
 1108:        unless ($folder=~/supplemental/) { $folder='supplemental'; }
 1109:        &editor($r,$coursenum,$coursedom,$folder,$allowed);
 1110:        if ($allowed) {
 1111:        my $folderseq=
 1112:                   '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
 1113:                      '.sequence';
 1114: 
 1115:           $r->print(<<ENDSUPFORM);
 1116: <table cellspacing=4 cellpadding=4><tr>
 1117: <th bgcolor="#DDDDDD">$lt{'upls'}</th>
 1118: <th bgcolor="#DDDDDD">$lt{'impp'}</th>
 1119: <th bgcolor="#DDDDDD">$lt{'spec'}</th>
 1120: </tr>
 1121: <tr><td bgcolor="#DDDDDD">
 1122: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
 1123: <input type="file" name="uploaddoc" size="40">
 1124: <br />Comment:<br />
 1125: <textarea cols=50 rows=4 name='comment'>
 1126: </textarea>
 1127: <input type="hidden" name="folder" value="$folder">
 1128: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
 1129: <input type="hidden" name="cmd" value="upload_supplemental">
 1130: <nobr>
 1131: <input type="submit" value="$lt{'upld'}">
 1132:  $help{'Uploading_From_Harddrive'}
 1133: </nobr>
 1134: </form>
 1135: </td>
 1136: <td bgcolor="#DDDDDD">
 1137: <form action="/adm/coursedocs" method="post" name="simpleeditsupplement">
 1138: <input type="hidden" name="folder" value="$folder">
 1139: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
 1140: <input type=hidden name="importdetail" value="">
 1141: <input type=button onClick=
 1142: "javascript:document.forms.simpleedit.folder.value='$folder';groupsearch()" value="$lt{'srch'}">
 1143: <input type=button onClick=
 1144: "javascript:document.forms.simpleedit.folder.value='$folder';groupimport();" value="$lt{'impo'}">$help{'Importing_LON-CAPA_Resource'}
 1145: <p>
 1146: <hr />
 1147: <input type="text" size="20" name="importmap">
 1148: <input type=button 
 1149: onClick="javascript:openbrowser('simpleeditsupplement','importmap','sequence,page','')"
 1150: value="$lt{'selm'}"><input type="submit" name="loadmap" value="$lt{'load'}">$help{'Load_Map'}
 1151: </p>
 1152: </form>
 1153: </td><td bgcolor="#DDDDDD">
 1154: <form action="/adm/coursedocs" method="post" name="supnewfolder">
 1155: <input type="hidden" name="folder" value="$folder">
 1156: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
 1157: <input type=hidden name="importdetail" value="">
 1158: <nobr>
 1159: <input name="newfolder" type="button"
 1160: onClick="javascript:makenewfolder(this.form,'$folderseq');"
 1161: value="$lt{'newf'}" /> $help{'Adding_Folders'}
 1162: </nobr>
 1163: </form>
 1164: <form action="/adm/coursedocs" method="post" name="supnewext">
 1165: <input type="hidden" name="folder" value="$folder">
 1166: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
 1167: <input type=hidden name="importdetail" value="">
 1168: <nobr>
 1169: <input name="newext" type="button" 
 1170: onClick="javascript:makenewext('supnewext');"
 1171: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
 1172: </nobr>
 1173: </form>
 1174: <form action="/adm/coursedocs" method="post" name="supnewsyl">
 1175: <input type="hidden" name="folder" value="$folder">
 1176: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
 1177: <input type=hidden name="importdetail" 
 1178: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
 1179: <nobr>
 1180: <input name="newsyl" type="submit" value="$lt{'syll'}" />
 1181: $help{'Syllabus'}
 1182: </nobr>
 1183: </form>
 1184: <form action="/adm/coursedocs" method="post" name="subnewaboutme">
 1185: <input type="hidden" name="folder" value="$folder">
 1186: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
 1187: <input type=hidden name="importdetail" 
 1188: value="$plainname=/adm/$udom/$uname/aboutme">
 1189: <nobr>
 1190: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
 1191: $help{'My Personal Info'}
 1192: </nobr>
 1193: </form>
 1194: </td></tr>
 1195: </table></td></tr>
 1196: ENDSUPFORM
 1197:        }
 1198:     }
 1199:     if ($allowed) {
 1200: 	$r->print('<form name="extimport"><input type="hidden" name="title"><input type="hidden" name="url"><input type="hidden" name="useform"></form>');
 1201:     }
 1202:     $r->print('</table>');
 1203:   } else {
 1204: # -------------------------------------------------------- This is showdoc mode
 1205:       $r->print("<h1>".&mt('Uploaded Document').'</h1><p>'.
 1206: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><p><table>".
 1207:          &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table></p>');
 1208:   }
 1209:  }
 1210:  $r->print(&Apache::lonlocal::endreroutetrans().'</body></html>');
 1211:  return OK;
 1212: } 
 1213: 
 1214: 1;
 1215: __END__

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