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

1.1       www         1: # The LearningOnline Network
1.2       www         2: # Documents
1.1       www         3: #
1.114   ! albertel    4: # $Id: londocs.pm,v 1.113 2004/04/06 23:05:29 albertel 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.81      www        41: use Apache::lonlocal;
1.7       www        42: 
1.8       www        43: my $iconpath;
1.7       www        44: 
1.27      www        45: my %hash;
                     46: 
                     47: my $hashtied;
1.29      www        48: my %alreadyseen=();
1.27      www        49: 
1.40      www        50: my $hadchanges;
                     51: 
1.47      www        52: # Available help topics
                     53: 
                     54: my %help=();
                     55: 
1.7       www        56: # Mapread read maps into lonratedt::global arrays 
1.10      www        57: # @order and @resources, determines status
1.7       www        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)=@_;
1.104     albertel   71:     my ($outtext,$errtext)=
1.7       www        72:       &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.15      www        73:                                 $map,1);
1.104     albertel   74:     if ($errtext) { return ($errtext,2); }
                     75:     
                     76:     $hadchanges=1;
                     77:     return ($errtext,0);
1.7       www        78: }
                     79: 
1.74      www        80: # ----------------------------------------- Return hash with valid author names
                     81: 
                     82: sub authorhosts {
                     83:     my %outhash=();
                     84:     my $home=0;
                     85:     my $other=0;
                     86:     foreach (keys %ENV) {
                     87: 	if ($_=~/^user\.role\.(au|ca)\.(.+)$/) {
                     88: 	    my $role=$1;
                     89: 	    my $realm=$2;
                     90: 	    my ($start,$end)=split(/\./,$ENV{$_});
                     91: 	    if (($start) && ($start>time)) { next; }
                     92: 	    if (($end) && (time>$end)) { next; }
                     93: 	    my $ca; my $cd;
                     94: 	    if ($1 eq 'au') {
                     95: 		$ca=$ENV{'user.name'};
                     96: 		$cd=$ENV{'user.domain'};
                     97: 	    } else {
                     98: 		($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/);
                     99: 	    }
1.107     albertel  100: 	    my $allowed=0;
                    101: 	    my $myhome=&Apache::lonnet::homeserver($ca,$cd);
                    102: 	    my @ids=&Apache::lonnet::current_machine_ids();
                    103: 	    foreach my $id (@ids) { if ($id eq $myhome) { $allowed=1; } }
                    104: 	    if ($allowed) {
1.74      www       105: 		$home++;
                    106: 		$outhash{'home_'.$ca.'@'.$cd}=1;
                    107: 	    } else {
1.107     albertel  108: 		$outhash{'otherhome_'.$ca.'@'.$cd}=$myhome;
1.74      www       109: 		$other++;
                    110: 	    }
                    111: 	}
                    112:     }
                    113:     return ($home,$other,%outhash);
                    114: }
                    115: # ------------------------------------------------------ Generate "dump" button
                    116: 
                    117: sub dumpbutton {
                    118:     my ($home,$other,%outhash)=&authorhosts();
                    119:     if ($home+$other==0) { return ''; }
                    120:     my $output='</td><td bgcolor="#DDDDCC">';
                    121:     if ($home) {
                    122: 	return '</td><td bgcolor="#DDDDCC">'.
1.81      www       123: 	    '<input type="submit" name="dumpcourse" value="'.
                    124: 	    &mt('Dump Course DOCS to Construction Space').'" />';
1.74      www       125:     } else {
                    126: 	return'</td><td bgcolor="#DDDDCC">'.
1.81      www       127:      &mt('Dump Course DOCS to Construction Space: available on other servers');
1.74      www       128:     }
                    129: }
                    130: 
                    131: # -------------------------------------------------------- Actually dump course
                    132: 
                    133: sub dumpcourse {
1.75      www       134:     my $r=shift;
                    135:     $r->print('<html><head><title>Dump DOCS</title></head>'.
1.76      www       136:         &Apache::loncommon::bodytag('Dump Course DOCS to Construction Space').
                    137: 	      '<form name="dumpdoc" method="post">');
1.74      www       138:     my ($home,$other,%outhash)=&authorhosts();
1.75      www       139:     unless ($home) { return ''; }
1.76      www       140:     my $origcrsid=$ENV{'request.course.id'};
                    141:     my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
                    142:     if (($ENV{'form.authorspace'}) && ($ENV{'form.authorfolder'}=~/\w/)) {
                    143: # Do the dumping
1.75      www       144: 	unless ($outhash{'home_'.$ENV{'form.authorspace'}}) { return ''; }
                    145: 	my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'});
1.87      www       146: 	$r->print('<h3>'.&mt('Copying Files').'</h3>');
1.76      www       147: 	my $title=$ENV{'form.authorfolder'};
1.79      www       148: 	$title=~s/[^\w\/]+/\_/g;
                    149: 	my %replacehash=();
                    150: 	foreach (keys %ENV) {
                    151: 	    if ($_=~/^form\.namefor\_(.+)/) {
                    152: 		$replacehash{$1}=$ENV{$_};
                    153: 	    }
                    154: 	}
                    155: 	my $crs='/uploaded/'.$ENV{'request.course.id'}.'/';
                    156: 	$crs=~s/\_/\//g;
                    157: 	foreach (keys %replacehash) {
                    158: 	    my $newfilename=$title.'/'.$replacehash{$_};
                    159: 	    $newfilename=~s/[^\w\/\.]+/\_/g;
                    160: 	    my @dirs=split(/\//,$newfilename);
                    161: 	    my $path='/home/'.$ca.'/public_html';
                    162: 	    my $makepath=$path;
                    163: 	    my $fail=0;
                    164: 	    for (my $i=0;$i<$#dirs;$i++) {
                    165: 		$makepath.='/'.$dirs[$i];
                    166: 		unless (-e $makepath) { 
                    167: 		    unless(mkdir($makepath,0777)) { $fail=1; } 
                    168: 		}
                    169: 	    }
                    170: 	    $r->print('<br /><tt>'.$_.'</tt> => <tt>'.$newfilename.'</tt>: ');
                    171: 	    if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
                    172: 		if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
                    173: 		    print $fh &Apache::loncreatecourse::rewritefile(
                    174:          &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_),
                    175: 				     (%replacehash,$crs => '')
                    176: 								    );
                    177: 		} else {
                    178: 		    print $fh
                    179:          &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_);
                    180: 		       }
                    181: 		$fh->close();
                    182: 	    } else {
                    183: 		$fail=1;
                    184: 	    }
                    185: 	    if ($fail) {
                    186: 		$r->print('<font color="red">fail</font>');
                    187: 	    } else {
                    188: 		$r->print('<font color="green">ok</font>');
                    189: 	    }
                    190: 	}
1.76      www       191:     } else {
                    192: # Input form
                    193: 	unless ($home==1) {
                    194: 	    $r->print(
1.81      www       195: 		      '<h3>'.&mt('Select the Construction Space').'</h3><select name="authorspace">');
1.76      www       196: 	}
                    197: 	foreach (sort keys %outhash) {
                    198: 	    if ($_=~/^home_(.+)$/) {
                    199: 		if ($home==1) {
                    200: 		    $r->print(
                    201: 		  '<input type="hidden" name="authorspace" value="'.$1.'" />');
                    202: 		} else {
                    203: 		    $r->print('<option value="'.$1.'">'.$_.'</option>');
                    204: 		}
                    205: 	    }
                    206: 	}
                    207: 	unless ($home==1) {
                    208: 	    $r->print('</select>');
                    209: 	}
                    210: 	my $title=$origcrsdata{'description'};
                    211: 	$title=~s/\s+/\_/gs;
                    212: 	$title=~s/\W//gs;
1.81      www       213: 	$r->print('<h3>'.&mt('Folder in Construction Space').'</h3><input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
1.76      www       214: 	&tiehash();
1.81      www       215: 	$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>');
1.76      www       216: 	foreach (&Apache::loncreatecourse::crsdirlist($origcrsid,'userfiles')) {
1.78      www       217: 	    $r->print('<tr><td>'.$_.'</td>');
                    218: 	    my ($ext)=($_=~/\.(\w+)$/);
                    219: 	    my $title=$hash{'title_'.$hash{
                    220: 		'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}};
                    221: 	    $r->print('<td>'.($title?$title:'&nbsp;').'</td>');
                    222: 	    unless ($title) {
                    223: 		$title=$_;
                    224: 	    }
                    225: 	    $title=~s/\.(\w+)$//;
                    226: 	    $title=~s/\W+/\_/gs;
                    227: 	    $title.='.'.$ext;
1.79      www       228: 	    $r->print("\n<td><input type='text' size='60' name='namefor_".$_."' value='".$title."' /></td></tr>\n");
1.76      www       229: 	}
1.78      www       230: 	$r->print("</table>\n");
1.76      www       231: 	&untiehash();
                    232: 	$r->print(
1.81      www       233:   '<p><input type="submit" name="dumpcourse" value="'.&mt('Dump Course DOCS').'" /></p></form>');
1.75      www       234:     }
1.74      www       235: }
1.76      www       236: 
1.74      www       237: 
1.73      bowersj2  238: # Imports the given (name, url) resources into the course
                    239: # coursenum, coursedom, and folder must precede the list
                    240: sub group_import {
                    241:     my $coursenum = shift;
                    242:     my $coursedom = shift;
                    243:     my $folder = shift;
                    244:     while (@_) {
                    245: 	my $name = shift;
                    246: 	my $url = shift;
                    247: 	if ($url) {
                    248: 	    my $idx = $#Apache::lonratedt::resources + 1;
                    249: 	    $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=$idx;
                    250: 	    my $ext = 'false';
                    251: 	    if ($url=~/^http:\/\//) { $ext = 'true'; }
                    252: 	    $url =~ s/:/\&colon;/g;
                    253: 	    $name =~ s/:/\&colon;/g;
                    254: 	    $Apache::lonratedt::resources[$idx] = 
                    255: 		join ':', ($name, $url, $ext, 'normal', 'res');
                    256: 	}
                    257:     }
1.104     albertel  258:     return &storemap($coursenum, $coursedom, $folder.'.sequence');
1.73      bowersj2  259: }
                    260: 
1.114   ! albertel  261: sub breadcrumbs {
        !           262:     my ($where)=@_;
        !           263:     &Apache::lonhtmlcommon::clear_breadcrumbs();
        !           264:     if ($where =~ /^default/) {
        !           265: 	&Apache::lonhtmlcommon::add_breadcrumb({'href'=>'/adm/coursedocs',
        !           266: 				    'title'=>'Main Course Documents',
        !           267: 				    'text' =>'Main Course Documents'});
        !           268:     } elsif ($where =~ /^supplemental/) {
        !           269: 	&Apache::lonhtmlcommon::add_breadcrumb({'href'=>'/adm/coursedocs',
        !           270: 				    'title'=>'Supplemental Course Documents',
        !           271: 				    'text' =>'Supplemental Course Documents'});
        !           272: 
        !           273:     } else {
        !           274: 	&Apache::lonhtmlcommon::add_breadcrumb({'href'=>'/adm/coursedocs',
        !           275: 						'title'=>$where,
        !           276: 						'text' =>$where});
        !           277:     }
        !           278:     if ($ENV{'form.foldername'}) {
        !           279: 	my @folders;
        !           280: 	if (defined($ENV{'form.folders'})) {
        !           281: 	    @folders=@{$ENV{'form.folders'}};
        !           282: 	}
        !           283: 	@folders=(@folders,$ENV{'form.folder'},
        !           284: 		  &Apache::lonnet::escape($ENV{'form.foldername'}));
        !           285: 
        !           286: 	my $folderpath;
        !           287: 	while (@folders) {
        !           288: 	    my $folder=shift(@folders);
        !           289: 	    my $foldername=shift(@folders);
        !           290: 	    if ($folderpath) {$folderpath.='&';}
        !           291: 	    $folderpath.=$folder.'&'.$foldername;
        !           292: 	    my $url='/adm/coursedocs?folderpath='.
        !           293: 		&Apache::lonnet::escape($folderpath);
        !           294: 	    &Apache::lonhtmlcommon::add_breadcrumb(
        !           295: 		      {'href'=>$url,
        !           296: 		       'title'=>&Apache::lonnet::unescape($foldername),
        !           297: 		       'text'=>&Apache::lonnet::unescape($foldername)});
        !           298: 		       
        !           299: 						 
        !           300: 	}
        !           301:     }
        !           302:     return &Apache::lonhtmlcommon::breadcrumbs();
        !           303: }
        !           304: 
1.7       www       305: sub editor {
                    306:     my ($r,$coursenum,$coursedom,$folder,$allowed)=@_;
1.114   ! albertel  307: 
        !           308:     $r->print(&breadcrumbs($folder));
1.10      www       309:     my $errtext='';
                    310:     my $fatal=0;
                    311:     ($errtext,$fatal)=
1.7       www       312:           &mapread($coursenum,$coursedom,$folder.'.sequence');
1.17      www       313:     if ($#Apache::lonratedt::order<1) {
                    314:        	$Apache::lonratedt::order[0]=1;
                    315:         $Apache::lonratedt::resources[1]='';
                    316:     }
1.7       www       317:     if ($fatal) {
                    318: 	   $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    319:     } else {
                    320: # ------------------------------------------------------------ Process commands
1.16      www       321: # ---------------- if they are for this folder and user allowed to make changes
                    322: 	if (($allowed) && ($ENV{'form.folder'} eq $folder)) {
1.10      www       323: # upload a file, if present
                    324:            if (($ENV{'form.uploaddoc.filename'}) &&
                    325:                ($ENV{'form.cmd'}=~/^upload_(\w+)/)) {
1.112     raeburn   326: 	    if ( ($folder=~/^$1/) || ($1 eq 'default') ) {
1.10      www       327: # this is for a course, not a user, so set coursedoc flag
                    328: # probably the only place in the system where this should be "1"
                    329: 	      my $url=&Apache::lonnet::userfileupload('uploaddoc',1);
                    330:               my $ext='false';
                    331:               if ($url=~/^http\:\/\//) { $ext='true'; }
                    332:               $url=~s/\:/\&colon;/g;
                    333: 	      my $comment=$ENV{'form.comment'};
                    334:               $comment=~s/\</\&lt\;/g;
                    335:               $comment=~s/\>/\&gt\;/g;
                    336:               $comment=~s/\:/\&colon;/g;
1.17      www       337:               if ($folder=~/^supplemental/) {
                    338: 		  $comment=time.'___&&&___'.$ENV{'user.name'}.'___&&&___'.
                    339: 		      $ENV{'user.domain'}.'___&&&___'.$comment;
                    340:               }
1.10      www       341:               my $newidx=$#Apache::lonratedt::resources+1;
                    342:               $Apache::lonratedt::resources[$newidx]=
                    343:                   $comment.':'.$url.':'.$ext.':normal:res';
                    344:               $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=
                    345:                                                               $newidx;       
1.104     albertel  346: 
                    347: 	      ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.sequence');
                    348: 	      if ($fatal) {
                    349: 		  $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    350: 		  return;
                    351: 	      }
1.10      www       352: 	     }
                    353:             }
1.8       www       354: 	    if ($ENV{'form.cmd'}) {
1.10      www       355:                 my ($cmd,$idx)=split(/\_/,$ENV{'form.cmd'});
                    356:                 if ($cmd eq 'del') {
                    357: 		    for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) {
                    358:                         $Apache::lonratedt::order[$i]=
                    359:                           $Apache::lonratedt::order[$i+1];
                    360:                     }
                    361:                     $#Apache::lonratedt::order--;
                    362:                 } elsif ($cmd eq 'up') {
1.38      www       363: 		  if (($idx) && (defined($Apache::lonratedt::order[$idx-1]))) {
1.10      www       364:                     my $i=$Apache::lonratedt::order[$idx-1];
                    365:                     $Apache::lonratedt::order[$idx-1]=
                    366: 			$Apache::lonratedt::order[$idx];
                    367:                     $Apache::lonratedt::order[$idx]=$i;
1.38      www       368: 		   }
1.10      www       369:                 } elsif ($cmd eq 'down') {
1.38      www       370: 		   if (defined($Apache::lonratedt::order[$idx+1])) {
1.10      www       371:                     my $i=$Apache::lonratedt::order[$idx+1];
                    372:                     $Apache::lonratedt::order[$idx+1]=
                    373: 			$Apache::lonratedt::order[$idx];
                    374:                     $Apache::lonratedt::order[$idx]=$i;
1.38      www       375: 		   }
1.36      www       376:                 } elsif ($cmd eq 'rename') {
                    377:                     my ($rtitle,@rrest)=split(/\:/,
                    378:                        $Apache::lonratedt::resources[
                    379: 				       $Apache::lonratedt::order[$idx]]);
1.38      www       380:                     my $comment=
                    381:                      &HTML::Entities::decode($ENV{'form.title'});
1.36      www       382:                     $comment=~s/\</\&lt\;/g;
                    383:                     $comment=~s/\>/\&gt\;/g;
                    384:                     $comment=~s/\:/\&colon;/g;
                    385:                     $Apache::lonratedt::resources[
                    386: 				       $Apache::lonratedt::order[$idx]]=
                    387:                              $comment.':'.join(':',@rrest);
                    388:                     
1.10      www       389:                 }
                    390: # Store the changed version
1.104     albertel  391: 		($errtext,$fatal)=&storemap($coursenum,$coursedom,
                    392: 					    $folder.'.sequence');
                    393: 		if ($fatal) {
                    394: 		    $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    395: 		    return;
                    396: 		}
1.8       www       397:             }
1.11      www       398: # Group import/search
                    399: 	    if ($ENV{'form.importdetail'}) {
1.73      bowersj2  400: 		my @imports;
                    401: 		foreach (split(/\&/,$ENV{'form.importdetail'})) {
                    402: 		    if (defined($_)) {
                    403: 			my ($name,$url)=split(/\=/,$_);
                    404: 			$name=&Apache::lonnet::unescape($name);
                    405: 			$url=&Apache::lonnet::unescape($url);
                    406: 			push @imports, $name, $url;
                    407: 		    }
                    408: 		}
1.11      www       409: # Store the changed version
1.104     albertel  410: 		($errtext,$fatal)=group_import($coursenum, $coursedom, $folder,
                    411: 					       @imports);
                    412: 		if ($fatal) {
                    413: 		    $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    414: 		    return;
                    415: 		}
1.11      www       416:             }
1.53      www       417: # Loading a complete map
                    418: 	   if (($ENV{'form.importmap'}) && ($ENV{'form.loadmap'})) {
1.104     albertel  419: 	       foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$ENV{'form.importmap'}))) {
1.53      www       420:                    my $idx=$#Apache::lonratedt::resources;
                    421:                    $idx++;
                    422:                    $Apache::lonratedt::resources[$idx]=$_;
                    423:                    $Apache::lonratedt::order
1.104     albertel  424: 		       [$#Apache::lonratedt::order+1]=$idx;
                    425: 	       }
1.53      www       426: 
                    427: # Store the changed version
1.104     albertel  428: 	       ($errtext,$fatal)=&storemap($coursenum,$coursedom,
                    429: 					   $folder.'.sequence');
                    430: 	       if ($fatal) {
                    431: 		   $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    432: 		   return;
                    433: 	       }
1.53      www       434:            }
1.16      www       435:        }
                    436: # ---------------------------------------------------------------- End commands
1.7       www       437: # ---------------------------------------------------------------- Print screen
1.10      www       438:         my $idx=0;
                    439:         $r->print('<table>');
                    440:         foreach (@Apache::lonratedt::order) {
                    441:            my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]);
                    442:            unless ($name) {  $name=(split(/\//,$url))[-1]; }
1.106     www       443:            unless ($name) { next; }
1.112     raeburn   444:            $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum));
1.10      www       445:            $idx++;
                    446:         }
                    447:         $r->print('</table>');
1.7       www       448:     }
                    449: }
1.1       www       450: 
1.8       www       451: # --------------------------------------------------------------- An entry line
                    452: 
                    453: sub entryline {
1.112     raeburn   454:     my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;
1.38      www       455:     $title=~s/\&colon\;/\:/g;
                    456:     $title=&HTML::Entities::encode(&HTML::Entities::decode(
1.109     albertel  457:      &Apache::lonnet::unescape($title)),'"<>&\'');
1.38      www       458:     my $renametitle=$title;
                    459:     my $foldertitle=$title;
1.109     albertel  460:     if ($title=~ /^(\d+)___&amp;&amp;&amp;___(\w+)___&amp;&amp;&amp;___(\w+)___&amp;&amp;&amp;___(.*)$/	) { 
                    461: 	$foldertitle=&Apache::lontexconvert::msgtexconverted($4);
                    462: 	$renametitle=$4;
                    463: 	$title='<i>'.&Apache::lonlocal::locallocaltime($1).'</i> '.
                    464: 	    &Apache::loncommon::plainname($2,$3).': <br />'.
                    465: 	    $foldertitle;
                    466:     }
1.38      www       467:     $renametitle=~s/\&quot\;/\\\"/g;
1.8       www       468:     my $line='<tr>';
                    469: # Edit commands
1.109     albertel  470:     if ($allowed) {
                    471: 	my %lt=('up' => 'Move Up',
                    472: 		'dw' => 'Move Down',
                    473: 		'rm' => 'Remove',
                    474: 		'rn' => 'Rename');
                    475: 	my ($foldername,$htmlfoldername);
                    476: 	if ($ENV{'form.foldername'}) {
                    477: 	    $foldername='&foldername='.
                    478: 		&Apache::lonnet::escape($ENV{'form.foldername'});
1.111     albertel  479: 	    $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'},'<>&"');
1.109     albertel  480: 	}
                    481: 	$line.=(<<END);
1.54      www       482: <td><table border='0' cellspacing='2' cellpadding='0'>
                    483: <tr><td bgcolor="#DDDDDD">
1.109     albertel  484: <a href='/adm/coursedocs?folder=$folder&cmd=up_$index$foldername'>
1.90      www       485: <img src="${iconpath}move_up.gif" alt='$lt{'up'}' border='0' /></a></td></tr>
1.54      www       486: <tr><td bgcolor="#DDDDDD">
1.109     albertel  487: <a href='/adm/coursedocs?folder=$folder&cmd=down_$index$foldername'>
1.90      www       488: <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' border='0' /></a></td></tr>
1.54      www       489: </table></td><td bgcolor="#DDDDDD">
1.109     albertel  490: <a href='javascript:removeres("$folder","$index","$renametitle","$htmlfoldername");'>
1.90      www       491: <font size="-2" color="#990000">$lt{'rm'}</font></a>
1.109     albertel  492: <a href='javascript:changename("$folder","$index","$renametitle","$htmlfoldername");'>
1.90      www       493: <font size="-2" color="#009900">$lt{'rn'}</font></a></td>
1.8       www       494: END
                    495:     }
1.16      www       496: # Figure out what kind of a resource this is
                    497:     my ($extension)=($url=~/\.(\w+)$/);
                    498:     my $uploaded=($url=~/^\/*uploaded\//);
1.97      albertel  499:     my $icon=&Apache::loncommon::icon($url);
1.17      www       500:     my $isfolder=0;
1.114   ! albertel  501:     my $folderarg;
1.16      www       502:     if ($uploaded) {
                    503:        if ($extension eq 'sequence') {
1.97      albertel  504: 	  $icon=$iconpath.'/folder_closed.gif';
1.112     raeburn   505:           $url=~/$coursenum\/([\/\w]+)\.sequence$/;
1.114   ! albertel  506:           $url='/adm/coursedocs?';
        !           507: 	  $folderarg=$1;
1.17      www       508:           $isfolder=1;
1.16      www       509:        } else {
                    510: 	  $url=&Apache::lonnet::tokenwrapper($url);
                    511:        } 
                    512:     }
1.18      www       513:     $url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//;
1.113     albertel  514:     if ((!$isfolder) && ($residx) && ($folder!~/supplemental/)) {
                    515: 	my $symb=&Apache::lonnet::symbclean(
1.50      www       516:           &Apache::lonnet::declutter('uploaded/'.
                    517:            $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.'/'.
                    518:            $ENV{'course.'.$ENV{'request.course.id'}.'.num'}.'/'.$folder.
                    519:            '.sequence').
                    520:            '___'.$residx.'___'.
1.113     albertel  521: 	   &Apache::lonnet::declutter($url));
                    522: 	(undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
                    523: 	$url=&Apache::lonnet::clutter($url);
                    524: 	$url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb);
1.50      www       525:     }
1.114   ! albertel  526:     if ($isfolder) {
        !           527: 	my $foldername=&Apache::lonnet::escape($foldertitle);
        !           528: 	my $folderpath=$ENV{'form.folderpath'};
        !           529: 	if ($folderpath) { $folderpath.='&' };
        !           530: 	$folderpath.=$folderarg.'&'.$foldername;
        !           531: 	$url.='folderpath='.&Apache::lonnet::escape($folderpath);
        !           532:     }
1.113     albertel  533:     $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'"><img src="'.$icon.
                    534: 	'" border="0"></a></td>'.
                    535:         "<td bgcolor='#FFFFBB'><a href='$url'>$title</a></td></tr>";
1.8       www       536:     return $line;
                    537: }
                    538: 
1.27      www       539: # ---------------------------------------------------------------- tie the hash
                    540: 
                    541: sub tiehash {
                    542:     $hashtied=0;
                    543:     if ($ENV{'request.course.fn'}) {
                    544:         if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
                    545:             &GDBM_READER(),0640)) {
                    546:                 $hashtied=1;
                    547:         }
                    548:     }    
                    549: }
                    550: 
                    551: sub untiehash {
                    552:     if ($hashtied) { untie %hash; }
                    553:     $hashtied=0;
                    554: }
                    555: 
1.29      www       556: # --------------------------------------------------------------- check on this
                    557: 
                    558: sub checkonthis {
                    559:     my ($r,$url,$level,$title)=@_;
                    560:     $alreadyseen{$url}=1;
                    561:     $r->rflush();
1.41      www       562:     if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
1.108     albertel  563:        $r->print("\n<br />");
1.29      www       564:        for (my $i=0;$i<=$level*5;$i++) {
                    565:            $r->print('&nbsp;');
                    566:        }
                    567:        $r->print('<a href="'.$url.'" target="cat">'.
                    568: 		 ($title?$title:$url).'</a> ');
                    569:        if ($url=~/^\/res\//) {
                    570: 	  my $result=&Apache::lonnet::repcopy(
                    571:                               &Apache::lonnet::filelocation('',$url));
                    572:           if ($result==OK) {
1.87      www       573:              $r->print('<font color="green">'.&mt('ok').'</font>');
1.29      www       574:              $r->rflush();
1.34      www       575:              &Apache::lonnet::countacc($url);
                    576:              $url=~/\.(\w+)$/;
                    577:              if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
                    578: 		 $r->print('<br />');
                    579:                  $r->rflush();
                    580:                  for (my $i=0;$i<=$level*5;$i++) {
                    581:                      $r->print('&nbsp;');
                    582:                  }
1.84      www       583:                  $r->print('- '.&mt('Rendering').': ');
1.69      albertel  584:                  my $oldpath=$ENV{'request.filename'};
                    585:                  $ENV{'request.filename'}=&Apache::lonnet::filelocation('',$url);
1.34      www       586:                  &Apache::lonxml::xmlparse($r,'web',
                    587:                    &Apache::lonnet::getfile(
1.35      albertel  588:                     &Apache::lonnet::filelocation('',$url)));
1.94      www       589: 		 undef($Apache::lonhomework::parsing_a_problem);
1.69      albertel  590: 		 $ENV{'request.filename'}=$oldpath;
1.34      www       591:                  if (($Apache::lonxml::errorcount) ||
                    592:                      ($Apache::lonxml::warningcount)) {
                    593: 		     if ($Apache::lonxml::errorcount) {
1.98      www       594:                         $r->print('<img src="/adm/lonMisc/bomb.gif" /><font color="red"><b>'.
1.87      www       595: 			  $Apache::lonxml::errorcount.' '.
                    596: 				  &mt('error(s)').'</b></font> ');
1.34      www       597:                      }
                    598: 		     if ($Apache::lonxml::warningcount) {
                    599:                         $r->print('<font color="blue">'.
1.84      www       600: 			  $Apache::lonxml::warningcount.' '.
                    601: 				  &mt('warning(s)').'</font>');
1.34      www       602:                      }
                    603:                  } else {
1.87      www       604:                      $r->print('<font color="green">'.&mt('ok').'</font>');
1.34      www       605:                  }
                    606:                  $r->rflush();
                    607:              }
1.29      www       608: 	     my $dependencies=
                    609:                 &Apache::lonnet::metadata($url,'dependencies');
                    610:              foreach (split(/\,/,$dependencies)) {
                    611: 		 if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {
                    612:                     &checkonthis($r,$_,$level+1);
                    613:                  }
                    614:              }
                    615:           } elsif ($result==HTTP_SERVICE_UNAVAILABLE) {
1.84      www       616:              $r->print('<font color="red"><b>'.&mt('connection down').'</b></font>');
1.29      www       617:           } elsif ($result==HTTP_NOT_FOUND) {
1.100     www       618: 	      unless ($url=~/\$/) {
                    619: 		  $r->print('<font color="red"><b>'.&mt('not found').'</b></font>');
                    620: 	      } else {
                    621: 		  $r->print('<font color="yellow"><b>'.&mt('unable to verify variable URL').'</b></font>');
                    622: 	      }
1.29      www       623:           } else {
1.84      www       624:              $r->print('<font color="red"><b>'.&mt('access denied').'</b></font>');
1.29      www       625:           }
                    626:       }
                    627:    }
                    628: }
                    629: 
1.1       www       630: 
1.75      www       631: #
                    632: # -------------------------------------------------------------- Verify Content
                    633: # 
                    634: sub verifycontent {
                    635:    my $r=shift; 
1.26      www       636:    my $loaderror=&Apache::lonnet::overloaderror($r);
                    637:    if ($loaderror) { return $loaderror; }
                    638: 
                    639:    $r->print('<html><head><title>Verify Content</title></head>'.
                    640:               &Apache::loncommon::bodytag('Verify Course Documents'));
1.27      www       641:    $hashtied=0;
1.30      www       642:    undef %alreadyseen;
                    643:    %alreadyseen=();
1.27      www       644:    &tiehash();
                    645:    foreach (keys %hash) {
1.28      www       646:        if (($_=~/^src\_(.+)$/) && (!$alreadyseen{$hash{$_}})) {
1.29      www       647:            &checkonthis($r,$hash{$_},0,$hash{'title_'.$1});
1.27      www       648:        }
                    649:    }
                    650:    &untiehash();
1.108     albertel  651:    $r->print('<h1>'.&mt('Done').'.</h1>'.'<a href="/adm/coursedocs">'.
                    652: 	     &mt('Return to DOCS').'</a>');
1.75      www       653: }
                    654: 
                    655: # -------------------------------------------------------------- Check Versions
                    656: 
                    657: sub checkversions {
                    658:     my $r=shift;
1.89      www       659:     $r->print('<html><head><title>Check Versions</title></head>'.
1.26      www       660:               &Apache::loncommon::bodytag('Check Course Document Versions'));
1.89      www       661:     my $header='';
                    662:     my $startsel='';
                    663:     my $monthsel='';
                    664:     my $weeksel='';
                    665:     my $daysel='';
                    666:     my $allsel='';
                    667:     my %changes=();
                    668:     my $starttime=0;
1.91      www       669:     my $haschanged=0;
1.92      www       670:     my %setversions=&Apache::lonnet::dump('resourceversions',
                    671: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
                    672: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
                    673: 
                    674:     $hashtied=0;
                    675:     &tiehash();
                    676:     my %newsetversions=();
1.91      www       677:     if ($ENV{'form.setmostrecent'}) {
                    678: 	$haschanged=1;
1.92      www       679: 	foreach (keys %hash) {
                    680: 	    if ($_=~/^ids\_(\/res\/.+)$/) {
1.93      www       681: 		$newsetversions{$1}='mostrecent';
1.92      www       682: 	    }
                    683: 	}
1.91      www       684:     } elsif ($ENV{'form.setcurrent'}) {
                    685: 	$haschanged=1;
1.92      www       686: 	foreach (keys %hash) {
                    687: 	    if ($_=~/^ids\_(\/res\/.+)$/) {
1.93      www       688: 		my $getvers=&Apache::lonnet::getversion($1);
                    689: 		if ($getvers>0) {
                    690: 		    $newsetversions{$1}=$getvers;
                    691: 		}
1.92      www       692: 	    }
                    693: 	}
1.91      www       694:     } elsif ($ENV{'form.setversions'}) {
                    695: 	$haschanged=1;
1.92      www       696: 	foreach (keys %ENV) {
                    697: 	    if ($_=~/^form\.set_version_(.+)$/) {
                    698: 		my $src=$1;
                    699: 		&Apache::lonnet::logthis('Found: '.$1.' '.$ENV{$_});
                    700: 		if (($ENV{$_}) && ($ENV{$_} ne $setversions{$src})) {
                    701: 		    $newsetversions{$src}=$ENV{$_};
                    702: 		}
                    703: 	    }
                    704: 	}
1.91      www       705:     }
                    706:     if ($haschanged) {
1.92      www       707:         if (&Apache::lonnet::put('resourceversions',\%newsetversions,
                    708: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
                    709: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.num'}) eq 'ok') {		
                    710: 	    $r->print('<h1>'.&mt('Your Version Settings have been Stored').'</h1>');
                    711: 	} else {
                    712: 	    $r->print('<h1><font color="red">'.&mt('An Error Occured while Attempting to Store your Version Settings').'</font></h1>');
                    713: 	}
1.91      www       714: 	&changewarning($r,'');
                    715:     }
1.89      www       716:     if ($ENV{'form.timerange'} eq 'all') {
                    717: # show all documents
                    718: 	$header=&mt('All Documents in Course');
1.91      www       719: 	$allsel=1;
1.90      www       720: 	foreach (keys %hash) {
                    721: 	    if ($_=~/^ids\_(\/res\/.+)$/) {
                    722: 		my $src=$1;
                    723: 		$changes{$src}=1;
                    724: 	    }
                    725: 	}
1.89      www       726:     } else {
                    727: # show documents which changed
                    728: 	%changes=&Apache::lonnet::dump
                    729: 	 ('versionupdate',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1.30      www       730:                      $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.89      www       731: 	my $firstkey=(keys %changes)[0];
                    732: 	unless ($firstkey=~/^error\:/) {
                    733: 	    unless ($ENV{'form.timerange'}) {
                    734: 		$ENV{'form.timerange'}=604800;
                    735: 	    }
                    736: 	    my $seltext=&mt('during the last').' '.$ENV{'form.timerange'}.' '
                    737: 		.&mt('seconds');
                    738: 	    if ($ENV{'form.timerange'}==-1) {
                    739: 		$seltext='since start of course';
                    740: 		$startsel='selected';
                    741: 		$ENV{'form.timerange'}=time;
                    742: 	    }
                    743: 	    $starttime=time-$ENV{'form.timerange'};
                    744: 	    if ($ENV{'form.timerange'}==2592000) {
                    745: 		$seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
                    746: 		$monthsel='selected';
                    747: 	    } elsif ($ENV{'form.timerange'}==604800) {
                    748: 		$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
                    749: 		$weeksel='selected';
                    750: 	    } elsif ($ENV{'form.timerange'}==86400) {
                    751: 		$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
                    752: 		$daysel='selected';
                    753: 	    }
                    754: 	    $header=&mt('Content changed').' '.$seltext;
                    755: 	} else {
                    756: 	    $header=&mt('No content modifications yet.');
                    757: 	}
                    758:     }
1.92      www       759:     %setversions=&Apache::lonnet::dump('resourceversions',
                    760: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
                    761: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.89      www       762:     my %lt=&Apache::lonlocal::texthash
1.88      www       763: 	      ('st' => 'Version changes since start of Course',
                    764: 	       'lm' => 'Version changes since last Month',
                    765: 	       'lw' => 'Version changes since last Week',
                    766: 	       'sy' => 'Version changes since Yesterday',
1.91      www       767:                'al' => 'All Resources (possibly large output)',
1.88      www       768: 	       'sd' => 'Display',
1.84      www       769: 	       'fi' => 'File',
                    770: 	       'md' => 'Modification Date',
1.87      www       771:                'mr' => 'Most recently published Version',
                    772: 	       've' => 'Version used in Course',
1.91      www       773:                'vu' => 'Set Version to be used in Course',
                    774: 'sv' => 'Set Versions to be used in Course according to Selections below',
                    775: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
                    776: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.84      www       777: 	       'di' => 'Differences');
1.89      www       778:     $r->print(<<ENDHEADERS);
1.31      www       779: <form action="/adm/coursedocs" method="post">
1.91      www       780: <input type="hidden" name="versions" value="1" />
                    781: <input type="submit" name="setmostrecent" value="$lt{'sm'}" />
                    782: <input type="submit" name="setcurrent" value="$lt{'sc'}" /><hr />
1.31      www       783: <select name="timerange">
1.88      www       784: <option value='all' $allsel>$lt{'al'}</option>
1.84      www       785: <option value="-1" $startsel>$lt{'st'}</option>
                    786: <option value="2592000" $monthsel>$lt{'lm'}</option>
                    787: <option value="604800" $weeksel>$lt{'lw'}</option>
                    788: <option value="86400" $daysel>$lt{'sy'}</option>
1.31      www       789: </select>
1.91      www       790: <input type="submit" name="display" value="$lt{'sd'}" />
1.89      www       791: <h3>$header</h3>
1.91      www       792: <input type="submit" name="setversions" value="$lt{'sv'}" />
1.103     matthew   793: <table border="0">
1.31      www       794: ENDHEADERS
1.91      www       795:     foreach (sort keys %changes) {
1.89      www       796: 	if ($changes{$_}>$starttime) {
                    797: 	    my ($root,$extension)=($_=~/^(.*)\.(\w+)$/);
                    798: 	    my $currentversion=&Apache::lonnet::getversion($_);
1.93      www       799: 	    if ($currentversion<0) {
                    800: 		$currentversion=&mt('Could not be determined.');
                    801: 	    }
1.89      www       802: 	    my $linkurl=&Apache::lonnet::clutter($_);
                    803: 	    $r->print(
1.103     matthew   804: 		      '<tr><td colspan="5"><br /><br /><font size="+1"><b>'.
1.91      www       805: 		      &Apache::lonnet::gettitle($linkurl).
1.103     matthew   806:                       '</b></font></td></tr>'.
                    807:                       '<tr><td>&nbsp;&nbsp;&nbsp;</td>'.
                    808:                       '<td colspan="4">'.
                    809:                       '<a href="'.$linkurl.'" target="cat">'.$linkurl.
                    810: 		      '</a></td></tr>'.
                    811:                       '<tr><td></td>'.
                    812:                       '<td title="'.$lt{'md'}.'">'.
1.102     matthew   813: 		      &Apache::lonlocal::locallocaltime(
                    814:                            &Apache::lonnet::metadata($root.'.'.$extension,
                    815:                                                      'lastrevisiondate')
                    816:                                                         ).
1.103     matthew   817:                       '</td>'.
                    818:                       '<td title="'.$lt{'mr'}.'"><nobr>Most Recent: '.
                    819:                       '<font size="+1">'.$currentversion.'</font>'.
                    820:                       '</nobr></td>'.
                    821:                       '<td title="'.$lt{'ve'}.'"><nobr>In Course: '.
                    822:                       '<font size="+1">');
1.87      www       823: # Used in course
1.89      www       824: 	    my $usedversion=$hash{'version_'.$linkurl};
1.93      www       825: 	    if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.89      www       826: 		$r->print($usedversion);
                    827: 	    } else {
                    828: 		$r->print($currentversion);
                    829: 	    }
1.103     matthew   830: 	    $r->print('</font></nobr></td><td title="'.$lt{'vu'}.'">'.
                    831:                       '<nobr>Use: ');
1.87      www       832: # Set version
1.92      www       833: 	    $r->print(&Apache::loncommon::select_form($setversions{$linkurl},
1.89      www       834: 						      'set_version_'.$linkurl,
                    835: 						      ('' => '',
1.93      www       836: 						       'mostrecent' => 'most recent',
1.89      www       837: 						       map {$_,$_} (1..$currentversion))));
1.103     matthew   838: 	    $r->print('</nobr></td></tr><tr><td></td>');
1.89      www       839: 	    my $lastold=1;
                    840: 	    for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
                    841: 		my $url=$root.'.'.$prevvers.'.'.$extension;
                    842: 		if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
                    843: 		    $starttime) {
                    844: 		    $lastold=$prevvers;
                    845: 		}
                    846: 	    }
1.103     matthew   847:             # 
                    848:             # Code to figure out how many version entries should go in
                    849:             # each of the four columns
                    850:             my $entries_per_col = 0;
                    851:             my $num_entries = ($currentversion-$lastold);
                    852:             if ($num_entries % 4 == 0) {
                    853:                 $entries_per_col = $num_entries/4;
                    854:             } else {
                    855:                 $entries_per_col = $num_entries/4 + 1;
                    856:             }
                    857:             my $entries_count = 0;
                    858:             $r->print('<td valign="top"><font size="-2">'); 
                    859:             my $cols_output = 1;
1.32      www       860:             for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
1.89      www       861: 		my $url=$root.'.'.$prevvers.'.'.$extension;
1.103     matthew   862: 		$r->print('<nobr><a href="'.&Apache::lonnet::clutter($url).
1.91      www       863: 			  '">'.&mt('Version').' '.$prevvers.'</a> ('.
1.103     matthew   864: 			  &Apache::lonlocal::locallocaltime(
                    865:                                 &Apache::lonnet::metadata($url,
                    866:                                                           'lastrevisiondate')
                    867:                                                             ).
1.91      www       868: 			  ')');
1.89      www       869: 		if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
1.33      www       870:                     $r->print(' <a href="/adm/diff?filename='.
1.89      www       871: 			      &Apache::lonnet::clutter($root.'.'.$extension).
                    872: 			      '&versionone='.$prevvers.
                    873: 			      '">'.&mt('Diffs').'</a>');
                    874: 		}
1.103     matthew   875: 		$r->print('</nobr><br />');
                    876:                 if (++$entries_count % $entries_per_col == 0) {
                    877:                     $r->print('</font></td>');
                    878:                     if ($cols_output != 4) {
                    879:                         $r->print('<td valign="top"><font size="-2">');
                    880:                         $cols_output++;
                    881:                     }
                    882:                 }
1.89      www       883: 	    }
1.103     matthew   884:             while($cols_output++ < 4) {
                    885:                 $r->print('</font></td><td><font>')
                    886:             }
                    887: 	    $r->print('</font></td></tr>'."\n");
1.89      www       888: 	}
                    889:     }
1.92      www       890:     $r->print('</table></form>');
1.89      www       891:     $r->print('<h1>'.&mt('Done').'.</h1>');
                    892: 
                    893:     &untiehash();
1.75      www       894: }
                    895: 
1.91      www       896: sub changewarning {
                    897:     my ($r,$postexec)=@_;
                    898:     $r->print(
                    899: '<script>function reinit(tf) { tf.submit();'.$postexec.' }</script>'. 
                    900: '<form method="post" action="/adm/roles" target="loncapaclient">'.
                    901: '<input type="hidden" name="orgurl" value="/adm/coursedocs" /><input type="hidden" name="selectrole" value="1" /><h3><font color="red">'.
                    902: &mt('Changes will become active for your current session after').
                    903: ' <input type="hidden" name="'.
                    904: $ENV{'request.role'}.'" value="1" /><input type="button" value="'.
                    905: &mt('re-initializing course').'" onClick="reinit(this.form)"/>'.&mt(', or the next time you log in.').
                    906: $help{'Caching'}.'</font></h3></form>');
                    907: }
                    908: 
1.75      www       909: # ================================================================ Main Handler
                    910: sub handler {
                    911:     my $r = shift;
1.82      www       912:     &Apache::loncommon::content_type($r,'text/html');
1.75      www       913:     $r->send_http_header;
                    914:     return OK if $r->header_only;
                    915: 
                    916: # --------------------------------------------- Initialize help topics for this
                    917:   foreach ('Adding_Course_Doc','Main_Course_Documents',
                    918:            'Adding_External_Resource','Navigate_Content',
                    919:            'Adding_Folders','Docs_Overview', 'Load_Map',
                    920:            'Supplemental', 'Score_Upload_Form',
                    921:            'Importing_LON-CAPA_Resource','Uploading_From_Harddrive') {
                    922:       $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);
                    923:   }
                    924:     # Composite help files
                    925:     $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
                    926: 		    'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
                    927:     $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
                    928: 		    'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
1.86      albertel  929:     $help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
                    930: 		    'Option_Response_Simple');
1.75      www       931:     $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
                    932: 		    'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
                    933:     $help{'My Personal Info'} = &Apache::loncommon::help_open_topic(
                    934: 		  'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
                    935:     $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
                    936:  
                    937:   if ($ENV{'form.verify'}) {
                    938:       &verifycontent($r);
                    939:   } elsif ($ENV{'form.versions'}) {
                    940:       &checkversions($r);
                    941:   } elsif ($ENV{'form.dumpcourse'}) {
                    942:       &dumpcourse($r);
1.26      www       943:   } else {
1.7       www       944: # is this a standard course?
                    945: 
                    946:     my $standard=($ENV{'request.course.uri'}=~/^\/uploaded\//);
1.15      www       947:     my $forcestandard;
                    948:     my $forcesupplement;
                    949:     my $script='';
                    950:     my $allowed;
                    951:     my $events='';
1.19      www       952:     my $showdoc=0;
1.15      www       953:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.114   ! albertel  954: 					    ['folderpath']);
        !           955:     if ($ENV{'form.folderpath'}) {
        !           956: 	my (@folderpath)=split('&',$ENV{'form.folderpath'});
        !           957: 	$ENV{'form.foldername'}=&Apache::lonnet::unescape(pop(@folderpath));
        !           958: 	$ENV{'form.folder'}=pop(@folderpath);
        !           959: 	$ENV{'form.folders'}=\@folderpath;
        !           960:     }
1.21      www       961:     if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
                    962:        $showdoc=$1;
                    963:     }
                    964:     unless ($showdoc) { # got called from remote
1.15      www       965:        $forcestandard=($ENV{'form.folder'}=~/^default_/);
                    966:        $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
1.7       www       967: 
1.4       www       968: # does this user have privileges to post, etc?
1.77      www       969:        $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
1.15      www       970:        if ($allowed) { 
                    971:          &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
                    972:          $script=&Apache::lonratedt::editscript('simple'); 
                    973:        }
                    974:     } else { # got called in sequence from course
                    975:        $allowed=0;
1.49      www       976:        $script='</script>'.&Apache::lonmenu::registerurl(1,undef).'<script>';
                    977:        $events='onLoad="'.&Apache::lonmenu::loadevents.
                    978:            '" onUnload="'.&Apache::lonmenu::unloadevents.'"';
1.3       www       979:     }
1.4       www       980: 
                    981: # get course data
                    982:     my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
                    983:     my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
                    984: 
1.14      www       985: # get personal data
                    986:  
                    987:     my $uname=$ENV{'user.name'};
                    988:     my $udom=$ENV{'user.domain'};
                    989:     my $plainname=&Apache::lonnet::escape(
                    990:                      &Apache::loncommon::plainname($uname,$udom));
                    991: 
1.8       www       992: # graphics settings
1.4       www       993: 
1.8       www       994:     $iconpath = $r->dir_config('lonIconsURL') . "/";
                    995: 
1.22      www       996:     my $now=time;
1.64      www       997: 
1.4       www       998: # print screen
1.1       www       999:     $r->print(<<ENDDOCUMENT);
                   1000: <html>
                   1001: <head>
                   1002: <title>The LearningOnline Network with CAPA</title>
1.16      www      1003: <script>
                   1004: $script
1.20      www      1005: </script>
1.19      www      1006: ENDDOCUMENT
                   1007:    if ($allowed) {
                   1008:     $r->print(<<ENDNEWSCRIPT);
1.20      www      1009: <script>
1.16      www      1010: function makenewfolder(targetform,folderseq) {
                   1011:     var foldername=prompt('Name of New Folder','New Folder');
                   1012:     if (foldername) {
                   1013: 	targetform.importdetail.value=foldername+"="+folderseq;
                   1014:         targetform.submit();
                   1015:     }
                   1016: }
                   1017: 
1.18      www      1018: function makenewext(targetname) {
                   1019:     this.document.forms.extimport.useform.value=targetname;
                   1020:     window.open('/adm/rat/extpickframe.html');
                   1021: }
                   1022: 
1.62      www      1023: function makeexamupload() {
                   1024:    var title=prompt('Listed Title for the Uploaded Score');
                   1025:    if (title) { 
                   1026:     this.document.forms.newexamupload.importdetail.value=
                   1027: 	title+'=/res/lib/templates/examupload.problem';
                   1028:     this.document.forms.newexamupload.submit();
                   1029:    }
                   1030: }
                   1031: 
1.22      www      1032: function makesmppage() {
1.38      www      1033:    var title=prompt('Listed Title for the Page');
                   1034:    if (title) { 
1.22      www      1035:     this.document.forms.newsmppg.importdetail.value=
                   1036: 	title+'=/adm/$udom/$uname/$now/smppg';
                   1037:     this.document.forms.newsmppg.submit();
1.38      www      1038:    }
1.22      www      1039: }
                   1040: 
1.55      www      1041: function makesmpproblem() {
                   1042:    var title=prompt('Listed Title for the Problem');
                   1043:    if (title) { 
                   1044:     this.document.forms.newsmpproblem.importdetail.value=
1.63      www      1045: 	title+'=/res/lib/templates/simpleproblem.problem';
1.55      www      1046:     this.document.forms.newsmpproblem.submit();
                   1047:    }
                   1048: }
                   1049: 
1.22      www      1050: function makebulboard() {
1.38      www      1051:    var title=prompt('Listed Title for the Bulletin Board');
                   1052:    if (title) {
1.22      www      1053:     this.document.forms.newbul.importdetail.value=
                   1054: 	title+'=/adm/$udom/$uname/$now/bulletinboard';
                   1055:     this.document.forms.newbul.submit();
1.38      www      1056:    }
1.22      www      1057: }
                   1058: 
1.101     www      1059: function makeabout() {
                   1060:    var user=prompt("Enter user\@domain for User's 'About Me' Page");
                   1061:    if (user) {
                   1062:        var comp=new Array();
                   1063:        comp=user.split('\@');
                   1064:        if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
                   1065: 	   if ((comp[0]) && (comp[1])) {
                   1066: 	       this.document.forms.newaboutsomeone.importdetail.value=
                   1067: 		   'About '+user+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
                   1068: 	       this.document.forms.newaboutsomeone.submit();
                   1069: 	   }
                   1070:        }
                   1071:    }
                   1072: }
                   1073: 
1.110     raeburn  1074: function makeims() {
                   1075:     var caller = document.forms.ims.folder.value
                   1076:     var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one"
                   1077:     newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes")
                   1078:     newWindow.location.href = newlocation
                   1079: }
                   1080: 
                   1081: 
1.18      www      1082: function finishpick() {
                   1083:     var title=this.document.forms.extimport.title.value;
                   1084:     var url=this.document.forms.extimport.url.value;
                   1085:     var form=this.document.forms.extimport.useform.value;
                   1086:     eval
                   1087:      ('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+
                   1088:     '";this.document.forms.'+form+'.submit();');
1.16      www      1089: }
1.36      www      1090: 
1.109     albertel 1091: function changename(folder,index,oldtitle,foldername) {
1.36      www      1092:     var title=prompt('New Title',oldtitle);
                   1093:     if (title) {
                   1094: 	this.document.forms.renameform.title.value=title;
                   1095: 	this.document.forms.renameform.cmd.value='rename_'+index;
1.54      www      1096: 	this.document.forms.renameform.folder.value=folder;
1.109     albertel 1097: 	this.document.forms.renameform.foldername.value=foldername;
1.54      www      1098:         this.document.forms.renameform.submit();
                   1099:     }
                   1100: }
                   1101: 
1.109     albertel 1102: function removeres(folder,index,oldtitle,foldername) {
1.106     www      1103:     if (confirm('Remove "'+oldtitle+'"?')) {
1.54      www      1104: 	this.document.forms.renameform.cmd.value='del_'+index;
1.36      www      1105: 	this.document.forms.renameform.folder.value=folder;
1.109     albertel 1106: 	this.document.forms.renameform.foldername.value=foldername;
1.36      www      1107:         this.document.forms.renameform.submit();
                   1108:     }
                   1109: }
1.16      www      1110: </script>
1.42      www      1111: 
                   1112: ENDNEWSCRIPT
                   1113:   }
                   1114: # -------------------------------------------------------------------- Body tag
                   1115:   $r->print('</head>'.
1.72      www      1116:             &Apache::loncommon::bodytag('Course Documents','',$events,
1.99      www      1117: 					'','',$showdoc).
                   1118: 	    &Apache::loncommon::help_open_faq(273).
                   1119: 	    &Apache::loncommon::help_open_bug('RAT'));
1.42      www      1120:   unless ($showdoc) {
1.81      www      1121: # -----------------------------------------------------------------------------
                   1122:        my %lt=&Apache::lonlocal::texthash(
                   1123:                 'uplm' => 'Upload a new main course document',
                   1124:                 'upls' => 'Upload a new supplemental course document',
                   1125:                 'impp' => 'Import a published document',
                   1126:                 'spec' => 'Special documents',
                   1127:                 'upld' => 'Upload Document',
                   1128:                 'srch' => 'Search',
                   1129:                 'impo' => 'Import',
                   1130:                 'selm' => 'Select Map',
                   1131:                 'load' => 'Load Map',
                   1132:                 'newf' => 'New Folder',
                   1133:                 'extr' => 'External Resource',
                   1134:                 'syll' => 'Syllabus',
                   1135:                 'navc' => 'Navigate Contents',
                   1136:                 'sipa' => 'Simple Page',
                   1137:                 'sipr' => 'Simple Problem',
                   1138:                 'scuf' => 'Score Upload Form',
                   1139:                 'bull' => 'Bulletin Board',
1.96      sakharuk 1140:                 'mypi' => 'My Personal Info',
1.101     www      1141: 		'abou' => 'About User',
1.110     raeburn  1142:                 'imsf' => 'Import IMS package',
1.96      sakharuk 1143:                 'file' =>  'File',
                   1144:                 'title' => 'Title',
                   1145:                 'comment' => 'Comment' 
1.81      www      1146: 					  );
                   1147: # -----------------------------------------------------------------------------
1.42      www      1148:     if ($allowed) {
1.74      www      1149:        my $dumpbut=&dumpbutton();
1.88      www      1150:        my %lt=&Apache::lonlocal::texthash(
                   1151: 					 'vc' => 'Verify Content',
                   1152: 					 'cv' => 'Check/Set Resource Versions',
                   1153: 					  );
1.42      www      1154:        $r->print(<<ENDCOURSEVERIFY);
1.36      www      1155: <form name="renameform" method="post" action="/adm/coursedocs">
                   1156: <input type="hidden" name="title" />
                   1157: <input type="hidden" name="cmd" />
                   1158: <input type="hidden" name="folder" />
1.109     albertel 1159: <input type="hidden" name="foldername" />
1.36      www      1160: </form>
1.39      www      1161: <form name="simpleedit" method="post" action="/adm/coursedocs">
                   1162: <input type=hidden name="importdetail" value="">
                   1163: <input type="hidden" name="folder" />
1.109     albertel 1164: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
1.39      www      1165: </form>
1.26      www      1166: <form action="/adm/coursedocs" method="post" name="courseverify">
1.74      www      1167: <table bgcolor="#AAAAAA" width="100%" cellspacing="4" cellpadding="4">
                   1168: <tr><td bgcolor="#DDDDCC">
1.88      www      1169: <input type="submit" name="verify" value="$lt{'vc'}" />
1.74      www      1170: </td><td bgcolor="#DDDDCC">
1.88      www      1171: <input type="submit" name="versions" value="$lt{'cv'}" />
1.74      www      1172: $dumpbut
                   1173: </td></tr></table>
1.25      www      1174: </form>
                   1175: ENDCOURSEVERIFY
1.74      www      1176:        $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
1.96      sakharuk 1177: 		     &mt('Editing the Table of Contents for your Course')));
1.25      www      1178:     }
1.17      www      1179: # --------------------------------------------------------- Standard documents
1.111     albertel 1180:     my $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'},'<>&"');
1.43      www      1181:     $r->print('<table border=2 cellspacing=4 cellpadding=4>');
1.7       www      1182:     if (($standard) && ($allowed) && (!$forcesupplement)) {
1.81      www      1183:        $r->print('<tr><td bgcolor="#BBBBBB"><h2>'.&mt('Main Course Documents').
1.47      www      1184:   ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>');
1.7       www      1185:        my $folder=$ENV{'form.folder'};
1.112     raeburn  1186:        if ($folder eq '') {
                   1187:            $folder='default';
                   1188:        }
1.51      www      1189:        my $postexec='';
                   1190:        if ($folder eq 'default') {
                   1191: 	   $r->print('<script>this.window.name="loncapaclient";</script>');
                   1192:        } else {
                   1193:            $postexec='self.close();';
                   1194:        }
1.40      www      1195:        $hadchanges=0;
1.7       www      1196:        &editor($r,$coursenum,$coursedom,$folder,$allowed);
1.40      www      1197:        if ($hadchanges) {
1.91      www      1198: 	   &changewarning($r,$postexec);
1.40      www      1199:        }
1.16      www      1200:        my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
                   1201:                      '.sequence';
1.8       www      1202:        $r->print(<<ENDFORM);
1.43      www      1203: <table cellspacing=4 cellpadding=4><tr>
1.81      www      1204: <th bgcolor="#DDDDDD">$lt{'uplm'}</th>
                   1205: <th bgcolor="#DDDDDD">$lt{'impp'}</th>
                   1206: <th bgcolor="#DDDDDD">$lt{'spec'}</th>
1.11      www      1207: </tr>
1.16      www      1208: <tr><td bgcolor="#DDDDDD">
1.96      sakharuk 1209: $lt{'file'}:<br />
1.10      www      1210: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.59      www      1211: <input type="file" name="uploaddoc" size="40">
1.8       www      1212: <br />
1.96      sakharuk 1213: $lt{'title'}:<br />
1.11      www      1214: <input type="text" size="50" name="comment">
1.8       www      1215: <input type="hidden" name="folder" value="$folder">
1.109     albertel 1216: <input type="hidden" name="foldername" value="$htmlfoldername">
1.10      www      1217: <input type="hidden" name="cmd" value="upload_default">
1.81      www      1218: <input type="submit" value="$lt{'upld'}">
1.59      www      1219: <nobr>
1.60      albertel 1220:  $help{'Uploading_From_Harddrive'}
1.58      albertel 1221: </nobr>
1.60      albertel 1222: </form>
1.11      www      1223: </td>
1.16      www      1224: <td bgcolor="#DDDDDD">
1.39      www      1225: <form action="/adm/coursedocs" method="post" name="simpleeditdefault">
1.53      www      1226: <input type="hidden" name="folder" value="$folder">
1.109     albertel 1227: <input type="hidden" name="foldername" value="$htmlfoldername">
1.11      www      1228: <input type=button onClick=
1.81      www      1229: "javascript:document.forms.simpleedit.folder.value='$folder';groupsearch()" value="$lt{'srch'}">
1.58      albertel 1230: <nobr>
1.11      www      1231: <input type=button onClick=
1.81      www      1232: "javascript:document.forms.simpleedit.folder.value='$folder';groupimport();" value="$lt{'impo'}">
1.58      albertel 1233: $help{'Importing_LON-CAPA_Resource'}
                   1234: </nobr>
1.59      www      1235: <p>
                   1236: <hr />
1.68      bowersj2 1237: <input type="text" size="20" name="importmap"><br />
                   1238: <nobr><input type=button 
1.52      www      1239: onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
1.81      www      1240: value="$lt{'selm'}"> <input type="submit" name="loadmap" value="$lt{'load'}">
1.68      bowersj2 1241: $help{'Load_Map'}</nobr>
1.59      www      1242: </p>
1.52      www      1243: </form>
1.16      www      1244: </td><td bgcolor="#DDDDDD">
1.11      www      1245: <form action="/adm/coursedocs" method="post" name="newfolder">
1.16      www      1246: <input type="hidden" name="folder" value="$folder">
1.109     albertel 1247: <input type="hidden" name="foldername" value="$htmlfoldername">
1.13      www      1248: <input type=hidden name="importdetail" value="">
1.58      albertel 1249: <nobr>
1.16      www      1250: <input name="newfolder" type="button"
                   1251: onClick="javascript:makenewfolder(this.form,'$folderseq');"
1.81      www      1252: value="$lt{'newf'}" />$help{'Adding_Folders'}
1.58      albertel 1253: </nobr>
1.11      www      1254: </form>
                   1255: <form action="/adm/coursedocs" method="post" name="newext">
1.16      www      1256: <input type="hidden" name="folder" value="$folder">
1.109     albertel 1257: <input type="hidden" name="foldername" value="$htmlfoldername">
1.13      www      1258: <input type=hidden name="importdetail" value="">
1.58      albertel 1259: <nobr>
1.18      www      1260: <input name="newext" type="button" onClick="javascript:makenewext('newext');"
1.81      www      1261: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
1.58      albertel 1262: </nobr>
1.11      www      1263: </form>
                   1264: <form action="/adm/coursedocs" method="post" name="newsyl">
1.16      www      1265: <input type="hidden" name="folder" value="$folder">
1.109     albertel 1266: <input type="hidden" name="foldername" value="$htmlfoldername">
1.14      www      1267: <input type=hidden name="importdetail" 
                   1268: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
1.58      albertel 1269: <nobr>
1.81      www      1270: <input name="newsyl" type="submit" value="$lt{'syll'}" /> 
1.65      bowersj2 1271:  $help{'Syllabus'}
1.58      albertel 1272: </nobr>
                   1273: </form>
1.17      www      1274: <form action="/adm/coursedocs" method="post" name="newnav">
1.20      www      1275: <input type="hidden" name="folder" value="$folder">
1.109     albertel 1276: <input type="hidden" name="foldername" value="$htmlfoldername">
1.15      www      1277: <input type=hidden name="importdetail" 
                   1278: value="Navigate Content=/adm/navmaps">
1.58      albertel 1279: <nobr>
1.81      www      1280: <input name="newnav" type="submit" value="$lt{'navc'}" />
1.47      www      1281: $help{'Navigate_Content'}
1.58      albertel 1282: </nobr>
1.22      www      1283: </form>
                   1284: <form action="/adm/coursedocs" method="post" name="newsmppg">
                   1285: <input type="hidden" name="folder" value="$folder">
1.109     albertel 1286: <input type="hidden" name="foldername" value="$htmlfoldername">
1.22      www      1287: <input type=hidden name="importdetail" value="">
1.58      albertel 1288: <nobr>
1.81      www      1289: <input name="newsmppg" type="button" value="$lt{'sipa'}"
1.65      bowersj2 1290: onClick="javascript:makesmppage();" /> $help{'Simple Page'}
1.58      albertel 1291: </nobr>
1.55      www      1292: </form>
                   1293: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
                   1294: <input type="hidden" name="folder" value="$folder">
1.109     albertel 1295: <input type="hidden" name="foldername" value="$htmlfoldername">
1.55      www      1296: <input type=hidden name="importdetail" value="">
1.58      albertel 1297: <nobr>
1.81      www      1298: <input name="newsmpproblem" type="button" value="$lt{'sipr'}"
1.65      bowersj2 1299: onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
1.62      www      1300: </nobr>
                   1301: </form>
                   1302: <form action="/adm/coursedocs" method="post" name="newexamupload">
                   1303: <input type="hidden" name="folder" value="$folder">
1.109     albertel 1304: <input type="hidden" name="foldername" value="$htmlfoldername">
1.62      www      1305: <input type=hidden name="importdetail" value="">
                   1306: <nobr>
1.81      www      1307: <input name="newexamupload" type="button" value="$lt{'scuf'}"
1.62      www      1308: onClick="javascript:makeexamupload();" />
1.66      bowersj2 1309: $help{'Score_Upload_Form'}
1.58      albertel 1310: </nobr>
1.22      www      1311: </form>
                   1312: <form action="/adm/coursedocs" method="post" name="newbul">
                   1313: <input type="hidden" name="folder" value="$folder">
1.109     albertel 1314: <input type="hidden" name="foldername" value="$htmlfoldername">
1.22      www      1315: <input type=hidden name="importdetail" value="">
1.58      albertel 1316: <nobr>
1.81      www      1317: <input name="newbulletin" type="button" value="$lt{'bull'}"
1.22      www      1318: onClick="javascript:makebulboard();" />
1.65      bowersj2 1319: $help{'Bulletin Board'}
1.58      albertel 1320: </nobr>
                   1321: </form>
1.12      www      1322: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.16      www      1323: <input type="hidden" name="folder" value="$folder">
1.109     albertel 1324: <input type="hidden" name="foldername" value="$htmlfoldername">
1.14      www      1325: <input type=hidden name="importdetail" 
                   1326: value="$plainname=/adm/$udom/$uname/aboutme">
1.58      albertel 1327: <nobr>
1.81      www      1328: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
1.65      bowersj2 1329: $help{'My Personal Info'}
1.101     www      1330: </nobr>
                   1331: </form>
                   1332: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
                   1333: <input type="hidden" name="folder" value="$folder">
1.109     albertel 1334: <input type="hidden" name="foldername" value="$htmlfoldername">
1.101     www      1335: <input type=hidden name="importdetail" value="">
                   1336: <nobr>
                   1337: <input name="newaboutsomeone" type="button" value="$lt{'abou'}" 
                   1338: onClick="javascript:makeabout();" />
1.110     raeburn  1339: </nobr>
                   1340: </form>
                   1341: <form action="/adm/imsimportdocs" method="post" name="ims">
                   1342: <input type="hidden" name="folder" value="$folder" />
                   1343: <input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" />
1.58      albertel 1344: </nobr>
                   1345: </form>
1.11      www      1346: </td></tr>
                   1347: </table>
1.8       www      1348: ENDFORM
1.24      www      1349:        $r->print('</td></tr>');
1.7       www      1350:     }
                   1351: # ----------------------------------------------------- Supplemental documents
                   1352:     if (!$forcestandard) {
1.24      www      1353:        $r->print(
1.81      www      1354:   '<tr><td bgcolor="#BBBBBB"><h2>'.&mt('Supplemental Course Documents').
1.47      www      1355:   ($allowed?' '.$help{'Supplemental'}:'').'</h2>');
1.7       www      1356:        my $folder=$ENV{'form.folder'};
1.10      www      1357:        unless ($folder=~/supplemental/) { $folder='supplemental'; }
1.7       www      1358:        &editor($r,$coursenum,$coursedom,$folder,$allowed);
1.8       www      1359:        if ($allowed) {
1.17      www      1360:        my $folderseq=
                   1361:                   '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
                   1362:                      '.sequence';
                   1363: 
1.8       www      1364:           $r->print(<<ENDSUPFORM);
1.43      www      1365: <table cellspacing=4 cellpadding=4><tr>
1.81      www      1366: <th bgcolor="#DDDDDD">$lt{'upls'}</th>
                   1367: <th bgcolor="#DDDDDD">$lt{'spec'}</th>
1.17      www      1368: </tr>
                   1369: <tr><td bgcolor="#DDDDDD">
1.10      www      1370: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.59      www      1371: <input type="file" name="uploaddoc" size="40">
1.96      sakharuk 1372: <br />$lt{'comment'}:<br />
1.4       www      1373: <textarea cols=50 rows=4 name='comment'>
                   1374: </textarea>
1.8       www      1375: <input type="hidden" name="folder" value="$folder">
1.109     albertel 1376: <input type="hidden" name="foldername" value="$htmlfoldername">
1.10      www      1377: <input type="hidden" name="cmd" value="upload_supplemental">
1.58      albertel 1378: <nobr>
1.81      www      1379: <input type="submit" value="$lt{'upld'}">
1.58      albertel 1380:  $help{'Uploading_From_Harddrive'}
                   1381: </nobr>
                   1382: </form>
1.17      www      1383: </td>
                   1384: <td bgcolor="#DDDDDD">
1.18      www      1385: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.17      www      1386: <input type="hidden" name="folder" value="$folder">
1.109     albertel 1387: <input type="hidden" name="foldername" value="$htmlfoldername">
1.17      www      1388: <input type=hidden name="importdetail" value="">
1.58      albertel 1389: <nobr>
1.17      www      1390: <input name="newfolder" type="button"
                   1391: onClick="javascript:makenewfolder(this.form,'$folderseq');"
1.81      www      1392: value="$lt{'newf'}" /> $help{'Adding_Folders'}
1.58      albertel 1393: </nobr>
1.17      www      1394: </form>
1.18      www      1395: <form action="/adm/coursedocs" method="post" name="supnewext">
1.17      www      1396: <input type="hidden" name="folder" value="$folder">
1.109     albertel 1397: <input type="hidden" name="foldername" value="$htmlfoldername">
1.17      www      1398: <input type=hidden name="importdetail" value="">
1.58      albertel 1399: <nobr>
1.18      www      1400: <input name="newext" type="button" 
                   1401: onClick="javascript:makenewext('supnewext');"
1.81      www      1402: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
1.58      albertel 1403: </nobr>
1.17      www      1404: </form>
1.18      www      1405: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.17      www      1406: <input type="hidden" name="folder" value="$folder">
1.109     albertel 1407: <input type="hidden" name="foldername" value="$htmlfoldername">
1.17      www      1408: <input type=hidden name="importdetail" 
                   1409: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
1.58      albertel 1410: <nobr>
1.81      www      1411: <input name="newsyl" type="submit" value="$lt{'syll'}" />
1.65      bowersj2 1412: $help{'Syllabus'}
1.58      albertel 1413: </nobr>
                   1414: </form>
1.18      www      1415: <form action="/adm/coursedocs" method="post" name="subnewaboutme">
1.17      www      1416: <input type="hidden" name="folder" value="$folder">
1.109     albertel 1417: <input type="hidden" name="foldername" value="$htmlfoldername">
1.17      www      1418: <input type=hidden name="importdetail" 
                   1419: value="$plainname=/adm/$udom/$uname/aboutme">
1.58      albertel 1420: <nobr>
1.81      www      1421: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
1.65      bowersj2 1422: $help{'My Personal Info'}
1.58      albertel 1423: </nobr>
                   1424: </form>
1.17      www      1425: </td></tr>
1.24      www      1426: </table></td></tr>
1.8       www      1427: ENDSUPFORM
                   1428:        }
1.7       www      1429:     }
1.18      www      1430:     if ($allowed) {
                   1431: 	$r->print('<form name="extimport"><input type="hidden" name="title"><input type="hidden" name="url"><input type="hidden" name="useform"></form>');
                   1432:     }
1.24      www      1433:     $r->print('</table>');
1.19      www      1434:   } else {
                   1435: # -------------------------------------------------------- This is showdoc mode
1.81      www      1436:       $r->print("<h1>".&mt('Uploaded Document').'</h1><p>'.
                   1437: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><p><table>".
                   1438:          &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table></p>');
1.19      www      1439:   }
1.26      www      1440:  }
1.95      www      1441:  $r->print('</body></html>');
1.26      www      1442:  return OK;
1.1       www      1443: } 
                   1444: 
                   1445: 1;
                   1446: __END__

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