Annotation of loncom/interface/londocs.pm, revision 1.575
1.329 droeschl 1: # The LearningOnline Network
2: # Documents
3: #
1.575 ! raeburn 4: # $Id: londocs.pm,v 1.574 2013/12/30 21:10:36 raeburn Exp $
1.329 droeschl 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29: package Apache::londocs;
30:
31: use strict;
32: use Apache::Constants qw(:common :http);
33: use Apache::imsexport;
34: use Apache::lonnet;
35: use Apache::loncommon;
1.383 tempelho 36: use Apache::lonhtmlcommon;
1.329 droeschl 37: use LONCAPA::map();
38: use Apache::lonratedt();
39: use Apache::lonxml;
40: use Apache::lonclonecourse;
41: use Apache::lonnavmaps;
1.472 raeburn 42: use Apache::lonnavdisplay();
1.510 raeburn 43: use Apache::lonextresedit();
1.567 raeburn 44: use Apache::lontemplate();
45: use Apache::lonsimplepage();
1.329 droeschl 46: use HTML::Entities;
1.488 raeburn 47: use HTML::TokeParser;
1.329 droeschl 48: use GDBM_File;
49: use Apache::lonlocal;
50: use Cwd;
51: use LONCAPA qw(:DEFAULT :match);
52:
53: my $iconpath;
54:
55: my %hash;
56:
57: my $hashtied;
58: my %alreadyseen=();
59:
60: my $hadchanges;
1.557 raeburn 61: my $suppchanges;
1.329 droeschl 62:
63:
64: my %help=();
65:
66:
67: sub mapread {
68: my ($coursenum,$coursedom,$map)=@_;
69: return
70: &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
71: $map);
72: }
73:
74: sub storemap {
1.492 raeburn 75: my ($coursenum,$coursedom,$map,$contentchg)=@_;
76: my $report;
77: if (($contentchg) && ($map =~ /^default/)) {
78: $report = 1;
79: }
1.329 droeschl 80: my ($outtext,$errtext)=
81: &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.492 raeburn 82: $map,1,$report);
1.329 droeschl 83: if ($errtext) { return ($errtext,2); }
1.364 bisitz 84:
1.557 raeburn 85: if ($map =~ /^default/) {
86: $hadchanges=1;
87: } else {
88: $suppchanges=1;
89: }
1.329 droeschl 90: return ($errtext,0);
91: }
92:
93:
94:
95: sub authorhosts {
96: my %outhash=();
97: my $home=0;
98: my $other=0;
99: foreach my $key (keys(%env)) {
100: if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
101: my $role=$1;
102: my $realm=$2;
103: my ($start,$end)=split(/\./,$env{$key});
104: if (($start) && ($start>time)) { next; }
105: if (($end) && (time>$end)) { next; }
106: my ($ca,$cd);
107: if ($1 eq 'au') {
108: $ca=$env{'user.name'};
109: $cd=$env{'user.domain'};
110: } else {
111: ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
112: }
113: my $allowed=0;
114: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
115: my @ids=&Apache::lonnet::current_machine_ids();
1.484 raeburn 116: foreach my $id (@ids) {
117: if ($id eq $myhome) {
118: $allowed=1;
119: last;
120: }
121: }
1.329 droeschl 122: if ($allowed) {
123: $home++;
1.484 raeburn 124: $outhash{'home_'.$ca.':'.$cd}=1;
1.329 droeschl 125: } else {
1.484 raeburn 126: $outhash{'otherhome_'.$ca.':'.$cd}=$myhome;
1.329 droeschl 127: $other++;
128: }
129: }
130: }
131: return ($home,$other,%outhash);
132: }
133:
134:
135: sub clean {
136: my ($title)=@_;
137: $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
1.344 bisitz 138: return $title;
1.329 droeschl 139: }
140:
141:
142:
143: sub dumpcourse {
144: my ($r) = @_;
1.408 raeburn 145: my $crstype = &Apache::loncommon::course_type();
1.567 raeburn 146: my ($starthash,$js);
147: unless (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
148: $js = <<"ENDJS";
149: <script type="text/javascript">
150: // <![CDATA[
151:
152: function hide_searching() {
153: if (document.getElementById('searching')) {
154: document.getElementById('searching').style.display = 'none';
155: }
156: return;
157: }
158:
159: // ]]>
160: </script>
161: ENDJS
162: $starthash = {
163: add_entries => {'onload' => "hide_searching();"},
164: };
165: }
1.568 raeburn 166: $r->print(&Apache::loncommon::start_page('Copy '.$crstype.' Content to Authoring Space',$js,$starthash)."\n".
167: &Apache::lonhtmlcommon::breadcrumbs('Copy '.$crstype.' Content to Authoring Space')."\n");
1.484 raeburn 168: $r->print(&startContentScreen('tools'));
1.329 droeschl 169: my ($home,$other,%outhash)=&authorhosts();
1.484 raeburn 170: unless ($home) {
171: $r->print(&endContentScreen());
172: return '';
173: }
1.329 droeschl 174: my $origcrsid=$env{'request.course.id'};
175: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
176: if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
177: # Do the dumping
1.484 raeburn 178: unless ($outhash{'home_'.$env{'form.authorspace'}}) {
179: $r->print(&endContentScreen());
180: return '';
181: }
1.531 raeburn 182: my ($ca,$cd)=split(/\:/,$env{'form.authorspace'});
1.329 droeschl 183: $r->print('<h3>'.&mt('Copying Files').'</h3>');
184: my $title=$env{'form.authorfolder'};
185: $title=&clean($title);
1.567 raeburn 186: my ($navmap,$errormsg) =
187: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
188: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
189: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
190: my (%maps,%resources,%titles);
191: if (!ref($navmap)) {
192: $r->print($errormsg.
193: &endContentScreen());
194: return '';
195: } else {
196: &Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles,
197: 'dumpdocs',$cdom,$cnum);
1.329 droeschl 198: }
1.567 raeburn 199: my @todump = &Apache::loncommon::get_env_multiple('form.archive');
200: my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages,
201: %newcontent,%has_simpleprobs);
202: foreach my $item (sort {$a <=> $b} (@todump)) {
203: my $name = $env{'form.namefor_'.$item};
204: if ($resources{$item}) {
205: my ($map,$id,$res) = &Apache::lonnet::decode_symb($resources{$item});
206: if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) {
207: $tocopy{$1} = $name;
208: $display{$item} = $1;
209: $lookup{$1} = $item;
210: } elsif ($res eq 'lib/templates/simpleproblem.problem') {
211: $simpleproblems{$item} = {
212: symb => $resources{$item},
213: name => $name,
214: };
215: $display{$item} = 'simpleproblem_'.$name;
216: if ($map =~ m{^\Quploaded/$cdom/$cnum/\E(.+)$}) {
217: $has_simpleprobs{$1}{$id} = $item;
218: }
219: } elsif ($res =~ m{^adm/$match_domain/$match_username/(\d+)/smppg}) {
220: my $marker = $1;
221: my $db_name = &Apache::lonsimplepage::get_db_name($res,$marker,$cdom,$cnum);
222: $simplepages{$item} = {
223: res => $res,
224: title => $titles{$item},
225: db => $db_name,
226: marker => $marker,
227: symb => $resources{$item},
228: name => $name,
229: };
230: $display{$item} = '/'.$res;
231: }
232: } elsif ($maps{$item}) {
233: if ($maps{$item} =~ m{^\Quploaded/$cdom/$cnum/\E((?:default|supplemental)_\d+\.(?:sequence|page))$}) {
234: $tocopy{$1} = $name;
235: $display{$item} = $1;
236: $lookup{$1} = $item;
237: }
238: } else {
239: next;
240: }
241: }
1.329 droeschl 242: my $crs='/uploaded/'.$env{'request.course.id'}.'/';
243: $crs=~s/\_/\//g;
1.567 raeburn 244: my $mm = new File::MMagic;
245: my $prefix = "/uploaded/$cdom/$cnum/";
246: %replacehash = %tocopy;
247: foreach my $item (sort(keys(%simpleproblems))) {
248: my $content = &Apache::imsexport::simpleproblem($simpleproblems{$item}{'symb'});
249: $newcontent{$display{$item}} = $content;
250: }
251: my $gateway = Apache::lonhtmlgateway->new('web');
252: foreach my $item (sort(keys(%simplepages))) {
253: if (ref($simplepages{$item}) eq 'HASH') {
254: my $pagetitle = $simplepages{$item}{'title'};
255: my %fields = &Apache::lonnet::dump($simplepages{$item}{'db'},$cdom,$cnum);
256: my %contents;
257: foreach my $field (keys(%fields)) {
258: if ($field =~ /^(?:aaa|bbb|ccc)_(\w+)$/) {
259: my $name = $1;
260: my $msg = $fields{$field};
261: if ($name eq 'webreferences') {
262: if ($msg =~ m{^https?://}) {
263: $contents{$name} = '<a href="'.$msg.'"><tt>'.$msg.'</tt></a>';
264: }
265: } else {
266: $msg = &Encode::decode('utf8',$msg);
267: $msg = $gateway->process_outgoing_html($msg,1);
268: $contents{$name} = $msg;
269: }
270: } elsif ($field eq 'uploaded.photourl') {
271: my $marker = $simplepages{$item}{marker};
272: if ($fields{$field} =~ m{^\Q$prefix\E(simplepage/$marker/.+)$}) {
273: my $filepath = $1;
274: my ($relpath,$fname) = ($filepath =~ m{^(.+/)([^/]+)$});
275: if ($fname ne '') {
276: $fname=~s/\.(\w+)$//;
277: my $ext=$1;
278: $fname = &clean($fname);
279: $fname.='.'.$ext;
280: $contents{image} = '<img src="'.$relpath.$fname.'" alt="Image" />';
281: $replacehash{$filepath} = $relpath.$fname;
282: $deps{$item}{$filepath} = 1;
283: }
284: }
285: }
286: }
287: $replacehash{'/'.$simplepages{$item}{'res'}} = $simplepages{$item}{'name'};
288: $lookup{'/'.$simplepages{$item}{'res'}} = $item;
289: my $content = '
290: <html>
291: <head>
292: <title>'.$pagetitle.'</title>
293: </head>
294: <body bgcolor="#ffffff">';
295: if ($contents{title}) {
296: $content .= "\n".'<h2>'.$contents{title}.'</h2>';
297: }
298: if ($contents{image}) {
299: $content .= "\n".$contents{image};
300: }
301: if ($contents{content}) {
302: $content .= '
303: <div class="LC_Box">
304: <h4 class="LC_hcell">Content</h4>'.
305: $contents{content}.'
306: </div>';
307: }
308: if ($contents{webreferences}) {
309: $content .= '
310: <div class="LC_Box">
311: <h4 class="LC_hcell">Web References</h4>'.
312: $contents{webreferences}.'
313: </div>';
314: }
315: $content .= '
316: </body>
317: </html>
318: ';
319: $newcontent{'/'.$simplepages{$item}{res}} = $content;
320: }
321: }
322: foreach my $item (keys(%tocopy)) {
323: unless ($item=~/\.(sequence|page)$/) {
324: my $currurlpath = $prefix.$item;
325: my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath);
326: &recurse_html($mm,$prefix,$currdirpath,$currurlpath,$item,$lookup{$item},\%replacehash,\%deps);
327: }
328: }
329: foreach my $num (sort {$a <=> $b} (@todump)) {
330: my $src = $display{$num};
331: next if ($src eq '');
332: my @needcopy = ();
333: if ($replacehash{$src}) {
334: push(@needcopy,$src);
335: if (ref($deps{$num}) eq 'HASH') {
336: foreach my $dep (sort(keys(%{$deps{$num}}))) {
337: if ($replacehash{$dep}) {
338: push(@needcopy,$dep);
339: }
340: }
341: }
342: } elsif ($src =~ /^simpleproblem_/) {
343: push(@needcopy,$src);
344: }
345: next if (@needcopy == 0);
346: my ($result,$depresult);
347: for (my $i=0; $i<@needcopy; $i++) {
348: my $item = $needcopy[$i];
349: my $newfilename;
350: if ($simpleproblems{$num}) {
351: $newfilename=$title.'/'.$simpleproblems{$num}{'name'};
352: } else {
353: $newfilename=$title.'/'.$replacehash{$item};
354: }
355: $newfilename=~s/\.(\w+)$//;
356: my $ext=$1;
357: $newfilename=&clean($newfilename);
358: $newfilename.='.'.$ext;
359: my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$});
360: if ($newrelpath ne $replacehash{$item}) {
361: $replacehash{$item} = $newrelpath;
362: }
363: my @dirs=split(/\//,$newfilename);
364: my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
365: my $makepath=$path;
366: my $fail;
367: my $origin;
368: for (my $i=0;$i<$#dirs;$i++) {
369: $makepath.='/'.$dirs[$i];
370: unless (-e $makepath) {
371: unless(mkdir($makepath,0755)) {
372: $fail = &mt('Directory creation failed.');
373: }
374: }
375: }
376: if ($i == 0) {
377: $result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ';
378: } else {
379: $depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '.
380: '<span class="LC_fontsize_small" style="font-weight: bold;">'.
381: &mt('(dependency)').'</span>: ';
382: }
383: if (-e $path.'/'.$newfilename) {
384: $fail = &mt('Destination already exists -- not overwriting.');
385: } else {
386: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
387: if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) ||
388: ($item =~ /^simpleproblem_/)) {
389: print $fh $newcontent{$item};
390: } else {
391: my $fileloc = &Apache::lonnet::filelocation('',$prefix.$item);
392: if (-e $fileloc) {
393: if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
394: if ((($1 eq 'sequence') || ($1 eq 'page')) &&
395: (ref($has_simpleprobs{$item}) eq 'HASH')) {
396: my %changes = %{$has_simpleprobs{$item}};
397: my $content = &Apache::lonclonecourse::rewritefile(
398: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
399: (%replacehash,$crs => '')
400: );
401: my $updatedcontent = '';
402: my $parser = HTML::TokeParser->new(\$content);
403: $parser->attr_encoded(1);
404: while (my $token = $parser->get_token) {
405: if ($token->[0] eq 'S') {
406: if (($token->[1] eq 'resource') &&
407: ($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') &&
408: ($changes{$token->[2]->{'id'}})) {
409: my $id = $token->[2]->{'id'};
410: $updatedcontent .= '<'.$token->[1];
411: foreach my $attrib (@{$token->[3]}) {
412: next unless ($attrib =~ /^(src|type|title|id)$/);
413: if ($attrib eq 'src') {
414: my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/);
415: if ($file) {
416: $updatedcontent .= ' '.$attrib.'="'.$file.'"';
417: } else {
418: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
419: }
420: } else {
421: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
422: }
423: }
424: $updatedcontent .= ' />'."\n";
425: } else {
426: $updatedcontent .= $token->[4]."\n";
427: }
428: } else {
429: $updatedcontent .= $token->[2];
430: }
431: }
432: print $fh $updatedcontent;
433: } else {
434: print $fh &Apache::lonclonecourse::rewritefile(
435: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
436: (%replacehash,$crs => '')
437: );
438: }
439: } else {
440: print $fh
441: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
442: }
443: } else {
444: $fail = &mt('Source does not exist.');
445: }
446: }
447: $fh->close();
448: } else {
449: $fail = &mt('Could not write to destination.');
450: }
451: }
452: my $text;
453: if ($fail) {
454: $text = '<span class="LC_error">'.&mt('fail').(' 'x3).$fail.'</span>';
455: } else {
456: $text = '<span class="LC_success">'.&mt('ok').'</span>';
457: }
458: if ($i == 0) {
459: $result .= $text;
460: } else {
461: $depresult .= $text.'</li>';
462: }
463: }
464: $r->print($result);
465: if ($depresult) {
466: $r->print('<ul>'.$depresult.'</ul>');
467: }
468: }
469: } else {
470: my ($navmap,$errormsg) =
471: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
472: if (!ref($navmap)) {
473: $r->print($errormsg);
474: } else {
475: $r->print('<div id="searching">'.&mt('Searching ...').'</div>');
476: $r->rflush();
477: my ($preamble,$formname);
478: $formname = 'dumpdoc';
479: unless ($home==1) {
480: $preamble = '<div class="LC_left_float">'.
481: '<fieldset><legend>'.
482: &mt('Select the Authoring Space').
483: '</legend><select name="authorspace">';
1.329 droeschl 484: }
1.567 raeburn 485: my @orderspaces = ();
486: foreach my $key (sort(keys(%outhash))) {
487: if ($key=~/^home_(.+)$/) {
488: if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) {
489: unshift(@orderspaces,$1);
490: } else {
491: push(@orderspaces,$1);
492: }
493: }
494: }
1.569 raeburn 495: if ($home>1) {
496: $preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>';
497: }
1.567 raeburn 498: foreach my $user (@orderspaces) {
1.329 droeschl 499: if ($home==1) {
1.567 raeburn 500: $preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />';
1.329 droeschl 501: } else {
1.567 raeburn 502: $preamble .= '<option value="'.$user.'">'.$user.' - '.
503: &Apache::loncommon::plainname(split(/\:/,$user)).'</option>';
504: }
1.329 droeschl 505: }
1.567 raeburn 506: unless ($home==1) {
507: $preamble .= '</select></fieldset></div>'."\n";
1.329 droeschl 508: }
1.567 raeburn 509: my $title=$origcrsdata{'description'};
510: $title=~s/[\/\s]+/\_/gs;
1.329 droeschl 511: $title=&clean($title);
1.567 raeburn 512: $preamble .= '<div class="LC_left_float">'.
513: '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.
514: '<input type="text" size="50" name="authorfolder" value="'.
515: $title.'" />'.
516: '</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n";
517: my %uploadedfiles;
518: &tiehash();
519: foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
520: my ($ext)=($file=~/\.(\w+)$/);
521: # FIXME Check supplemental here
522: my $title=$hash{'title_'.$hash{
523: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
524: if (!$title) {
525: $title=$file;
526: } else {
527: $title=~s|/|_|g;
528: }
529: $title=~s/\.(\w+)$//;
530: $title=&clean($title);
531: $title.='.'.$ext;
532: # $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
533: $uploadedfiles{$file} = $title;
534: }
535: &untiehash();
536: $r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef,
537: undef,undef,$preamble,$home,\%uploadedfiles));
538: }
1.329 droeschl 539: }
1.484 raeburn 540: $r->print(&endContentScreen());
1.329 droeschl 541: }
542:
1.567 raeburn 543: sub recurse_html {
544: my ($mm,$prefix,$currdirpath,$currurlpath,$container,$item,$replacehash,$deps) = @_;
545: return unless ((ref($replacehash) eq 'HASH') && (ref($deps) eq 'HASH'));
546: my (%allfiles,%codebase);
547: if (&Apache::lonnet::extract_embedded_items($currdirpath,\%allfiles,\%codebase) eq 'ok') {
548: if (keys(%allfiles)) {
549: foreach my $dependency (keys(%allfiles)) {
550: next if (($dependency =~ m{^/(res|adm)/}) || ($dependency =~ m{^https?://}));
551: my ($depurl,$relfile,$newcontainer);
552: if ($dependency =~ m{^/}) {
553: if ($dependency =~ m{^\Q$currurlpath/\E(.+)$}) {
554: $relfile = $1;
555: if ($dependency =~ m{^\Q$prefix\E(.+)$}) {
556: $newcontainer = $1;
557: next if ($replacehash->{$newcontainer});
558: }
559: $depurl = $dependency;
560: } else {
561: next;
562: }
563: } else {
564: $relfile = $dependency;
565: $depurl = $currurlpath;
566: $depurl =~ s{[^/]+$}{};
567: $depurl .= $dependency;
568: ($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$});
569: }
570: next if ($relfile eq '');
571: my $newname = $replacehash->{$container};
572: $newname =~ s{[^/]+$}{};
573: $replacehash->{$newcontainer} = $newname.$relfile;
574: $deps->{$item}{$newcontainer} = 1;
575: my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$});
576: my $depfile = &Apache::lonnet::filelocation('',$depurl);
577: my $type = $mm->checktype_filename($depfile);
578: if ($type eq 'text/html') {
579: &recurse_html($mm,$prefix,$depfile,$newurlpath,$newcontainer,$item,$replacehash,$deps);
580: }
581: }
582: }
583: }
584: return;
585: }
586:
1.329 droeschl 587: sub group_import {
588: my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
1.529 raeburn 589: my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap,
590: %removeparam,$importuploaded,$fixuperrors);
591: $allmaps = {};
1.329 droeschl 592: while (@files) {
593: my ($name, $url, $residx) = @{ shift(@files) };
1.344 bisitz 594: if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
1.329 droeschl 595: && ($caller eq 'londocs')
596: && (!&Apache::lonnet::stat_file($url))) {
1.364 bisitz 597:
1.329 droeschl 598: my $errtext = '';
599: my $fatal = 0;
600: my $newmapstr = '<map>'."\n".
601: '<resource id="1" src="" type="start"></resource>'."\n".
602: '<link from="1" to="2" index="1"></link>'."\n".
603: '<resource id="2" src="" type="finish"></resource>'."\n".
604: '</map>';
605: $env{'form.output'}=$newmapstr;
606: my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
607: 'output',$1.$2);
1.534 raeburn 608: if ($result !~ m{^/uploaded/}) {
1.329 droeschl 609: $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
610: $fatal = 2;
611: }
612: if ($fatal) {
613: return ($errtext,$fatal);
614: }
615: }
616: if ($url) {
1.529 raeburn 617: if (($caller eq 'londocs') &&
618: ($folder =~ /^default/)) {
1.534 raeburn 619: if (($url =~ /\.(page|sequence)$/) && (!$donechk)) {
1.529 raeburn 620: my $chome = &Apache::lonnet::homeserver($coursenum,$coursedom);
621: my $cid = $coursedom.'_'.$coursenum;
622: $allmaps =
623: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
624: $chome,$cid);
625: $donechk = 1;
626: }
627: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) {
628: &contained_map_check($url,$folder,\%removefrommap,\%removeparam,
629: \%addedmaps,\%hierarchy,\%titles,$allmaps);
630: $importuploaded = 1;
631: } elsif ($url =~ m{^/res/.+\.(page|sequence)$}) {
632: next if ($allmaps->{$url});
633: }
634: }
1.344 bisitz 635: if (!$residx
1.329 droeschl 636: || defined($LONCAPA::map::zombies[$residx])) {
637: $residx = &LONCAPA::map::getresidx($url,$residx);
638: push(@LONCAPA::map::order, $residx);
639: }
640: my $ext = 'false';
641: if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
642: $name = &LONCAPA::map::qtunescape($name);
1.534 raeburn 643: if ($name eq '') {
1.538 raeburn 644: $name = &LONCAPA::map::qtunescape(&mt('Web Page'));
1.534 raeburn 645: }
646: if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) {
647: my $filepath = $1;
648: my $fname = $name;
649: if ($fname =~ /^\W+$/) {
650: $fname = 'web';
651: } else {
652: $fname =~ s/\W/_/g;
653: }
654: if (length($fname > 15)) {
655: $fname = substr($fname,0,14);
656: }
657: my $initialtext = &mt('Replace with your own content.');
658: my $newhtml = <<END;
1.545 raeburn 659: <html>
1.534 raeburn 660: <head>
661: <title>$name</title>
662: </head>
663: <body bgcolor="#ffffff">
664: $initialtext
665: </body>
666: </html>
667: END
668: $env{'form.output'}=$newhtml;
669: my $result =
670: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
671: 'output',
672: "$filepath/$residx/$fname.html");
673: if ($result =~ m{^/uploaded/}) {
674: $url = $result;
675: if ($filepath =~ /^supplemental/) {
676: $name = time.'___&&&___'.$env{'user.name'}.'___&&&___'.
677: $env{'user.domain'}.'___&&&___'.$name;
678: }
679: } else {
680: return (&mt('Failed to save new web page.'),1);
681: }
682: }
1.538 raeburn 683: $url = &LONCAPA::map::qtunescape($url);
1.344 bisitz 684: $LONCAPA::map::resources[$residx] =
1.329 droeschl 685: join(':', ($name, $url, $ext, 'normal', 'res'));
686: }
687: }
1.529 raeburn 688: if ($importuploaded) {
689: my %import_errors;
690: my %updated = (
691: removefrommap => \%removefrommap,
692: removeparam => \%removeparam,
693: );
1.533 raeburn 694: my ($result,$msgsarray,$lockerror) =
695: &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
1.529 raeburn 696: if (keys(%import_errors) > 0) {
1.530 raeburn 697: $fixuperrors =
1.529 raeburn 698: '<p span class="LC_warning">'."\n".
699: &mt('The following files are either dependencies of a web page or references within a folder and/or composite page for which errors occurred during import:')."\n".
700: '<ul>'."\n";
701: foreach my $key (sort(keys(%import_errors))) {
702: $fixuperrors .= '<li>'.$key.'</li>'."\n";
703: }
704: $fixuperrors .= '</ul></p>'."\n";
705: }
1.533 raeburn 706: if (ref($msgsarray) eq 'ARRAY') {
707: if (@{$msgsarray} > 0) {
708: $fixuperrors .= '<p class="LC_info">'.
709: join('<br />',@{$msgsarray}).
710: '</p>';
711: }
712: }
713: if ($lockerror) {
714: $fixuperrors .= '<p class="LC_error">'.
715: $lockerror.
716: '</p>';
717: }
1.529 raeburn 718: }
719: my ($errtext,$fatal) =
720: &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
1.557 raeburn 721: unless ($fatal) {
722: if ($folder =~ /^supplemental/) {
723: &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
1.561 raeburn 724: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
725: $folder.'.'.$container);
1.557 raeburn 726: }
727: }
1.529 raeburn 728: return ($errtext,$fatal,$fixuperrors);
1.329 droeschl 729: }
730:
731: sub log_docs {
1.494 raeburn 732: return &Apache::lonnet::write_log('course','docslog',@_);
1.329 droeschl 733: }
734:
735: {
736: my @oldresources=();
737: my @oldorder=();
738: my $parmidx;
739: my %parmaction=();
740: my %parmvalue=();
741: my $changedflag;
742:
743: sub snapshotbefore {
744: @oldresources=@LONCAPA::map::resources;
745: @oldorder=@LONCAPA::map::order;
746: $parmidx=undef;
747: %parmaction=();
748: %parmvalue=();
749: $changedflag=0;
750: }
751:
752: sub remember_parms {
753: my ($idx,$parameter,$action,$value)=@_;
754: $parmidx=$idx;
755: $parmaction{$parameter}=$action;
756: $parmvalue{$parameter}=$value;
757: $changedflag=1;
758: }
759:
760: sub log_differences {
761: my ($plain)=@_;
762: my %storehash=('folder' => $plain,
763: 'currentfolder' => $env{'form.folder'});
764: if ($parmidx) {
765: $storehash{'parameter_res'}=$oldresources[$parmidx];
766: foreach my $parm (keys(%parmaction)) {
767: $storehash{'parameter_action_'.$parm}=$parmaction{$parm};
768: $storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
769: }
770: }
771: my $maxidx=$#oldresources;
772: if ($#LONCAPA::map::resources>$#oldresources) {
773: $maxidx=$#LONCAPA::map::resources;
774: }
775: for (my $idx=0; $idx<=$maxidx; $idx++) {
776: if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
777: $storehash{'before_resources_'.$idx}=$oldresources[$idx];
778: $storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
779: $changedflag=1;
780: }
781: if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
782: $storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
783: $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
784: $changedflag=1;
785: }
786: }
787: $storehash{'maxidx'}=$maxidx;
788: if ($changedflag) { &log_docs(\%storehash); }
789: }
790: }
791:
792: sub docs_change_log {
1.484 raeburn 793: my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath)=@_;
1.486 raeburn 794: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
1.483 raeburn 795: my $js = '<script type="text/javascript">'."\n".
796: '// <![CDATA['."\n".
797: &Apache::loncommon::display_filter_js('docslog')."\n".
1.486 raeburn 798: &editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag)."\n".
1.483 raeburn 799: &history_tab_js()."\n".
1.484 raeburn 800: &Apache::lonratedt::editscript('simple')."\n".
1.483 raeburn 801: '// ]]>'."\n".
802: '</script>'."\n";
1.484 raeburn 803: $r->print(&Apache::loncommon::start_page('Content Change Log',$js));
804: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Change Log'));
1.489 raeburn 805: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484 raeburn 806: my %orderhash;
807: my $container='sequence';
808: my $pathitem;
1.519 raeburn 809: if ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 810: $container='page';
811: }
1.519 raeburn 812: my $folderpath=$env{'form.folderpath'};
813: if ($folderpath eq '') {
1.548 raeburn 814: $folderpath = 'default&'.&escape(&mt('Main Content').':::::');
1.519 raeburn 815: }
816: $pathitem = '<input type="hidden" name="folderpath" value="'.
817: &HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 818: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
819: my $jumpto = $readfile;
820: $jumpto =~ s{^/}{};
821: my $tid = 1;
1.489 raeburn 822: if ($supplementalflag) {
823: $tid = 2;
824: }
1.509 raeburn 825: my ($breadcrumbtrail) =
826: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
1.484 raeburn 827: $r->print($breadcrumbtrail.
828: &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto,
829: $readfile));
1.329 droeschl 830: my %docslog=&Apache::lonnet::dump('nohist_docslog',
831: $env{'course.'.$env{'request.course.id'}.'.domain'},
832: $env{'course.'.$env{'request.course.id'}.'.num'});
833:
834: if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
835:
836: my %saveable_parameters = ('show' => 'scalar',);
837: &Apache::loncommon::store_course_settings('docs_log',
838: \%saveable_parameters);
839: &Apache::loncommon::restore_course_settings('docs_log',
840: \%saveable_parameters);
841: if (!$env{'form.show'}) { $env{'form.show'}=10; }
1.452 www 842: # FIXME: internationalization seems wrong here
1.329 droeschl 843: my %lt=('hiddenresource' => 'Resources hidden',
844: 'encrypturl' => 'URL hidden',
845: 'randompick' => 'Randomly pick',
846: 'randomorder' => 'Randomly ordered',
847: 'set' => 'set to',
848: 'del' => 'deleted');
1.484 raeburn 849: my $filter = &Apache::loncommon::display_filter('docslog')."\n".
850: $pathitem."\n".
851: '<input type="hidden" name="folder" value="'.$env{'form.folder'}.'" />'.
852: (' 'x2).'<input type="submit" value="'.&mt('Display').'" />';
853: $r->print('<div class="LC_left_float">'.
854: '<fieldset><legend>'.&mt('Display of Content Changes').'</legend>'."\n".
855: &makedocslogform($filter,1).
856: '</fieldset></div><br clear="all" />');
1.329 droeschl 857: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
858: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
859: &mt('After').'</th>'.
860: &Apache::loncommon::end_data_table_header_row());
861: my $shown=0;
862: foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
863: if ($env{'form.displayfilter'} eq 'currentfolder') {
864: if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
865: }
866: my @changes=keys(%{$docslog{$id}{'logentry'}});
867: if ($env{'form.displayfilter'} eq 'containing') {
868: my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
869: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
870: foreach my $key (@changes) {
871: $wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
872: }
1.344 bisitz 873: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
1.329 droeschl 874: }
875: my $count = 0;
876: my $time =
877: &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
878: my $plainname =
879: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
880: $docslog{$id}{'exe_udom'});
881: my $about_me_link =
882: &Apache::loncommon::aboutmewrapper($plainname,
883: $docslog{$id}{'exe_uname'},
884: $docslog{$id}{'exe_udom'});
885: my $send_msg_link='';
886: if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
887: || ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
888: $send_msg_link ='<br />'.
889: &Apache::loncommon::messagewrapper(&mt('Send message'),
890: $docslog{$id}{'exe_uname'},
891: $docslog{$id}{'exe_udom'});
892: }
893: $r->print(&Apache::loncommon::start_data_table_row());
894: $r->print('<td>'.$time.'</td>
895: <td>'.$about_me_link.
896: '<br /><tt>'.$docslog{$id}{'exe_uname'}.
897: ':'.$docslog{$id}{'exe_udom'}.'</tt>'.
898: $send_msg_link.'</td><td>'.
899: $docslog{$id}{'logentry'}{'folder'}.'</td><td>');
1.488 raeburn 900: my $is_supp = 0;
901: if ($docslog{$id}{'logentry'}{'currentfolder'} =~ /^supplemental/) {
902: $is_supp = 1;
903: }
1.329 droeschl 904: # Before
905: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
906: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
907: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
908: if ($oldname ne $newname) {
1.488 raeburn 909: my $shown = &LONCAPA::map::qtescape($oldname);
910: if ($is_supp) {
911: $shown = &Apache::loncommon::parse_supplemental_title($shown);
912: }
913: $r->print($shown);
1.329 droeschl 914: }
915: }
916: $r->print('<ul>');
917: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
918: if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
1.488 raeburn 919: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]);
920: if ($is_supp) {
921: $shown = &Apache::loncommon::parse_supplemental_title($shown);
922: }
923: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 924: }
925: }
926: $r->print('</ul>');
927: # After
928: $r->print('</td><td>');
929:
930: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
931: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
932: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
933: if ($oldname ne '' && $oldname ne $newname) {
1.488 raeburn 934: my $shown = &LONCAPA::map::qtescape($newname);
935: if ($is_supp) {
936: $shown = &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($newname));
937: }
938: $r->print($shown);
1.329 droeschl 939: }
1.364 bisitz 940: }
1.329 droeschl 941: $r->print('<ul>');
942: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
943: if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
1.488 raeburn 944: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]);
945: if ($is_supp) {
946: $shown = &Apache::loncommon::parse_supplemental_title($shown);
947: }
948: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 949: }
950: }
951: $r->print('</ul>');
952: if ($docslog{$id}{'logentry'}{'parameter_res'}) {
953: $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
954: foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
955: if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
1.452 www 956: # FIXME: internationalization seems wrong here
1.329 droeschl 957: $r->print('<li>'.
958: &mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
959: $docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
960: .'</li>');
961: }
962: }
963: $r->print('</ul>');
964: }
965: # End
966: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
967: $shown++;
968: if (!($env{'form.show'} eq &mt('all')
969: || $shown<=$env{'form.show'})) { last; }
970: }
1.484 raeburn 971: $r->print(&Apache::loncommon::end_data_table()."\n".
972: &makesimpleeditform($pathitem)."\n".
973: '</div></div>');
974: $r->print(&endContentScreen());
1.329 droeschl 975: }
976:
977: sub update_paste_buffer {
1.492 raeburn 978: my ($coursenum,$coursedom,$folder) = @_;
1.538 raeburn 979: my (@possibles,%removals,%cuts);
980: if ($env{'form.multiremove'}) {
981: $env{'form.multiremove'} =~ s/,$//;
982: map { $removals{$_} = 1; } split(/,/,$env{'form.multiremove'});
983: }
984: if (($env{'form.multicopy'}) || ($env{'form.multicut'})) {
985: if ($env{'form.multicut'}) {
986: $env{'form.multicut'} =~ s/,$//;
987: foreach my $item (split(/,/,$env{'form.multicut'})) {
988: unless ($removals{$item}) {
989: $cuts{$item} = 1;
990: push(@possibles,$item.':cut');
991: }
992: }
993: }
994: if ($env{'form.multicopy'}) {
995: $env{'form.multicopy'} =~ s/,$//;
996: foreach my $item (split(/,/,$env{'form.multicopy'})) {
997: unless ($removals{$item} || $cuts{$item}) {
998: push(@possibles,$item.':copy');
999: }
1000: }
1001: }
1002: } elsif ($env{'form.markcopy'}) {
1003: @possibles = split(/,/,$env{'form.markcopy'});
1004: }
1.329 droeschl 1005:
1.538 raeburn 1006: return if (@possibles == 0);
1.329 droeschl 1007: return if (!defined($env{'form.copyfolder'}));
1008:
1009: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1010: $env{'form.copyfolder'});
1.538 raeburn 1011: return if ($fatal);
1012:
1013: my %curr_groups = &Apache::longroup::coursegroups();
1.364 bisitz 1014:
1.538 raeburn 1015: # Retrieve current paste buffer suffixes.
1016: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1017: my (%pasteurls,@newpaste);
1018:
1019: # Construct identifiers for current contents of user's paste buffer
1020: if (@currpaste) {
1021: foreach my $suffix (@currpaste) {
1022: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1023: my $url = $env{'docs.markedcopy_url_'.$suffix};
1024: if (($cid =~ /^$match_domain(?:_)$match_courseid$/) &&
1025: ($url ne '')) {
1.564 raeburn 1026: $pasteurls{$cid.'_'.$url} = 1;
1.538 raeburn 1027: }
1028: }
1029: }
1030:
1031: # Mark items for copying (skip any items already in user's paste buffer)
1032: my %addtoenv;
1033:
1034: foreach my $item (@possibles) {
1035: my ($orderidx,$cmd) = split(/:/,$item);
1036: next if ($orderidx =~ /\D/);
1037: next unless (($cmd eq 'cut') || ($cmd eq 'copy') || ($cmd eq 'remove'));
1038: my ($title,$url)=split(':',$LONCAPA::map::resources[$orderidx]);
1039: my %denied = &action_restrictions($coursenum,$coursedom,
1040: &LONCAPA::map::qtescape($url),
1041: $env{'form.folderpath'},\%curr_groups);
1042: next if ($denied{'copy'});
1043: $url=~s{http(:|:)//https(:|:)//}{https$2//};
1044: next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$url}));
1045: my ($suffix,$errortxt,$locknotfreed) =
1046: &new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste');
1047: push(@newpaste,$suffix);
1048: if ($locknotfreed) {
1049: return $locknotfreed;
1050: last;
1051: }
1052: if (&is_supplemental_title($title)) {
1053: &Apache::lonnet::appenv({'docs.markedcopy_supplemental_'.$suffix => $title});
1054: ($title) = &Apache::loncommon::parse_supplemental_title($title);
1055: }
1.329 droeschl 1056:
1.538 raeburn 1057: $addtoenv{'docs.markedcopy_title_'.$suffix} = $title,
1058: $addtoenv{'docs.markedcopy_url_'.$suffix} = $url,
1059: $addtoenv{'docs.markedcopy_cmd_'.$suffix} = $cmd,
1060: $addtoenv{'docs.markedcopy_crs_'.$suffix} = $env{'request.course.id'};
1061:
1062: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) {
1063: my $prefix = $1;
1064: my $subdir =$2;
1065: if ($subdir eq '') {
1066: $subdir = $prefix;
1.492 raeburn 1067: }
1.538 raeburn 1068: my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps);
1069: &contained_map_check($url,$folder,\%removefrommap,\%removeparam,\%addedmaps,
1070: \%hierarchy,\%titles,\%allmaps);
1071: if (ref($hierarchy{$url}) eq 'HASH') {
1072: my ($nested,$nestednames);
1073: &recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames);
1074: $nested =~ s/\&$//;
1075: $nestednames =~ s/\Q___&&&___\E$//;
1076: if ($nested ne '') {
1077: $addtoenv{'docs.markedcopy_nested_'.$suffix} = $nested;
1078: }
1079: if ($nestednames ne '') {
1080: $addtoenv{'docs.markedcopy_nestednames_'.$suffix} = $nestednames;
1081: }
1.492 raeburn 1082: }
1083: }
1084: }
1.538 raeburn 1085: if (@newpaste) {
1086: $addtoenv{'docs.markedcopies'} = join(',',(@currpaste,@newpaste));
1087: }
1.492 raeburn 1088: &Apache::lonnet::appenv(\%addtoenv);
1.329 droeschl 1089: delete($env{'form.markcopy'});
1090: }
1091:
1.492 raeburn 1092: sub recurse_uploaded_maps {
1093: my ($url,$dir,$hierarchy,$titlesref,$nestref,$namesref) = @_;
1094: if (ref($hierarchy->{$url}) eq 'HASH') {
1095: my @maps = map { $hierarchy->{$url}{$_}; } sort { $a <=> $b } (keys(%{$hierarchy->{$url}}));
1096: my @titles = map { $titlesref->{$url}{$_}; } sort { $a <=> $b } (keys(%{$titlesref->{$url}}));
1097: my (@uploaded,@names,%shorter);
1098: for (my $i=0; $i<@maps; $i++) {
1099: my ($inner) = ($maps[$i] =~ m{^/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_(\d+)\.(?:page|sequence)$});
1100: if ($inner ne '') {
1101: push(@uploaded,$inner);
1102: push(@names,&escape($titles[$i]));
1103: $shorter{$maps[$i]} = $inner;
1104: }
1105: }
1106: $$nestref .= "$dir:".join(',',@uploaded).'&';
1107: $$namesref .= "$dir:".(join(',',@names)).'___&&&___';
1108: foreach my $map (@maps) {
1109: if ($shorter{$map} ne '') {
1110: &recurse_uploaded_maps($map,$shorter{$map},$hierarchy,$titlesref,$nestref,$namesref);
1111: }
1112: }
1113: }
1114: return;
1115: }
1116:
1.329 droeschl 1117: sub print_paste_buffer {
1.492 raeburn 1118: my ($r,$container,$folder,$coursedom,$coursenum) = @_;
1.538 raeburn 1119: return if (!defined($env{'docs.markedcopies'}));
1.329 droeschl 1120:
1.538 raeburn 1121: unless (($env{'form.pastemarked'}) || ($env{'form.clearmarked'})) {
1122: return if ($env{'docs.markedcopies'} eq '');
1.488 raeburn 1123: }
1124:
1.538 raeburn 1125: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1126: my ($pasteitems,@pasteable);
1.575 ! raeburn 1127: my $clipboardcount = 0;
1.488 raeburn 1128:
1.538 raeburn 1129: # Construct identifiers for current contents of user's paste buffer
1130: foreach my $suffix (@currpaste) {
1131: next if ($suffix =~ /\D/);
1132: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1133: my $url = $env{'docs.markedcopy_url_'.$suffix};
1134: if (($cid =~ /^$match_domain\_$match_courseid$/) &&
1135: ($url ne '')) {
1.575 ! raeburn 1136: $clipboardcount ++;
1.538 raeburn 1137: my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent,
1138: $canpaste,$nopaste,$othercrs,$areachange);
1139: my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1];
1140: if ($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
1141: $is_external = 1;
1142: }
1143: if ($folder =~ /^supplemental/) {
1144: $canpaste = &supp_pasteable($env{'docs.markedcopy_url_'.$suffix});
1145: unless ($canpaste) {
1146: $nopaste = &mt('Paste into Supplemental Content unavailable.');
1147: }
1148: } else {
1149: $canpaste = 1;
1150: }
1151: if ($canpaste) {
1152: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1153: my $srcdom = $1;
1154: my $srcnum = $2;
1155: my $rem = $3;
1156: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
1157: $othercourse = 1;
1158: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1159: if ($canpaste) {
1.539 raeburn 1160: $othercrs = '<br />'.&mt('(from another course)');
1.538 raeburn 1161: }
1162: } else {
1163: $canpaste = 0;
1164: $nopaste = &mt('Paste from another course unavailable.');
1165: }
1166: }
1167: if ($rem =~ m{^(default|supplemental)_?(\d*)\.(?:page|sequence)$}) {
1168: my $prefix = $1;
1169: $parent = $2;
1170: if ($folder !~ /^\Q$prefix\E/) {
1171: $areachange = 1;
1172: }
1173: $is_uploaded_map = 1;
1.492 raeburn 1174: }
1175: }
1176: }
1.538 raeburn 1177: if ($canpaste) {
1178: push(@pasteable,$suffix);
1179: }
1180: my $buffer;
1181: if ($is_external) {
1182: $buffer = &mt('External Resource').': '.
1183: &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('.
1184: &LONCAPA::map::qtescape($url).')';
1185: } else {
1186: my $icon = &Apache::loncommon::icon($extension);
1187: if ($extension eq 'sequence' &&
1188: $url =~ m{/default_\d+\.sequence$}x) {
1189: $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
1190: $icon .= '/navmap.folder.closed.gif';
1191: }
1192: $buffer = '<img src="'.$icon.'" alt="" class="LC_icon" />'.
1193: ': '.
1194: &Apache::loncommon::parse_supplemental_title(
1195: &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}));
1196: }
1197: $pasteitems .= '<div class="LC_left_float">';
1198: my ($options,$onclick);
1199: if (($canpaste) && (!$areachange) && (!$othercourse) &&
1200: ($env{'docs.markedcopy_cmd_'.$suffix} eq 'cut')) {
1201: if (($is_uploaded_map) ||
1202: ($url =~ /(bulletinboard|smppg)$/) ||
1203: ($url =~ m{^/uploaded/$coursedom/$coursenum/(?:docs|supplemental)/(.+)$})) {
1204: $options = &paste_options($suffix,$is_uploaded_map,$parent);
1205: $onclick= 'onclick="showOptions(this,'."'$suffix'".');" ';
1206: }
1207: }
1208: $pasteitems .= '<label><input type="checkbox" name="pasting" id="pasting_'.$suffix.'" value="'.$suffix.'" '.$onclick.'/>'.$buffer.'</label>';
1209: if ($nopaste) {
1210: $pasteitems .= $nopaste;
1211: } else {
1212: if ($othercrs) {
1213: $pasteitems .= $othercrs;
1214: }
1215: if ($options) {
1216: $pasteitems .= $options;
1.492 raeburn 1217: }
1218: }
1.538 raeburn 1219: $pasteitems .= '</div>';
1220: }
1221: }
1222: if ($pasteitems eq '') {
1223: &Apache::lonnet::delenv('docs.markedcopies');
1224: }
1225: my ($pasteform,$form_start,$buttons,$form_end);
1226: if ($pasteitems) {
1227: $pasteitems .= '<div style="padding:0;clear:both;margin:0;border:0"></div>';
1.541 raeburn 1228: $form_start = '<form name="pasteform" action="/adm/coursedocs" method="post" onsubmit="return validateClipboard();">';
1.538 raeburn 1229: if (@pasteable) {
1.575 ! raeburn 1230: my $value = &mt('Paste to current folder');
! 1231: if ($container eq 'page') {
! 1232: $value = &mt('Paste to current page');
! 1233: }
! 1234: $buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.(' 'x2);
! 1235: }
! 1236: $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.(' 'x2);
! 1237: if ($clipboardcount > 1) {
! 1238: $buttons .=
! 1239: '<span style="text-decoration:line-through">'.(' 'x20).'</span>'.(' 'x2).
! 1240: '<input type="button" name="checkallclip" value="'.&mt('Check all').'" style="height:20px;" onclick="checkClipboard();" />'.
! 1241: (' 'x2).
! 1242: '<input type="button" name="uncheckallclip" value="'.&mt('Uncheck all').'" style="height:20px;" onclick="uncheckClipboard();" />'.
! 1243: (' 'x2);
1.492 raeburn 1244: }
1.575 ! raeburn 1245: $form_end = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'.
! 1246: '</form>';
1.538 raeburn 1247: } else {
1248: $pasteitems = &mt('Clipboard is empty');
1.488 raeburn 1249: }
1.538 raeburn 1250: $r->print($form_start
1251: .'<fieldset>'
1252: .'<legend>'.&mt('Clipboard').(' ' x2).$buttons.'</legend>'
1253: .$pasteitems
1254: .'</fieldset>'
1255: .$form_end);
1256: }
1257:
1258: sub paste_options {
1259: my ($suffix,$is_uploaded_map,$parent) = @_;
1260: my ($copytext,$movetext);
1261: if ($is_uploaded_map) {
1262: $copytext = &mt('Copy to new folder');
1263: $movetext = &mt('Move old');
1264: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /bulletinboard$/) {
1265: $copytext = &mt('Copy to new board');
1266: $movetext = &mt('Move (not posts)');
1267: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /smppg$/) {
1268: $copytext = &mt('Copy to new page');
1269: $movetext = &mt('Move');
1.533 raeburn 1270: } else {
1.538 raeburn 1271: $copytext = &mt('Copy to new file');
1272: $movetext = &mt('Move');
1273: }
1274: my $output = '<br />'.
1275: '<span id="pasteoptionstext_'.$suffix.'" class="LC_fontsize_small LC_nobreak"></span>'.
1276: '<div id="pasteoptions_'.$suffix.'" class="LC_dccid" style="display:none;"><span class="LC_nobreak">'.(' 'x 4).
1277: '<label>'.
1278: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="new" checked="checked" />'.
1279: $copytext.'</label></span>'.(' 'x2).' '.
1280: '<span class="LC_nobreak"><label>'.
1281: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="move" />'.
1282: $movetext.'</label></span>';
1283: if (($is_uploaded_map) && ($env{'docs.markedcopy_nested_'.$suffix})) {
1284: $output .= '<br /><fieldset><legend>'.&mt('Folder to paste contains sub-folders').
1285: '</legend><table border="0">';
1286: my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1287: my @titles = split(/\Q___&&&___\E/,$env{'docs.markedcopy_nestednames_'.$suffix});
1288: my $lastdir = $parent;
1289: my %depths = (
1290: $lastdir => 0,
1291: );
1292: my (%display,%deps);
1293: for (my $i=0; $i<@pastemaps; $i++) {
1294: ($lastdir,my $subfolderstr) = split(/\:/,$pastemaps[$i]);
1295: my ($namedir,$esctitlestr) = split(/\:/,$titles[$i]);
1296: my @subfolders = split(/,/,$subfolderstr);
1297: $deps{$lastdir} = \@subfolders;
1298: my @subfoldertitles = map { &unescape($_); } split(/,/,$esctitlestr);
1299: my $depth = $depths{$lastdir} + 1;
1300: my $offset = int($depth * 4);
1301: my $indent = (' ' x $offset);
1302: for (my $j=0; $j<@subfolders; $j++) {
1303: $depths{$subfolders[$j]} = $depth;
1304: $display{$subfolders[$j]} =
1305: '<tr><td>'.$indent.$subfoldertitles[$j].' </td>'.
1306: '<td><label>'.
1307: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="new" checked="checked" />'.&mt('Copy to new').'</label>'.(' ' x2).
1308: '<label>'.
1309: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="move" />'.
1310: &mt('Move old').'</label>'.
1311: '</td></tr>';
1312: }
1.492 raeburn 1313: }
1.538 raeburn 1314: &recurse_print(\$output,$parent,\%deps,\%display);
1315: $output .= '</table></fieldset>';
1.329 droeschl 1316: }
1.538 raeburn 1317: $output .= '</div>';
1318: return $output;
1.488 raeburn 1319: }
1320:
1.492 raeburn 1321: sub recurse_print {
1.538 raeburn 1322: my ($outputref,$dir,$deps,$display) = @_;
1323: $$outputref .= $display->{$dir}."\n";
1.492 raeburn 1324: if (ref($deps->{$dir}) eq 'ARRAY') {
1325: foreach my $subdir (@{$deps->{$dir}}) {
1.538 raeburn 1326: &recurse_print($outputref,$subdir,$deps,$display);
1.492 raeburn 1327: }
1328: }
1329: }
1330:
1.488 raeburn 1331: sub supp_pasteable {
1332: my ($url) = @_;
1333: if (($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//}) ||
1334: (($url =~ /\.sequence$/) && ($url =~ m{^/uploaded/})) ||
1335: ($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) ||
1336: ($url =~ m{^/adm/$match_domain/$match_username/aboutme}) ||
1337: ($url =~ m{^/public/$match_domain/$match_courseid/syllabus})) {
1338: return 1;
1339: }
1340: return;
1.329 droeschl 1341: }
1342:
1.492 raeburn 1343: sub paste_popup_js {
1344: my %lt = &Apache::lonlocal::texthash(
1.538 raeburn 1345: show => 'Show Options',
1346: hide => 'Hide Options',
1.541 raeburn 1347: none => 'No items selected from clipboard.',
1.492 raeburn 1348: );
1349: return <<"END";
1350:
1.538 raeburn 1351: function showPasteOptions(suffix) {
1352: document.getElementById('pasteoptions_'+suffix).style.display='block';
1353: document.getElementById('pasteoptionstext_'+suffix).innerHTML = ' <a href="javascript:hidePasteOptions(\\''+suffix+'\\');" class="LC_menubuttons_link">$lt{'hide'}</a>';
1.492 raeburn 1354: return;
1355: }
1356:
1.538 raeburn 1357: function hidePasteOptions(suffix) {
1358: document.getElementById('pasteoptions_'+suffix).style.display='none';
1359: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$lt{'show'}</a>';
1360: return;
1361: }
1362:
1363: function showOptions(caller,suffix) {
1364: if (document.getElementById('pasteoptionstext_'+suffix)) {
1365: if (caller.checked) {
1366: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$lt{'show'}</a>';
1367: } else {
1368: document.getElementById('pasteoptionstext_'+suffix).innerHTML ='';
1369: }
1370: if (document.getElementById('pasteoptions_'+suffix)) {
1371: document.getElementById('pasteoptions_'+suffix).style.display='none';
1372: }
1373: }
1.492 raeburn 1374: return;
1375: }
1376:
1.541 raeburn 1377: function validateClipboard() {
1378: var numchk = 0;
1379: if (document.pasteform.pasting.length > 1) {
1380: for (var i=0; i<document.pasteform.pasting.length; i++) {
1381: if (document.pasteform.pasting[i].checked) {
1382: numchk ++;
1383: }
1384: }
1385: } else {
1386: if (document.pasteform.pasting.type == 'checkbox') {
1387: if (document.pasteform.pasting.checked) {
1388: numchk ++;
1389: }
1390: }
1391: }
1392: if (numchk > 0) {
1393: return true;
1394: } else {
1395: alert("$lt{'none'}");
1396: return false;
1397: }
1398: }
1399:
1.575 ! raeburn 1400: function checkClipboard() {
! 1401: if (document.pasteform.pasting.length > 1) {
! 1402: for (var i=0; i<document.pasteform.pasting.length; i++) {
! 1403: document.pasteform.pasting[i].checked = true;
! 1404: }
! 1405: }
! 1406: return;
! 1407: }
! 1408:
! 1409: function uncheckClipboard() {
! 1410: if (document.pasteform.pasting.length >1) {
! 1411: for (var i=0; i<document.pasteform.pasting.length; i++) {
! 1412: document.pasteform.pasting[i].checked = false;
! 1413: }
! 1414: }
! 1415: return;
! 1416: }
! 1417:
1.492 raeburn 1418: END
1419:
1420: }
1421:
1.329 droeschl 1422: sub do_paste_from_buffer {
1.492 raeburn 1423: my ($coursenum,$coursedom,$folder,$container,$errors) = @_;
1.329 droeschl 1424:
1.538 raeburn 1425: # Array of items in paste buffer
1426: my (@currpaste,%pastebuffer,%allerrors);
1427: @currpaste = split(/,/,$env{'docs.markedcopies'});
1428:
1.492 raeburn 1429: # Early out if paste buffer is empty
1.538 raeburn 1430: if (@currpaste == 0) {
1.492 raeburn 1431: return ();
1.538 raeburn 1432: }
1433: map { $pastebuffer{$_} = 1; } @currpaste;
1434:
1435: # Array of items selected items to paste
1436: my @reqpaste = &Apache::loncommon::get_env_multiple('form.pasting');
1437:
1438: # Early out if nothing selected to paste
1439: if (@reqpaste == 0) {
1440: return();
1441: }
1442: my @topaste;
1443: foreach my $suffix (@reqpaste) {
1444: next if ($suffix =~ /\D/);
1445: next unless (exists($pastebuffer{$suffix}));
1446: push(@topaste,$suffix);
1447: }
1448:
1449: # Early out if nothing available to paste
1450: if (@topaste == 0) {
1451: return();
1.329 droeschl 1452: }
1453:
1.538 raeburn 1454: my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%duplicate,
1.564 raeburn 1455: %prefixchg,%srcdom,%srcnum,%marktomove,$save_err,$lockerrors,$allresult);
1.538 raeburn 1456:
1457: foreach my $suffix (@topaste) {
1458: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1.492 raeburn 1459: # Supplemental content may only include certain types of content
1460: # Early out if pasted content is not supported in Supplemental area
1.538 raeburn 1461: if ($folder =~ /^supplemental/) {
1462: unless (&supp_pasteable($url)) {
1463: $notinsupp{$suffix} = 1;
1464: next;
1465: }
1.492 raeburn 1466: }
1.538 raeburn 1467: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/}) {
1468: my $srcd = $1;
1469: my $srcn = $2;
1.492 raeburn 1470: # When paste buffer was populated using an active role in a different course
1.538 raeburn 1471: # check for mdc privilege in the course from which the resource was pasted
1472: if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1473: unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1474: $notincrs{$suffix} = 1;
1475: next;
1476: }
1.491 raeburn 1477: }
1.538 raeburn 1478: $srcdom{$suffix} = $srcd;
1479: $srcnum{$suffix} = $srcn;
1.491 raeburn 1480: }
1.538 raeburn 1481:
1482: push(@dopaste,$suffix);
1483: if ($url=~/\.(page|sequence)$/) {
1484: $is_map{$suffix} = 1;
1485: }
1486:
1487: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/([^/]+)}) {
1488: my $oldprefix = $1;
1.492 raeburn 1489: # When pasting content from Main Content to Supplemental Content and vice versa
1490: # URLs will contain different paths (which depend on whether pasted item is
1491: # a folder/page or a document.
1.538 raeburn 1492: if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) {
1493: $prefixchg{$suffix} = 'docstosupp';
1494: } elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) {
1495: $prefixchg{$suffix} = 'supptodocs';
1496: }
1.491 raeburn 1497:
1.492 raeburn 1498: # If pasting an uploaded map, get list of contained uploaded maps.
1.538 raeburn 1499: if ($env{'docs.markedcopy_nested_'.$suffix}) {
1500: my @nested;
1501: my ($type) = ($oldprefix =~ /^(default|supplemental)/);
1502: my @items = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1503: my @deps = map { /\d+:([\d,]+$)/ } @items;
1504: foreach my $dep (@deps) {
1505: if ($dep =~ /,/) {
1506: push(@nested,split(/,/,$dep));
1507: } else {
1508: push(@nested,$dep);
1509: }
1.492 raeburn 1510: }
1.538 raeburn 1511: foreach my $item (@nested) {
1512: if ($env{'form.docs.markedcopy_'.$suffix.'_'.$item} eq 'move') {
1513: push(@{$marktomove{$suffix}},$type.'_'.$item);
1514: }
1.492 raeburn 1515: }
1516: }
1.488 raeburn 1517: }
1518: }
1519:
1.538 raeburn 1520: # Early out if nothing available to paste
1521: if (@dopaste == 0) {
1522: return ();
1523: }
1524:
1525: # Populate message hash and hashes used for main content <=> supplemental content
1526: # changes
1527:
1528: %msgs = &Apache::lonlocal::texthash (
1529: notinsupp => 'Paste failed: content type is not supported within Supplemental Content',
1530: notincrs => 'Paste failed: Item is from a different course which you do not have rights to edit.',
1531: duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.',
1532: );
1533:
1534: %before = (
1535: docstosupp => {
1536: map => 'default',
1537: doc => 'docs',
1538: },
1539: supptodocs => {
1540: map => 'supplemental',
1541: doc => 'supplemental',
1542: },
1543: );
1544:
1545: %after = (
1546: docstosupp => {
1547: map => 'supplemental',
1548: doc => 'supplemental'
1549: },
1550: supptodocs => {
1551: map => 'default',
1552: doc => 'docs',
1553: },
1554: );
1555:
1556: # Retrieve information about all course maps in main content area
1557:
1558: my $allmaps = {};
1559: if ($folder =~ /^default/) {
1560: $allmaps =
1561: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
1562: $env{"course.$env{'request.course.id'}.home"},
1563: $env{'request.course.id'});
1564: }
1565:
1566: my (@toclear,%mapurls,%lockerrs,%msgerrs,%results);
1567:
1568: # Loop over the items to paste
1569: foreach my $suffix (@dopaste) {
1.329 droeschl 1570: # Maps need to be copied first
1.538 raeburn 1571: my (%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies,
1572: %dbcopies,%zombies,%params,%docmoves,%mapmoves,%mapchanges,%newsubdir,
1573: %newurls,%tomove);
1574: if (ref($marktomove{$suffix}) eq 'ARRAY') {
1575: map { $tomove{$_} = 1; } @{$marktomove{$suffix}};
1576: }
1577: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1578: my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1579: my $oldurl = $url;
1580: if ($is_map{$suffix}) {
1.491 raeburn 1581: # If pasting a map, check if map contains other maps
1.538 raeburn 1582: my (%hierarchy,%titles);
1583: &contained_map_check($url,$folder,\%removefrommap,\%removeparam,
1584: \%addedmaps,\%hierarchy,\%titles,$allmaps);
1585: if ($url=~ m{^/uploaded/}) {
1586: my $newurl;
1587: unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
1588: ($newurl,my $error) =
1589: &get_newmap_url($url,$folder,$prefixchg{$suffix},$coursedom,
1590: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1591: \$title,$allmaps,\%newurls);
1592: if ($error) {
1593: $allerrors{$suffix} = $error;
1594: next;
1595: }
1596: if ($newurl ne '') {
1597: if ($newurl ne $url) {
1598: if ($newurl =~ /(?:default|supplemental)_(\d+).(?:sequence|page)$/) {
1599: $newsubdir{$url} = $1;
1600: }
1601: $mapchanges{$url} = 1;
1.492 raeburn 1602: }
1.538 raeburn 1603: }
1604: }
1605: if (($srcdom{$suffix} ne $coursedom) ||
1606: ($srcnum{$suffix} ne $coursenum) ||
1607: ($prefixchg{$suffix}) || (($newurl ne '') && ($newurl ne $url))) {
1608: unless (&url_paste_fixups($url,$folder,$prefixchg{$suffix},
1609: $coursedom,$coursenum,$srcdom{$suffix},
1610: $srcnum{$suffix},$allmaps,\%rewrites,
1611: \%retitles,\%copies,\%dbcopies,
1612: \%zombies,\%params,\%mapmoves,
1613: \%mapchanges,\%tomove,\%newsubdir,
1614: \%newurls)) {
1615: $mapmoves{$url} = 1;
1616: }
1617: $url = $newurl;
1618: } elsif ($env{'docs.markedcopy_nested_'.$suffix}) {
1619: &url_paste_fixups($url,$folder,$prefixchg{$suffix},$coursedom,
1620: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1621: $allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies,
1622: \%zombies,\%params,\%mapmoves,\%mapchanges,
1623: \%tomove,\%newsubdir,\%newurls);
1624: }
1625: } elsif ($url=~m {^/res/}) {
1626: # published map can only exists once, so remove from paste buffer when done
1627: push(@toclear,$suffix);
1628: # if pasting published map (main content area only) check map not already in course
1629: if ($folder =~ /^default/) {
1630: if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) {
1631: $duplicate{$suffix} = 1;
1632: next;
1.492 raeburn 1633: }
1.491 raeburn 1634: }
1635: }
1.538 raeburn 1636: }
1637: if ($url=~ m{/(bulletinboard|smppg)$}) {
1638: my $prefix = $1;
1639: #need to copy the db contents to a new one, unless this is a move.
1640: my %info = (
1641: src => $url,
1642: cdom => $coursedom,
1643: cnum => $coursenum,
1644: );
1645: unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
1646: my (%lockerr,$msg);
1647: my ($newurl,$result,$errtext) =
1648: &dbcopy(\%info,$coursedom,$coursenum,\%lockerr);
1649: if ($result eq 'ok') {
1650: $url = $newurl;
1651: $title=&mt('Copy of').' '.$title;
1652: } else {
1653: if ($prefix eq 'smppg') {
1654: $msg = &mt('Paste failed: An error occurred when copying the simple page.').' '.$errtext;
1655: } elsif ($prefix eq 'bulletinboard') {
1.565 bisitz 1656: $msg = &mt('Paste failed: An error occurred when copying the discussion board.').' '.$errtext;
1.538 raeburn 1657: }
1658: $results{$suffix} = $result;
1659: $msgerrs{$suffix} = $msg;
1660: $lockerrs{$suffix} = $lockerr{$prefix};
1661: next;
1662: }
1663: if ($lockerr{$prefix}) {
1664: $lockerrs{$suffix} = $lockerr{$prefix};
1.491 raeburn 1665: }
1.489 raeburn 1666: }
1667: }
1.538 raeburn 1668: $title = &LONCAPA::map::qtunescape($title);
1669: my $ext='false';
1670: if ($url=~m{^http(|s)://}) { $ext='true'; }
1671: if ($env{'docs.markedcopy_supplemental_'.$suffix}) {
1672: if ($folder !~ /^supplemental/) {
1673: (undef,undef,$title) =
1674: &Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental_'.$suffix});
1675: }
1676: } else {
1677: if ($folder=~/^supplemental/) {
1678: $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
1679: $env{'user.domain'}.'___&&&___'.$title;
1.491 raeburn 1680: }
1.533 raeburn 1681: }
1.491 raeburn 1682:
1683: # For uploaded files (excluding pages/sequences) path in copied file is changed
1684: # if paste is from Main to Supplemental (or vice versa), or if pasting between
1685: # courses.
1686:
1.538 raeburn 1687: unless ($is_map{$suffix}) {
1688: my $newidx;
1.492 raeburn 1689: # Now insert the URL at the bottom
1.538 raeburn 1690: $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
1691: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(.+)$}) {
1692: my $relpath = $1;
1693: if ($relpath ne '') {
1694: my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$});
1695: my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/);
1696: my $newprefix = $newloc;
1697: if ($newloc eq 'default') {
1698: $newprefix = 'docs';
1699: }
1700: if ($newdocsdir eq '') {
1701: $newdocsdir = 'default';
1702: }
1703: if (($prefixchg{$suffix}) ||
1704: ($srcdom{$suffix} ne $coursedom) ||
1705: ($srcnum{$suffix} ne $coursenum) ||
1706: ($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) {
1707: my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";
1708: $url =
1709: &Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath,
1710: &Apache::lonnet::getfile($oldurl));
1711: if ($url eq '/adm/notfound.html') {
1712: $msgs{$suffix} = &mt('Paste failed: an error occurred saving the file.');
1713: next;
1714: } else {
1715: my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$});
1716: $newsubpath =~ s{/+$}{/};
1717: $docmoves{$oldurl} = $newsubpath;
1718: }
1.491 raeburn 1719: }
1720: }
1721: }
1.538 raeburn 1722: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
1723: ':'.$ext.':normal:res';
1724: push(@LONCAPA::map::order,$newidx);
1725: # Store the result
1726: my ($errtext,$fatal) =
1727: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1728: if ($fatal) {
1729: $save_err .= $errtext;
1730: $allresult = 'fail';
1731: }
1.488 raeburn 1732: }
1.538 raeburn 1733:
1.492 raeburn 1734: # Apply any changes to maps, or copy dependencies for uploaded HTML pages
1.538 raeburn 1735: unless ($allresult eq 'fail') {
1736: my %updated = (
1737: rewrites => \%rewrites,
1738: zombies => \%zombies,
1739: removefrommap => \%removefrommap,
1740: removeparam => \%removeparam,
1741: dbcopies => \%dbcopies,
1742: retitles => \%retitles,
1743: );
1744: my %info = (
1745: newsubdir => \%newsubdir,
1746: params => \%params,
1747: );
1748: if ($prefixchg{$suffix}) {
1749: $info{'before'} = $before{$prefixchg{$suffix}};
1750: $info{'after'} = $after{$prefixchg{$suffix}};
1751: }
1752: my %moves = (
1753: copies => \%copies,
1754: docmoves => \%docmoves,
1755: mapmoves => \%mapmoves,
1756: );
1757: (my $result,$msgs{$suffix},my $lockerror) =
1758: &apply_fixups($folder,$is_map{$suffix},$coursedom,$coursenum,$errors,
1759: \%updated,\%info,\%moves,$prefixchg{$suffix},$oldurl,
1760: $url,'paste');
1761: $lockerrors .= $lockerror;
1762: if ($result eq 'ok') {
1763: if ($is_map{$suffix}) {
1764: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1765: $folder.'.'.$container);
1766: if ($fatal) {
1767: $allresult = 'failread';
1768: } else {
1769: if ($#LONCAPA::map::order<1) {
1770: my $idx=&LONCAPA::map::getresidx();
1771: if ($idx<=0) { $idx=1; }
1772: $LONCAPA::map::order[0]=$idx;
1773: $LONCAPA::map::resources[$idx]='';
1774: }
1775: my $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
1776: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
1777: ':'.$ext.':normal:res';
1778: push(@LONCAPA::map::order,$newidx);
1.492 raeburn 1779:
1780: # Store the result
1.538 raeburn 1781: my ($errtext,$fatal) =
1782: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1783: if ($fatal) {
1784: $save_err .= $errtext;
1785: $allresult = 'failstore';
1786: }
1787: }
1788: }
1789: if ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
1790: push(@toclear,$suffix);
1791: }
1792: }
1.492 raeburn 1793: }
1794: }
1.538 raeburn 1795: &clear_from_buffer(\@toclear,\@currpaste);
1796: my $msgsarray;
1797: foreach my $suffix (keys(%msgs)) {
1798: if (ref($msgs{$suffix}) eq 'ARRAY') {
1799: $msgsarray .= join(',',@{$msgs{$suffix}});
1800: }
1801: }
1802: return ($allresult,$save_err,$msgsarray,$lockerrors);
1803: }
1.533 raeburn 1804:
1.538 raeburn 1805: sub do_buffer_empty {
1806: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1807: if (@currpaste == 0) {
1808: return &mt('Clipboard is already empty');
1809: }
1810: my @toclear = &Apache::loncommon::get_env_multiple('form.pasting');
1811: if (@toclear == 0) {
1812: return &mt('Nothing selected to clear from clipboard');
1813: }
1814: my $numdel = &clear_from_buffer(\@toclear,\@currpaste);
1815: if ($numdel) {
1816: return &mt('[quant,_1,item] cleared from clipboard',$numdel);
1817: } else {
1818: return &mt('Clipboard unchanged');
1.492 raeburn 1819: }
1.538 raeburn 1820: return;
1821: }
1822:
1823: sub clear_from_buffer {
1824: my ($toclear,$currpaste) = @_;
1825: return unless ((ref($toclear) eq 'ARRAY') && (ref($currpaste) eq 'ARRAY'));
1826: my %pastebuffer;
1827: map { $pastebuffer{$_} = 1; } @{$currpaste};
1828: my $numdel = 0;
1829: foreach my $suffix (@{$toclear}) {
1830: next if ($suffix =~ /\D/);
1831: next unless (exists($pastebuffer{$suffix}));
1832: my $regexp = 'docs.markedcopy_[a-z]+_'.$suffix;
1833: if (&Apache::lonnet::delenv($regexp,1) eq 'ok') {
1834: delete($pastebuffer{$suffix});
1835: $numdel ++;
1836: }
1837: }
1838: my $newbuffer = join(',',sort(keys(%pastebuffer)));
1839: &Apache::lonnet::appenv({'docs.markedcopies' => $newbuffer});
1840: return $numdel;
1.492 raeburn 1841: }
1842:
1843: sub get_newmap_url {
1844: my ($url,$folder,$prefixchg,$coursedom,$coursenum,$srcdom,$srcnum,
1845: $titleref,$allmaps,$newurls) = @_;
1846: my $newurl;
1847: if ($url=~ m{^/uploaded/}) {
1848: $$titleref=&mt('Copy of').' '.$$titleref;
1849: }
1850: my $now = time;
1851: my $suffix=$$.int(rand(100)).$now;
1852: my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
1853: if ($oldid =~ m{^(/uploaded/$match_domain/$match_courseid/)(\D+)(\d+)$}) {
1854: my $path = $1;
1855: my $prefix = $2;
1856: my $ancestor = $3;
1857: if (length($ancestor) > 10) {
1858: $ancestor = substr($ancestor,-10,10);
1859: }
1860: my $newid;
1861: if ($prefixchg) {
1862: if ($folder =~ /^supplemental/) {
1863: $prefix =~ s/^default/supplemental/;
1864: } else {
1865: $prefix =~ s/^supplemental/default/;
1866: }
1867: }
1868: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
1869: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
1870: } else {
1871: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$now.'.'.$ext;
1872: }
1873: my $counter = 0;
1874: my $is_unique = &uniqueness_check($newurl);
1875: if ($folder =~ /^default/) {
1876: if ($allmaps->{$newurl}) {
1877: $is_unique = 0;
1878: }
1879: }
1880: while ((!$is_unique || $allmaps->{$newurl} || $newurls->{$newurl}) && ($counter < 100)) {
1881: $counter ++;
1882: $suffix ++;
1883: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
1884: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
1885: } else {
1886: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$ancestor.$suffix.'.'.$ext;
1887: }
1888: $is_unique = &uniqueness_check($newurl);
1889: }
1890: if ($is_unique) {
1891: $newurls->{$newurl} = 1;
1892: } else {
1893: if ($url=~/\.page$/) {
1894: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the composite page'));
1895: } else {
1896: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the folder'));
1897: }
1898: }
1.329 droeschl 1899: }
1.492 raeburn 1900: return ($newurl);
1.329 droeschl 1901: }
1902:
1.488 raeburn 1903: sub dbcopy {
1.533 raeburn 1904: my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_;
1905: my ($url,$result,$errtext);
1.564 raeburn 1906: $url = $dbref->{'src'};
1.533 raeburn 1907: if (ref($dbref) eq 'HASH') {
1908: if ($url =~ m{/(smppg|bulletinboard)$}) {
1909: my $prefix = $1;
1910: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
1911: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
1912: my $db_name;
1913: my $marker = (split(m{/},$url))[4];
1914: $marker=~s/\D//g;
1915: if ($dbref->{'src'} =~ m{/smppg$}) {
1916: $db_name =
1917: &Apache::lonsimplepage::get_db_name($url,$marker,
1918: $dbref->{'cdom'},
1919: $dbref->{'cnum'});
1920: } else {
1921: $db_name = 'bulletinpage_'.$marker;
1922: }
1923: my ($suffix,$freedlock,$error) =
1924: &Apache::lonnet::get_timebased_id($prefix,'num','templated',
1925: $coursedom,$coursenum,
1926: 'concat');
1927: if (!$suffix) {
1928: if ($prefix eq 'smppg') {
1929: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);
1930: } else {
1.565 bisitz 1931: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url);
1.533 raeburn 1932: }
1933: if ($error) {
1934: $errtext .= '<br />'.$error;
1935: }
1936: } else {
1937: #need to copy the db contents to a new one.
1938: my %contents=&Apache::lonnet::dump($db_name,
1939: $dbref->{'cdom'},
1940: $dbref->{'cnum'});
1941: if (exists($contents{'uploaded.photourl'})) {
1942: my $photo = $contents{'uploaded.photourl'};
1943: my ($subdir,$fname) =
1944: ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});
1945: my $newphoto;
1946: if ($fname ne '') {
1947: my $content = &Apache::lonnet::getfile($photo);
1948: unless ($content eq '-1') {
1949: $env{'form.'.$suffix.'.photourl'} = $content;
1950: $newphoto =
1951: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");
1952: delete($env{'form.'.$suffix.'.photourl'});
1953: }
1954: }
1955: if ($newphoto =~ m{^/uploaded/}) {
1956: $contents{'uploaded.photourl'} = $newphoto;
1957: }
1958: }
1959: $db_name =~ s{_\d*$ }{_$suffix}x;
1960: $result=&Apache::lonnet::put($db_name,\%contents,
1961: $coursedom,$coursenum);
1962: if ($result eq 'ok') {
1963: $url =~ s{/(\d*)/(smppg|bulletinboard)$}{/$suffix/$2}x;
1964: }
1965: }
1966: if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) {
1.559 raeburn 1967: $lockerrorsref->{$prefix} =
1.533 raeburn 1968: '<div class="LC_error">'.
1969: &mt('There was a problem removing a lockfile.');
1970: if ($prefix eq 'smppg') {
1.560 raeburn 1971: $lockerrorsref->{$prefix} .=
1.559 raeburn 1972: ' '.&mt('This will prevent creation of additional simple pages in this course.');
1.533 raeburn 1973: } else {
1.565 bisitz 1974: $lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional discussion boards in this course.');
1.533 raeburn 1975: }
1.560 raeburn 1976: $lockerrorsref->{$prefix} .= ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
1977: '<a href="/adm/helpdesk" target="_helpdesk">','</a>').
1978: '</div>';
1.533 raeburn 1979: }
1980: }
1981: } elsif ($url =~ m{/syllabus$}) {
1982: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
1983: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
1984: if (($dbref->{'cdom'} ne $coursedom) ||
1985: ($dbref->{'cnum'} ne $coursenum)) {
1986: my %contents=&Apache::lonnet::dump('syllabus',
1987: $dbref->{'cdom'},
1988: $dbref->{'cnum'});
1989: $result=&Apache::lonnet::put('syllabus',\%contents,
1990: $coursedom,$coursenum);
1991: }
1992: }
1.488 raeburn 1993: }
1994: }
1.533 raeburn 1995: return ($url,$result,$errtext);
1.488 raeburn 1996: }
1997:
1.329 droeschl 1998: sub uniqueness_check {
1999: my ($newurl) = @_;
2000: my $unique = 1;
2001: foreach my $res (@LONCAPA::map::order) {
2002: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2003: $url=&LONCAPA::map::qtescape($url);
2004: if ($newurl eq $url) {
2005: $unique = 0;
1.344 bisitz 2006: last;
1.329 droeschl 2007: }
2008: }
2009: return $unique;
2010: }
2011:
1.488 raeburn 2012: sub contained_map_check {
1.492 raeburn 2013: my ($url,$folder,$removefrommap,$removeparam,$addedmaps,$hierarchy,$titles,
2014: $allmaps) = @_;
1.488 raeburn 2015: my $content = &Apache::lonnet::getfile($url);
2016: unless ($content eq '-1') {
2017: my $parser = HTML::TokeParser->new(\$content);
2018: $parser->attr_encoded(1);
2019: while (my $token = $parser->get_token) {
2020: next if ($token->[0] ne 'S');
2021: if ($token->[1] eq 'resource') {
2022: next if ($token->[2]->{'type'} eq 'zombie');
2023: my $ressrc = $token->[2]->{'src'};
2024: if ($folder =~ /^supplemental/) {
2025: unless (&supp_pasteable($ressrc)) {
1.492 raeburn 2026: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.488 raeburn 2027: next;
2028: }
2029: }
1.492 raeburn 2030: if ($ressrc =~ m{^/(res|uploaded)/.+\.(sequence|page)$}) {
2031: if ($1 eq 'uploaded') {
2032: $hierarchy->{$url}{$token->[2]->{'id'}} = $ressrc;
2033: $titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'};
1.488 raeburn 2034: } else {
1.492 raeburn 2035: if ($allmaps->{$ressrc}) {
1.529 raeburn 2036: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.492 raeburn 2037: } elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') {
2038: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2039: } else {
2040: $addedmaps->{$ressrc} = [$url];
2041: }
1.488 raeburn 2042: }
1.492 raeburn 2043: &contained_map_check($ressrc,$folder,$removefrommap,$removeparam,
2044: $addedmaps,$hierarchy,$titles,$allmaps);
1.488 raeburn 2045: }
1.492 raeburn 2046: } elsif ($token->[1] eq 'param') {
1.488 raeburn 2047: if ($folder =~ /^supplemental/) {
1.492 raeburn 2048: if (ref($removeparam->{$url}{$token->[2]->{'to'}}) eq 'ARRAY') {
2049: push(@{$removeparam->{$url}{$token->[2]->{'to'}}},$token->[2]->{'name'});
2050: } else {
2051: $removeparam->{$url}{$token->[2]->{'to'}} = [$token->[2]->{'name'}];
2052: }
1.488 raeburn 2053: }
2054: }
2055: }
2056: }
2057: return;
2058: }
2059:
2060: sub url_paste_fixups {
1.533 raeburn 2061: my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$fromcdom,$fromcnum,$allmaps,
2062: $rewrites,$retitles,$copies,$dbcopies,$zombies,$params,$mapmoves,
2063: $mapchanges,$tomove,$newsubdir,$newurls) = @_;
1.491 raeburn 2064: my $checktitle;
2065: if (($prefixchg) &&
1.492 raeburn 2066: ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) {
1.491 raeburn 2067: $checktitle = 1;
2068: }
1.492 raeburn 2069: my $skip;
2070: if ($oldurl =~ m{^\Q/uploaded/$cdom/$cnum/\E(default|supplemental)(_?\d*)\.(?:page|sequence)$}) {
2071: my $mapid = $1.$2;
2072: if ($tomove->{$mapid}) {
2073: $skip = 1;
2074: }
2075: }
1.491 raeburn 2076: my $file = &Apache::lonnet::getfile($oldurl);
1.488 raeburn 2077: return if ($file eq '-1');
2078: my $parser = HTML::TokeParser->new(\$file);
2079: $parser->attr_encoded(1);
1.491 raeburn 2080: my $changed = 0;
1.488 raeburn 2081: while (my $token = $parser->get_token) {
2082: next if ($token->[0] ne 'S');
2083: if ($token->[1] eq 'resource') {
2084: my $ressrc = $token->[2]->{'src'};
2085: next if ($ressrc eq '');
1.491 raeburn 2086: my $id = $token->[2]->{'id'};
1.492 raeburn 2087: my $title = $token->[2]->{'title'};
1.491 raeburn 2088: if ($checktitle) {
2089: if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1.532 raeburn 2090: $retitles->{$oldurl}{$id} = $ressrc;
1.491 raeburn 2091: }
2092: }
1.488 raeburn 2093: next if ($token->[2]->{'type'} eq 'external');
2094: if ($token->[2]->{'type'} eq 'zombie') {
1.492 raeburn 2095: next if ($skip);
1.532 raeburn 2096: $zombies->{$oldurl}{$id} = $ressrc;
1.491 raeburn 2097: $changed = 1;
2098: } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1.492 raeburn 2099: my $srcdom = $1;
2100: my $srcnum = $2;
1.488 raeburn 2101: my $rem = $3;
1.492 raeburn 2102: my $newurl;
2103: my $mapname;
2104: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
2105: my $prefix = $1;
2106: $mapname = $prefix.$2;
2107: if ($tomove->{$mapname}) {
1.533 raeburn 2108: &url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,
2109: $srcdom,$srcnum,$allmaps,$rewrites,
2110: $retitles,$copies,$dbcopies,$zombies,
2111: $params,$mapmoves,$mapchanges,$tomove,
2112: $newsubdir,$newurls);
1.492 raeburn 2113: next;
2114: } else {
2115: ($newurl,my $error) =
2116: &get_newmap_url($ressrc,$folder,$prefixchg,$cdom,$cnum,
2117: $srcdom,$srcnum,\$title,$allmaps,$newurls);
2118: if ($newurl =~ /(?:default|supplemental)_(\d+)\.(?:sequence|page)$/) {
2119: $newsubdir->{$ressrc} = $1;
2120: }
2121: if ($error) {
2122: next;
2123: }
2124: }
2125: }
2126: if (($srcdom ne $cdom) || ($srcnum ne $cnum) || ($prefixchg) ||
2127: ($mapchanges->{$oldurl}) || (($newurl ne '') && ($newurl ne $oldurl))) {
2128:
1.488 raeburn 2129: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
1.532 raeburn 2130: $rewrites->{$oldurl}{$id} = $ressrc;
1.491 raeburn 2131: $mapchanges->{$ressrc} = 1;
1.533 raeburn 2132: unless (&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,
2133: $cnum,$srcdom,$srcnum,$allmaps,
2134: $rewrites,$retitles,$copies,$dbcopies,
2135: $zombies,$params,$mapmoves,$mapchanges,
2136: $tomove,$newsubdir,$newurls)) {
1.491 raeburn 2137: $mapmoves->{$ressrc} = 1;
2138: }
2139: $changed = 1;
1.488 raeburn 2140: } else {
1.532 raeburn 2141: $rewrites->{$oldurl}{$id} = $ressrc;
1.488 raeburn 2142: $copies->{$oldurl}{$ressrc} = $id;
1.491 raeburn 2143: $changed = 1;
1.488 raeburn 2144: }
2145: }
1.533 raeburn 2146: } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/.+$}) {
2147: next if ($skip);
1.492 raeburn 2148: my $srcdom = $1;
2149: my $srcnum = $2;
2150: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.532 raeburn 2151: $rewrites->{$oldurl}{$id} = $ressrc;
1.533 raeburn 2152: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2153: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2154: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
2155: $changed = 1;
2156: }
2157: } elsif ($ressrc =~ m{^/adm/$match_domain/$match_username/\d+/(smppg|bulletinboard)$}) {
2158: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum) ||
2159: ($env{'form.docs.markedcopy_options'} ne 'move')) {
2160: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2161: $dbcopies->{$oldurl}{$id}{'cdom'} = $fromcdom;
2162: $dbcopies->{$oldurl}{$id}{'cnum'} = $fromcnum;
1.491 raeburn 2163: $changed = 1;
1.488 raeburn 2164: }
2165: } elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) {
1.492 raeburn 2166: next if ($skip);
2167: my $srcdom = $1;
2168: my $srcnum = $2;
2169: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.533 raeburn 2170: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2171: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2172: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
1.491 raeburn 2173: $changed = 1;
1.488 raeburn 2174: }
2175: }
2176: } elsif ($token->[1] eq 'param') {
1.492 raeburn 2177: next if ($skip);
1.488 raeburn 2178: my $to = $token->[2]->{'to'};
2179: if ($to ne '') {
2180: if (ref($params->{$oldurl}{$to}) eq 'ARRAY') {
1.492 raeburn 2181: push(@{$params->{$oldurl}{$to}},$token->[2]->{'name'});
1.488 raeburn 2182: } else {
2183: @{$params->{$oldurl}{$to}} = ($token->[2]->{'name'});
2184: }
2185: }
2186: }
2187: }
1.491 raeburn 2188: return $changed;
1.488 raeburn 2189: }
2190:
2191: sub apply_fixups {
1.529 raeburn 2192: my ($folder,$is_map,$cdom,$cnum,$errors,$updated,$info,$moves,$prefixchg,
2193: $oldurl,$url,$caller) = @_;
2194: my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles,
1.533 raeburn 2195: %params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs,
2196: %lockerrors,$lockmsg);
1.529 raeburn 2197: if (ref($updated) eq 'HASH') {
2198: if (ref($updated->{'rewrites'}) eq 'HASH') {
2199: %rewrites = %{$updated->{'rewrites'}};
2200: }
2201: if (ref($updated->{'zombies'}) eq 'HASH') {
2202: %zombies = %{$updated->{'zombies'}};
2203: }
2204: if (ref($updated->{'removefrommap'}) eq 'HASH') {
2205: %removefrommap = %{$updated->{'removefrommap'}};
2206: }
2207: if (ref($updated->{'removeparam'}) eq 'HASH') {
2208: %removeparam = %{$updated->{'removeparam'}};
2209: }
2210: if (ref($updated->{'dbcopies'}) eq 'HASH') {
2211: %dbcopies = %{$updated->{'dbcopies'}};
2212: }
2213: if (ref($updated->{'retitles'}) eq 'HASH') {
2214: %retitles = %{$updated->{'retitles'}};
2215: }
2216: }
2217: if (ref($info) eq 'HASH') {
2218: if (ref($info->{'newsubdir'}) eq 'HASH') {
2219: %newsubdir = %{$info->{'newsubdir'}};
2220: }
2221: if (ref($info->{'params'}) eq 'HASH') {
2222: %params = %{$info->{'params'}};
2223: }
2224: if (ref($info->{'before'}) eq 'HASH') {
2225: %before = %{$info->{'before'}};
2226: }
2227: if (ref($info->{'after'}) eq 'HASH') {
2228: %after = %{$info->{'after'}};
2229: }
2230: }
2231: if (ref($moves) eq 'HASH') {
2232: if (ref($moves->{'copies'}) eq 'HASH') {
2233: %copies = %{$moves->{'copies'}};
2234: }
2235: if (ref($moves->{'docmoves'}) eq 'HASH') {
2236: %docmoves = %{$moves->{'docmoves'}};
2237: }
2238: if (ref($moves->{'mapmoves'}) eq 'HASH') {
2239: %mapmoves = %{$moves->{'mapmoves'}};
2240: }
2241: }
2242: foreach my $key (keys(%copies),keys(%docmoves)) {
1.491 raeburn 2243: my @allcopies;
1.529 raeburn 2244: if (exists($copies{$key})) {
2245: if (ref($copies{$key}) eq 'HASH') {
2246: my %added;
2247: foreach my $innerkey (keys(%{$copies{$key}})) {
2248: if (($innerkey ne '') && (!$added{$innerkey})) {
2249: push(@allcopies,$innerkey);
2250: $added{$innerkey} = 1;
2251: }
1.491 raeburn 2252: }
1.529 raeburn 2253: undef(%added);
1.491 raeburn 2254: }
2255: }
2256: if ($key eq $oldurl) {
1.529 raeburn 2257: if ((exists($docmoves{$key}))) {
1.532 raeburn 2258: unless (grep(/^\Q$oldurl\E$/,@allcopies)) {
1.491 raeburn 2259: push(@allcopies,$oldurl);
2260: }
2261: }
2262: }
2263: if (@allcopies > 0) {
2264: foreach my $item (@allcopies) {
1.492 raeburn 2265: my ($relpath,$oldsubdir,$fname) =
2266: ($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(default|\d+)/.*/)([^/]+)$});
1.491 raeburn 2267: if ($fname ne '') {
2268: my $content = &Apache::lonnet::getfile($item);
2269: unless ($content eq '-1') {
2270: my $storefn;
1.529 raeburn 2271: if (($key eq $oldurl) && (exists($docmoves{$key}))) {
2272: $storefn = $docmoves{$key};
1.491 raeburn 2273: } else {
2274: $storefn = $relpath;
2275: $storefn =~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 2276: if ($prefixchg && $before{'doc'} && $after{'doc'}) {
2277: $storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/;
1.491 raeburn 2278: }
1.529 raeburn 2279: if ($newsubdir{$key}) {
1.532 raeburn 2280: $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}/#;
1.491 raeburn 2281: }
2282: }
2283: ©_dependencies($item,$storefn,$relpath,$errors,\$content);
2284: my $copyurl =
2285: &Apache::lonclonecourse::writefile($env{'request.course.id'},
2286: $storefn.$fname,$content);
2287: if ($copyurl eq '/adm/notfound.html') {
1.529 raeburn 2288: if (exists($docmoves{$oldurl})) {
1.491 raeburn 2289: return &mt('Paste failed: an error occurred copying the file.');
2290: } elsif (ref($errors) eq 'HASH') {
2291: $errors->{$item} = 1;
1.489 raeburn 2292: }
2293: }
1.488 raeburn 2294: }
2295: }
1.491 raeburn 2296: }
2297: }
2298: }
1.529 raeburn 2299: foreach my $key (keys(%mapmoves)) {
1.491 raeburn 2300: my $storefn=$key;
2301: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 2302: if ($prefixchg && $before{'map'} && $after{'map'}) {
2303: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.491 raeburn 2304: }
1.529 raeburn 2305: if ($newsubdir{$key}) {
2306: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.492 raeburn 2307: }
1.491 raeburn 2308: my $mapcontent = &Apache::lonnet::getfile($key);
2309: if ($mapcontent eq '-1') {
2310: if (ref($errors) eq 'HASH') {
2311: $errors->{$key} = 1;
2312: }
2313: } else {
2314: my $newmap =
2315: &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
2316: $mapcontent);
2317: if ($newmap eq '/adm/notfound.html') {
2318: if (ref($errors) eq 'HASH') {
2319: $errors->{$key} = 1;
1.489 raeburn 2320: }
1.488 raeburn 2321: }
2322: }
2323: }
1.491 raeburn 2324: my %updates;
2325: if ($is_map) {
1.529 raeburn 2326: if (ref($updated) eq 'HASH') {
2327: foreach my $type (keys(%{$updated})) {
2328: if (ref($updated->{$type}) eq 'HASH') {
2329: foreach my $key (keys(%{$updated->{$type}})) {
2330: $updates{$key} = 1;
2331: }
2332: }
2333: }
1.491 raeburn 2334: }
2335: foreach my $key (keys(%updates)) {
1.492 raeburn 2336: my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb);
1.529 raeburn 2337: if (ref($rewrites{$key}) eq 'HASH') {
2338: %torewrite = %{$rewrites{$key}};
1.491 raeburn 2339: }
1.529 raeburn 2340: if (ref($retitles{$key}) eq 'HASH') {
2341: %toretitle = %{$retitles{$key}};
1.491 raeburn 2342: }
1.529 raeburn 2343: if (ref($removefrommap{$key}) eq 'HASH') {
2344: %toremove = %{$removefrommap{$key}};
1.491 raeburn 2345: }
1.529 raeburn 2346: if (ref($removeparam{$key}) eq 'HASH') {
2347: %remparam = %{$removeparam{$key}};
1.492 raeburn 2348: }
1.529 raeburn 2349: if (ref($zombies{$key}) eq 'HASH') {
2350: %zombie = %{$zombies{$key}};
1.491 raeburn 2351: }
1.529 raeburn 2352: if (ref($dbcopies{$key}) eq 'HASH') {
1.533 raeburn 2353: foreach my $idx (keys(%{$dbcopies{$key}})) {
2354: if (ref($dbcopies{$key}{$idx}) eq 'HASH') {
2355: my ($newurl,$result,$errtext) =
2356: &dbcopy($dbcopies{$key}{$idx},$cdom,$cnum,\%lockerrors);
2357: if ($result eq 'ok') {
2358: $newdb{$idx} = $newurl;
2359: } elsif (ref($errors) eq 'HASH') {
2360: $errors->{$key} = 1;
2361: }
2362: push(@msgs,$errtext);
2363: }
1.491 raeburn 2364: }
2365: }
1.529 raeburn 2366: if (ref($params{$key}) eq 'HASH') {
2367: %currparam = %{$params{$key}};
1.492 raeburn 2368: }
2369: my ($errtext,$fatal) = &LONCAPA::map::mapread($key);
2370: if ($fatal) {
1.533 raeburn 2371: return ($errtext);
1.492 raeburn 2372: }
2373: for (my $i=0; $i<@LONCAPA::map::zombies; $i++) {
2374: if (defined($LONCAPA::map::zombies[$i])) {
2375: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::zombies[$i]);
1.532 raeburn 2376: if ($zombie{$i} eq $src) {
1.492 raeburn 2377: undef($LONCAPA::map::zombies[$i]);
2378: }
2379: }
2380: }
1.529 raeburn 2381: for (my $i=0; $i<@LONCAPA::map::order; $i++) {
2382: my $idx = $LONCAPA::map::order[$i];
2383: if (defined($LONCAPA::map::resources[$idx])) {
1.492 raeburn 2384: my $changed;
1.529 raeburn 2385: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]);
1.538 raeburn 2386: if ((exists($toremove{$idx})) &&
2387: ($toremove{$idx} eq &LONCAPA::map::qtescape($src))) {
1.492 raeburn 2388: splice(@LONCAPA::map::order,$i,1);
1.529 raeburn 2389: if (ref($currparam{$idx}) eq 'ARRAY') {
2390: foreach my $name (@{$currparam{$idx}}) {
2391: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
1.492 raeburn 2392: }
2393: }
2394: next;
2395: }
2396: my $origsrc = $src;
1.532 raeburn 2397: if ((exists($toretitle{$idx})) && ($toretitle{$idx} eq $src)) {
1.492 raeburn 2398: if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
2399: $changed = 1;
1.491 raeburn 2400: }
1.492 raeburn 2401: }
1.532 raeburn 2402: if ((exists($torewrite{$idx})) && ($torewrite{$idx} eq $src)) {
1.492 raeburn 2403: $src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
2404: if ($origsrc =~ m{^/uploaded/}) {
1.529 raeburn 2405: if ($prefixchg && $before{'map'} && $after{'map'}) {
1.492 raeburn 2406: if ($src =~ /\.(page|sequence)$/) {
1.529 raeburn 2407: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'map'}\E#$1$after{'map'}#;
1.492 raeburn 2408: } else {
1.529 raeburn 2409: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
1.488 raeburn 2410: }
1.491 raeburn 2411: }
1.532 raeburn 2412: if ($origsrc =~ /\.(page|sequence)$/) {
2413: if ($newsubdir{$origsrc}) {
1.529 raeburn 2414: $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir{$origsrc}#;
1.491 raeburn 2415: }
1.532 raeburn 2416: } elsif ($newsubdir{$key}) {
2417: $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$key}#;
1.488 raeburn 2418: }
2419: }
1.492 raeburn 2420: $changed = 1;
1.533 raeburn 2421: } elsif ($newdb{$idx} ne '') {
2422: $src = $newdb{$idx};
1.492 raeburn 2423: $changed = 1;
2424: }
2425: if ($changed) {
1.538 raeburn 2426: $LONCAPA::map::resources[$idx] = join(':',($title,&LONCAPA::map::qtunescape($src),$ext,$type));
1.492 raeburn 2427: }
2428: }
2429: }
2430: foreach my $idx (keys(%remparam)) {
2431: if (ref($remparam{$idx}) eq 'ARRAY') {
2432: foreach my $name (@{$remparam{$idx}}) {
2433: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
1.491 raeburn 2434: }
2435: }
2436: }
1.533 raeburn 2437: if (values(%lockerrors) > 0) {
2438: $lockmsg = join('<br />',values(%lockerrors));
2439: }
1.491 raeburn 2440: my $storefn;
2441: if ($key eq $oldurl) {
2442: $storefn = $url;
2443: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
2444: } else {
2445: $storefn = $key;
2446: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 2447: if ($prefixchg && $before{'map'} && $after{'map'}) {
2448: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.491 raeburn 2449: }
1.529 raeburn 2450: if ($newsubdir{$key}) {
2451: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.492 raeburn 2452: }
1.491 raeburn 2453: }
1.492 raeburn 2454: my $report;
2455: if ($folder !~ /^supplemental/) {
2456: $report = 1;
2457: }
1.527 raeburn 2458: (my $outtext,$errtext) =
1.492 raeburn 2459: &LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report);
2460: if ($errtext) {
1.529 raeburn 2461: if ($caller eq 'paste') {
1.533 raeburn 2462: return (&mt('Paste failed: an error occurred saving the folder or page.'));
1.529 raeburn 2463: }
1.491 raeburn 2464: }
2465: }
2466: }
1.533 raeburn 2467: return ('ok',\@msgs,$lockmsg);
1.491 raeburn 2468: }
2469:
2470: sub copy_dependencies {
2471: my ($item,$storefn,$relpath,$errors,$contentref) = @_;
2472: my $content;
2473: if (ref($contentref)) {
2474: $content = $$contentref;
2475: } else {
2476: $content = &Apache::lonnet::getfile($item);
2477: }
2478: unless ($content eq '-1') {
2479: my $mm = new File::MMagic;
2480: my $mimetype = $mm->checktype_contents($content);
2481: if ($mimetype eq 'text/html') {
2482: my (%allfiles,%codebase,$state);
2483: my $res = &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,\$content);
2484: if ($res eq 'ok') {
2485: my ($numexisting,$numpathchanges,$existing);
2486: (undef,$numexisting,$numpathchanges,$existing) =
2487: &Apache::loncommon::ask_for_embedded_content(
2488: '/adm/coursedocs',$state,\%allfiles,\%codebase,
2489: {'error_on_invalid_names' => 1,
2490: 'ignore_remote_references' => 1,
2491: 'docs_url' => $item,
2492: 'context' => 'paste'});
2493: if ($numexisting > 0) {
2494: if (ref($existing) eq 'HASH') {
2495: foreach my $dep (keys(%{$existing})) {
2496: my $depfile = $dep;
2497: unless ($depfile =~ m{^\Q$relpath\E}) {
2498: $depfile = $relpath.$dep;
2499: }
2500: my $depcontent = &Apache::lonnet::getfile($depfile);
2501: unless ($depcontent eq '-1') {
2502: my $storedep = $dep;
2503: $storedep =~ s{^\Q$relpath\E}{};
2504: my $dep_url =
2505: &Apache::lonclonecourse::writefile(
2506: $env{'request.course.id'},
2507: $storefn.$storedep,$depcontent);
2508: if ($dep_url eq '/adm/notfound.html') {
2509: if (ref($errors) eq 'HASH') {
2510: $errors->{$depfile} = 1;
2511: }
2512: } else {
2513: ©_dependencies($depfile,$storefn,$relpath,$errors,\$depcontent);
2514: }
2515: }
2516: }
1.488 raeburn 2517: }
2518: }
2519: }
2520: }
2521: }
2522: return;
2523: }
2524:
1.329 droeschl 2525: my %parameter_type = ( 'randompick' => 'int_pos',
2526: 'hiddenresource' => 'string_yesno',
2527: 'encrypturl' => 'string_yesno',
2528: 'randomorder' => 'string_yesno',);
2529: my $valid_parameters_re = join('|',keys(%parameter_type));
2530: # set parameters
2531: sub update_parameter {
1.537 raeburn 2532: if ($env{'form.changeparms'} eq 'all') {
2533: my (@allidx,@allmapidx,%allchecked,%currchecked);
2534: %allchecked = (
2535: 'hiddenresource' => {},
2536: 'encrypturl' => {},
2537: 'randompick' => {},
2538: 'randomorder' => {},
2539: );
2540: foreach my $which (keys(%allchecked)) {
2541: $env{'form.all'.$which} =~ s/,$//;
2542: if ($which eq 'randompick') {
2543: foreach my $item (split(/,/,$env{'form.all'.$which})) {
2544: my ($res,$value) = split(/:/,$item);
2545: if ($value =~ /^\d+$/) {
2546: $allchecked{$which}{$res} = $value;
2547: }
2548: }
2549: } else {
1.539 raeburn 2550: if ($env{'form.all'.$which}) {
2551: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.all'.$which});
2552: }
1.537 raeburn 2553: }
2554: }
2555: my $haschanges = 0;
2556: foreach my $res (@LONCAPA::map::order) {
2557: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2558: $name=&LONCAPA::map::qtescape($name);
2559: $url=&LONCAPA::map::qtescape($url);
2560: next unless ($name && $url);
2561: my $is_map;
2562: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
2563: $is_map = 1;
2564: }
2565: foreach my $which (keys(%allchecked)) {
2566: if (($which eq 'randompick' || $which eq 'randomorder')) {
2567: next if (!$is_map);
2568: }
2569: my $oldvalue = 0;
2570: my $newvalue = 0;
2571: if ($allchecked{$which}{$res}) {
2572: $newvalue = $allchecked{$which}{$res};
2573: }
2574: my $current = (&LONCAPA::map::getparameter($res,'parameter_'.$which))[0];
2575: if ($which eq 'randompick') {
2576: if ($current =~ /^(\d+)$/) {
2577: $oldvalue = $1;
2578: }
2579: } else {
2580: if ($current =~ /^yes$/i) {
2581: $oldvalue = 1;
2582: }
2583: }
2584: if ($oldvalue ne $newvalue) {
2585: $haschanges = 1;
2586: if ($newvalue) {
2587: my $storeval = 'yes';
2588: if ($which eq 'randompick') {
2589: $storeval = $newvalue;
2590: }
2591: &LONCAPA::map::storeparameter($res,'parameter_'.$which,
2592: $storeval,
2593: $parameter_type{$which});
2594: &remember_parms($res,$which,'set',$storeval);
2595: } elsif ($oldvalue) {
2596: &LONCAPA::map::delparameter($res,'parameter_'.$which);
2597: &remember_parms($res,$which,'del');
2598: }
2599: }
2600: }
2601: }
2602: return $haschanges;
2603: } else {
2604: return 0 if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
1.329 droeschl 2605:
1.537 raeburn 2606: my $which = $env{'form.changeparms'};
2607: my $idx = $env{'form.setparms'};
2608: if ($env{'form.'.$which.'_'.$idx}) {
2609: my $value = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx}
2610: : 'yes';
2611: &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $value,
2612: $parameter_type{$which});
2613: &remember_parms($idx,$which,'set',$value);
2614: } else {
2615: &LONCAPA::map::delparameter($idx,'parameter_'.$which);
1.329 droeschl 2616:
1.537 raeburn 2617: &remember_parms($idx,$which,'del');
2618: }
2619: return 1;
1.329 droeschl 2620: }
2621: }
2622:
2623:
2624: sub handle_edit_cmd {
2625: my ($coursenum,$coursedom) =@_;
1.543 raeburn 2626: if ($env{'form.cmd'} eq '') {
2627: return 0;
2628: }
1.329 droeschl 2629: my ($cmd,$idx)=split('_',$env{'form.cmd'});
2630:
2631: my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
2632: my ($title, $url, @rrest) = split(':', $ratstr);
2633:
1.538 raeburn 2634: if ($cmd eq 'remove') {
1.329 droeschl 2635: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
1.463 www 2636: ($url!~/$LONCAPA::assess_page_seq_re/)) {
1.329 droeschl 2637: &Apache::lonnet::removeuploadedurl($url);
2638: } else {
2639: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
2640: }
2641: splice(@LONCAPA::map::order, $idx, 1);
2642:
2643: } elsif ($cmd eq 'cut') {
2644: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
2645: splice(@LONCAPA::map::order, $idx, 1);
2646:
1.344 bisitz 2647: } elsif ($cmd eq 'up'
1.329 droeschl 2648: && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
2649: @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
2650:
2651: } elsif ($cmd eq 'down'
2652: && defined($LONCAPA::map::order[$idx+1])) {
2653: @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
2654:
2655: } elsif ($cmd eq 'rename') {
2656: my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
2657: if ($comment=~/\S/) {
2658: $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
2659: $comment.':'.join(':', $url, @rrest);
2660: }
2661: # Devalidate title cache
2662: my $renamed_url=&LONCAPA::map::qtescape($url);
2663: &Apache::lonnet::devalidate_title_cache($renamed_url);
1.538 raeburn 2664:
1.329 droeschl 2665: } else {
2666: return 0;
2667: }
2668: return 1;
2669: }
2670:
2671: sub editor {
1.458 raeburn 2672: my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
1.508 raeburn 2673: $supplementalflag,$orderhash,$iconpath,$pathitem)=@_;
1.519 raeburn 2674: my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
1.510 raeburn 2675: if ($allowed) {
1.519 raeburn 2676: (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
2677: $is_random_order,$container) =
1.510 raeburn 2678: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
2679: $r->print($breadcrumbtrail);
1.519 raeburn 2680: } elsif ($env{'form.folderpath'} =~ /\:1$/) {
2681: $container = 'page';
2682: } else {
2683: $container = 'sequence';
1.510 raeburn 2684: }
1.484 raeburn 2685:
1.525 raeburn 2686: my $jumpto;
2687:
2688: unless ($supplementalflag) {
1.546 raeburn 2689: $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
1.525 raeburn 2690: }
1.484 raeburn 2691:
2692: unless ($allowed) {
2693: $randompick = -1;
2694: }
2695:
1.329 droeschl 2696: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
2697: $folder.'.'.$container);
2698: return $errtext if ($fatal);
2699:
2700: if ($#LONCAPA::map::order<1) {
2701: my $idx=&LONCAPA::map::getresidx();
2702: if ($idx<=0) { $idx=1; }
2703: $LONCAPA::map::order[0]=$idx;
2704: $LONCAPA::map::resources[$idx]='';
2705: }
1.364 bisitz 2706:
1.329 droeschl 2707: # ------------------------------------------------------------ Process commands
2708:
2709: # ---------------- if they are for this folder and user allowed to make changes
2710: if (($allowed) && ($env{'form.folder'} eq $folder)) {
2711: # set parameters and change order
2712: &snapshotbefore();
2713:
2714: if (&update_parameter()) {
2715: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
2716: return $errtext if ($fatal);
2717: }
2718:
2719: if ($env{'form.newpos'} && $env{'form.currentpos'}) {
2720: # change order
2721: my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
2722: splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
2723:
2724: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
2725: return $errtext if ($fatal);
2726: }
1.364 bisitz 2727:
1.329 droeschl 2728: if ($env{'form.pastemarked'}) {
1.491 raeburn 2729: my %paste_errors;
1.533 raeburn 2730: my ($paste_res,$save_error,$pastemsgarray,$lockerror) =
1.492 raeburn 2731: &do_paste_from_buffer($coursenum,$coursedom,$folder,$container,
2732: \%paste_errors);
1.541 raeburn 2733: if (ref($pastemsgarray) eq 'ARRAY') {
2734: if (@{$pastemsgarray} > 0) {
2735: $r->print('<p class="LC_info">'.
2736: join('<br />',@{$pastemsgarray}).
1.533 raeburn 2737: '</p>');
2738: }
1.541 raeburn 2739: }
2740: if ($lockerror) {
2741: $r->print('<p class="LC_error">'.
2742: $lockerror.
2743: '</p>');
2744: }
2745: if ($save_error ne '') {
2746: return $save_error;
2747: }
2748: if ($paste_res) {
2749: my %errortext = &Apache::lonlocal::texthash (
2750: fail => 'Storage of folder contents failed',
2751: failread => 'Reading folder contents failed',
2752: failstore => 'Storage of folder contents failed',
2753: );
2754: if ($errortext{$paste_res}) {
2755: $r->print('<p class="LC_error">'.$errortext{$paste_res}.'</p>');
1.492 raeburn 2756: }
1.329 droeschl 2757: }
1.491 raeburn 2758: if (keys(%paste_errors) > 0) {
1.538 raeburn 2759: $r->print('<p class="LC_warning">'."\n".
1.491 raeburn 2760: &mt('The following files are either dependencies of a web page or references within a folder and/or composite page which could not be copied during the paste operation:')."\n".
2761: '<ul>'."\n");
2762: foreach my $key (sort(keys(%paste_errors))) {
2763: $r->print('<li>'.$key.'</li>'."\n");
2764: }
2765: $r->print('</ul></p>'."\n");
2766: }
1.538 raeburn 2767: } elsif ($env{'form.clearmarked'}) {
2768: my $output = &do_buffer_empty();
2769: if ($output) {
2770: $r->print('<p class="LC_info">'.$output.'</p>');
2771: }
2772: }
1.329 droeschl 2773:
2774: $r->print($upload_output);
2775:
1.538 raeburn 2776: # Rename, cut, copy or remove a single resource
1.329 droeschl 2777: if (&handle_edit_cmd()) {
1.492 raeburn 2778: my $contentchg;
1.538 raeburn 2779: if ($env{'form.cmd'} =~ m{^(del|cut)_}) {
1.492 raeburn 2780: $contentchg = 1;
2781: }
2782: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);
1.329 droeschl 2783: return $errtext if ($fatal);
2784: }
1.538 raeburn 2785:
2786: # Cut, copy and/or remove multiple resources
2787: if ($env{'form.multichange'}) {
2788: my %allchecked = (
2789: cut => {},
2790: remove => {},
2791: );
2792: my $needsupdate;
2793: foreach my $which (keys(%allchecked)) {
2794: $env{'form.multi'.$which} =~ s/,$//;
2795: if ($env{'form.multi'.$which}) {
2796: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.multi'.$which});
2797: if (ref($allchecked{$which}) eq 'HASH') {
2798: $needsupdate += scalar(keys(%{$allchecked{$which}}));
2799: }
2800: }
2801: }
2802: if ($needsupdate) {
2803: my $haschanges = 0;
2804: my %curr_groups = &Apache::longroup::coursegroups();
2805: my $total = scalar(@LONCAPA::map::order) - 1;
2806: for (my $i=$total; $i>=0; $i--) {
2807: my $res = $LONCAPA::map::order[$i];
2808: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2809: $name=&LONCAPA::map::qtescape($name);
2810: $url=&LONCAPA::map::qtescape($url);
2811: next unless ($name && $url);
2812: my %denied =
2813: &action_restrictions($coursenum,$coursedom,$url,
2814: $env{'form.folderpath'},\%curr_groups);
2815: foreach my $which (keys(%allchecked)) {
2816: next if ($denied{$which});
2817: next unless ($allchecked{$which}{$res});
2818: if ($which eq 'remove') {
2819: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
2820: ($url!~/$LONCAPA::assess_page_seq_re/)) {
2821: &Apache::lonnet::removeuploadedurl($url);
2822: } else {
2823: &LONCAPA::map::makezombie($res);
2824: }
2825: splice(@LONCAPA::map::order,$i,1);
2826: $haschanges ++;
2827: } elsif ($which eq 'cut') {
2828: &LONCAPA::map::makezombie($res);
2829: splice(@LONCAPA::map::order,$i,1);
2830: $haschanges ++;
2831: }
2832: }
2833: }
2834: if ($haschanges) {
2835: ($errtext,$fatal) =
2836: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
2837: return $errtext if ($fatal);
2838: }
2839: }
2840: }
2841:
1.329 droeschl 2842: # Group import/search
2843: if ($env{'form.importdetail'}) {
2844: my @imports;
2845: foreach my $item (split(/\&/,$env{'form.importdetail'})) {
2846: if (defined($item)) {
2847: my ($name,$url,$residx)=
1.533 raeburn 2848: map { &unescape($_); } split(/\=/,$item);
2849: if ($url =~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
2850: my ($suffix,$errortxt,$locknotfreed) =
2851: &new_timebased_suffix($coursedom,$coursenum,'map',$1,$2);
1.504 raeburn 2852: if ($locknotfreed) {
2853: $r->print($locknotfreed);
2854: }
2855: if ($suffix) {
2856: $url =~ s/_new\./_$suffix./;
2857: } else {
2858: return $errortxt;
2859: }
1.533 raeburn 2860: } elsif ($url =~ m{^/adm/$match_domain/$match_username/new/(smppg|bulletinboard)$}) {
2861: my $type = $1;
2862: my ($suffix,$errortxt,$locknotfreed) =
2863: &new_timebased_suffix($coursedom,$coursenum,$type);
2864: if ($locknotfreed) {
2865: $r->print($locknotfreed);
2866: }
2867: if ($suffix) {
2868: $url =~ s{^(/adm/$match_domain/$match_username)/new}{$1/$suffix};
2869: } else {
2870: return $errortxt;
2871: }
1.534 raeburn 2872: } elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) {
2873: if ($supplementalflag) {
2874: next unless ($1 eq 'supplemental');
2875: if ($folder eq 'supplemental') {
2876: next unless ($2 eq 'default');
2877: } else {
2878: next unless ($folder eq 'supplemental_'.$2);
2879: }
2880: } else {
2881: next unless ($1 eq 'docs');
2882: if ($folder eq 'default') {
2883: next unless ($2 eq 'default');
2884: } else {
2885: next unless ($folder eq 'default_'.$2);
2886: }
2887: }
1.504 raeburn 2888: }
1.329 droeschl 2889: push(@imports, [$name, $url, $residx]);
2890: }
2891: }
1.530 raeburn 2892: ($errtext,$fatal,my $fixuperrors) =
1.529 raeburn 2893: &group_import($coursenum, $coursedom, $folder,$container,
2894: 'londocs',@imports);
1.329 droeschl 2895: return $errtext if ($fatal);
1.529 raeburn 2896: if ($fixuperrors) {
2897: $r->print($fixuperrors);
2898: }
1.329 droeschl 2899: }
2900: # Loading a complete map
2901: if ($env{'form.loadmap'}) {
2902: if ($env{'form.importmap'}=~/\w/) {
2903: foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
2904: my ($title,$url,$ext,$type)=split(/\:/,$res);
2905: my $idx=&LONCAPA::map::getresidx($url);
2906: $LONCAPA::map::resources[$idx]=$res;
2907: $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
2908: }
2909: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.492 raeburn 2910: $folder.'.'.$container,1);
1.329 droeschl 2911: return $errtext if ($fatal);
2912: } else {
2913: $r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
1.364 bisitz 2914:
1.329 droeschl 2915: }
2916: }
2917: &log_differences($plain);
2918: }
2919: # ---------------------------------------------------------------- End commands
2920: # ---------------------------------------------------------------- Print screen
2921: my $idx=0;
2922: my $shown=0;
2923: if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
1.381 bisitz 2924: $r->print('<div class="LC_Box">'.
1.432 raeburn 2925: '<ol class="LC_docs_parameters"><li class="LC_docs_parameters_title">'.&mt('Parameters:').'</li>'.
2926: ($randompick>=0?'<li>'.&mt('randomly pick [quant,_1,resource]',$randompick).'</li>':'').
2927: ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
2928: ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
2929: ($is_random_order?'<li>'.&mt('random order').'</li>':'').
1.431 raeburn 2930: '</ol>');
1.381 bisitz 2931: if ($randompick>=0) {
2932: $r->print('<p class="LC_warning">'
2933: .&mt('Caution: this folder is set to randomly pick a subset'
2934: .' of resources. Adding or removing resources from this'
2935: .' folder will change the set of resources that the'
2936: .' students see, resulting in spurious or missing credit'
2937: .' for completed problems, not limited to ones you'
2938: .' modify. Do not modify the contents of this folder if'
2939: .' it is in active student use.')
2940: .'</p>'
2941: );
2942: }
2943: if ($is_random_order) {
2944: $r->print('<p class="LC_warning">'
2945: .&mt('Caution: this folder is set to randomly order its'
2946: .' contents. Adding or removing resources from this folder'
2947: .' will change the order of resources shown.')
2948: .'</p>'
2949: );
2950: }
2951: $r->print('</div>');
1.364 bisitz 2952: }
1.381 bisitz 2953:
1.538 raeburn 2954: my ($to_show,$output,@allidx,@allmapidx,%filters,%lists,%curr_groups);
2955: %filters = (
1.543 raeburn 2956: canremove => [],
2957: cancut => [],
2958: cancopy => [],
2959: hiddenresource => [],
2960: encrypturl => [],
2961: randomorder => [],
2962: randompick => [],
1.538 raeburn 2963: );
2964: %curr_groups = &Apache::longroup::coursegroups();
1.424 onken 2965: &Apache::loncommon::start_data_table_count(); #setup a row counter
1.381 bisitz 2966: foreach my $res (@LONCAPA::map::order) {
2967: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2968: $name=&LONCAPA::map::qtescape($name);
2969: $url=&LONCAPA::map::qtescape($url);
2970: unless ($name) { $name=(split(/\//,$url))[-1]; }
2971: unless ($name) { $idx++; next; }
1.537 raeburn 2972: push(@allidx,$res);
2973: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
2974: push(@allmapidx,$res);
2975: }
1.381 bisitz 2976: $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
1.501 raeburn 2977: $coursenum,$coursedom,$crstype,
1.538 raeburn 2978: $pathitem,$supplementalflag,$container,
2979: \%filters,\%curr_groups);
1.381 bisitz 2980: $idx++;
2981: $shown++;
1.329 droeschl 2982: }
1.424 onken 2983: &Apache::loncommon::end_data_table_count();
1.510 raeburn 2984:
1.538 raeburn 2985: my $need_save;
1.510 raeburn 2986: if (($allowed) || ($supplementalflag && $folder eq 'supplemental')) {
1.544 raeburn 2987: my $toolslink;
2988: if ($allowed || &Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
2989: $toolslink = '<table><tr><td>'
1.520 raeburn 2990: .&Apache::loncommon::help_open_menu('Navigation Screen',
2991: 'Navigation_Screen',undef,'RAT')
2992: .'</td><td class="LC_middle">'.&mt('Tools:').'</td>'
2993: .'<td align="left"><ul id="LC_toolbar">'
1.525 raeburn 2994: .'<li><a href="/adm/coursedocs?forcesupplement=1&command=editsupp" '
1.520 raeburn 2995: .'id="LC_content_toolbar_edittoplevel" '
2996: .'class="LC_toolbarItem" '
2997: .'title="'.&mt('Supplemental Content Editor').'">'
2998: .'</a></li></ul></td></tr></table><br />';
1.544 raeburn 2999: }
1.510 raeburn 3000: if ($shown) {
3001: if ($allowed) {
3002: $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
3003: .&Apache::loncommon::start_data_table(undef,'contentlist')
3004: .&Apache::loncommon::start_data_table_header_row()
3005: .'<th colspan="2">'.&mt('Move').'</th>'
1.538 raeburn 3006: .'<th colspan="2">'.&mt('Actions').'</th>'
3007: .'<th>'.&mt('Document').'</th>';
1.510 raeburn 3008: if ($folder !~ /^supplemental/) {
3009: $to_show .= '<th colspan="4">'.&mt('Settings').'</th>';
3010: }
1.537 raeburn 3011: $to_show .= &Apache::loncommon::end_data_table_header_row();
3012: if ($folder !~ /^supplemental/) {
1.538 raeburn 3013: $lists{'canhide'} = join(',',@allidx);
3014: $lists{'canrandomlyorder'} = join(',',@allmapidx);
1.543 raeburn 3015: my @possfilters = ('canremove','cancut','cancopy','hiddenresource','encrypturl',
3016: 'randomorder','randompick');
3017: foreach my $item (@possfilters) {
1.538 raeburn 3018: if (ref($filters{$item}) eq 'ARRAY') {
1.543 raeburn 3019: if (@{$filters{$item}} > 0) {
3020: $lists{$item} = join(',',@{$filters{$item}});
3021: }
1.538 raeburn 3022: }
3023: }
1.537 raeburn 3024: if (@allidx > 0) {
3025: my $path;
3026: if ($env{'form.folderpath'}) {
3027: $path =
3028: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3029: }
1.538 raeburn 3030: if (@allidx > 1) {
3031: $to_show .=
3032: &Apache::loncommon::continue_data_table_row().
3033: '<td colspan="2"> </td>'.
3034: '<td>'.
3035: &multiple_check_form('actions',\%lists).
3036: '</td>'.
3037: '<td> </td>'.
3038: '<td> </td>'.
3039: '<td colspan="4">'.
3040: &multiple_check_form('settings',\%lists).
3041: '</td>'.
3042: &Apache::loncommon::end_data_table_row();
3043: $need_save = 1;
3044: }
1.537 raeburn 3045: }
3046: }
3047: $to_show .= $output.' '
1.510 raeburn 3048: .&Apache::loncommon::end_data_table()
3049: .'<br style="line-height:2px;" />'
3050: .&Apache::loncommon::end_scrollbox();
3051: } else {
1.520 raeburn 3052: $to_show .= $toolslink
1.510 raeburn 3053: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3054: .$output.' '
3055: .&Apache::loncommon::end_data_table();
1.393 raeburn 3056: }
1.510 raeburn 3057: } else {
1.520 raeburn 3058: if (!$allowed) {
3059: $to_show .= $toolslink;
3060: }
1.510 raeburn 3061: $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
3062: .'<div class="LC_info" id="contentlist">'
1.550 raeburn 3063: .&mt('Currently empty')
1.510 raeburn 3064: .'</div>'
3065: .&Apache::loncommon::end_scrollbox();
1.393 raeburn 3066: }
3067: } else {
1.510 raeburn 3068: if ($shown) {
3069: $to_show = '<div>'
3070: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3071: .$output
3072: .&Apache::loncommon::end_data_table()
3073: .'</div>';
3074: } else {
3075: $to_show = '<div class="LC_info" id="contentlist">'
1.550 raeburn 3076: .&mt('Currently empty')
1.510 raeburn 3077: .'</div>'
3078: }
1.458 raeburn 3079: }
3080: my $tid = 1;
3081: if ($supplementalflag) {
3082: $tid = 2;
1.329 droeschl 3083: }
3084: if ($allowed) {
1.484 raeburn 3085: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
1.538 raeburn 3086: $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,
3087: $jumpto,$readfile,$need_save,"$folder.$container"));
1.492 raeburn 3088: &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
1.460 raeburn 3089: } else {
3090: $r->print($to_show);
1.329 droeschl 3091: }
3092: return;
3093: }
3094:
1.538 raeburn 3095: sub multiple_check_form {
3096: my ($caller,$listsref) = @_;
3097: return unless (ref($listsref) eq 'HASH');
3098: my $output =
3099: '<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'.
3100: '<span class="LC_nobreak" style="font-size:x-small;font-weight:bold;">'.
3101: '<label><input type="radio" name="showmultpick" value="0" onclick="javascript:togglePick('."'$caller','0'".');" checked="checked" />'.&mt('one').'</label>'.(' 'x2).'<label><input type="radio" name="showmultpick" value="1" onclick="javascript:togglePick('."'$caller','1'".');" />'.&mt('multiple').'</label></span><span id="more'.$caller.'" class="LC_nobreak LC_docs_ext_edit"></span></form>'.
3102: '<div id="multi'.$caller.'" style="display:none;margin:0;padding:0;border:0">'.
3103: '<form action="/adm/coursedocs" method="post" name="cumulative'.$caller.'">'."\n".
3104: '<fieldset id="allfields'.$caller.'" style="display:none"><legend style="font-size:x-small;">'.&mt('check/uncheck all').'</legend>'."\n";
3105: if ($caller eq 'settings') {
3106: $output .=
3107: '<table><tr>'.
3108: '<td class="LC_docs_entry_parameter">'.
3109: '<span class="LC_nobreak"><label>'.
3110: '<input type="checkbox" name="hiddenresourceall" id="hiddenresourceall" onclick="propagateState(this.form,'."'hiddenresource'".')" />'.&mt('Hidden').
3111: '</label></span></td>'.
3112: '<td class="LC_docs_entry_parameter">'.
3113: '<span class="LC_nobreak"><label><input type="checkbox" name="randompickall" id="randompickall" onclick="updatePick(this.form,'."'all','check'".');propagateState(this.form,'."'randompick'".');propagateState(this.form,'."'rpicknum'".');" />'.&mt('Randomly Pick').'</label><span id="rpicktextall"></span><input type="hidden" name="rpicknumall" id="rpicknumall" value="" />'.
3114: '</span></td>'.
3115: '</tr>'."\n".
3116: '<tr>'.
3117: '<td class="LC_docs_entry_parameter">'.
3118: '<span class="LC_nobreak"><label><input type="checkbox" name="encrypturlall" id="encrypturlall" onclick="propagateState(this.form,'."'encrypturl'".')" />'.&mt('URL hidden').'</label></span></td><td class="LC_docs_entry_parameter"><span class="LC_nobreak"><label><input type="checkbox" name="randomorderall" id="randomorderall" onclick="propagateState(this.form,'."'randomorder'".')" />'.&mt('Random Order').
3119: '</label></span>'.
3120: '</td></tr></table>'."\n";
3121: } else {
3122: $output .=
3123: '<table><tr>'.
3124: '<td class="LC_docs_entry_parameter">'.
3125: '<span class="LC_nobreak LC_docs_remove">'.
3126: '<label><input type="checkbox" name="removeall" id="removeall" onclick="propagateState(this.form,'."'remove'".')" />'.&mt('Remove').
3127: '</label></span></td>'.
3128: '<td class="LC_docs_entry_parameter">'.
3129: '<span class="LC_nobreak LC_docs_cut">'.
3130: '<label><input type="checkbox" name="cut" id="cutall" onclick="propagateState(this.form,'."'cut'".');" />'.&mt('Cut').
3131: '</label></span></td>'."\n".
3132: '<td class="LC_docs_entry_parameter">'.
3133: '<span class="LC_nobreak LC_docs_copy">'.
3134: '<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')" />'.&mt('Copy').
3135: '</label></span></td>'.
3136: '</tr></table>'."\n";
3137: }
3138: $output .=
3139: '</fieldset>'.
3140: '<input type="hidden" name="allidx" value="'.$listsref->{'canhide'}.'" />';
3141: if ($caller eq 'settings') {
3142: $output .=
1.543 raeburn 3143: '<input type="hidden" name="allmapidx" value="'.$listsref->{'canrandomlyorder'}.'" />'."\n".
3144: '<input type="hidden" name="currhiddenresource" value="'.$listsref->{'hiddenresource'}.'" />'."\n".
3145: '<input type="hidden" name="currencrypturl" value="'.$listsref->{'encrypturl'}.'" />'."\n".
3146: '<input type="hidden" name="currrandomorder" value="'.$listsref->{'randomorder'}.'" />'."\n".
3147: '<input type="hidden" name="currrandompick" value="'.$listsref->{'randompick'}.'" />'."\n";
1.538 raeburn 3148: } elsif ($caller eq 'actions') {
3149: $output .=
3150: '<input type="hidden" name="allremoveidx" id="allremoveidx" value="'.$listsref->{'canremove'}.'" />'.
3151: '<input type="hidden" name="allcutidx" id="allcutidx" value="'.$listsref->{'cancut'}.'" />'.
3152: '<input type="hidden" name="allcopyidx" id="allcopyidx" value="'.$listsref->{'cancopy'}.'" />';
3153: }
3154: $output .=
3155: '</form>'.
3156: '</div>';
3157: return $output;
3158: }
3159:
1.329 droeschl 3160: sub process_file_upload {
1.552 raeburn 3161: my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd,$crstype) = @_;
1.329 droeschl 3162: # upload a file, if present
1.552 raeburn 3163: my $filesize = length($env{'form.uploaddoc'});
3164: if (!$filesize) {
3165: $$upload_output = '<div class="LC_error">'.
3166: &mt('Unable to upload [_1]. (size = [_2] bytes)',
3167: '<span class="LC_filename">'.$env{'form.uploaddoc.filename'}.'</span>',
3168: $filesize).'<br />'.
3169: &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'<br />'.
3170: '</div>';
3171: return;
3172: }
3173: my $quotatype = 'unofficial';
3174: if ($crstype eq 'Community') {
3175: $quotatype = 'community';
3176: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.instcode'}) {
3177: $quotatype = 'official';
1.573 raeburn 3178: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
3179: $quotatype = 'textbook';
1.552 raeburn 3180: }
3181: if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) {
3182: $filesize = int($filesize/1000); #expressed in kb
3183: $$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course',
3184: $env{'form.uploaddoc.filename'},$filesize,'upload');
3185: return if ($$upload_output);
3186: }
1.440 raeburn 3187: my ($parseaction,$showupload,$nextphase,$mimetype);
3188: if ($env{'form.parserflag'}) {
1.329 droeschl 3189: $parseaction = 'parse';
3190: }
3191: my $folder=$env{'form.folder'};
3192: if ($folder eq '') {
3193: $folder='default';
3194: }
3195: if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
3196: my $errtext='';
3197: my $fatal=0;
3198: my $container='sequence';
1.519 raeburn 3199: if ($env{'form.folderpath'} =~ /:1$/) {
1.329 droeschl 3200: $container='page';
3201: }
3202: ($errtext,$fatal)=
1.534 raeburn 3203: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1.329 droeschl 3204: if ($#LONCAPA::map::order<1) {
3205: $LONCAPA::map::order[0]=1;
3206: $LONCAPA::map::resources[1]='';
3207: }
3208: my $destination = 'docs/';
3209: if ($folder =~ /^supplemental/) {
3210: $destination = 'supplemental/';
3211: }
3212: if (($folder eq 'default') || ($folder eq 'supplemental')) {
3213: $destination .= 'default/';
3214: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
3215: $destination .= $2.'/';
3216: }
1.534 raeburn 3217: if ($fatal) {
3218: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'</div>';
3219: return;
3220: }
1.440 raeburn 3221: # this is for a course, not a user, so set context to coursedoc.
1.329 droeschl 3222: my $newidx=&LONCAPA::map::getresidx();
3223: $destination .= $newidx;
1.439 raeburn 3224: my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination,
1.329 droeschl 3225: $parseaction,$allfiles,
1.440 raeburn 3226: $codebase,undef,undef,undef,undef,
3227: undef,undef,\$mimetype);
3228: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) {
3229: my $stored = $1;
3230: $showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'.
3231: $stored.'</span>').'</p>';
3232: } else {
3233: my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});
3234:
1.457 raeburn 3235: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>';
1.440 raeburn 3236: return;
3237: }
1.329 droeschl 3238: my $ext='false';
3239: if ($url=~m{^http://}) { $ext='true'; }
3240: $url = &LONCAPA::map::qtunescape($url);
3241: my $comment=$env{'form.comment'};
3242: $comment = &LONCAPA::map::qtunescape($comment);
3243: if ($folder=~/^supplemental/) {
3244: $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
3245: $env{'user.domain'}.'___&&&___'.$comment;
3246: }
3247:
3248: $LONCAPA::map::resources[$newidx]=
3249: $comment.':'.$url.':'.$ext.':normal:res';
3250: $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
3251: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.492 raeburn 3252: $folder.'.'.$container,1);
1.329 droeschl 3253: if ($fatal) {
1.457 raeburn 3254: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>';
1.440 raeburn 3255: return;
1.329 droeschl 3256: } else {
1.440 raeburn 3257: if ($parseaction eq 'parse' && $mimetype eq 'text/html') {
3258: $$upload_output = $showupload;
1.384 raeburn 3259: my $total_embedded = scalar(keys(%{$allfiles}));
1.329 droeschl 3260: if ($total_embedded > 0) {
1.440 raeburn 3261: my $uploadphase = 'upload_embedded';
3262: my $primaryurl = &HTML::Entities::encode($url,'<>&"');
3263: my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx);
3264: my ($embedded,$num) =
3265: &Apache::loncommon::ask_for_embedded_content(
3266: '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url});
3267: if ($embedded) {
3268: if ($num) {
3269: $$upload_output .=
3270: '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
3271: $nextphase = $uploadphase;
3272: } else {
3273: $$upload_output .= $embedded;
3274: }
3275: } else {
3276: $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
3277: }
1.329 droeschl 3278: } else {
1.440 raeburn 3279: $$upload_output .= &mt('No embedded items identified').'<br />';
1.329 droeschl 3280: }
1.457 raeburn 3281: $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
1.476 raeburn 3282: } elsif (&Apache::loncommon::is_archive_file($mimetype)) {
3283: $nextphase = 'decompress_uploaded';
3284: my $position = scalar(@LONCAPA::map::order)-1;
3285: my $noextract = &return_to_editor();
3286: my $archiveurl = &HTML::Entities::encode($url,'<>&"');
3287: my %archiveitems = (
3288: folderpath => $env{'form.folderpath'},
3289: cmd => $nextphase,
3290: newidx => $newidx,
3291: position => $position,
3292: phase => $nextphase,
1.477 raeburn 3293: comment => $comment,
1.480 raeburn 3294: );
3295: my ($destination,$dir_root) = &embedded_destination($coursenum,$coursedom);
3296: my @current = &get_dir_list($url,$coursenum,$coursedom,$newidx);
1.476 raeburn 3297: $$upload_output = $showupload.
3298: &Apache::loncommon::decompress_form($mimetype,
3299: $archiveurl,'/adm/coursedocs',$noextract,
1.480 raeburn 3300: \%archiveitems,\@current);
1.329 droeschl 3301: }
3302: }
3303: }
1.440 raeburn 3304: return $nextphase;
1.329 droeschl 3305: }
3306:
1.480 raeburn 3307: sub get_dir_list {
3308: my ($url,$coursenum,$coursedom,$newidx) = @_;
3309: my ($destination,$dir_root) = &embedded_destination();
3310: my ($dirlistref,$listerror) =
3311: &Apache::lonnet::dirlist("$dir_root/$destination/$newidx",$coursedom,$coursenum,1);
3312: my @dir_lines;
3313: my $dirptr=16384;
3314: if (ref($dirlistref) eq 'ARRAY') {
3315: foreach my $dir_line (sort
3316: {
3317: my ($afile)=split('&',$a,2);
3318: my ($bfile)=split('&',$b,2);
3319: return (lc($afile) cmp lc($bfile));
3320: } (@{$dirlistref})) {
3321: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
3322: $filename =~ s/\s+$//;
3323: next if ($filename =~ /^\.\.?$/);
3324: my $isdir = 0;
3325: if ($dirptr&$testdir) {
3326: $isdir = 1;
3327: }
3328: push(@dir_lines, [$filename,$dom,$isdir,$size,$mtime,$obs]);
3329: }
3330: }
3331: return @dir_lines;
3332: }
3333:
1.329 droeschl 3334: sub is_supplemental_title {
3335: my ($title) = @_;
3336: return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
3337: }
3338:
3339: # --------------------------------------------------------------- An entry line
3340:
3341: sub entryline {
1.501 raeburn 3342: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
1.538 raeburn 3343: $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups)=@_;
1.519 raeburn 3344: my ($foldertitle,$renametitle);
1.329 droeschl 3345: if (&is_supplemental_title($title)) {
1.488 raeburn 3346: ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
1.329 droeschl 3347: } else {
3348: $title=&HTML::Entities::encode($title,'"<>&\'');
3349: $renametitle=$title;
3350: $foldertitle=$title;
3351: }
3352:
3353: my $orderidx=$LONCAPA::map::order[$index];
1.364 bisitz 3354:
1.329 droeschl 3355: $renametitle=~s/\\/\\\\/g;
3356: $renametitle=~s/\"\;/\\\"/g;
3357: $renametitle=~s/ /%20/g;
1.379 bisitz 3358: my $line=&Apache::loncommon::start_data_table_row();
1.538 raeburn 3359: my ($form_start,$form_end,$form_common,$form_param);
1.329 droeschl 3360: # Edit commands
1.535 raeburn 3361: my ($esc_path, $path, $symb);
1.329 droeschl 3362: if ($env{'form.folderpath'}) {
3363: $esc_path=&escape($env{'form.folderpath'});
3364: $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3365: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
3366: }
1.505 raeburn 3367: my $isexternal;
1.510 raeburn 3368: if ($residx) {
1.501 raeburn 3369: my $currurl = $url;
3370: $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.505 raeburn 3371: if ($currurl =~ m{^/adm/wrapper/ext/}) {
3372: $isexternal = 1;
3373: }
1.510 raeburn 3374: if (!$supplementalflag) {
3375: my $path = 'uploaded/'.
3376: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
3377: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
3378: $symb = &Apache::lonnet::encode_symb($path.$folder.".$container",
3379: $residx,
3380: &Apache::lonnet::declutter($currurl));
3381: }
1.501 raeburn 3382: }
1.538 raeburn 3383: my ($renamelink,%lt,$ishash);
3384: if (ref($filtersref) eq 'HASH') {
3385: $ishash = 1;
3386: }
3387:
1.329 droeschl 3388: if ($allowed) {
1.538 raeburn 3389: $form_start = '
3390: <form action="/adm/coursedocs" method="post">
3391: ';
3392: $form_common=(<<END);
3393: <input type="hidden" name="folderpath" value="$path" />
3394: <input type="hidden" name="symb" value="$symb" />
3395: END
3396: $form_param=(<<END);
3397: <input type="hidden" name="setparms" value="$orderidx" />
3398: <input type="hidden" name="changeparms" value="0" />
3399: END
3400: $form_end = '</form>';
3401:
1.329 droeschl 3402: my $incindex=$index+1;
3403: my $selectbox='';
1.471 raeburn 3404: if (($#LONCAPA::map::order>0) &&
1.329 droeschl 3405: ((split(/\:/,
1.344 bisitz 3406: $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
3407: ne '') &&
1.329 droeschl 3408: ((split(/\:/,
1.344 bisitz 3409: $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1.329 droeschl 3410: ne '')) {
3411: $selectbox=
3412: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.373 bisitz 3413: '<select name="newpos" onchange="this.form.submit()">';
1.329 droeschl 3414: for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
3415: if ($i==$incindex) {
1.358 bisitz 3416: $selectbox.='<option value="" selected="selected">('.$i.')</option>';
1.329 droeschl 3417: } else {
3418: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
3419: }
3420: }
3421: $selectbox.='</select>';
3422: }
1.501 raeburn 3423: %lt=&Apache::lonlocal::texthash(
1.329 droeschl 3424: 'up' => 'Move Up',
3425: 'dw' => 'Move Down',
3426: 'rm' => 'Remove',
3427: 'ct' => 'Cut',
3428: 'rn' => 'Rename',
1.501 raeburn 3429: 'cp' => 'Copy',
3430: 'ex' => 'External Resource',
3431: 'ed' => 'Edit',
3432: 'pr' => 'Preview',
3433: 'sv' => 'Save',
3434: 'ul' => 'URL',
3435: 'ti' => 'Title',
3436: );
1.538 raeburn 3437: my %denied = &action_restrictions($coursenum,$coursedom,$url,
3438: $env{'form.folderpath'},
3439: $currgroups);
1.517 raeburn 3440: my ($copylink,$cutlink,$removelink);
1.329 droeschl 3441: my $skip_confirm = 0;
3442: if ( $folder =~ /^supplemental/
3443: || ($url =~ m{( /smppg$
3444: |/syllabus$
3445: |/aboutme$
3446: |/navmaps$
3447: |/bulletinboard$
1.505 raeburn 3448: |\.html$)}x)
3449: || $isexternal) {
1.329 droeschl 3450: $skip_confirm = 1;
3451: }
3452:
1.538 raeburn 3453: if ($denied{'copy'}) {
1.543 raeburn 3454: $copylink=(<<ENDCOPY)
1.507 raeburn 3455: <span style="visibility: hidden;">$lt{'cp'}</span>
3456: ENDCOPY
3457: } else {
1.538 raeburn 3458: my $formname = 'edit_copy_'.$orderidx;
3459: my $js = "javascript:checkForSubmit(document.forms.renameform,'copy','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.329 droeschl 3460: $copylink=(<<ENDCOPY);
1.538 raeburn 3461: <form name="$formname" method="post" action="/adm/coursedocs">
3462: $form_common
1.540 raeburn 3463: <input type="checkbox" name="copy" id="copy_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','copy');" class="LC_hidden" /><a href="$js" class="LC_docs_copy">$lt{'cp'}</a>
1.538 raeburn 3464: $form_end
1.329 droeschl 3465: ENDCOPY
1.538 raeburn 3466: if (($ishash) && (ref($filtersref->{'cancopy'}) eq 'ARRAY')) {
3467: push(@{$filtersref->{'cancopy'}},$orderidx);
3468: }
1.329 droeschl 3469: }
1.538 raeburn 3470: if ($denied{'cut'}) {
1.507 raeburn 3471: $cutlink=(<<ENDCUT);
3472: <span style="visibility: hidden;">$lt{'ct'}</span>
3473: ENDCUT
3474: } else {
1.538 raeburn 3475: my $formname = 'edit_cut_'.$orderidx;
3476: my $js = "javascript:checkForSubmit(document.forms.renameform,'cut','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.329 droeschl 3477: $cutlink=(<<ENDCUT);
1.538 raeburn 3478: <form name="$formname" method="post" action="/adm/coursedocs">
3479: $form_common
1.542 raeburn 3480: <input type="hidden" name="skip_$orderidx" id="skip_cut_$orderidx" value="$skip_confirm" />
1.540 raeburn 3481: <input type="checkbox" name="cut" id="cut_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','cut');" class="LC_hidden" /><a href="$js" class="LC_docs_cut">$lt{'ct'}</a>
1.538 raeburn 3482: $form_end
1.329 droeschl 3483: ENDCUT
1.538 raeburn 3484: if (($ishash) && (ref($filtersref->{'cancut'}) eq 'ARRAY')) {
3485: push(@{$filtersref->{'cancut'}},$orderidx);
3486: }
1.329 droeschl 3487: }
1.538 raeburn 3488: if ($denied{'remove'}) {
1.507 raeburn 3489: $removelink=(<<ENDREM);
3490: <span style="visibility: hidden;">$lt{'rm'}</a>
3491: ENDREM
3492: } else {
1.538 raeburn 3493: my $formname = 'edit_remove_'.$orderidx;
3494: my $js = "javascript:checkForSubmit(document.forms.renameform,'remove','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm);";
1.497 raeburn 3495: $removelink=(<<ENDREM);
1.538 raeburn 3496: <form name="$formname" method="post" action="/adm/coursedocs">
3497: $form_common
1.542 raeburn 3498: <input type="hidden" name="skip_$orderidx" id="skip_remove_$orderidx" value="$skip_confirm" />
1.540 raeburn 3499: <input type="checkbox" name="remove" id="remove_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','remove');" class="LC_hidden" /><a href="$js" class="LC_docs_remove">$lt{'rm'}</a>
1.538 raeburn 3500: $form_end
1.497 raeburn 3501: ENDREM
1.538 raeburn 3502: if (($ishash) && (ref($filtersref->{'canremove'}) eq 'ARRAY')) {
3503: push(@{$filtersref->{'canremove'}},$orderidx);
3504: }
1.497 raeburn 3505: }
1.551 raeburn 3506: $renamelink=(<<ENDREN);
1.519 raeburn 3507: <a href='javascript:changename("$esc_path","$index","$renametitle");' class="LC_docs_rename">$lt{'rn'}</a>
1.507 raeburn 3508: ENDREN
1.329 droeschl 3509: $line.=(<<END);
3510: <td>
1.379 bisitz 3511: <div class="LC_docs_entry_move">
1.535 raeburn 3512: <a href='/adm/coursedocs?cmd=up_$index&folderpath=$esc_path&symb=$symb'>
1.501 raeburn 3513: <img src="${iconpath}move_up.gif" alt="$lt{'up'}" class="LC_icon" />
1.379 bisitz 3514: </a>
3515: </div>
3516: <div class="LC_docs_entry_move">
1.536 raeburn 3517: <a href='/adm/coursedocs?cmd=down_$index&folderpath=$esc_path&symb=$symb'>
1.501 raeburn 3518: <img src="${iconpath}move_down.gif" alt="$lt{'dw'}" class="LC_icon" />
1.379 bisitz 3519: </a>
3520: </div>
1.329 droeschl 3521: </td>
3522: <td>
3523: $form_start
1.538 raeburn 3524: $form_param
1.478 raeburn 3525: $form_common
1.329 droeschl 3526: $selectbox
3527: $form_end
3528: </td>
1.540 raeburn 3529: <td class="LC_docs_entry_commands LC_nobreak">
1.497 raeburn 3530: $removelink
1.329 droeschl 3531: $cutlink
3532: $copylink
3533: </td>
3534: END
3535: }
3536: # Figure out what kind of a resource this is
3537: my ($extension)=($url=~/\.(\w+)$/);
3538: my $uploaded=($url=~/^\/*uploaded\//);
3539: my $icon=&Apache::loncommon::icon($url);
1.519 raeburn 3540: my $isfolder;
3541: my $ispage;
3542: my $containerarg;
1.329 droeschl 3543: if ($uploaded) {
1.472 raeburn 3544: if (($extension eq 'sequence') || ($extension eq 'page')) {
3545: $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
1.519 raeburn 3546: $containerarg = $1;
1.472 raeburn 3547: if ($extension eq 'sequence') {
3548: $icon=$iconpath.'navmap.folder.closed.gif';
3549: $isfolder=1;
3550: } else {
3551: $icon=$iconpath.'page.gif';
3552: $ispage=1;
3553: }
3554: if ($allowed) {
3555: $url='/adm/coursedocs?';
3556: } else {
3557: $url='/adm/supplemental?';
3558: }
1.329 droeschl 3559: } else {
3560: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
3561: }
3562: }
1.364 bisitz 3563:
1.518 raeburn 3564: my ($editlink,$extresform);
1.329 droeschl 3565: my $orig_url = $url;
1.340 raeburn 3566: $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
1.510 raeburn 3567: $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.501 raeburn 3568: if (!$supplementalflag && $residx && $symb) {
3569: if ((!$isfolder) && (!$ispage)) {
3570: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
3571: $url=&Apache::lonnet::clutter($url);
3572: if ($url=~/^\/*uploaded\//) {
3573: $url=~/\.(\w+)$/;
3574: my $embstyle=&Apache::loncommon::fileembstyle($1);
3575: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
3576: $url='/adm/wrapper'.$url;
3577: } elsif ($embstyle eq 'ssi') {
3578: #do nothing with these
3579: } elsif ($url!~/\.(sequence|page)$/) {
3580: $url='/adm/coursedocs/showdoc'.$url;
3581: }
3582: } elsif ($url=~m|^/ext/|) {
3583: $url='/adm/wrapper'.$url;
1.329 droeschl 3584: }
1.501 raeburn 3585: if (&Apache::lonnet::symbverify($symb,$url)) {
3586: $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
3587: } else {
3588: $url='';
3589: }
1.329 droeschl 3590: }
3591: }
1.478 raeburn 3592: my ($rand_pick_text,$rand_order_text);
1.519 raeburn 3593: if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') {
1.329 droeschl 3594: my $foldername=&escape($foldertitle);
3595: my $folderpath=$env{'form.folderpath'};
3596: if ($folderpath) { $folderpath.='&' };
1.510 raeburn 3597: if (!$allowed && $supplementalflag) {
1.519 raeburn 3598: $folderpath.=$containerarg.'&'.$foldername;
1.510 raeburn 3599: $url.='folderpath='.&escape($folderpath);
3600: } else {
1.344 bisitz 3601: # Append randompick number, hidden, and encrypted with ":" to foldername,
1.329 droeschl 3602: # so it gets transferred between levels
1.519 raeburn 3603: $folderpath.=$containerarg.'&'.$foldername.
1.510 raeburn 3604: ':'.(&LONCAPA::map::getparameter($orderidx,
1.329 droeschl 3605: 'parameter_randompick'))[0]
3606: .':'.((&LONCAPA::map::getparameter($orderidx,
3607: 'parameter_hiddenresource'))[0]=~/^yes$/i)
3608: .':'.((&LONCAPA::map::getparameter($orderidx,
3609: 'parameter_encrypturl'))[0]=~/^yes$/i)
3610: .':'.((&LONCAPA::map::getparameter($orderidx,
1.519 raeburn 3611: 'parameter_randomorder'))[0]=~/^yes$/i)
3612: .':'.$ispage;
1.510 raeburn 3613: $url.='folderpath='.&escape($folderpath);
3614: my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
3615: 'parameter_randompick'))[0];
3616: my $rpckchk;
3617: if ($rpicknum) {
3618: $rpckchk = ' checked="checked"';
1.543 raeburn 3619: if (($ishash) && (ref($filtersref->{'randompick'}) eq 'ARRAY')) {
3620: push(@{$filtersref->{'randompick'}},$orderidx.':'.$rpicknum);
3621: }
1.510 raeburn 3622: }
1.537 raeburn 3623: my $formname = 'edit_randompick_'.$orderidx;
1.510 raeburn 3624: $rand_pick_text =
1.478 raeburn 3625: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.538 raeburn 3626: $form_param."\n".
1.478 raeburn 3627: $form_common."\n".
1.537 raeburn 3628: '<span class="LC_nobreak"><label><input type="checkbox" name="randompick_'.$orderidx.'" id="randompick_'.$orderidx.'" onclick="'."updatePick(this.form,'$orderidx','check');".'"'.$rpckchk.' /> '.&mt('Randomly Pick').'</label><input type="hidden" name="rpicknum_'.$orderidx.'" id="rpicknum_'.$orderidx.'" value="'.$rpicknum.'" /><span id="randompicknum_'.$orderidx.'">';
1.510 raeburn 3629: if ($rpicknum ne '') {
3630: $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
3631: }
1.537 raeburn 3632: $rand_pick_text .= '</span></span>'.
3633: $form_end;
1.543 raeburn 3634: my $ro_set;
3635: if ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i) {
3636: $ro_set = 'checked="checked"';
3637: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
3638: push(@{$filtersref->{'randomorder'}},$orderidx);
3639: }
3640: }
1.564 raeburn 3641: $formname = 'edit_rorder_'.$orderidx;
1.510 raeburn 3642: $rand_order_text =
1.537 raeburn 3643: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.538 raeburn 3644: $form_param."\n".
1.537 raeburn 3645: $form_common."\n".
1.538 raeburn 3646: '<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.' /> '.&mt('Random Order').' </label></span>'.
1.537 raeburn 3647: $form_end;
1.510 raeburn 3648: }
1.509 raeburn 3649: } elsif ($supplementalflag && !$allowed) {
1.510 raeburn 3650: $url .= ($url =~ /\?/) ? '&':'?';
1.509 raeburn 3651: $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
1.510 raeburn 3652: if ($title) {
3653: $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"');
3654: }
1.511 raeburn 3655: if ($isexternal && $orderidx) {
1.510 raeburn 3656: $url .= '&idx='.$orderidx;
3657: }
1.329 droeschl 3658: }
1.519 raeburn 3659: my ($tdalign,$tdwidth);
1.501 raeburn 3660: if ($allowed) {
3661: my $fileloc =
3662: &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
1.510 raeburn 3663: if ($isexternal) {
1.518 raeburn 3664: ($editlink,$extresform) =
1.510 raeburn 3665: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem);
1.511 raeburn 3666: } elsif (!$isfolder && !$ispage) {
1.503 raeburn 3667: my ($cfile,$home,$switchserver,$forceedit,$forceview) =
3668: &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
1.511 raeburn 3669: if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
1.501 raeburn 3670: my $jscall =
3671: &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
3672: $switchserver,
1.503 raeburn 3673: $forceedit,
1.511 raeburn 3674: undef,$symb,
3675: &escape($env{'form.folderpath'}),
1.524 raeburn 3676: $renametitle,'','',1);
1.501 raeburn 3677: if ($jscall) {
1.518 raeburn 3678: $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
3679: $jscall.'" >'.&mt('Edit').'</a> '."\n";
1.501 raeburn 3680: }
3681: }
3682: }
1.519 raeburn 3683: $tdalign = ' align="right" valign="top"';
3684: $tdwidth = ' width="80%"';
1.329 droeschl 3685: }
1.408 raeburn 3686: my $reinit;
3687: if ($crstype eq 'Community') {
3688: $reinit = &mt('(re-initialize community to access)');
3689: } else {
3690: $reinit = &mt('(re-initialize course to access)');
1.519 raeburn 3691: }
3692: $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;
1.472 raeburn 3693: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 3694: $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
3695: } elsif ($url) {
1.484 raeburn 3696: $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
1.470 raeburn 3697: '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
1.469 www 3698: } else {
3699: $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
3700: }
1.519 raeburn 3701: $line.='</span></td><td'.$tdwidth.'>';
1.472 raeburn 3702: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 3703: $line.='<a href="'.$url.'">'.$title.'</a>';
3704: } elsif ($url) {
1.484 raeburn 3705: $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
1.470 raeburn 3706: $title,600,500);
1.469 www 3707: } else {
3708: $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
3709: }
1.518 raeburn 3710: $line.="$extresform</td>";
1.478 raeburn 3711: $rand_pick_text = ' ' if ($rand_pick_text eq '');
3712: $rand_order_text = ' ' if ($rand_order_text eq '');
1.329 droeschl 3713: if (($allowed) && ($folder!~/^supplemental/)) {
3714: my %lt=&Apache::lonlocal::texthash(
3715: 'hd' => 'Hidden',
3716: 'ec' => 'URL hidden');
1.543 raeburn 3717: my ($enctext,$hidtext);
3718: if ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) {
3719: $enctext = ' checked="checked"';
3720: if (($ishash) && (ref($filtersref->{'encrypturl'}) eq 'ARRAY')) {
3721: push(@{$filtersref->{'encrypturl'}},$orderidx);
3722: }
3723: }
3724: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
3725: $hidtext = ' checked="checked"';
3726: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
3727: push(@{$filtersref->{'hiddenresource'}},$orderidx);
3728: }
3729: }
1.537 raeburn 3730: my $formhidden = 'edit_hiddenresource_'.$orderidx;
3731: my $formurlhidden = 'edit_encrypturl_'.$orderidx;
1.329 droeschl 3732: $line.=(<<ENDPARMS);
3733: <td class="LC_docs_entry_parameter">
1.537 raeburn 3734: <form action="/adm/coursedocs" method="post" name="$formhidden">
1.538 raeburn 3735: $form_param
1.478 raeburn 3736: $form_common
1.538 raeburn 3737: <label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'hiddenresource','settings');" $hidtext /> $lt{'hd'}</label>
1.329 droeschl 3738: $form_end
1.458 raeburn 3739: <br />
1.537 raeburn 3740: <form action="/adm/coursedocs" method="post" name="$formurlhidden">
1.538 raeburn 3741: $form_param
1.478 raeburn 3742: $form_common
1.538 raeburn 3743: <label><input type="checkbox" name="encrypturl_$orderidx" id="encrypturl_$orderidx" onclick="checkForSubmit(this.form,'encrypturl','settings');" $enctext /> $lt{'ec'}</label>
1.329 droeschl 3744: $form_end
3745: </td>
1.478 raeburn 3746: <td class="LC_docs_entry_parameter">$rand_pick_text<br />
3747: $rand_order_text</td>
1.329 droeschl 3748: ENDPARMS
3749: }
1.379 bisitz 3750: $line.=&Apache::loncommon::end_data_table_row();
1.329 droeschl 3751: return $line;
3752: }
3753:
1.538 raeburn 3754: sub action_restrictions {
3755: my ($cnum,$cdom,$url,$folderpath,$currgroups) = @_;
3756: my %denied = (
3757: cut => 0,
3758: copy => 0,
3759: remove => 0,
3760: );
3761: if ($url=~ m{^/res/.+\.(page|sequence)$}) {
3762: # no copy for published maps
3763: $denied{'copy'} = 1;
3764: } elsif ($url=~m{^/res/lib/templates/}) {
3765: $denied{'copy'} = 1;
3766: $denied{'cut'} = 1;
3767: } elsif ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") {
3768: if ($folderpath =~ /^default&[^\&]+$/) {
3769: if ((ref($currgroups) eq 'HASH') && (keys(%{$currgroups}) > 0)) {
3770: $denied{'remove'} = 1;
3771: }
3772: $denied{'cut'} = 1;
3773: $denied{'copy'} = 1;
3774: }
3775: } elsif ($url =~ m{^\Q/uploaded/$cdom/$cnum/group_folder_\E(\w+)\.sequence$}) {
3776: my $group = $1;
3777: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+$/) {
3778: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
3779: $denied{'remove'} = 1;
3780: }
3781: }
3782: $denied{'cut'} = 1;
3783: $denied{'copy'} = 1;
3784: } elsif ($url =~ m{^\Q/adm/$cdom/$cnum/\E(\w+)/smppg$}) {
3785: my $group = $1;
3786: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&\Qgroup_folder_$group\E\&[^\&]+$/) {
3787: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
3788: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
3789: if (keys(%groupsettings) > 0) {
3790: $denied{'remove'} = 1;
3791: }
3792: $denied{'cut'} = 1;
3793: $denied{'copy'} = 1;
3794: }
3795: }
3796: } elsif ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&group_folder_(\w+)\&/) {
3797: my $group = $1;
3798: if ($url =~ /group_boards_\Q$group\E/) {
3799: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
3800: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
3801: if (keys(%groupsettings) > 0) {
3802: if (ref($groupsettings{'functions'}) eq 'HASH') {
3803: if ($groupsettings{'functions'}{'discussion'} eq 'on') {
3804: $denied{'remove'} = 1;
3805: }
3806: }
3807: }
3808: $denied{'cut'} = 1;
3809: $denied{'copy'} = 1;
3810: }
3811: }
3812: }
3813: return %denied;
3814: }
3815:
1.533 raeburn 3816: sub new_timebased_suffix {
1.538 raeburn 3817: my ($dom,$num,$type,$area,$container) = @_;
1.533 raeburn 3818: my ($prefix,$namespace,$idtype,$errtext,$locknotfreed);
1.538 raeburn 3819: if ($type eq 'paste') {
3820: $prefix = $type;
3821: $namespace = 'courseeditor';
3822: } elsif ($type eq 'map') {
1.533 raeburn 3823: $prefix = 'docs';
3824: if ($area eq 'supplemental') {
3825: $prefix = 'supp';
3826: }
3827: $prefix .= $container;
3828: $namespace = 'uploadedmaps';
3829: } else {
3830: $prefix = $type;
3831: $namespace = 'templated';
1.504 raeburn 3832: }
3833: $idtype = 'concat';
3834: my ($suffix,$freedlock,$error) =
1.538 raeburn 3835: &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num);
1.504 raeburn 3836: if (!$suffix) {
1.538 raeburn 3837: if ($type eq 'paste') {
3838: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.');
3839: } elsif ($type eq 'map') {
1.533 raeburn 3840: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
3841: } elsif ($type eq 'smppg') {
3842: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.');
3843: } else {
1.565 bisitz 3844: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new discussion board.');
1.533 raeburn 3845: }
1.504 raeburn 3846: if ($error) {
3847: $errtext .= '<br />'.$error;
3848: }
3849: }
3850: if ($freedlock ne 'ok') {
1.533 raeburn 3851: $locknotfreed =
3852: '<div class="LC_error">'.
3853: &mt('There was a problem removing a lockfile.').' ';
1.538 raeburn 3854: if ($type eq 'paste') {
3855: &mt('This will prevent use of the paste buffer until th next log-in.');
3856: } elsif ($type eq 'map') {
1.533 raeburn 3857: &mt('This will prevent creation of additional folders or composite pages in this course.');
3858: } elsif ($type eq 'smppg') {
3859: $locknotfreed .=
3860: &mt('This will prevent creation of additional simple pages in this course.');
3861: } else {
3862: $locknotfreed .=
1.565 bisitz 3863: &mt('This will prevent creation of additional discussion boards in this course.');
1.533 raeburn 3864: }
1.538 raeburn 3865: unless ($type eq 'paste') {
3866: $locknotfreed .=
1.560 raeburn 3867: ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
3868: '<a href="/adm/helpdesk" target="_helpdesk">','</a>');
1.538 raeburn 3869: }
3870: $locknotfreed .= '</div>';
1.504 raeburn 3871: }
3872: return ($suffix,$errtext,$locknotfreed);
3873: }
3874:
1.329 droeschl 3875: =pod
3876:
3877: =item tiehash()
3878:
3879: tie the hash
3880:
3881: =cut
3882:
3883: sub tiehash {
3884: my ($mode)=@_;
3885: $hashtied=0;
3886: if ($env{'request.course.fn'}) {
3887: if ($mode eq 'write') {
3888: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
3889: &GDBM_WRCREAT(),0640)) {
3890: $hashtied=2;
3891: }
3892: } else {
3893: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
3894: &GDBM_READER(),0640)) {
3895: $hashtied=1;
3896: }
3897: }
1.364 bisitz 3898: }
1.329 droeschl 3899: }
3900:
3901: sub untiehash {
3902: if ($hashtied) { untie %hash; }
3903: $hashtied=0;
3904: return OK;
3905: }
3906:
3907:
3908:
3909:
3910: sub checkonthis {
3911: my ($r,$url,$level,$title)=@_;
3912: $url=&unescape($url);
3913: $alreadyseen{$url}=1;
3914: $r->rflush();
3915: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
3916: $r->print("\n<br />");
3917: if ($level==0) {
3918: $r->print("<br />");
3919: }
3920: for (my $i=0;$i<=$level*5;$i++) {
3921: $r->print(' ');
3922: }
3923: $r->print('<a href="'.$url.'" target="cat">'.
3924: ($title?$title:$url).'</a> ');
3925: if ($url=~/^\/res\//) {
3926: my $result=&Apache::lonnet::repcopy(
3927: &Apache::lonnet::filelocation('',$url));
3928: if ($result eq 'ok') {
3929: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
3930: $r->rflush();
3931: &Apache::lonnet::countacc($url);
3932: $url=~/\.(\w+)$/;
3933: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
3934: $r->print('<br />');
3935: $r->rflush();
3936: for (my $i=0;$i<=$level*5;$i++) {
3937: $r->print(' ');
3938: }
3939: $r->print('- '.&mt('Rendering:').' ');
3940: my ($errorcount,$warningcount)=split(/:/,
3941: &Apache::lonnet::ssi_body($url,
3942: ('grade_target'=>'web',
3943: 'return_only_error_and_warning_counts' => 1)));
3944: if (($errorcount) ||
3945: ($warningcount)) {
3946: if ($errorcount) {
1.369 bisitz 3947: $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1.329 droeschl 3948: &mt('[quant,_1,error]',$errorcount).'</span>');
3949: }
3950: if ($warningcount) {
3951: $r->print('<span class="LC_warning">'.
3952: &mt('[quant,_1,warning]',$warningcount).'</span>');
3953: }
3954: } else {
3955: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
3956: }
3957: $r->rflush();
3958: }
3959: my $dependencies=
3960: &Apache::lonnet::metadata($url,'dependencies');
3961: foreach my $dep (split(/\,/,$dependencies)) {
3962: if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
3963: &checkonthis($r,$dep,$level+1);
3964: }
3965: }
3966: } elsif ($result eq 'unavailable') {
3967: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
3968: } elsif ($result eq 'not_found') {
3969: unless ($url=~/\$/) {
1.521 bisitz 3970: $r->print('<span class="LC_error">'.&mt('not found').'</span>');
1.329 droeschl 3971: } else {
1.366 bisitz 3972: $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1.329 droeschl 3973: }
3974: } else {
3975: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
3976: }
3977: }
3978: }
3979: }
3980:
3981:
3982:
3983: =pod
3984:
3985: =item list_symbs()
3986:
1.485 raeburn 3987: List Content Identifiers
1.329 droeschl 3988:
3989: =cut
3990:
3991: sub list_symbs {
3992: my ($r) = @_;
3993:
1.408 raeburn 3994: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 3995: $r->print(&Apache::loncommon::start_page('List of Content Identifiers'));
3996: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Identifiers'));
3997: $r->print(&startContentScreen('tools'));
1.329 droeschl 3998: my $navmap = Apache::lonnavmaps::navmap->new();
3999: if (!defined($navmap)) {
4000: $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
4001: '<div class="LC_error">'.
4002: &mt('Unable to retrieve information about course contents').
4003: '</div>');
1.408 raeburn 4004: &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
1.329 droeschl 4005: } else {
1.484 raeburn 4006: $r->print('<h4 class="LC_info">'.&mt("$crstype Content Identifiers").'</h4>'.
4007: &Apache::loncommon::start_data_table().
4008: &Apache::loncommon::start_data_table_header_row().
4009: '<th>'.&mt('Title').'</th><th>'.&mt('Identifier').'</th>'.
4010: &Apache::loncommon::end_data_table_header_row()."\n");
4011: my $count;
1.329 droeschl 4012: foreach my $res ($navmap->retrieveResources()) {
1.484 raeburn 4013: $r->print(&Apache::loncommon::start_data_table_row().
4014: '<td>'.$res->compTitle().'</td>'.
4015: '<td>'.$res->symb().'</td>'.
1.521 bisitz 4016: &Apache::loncommon::end_data_table_row());
1.484 raeburn 4017: $count ++;
4018: }
4019: if (!$count) {
4020: $r->print(&Apache::loncommon::start_data_table_row().
4021: '<td colspan="2">'.&mt("$crstype is empty").'</td>'.
4022: &Apache::loncommon::end_data_table_row());
1.329 droeschl 4023: }
1.484 raeburn 4024: $r->print(&Apache::loncommon::end_data_table());
1.329 droeschl 4025: }
1.521 bisitz 4026: $r->print(&endContentScreen());
1.329 droeschl 4027: }
4028:
4029:
4030: sub verifycontent {
4031: my ($r) = @_;
1.408 raeburn 4032: my $crstype = &Apache::loncommon::course_type();
1.549 raeburn 4033: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
4034: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
1.484 raeburn 4035: $r->print(&startContentScreen('tools'));
4036: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
1.329 droeschl 4037: $hashtied=0;
4038: undef %alreadyseen;
4039: %alreadyseen=();
4040: &tiehash();
1.484 raeburn 4041:
1.329 droeschl 4042: foreach my $key (keys(%hash)) {
4043: if ($hash{$key}=~/\.(page|sequence)$/) {
4044: if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
4045: $r->print('<hr /><span class="LC_error">'.
1.419 bisitz 4046: &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
1.329 droeschl 4047: &unescape($hash{$key}).'</span><br />'.
1.419 bisitz 4048: &mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />');
1.329 droeschl 4049: }
4050: }
4051: if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
4052: &checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
4053: }
4054: }
4055: &untiehash();
1.442 www 4056: $r->print('<p class="LC_success">'.&mt('Done').'</p>');
1.521 bisitz 4057: $r->print(&endContentScreen());
1.329 droeschl 4058: }
4059:
4060:
4061: sub devalidateversioncache {
4062: my $src=shift;
4063: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
4064: &Apache::lonnet::clutter($src));
4065: }
4066:
4067: sub checkversions {
4068: my ($r) = @_;
1.408 raeburn 4069: my $crstype = &Apache::loncommon::course_type();
1.571 raeburn 4070: $r->print(&Apache::loncommon::start_page("Check $crstype Resource Versions"));
4071: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Resource Versions"));
1.484 raeburn 4072: $r->print(&startContentScreen('tools'));
1.442 www 4073:
1.329 droeschl 4074: my $header='';
4075: my $startsel='';
4076: my $monthsel='';
4077: my $weeksel='';
4078: my $daysel='';
4079: my $allsel='';
4080: my %changes=();
4081: my $starttime=0;
4082: my $haschanged=0;
4083: my %setversions=&Apache::lonnet::dump('resourceversions',
4084: $env{'course.'.$env{'request.course.id'}.'.domain'},
4085: $env{'course.'.$env{'request.course.id'}.'.num'});
4086:
4087: $hashtied=0;
4088: &tiehash();
4089: my %newsetversions=();
4090: if ($env{'form.setmostrecent'}) {
4091: $haschanged=1;
4092: foreach my $key (keys(%hash)) {
4093: if ($key=~/^ids\_(\/res\/.+)$/) {
4094: $newsetversions{$1}='mostrecent';
4095: &devalidateversioncache($1);
4096: }
4097: }
4098: } elsif ($env{'form.setcurrent'}) {
4099: $haschanged=1;
4100: foreach my $key (keys(%hash)) {
4101: if ($key=~/^ids\_(\/res\/.+)$/) {
4102: my $getvers=&Apache::lonnet::getversion($1);
4103: if ($getvers>0) {
4104: $newsetversions{$1}=$getvers;
4105: &devalidateversioncache($1);
4106: }
4107: }
4108: }
4109: } elsif ($env{'form.setversions'}) {
4110: $haschanged=1;
4111: foreach my $key (keys(%env)) {
4112: if ($key=~/^form\.set_version_(.+)$/) {
4113: my $src=$1;
4114: if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
4115: $newsetversions{$src}=$env{$key};
4116: &devalidateversioncache($src);
4117: }
4118: }
4119: }
4120: }
4121: if ($haschanged) {
4122: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
4123: $env{'course.'.$env{'request.course.id'}.'.domain'},
1.344 bisitz 4124: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
1.479 golterma 4125: $r->print(&Apache::loncommon::confirmwrapper(
4126: &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
1.329 droeschl 4127: } else {
1.479 golterma 4128: $r->print(&Apache::loncommon::confirmwrapper(
4129: &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
1.329 droeschl 4130: }
4131: &mark_hash_old();
4132: }
4133: &changewarning($r,'');
4134: if ($env{'form.timerange'} eq 'all') {
4135: # show all documents
1.549 raeburn 4136: $header=&mt('All content in '.$crstype);
1.521 bisitz 4137: $allsel=' selected="selected"';
1.329 droeschl 4138: foreach my $key (keys(%hash)) {
4139: if ($key=~/^ids\_(\/res\/.+)$/) {
4140: my $src=$1;
4141: $changes{$src}=1;
4142: }
4143: }
4144: } else {
4145: # show documents which changed
4146: %changes=&Apache::lonnet::dump
4147: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
4148: $env{'course.'.$env{'request.course.id'}.'.num'});
4149: my $firstkey=(keys(%changes))[0];
4150: unless ($firstkey=~/^error\:/) {
4151: unless ($env{'form.timerange'}) {
4152: $env{'form.timerange'}=604800;
4153: }
4154: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
4155: .&mt('seconds');
4156: if ($env{'form.timerange'}==-1) {
4157: $seltext='since start of course';
1.521 bisitz 4158: $startsel=' selected="selected"';
1.329 droeschl 4159: $env{'form.timerange'}=time;
4160: }
4161: $starttime=time-$env{'form.timerange'};
4162: if ($env{'form.timerange'}==2592000) {
4163: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 4164: $monthsel=' selected="selected"';
1.329 droeschl 4165: } elsif ($env{'form.timerange'}==604800) {
4166: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 4167: $weeksel=' selected="selected"';
1.329 droeschl 4168: } elsif ($env{'form.timerange'}==86400) {
4169: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 4170: $daysel=' selected="selected"';
1.329 droeschl 4171: }
4172: $header=&mt('Content changed').' '.$seltext;
4173: } else {
4174: $header=&mt('No content modifications yet.');
4175: }
4176: }
4177: %setversions=&Apache::lonnet::dump('resourceversions',
4178: $env{'course.'.$env{'request.course.id'}.'.domain'},
4179: $env{'course.'.$env{'request.course.id'}.'.num'});
4180: my %lt=&Apache::lonlocal::texthash
1.408 raeburn 4181: ('st' => 'Version changes since start of '.$crstype,
1.329 droeschl 4182: 'lm' => 'Version changes since last Month',
4183: 'lw' => 'Version changes since last Week',
4184: 'sy' => 'Version changes since Yesterday',
4185: 'al' => 'All Resources (possibly large output)',
1.484 raeburn 4186: 'cd' => 'Change display',
1.329 droeschl 4187: 'sd' => 'Display',
4188: 'fi' => 'File',
4189: 'md' => 'Modification Date',
4190: 'mr' => 'Most recently published Version',
1.408 raeburn 4191: 've' => 'Version used in '.$crstype,
4192: 'vu' => 'Set Version to be used in '.$crstype,
4193: 'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
1.329 droeschl 4194: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
4195: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.479 golterma 4196: 'di' => 'Differences',
1.484 raeburn 4197: 'save' => 'Save changes',
4198: 'vers' => 'Version choice(s) for specific resources',
1.479 golterma 4199: 'act' => 'Actions');
1.329 droeschl 4200: $r->print(<<ENDHEADERS);
1.484 raeburn 4201: <h4 class="LC_info">$header</h4>
1.329 droeschl 4202: <form action="/adm/coursedocs" method="post">
4203: <input type="hidden" name="versions" value="1" />
1.484 raeburn 4204: <div class="LC_left_float">
1.479 golterma 4205: <fieldset>
1.484 raeburn 4206: <legend>$lt{'cd'}</legend>
1.329 droeschl 4207: <select name="timerange">
1.521 bisitz 4208: <option value='all'$allsel>$lt{'al'}</option>
4209: <option value="-1"$startsel>$lt{'st'}</option>
4210: <option value="2592000"$monthsel>$lt{'lm'}</option>
4211: <option value="604800"$weeksel>$lt{'lw'}</option>
4212: <option value="86400"$daysel>$lt{'sy'}</option>
1.329 droeschl 4213: </select>
4214: <input type="submit" name="display" value="$lt{'sd'}" />
1.484 raeburn 4215: </fieldset>
4216: </div>
4217: <div class="LC_left_float">
4218: <fieldset>
4219: <legend>$lt{'act'}</legend>
4220: $lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" /><br />
4221: $lt{'sc'}: <input type="submit" name="setcurrent" value="Go" />
4222: </fieldset>
4223: </div>
4224: <br clear="all" />
4225: <hr />
4226: <h4>$lt{'vers'}</h4>
1.329 droeschl 4227: ENDHEADERS
1.479 golterma 4228: #number of columns for version history
1.571 raeburn 4229: my %changedbytime;
4230: foreach my $key (keys(%changes)) {
4231: #excludes not versionable problems from resource version history:
4232: next if ($key =~ /^\/res\/lib\/templates/);
4233: my $chg;
4234: if ($env{'form.timerange'} eq 'all') {
4235: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
4236: $chg = &Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate');
4237: } else {
4238: $chg = $changes{$key};
4239: next if ($chg < $starttime);
4240: }
4241: push(@{$changedbytime{$chg}},$key);
4242: }
4243: if (keys(%changedbytime) == 0) {
4244: &untiehash();
4245: $r->print(&mt('No content changes in imported content in specified time frame').
4246: &endContentScreen());
4247: return;
4248: }
1.479 golterma 4249: $r->print(
1.571 raeburn 4250: '<input type="submit" name="setversions" value="'.$lt{'save'}.'" />'.
1.521 bisitz 4251: &Apache::loncommon::start_data_table().
4252: &Apache::loncommon::start_data_table_header_row().
4253: '<th>'.&mt('Resources').'</th>'.
4254: "<th>$lt{'mr'}</th>".
4255: "<th>$lt{'ve'}</th>".
4256: "<th>$lt{'vu'}</th>".
4257: '<th>'.&mt('History').'</th>'.
4258: &Apache::loncommon::end_data_table_header_row()
4259: );
1.571 raeburn 4260: foreach my $chg (sort {$b <=> $a } keys(%changedbytime)) {
4261: foreach my $key (sort(@{$changedbytime{$chg}})) {
4262: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
4263: my $currentversion=&Apache::lonnet::getversion($key);
4264: if ($currentversion<0) {
4265: $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
4266: }
4267: my $linkurl=&Apache::lonnet::clutter($key);
4268: $r->print(
4269: &Apache::loncommon::start_data_table_row().
4270: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br />'.
4271: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
4272: '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br />('.
4273: &Apache::lonlocal::locallocaltime($chg).')</span></td>'.
4274: '<td align="right">'
4275: );
4276: # Used in course
4277: my $usedversion=$hash{'version_'.$linkurl};
4278: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.521 bisitz 4279: if ($usedversion != $currentversion) {
1.479 golterma 4280: $r->print('<span class="LC_warning">'.$usedversion.'</span>');
1.521 bisitz 4281: } else {
1.479 golterma 4282: $r->print($usedversion);
4283: }
1.329 droeschl 4284: } else {
1.521 bisitz 4285: $r->print($currentversion);
1.329 droeschl 4286: }
1.571 raeburn 4287: $r->print('</td><td title="'.$lt{'vu'}.'">');
4288: # Set version
4289: $r->print(&Apache::loncommon::select_form(
4290: $setversions{$linkurl},
4291: 'set_version_'.$linkurl,
4292: {'select_form_order' => ['',1..$currentversion,'mostrecent'],
4293: '' => '',
4294: 'mostrecent' => &mt('most recent'),
4295: map {$_,$_} (1..$currentversion)}));
4296: my $lastold=1;
4297: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
4298: my $url=$root.'.'.$prevvers.'.'.$extension;
4299: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) {
4300: $lastold=$prevvers;
4301: }
4302: }
4303: $r->print('</td>');
4304: # List all available versions
4305: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
4306: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
4307: my $url=$root.'.'.$prevvers.'.'.$extension;
4308: $r->print(
4309: '<span class="LC_nobreak">'
4310: .'<a href="'.&Apache::lonnet::clutter($url).'">'
4311: .&mt('Version [_1]',$prevvers).'</a>'
4312: .' ('.&Apache::lonlocal::locallocaltime(
1.521 bisitz 4313: &Apache::lonnet::metadata($url,'lastrevisiondate'))
1.571 raeburn 4314: .')');
4315: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
4316: $r->print(
4317: ' <a href="/adm/diff?filename='.
4318: &Apache::lonnet::clutter($root.'.'.$extension).
4319: &HTML::Entities::encode('&versionone='.$prevvers,'"<>&').
4320: '" target="diffs">'.&mt('Diffs').'</a>');
4321: }
4322: $r->print('</span><br />');
1.329 droeschl 4323: }
1.571 raeburn 4324: $r->print('</span></td>'.&Apache::loncommon::end_data_table_row());
1.521 bisitz 4325: }
1.329 droeschl 4326: }
1.521 bisitz 4327: $r->print(
4328: &Apache::loncommon::end_data_table().
4329: '<input type="submit" name="setversions" value="'.$lt{'save'}.'" />'.
4330: '</form>'
4331: );
1.329 droeschl 4332:
4333: &untiehash();
1.521 bisitz 4334: $r->print(&endContentScreen());
1.571 raeburn 4335: return;
1.329 droeschl 4336: }
4337:
4338: sub mark_hash_old {
4339: my $retie_hash=0;
4340: if ($hashtied) {
4341: $retie_hash=1;
4342: &untiehash();
4343: }
4344: &tiehash('write');
4345: $hash{'old'}=1;
4346: &untiehash();
4347: if ($retie_hash) { &tiehash(); }
4348: }
4349:
4350: sub is_hash_old {
4351: my $untie_hash=0;
4352: if (!$hashtied) {
4353: $untie_hash=1;
4354: &tiehash();
4355: }
4356: my $return=$hash{'old'};
4357: if ($untie_hash) { &untiehash(); }
4358: return $return;
4359: }
4360:
4361: sub changewarning {
4362: my ($r,$postexec,$message,$url)=@_;
4363: if (!&is_hash_old()) { return; }
4364: my $pathvar='folderpath';
4365: my $path=&escape($env{'form.folderpath'});
4366: if (!defined($url)) {
4367: $url='/adm/coursedocs?'.$pathvar.'='.$path;
4368: }
4369: my $course_type = &Apache::loncommon::course_type();
4370: if (!defined($message)) {
4371: $message='Changes will become active for your current session after [_1], or the next time you log in.';
4372: }
4373: $r->print("\n\n".
1.372 bisitz 4374: '<script type="text/javascript">'."\n".
4375: '// <![CDATA['."\n".
4376: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
4377: '// ]]>'."\n".
1.369 bisitz 4378: '</script>'."\n".
1.375 tempelho 4379: '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
1.329 droeschl 4380: '<input type="hidden" name="orgurl" value="'.$url.
1.372 bisitz 4381: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
1.329 droeschl 4382: &mt($message,' <input type="hidden" name="'.
4383: $env{'request.role'}.'" value="1" /><input type="button" value="'.
1.369 bisitz 4384: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1.372 bisitz 4385: $help{'Caching'}.'</p></form>'."\n\n");
1.329 droeschl 4386: }
4387:
4388:
4389: sub init_breadcrumbs {
1.571 raeburn 4390: my ($form,$text,$help)=@_;
1.329 droeschl 4391: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484 raeburn 4392: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
1.405 bisitz 4393: text=>&Apache::loncommon::course_type().' Editor',
1.329 droeschl 4394: faq=>273,
4395: bug=>'Instructor Interface',
1.571 raeburn 4396: help => $help});
1.329 droeschl 4397: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
4398: text=>$text,
4399: faq=>273,
4400: bug=>'Instructor Interface'});
4401: }
4402:
1.441 www 4403: # subroutine to list form elements
4404: sub create_list_elements {
4405: my @formarr = @_;
4406: my $list = '';
1.501 raeburn 4407: foreach my $button (@formarr){
4408: foreach my $picture (keys(%{$button})) {
4409: $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
1.441 www 4410: }
4411: }
4412: return $list;
4413: }
1.329 droeschl 4414:
1.441 www 4415: # subroutine to create ul from list elements
4416: sub create_form_ul {
4417: my $list = shift;
4418: my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
4419: return $ul;
4420: }
1.329 droeschl 4421:
1.442 www 4422: #
4423: # Start tabs
4424: #
4425:
4426: sub startContentScreen {
1.484 raeburn 4427: my ($mode) = @_;
4428: my $output = '<ul class="LC_TabContentBigger" id="mainnav">';
1.472 raeburn 4429: if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
1.484 raeburn 4430: $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n";
4431: $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n";
4432: $output .= '<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b> '.&mt('Content Index').' </b></a></li>'."\n";
4433: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
4434: } else {
1.549 raeburn 4435: $output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Main Content Editor').' </b></a></li>'."\n";
1.484 raeburn 4436: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
4437: $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>'."\n";
4438: '><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>';
4439: }
4440: $output .= "\n".'</ul>'."\n";
4441: $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
4442: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
4443: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
4444: return $output;
1.442 www 4445: }
4446:
4447: #
4448: # End tabs
4449: #
4450:
4451: sub endContentScreen {
1.484 raeburn 4452: return '</div></div></div>';
1.442 www 4453: }
1.329 droeschl 4454:
1.446 www 4455: sub supplemental_base {
1.548 raeburn 4456: return 'supplemental&'.&escape(&mt('Supplemental Content'));
1.446 www 4457: }
4458:
1.329 droeschl 4459: sub handler {
4460: my $r = shift;
4461: &Apache::loncommon::content_type($r,'text/html');
4462: $r->send_http_header;
4463: return OK if $r->header_only;
1.484 raeburn 4464:
4465: # get course data
1.408 raeburn 4466: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 4467: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
4468: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
4469:
4470: # graphics settings
4471: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329 droeschl 4472:
1.443 www 4473: #
1.329 droeschl 4474: # --------------------------------------------- Initialize help topics for this
4475: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
4476: 'Adding_External_Resource','Navigate_Content',
4477: 'Adding_Folders','Docs_Overview', 'Load_Map',
4478: 'Supplemental','Score_Upload_Form','Adding_Pages',
1.501 raeburn 4479: 'Importing_LON-CAPA_Resource','Importing_IMS_Course',
1.571 raeburn 4480: 'Uploading_From_Harddrive','Course_Roster','Web_Page',
1.572 raeburn 4481: 'Dropbox','Simple_Problem') {
1.329 droeschl 4482: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
4483: }
4484: # Composite help files
4485: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
4486: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
4487: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
4488: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
4489: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
4490: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 4491: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 4492: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 4493: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 4494: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1.534 raeburn 4495:
1.472 raeburn 4496: my $allowed;
4497: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
4498: unless ($r->uri eq '/adm/supplemental') {
4499: # does this user have privileges to modify content.
4500: $allowed = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
4501: }
4502:
1.484 raeburn 4503: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['chooseserver',
4504: 'inhibitmenu']);
4505: if ($allowed && $env{'form.chooseserver'}) {
4506: &choose_dump_server($r);
4507: return OK;
4508: } elsif ($allowed && $env{'form.verify'}) {
1.571 raeburn 4509: &init_breadcrumbs('verify','Verify Content','Docs_Verify_Content');
1.329 droeschl 4510: &verifycontent($r);
4511: } elsif ($allowed && $env{'form.listsymbs'}) {
1.484 raeburn 4512: &init_breadcrumbs('listsymbs','List Content IDs');
1.329 droeschl 4513: &list_symbs($r);
4514: } elsif ($allowed && $env{'form.docslog'}) {
4515: &init_breadcrumbs('docslog','Show Log');
1.484 raeburn 4516: my $folder = $env{'form.folder'};
4517: if ($folder eq '') {
4518: $folder='default';
4519: }
4520: &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath);
1.329 droeschl 4521: } elsif ($allowed && $env{'form.versions'}) {
1.571 raeburn 4522: &init_breadcrumbs('versions','Check/Set Resource Versions','Docs_Check_Resource_Versions');
1.329 droeschl 4523: &checkversions($r);
4524: } elsif ($allowed && $env{'form.dumpcourse'}) {
1.568 raeburn 4525: &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329 droeschl 4526: &dumpcourse($r);
4527: } elsif ($allowed && $env{'form.exportcourse'}) {
1.377 bisitz 4528: &init_breadcrumbs('exportcourse','IMS Export');
1.475 raeburn 4529: &Apache::imsexport::exportcourse($r);
1.329 droeschl 4530: } else {
1.445 www 4531: #
4532: # Done catching special calls
1.484 raeburn 4533: # The whole rest is for course and supplemental documents and utilities menu
1.445 www 4534: # Get the parameters that may be needed
4535: #
4536: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.519 raeburn 4537: ['folderpath',
4538: 'forcesupplement','forcestandard',
1.510 raeburn 4539: 'tools','symb','command','supppath']);
1.445 www 4540:
4541: # standard=1: this is a "new-style" course with an uploaded map as top level
4542: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329 droeschl 4543:
4544: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445 www 4545:
1.484 raeburn 4546: # Decide whether this should display supplemental or main content or utilities
1.445 www 4547: # supplementalflag=1: show supplemental documents
4548: # supplementalflag=0: show standard documents
1.484 raeburn 4549: # toolsflag=1: show utilities
1.445 www 4550:
1.561 raeburn 4551: my $unesc_folderpath = &unescape($env{'form.folderpath'});
4552: my $supplementalflag=($unesc_folderpath=~/^supplemental/);
4553: if (($unesc_folderpath=~/^default/) || ($unesc_folderpath eq "")) {
1.445 www 4554: $supplementalflag=0;
4555: }
4556: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
4557: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
4558: unless ($allowed) { $supplementalflag=1; }
4559: unless ($standard) { $supplementalflag=1; }
1.484 raeburn 4560: my $toolsflag=0;
4561: if ($env{'form.tools'}) { $toolsflag=1; }
1.445 www 4562:
1.329 droeschl 4563: my $script='';
4564: my $showdoc=0;
1.457 raeburn 4565: my $addentries = {};
1.475 raeburn 4566: my $container;
1.329 droeschl 4567: my $containertag;
1.508 raeburn 4568: my $pathitem;
1.329 droeschl 4569:
1.464 www 4570: # Do we directly jump somewhere?
1.466 www 4571:
1.525 raeburn 4572: if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
1.472 raeburn 4573: if ($env{'form.symb'} ne '') {
1.522 raeburn 4574: $env{'form.folderpath'}=
4575: &Apache::loncommon::symb_to_docspath($env{'form.symb'});
1.530 raeburn 4576: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
1.525 raeburn 4577: $env{'form.command'}.'_'.$env{'form.symb'}});
1.472 raeburn 4578: } elsif ($env{'form.supppath'} ne '') {
4579: $env{'form.folderpath'}=$env{'form.supppath'};
1.530 raeburn 4580: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
1.525 raeburn 4581: $env{'form.command'}.'_'.$env{'form.supppath'}});
1.466 www 4582: }
1.472 raeburn 4583: } elsif ($env{'form.command'} eq 'editdocs') {
1.525 raeburn 4584: $env{'form.folderpath'} = 'default&'.
1.548 raeburn 4585: &escape(&mt('Main Content').':::::');
1.525 raeburn 4586: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
1.472 raeburn 4587: } elsif ($env{'form.command'} eq 'editsupp') {
1.525 raeburn 4588: $env{'form.folderpath'} = 'supplemental&'.
1.538 raeburn 4589: &escape('Supplemental Content');
1.525 raeburn 4590: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
4591: } elsif ($env{'form.command'} eq 'contents') {
4592: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
4593: } elsif ($env{'form.command'} eq 'home') {
4594: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
1.464 www 4595: }
4596:
1.525 raeburn 4597:
1.445 www 4598: # Where do we store these for when we come back?
4599: my $stored_folderpath='docs_folderpath';
4600: if ($supplementalflag) {
4601: $stored_folderpath='docs_sup_folderpath';
4602: }
1.464 www 4603:
1.519 raeburn 4604: # No folderpath, and in edit mode, see if we have something stored
4605: if ((!$env{'form.folderpath'}) && $allowed) {
1.445 www 4606: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.510 raeburn 4607: {'folderpath' => 'scalar'});
1.523 raeburn 4608: unless (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
4609: undef($env{'form.folderpath'});
4610: }
1.329 droeschl 4611: }
1.446 www 4612:
4613: # If we are not allowed to make changes, all we can see are supplemental docs
1.409 raeburn 4614: if (!$allowed) {
1.446 www 4615: unless ($env{'form.folderpath'} =~ /^supplemental/) {
4616: $env{'form.folderpath'} = &supplemental_base();
1.409 raeburn 4617: }
4618: }
1.446 www 4619: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329 droeschl 4620: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446 www 4621: $env{'form.folderpath'} = &supplemental_base()
4622: .'&'.
1.329 droeschl 4623: $env{'form.folderpath'};
4624: }
1.446 www 4625: # If after all of this, we still don't have any paths, make them
1.519 raeburn 4626: unless ($env{'form.folderpath'}) {
1.446 www 4627: if ($supplementalflag) {
4628: $env{'form.folderpath'}=&supplemental_base();
4629: } else {
1.548 raeburn 4630: $env{'form.folderpath'}='default&'.&escape(&mt('Main Content').
1.538 raeburn 4631: ':::::');
1.446 www 4632: }
1.472 raeburn 4633: }
1.446 www 4634:
1.445 www 4635: # Store this
1.484 raeburn 4636: unless ($toolsflag) {
1.510 raeburn 4637: if ($allowed) {
4638: &Apache::loncommon::store_course_settings($stored_folderpath,
1.519 raeburn 4639: {'folderpath' => 'scalar'});
1.510 raeburn 4640: }
1.519 raeburn 4641: my $folderpath;
1.484 raeburn 4642: if ($env{'form.folderpath'}) {
1.519 raeburn 4643: $folderpath = $env{'form.folderpath'};
4644: my (@folders)=split('&',$env{'form.folderpath'});
4645: $env{'form.foldername'}=&unescape(pop(@folders));
4646: if ($env{'form.foldername'} =~ /\:1$/) {
4647: $container = 'page';
4648: } else {
4649: $container = 'sequence';
4650: }
4651: $env{'form.folder'}=pop(@folders);
1.484 raeburn 4652: } else {
1.519 raeburn 4653: if ($env{'form.folder'} eq '' ||
4654: $env{'form.folder'} eq 'supplemental') {
4655: $folderpath='default&'.
1.548 raeburn 4656: &escape(&mt('Main Content').':::::');
1.484 raeburn 4657: }
4658: }
1.519 raeburn 4659: $containertag = '<input type="hidden" name="folderpath" value="" />';
4660: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 4661: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
4662: $showdoc='/'.$1;
4663: }
4664: if ($showdoc) { # got called in sequence from course
4665: $allowed=0;
4666: } else {
4667: if ($allowed) {
4668: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
4669: $script=&Apache::lonratedt::editscript('simple');
1.433 raeburn 4670: }
4671: }
1.329 droeschl 4672: }
4673:
1.344 bisitz 4674: # get personal data
1.329 droeschl 4675: my $uname=$env{'user.name'};
4676: my $udom=$env{'user.domain'};
4677: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
4678:
4679: if ($allowed) {
1.484 raeburn 4680: if ($toolsflag) {
4681: $script .= &inject_data_js();
4682: my ($home,$other,%outhash)=&authorhosts();
4683: if (!$home && $other) {
4684: my @hosts;
4685: foreach my $aurole (keys(%outhash)) {
4686: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
4687: push(@hosts,$outhash{$aurole});
4688: }
4689: }
4690: $script .= &dump_switchserver_js(@hosts);
4691: }
1.458 raeburn 4692: } else {
1.570 raeburn 4693: my $tid = 1;
1.484 raeburn 4694: my @tabids;
4695: if ($supplementalflag) {
4696: @tabids = ('002','ee2','ff2');
1.570 raeburn 4697: $tid = 2;
1.484 raeburn 4698: } else {
4699: @tabids = ('aa1','bb1','cc1','ff1');
1.519 raeburn 4700: unless ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 4701: unshift(@tabids,'001');
4702: push(@tabids,('dd1','ee1'));
4703: }
1.458 raeburn 4704: }
1.484 raeburn 4705: my $tabidstr = join("','",@tabids);
4706: $script .= &editing_js($udom,$uname,$supplementalflag).
4707: &history_tab_js().
4708: &inject_data_js().
1.570 raeburn 4709: &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
1.510 raeburn 4710: &Apache::lonextresedit::extedit_javascript();
1.484 raeburn 4711: $addentries = {
1.485 raeburn 4712: onload => "javascript:resize_scrollbox('contentscroll','1','1');",
1.484 raeburn 4713: };
1.458 raeburn 4714: }
1.538 raeburn 4715: $script .= &paste_popup_js();
1.501 raeburn 4716: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
4717: &mt('Switch server?');
4718:
4719:
1.329 droeschl 4720: }
4721: # -------------------------------------------------------------------- Body tag
1.369 bisitz 4722: $script = '<script type="text/javascript">'."\n"
1.372 bisitz 4723: .'// <![CDATA['."\n"
4724: .$script."\n"
4725: .'// ]]>'."\n"
4726: .'</script>'."\n";
1.385 bisitz 4727:
4728: # Breadcrumbs
4729: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.510 raeburn 4730:
4731: if ($showdoc) {
4732: $r->print(&Apache::loncommon::start_page("$crstype documents",undef,
4733: {'force_register' => $showdoc,}));
1.571 raeburn 4734: } elsif ($toolsflag) {
4735: &Apache::lonhtmlcommon::add_breadcrumb({
4736: href=>"/adm/coursedocs",text=>"$crstype Contents"});
4737: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script)
4738: .&Apache::loncommon::help_open_menu('','',273,'RAT')
4739: .&Apache::lonhtmlcommon::breadcrumbs(
4740: 'Editing Course Contents')
4741: );
1.510 raeburn 4742: } elsif ($r->uri eq '/adm/supplemental') {
4743: my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
4744: $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
4745: {'bread_crumbs' => $brcrum,}));
4746: } else {
1.392 raeburn 4747: &Apache::lonhtmlcommon::add_breadcrumb({
1.446 www 4748: href=>"/adm/coursedocs",text=>"$crstype Contents"});
4749: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.510 raeburn 4750: {'add_entries' => $addentries}
4751: )
1.392 raeburn 4752: .&Apache::loncommon::help_open_menu('','',273,'RAT')
4753: .&Apache::lonhtmlcommon::breadcrumbs(
1.484 raeburn 4754: 'Editing '.$crstype.' Contents',
1.392 raeburn 4755: 'Docs_Adding_Course_Doc')
4756: );
4757: }
1.364 bisitz 4758:
1.329 droeschl 4759: my %allfiles = ();
4760: my %codebase = ();
1.440 raeburn 4761: my ($upload_result,$upload_output,$uploadphase);
1.329 droeschl 4762: if ($allowed) {
4763: if (($env{'form.uploaddoc.filename'}) &&
4764: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440 raeburn 4765: my $context = $1;
4766: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 4767: undef($hadchanges);
1.440 raeburn 4768: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
1.552 raeburn 4769: \%allfiles,\%codebase,$context,$crstype);
1.329 droeschl 4770: if ($hadchanges) {
4771: &mark_hash_old();
4772: }
1.440 raeburn 4773: $r->print($upload_output);
4774: } elsif ($env{'form.phase'} eq 'upload_embedded') {
4775: # Process file upload - phase two - upload embedded objects
4776: $uploadphase = 'check_embedded';
4777: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
4778: my $state = &embedded_form_elems($uploadphase,$primaryurl,
4779: $env{'form.newidx'});
4780: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
4781: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
4782: my ($destination,$dir_root) = &embedded_destination();
4783: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
4784: my $actionurl = '/adm/coursedocs';
4785: my ($result,$flag) =
4786: &Apache::loncommon::upload_embedded('coursedoc',$destination,
4787: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
4788: $actionurl);
4789: $r->print($result.&return_to_editor());
4790: } elsif ($env{'form.phase'} eq 'check_embedded') {
4791: # Process file upload - phase three - modify references in HTML file
4792: $uploadphase = 'modified_orightml';
4793: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
4794: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
4795: my ($destination,$dir_root) = &embedded_destination();
1.482 raeburn 4796: my $result =
4797: &Apache::loncommon::modify_html_refs('coursedoc',$destination,
4798: $docuname,$docudom,undef,
4799: $dir_root);
4800: $r->print($result.&return_to_editor());
1.476 raeburn 4801: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
4802: $uploadphase = 'decompress_phase_one';
4803: $r->print(&decompression_phase_one().
4804: &return_to_editor());
4805: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
4806: $uploadphase = 'decompress_phase_two';
4807: $r->print(&decompression_phase_two().
4808: &return_to_editor());
1.329 droeschl 4809: }
4810: }
4811:
1.484 raeburn 4812: if ($allowed && $toolsflag) {
4813: $r->print(&startContentScreen('tools'));
4814: $r->print(&generate_admin_menu($crstype));
4815: $r->print(&endContentScreen());
4816: } elsif ((!$showdoc) && (!$uploadphase)) {
1.329 droeschl 4817: # -----------------------------------------------------------------------------
4818: my %lt=&Apache::lonlocal::texthash(
4819: 'copm' => 'All documents out of a published map into this folder',
1.501 raeburn 4820: 'upfi' => 'Upload File',
1.553 raeburn 4821: 'upld' => 'Upload Content',
1.329 droeschl 4822: 'srch' => 'Search',
4823: 'impo' => 'Import',
1.487 raeburn 4824: 'lnks' => 'Import from Stored Links',
1.502 raeburn 4825: 'impm' => 'Import from Assembled Map',
1.329 droeschl 4826: 'selm' => 'Select Map',
4827: 'load' => 'Load Map',
4828: 'newf' => 'New Folder',
4829: 'newp' => 'New Composite Page',
4830: 'syll' => 'Syllabus',
1.425 raeburn 4831: 'navc' => 'Table of Contents',
1.343 biermanm 4832: 'sipa' => 'Simple Course Page',
1.329 droeschl 4833: 'sipr' => 'Simple Problem',
1.534 raeburn 4834: 'webp' => 'Blank Web Page (editable)',
1.329 droeschl 4835: 'drbx' => 'Drop Box',
1.451 www 4836: 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336 schafran 4837: 'bull' => 'Discussion Board',
1.347 weissno 4838: 'mypi' => 'My Personal Information Page',
1.353 weissno 4839: 'grpo' => 'Group Portfolio',
1.329 droeschl 4840: 'rost' => 'Course Roster',
1.528 raeburn 4841: 'abou' => 'Personal Information Page for a User',
1.553 raeburn 4842: 'imsf' => 'IMS Upload',
4843: 'imsl' => 'Upload IMS package',
1.501 raeburn 4844: 'cms' => 'Origin of IMS package',
4845: 'se' => 'Select',
1.329 droeschl 4846: 'file' => 'File',
4847: 'title' => 'Title',
4848: 'comment' => 'Comment',
1.403 raeburn 4849: 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.329 droeschl 4850: );
4851: # -----------------------------------------------------------------------------
4852: my $fileupload=(<<FIUP);
4853: $lt{'file'}:<br />
4854: <input type="file" name="uploaddoc" size="40" />
4855: FIUP
4856:
4857: my $checkbox=(<<CHBO);
4858: <!-- <label>$lt{'parse'}?
4859: <input type="checkbox" name="parserflag" />
4860: </label> -->
4861: <label>
4862: <input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
4863: </label>
4864: CHBO
1.501 raeburn 4865: my $imsfolder = $env{'form.folder'};
4866: if ($imsfolder eq '') {
4867: $imsfolder = 'default';
4868: }
4869: my $imspform=(<<IMSFORM);
4870: <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
4871: $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
4872: <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
1.516 raeburn 4873: <fieldset id="uploadimsform" style="display: none;">
1.501 raeburn 4874: <legend>$lt{'imsf'}</legend>
4875: $fileupload
4876: <br />
4877: <p>
4878: $lt{'cms'}:
4879: <select name="source">
4880: <option value="-1" selected="selected">$lt{'se'}</option>
4881: <option value="bb5">Blackboard 5</option>
4882: <option value="bb6">Blackboard 6</option>
4883: <option value="angel5">ANGEL 5.5</option>
4884: <option value="webctce4">WebCT 4 Campus Edition</option>
4885: </select>
4886: <input type="hidden" name="folder" value="$imsfolder" />
4887: </p>
4888: <input type="hidden" name="phase" value="one" />
4889: <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" />
4890: </fieldset>
4891: </form>
4892: IMSFORM
1.329 droeschl 4893:
4894: my $fileuploadform=(<<FUFORM);
1.501 raeburn 4895: <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
4896: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
4897: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.516 raeburn 4898: <fieldset id="uploaddocform" style="display: none;">
1.501 raeburn 4899: <legend>$lt{'upfi'}</legend>
1.371 tempelho 4900: <input type="hidden" name="active" value="aa" />
1.329 droeschl 4901: $fileupload
4902: <br />
4903: $lt{'title'}:<br />
1.458 raeburn 4904: <input type="text" size="60" name="comment" />
1.508 raeburn 4905: $pathitem
1.329 droeschl 4906: <input type="hidden" name="cmd" value="upload_default" />
4907: <br />
1.458 raeburn 4908: <span class="LC_nobreak" style="float:left">
1.329 droeschl 4909: $checkbox
4910: </span>
1.501 raeburn 4911: <br clear="all" />
4912: <input type="submit" value="$lt{'upld'}" />
4913: </fieldset>
4914: </form>
1.383 tempelho 4915: FUFORM
1.329 droeschl 4916:
1.502 raeburn 4917: my $importpubform=(<<SEDFFORM);
1.514 raeburn 4918: <a class="LC_menubuttons_link" href="javascript:toggleMap('map');">
1.502 raeburn 4919: $lt{'impm'}</a>$help{'Load_Map'}
4920: <form action="/adm/coursedocs" method="post" name="mapimportform">
1.516 raeburn 4921: <fieldset id="importmapform" style="display: none;">
1.502 raeburn 4922: <legend>$lt{'impm'}</legend>
1.371 tempelho 4923: <input type="hidden" name="active" value="bb" />
1.502 raeburn 4924: $lt{'copm'}<br />
4925: <span class="LC_nobreak">
4926: <input type="text" name="importmap" size="40" value=""
4927: onfocus="this.blur();openbrowser('mapimportform','importmap','sequence,page','');" />
1.516 raeburn 4928: <a href="javascript:openbrowser('mapimportform','importmap','sequence,page','');">$lt{'selm'}</a></span><br />
1.502 raeburn 4929: <input type="submit" name="loadmap" value="$lt{'load'}" />
4930: </fieldset>
4931: </form>
4932:
1.383 tempelho 4933: SEDFFORM
1.502 raeburn 4934: my @importpubforma = (
1.508 raeburn 4935: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/src.png" alt="'.$lt{srch}.'" onclick="javascript:groupsearch()" />' => $pathitem."<a class='LC_menubuttons_link' href='javascript:groupsearch()'>$lt{'srch'}</a>" },
1.423 onken 4936: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{impo}.'" onclick="javascript:groupimport();"/>' => "<a class='LC_menubuttons_link' href='javascript:groupimport();'>$lt{'impo'}</a>$help{'Importing_LON-CAPA_Resource'}" },
1.487 raeburn 4937: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{lnks}.'" onclick="javascript:open_StoredLinks_Import();" />' => "<a class='LC_menubuttons_link' href='javascript:open_StoredLinks_Import();'>$lt{'lnks'}</a>" },
1.514 raeburn 4938: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform }
1.383 tempelho 4939: );
1.502 raeburn 4940: $importpubform = &create_form_ul(&create_list_elements(@importpubforma));
1.510 raeburn 4941: my $extresourcesform =
4942: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
4943: $help{'Adding_External_Resource'});
1.329 droeschl 4944: if ($allowed) {
1.492 raeburn 4945: my $folder = $env{'form.folder'};
4946: if ($folder eq '') {
4947: $folder='default';
4948: }
1.538 raeburn 4949: my $output = &update_paste_buffer($coursenum,$coursedom,$folder);
4950: if ($output) {
4951: $r->print($output);
4952: }
1.337 ehlerst 4953: $r->print(<<HIDDENFORM);
4954: <form name="renameform" method="post" action="/adm/coursedocs">
4955: <input type="hidden" name="title" />
4956: <input type="hidden" name="cmd" />
4957: <input type="hidden" name="markcopy" />
4958: <input type="hidden" name="copyfolder" />
4959: $containertag
4960: </form>
1.484 raeburn 4961:
1.337 ehlerst 4962: HIDDENFORM
1.508 raeburn 4963: $r->print(&makesimpleeditform($pathitem)."\n".
4964: &makedocslogform($pathitem."\n".
1.484 raeburn 4965: '<input type="hidden" name="folder" value="'.
4966: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 4967: }
1.442 www 4968:
4969: # Generate the tabs
1.510 raeburn 4970: my ($mode,$needs_end);
1.472 raeburn 4971: if (($supplementalflag) && (!$allowed)) {
1.510 raeburn 4972: my @folders = split('&',$env{'form.folderpath'});
4973: unless (@folders > 2) {
4974: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
4975: $needs_end = 1;
4976: }
1.472 raeburn 4977: } else {
1.484 raeburn 4978: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.510 raeburn 4979: $needs_end = 1;
1.472 raeburn 4980: }
1.443 www 4981:
1.442 www 4982: #
4983:
4984: my $savefolderpath;
4985:
1.395 raeburn 4986: if ($allowed) {
1.329 droeschl 4987: my $folder=$env{'form.folder'};
1.443 www 4988: if ($folder eq '' || $supplementalflag) {
1.329 droeschl 4989: $folder='default';
1.356 tempelho 4990: $savefolderpath = $env{'form.folderpath'};
1.548 raeburn 4991: $env{'form.folderpath'}='default&'.&escape(&mt('Main Content'));
1.508 raeburn 4992: $pathitem = '<input type="hidden" name="folderpath" value="'.
1.329 droeschl 4993: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
4994: }
4995: my $postexec='';
4996: if ($folder eq 'default') {
1.372 bisitz 4997: $r->print('<script type="text/javascript">'."\n"
4998: .'// <![CDATA['."\n"
4999: .'this.window.name="loncapaclient";'."\n"
5000: .'// ]]>'."\n"
5001: .'</script>'."\n"
1.369 bisitz 5002: );
1.329 droeschl 5003: } else {
5004: #$postexec='self.close();';
5005: }
1.504 raeburn 5006: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
5007: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
1.329 droeschl 5008: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
5009:
5010: my $newnavform=(<<NNFORM);
5011: <form action="/adm/coursedocs" method="post" name="newnav">
1.570 raeburn 5012: <input type="hidden" name="active" value="ee" />
1.508 raeburn 5013: $pathitem
1.329 droeschl 5014: <input type="hidden" name="importdetail"
5015: value="$lt{'navc'}=/adm/navmaps" />
1.423 onken 5016: <a class="LC_menubuttons_link" href="javascript:document.newnav.submit()">$lt{'navc'}</a>
1.329 droeschl 5017: $help{'Navigate_Content'}
5018: </form>
5019: NNFORM
5020: my $newsmppageform=(<<NSPFORM);
5021: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.570 raeburn 5022: <input type="hidden" name="active" value="ee" />
1.508 raeburn 5023: $pathitem
1.329 droeschl 5024: <input type="hidden" name="importdetail" value="" />
1.423 onken 5025: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 5026: $help{'Simple Page'}
1.329 droeschl 5027: </form>
5028: NSPFORM
5029:
5030: my $newsmpproblemform=(<<NSPROBFORM);
5031: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371 tempelho 5032: <input type="hidden" name="active" value="cc" />
1.508 raeburn 5033: $pathitem
1.329 droeschl 5034: <input type="hidden" name="importdetail" value="" />
1.423 onken 5035: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.572 raeburn 5036: $help{'Simple_Problem'}
1.329 droeschl 5037: </form>
5038:
5039: NSPROBFORM
5040:
5041: my $newdropboxform=(<<NDBFORM);
5042: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.371 tempelho 5043: <input type="hidden" name="active" value="cc" />
1.508 raeburn 5044: $pathitem
1.329 droeschl 5045: <input type="hidden" name="importdetail" value="" />
1.423 onken 5046: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.554 raeburn 5047: $help{'Dropbox'}
1.344 bisitz 5048: </form>
1.329 droeschl 5049: NDBFORM
5050:
5051: my $newexuploadform=(<<NEXUFORM);
5052: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.371 tempelho 5053: <input type="hidden" name="active" value="cc" />
1.508 raeburn 5054: $pathitem
1.329 droeschl 5055: <input type="hidden" name="importdetail" value="" />
1.423 onken 5056: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 5057: $help{'Score_Upload_Form'}
5058: </form>
5059: NEXUFORM
5060:
5061: my $newbulform=(<<NBFORM);
5062: <form action="/adm/coursedocs" method="post" name="newbul">
1.570 raeburn 5063: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5064: $pathitem
1.329 droeschl 5065: <input type="hidden" name="importdetail" value="" />
1.423 onken 5066: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 5067: $help{'Bulletin Board'}
5068: </form>
5069: NBFORM
5070:
5071: my $newaboutmeform=(<<NAMFORM);
5072: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.570 raeburn 5073: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5074: $pathitem
1.329 droeschl 5075: <input type="hidden" name="importdetail"
5076: value="$plainname=/adm/$udom/$uname/aboutme" />
1.423 onken 5077: <a class="LC_menubuttons_link" href="javascript:document.newaboutme.submit()">$lt{'mypi'}</a>
1.347 weissno 5078: $help{'My Personal Information Page'}
1.329 droeschl 5079: </form>
5080: NAMFORM
5081:
5082: my $newaboutsomeoneform=(<<NASOFORM);
5083: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.570 raeburn 5084: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5085: $pathitem
1.329 droeschl 5086: <input type="hidden" name="importdetail" value="" />
1.423 onken 5087: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 5088: </form>
5089: NASOFORM
5090:
5091: my $newrosterform=(<<NROSTFORM);
5092: <form action="/adm/coursedocs" method="post" name="newroster">
1.570 raeburn 5093: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5094: $pathitem
1.329 droeschl 5095: <input type="hidden" name="importdetail"
5096: value="$lt{'rost'}=/adm/viewclasslist" />
1.423 onken 5097: <a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a>
1.556 raeburn 5098: $help{'Course_Roster'}
1.329 droeschl 5099: </form>
5100: NROSTFORM
5101:
1.534 raeburn 5102: my $newwebpage;
5103: if ($folder =~ /^default_?(\d*)$/) {
5104: $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
5105: if ($1) {
5106: $newwebpage .= $1;
5107: } else {
5108: $newwebpage .= 'default';
5109: }
5110: $newwebpage .= '/new.html';
5111: }
5112: my $newwebpageform =(<<NWEBFORM);
5113: <form action="/adm/coursedocs" method="post" name="newwebpage">
1.570 raeburn 5114: <input type="hidden" name="active" value="ee" />
1.534 raeburn 5115: $pathitem
5116: <input type="hidden" name="importdetail" value="$newwebpage" />
5117: <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
1.556 raeburn 5118: $help{'Web_Page'}
1.534 raeburn 5119: </form>
5120: NWEBFORM
5121:
5122:
1.342 ehlerst 5123: my $specialdocumentsform;
1.383 tempelho 5124: my @specialdocumentsforma;
1.451 www 5125: my $gradingform;
5126: my @gradingforma;
5127: my $communityform;
5128: my @communityforma;
1.351 ehlerst 5129: my $newfolderform;
1.390 tempelho 5130: my $newfolderb;
1.342 ehlerst 5131:
1.451 www 5132: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 5133:
1.329 droeschl 5134: my $newpageform=(<<NPFORM);
5135: <form action="/adm/coursedocs" method="post" name="newpage">
5136: <input type="hidden" name="folderpath" value="$path" />
5137: <input type="hidden" name="importdetail" value="" />
1.570 raeburn 5138: <input type="hidden" name="active" value="ee" />
1.423 onken 5139: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 5140: $help{'Adding_Pages'}
1.329 droeschl 5141: </form>
5142: NPFORM
1.390 tempelho 5143:
5144:
1.351 ehlerst 5145: $newfolderform=(<<NFFORM);
1.329 droeschl 5146: <form action="/adm/coursedocs" method="post" name="newfolder">
1.508 raeburn 5147: $pathitem
1.329 droeschl 5148: <input type="hidden" name="importdetail" value="" />
1.570 raeburn 5149: <input type="hidden" name="active" value="" />
1.422 onken 5150: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 5151: </form>
5152: NFFORM
5153:
5154: my $newsylform=(<<NSYLFORM);
5155: <form action="/adm/coursedocs" method="post" name="newsyl">
1.570 raeburn 5156: <input type="hidden" name="active" value="ee" />
1.508 raeburn 5157: $pathitem
1.329 droeschl 5158: <input type="hidden" name="importdetail"
5159: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.423 onken 5160: <a class="LC_menubuttons_link" href="javascript:document.newsyl.submit()">$lt{'syll'}</a>
1.329 droeschl 5161: $help{'Syllabus'}
1.383 tempelho 5162:
1.329 droeschl 5163: </form>
5164: NSYLFORM
1.364 bisitz 5165:
1.329 droeschl 5166: my $newgroupfileform=(<<NGFFORM);
5167: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.570 raeburn 5168: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5169: $pathitem
1.329 droeschl 5170: <input type="hidden" name="importdetail"
5171: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.423 onken 5172: <a class="LC_menubuttons_link" href="javascript:document.newgroupfiles.submit()">$lt{'grpo'}</a>
1.353 weissno 5173: $help{'Group Portfolio'}
1.329 droeschl 5174: </form>
5175: NGFFORM
1.383 tempelho 5176: @specialdocumentsforma=(
1.421 onken 5177: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/page.png" alt="'.$lt{newp}.'" onclick="javascript:makenewpage(document.newpage,\''.$pageseq.'\');" />'=>$newpageform},
1.417 droeschl 5178: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.newsyl.submit()" />'=>$newsylform},
1.451 www 5179: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="document.newnav.submit()" />'=>$newnavform},
5180: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
1.534 raeburn 5181: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
1.451 www 5182: );
5183: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
5184:
1.434 raeburn 5185:
5186: my @importdoc = (
1.519 raeburn 5187: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform}
5188: );
5189: unless ($container eq 'page') {
5190: push(@importdoc,
5191: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform}
5192: );
5193: }
5194: push(@importdoc,
1.558 raeburn 5195: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'doc\');" />'=>$fileuploadform}
1.519 raeburn 5196: );
1.501 raeburn 5197: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
1.434 raeburn 5198:
1.451 www 5199: @gradingforma=(
5200: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
5201: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
5202: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
5203:
5204: );
5205: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
5206:
5207: @communityforma=(
5208: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
5209: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
5210: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
5211: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="document.newroster.submit()" />'=>$newrosterform},
5212: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="document.newgroupfiles.submit()" />'=>$newgroupfileform},
5213: );
5214: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 5215:
1.330 tempelho 5216: my %orderhash = (
1.553 raeburn 5217: 'aa' => ['Upload',$fileuploadform],
5218: 'bb' => ['Import',$importpubform],
5219: 'cc' => ['Grading',$gradingform],
1.330 tempelho 5220: );
1.519 raeburn 5221: unless ($container eq 'page') {
1.434 raeburn 5222: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.484 raeburn 5223: $orderhash{'dd'} = ['Collaboration',$communityform];
1.553 raeburn 5224: $orderhash{'ee'} = ['Other',$specialdocumentsform];
1.434 raeburn 5225: }
5226:
1.341 ehlerst 5227: $hadchanges=0;
1.484 raeburn 5228: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 5229: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.508 raeburn 5230: $supplementalflag,\%orderhash,$iconpath,$pathitem);
1.443 www 5231: if ($error) {
5232: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
5233: }
5234: if ($hadchanges) {
5235: &mark_hash_old();
5236: }
1.341 ehlerst 5237:
1.443 www 5238: &changewarning($r,'');
5239: }
1.458 raeburn 5240: }
1.442 www 5241:
1.443 www 5242: # Supplemental documents start here
5243:
1.329 droeschl 5244: my $folder=$env{'form.folder'};
1.443 www 5245: unless ($supplementalflag) {
1.329 droeschl 5246: $folder='supplemental';
5247: }
5248: if ($folder =~ /^supplemental$/ &&
5249: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 5250: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 5251: } elsif ($allowed) {
1.356 tempelho 5252: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 5253: }
1.508 raeburn 5254: $pathitem = '<input type="hidden" name="folderpath" value="'.
5255: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.329 droeschl 5256: if ($allowed) {
5257: my $folderseq=
1.504 raeburn 5258: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
1.329 droeschl 5259:
5260: my $supupdocform=(<<SUPDOCFORM);
1.501 raeburn 5261: <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
5262: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
1.383 tempelho 5263: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.516 raeburn 5264: <fieldset id="uploadsuppdocform" style="display: none;">
1.501 raeburn 5265: <legend>$lt{'upfi'}</legend>
1.371 tempelho 5266: <input type="hidden" name="active" value="ee" />
1.329 droeschl 5267: $fileupload
5268: <br />
5269: <br />
5270: <span class="LC_nobreak">
5271: $checkbox
5272: </span>
5273: <br /><br />
5274: $lt{'comment'}:<br />
1.383 tempelho 5275: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 5276: <br />
1.508 raeburn 5277: $pathitem
1.329 droeschl 5278: <input type="hidden" name="cmd" value="upload_supplemental" />
1.501 raeburn 5279: <input type='submit' value="$lt{'upld'}" />
5280: </form>
1.329 droeschl 5281: SUPDOCFORM
5282:
5283: my $supnewfolderform=(<<SNFFORM);
5284: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.570 raeburn 5285: <input type="hidden" name="active" value="" />
1.508 raeburn 5286: $pathitem
1.329 droeschl 5287: <input type="hidden" name="importdetail" value="" />
1.423 onken 5288: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 5289: $help{'Adding_Folders'}
1.329 droeschl 5290: </form>
5291: SNFFORM
1.383 tempelho 5292:
1.510 raeburn 5293: my $supextform =
5294: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
5295: $help{'Adding_External_Resource'});
1.329 droeschl 5296:
5297: my $supnewsylform=(<<SNSFORM);
5298: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 5299: <input type="hidden" name="active" value="ff" />
1.508 raeburn 5300: $pathitem
1.329 droeschl 5301: <input type="hidden" name="importdetail"
5302: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.423 onken 5303: <a class="LC_menubuttons_link" href="javascript:document.supnewsyl.submit()">$lt{'syll'}</a>
1.329 droeschl 5304: $help{'Syllabus'}
5305: </form>
5306: SNSFORM
5307:
5308: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 5309: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 5310: <input type="hidden" name="active" value="ff" />
1.508 raeburn 5311: $pathitem
1.329 droeschl 5312: <input type="hidden" name="importdetail"
5313: value="$plainname=/adm/$udom/$uname/aboutme" />
1.423 onken 5314: <a class="LC_menubuttons_link" href="javascript:document.supnewaboutme.submit()">$lt{'mypi'}</a>
1.347 weissno 5315: $help{'My Personal Information Page'}
1.329 droeschl 5316: </form>
5317: SNAMFORM
5318:
1.534 raeburn 5319: my $supwebpage;
5320: if ($folder =~ /^supplemental_?(\d*)$/) {
5321: $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
5322: if ($1) {
5323: $supwebpage .= $1;
5324: } else {
5325: $supwebpage .= 'default';
5326: }
5327: $supwebpage .= '/new.html';
5328: }
5329: my $supwebpageform =(<<SWEBFORM);
5330: <form action="/adm/coursedocs" method="post" name="supwebpage">
5331: <input type="hidden" name="active" value="cc" />
5332: $pathitem
5333: <input type="hidden" name="importdetail" value="$supwebpage" />
5334: <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
1.556 raeburn 5335: $help{'Web_Page'}
1.534 raeburn 5336: </form>
5337: SWEBFORM
5338:
1.333 muellerd 5339:
1.383 tempelho 5340: my @specialdocs = (
1.417 droeschl 5341: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.supnewsyl.submit()" />'
5342: =>$supnewsylform},
5343: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="document.supnewaboutme.submit()" />'
5344: =>$supnewaboutmeform},
1.534 raeburn 5345: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
5346:
1.383 tempelho 5347: );
1.417 droeschl 5348: my @supimportdoc = (
1.515 raeburn 5349: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleUpload(\'suppext\')" />'
1.501 raeburn 5350: =>$supextform},
5351: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
5352: =>$supupdocform},
5353: );
5354:
5355: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
1.333 muellerd 5356: my %suporderhash = (
1.390 tempelho 5357: '00' => ['Supnewfolder', $supnewfolderform],
1.553 raeburn 5358: 'ee' => ['Upload',$supupdocform],
5359: 'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 5360: );
1.443 www 5361: if ($supplementalflag) {
1.458 raeburn 5362: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.508 raeburn 5363: $supplementalflag,\%suporderhash,$iconpath,$pathitem);
1.443 www 5364: if ($error) {
5365: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.557 raeburn 5366: } else {
5367: if ($suppchanges) {
5368: my %servers = &Apache::lonnet::internet_dom_servers($coursedom);
5369: my @ids=&Apache::lonnet::current_machine_ids();
5370: foreach my $server (keys(%servers)) {
5371: next if (grep(/^\Q$server\E$/,@ids));
5372: my $hashid=$coursenum.':'.$coursedom;
1.566 raeburn 5373: my $cachekey = &escape('suppcount').':'.&escape($hashid);
5374: &Apache::lonnet::remote_devalidate_cache($server,[$cachekey]);
1.557 raeburn 5375: }
5376: &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
5377: undef($suppchanges);
5378: }
5379: }
1.393 raeburn 5380: }
1.443 www 5381: } elsif ($supplementalflag) {
1.458 raeburn 5382: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.508 raeburn 5383: $supplementalflag,'',$iconpath,$pathitem);
1.393 raeburn 5384: if ($error) {
5385: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 5386: }
1.393 raeburn 5387: }
1.389 tempelho 5388:
1.510 raeburn 5389: if ($needs_end) {
5390: $r->print(&endContentScreen());
5391: }
1.383 tempelho 5392:
1.329 droeschl 5393: if ($allowed) {
5394: $r->print('
5395: <form method="post" name="extimport" action="/adm/coursedocs">
5396: <input type="hidden" name="title" />
5397: <input type="hidden" name="url" />
5398: <input type="hidden" name="useform" />
5399: <input type="hidden" name="residx" />
5400: </form>');
5401: }
1.484 raeburn 5402: } elsif ($showdoc) {
1.329 droeschl 5403: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 5404: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.498 bisitz 5405: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 5406: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 5407: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 5408: }
5409: }
5410: $r->print(&Apache::loncommon::end_page());
5411: return OK;
1.364 bisitz 5412: }
1.329 droeschl 5413:
1.440 raeburn 5414: sub embedded_form_elems {
5415: my ($phase,$primaryurl,$newidx) = @_;
5416: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
5417: return <<STATE;
5418: <input type="hidden" name="folderpath" value="$folderpath" />
5419: <input type="hidden" name="cmd" value="upload_embedded" />
5420: <input type="hidden" name="newidx" value="$newidx" />
5421: <input type="hidden" name="phase" value="$phase" />
5422: <input type="hidden" name="primaryurl" value="$primaryurl" />
5423: STATE
5424: }
5425:
5426: sub embedded_destination {
5427: my $folder=$env{'form.folder'};
5428: my $destination = 'docs/';
5429: if ($folder =~ /^supplemental/) {
5430: $destination = 'supplemental/';
5431: }
5432: if (($folder eq 'default') || ($folder eq 'supplemental')) {
5433: $destination .= 'default/';
5434: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
5435: $destination .= $2.'/';
5436: }
5437: $destination .= $env{'form.newidx'};
5438: my $dir_root = '/userfiles';
5439: return ($destination,$dir_root);
5440: }
5441:
5442: sub return_to_editor {
5443: my $actionurl = '/adm/coursedocs';
5444: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
5445: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
5446: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
5447: '</a></p>';
5448: }
5449:
1.476 raeburn 5450: sub decompression_info {
5451: my ($destination,$dir_root) = &embedded_destination();
5452: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
5453: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5454: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5455: my $container='sequence';
1.480 raeburn 5456: my ($pathitem,$hiddenelem);
1.519 raeburn 5457: my @hiddens = ('newidx','comment','position','folderpath');
5458: if ($env{'form.folderpath'} =~ /\:1$/) {
1.476 raeburn 5459: $container='page';
5460: }
1.480 raeburn 5461: unshift(@hiddens,$pathitem);
5462: foreach my $item (@hiddens) {
5463: if ($env{'form.'.$item}) {
5464: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
5465: $env{'form.'.$item}.'" />'."\n";
5466: }
1.477 raeburn 5467: }
1.476 raeburn 5468: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
5469: $hiddenelem);
5470: }
5471:
5472: sub decompression_phase_one {
5473: my ($dir,$file,$warning,$error,$output);
5474: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
5475: &decompression_info();
1.490 raeburn 5476: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 5477: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
5478: } else {
5479: my $file = $1;
1.481 raeburn 5480: $output =
5481: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
5482: $destination,$dir_root,
5483: $hiddenelem);
5484: if ($env{'form.autoextract_camtasia'}) {
5485: $output .= &remove_archive($docudom,$docuname,$container);
5486: }
1.476 raeburn 5487: }
5488: if ($error) {
5489: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
5490: $error.'</p>'."\n";
5491: }
5492: if ($warning) {
5493: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
5494: }
5495: return $output;
5496: }
5497:
5498: sub decompression_phase_two {
5499: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
5500: &decompression_info();
1.481 raeburn 5501: my $output;
1.480 raeburn 5502: if ($env{'form.archivedelete'}) {
1.481 raeburn 5503: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 5504: }
5505: $output .=
1.481 raeburn 5506: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 5507: $destination,$dir_root,$hiddenelem);
5508: return $output;
5509: }
5510:
1.480 raeburn 5511: sub remove_archive {
5512: my ($docudom,$docuname,$container) = @_;
5513: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 5514: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 5515: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
5516: if ($fatal) {
5517: if ($container eq 'page') {
5518: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
5519: } else {
5520: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
5521: }
5522: $delwarning .= &mt('As a result the archive file has not been removed.');
5523: } else {
5524: my $currcmd = $env{'form.cmd'};
5525: my $position = $env{'form.position'};
1.563 raeburn 5526: if ($position > 0) {
5527: $env{'form.cmd'} = 'remove_'.$position;
1.480 raeburn 5528: my ($title,$url,@rrest) =
5529: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]);
5530: if (&handle_edit_cmd($docuname,$docudom)) {
1.492 raeburn 5531: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
1.480 raeburn 5532: if ($fatal) {
5533: if ($container eq 'page') {
5534: $delwarning = &mt('An error occurred updating the contents of the current page.');
5535: } else {
5536: $delwarning = &mt('An error occurred updating the contents of the current folder.');
5537: }
5538: } else {
1.481 raeburn 5539: $delresult = &mt('Archive file removed.');
1.480 raeburn 5540: }
5541: }
5542: }
5543: $env{'form.cmd'} = $currcmd;
5544: }
5545: if ($delwarning) {
5546: $output = '<p class="LC_warning">'.
5547: $delwarning.
5548: '</p>';
5549: }
5550: if ($delresult) {
5551: $output .= '<p class="LC_info">'.
5552: $delresult.
5553: '</p>';
5554: }
1.481 raeburn 5555: return $output;
1.480 raeburn 5556: }
5557:
1.484 raeburn 5558: sub generate_admin_menu {
5559: my ($crstype) = @_;
5560: my $lc_crstype = lc($crstype);
5561: my ($home,$other,%outhash)=&authorhosts();
1.562 bisitz 5562: my %lt= ( # do not translate here
1.484 raeburn 5563: 'vc' => 'Verify Content',
5564: 'cv' => 'Check/Set Resource Versions',
5565: 'ls' => 'List Resource Identifiers',
5566: 'imse' => 'Export contents to IMS Archive',
1.568 raeburn 5567: 'dcd' => "Copy $crstype Content to Authoring Space",
1.562 bisitz 5568: );
1.484 raeburn 5569: my ($candump,$dumpurl);
5570: if ($home + $other > 0) {
5571: $candump = 'F';
5572: if ($home) {
5573: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
5574: } else {
5575: my @hosts;
5576: foreach my $aurole (keys(%outhash)) {
5577: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
5578: push(@hosts,$outhash{$aurole});
1.538 raeburn 5579: }
1.484 raeburn 5580: }
5581: if (@hosts == 1) {
5582: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
5583: '&role='.
5584: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
5585: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
5586: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
5587: } else {
5588: $dumpurl = "javascript:choose_switchserver_window()";
5589: }
5590: }
5591: }
5592: my @menu=
5593: ({ categorytitle=>'Administration',
5594: items =>[
5595: { linktext => $lt{'vc'},
5596: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
5597: permission => 'F',
1.571 raeburn 5598: help => 'Docs_Verify_Content',
1.484 raeburn 5599: icon => 'verify.png',
5600: linktitle => 'Verify contents can be retrieved/rendered',
5601: },
5602: { linktext => $lt{'cv'},
5603: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
5604: permission => 'F',
1.571 raeburn 5605: help => 'Docs_Check_Resource_Versions',
1.484 raeburn 5606: icon => 'resversion.png',
5607: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
5608: },
5609: { linktext => $lt{'ls'},
5610: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
5611: permission => 'F',
5612: #help => '',
5613: icon => 'symbs.png',
5614: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
5615: },
5616: ]
5617: },
5618: { categorytitle=>'Export',
5619: items =>[
5620: { linktext => $lt{'imse'},
5621: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
5622: permission => 'F',
5623: help => 'Docs_Export_Course_Docs',
5624: icon => 'imsexport.png',
5625: linktitle => $lt{'imse'},
5626: },
5627: { linktext => $lt{'dcd'},
5628: url => $dumpurl,
5629: permission => $candump,
1.571 raeburn 5630: help => 'Docs_Dump_Course_Docs',
1.484 raeburn 5631: icon => 'dump.png',
5632: linktitle => $lt{'dcd'},
5633: },
5634: ]
5635: });
5636: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
5637: '<input type="hidden" id="dummy" />'."\n".
5638: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
5639: '</form>';
1.329 droeschl 5640: }
5641:
5642: sub generate_edit_table {
1.538 raeburn 5643: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile,
5644: $need_save,$copyfolder) = @_;
1.406 raeburn 5645: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 5646: my %orderhash = %{$orderhash_ref};
1.344 bisitz 5647: my $form;
1.371 tempelho 5648: my $activetab;
5649: my $active;
1.570 raeburn 5650: if (($env{'form.active'} ne '') && ($env{'form.active'} ne '00')) {
1.371 tempelho 5651: $activetab = $env{'form.active'};
5652: }
1.472 raeburn 5653: my $backicon = $iconpath.'clickhere.gif';
1.525 raeburn 5654: my $backtext = &mt('Exit Editor');
1.458 raeburn 5655: $form = '<div class="LC_Box" style="margin:0;">'.
1.488 raeburn 5656: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
5657: '<li class="goback">'.
1.546 raeburn 5658: '<a href="javascript:toContents('."'$jumpto'".');">'.
1.488 raeburn 5659: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
5660: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
5661: '<li>'.
5662: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
5663: &mt('Undo Delete').'</a></li>'."\n";
5664: if ($env{'form.docslog'}) {
5665: $form .= '<li class="active">';
5666: } else {
5667: $form .= '<li>';
5668: }
5669: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
5670: &mt('History').'</a></li>'."\n";
5671: if ($env{'form.docslog'}) {
5672: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
5673: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 5674: }
1.458 raeburn 5675: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 5676: if($name ne '00'){
1.371 tempelho 5677: if($activetab eq '' || $activetab ne $name){
5678: $active = '';
5679: }elsif($activetab eq $name){
5680: $active = 'class="active"';
5681: }
1.458 raeburn 5682: $form .= '<li style="float:right" '.$active
1.484 raeburn 5683: .' onclick="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"><a href="javascript:;"><b>'.&mt(${$orderhash{$name}}[0]).'</b></a></li>'."\n";
1.390 tempelho 5684: } else {
1.570 raeburn 5685: $form .= '<li style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 5686:
5687: }
1.329 droeschl 5688: }
1.484 raeburn 5689: $form .= '</ul>'."\n";
5690: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 5691:
5692: if ($to_show ne '') {
1.538 raeburn 5693: my $saveform;
5694: if ($need_save) {
5695: my $button = &mt('Make changes');
5696: my $path;
5697: if ($env{'form.folderpath'}) {
5698: $path =
5699: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
5700: }
5701: $saveform = <<"END";
5702: <div id="multisave" style="display:none; clear:both;" >
5703: <form name="saveactions" method="post" action="/adm/coursedocs" onsubmit="return checkSubmits();">
5704: <input type="hidden" name="folderpath" value="$path" />
5705: <input type="hidden" name="symb" value="$env{'form.symb'}" />
5706: <input type="hidden" name="allhiddenresource" value="" />
5707: <input type="hidden" name="allencrypturl" value="" />
5708: <input type="hidden" name="allrandompick" value="" />
5709: <input type="hidden" name="allrandomorder" value="" />
5710: <input type="hidden" name="changeparms" value="" />
5711: <input type="hidden" name="multiremove" value="" />
5712: <input type="hidden" name="multicut" value="" />
5713: <input type="hidden" name="multicopy" value="" />
5714: <input type="hidden" name="multichange" value="" />
5715: <input type="hidden" name="copyfolder" value="$copyfolder" />
5716: <input type="submit" name="savemultiples" value="$button" />
5717: </form>
5718: </div>
5719: END
5720: }
5721: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'.$saveform."\n";
1.458 raeburn 5722: }
1.363 ehlerst 5723: foreach my $field (keys(%orderhash)){
1.390 tempelho 5724: if($field ne '00'){
1.422 onken 5725: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 5726: $active = 'style="display: none;float:left"';
1.422 onken 5727: }elsif($activetab eq $field){
1.458 raeburn 5728: $active = 'style="display:block;float:left"';
1.422 onken 5729: }
5730: $form .= '<div id="'.$field.$tid.'"'
5731: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 5732: .'</div>'."\n";
1.363 ehlerst 5733: }
5734: }
1.484 raeburn 5735: unless ($env{'form.docslog'}) {
5736: $form .= '</div></div>'."\n";
5737: }
1.329 droeschl 5738: return $form;
5739: }
5740:
5741: sub editing_js {
1.472 raeburn 5742: my ($udom,$uname,$supplementalflag) = @_;
1.329 droeschl 5743: my %lt = &Apache::lonlocal::texthash(
5744: p_mnf => 'Name of New Folder',
5745: t_mnf => 'New Folder',
5746: p_mnp => 'Name of New Page',
5747: t_mnp => 'New Page',
1.451 www 5748: p_mxu => 'Title for the External Score',
1.349 biermanm 5749: p_msp => 'Name of Simple Course Page',
1.329 droeschl 5750: p_msb => 'Title for the Problem',
5751: p_mdb => 'Title for the Drop Box',
1.336 schafran 5752: p_mbb => 'Title for the Discussion Board',
1.534 raeburn 5753: p_mwp => 'Title for Web Page',
1.348 weissno 5754: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 5755: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 5756: p_mab_alrt1 => 'Not a valid user:domain',
5757: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
5758: p_chn => 'New Title',
5759: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
5760: p_rmr2a => 'Remove[_99]',
5761: p_rmr2b => '?[_99]',
1.542 raeburn 5762: p_rmr3a => 'Remove those [_2]',
5763: p_rmr3b => 'items?[_2]',
1.329 droeschl 5764: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
5765: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
5766: p_ctr2a => 'Cut[_98]',
1.478 raeburn 5767: p_ctr2b => '?[_98]',
1.542 raeburn 5768: p_ctr3a => 'Cut those[_2]',
5769: p_ctr3b => 'items?[_2]',
1.478 raeburn 5770: rpck => 'Enter number to pick (e.g., 3)',
1.501 raeburn 5771: imsfile => 'You must choose an IMS package for import',
5772: imscms => 'You must select which Course Management System was the source of the IMS package',
5773: invurl => 'Invalid URL',
5774: titbl => 'Title is blank',
1.538 raeburn 5775: more => '(More ...)',
5776: less => '(Less ...)',
1.543 raeburn 5777: noor => 'No actions selected or changes to settings specified.',
5778: noch => 'No changes to settings specified.',
5779: noac => 'No actions selected.',
1.329 droeschl 5780: );
5781:
1.433 raeburn 5782: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 5783: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
5784: my $main_container_page;
1.519 raeburn 5785: if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) {
5786: $main_container_page = 1;
1.434 raeburn 5787: }
1.538 raeburn 5788: my $toplevelmain =
1.548 raeburn 5789: &escape(&mt('Main Content').':::::');
1.446 www 5790: my $toplevelsupp = &supplemental_base();
1.433 raeburn 5791:
1.525 raeburn 5792: my $backtourl;
1.530 raeburn 5793: if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
5794: my $caller = $1;
1.525 raeburn 5795: if ($caller =~ /^supplemental/) {
5796: $backtourl = '/adm/supplemental?folderpath='.&escape($caller);
5797: } else {
5798: my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
5799: $res = &Apache::lonnet::clutter($res);
5800: if (&Apache::lonnet::is_on_map($res)) {
5801: $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($res),'<>&"').'?symb='.
5802: &HTML::Entities::encode($caller,'<>&"');
1.544 raeburn 5803: } else {
5804: $backtourl = '/adm/navmaps';
1.525 raeburn 5805: }
5806: }
5807: } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
5808: $backtourl = '/adm/menu';
5809: } elsif ($supplementalflag) {
1.472 raeburn 5810: $backtourl = '/adm/supplemental';
1.525 raeburn 5811: } else {
5812: $backtourl = '/adm/navmaps';
1.472 raeburn 5813: }
5814:
1.519 raeburn 5815: my $fieldsets = "'ext','doc'";
5816: unless ($main_container_page) {
5817: $fieldsets .=",'ims'";
5818: }
1.501 raeburn 5819: if ($supplementalflag) {
5820: $fieldsets = "'suppext','suppdoc'";
5821: }
5822:
1.329 droeschl 5823: return <<ENDNEWSCRIPT;
5824: function makenewfolder(targetform,folderseq) {
5825: var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');
5826: if (foldername) {
5827: targetform.importdetail.value=escape(foldername)+"="+folderseq;
5828: targetform.submit();
5829: }
5830: }
5831:
5832: function makenewpage(targetform,folderseq) {
5833: var pagename=prompt('$lt{"p_mnp"}','$lt{"t_mnp"}');
5834: if (pagename) {
5835: targetform.importdetail.value=escape(pagename)+"="+folderseq;
5836: targetform.submit();
5837: }
5838: }
5839:
5840: function makeexamupload() {
5841: var title=prompt('$lt{"p_mxu"}');
1.344 bisitz 5842: if (title) {
1.329 droeschl 5843: this.document.forms.newexamupload.importdetail.value=
5844: escape(title)+'=/res/lib/templates/examupload.problem';
5845: this.document.forms.newexamupload.submit();
5846: }
5847: }
5848:
5849: function makesmppage() {
5850: var title=prompt('$lt{"p_msp"}');
1.344 bisitz 5851: if (title) {
1.329 droeschl 5852: this.document.forms.newsmppg.importdetail.value=
1.533 raeburn 5853: escape(title)+'=/adm/$udom/$uname/new/smppg';
1.329 droeschl 5854: this.document.forms.newsmppg.submit();
5855: }
5856: }
5857:
1.534 raeburn 5858: function makewebpage(type) {
5859: var title=prompt('$lt{"p_mwp"}');
5860: var formname;
5861: if (type == 'supp') {
5862: formname = this.document.forms.supwebpage;
5863: } else {
5864: formname = this.document.forms.newwebpage;
5865: }
5866: if (title) {
5867: var webpage = formname.importdetail.value;
5868: formname.importdetail.value = escape(title)+'='+webpage;
5869: formname.submit();
5870: }
5871: }
5872:
1.329 droeschl 5873: function makesmpproblem() {
5874: var title=prompt('$lt{"p_msb"}');
1.344 bisitz 5875: if (title) {
1.329 droeschl 5876: this.document.forms.newsmpproblem.importdetail.value=
5877: escape(title)+'=/res/lib/templates/simpleproblem.problem';
5878: this.document.forms.newsmpproblem.submit();
5879: }
5880: }
5881:
5882: function makedropbox() {
5883: var title=prompt('$lt{"p_mdb"}');
1.344 bisitz 5884: if (title) {
1.329 droeschl 5885: this.document.forms.newdropbox.importdetail.value=
5886: escape(title)+'=/res/lib/templates/DropBox.problem';
5887: this.document.forms.newdropbox.submit();
5888: }
5889: }
5890:
5891: function makebulboard() {
5892: var title=prompt('$lt{"p_mbb"}');
5893: if (title) {
5894: this.document.forms.newbul.importdetail.value=
1.533 raeburn 5895: escape(title)+'=/adm/$udom/$uname/new/bulletinboard';
1.329 droeschl 5896: this.document.forms.newbul.submit();
5897: }
5898: }
5899:
5900: function makeabout() {
5901: var user=prompt("$lt{'p_mab'}");
5902: if (user) {
5903: var comp=new Array();
5904: comp=user.split(':');
5905: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
5906: if ((comp[0]) && (comp[1])) {
5907: this.document.forms.newaboutsomeone.importdetail.value=
5908: '$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.335 ehlerst 5909: this.document.forms.newaboutsomeone.submit();
5910: } else {
5911: alert("$lt{'p_mab_alrt1'}");
1.329 droeschl 5912: }
1.335 ehlerst 5913: } else {
5914: alert("$lt{'p_mab_alrt2'}");
5915: }
5916: }
1.329 droeschl 5917: }
5918:
1.501 raeburn 5919: function toggleUpload(caller) {
5920: var blocks = Array($fieldsets);
5921: for (var i=0; i<blocks.length; i++) {
5922: var disp = 'none';
5923: if (caller == blocks[i]) {
5924: var curr = document.getElementById('upload'+caller+'form').style.display;
5925: if (curr == 'none') {
5926: disp='block';
5927: }
5928: }
5929: document.getElementById('upload'+blocks[i]+'form').style.display=disp;
5930: }
1.502 raeburn 5931: resize_scrollbox('contentscroll','1','1');
5932: return;
5933: }
5934:
1.514 raeburn 5935: function toggleMap(caller) {
1.502 raeburn 5936: var disp = 'none';
1.510 raeburn 5937: if (document.getElementById('importmapform')) {
1.514 raeburn 5938: if (caller == 'map') {
5939: var curr = document.getElementById('importmapform').style.display;
5940: if (curr == 'none') {
5941: disp='block';
5942: }
1.510 raeburn 5943: }
5944: document.getElementById('importmapform').style.display=disp;
5945: resize_scrollbox('contentscroll','1','1');
1.502 raeburn 5946: }
1.501 raeburn 5947: return;
1.329 droeschl 5948: }
5949:
1.501 raeburn 5950: function makeims(imsform) {
5951: if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
5952: alert("$lt{'imsfile'}");
5953: return;
5954: }
5955: if (imsform.source.selectedIndex == 0) {
5956: alert("$lt{'imscms'}");
5957: return;
5958: }
5959: newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
5960: imsform.submit();
5961: }
5962:
1.519 raeburn 5963: function changename(folderpath,index,oldtitle) {
1.335 ehlerst 5964: var title=prompt('$lt{"p_chn"}',oldtitle);
5965: if (title) {
1.538 raeburn 5966: this.document.forms.renameform.markcopy.value='';
1.335 ehlerst 5967: this.document.forms.renameform.title.value=title;
5968: this.document.forms.renameform.cmd.value='rename_'+index;
1.519 raeburn 5969: this.document.forms.renameform.folderpath.value=folderpath;
1.335 ehlerst 5970: this.document.forms.renameform.submit();
5971: }
1.329 droeschl 5972: }
5973:
1.478 raeburn 5974: function updatePick(targetform,index,caller) {
1.537 raeburn 5975: var pickitem;
5976: var picknumitem;
5977: var picknumtext;
5978: if (index == 'all') {
5979: pickitem = document.getElementById('randompickall');
5980: picknumitem = document.getElementById('rpicknumall');
5981: picknumtext = document.getElementById('rpicktextall');
5982: } else {
5983: pickitem = document.getElementById('randompick_'+index);
5984: picknumitem = document.getElementById('rpicknum_'+index);
5985: picknumtext = document.getElementById('randompicknum_'+index);
5986: }
1.478 raeburn 5987: if (pickitem.checked) {
5988: var picknum=prompt('$lt{"rpck"}',picknumitem.value);
5989: if (picknum == '' || picknum == null) {
5990: if (caller == 'check') {
5991: pickitem.checked=false;
1.537 raeburn 5992: if (index == 'all') {
5993: picknumtext.innerHTML = '';
5994: if (caller == 'link') {
5995: propagateState(targetform,'rpicknum');
5996: }
5997: } else {
1.538 raeburn 5998: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 5999: }
1.478 raeburn 6000: }
6001: } else {
6002: picknum.toString();
6003: var regexdigit=/^\\d+\$/;
6004: if (regexdigit.test(picknum)) {
6005: picknumitem.value = picknum;
1.537 raeburn 6006: if (index == 'all') {
1.538 raeburn 6007: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.cumulativesettings,\\'all\\',\\'link\\');">'+picknum+'</a>';
1.537 raeburn 6008: if (caller == 'link') {
6009: propagateState(targetform,'rpicknum');
6010: }
6011: } else {
6012: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.edit_randompick_'+index+',\\''+index+'\\',\\'link\\');">'+picknum+'</a>';
1.538 raeburn 6013: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 6014: }
1.478 raeburn 6015: } else {
6016: if (caller == 'check') {
1.537 raeburn 6017: if (index == 'all') {
6018: picknumtext.innerHTML = '';
6019: if (caller == 'link') {
6020: propagateState(targetform,'rpicknum');
6021: }
6022: } else {
6023: pickitem.checked=false;
1.538 raeburn 6024: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 6025: }
1.478 raeburn 6026: }
6027: return;
6028: }
6029: }
6030: } else {
1.537 raeburn 6031: picknumitem.value = '';
6032: picknumtext.innerHTML = '';
6033: if (index == 'all') {
6034: if (caller == 'link') {
6035: propagateState(targetform,'rpicknum');
6036: }
6037: } else {
1.538 raeburn 6038: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 6039: }
6040: }
6041: }
6042:
6043: function propagateState(form,param) {
6044: if (document.getElementById(param+'all')) {
6045: var setcheck = 0;
6046: var rpick = 0;
6047: if (param == 'rpicknum') {
6048: if (document.getElementById('randompickall')) {
6049: if (document.getElementById('randompickall').checked) {
6050: if (document.getElementById('rpicknumall')) {
6051: rpick = document.getElementById('rpicknumall').value;
6052: }
6053: }
6054: }
6055: } else {
6056: if (document.getElementById(param+'all').checked) {
6057: setcheck = 1;
6058: }
6059: }
1.538 raeburn 6060: var allidxlist;
6061: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
6062: if (document.getElementById('all'+param+'idx')) {
6063: allidxlist = document.getElementById('all'+param+'idx').value;
6064: }
6065: var actions = new Array ('remove','cut','copy');
6066: for (var i=0; i<actions.length; i++) {
6067: if (actions[i] != param) {
6068: if (document.getElementById(actions[i]+'all')) {
6069: document.getElementById(actions[i]+'all').checked = false;
6070: }
6071: }
6072: }
6073: }
1.537 raeburn 6074: if ((param == 'encrypturl') || (param == 'hiddenresource')) {
1.538 raeburn 6075: allidxlist = form.allidx.value;
6076: }
6077: if ((param == 'randompick') || (param == 'rpicknum') || (param == 'randomorder')) {
6078: allidxlist = form.allmapidx.value;
6079: }
6080: if ((allidxlist != '') && (allidxlist != null)) {
6081: var allidxs = allidxlist.split(',');
6082: if (allidxs.length > 1) {
6083: for (var i=0; i<allidxs.length; i++) {
6084: if (document.getElementById(param+'_'+allidxs[i])) {
6085: if (param == 'rpicknum') {
6086: if (document.getElementById('randompick_'+allidxs[i])) {
6087: if (document.getElementById('randompick_'+allidxs[i]).checked) {
6088: document.getElementById(param+'_'+allidxs[i]).value = rpick;
6089: if (rpick > 0) {
6090: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = ': <a href="javascript:updatePick(document.edit_randompick_'+allidxs[i]+',\\''+allidxs[i]+'\\',\\'link\\')">'+rpick+'</a>';
6091: } else {
6092: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
6093: }
6094: }
6095: }
6096: } else {
1.537 raeburn 6097: if (setcheck == 1) {
6098: document.getElementById(param+'_'+allidxs[i]).checked = true;
6099: } else {
6100: document.getElementById(param+'_'+allidxs[i]).checked = false;
1.538 raeburn 6101: if (param == 'randompick') {
6102: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
6103: }
1.537 raeburn 6104: }
6105: }
6106: }
6107: }
1.538 raeburn 6108: if (setcheck == 1) {
6109: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
6110: var actions = new Array('copy','cut','remove');
6111: for (var i=0; i<actions.length; i++) {
6112: var otheractions;
6113: var otheridxs;
6114: if (actions[i] === param) {
6115: continue;
6116: } else {
6117: if (document.getElementById('all'+actions[i]+'idx')) {
6118: otheractions = document.getElementById('all'+actions[i]+'idx').value;
6119: otheridxs = otheractions.split(',');
6120: if (otheridxs.length > 1) {
6121: for (var j=0; j<otheridxs.length; j++) {
6122: if (document.getElementById(actions[i]+'_'+otheridxs[j])) {
6123: document.getElementById(actions[i]+'_'+otheridxs[j]).checked = false;
6124: }
1.537 raeburn 6125: }
6126: }
6127: }
1.538 raeburn 6128: }
6129: }
6130: }
6131: }
6132: }
6133: }
6134: }
6135: return;
6136: }
6137:
6138: function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder) {
1.539 raeburn 6139: var dosettings;
6140: var doaction;
1.538 raeburn 6141: var control = document.togglemultsettings;
6142: if (context == 'actions') {
6143: control = document.togglemultactions;
1.539 raeburn 6144: doaction = 1;
6145: } else {
6146: dosettings = 1;
1.538 raeburn 6147: }
1.539 raeburn 6148: if (control) {
6149: if (control.showmultpick.length) {
6150: for (var i=0; i<control.showmultpick.length; i++) {
6151: if (control.showmultpick[i].checked) {
6152: if (control.showmultpick[i].value == 1) {
6153: if (context == 'settings') {
6154: dosettings = 0;
6155: } else {
6156: doaction = 0;
1.538 raeburn 6157: }
6158: }
6159: }
1.537 raeburn 6160: }
6161: }
1.539 raeburn 6162: }
6163: if (context == 'settings') {
6164: if (dosettings == 1) {
1.538 raeburn 6165: targetform.changeparms.value=param;
6166: targetform.submit();
6167: }
1.537 raeburn 6168: }
1.539 raeburn 6169: if (context == 'actions') {
6170: if (doaction == 1) {
6171: targetform.cmd.value=param+'_'+index;
6172: targetform.folderpath.value=folderpath;
6173: targetform.markcopy.value=idx+':'+param;
6174: targetform.copyfolder.value=folder+'.'+container;
6175: if (param == 'remove') {
6176: if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) {
6177: targetform.markcopy.value='';
6178: targetform.copyfolder.value='';
6179: targetform.submit();
6180: }
6181: }
6182: if (param == 'cut') {
6183: if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) {
6184: targetform.submit();
6185: return;
6186: }
6187: }
6188: if (param == 'copy') {
6189: targetform.submit();
6190: return;
6191: }
6192: targetform.markcopy.value='';
6193: targetform.copyfolder.value='';
6194: targetform.cmd.value='';
6195: targetform.folderpath.value='';
6196: return;
6197: } else {
6198: if (document.getElementById(param+'_'+idx)) {
6199: item = document.getElementById(param+'_'+idx);
6200: if (item.type == 'checkbox') {
6201: if (item.checked) {
6202: item.checked = false;
6203: } else {
6204: item.checked = true;
6205: singleCheck(item,idx,param);
6206: }
6207: }
6208: }
6209: }
6210: }
1.537 raeburn 6211: return;
6212: }
6213:
1.538 raeburn 6214: function singleCheck(caller,idx,action) {
6215: actions = new Array('cut','copy','remove');
6216: if (caller.checked) {
6217: for (var i=0; i<actions.length; i++) {
6218: if (actions[i] != action) {
6219: if (document.getElementById(actions[i]+'_'+idx)) {
6220: if (document.getElementById(actions[i]+'_'+idx).checked) {
6221: document.getElementById(actions[i]+'_'+idx).checked = false;
6222: }
1.537 raeburn 6223: }
6224: }
6225: }
1.478 raeburn 6226: }
1.537 raeburn 6227: return;
1.478 raeburn 6228: }
6229:
1.334 muellerd 6230: function unselectInactive(nav) {
1.335 ehlerst 6231: currentNav = document.getElementById(nav);
6232: currentLis = currentNav.getElementsByTagName('LI');
6233: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 6234: if (currentLis[i].className == 'goback') {
6235: currentLis[i].className = 'goback';
6236: } else {
6237: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 6238: currentLis[i].className = 'right';
1.472 raeburn 6239: } else {
1.374 tempelho 6240: currentLis[i].className = 'i';
1.472 raeburn 6241: }
6242: }
1.335 ehlerst 6243: }
1.332 tempelho 6244: }
6245:
1.334 muellerd 6246: function hideAll(current, nav, data) {
1.335 ehlerst 6247: unselectInactive(nav);
1.570 raeburn 6248: if (current) {
6249: if (current.className == 'right'){
6250: current.className = 'right active'
6251: } else {
6252: current.className = 'active';
6253: }
1.374 tempelho 6254: }
1.335 ehlerst 6255: currentData = document.getElementById(data);
6256: currentDivs = currentData.getElementsByTagName('DIV');
6257: for (i = 0; i < currentDivs.length; i++) {
6258: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 6259: currentDivs[i].style.display = 'none';
1.330 tempelho 6260: }
6261: }
1.335 ehlerst 6262: }
1.330 tempelho 6263:
1.374 tempelho 6264: function openTabs(pageId) {
6265: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 6266: if(tabnav.length > 2 ){
1.389 tempelho 6267: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 6268: currentLis = currentNav.getElementsByTagName('LI');
6269: for(i = 0; i< currentLis.length; i++){
6270: if(currentLis[i].className == 'active') {
1.375 tempelho 6271: funcString = currentLis[i].onclick.toString();
6272: tab = funcString.split('"');
1.420 onken 6273: if(tab.length < 2) {
6274: tab = funcString.split("'");
6275: }
1.375 tempelho 6276: currentData = document.getElementById(tab[1]);
6277: currentData.style.display = 'block';
1.374 tempelho 6278: }
6279: }
6280: }
6281: }
6282:
1.334 muellerd 6283: function showPage(current, pageId, nav, data) {
1.570 raeburn 6284: currstate = current.className;
1.334 muellerd 6285: hideAll(current, nav, data);
1.375 tempelho 6286: openTabs(pageId);
1.334 muellerd 6287: unselectInactive(nav);
1.570 raeburn 6288: if ((currstate == 'active') || (currstate == 'right active')) {
6289: if (currstate == 'active') {
6290: current.className = '';
6291: } else {
6292: current.className = 'right';
6293: }
6294: activeTab = '';
6295: toggleUpload();
6296: toggleMap();
6297: resize_scrollbox('contentscroll','1','0');
6298: return;
6299: } else {
6300: current.className = 'active';
6301: }
1.330 tempelho 6302: currentData = document.getElementById(pageId);
6303: currentData.style.display = 'block';
1.458 raeburn 6304: activeTab = pageId;
1.501 raeburn 6305: toggleUpload();
1.503 raeburn 6306: toggleMap();
1.433 raeburn 6307: if (nav == 'mainnav') {
6308: var storedpath = "$docs_folderpath";
1.434 raeburn 6309: var storedpage = "$main_container_page";
1.433 raeburn 6310: var reg = new RegExp("^supplemental");
6311: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 6312: if (storedpage == 1) {
6313: document.simpleedit.folderpath.value = '';
6314: document.uploaddocument.folderpath.value = '';
6315: } else {
6316: if (reg.test(storedpath)) {
6317: document.simpleedit.folderpath.value = '$toplevelmain';
6318: document.uploaddocument.folderpath.value = '$toplevelmain';
6319: document.newext.folderpath.value = '$toplevelmain';
6320: } else {
6321: document.simpleedit.folderpath.value = storedpath;
6322: document.uploaddocument.folderpath.value = storedpath;
6323: document.newext.folderpath.value = storedpath;
6324: }
1.433 raeburn 6325: }
6326: } else {
1.434 raeburn 6327: if (reg.test(storedpath)) {
6328: document.simpleedit.folderpath.value = storedpath;
6329: document.supuploaddocument.folderpath.value = storedpath;
6330: document.supnewext.folderpath.value = storedpath;
6331: } else {
1.433 raeburn 6332: document.simpleedit.folderpath.value = '$toplevelsupp';
6333: document.supuploaddocument.folderpath.value = '$toplevelsupp';
6334: document.supnewext.folderpath.value = '$toplevelsupp';
6335: }
6336: }
6337: }
1.485 raeburn 6338: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 6339: return false;
6340: }
1.329 droeschl 6341:
1.472 raeburn 6342: function toContents(jumpto) {
6343: var newurl = '$backtourl';
1.525 raeburn 6344: if ((newurl == '/adm/navmaps') && (jumpto != '')) {
1.472 raeburn 6345: newurl = newurl+'?postdata='+jumpto;
6346: }
6347: location.href=newurl;
6348: }
6349:
1.538 raeburn 6350: function togglePick(caller,value) {
6351: var disp = 'none';
6352: if (document.getElementById('multi'+caller)) {
6353: var curr = document.getElementById('multi'+caller).style.display;
6354: if (value == 1) {
6355: disp='block';
6356: }
6357: if (curr == disp) {
6358: return;
6359: }
6360: document.getElementById('multi'+caller).style.display=disp;
6361: if (value == 1) {
6362: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$lt{'more'}</a>';
6363: } else {
6364: document.getElementById('more'+caller).innerHTML = '';
6365: }
6366: if (caller == 'actions') {
6367: setClass(value);
6368: setBoxes(value);
6369: }
6370: }
6371: var showButton = multiSettings();
6372: if (showButton != 1) {
6373: showButton = multiActions();
6374: }
6375: if (document.getElementById('multisave')) {
6376: if (showButton == 1) {
6377: document.getElementById('multisave').style.display='block';
6378: } else {
6379: document.getElementById('multisave').style.display='none';
6380: }
6381: }
6382: resize_scrollbox('contentscroll','1','1');
6383: return;
6384: }
6385:
6386: function toggleCheckUncheck(caller,more) {
6387: if (more == 1) {
6388: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',0);" style="text-decoration:none;">$lt{'less'}</a>';
6389: document.getElementById('allfields'+caller).style.display='block';
6390: } else {
6391: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$lt{'more'}</a>';
6392: document.getElementById('allfields'+caller).style.display='none';
6393: }
6394: resize_scrollbox('contentscroll','1','1');
6395: }
6396:
6397: function multiSettings() {
6398: var inuse = 0;
6399: var settingsform = document.togglemultsettings;
6400: if (settingsform.showmultpick.length > 1) {
6401: for (var i=0; i<settingsform.showmultpick.length; i++) {
6402: if (settingsform.showmultpick[i].checked) {
6403: if (settingsform.showmultpick[i].value == 1) {
6404: inuse = 1;
6405: }
6406: }
6407: }
6408: }
6409: return inuse;
6410: }
6411:
6412: function multiActions() {
6413: var inuse = 0;
6414: var actionsform = document.togglemultactions;
6415: if (actionsform.showmultpick.length > 1) {
6416: for (var i=0; i<actionsform.showmultpick.length; i++) {
6417: if (actionsform.showmultpick[i].checked) {
6418: if (actionsform.showmultpick[i].value == 1) {
6419: inuse = 1;
6420: }
6421: }
6422: }
6423: }
6424: return inuse;
6425: }
6426:
6427: function checkSubmits() {
6428: var numchanges = 0;
6429: var form = document.saveactions;
6430: var doactions = multiActions();
1.542 raeburn 6431: var cutwarnings = 0;
6432: var remwarnings = 0;
1.538 raeburn 6433: if (doactions == 1) {
6434: var remidxlist = document.cumulativeactions.allremoveidx.value;
6435: if ((remidxlist != '') && (remidxlist != null)) {
6436: var remidxs = remidxlist.split(',');
6437: for (var i=0; i<remidxs.length; i++) {
6438: if (document.getElementById('remove_'+remidxs[i])) {
6439: if (document.getElementById('remove_'+remidxs[i]).checked) {
6440: form.multiremove.value += remidxs[i]+',';
6441: numchanges ++;
1.542 raeburn 6442: if (document.getElementById('skip_remove_'+remidxs[i])) {
6443: if (document.getElementById('skip_remove_'+remidxs[i]).value == 0) {
6444: remwarnings ++;
6445: }
6446: }
1.537 raeburn 6447: }
6448: }
1.538 raeburn 6449: }
6450: }
6451: var cutidxlist = document.cumulativeactions.allcutidx.value;
6452: if ((cutidxlist != '') && (cutidxlist != null)) {
6453: var cutidxs = cutidxlist.split(',');
6454: for (var i=0; i<cutidxs.length; i++) {
6455: if (document.getElementById('cut_'+cutidxs[i])) {
6456: if (document.getElementById('cut_'+cutidxs[i]).checked == true) {
6457: form.multicut.value += cutidxs[i]+',';
6458: numchanges ++;
1.542 raeburn 6459: if (document.getElementById('skip_cut_'+cutidxs[i])) {
6460: if (document.getElementById('skip_cut_'+cutidxs[i]).value == 0) {
6461: cutwarnings ++;
6462: }
6463: }
1.537 raeburn 6464: }
6465: }
6466: }
6467: }
1.538 raeburn 6468: var copyidxlist = document.cumulativeactions.allcopyidx.value;
6469: if ((copyidxlist != '') && (copyidxlist != null)) {
6470: var copyidxs = copyidxlist.split(',');
6471: for (var i=0; i<copyidxs.length; i++) {
6472: if (document.getElementById('copy_'+copyidxs[i])) {
6473: if (document.getElementById('copy_'+copyidxs[i]).checked) {
6474: form.multicopy.value += copyidxs[i]+',';
6475: numchanges ++;
6476: }
6477: }
6478: }
6479: }
6480: if (numchanges > 0) {
6481: form.multichange.value = numchanges;
6482: }
1.537 raeburn 6483: }
1.538 raeburn 6484: var dosettings = multiSettings();
1.543 raeburn 6485: var haschanges = 0;
1.538 raeburn 6486: if (dosettings == 1) {
6487: form.allencrypturl.value = '';
6488: form.allhiddenresource.value = '';
1.543 raeburn 6489: form.changeparms.value = 'all';
6490: var patt=new RegExp(",\$");
1.538 raeburn 6491: var allidxlist = document.cumulativesettings.allidx.value;
6492: if ((allidxlist != '') && (allidxlist != null)) {
6493: var allidxs = allidxlist.split(',');
6494: if (allidxs.length > 1) {
6495: for (var i=0; i<allidxs.length; i++) {
6496: if (document.getElementById('hiddenresource_'+allidxs[i])) {
6497: if (document.getElementById('hiddenresource_'+allidxs[i]).checked) {
6498: form.allhiddenresource.value += allidxs[i]+',';
6499: }
6500: }
6501: if (document.getElementById('encrypturl_'+allidxs[i])) {
6502: if (document.getElementById('encrypturl_'+allidxs[i]).checked) {
6503: form.allencrypturl.value += allidxs[i]+',';
6504: }
6505: }
6506: }
1.543 raeburn 6507: form.allhiddenresource.value = form.allhiddenresource.value.replace(patt,"");
6508: form.allencrypturl.value = form.allencrypturl.value.replace(patt,"");
1.537 raeburn 6509: }
1.538 raeburn 6510: }
6511: form.allrandompick.value = '';
6512: form.allrandomorder.value = '';
6513: var allmapidxlist = document.cumulativesettings.allmapidx.value;
6514: if ((allmapidxlist != '') && (allmapidxlist != null)) {
6515: var allmapidxs = allmapidxlist.split(',');
6516: for (var i=0; i<allmapidxs.length; i++) {
6517: var randompick = document.getElementById('randompick_'+allmapidxs[i]);
6518: var rpicknum = document.getElementById('rpicknum_'+allmapidxs[i]);
6519: var randorder = document.getElementById('randomorder_'+allmapidxs[i]);
6520: if ((randompick.checked) && (rpicknum.value != '')) {
6521: form.allrandompick.value += allmapidxs[i]+':'+rpicknum.value+',';
6522: }
6523: if (randorder.checked) {
6524: form.allrandomorder.value += allmapidxs[i]+',';
6525: }
1.537 raeburn 6526: }
1.543 raeburn 6527: form.allrandompick.value = form.allrandompick.value.replace(patt,"");
6528: form.allrandomorder.value = form.allrandomorder.value.replace(patt,"");
6529: }
6530: if (document.cumulativesettings.currhiddenresource.value != form.allhiddenresource.value) {
6531: haschanges = 1;
6532: }
6533: if (document.cumulativesettings.currencrypturl.value != form.allencrypturl.value) {
6534: haschanges = 1;
6535: }
6536: if (document.cumulativesettings.currrandomorder.value != form.allrandomorder.value) {
6537: haschanges = 1;
6538: }
6539: if (document.cumulativesettings.currrandompick.value != form.allrandompick.value) {
6540: haschanges = 1;
1.537 raeburn 6541: }
6542: }
1.543 raeburn 6543: if (doactions == 1) {
1.542 raeburn 6544: if (numchanges > 0) {
6545: if ((cutwarnings > 0) || (remwarnings > 0)) {
6546: if (remwarnings > 0) {
6547: if (!confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr3a"} '+remwarnings+' $lt{"p_rmr3b"}')) {
6548: return false;
6549: }
6550: }
6551: if (cutwarnings > 0) {
6552: if (!confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr3a"} '+cutwarnings+' $lt{"p_ctr3b"}')) {
6553: return false;
6554: }
6555: }
6556: }
6557: form.submit();
6558: return true;
1.543 raeburn 6559: }
6560: }
6561: if (dosettings == 1) {
6562: if (haschanges == 1) {
1.542 raeburn 6563: form.submit();
6564: return true;
6565: }
1.543 raeburn 6566: }
6567: if ((dosettings == 1) && (doactions == 1)) {
6568: alert("$lt{'noor'}");
6569: } else {
6570: if (dosettings == 1) {
6571: alert("$lt{'noch'}");
6572: } else {
6573: alert("$lt{'noac'}");
6574: }
6575: }
1.538 raeburn 6576: return false;
6577: }
6578:
6579: function setClass(value) {
6580: var cutclass = 'LC_docs_cut';
6581: var copyclass = 'LC_docs_copy';
6582: var removeclass = 'LC_docs_remove';
6583: var cutreg = new RegExp("\\\\b"+cutclass+"\\\\b");
6584: var copyreg = new RegExp("\\\\b"+copyclass+"\\\\b");
6585: var removereg = new RegExp("\\\\"+removeclass+"\\\\b");
6586: var links = document.getElementsByTagName('a');
6587: for (var i=0; i<links.length; i++) {
6588: var classes = links[i].className;
6589: if (cutreg.test(classes)) {
6590: links[i].className = cutclass;
6591: if (value == 1) {
6592: links[i].className += " LC_menubuttons_link";
6593: }
6594: } else {
6595: if (copyreg.test(classes)) {
6596: links[i].className = copyclass;
6597: if (value == 1) {
6598: links[i].className += " LC_menubuttons_link";
6599: }
6600: } else {
6601: if (removereg.test(classes)) {
6602: links[i].className = removeclass;
6603: if (value == 1) {
6604: links[i].className += " LC_menubuttons_link";
6605: }
6606: }
6607: }
6608: }
6609: }
6610: return;
1.537 raeburn 6611: }
6612:
1.538 raeburn 6613: function setBoxes(value) {
6614: var remidxlist = document.cumulativeactions.allremoveidx.value;
6615: if ((remidxlist != '') && (remidxlist != null)) {
6616: var remidxs = remidxlist.split(',');
6617: for (var i=0; i<remidxs.length; i++) {
6618: if (document.getElementById('remove_'+remidxs[i])) {
6619: var item = document.getElementById('remove_'+remidxs[i]);
6620: if (value == 1) {
6621: item.className = 'LC_docs_remove';
6622: } else {
6623: item.className = 'LC_hidden';
6624: }
6625: }
6626: }
6627: }
6628: var cutidxlist = document.cumulativeactions.allcutidx.value;
6629: if ((cutidxlist != '') && (cutidxlist != null)) {
6630: var cutidxs = cutidxlist.split(',');
6631: for (var i=0; i<cutidxs.length; i++) {
6632: if (document.getElementById('cut_'+cutidxs[i])) {
6633: var item = document.getElementById('cut_'+cutidxs[i]);
6634: if (value == 1) {
6635: item.className = 'LC_docs_cut';
6636: } else {
6637: item.className = 'LC_hidden';
6638: }
6639: }
1.537 raeburn 6640: }
6641: }
1.538 raeburn 6642: var copyidxlist = document.cumulativeactions.allcopyidx.value;
6643: if ((copyidxlist != '') && (copyidxlist != null)) {
6644: var copyidxs = copyidxlist.split(',');
6645: for (var i=0; i<copyidxs.length; i++) {
6646: if (document.getElementById('copy_'+copyidxs[i])) {
6647: var item = document.getElementById('copy_'+copyidxs[i]);
6648: if (value == 1) {
6649: item.className = 'LC_docs_copy';
6650: } else {
6651: item.className = 'LC_hidden';
6652: }
6653: }
1.537 raeburn 6654: }
6655: }
6656: return;
6657: }
6658:
1.329 droeschl 6659: ENDNEWSCRIPT
6660: }
1.457 raeburn 6661:
1.483 raeburn 6662: sub history_tab_js {
6663: return <<"ENDHIST";
6664: function toggleHistoryDisp(choice) {
6665: document.docslogform.docslog.value = choice;
6666: document.docslogform.submit();
6667: return;
6668: }
6669:
6670: ENDHIST
6671: }
6672:
1.484 raeburn 6673: sub inject_data_js {
6674: return <<ENDINJECT;
6675:
6676: function injectData(current, hiddenField, name, value) {
6677: currentElement = document.getElementById(hiddenField);
6678: currentElement.name = name;
6679: currentElement.value = value;
6680: current.submit();
6681: }
6682:
6683: ENDINJECT
6684: }
6685:
6686: sub dump_switchserver_js {
6687: my @hosts = @_;
6688: my %lt = &Apache::lonlocal::texthash(
1.574 raeburn 6689: dump => 'Copying content to Authoring Space requires switching server.',
1.484 raeburn 6690: swit => 'Switch server?',
1.568 raeburn 6691: duco => 'Copying Content to Authoring Space',
1.484 raeburn 6692: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
6693: chos => 'Choose server',
6694: );
6695: my $role = $env{'request.role'};
6696: my $js = <<"ENDSWJS";
6697: <script type="text/javascript">
6698: function write_switchserver() {
6699: var server;
6700: if (document.setserver.posshosts.length > 0) {
6701: for (var i=0; i<document.setserver.posshosts.length; i++) {
6702: if (document.setserver.posshosts[i].checked) {
6703: server = document.setserver.posshosts[i].value;
6704: }
6705: }
6706: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
6707: }
6708: window.close();
6709: }
6710: </script>
6711:
6712: ENDSWJS
6713:
6714: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
6715: {'only_body' => 1,
6716: 'js_ready' => 1,});
6717: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
6718:
6719: my $hostpicker;
6720: my $count = 0;
6721: foreach my $host (sort(@hosts)) {
6722: my $checked;
6723: if ($count == 0) {
6724: $checked = ' checked="checked"';
6725: }
6726: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
6727: $host.'"'.$checked.' />'.$host.'</label> ';
6728: $count++;
6729: }
6730:
6731: return <<"ENDSWITCHJS";
6732:
6733: function dump_needs_switchserver(url) {
6734: if (url!='' && url!= null) {
6735: if (confirm("$lt{'dump'}\\n$lt{'swit'}")) {
6736: go(url);
6737: }
6738: }
6739: return;
6740: }
6741:
6742: function choose_switchserver_window() {
6743: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
6744: newWindow.document.open();
6745: newWindow.document.writeln('$startpage');
6746: newWindow.document.write('<h3>$lt{'duco'}<\\/h3>\\n'+
6747: '<p>$lt{'yone'}<\\/p>\\n'+
6748: '<div class="LC_left_float"><fieldset><legend>$lt{'chos'}<\\/legend>\\n'+
6749: '<form name="setserver" method="post" action="" \\/>\\n'+
6750: '$hostpicker\\n'+
6751: '<br \\/><br \\/>\\n'+
6752: '<input type="button" name="makeswitch" value="$lt{'swit'}" '+
6753: 'onclick="write_switchserver();" \\/>\\n'+
6754: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
6755: newWindow.document.writeln('$endpage');
6756: newWindow.document.close();
6757: newWindow.focus();
6758: }
6759:
6760: ENDSWITCHJS
6761: }
6762:
6763: sub makedocslogform {
6764: my ($formelems,$docslog) = @_;
6765: return <<"LOGSFORM";
6766: <form action="/adm/coursedocs" method="post" name="docslogform">
6767: <input type="hidden" name="docslog" value="$docslog" />
6768: $formelems
6769: </form>
6770: LOGSFORM
6771: }
6772:
6773: sub makesimpleeditform {
6774: my ($formelems) = @_;
6775: return <<"SIMPFORM";
6776: <form name="simpleedit" method="post" action="/adm/coursedocs">
6777: <input type="hidden" name="importdetail" value="" />
6778: $formelems
6779: </form>
6780: SIMPFORM
6781: }
6782:
1.329 droeschl 6783: 1;
6784: __END__
6785:
6786:
6787: =head1 NAME
6788:
6789: Apache::londocs.pm
6790:
6791: =head1 SYNOPSIS
6792:
6793: This is part of the LearningOnline Network with CAPA project
6794: described at http://www.lon-capa.org.
6795:
6796: =head1 SUBROUTINES
6797:
6798: =over
6799:
6800: =item %help=()
6801:
6802: Available help topics
6803:
6804: =item mapread()
6805:
1.344 bisitz 6806: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 6807: @order and @resources, determines status
6808: sets @order - pointer to resources in right order
6809: sets @resources - array with the resources with correct idx
6810:
6811: =item authorhosts()
6812:
6813: Return hash with valid author names
6814:
6815: =item clean()
6816:
6817: =item dumpcourse()
6818:
6819: Actually dump course
6820:
6821: =item group_import()
6822:
6823: Imports the given (name, url) resources into the course
6824: coursenum, coursedom, and folder must precede the list
6825:
6826: =item breadcrumbs()
6827:
6828: =item log_docs()
6829:
6830: =item docs_change_log()
6831:
6832: =item update_paste_buffer()
6833:
6834: =item print_paste_buffer()
6835:
6836: =item do_paste_from_buffer()
6837:
1.538 raeburn 6838: =item do_buffer_empty()
6839:
6840: =item clear_from_buffer()
6841:
1.492 raeburn 6842: =item get_newmap_url()
6843:
6844: =item dbcopy()
6845:
6846: =item uniqueness_check()
6847:
6848: =item contained_map_check()
6849:
6850: =item url_paste_fixups()
6851:
6852: =item apply_fixups()
6853:
6854: =item copy_dependencies()
6855:
1.329 droeschl 6856: =item update_parameter()
6857:
6858: =item handle_edit_cmd()
6859:
6860: =item editor()
6861:
6862: =item process_file_upload()
6863:
6864: =item process_secondary_uploads()
6865:
6866: =item is_supplemental_title()
6867:
6868: =item entryline()
6869:
6870: =item tiehash()
6871:
6872: =item untiehash()
6873:
6874: =item checkonthis()
6875:
6876: check on this
6877:
6878: =item verifycontent()
6879:
6880: Verify Content
6881:
6882: =item devalidateversioncache() & checkversions()
6883:
6884: Check Versions
6885:
6886: =item mark_hash_old()
6887:
6888: =item is_hash_old()
6889:
6890: =item changewarning()
6891:
6892: =item init_breadcrumbs()
6893:
6894: Breadcrumbs for special functions
6895:
1.484 raeburn 6896: =item create_list_elements()
6897:
6898: =item create_form_ul()
6899:
6900: =item startContentScreen()
6901:
6902: =item endContentScreen()
6903:
6904: =item supplemental_base()
6905:
6906: =item embedded_form_elems()
6907:
6908: =item embedded_destination()
6909:
6910: =item return_to_editor()
6911:
6912: =item decompression_info()
6913:
6914: =item decompression_phase_one()
6915:
6916: =item decompression_phase_two()
6917:
6918: =item remove_archive()
6919:
6920: =item generate_admin_menu()
6921:
6922: =item generate_edit_table()
6923:
6924: =item editing_js()
6925:
6926: =item history_tab_js()
6927:
6928: =item inject_data_js()
6929:
6930: =item dump_switchserver_js()
6931:
1.485 raeburn 6932: =item resize_scrollbox_js()
1.484 raeburn 6933:
6934: =item makedocslogform()
6935:
1.485 raeburn 6936: =item makesimpleeditform()
6937:
1.329 droeschl 6938: =back
6939:
6940: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>