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

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

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