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

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

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