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

1.1       www         1: # The LearningOnline Network
1.2       www         2: # Documents
1.1       www         3: #
1.156   ! albertel    4: # $Id: londocs.pm,v 1.155 2004/12/13 01:57:10 raeburn Exp $
1.1       www         5: #
1.3       www         6: # Copyright Michigan State University Board of Trustees
1.1       www         7: #
1.3       www         8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
1.1       www         9: #
1.3       www        10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
1.1       www        14: #
1.3       www        15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
                     28: 
1.2       www        29: package Apache::londocs;
1.1       www        30: 
                     31: use strict;
1.28      www        32: use Apache::Constants qw(:common :http);
1.4       www        33: use Apache::lonnet;
                     34: use Apache::loncommon;
1.7       www        35: use Apache::lonratedt;
                     36: use Apache::lonratsrv;
1.15      www        37: use Apache::lonxml;
1.74      www        38: use Apache::loncreatecourse;
1.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.143     raeburn    43: use Cwd;
1.7       www        44: 
1.8       www        45: my $iconpath;
1.7       www        46: 
1.27      www        47: my %hash;
                     48: 
                     49: my $hashtied;
1.29      www        50: my %alreadyseen=();
1.27      www        51: 
1.40      www        52: my $hadchanges;
                     53: 
1.47      www        54: # Available help topics
                     55: 
                     56: my %help=();
                     57: 
1.7       www        58: # Mapread read maps into lonratedt::global arrays 
1.10      www        59: # @order and @resources, determines status
1.7       www        60: # sets @order - pointer to resources in right order
                     61: # sets @resources - array with the resources with correct idx
                     62: #
                     63: 
                     64: sub mapread {
                     65:     my ($coursenum,$coursedom,$map)=@_;
                     66:     return
                     67:       &Apache::lonratedt::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
                     68:                                 $map);
                     69: }
                     70: 
                     71: sub storemap {
                     72:     my ($coursenum,$coursedom,$map)=@_;
1.104     albertel   73:     my ($outtext,$errtext)=
1.7       www        74:       &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.15      www        75:                                 $map,1);
1.104     albertel   76:     if ($errtext) { return ($errtext,2); }
                     77:     
                     78:     $hadchanges=1;
                     79:     return ($errtext,0);
1.7       www        80: }
                     81: 
1.74      www        82: # ----------------------------------------- Return hash with valid author names
                     83: 
                     84: sub authorhosts {
                     85:     my %outhash=();
                     86:     my $home=0;
                     87:     my $other=0;
                     88:     foreach (keys %ENV) {
                     89: 	if ($_=~/^user\.role\.(au|ca)\.(.+)$/) {
                     90: 	    my $role=$1;
                     91: 	    my $realm=$2;
                     92: 	    my ($start,$end)=split(/\./,$ENV{$_});
                     93: 	    if (($start) && ($start>time)) { next; }
                     94: 	    if (($end) && (time>$end)) { next; }
                     95: 	    my $ca; my $cd;
                     96: 	    if ($1 eq 'au') {
                     97: 		$ca=$ENV{'user.name'};
                     98: 		$cd=$ENV{'user.domain'};
                     99: 	    } else {
                    100: 		($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/);
                    101: 	    }
1.107     albertel  102: 	    my $allowed=0;
                    103: 	    my $myhome=&Apache::lonnet::homeserver($ca,$cd);
                    104: 	    my @ids=&Apache::lonnet::current_machine_ids();
                    105: 	    foreach my $id (@ids) { if ($id eq $myhome) { $allowed=1; } }
                    106: 	    if ($allowed) {
1.74      www       107: 		$home++;
                    108: 		$outhash{'home_'.$ca.'@'.$cd}=1;
                    109: 	    } else {
1.107     albertel  110: 		$outhash{'otherhome_'.$ca.'@'.$cd}=$myhome;
1.74      www       111: 		$other++;
                    112: 	    }
                    113: 	}
                    114:     }
                    115:     return ($home,$other,%outhash);
                    116: }
                    117: # ------------------------------------------------------ Generate "dump" button
                    118: 
                    119: sub dumpbutton {
                    120:     my ($home,$other,%outhash)=&authorhosts();
                    121:     if ($home+$other==0) { return ''; }
                    122:     my $output='</td><td bgcolor="#DDDDCC">';
                    123:     if ($home) {
                    124: 	return '</td><td bgcolor="#DDDDCC">'.
1.81      www       125: 	    '<input type="submit" name="dumpcourse" value="'.
1.130     www       126: 	    &mt('Dump Course DOCS to Construction Space').'" />'.
                    127: 	    &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs');
1.74      www       128:     } else {
                    129: 	return'</td><td bgcolor="#DDDDCC">'.
1.81      www       130:      &mt('Dump Course DOCS to Construction Space: available on other servers');
1.74      www       131:     }
                    132: }
                    133: 
                    134: # -------------------------------------------------------- Actually dump course
                    135: 
                    136: sub dumpcourse {
1.75      www       137:     my $r=shift;
                    138:     $r->print('<html><head><title>Dump DOCS</title></head>'.
1.76      www       139:         &Apache::loncommon::bodytag('Dump Course DOCS to Construction Space').
                    140: 	      '<form name="dumpdoc" method="post">');
1.74      www       141:     my ($home,$other,%outhash)=&authorhosts();
1.75      www       142:     unless ($home) { return ''; }
1.76      www       143:     my $origcrsid=$ENV{'request.course.id'};
                    144:     my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
                    145:     if (($ENV{'form.authorspace'}) && ($ENV{'form.authorfolder'}=~/\w/)) {
                    146: # Do the dumping
1.75      www       147: 	unless ($outhash{'home_'.$ENV{'form.authorspace'}}) { return ''; }
                    148: 	my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'});
1.87      www       149: 	$r->print('<h3>'.&mt('Copying Files').'</h3>');
1.76      www       150: 	my $title=$ENV{'form.authorfolder'};
1.79      www       151: 	$title=~s/[^\w\/]+/\_/g;
                    152: 	my %replacehash=();
                    153: 	foreach (keys %ENV) {
                    154: 	    if ($_=~/^form\.namefor\_(.+)/) {
                    155: 		$replacehash{$1}=$ENV{$_};
                    156: 	    }
                    157: 	}
                    158: 	my $crs='/uploaded/'.$ENV{'request.course.id'}.'/';
                    159: 	$crs=~s/\_/\//g;
                    160: 	foreach (keys %replacehash) {
                    161: 	    my $newfilename=$title.'/'.$replacehash{$_};
1.132     www       162: 	    $newfilename=~s/[^\w\/\.\/]+/\_/g;
1.79      www       163: 	    my @dirs=split(/\//,$newfilename);
                    164: 	    my $path='/home/'.$ca.'/public_html';
                    165: 	    my $makepath=$path;
                    166: 	    my $fail=0;
                    167: 	    for (my $i=0;$i<$#dirs;$i++) {
                    168: 		$makepath.='/'.$dirs[$i];
                    169: 		unless (-e $makepath) { 
                    170: 		    unless(mkdir($makepath,0777)) { $fail=1; } 
                    171: 		}
                    172: 	    }
                    173: 	    $r->print('<br /><tt>'.$_.'</tt> => <tt>'.$newfilename.'</tt>: ');
                    174: 	    if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
                    175: 		if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
                    176: 		    print $fh &Apache::loncreatecourse::rewritefile(
                    177:          &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_),
                    178: 				     (%replacehash,$crs => '')
                    179: 								    );
                    180: 		} else {
                    181: 		    print $fh
                    182:          &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_);
                    183: 		       }
                    184: 		$fh->close();
                    185: 	    } else {
                    186: 		$fail=1;
                    187: 	    }
                    188: 	    if ($fail) {
                    189: 		$r->print('<font color="red">fail</font>');
                    190: 	    } else {
                    191: 		$r->print('<font color="green">ok</font>');
                    192: 	    }
                    193: 	}
1.76      www       194:     } else {
                    195: # Input form
                    196: 	unless ($home==1) {
                    197: 	    $r->print(
1.81      www       198: 		      '<h3>'.&mt('Select the Construction Space').'</h3><select name="authorspace">');
1.76      www       199: 	}
                    200: 	foreach (sort keys %outhash) {
                    201: 	    if ($_=~/^home_(.+)$/) {
                    202: 		if ($home==1) {
                    203: 		    $r->print(
                    204: 		  '<input type="hidden" name="authorspace" value="'.$1.'" />');
                    205: 		} else {
1.133     www       206: 		    $r->print('<option value="'.$1.'">'.$1.' - '.
                    207: 			      &Apache::loncommon::plainname(split(/\@/,$1)).'</option>');
1.76      www       208: 		}
                    209: 	    }
                    210: 	}
                    211: 	unless ($home==1) {
                    212: 	    $r->print('</select>');
                    213: 	}
                    214: 	my $title=$origcrsdata{'description'};
                    215: 	$title=~s/\s+/\_/gs;
                    216: 	$title=~s/\W//gs;
1.81      www       217: 	$r->print('<h3>'.&mt('Folder in Construction Space').'</h3><input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
1.76      www       218: 	&tiehash();
1.81      www       219: 	$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       220: 	foreach (&Apache::loncreatecourse::crsdirlist($origcrsid,'userfiles')) {
1.78      www       221: 	    $r->print('<tr><td>'.$_.'</td>');
                    222: 	    my ($ext)=($_=~/\.(\w+)$/);
                    223: 	    my $title=$hash{'title_'.$hash{
                    224: 		'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}};
                    225: 	    $r->print('<td>'.($title?$title:'&nbsp;').'</td>');
                    226: 	    unless ($title) {
                    227: 		$title=$_;
                    228: 	    }
                    229: 	    $title=~s/\.(\w+)$//;
1.132     www       230: 	    $title=~s/[^\w\/]+/\_/gs;
1.78      www       231: 	    $title.='.'.$ext;
1.79      www       232: 	    $r->print("\n<td><input type='text' size='60' name='namefor_".$_."' value='".$title."' /></td></tr>\n");
1.76      www       233: 	}
1.78      www       234: 	$r->print("</table>\n");
1.76      www       235: 	&untiehash();
                    236: 	$r->print(
1.81      www       237:   '<p><input type="submit" name="dumpcourse" value="'.&mt('Dump Course DOCS').'" /></p></form>');
1.75      www       238:     }
1.74      www       239: }
1.76      www       240: 
1.138     raeburn   241: # ------------------------------------------------------ Generate "export" button
                    242: 
                    243: sub exportbutton {
                    244:     return '</td><td bgcolor="#DDDDCC">'.
                    245:             '<input type="submit" name="exportcourse" value="'.
                    246:             &mt('Export Course to IMS').'" />'.
                    247:             &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs');
                    248: }
                    249: 
                    250: sub exportcourse {
                    251:     my $r=shift;
                    252:     my %discussiontime = &Apache::lonnet::dump('discussiontimes',
                    253:                                                $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
                    254:     my $numdisc = keys %discussiontime;
                    255:     my $navmap = Apache::lonnavmaps::navmap->new();
                    256:     my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
                    257:     my $curRes;
1.143     raeburn   258:     my $outcome;
1.138     raeburn   259: 
                    260:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                    261:                                             ['finishexport']);
                    262:     if ($ENV{'form.finishexport'}) {
                    263:         &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                    264:                                             ['archive','discussion']);
                    265: 
                    266:         my @exportitems = ();
                    267:         if (defined($ENV{'form.archive'})) {
                    268:             if (ref($ENV{'form.archive'}) eq 'ARRAY') {
                    269:                 @exportitems = @{$ENV{'form.archive'}};
                    270:             } else {
                    271:                 $exportitems[0] = $ENV{'form.archive'};
                    272:             }
                    273:         }
                    274:         my @discussions = ();
                    275:         if (defined($ENV{'form.discussion'})) {
                    276:             if (ref($ENV{'form.discussion'}) eq 'ARRAY') {
                    277:                 @discussions = $ENV{'form.discussion'};
                    278:             } else {
                    279:                 $discussions[0] = $ENV{'form.discussion'};
                    280:             }
                    281:         }
1.143     raeburn   282:         if (@exportitems == 0 && @discussions == 0) {
                    283:             $outcome = '<br />As you did not select any content items or discussions for export, an IMS package has not been created.  Please <a href="javascript:history.go(-1)">go back</a> to select either content items or discussions for export';
                    284:         } else {
                    285:             my $now = time;
                    286:             my $count = 0;
                    287:             my %symbs;
                    288:             my $manifestok = 0;
                    289:             my $imsresources;
                    290:             my $tempexport;
                    291:             my $copyresult;
                    292:             my $ims_manifest = &create_ims_store($now,\$manifestok,\$outcome,\$tempexport);
                    293:             if ($manifestok) {
                    294:                 &build_package($now,$navmap,\@exportitems,\@discussions,\$outcome,\$tempexport,\$copyresult,$ims_manifest);
                    295:                 close($ims_manifest);
                    296: 
                    297: #Create zip file in prtspool
                    298:                 my $imszipfile = '/prtspool/'.
                    299:                 $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.
                    300:                    time.'_'.rand(1000000000).'.zip';
                    301: # zip can cause an sh launch which can pass along all of %ENV
                    302: # which can be too large for /bin/sh to handle
                    303:                 my %oldENV=%ENV;
                    304:                 undef(%ENV);
                    305:                 my $cwd = &Cwd::getcwd();
                    306:                 my $imszip = '/home/httpd/'.$imszipfile;
                    307:                 chdir $tempexport;
                    308:                 open(OUTPUT, "zip -r $imszip *  2> /dev/null |");
                    309:                 close(OUTPUT);
                    310:                 chdir $cwd;
                    311:                 %ENV=%oldENV;
                    312:                 undef(%oldENV);
                    313:                 $outcome .= 'Download the zip file from <a href="'.$imszipfile.'">IMS course archive</a><br />';
                    314:                 if ($copyresult) {
                    315:                     $outcome .= 'The following errors occurred during export - '.$copyresult;
1.138     raeburn   316:                 }
1.143     raeburn   317:             } else {
                    318:                 $outcome = '<br />Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file.<br />';
1.138     raeburn   319:             }
                    320:         }
                    321: 
                    322:         $r->print('<html><head><title>Export Course</title></head>'.
1.143     raeburn   323:             &Apache::loncommon::bodytag('Export course to IMS or SCORM content package'));
                    324:         $r->print($outcome);
1.138     raeburn   325:         $r->print('</body></html>');
                    326:     } else {
                    327:         my $display;
                    328:         $display = '<form name="exportdoc" method="post">'."\n";
                    329:         $display .= 'Choose which items you wish to export from your course.<br /><br />';
                    330:         $display .= '<table border="0" cellspacing="0" cellpadding="3">'.
                    331:                     '<tr><td><fieldset><legend>&nbsp;<b>Content items</b></legend>'.
                    332:                     '<input type="button" value="check all" '.
                    333:                     'onclick="javascript:checkAll(document.exportdoc.archive)" />'.
                    334:                     '&nbsp;&nbsp;<input type="button" value="uncheck all"'.
                    335:                     ' onclick="javascript:uncheckAll(document.exportdoc.archive)" /></fieldset></td>'.
                    336:                     '<td>&nbsp;</td><td>&nbsp;</td>'.
                    337:                     '<td align="right"><fieldset><legend>&nbsp;<b>Discussion posts'.
                    338:                     '</b></legend><input type="button" value="check all"'.
                    339:                     ' onclick="javascript:checkAll(document.exportdoc.discussion)" />'.
                    340:                     '&nbsp;&nbsp;<input type="button" value="uncheck all"'.
                    341:                     ' onclick="javascript:uncheckAll(document.exportdoc.discussion)" /></fieldset></td>'.
                    342:                     '</tr></table>';
                    343:         my $curRes;
                    344:         my $depth = 0;
                    345:         my $count = 0;
                    346:         my $boards = 0;
                    347:         my $startcount = 5;
                    348:         my %parent = ();
                    349:         my %children = ();
                    350:         my $lastcontainer = $startcount;
                    351:         my @bgcolors = ('#F6F6F6','#FFFFFF');
                    352:         $display .= '<table cellspacing="0"><tr>'.
                    353:             '<td><b>Export content item?<br /></b></td><td>&nbsp;</td><td align="right">'."\n";
                    354:         if ($numdisc > 0) {
                    355:             $display.='<b>Export&nbsp;discussion posts?</b>'."\n";
                    356:         }
                    357:         $display.='&nbsp;</td></tr>';
                    358:         while ($curRes = $it->next()) {
                    359:             if (ref($curRes)) {
                    360:                 $count ++;
                    361:             }
                    362:             if ($curRes == $it->BEGIN_MAP()) {
                    363:                 $depth++;
                    364:                 $parent{$depth} = $lastcontainer;
                    365:             }
                    366:             if ($curRes == $it->END_MAP()) {
                    367:                 $depth--;
                    368:                 $lastcontainer = $parent{$depth};
                    369:             }
                    370:             if (ref($curRes)) {
                    371:                 my $symb = $curRes->symb();
                    372:                 my $color = $count%2;
                    373:                 $display .='<tr bgcolor='.$bgcolors[$color].'><td>'."\n".
                    374:                     '<input type="checkbox" name="archive" value="'.$count.'" ';
                    375:                 if (($curRes->is_sequence()) || ($curRes->is_page())) {
                    376:                     my $checkitem = $count + $boards + $startcount;
                    377:                     $display .= 'onClick="javascript:propagateCheck('."'$checkitem'".')"';
                    378:                 }
                    379:                 $display .= ' />'."\n";
                    380:                 for (my $i=0; $i<$depth; $i++) {
                    381:                     $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";
                    382:                 }
                    383:                 if ($curRes->is_sequence()) {
                    384:                     $display .= '<img src="/adm/lonIcons/navmap.folder.open.gif">&nbsp;'."\n";
                    385:                     $lastcontainer = $count + $startcount + $boards;
                    386:                 } elsif ($curRes->is_page()) {
                    387:                     $display .= '<img src="/adm/lonIcons/navmap.page.open.gif">&nbsp;'."\n";
                    388:                     $lastcontainer = $count + $startcount + $boards;
                    389:                 }
                    390:                 my $currelem = $count+$boards+$startcount;
                    391:                 $children{$parent{$depth}} .= $currelem.':';
                    392:                 $display .= '&nbsp;'.$curRes->title().'</td>';
                    393:                 if ($discussiontime{$symb} > 0) {
                    394:                     $boards ++;
                    395:                     $currelem = $count+$boards+$startcount;
                    396:                     $display .= '<td>&nbsp;</td><td align="right"><input type="checkbox" name="discussion" value="'.$count.'" />&nbsp;</td>'."\n";
                    397:                 } else {
                    398:                     $display .= '<td colspan="2">&nbsp;</td>'."\n";
                    399:                 }
                    400:             }
                    401:         }
                    402:         my $scripttag = qq|
                    403: <script>
                    404: 
                    405: function checkAll(field) {
                    406:     for (i = 0; i < field.length; i++)
                    407:         field[i].checked = true ;
                    408: }
                    409: 
                    410: function uncheckAll(field) {
                    411:     for (i = 0; i < field.length; i++)
                    412:         field[i].checked = false ;
                    413: }
                    414: 
                    415: function propagateCheck(item) {
                    416:     if (document.exportdoc.elements[item].checked == true) {
                    417:         containerCheck(item)
                    418:     }
                    419: } 
                    420: 
                    421: function containerCheck(item) {
                    422:     document.exportdoc.elements[item].checked = true
                    423:     var numitems = $count + $boards + $startcount
                    424:     var parents = new Array(numitems)
                    425:     for (var i=$startcount; i<numitems; i++) {
                    426:         parents[i] = new Array
                    427:     }
                    428:         |;
                    429: 
                    430:         foreach my $container (sort { $a <=> $b } keys %children) {
                    431:             my @contents = split/:/,$children{$container};
                    432:             for (my $i=0; $i<@contents; $i ++) {
                    433:                 $scripttag .= '    parents['.$container.']['.$i.'] = '.$contents[$i]."\n";
                    434:             }
                    435:         }
                    436: 
                    437:         $scripttag .= qq|
                    438:     if (parents[item].length > 0) {
                    439:         for (var j=0; j<parents[item].length; j++) {
                    440:             containerCheck(parents[item][j])
                    441:         }
                    442:      }   
                    443: }
                    444: 
                    445: </script>
                    446:         |;
                    447:         $r->print('<html><head><title>Export Course</title>'.$scripttag.'</head>'.
                    448:             &Apache::loncommon::bodytag('Export course to IMS or SCORM content package'
                    449: ));
                    450: 
                    451:         $r->print($display.'</table>'.
                    452:                   '<p><input type="hidden" name="finishexport" value="1">'.
                    453:                   '<input type="submit" name="exportcourse" value="'.
                    454:                   &mt('Export Course DOCS').'" /></p></form></body></html>');
                    455:     }
                    456: }
                    457: 
1.143     raeburn   458: sub create_ims_store {
                    459:     my ($now,$manifestok,$outcome,$tempexport) = @_;
                    460:     $$tempexport = $Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/ims_exports';
                    461:     my $ims_manifest;
                    462:     if (!-e $$tempexport) {
                    463:         mkdir($$tempexport,0700);
                    464:     }
                    465:     $$tempexport .= '/'.$now;
                    466:     if (!-e $$tempexport) {
                    467:         mkdir($$tempexport,0700);
                    468:     }
                    469:     $$tempexport .= '/'.$ENV{'user.domain'}.'_'.$ENV{'user.name'};
                    470:     if (!-e $$tempexport) {
                    471:         mkdir($$tempexport,0700);
                    472:     }
                    473: # open manifest file
                    474:     my $manifest = '/imsmanifest.xml';
                    475:     my $manifestfilename = $$tempexport.$manifest;
                    476:     if ($ims_manifest = Apache::File->new('>'.$manifestfilename)) {
                    477:         $$manifestok=1;
                    478:         print $ims_manifest
                    479: '<?xml version="1.0" encoding="UTF-8"?>'."\n".
                    480: '<manifest xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"'.
                    481: ' xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"'.
                    482: ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'.
                    483: ' identifier="MANIFEST-'.$ENV{'request.course.id'}.'-'.$now.'"'.
                    484: '  xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1imscp_v1p1.xsd'.
                    485: '  http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">'."\n".
                    486: '  <organizations default="ORG-."'.$ENV{'request,course.id'}.'-'.$now.'">'."\n".
                    487: '    <organization identifier="ORG-'.$ENV{'request.course.id'}.'-'.$now.'"'.
                    488: ' structure="hierarchical">'."\n".
                    489: '      <title>'.$ENV{'request.'.$ENV{'request.course.id'}.'.description'}.'</title>'
                    490:     } else {
                    491:         $$outcome .= 'An error occurred opening the IMS manifest file.<br />'
                    492: ;
                    493:     }
                    494:     return $ims_manifest;
                    495: }
                    496: 
                    497: sub build_package {
                    498:     my ($now,$navmap,$exportitems,$discussions,$outcome,$tempexport,$copyresult,$ims_manifest) = @_;
                    499: # first iterator to look for dependencies
                    500:     my $it = $navmap->getIterator(undef,undef,undef,1,undef,undef);
                    501:     my $curRes;
                    502:     my $count = 0;
                    503:     my $depth = 0;
                    504:     my $lastcontainer = 0;
                    505:     my %parent = ();
                    506:     my @dependencies = ();
                    507:     my $cnum = $ENV{'request.'.$ENV{'request.course.id'}.'.num'};
                    508:     my $cdom = $ENV{'request.'.$ENV{'request.course.id'}.'.domain'};
                    509:     while ($curRes = $it->next()) {
                    510:         if (ref($curRes)) {
                    511:             $count ++;
                    512:         }
                    513:         if ($curRes == $it->BEGIN_MAP()) {
                    514:             $depth++;
                    515:             $parent{$depth} = $lastcontainer;
                    516:         }
                    517:         if ($curRes == $it->END_MAP()) {
                    518:             $depth--;
                    519:             $lastcontainer = $parent{$depth};
                    520:         }
                    521:         if (ref($curRes)) {
                    522:             if ($curRes->is_sequence() || $curRes->is_page()) {
                    523:                 $lastcontainer = $count;
                    524:             }
                    525:             if (grep/^$count$/,@$exportitems) {
                    526:                 &get_dependencies($exportitems,\%parent,$depth,\@dependencies);
                    527:             }
                    528:         }
                    529:     }
                    530: # second iterator to build manifest and store resources
                    531:     $it = $navmap->getIterator(undef,undef,undef,1,undef,undef);
                    532:     $depth = 0;
                    533:     my $prevdepth;
                    534:     $count = 0;
                    535:     my $imsresources;
                    536:     my $pkgdepth;
                    537:     if ($curRes == $it->BEGIN_MAP()) {
                    538:         $prevdepth = $depth;
                    539:         $depth++;
                    540:     }
                    541:     if ($curRes == $it->END_MAP()) {
                    542:         $prevdepth = $depth;
                    543:         $depth--;
                    544:     }
                    545: 
                    546:     if (ref($curRes)) {
                    547:         if ((grep/^$count$/,@$exportitems) || (grep/^$count$/,@dependencies)) {
                    548:             my $symb = $curRes->symb();
                    549:             my $isvisible = 'true';
                    550:             my $resourceref;
                    551:             if ($curRes->randomout()) {
                    552:                 $isvisible = 'false';
                    553:             }
                    554:             unless ($curRes->is_sequence()) {
                    555:                 $resourceref = 'identifierref="RES-'.$ENV{'request.course.id'}.'-'.$count.'"';
                    556:             }
                    557:             if (($depth <= $prevdepth) && ($count > 1)) {
                    558:                 print $ims_manifest '  </item>'."\n";
                    559:             }
                    560:             $prevdepth = $depth;
                    561: 
                    562:             my $itementry =
                    563:               '<item identifier="ITEM-'.$ENV{'request.course.id'}.'-'.$count.
                    564:               '" isvisible="'.$isvisible.'" '.$resourceref.'>'.
                    565:               '<title>'.$curRes->title().'</title>';
                    566:             print $ims_manifest "\n".$itementry;
                    567: 
                    568:             unless ($curRes->is_sequence()) {
                    569:                 my $content_file;
                    570:                 my @hrefs = ();
                    571:                 &process_content($count,$curRes,$cdom,$cnum,$symb,$content_file,\@hrefs,$copyresult,$tempexport);
                    572:                 if ($content_file) {
                    573:                     $imsresources .= "\n".
                    574:                      '   <resource identifier="RES-'.$ENV{'request.course.id'}.'-'.$count.
                    575:                      '" type="webcontent" href="'.$content_file.'">'."\n".
                    576:                      '       <file href="'.$content_file.'" />'."\n";
                    577:                     foreach (@hrefs) {
                    578:                         $imsresources .=
                    579:                      '        <file href="'.$_.'" />'."\n";
                    580:                     }
                    581:                     $imsresources .= '    </resource>'."\n";
                    582:                 }
                    583:             }
                    584:             $pkgdepth = $depth;
                    585:         }
                    586:     }
                    587:     while ($pkgdepth > -1) {
                    588:         print $ims_manifest "    </item>\n";
                    589:         $pkgdepth --;
                    590:     }
                    591:     my $resource_text = qq|
                    592:     </organization>
                    593:   </organizations>
                    594:   <resources>
                    595:     $imsresources
                    596:   </resources>
                    597: </manifest>
                    598:     |;
                    599:     print $ims_manifest $resource_text;
                    600: }
                    601: 
                    602: sub get_dependencies {
                    603:     my ($exportitems,$parent,$depth,$dependencies) = @_;
                    604:     if ($depth > 1) {
                    605:         unless (grep/^$$parent{$depth}$/,@$exportitems || grep/^$$parent{$depth}$/,@$dependencies) {
                    606:             push @$dependencies, $$parent{$depth};
                    607:             if ($depth > 2) {
                    608:                 &get_dependencies($exportitems,$parent,$depth-1,$dependencies);
                    609:             }
                    610:         }
                    611:     }
                    612: }
                    613: 
                    614: sub process_content {
                    615:     my ($count,$curRes,$cdom,$cnum,$symb,$content_file,$href,$copyresult,$tempexport) = @_;
                    616:     my $content_type;
                    617:     my $message;
                    618: # find where user is author or co-author
                    619:     my %roleshash = &Appache::lonnet::get_my_roles();
                    620:     if ($curRes->is_page()) {
                    621:         $content_type = 'page';
                    622:     } elsif ($symb =~ m-public/$cdom/$cnum/syllabus$-) {
                    623:         $content_type = 'syllabus';
                    624:     } elsif ($symb =~ m-\.sequence____\d+____ext-) {
                    625:         $content_type = 'external';
                    626:     } elsif ($symb =~ m-adm/navmaps$-) {
                    627:         $content_type =  'navmap';
                    628:     } elsif ($symb =~ m-adm/$cdom/$cnum/\d+/smppg$-) {
                    629:         $content_type = 'simplepage';
                    630:     } elsif ($symb =~ m-$-) {
                    631:         $content_type = 'simpleproblem';
                    632:     } elsif ($symb =~ m-adm/$cdom/$cnum/\d+/bulletinboard$-) {
                    633:         $content_type = 'bulletinboard';
                    634:     } elsif ($symb =~ m-adm/$cdom/$cnum/\d+/aboutme$-) {
                    635:         $content_type = 'aboutme';
                    636:     } elsif ($symb =~ m-uploaded/$cdom/$cnum-) {
                    637:         &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,'uploaded');
                    638:     } elsif ($symb =~ m-\.sequence____\d+____([^/])/([^/])-) {
                    639:         my $coauth = $2.':'.$1.':ca';
                    640:         my $canedit = 0;
                    641:         if ($1 eq $ENV{'user.domain'} && $2 eq $ENV{'user.name'})  {
                    642:             $canedit= 1;
                    643:         } elsif (defined($roleshash{$coauth})) {
                    644:             if ($roleshash{$coauth} =~ /(\d+):(\d+)/) {
                    645:                 if (($1 < time || $1 == 0) && ($2 == 0 || $2 >= time)) {
                    646:                     $canedit = 1;
                    647:                 }
                    648:             } elsif ($roleshash{$coauth} eq ':') {
                    649:                 $canedit = 1;
                    650:             }
                    651:         }
                    652:         if ($canedit) {
                    653:             &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,'resource');
                    654:         } else {
                    655:             &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,'noedit');
                    656:         }
                    657:     }
                    658:     $$copyresult .= $message."\n";
                    659: }
                    660: 
                    661: sub replicate_content {
                    662:     my ($cdom,$cnum,$tempexport,$symb,$count,$message,$caller) = @_;
                    663:     my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
                    664:     my $feedurl = &Apache::lonnet::clutter($url);
                    665: 
                    666:     my $content;
                    667:     my $filename;
                    668:     my $repstatus;
                    669:     if ($url =~ m-[^/]/(.+)$-) {
                    670:         $filename = $1;
                    671:         if (!-e $tempexport.'/resources') {
                    672:             mkdir($tempexport.'/resources',0700);
                    673:         }
                    674:         if (!-e $tempexport.'/resources') {
                    675:             mkdir($tempexport.'/resources/'.$count,0700);
                    676:         }
                    677:         my $destination = $$tempexport.'/resources/'.$count.'/'.$filename;
                    678:         my $copiedfile;
                    679:         if ($copiedfile = Apache::File->new('>'.$destination)) {
                    680:             my $content;
                    681:             if ($caller eq 'uploaded' || $caller eq 'resource') {
                    682:                 $content = &Apache::lonnet::getfile($url);
                    683:                 if ($content eq -1) {
                    684:                     $$message = 'Could not copy file '.$filename;
                    685:                 } else {
                    686:                     $repstatus = 'ok';
                    687:                 }
                    688:             } elsif ($caller eq 'noedit') {
                    689:                 my $rtncode;
                    690:                 $repstatus = &getuploaded('GET',$url,$cdom,$cnum,$content,$rtncode);
                    691:                 unless ($repstatus eq 'ok') {
                    692:                     $$message = 'Could not render '.$url.' server message - '.$rtncode;
                    693:                 }
                    694:             }
                    695:             if ($repstatus eq 'ok') {
                    696:                 print $copiedfile $content;
                    697:             }
                    698:             close($copiedfile);
                    699:         } else {
                    700:             $$message = 'Could not open destination file for '.$filename."\n";
                    701:         }
                    702:     } else {
                    703:         $$message = 'Could not determine name of file for ';
                    704:     }
                    705:     return $repstatus;
                    706: }
1.74      www       707: 
1.73      bowersj2  708: # Imports the given (name, url) resources into the course
                    709: # coursenum, coursedom, and folder must precede the list
                    710: sub group_import {
                    711:     my $coursenum = shift;
                    712:     my $coursedom = shift;
                    713:     my $folder = shift;
1.142     raeburn   714:     my $container = shift;
                    715:     my $caller = shift;
1.73      bowersj2  716:     while (@_) {
                    717: 	my $name = shift;
                    718: 	my $url = shift;
1.142     raeburn   719:         if (($url =~ m#^/uploaded/$coursedom/$coursenum/(default_\d+\.)(page|sequence)$#) && ($caller eq 'londocs')) {
                    720:             my $errtext = '';
                    721:             my $fatal = 0;
                    722:             my $newmapstr = '<map>'."\n".
                    723:                             '<resource id="1" src="" type="start"></resource>'."\n".
                    724:                             '<link from="1" to="2" index="1"></link>'."\n".
                    725:                             '<resource id="2" src="" type="finish"></resource>'."\n".
                    726:                             '</map>';
                    727:             $ENV{'form.output'}=$newmapstr;
                    728:             my $home=&Apache::lonnet::homeserver($coursenum,$coursedom);
                    729:             my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$home,
                    730:                                                 'output',$1.$2);
                    731:             if ($result != m|^/uploaded/|) {
                    732:                 $errtext.='Map not saved: A network error occured when trying to save the new map. ';
                    733:                 $fatal = 2;
                    734:             }
                    735:             if ($fatal) {
                    736:                 return ($errtext,$fatal);
                    737:             }
                    738:         }
1.73      bowersj2  739: 	if ($url) {
                    740: 	    my $idx = $#Apache::lonratedt::resources + 1;
                    741: 	    $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=$idx;
                    742: 	    my $ext = 'false';
                    743: 	    if ($url=~/^http:\/\//) { $ext = 'true'; }
                    744: 	    $url =~ s/:/\&colon;/g;
                    745: 	    $name =~ s/:/\&colon;/g;
                    746: 	    $Apache::lonratedt::resources[$idx] = 
                    747: 		join ':', ($name, $url, $ext, 'normal', 'res');
                    748: 	}
                    749:     }
1.142     raeburn   750:     return &storemap($coursenum, $coursedom, $folder.'.'.$container);
1.73      bowersj2  751: }
                    752: 
1.114     albertel  753: sub breadcrumbs {
                    754:     my ($where)=@_;
                    755:     &Apache::lonhtmlcommon::clear_breadcrumbs();
1.142     raeburn   756:     my (@folders);
                    757:     if ($ENV{'form.pagepath'}) {
                    758:         @folders = split('&',$ENV{'form.pagepath'});
                    759:     } else {
                    760:         @folders=split('&',$ENV{'form.folderpath'});
                    761:     }
1.116     albertel  762:     my $folderpath;
                    763:     while (@folders) {
                    764: 	my $folder=shift(@folders);
                    765: 	my $foldername=shift(@folders);
                    766: 	if ($folderpath) {$folderpath.='&';}
                    767: 	$folderpath.=$folder.'&'.$foldername;
                    768: 	my $url='/adm/coursedocs?folderpath='.
                    769: 	    &Apache::lonnet::escape($folderpath);
1.114     albertel  770: 	    &Apache::lonhtmlcommon::add_breadcrumb(
                    771: 		      {'href'=>$url,
                    772: 		       'title'=>&Apache::lonnet::unescape($foldername),
1.117     albertel  773: 		       'text'=>'<font size="+1">'.
                    774: 			   &Apache::lonnet::unescape($foldername).'</font>'
                    775: 		       });
1.114     albertel  776: 		       
                    777: 						 
                    778:     }
1.137     albertel  779:     return &Apache::lonhtmlcommon::breadcrumbs(undef,undef,undef,undef,undef,
                    780: 					       0,'nohelp');
1.114     albertel  781: }
                    782: 
1.7       www       783: sub editor {
                    784:     my ($r,$coursenum,$coursedom,$folder,$allowed)=@_;
1.114     albertel  785: 
                    786:     $r->print(&breadcrumbs($folder));
1.10      www       787:     my $errtext='';
                    788:     my $fatal=0;
1.142     raeburn   789:     my $container='sequence';
                    790:     if ($ENV{'form.pagepath'}) {
                    791:         $container='page';
                    792:     }
1.10      www       793:     ($errtext,$fatal)=
1.142     raeburn   794:               &mapread($coursenum,$coursedom,$folder.'.'.$container);
1.17      www       795:     if ($#Apache::lonratedt::order<1) {
                    796:        	$Apache::lonratedt::order[0]=1;
                    797:         $Apache::lonratedt::resources[1]='';
                    798:     }
1.7       www       799:     if ($fatal) {
                    800: 	   $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    801:     } else {
                    802: # ------------------------------------------------------------ Process commands
1.121     www       803: 
1.16      www       804: # ---------------- if they are for this folder and user allowed to make changes
                    805: 	if (($allowed) && ($ENV{'form.folder'} eq $folder)) {
1.123     www       806: # set parameters and change order
1.121     www       807: 	    if (defined($ENV{'form.setparms'})) {
                    808: 		my $idx=$ENV{'form.setparms'};
1.123     www       809: # set parameters
1.121     www       810: 		if ($ENV{'form.randpick_'.$idx}) {
1.122     www       811: 		    &Apache::lonratedt::storeparameter($idx,'parameter_randompick',$ENV{'form.randpick_'.$idx},'int_pos');
1.121     www       812: 		} else {
1.122     www       813: 		    &Apache::lonratedt::delparameter($idx,'parameter_randompick');
1.121     www       814: 		}
                    815: 		if ($ENV{'form.hidprs_'.$idx}) {
1.122     www       816: 		    &Apache::lonratedt::storeparameter($idx,'parameter_hiddenresource','yes','string_yesno');
1.121     www       817: 		} else {
1.122     www       818: 		    &Apache::lonratedt::delparameter($idx,'parameter_hiddenresource');
1.121     www       819: 		}
                    820: 		if ($ENV{'form.encprs_'.$idx}) {
1.122     www       821: 		    &Apache::lonratedt::storeparameter($idx,'parameter_encrypturl','yes','string_yesno');
1.121     www       822: 		} else {
1.122     www       823: 		    &Apache::lonratedt::delparameter($idx,'parameter_encrypturl');
1.121     www       824: 		}
                    825: 
1.123     www       826: 		if ($ENV{'form.newpos'}) {
                    827: # change order
                    828: 
                    829: 		    my $newpos=$ENV{'form.newpos'}-1;
1.124     www       830: 		    my $currentpos=$ENV{'form.currentpos'}-1;
1.125     www       831: 		    my $i;
                    832: 		    my @neworder=();
                    833: 		    if ($newpos>$currentpos) {
                    834: # moving stuff up
                    835: 			for ($i=0;$i<$currentpos;$i++) {
                    836: 			    $neworder[$i]=$Apache::lonratedt::order[$i];
                    837: 			}
                    838: 			for ($i=$currentpos;$i<$newpos;$i++) {
                    839: 			    $neworder[$i]=$Apache::lonratedt::order[$i+1];
                    840: 			}
                    841:                         $neworder[$newpos]=$Apache::lonratedt::order[$currentpos];
                    842: 			for ($i=$newpos+1;$i<=$#Apache::lonratedt::order;$i++) {
                    843: 			    $neworder[$i]=$Apache::lonratedt::order[$i];
                    844: 			}
                    845: 		    } else {
                    846: # moving stuff down
                    847: 			for ($i=0;$i<$newpos;$i++) {
                    848: 			    $neworder[$i]=$Apache::lonratedt::order[$i];
                    849: 			}
                    850: 			$neworder[$newpos]=$Apache::lonratedt::order[$currentpos];
                    851: 			for ($i=$newpos+1;$i<$currentpos+1;$i++) {
                    852: 			    $neworder[$i]=$Apache::lonratedt::order[$i-1];
                    853: 			}
                    854: 			for ($i=$currentpos+1;$i<=$#Apache::lonratedt::order;$i++) {
                    855: 			    $neworder[$i]=$Apache::lonratedt::order[$i];
                    856: 			}
                    857: 		    }
                    858: 		    @Apache::lonratedt::order=@neworder;
1.124     www       859: 		}
                    860: # store the changed version
1.123     www       861: 
1.142     raeburn   862: 		($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
1.124     www       863: 		if ($fatal) {
                    864: 		    $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    865: 		    return;
1.123     www       866: 		}
1.124     www       867: 		
                    868: 	    }
1.123     www       869: 
1.10      www       870: # upload a file, if present
                    871:            if (($ENV{'form.uploaddoc.filename'}) &&
                    872:                ($ENV{'form.cmd'}=~/^upload_(\w+)/)) {
1.112     raeburn   873: 	    if ( ($folder=~/^$1/) || ($1 eq 'default') ) {
1.10      www       874: # this is for a course, not a user, so set coursedoc flag
                    875: # probably the only place in the system where this should be "1"
1.126     albertel  876: 	      my $url=&Apache::lonnet::userfileupload('uploaddoc',1,'docs');
1.10      www       877:               my $ext='false';
                    878:               if ($url=~/^http\:\/\//) { $ext='true'; }
                    879:               $url=~s/\:/\&colon;/g;
                    880: 	      my $comment=$ENV{'form.comment'};
                    881:               $comment=~s/\</\&lt\;/g;
                    882:               $comment=~s/\>/\&gt\;/g;
                    883:               $comment=~s/\:/\&colon;/g;
1.17      www       884:               if ($folder=~/^supplemental/) {
                    885: 		  $comment=time.'___&&&___'.$ENV{'user.name'}.'___&&&___'.
                    886: 		      $ENV{'user.domain'}.'___&&&___'.$comment;
                    887:               }
1.10      www       888:               my $newidx=$#Apache::lonratedt::resources+1;
                    889:               $Apache::lonratedt::resources[$newidx]=
                    890:                   $comment.':'.$url.':'.$ext.':normal:res';
                    891:               $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=
                    892:                                                               $newidx;       
1.104     albertel  893: 
1.142     raeburn   894: 	      ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
1.104     albertel  895: 	      if ($fatal) {
                    896: 		  $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    897: 		  return;
                    898: 	      }
1.10      www       899: 	     }
                    900:             }
1.8       www       901: 	    if ($ENV{'form.cmd'}) {
1.10      www       902:                 my ($cmd,$idx)=split(/\_/,$ENV{'form.cmd'});
                    903:                 if ($cmd eq 'del') {
1.128     albertel  904: 		    my (undef,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]);
                    905: 		    if ($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) {
                    906: 			&Apache::lonnet::removeuploadedurl($url);
                    907: 		    }
1.10      www       908: 		    for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) {
                    909:                         $Apache::lonratedt::order[$i]=
                    910:                           $Apache::lonratedt::order[$i+1];
                    911:                     }
                    912:                     $#Apache::lonratedt::order--;
                    913:                 } elsif ($cmd eq 'up') {
1.38      www       914: 		  if (($idx) && (defined($Apache::lonratedt::order[$idx-1]))) {
1.10      www       915:                     my $i=$Apache::lonratedt::order[$idx-1];
                    916:                     $Apache::lonratedt::order[$idx-1]=
                    917: 			$Apache::lonratedt::order[$idx];
                    918:                     $Apache::lonratedt::order[$idx]=$i;
1.38      www       919: 		   }
1.10      www       920:                 } elsif ($cmd eq 'down') {
1.38      www       921: 		   if (defined($Apache::lonratedt::order[$idx+1])) {
1.10      www       922:                     my $i=$Apache::lonratedt::order[$idx+1];
                    923:                     $Apache::lonratedt::order[$idx+1]=
                    924: 			$Apache::lonratedt::order[$idx];
                    925:                     $Apache::lonratedt::order[$idx]=$i;
1.38      www       926: 		   }
1.36      www       927:                 } elsif ($cmd eq 'rename') {
1.142     raeburn   928:                     my $ratstr = $Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]];
1.36      www       929:                     my ($rtitle,@rrest)=split(/\:/,
                    930:                        $Apache::lonratedt::resources[
                    931: 				       $Apache::lonratedt::order[$idx]]);
1.38      www       932:                     my $comment=
                    933:                      &HTML::Entities::decode($ENV{'form.title'});
1.36      www       934:                     $comment=~s/\</\&lt\;/g;
                    935:                     $comment=~s/\>/\&gt\;/g;
                    936:                     $comment=~s/\:/\&colon;/g;
1.144     albertel  937: 		    if ($comment=~/\S/) {
                    938: 			$Apache::lonratedt::resources[
1.36      www       939: 				       $Apache::lonratedt::order[$idx]]=
1.144     albertel  940: 				            $comment.':'.join(':',@rrest);
                    941: 		    }
1.10      www       942:                 }
                    943: # Store the changed version
1.104     albertel  944: 		($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.142     raeburn   945: 					    $folder.'.'.$container);
1.104     albertel  946: 		if ($fatal) {
                    947: 		    $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    948: 		    return;
                    949: 		}
1.8       www       950:             }
1.11      www       951: # Group import/search
                    952: 	    if ($ENV{'form.importdetail'}) {
1.73      bowersj2  953: 		my @imports;
                    954: 		foreach (split(/\&/,$ENV{'form.importdetail'})) {
                    955: 		    if (defined($_)) {
                    956: 			my ($name,$url)=split(/\=/,$_);
                    957: 			$name=&Apache::lonnet::unescape($name);
                    958: 			$url=&Apache::lonnet::unescape($url);
                    959: 			push @imports, $name, $url;
                    960: 		    }
                    961: 		}
1.11      www       962: # Store the changed version
1.104     albertel  963: 		($errtext,$fatal)=group_import($coursenum, $coursedom, $folder,
1.142     raeburn   964: 					       $container,'londocs',@imports);
1.104     albertel  965: 		if ($fatal) {
                    966: 		    $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    967: 		    return;
                    968: 		}
1.11      www       969:             }
1.53      www       970: # Loading a complete map
                    971: 	   if (($ENV{'form.importmap'}) && ($ENV{'form.loadmap'})) {
1.104     albertel  972: 	       foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$ENV{'form.importmap'}))) {
1.53      www       973:                    my $idx=$#Apache::lonratedt::resources;
                    974:                    $idx++;
                    975:                    $Apache::lonratedt::resources[$idx]=$_;
                    976:                    $Apache::lonratedt::order
1.104     albertel  977: 		       [$#Apache::lonratedt::order+1]=$idx;
                    978: 	       }
1.53      www       979: 
                    980: # Store the changed version
1.104     albertel  981: 	       ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.142     raeburn   982: 					   $folder.'.'.$container);
1.104     albertel  983: 	       if ($fatal) {
                    984: 		   $r->print('<p><font color="red">'.$errtext.'</font></p>');
                    985: 		   return;
                    986: 	       }
1.53      www       987:            }
1.16      www       988:        }
                    989: # ---------------------------------------------------------------- End commands
1.7       www       990: # ---------------------------------------------------------------- Print screen
1.10      www       991:         my $idx=0;
1.148     www       992: 	my $shown=0;
1.10      www       993:         $r->print('<table>');
                    994:         foreach (@Apache::lonratedt::order) {
                    995:            my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]);
                    996:            unless ($name) {  $name=(split(/\//,$url))[-1]; }
1.148     www       997:            unless ($name) { $idx++; next; }
1.112     raeburn   998:            $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum));
1.10      www       999:            $idx++;
1.148     www      1000: 	   $shown++;
1.10      www      1001:         }
1.148     www      1002: 	unless ($shown) {
1.131     www      1003: 	    $r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>');
                   1004: 	}
1.10      www      1005:         $r->print('</table>');
1.7       www      1006:     }
                   1007: }
1.1       www      1008: 
1.8       www      1009: # --------------------------------------------------------------- An entry line
                   1010: 
                   1011: sub entryline {
1.112     raeburn  1012:     my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;
1.38      www      1013:     $title=~s/\&colon\;/\:/g;
                   1014:     $title=&HTML::Entities::encode(&HTML::Entities::decode(
1.109     albertel 1015:      &Apache::lonnet::unescape($title)),'"<>&\'');
1.38      www      1016:     my $renametitle=$title;
                   1017:     my $foldertitle=$title;
1.142     raeburn  1018:     my $pagetitle=$title;
1.122     www      1019:     my $orderidx=$Apache::lonratedt::order[$index];
1.109     albertel 1020:     if ($title=~ /^(\d+)___&amp;&amp;&amp;___(\w+)___&amp;&amp;&amp;___(\w+)___&amp;&amp;&amp;___(.*)$/	) { 
                   1021: 	$foldertitle=&Apache::lontexconvert::msgtexconverted($4);
                   1022: 	$renametitle=$4;
                   1023: 	$title='<i>'.&Apache::lonlocal::locallocaltime($1).'</i> '.
                   1024: 	    &Apache::loncommon::plainname($2,$3).': <br />'.
                   1025: 	    $foldertitle;
                   1026:     }
1.38      www      1027:     $renametitle=~s/\&quot\;/\\\"/g;
1.8       www      1028:     my $line='<tr>';
                   1029: # Edit commands
1.142     raeburn  1030:     my $container;
1.120     www      1031:     my $folderpath;
                   1032:     if ($ENV{'form.folderpath'}) {
1.142     raeburn  1033:         $container = 'sequence';
1.120     www      1034: 	$folderpath=&Apache::lonnet::escape($ENV{'form.folderpath'});
                   1035: 	# $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'},'<>&"');
                   1036:     }
1.156   ! albertel 1037:     my ($pagepath,$pagesymb);
1.142     raeburn  1038:     if ($ENV{'form.pagepath'}) {
                   1039:         $container = 'page';
                   1040:         $pagepath=&Apache::lonnet::escape($ENV{'form.pagepath'});
1.156   ! albertel 1041:         $pagesymb=&Apache::lonnet::escape($ENV{'form.pagesymb'});
1.142     raeburn  1042:     }
1.109     albertel 1043:     if ($allowed) {
1.123     www      1044: 	my $incindex=$index+1;
                   1045: 	my $selectbox='';
                   1046: 	if ($folder!~/^supplemental/) {
                   1047: 	    $selectbox=
1.124     www      1048: 		'<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.123     www      1049: 		'<select name="newpos" onChange="this.form.submit()">';
                   1050: 	    for (my $i=1;$i<=$#Apache::lonratedt::order+1;$i++) {
                   1051: 		if ($i==$incindex) {
                   1052: 		    $selectbox.='<option value="" selected="1">('.$i.')</option>';
                   1053: 		} else {
                   1054: 		    $selectbox.='<option value="'.$i.'">'.$i.'</option>';
                   1055: 		}
                   1056: 	    }
                   1057: 	    $selectbox.='</select>';
                   1058: 	}
1.119     www      1059: 	my %lt=&Apache::lonlocal::texthash(
                   1060:                 'up' => 'Move Up',
1.109     albertel 1061: 		'dw' => 'Move Down',
                   1062: 		'rm' => 'Remove',
                   1063: 		'rn' => 'Rename');
1.142     raeburn  1064:         if ($ENV{'form.pagepath'}) {
                   1065:             $line.=(<<END);
                   1066: <form name="entry_$index" action="/adm/coursedocs" method="post">
                   1067: <input type="hidden" name="pagepath" value="$ENV{'form.pagepath'}" />
1.156   ! albertel 1068: <input type="hidden" name="pagesymb" value="$ENV{'form.pagesymb'}" />
1.142     raeburn  1069: <input type="hidden" name="setparms" value="$orderidx" />
                   1070: <td><table border='0' cellspacing='2' cellpadding='0'>
                   1071: <tr><td bgcolor="#DDDDDD">
1.156   ! albertel 1072: <a href='/adm/coursedocs?cmd=up_$index&pagepath=$pagepath&pagesymb=$pagesymb'>
1.142     raeburn  1073: <img src="${iconpath}move_up.gif" alt='$lt{'up'}' border='0' /></a></td></tr>
                   1074: <tr><td bgcolor="#DDDDDD">
1.156   ! albertel 1075: <a href='/adm/coursedocs?cmd=down_$index&pagepath=$pagepath&pagesymb=$pagesymb'>
1.142     raeburn  1076: <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' border='0' /></a></td></tr>
                   1077: </table></td>
                   1078: <td>$selectbox
                   1079: </td><td bgcolor="#DDDDDD">
1.156   ! albertel 1080: <a href='javascript:removeres("$pagepath","$index","$renametitle","page","$pagesymb");'>
1.142     raeburn  1081: <font size="-2" color="#990000">$lt{'rm'}</font></a>
1.156   ! albertel 1082: <a href='javascript:changename("$pagepath","$index","$renametitle","page","$pagesymb");'>
1.142     raeburn  1083: <font size="-2" color="#009900">$lt{'rn'}</font></a></td>
                   1084: END
                   1085:         } else {
                   1086:             $line.=(<<END); 
1.121     www      1087: <form name="entry_$index" action="/adm/coursedocs" method="post">
                   1088: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.122     www      1089: <input type="hidden" name="setparms" value="$orderidx" />
1.54      www      1090: <td><table border='0' cellspacing='2' cellpadding='0'>
                   1091: <tr><td bgcolor="#DDDDDD">
1.115     albertel 1092: <a href='/adm/coursedocs?cmd=up_$index&folderpath=$folderpath'>
1.90      www      1093: <img src="${iconpath}move_up.gif" alt='$lt{'up'}' border='0' /></a></td></tr>
1.54      www      1094: <tr><td bgcolor="#DDDDDD">
1.115     albertel 1095: <a href='/adm/coursedocs?cmd=down_$index&folderpath=$folderpath'>
1.90      www      1096: <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' border='0' /></a></td></tr>
1.123     www      1097: </table></td>
                   1098: <td>$selectbox
                   1099: </td><td bgcolor="#DDDDDD">
1.142     raeburn  1100: <a href='javascript:removeres("$folderpath","$index","$renametitle","sequence");'>
1.90      www      1101: <font size="-2" color="#990000">$lt{'rm'}</font></a>
1.142     raeburn  1102: <a href='javascript:changename("$folderpath","$index","$renametitle","sequence");'>
1.90      www      1103: <font size="-2" color="#009900">$lt{'rn'}</font></a></td>
1.8       www      1104: END
1.142     raeburn  1105:         }
1.8       www      1106:     }
1.16      www      1107: # Figure out what kind of a resource this is
                   1108:     my ($extension)=($url=~/\.(\w+)$/);
                   1109:     my $uploaded=($url=~/^\/*uploaded\//);
1.97      albertel 1110:     my $icon=&Apache::loncommon::icon($url);
1.17      www      1111:     my $isfolder=0;
1.142     raeburn  1112:     my $ispage=0;
1.114     albertel 1113:     my $folderarg;
1.142     raeburn  1114:     my $pagearg;
                   1115:     my $pagefile;
1.16      www      1116:     if ($uploaded) {
1.135     albertel 1117: 	if ($extension eq 'sequence') {
                   1118: 	    $icon=$iconpath.'/folder_closed.gif';
                   1119: 	    $url=~/$coursenum\/([\/\w]+)\.sequence$/;
                   1120: 	    $url='/adm/coursedocs?';
                   1121: 	    $folderarg=$1;
                   1122: 	    $isfolder=1;
1.142     raeburn  1123:         } elsif ($extension eq 'page') {
                   1124:             $icon=$iconpath.'/page.gif';
                   1125:             $url=~/$coursenum\/([\/\w]+)\.page$/;
                   1126:             $pagearg=$1;
                   1127:             $url='/adm/coursedocs?';
                   1128:             $ispage=1;
1.135     albertel 1129: 	} else {
                   1130: 	    &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
                   1131: 	}
1.16      www      1132:     }
1.18      www      1133:     $url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//;
1.142     raeburn  1134:     if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
1.113     albertel 1135: 	my $symb=&Apache::lonnet::symbclean(
1.50      www      1136:           &Apache::lonnet::declutter('uploaded/'.
                   1137:            $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.'/'.
                   1138:            $ENV{'course.'.$ENV{'request.course.id'}.'.num'}.'/'.$folder.
                   1139:            '.sequence').
                   1140:            '___'.$residx.'___'.
1.113     albertel 1141: 	   &Apache::lonnet::declutter($url));
                   1142: 	(undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
                   1143: 	$url=&Apache::lonnet::clutter($url);
1.127     albertel 1144: 	if ($url=~/^\/*uploaded\//) {
                   1145: 	    $url=~/\.(\w+)$/;
                   1146: 	    my $embstyle=&Apache::loncommon::fileembstyle($1);
                   1147: 	    if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
                   1148: 		$url='/adm/wrapper'.$url;
                   1149: 	    } elsif ($embstyle eq 'ssi') {
                   1150: 		#do nothing with these
                   1151: 	    } elsif ($url!~/\.(sequence|page)$/) {
                   1152: 		$url='/adm/coursedocs/showdoc'.$url;
                   1153: 	    }
1.145     albertel 1154: 	} elsif ($url=~m|^/ext/|) { 
                   1155: 	    $url='/adm/wrapper'.$url;
1.127     albertel 1156: 	}
1.152     albertel 1157: 	$url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb);
                   1158: 	if ($container eq 'page') {
                   1159: 	    my $symb=$ENV{'form.pagesymb'};
                   1160: 	    	    
                   1161: 	    $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
1.142     raeburn  1162: 	    $url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb);
1.152     albertel 1163: 	}
1.50      www      1164:     }
1.120     www      1165:     my $parameterset='&nbsp;';
1.114     albertel 1166:     if ($isfolder) {
                   1167: 	my $foldername=&Apache::lonnet::escape($foldertitle);
                   1168: 	my $folderpath=$ENV{'form.folderpath'};
                   1169: 	if ($folderpath) { $folderpath.='&' };
                   1170: 	$folderpath.=$folderarg.'&'.$foldername;
                   1171: 	$url.='folderpath='.&Apache::lonnet::escape($folderpath);
1.147     matthew  1172: 	$parameterset='<label>'.&mt('Randomly Pick: ').
1.122     www      1173: 	    '<input type="text" size="4" name="randpick_'.$orderidx.'" value="'.
1.147     matthew  1174: 	    (&Apache::lonratedt::getparameter($orderidx,
                   1175:                                               'parameter_randompick'))[0].
                   1176:                                               '" />'.'</label>';
                   1177:        
1.114     albertel 1178:     }
1.142     raeburn  1179:     if ($ispage) {
                   1180:         my $pagename=&Apache::lonnet::escape($pagetitle);
                   1181:         my $pagepath;
                   1182:         my $folderpath=$ENV{'form.folderpath'};
                   1183:         if ($folderpath) { $pagepath = $folderpath.'&' };
                   1184:         $pagepath.=$pagearg.'&'.$pagename;
1.152     albertel 1185: 	my $symb=$ENV{'form.pagesymb'};
                   1186: 	if (!$symb) {
                   1187: 	    my $path='uploaded/'.
                   1188: 		$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.'/'.
                   1189: 		$ENV{'course.'.$ENV{'request.course.id'}.'.num'}.'/';
                   1190: 	    $symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence',
                   1191: 					       $residx,
                   1192: 					       $path.$pagearg.'.page');
                   1193: 	}
                   1194: 	$url.='pagepath='.&Apache::lonnet::escape($pagepath).
                   1195: 	    '&pagesymb='.&Apache::lonnet::escape($symb);
1.142     raeburn  1196:     }
1.113     albertel 1197:     $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'"><img src="'.$icon.
                   1198: 	'" border="0"></a></td>'.
1.119     www      1199:         "<td bgcolor='#FFFFBB'><a href='$url'>$title</a></td>";
1.120     www      1200:     if (($allowed) && ($folder!~/^supplemental/)) {
                   1201:  	my %lt=&Apache::lonlocal::texthash(
                   1202:  			      'hd' => 'Hidden',
                   1203:  			      'ec' => 'URL hidden',
                   1204:  			      'sp' => 'Store Parameters');
1.122     www      1205: 	my $enctext=
                   1206: 	    ((&Apache::lonratedt::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="1"':'');
                   1207: 	my $hidtext=
                   1208: 	    ((&Apache::lonratedt::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':'');
1.120     www      1209: 	$line.=(<<ENDPARMS);
                   1210: <td bgcolor="#BBBBFF"><font size='-2'>
1.147     matthew  1211: <nobr><label><input type="checkbox" name="hidprs_$orderidx" $hidtext/> $lt{'hd'}</label></nobr></td>
1.149     albertel 1212: <td bgcolor="#BBBBFF"><font size='-2'>
                   1213: <nobr><label><input type="checkbox" name="encprs_$orderidx" $enctext/> $lt{'ec'}</label></nobr></td>
1.120     www      1214: <td bgcolor="#BBBBFF"><font size="-2">$parameterset</font></td>
                   1215: <td bgcolor="#BBBBFF"><font size='-2'>
1.121     www      1216: <input type="submit" value="$lt{'sp'}" />
1.120     www      1217: </font></td>
                   1218: ENDPARMS
1.119     www      1219:     }
1.120     www      1220:     $line.="</form></tr>";
1.8       www      1221:     return $line;
                   1222: }
                   1223: 
1.27      www      1224: # ---------------------------------------------------------------- tie the hash
                   1225: 
                   1226: sub tiehash {
1.136     albertel 1227:     my ($mode)=@_;
1.27      www      1228:     $hashtied=0;
                   1229:     if ($ENV{'request.course.fn'}) {
1.136     albertel 1230: 	if ($mode eq 'write') {
                   1231: 	    if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
                   1232: 		    &GDBM_WRCREAT(),0640)) {
                   1233:                 $hashtied=2;
                   1234: 	    }
                   1235: 	} else {
                   1236: 	    if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
                   1237: 		    &GDBM_READER(),0640)) {
1.27      www      1238:                 $hashtied=1;
1.136     albertel 1239: 	    }
                   1240: 	}
1.27      www      1241:     }    
                   1242: }
                   1243: 
                   1244: sub untiehash {
                   1245:     if ($hashtied) { untie %hash; }
                   1246:     $hashtied=0;
                   1247: }
                   1248: 
1.29      www      1249: # --------------------------------------------------------------- check on this
                   1250: 
                   1251: sub checkonthis {
                   1252:     my ($r,$url,$level,$title)=@_;
1.140     www      1253:     $url=&Apache::lonnet::unescape($url);
1.29      www      1254:     $alreadyseen{$url}=1;
                   1255:     $r->rflush();
1.41      www      1256:     if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
1.108     albertel 1257:        $r->print("\n<br />");
1.29      www      1258:        for (my $i=0;$i<=$level*5;$i++) {
                   1259:            $r->print('&nbsp;');
                   1260:        }
                   1261:        $r->print('<a href="'.$url.'" target="cat">'.
                   1262: 		 ($title?$title:$url).'</a> ');
                   1263:        if ($url=~/^\/res\//) {
                   1264: 	  my $result=&Apache::lonnet::repcopy(
                   1265:                               &Apache::lonnet::filelocation('',$url));
                   1266:           if ($result==OK) {
1.87      www      1267:              $r->print('<font color="green">'.&mt('ok').'</font>');
1.29      www      1268:              $r->rflush();
1.34      www      1269:              &Apache::lonnet::countacc($url);
                   1270:              $url=~/\.(\w+)$/;
                   1271:              if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
                   1272: 		 $r->print('<br />');
                   1273:                  $r->rflush();
                   1274:                  for (my $i=0;$i<=$level*5;$i++) {
                   1275:                      $r->print('&nbsp;');
                   1276:                  }
1.84      www      1277:                  $r->print('- '.&mt('Rendering').': ');
1.69      albertel 1278:                  my $oldpath=$ENV{'request.filename'};
                   1279:                  $ENV{'request.filename'}=&Apache::lonnet::filelocation('',$url);
1.34      www      1280:                  &Apache::lonxml::xmlparse($r,'web',
                   1281:                    &Apache::lonnet::getfile(
1.35      albertel 1282:                     &Apache::lonnet::filelocation('',$url)));
1.94      www      1283: 		 undef($Apache::lonhomework::parsing_a_problem);
1.69      albertel 1284: 		 $ENV{'request.filename'}=$oldpath;
1.34      www      1285:                  if (($Apache::lonxml::errorcount) ||
                   1286:                      ($Apache::lonxml::warningcount)) {
                   1287: 		     if ($Apache::lonxml::errorcount) {
1.98      www      1288:                         $r->print('<img src="/adm/lonMisc/bomb.gif" /><font color="red"><b>'.
1.87      www      1289: 			  $Apache::lonxml::errorcount.' '.
                   1290: 				  &mt('error(s)').'</b></font> ');
1.34      www      1291:                      }
                   1292: 		     if ($Apache::lonxml::warningcount) {
                   1293:                         $r->print('<font color="blue">'.
1.84      www      1294: 			  $Apache::lonxml::warningcount.' '.
                   1295: 				  &mt('warning(s)').'</font>');
1.34      www      1296:                      }
                   1297:                  } else {
1.87      www      1298:                      $r->print('<font color="green">'.&mt('ok').'</font>');
1.34      www      1299:                  }
                   1300:                  $r->rflush();
                   1301:              }
1.29      www      1302: 	     my $dependencies=
                   1303:                 &Apache::lonnet::metadata($url,'dependencies');
                   1304:              foreach (split(/\,/,$dependencies)) {
                   1305: 		 if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {
                   1306:                     &checkonthis($r,$_,$level+1);
                   1307:                  }
                   1308:              }
                   1309:           } elsif ($result==HTTP_SERVICE_UNAVAILABLE) {
1.84      www      1310:              $r->print('<font color="red"><b>'.&mt('connection down').'</b></font>');
1.29      www      1311:           } elsif ($result==HTTP_NOT_FOUND) {
1.100     www      1312: 	      unless ($url=~/\$/) {
                   1313: 		  $r->print('<font color="red"><b>'.&mt('not found').'</b></font>');
                   1314: 	      } else {
                   1315: 		  $r->print('<font color="yellow"><b>'.&mt('unable to verify variable URL').'</b></font>');
                   1316: 	      }
1.29      www      1317:           } else {
1.84      www      1318:              $r->print('<font color="red"><b>'.&mt('access denied').'</b></font>');
1.29      www      1319:           }
                   1320:       }
                   1321:    }
                   1322: }
                   1323: 
1.1       www      1324: 
1.75      www      1325: #
                   1326: # -------------------------------------------------------------- Verify Content
                   1327: # 
                   1328: sub verifycontent {
                   1329:    my $r=shift; 
1.26      www      1330:    my $loaderror=&Apache::lonnet::overloaderror($r);
                   1331:    if ($loaderror) { return $loaderror; }
                   1332: 
                   1333:    $r->print('<html><head><title>Verify Content</title></head>'.
                   1334:               &Apache::loncommon::bodytag('Verify Course Documents'));
1.27      www      1335:    $hashtied=0;
1.30      www      1336:    undef %alreadyseen;
                   1337:    %alreadyseen=();
1.27      www      1338:    &tiehash();
                   1339:    foreach (keys %hash) {
1.140     www      1340:        if ($hash{$_}=~/\.(page|sequence)$/) {
                   1341: 	   if (($_=~/^src_/) && ($alreadyseen{&Apache::lonnet::unescape($hash{$_})})) {
                   1342: 	       $r->print('<hr /><font color="red">'.
                   1343: 			 &mt('The following sequence or page is included more than once in your course: ').
                   1344: 			 &Apache::lonnet::unescape($hash{$_}).'</font><br />'.
                   1345: 			 &mt('Note that grading records for problems included in this sequence or folder will overlap.<hr />'));
                   1346: 	   }
                   1347:        }
                   1348:        if (($_=~/^src\_(.+)$/) && (!$alreadyseen{&Apache::lonnet::unescape($hash{$_})})) {
1.29      www      1349:            &checkonthis($r,$hash{$_},0,$hash{'title_'.$1});
1.27      www      1350:        }
                   1351:    }
                   1352:    &untiehash();
1.108     albertel 1353:    $r->print('<h1>'.&mt('Done').'.</h1>'.'<a href="/adm/coursedocs">'.
                   1354: 	     &mt('Return to DOCS').'</a>');
1.75      www      1355: }
                   1356: 
                   1357: # -------------------------------------------------------------- Check Versions
                   1358: 
                   1359: sub checkversions {
                   1360:     my $r=shift;
1.89      www      1361:     $r->print('<html><head><title>Check Versions</title></head>'.
1.26      www      1362:               &Apache::loncommon::bodytag('Check Course Document Versions'));
1.89      www      1363:     my $header='';
                   1364:     my $startsel='';
                   1365:     my $monthsel='';
                   1366:     my $weeksel='';
                   1367:     my $daysel='';
                   1368:     my $allsel='';
                   1369:     my %changes=();
                   1370:     my $starttime=0;
1.91      www      1371:     my $haschanged=0;
1.92      www      1372:     my %setversions=&Apache::lonnet::dump('resourceversions',
                   1373: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
                   1374: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
                   1375: 
                   1376:     $hashtied=0;
                   1377:     &tiehash();
                   1378:     my %newsetversions=();
1.91      www      1379:     if ($ENV{'form.setmostrecent'}) {
                   1380: 	$haschanged=1;
1.92      www      1381: 	foreach (keys %hash) {
                   1382: 	    if ($_=~/^ids\_(\/res\/.+)$/) {
1.93      www      1383: 		$newsetversions{$1}='mostrecent';
1.92      www      1384: 	    }
                   1385: 	}
1.91      www      1386:     } elsif ($ENV{'form.setcurrent'}) {
                   1387: 	$haschanged=1;
1.92      www      1388: 	foreach (keys %hash) {
                   1389: 	    if ($_=~/^ids\_(\/res\/.+)$/) {
1.93      www      1390: 		my $getvers=&Apache::lonnet::getversion($1);
                   1391: 		if ($getvers>0) {
                   1392: 		    $newsetversions{$1}=$getvers;
                   1393: 		}
1.92      www      1394: 	    }
                   1395: 	}
1.91      www      1396:     } elsif ($ENV{'form.setversions'}) {
                   1397: 	$haschanged=1;
1.92      www      1398: 	foreach (keys %ENV) {
                   1399: 	    if ($_=~/^form\.set_version_(.+)$/) {
                   1400: 		my $src=$1;
                   1401: 		if (($ENV{$_}) && ($ENV{$_} ne $setversions{$src})) {
                   1402: 		    $newsetversions{$src}=$ENV{$_};
                   1403: 		}
                   1404: 	    }
                   1405: 	}
1.91      www      1406:     }
                   1407:     if ($haschanged) {
1.92      www      1408:         if (&Apache::lonnet::put('resourceversions',\%newsetversions,
                   1409: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
                   1410: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.num'}) eq 'ok') {		
                   1411: 	    $r->print('<h1>'.&mt('Your Version Settings have been Stored').'</h1>');
                   1412: 	} else {
                   1413: 	    $r->print('<h1><font color="red">'.&mt('An Error Occured while Attempting to Store your Version Settings').'</font></h1>');
                   1414: 	}
1.136     albertel 1415: 	&mark_hash_old();
1.91      www      1416:     }
1.136     albertel 1417:     &changewarning($r,'');
1.89      www      1418:     if ($ENV{'form.timerange'} eq 'all') {
                   1419: # show all documents
                   1420: 	$header=&mt('All Documents in Course');
1.91      www      1421: 	$allsel=1;
1.90      www      1422: 	foreach (keys %hash) {
                   1423: 	    if ($_=~/^ids\_(\/res\/.+)$/) {
                   1424: 		my $src=$1;
                   1425: 		$changes{$src}=1;
                   1426: 	    }
                   1427: 	}
1.89      www      1428:     } else {
                   1429: # show documents which changed
                   1430: 	%changes=&Apache::lonnet::dump
                   1431: 	 ('versionupdate',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1.30      www      1432:                      $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.89      www      1433: 	my $firstkey=(keys %changes)[0];
                   1434: 	unless ($firstkey=~/^error\:/) {
                   1435: 	    unless ($ENV{'form.timerange'}) {
                   1436: 		$ENV{'form.timerange'}=604800;
                   1437: 	    }
                   1438: 	    my $seltext=&mt('during the last').' '.$ENV{'form.timerange'}.' '
                   1439: 		.&mt('seconds');
                   1440: 	    if ($ENV{'form.timerange'}==-1) {
                   1441: 		$seltext='since start of course';
                   1442: 		$startsel='selected';
                   1443: 		$ENV{'form.timerange'}=time;
                   1444: 	    }
                   1445: 	    $starttime=time-$ENV{'form.timerange'};
                   1446: 	    if ($ENV{'form.timerange'}==2592000) {
                   1447: 		$seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
                   1448: 		$monthsel='selected';
                   1449: 	    } elsif ($ENV{'form.timerange'}==604800) {
                   1450: 		$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
                   1451: 		$weeksel='selected';
                   1452: 	    } elsif ($ENV{'form.timerange'}==86400) {
                   1453: 		$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
                   1454: 		$daysel='selected';
                   1455: 	    }
                   1456: 	    $header=&mt('Content changed').' '.$seltext;
                   1457: 	} else {
                   1458: 	    $header=&mt('No content modifications yet.');
                   1459: 	}
                   1460:     }
1.92      www      1461:     %setversions=&Apache::lonnet::dump('resourceversions',
                   1462: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
                   1463: 			  $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.89      www      1464:     my %lt=&Apache::lonlocal::texthash
1.88      www      1465: 	      ('st' => 'Version changes since start of Course',
                   1466: 	       'lm' => 'Version changes since last Month',
                   1467: 	       'lw' => 'Version changes since last Week',
                   1468: 	       'sy' => 'Version changes since Yesterday',
1.91      www      1469:                'al' => 'All Resources (possibly large output)',
1.88      www      1470: 	       'sd' => 'Display',
1.84      www      1471: 	       'fi' => 'File',
                   1472: 	       'md' => 'Modification Date',
1.87      www      1473:                'mr' => 'Most recently published Version',
                   1474: 	       've' => 'Version used in Course',
1.91      www      1475:                'vu' => 'Set Version to be used in Course',
                   1476: 'sv' => 'Set Versions to be used in Course according to Selections below',
                   1477: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
                   1478: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.84      www      1479: 	       'di' => 'Differences');
1.89      www      1480:     $r->print(<<ENDHEADERS);
1.31      www      1481: <form action="/adm/coursedocs" method="post">
1.91      www      1482: <input type="hidden" name="versions" value="1" />
                   1483: <input type="submit" name="setmostrecent" value="$lt{'sm'}" />
                   1484: <input type="submit" name="setcurrent" value="$lt{'sc'}" /><hr />
1.31      www      1485: <select name="timerange">
1.88      www      1486: <option value='all' $allsel>$lt{'al'}</option>
1.84      www      1487: <option value="-1" $startsel>$lt{'st'}</option>
                   1488: <option value="2592000" $monthsel>$lt{'lm'}</option>
                   1489: <option value="604800" $weeksel>$lt{'lw'}</option>
                   1490: <option value="86400" $daysel>$lt{'sy'}</option>
1.31      www      1491: </select>
1.91      www      1492: <input type="submit" name="display" value="$lt{'sd'}" />
1.89      www      1493: <h3>$header</h3>
1.91      www      1494: <input type="submit" name="setversions" value="$lt{'sv'}" />
1.103     matthew  1495: <table border="0">
1.31      www      1496: ENDHEADERS
1.91      www      1497:     foreach (sort keys %changes) {
1.89      www      1498: 	if ($changes{$_}>$starttime) {
                   1499: 	    my ($root,$extension)=($_=~/^(.*)\.(\w+)$/);
                   1500: 	    my $currentversion=&Apache::lonnet::getversion($_);
1.93      www      1501: 	    if ($currentversion<0) {
                   1502: 		$currentversion=&mt('Could not be determined.');
                   1503: 	    }
1.89      www      1504: 	    my $linkurl=&Apache::lonnet::clutter($_);
                   1505: 	    $r->print(
1.103     matthew  1506: 		      '<tr><td colspan="5"><br /><br /><font size="+1"><b>'.
1.91      www      1507: 		      &Apache::lonnet::gettitle($linkurl).
1.103     matthew  1508:                       '</b></font></td></tr>'.
                   1509:                       '<tr><td>&nbsp;&nbsp;&nbsp;</td>'.
                   1510:                       '<td colspan="4">'.
                   1511:                       '<a href="'.$linkurl.'" target="cat">'.$linkurl.
                   1512: 		      '</a></td></tr>'.
                   1513:                       '<tr><td></td>'.
                   1514:                       '<td title="'.$lt{'md'}.'">'.
1.102     matthew  1515: 		      &Apache::lonlocal::locallocaltime(
                   1516:                            &Apache::lonnet::metadata($root.'.'.$extension,
                   1517:                                                      'lastrevisiondate')
                   1518:                                                         ).
1.103     matthew  1519:                       '</td>'.
                   1520:                       '<td title="'.$lt{'mr'}.'"><nobr>Most Recent: '.
                   1521:                       '<font size="+1">'.$currentversion.'</font>'.
                   1522:                       '</nobr></td>'.
                   1523:                       '<td title="'.$lt{'ve'}.'"><nobr>In Course: '.
                   1524:                       '<font size="+1">');
1.87      www      1525: # Used in course
1.89      www      1526: 	    my $usedversion=$hash{'version_'.$linkurl};
1.93      www      1527: 	    if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.89      www      1528: 		$r->print($usedversion);
                   1529: 	    } else {
                   1530: 		$r->print($currentversion);
                   1531: 	    }
1.103     matthew  1532: 	    $r->print('</font></nobr></td><td title="'.$lt{'vu'}.'">'.
                   1533:                       '<nobr>Use: ');
1.87      www      1534: # Set version
1.92      www      1535: 	    $r->print(&Apache::loncommon::select_form($setversions{$linkurl},
1.89      www      1536: 						      'set_version_'.$linkurl,
1.136     albertel 1537: 						      ('select_form_order' =>
                   1538: 						       ['',1..$currentversion,'mostrecent'],
                   1539: 						       '' => '',
1.93      www      1540: 						       'mostrecent' => 'most recent',
1.89      www      1541: 						       map {$_,$_} (1..$currentversion))));
1.103     matthew  1542: 	    $r->print('</nobr></td></tr><tr><td></td>');
1.89      www      1543: 	    my $lastold=1;
                   1544: 	    for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
                   1545: 		my $url=$root.'.'.$prevvers.'.'.$extension;
                   1546: 		if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
                   1547: 		    $starttime) {
                   1548: 		    $lastold=$prevvers;
                   1549: 		}
                   1550: 	    }
1.103     matthew  1551:             # 
                   1552:             # Code to figure out how many version entries should go in
                   1553:             # each of the four columns
                   1554:             my $entries_per_col = 0;
                   1555:             my $num_entries = ($currentversion-$lastold);
                   1556:             if ($num_entries % 4 == 0) {
                   1557:                 $entries_per_col = $num_entries/4;
                   1558:             } else {
                   1559:                 $entries_per_col = $num_entries/4 + 1;
                   1560:             }
                   1561:             my $entries_count = 0;
                   1562:             $r->print('<td valign="top"><font size="-2">'); 
                   1563:             my $cols_output = 1;
1.32      www      1564:             for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
1.89      www      1565: 		my $url=$root.'.'.$prevvers.'.'.$extension;
1.103     matthew  1566: 		$r->print('<nobr><a href="'.&Apache::lonnet::clutter($url).
1.91      www      1567: 			  '">'.&mt('Version').' '.$prevvers.'</a> ('.
1.103     matthew  1568: 			  &Apache::lonlocal::locallocaltime(
                   1569:                                 &Apache::lonnet::metadata($url,
                   1570:                                                           'lastrevisiondate')
                   1571:                                                             ).
1.91      www      1572: 			  ')');
1.89      www      1573: 		if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
1.33      www      1574:                     $r->print(' <a href="/adm/diff?filename='.
1.89      www      1575: 			      &Apache::lonnet::clutter($root.'.'.$extension).
                   1576: 			      '&versionone='.$prevvers.
                   1577: 			      '">'.&mt('Diffs').'</a>');
                   1578: 		}
1.103     matthew  1579: 		$r->print('</nobr><br />');
                   1580:                 if (++$entries_count % $entries_per_col == 0) {
                   1581:                     $r->print('</font></td>');
                   1582:                     if ($cols_output != 4) {
                   1583:                         $r->print('<td valign="top"><font size="-2">');
                   1584:                         $cols_output++;
                   1585:                     }
                   1586:                 }
1.89      www      1587: 	    }
1.103     matthew  1588:             while($cols_output++ < 4) {
                   1589:                 $r->print('</font></td><td><font>')
                   1590:             }
                   1591: 	    $r->print('</font></td></tr>'."\n");
1.89      www      1592: 	}
                   1593:     }
1.92      www      1594:     $r->print('</table></form>');
1.89      www      1595:     $r->print('<h1>'.&mt('Done').'.</h1>');
                   1596: 
                   1597:     &untiehash();
1.75      www      1598: }
                   1599: 
1.136     albertel 1600: sub mark_hash_old {
                   1601:     my $retie_hash=0;
                   1602:     if ($hashtied) {
                   1603: 	$retie_hash=1;
                   1604: 	&untiehash();
                   1605:     }
                   1606:     &tiehash('write');
                   1607:     $hash{'old'}=1;
                   1608:     &untiehash();
                   1609:     if ($retie_hash) { &tiehash(); }
                   1610: }
                   1611: 
                   1612: sub is_hash_old {
                   1613:     my $untie_hash=0;
                   1614:     if (!$hashtied) {
                   1615: 	$untie_hash=1;
                   1616: 	&tiehash();
                   1617:     }
                   1618:     my $return=$hash{'old'};
                   1619:     if ($untie_hash) { &untiehash(); }
                   1620:     return $return;
                   1621: }
                   1622: 
1.91      www      1623: sub changewarning {
                   1624:     my ($r,$postexec)=@_;
1.136     albertel 1625:     if (!&is_hash_old()) { return; }
1.150     albertel 1626:     my $pathvar='folderpath';
                   1627:     my $path=&Apache::lonnet::escape($ENV{'form.folderpath'});
                   1628:     if (defined($ENV{'form.pagepath'})) {
                   1629: 	$pathvar='pagepath';
                   1630: 	$path=&Apache::lonnet::escape($ENV{'form.pagepath'});
1.156   ! albertel 1631: 	$path.='&amp;symb='.&Apache::lonnet::escape($ENV{'form.pagesymb'});
1.150     albertel 1632:     }
1.91      www      1633:     $r->print(
                   1634: '<script>function reinit(tf) { tf.submit();'.$postexec.' }</script>'. 
                   1635: '<form method="post" action="/adm/roles" target="loncapaclient">'.
1.150     albertel 1636: '<input type="hidden" name="orgurl" value="/adm/coursedocs?'.
                   1637: $pathvar.'='.$path.
1.117     albertel 1638: '" /><input type="hidden" name="selectrole" value="1" /><h3><font color="red">'.
1.91      www      1639: &mt('Changes will become active for your current session after').
                   1640: ' <input type="hidden" name="'.
                   1641: $ENV{'request.role'}.'" value="1" /><input type="button" value="'.
                   1642: &mt('re-initializing course').'" onClick="reinit(this.form)"/>'.&mt(', or the next time you log in.').
                   1643: $help{'Caching'}.'</font></h3></form>');
                   1644: }
                   1645: 
1.75      www      1646: # ================================================================ Main Handler
                   1647: sub handler {
                   1648:     my $r = shift;
1.82      www      1649:     &Apache::loncommon::content_type($r,'text/html');
1.75      www      1650:     $r->send_http_header;
                   1651:     return OK if $r->header_only;
                   1652: 
                   1653: # --------------------------------------------- Initialize help topics for this
                   1654:   foreach ('Adding_Course_Doc','Main_Course_Documents',
                   1655:            'Adding_External_Resource','Navigate_Content',
                   1656:            'Adding_Folders','Docs_Overview', 'Load_Map',
1.142     raeburn  1657:            'Supplemental','Score_Upload_Form','Adding_Pages',
1.130     www      1658:            'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
                   1659: 	   'Check_Resource_Versions','Verify_Content') {
1.75      www      1660:       $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);
                   1661:   }
                   1662:     # Composite help files
                   1663:     $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
                   1664: 		    'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
                   1665:     $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
                   1666: 		    'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
1.86      albertel 1667:     $help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
                   1668: 		    'Option_Response_Simple');
1.75      www      1669:     $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
                   1670: 		    'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
                   1671:     $help{'My Personal Info'} = &Apache::loncommon::help_open_topic(
                   1672: 		  'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
                   1673:     $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1.142     raeburn  1674: 
1.75      www      1675:   if ($ENV{'form.verify'}) {
                   1676:       &verifycontent($r);
                   1677:   } elsif ($ENV{'form.versions'}) {
                   1678:       &checkversions($r);
                   1679:   } elsif ($ENV{'form.dumpcourse'}) {
                   1680:       &dumpcourse($r);
1.138     raeburn  1681:   } elsif ($ENV{'form.exportcourse'}) {
                   1682:       &exportcourse($r);
1.26      www      1683:   } else {
1.7       www      1684: # is this a standard course?
                   1685: 
                   1686:     my $standard=($ENV{'request.course.uri'}=~/^\/uploaded\//);
1.155     raeburn  1687:     my $forcestandard = 0;
1.15      www      1688:     my $forcesupplement;
                   1689:     my $script='';
                   1690:     my $allowed;
                   1691:     my $events='';
1.19      www      1692:     my $showdoc=0;
1.142     raeburn  1693:     my $containertag;
                   1694:     my $uploadtag;
1.15      www      1695:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.152     albertel 1696: 					    ['folderpath','pagepath','pagesymb']);
1.114     albertel 1697:     if ($ENV{'form.folderpath'}) {
                   1698: 	my (@folderpath)=split('&',$ENV{'form.folderpath'});
                   1699: 	$ENV{'form.foldername'}=&Apache::lonnet::unescape(pop(@folderpath));
                   1700: 	$ENV{'form.folder'}=pop(@folderpath);
1.142     raeburn  1701:     }
                   1702:     if ($ENV{'form.pagepath'}) {
                   1703:         my (@pagepath)=split('&',$ENV{'form.pagepath'});
                   1704:         $ENV{'form.pagename'}=&Apache::lonnet::unescape(pop(@pagepath));
                   1705:         $ENV{'form.folder'}=pop(@pagepath);
1.156   ! albertel 1706:         $containertag = '<input type="hidden" name="pagepath" value="" />'.
        !          1707: 	    '<input type="hidden" name="pagesymb" value="" />';
        !          1708:         $uploadtag = '<input type="hidden" name="pagepath" value="'.$ENV{'form.pagepath'}.'" />'.
        !          1709: 	    '<input type="hidden" name="pagesymb" value="'.$ENV{'form.pagesymb'}.'" />';
1.142     raeburn  1710:     }
1.21      www      1711:     if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
1.127     albertel 1712:        $showdoc='/'.$1;
1.21      www      1713:     }
                   1714:     unless ($showdoc) { # got called from remote
1.156   ! albertel 1715:        if (($ENV{'form.folder'}=~/^default_/) || 
1.155     raeburn  1716:           ($ENV{'form.folder'} =~ m#^\d+/(pages|sequences)/#)) {
                   1717:            $forcestandard = 1;
                   1718:        } 
1.15      www      1719:        $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
1.7       www      1720: 
1.4       www      1721: # does this user have privileges to post, etc?
1.77      www      1722:        $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
1.15      www      1723:        if ($allowed) { 
                   1724:          &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
                   1725:          $script=&Apache::lonratedt::editscript('simple'); 
                   1726:        }
                   1727:     } else { # got called in sequence from course
                   1728:        $allowed=0;
1.49      www      1729:        $script='</script>'.&Apache::lonmenu::registerurl(1,undef).'<script>';
                   1730:        $events='onLoad="'.&Apache::lonmenu::loadevents.
                   1731:            '" onUnload="'.&Apache::lonmenu::unloadevents.'"';
1.3       www      1732:     }
1.4       www      1733: 
                   1734: # get course data
                   1735:     my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
                   1736:     my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
                   1737: 
1.14      www      1738: # get personal data
                   1739:  
                   1740:     my $uname=$ENV{'user.name'};
                   1741:     my $udom=$ENV{'user.domain'};
                   1742:     my $plainname=&Apache::lonnet::escape(
                   1743:                      &Apache::loncommon::plainname($uname,$udom));
                   1744: 
1.8       www      1745: # graphics settings
1.4       www      1746: 
1.8       www      1747:     $iconpath = $r->dir_config('lonIconsURL') . "/";
                   1748: 
1.22      www      1749:     my $now=time;
1.64      www      1750: 
1.4       www      1751: # print screen
1.1       www      1752:     $r->print(<<ENDDOCUMENT);
                   1753: <html>
                   1754: <head>
                   1755: <title>The LearningOnline Network with CAPA</title>
1.16      www      1756: <script>
                   1757: $script
1.20      www      1758: </script>
1.19      www      1759: ENDDOCUMENT
                   1760:    if ($allowed) {
                   1761:     $r->print(<<ENDNEWSCRIPT);
1.20      www      1762: <script>
1.16      www      1763: function makenewfolder(targetform,folderseq) {
                   1764:     var foldername=prompt('Name of New Folder','New Folder');
                   1765:     if (foldername) {
                   1766: 	targetform.importdetail.value=foldername+"="+folderseq;
                   1767:         targetform.submit();
                   1768:     }
                   1769: }
                   1770: 
1.142     raeburn  1771: function makenewpage(targetform,folderseq) {
                   1772:     var pagename=prompt('Name of New Page','New Page');
                   1773:     if (pagename) {
                   1774:         targetform.importdetail.value=pagename+"="+folderseq;
                   1775:         targetform.submit();
                   1776:     }
                   1777: }
                   1778: 
1.18      www      1779: function makenewext(targetname) {
                   1780:     this.document.forms.extimport.useform.value=targetname;
                   1781:     window.open('/adm/rat/extpickframe.html');
                   1782: }
                   1783: 
1.62      www      1784: function makeexamupload() {
                   1785:    var title=prompt('Listed Title for the Uploaded Score');
                   1786:    if (title) { 
                   1787:     this.document.forms.newexamupload.importdetail.value=
                   1788: 	title+'=/res/lib/templates/examupload.problem';
                   1789:     this.document.forms.newexamupload.submit();
                   1790:    }
                   1791: }
                   1792: 
1.22      www      1793: function makesmppage() {
1.38      www      1794:    var title=prompt('Listed Title for the Page');
                   1795:    if (title) { 
1.22      www      1796:     this.document.forms.newsmppg.importdetail.value=
                   1797: 	title+'=/adm/$udom/$uname/$now/smppg';
                   1798:     this.document.forms.newsmppg.submit();
1.38      www      1799:    }
1.22      www      1800: }
                   1801: 
1.55      www      1802: function makesmpproblem() {
                   1803:    var title=prompt('Listed Title for the Problem');
                   1804:    if (title) { 
                   1805:     this.document.forms.newsmpproblem.importdetail.value=
1.63      www      1806: 	title+'=/res/lib/templates/simpleproblem.problem';
1.55      www      1807:     this.document.forms.newsmpproblem.submit();
                   1808:    }
                   1809: }
                   1810: 
1.22      www      1811: function makebulboard() {
1.38      www      1812:    var title=prompt('Listed Title for the Bulletin Board');
                   1813:    if (title) {
1.22      www      1814:     this.document.forms.newbul.importdetail.value=
                   1815: 	title+'=/adm/$udom/$uname/$now/bulletinboard';
                   1816:     this.document.forms.newbul.submit();
1.38      www      1817:    }
1.22      www      1818: }
                   1819: 
1.101     www      1820: function makeabout() {
                   1821:    var user=prompt("Enter user\@domain for User's 'About Me' Page");
                   1822:    if (user) {
                   1823:        var comp=new Array();
                   1824:        comp=user.split('\@');
                   1825:        if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
                   1826: 	   if ((comp[0]) && (comp[1])) {
                   1827: 	       this.document.forms.newaboutsomeone.importdetail.value=
                   1828: 		   'About '+user+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
                   1829: 	       this.document.forms.newaboutsomeone.submit();
                   1830: 	   }
                   1831:        }
                   1832:    }
                   1833: }
                   1834: 
1.110     raeburn  1835: function makeims() {
                   1836:     var caller = document.forms.ims.folder.value
                   1837:     var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one"
                   1838:     newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes")
                   1839:     newWindow.location.href = newlocation
                   1840: }
                   1841: 
                   1842: 
1.18      www      1843: function finishpick() {
                   1844:     var title=this.document.forms.extimport.title.value;
                   1845:     var url=this.document.forms.extimport.url.value;
                   1846:     var form=this.document.forms.extimport.useform.value;
                   1847:     eval
                   1848:      ('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+
                   1849:     '";this.document.forms.'+form+'.submit();');
1.16      www      1850: }
1.36      www      1851: 
1.156   ! albertel 1852: function changename(folderpath,index,oldtitle,container,pagesymb) {
1.36      www      1853:     var title=prompt('New Title',oldtitle);
                   1854:     if (title) {
                   1855: 	this.document.forms.renameform.title.value=title;
                   1856: 	this.document.forms.renameform.cmd.value='rename_'+index;
1.142     raeburn  1857:         if (container == 'sequence') {
                   1858: 	    this.document.forms.renameform.folderpath.value=folderpath;
                   1859:         }
                   1860:         if (container == 'page') {
                   1861:             this.document.forms.renameform.pagepath.value=folderpath;
1.156   ! albertel 1862:             this.document.forms.renameform.pagesymb.value=pagesymb;
1.142     raeburn  1863:         }
1.54      www      1864:         this.document.forms.renameform.submit();
                   1865:     }
                   1866: }
                   1867: 
1.156   ! albertel 1868: function removeres(folderpath,index,oldtitle,container,pagesymb) {
1.106     www      1869:     if (confirm('Remove "'+oldtitle+'"?')) {
1.54      www      1870: 	this.document.forms.renameform.cmd.value='del_'+index;
1.142     raeburn  1871:         if (container == 'sequence') {
                   1872:             this.document.forms.renameform.folderpath.value=folderpath;
                   1873:         }
                   1874:         if (container == 'page') {
                   1875:             this.document.forms.renameform.pagepath.value=folderpath;
1.156   ! albertel 1876:             this.document.forms.renameform.pagesymb.value=pagesymb;
1.142     raeburn  1877:         }
1.36      www      1878:         this.document.forms.renameform.submit();
                   1879:     }
                   1880: }
1.121     www      1881: 
1.16      www      1882: </script>
1.42      www      1883: 
                   1884: ENDNEWSCRIPT
                   1885:   }
                   1886: # -------------------------------------------------------------------- Body tag
                   1887:   $r->print('</head>'.
1.72      www      1888:             &Apache::loncommon::bodytag('Course Documents','',$events,
1.99      www      1889: 					'','',$showdoc).
1.134     albertel 1890: 	    &Apache::loncommon::help_open_menu('','','','',273,'RAT'));
1.42      www      1891:   unless ($showdoc) {
1.81      www      1892: # -----------------------------------------------------------------------------
                   1893:        my %lt=&Apache::lonlocal::texthash(
                   1894:                 'uplm' => 'Upload a new main course document',
                   1895:                 'upls' => 'Upload a new supplemental course document',
                   1896:                 'impp' => 'Import a published document',
                   1897:                 'spec' => 'Special documents',
                   1898:                 'upld' => 'Upload Document',
                   1899:                 'srch' => 'Search',
                   1900:                 'impo' => 'Import',
                   1901:                 'selm' => 'Select Map',
                   1902:                 'load' => 'Load Map',
                   1903:                 'newf' => 'New Folder',
1.142     raeburn  1904:                 'newp' => 'New Composite Page',
1.81      www      1905:                 'extr' => 'External Resource',
                   1906:                 'syll' => 'Syllabus',
                   1907:                 'navc' => 'Navigate Contents',
                   1908:                 'sipa' => 'Simple Page',
                   1909:                 'sipr' => 'Simple Problem',
                   1910:                 'scuf' => 'Score Upload Form',
                   1911:                 'bull' => 'Bulletin Board',
1.96      sakharuk 1912:                 'mypi' => 'My Personal Info',
1.101     www      1913: 		'abou' => 'About User',
1.110     raeburn  1914:                 'imsf' => 'Import IMS package',
1.96      sakharuk 1915:                 'file' =>  'File',
                   1916:                 'title' => 'Title',
                   1917:                 'comment' => 'Comment' 
1.81      www      1918: 					  );
                   1919: # -----------------------------------------------------------------------------
1.42      www      1920:     if ($allowed) {
1.74      www      1921:        my $dumpbut=&dumpbutton();
1.138     raeburn  1922:        my $exportbut=&exportbutton();
1.88      www      1923:        my %lt=&Apache::lonlocal::texthash(
                   1924: 					 'vc' => 'Verify Content',
                   1925: 					 'cv' => 'Check/Set Resource Versions',
                   1926: 					  );
1.118     albertel 1927: 
                   1928:        my $folderpath=$ENV{'form.folderpath'};
                   1929:        if (!$folderpath) {
                   1930: 	   if ($ENV{'form.folder'} eq '' ||
                   1931: 	       $ENV{'form.folder'} eq 'supplemental') {
                   1932: 	       $folderpath='default&'.
                   1933: 		   &Apache::lonnet::escape(&mt('Main Course Documents'));
                   1934: 	   }
                   1935:        }
1.142     raeburn  1936:        unless ($ENV{'form.pagepath'}) {
                   1937:            $containertag = '<input type="hidden" name="folderpath" value="" />';
                   1938:            $uploadtag = '<input type="hidden" name="folderpath" value="'.$folderpath.'" />';
                   1939:        }
                   1940: 
1.42      www      1941:        $r->print(<<ENDCOURSEVERIFY);
1.36      www      1942: <form name="renameform" method="post" action="/adm/coursedocs">
                   1943: <input type="hidden" name="title" />
                   1944: <input type="hidden" name="cmd" />
1.142     raeburn  1945: $containertag
1.36      www      1946: </form>
1.39      www      1947: <form name="simpleedit" method="post" action="/adm/coursedocs">
                   1948: <input type=hidden name="importdetail" value="">
1.142     raeburn  1949: $uploadtag
1.39      www      1950: </form>
1.26      www      1951: <form action="/adm/coursedocs" method="post" name="courseverify">
1.74      www      1952: <table bgcolor="#AAAAAA" width="100%" cellspacing="4" cellpadding="4">
                   1953: <tr><td bgcolor="#DDDDCC">
1.130     www      1954: <input type="submit" name="verify" value="$lt{'vc'}" />$help{'Verify_Content'}
1.74      www      1955: </td><td bgcolor="#DDDDCC">
1.130     www      1956:     <input type="submit" name="versions" value="$lt{'cv'}" />$help{'Check_Resource_Versions'}
1.74      www      1957: $dumpbut
1.138     raeburn  1958: $exportbut
1.74      www      1959: </td></tr></table>
1.25      www      1960: </form>
                   1961: ENDCOURSEVERIFY
1.74      www      1962:        $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
1.96      sakharuk 1963: 		     &mt('Editing the Table of Contents for your Course')));
1.25      www      1964:     }
1.17      www      1965: # --------------------------------------------------------- Standard documents
1.43      www      1966:     $r->print('<table border=2 cellspacing=4 cellpadding=4>');
1.7       www      1967:     if (($standard) && ($allowed) && (!$forcesupplement)) {
1.116     albertel 1968: 	$r->print('<tr><td bgcolor="#BBBBBB">');
                   1969: #  '<h2>'.&mt('Main Course Documents').
                   1970: #  ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>');
1.7       www      1971:        my $folder=$ENV{'form.folder'};
1.117     albertel 1972:        if ($folder eq '' || $folder eq 'supplemental') {
1.112     raeburn  1973:            $folder='default';
1.116     albertel 1974: 	   $ENV{'form.folderpath'}='default&'.&Apache::lonnet::escape(&mt('Main Course Documents'));
1.112     raeburn  1975:        }
1.51      www      1976:        my $postexec='';
                   1977:        if ($folder eq 'default') {
                   1978: 	   $r->print('<script>this.window.name="loncapaclient";</script>');
                   1979:        } else {
1.117     albertel 1980:            #$postexec='self.close();';
1.51      www      1981:        }
1.40      www      1982:        $hadchanges=0;
1.7       www      1983:        &editor($r,$coursenum,$coursedom,$folder,$allowed);
1.40      www      1984:        if ($hadchanges) {
1.136     albertel 1985: 	   &mark_hash_old()
1.40      www      1986:        }
1.136     albertel 1987:        &changewarning($r,$postexec);
1.16      www      1988:        my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
                   1989:                      '.sequence';
1.142     raeburn  1990:        my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
                   1991:                      '.page';
                   1992: 
1.8       www      1993:        $r->print(<<ENDFORM);
1.43      www      1994: <table cellspacing=4 cellpadding=4><tr>
1.81      www      1995: <th bgcolor="#DDDDDD">$lt{'uplm'}</th>
                   1996: <th bgcolor="#DDDDDD">$lt{'impp'}</th>
                   1997: <th bgcolor="#DDDDDD">$lt{'spec'}</th>
1.11      www      1998: </tr>
1.16      www      1999: <tr><td bgcolor="#DDDDDD">
1.96      sakharuk 2000: $lt{'file'}:<br />
1.10      www      2001: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.59      www      2002: <input type="file" name="uploaddoc" size="40">
1.8       www      2003: <br />
1.96      sakharuk 2004: $lt{'title'}:<br />
1.11      www      2005: <input type="text" size="50" name="comment">
1.142     raeburn  2006: $uploadtag
1.10      www      2007: <input type="hidden" name="cmd" value="upload_default">
1.129     albertel 2008: <nobr>
1.81      www      2009: <input type="submit" value="$lt{'upld'}">
1.60      albertel 2010:  $help{'Uploading_From_Harddrive'}
1.58      albertel 2011: </nobr>
1.60      albertel 2012: </form>
1.11      www      2013: </td>
1.16      www      2014: <td bgcolor="#DDDDDD">
1.39      www      2015: <form action="/adm/coursedocs" method="post" name="simpleeditdefault">
1.142     raeburn  2016: $uploadtag
1.115     albertel 2017: <input type=button onClick="javascript:groupsearch()" value="$lt{'srch'}">
1.58      albertel 2018: <nobr>
1.115     albertel 2019: <input type=button onClick="javascript:groupimport();" value="$lt{'impo'}">
1.58      albertel 2020: $help{'Importing_LON-CAPA_Resource'}
                   2021: </nobr>
1.59      www      2022: <p>
                   2023: <hr />
1.68      bowersj2 2024: <input type="text" size="20" name="importmap"><br />
                   2025: <nobr><input type=button 
1.52      www      2026: onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
1.81      www      2027: value="$lt{'selm'}"> <input type="submit" name="loadmap" value="$lt{'load'}">
1.68      bowersj2 2028: $help{'Load_Map'}</nobr>
1.59      www      2029: </p>
1.52      www      2030: </form>
1.142     raeburn  2031: </td>
                   2032: <td bgcolor="#DDDDDD">
                   2033: ENDFORM
                   2034:        unless ($ENV{'form.pagepath'}) {
                   2035:            $r->print(<<ENDFORM);
1.11      www      2036: <form action="/adm/coursedocs" method="post" name="newfolder">
1.115     albertel 2037: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.13      www      2038: <input type=hidden name="importdetail" value="">
1.58      albertel 2039: <nobr>
1.16      www      2040: <input name="newfolder" type="button"
                   2041: onClick="javascript:makenewfolder(this.form,'$folderseq');"
1.81      www      2042: value="$lt{'newf'}" />$help{'Adding_Folders'}
1.58      albertel 2043: </nobr>
1.11      www      2044: </form>
1.142     raeburn  2045: <form action="/adm/coursedocs" method="post" name="newpage">
                   2046: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
                   2047: <input type=hidden name="importdetail" value="">
                   2048: <nobr>
                   2049: <input name="newpage" type="button"
                   2050: onClick="javascript:makenewpage(this.form,'$pageseq');"
                   2051: value="$lt{'newp'}" />$help{'Adding_Pages'}
                   2052: </nobr>
                   2053: </form>
1.11      www      2054: <form action="/adm/coursedocs" method="post" name="newext">
1.142     raeburn  2055: $uploadtag
1.13      www      2056: <input type=hidden name="importdetail" value="">
1.58      albertel 2057: <nobr>
1.18      www      2058: <input name="newext" type="button" onClick="javascript:makenewext('newext');"
1.81      www      2059: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
1.58      albertel 2060: </nobr>
1.11      www      2061: </form>
                   2062: <form action="/adm/coursedocs" method="post" name="newsyl">
1.142     raeburn  2063: $uploadtag
1.14      www      2064: <input type=hidden name="importdetail" 
                   2065: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
1.58      albertel 2066: <nobr>
1.81      www      2067: <input name="newsyl" type="submit" value="$lt{'syll'}" /> 
1.65      bowersj2 2068:  $help{'Syllabus'}
1.58      albertel 2069: </nobr>
                   2070: </form>
1.17      www      2071: <form action="/adm/coursedocs" method="post" name="newnav">
1.142     raeburn  2072: $uploadtag
1.15      www      2073: <input type=hidden name="importdetail" 
                   2074: value="Navigate Content=/adm/navmaps">
1.58      albertel 2075: <nobr>
1.81      www      2076: <input name="newnav" type="submit" value="$lt{'navc'}" />
1.47      www      2077: $help{'Navigate_Content'}
1.58      albertel 2078: </nobr>
1.22      www      2079: </form>
                   2080: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.142     raeburn  2081: $uploadtag
1.22      www      2082: <input type=hidden name="importdetail" value="">
1.58      albertel 2083: <nobr>
1.81      www      2084: <input name="newsmppg" type="button" value="$lt{'sipa'}"
1.65      bowersj2 2085: onClick="javascript:makesmppage();" /> $help{'Simple Page'}
1.58      albertel 2086: </nobr>
1.55      www      2087: </form>
                   2088: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.142     raeburn  2089: $uploadtag
1.55      www      2090: <input type=hidden name="importdetail" value="">
1.58      albertel 2091: <nobr>
1.81      www      2092: <input name="newsmpproblem" type="button" value="$lt{'sipr'}"
1.65      bowersj2 2093: onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
1.62      www      2094: </nobr>
                   2095: </form>
                   2096: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.142     raeburn  2097: $uploadtag
1.62      www      2098: <input type=hidden name="importdetail" value="">
                   2099: <nobr>
1.81      www      2100: <input name="newexamupload" type="button" value="$lt{'scuf'}"
1.62      www      2101: onClick="javascript:makeexamupload();" />
1.66      bowersj2 2102: $help{'Score_Upload_Form'}
1.58      albertel 2103: </nobr>
1.22      www      2104: </form>
                   2105: <form action="/adm/coursedocs" method="post" name="newbul">
1.142     raeburn  2106: $uploadtag
1.22      www      2107: <input type=hidden name="importdetail" value="">
1.58      albertel 2108: <nobr>
1.81      www      2109: <input name="newbulletin" type="button" value="$lt{'bull'}"
1.22      www      2110: onClick="javascript:makebulboard();" />
1.65      bowersj2 2111: $help{'Bulletin Board'}
1.58      albertel 2112: </nobr>
                   2113: </form>
1.12      www      2114: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.142     raeburn  2115: $uploadtag
1.14      www      2116: <input type=hidden name="importdetail" 
                   2117: value="$plainname=/adm/$udom/$uname/aboutme">
1.58      albertel 2118: <nobr>
1.81      www      2119: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
1.65      bowersj2 2120: $help{'My Personal Info'}
1.101     www      2121: </nobr>
                   2122: </form>
                   2123: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.142     raeburn  2124: $uploadtag
1.101     www      2125: <input type=hidden name="importdetail" value="">
                   2126: <nobr>
                   2127: <input name="newaboutsomeone" type="button" value="$lt{'abou'}" 
                   2128: onClick="javascript:makeabout();" />
1.110     raeburn  2129: </nobr>
1.142     raeburn  2130: ENDFORM
                   2131:        }
                   2132:        if ($ENV{'form.pagepath'}) {
                   2133:            $r->print(<<ENDBLOCK);
                   2134: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
                   2135: $uploadtag
                   2136: <input type=hidden name="importdetail" value="">
                   2137: <nobr>
                   2138: <input name="newsmpproblem" type="button" value="$lt{'sipr'}"
                   2139: onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
                   2140: </nobr>
                   2141: </form>
                   2142: <form action="/adm/coursedocs" method="post" name="newexamupload">
                   2143: $uploadtag
                   2144: <input type=hidden name="importdetail" value="">
                   2145: <nobr>
                   2146: <input name="newexamupload" type="button" value="$lt{'scuf'}"
                   2147: onClick="javascript:makeexamupload();" />
                   2148: $help{'Score_Upload_Form'}
                   2149: </nobr>
                   2150: </form>
                   2151: ENDBLOCK
                   2152:        } else {
                   2153:            $r->print(<<ENDFORM);
1.110     raeburn  2154: </form>
                   2155: <form action="/adm/imsimportdocs" method="post" name="ims">
1.118     albertel 2156: <input type="hidden" name="folder" value="$folder" />
1.110     raeburn  2157: <input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" />
1.58      albertel 2158: </nobr>
                   2159: </form>
1.8       www      2160: ENDFORM
1.142     raeburn  2161:        }
                   2162:        $r->print('</td></tr>'."\n".
                   2163: '</table>');
1.24      www      2164:        $r->print('</td></tr>');
1.7       www      2165:     }
                   2166: # ----------------------------------------------------- Supplemental documents
                   2167:     if (!$forcestandard) {
1.116     albertel 2168:        $r->print('<tr><td bgcolor="#BBBBBB">');
                   2169: # '<h2>'.&mt('Supplemental Course Documents').
                   2170: #  ($allowed?' '.$help{'Supplemental'}:'').'</h2>');
1.7       www      2171:        my $folder=$ENV{'form.folder'};
1.117     albertel 2172:        unless ($folder=~/^supplemental/) {
1.116     albertel 2173: 	   $folder='supplemental';
1.117     albertel 2174:        }
                   2175:        if ($folder =~ /^supplemental$/ &&
                   2176: 	   $ENV{'form.folderpath'} =~ /^default\&/) {
                   2177: 	   $ENV{'form.folderpath'}='supplemental&'.
                   2178: 	       &Apache::lonnet::escape(&mt('Supplemental Course Documents'));
1.116     albertel 2179:        }
1.7       www      2180:        &editor($r,$coursenum,$coursedom,$folder,$allowed);
1.8       www      2181:        if ($allowed) {
1.17      www      2182:        my $folderseq=
                   2183:                   '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
                   2184:                      '.sequence';
                   2185: 
1.8       www      2186:           $r->print(<<ENDSUPFORM);
1.43      www      2187: <table cellspacing=4 cellpadding=4><tr>
1.81      www      2188: <th bgcolor="#DDDDDD">$lt{'upls'}</th>
                   2189: <th bgcolor="#DDDDDD">$lt{'spec'}</th>
1.17      www      2190: </tr>
                   2191: <tr><td bgcolor="#DDDDDD">
1.10      www      2192: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.59      www      2193: <input type="file" name="uploaddoc" size="40">
1.96      sakharuk 2194: <br />$lt{'comment'}:<br />
1.4       www      2195: <textarea cols=50 rows=4 name='comment'>
                   2196: </textarea>
1.115     albertel 2197: <br />
                   2198: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.10      www      2199: <input type="hidden" name="cmd" value="upload_supplemental">
1.58      albertel 2200: <nobr>
1.81      www      2201: <input type="submit" value="$lt{'upld'}">
1.58      albertel 2202:  $help{'Uploading_From_Harddrive'}
                   2203: </nobr>
                   2204: </form>
1.17      www      2205: </td>
                   2206: <td bgcolor="#DDDDDD">
1.18      www      2207: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.115     albertel 2208: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.17      www      2209: <input type=hidden name="importdetail" value="">
1.58      albertel 2210: <nobr>
1.17      www      2211: <input name="newfolder" type="button"
                   2212: onClick="javascript:makenewfolder(this.form,'$folderseq');"
1.81      www      2213: value="$lt{'newf'}" /> $help{'Adding_Folders'}
1.58      albertel 2214: </nobr>
1.17      www      2215: </form>
1.18      www      2216: <form action="/adm/coursedocs" method="post" name="supnewext">
1.115     albertel 2217: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.17      www      2218: <input type=hidden name="importdetail" value="">
1.58      albertel 2219: <nobr>
1.18      www      2220: <input name="newext" type="button" 
                   2221: onClick="javascript:makenewext('supnewext');"
1.81      www      2222: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
1.58      albertel 2223: </nobr>
1.17      www      2224: </form>
1.18      www      2225: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.115     albertel 2226: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.17      www      2227: <input type=hidden name="importdetail" 
                   2228: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
1.58      albertel 2229: <nobr>
1.81      www      2230: <input name="newsyl" type="submit" value="$lt{'syll'}" />
1.65      bowersj2 2231: $help{'Syllabus'}
1.58      albertel 2232: </nobr>
                   2233: </form>
1.18      www      2234: <form action="/adm/coursedocs" method="post" name="subnewaboutme">
1.115     albertel 2235: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.17      www      2236: <input type=hidden name="importdetail" 
                   2237: value="$plainname=/adm/$udom/$uname/aboutme">
1.58      albertel 2238: <nobr>
1.81      www      2239: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
1.65      bowersj2 2240: $help{'My Personal Info'}
1.58      albertel 2241: </nobr>
                   2242: </form>
1.17      www      2243: </td></tr>
1.24      www      2244: </table></td></tr>
1.8       www      2245: ENDSUPFORM
                   2246:        }
1.7       www      2247:     }
1.18      www      2248:     if ($allowed) {
                   2249: 	$r->print('<form name="extimport"><input type="hidden" name="title"><input type="hidden" name="url"><input type="hidden" name="useform"></form>');
                   2250:     }
1.24      www      2251:     $r->print('</table>');
1.19      www      2252:   } else {
                   2253: # -------------------------------------------------------- This is showdoc mode
1.141     albertel 2254:       $r->print("<h1>".&mt('Uploaded Document').' - '.
                   2255: 		&Apache::lonnet::gettitle($r->uri).'</h1><p>'.
1.81      www      2256: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><p><table>".
                   2257:          &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table></p>');
1.19      www      2258:   }
1.26      www      2259:  }
1.95      www      2260:  $r->print('</body></html>');
1.26      www      2261:  return OK;
1.1       www      2262: } 
                   2263: 
                   2264: 1;
                   2265: __END__

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