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

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

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