File:
[LON-CAPA] /
loncom /
interface /
londocs.pm
Revision
1.49:
download - view:
text,
annotated -
select for diffs
Fri Feb 14 19:35:54 2003 UTC (21 years, 6 months ago) by
www
Branches:
MAIN
CVS tags:
HEAD
A lot of things happened here:
* everything menu-related was moved out of lonxml, and into lonmenu
* thus, function calls to registerurl, loadevents and unloadevents modified
* fixed lontex.pm, which actually did not call the right routines
* put in calls to lonmenu::menubuttons, which is supposed to insert buttons
after the body tag in "textual mode" - this function and registerurl will
be unified (buttons either in Remote or on top of page)
1: # The LearningOnline Network
2: # Documents
3: #
4: # $Id: londocs.pm,v 1.49 2003/02/14 19:35:54 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 HTML::Entities;
39: use GDBM_File;
40:
41: my $iconpath;
42:
43: my %hash;
44:
45: my $hashtied;
46: my %alreadyseen=();
47:
48: my $hadchanges;
49:
50: # Available help topics
51:
52: my %help=();
53:
54: # Mapread read maps into lonratedt::global arrays
55: # @order and @resources, determines status
56: # sets @order - pointer to resources in right order
57: # sets @resources - array with the resources with correct idx
58: #
59:
60: sub mapread {
61: my ($coursenum,$coursedom,$map)=@_;
62: return
63: &Apache::lonratedt::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
64: $map);
65: }
66:
67: sub storemap {
68: my ($coursenum,$coursedom,$map)=@_;
69: $hadchanges=1;
70: return
71: &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
72: $map,1);
73: }
74:
75: sub editor {
76: my ($r,$coursenum,$coursedom,$folder,$allowed)=@_;
77: if ($ENV{'form.foldername'}) {
78: $r->print('<h3>Folder: '.$ENV{'form.foldername'}.'</h3>');
79: }
80: my $errtext='';
81: my $fatal=0;
82: ($errtext,$fatal)=
83: &mapread($coursenum,$coursedom,$folder.'.sequence');
84: if ($#Apache::lonratedt::order<1) {
85: $Apache::lonratedt::order[0]=1;
86: $Apache::lonratedt::resources[1]='';
87: }
88: if ($fatal) {
89: $r->print('<p><font color="red">'.$errtext.'</font></p>');
90: } else {
91: # ------------------------------------------------------------ Process commands
92: # ---------------- if they are for this folder and user allowed to make changes
93: if (($allowed) && ($ENV{'form.folder'} eq $folder)) {
94: # upload a file, if present
95: if (($ENV{'form.uploaddoc.filename'}) &&
96: ($ENV{'form.cmd'}=~/^upload_(\w+)/)) {
97: if ($folder=~/^$1/) {
98: # this is for a course, not a user, so set coursedoc flag
99: # probably the only place in the system where this should be "1"
100: my $url=&Apache::lonnet::userfileupload('uploaddoc',1);
101: my $ext='false';
102: if ($url=~/^http\:\/\//) { $ext='true'; }
103: $url=~s/\:/\:/g;
104: my $comment=$ENV{'form.comment'};
105: $comment=~s/\</\<\;/g;
106: $comment=~s/\>/\>\;/g;
107: $comment=~s/\:/\:/g;
108: if ($folder=~/^supplemental/) {
109: $comment=time.'___&&&___'.$ENV{'user.name'}.'___&&&___'.
110: $ENV{'user.domain'}.'___&&&___'.$comment;
111: }
112: my $newidx=$#Apache::lonratedt::resources+1;
113: $Apache::lonratedt::resources[$newidx]=
114: $comment.':'.$url.':'.$ext.':normal:res';
115: $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=
116: $newidx;
117: &storemap($coursenum,$coursedom,$folder.'.sequence');
118: }
119: }
120: if ($ENV{'form.cmd'}) {
121: my ($cmd,$idx)=split(/\_/,$ENV{'form.cmd'});
122: if ($cmd eq 'del') {
123: for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) {
124: $Apache::lonratedt::order[$i]=
125: $Apache::lonratedt::order[$i+1];
126: }
127: $#Apache::lonratedt::order--;
128: } elsif ($cmd eq 'up') {
129: if (($idx) && (defined($Apache::lonratedt::order[$idx-1]))) {
130: my $i=$Apache::lonratedt::order[$idx-1];
131: $Apache::lonratedt::order[$idx-1]=
132: $Apache::lonratedt::order[$idx];
133: $Apache::lonratedt::order[$idx]=$i;
134: }
135: } elsif ($cmd eq 'down') {
136: if (defined($Apache::lonratedt::order[$idx+1])) {
137: my $i=$Apache::lonratedt::order[$idx+1];
138: $Apache::lonratedt::order[$idx+1]=
139: $Apache::lonratedt::order[$idx];
140: $Apache::lonratedt::order[$idx]=$i;
141: }
142: } elsif ($cmd eq 'rename') {
143: my ($rtitle,@rrest)=split(/\:/,
144: $Apache::lonratedt::resources[
145: $Apache::lonratedt::order[$idx]]);
146: my $comment=
147: &HTML::Entities::decode($ENV{'form.title'});
148: $comment=~s/\</\<\;/g;
149: $comment=~s/\>/\>\;/g;
150: $comment=~s/\:/\:/g;
151: $Apache::lonratedt::resources[
152: $Apache::lonratedt::order[$idx]]=
153: $comment.':'.join(':',@rrest);
154:
155: }
156: # Store the changed version
157: &storemap($coursenum,$coursedom,$folder.'.sequence');
158: }
159: # Group import/search
160: if ($ENV{'form.importdetail'}) {
161: foreach (split(/\&/,$ENV{'form.importdetail'})) {
162: if (defined($_)) {
163: my ($name,$url)=split(/\=/,$_);
164: $name=&Apache::lonnet::unescape($name);
165: $url=&Apache::lonnet::unescape($url);
166: if ($url) {
167: my $idx=$#Apache::lonratedt::resources+1;
168: $Apache::lonratedt::order
169: [$#Apache::lonratedt::order+1]=$idx;
170: my $ext='false';
171: if ($url=~/^http\:\/\//) { $ext='true'; }
172: $url=~s/\:/\:/g;
173: $name=~s/\:/\:/g;
174: $Apache::lonratedt::resources[$idx]=
175: $name.':'.$url.':'.$ext.':normal:res';
176: }
177: }
178: }
179: # Store the changed version
180: &storemap($coursenum,$coursedom,$folder.'.sequence');
181: }
182: }
183: # ---------------------------------------------------------------- End commands
184: # ---------------------------------------------------------------- Print screen
185: my $idx=0;
186: $r->print('<table>');
187: foreach (@Apache::lonratedt::order) {
188: my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]);
189: unless ($name) { $name=(split(/\//,$url))[-1]; }
190: unless ($name) { $name='NO RESOURCE'; $url='/adm/notfound.html'; }
191: $r->print(&entryline($idx,$name,$url,$folder,$allowed));
192: $idx++;
193: }
194: $r->print('</table>');
195: }
196: }
197:
198: # --------------------------------------------------------------- An entry line
199:
200: sub entryline {
201: my ($index,$title,$url,$folder,$allowed)=@_;
202: $title=~s/\&colon\;/\:/g;
203: $title=&HTML::Entities::encode(&HTML::Entities::decode(
204: &Apache::lonnet::unescape($title)),'\"\<\>\&\'');
205: my $renametitle=$title;
206: my $foldertitle=$title;
207: if ($title=~
208: /^(\d+)\_\_\_\&\;\&\;\&\;\_\_\_(\w+)\_\_\_\&\;\&\;\&\;\_\_\_(\w+)\_\_\_\&\;\&\;\&\;\_\_\_(.*)$/
209: ) {
210: $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
211: $renametitle=$4;
212: $title='<i>'.localtime($1).'</i> '.
213: &Apache::loncommon::plainname($2,$3).': <br>'.
214: $foldertitle;
215: }
216: $renametitle=~s/\"\;/\\\"/g;
217: my $line='<tr>';
218: # Edit commands
219: if ($allowed) {
220: $line.=(<<END);
221: <td><table border='0' cellspacing='0' cellpadding='0'>
222: <tr><td><a href='/adm/coursedocs?folder=$folder&cmd=up_$index'>
223: <img src="${iconpath}move_up.gif" alt='UP' border='0' /></a></td></tr>
224: <tr><td><a href='/adm/coursedocs?folder=$folder&cmd=down_$index'>
225: <img src="${iconpath}move_down.gif" alt='DOWN' border='0' /></a></td></tr>
226: </table></td><td>
227: <a href='/adm/coursedocs?folder=$folder&cmd=del_$index'>
228: <font size="-2">Remove</font></a>
229: <a href='javascript:changename("$folder","$index","$renametitle");'>
230: <font size="-2">Rename</font></a></td>
231: END
232: }
233: # Figure out what kind of a resource this is
234: my ($extension)=($url=~/\.(\w+)$/);
235: my $uploaded=($url=~/^\/*uploaded\//);
236: my $icon='unknown';
237: if (-e "/home/httpd/html/adm/lonIcons/$extension.gif") {
238: $icon=$extension;
239: }
240: my $isfolder=0;
241: if ($uploaded) {
242: if ($extension eq 'sequence') {
243: $icon='folder_closed';
244: $url=~/\/(\w+)\.sequence/;
245: $url='/adm/coursedocs?folder='.$1;
246: $isfolder=1;
247: } else {
248: $url=&Apache::lonnet::tokenwrapper($url);
249: }
250: }
251: $url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//;
252: if ($isfolder) { $url.='&foldername='.
253: &Apache::lonnet::escape($foldertitle); }
254: $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'" target="cat_'.$folder.
255: '"><img src="/adm/lonIcons/'.
256: $icon.'.gif" border="0"></a></td>'.
257: "<td bgcolor='#FFFFBB'><a href='$url' target='cat_$folder'>$title</a></td></tr>";
258: return $line;
259: }
260:
261: # ---------------------------------------------------------------- tie the hash
262:
263: sub tiehash {
264: $hashtied=0;
265: if ($ENV{'request.course.fn'}) {
266: if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
267: &GDBM_READER(),0640)) {
268: $hashtied=1;
269: }
270: }
271: }
272:
273: sub untiehash {
274: if ($hashtied) { untie %hash; }
275: $hashtied=0;
276: }
277:
278: # --------------------------------------------------------------- check on this
279:
280: sub checkonthis {
281: my ($r,$url,$level,$title)=@_;
282: $alreadyseen{$url}=1;
283: $r->rflush();
284: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
285: $r->print('<br />');
286: for (my $i=0;$i<=$level*5;$i++) {
287: $r->print(' ');
288: }
289: $r->print('<a href="'.$url.'" target="cat">'.
290: ($title?$title:$url).'</a> ');
291: if ($url=~/^\/res\//) {
292: my $result=&Apache::lonnet::repcopy(
293: &Apache::lonnet::filelocation('',$url));
294: if ($result==OK) {
295: $r->print('<font color="green">ok</font>');
296: $r->rflush();
297: &Apache::lonnet::countacc($url);
298: $url=~/\.(\w+)$/;
299: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
300: $r->print('<br />');
301: $r->rflush();
302: for (my $i=0;$i<=$level*5;$i++) {
303: $r->print(' ');
304: }
305: $r->print('- Rendering: ');
306: &Apache::lonxml::xmlparse($r,'web',
307: &Apache::lonnet::getfile(
308: &Apache::lonnet::filelocation('',$url)));
309: if (($Apache::lonxml::errorcount) ||
310: ($Apache::lonxml::warningcount)) {
311: if ($Apache::lonxml::errorcount) {
312: $r->print('<font color="red"><b>'.
313: $Apache::lonxml::errorcount.' error(s)</b></font> ');
314: }
315: if ($Apache::lonxml::warningcount) {
316: $r->print('<font color="blue">'.
317: $Apache::lonxml::warningcount.' warning(s)</font>');
318: }
319: } else {
320: $r->print('<font color="green">ok</font>');
321: }
322: $r->rflush();
323: }
324: my $dependencies=
325: &Apache::lonnet::metadata($url,'dependencies');
326: foreach (split(/\,/,$dependencies)) {
327: if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {
328: &checkonthis($r,$_,$level+1);
329: }
330: }
331: } elsif ($result==HTTP_SERVICE_UNAVAILABLE) {
332: $r->print('<font color="red"><b>connection down</b></font>');
333: } elsif ($result==HTTP_NOT_FOUND) {
334: $r->print('<font color="red"><b>not found</b></font>');
335: } else {
336: $r->print('<font color="red"><b>access denied</b></font>');
337: }
338: }
339: }
340: }
341:
342: # ================================================================ Main Handler
343: sub handler {
344: my $r = shift;
345: $r->content_type('text/html');
346: $r->send_http_header;
347: return OK if $r->header_only;
348:
349: # --------------------------------------------- Initialize help topics for this
350: foreach ('Adding_Course_Doc','Main_Course_Documents',
351: 'Adding_External_Resource','Navigate_Content',
352: 'Adding_Folders','Docs_Overview',
353: 'Creating_From_Template','Supplemental',
354: 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive') {
355: $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);
356: }
357:
358: if ($ENV{'form.verify'}) {
359:
360: my $loaderror=&Apache::lonnet::overloaderror($r);
361: if ($loaderror) { return $loaderror; }
362:
363: $r->print('<html><head><title>Verify Content</title></head>'.
364: &Apache::loncommon::bodytag('Verify Course Documents'));
365: $hashtied=0;
366: undef %alreadyseen;
367: %alreadyseen=();
368: &tiehash();
369: foreach (keys %hash) {
370: if (($_=~/^src\_(.+)$/) && (!$alreadyseen{$hash{$_}})) {
371: &checkonthis($r,$hash{$_},0,$hash{'title_'.$1});
372: }
373: }
374: &untiehash();
375: } elsif ($ENV{'form.versions'}) {
376: $r->print('<html><head><title>Check Versions</title></head>'.
377: &Apache::loncommon::bodytag('Check Course Document Versions'));
378: $hashtied=0;
379: &tiehash();
380: my %changes=&Apache::lonnet::dump
381: ('versionupdate',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
382: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
383: my $firstkey=(keys %changes)[0];
384: unless ($firstkey=~/^error\:/) {
385: unless ($ENV{'form.timerange'}) {
386: $ENV{'form.timerange'}=604800;
387: }
388: my $seltext='during the last '.$ENV{'form.timerange'}.' seconds';
389: my $startsel='';
390: my $monthsel='';
391: my $weeksel='';
392: my $daysel='';
393: if ($ENV{'form.timerange'}==-1) {
394: $seltext='since start of course';
395: $startsel='selected';
396: $ENV{'form.timerange'}=time;
397: }
398: my $starttime=time-$ENV{'form.timerange'};
399: if ($ENV{'form.timerange'}==2592000) {
400: $seltext='during the last month ('.localtime($starttime).')';
401: $monthsel='selected';
402: } elsif ($ENV{'form.timerange'}==604800) {
403: $seltext='during the last week ('.localtime($starttime).')';
404: $weeksel='selected';
405: } elsif ($ENV{'form.timerange'}==86400) {
406: $seltext='since yesterday ('.localtime($starttime).')';
407: $daysel='selected';
408: }
409:
410: $r->print(<<ENDHEADERS);
411: <form action="/adm/coursedocs" method="post">
412: <select name="timerange">
413: <option value="-1" $startsel>Since Start of Course</option>
414: <option value="2592000" $monthsel>Last Month</option>
415: <option value="604800" $weeksel>Last Week</option>
416: <option value="86400" $daysel>Since Yesterday</option>
417: </select>
418: <input type="submit" name="versions" value="Display" />
419: </form>
420: <h3>Content changed $seltext</h3>
421: <table border="2">
422: <tr>
423: <th>File</th><th>Modification Date</th>
424: <th>Version</th><th>Differences</th></tr>
425: ENDHEADERS
426: foreach (keys %changes) {
427: if ($changes{$_}>$starttime) {
428: my ($root,$extension)=($_=~/^(.*)\.(\w+)$/);
429: my $currentversion=&Apache::lonnet::getversion($_);
430: my $linkurl=&Apache::lonnet::clutter($_);
431: $r->print(
432: '<tr><td><a href="'.$linkurl.'" target="cat">'.$linkurl.
433: '</a></td><td>'.
434: localtime($changes{$_}).'</td><td>'.$currentversion.'</td>'.
435: '<td>');
436: my $lastold=1;
437: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
438: my $url=$root.'.'.$prevvers.'.'.$extension;
439: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
440: $starttime) {
441: $lastold=$prevvers;
442: }
443: }
444: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
445: my $url=$root.'.'.$prevvers.'.'.$extension;
446: $r->print('<a href="'.&Apache::lonnet::clutter($url).
447: '">Version '.$prevvers.' ('.
448: localtime(&Apache::lonnet::metadata($url,'lastrevisiondate')).
449: ')</a>');
450: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
451: $r->print(' <a href="/adm/diff?filename='.
452: &Apache::lonnet::clutter($root.'.'.$extension).
453: '&versionone='.$prevvers.
454: '">Diffs</a>');
455: }
456: $r->print('<br />');
457: }
458: $r->print('</td></tr>');
459: }
460: }
461: $r->print('</table>');
462: } else {
463: $r->print('<p>No content modifications yet.</p>');
464: }
465: &untiehash();
466: } else {
467: # is this a standard course?
468:
469: my $standard=($ENV{'request.course.uri'}=~/^\/uploaded\//);
470: my $forcestandard;
471: my $forcesupplement;
472: my $script='';
473: my $allowed;
474: my $events='';
475: my $buttons='';
476: my $showdoc=0;
477: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
478: ['folder','foldername']);
479: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
480: $showdoc=$1;
481: }
482: unless ($showdoc) { # got called from remote
483: $forcestandard=($ENV{'form.folder'}=~/^default_/);
484: $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
485:
486: # does this user have privileges to post, etc?
487: $allowed=&Apache::lonnet::allowed('srm',$ENV{'request.course.id'});
488: if ($allowed) {
489: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
490: $script=&Apache::lonratedt::editscript('simple');
491: }
492: } else { # got called in sequence from course
493: $allowed=0;
494: $script='</script>'.&Apache::lonmenu::registerurl(1,undef).'<script>';
495: $events='onLoad="'.&Apache::lonmenu::loadevents.
496: '" onUnload="'.&Apache::lonmenu::unloadevents.'"';
497: $buttons=&Apache::lonmenu::menubuttons(1,undef);
498: }
499:
500: # get course data
501: my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
502: my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
503:
504: # get personal data
505:
506: my $uname=$ENV{'user.name'};
507: my $udom=$ENV{'user.domain'};
508: my $plainname=&Apache::lonnet::escape(
509: &Apache::loncommon::plainname($uname,$udom));
510:
511: # graphics settings
512:
513: $iconpath = $r->dir_config('lonIconsURL') . "/";
514:
515: my $now=time;
516:
517: # print screen
518: $r->print(<<ENDDOCUMENT);
519: <html>
520: <head>
521: <title>The LearningOnline Network with CAPA</title>
522: <script>
523: $script
524: </script>
525: ENDDOCUMENT
526: if ($allowed) {
527: $r->print(<<ENDNEWSCRIPT);
528: <script>
529: function makenewfolder(targetform,folderseq) {
530: var foldername=prompt('Name of New Folder','New Folder');
531: if (foldername) {
532: targetform.importdetail.value=foldername+"="+folderseq;
533: targetform.submit();
534: }
535: }
536:
537: function makenewext(targetname) {
538: this.document.forms.extimport.useform.value=targetname;
539: window.open('/adm/rat/extpickframe.html');
540: }
541:
542: function makesmppage() {
543: var title=prompt('Listed Title for the Page');
544: if (title) {
545: this.document.forms.newsmppg.importdetail.value=
546: title+'=/adm/$udom/$uname/$now/smppg';
547: this.document.forms.newsmppg.submit();
548: }
549: }
550:
551: function makebulboard() {
552: var title=prompt('Listed Title for the Bulletin Board');
553: if (title) {
554: this.document.forms.newbul.importdetail.value=
555: title+'=/adm/$udom/$uname/$now/bulletinboard';
556: this.document.forms.newbul.submit();
557: }
558: }
559:
560: function finishpick() {
561: var title=this.document.forms.extimport.title.value;
562: var url=this.document.forms.extimport.url.value;
563: var form=this.document.forms.extimport.useform.value;
564: eval
565: ('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+
566: '";this.document.forms.'+form+'.submit();');
567: }
568:
569: function changename(folder,index,oldtitle) {
570: var title=prompt('New Title',oldtitle);
571: if (title) {
572: this.document.forms.renameform.title.value=title;
573: this.document.forms.renameform.cmd.value='rename_'+index;
574: this.document.forms.renameform.folder.value=folder;
575: this.document.forms.renameform.submit();
576: }
577: }
578: </script>
579:
580: ENDNEWSCRIPT
581: }
582: # -------------------------------------------------------------------- Body tag
583: $r->print('</head>'.
584: &Apache::loncommon::bodytag('Course Documents','',$events).
585: $buttons);
586: unless ($showdoc) {
587: if ($allowed) {
588: $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
589: 'Editing the Table of Contents for your Course'));
590: $r->print(<<ENDCOURSEVERIFY);
591: <form name="renameform" method="post" action="/adm/coursedocs">
592: <input type="hidden" name="title" />
593: <input type="hidden" name="cmd" />
594: <input type="hidden" name="folder" />
595: </form>
596: <form name="simpleedit" method="post" action="/adm/coursedocs">
597: <input type=hidden name="importdetail" value="">
598: <input type="hidden" name="folder" />
599: </form>
600: <form action="/adm/coursedocs" method="post" name="courseverify">
601: <input type="submit" name="verify" value="Verify Content" />
602: <input type="submit" name="versions" value="Check Resource Versions" />
603: </form>
604: ENDCOURSEVERIFY
605: }
606: # --------------------------------------------------------- Standard documents
607: $r->print('<table border=2 cellspacing=4 cellpadding=4>');
608: if (($standard) && ($allowed) && (!$forcesupplement)) {
609: $r->print('<tr><td bgcolor="#BBBBBB"><h2>Main Course Documents'.
610: ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>');
611: my $folder=$ENV{'form.folder'};
612: unless ($folder=~/^default/) { $folder='default'; }
613: $hadchanges=0;
614: &editor($r,$coursenum,$coursedom,$folder,$allowed);
615: if ($hadchanges) {
616: $r->print('<form method="post" action="/adm/roles">'.
617: '<input type=hidden name=orgurl value="/adm/coursedocs" /><input type=hidden name=selectrole value=1 /><h3><font color="red">Changes will become active for your current session after <input type="submit" name="'.
618: $ENV{'request.role'}.'" value="re-initializing course" />, or the next time you log in.</font></h3></form>');
619: }
620: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
621: '.sequence';
622:
623: $r->print(<<ENDFORM);
624: <table cellspacing=4 cellpadding=4><tr>
625: <th bgcolor="#DDDDDD">Upload a new main course document</th>
626: <th bgcolor="#DDDDDD">Import a published document</th>
627: <th bgcolor="#DDDDDD">Special documents</th>
628: </tr>
629: <tr><td bgcolor="#DDDDDD">
630: File:<br />
631: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
632: <input type="file" name="uploaddoc" size="50">
633: <br />
634: Title:<br />
635: <input type="text" size="50" name="comment">
636: <input type="hidden" name="folder" value="$folder">
637: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
638: <input type="hidden" name="cmd" value="upload_default">
639: <input type="submit" value="Upload Document">
640: $help{'Uploading_From_Harddrive'}</form>
641: </td>
642: <td bgcolor="#DDDDDD">
643: <form action="/adm/coursedocs" method="post" name="simpleeditdefault">
644: <input type=button onClick=
645: "javascript:document.forms.simpleedit.folder.value='$folder';groupsearch()" value="Search">
646: <input type=button onClick=
647: "javascript:document.forms.simpleedit.folder.value='$folder';groupimport();" value="Import">
648: $help{'Importing_LON-CAPA_Resource'}</form>
649: </td><td bgcolor="#DDDDDD">
650: <form action="/adm/coursedocs" method="post" name="newfolder">
651: <input type="hidden" name="folder" value="$folder">
652: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
653: <input type=hidden name="importdetail" value="">
654: <input name="newfolder" type="button"
655: onClick="javascript:makenewfolder(this.form,'$folderseq');"
656: value="New Folder" /> $help{'Adding_Folders'}
657: </form>
658: <form action="/adm/coursedocs" method="post" name="newext">
659: <input type="hidden" name="folder" value="$folder">
660: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
661: <input type=hidden name="importdetail" value="">
662: <input name="newext" type="button" onClick="javascript:makenewext('newext');"
663: value="External Resource" /> $help{'Adding_External_Resource'}
664: </form>
665: <form action="/adm/coursedocs" method="post" name="newsyl">
666: <input type="hidden" name="folder" value="$folder">
667: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
668: <input type=hidden name="importdetail"
669: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
670: <input name="newsyl" type="submit" value="Syllabus" />
671: $help{'Creating_From_Template'}</form>
672: <form action="/adm/coursedocs" method="post" name="newnav">
673: <input type="hidden" name="folder" value="$folder">
674: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
675: <input type=hidden name="importdetail"
676: value="Navigate Content=/adm/navmaps">
677: <input name="newnav" type="submit" value="Navigate Content" />
678: $help{'Navigate_Content'}
679: </form>
680: <form action="/adm/coursedocs" method="post" name="newsmppg">
681: <input type="hidden" name="folder" value="$folder">
682: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
683: <input type=hidden name="importdetail" value="">
684: <input name="newsmppg" type="button" value="Simple Page"
685: onClick="javascript:makesmppage();" /> $help{'Creating_From_Template'}
686: </form>
687: <form action="/adm/coursedocs" method="post" name="newbul">
688: <input type="hidden" name="folder" value="$folder">
689: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
690: <input type=hidden name="importdetail" value="">
691: <input name="newbulletin" type="button" value="Bulletin Board"
692: onClick="javascript:makebulboard();" />
693: $help{'Creating_From_Template'}</form>
694: <form action="/adm/coursedocs" method="post" name="newaboutme">
695: <input type="hidden" name="folder" value="$folder">
696: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
697: <input type=hidden name="importdetail"
698: value="$plainname=/adm/$udom/$uname/aboutme">
699: <input name="newaboutme" type="submit" value="My Personal Info" />
700: $help{'Creating_From_Template'}</form>
701: </td></tr>
702: </table>
703: ENDFORM
704: $r->print('</td></tr>');
705: }
706: # ----------------------------------------------------- Supplemental documents
707: if (!$forcestandard) {
708: $r->print(
709: '<tr><td bgcolor="#BBBBBB"><h2>Supplemental Course Documents'.
710: ($allowed?' '.$help{'Supplemental'}:'').'</h2>');
711: my $folder=$ENV{'form.folder'};
712: unless ($folder=~/supplemental/) { $folder='supplemental'; }
713: &editor($r,$coursenum,$coursedom,$folder,$allowed);
714: if ($allowed) {
715: my $folderseq=
716: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
717: '.sequence';
718:
719: $r->print(<<ENDSUPFORM);
720: <table cellspacing=4 cellpadding=4><tr>
721: <th bgcolor="#DDDDDD">Upload a new supplemental course document</th>
722: <th bgcolor="#DDDDDD">Import a published document</th>
723: <th bgcolor="#DDDDDD">Special documents</th>
724: </tr>
725: <tr><td bgcolor="#DDDDDD">
726: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
727: <input type="file" name="uploaddoc" size="50">
728: <br />Comment:<br />
729: <textarea cols=50 rows=4 name='comment'>
730: </textarea>
731: <input type="hidden" name="folder" value="$folder">
732: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
733: <input type="hidden" name="cmd" value="upload_supplemental">
734: <input type="submit" value="Upload Document">
735: $help{'Uploading_From_Harddrive'}</form>
736: </td>
737: <td bgcolor="#DDDDDD">
738: <form action="/adm/coursedocs" method="post" name="simpleeditsupplement">
739: <input type=hidden name="importdetail" value="">
740: <input type=button onClick=
741: "javascript:document.forms.simpleedit.folder.value='$folder';groupsearch()" value="Search">
742: <input type=button onClick=
743: "javascript:document.forms.simpleedit.folder.value='$folder';groupimport();" value="Import">$help{'Importing_LON-CAPA_Resource'}
744: </form>
745: </td><td bgcolor="#DDDDDD">
746: <form action="/adm/coursedocs" method="post" name="supnewfolder">
747: <input type="hidden" name="folder" value="$folder">
748: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
749: <input type=hidden name="importdetail" value="">
750: <input name="newfolder" type="button"
751: onClick="javascript:makenewfolder(this.form,'$folderseq');"
752: value="New Folder" /> $help{'Adding_Folders'}
753: </form>
754: <form action="/adm/coursedocs" method="post" name="supnewext">
755: <input type="hidden" name="folder" value="$folder">
756: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
757: <input type=hidden name="importdetail" value="">
758: <input name="newext" type="button"
759: onClick="javascript:makenewext('supnewext');"
760: value="External Resource" /> $help{'Adding_External_Resource'}
761: </form>
762: <form action="/adm/coursedocs" method="post" name="supnewsyl">
763: <input type="hidden" name="folder" value="$folder">
764: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
765: <input type=hidden name="importdetail"
766: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
767: <input name="newsyl" type="submit" value="Syllabus" />
768: $help{'Creating_From_Template'}</form>
769: <form action="/adm/coursedocs" method="post" name="subnewaboutme">
770: <input type="hidden" name="folder" value="$folder">
771: <input type="hidden" name="foldername" value="$ENV{'form.foldername'}">
772: <input type=hidden name="importdetail"
773: value="$plainname=/adm/$udom/$uname/aboutme">
774: <input name="newaboutme" type="submit" value="My Personal Info" />
775: $help{'Creating_From_Template'}</form>
776: </td></tr>
777: </table></td></tr>
778: ENDSUPFORM
779: }
780: }
781: if ($allowed) {
782: $r->print('<form name="extimport"><input type="hidden" name="title"><input type="hidden" name="url"><input type="hidden" name="useform"></form>');
783: }
784: $r->print('</table>');
785: } else {
786: # -------------------------------------------------------- This is showdoc mode
787: $r->print("<h1>Uploaded Document</h1><p>It is recommended that you use an up-to-date virus scanner before handling this file.</p><p><table>".
788: &entryline(0,"Click to download or use your browser's Save Link function",$showdoc).'</table></p>');
789: }
790: }
791: $r->print('</body></html>');
792: return OK;
793: }
794:
795: 1;
796: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>