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

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

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