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