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