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