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