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

1.1       www         1: # The LearningOnline Network
1.2       www         2: # Documents
1.1       www         3: #
1.125   ! www         4: # $Id: londocs.pm,v 1.124 2004/05/06 18:28:16 www Exp $
1.1       www         5: #
1.3       www         6: # Copyright Michigan State University Board of Trustees
1.1       www         7: #
1.3       www         8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
1.1       www         9: #
1.3       www        10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
1.1       www        14: #
1.3       www        15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
                     28: 
1.2       www        29: package Apache::londocs;
1.1       www        30: 
                     31: use strict;
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();
1.116     albertel  264:     my (@folders)=split('&',$ENV{'form.folderpath'});
                    265:     my $folderpath;
                    266:     while (@folders) {
                    267: 	my $folder=shift(@folders);
                    268: 	my $foldername=shift(@folders);
                    269: 	if ($folderpath) {$folderpath.='&';}
                    270: 	$folderpath.=$folder.'&'.$foldername;
                    271: 	my $url='/adm/coursedocs?folderpath='.
                    272: 	    &Apache::lonnet::escape($folderpath);
1.114     albertel  273: 	    &Apache::lonhtmlcommon::add_breadcrumb(
                    274: 		      {'href'=>$url,
                    275: 		       'title'=>&Apache::lonnet::unescape($foldername),
1.117     albertel  276: 		       'text'=>'<font size="+1">'.
                    277: 			   &Apache::lonnet::unescape($foldername).'</font>'
                    278: 		       });
1.114     albertel  279: 		       
                    280: 						 
                    281:     }
1.116     albertel  282:     return &Apache::lonhtmlcommon::breadcrumbs(undef,undef,undef,undef,undef,0);
1.114     albertel  283: }
                    284: 
1.7       www       285: sub editor {
                    286:     my ($r,$coursenum,$coursedom,$folder,$allowed)=@_;
1.114     albertel  287: 
                    288:     $r->print(&breadcrumbs($folder));
1.10      www       289:     my $errtext='';
                    290:     my $fatal=0;
                    291:     ($errtext,$fatal)=
1.7       www       292:           &mapread($coursenum,$coursedom,$folder.'.sequence');
1.17      www       293:     if ($#Apache::lonratedt::order<1) {
                    294:        	$Apache::lonratedt::order[0]=1;
                    295:         $Apache::lonratedt::resources[1]='';
                    296:     }
1.7       www       297:     if ($fatal) {
                    298: 	   $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    299:     } else {
                    300: # ------------------------------------------------------------ Process commands
1.121     www       301: 
1.16      www       302: # ---------------- if they are for this folder and user allowed to make changes
                    303: 	if (($allowed) && ($ENV{'form.folder'} eq $folder)) {
1.123     www       304: # set parameters and change order
1.121     www       305: 	    if (defined($ENV{'form.setparms'})) {
                    306: 		my $idx=$ENV{'form.setparms'};
1.123     www       307: # set parameters
1.121     www       308: 		if ($ENV{'form.randpick_'.$idx}) {
1.122     www       309: 		    &Apache::lonratedt::storeparameter($idx,'parameter_randompick',$ENV{'form.randpick_'.$idx},'int_pos');
1.121     www       310: 		} else {
1.122     www       311: 		    &Apache::lonratedt::delparameter($idx,'parameter_randompick');
1.121     www       312: 		}
                    313: 		if ($ENV{'form.hidprs_'.$idx}) {
1.122     www       314: 		    &Apache::lonratedt::storeparameter($idx,'parameter_hiddenresource','yes','string_yesno');
1.121     www       315: 		} else {
1.122     www       316: 		    &Apache::lonratedt::delparameter($idx,'parameter_hiddenresource');
1.121     www       317: 		}
                    318: 		if ($ENV{'form.encprs_'.$idx}) {
1.122     www       319: 		    &Apache::lonratedt::storeparameter($idx,'parameter_encrypturl','yes','string_yesno');
1.121     www       320: 		} else {
1.122     www       321: 		    &Apache::lonratedt::delparameter($idx,'parameter_encrypturl');
1.121     www       322: 		}
                    323: 
1.123     www       324: 		if ($ENV{'form.newpos'}) {
                    325: # change order
                    326: 
                    327: 		    my $newpos=$ENV{'form.newpos'}-1;
1.124     www       328: 		    my $currentpos=$ENV{'form.currentpos'}-1;
1.125   ! www       329: 		    my $i;
        !           330: 		    my @neworder=();
        !           331: 		    if ($newpos>$currentpos) {
        !           332: # moving stuff up
        !           333: 			for ($i=0;$i<$currentpos;$i++) {
        !           334: 			    $neworder[$i]=$Apache::lonratedt::order[$i];
        !           335: 			}
        !           336: 			for ($i=$currentpos;$i<$newpos;$i++) {
        !           337: 			    $neworder[$i]=$Apache::lonratedt::order[$i+1];
        !           338: 			}
        !           339:                         $neworder[$newpos]=$Apache::lonratedt::order[$currentpos];
        !           340: 			for ($i=$newpos+1;$i<=$#Apache::lonratedt::order;$i++) {
        !           341: 			    $neworder[$i]=$Apache::lonratedt::order[$i];
        !           342: 			}
        !           343: 		    } else {
        !           344: # moving stuff down
        !           345: 			for ($i=0;$i<$newpos;$i++) {
        !           346: 			    $neworder[$i]=$Apache::lonratedt::order[$i];
        !           347: 			}
        !           348: 			$neworder[$newpos]=$Apache::lonratedt::order[$currentpos];
        !           349: 			for ($i=$newpos+1;$i<$currentpos+1;$i++) {
        !           350: 			    $neworder[$i]=$Apache::lonratedt::order[$i-1];
        !           351: 			}
        !           352: 			for ($i=$currentpos+1;$i<=$#Apache::lonratedt::order;$i++) {
        !           353: 			    $neworder[$i]=$Apache::lonratedt::order[$i];
        !           354: 			}
        !           355: 		    }
        !           356: 		    @Apache::lonratedt::order=@neworder;
1.124     www       357: 		}
                    358: # store the changed version
1.123     www       359: 
1.124     www       360: 		($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.sequence');
                    361: 		if ($fatal) {
                    362: 		    $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    363: 		    return;
1.123     www       364: 		}
1.124     www       365: 		
                    366: 	    }
1.123     www       367: 
1.10      www       368: # upload a file, if present
                    369:            if (($ENV{'form.uploaddoc.filename'}) &&
                    370:                ($ENV{'form.cmd'}=~/^upload_(\w+)/)) {
1.112     raeburn   371: 	    if ( ($folder=~/^$1/) || ($1 eq 'default') ) {
1.10      www       372: # this is for a course, not a user, so set coursedoc flag
                    373: # probably the only place in the system where this should be "1"
                    374: 	      my $url=&Apache::lonnet::userfileupload('uploaddoc',1);
                    375:               my $ext='false';
                    376:               if ($url=~/^http\:\/\//) { $ext='true'; }
                    377:               $url=~s/\:/\&colon;/g;
                    378: 	      my $comment=$ENV{'form.comment'};
                    379:               $comment=~s/\</\&lt\;/g;
                    380:               $comment=~s/\>/\&gt\;/g;
                    381:               $comment=~s/\:/\&colon;/g;
1.17      www       382:               if ($folder=~/^supplemental/) {
                    383: 		  $comment=time.'___&&&___'.$ENV{'user.name'}.'___&&&___'.
                    384: 		      $ENV{'user.domain'}.'___&&&___'.$comment;
                    385:               }
1.10      www       386:               my $newidx=$#Apache::lonratedt::resources+1;
                    387:               $Apache::lonratedt::resources[$newidx]=
                    388:                   $comment.':'.$url.':'.$ext.':normal:res';
                    389:               $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=
                    390:                                                               $newidx;       
1.104     albertel  391: 
                    392: 	      ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.sequence');
                    393: 	      if ($fatal) {
                    394: 		  $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    395: 		  return;
                    396: 	      }
1.10      www       397: 	     }
                    398:             }
1.8       www       399: 	    if ($ENV{'form.cmd'}) {
1.10      www       400:                 my ($cmd,$idx)=split(/\_/,$ENV{'form.cmd'});
                    401:                 if ($cmd eq 'del') {
                    402: 		    for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) {
                    403:                         $Apache::lonratedt::order[$i]=
                    404:                           $Apache::lonratedt::order[$i+1];
                    405:                     }
                    406:                     $#Apache::lonratedt::order--;
                    407:                 } elsif ($cmd eq 'up') {
1.38      www       408: 		  if (($idx) && (defined($Apache::lonratedt::order[$idx-1]))) {
1.10      www       409:                     my $i=$Apache::lonratedt::order[$idx-1];
                    410:                     $Apache::lonratedt::order[$idx-1]=
                    411: 			$Apache::lonratedt::order[$idx];
                    412:                     $Apache::lonratedt::order[$idx]=$i;
1.38      www       413: 		   }
1.10      www       414:                 } elsif ($cmd eq 'down') {
1.38      www       415: 		   if (defined($Apache::lonratedt::order[$idx+1])) {
1.10      www       416:                     my $i=$Apache::lonratedt::order[$idx+1];
                    417:                     $Apache::lonratedt::order[$idx+1]=
                    418: 			$Apache::lonratedt::order[$idx];
                    419:                     $Apache::lonratedt::order[$idx]=$i;
1.38      www       420: 		   }
1.36      www       421:                 } elsif ($cmd eq 'rename') {
                    422:                     my ($rtitle,@rrest)=split(/\:/,
                    423:                        $Apache::lonratedt::resources[
                    424: 				       $Apache::lonratedt::order[$idx]]);
1.38      www       425:                     my $comment=
                    426:                      &HTML::Entities::decode($ENV{'form.title'});
1.36      www       427:                     $comment=~s/\</\&lt\;/g;
                    428:                     $comment=~s/\>/\&gt\;/g;
                    429:                     $comment=~s/\:/\&colon;/g;
                    430:                     $Apache::lonratedt::resources[
                    431: 				       $Apache::lonratedt::order[$idx]]=
                    432:                              $comment.':'.join(':',@rrest);
                    433:                     
1.10      www       434:                 }
                    435: # Store the changed version
1.104     albertel  436: 		($errtext,$fatal)=&storemap($coursenum,$coursedom,
                    437: 					    $folder.'.sequence');
                    438: 		if ($fatal) {
                    439: 		    $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    440: 		    return;
                    441: 		}
1.8       www       442:             }
1.11      www       443: # Group import/search
                    444: 	    if ($ENV{'form.importdetail'}) {
1.73      bowersj2  445: 		my @imports;
                    446: 		foreach (split(/\&/,$ENV{'form.importdetail'})) {
                    447: 		    if (defined($_)) {
                    448: 			my ($name,$url)=split(/\=/,$_);
                    449: 			$name=&Apache::lonnet::unescape($name);
                    450: 			$url=&Apache::lonnet::unescape($url);
                    451: 			push @imports, $name, $url;
                    452: 		    }
                    453: 		}
1.11      www       454: # Store the changed version
1.104     albertel  455: 		($errtext,$fatal)=group_import($coursenum, $coursedom, $folder,
                    456: 					       @imports);
                    457: 		if ($fatal) {
                    458: 		    $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    459: 		    return;
                    460: 		}
1.11      www       461:             }
1.53      www       462: # Loading a complete map
                    463: 	   if (($ENV{'form.importmap'}) && ($ENV{'form.loadmap'})) {
1.104     albertel  464: 	       foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$ENV{'form.importmap'}))) {
1.53      www       465:                    my $idx=$#Apache::lonratedt::resources;
                    466:                    $idx++;
                    467:                    $Apache::lonratedt::resources[$idx]=$_;
                    468:                    $Apache::lonratedt::order
1.104     albertel  469: 		       [$#Apache::lonratedt::order+1]=$idx;
                    470: 	       }
1.53      www       471: 
                    472: # Store the changed version
1.104     albertel  473: 	       ($errtext,$fatal)=&storemap($coursenum,$coursedom,
                    474: 					   $folder.'.sequence');
                    475: 	       if ($fatal) {
                    476: 		   $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    477: 		   return;
                    478: 	       }
1.53      www       479:            }
1.16      www       480:        }
                    481: # ---------------------------------------------------------------- End commands
1.7       www       482: # ---------------------------------------------------------------- Print screen
1.10      www       483:         my $idx=0;
                    484:         $r->print('<table>');
                    485:         foreach (@Apache::lonratedt::order) {
                    486:            my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]);
                    487:            unless ($name) {  $name=(split(/\//,$url))[-1]; }
1.106     www       488:            unless ($name) { next; }
1.112     raeburn   489:            $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum));
1.10      www       490:            $idx++;
                    491:         }
                    492:         $r->print('</table>');
1.7       www       493:     }
                    494: }
1.1       www       495: 
1.8       www       496: # --------------------------------------------------------------- An entry line
                    497: 
                    498: sub entryline {
1.112     raeburn   499:     my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;
1.38      www       500:     $title=~s/\&colon\;/\:/g;
                    501:     $title=&HTML::Entities::encode(&HTML::Entities::decode(
1.109     albertel  502:      &Apache::lonnet::unescape($title)),'"<>&\'');
1.38      www       503:     my $renametitle=$title;
                    504:     my $foldertitle=$title;
1.122     www       505:     my $orderidx=$Apache::lonratedt::order[$index];
1.109     albertel  506:     if ($title=~ /^(\d+)___&amp;&amp;&amp;___(\w+)___&amp;&amp;&amp;___(\w+)___&amp;&amp;&amp;___(.*)$/	) { 
                    507: 	$foldertitle=&Apache::lontexconvert::msgtexconverted($4);
                    508: 	$renametitle=$4;
                    509: 	$title='<i>'.&Apache::lonlocal::locallocaltime($1).'</i> '.
                    510: 	    &Apache::loncommon::plainname($2,$3).': <br />'.
                    511: 	    $foldertitle;
                    512:     }
1.38      www       513:     $renametitle=~s/\&quot\;/\\\"/g;
1.8       www       514:     my $line='<tr>';
                    515: # Edit commands
1.120     www       516:     my $folderpath;
                    517:     if ($ENV{'form.folderpath'}) {
                    518: 	$folderpath=&Apache::lonnet::escape($ENV{'form.folderpath'});
                    519: 	# $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'},'<>&"');
                    520:     }
1.109     albertel  521:     if ($allowed) {
1.123     www       522: 	my $incindex=$index+1;
                    523: 	my $selectbox='';
                    524: 	if ($folder!~/^supplemental/) {
                    525: 	    $selectbox=
1.124     www       526: 		'<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.123     www       527: 		'<select name="newpos" onChange="this.form.submit()">';
                    528: 	    for (my $i=1;$i<=$#Apache::lonratedt::order+1;$i++) {
                    529: 		if ($i==$incindex) {
                    530: 		    $selectbox.='<option value="" selected="1">('.$i.')</option>';
                    531: 		} else {
                    532: 		    $selectbox.='<option value="'.$i.'">'.$i.'</option>';
                    533: 		}
                    534: 	    }
                    535: 	    $selectbox.='</select>';
                    536: 	}
1.119     www       537: 	my %lt=&Apache::lonlocal::texthash(
                    538:                 'up' => 'Move Up',
1.109     albertel  539: 		'dw' => 'Move Down',
                    540: 		'rm' => 'Remove',
                    541: 		'rn' => 'Rename');
                    542: 	$line.=(<<END);
1.121     www       543: <form name="entry_$index" action="/adm/coursedocs" method="post">
                    544: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.122     www       545: <input type="hidden" name="setparms" value="$orderidx" />
1.54      www       546: <td><table border='0' cellspacing='2' cellpadding='0'>
                    547: <tr><td bgcolor="#DDDDDD">
1.115     albertel  548: <a href='/adm/coursedocs?cmd=up_$index&folderpath=$folderpath'>
1.90      www       549: <img src="${iconpath}move_up.gif" alt='$lt{'up'}' border='0' /></a></td></tr>
1.54      www       550: <tr><td bgcolor="#DDDDDD">
1.115     albertel  551: <a href='/adm/coursedocs?cmd=down_$index&folderpath=$folderpath'>
1.90      www       552: <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' border='0' /></a></td></tr>
1.123     www       553: </table></td>
                    554: <td>$selectbox
                    555: </td><td bgcolor="#DDDDDD">
1.115     albertel  556: <a href='javascript:removeres("$folderpath","$index","$renametitle");'>
1.90      www       557: <font size="-2" color="#990000">$lt{'rm'}</font></a>
1.115     albertel  558: <a href='javascript:changename("$folderpath","$index","$renametitle");'>
1.90      www       559: <font size="-2" color="#009900">$lt{'rn'}</font></a></td>
1.8       www       560: END
                    561:     }
1.16      www       562: # Figure out what kind of a resource this is
                    563:     my ($extension)=($url=~/\.(\w+)$/);
                    564:     my $uploaded=($url=~/^\/*uploaded\//);
1.97      albertel  565:     my $icon=&Apache::loncommon::icon($url);
1.17      www       566:     my $isfolder=0;
1.114     albertel  567:     my $folderarg;
1.16      www       568:     if ($uploaded) {
                    569:        if ($extension eq 'sequence') {
1.97      albertel  570: 	  $icon=$iconpath.'/folder_closed.gif';
1.112     raeburn   571:           $url=~/$coursenum\/([\/\w]+)\.sequence$/;
1.114     albertel  572:           $url='/adm/coursedocs?';
                    573: 	  $folderarg=$1;
1.17      www       574:           $isfolder=1;
1.118     albertel  575:        }
1.16      www       576:     }
1.18      www       577:     $url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//;
1.113     albertel  578:     if ((!$isfolder) && ($residx) && ($folder!~/supplemental/)) {
                    579: 	my $symb=&Apache::lonnet::symbclean(
1.50      www       580:           &Apache::lonnet::declutter('uploaded/'.
                    581:            $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.'/'.
                    582:            $ENV{'course.'.$ENV{'request.course.id'}.'.num'}.'/'.$folder.
                    583:            '.sequence').
                    584:            '___'.$residx.'___'.
1.113     albertel  585: 	   &Apache::lonnet::declutter($url));
                    586: 	(undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
                    587: 	$url=&Apache::lonnet::clutter($url);
                    588: 	$url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb);
1.50      www       589:     }
1.120     www       590:     my $parameterset='&nbsp;';
1.114     albertel  591:     if ($isfolder) {
                    592: 	my $foldername=&Apache::lonnet::escape($foldertitle);
                    593: 	my $folderpath=$ENV{'form.folderpath'};
                    594: 	if ($folderpath) { $folderpath.='&' };
                    595: 	$folderpath.=$folderarg.'&'.$foldername;
                    596: 	$url.='folderpath='.&Apache::lonnet::escape($folderpath);
1.120     www       597: 	$parameterset=&mt('Randomly Pick: ').
1.122     www       598: 	    '<input type="text" size="4" name="randpick_'.$orderidx.'" value="'.
                    599: 	    (&Apache::lonratedt::getparameter($orderidx,'parameter_randompick'))[0].'" />';
1.114     albertel  600:     }
1.113     albertel  601:     $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'"><img src="'.$icon.
                    602: 	'" border="0"></a></td>'.
1.119     www       603:         "<td bgcolor='#FFFFBB'><a href='$url'>$title</a></td>";
1.120     www       604:     if (($allowed) && ($folder!~/^supplemental/)) {
                    605:  	my %lt=&Apache::lonlocal::texthash(
                    606:  			      'hd' => 'Hidden',
                    607:  			      'ec' => 'URL hidden',
                    608:  			      'sp' => 'Store Parameters');
1.122     www       609: 	my $enctext=
                    610: 	    ((&Apache::lonratedt::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="1"':'');
                    611: 	my $hidtext=
                    612: 	    ((&Apache::lonratedt::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':'');
1.120     www       613: 	$line.=(<<ENDPARMS);
                    614: <td bgcolor="#BBBBFF"><font size='-2'>
1.122     www       615: <input type="checkbox" name="hidprs_$orderidx" $hidtext/> $lt{'hd'}</td>
1.120     www       616: <td bgcolor="#BBBBFF"><font size='-2'>
1.122     www       617: <input type="checkbox" name="encprs_$orderidx" $enctext/> $lt{'ec'}</td>
1.120     www       618: <td bgcolor="#BBBBFF"><font size="-2">$parameterset</font></td>
                    619: <td bgcolor="#BBBBFF"><font size='-2'>
1.121     www       620: <input type="submit" value="$lt{'sp'}" />
1.120     www       621: </font></td>
                    622: ENDPARMS
1.119     www       623:     }
1.120     www       624:     $line.="</form></tr>";
1.8       www       625:     return $line;
                    626: }
                    627: 
1.27      www       628: # ---------------------------------------------------------------- tie the hash
                    629: 
                    630: sub tiehash {
                    631:     $hashtied=0;
                    632:     if ($ENV{'request.course.fn'}) {
                    633:         if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
                    634:             &GDBM_READER(),0640)) {
                    635:                 $hashtied=1;
                    636:         }
                    637:     }    
                    638: }
                    639: 
                    640: sub untiehash {
                    641:     if ($hashtied) { untie %hash; }
                    642:     $hashtied=0;
                    643: }
                    644: 
1.29      www       645: # --------------------------------------------------------------- check on this
                    646: 
                    647: sub checkonthis {
                    648:     my ($r,$url,$level,$title)=@_;
                    649:     $alreadyseen{$url}=1;
                    650:     $r->rflush();
1.41      www       651:     if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
1.108     albertel  652:        $r->print("\n<br />");
1.29      www       653:        for (my $i=0;$i<=$level*5;$i++) {
                    654:            $r->print('&nbsp;');
                    655:        }
                    656:        $r->print('<a href="'.$url.'" target="cat">'.
                    657: 		 ($title?$title:$url).'</a> ');
                    658:        if ($url=~/^\/res\//) {
                    659: 	  my $result=&Apache::lonnet::repcopy(
                    660:                               &Apache::lonnet::filelocation('',$url));
                    661:           if ($result==OK) {
1.87      www       662:              $r->print('<font color="green">'.&mt('ok').'</font>');
1.29      www       663:              $r->rflush();
1.34      www       664:              &Apache::lonnet::countacc($url);
                    665:              $url=~/\.(\w+)$/;
                    666:              if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
                    667: 		 $r->print('<br />');
                    668:                  $r->rflush();
                    669:                  for (my $i=0;$i<=$level*5;$i++) {
                    670:                      $r->print('&nbsp;');
                    671:                  }
1.84      www       672:                  $r->print('- '.&mt('Rendering').': ');
1.69      albertel  673:                  my $oldpath=$ENV{'request.filename'};
                    674:                  $ENV{'request.filename'}=&Apache::lonnet::filelocation('',$url);
1.34      www       675:                  &Apache::lonxml::xmlparse($r,'web',
                    676:                    &Apache::lonnet::getfile(
1.35      albertel  677:                     &Apache::lonnet::filelocation('',$url)));
1.94      www       678: 		 undef($Apache::lonhomework::parsing_a_problem);
1.69      albertel  679: 		 $ENV{'request.filename'}=$oldpath;
1.34      www       680:                  if (($Apache::lonxml::errorcount) ||
                    681:                      ($Apache::lonxml::warningcount)) {
                    682: 		     if ($Apache::lonxml::errorcount) {
1.98      www       683:                         $r->print('<img src="/adm/lonMisc/bomb.gif" /><font color="red"><b>'.
1.87      www       684: 			  $Apache::lonxml::errorcount.' '.
                    685: 				  &mt('error(s)').'</b></font> ');
1.34      www       686:                      }
                    687: 		     if ($Apache::lonxml::warningcount) {
                    688:                         $r->print('<font color="blue">'.
1.84      www       689: 			  $Apache::lonxml::warningcount.' '.
                    690: 				  &mt('warning(s)').'</font>');
1.34      www       691:                      }
                    692:                  } else {
1.87      www       693:                      $r->print('<font color="green">'.&mt('ok').'</font>');
1.34      www       694:                  }
                    695:                  $r->rflush();
                    696:              }
1.29      www       697: 	     my $dependencies=
                    698:                 &Apache::lonnet::metadata($url,'dependencies');
                    699:              foreach (split(/\,/,$dependencies)) {
                    700: 		 if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {
                    701:                     &checkonthis($r,$_,$level+1);
                    702:                  }
                    703:              }
                    704:           } elsif ($result==HTTP_SERVICE_UNAVAILABLE) {
1.84      www       705:              $r->print('<font color="red"><b>'.&mt('connection down').'</b></font>');
1.29      www       706:           } elsif ($result==HTTP_NOT_FOUND) {
1.100     www       707: 	      unless ($url=~/\$/) {
                    708: 		  $r->print('<font color="red"><b>'.&mt('not found').'</b></font>');
                    709: 	      } else {
                    710: 		  $r->print('<font color="yellow"><b>'.&mt('unable to verify variable URL').'</b></font>');
                    711: 	      }
1.29      www       712:           } else {
1.84      www       713:              $r->print('<font color="red"><b>'.&mt('access denied').'</b></font>');
1.29      www       714:           }
                    715:       }
                    716:    }
                    717: }
                    718: 
1.1       www       719: 
1.75      www       720: #
                    721: # -------------------------------------------------------------- Verify Content
                    722: # 
                    723: sub verifycontent {
                    724:    my $r=shift; 
1.26      www       725:    my $loaderror=&Apache::lonnet::overloaderror($r);
                    726:    if ($loaderror) { return $loaderror; }
                    727: 
                    728:    $r->print('<html><head><title>Verify Content</title></head>'.
                    729:               &Apache::loncommon::bodytag('Verify Course Documents'));
1.27      www       730:    $hashtied=0;
1.30      www       731:    undef %alreadyseen;
                    732:    %alreadyseen=();
1.27      www       733:    &tiehash();
                    734:    foreach (keys %hash) {
1.28      www       735:        if (($_=~/^src\_(.+)$/) && (!$alreadyseen{$hash{$_}})) {
1.29      www       736:            &checkonthis($r,$hash{$_},0,$hash{'title_'.$1});
1.27      www       737:        }
                    738:    }
                    739:    &untiehash();
1.108     albertel  740:    $r->print('<h1>'.&mt('Done').'.</h1>'.'<a href="/adm/coursedocs">'.
                    741: 	     &mt('Return to DOCS').'</a>');
1.75      www       742: }
                    743: 
                    744: # -------------------------------------------------------------- Check Versions
                    745: 
                    746: sub checkversions {
                    747:     my $r=shift;
1.89      www       748:     $r->print('<html><head><title>Check Versions</title></head>'.
1.26      www       749:               &Apache::loncommon::bodytag('Check Course Document Versions'));
1.89      www       750:     my $header='';
                    751:     my $startsel='';
                    752:     my $monthsel='';
                    753:     my $weeksel='';
                    754:     my $daysel='';
                    755:     my $allsel='';
                    756:     my %changes=();
                    757:     my $starttime=0;
1.91      www       758:     my $haschanged=0;
1.92      www       759:     my %setversions=&Apache::lonnet::dump('resourceversions',
                    760: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
                    761: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
                    762: 
                    763:     $hashtied=0;
                    764:     &tiehash();
                    765:     my %newsetversions=();
1.91      www       766:     if ($ENV{'form.setmostrecent'}) {
                    767: 	$haschanged=1;
1.92      www       768: 	foreach (keys %hash) {
                    769: 	    if ($_=~/^ids\_(\/res\/.+)$/) {
1.93      www       770: 		$newsetversions{$1}='mostrecent';
1.92      www       771: 	    }
                    772: 	}
1.91      www       773:     } elsif ($ENV{'form.setcurrent'}) {
                    774: 	$haschanged=1;
1.92      www       775: 	foreach (keys %hash) {
                    776: 	    if ($_=~/^ids\_(\/res\/.+)$/) {
1.93      www       777: 		my $getvers=&Apache::lonnet::getversion($1);
                    778: 		if ($getvers>0) {
                    779: 		    $newsetversions{$1}=$getvers;
                    780: 		}
1.92      www       781: 	    }
                    782: 	}
1.91      www       783:     } elsif ($ENV{'form.setversions'}) {
                    784: 	$haschanged=1;
1.92      www       785: 	foreach (keys %ENV) {
                    786: 	    if ($_=~/^form\.set_version_(.+)$/) {
                    787: 		my $src=$1;
                    788: 		if (($ENV{$_}) && ($ENV{$_} ne $setversions{$src})) {
                    789: 		    $newsetversions{$src}=$ENV{$_};
                    790: 		}
                    791: 	    }
                    792: 	}
1.91      www       793:     }
                    794:     if ($haschanged) {
1.92      www       795:         if (&Apache::lonnet::put('resourceversions',\%newsetversions,
                    796: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
                    797: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.num'}) eq 'ok') {		
                    798: 	    $r->print('<h1>'.&mt('Your Version Settings have been Stored').'</h1>');
                    799: 	} else {
                    800: 	    $r->print('<h1><font color="red">'.&mt('An Error Occured while Attempting to Store your Version Settings').'</font></h1>');
                    801: 	}
1.91      www       802: 	&changewarning($r,'');
                    803:     }
1.89      www       804:     if ($ENV{'form.timerange'} eq 'all') {
                    805: # show all documents
                    806: 	$header=&mt('All Documents in Course');
1.91      www       807: 	$allsel=1;
1.90      www       808: 	foreach (keys %hash) {
                    809: 	    if ($_=~/^ids\_(\/res\/.+)$/) {
                    810: 		my $src=$1;
                    811: 		$changes{$src}=1;
                    812: 	    }
                    813: 	}
1.89      www       814:     } else {
                    815: # show documents which changed
                    816: 	%changes=&Apache::lonnet::dump
                    817: 	 ('versionupdate',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1.30      www       818:                      $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.89      www       819: 	my $firstkey=(keys %changes)[0];
                    820: 	unless ($firstkey=~/^error\:/) {
                    821: 	    unless ($ENV{'form.timerange'}) {
                    822: 		$ENV{'form.timerange'}=604800;
                    823: 	    }
                    824: 	    my $seltext=&mt('during the last').' '.$ENV{'form.timerange'}.' '
                    825: 		.&mt('seconds');
                    826: 	    if ($ENV{'form.timerange'}==-1) {
                    827: 		$seltext='since start of course';
                    828: 		$startsel='selected';
                    829: 		$ENV{'form.timerange'}=time;
                    830: 	    }
                    831: 	    $starttime=time-$ENV{'form.timerange'};
                    832: 	    if ($ENV{'form.timerange'}==2592000) {
                    833: 		$seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
                    834: 		$monthsel='selected';
                    835: 	    } elsif ($ENV{'form.timerange'}==604800) {
                    836: 		$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
                    837: 		$weeksel='selected';
                    838: 	    } elsif ($ENV{'form.timerange'}==86400) {
                    839: 		$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
                    840: 		$daysel='selected';
                    841: 	    }
                    842: 	    $header=&mt('Content changed').' '.$seltext;
                    843: 	} else {
                    844: 	    $header=&mt('No content modifications yet.');
                    845: 	}
                    846:     }
1.92      www       847:     %setversions=&Apache::lonnet::dump('resourceversions',
                    848: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
                    849: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.89      www       850:     my %lt=&Apache::lonlocal::texthash
1.88      www       851: 	      ('st' => 'Version changes since start of Course',
                    852: 	       'lm' => 'Version changes since last Month',
                    853: 	       'lw' => 'Version changes since last Week',
                    854: 	       'sy' => 'Version changes since Yesterday',
1.91      www       855:                'al' => 'All Resources (possibly large output)',
1.88      www       856: 	       'sd' => 'Display',
1.84      www       857: 	       'fi' => 'File',
                    858: 	       'md' => 'Modification Date',
1.87      www       859:                'mr' => 'Most recently published Version',
                    860: 	       've' => 'Version used in Course',
1.91      www       861:                'vu' => 'Set Version to be used in Course',
                    862: 'sv' => 'Set Versions to be used in Course according to Selections below',
                    863: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
                    864: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.84      www       865: 	       'di' => 'Differences');
1.89      www       866:     $r->print(<<ENDHEADERS);
1.31      www       867: <form action="/adm/coursedocs" method="post">
1.91      www       868: <input type="hidden" name="versions" value="1" />
                    869: <input type="submit" name="setmostrecent" value="$lt{'sm'}" />
                    870: <input type="submit" name="setcurrent" value="$lt{'sc'}" /><hr />
1.31      www       871: <select name="timerange">
1.88      www       872: <option value='all' $allsel>$lt{'al'}</option>
1.84      www       873: <option value="-1" $startsel>$lt{'st'}</option>
                    874: <option value="2592000" $monthsel>$lt{'lm'}</option>
                    875: <option value="604800" $weeksel>$lt{'lw'}</option>
                    876: <option value="86400" $daysel>$lt{'sy'}</option>
1.31      www       877: </select>
1.91      www       878: <input type="submit" name="display" value="$lt{'sd'}" />
1.89      www       879: <h3>$header</h3>
1.91      www       880: <input type="submit" name="setversions" value="$lt{'sv'}" />
1.103     matthew   881: <table border="0">
1.31      www       882: ENDHEADERS
1.91      www       883:     foreach (sort keys %changes) {
1.89      www       884: 	if ($changes{$_}>$starttime) {
                    885: 	    my ($root,$extension)=($_=~/^(.*)\.(\w+)$/);
                    886: 	    my $currentversion=&Apache::lonnet::getversion($_);
1.93      www       887: 	    if ($currentversion<0) {
                    888: 		$currentversion=&mt('Could not be determined.');
                    889: 	    }
1.89      www       890: 	    my $linkurl=&Apache::lonnet::clutter($_);
                    891: 	    $r->print(
1.103     matthew   892: 		      '<tr><td colspan="5"><br /><br /><font size="+1"><b>'.
1.91      www       893: 		      &Apache::lonnet::gettitle($linkurl).
1.103     matthew   894:                       '</b></font></td></tr>'.
                    895:                       '<tr><td>&nbsp;&nbsp;&nbsp;</td>'.
                    896:                       '<td colspan="4">'.
                    897:                       '<a href="'.$linkurl.'" target="cat">'.$linkurl.
                    898: 		      '</a></td></tr>'.
                    899:                       '<tr><td></td>'.
                    900:                       '<td title="'.$lt{'md'}.'">'.
1.102     matthew   901: 		      &Apache::lonlocal::locallocaltime(
                    902:                            &Apache::lonnet::metadata($root.'.'.$extension,
                    903:                                                      'lastrevisiondate')
                    904:                                                         ).
1.103     matthew   905:                       '</td>'.
                    906:                       '<td title="'.$lt{'mr'}.'"><nobr>Most Recent: '.
                    907:                       '<font size="+1">'.$currentversion.'</font>'.
                    908:                       '</nobr></td>'.
                    909:                       '<td title="'.$lt{'ve'}.'"><nobr>In Course: '.
                    910:                       '<font size="+1">');
1.87      www       911: # Used in course
1.89      www       912: 	    my $usedversion=$hash{'version_'.$linkurl};
1.93      www       913: 	    if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.89      www       914: 		$r->print($usedversion);
                    915: 	    } else {
                    916: 		$r->print($currentversion);
                    917: 	    }
1.103     matthew   918: 	    $r->print('</font></nobr></td><td title="'.$lt{'vu'}.'">'.
                    919:                       '<nobr>Use: ');
1.87      www       920: # Set version
1.92      www       921: 	    $r->print(&Apache::loncommon::select_form($setversions{$linkurl},
1.89      www       922: 						      'set_version_'.$linkurl,
                    923: 						      ('' => '',
1.93      www       924: 						       'mostrecent' => 'most recent',
1.89      www       925: 						       map {$_,$_} (1..$currentversion))));
1.103     matthew   926: 	    $r->print('</nobr></td></tr><tr><td></td>');
1.89      www       927: 	    my $lastold=1;
                    928: 	    for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
                    929: 		my $url=$root.'.'.$prevvers.'.'.$extension;
                    930: 		if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
                    931: 		    $starttime) {
                    932: 		    $lastold=$prevvers;
                    933: 		}
                    934: 	    }
1.103     matthew   935:             # 
                    936:             # Code to figure out how many version entries should go in
                    937:             # each of the four columns
                    938:             my $entries_per_col = 0;
                    939:             my $num_entries = ($currentversion-$lastold);
                    940:             if ($num_entries % 4 == 0) {
                    941:                 $entries_per_col = $num_entries/4;
                    942:             } else {
                    943:                 $entries_per_col = $num_entries/4 + 1;
                    944:             }
                    945:             my $entries_count = 0;
                    946:             $r->print('<td valign="top"><font size="-2">'); 
                    947:             my $cols_output = 1;
1.32      www       948:             for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
1.89      www       949: 		my $url=$root.'.'.$prevvers.'.'.$extension;
1.103     matthew   950: 		$r->print('<nobr><a href="'.&Apache::lonnet::clutter($url).
1.91      www       951: 			  '">'.&mt('Version').' '.$prevvers.'</a> ('.
1.103     matthew   952: 			  &Apache::lonlocal::locallocaltime(
                    953:                                 &Apache::lonnet::metadata($url,
                    954:                                                           'lastrevisiondate')
                    955:                                                             ).
1.91      www       956: 			  ')');
1.89      www       957: 		if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
1.33      www       958:                     $r->print(' <a href="/adm/diff?filename='.
1.89      www       959: 			      &Apache::lonnet::clutter($root.'.'.$extension).
                    960: 			      '&versionone='.$prevvers.
                    961: 			      '">'.&mt('Diffs').'</a>');
                    962: 		}
1.103     matthew   963: 		$r->print('</nobr><br />');
                    964:                 if (++$entries_count % $entries_per_col == 0) {
                    965:                     $r->print('</font></td>');
                    966:                     if ($cols_output != 4) {
                    967:                         $r->print('<td valign="top"><font size="-2">');
                    968:                         $cols_output++;
                    969:                     }
                    970:                 }
1.89      www       971: 	    }
1.103     matthew   972:             while($cols_output++ < 4) {
                    973:                 $r->print('</font></td><td><font>')
                    974:             }
                    975: 	    $r->print('</font></td></tr>'."\n");
1.89      www       976: 	}
                    977:     }
1.92      www       978:     $r->print('</table></form>');
1.89      www       979:     $r->print('<h1>'.&mt('Done').'.</h1>');
                    980: 
                    981:     &untiehash();
1.75      www       982: }
                    983: 
1.91      www       984: sub changewarning {
                    985:     my ($r,$postexec)=@_;
                    986:     $r->print(
                    987: '<script>function reinit(tf) { tf.submit();'.$postexec.' }</script>'. 
                    988: '<form method="post" action="/adm/roles" target="loncapaclient">'.
1.117     albertel  989: '<input type="hidden" name="orgurl" value="/adm/coursedocs?folderpath='.
                    990: &Apache::lonnet::escape($ENV{'form.folderpath'}).
                    991: '" /><input type="hidden" name="selectrole" value="1" /><h3><font color="red">'.
1.91      www       992: &mt('Changes will become active for your current session after').
                    993: ' <input type="hidden" name="'.
                    994: $ENV{'request.role'}.'" value="1" /><input type="button" value="'.
                    995: &mt('re-initializing course').'" onClick="reinit(this.form)"/>'.&mt(', or the next time you log in.').
                    996: $help{'Caching'}.'</font></h3></form>');
                    997: }
                    998: 
1.75      www       999: # ================================================================ Main Handler
                   1000: sub handler {
                   1001:     my $r = shift;
1.82      www      1002:     &Apache::loncommon::content_type($r,'text/html');
1.75      www      1003:     $r->send_http_header;
                   1004:     return OK if $r->header_only;
                   1005: 
                   1006: # --------------------------------------------- Initialize help topics for this
                   1007:   foreach ('Adding_Course_Doc','Main_Course_Documents',
                   1008:            'Adding_External_Resource','Navigate_Content',
                   1009:            'Adding_Folders','Docs_Overview', 'Load_Map',
                   1010:            'Supplemental', 'Score_Upload_Form',
                   1011:            'Importing_LON-CAPA_Resource','Uploading_From_Harddrive') {
                   1012:       $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);
                   1013:   }
                   1014:     # Composite help files
                   1015:     $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
                   1016: 		    'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
                   1017:     $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
                   1018: 		    'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
1.86      albertel 1019:     $help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
                   1020: 		    'Option_Response_Simple');
1.75      www      1021:     $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
                   1022: 		    'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
                   1023:     $help{'My Personal Info'} = &Apache::loncommon::help_open_topic(
                   1024: 		  'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
                   1025:     $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
                   1026:  
                   1027:   if ($ENV{'form.verify'}) {
                   1028:       &verifycontent($r);
                   1029:   } elsif ($ENV{'form.versions'}) {
                   1030:       &checkversions($r);
                   1031:   } elsif ($ENV{'form.dumpcourse'}) {
                   1032:       &dumpcourse($r);
1.26      www      1033:   } else {
1.7       www      1034: # is this a standard course?
                   1035: 
                   1036:     my $standard=($ENV{'request.course.uri'}=~/^\/uploaded\//);
1.15      www      1037:     my $forcestandard;
                   1038:     my $forcesupplement;
                   1039:     my $script='';
                   1040:     my $allowed;
                   1041:     my $events='';
1.19      www      1042:     my $showdoc=0;
1.15      www      1043:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.114     albertel 1044: 					    ['folderpath']);
                   1045:     if ($ENV{'form.folderpath'}) {
                   1046: 	my (@folderpath)=split('&',$ENV{'form.folderpath'});
                   1047: 	$ENV{'form.foldername'}=&Apache::lonnet::unescape(pop(@folderpath));
                   1048: 	$ENV{'form.folder'}=pop(@folderpath);
1.116     albertel 1049:     } 
1.21      www      1050:     if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
                   1051:        $showdoc=$1;
                   1052:     }
                   1053:     unless ($showdoc) { # got called from remote
1.15      www      1054:        $forcestandard=($ENV{'form.folder'}=~/^default_/);
                   1055:        $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
1.7       www      1056: 
1.4       www      1057: # does this user have privileges to post, etc?
1.77      www      1058:        $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
1.15      www      1059:        if ($allowed) { 
                   1060:          &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
                   1061:          $script=&Apache::lonratedt::editscript('simple'); 
                   1062:        }
                   1063:     } else { # got called in sequence from course
                   1064:        $allowed=0;
1.49      www      1065:        $script='</script>'.&Apache::lonmenu::registerurl(1,undef).'<script>';
                   1066:        $events='onLoad="'.&Apache::lonmenu::loadevents.
                   1067:            '" onUnload="'.&Apache::lonmenu::unloadevents.'"';
1.3       www      1068:     }
1.4       www      1069: 
                   1070: # get course data
                   1071:     my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
                   1072:     my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
                   1073: 
1.14      www      1074: # get personal data
                   1075:  
                   1076:     my $uname=$ENV{'user.name'};
                   1077:     my $udom=$ENV{'user.domain'};
                   1078:     my $plainname=&Apache::lonnet::escape(
                   1079:                      &Apache::loncommon::plainname($uname,$udom));
                   1080: 
1.8       www      1081: # graphics settings
1.4       www      1082: 
1.8       www      1083:     $iconpath = $r->dir_config('lonIconsURL') . "/";
                   1084: 
1.22      www      1085:     my $now=time;
1.64      www      1086: 
1.4       www      1087: # print screen
1.1       www      1088:     $r->print(<<ENDDOCUMENT);
                   1089: <html>
                   1090: <head>
                   1091: <title>The LearningOnline Network with CAPA</title>
1.16      www      1092: <script>
                   1093: $script
1.20      www      1094: </script>
1.19      www      1095: ENDDOCUMENT
                   1096:    if ($allowed) {
                   1097:     $r->print(<<ENDNEWSCRIPT);
1.20      www      1098: <script>
1.16      www      1099: function makenewfolder(targetform,folderseq) {
                   1100:     var foldername=prompt('Name of New Folder','New Folder');
                   1101:     if (foldername) {
                   1102: 	targetform.importdetail.value=foldername+"="+folderseq;
                   1103:         targetform.submit();
                   1104:     }
                   1105: }
                   1106: 
1.18      www      1107: function makenewext(targetname) {
                   1108:     this.document.forms.extimport.useform.value=targetname;
                   1109:     window.open('/adm/rat/extpickframe.html');
                   1110: }
                   1111: 
1.62      www      1112: function makeexamupload() {
                   1113:    var title=prompt('Listed Title for the Uploaded Score');
                   1114:    if (title) { 
                   1115:     this.document.forms.newexamupload.importdetail.value=
                   1116: 	title+'=/res/lib/templates/examupload.problem';
                   1117:     this.document.forms.newexamupload.submit();
                   1118:    }
                   1119: }
                   1120: 
1.22      www      1121: function makesmppage() {
1.38      www      1122:    var title=prompt('Listed Title for the Page');
                   1123:    if (title) { 
1.22      www      1124:     this.document.forms.newsmppg.importdetail.value=
                   1125: 	title+'=/adm/$udom/$uname/$now/smppg';
                   1126:     this.document.forms.newsmppg.submit();
1.38      www      1127:    }
1.22      www      1128: }
                   1129: 
1.55      www      1130: function makesmpproblem() {
                   1131:    var title=prompt('Listed Title for the Problem');
                   1132:    if (title) { 
                   1133:     this.document.forms.newsmpproblem.importdetail.value=
1.63      www      1134: 	title+'=/res/lib/templates/simpleproblem.problem';
1.55      www      1135:     this.document.forms.newsmpproblem.submit();
                   1136:    }
                   1137: }
                   1138: 
1.22      www      1139: function makebulboard() {
1.38      www      1140:    var title=prompt('Listed Title for the Bulletin Board');
                   1141:    if (title) {
1.22      www      1142:     this.document.forms.newbul.importdetail.value=
                   1143: 	title+'=/adm/$udom/$uname/$now/bulletinboard';
                   1144:     this.document.forms.newbul.submit();
1.38      www      1145:    }
1.22      www      1146: }
                   1147: 
1.101     www      1148: function makeabout() {
                   1149:    var user=prompt("Enter user\@domain for User's 'About Me' Page");
                   1150:    if (user) {
                   1151:        var comp=new Array();
                   1152:        comp=user.split('\@');
                   1153:        if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
                   1154: 	   if ((comp[0]) && (comp[1])) {
                   1155: 	       this.document.forms.newaboutsomeone.importdetail.value=
                   1156: 		   'About '+user+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
                   1157: 	       this.document.forms.newaboutsomeone.submit();
                   1158: 	   }
                   1159:        }
                   1160:    }
                   1161: }
                   1162: 
1.110     raeburn  1163: function makeims() {
                   1164:     var caller = document.forms.ims.folder.value
                   1165:     var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one"
                   1166:     newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes")
                   1167:     newWindow.location.href = newlocation
                   1168: }
                   1169: 
                   1170: 
1.18      www      1171: function finishpick() {
                   1172:     var title=this.document.forms.extimport.title.value;
                   1173:     var url=this.document.forms.extimport.url.value;
                   1174:     var form=this.document.forms.extimport.useform.value;
                   1175:     eval
                   1176:      ('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+
                   1177:     '";this.document.forms.'+form+'.submit();');
1.16      www      1178: }
1.36      www      1179: 
1.115     albertel 1180: function changename(folderpath,index,oldtitle) {
1.36      www      1181:     var title=prompt('New Title',oldtitle);
                   1182:     if (title) {
                   1183: 	this.document.forms.renameform.title.value=title;
                   1184: 	this.document.forms.renameform.cmd.value='rename_'+index;
1.115     albertel 1185: 	this.document.forms.renameform.folderpath.value=folderpath;
1.54      www      1186:         this.document.forms.renameform.submit();
                   1187:     }
                   1188: }
                   1189: 
1.115     albertel 1190: function removeres(folderpath,index,oldtitle) {
1.106     www      1191:     if (confirm('Remove "'+oldtitle+'"?')) {
1.54      www      1192: 	this.document.forms.renameform.cmd.value='del_'+index;
1.115     albertel 1193: 	this.document.forms.renameform.folderpath.value=folderpath;
1.36      www      1194:         this.document.forms.renameform.submit();
                   1195:     }
                   1196: }
1.121     www      1197: 
1.16      www      1198: </script>
1.42      www      1199: 
                   1200: ENDNEWSCRIPT
                   1201:   }
                   1202: # -------------------------------------------------------------------- Body tag
                   1203:   $r->print('</head>'.
1.72      www      1204:             &Apache::loncommon::bodytag('Course Documents','',$events,
1.99      www      1205: 					'','',$showdoc).
                   1206: 	    &Apache::loncommon::help_open_faq(273).
                   1207: 	    &Apache::loncommon::help_open_bug('RAT'));
1.42      www      1208:   unless ($showdoc) {
1.81      www      1209: # -----------------------------------------------------------------------------
                   1210:        my %lt=&Apache::lonlocal::texthash(
                   1211:                 'uplm' => 'Upload a new main course document',
                   1212:                 'upls' => 'Upload a new supplemental course document',
                   1213:                 'impp' => 'Import a published document',
                   1214:                 'spec' => 'Special documents',
                   1215:                 'upld' => 'Upload Document',
                   1216:                 'srch' => 'Search',
                   1217:                 'impo' => 'Import',
                   1218:                 'selm' => 'Select Map',
                   1219:                 'load' => 'Load Map',
                   1220:                 'newf' => 'New Folder',
                   1221:                 'extr' => 'External Resource',
                   1222:                 'syll' => 'Syllabus',
                   1223:                 'navc' => 'Navigate Contents',
                   1224:                 'sipa' => 'Simple Page',
                   1225:                 'sipr' => 'Simple Problem',
                   1226:                 'scuf' => 'Score Upload Form',
                   1227:                 'bull' => 'Bulletin Board',
1.96      sakharuk 1228:                 'mypi' => 'My Personal Info',
1.101     www      1229: 		'abou' => 'About User',
1.110     raeburn  1230:                 'imsf' => 'Import IMS package',
1.96      sakharuk 1231:                 'file' =>  'File',
                   1232:                 'title' => 'Title',
                   1233:                 'comment' => 'Comment' 
1.81      www      1234: 					  );
                   1235: # -----------------------------------------------------------------------------
1.42      www      1236:     if ($allowed) {
1.74      www      1237:        my $dumpbut=&dumpbutton();
1.88      www      1238:        my %lt=&Apache::lonlocal::texthash(
                   1239: 					 'vc' => 'Verify Content',
                   1240: 					 'cv' => 'Check/Set Resource Versions',
                   1241: 					  );
1.118     albertel 1242: 
                   1243:        my $folderpath=$ENV{'form.folderpath'};
                   1244:        if (!$folderpath) {
                   1245: 	   if ($ENV{'form.folder'} eq '' ||
                   1246: 	       $ENV{'form.folder'} eq 'supplemental') {
                   1247: 	       $folderpath='default&'.
                   1248: 		   &Apache::lonnet::escape(&mt('Main Course Documents'));
                   1249: 	   }
                   1250:        }
1.42      www      1251:        $r->print(<<ENDCOURSEVERIFY);
1.36      www      1252: <form name="renameform" method="post" action="/adm/coursedocs">
                   1253: <input type="hidden" name="title" />
                   1254: <input type="hidden" name="cmd" />
1.115     albertel 1255: <input type="hidden" name="folderpath" />
1.36      www      1256: </form>
1.39      www      1257: <form name="simpleedit" method="post" action="/adm/coursedocs">
                   1258: <input type=hidden name="importdetail" value="">
1.118     albertel 1259: <input type="hidden" name="folderpath" value="$folderpath" />
1.39      www      1260: </form>
1.26      www      1261: <form action="/adm/coursedocs" method="post" name="courseverify">
1.74      www      1262: <table bgcolor="#AAAAAA" width="100%" cellspacing="4" cellpadding="4">
                   1263: <tr><td bgcolor="#DDDDCC">
1.88      www      1264: <input type="submit" name="verify" value="$lt{'vc'}" />
1.74      www      1265: </td><td bgcolor="#DDDDCC">
1.88      www      1266: <input type="submit" name="versions" value="$lt{'cv'}" />
1.74      www      1267: $dumpbut
                   1268: </td></tr></table>
1.25      www      1269: </form>
                   1270: ENDCOURSEVERIFY
1.74      www      1271:        $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
1.96      sakharuk 1272: 		     &mt('Editing the Table of Contents for your Course')));
1.25      www      1273:     }
1.17      www      1274: # --------------------------------------------------------- Standard documents
1.43      www      1275:     $r->print('<table border=2 cellspacing=4 cellpadding=4>');
1.7       www      1276:     if (($standard) && ($allowed) && (!$forcesupplement)) {
1.116     albertel 1277: 	$r->print('<tr><td bgcolor="#BBBBBB">');
                   1278: #  '<h2>'.&mt('Main Course Documents').
                   1279: #  ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>');
1.7       www      1280:        my $folder=$ENV{'form.folder'};
1.117     albertel 1281:        if ($folder eq '' || $folder eq 'supplemental') {
1.112     raeburn  1282:            $folder='default';
1.116     albertel 1283: 	   $ENV{'form.folderpath'}='default&'.&Apache::lonnet::escape(&mt('Main Course Documents'));
1.112     raeburn  1284:        }
1.51      www      1285:        my $postexec='';
                   1286:        if ($folder eq 'default') {
                   1287: 	   $r->print('<script>this.window.name="loncapaclient";</script>');
                   1288:        } else {
1.117     albertel 1289:            #$postexec='self.close();';
1.51      www      1290:        }
1.40      www      1291:        $hadchanges=0;
1.7       www      1292:        &editor($r,$coursenum,$coursedom,$folder,$allowed);
1.40      www      1293:        if ($hadchanges) {
1.91      www      1294: 	   &changewarning($r,$postexec);
1.40      www      1295:        }
1.16      www      1296:        my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
                   1297:                      '.sequence';
1.8       www      1298:        $r->print(<<ENDFORM);
1.43      www      1299: <table cellspacing=4 cellpadding=4><tr>
1.81      www      1300: <th bgcolor="#DDDDDD">$lt{'uplm'}</th>
                   1301: <th bgcolor="#DDDDDD">$lt{'impp'}</th>
                   1302: <th bgcolor="#DDDDDD">$lt{'spec'}</th>
1.11      www      1303: </tr>
1.16      www      1304: <tr><td bgcolor="#DDDDDD">
1.96      sakharuk 1305: $lt{'file'}:<br />
1.10      www      1306: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.59      www      1307: <input type="file" name="uploaddoc" size="40">
1.8       www      1308: <br />
1.96      sakharuk 1309: $lt{'title'}:<br />
1.11      www      1310: <input type="text" size="50" name="comment">
1.115     albertel 1311: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.10      www      1312: <input type="hidden" name="cmd" value="upload_default">
1.81      www      1313: <input type="submit" value="$lt{'upld'}">
1.59      www      1314: <nobr>
1.60      albertel 1315:  $help{'Uploading_From_Harddrive'}
1.58      albertel 1316: </nobr>
1.60      albertel 1317: </form>
1.11      www      1318: </td>
1.16      www      1319: <td bgcolor="#DDDDDD">
1.39      www      1320: <form action="/adm/coursedocs" method="post" name="simpleeditdefault">
1.115     albertel 1321: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
                   1322: <input type=button onClick="javascript:groupsearch()" value="$lt{'srch'}">
1.58      albertel 1323: <nobr>
1.115     albertel 1324: <input type=button onClick="javascript:groupimport();" value="$lt{'impo'}">
1.58      albertel 1325: $help{'Importing_LON-CAPA_Resource'}
                   1326: </nobr>
1.59      www      1327: <p>
                   1328: <hr />
1.68      bowersj2 1329: <input type="text" size="20" name="importmap"><br />
                   1330: <nobr><input type=button 
1.52      www      1331: onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
1.81      www      1332: value="$lt{'selm'}"> <input type="submit" name="loadmap" value="$lt{'load'}">
1.68      bowersj2 1333: $help{'Load_Map'}</nobr>
1.59      www      1334: </p>
1.52      www      1335: </form>
1.16      www      1336: </td><td bgcolor="#DDDDDD">
1.11      www      1337: <form action="/adm/coursedocs" method="post" name="newfolder">
1.115     albertel 1338: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.13      www      1339: <input type=hidden name="importdetail" value="">
1.58      albertel 1340: <nobr>
1.16      www      1341: <input name="newfolder" type="button"
                   1342: onClick="javascript:makenewfolder(this.form,'$folderseq');"
1.81      www      1343: value="$lt{'newf'}" />$help{'Adding_Folders'}
1.58      albertel 1344: </nobr>
1.11      www      1345: </form>
                   1346: <form action="/adm/coursedocs" method="post" name="newext">
1.115     albertel 1347: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.13      www      1348: <input type=hidden name="importdetail" value="">
1.58      albertel 1349: <nobr>
1.18      www      1350: <input name="newext" type="button" onClick="javascript:makenewext('newext');"
1.81      www      1351: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
1.58      albertel 1352: </nobr>
1.11      www      1353: </form>
                   1354: <form action="/adm/coursedocs" method="post" name="newsyl">
1.115     albertel 1355: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.14      www      1356: <input type=hidden name="importdetail" 
                   1357: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
1.58      albertel 1358: <nobr>
1.81      www      1359: <input name="newsyl" type="submit" value="$lt{'syll'}" /> 
1.65      bowersj2 1360:  $help{'Syllabus'}
1.58      albertel 1361: </nobr>
                   1362: </form>
1.17      www      1363: <form action="/adm/coursedocs" method="post" name="newnav">
1.115     albertel 1364: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.15      www      1365: <input type=hidden name="importdetail" 
                   1366: value="Navigate Content=/adm/navmaps">
1.58      albertel 1367: <nobr>
1.81      www      1368: <input name="newnav" type="submit" value="$lt{'navc'}" />
1.47      www      1369: $help{'Navigate_Content'}
1.58      albertel 1370: </nobr>
1.22      www      1371: </form>
                   1372: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.115     albertel 1373: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.22      www      1374: <input type=hidden name="importdetail" value="">
1.58      albertel 1375: <nobr>
1.81      www      1376: <input name="newsmppg" type="button" value="$lt{'sipa'}"
1.65      bowersj2 1377: onClick="javascript:makesmppage();" /> $help{'Simple Page'}
1.58      albertel 1378: </nobr>
1.55      www      1379: </form>
                   1380: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.115     albertel 1381: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.55      www      1382: <input type=hidden name="importdetail" value="">
1.58      albertel 1383: <nobr>
1.81      www      1384: <input name="newsmpproblem" type="button" value="$lt{'sipr'}"
1.65      bowersj2 1385: onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
1.62      www      1386: </nobr>
                   1387: </form>
                   1388: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.115     albertel 1389: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.62      www      1390: <input type=hidden name="importdetail" value="">
                   1391: <nobr>
1.81      www      1392: <input name="newexamupload" type="button" value="$lt{'scuf'}"
1.62      www      1393: onClick="javascript:makeexamupload();" />
1.66      bowersj2 1394: $help{'Score_Upload_Form'}
1.58      albertel 1395: </nobr>
1.22      www      1396: </form>
                   1397: <form action="/adm/coursedocs" method="post" name="newbul">
1.115     albertel 1398: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.22      www      1399: <input type=hidden name="importdetail" value="">
1.58      albertel 1400: <nobr>
1.81      www      1401: <input name="newbulletin" type="button" value="$lt{'bull'}"
1.22      www      1402: onClick="javascript:makebulboard();" />
1.65      bowersj2 1403: $help{'Bulletin Board'}
1.58      albertel 1404: </nobr>
                   1405: </form>
1.12      www      1406: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.115     albertel 1407: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.14      www      1408: <input type=hidden name="importdetail" 
                   1409: value="$plainname=/adm/$udom/$uname/aboutme">
1.58      albertel 1410: <nobr>
1.81      www      1411: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
1.65      bowersj2 1412: $help{'My Personal Info'}
1.101     www      1413: </nobr>
                   1414: </form>
                   1415: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.115     albertel 1416: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.101     www      1417: <input type=hidden name="importdetail" value="">
                   1418: <nobr>
                   1419: <input name="newaboutsomeone" type="button" value="$lt{'abou'}" 
                   1420: onClick="javascript:makeabout();" />
1.110     raeburn  1421: </nobr>
                   1422: </form>
                   1423: <form action="/adm/imsimportdocs" method="post" name="ims">
1.118     albertel 1424: <input type="hidden" name="folder" value="$folder" />
1.110     raeburn  1425: <input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" />
1.58      albertel 1426: </nobr>
                   1427: </form>
1.11      www      1428: </td></tr>
                   1429: </table>
1.8       www      1430: ENDFORM
1.24      www      1431:        $r->print('</td></tr>');
1.7       www      1432:     }
                   1433: # ----------------------------------------------------- Supplemental documents
                   1434:     if (!$forcestandard) {
1.116     albertel 1435:        $r->print('<tr><td bgcolor="#BBBBBB">');
                   1436: # '<h2>'.&mt('Supplemental Course Documents').
                   1437: #  ($allowed?' '.$help{'Supplemental'}:'').'</h2>');
1.7       www      1438:        my $folder=$ENV{'form.folder'};
1.117     albertel 1439:        unless ($folder=~/^supplemental/) {
1.116     albertel 1440: 	   $folder='supplemental';
1.117     albertel 1441:        }
                   1442:        if ($folder =~ /^supplemental$/ &&
                   1443: 	   $ENV{'form.folderpath'} =~ /^default\&/) {
                   1444: 	   $ENV{'form.folderpath'}='supplemental&'.
                   1445: 	       &Apache::lonnet::escape(&mt('Supplemental Course Documents'));
1.116     albertel 1446:        }
1.7       www      1447:        &editor($r,$coursenum,$coursedom,$folder,$allowed);
1.8       www      1448:        if ($allowed) {
1.17      www      1449:        my $folderseq=
                   1450:                   '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
                   1451:                      '.sequence';
                   1452: 
1.8       www      1453:           $r->print(<<ENDSUPFORM);
1.43      www      1454: <table cellspacing=4 cellpadding=4><tr>
1.81      www      1455: <th bgcolor="#DDDDDD">$lt{'upls'}</th>
                   1456: <th bgcolor="#DDDDDD">$lt{'spec'}</th>
1.17      www      1457: </tr>
                   1458: <tr><td bgcolor="#DDDDDD">
1.10      www      1459: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.59      www      1460: <input type="file" name="uploaddoc" size="40">
1.96      sakharuk 1461: <br />$lt{'comment'}:<br />
1.4       www      1462: <textarea cols=50 rows=4 name='comment'>
                   1463: </textarea>
1.115     albertel 1464: <br />
                   1465: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.10      www      1466: <input type="hidden" name="cmd" value="upload_supplemental">
1.58      albertel 1467: <nobr>
1.81      www      1468: <input type="submit" value="$lt{'upld'}">
1.58      albertel 1469:  $help{'Uploading_From_Harddrive'}
                   1470: </nobr>
                   1471: </form>
1.17      www      1472: </td>
                   1473: <td bgcolor="#DDDDDD">
1.18      www      1474: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.115     albertel 1475: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.17      www      1476: <input type=hidden name="importdetail" value="">
1.58      albertel 1477: <nobr>
1.17      www      1478: <input name="newfolder" type="button"
                   1479: onClick="javascript:makenewfolder(this.form,'$folderseq');"
1.81      www      1480: value="$lt{'newf'}" /> $help{'Adding_Folders'}
1.58      albertel 1481: </nobr>
1.17      www      1482: </form>
1.18      www      1483: <form action="/adm/coursedocs" method="post" name="supnewext">
1.115     albertel 1484: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.17      www      1485: <input type=hidden name="importdetail" value="">
1.58      albertel 1486: <nobr>
1.18      www      1487: <input name="newext" type="button" 
                   1488: onClick="javascript:makenewext('supnewext');"
1.81      www      1489: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
1.58      albertel 1490: </nobr>
1.17      www      1491: </form>
1.18      www      1492: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.115     albertel 1493: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.17      www      1494: <input type=hidden name="importdetail" 
                   1495: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
1.58      albertel 1496: <nobr>
1.81      www      1497: <input name="newsyl" type="submit" value="$lt{'syll'}" />
1.65      bowersj2 1498: $help{'Syllabus'}
1.58      albertel 1499: </nobr>
                   1500: </form>
1.18      www      1501: <form action="/adm/coursedocs" method="post" name="subnewaboutme">
1.115     albertel 1502: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.17      www      1503: <input type=hidden name="importdetail" 
                   1504: value="$plainname=/adm/$udom/$uname/aboutme">
1.58      albertel 1505: <nobr>
1.81      www      1506: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
1.65      bowersj2 1507: $help{'My Personal Info'}
1.58      albertel 1508: </nobr>
                   1509: </form>
1.17      www      1510: </td></tr>
1.24      www      1511: </table></td></tr>
1.8       www      1512: ENDSUPFORM
                   1513:        }
1.7       www      1514:     }
1.18      www      1515:     if ($allowed) {
                   1516: 	$r->print('<form name="extimport"><input type="hidden" name="title"><input type="hidden" name="url"><input type="hidden" name="useform"></form>');
                   1517:     }
1.24      www      1518:     $r->print('</table>');
1.19      www      1519:   } else {
                   1520: # -------------------------------------------------------- This is showdoc mode
1.81      www      1521:       $r->print("<h1>".&mt('Uploaded Document').'</h1><p>'.
                   1522: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><p><table>".
                   1523:          &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table></p>');
1.19      www      1524:   }
1.26      www      1525:  }
1.95      www      1526:  $r->print('</body></html>');
1.26      www      1527:  return OK;
1.1       www      1528: } 
                   1529: 
                   1530: 1;
                   1531: __END__

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