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