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