Annotation of loncom/interface/londocs.pm, revision 1.139
1.1 www 1: # The LearningOnline Network
1.2 www 2: # Documents
1.1 www 3: #
1.139 ! albertel 4: # $Id: londocs.pm,v 1.138 2004/08/22 18:15:54 raeburn 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.138 raeburn 39: use Apache::lonnavmaps;
1.38 www 40: use HTML::Entities;
1.27 www 41: use GDBM_File;
1.81 www 42: use Apache::lonlocal;
1.7 www 43:
1.8 www 44: my $iconpath;
1.7 www 45:
1.27 www 46: my %hash;
47:
48: my $hashtied;
1.29 www 49: my %alreadyseen=();
1.27 www 50:
1.40 www 51: my $hadchanges;
52:
1.47 www 53: # Available help topics
54:
55: my %help=();
56:
1.7 www 57: # Mapread read maps into lonratedt::global arrays
1.10 www 58: # @order and @resources, determines status
1.7 www 59: # sets @order - pointer to resources in right order
60: # sets @resources - array with the resources with correct idx
61: #
62:
63: sub mapread {
64: my ($coursenum,$coursedom,$map)=@_;
65: return
66: &Apache::lonratedt::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
67: $map);
68: }
69:
70: sub storemap {
71: my ($coursenum,$coursedom,$map)=@_;
1.104 albertel 72: my ($outtext,$errtext)=
1.7 www 73: &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.15 www 74: $map,1);
1.104 albertel 75: if ($errtext) { return ($errtext,2); }
76:
77: $hadchanges=1;
78: return ($errtext,0);
1.7 www 79: }
80:
1.74 www 81: # ----------------------------------------- Return hash with valid author names
82:
83: sub authorhosts {
84: my %outhash=();
85: my $home=0;
86: my $other=0;
87: foreach (keys %ENV) {
88: if ($_=~/^user\.role\.(au|ca)\.(.+)$/) {
89: my $role=$1;
90: my $realm=$2;
91: my ($start,$end)=split(/\./,$ENV{$_});
92: if (($start) && ($start>time)) { next; }
93: if (($end) && (time>$end)) { next; }
94: my $ca; my $cd;
95: if ($1 eq 'au') {
96: $ca=$ENV{'user.name'};
97: $cd=$ENV{'user.domain'};
98: } else {
99: ($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/);
100: }
1.107 albertel 101: my $allowed=0;
102: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
103: my @ids=&Apache::lonnet::current_machine_ids();
104: foreach my $id (@ids) { if ($id eq $myhome) { $allowed=1; } }
105: if ($allowed) {
1.74 www 106: $home++;
107: $outhash{'home_'.$ca.'@'.$cd}=1;
108: } else {
1.107 albertel 109: $outhash{'otherhome_'.$ca.'@'.$cd}=$myhome;
1.74 www 110: $other++;
111: }
112: }
113: }
114: return ($home,$other,%outhash);
115: }
116: # ------------------------------------------------------ Generate "dump" button
117:
118: sub dumpbutton {
119: my ($home,$other,%outhash)=&authorhosts();
120: if ($home+$other==0) { return ''; }
121: my $output='</td><td bgcolor="#DDDDCC">';
122: if ($home) {
123: return '</td><td bgcolor="#DDDDCC">'.
1.81 www 124: '<input type="submit" name="dumpcourse" value="'.
1.130 www 125: &mt('Dump Course DOCS to Construction Space').'" />'.
126: &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs');
1.74 www 127: } else {
128: return'</td><td bgcolor="#DDDDCC">'.
1.81 www 129: &mt('Dump Course DOCS to Construction Space: available on other servers');
1.74 www 130: }
131: }
132:
133: # -------------------------------------------------------- Actually dump course
134:
135: sub dumpcourse {
1.75 www 136: my $r=shift;
137: $r->print('<html><head><title>Dump DOCS</title></head>'.
1.76 www 138: &Apache::loncommon::bodytag('Dump Course DOCS to Construction Space').
139: '<form name="dumpdoc" method="post">');
1.74 www 140: my ($home,$other,%outhash)=&authorhosts();
1.75 www 141: unless ($home) { return ''; }
1.76 www 142: my $origcrsid=$ENV{'request.course.id'};
143: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
144: if (($ENV{'form.authorspace'}) && ($ENV{'form.authorfolder'}=~/\w/)) {
145: # Do the dumping
1.75 www 146: unless ($outhash{'home_'.$ENV{'form.authorspace'}}) { return ''; }
147: my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'});
1.87 www 148: $r->print('<h3>'.&mt('Copying Files').'</h3>');
1.76 www 149: my $title=$ENV{'form.authorfolder'};
1.79 www 150: $title=~s/[^\w\/]+/\_/g;
151: my %replacehash=();
152: foreach (keys %ENV) {
153: if ($_=~/^form\.namefor\_(.+)/) {
154: $replacehash{$1}=$ENV{$_};
155: }
156: }
157: my $crs='/uploaded/'.$ENV{'request.course.id'}.'/';
158: $crs=~s/\_/\//g;
159: foreach (keys %replacehash) {
160: my $newfilename=$title.'/'.$replacehash{$_};
1.132 www 161: $newfilename=~s/[^\w\/\.\/]+/\_/g;
1.79 www 162: my @dirs=split(/\//,$newfilename);
163: my $path='/home/'.$ca.'/public_html';
164: my $makepath=$path;
165: my $fail=0;
166: for (my $i=0;$i<$#dirs;$i++) {
167: $makepath.='/'.$dirs[$i];
168: unless (-e $makepath) {
169: unless(mkdir($makepath,0777)) { $fail=1; }
170: }
171: }
172: $r->print('<br /><tt>'.$_.'</tt> => <tt>'.$newfilename.'</tt>: ');
173: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
174: if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
175: print $fh &Apache::loncreatecourse::rewritefile(
176: &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_),
177: (%replacehash,$crs => '')
178: );
179: } else {
180: print $fh
181: &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_);
182: }
183: $fh->close();
184: } else {
185: $fail=1;
186: }
187: if ($fail) {
188: $r->print('<font color="red">fail</font>');
189: } else {
190: $r->print('<font color="green">ok</font>');
191: }
192: }
1.76 www 193: } else {
194: # Input form
195: unless ($home==1) {
196: $r->print(
1.81 www 197: '<h3>'.&mt('Select the Construction Space').'</h3><select name="authorspace">');
1.76 www 198: }
199: foreach (sort keys %outhash) {
200: if ($_=~/^home_(.+)$/) {
201: if ($home==1) {
202: $r->print(
203: '<input type="hidden" name="authorspace" value="'.$1.'" />');
204: } else {
1.133 www 205: $r->print('<option value="'.$1.'">'.$1.' - '.
206: &Apache::loncommon::plainname(split(/\@/,$1)).'</option>');
1.76 www 207: }
208: }
209: }
210: unless ($home==1) {
211: $r->print('</select>');
212: }
213: my $title=$origcrsdata{'description'};
214: $title=~s/\s+/\_/gs;
215: $title=~s/\W//gs;
1.81 www 216: $r->print('<h3>'.&mt('Folder in Construction Space').'</h3><input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
1.76 www 217: &tiehash();
1.81 www 218: $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 219: foreach (&Apache::loncreatecourse::crsdirlist($origcrsid,'userfiles')) {
1.78 www 220: $r->print('<tr><td>'.$_.'</td>');
221: my ($ext)=($_=~/\.(\w+)$/);
222: my $title=$hash{'title_'.$hash{
223: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}};
224: $r->print('<td>'.($title?$title:' ').'</td>');
225: unless ($title) {
226: $title=$_;
227: }
228: $title=~s/\.(\w+)$//;
1.132 www 229: $title=~s/[^\w\/]+/\_/gs;
1.78 www 230: $title.='.'.$ext;
1.79 www 231: $r->print("\n<td><input type='text' size='60' name='namefor_".$_."' value='".$title."' /></td></tr>\n");
1.76 www 232: }
1.78 www 233: $r->print("</table>\n");
1.76 www 234: &untiehash();
235: $r->print(
1.81 www 236: '<p><input type="submit" name="dumpcourse" value="'.&mt('Dump Course DOCS').'" /></p></form>');
1.75 www 237: }
1.74 www 238: }
1.76 www 239:
1.138 raeburn 240: # ------------------------------------------------------ Generate "export" button
241:
242: sub exportbutton {
243: return '</td><td bgcolor="#DDDDCC">'.
244: '<input type="submit" name="exportcourse" value="'.
245: &mt('Export Course to IMS').'" />'.
246: &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs');
247: }
248:
249: sub exportcourse {
250: my $r=shift;
251: my %discussiontime = &Apache::lonnet::dump('discussiontimes',
252: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
253: my $numdisc = keys %discussiontime;
254: my $navmap = Apache::lonnavmaps::navmap->new();
255: my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
256: my $curRes;
257:
258: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
259: ['finishexport']);
260: if ($ENV{'form.finishexport'}) {
261: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
262: ['archive','discussion']);
263:
264: my @exportitems = ();
265: if (defined($ENV{'form.archive'})) {
266: if (ref($ENV{'form.archive'}) eq 'ARRAY') {
267: @exportitems = @{$ENV{'form.archive'}};
268: } else {
269: $exportitems[0] = $ENV{'form.archive'};
270: }
271: }
272: my @discussions = ();
273: if (defined($ENV{'form.discussion'})) {
274: if (ref($ENV{'form.discussion'}) eq 'ARRAY') {
275: @discussions = $ENV{'form.discussion'};
276: } else {
277: $discussions[0] = $ENV{'form.discussion'};
278: }
279: }
280: my $curRes;
281: my $count;
282: my %symbs;
283: my $display;
284: while ($curRes = $it->next()) {
285: if (ref($curRes)) {
286: $count ++;
287: $symbs{$count} = $curRes->symb();
288: if (grep/^$count$/,@exportitems) {
289: $display.= 'Export content item '.$curRes->title()."<br />\n";
290: }
291: if (grep/^$count$/,@discussions) {
292: $display.= 'Export discussion posts '.$curRes->title()."<br />\n";
293: }
294: }
295: }
296:
297: $r->print('<html><head><title>Export Course</title></head>'.
298: &Apache::loncommon::bodytag('Export course to IMS or SCORM content package'
299: ));
300:
301: my $exportfile;
302: $r->print($display);
303: $r->print('</body></html>');
304: } else {
305: my $display;
306: $display = '<form name="exportdoc" method="post">'."\n";
307: $display .= 'Choose which items you wish to export from your course.<br /><br />';
308: $display .= '<table border="0" cellspacing="0" cellpadding="3">'.
309: '<tr><td><fieldset><legend> <b>Content items</b></legend>'.
310: '<input type="button" value="check all" '.
311: 'onclick="javascript:checkAll(document.exportdoc.archive)" />'.
312: ' <input type="button" value="uncheck all"'.
313: ' onclick="javascript:uncheckAll(document.exportdoc.archive)" /></fieldset></td>'.
314: '<td> </td><td> </td>'.
315: '<td align="right"><fieldset><legend> <b>Discussion posts'.
316: '</b></legend><input type="button" value="check all"'.
317: ' onclick="javascript:checkAll(document.exportdoc.discussion)" />'.
318: ' <input type="button" value="uncheck all"'.
319: ' onclick="javascript:uncheckAll(document.exportdoc.discussion)" /></fieldset></td>'.
320: '</tr></table>';
321: my $curRes;
322: my $depth = 0;
323: my $count = 0;
324: my $boards = 0;
325: my $startcount = 5;
326: my %parent = ();
327: my %children = ();
328: my $lastcontainer = $startcount;
329: my @bgcolors = ('#F6F6F6','#FFFFFF');
330: $display .= '<table cellspacing="0"><tr>'.
331: '<td><b>Export content item?<br /></b></td><td> </td><td align="right">'."\n";
332: if ($numdisc > 0) {
333: $display.='<b>Export discussion posts?</b>'."\n";
334: }
335: $display.=' </td></tr>';
336: while ($curRes = $it->next()) {
337: if (ref($curRes)) {
338: $count ++;
339: }
340: if ($curRes == $it->BEGIN_MAP()) {
341: $depth++;
342: $parent{$depth} = $lastcontainer;
343: }
344: if ($curRes == $it->END_MAP()) {
345: $depth--;
346: $lastcontainer = $parent{$depth};
347: }
348: if (ref($curRes)) {
349: my $symb = $curRes->symb();
350: my $color = $count%2;
351: $display .='<tr bgcolor='.$bgcolors[$color].'><td>'."\n".
352: '<input type="checkbox" name="archive" value="'.$count.'" ';
353: if (($curRes->is_sequence()) || ($curRes->is_page())) {
354: my $checkitem = $count + $boards + $startcount;
355: $display .= 'onClick="javascript:propagateCheck('."'$checkitem'".')"';
356: }
357: $display .= ' />'."\n";
358: for (my $i=0; $i<$depth; $i++) {
359: $display .= '<img src="/adm/lonIcons/whitespace1.gif" width="25" height="1" alt="" border="0" /><img src="/adm/lonIcons/whitespace1.gif" width="25" height="1" alt="" border="0" />'."\n";
360: }
361: if ($curRes->is_sequence()) {
362: $display .= '<img src="/adm/lonIcons/navmap.folder.open.gif"> '."\n";
363: $lastcontainer = $count + $startcount + $boards;
364: } elsif ($curRes->is_page()) {
365: $display .= '<img src="/adm/lonIcons/navmap.page.open.gif"> '."\n";
366: $lastcontainer = $count + $startcount + $boards;
367: }
368: my $currelem = $count+$boards+$startcount;
369: $children{$parent{$depth}} .= $currelem.':';
370: $display .= ' '.$curRes->title().'</td>';
371: if ($discussiontime{$symb} > 0) {
372: $boards ++;
373: $currelem = $count+$boards+$startcount;
374: $display .= '<td> </td><td align="right"><input type="checkbox" name="discussion" value="'.$count.'" /> </td>'."\n";
375: } else {
376: $display .= '<td colspan="2"> </td>'."\n";
377: }
378: }
379: }
380: my $scripttag = qq|
381: <script>
382:
383: function checkAll(field) {
384: for (i = 0; i < field.length; i++)
385: field[i].checked = true ;
386: }
387:
388: function uncheckAll(field) {
389: for (i = 0; i < field.length; i++)
390: field[i].checked = false ;
391: }
392:
393: function propagateCheck(item) {
394: if (document.exportdoc.elements[item].checked == true) {
395: containerCheck(item)
396: }
397: }
398:
399: function containerCheck(item) {
400: document.exportdoc.elements[item].checked = true
401: var numitems = $count + $boards + $startcount
402: var parents = new Array(numitems)
403: for (var i=$startcount; i<numitems; i++) {
404: parents[i] = new Array
405: }
406: |;
407:
408: foreach my $container (sort { $a <=> $b } keys %children) {
409: my @contents = split/:/,$children{$container};
410: for (my $i=0; $i<@contents; $i ++) {
411: $scripttag .= ' parents['.$container.']['.$i.'] = '.$contents[$i]."\n";
412: }
413: }
414:
415: $scripttag .= qq|
416: if (parents[item].length > 0) {
417: for (var j=0; j<parents[item].length; j++) {
418: containerCheck(parents[item][j])
419: }
420: }
421: }
422:
423: </script>
424: |;
425: $r->print('<html><head><title>Export Course</title>'.$scripttag.'</head>'.
426: &Apache::loncommon::bodytag('Export course to IMS or SCORM content package'
427: ));
428:
429: $r->print($display.'</table>'.
430: '<p><input type="hidden" name="finishexport" value="1">'.
431: '<input type="submit" name="exportcourse" value="'.
432: &mt('Export Course DOCS').'" /></p></form></body></html>');
433: }
434: }
435:
1.74 www 436:
1.73 bowersj2 437: # Imports the given (name, url) resources into the course
438: # coursenum, coursedom, and folder must precede the list
439: sub group_import {
440: my $coursenum = shift;
441: my $coursedom = shift;
442: my $folder = shift;
443: while (@_) {
444: my $name = shift;
445: my $url = shift;
446: if ($url) {
447: my $idx = $#Apache::lonratedt::resources + 1;
448: $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=$idx;
449: my $ext = 'false';
450: if ($url=~/^http:\/\//) { $ext = 'true'; }
451: $url =~ s/:/\:/g;
452: $name =~ s/:/\:/g;
453: $Apache::lonratedt::resources[$idx] =
454: join ':', ($name, $url, $ext, 'normal', 'res');
455: }
456: }
1.104 albertel 457: return &storemap($coursenum, $coursedom, $folder.'.sequence');
1.73 bowersj2 458: }
459:
1.114 albertel 460: sub breadcrumbs {
461: my ($where)=@_;
462: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.116 albertel 463: my (@folders)=split('&',$ENV{'form.folderpath'});
464: my $folderpath;
465: while (@folders) {
466: my $folder=shift(@folders);
467: my $foldername=shift(@folders);
468: if ($folderpath) {$folderpath.='&';}
469: $folderpath.=$folder.'&'.$foldername;
470: my $url='/adm/coursedocs?folderpath='.
471: &Apache::lonnet::escape($folderpath);
1.114 albertel 472: &Apache::lonhtmlcommon::add_breadcrumb(
473: {'href'=>$url,
474: 'title'=>&Apache::lonnet::unescape($foldername),
1.117 albertel 475: 'text'=>'<font size="+1">'.
476: &Apache::lonnet::unescape($foldername).'</font>'
477: });
1.114 albertel 478:
479:
480: }
1.137 albertel 481: return &Apache::lonhtmlcommon::breadcrumbs(undef,undef,undef,undef,undef,
482: 0,'nohelp');
1.114 albertel 483: }
484:
1.7 www 485: sub editor {
486: my ($r,$coursenum,$coursedom,$folder,$allowed)=@_;
1.114 albertel 487:
488: $r->print(&breadcrumbs($folder));
1.10 www 489: my $errtext='';
490: my $fatal=0;
491: ($errtext,$fatal)=
1.7 www 492: &mapread($coursenum,$coursedom,$folder.'.sequence');
1.17 www 493: if ($#Apache::lonratedt::order<1) {
494: $Apache::lonratedt::order[0]=1;
495: $Apache::lonratedt::resources[1]='';
496: }
1.7 www 497: if ($fatal) {
498: $r->print('<p><font color="red">'.$errtext.'</font></p>');
499: } else {
500: # ------------------------------------------------------------ Process commands
1.121 www 501:
1.16 www 502: # ---------------- if they are for this folder and user allowed to make changes
503: if (($allowed) && ($ENV{'form.folder'} eq $folder)) {
1.123 www 504: # set parameters and change order
1.121 www 505: if (defined($ENV{'form.setparms'})) {
506: my $idx=$ENV{'form.setparms'};
1.123 www 507: # set parameters
1.121 www 508: if ($ENV{'form.randpick_'.$idx}) {
1.122 www 509: &Apache::lonratedt::storeparameter($idx,'parameter_randompick',$ENV{'form.randpick_'.$idx},'int_pos');
1.121 www 510: } else {
1.122 www 511: &Apache::lonratedt::delparameter($idx,'parameter_randompick');
1.121 www 512: }
513: if ($ENV{'form.hidprs_'.$idx}) {
1.122 www 514: &Apache::lonratedt::storeparameter($idx,'parameter_hiddenresource','yes','string_yesno');
1.121 www 515: } else {
1.122 www 516: &Apache::lonratedt::delparameter($idx,'parameter_hiddenresource');
1.121 www 517: }
518: if ($ENV{'form.encprs_'.$idx}) {
1.122 www 519: &Apache::lonratedt::storeparameter($idx,'parameter_encrypturl','yes','string_yesno');
1.121 www 520: } else {
1.122 www 521: &Apache::lonratedt::delparameter($idx,'parameter_encrypturl');
1.121 www 522: }
523:
1.123 www 524: if ($ENV{'form.newpos'}) {
525: # change order
526:
527: my $newpos=$ENV{'form.newpos'}-1;
1.124 www 528: my $currentpos=$ENV{'form.currentpos'}-1;
1.125 www 529: my $i;
530: my @neworder=();
531: if ($newpos>$currentpos) {
532: # moving stuff up
533: for ($i=0;$i<$currentpos;$i++) {
534: $neworder[$i]=$Apache::lonratedt::order[$i];
535: }
536: for ($i=$currentpos;$i<$newpos;$i++) {
537: $neworder[$i]=$Apache::lonratedt::order[$i+1];
538: }
539: $neworder[$newpos]=$Apache::lonratedt::order[$currentpos];
540: for ($i=$newpos+1;$i<=$#Apache::lonratedt::order;$i++) {
541: $neworder[$i]=$Apache::lonratedt::order[$i];
542: }
543: } else {
544: # moving stuff down
545: for ($i=0;$i<$newpos;$i++) {
546: $neworder[$i]=$Apache::lonratedt::order[$i];
547: }
548: $neworder[$newpos]=$Apache::lonratedt::order[$currentpos];
549: for ($i=$newpos+1;$i<$currentpos+1;$i++) {
550: $neworder[$i]=$Apache::lonratedt::order[$i-1];
551: }
552: for ($i=$currentpos+1;$i<=$#Apache::lonratedt::order;$i++) {
553: $neworder[$i]=$Apache::lonratedt::order[$i];
554: }
555: }
556: @Apache::lonratedt::order=@neworder;
1.124 www 557: }
558: # store the changed version
1.123 www 559:
1.124 www 560: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.sequence');
561: if ($fatal) {
562: $r->print('<p><font color="red">'.$errtext.'</font></p>');
563: return;
1.123 www 564: }
1.124 www 565:
566: }
1.123 www 567:
1.10 www 568: # upload a file, if present
569: if (($ENV{'form.uploaddoc.filename'}) &&
570: ($ENV{'form.cmd'}=~/^upload_(\w+)/)) {
1.112 raeburn 571: if ( ($folder=~/^$1/) || ($1 eq 'default') ) {
1.10 www 572: # this is for a course, not a user, so set coursedoc flag
573: # probably the only place in the system where this should be "1"
1.126 albertel 574: my $url=&Apache::lonnet::userfileupload('uploaddoc',1,'docs');
1.10 www 575: my $ext='false';
576: if ($url=~/^http\:\/\//) { $ext='true'; }
577: $url=~s/\:/\:/g;
578: my $comment=$ENV{'form.comment'};
579: $comment=~s/\</\<\;/g;
580: $comment=~s/\>/\>\;/g;
581: $comment=~s/\:/\:/g;
1.17 www 582: if ($folder=~/^supplemental/) {
583: $comment=time.'___&&&___'.$ENV{'user.name'}.'___&&&___'.
584: $ENV{'user.domain'}.'___&&&___'.$comment;
585: }
1.10 www 586: my $newidx=$#Apache::lonratedt::resources+1;
587: $Apache::lonratedt::resources[$newidx]=
588: $comment.':'.$url.':'.$ext.':normal:res';
589: $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=
590: $newidx;
1.104 albertel 591:
592: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.sequence');
593: if ($fatal) {
594: $r->print('<p><font color="red">'.$errtext.'</font></p>');
595: return;
596: }
1.10 www 597: }
598: }
1.8 www 599: if ($ENV{'form.cmd'}) {
1.10 www 600: my ($cmd,$idx)=split(/\_/,$ENV{'form.cmd'});
601: if ($cmd eq 'del') {
1.128 albertel 602: my (undef,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]);
603: if ($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) {
604: &Apache::lonnet::removeuploadedurl($url);
605: }
1.10 www 606: for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) {
607: $Apache::lonratedt::order[$i]=
608: $Apache::lonratedt::order[$i+1];
609: }
610: $#Apache::lonratedt::order--;
611: } elsif ($cmd eq 'up') {
1.38 www 612: if (($idx) && (defined($Apache::lonratedt::order[$idx-1]))) {
1.10 www 613: my $i=$Apache::lonratedt::order[$idx-1];
614: $Apache::lonratedt::order[$idx-1]=
615: $Apache::lonratedt::order[$idx];
616: $Apache::lonratedt::order[$idx]=$i;
1.38 www 617: }
1.10 www 618: } elsif ($cmd eq 'down') {
1.38 www 619: if (defined($Apache::lonratedt::order[$idx+1])) {
1.10 www 620: my $i=$Apache::lonratedt::order[$idx+1];
621: $Apache::lonratedt::order[$idx+1]=
622: $Apache::lonratedt::order[$idx];
623: $Apache::lonratedt::order[$idx]=$i;
1.38 www 624: }
1.36 www 625: } elsif ($cmd eq 'rename') {
626: my ($rtitle,@rrest)=split(/\:/,
627: $Apache::lonratedt::resources[
628: $Apache::lonratedt::order[$idx]]);
1.38 www 629: my $comment=
630: &HTML::Entities::decode($ENV{'form.title'});
1.36 www 631: $comment=~s/\</\<\;/g;
632: $comment=~s/\>/\>\;/g;
633: $comment=~s/\:/\:/g;
634: $Apache::lonratedt::resources[
635: $Apache::lonratedt::order[$idx]]=
636: $comment.':'.join(':',@rrest);
637:
1.10 www 638: }
639: # Store the changed version
1.104 albertel 640: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
641: $folder.'.sequence');
642: if ($fatal) {
643: $r->print('<p><font color="red">'.$errtext.'</font></p>');
644: return;
645: }
1.8 www 646: }
1.11 www 647: # Group import/search
648: if ($ENV{'form.importdetail'}) {
1.73 bowersj2 649: my @imports;
650: foreach (split(/\&/,$ENV{'form.importdetail'})) {
651: if (defined($_)) {
652: my ($name,$url)=split(/\=/,$_);
653: $name=&Apache::lonnet::unescape($name);
654: $url=&Apache::lonnet::unescape($url);
655: push @imports, $name, $url;
656: }
657: }
1.11 www 658: # Store the changed version
1.104 albertel 659: ($errtext,$fatal)=group_import($coursenum, $coursedom, $folder,
660: @imports);
661: if ($fatal) {
662: $r->print('<p><font color="red">'.$errtext.'</font></p>');
663: return;
664: }
1.11 www 665: }
1.53 www 666: # Loading a complete map
667: if (($ENV{'form.importmap'}) && ($ENV{'form.loadmap'})) {
1.104 albertel 668: foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$ENV{'form.importmap'}))) {
1.53 www 669: my $idx=$#Apache::lonratedt::resources;
670: $idx++;
671: $Apache::lonratedt::resources[$idx]=$_;
672: $Apache::lonratedt::order
1.104 albertel 673: [$#Apache::lonratedt::order+1]=$idx;
674: }
1.53 www 675:
676: # Store the changed version
1.104 albertel 677: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
678: $folder.'.sequence');
679: if ($fatal) {
680: $r->print('<p><font color="red">'.$errtext.'</font></p>');
681: return;
682: }
1.53 www 683: }
1.16 www 684: }
685: # ---------------------------------------------------------------- End commands
1.7 www 686: # ---------------------------------------------------------------- Print screen
1.10 www 687: my $idx=0;
688: $r->print('<table>');
689: foreach (@Apache::lonratedt::order) {
690: my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]);
691: unless ($name) { $name=(split(/\//,$url))[-1]; }
1.106 www 692: unless ($name) { next; }
1.112 raeburn 693: $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum));
1.10 www 694: $idx++;
695: }
1.131 www 696: unless ($idx) {
697: $r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>');
698: }
1.10 www 699: $r->print('</table>');
1.7 www 700: }
701: }
1.1 www 702:
1.8 www 703: # --------------------------------------------------------------- An entry line
704:
705: sub entryline {
1.112 raeburn 706: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;
1.38 www 707: $title=~s/\&colon\;/\:/g;
708: $title=&HTML::Entities::encode(&HTML::Entities::decode(
1.109 albertel 709: &Apache::lonnet::unescape($title)),'"<>&\'');
1.38 www 710: my $renametitle=$title;
711: my $foldertitle=$title;
1.122 www 712: my $orderidx=$Apache::lonratedt::order[$index];
1.109 albertel 713: if ($title=~ /^(\d+)___&&&___(\w+)___&&&___(\w+)___&&&___(.*)$/ ) {
714: $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
715: $renametitle=$4;
716: $title='<i>'.&Apache::lonlocal::locallocaltime($1).'</i> '.
717: &Apache::loncommon::plainname($2,$3).': <br />'.
718: $foldertitle;
719: }
1.38 www 720: $renametitle=~s/\"\;/\\\"/g;
1.8 www 721: my $line='<tr>';
722: # Edit commands
1.120 www 723: my $folderpath;
724: if ($ENV{'form.folderpath'}) {
725: $folderpath=&Apache::lonnet::escape($ENV{'form.folderpath'});
726: # $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'},'<>&"');
727: }
1.109 albertel 728: if ($allowed) {
1.123 www 729: my $incindex=$index+1;
730: my $selectbox='';
731: if ($folder!~/^supplemental/) {
732: $selectbox=
1.124 www 733: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.123 www 734: '<select name="newpos" onChange="this.form.submit()">';
735: for (my $i=1;$i<=$#Apache::lonratedt::order+1;$i++) {
736: if ($i==$incindex) {
737: $selectbox.='<option value="" selected="1">('.$i.')</option>';
738: } else {
739: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
740: }
741: }
742: $selectbox.='</select>';
743: }
1.119 www 744: my %lt=&Apache::lonlocal::texthash(
745: 'up' => 'Move Up',
1.109 albertel 746: 'dw' => 'Move Down',
747: 'rm' => 'Remove',
748: 'rn' => 'Rename');
749: $line.=(<<END);
1.121 www 750: <form name="entry_$index" action="/adm/coursedocs" method="post">
751: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.122 www 752: <input type="hidden" name="setparms" value="$orderidx" />
1.54 www 753: <td><table border='0' cellspacing='2' cellpadding='0'>
754: <tr><td bgcolor="#DDDDDD">
1.115 albertel 755: <a href='/adm/coursedocs?cmd=up_$index&folderpath=$folderpath'>
1.90 www 756: <img src="${iconpath}move_up.gif" alt='$lt{'up'}' border='0' /></a></td></tr>
1.54 www 757: <tr><td bgcolor="#DDDDDD">
1.115 albertel 758: <a href='/adm/coursedocs?cmd=down_$index&folderpath=$folderpath'>
1.90 www 759: <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' border='0' /></a></td></tr>
1.123 www 760: </table></td>
761: <td>$selectbox
762: </td><td bgcolor="#DDDDDD">
1.115 albertel 763: <a href='javascript:removeres("$folderpath","$index","$renametitle");'>
1.90 www 764: <font size="-2" color="#990000">$lt{'rm'}</font></a>
1.115 albertel 765: <a href='javascript:changename("$folderpath","$index","$renametitle");'>
1.90 www 766: <font size="-2" color="#009900">$lt{'rn'}</font></a></td>
1.8 www 767: END
768: }
1.16 www 769: # Figure out what kind of a resource this is
770: my ($extension)=($url=~/\.(\w+)$/);
771: my $uploaded=($url=~/^\/*uploaded\//);
1.97 albertel 772: my $icon=&Apache::loncommon::icon($url);
1.17 www 773: my $isfolder=0;
1.114 albertel 774: my $folderarg;
1.16 www 775: if ($uploaded) {
1.135 albertel 776: if ($extension eq 'sequence') {
777: $icon=$iconpath.'/folder_closed.gif';
778: $url=~/$coursenum\/([\/\w]+)\.sequence$/;
779: $url='/adm/coursedocs?';
780: $folderarg=$1;
781: $isfolder=1;
782: } else {
783: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
784: }
1.16 www 785: }
1.18 www 786: $url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//;
1.113 albertel 787: if ((!$isfolder) && ($residx) && ($folder!~/supplemental/)) {
788: my $symb=&Apache::lonnet::symbclean(
1.50 www 789: &Apache::lonnet::declutter('uploaded/'.
790: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.'/'.
791: $ENV{'course.'.$ENV{'request.course.id'}.'.num'}.'/'.$folder.
792: '.sequence').
793: '___'.$residx.'___'.
1.113 albertel 794: &Apache::lonnet::declutter($url));
795: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
796: $url=&Apache::lonnet::clutter($url);
1.127 albertel 797: if ($url=~/^\/*uploaded\//) {
798: $url=~/\.(\w+)$/;
799: my $embstyle=&Apache::loncommon::fileembstyle($1);
800: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
801: $url='/adm/wrapper'.$url;
802: } elsif ($embstyle eq 'ssi') {
803: #do nothing with these
804: } elsif ($url!~/\.(sequence|page)$/) {
805: $url='/adm/coursedocs/showdoc'.$url;
806: }
807: }
1.113 albertel 808: $url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb);
1.50 www 809: }
1.120 www 810: my $parameterset=' ';
1.114 albertel 811: if ($isfolder) {
812: my $foldername=&Apache::lonnet::escape($foldertitle);
813: my $folderpath=$ENV{'form.folderpath'};
814: if ($folderpath) { $folderpath.='&' };
815: $folderpath.=$folderarg.'&'.$foldername;
816: $url.='folderpath='.&Apache::lonnet::escape($folderpath);
1.120 www 817: $parameterset=&mt('Randomly Pick: ').
1.122 www 818: '<input type="text" size="4" name="randpick_'.$orderidx.'" value="'.
819: (&Apache::lonratedt::getparameter($orderidx,'parameter_randompick'))[0].'" />';
1.114 albertel 820: }
1.113 albertel 821: $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'"><img src="'.$icon.
822: '" border="0"></a></td>'.
1.119 www 823: "<td bgcolor='#FFFFBB'><a href='$url'>$title</a></td>";
1.120 www 824: if (($allowed) && ($folder!~/^supplemental/)) {
825: my %lt=&Apache::lonlocal::texthash(
826: 'hd' => 'Hidden',
827: 'ec' => 'URL hidden',
828: 'sp' => 'Store Parameters');
1.122 www 829: my $enctext=
830: ((&Apache::lonratedt::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="1"':'');
831: my $hidtext=
832: ((&Apache::lonratedt::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':'');
1.120 www 833: $line.=(<<ENDPARMS);
834: <td bgcolor="#BBBBFF"><font size='-2'>
1.122 www 835: <input type="checkbox" name="hidprs_$orderidx" $hidtext/> $lt{'hd'}</td>
1.139 ! albertel 836: <!--<td bgcolor="#BBBBFF"><font size='-2'>
! 837: <input type="checkbox" name="encprs_$orderidx" $enctext/> $lt{'ec'}</td>-->
1.120 www 838: <td bgcolor="#BBBBFF"><font size="-2">$parameterset</font></td>
839: <td bgcolor="#BBBBFF"><font size='-2'>
1.121 www 840: <input type="submit" value="$lt{'sp'}" />
1.120 www 841: </font></td>
842: ENDPARMS
1.119 www 843: }
1.120 www 844: $line.="</form></tr>";
1.8 www 845: return $line;
846: }
847:
1.27 www 848: # ---------------------------------------------------------------- tie the hash
849:
850: sub tiehash {
1.136 albertel 851: my ($mode)=@_;
1.27 www 852: $hashtied=0;
853: if ($ENV{'request.course.fn'}) {
1.136 albertel 854: if ($mode eq 'write') {
855: if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
856: &GDBM_WRCREAT(),0640)) {
857: $hashtied=2;
858: }
859: } else {
860: if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
861: &GDBM_READER(),0640)) {
1.27 www 862: $hashtied=1;
1.136 albertel 863: }
864: }
1.27 www 865: }
866: }
867:
868: sub untiehash {
869: if ($hashtied) { untie %hash; }
870: $hashtied=0;
871: }
872:
1.29 www 873: # --------------------------------------------------------------- check on this
874:
875: sub checkonthis {
876: my ($r,$url,$level,$title)=@_;
877: $alreadyseen{$url}=1;
878: $r->rflush();
1.41 www 879: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
1.108 albertel 880: $r->print("\n<br />");
1.29 www 881: for (my $i=0;$i<=$level*5;$i++) {
882: $r->print(' ');
883: }
884: $r->print('<a href="'.$url.'" target="cat">'.
885: ($title?$title:$url).'</a> ');
886: if ($url=~/^\/res\//) {
887: my $result=&Apache::lonnet::repcopy(
888: &Apache::lonnet::filelocation('',$url));
889: if ($result==OK) {
1.87 www 890: $r->print('<font color="green">'.&mt('ok').'</font>');
1.29 www 891: $r->rflush();
1.34 www 892: &Apache::lonnet::countacc($url);
893: $url=~/\.(\w+)$/;
894: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
895: $r->print('<br />');
896: $r->rflush();
897: for (my $i=0;$i<=$level*5;$i++) {
898: $r->print(' ');
899: }
1.84 www 900: $r->print('- '.&mt('Rendering').': ');
1.69 albertel 901: my $oldpath=$ENV{'request.filename'};
902: $ENV{'request.filename'}=&Apache::lonnet::filelocation('',$url);
1.34 www 903: &Apache::lonxml::xmlparse($r,'web',
904: &Apache::lonnet::getfile(
1.35 albertel 905: &Apache::lonnet::filelocation('',$url)));
1.94 www 906: undef($Apache::lonhomework::parsing_a_problem);
1.69 albertel 907: $ENV{'request.filename'}=$oldpath;
1.34 www 908: if (($Apache::lonxml::errorcount) ||
909: ($Apache::lonxml::warningcount)) {
910: if ($Apache::lonxml::errorcount) {
1.98 www 911: $r->print('<img src="/adm/lonMisc/bomb.gif" /><font color="red"><b>'.
1.87 www 912: $Apache::lonxml::errorcount.' '.
913: &mt('error(s)').'</b></font> ');
1.34 www 914: }
915: if ($Apache::lonxml::warningcount) {
916: $r->print('<font color="blue">'.
1.84 www 917: $Apache::lonxml::warningcount.' '.
918: &mt('warning(s)').'</font>');
1.34 www 919: }
920: } else {
1.87 www 921: $r->print('<font color="green">'.&mt('ok').'</font>');
1.34 www 922: }
923: $r->rflush();
924: }
1.29 www 925: my $dependencies=
926: &Apache::lonnet::metadata($url,'dependencies');
927: foreach (split(/\,/,$dependencies)) {
928: if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {
929: &checkonthis($r,$_,$level+1);
930: }
931: }
932: } elsif ($result==HTTP_SERVICE_UNAVAILABLE) {
1.84 www 933: $r->print('<font color="red"><b>'.&mt('connection down').'</b></font>');
1.29 www 934: } elsif ($result==HTTP_NOT_FOUND) {
1.100 www 935: unless ($url=~/\$/) {
936: $r->print('<font color="red"><b>'.&mt('not found').'</b></font>');
937: } else {
938: $r->print('<font color="yellow"><b>'.&mt('unable to verify variable URL').'</b></font>');
939: }
1.29 www 940: } else {
1.84 www 941: $r->print('<font color="red"><b>'.&mt('access denied').'</b></font>');
1.29 www 942: }
943: }
944: }
945: }
946:
1.1 www 947:
1.75 www 948: #
949: # -------------------------------------------------------------- Verify Content
950: #
951: sub verifycontent {
952: my $r=shift;
1.26 www 953: my $loaderror=&Apache::lonnet::overloaderror($r);
954: if ($loaderror) { return $loaderror; }
955:
956: $r->print('<html><head><title>Verify Content</title></head>'.
957: &Apache::loncommon::bodytag('Verify Course Documents'));
1.27 www 958: $hashtied=0;
1.30 www 959: undef %alreadyseen;
960: %alreadyseen=();
1.27 www 961: &tiehash();
962: foreach (keys %hash) {
1.28 www 963: if (($_=~/^src\_(.+)$/) && (!$alreadyseen{$hash{$_}})) {
1.29 www 964: &checkonthis($r,$hash{$_},0,$hash{'title_'.$1});
1.27 www 965: }
966: }
967: &untiehash();
1.108 albertel 968: $r->print('<h1>'.&mt('Done').'.</h1>'.'<a href="/adm/coursedocs">'.
969: &mt('Return to DOCS').'</a>');
1.75 www 970: }
971:
972: # -------------------------------------------------------------- Check Versions
973:
974: sub checkversions {
975: my $r=shift;
1.89 www 976: $r->print('<html><head><title>Check Versions</title></head>'.
1.26 www 977: &Apache::loncommon::bodytag('Check Course Document Versions'));
1.89 www 978: my $header='';
979: my $startsel='';
980: my $monthsel='';
981: my $weeksel='';
982: my $daysel='';
983: my $allsel='';
984: my %changes=();
985: my $starttime=0;
1.91 www 986: my $haschanged=0;
1.92 www 987: my %setversions=&Apache::lonnet::dump('resourceversions',
988: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
989: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
990:
991: $hashtied=0;
992: &tiehash();
993: my %newsetversions=();
1.91 www 994: if ($ENV{'form.setmostrecent'}) {
995: $haschanged=1;
1.92 www 996: foreach (keys %hash) {
997: if ($_=~/^ids\_(\/res\/.+)$/) {
1.93 www 998: $newsetversions{$1}='mostrecent';
1.92 www 999: }
1000: }
1.91 www 1001: } elsif ($ENV{'form.setcurrent'}) {
1002: $haschanged=1;
1.92 www 1003: foreach (keys %hash) {
1004: if ($_=~/^ids\_(\/res\/.+)$/) {
1.93 www 1005: my $getvers=&Apache::lonnet::getversion($1);
1006: if ($getvers>0) {
1007: $newsetversions{$1}=$getvers;
1008: }
1.92 www 1009: }
1010: }
1.91 www 1011: } elsif ($ENV{'form.setversions'}) {
1012: $haschanged=1;
1.92 www 1013: foreach (keys %ENV) {
1014: if ($_=~/^form\.set_version_(.+)$/) {
1015: my $src=$1;
1016: if (($ENV{$_}) && ($ENV{$_} ne $setversions{$src})) {
1017: $newsetversions{$src}=$ENV{$_};
1018: }
1019: }
1020: }
1.91 www 1021: }
1022: if ($haschanged) {
1.92 www 1023: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
1024: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1025: $ENV{'course.'.$ENV{'request.course.id'}.'.num'}) eq 'ok') {
1026: $r->print('<h1>'.&mt('Your Version Settings have been Stored').'</h1>');
1027: } else {
1028: $r->print('<h1><font color="red">'.&mt('An Error Occured while Attempting to Store your Version Settings').'</font></h1>');
1029: }
1.136 albertel 1030: &mark_hash_old();
1.91 www 1031: }
1.136 albertel 1032: &changewarning($r,'');
1.89 www 1033: if ($ENV{'form.timerange'} eq 'all') {
1034: # show all documents
1035: $header=&mt('All Documents in Course');
1.91 www 1036: $allsel=1;
1.90 www 1037: foreach (keys %hash) {
1038: if ($_=~/^ids\_(\/res\/.+)$/) {
1039: my $src=$1;
1040: $changes{$src}=1;
1041: }
1042: }
1.89 www 1043: } else {
1044: # show documents which changed
1045: %changes=&Apache::lonnet::dump
1046: ('versionupdate',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1.30 www 1047: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.89 www 1048: my $firstkey=(keys %changes)[0];
1049: unless ($firstkey=~/^error\:/) {
1050: unless ($ENV{'form.timerange'}) {
1051: $ENV{'form.timerange'}=604800;
1052: }
1053: my $seltext=&mt('during the last').' '.$ENV{'form.timerange'}.' '
1054: .&mt('seconds');
1055: if ($ENV{'form.timerange'}==-1) {
1056: $seltext='since start of course';
1057: $startsel='selected';
1058: $ENV{'form.timerange'}=time;
1059: }
1060: $starttime=time-$ENV{'form.timerange'};
1061: if ($ENV{'form.timerange'}==2592000) {
1062: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1063: $monthsel='selected';
1064: } elsif ($ENV{'form.timerange'}==604800) {
1065: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1066: $weeksel='selected';
1067: } elsif ($ENV{'form.timerange'}==86400) {
1068: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1069: $daysel='selected';
1070: }
1071: $header=&mt('Content changed').' '.$seltext;
1072: } else {
1073: $header=&mt('No content modifications yet.');
1074: }
1075: }
1.92 www 1076: %setversions=&Apache::lonnet::dump('resourceversions',
1077: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1078: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.89 www 1079: my %lt=&Apache::lonlocal::texthash
1.88 www 1080: ('st' => 'Version changes since start of Course',
1081: 'lm' => 'Version changes since last Month',
1082: 'lw' => 'Version changes since last Week',
1083: 'sy' => 'Version changes since Yesterday',
1.91 www 1084: 'al' => 'All Resources (possibly large output)',
1.88 www 1085: 'sd' => 'Display',
1.84 www 1086: 'fi' => 'File',
1087: 'md' => 'Modification Date',
1.87 www 1088: 'mr' => 'Most recently published Version',
1089: 've' => 'Version used in Course',
1.91 www 1090: 'vu' => 'Set Version to be used in Course',
1091: 'sv' => 'Set Versions to be used in Course according to Selections below',
1092: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
1093: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.84 www 1094: 'di' => 'Differences');
1.89 www 1095: $r->print(<<ENDHEADERS);
1.31 www 1096: <form action="/adm/coursedocs" method="post">
1.91 www 1097: <input type="hidden" name="versions" value="1" />
1098: <input type="submit" name="setmostrecent" value="$lt{'sm'}" />
1099: <input type="submit" name="setcurrent" value="$lt{'sc'}" /><hr />
1.31 www 1100: <select name="timerange">
1.88 www 1101: <option value='all' $allsel>$lt{'al'}</option>
1.84 www 1102: <option value="-1" $startsel>$lt{'st'}</option>
1103: <option value="2592000" $monthsel>$lt{'lm'}</option>
1104: <option value="604800" $weeksel>$lt{'lw'}</option>
1105: <option value="86400" $daysel>$lt{'sy'}</option>
1.31 www 1106: </select>
1.91 www 1107: <input type="submit" name="display" value="$lt{'sd'}" />
1.89 www 1108: <h3>$header</h3>
1.91 www 1109: <input type="submit" name="setversions" value="$lt{'sv'}" />
1.103 matthew 1110: <table border="0">
1.31 www 1111: ENDHEADERS
1.91 www 1112: foreach (sort keys %changes) {
1.89 www 1113: if ($changes{$_}>$starttime) {
1114: my ($root,$extension)=($_=~/^(.*)\.(\w+)$/);
1115: my $currentversion=&Apache::lonnet::getversion($_);
1.93 www 1116: if ($currentversion<0) {
1117: $currentversion=&mt('Could not be determined.');
1118: }
1.89 www 1119: my $linkurl=&Apache::lonnet::clutter($_);
1120: $r->print(
1.103 matthew 1121: '<tr><td colspan="5"><br /><br /><font size="+1"><b>'.
1.91 www 1122: &Apache::lonnet::gettitle($linkurl).
1.103 matthew 1123: '</b></font></td></tr>'.
1124: '<tr><td> </td>'.
1125: '<td colspan="4">'.
1126: '<a href="'.$linkurl.'" target="cat">'.$linkurl.
1127: '</a></td></tr>'.
1128: '<tr><td></td>'.
1129: '<td title="'.$lt{'md'}.'">'.
1.102 matthew 1130: &Apache::lonlocal::locallocaltime(
1131: &Apache::lonnet::metadata($root.'.'.$extension,
1132: 'lastrevisiondate')
1133: ).
1.103 matthew 1134: '</td>'.
1135: '<td title="'.$lt{'mr'}.'"><nobr>Most Recent: '.
1136: '<font size="+1">'.$currentversion.'</font>'.
1137: '</nobr></td>'.
1138: '<td title="'.$lt{'ve'}.'"><nobr>In Course: '.
1139: '<font size="+1">');
1.87 www 1140: # Used in course
1.89 www 1141: my $usedversion=$hash{'version_'.$linkurl};
1.93 www 1142: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.89 www 1143: $r->print($usedversion);
1144: } else {
1145: $r->print($currentversion);
1146: }
1.103 matthew 1147: $r->print('</font></nobr></td><td title="'.$lt{'vu'}.'">'.
1148: '<nobr>Use: ');
1.87 www 1149: # Set version
1.92 www 1150: $r->print(&Apache::loncommon::select_form($setversions{$linkurl},
1.89 www 1151: 'set_version_'.$linkurl,
1.136 albertel 1152: ('select_form_order' =>
1153: ['',1..$currentversion,'mostrecent'],
1154: '' => '',
1.93 www 1155: 'mostrecent' => 'most recent',
1.89 www 1156: map {$_,$_} (1..$currentversion))));
1.103 matthew 1157: $r->print('</nobr></td></tr><tr><td></td>');
1.89 www 1158: my $lastold=1;
1159: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
1160: my $url=$root.'.'.$prevvers.'.'.$extension;
1161: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
1162: $starttime) {
1163: $lastold=$prevvers;
1164: }
1165: }
1.103 matthew 1166: #
1167: # Code to figure out how many version entries should go in
1168: # each of the four columns
1169: my $entries_per_col = 0;
1170: my $num_entries = ($currentversion-$lastold);
1171: if ($num_entries % 4 == 0) {
1172: $entries_per_col = $num_entries/4;
1173: } else {
1174: $entries_per_col = $num_entries/4 + 1;
1175: }
1176: my $entries_count = 0;
1177: $r->print('<td valign="top"><font size="-2">');
1178: my $cols_output = 1;
1.32 www 1179: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
1.89 www 1180: my $url=$root.'.'.$prevvers.'.'.$extension;
1.103 matthew 1181: $r->print('<nobr><a href="'.&Apache::lonnet::clutter($url).
1.91 www 1182: '">'.&mt('Version').' '.$prevvers.'</a> ('.
1.103 matthew 1183: &Apache::lonlocal::locallocaltime(
1184: &Apache::lonnet::metadata($url,
1185: 'lastrevisiondate')
1186: ).
1.91 www 1187: ')');
1.89 www 1188: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
1.33 www 1189: $r->print(' <a href="/adm/diff?filename='.
1.89 www 1190: &Apache::lonnet::clutter($root.'.'.$extension).
1191: '&versionone='.$prevvers.
1192: '">'.&mt('Diffs').'</a>');
1193: }
1.103 matthew 1194: $r->print('</nobr><br />');
1195: if (++$entries_count % $entries_per_col == 0) {
1196: $r->print('</font></td>');
1197: if ($cols_output != 4) {
1198: $r->print('<td valign="top"><font size="-2">');
1199: $cols_output++;
1200: }
1201: }
1.89 www 1202: }
1.103 matthew 1203: while($cols_output++ < 4) {
1204: $r->print('</font></td><td><font>')
1205: }
1206: $r->print('</font></td></tr>'."\n");
1.89 www 1207: }
1208: }
1.92 www 1209: $r->print('</table></form>');
1.89 www 1210: $r->print('<h1>'.&mt('Done').'.</h1>');
1211:
1212: &untiehash();
1.75 www 1213: }
1214:
1.136 albertel 1215: sub mark_hash_old {
1216: my $retie_hash=0;
1217: if ($hashtied) {
1218: $retie_hash=1;
1219: &untiehash();
1220: }
1221: &tiehash('write');
1222: $hash{'old'}=1;
1223: &untiehash();
1224: if ($retie_hash) { &tiehash(); }
1225: }
1226:
1227: sub is_hash_old {
1228: my $untie_hash=0;
1229: if (!$hashtied) {
1230: $untie_hash=1;
1231: &tiehash();
1232: }
1233: my $return=$hash{'old'};
1234: if ($untie_hash) { &untiehash(); }
1235: return $return;
1236: }
1237:
1.91 www 1238: sub changewarning {
1239: my ($r,$postexec)=@_;
1.136 albertel 1240: if (!&is_hash_old()) { return; }
1.91 www 1241: $r->print(
1242: '<script>function reinit(tf) { tf.submit();'.$postexec.' }</script>'.
1243: '<form method="post" action="/adm/roles" target="loncapaclient">'.
1.117 albertel 1244: '<input type="hidden" name="orgurl" value="/adm/coursedocs?folderpath='.
1245: &Apache::lonnet::escape($ENV{'form.folderpath'}).
1246: '" /><input type="hidden" name="selectrole" value="1" /><h3><font color="red">'.
1.91 www 1247: &mt('Changes will become active for your current session after').
1248: ' <input type="hidden" name="'.
1249: $ENV{'request.role'}.'" value="1" /><input type="button" value="'.
1250: &mt('re-initializing course').'" onClick="reinit(this.form)"/>'.&mt(', or the next time you log in.').
1251: $help{'Caching'}.'</font></h3></form>');
1252: }
1253:
1.75 www 1254: # ================================================================ Main Handler
1255: sub handler {
1256: my $r = shift;
1.82 www 1257: &Apache::loncommon::content_type($r,'text/html');
1.75 www 1258: $r->send_http_header;
1259: return OK if $r->header_only;
1260:
1261: # --------------------------------------------- Initialize help topics for this
1262: foreach ('Adding_Course_Doc','Main_Course_Documents',
1263: 'Adding_External_Resource','Navigate_Content',
1264: 'Adding_Folders','Docs_Overview', 'Load_Map',
1265: 'Supplemental', 'Score_Upload_Form',
1.130 www 1266: 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
1267: 'Check_Resource_Versions','Verify_Content') {
1.75 www 1268: $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);
1269: }
1270: # Composite help files
1271: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
1272: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
1273: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
1274: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
1.86 albertel 1275: $help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
1276: 'Option_Response_Simple');
1.75 www 1277: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
1278: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1279: $help{'My Personal Info'} = &Apache::loncommon::help_open_topic(
1280: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1281: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1282:
1283: if ($ENV{'form.verify'}) {
1284: &verifycontent($r);
1285: } elsif ($ENV{'form.versions'}) {
1286: &checkversions($r);
1287: } elsif ($ENV{'form.dumpcourse'}) {
1288: &dumpcourse($r);
1.138 raeburn 1289: } elsif ($ENV{'form.exportcourse'}) {
1290: &exportcourse($r);
1.26 www 1291: } else {
1.7 www 1292: # is this a standard course?
1293:
1294: my $standard=($ENV{'request.course.uri'}=~/^\/uploaded\//);
1.15 www 1295: my $forcestandard;
1296: my $forcesupplement;
1297: my $script='';
1298: my $allowed;
1299: my $events='';
1.19 www 1300: my $showdoc=0;
1.15 www 1301: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.114 albertel 1302: ['folderpath']);
1303: if ($ENV{'form.folderpath'}) {
1304: my (@folderpath)=split('&',$ENV{'form.folderpath'});
1305: $ENV{'form.foldername'}=&Apache::lonnet::unescape(pop(@folderpath));
1306: $ENV{'form.folder'}=pop(@folderpath);
1.116 albertel 1307: }
1.21 www 1308: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
1.127 albertel 1309: $showdoc='/'.$1;
1.21 www 1310: }
1311: unless ($showdoc) { # got called from remote
1.15 www 1312: $forcestandard=($ENV{'form.folder'}=~/^default_/);
1313: $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
1.7 www 1314:
1.4 www 1315: # does this user have privileges to post, etc?
1.77 www 1316: $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
1.15 www 1317: if ($allowed) {
1318: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
1319: $script=&Apache::lonratedt::editscript('simple');
1320: }
1321: } else { # got called in sequence from course
1322: $allowed=0;
1.49 www 1323: $script='</script>'.&Apache::lonmenu::registerurl(1,undef).'<script>';
1324: $events='onLoad="'.&Apache::lonmenu::loadevents.
1325: '" onUnload="'.&Apache::lonmenu::unloadevents.'"';
1.3 www 1326: }
1.4 www 1327:
1328: # get course data
1329: my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
1330: my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
1331:
1.14 www 1332: # get personal data
1333:
1334: my $uname=$ENV{'user.name'};
1335: my $udom=$ENV{'user.domain'};
1336: my $plainname=&Apache::lonnet::escape(
1337: &Apache::loncommon::plainname($uname,$udom));
1338:
1.8 www 1339: # graphics settings
1.4 www 1340:
1.8 www 1341: $iconpath = $r->dir_config('lonIconsURL') . "/";
1342:
1.22 www 1343: my $now=time;
1.64 www 1344:
1.4 www 1345: # print screen
1.1 www 1346: $r->print(<<ENDDOCUMENT);
1347: <html>
1348: <head>
1349: <title>The LearningOnline Network with CAPA</title>
1.16 www 1350: <script>
1351: $script
1.20 www 1352: </script>
1.19 www 1353: ENDDOCUMENT
1354: if ($allowed) {
1355: $r->print(<<ENDNEWSCRIPT);
1.20 www 1356: <script>
1.16 www 1357: function makenewfolder(targetform,folderseq) {
1358: var foldername=prompt('Name of New Folder','New Folder');
1359: if (foldername) {
1360: targetform.importdetail.value=foldername+"="+folderseq;
1361: targetform.submit();
1362: }
1363: }
1364:
1.18 www 1365: function makenewext(targetname) {
1366: this.document.forms.extimport.useform.value=targetname;
1367: window.open('/adm/rat/extpickframe.html');
1368: }
1369:
1.62 www 1370: function makeexamupload() {
1371: var title=prompt('Listed Title for the Uploaded Score');
1372: if (title) {
1373: this.document.forms.newexamupload.importdetail.value=
1374: title+'=/res/lib/templates/examupload.problem';
1375: this.document.forms.newexamupload.submit();
1376: }
1377: }
1378:
1.22 www 1379: function makesmppage() {
1.38 www 1380: var title=prompt('Listed Title for the Page');
1381: if (title) {
1.22 www 1382: this.document.forms.newsmppg.importdetail.value=
1383: title+'=/adm/$udom/$uname/$now/smppg';
1384: this.document.forms.newsmppg.submit();
1.38 www 1385: }
1.22 www 1386: }
1387:
1.55 www 1388: function makesmpproblem() {
1389: var title=prompt('Listed Title for the Problem');
1390: if (title) {
1391: this.document.forms.newsmpproblem.importdetail.value=
1.63 www 1392: title+'=/res/lib/templates/simpleproblem.problem';
1.55 www 1393: this.document.forms.newsmpproblem.submit();
1394: }
1395: }
1396:
1.22 www 1397: function makebulboard() {
1.38 www 1398: var title=prompt('Listed Title for the Bulletin Board');
1399: if (title) {
1.22 www 1400: this.document.forms.newbul.importdetail.value=
1401: title+'=/adm/$udom/$uname/$now/bulletinboard';
1402: this.document.forms.newbul.submit();
1.38 www 1403: }
1.22 www 1404: }
1405:
1.101 www 1406: function makeabout() {
1407: var user=prompt("Enter user\@domain for User's 'About Me' Page");
1408: if (user) {
1409: var comp=new Array();
1410: comp=user.split('\@');
1411: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
1412: if ((comp[0]) && (comp[1])) {
1413: this.document.forms.newaboutsomeone.importdetail.value=
1414: 'About '+user+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1415: this.document.forms.newaboutsomeone.submit();
1416: }
1417: }
1418: }
1419: }
1420:
1.110 raeburn 1421: function makeims() {
1422: var caller = document.forms.ims.folder.value
1423: var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one"
1424: newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes")
1425: newWindow.location.href = newlocation
1426: }
1427:
1428:
1.18 www 1429: function finishpick() {
1430: var title=this.document.forms.extimport.title.value;
1431: var url=this.document.forms.extimport.url.value;
1432: var form=this.document.forms.extimport.useform.value;
1433: eval
1434: ('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+
1435: '";this.document.forms.'+form+'.submit();');
1.16 www 1436: }
1.36 www 1437:
1.115 albertel 1438: function changename(folderpath,index,oldtitle) {
1.36 www 1439: var title=prompt('New Title',oldtitle);
1440: if (title) {
1441: this.document.forms.renameform.title.value=title;
1442: this.document.forms.renameform.cmd.value='rename_'+index;
1.115 albertel 1443: this.document.forms.renameform.folderpath.value=folderpath;
1.54 www 1444: this.document.forms.renameform.submit();
1445: }
1446: }
1447:
1.115 albertel 1448: function removeres(folderpath,index,oldtitle) {
1.106 www 1449: if (confirm('Remove "'+oldtitle+'"?')) {
1.54 www 1450: this.document.forms.renameform.cmd.value='del_'+index;
1.115 albertel 1451: this.document.forms.renameform.folderpath.value=folderpath;
1.36 www 1452: this.document.forms.renameform.submit();
1453: }
1454: }
1.121 www 1455:
1.16 www 1456: </script>
1.42 www 1457:
1458: ENDNEWSCRIPT
1459: }
1460: # -------------------------------------------------------------------- Body tag
1461: $r->print('</head>'.
1.72 www 1462: &Apache::loncommon::bodytag('Course Documents','',$events,
1.99 www 1463: '','',$showdoc).
1.134 albertel 1464: &Apache::loncommon::help_open_menu('','','','',273,'RAT'));
1.42 www 1465: unless ($showdoc) {
1.81 www 1466: # -----------------------------------------------------------------------------
1467: my %lt=&Apache::lonlocal::texthash(
1468: 'uplm' => 'Upload a new main course document',
1469: 'upls' => 'Upload a new supplemental course document',
1470: 'impp' => 'Import a published document',
1471: 'spec' => 'Special documents',
1472: 'upld' => 'Upload Document',
1473: 'srch' => 'Search',
1474: 'impo' => 'Import',
1475: 'selm' => 'Select Map',
1476: 'load' => 'Load Map',
1477: 'newf' => 'New Folder',
1478: 'extr' => 'External Resource',
1479: 'syll' => 'Syllabus',
1480: 'navc' => 'Navigate Contents',
1481: 'sipa' => 'Simple Page',
1482: 'sipr' => 'Simple Problem',
1483: 'scuf' => 'Score Upload Form',
1484: 'bull' => 'Bulletin Board',
1.96 sakharuk 1485: 'mypi' => 'My Personal Info',
1.101 www 1486: 'abou' => 'About User',
1.110 raeburn 1487: 'imsf' => 'Import IMS package',
1.96 sakharuk 1488: 'file' => 'File',
1489: 'title' => 'Title',
1490: 'comment' => 'Comment'
1.81 www 1491: );
1492: # -----------------------------------------------------------------------------
1.42 www 1493: if ($allowed) {
1.74 www 1494: my $dumpbut=&dumpbutton();
1.138 raeburn 1495: my $exportbut=&exportbutton();
1.88 www 1496: my %lt=&Apache::lonlocal::texthash(
1497: 'vc' => 'Verify Content',
1498: 'cv' => 'Check/Set Resource Versions',
1499: );
1.118 albertel 1500:
1501: my $folderpath=$ENV{'form.folderpath'};
1502: if (!$folderpath) {
1503: if ($ENV{'form.folder'} eq '' ||
1504: $ENV{'form.folder'} eq 'supplemental') {
1505: $folderpath='default&'.
1506: &Apache::lonnet::escape(&mt('Main Course Documents'));
1507: }
1508: }
1.42 www 1509: $r->print(<<ENDCOURSEVERIFY);
1.36 www 1510: <form name="renameform" method="post" action="/adm/coursedocs">
1511: <input type="hidden" name="title" />
1512: <input type="hidden" name="cmd" />
1.115 albertel 1513: <input type="hidden" name="folderpath" />
1.36 www 1514: </form>
1.39 www 1515: <form name="simpleedit" method="post" action="/adm/coursedocs">
1516: <input type=hidden name="importdetail" value="">
1.118 albertel 1517: <input type="hidden" name="folderpath" value="$folderpath" />
1.39 www 1518: </form>
1.26 www 1519: <form action="/adm/coursedocs" method="post" name="courseverify">
1.74 www 1520: <table bgcolor="#AAAAAA" width="100%" cellspacing="4" cellpadding="4">
1521: <tr><td bgcolor="#DDDDCC">
1.130 www 1522: <input type="submit" name="verify" value="$lt{'vc'}" />$help{'Verify_Content'}
1.74 www 1523: </td><td bgcolor="#DDDDCC">
1.130 www 1524: <input type="submit" name="versions" value="$lt{'cv'}" />$help{'Check_Resource_Versions'}
1.74 www 1525: $dumpbut
1.138 raeburn 1526: $exportbut
1.74 www 1527: </td></tr></table>
1.25 www 1528: </form>
1529: ENDCOURSEVERIFY
1.74 www 1530: $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
1.96 sakharuk 1531: &mt('Editing the Table of Contents for your Course')));
1.25 www 1532: }
1.17 www 1533: # --------------------------------------------------------- Standard documents
1.43 www 1534: $r->print('<table border=2 cellspacing=4 cellpadding=4>');
1.7 www 1535: if (($standard) && ($allowed) && (!$forcesupplement)) {
1.116 albertel 1536: $r->print('<tr><td bgcolor="#BBBBBB">');
1537: # '<h2>'.&mt('Main Course Documents').
1538: # ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>');
1.7 www 1539: my $folder=$ENV{'form.folder'};
1.117 albertel 1540: if ($folder eq '' || $folder eq 'supplemental') {
1.112 raeburn 1541: $folder='default';
1.116 albertel 1542: $ENV{'form.folderpath'}='default&'.&Apache::lonnet::escape(&mt('Main Course Documents'));
1.112 raeburn 1543: }
1.51 www 1544: my $postexec='';
1545: if ($folder eq 'default') {
1546: $r->print('<script>this.window.name="loncapaclient";</script>');
1547: } else {
1.117 albertel 1548: #$postexec='self.close();';
1.51 www 1549: }
1.40 www 1550: $hadchanges=0;
1.7 www 1551: &editor($r,$coursenum,$coursedom,$folder,$allowed);
1.40 www 1552: if ($hadchanges) {
1.136 albertel 1553: &mark_hash_old()
1.40 www 1554: }
1.136 albertel 1555: &changewarning($r,$postexec);
1.16 www 1556: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
1557: '.sequence';
1.8 www 1558: $r->print(<<ENDFORM);
1.43 www 1559: <table cellspacing=4 cellpadding=4><tr>
1.81 www 1560: <th bgcolor="#DDDDDD">$lt{'uplm'}</th>
1561: <th bgcolor="#DDDDDD">$lt{'impp'}</th>
1562: <th bgcolor="#DDDDDD">$lt{'spec'}</th>
1.11 www 1563: </tr>
1.16 www 1564: <tr><td bgcolor="#DDDDDD">
1.96 sakharuk 1565: $lt{'file'}:<br />
1.10 www 1566: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.59 www 1567: <input type="file" name="uploaddoc" size="40">
1.8 www 1568: <br />
1.96 sakharuk 1569: $lt{'title'}:<br />
1.11 www 1570: <input type="text" size="50" name="comment">
1.115 albertel 1571: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.10 www 1572: <input type="hidden" name="cmd" value="upload_default">
1.129 albertel 1573: <nobr>
1.81 www 1574: <input type="submit" value="$lt{'upld'}">
1.60 albertel 1575: $help{'Uploading_From_Harddrive'}
1.58 albertel 1576: </nobr>
1.60 albertel 1577: </form>
1.11 www 1578: </td>
1.16 www 1579: <td bgcolor="#DDDDDD">
1.39 www 1580: <form action="/adm/coursedocs" method="post" name="simpleeditdefault">
1.115 albertel 1581: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1582: <input type=button onClick="javascript:groupsearch()" value="$lt{'srch'}">
1.58 albertel 1583: <nobr>
1.115 albertel 1584: <input type=button onClick="javascript:groupimport();" value="$lt{'impo'}">
1.58 albertel 1585: $help{'Importing_LON-CAPA_Resource'}
1586: </nobr>
1.59 www 1587: <p>
1588: <hr />
1.68 bowersj2 1589: <input type="text" size="20" name="importmap"><br />
1590: <nobr><input type=button
1.52 www 1591: onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
1.81 www 1592: value="$lt{'selm'}"> <input type="submit" name="loadmap" value="$lt{'load'}">
1.68 bowersj2 1593: $help{'Load_Map'}</nobr>
1.59 www 1594: </p>
1.52 www 1595: </form>
1.16 www 1596: </td><td bgcolor="#DDDDDD">
1.11 www 1597: <form action="/adm/coursedocs" method="post" name="newfolder">
1.115 albertel 1598: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.13 www 1599: <input type=hidden name="importdetail" value="">
1.58 albertel 1600: <nobr>
1.16 www 1601: <input name="newfolder" type="button"
1602: onClick="javascript:makenewfolder(this.form,'$folderseq');"
1.81 www 1603: value="$lt{'newf'}" />$help{'Adding_Folders'}
1.58 albertel 1604: </nobr>
1.11 www 1605: </form>
1606: <form action="/adm/coursedocs" method="post" name="newext">
1.115 albertel 1607: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.13 www 1608: <input type=hidden name="importdetail" value="">
1.58 albertel 1609: <nobr>
1.18 www 1610: <input name="newext" type="button" onClick="javascript:makenewext('newext');"
1.81 www 1611: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
1.58 albertel 1612: </nobr>
1.11 www 1613: </form>
1614: <form action="/adm/coursedocs" method="post" name="newsyl">
1.115 albertel 1615: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.14 www 1616: <input type=hidden name="importdetail"
1617: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
1.58 albertel 1618: <nobr>
1.81 www 1619: <input name="newsyl" type="submit" value="$lt{'syll'}" />
1.65 bowersj2 1620: $help{'Syllabus'}
1.58 albertel 1621: </nobr>
1622: </form>
1.17 www 1623: <form action="/adm/coursedocs" method="post" name="newnav">
1.115 albertel 1624: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.15 www 1625: <input type=hidden name="importdetail"
1626: value="Navigate Content=/adm/navmaps">
1.58 albertel 1627: <nobr>
1.81 www 1628: <input name="newnav" type="submit" value="$lt{'navc'}" />
1.47 www 1629: $help{'Navigate_Content'}
1.58 albertel 1630: </nobr>
1.22 www 1631: </form>
1632: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.115 albertel 1633: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.22 www 1634: <input type=hidden name="importdetail" value="">
1.58 albertel 1635: <nobr>
1.81 www 1636: <input name="newsmppg" type="button" value="$lt{'sipa'}"
1.65 bowersj2 1637: onClick="javascript:makesmppage();" /> $help{'Simple Page'}
1.58 albertel 1638: </nobr>
1.55 www 1639: </form>
1640: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.115 albertel 1641: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.55 www 1642: <input type=hidden name="importdetail" value="">
1.58 albertel 1643: <nobr>
1.81 www 1644: <input name="newsmpproblem" type="button" value="$lt{'sipr'}"
1.65 bowersj2 1645: onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
1.62 www 1646: </nobr>
1647: </form>
1648: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.115 albertel 1649: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.62 www 1650: <input type=hidden name="importdetail" value="">
1651: <nobr>
1.81 www 1652: <input name="newexamupload" type="button" value="$lt{'scuf'}"
1.62 www 1653: onClick="javascript:makeexamupload();" />
1.66 bowersj2 1654: $help{'Score_Upload_Form'}
1.58 albertel 1655: </nobr>
1.22 www 1656: </form>
1657: <form action="/adm/coursedocs" method="post" name="newbul">
1.115 albertel 1658: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.22 www 1659: <input type=hidden name="importdetail" value="">
1.58 albertel 1660: <nobr>
1.81 www 1661: <input name="newbulletin" type="button" value="$lt{'bull'}"
1.22 www 1662: onClick="javascript:makebulboard();" />
1.65 bowersj2 1663: $help{'Bulletin Board'}
1.58 albertel 1664: </nobr>
1665: </form>
1.12 www 1666: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.115 albertel 1667: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.14 www 1668: <input type=hidden name="importdetail"
1669: value="$plainname=/adm/$udom/$uname/aboutme">
1.58 albertel 1670: <nobr>
1.81 www 1671: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
1.65 bowersj2 1672: $help{'My Personal Info'}
1.101 www 1673: </nobr>
1674: </form>
1675: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.115 albertel 1676: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.101 www 1677: <input type=hidden name="importdetail" value="">
1678: <nobr>
1679: <input name="newaboutsomeone" type="button" value="$lt{'abou'}"
1680: onClick="javascript:makeabout();" />
1.110 raeburn 1681: </nobr>
1682: </form>
1683: <form action="/adm/imsimportdocs" method="post" name="ims">
1.118 albertel 1684: <input type="hidden" name="folder" value="$folder" />
1.110 raeburn 1685: <input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" />
1.58 albertel 1686: </nobr>
1687: </form>
1.11 www 1688: </td></tr>
1689: </table>
1.8 www 1690: ENDFORM
1.24 www 1691: $r->print('</td></tr>');
1.7 www 1692: }
1693: # ----------------------------------------------------- Supplemental documents
1694: if (!$forcestandard) {
1.116 albertel 1695: $r->print('<tr><td bgcolor="#BBBBBB">');
1696: # '<h2>'.&mt('Supplemental Course Documents').
1697: # ($allowed?' '.$help{'Supplemental'}:'').'</h2>');
1.7 www 1698: my $folder=$ENV{'form.folder'};
1.117 albertel 1699: unless ($folder=~/^supplemental/) {
1.116 albertel 1700: $folder='supplemental';
1.117 albertel 1701: }
1702: if ($folder =~ /^supplemental$/ &&
1703: $ENV{'form.folderpath'} =~ /^default\&/) {
1704: $ENV{'form.folderpath'}='supplemental&'.
1705: &Apache::lonnet::escape(&mt('Supplemental Course Documents'));
1.116 albertel 1706: }
1.7 www 1707: &editor($r,$coursenum,$coursedom,$folder,$allowed);
1.8 www 1708: if ($allowed) {
1.17 www 1709: my $folderseq=
1710: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
1711: '.sequence';
1712:
1.8 www 1713: $r->print(<<ENDSUPFORM);
1.43 www 1714: <table cellspacing=4 cellpadding=4><tr>
1.81 www 1715: <th bgcolor="#DDDDDD">$lt{'upls'}</th>
1716: <th bgcolor="#DDDDDD">$lt{'spec'}</th>
1.17 www 1717: </tr>
1718: <tr><td bgcolor="#DDDDDD">
1.10 www 1719: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.59 www 1720: <input type="file" name="uploaddoc" size="40">
1.96 sakharuk 1721: <br />$lt{'comment'}:<br />
1.4 www 1722: <textarea cols=50 rows=4 name='comment'>
1723: </textarea>
1.115 albertel 1724: <br />
1725: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.10 www 1726: <input type="hidden" name="cmd" value="upload_supplemental">
1.58 albertel 1727: <nobr>
1.81 www 1728: <input type="submit" value="$lt{'upld'}">
1.58 albertel 1729: $help{'Uploading_From_Harddrive'}
1730: </nobr>
1731: </form>
1.17 www 1732: </td>
1733: <td bgcolor="#DDDDDD">
1.18 www 1734: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.115 albertel 1735: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.17 www 1736: <input type=hidden name="importdetail" value="">
1.58 albertel 1737: <nobr>
1.17 www 1738: <input name="newfolder" type="button"
1739: onClick="javascript:makenewfolder(this.form,'$folderseq');"
1.81 www 1740: value="$lt{'newf'}" /> $help{'Adding_Folders'}
1.58 albertel 1741: </nobr>
1.17 www 1742: </form>
1.18 www 1743: <form action="/adm/coursedocs" method="post" name="supnewext">
1.115 albertel 1744: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.17 www 1745: <input type=hidden name="importdetail" value="">
1.58 albertel 1746: <nobr>
1.18 www 1747: <input name="newext" type="button"
1748: onClick="javascript:makenewext('supnewext');"
1.81 www 1749: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
1.58 albertel 1750: </nobr>
1.17 www 1751: </form>
1.18 www 1752: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.115 albertel 1753: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.17 www 1754: <input type=hidden name="importdetail"
1755: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
1.58 albertel 1756: <nobr>
1.81 www 1757: <input name="newsyl" type="submit" value="$lt{'syll'}" />
1.65 bowersj2 1758: $help{'Syllabus'}
1.58 albertel 1759: </nobr>
1760: </form>
1.18 www 1761: <form action="/adm/coursedocs" method="post" name="subnewaboutme">
1.115 albertel 1762: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1.17 www 1763: <input type=hidden name="importdetail"
1764: value="$plainname=/adm/$udom/$uname/aboutme">
1.58 albertel 1765: <nobr>
1.81 www 1766: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
1.65 bowersj2 1767: $help{'My Personal Info'}
1.58 albertel 1768: </nobr>
1769: </form>
1.17 www 1770: </td></tr>
1.24 www 1771: </table></td></tr>
1.8 www 1772: ENDSUPFORM
1773: }
1.7 www 1774: }
1.18 www 1775: if ($allowed) {
1776: $r->print('<form name="extimport"><input type="hidden" name="title"><input type="hidden" name="url"><input type="hidden" name="useform"></form>');
1777: }
1.24 www 1778: $r->print('</table>');
1.19 www 1779: } else {
1780: # -------------------------------------------------------- This is showdoc mode
1.81 www 1781: $r->print("<h1>".&mt('Uploaded Document').'</h1><p>'.
1782: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><p><table>".
1783: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table></p>');
1.19 www 1784: }
1.26 www 1785: }
1.95 www 1786: $r->print('</body></html>');
1.26 www 1787: return OK;
1.1 www 1788: }
1789:
1790: 1;
1791: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>