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

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

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