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

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

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