Annotation of loncom/interface/londocs.pm, revision 1.602
1.329 droeschl 1: # The LearningOnline Network
2: # Documents
3: #
1.602 ! raeburn 4: # $Id: londocs.pm,v 1.601 2016/04/02 04:30:20 raeburn Exp $
1.329 droeschl 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29: package Apache::londocs;
30:
31: use strict;
32: use Apache::Constants qw(:common :http);
33: use Apache::imsexport;
34: use Apache::lonnet;
35: use Apache::loncommon;
1.383 tempelho 36: use Apache::lonhtmlcommon;
1.329 droeschl 37: use LONCAPA::map();
38: use Apache::lonratedt();
39: use Apache::lonxml;
40: use Apache::lonclonecourse;
41: use Apache::lonnavmaps;
1.472 raeburn 42: use Apache::lonnavdisplay();
1.510 raeburn 43: use Apache::lonextresedit();
1.567 raeburn 44: use Apache::lontemplate();
45: use Apache::lonsimplepage();
1.329 droeschl 46: use HTML::Entities;
1.488 raeburn 47: use HTML::TokeParser;
1.329 droeschl 48: use GDBM_File;
1.578 raeburn 49: use File::MMagic;
1.329 droeschl 50: use Apache::lonlocal;
51: use Cwd;
52: use LONCAPA qw(:DEFAULT :match);
53:
54: my $iconpath;
55:
56: my %hash;
57:
58: my $hashtied;
59: my %alreadyseen=();
60:
61: my $hadchanges;
1.557 raeburn 62: my $suppchanges;
1.329 droeschl 63:
64:
65: my %help=();
66:
67:
68: sub mapread {
69: my ($coursenum,$coursedom,$map)=@_;
70: return
71: &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
72: $map);
73: }
74:
75: sub storemap {
1.492 raeburn 76: my ($coursenum,$coursedom,$map,$contentchg)=@_;
77: my $report;
78: if (($contentchg) && ($map =~ /^default/)) {
79: $report = 1;
80: }
1.329 droeschl 81: my ($outtext,$errtext)=
82: &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.492 raeburn 83: $map,1,$report);
1.329 droeschl 84: if ($errtext) { return ($errtext,2); }
1.364 bisitz 85:
1.557 raeburn 86: if ($map =~ /^default/) {
87: $hadchanges=1;
88: } else {
89: $suppchanges=1;
90: }
1.329 droeschl 91: return ($errtext,0);
92: }
93:
94:
95:
96: sub authorhosts {
97: my %outhash=();
98: my $home=0;
99: my $other=0;
100: foreach my $key (keys(%env)) {
101: if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
102: my $role=$1;
103: my $realm=$2;
104: my ($start,$end)=split(/\./,$env{$key});
105: if (($start) && ($start>time)) { next; }
106: if (($end) && (time>$end)) { next; }
107: my ($ca,$cd);
108: if ($1 eq 'au') {
109: $ca=$env{'user.name'};
110: $cd=$env{'user.domain'};
111: } else {
112: ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
113: }
114: my $allowed=0;
115: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
116: my @ids=&Apache::lonnet::current_machine_ids();
1.484 raeburn 117: foreach my $id (@ids) {
118: if ($id eq $myhome) {
119: $allowed=1;
120: last;
121: }
122: }
1.329 droeschl 123: if ($allowed) {
124: $home++;
1.484 raeburn 125: $outhash{'home_'.$ca.':'.$cd}=1;
1.329 droeschl 126: } else {
1.484 raeburn 127: $outhash{'otherhome_'.$ca.':'.$cd}=$myhome;
1.329 droeschl 128: $other++;
129: }
130: }
131: }
132: return ($home,$other,%outhash);
133: }
134:
135:
136: sub clean {
137: my ($title)=@_;
138: $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
1.344 bisitz 139: return $title;
1.329 droeschl 140: }
141:
142:
143:
144: sub dumpcourse {
145: my ($r) = @_;
1.408 raeburn 146: my $crstype = &Apache::loncommon::course_type();
1.567 raeburn 147: my ($starthash,$js);
148: unless (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
149: $js = <<"ENDJS";
150: <script type="text/javascript">
151: // <![CDATA[
152:
153: function hide_searching() {
154: if (document.getElementById('searching')) {
155: document.getElementById('searching').style.display = 'none';
156: }
157: return;
158: }
159:
160: // ]]>
161: </script>
162: ENDJS
163: $starthash = {
164: add_entries => {'onload' => "hide_searching();"},
165: };
166: }
1.568 raeburn 167: $r->print(&Apache::loncommon::start_page('Copy '.$crstype.' Content to Authoring Space',$js,$starthash)."\n".
168: &Apache::lonhtmlcommon::breadcrumbs('Copy '.$crstype.' Content to Authoring Space')."\n");
1.484 raeburn 169: $r->print(&startContentScreen('tools'));
1.329 droeschl 170: my ($home,$other,%outhash)=&authorhosts();
1.484 raeburn 171: unless ($home) {
172: $r->print(&endContentScreen());
173: return '';
174: }
1.329 droeschl 175: my $origcrsid=$env{'request.course.id'};
176: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
177: if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
178: # Do the dumping
1.484 raeburn 179: unless ($outhash{'home_'.$env{'form.authorspace'}}) {
180: $r->print(&endContentScreen());
181: return '';
182: }
1.531 raeburn 183: my ($ca,$cd)=split(/\:/,$env{'form.authorspace'});
1.329 droeschl 184: $r->print('<h3>'.&mt('Copying Files').'</h3>');
185: my $title=$env{'form.authorfolder'};
186: $title=&clean($title);
1.567 raeburn 187: my ($navmap,$errormsg) =
188: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
189: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
190: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
191: my (%maps,%resources,%titles);
192: if (!ref($navmap)) {
193: $r->print($errormsg.
194: &endContentScreen());
195: return '';
196: } else {
197: &Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles,
198: 'dumpdocs',$cdom,$cnum);
1.329 droeschl 199: }
1.567 raeburn 200: my @todump = &Apache::loncommon::get_env_multiple('form.archive');
201: my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages,
202: %newcontent,%has_simpleprobs);
203: foreach my $item (sort {$a <=> $b} (@todump)) {
204: my $name = $env{'form.namefor_'.$item};
205: if ($resources{$item}) {
206: my ($map,$id,$res) = &Apache::lonnet::decode_symb($resources{$item});
207: if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) {
208: $tocopy{$1} = $name;
209: $display{$item} = $1;
210: $lookup{$1} = $item;
211: } elsif ($res eq 'lib/templates/simpleproblem.problem') {
212: $simpleproblems{$item} = {
213: symb => $resources{$item},
214: name => $name,
215: };
216: $display{$item} = 'simpleproblem_'.$name;
217: if ($map =~ m{^\Quploaded/$cdom/$cnum/\E(.+)$}) {
218: $has_simpleprobs{$1}{$id} = $item;
219: }
220: } elsif ($res =~ m{^adm/$match_domain/$match_username/(\d+)/smppg}) {
221: my $marker = $1;
222: my $db_name = &Apache::lonsimplepage::get_db_name($res,$marker,$cdom,$cnum);
223: $simplepages{$item} = {
224: res => $res,
225: title => $titles{$item},
226: db => $db_name,
227: marker => $marker,
228: symb => $resources{$item},
229: name => $name,
230: };
231: $display{$item} = '/'.$res;
232: }
233: } elsif ($maps{$item}) {
234: if ($maps{$item} =~ m{^\Quploaded/$cdom/$cnum/\E((?:default|supplemental)_\d+\.(?:sequence|page))$}) {
235: $tocopy{$1} = $name;
236: $display{$item} = $1;
237: $lookup{$1} = $item;
238: }
239: } else {
240: next;
241: }
242: }
1.329 droeschl 243: my $crs='/uploaded/'.$env{'request.course.id'}.'/';
244: $crs=~s/\_/\//g;
1.567 raeburn 245: my $mm = new File::MMagic;
246: my $prefix = "/uploaded/$cdom/$cnum/";
247: %replacehash = %tocopy;
248: foreach my $item (sort(keys(%simpleproblems))) {
249: my $content = &Apache::imsexport::simpleproblem($simpleproblems{$item}{'symb'});
250: $newcontent{$display{$item}} = $content;
251: }
252: my $gateway = Apache::lonhtmlgateway->new('web');
253: foreach my $item (sort(keys(%simplepages))) {
254: if (ref($simplepages{$item}) eq 'HASH') {
255: my $pagetitle = $simplepages{$item}{'title'};
256: my %fields = &Apache::lonnet::dump($simplepages{$item}{'db'},$cdom,$cnum);
257: my %contents;
258: foreach my $field (keys(%fields)) {
259: if ($field =~ /^(?:aaa|bbb|ccc)_(\w+)$/) {
260: my $name = $1;
261: my $msg = $fields{$field};
262: if ($name eq 'webreferences') {
263: if ($msg =~ m{^https?://}) {
264: $contents{$name} = '<a href="'.$msg.'"><tt>'.$msg.'</tt></a>';
265: }
266: } else {
267: $msg = &Encode::decode('utf8',$msg);
268: $msg = $gateway->process_outgoing_html($msg,1);
269: $contents{$name} = $msg;
270: }
271: } elsif ($field eq 'uploaded.photourl') {
272: my $marker = $simplepages{$item}{marker};
273: if ($fields{$field} =~ m{^\Q$prefix\E(simplepage/$marker/.+)$}) {
274: my $filepath = $1;
275: my ($relpath,$fname) = ($filepath =~ m{^(.+/)([^/]+)$});
276: if ($fname ne '') {
277: $fname=~s/\.(\w+)$//;
278: my $ext=$1;
279: $fname = &clean($fname);
280: $fname.='.'.$ext;
281: $contents{image} = '<img src="'.$relpath.$fname.'" alt="Image" />';
282: $replacehash{$filepath} = $relpath.$fname;
283: $deps{$item}{$filepath} = 1;
284: }
285: }
286: }
287: }
288: $replacehash{'/'.$simplepages{$item}{'res'}} = $simplepages{$item}{'name'};
289: $lookup{'/'.$simplepages{$item}{'res'}} = $item;
290: my $content = '
291: <html>
292: <head>
293: <title>'.$pagetitle.'</title>
294: </head>
295: <body bgcolor="#ffffff">';
296: if ($contents{title}) {
297: $content .= "\n".'<h2>'.$contents{title}.'</h2>';
298: }
299: if ($contents{image}) {
300: $content .= "\n".$contents{image};
301: }
302: if ($contents{content}) {
303: $content .= '
304: <div class="LC_Box">
1.577 bisitz 305: <h4 class="LC_hcell">'.&mt('Content').'</h4>'.
1.567 raeburn 306: $contents{content}.'
307: </div>';
308: }
309: if ($contents{webreferences}) {
310: $content .= '
311: <div class="LC_Box">
1.577 bisitz 312: <h4 class="LC_hcell">'.&mt('Web References').'</h4>'.
1.567 raeburn 313: $contents{webreferences}.'
314: </div>';
315: }
316: $content .= '
317: </body>
318: </html>
319: ';
320: $newcontent{'/'.$simplepages{$item}{res}} = $content;
321: }
322: }
323: foreach my $item (keys(%tocopy)) {
324: unless ($item=~/\.(sequence|page)$/) {
325: my $currurlpath = $prefix.$item;
326: my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath);
327: &recurse_html($mm,$prefix,$currdirpath,$currurlpath,$item,$lookup{$item},\%replacehash,\%deps);
328: }
329: }
330: foreach my $num (sort {$a <=> $b} (@todump)) {
331: my $src = $display{$num};
332: next if ($src eq '');
333: my @needcopy = ();
334: if ($replacehash{$src}) {
335: push(@needcopy,$src);
336: if (ref($deps{$num}) eq 'HASH') {
337: foreach my $dep (sort(keys(%{$deps{$num}}))) {
338: if ($replacehash{$dep}) {
339: push(@needcopy,$dep);
340: }
341: }
342: }
343: } elsif ($src =~ /^simpleproblem_/) {
344: push(@needcopy,$src);
345: }
346: next if (@needcopy == 0);
347: my ($result,$depresult);
348: for (my $i=0; $i<@needcopy; $i++) {
349: my $item = $needcopy[$i];
350: my $newfilename;
351: if ($simpleproblems{$num}) {
352: $newfilename=$title.'/'.$simpleproblems{$num}{'name'};
353: } else {
354: $newfilename=$title.'/'.$replacehash{$item};
355: }
356: $newfilename=~s/\.(\w+)$//;
357: my $ext=$1;
358: $newfilename=&clean($newfilename);
359: $newfilename.='.'.$ext;
360: my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$});
361: if ($newrelpath ne $replacehash{$item}) {
362: $replacehash{$item} = $newrelpath;
363: }
364: my @dirs=split(/\//,$newfilename);
365: my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
366: my $makepath=$path;
367: my $fail;
368: my $origin;
369: for (my $i=0;$i<$#dirs;$i++) {
370: $makepath.='/'.$dirs[$i];
371: unless (-e $makepath) {
372: unless(mkdir($makepath,0755)) {
373: $fail = &mt('Directory creation failed.');
374: }
375: }
376: }
377: if ($i == 0) {
378: $result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ';
379: } else {
380: $depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '.
381: '<span class="LC_fontsize_small" style="font-weight: bold;">'.
382: &mt('(dependency)').'</span>: ';
383: }
384: if (-e $path.'/'.$newfilename) {
385: $fail = &mt('Destination already exists -- not overwriting.');
386: } else {
387: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
388: if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) ||
389: ($item =~ /^simpleproblem_/)) {
390: print $fh $newcontent{$item};
391: } else {
392: my $fileloc = &Apache::lonnet::filelocation('',$prefix.$item);
393: if (-e $fileloc) {
394: if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
395: if ((($1 eq 'sequence') || ($1 eq 'page')) &&
396: (ref($has_simpleprobs{$item}) eq 'HASH')) {
397: my %changes = %{$has_simpleprobs{$item}};
398: my $content = &Apache::lonclonecourse::rewritefile(
399: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
400: (%replacehash,$crs => '')
401: );
402: my $updatedcontent = '';
403: my $parser = HTML::TokeParser->new(\$content);
404: $parser->attr_encoded(1);
405: while (my $token = $parser->get_token) {
406: if ($token->[0] eq 'S') {
407: if (($token->[1] eq 'resource') &&
408: ($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') &&
409: ($changes{$token->[2]->{'id'}})) {
410: my $id = $token->[2]->{'id'};
411: $updatedcontent .= '<'.$token->[1];
412: foreach my $attrib (@{$token->[3]}) {
413: next unless ($attrib =~ /^(src|type|title|id)$/);
414: if ($attrib eq 'src') {
415: my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/);
416: if ($file) {
417: $updatedcontent .= ' '.$attrib.'="'.$file.'"';
418: } else {
419: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
420: }
421: } else {
422: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
423: }
424: }
425: $updatedcontent .= ' />'."\n";
426: } else {
427: $updatedcontent .= $token->[4]."\n";
428: }
429: } else {
430: $updatedcontent .= $token->[2];
431: }
432: }
433: print $fh $updatedcontent;
434: } else {
435: print $fh &Apache::lonclonecourse::rewritefile(
436: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
437: (%replacehash,$crs => '')
438: );
439: }
440: } else {
441: print $fh
442: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
443: }
444: } else {
445: $fail = &mt('Source does not exist.');
446: }
447: }
448: $fh->close();
449: } else {
450: $fail = &mt('Could not write to destination.');
451: }
452: }
453: my $text;
454: if ($fail) {
455: $text = '<span class="LC_error">'.&mt('fail').(' 'x3).$fail.'</span>';
456: } else {
457: $text = '<span class="LC_success">'.&mt('ok').'</span>';
458: }
459: if ($i == 0) {
460: $result .= $text;
461: } else {
462: $depresult .= $text.'</li>';
463: }
464: }
465: $r->print($result);
466: if ($depresult) {
467: $r->print('<ul>'.$depresult.'</ul>');
468: }
469: }
470: } else {
471: my ($navmap,$errormsg) =
472: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
473: if (!ref($navmap)) {
474: $r->print($errormsg);
475: } else {
476: $r->print('<div id="searching">'.&mt('Searching ...').'</div>');
477: $r->rflush();
478: my ($preamble,$formname);
479: $formname = 'dumpdoc';
480: unless ($home==1) {
481: $preamble = '<div class="LC_left_float">'.
482: '<fieldset><legend>'.
483: &mt('Select the Authoring Space').
484: '</legend><select name="authorspace">';
1.329 droeschl 485: }
1.567 raeburn 486: my @orderspaces = ();
487: foreach my $key (sort(keys(%outhash))) {
488: if ($key=~/^home_(.+)$/) {
489: if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) {
490: unshift(@orderspaces,$1);
491: } else {
492: push(@orderspaces,$1);
493: }
494: }
495: }
1.569 raeburn 496: if ($home>1) {
497: $preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>';
498: }
1.567 raeburn 499: foreach my $user (@orderspaces) {
1.329 droeschl 500: if ($home==1) {
1.567 raeburn 501: $preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />';
1.329 droeschl 502: } else {
1.567 raeburn 503: $preamble .= '<option value="'.$user.'">'.$user.' - '.
504: &Apache::loncommon::plainname(split(/\:/,$user)).'</option>';
505: }
1.329 droeschl 506: }
1.567 raeburn 507: unless ($home==1) {
508: $preamble .= '</select></fieldset></div>'."\n";
1.329 droeschl 509: }
1.567 raeburn 510: my $title=$origcrsdata{'description'};
511: $title=~s/[\/\s]+/\_/gs;
1.329 droeschl 512: $title=&clean($title);
1.567 raeburn 513: $preamble .= '<div class="LC_left_float">'.
514: '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.
515: '<input type="text" size="50" name="authorfolder" value="'.
516: $title.'" />'.
517: '</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n";
518: my %uploadedfiles;
519: &tiehash();
520: foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
521: my ($ext)=($file=~/\.(\w+)$/);
522: # FIXME Check supplemental here
523: my $title=$hash{'title_'.$hash{
524: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
525: if (!$title) {
526: $title=$file;
527: } else {
528: $title=~s|/|_|g;
529: }
530: $title=~s/\.(\w+)$//;
531: $title=&clean($title);
532: $title.='.'.$ext;
533: # $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
534: $uploadedfiles{$file} = $title;
535: }
536: &untiehash();
537: $r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef,
538: undef,undef,$preamble,$home,\%uploadedfiles));
539: }
1.329 droeschl 540: }
1.484 raeburn 541: $r->print(&endContentScreen());
1.329 droeschl 542: }
543:
1.567 raeburn 544: sub recurse_html {
545: my ($mm,$prefix,$currdirpath,$currurlpath,$container,$item,$replacehash,$deps) = @_;
546: return unless ((ref($replacehash) eq 'HASH') && (ref($deps) eq 'HASH'));
547: my (%allfiles,%codebase);
548: if (&Apache::lonnet::extract_embedded_items($currdirpath,\%allfiles,\%codebase) eq 'ok') {
549: if (keys(%allfiles)) {
550: foreach my $dependency (keys(%allfiles)) {
551: next if (($dependency =~ m{^/(res|adm)/}) || ($dependency =~ m{^https?://}));
552: my ($depurl,$relfile,$newcontainer);
553: if ($dependency =~ m{^/}) {
554: if ($dependency =~ m{^\Q$currurlpath/\E(.+)$}) {
555: $relfile = $1;
556: if ($dependency =~ m{^\Q$prefix\E(.+)$}) {
557: $newcontainer = $1;
558: next if ($replacehash->{$newcontainer});
559: }
560: $depurl = $dependency;
561: } else {
562: next;
563: }
564: } else {
565: $relfile = $dependency;
566: $depurl = $currurlpath;
567: $depurl =~ s{[^/]+$}{};
568: $depurl .= $dependency;
569: ($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$});
570: }
571: next if ($relfile eq '');
572: my $newname = $replacehash->{$container};
573: $newname =~ s{[^/]+$}{};
574: $replacehash->{$newcontainer} = $newname.$relfile;
575: $deps->{$item}{$newcontainer} = 1;
576: my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$});
577: my $depfile = &Apache::lonnet::filelocation('',$depurl);
578: my $type = $mm->checktype_filename($depfile);
579: if ($type eq 'text/html') {
580: &recurse_html($mm,$prefix,$depfile,$newurlpath,$newcontainer,$item,$replacehash,$deps);
581: }
582: }
583: }
584: }
585: return;
586: }
587:
1.329 droeschl 588: sub group_import {
1.598 raeburn 589: my ($coursenum, $coursedom, $folder, $container, $caller, $ltitoolsref, @files) = @_;
1.529 raeburn 590: my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap,
591: %removeparam,$importuploaded,$fixuperrors);
592: $allmaps = {};
1.329 droeschl 593: while (@files) {
594: my ($name, $url, $residx) = @{ shift(@files) };
1.344 bisitz 595: if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
1.329 droeschl 596: && ($caller eq 'londocs')
597: && (!&Apache::lonnet::stat_file($url))) {
1.364 bisitz 598:
1.329 droeschl 599: my $errtext = '';
600: my $fatal = 0;
601: my $newmapstr = '<map>'."\n".
602: '<resource id="1" src="" type="start"></resource>'."\n".
603: '<link from="1" to="2" index="1"></link>'."\n".
604: '<resource id="2" src="" type="finish"></resource>'."\n".
605: '</map>';
606: $env{'form.output'}=$newmapstr;
607: my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
608: 'output',$1.$2);
1.534 raeburn 609: if ($result !~ m{^/uploaded/}) {
1.329 droeschl 610: $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
611: $fatal = 2;
612: }
613: if ($fatal) {
614: return ($errtext,$fatal);
615: }
616: }
617: if ($url) {
1.598 raeburn 618: if ($url =~ m{^(/adm/$coursedom/$coursenum/(\d+)/exttool)s?\:?(.*)$}) {
619: $url = $1;
620: my $marker = $2;
621: my $info = $3;
622: my ($toolid,%toolhash);
623: my @toolinfo = split(/:/,$info);
624: if ($residx) {
625: my %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
626: $toolid = $toolsettings{'id'};
627: } else {
628: $toolid = shift(@toolinfo);
629: }
630: $toolid =~ s/\D//g;
631: ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'}) = @toolinfo;
632: if (ref($ltitoolsref) eq 'HASH') {
633: if (ref($ltitoolsref->{$toolid}) eq 'HASH') {
634: if ($ltitoolsref->{$toolid}->{'url'} =~ m{^https://}) {
635: $url =~ s/exttool$/exttools/;
636: }
637: $toolhash{'id'} = $toolid;
638: if ($toolhash{'target'} eq 'iframe') {
639: delete($toolhash{'width'});
640: delete($toolhash{'height'});
641: } elsif ($toolhash{'target'} eq 'window') {
642: foreach my $item ('width','height') {
643: $toolhash{$item} =~ s/^\s+//;
644: $toolhash{$item} =~ s/\s+$//;
645: }
646: }
647: my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum);
648: }
649: }
650: }
1.529 raeburn 651: if (($caller eq 'londocs') &&
652: ($folder =~ /^default/)) {
1.534 raeburn 653: if (($url =~ /\.(page|sequence)$/) && (!$donechk)) {
1.529 raeburn 654: my $chome = &Apache::lonnet::homeserver($coursenum,$coursedom);
655: my $cid = $coursedom.'_'.$coursenum;
656: $allmaps =
657: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
658: $chome,$cid);
659: $donechk = 1;
660: }
661: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) {
662: &contained_map_check($url,$folder,\%removefrommap,\%removeparam,
663: \%addedmaps,\%hierarchy,\%titles,$allmaps);
664: $importuploaded = 1;
665: } elsif ($url =~ m{^/res/.+\.(page|sequence)$}) {
666: next if ($allmaps->{$url});
667: }
668: }
1.344 bisitz 669: if (!$residx
1.329 droeschl 670: || defined($LONCAPA::map::zombies[$residx])) {
671: $residx = &LONCAPA::map::getresidx($url,$residx);
672: push(@LONCAPA::map::order, $residx);
673: }
674: my $ext = 'false';
675: if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
676: $name = &LONCAPA::map::qtunescape($name);
1.534 raeburn 677: if ($name eq '') {
1.538 raeburn 678: $name = &LONCAPA::map::qtunescape(&mt('Web Page'));
1.534 raeburn 679: }
680: if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) {
681: my $filepath = $1;
682: my $fname = $name;
683: if ($fname =~ /^\W+$/) {
684: $fname = 'web';
685: } else {
686: $fname =~ s/\W/_/g;
687: }
1.599 damieng 688: if (length($fname) > 15) {
1.534 raeburn 689: $fname = substr($fname,0,14);
690: }
691: my $initialtext = &mt('Replace with your own content.');
692: my $newhtml = <<END;
1.545 raeburn 693: <html>
1.534 raeburn 694: <head>
695: <title>$name</title>
696: </head>
697: <body bgcolor="#ffffff">
698: $initialtext
699: </body>
700: </html>
701: END
702: $env{'form.output'}=$newhtml;
703: my $result =
704: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
705: 'output',
706: "$filepath/$residx/$fname.html");
707: if ($result =~ m{^/uploaded/}) {
708: $url = $result;
709: if ($filepath =~ /^supplemental/) {
710: $name = time.'___&&&___'.$env{'user.name'}.'___&&&___'.
711: $env{'user.domain'}.'___&&&___'.$name;
712: }
713: } else {
714: return (&mt('Failed to save new web page.'),1);
715: }
716: }
1.538 raeburn 717: $url = &LONCAPA::map::qtunescape($url);
1.344 bisitz 718: $LONCAPA::map::resources[$residx] =
1.329 droeschl 719: join(':', ($name, $url, $ext, 'normal', 'res'));
720: }
721: }
1.529 raeburn 722: if ($importuploaded) {
723: my %import_errors;
724: my %updated = (
725: removefrommap => \%removefrommap,
726: removeparam => \%removeparam,
727: );
1.533 raeburn 728: my ($result,$msgsarray,$lockerror) =
729: &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
1.529 raeburn 730: if (keys(%import_errors) > 0) {
1.530 raeburn 731: $fixuperrors =
1.529 raeburn 732: '<p span class="LC_warning">'."\n".
733: &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".
734: '<ul>'."\n";
735: foreach my $key (sort(keys(%import_errors))) {
736: $fixuperrors .= '<li>'.$key.'</li>'."\n";
737: }
738: $fixuperrors .= '</ul></p>'."\n";
739: }
1.533 raeburn 740: if (ref($msgsarray) eq 'ARRAY') {
741: if (@{$msgsarray} > 0) {
742: $fixuperrors .= '<p class="LC_info">'.
743: join('<br />',@{$msgsarray}).
744: '</p>';
745: }
746: }
747: if ($lockerror) {
748: $fixuperrors .= '<p class="LC_error">'.
749: $lockerror.
750: '</p>';
751: }
1.529 raeburn 752: }
753: my ($errtext,$fatal) =
754: &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
1.557 raeburn 755: unless ($fatal) {
756: if ($folder =~ /^supplemental/) {
757: &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
1.561 raeburn 758: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
759: $folder.'.'.$container);
1.557 raeburn 760: }
761: }
1.529 raeburn 762: return ($errtext,$fatal,$fixuperrors);
1.329 droeschl 763: }
764:
765: sub log_docs {
1.494 raeburn 766: return &Apache::lonnet::write_log('course','docslog',@_);
1.329 droeschl 767: }
768:
769: {
770: my @oldresources=();
771: my @oldorder=();
772: my $parmidx;
773: my %parmaction=();
774: my %parmvalue=();
775: my $changedflag;
776:
777: sub snapshotbefore {
778: @oldresources=@LONCAPA::map::resources;
779: @oldorder=@LONCAPA::map::order;
780: $parmidx=undef;
781: %parmaction=();
782: %parmvalue=();
783: $changedflag=0;
784: }
785:
786: sub remember_parms {
787: my ($idx,$parameter,$action,$value)=@_;
788: $parmidx=$idx;
789: $parmaction{$parameter}=$action;
790: $parmvalue{$parameter}=$value;
791: $changedflag=1;
792: }
793:
794: sub log_differences {
795: my ($plain)=@_;
796: my %storehash=('folder' => $plain,
797: 'currentfolder' => $env{'form.folder'});
798: if ($parmidx) {
799: $storehash{'parameter_res'}=$oldresources[$parmidx];
800: foreach my $parm (keys(%parmaction)) {
801: $storehash{'parameter_action_'.$parm}=$parmaction{$parm};
802: $storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
803: }
804: }
805: my $maxidx=$#oldresources;
806: if ($#LONCAPA::map::resources>$#oldresources) {
807: $maxidx=$#LONCAPA::map::resources;
808: }
809: for (my $idx=0; $idx<=$maxidx; $idx++) {
810: if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
811: $storehash{'before_resources_'.$idx}=$oldresources[$idx];
812: $storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
813: $changedflag=1;
814: }
815: if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
816: $storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
817: $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
818: $changedflag=1;
819: }
820: }
821: $storehash{'maxidx'}=$maxidx;
822: if ($changedflag) { &log_docs(\%storehash); }
823: }
824: }
825:
826: sub docs_change_log {
1.484 raeburn 827: my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath)=@_;
1.486 raeburn 828: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
1.483 raeburn 829: my $js = '<script type="text/javascript">'."\n".
830: '// <![CDATA['."\n".
831: &Apache::loncommon::display_filter_js('docslog')."\n".
1.486 raeburn 832: &editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag)."\n".
1.483 raeburn 833: &history_tab_js()."\n".
1.484 raeburn 834: &Apache::lonratedt::editscript('simple')."\n".
1.483 raeburn 835: '// ]]>'."\n".
836: '</script>'."\n";
1.484 raeburn 837: $r->print(&Apache::loncommon::start_page('Content Change Log',$js));
838: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Change Log'));
1.489 raeburn 839: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484 raeburn 840: my %orderhash;
841: my $container='sequence';
842: my $pathitem;
1.519 raeburn 843: if ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 844: $container='page';
845: }
1.519 raeburn 846: my $folderpath=$env{'form.folderpath'};
847: if ($folderpath eq '') {
1.548 raeburn 848: $folderpath = 'default&'.&escape(&mt('Main Content').':::::');
1.519 raeburn 849: }
850: $pathitem = '<input type="hidden" name="folderpath" value="'.
851: &HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 852: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
853: my $jumpto = $readfile;
854: $jumpto =~ s{^/}{};
855: my $tid = 1;
1.489 raeburn 856: if ($supplementalflag) {
857: $tid = 2;
858: }
1.509 raeburn 859: my ($breadcrumbtrail) =
860: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
1.484 raeburn 861: $r->print($breadcrumbtrail.
862: &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto,
863: $readfile));
1.329 droeschl 864: my %docslog=&Apache::lonnet::dump('nohist_docslog',
865: $env{'course.'.$env{'request.course.id'}.'.domain'},
866: $env{'course.'.$env{'request.course.id'}.'.num'});
867:
868: if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
869:
870: my %saveable_parameters = ('show' => 'scalar',);
871: &Apache::loncommon::store_course_settings('docs_log',
872: \%saveable_parameters);
873: &Apache::loncommon::restore_course_settings('docs_log',
874: \%saveable_parameters);
875: if (!$env{'form.show'}) { $env{'form.show'}=10; }
1.452 www 876: # FIXME: internationalization seems wrong here
1.329 droeschl 877: my %lt=('hiddenresource' => 'Resources hidden',
878: 'encrypturl' => 'URL hidden',
879: 'randompick' => 'Randomly pick',
880: 'randomorder' => 'Randomly ordered',
881: 'set' => 'set to',
882: 'del' => 'deleted');
1.484 raeburn 883: my $filter = &Apache::loncommon::display_filter('docslog')."\n".
884: $pathitem."\n".
885: '<input type="hidden" name="folder" value="'.$env{'form.folder'}.'" />'.
886: (' 'x2).'<input type="submit" value="'.&mt('Display').'" />';
887: $r->print('<div class="LC_left_float">'.
888: '<fieldset><legend>'.&mt('Display of Content Changes').'</legend>'."\n".
889: &makedocslogform($filter,1).
890: '</fieldset></div><br clear="all" />');
1.329 droeschl 891: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
892: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
893: &mt('After').'</th>'.
894: &Apache::loncommon::end_data_table_header_row());
895: my $shown=0;
896: foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
897: if ($env{'form.displayfilter'} eq 'currentfolder') {
898: if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
899: }
900: my @changes=keys(%{$docslog{$id}{'logentry'}});
901: if ($env{'form.displayfilter'} eq 'containing') {
902: my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
903: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
904: foreach my $key (@changes) {
905: $wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
906: }
1.344 bisitz 907: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
1.329 droeschl 908: }
909: my $count = 0;
910: my $time =
911: &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
912: my $plainname =
913: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
914: $docslog{$id}{'exe_udom'});
915: my $about_me_link =
916: &Apache::loncommon::aboutmewrapper($plainname,
917: $docslog{$id}{'exe_uname'},
918: $docslog{$id}{'exe_udom'});
919: my $send_msg_link='';
920: if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
921: || ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
922: $send_msg_link ='<br />'.
923: &Apache::loncommon::messagewrapper(&mt('Send message'),
924: $docslog{$id}{'exe_uname'},
925: $docslog{$id}{'exe_udom'});
926: }
927: $r->print(&Apache::loncommon::start_data_table_row());
928: $r->print('<td>'.$time.'</td>
929: <td>'.$about_me_link.
930: '<br /><tt>'.$docslog{$id}{'exe_uname'}.
931: ':'.$docslog{$id}{'exe_udom'}.'</tt>'.
932: $send_msg_link.'</td><td>'.
933: $docslog{$id}{'logentry'}{'folder'}.'</td><td>');
1.488 raeburn 934: my $is_supp = 0;
935: if ($docslog{$id}{'logentry'}{'currentfolder'} =~ /^supplemental/) {
936: $is_supp = 1;
937: }
1.329 droeschl 938: # Before
939: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
940: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
941: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
942: if ($oldname ne $newname) {
1.488 raeburn 943: my $shown = &LONCAPA::map::qtescape($oldname);
944: if ($is_supp) {
945: $shown = &Apache::loncommon::parse_supplemental_title($shown);
946: }
947: $r->print($shown);
1.329 droeschl 948: }
949: }
950: $r->print('<ul>');
951: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
952: if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
1.488 raeburn 953: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]);
954: if ($is_supp) {
955: $shown = &Apache::loncommon::parse_supplemental_title($shown);
956: }
957: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 958: }
959: }
960: $r->print('</ul>');
961: # After
962: $r->print('</td><td>');
963:
964: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
965: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
966: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
967: if ($oldname ne '' && $oldname ne $newname) {
1.488 raeburn 968: my $shown = &LONCAPA::map::qtescape($newname);
969: if ($is_supp) {
970: $shown = &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($newname));
971: }
972: $r->print($shown);
1.329 droeschl 973: }
1.364 bisitz 974: }
1.329 droeschl 975: $r->print('<ul>');
976: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
977: if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
1.488 raeburn 978: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]);
979: if ($is_supp) {
980: $shown = &Apache::loncommon::parse_supplemental_title($shown);
981: }
982: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 983: }
984: }
985: $r->print('</ul>');
986: if ($docslog{$id}{'logentry'}{'parameter_res'}) {
987: $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
988: foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
989: if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
1.452 www 990: # FIXME: internationalization seems wrong here
1.329 droeschl 991: $r->print('<li>'.
992: &mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
993: $docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
994: .'</li>');
995: }
996: }
997: $r->print('</ul>');
998: }
999: # End
1000: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1001: $shown++;
1002: if (!($env{'form.show'} eq &mt('all')
1003: || $shown<=$env{'form.show'})) { last; }
1004: }
1.484 raeburn 1005: $r->print(&Apache::loncommon::end_data_table()."\n".
1006: &makesimpleeditform($pathitem)."\n".
1007: '</div></div>');
1008: $r->print(&endContentScreen());
1.329 droeschl 1009: }
1010:
1011: sub update_paste_buffer {
1.492 raeburn 1012: my ($coursenum,$coursedom,$folder) = @_;
1.591 raeburn 1013: my (@possibles,%removals,%cuts,$output);
1.538 raeburn 1014: if ($env{'form.multiremove'}) {
1015: $env{'form.multiremove'} =~ s/,$//;
1016: map { $removals{$_} = 1; } split(/,/,$env{'form.multiremove'});
1017: }
1018: if (($env{'form.multicopy'}) || ($env{'form.multicut'})) {
1019: if ($env{'form.multicut'}) {
1020: $env{'form.multicut'} =~ s/,$//;
1021: foreach my $item (split(/,/,$env{'form.multicut'})) {
1022: unless ($removals{$item}) {
1023: $cuts{$item} = 1;
1024: push(@possibles,$item.':cut');
1025: }
1026: }
1027: }
1028: if ($env{'form.multicopy'}) {
1029: $env{'form.multicopy'} =~ s/,$//;
1030: foreach my $item (split(/,/,$env{'form.multicopy'})) {
1031: unless ($removals{$item} || $cuts{$item}) {
1032: push(@possibles,$item.':copy');
1033: }
1034: }
1035: }
1036: } elsif ($env{'form.markcopy'}) {
1037: @possibles = split(/,/,$env{'form.markcopy'});
1038: }
1.329 droeschl 1039:
1.538 raeburn 1040: return if (@possibles == 0);
1.329 droeschl 1041: return if (!defined($env{'form.copyfolder'}));
1042:
1043: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1044: $env{'form.copyfolder'});
1.538 raeburn 1045: return if ($fatal);
1046:
1047: my %curr_groups = &Apache::longroup::coursegroups();
1.364 bisitz 1048:
1.538 raeburn 1049: # Retrieve current paste buffer suffixes.
1050: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1051: my (%pasteurls,@newpaste);
1052:
1053: # Construct identifiers for current contents of user's paste buffer
1054: if (@currpaste) {
1055: foreach my $suffix (@currpaste) {
1056: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1057: my $url = $env{'docs.markedcopy_url_'.$suffix};
1.597 raeburn 1058: my $mapidx = $env{'docs.markedcopy_map_'.$suffix};
1.538 raeburn 1059: if (($cid =~ /^$match_domain(?:_)$match_courseid$/) &&
1060: ($url ne '')) {
1.597 raeburn 1061: $pasteurls{$cid.'_'.$url.'_'.$mapidx} = 1;
1.538 raeburn 1062: }
1063: }
1064: }
1065:
1066: # Mark items for copying (skip any items already in user's paste buffer)
1067: my %addtoenv;
1.597 raeburn 1068:
1069: my @pathitems = split(/\&/,$env{'form.folderpath'});
1070: my @folderconf = split(/\:/,$pathitems[-1]);
1071: my $ispage = $folderconf[4];
1072:
1.538 raeburn 1073: foreach my $item (@possibles) {
1074: my ($orderidx,$cmd) = split(/:/,$item);
1075: next if ($orderidx =~ /\D/);
1076: next unless (($cmd eq 'cut') || ($cmd eq 'copy') || ($cmd eq 'remove'));
1.597 raeburn 1077: my $mapidx = $folder.':'.$orderidx.':'.$ispage;
1.538 raeburn 1078: my ($title,$url)=split(':',$LONCAPA::map::resources[$orderidx]);
1079: my %denied = &action_restrictions($coursenum,$coursedom,
1080: &LONCAPA::map::qtescape($url),
1081: $env{'form.folderpath'},\%curr_groups);
1082: next if ($denied{'copy'});
1083: $url=~s{http(:|:)//https(:|:)//}{https$2//};
1.597 raeburn 1084: next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$mapidx}));
1.538 raeburn 1085: my ($suffix,$errortxt,$locknotfreed) =
1086: &new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste');
1.591 raeburn 1087: if ($suffix ne '') {
1088: push(@newpaste,$suffix);
1089: } else {
1090: if ($locknotfreed) {
1091: return $locknotfreed;
1092: }
1.538 raeburn 1093: }
1094: if (&is_supplemental_title($title)) {
1095: &Apache::lonnet::appenv({'docs.markedcopy_supplemental_'.$suffix => $title});
1096: ($title) = &Apache::loncommon::parse_supplemental_title($title);
1097: }
1.329 droeschl 1098:
1.538 raeburn 1099: $addtoenv{'docs.markedcopy_title_'.$suffix} = $title,
1100: $addtoenv{'docs.markedcopy_url_'.$suffix} = $url,
1101: $addtoenv{'docs.markedcopy_cmd_'.$suffix} = $cmd,
1102: $addtoenv{'docs.markedcopy_crs_'.$suffix} = $env{'request.course.id'};
1.597 raeburn 1103: $addtoenv{'docs.markedcopy_map_'.$suffix} = $mapidx;
1.538 raeburn 1104: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) {
1105: my $prefix = $1;
1106: my $subdir =$2;
1107: if ($subdir eq '') {
1108: $subdir = $prefix;
1.492 raeburn 1109: }
1.538 raeburn 1110: my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps);
1111: &contained_map_check($url,$folder,\%removefrommap,\%removeparam,\%addedmaps,
1112: \%hierarchy,\%titles,\%allmaps);
1113: if (ref($hierarchy{$url}) eq 'HASH') {
1114: my ($nested,$nestednames);
1115: &recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames);
1116: $nested =~ s/\&$//;
1117: $nestednames =~ s/\Q___&&&___\E$//;
1118: if ($nested ne '') {
1119: $addtoenv{'docs.markedcopy_nested_'.$suffix} = $nested;
1120: }
1121: if ($nestednames ne '') {
1122: $addtoenv{'docs.markedcopy_nestednames_'.$suffix} = $nestednames;
1123: }
1.492 raeburn 1124: }
1125: }
1.591 raeburn 1126: if ($locknotfreed) {
1127: $output = $locknotfreed;
1128: last;
1129: }
1.492 raeburn 1130: }
1.538 raeburn 1131: if (@newpaste) {
1132: $addtoenv{'docs.markedcopies'} = join(',',(@currpaste,@newpaste));
1133: }
1.492 raeburn 1134: &Apache::lonnet::appenv(\%addtoenv);
1.329 droeschl 1135: delete($env{'form.markcopy'});
1.591 raeburn 1136: return $output;
1.329 droeschl 1137: }
1138:
1.492 raeburn 1139: sub recurse_uploaded_maps {
1140: my ($url,$dir,$hierarchy,$titlesref,$nestref,$namesref) = @_;
1141: if (ref($hierarchy->{$url}) eq 'HASH') {
1142: my @maps = map { $hierarchy->{$url}{$_}; } sort { $a <=> $b } (keys(%{$hierarchy->{$url}}));
1143: my @titles = map { $titlesref->{$url}{$_}; } sort { $a <=> $b } (keys(%{$titlesref->{$url}}));
1144: my (@uploaded,@names,%shorter);
1145: for (my $i=0; $i<@maps; $i++) {
1146: my ($inner) = ($maps[$i] =~ m{^/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_(\d+)\.(?:page|sequence)$});
1147: if ($inner ne '') {
1148: push(@uploaded,$inner);
1149: push(@names,&escape($titles[$i]));
1150: $shorter{$maps[$i]} = $inner;
1151: }
1152: }
1153: $$nestref .= "$dir:".join(',',@uploaded).'&';
1154: $$namesref .= "$dir:".(join(',',@names)).'___&&&___';
1155: foreach my $map (@maps) {
1156: if ($shorter{$map} ne '') {
1157: &recurse_uploaded_maps($map,$shorter{$map},$hierarchy,$titlesref,$nestref,$namesref);
1158: }
1159: }
1160: }
1161: return;
1162: }
1163:
1.329 droeschl 1164: sub print_paste_buffer {
1.492 raeburn 1165: my ($r,$container,$folder,$coursedom,$coursenum) = @_;
1.538 raeburn 1166: return if (!defined($env{'docs.markedcopies'}));
1.329 droeschl 1167:
1.538 raeburn 1168: unless (($env{'form.pastemarked'}) || ($env{'form.clearmarked'})) {
1169: return if ($env{'docs.markedcopies'} eq '');
1.488 raeburn 1170: }
1171:
1.538 raeburn 1172: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1173: my ($pasteitems,@pasteable);
1.575 raeburn 1174: my $clipboardcount = 0;
1.488 raeburn 1175:
1.538 raeburn 1176: # Construct identifiers for current contents of user's paste buffer
1177: foreach my $suffix (@currpaste) {
1178: next if ($suffix =~ /\D/);
1179: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1180: my $url = $env{'docs.markedcopy_url_'.$suffix};
1.597 raeburn 1181: my $mapidx = $env{'docs.markedcopy_map_'.$suffix};
1.538 raeburn 1182: if (($cid =~ /^$match_domain\_$match_courseid$/) &&
1183: ($url ne '')) {
1.575 raeburn 1184: $clipboardcount ++;
1.538 raeburn 1185: my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent,
1.598 raeburn 1186: $canpaste,$nopaste,$othercrs,$areachange,$is_exttool);
1.538 raeburn 1187: my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1];
1188: if ($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
1189: $is_external = 1;
1.598 raeburn 1190: } elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/exttools?$}) {
1191: $is_exttool = 1;
1.538 raeburn 1192: }
1193: if ($folder =~ /^supplemental/) {
1194: $canpaste = &supp_pasteable($env{'docs.markedcopy_url_'.$suffix});
1195: unless ($canpaste) {
1196: $nopaste = &mt('Paste into Supplemental Content unavailable.');
1197: }
1198: } else {
1199: $canpaste = 1;
1200: }
1201: if ($canpaste) {
1202: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1203: my $srcdom = $1;
1204: my $srcnum = $2;
1205: my $rem = $3;
1206: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
1207: $othercourse = 1;
1208: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1.596 raeburn 1209: $othercrs = '<br />'.&mt('(from another course)');
1.538 raeburn 1210: } else {
1211: $canpaste = 0;
1212: $nopaste = &mt('Paste from another course unavailable.');
1213: }
1214: }
1215: if ($rem =~ m{^(default|supplemental)_?(\d*)\.(?:page|sequence)$}) {
1216: my $prefix = $1;
1217: $parent = $2;
1218: if ($folder !~ /^\Q$prefix\E/) {
1219: $areachange = 1;
1220: }
1221: $is_uploaded_map = 1;
1.492 raeburn 1222: }
1.597 raeburn 1223: } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
1224: ($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg)$})) {
1.596 raeburn 1225: if ($cid ne $env{'request.course.id'}) {
1226: my ($srcdom,$srcnum) = split(/_/,$cid);
1227: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1228: $othercrs = '<br />'.&mt('(from another course)');
1229: } else {
1230: $canpaste = 0;
1231: $nopaste = &mt('Paste from another course unavailable.');
1232: }
1233: }
1.492 raeburn 1234: }
1.596 raeburn 1235: if ($canpaste) {
1236: push(@pasteable,$suffix);
1237: }
1.538 raeburn 1238: }
1239: my $buffer;
1.598 raeburn 1240: if (($is_external) || ($is_exttool)) {
1.538 raeburn 1241: $buffer = &mt('External Resource').': '.
1242: &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('.
1243: &LONCAPA::map::qtescape($url).')';
1244: } else {
1245: my $icon = &Apache::loncommon::icon($extension);
1246: if ($extension eq 'sequence' &&
1247: $url =~ m{/default_\d+\.sequence$}x) {
1248: $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
1249: $icon .= '/navmap.folder.closed.gif';
1250: }
1.589 raeburn 1251: my $title = $env{'docs.markedcopy_title_'.$suffix};
1252: if ($title eq '') {
1253: ($title) = ($url =~ m{/([^/]+)$});
1254: }
1.538 raeburn 1255: $buffer = '<img src="'.$icon.'" alt="" class="LC_icon" />'.
1256: ': '.
1257: &Apache::loncommon::parse_supplemental_title(
1.589 raeburn 1258: &LONCAPA::map::qtescape($title));
1.538 raeburn 1259: }
1260: $pasteitems .= '<div class="LC_left_float">';
1261: my ($options,$onclick);
1262: if (($canpaste) && (!$areachange) && (!$othercourse) &&
1263: ($env{'docs.markedcopy_cmd_'.$suffix} eq 'cut')) {
1264: if (($is_uploaded_map) ||
1265: ($url =~ /(bulletinboard|smppg)$/) ||
1266: ($url =~ m{^/uploaded/$coursedom/$coursenum/(?:docs|supplemental)/(.+)$})) {
1267: $options = &paste_options($suffix,$is_uploaded_map,$parent);
1268: $onclick= 'onclick="showOptions(this,'."'$suffix'".');" ';
1269: }
1270: }
1271: $pasteitems .= '<label><input type="checkbox" name="pasting" id="pasting_'.$suffix.'" value="'.$suffix.'" '.$onclick.'/>'.$buffer.'</label>';
1272: if ($nopaste) {
1273: $pasteitems .= $nopaste;
1274: } else {
1275: if ($othercrs) {
1276: $pasteitems .= $othercrs;
1277: }
1278: if ($options) {
1279: $pasteitems .= $options;
1.492 raeburn 1280: }
1281: }
1.538 raeburn 1282: $pasteitems .= '</div>';
1283: }
1284: }
1285: if ($pasteitems eq '') {
1286: &Apache::lonnet::delenv('docs.markedcopies');
1287: }
1288: my ($pasteform,$form_start,$buttons,$form_end);
1289: if ($pasteitems) {
1290: $pasteitems .= '<div style="padding:0;clear:both;margin:0;border:0"></div>';
1.541 raeburn 1291: $form_start = '<form name="pasteform" action="/adm/coursedocs" method="post" onsubmit="return validateClipboard();">';
1.538 raeburn 1292: if (@pasteable) {
1.575 raeburn 1293: my $value = &mt('Paste to current folder');
1294: if ($container eq 'page') {
1295: $value = &mt('Paste to current page');
1296: }
1297: $buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.(' 'x2);
1298: }
1299: $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.(' 'x2);
1300: if ($clipboardcount > 1) {
1301: $buttons .=
1302: '<span style="text-decoration:line-through">'.(' 'x20).'</span>'.(' 'x2).
1303: '<input type="button" name="checkallclip" value="'.&mt('Check all').'" style="height:20px;" onclick="checkClipboard();" />'.
1304: (' 'x2).
1305: '<input type="button" name="uncheckallclip" value="'.&mt('Uncheck all').'" style="height:20px;" onclick="uncheckClipboard();" />'.
1306: (' 'x2);
1.492 raeburn 1307: }
1.575 raeburn 1308: $form_end = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'.
1309: '</form>';
1.538 raeburn 1310: } else {
1311: $pasteitems = &mt('Clipboard is empty');
1.488 raeburn 1312: }
1.538 raeburn 1313: $r->print($form_start
1314: .'<fieldset>'
1315: .'<legend>'.&mt('Clipboard').(' ' x2).$buttons.'</legend>'
1316: .$pasteitems
1317: .'</fieldset>'
1318: .$form_end);
1319: }
1320:
1321: sub paste_options {
1322: my ($suffix,$is_uploaded_map,$parent) = @_;
1323: my ($copytext,$movetext);
1324: if ($is_uploaded_map) {
1325: $copytext = &mt('Copy to new folder');
1326: $movetext = &mt('Move old');
1327: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /bulletinboard$/) {
1328: $copytext = &mt('Copy to new board');
1329: $movetext = &mt('Move (not posts)');
1330: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /smppg$/) {
1331: $copytext = &mt('Copy to new page');
1332: $movetext = &mt('Move');
1.533 raeburn 1333: } else {
1.538 raeburn 1334: $copytext = &mt('Copy to new file');
1335: $movetext = &mt('Move');
1336: }
1337: my $output = '<br />'.
1338: '<span id="pasteoptionstext_'.$suffix.'" class="LC_fontsize_small LC_nobreak"></span>'.
1339: '<div id="pasteoptions_'.$suffix.'" class="LC_dccid" style="display:none;"><span class="LC_nobreak">'.(' 'x 4).
1340: '<label>'.
1341: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="new" checked="checked" />'.
1342: $copytext.'</label></span>'.(' 'x2).' '.
1343: '<span class="LC_nobreak"><label>'.
1344: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="move" />'.
1345: $movetext.'</label></span>';
1346: if (($is_uploaded_map) && ($env{'docs.markedcopy_nested_'.$suffix})) {
1347: $output .= '<br /><fieldset><legend>'.&mt('Folder to paste contains sub-folders').
1348: '</legend><table border="0">';
1349: my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1350: my @titles = split(/\Q___&&&___\E/,$env{'docs.markedcopy_nestednames_'.$suffix});
1351: my $lastdir = $parent;
1352: my %depths = (
1353: $lastdir => 0,
1354: );
1355: my (%display,%deps);
1356: for (my $i=0; $i<@pastemaps; $i++) {
1357: ($lastdir,my $subfolderstr) = split(/\:/,$pastemaps[$i]);
1358: my ($namedir,$esctitlestr) = split(/\:/,$titles[$i]);
1359: my @subfolders = split(/,/,$subfolderstr);
1360: $deps{$lastdir} = \@subfolders;
1361: my @subfoldertitles = map { &unescape($_); } split(/,/,$esctitlestr);
1362: my $depth = $depths{$lastdir} + 1;
1363: my $offset = int($depth * 4);
1364: my $indent = (' ' x $offset);
1365: for (my $j=0; $j<@subfolders; $j++) {
1366: $depths{$subfolders[$j]} = $depth;
1367: $display{$subfolders[$j]} =
1368: '<tr><td>'.$indent.$subfoldertitles[$j].' </td>'.
1369: '<td><label>'.
1370: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="new" checked="checked" />'.&mt('Copy to new').'</label>'.(' ' x2).
1371: '<label>'.
1372: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="move" />'.
1373: &mt('Move old').'</label>'.
1374: '</td></tr>';
1375: }
1.492 raeburn 1376: }
1.538 raeburn 1377: &recurse_print(\$output,$parent,\%deps,\%display);
1378: $output .= '</table></fieldset>';
1.329 droeschl 1379: }
1.538 raeburn 1380: $output .= '</div>';
1381: return $output;
1.488 raeburn 1382: }
1383:
1.492 raeburn 1384: sub recurse_print {
1.538 raeburn 1385: my ($outputref,$dir,$deps,$display) = @_;
1386: $$outputref .= $display->{$dir}."\n";
1.492 raeburn 1387: if (ref($deps->{$dir}) eq 'ARRAY') {
1388: foreach my $subdir (@{$deps->{$dir}}) {
1.538 raeburn 1389: &recurse_print($outputref,$subdir,$deps,$display);
1.492 raeburn 1390: }
1391: }
1392: }
1393:
1.488 raeburn 1394: sub supp_pasteable {
1395: my ($url) = @_;
1396: if (($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//}) ||
1397: (($url =~ /\.sequence$/) && ($url =~ m{^/uploaded/})) ||
1398: ($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) ||
1399: ($url =~ m{^/adm/$match_domain/$match_username/aboutme}) ||
1.598 raeburn 1400: ($url =~ m{^/public/$match_domain/$match_courseid/syllabus}) ||
1401: ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/exttools?$})) {
1.488 raeburn 1402: return 1;
1403: }
1404: return;
1.329 droeschl 1405: }
1406:
1.492 raeburn 1407: sub paste_popup_js {
1.594 damieng 1408: my %html_js_lt = &Apache::lonlocal::texthash(
1.538 raeburn 1409: show => 'Show Options',
1410: hide => 'Hide Options',
1.594 damieng 1411: );
1412: my %js_lt = &Apache::lonlocal::texthash(
1.541 raeburn 1413: none => 'No items selected from clipboard.',
1.492 raeburn 1414: );
1.594 damieng 1415: &html_escape(\%html_js_lt);
1416: &js_escape(\%html_js_lt);
1417: &js_escape(\%js_lt);
1.492 raeburn 1418: return <<"END";
1419:
1.538 raeburn 1420: function showPasteOptions(suffix) {
1421: document.getElementById('pasteoptions_'+suffix).style.display='block';
1.594 damieng 1422: document.getElementById('pasteoptionstext_'+suffix).innerHTML = ' <a href="javascript:hidePasteOptions(\\''+suffix+'\\');" class="LC_menubuttons_link">$html_js_lt{'hide'}</a>';
1.492 raeburn 1423: return;
1424: }
1425:
1.538 raeburn 1426: function hidePasteOptions(suffix) {
1427: document.getElementById('pasteoptions_'+suffix).style.display='none';
1.594 damieng 1428: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.538 raeburn 1429: return;
1430: }
1431:
1432: function showOptions(caller,suffix) {
1433: if (document.getElementById('pasteoptionstext_'+suffix)) {
1434: if (caller.checked) {
1.594 damieng 1435: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.538 raeburn 1436: } else {
1437: document.getElementById('pasteoptionstext_'+suffix).innerHTML ='';
1438: }
1439: if (document.getElementById('pasteoptions_'+suffix)) {
1440: document.getElementById('pasteoptions_'+suffix).style.display='none';
1441: }
1442: }
1.492 raeburn 1443: return;
1444: }
1445:
1.541 raeburn 1446: function validateClipboard() {
1447: var numchk = 0;
1448: if (document.pasteform.pasting.length > 1) {
1449: for (var i=0; i<document.pasteform.pasting.length; i++) {
1450: if (document.pasteform.pasting[i].checked) {
1451: numchk ++;
1452: }
1453: }
1454: } else {
1455: if (document.pasteform.pasting.type == 'checkbox') {
1456: if (document.pasteform.pasting.checked) {
1457: numchk ++;
1458: }
1459: }
1460: }
1461: if (numchk > 0) {
1462: return true;
1463: } else {
1.594 damieng 1464: alert("$js_lt{'none'}");
1.541 raeburn 1465: return false;
1466: }
1467: }
1468:
1.575 raeburn 1469: function checkClipboard() {
1470: if (document.pasteform.pasting.length > 1) {
1471: for (var i=0; i<document.pasteform.pasting.length; i++) {
1472: document.pasteform.pasting[i].checked = true;
1473: }
1474: }
1475: return;
1476: }
1477:
1478: function uncheckClipboard() {
1479: if (document.pasteform.pasting.length >1) {
1480: for (var i=0; i<document.pasteform.pasting.length; i++) {
1481: document.pasteform.pasting[i].checked = false;
1482: }
1483: }
1484: return;
1485: }
1486:
1.492 raeburn 1487: END
1488:
1489: }
1490:
1.329 droeschl 1491: sub do_paste_from_buffer {
1.492 raeburn 1492: my ($coursenum,$coursedom,$folder,$container,$errors) = @_;
1.329 droeschl 1493:
1.538 raeburn 1494: # Array of items in paste buffer
1495: my (@currpaste,%pastebuffer,%allerrors);
1496: @currpaste = split(/,/,$env{'docs.markedcopies'});
1497:
1.492 raeburn 1498: # Early out if paste buffer is empty
1.538 raeburn 1499: if (@currpaste == 0) {
1.492 raeburn 1500: return ();
1.538 raeburn 1501: }
1502: map { $pastebuffer{$_} = 1; } @currpaste;
1503:
1504: # Array of items selected items to paste
1505: my @reqpaste = &Apache::loncommon::get_env_multiple('form.pasting');
1506:
1507: # Early out if nothing selected to paste
1508: if (@reqpaste == 0) {
1509: return();
1510: }
1511: my @topaste;
1512: foreach my $suffix (@reqpaste) {
1513: next if ($suffix =~ /\D/);
1514: next unless (exists($pastebuffer{$suffix}));
1515: push(@topaste,$suffix);
1516: }
1517:
1518: # Early out if nothing available to paste
1519: if (@topaste == 0) {
1520: return();
1.329 droeschl 1521: }
1522:
1.538 raeburn 1523: my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%duplicate,
1.597 raeburn 1524: %prefixchg,%srcdom,%srcnum,%srcmapidx,%marktomove,$save_err,$lockerrors,$allresult);
1.538 raeburn 1525:
1526: foreach my $suffix (@topaste) {
1527: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1.596 raeburn 1528: my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.597 raeburn 1529: my $mapidx=&LONCAPA::map::qtescape($env{'docs.markedcopy_map_'.$suffix});
1.492 raeburn 1530: # Supplemental content may only include certain types of content
1531: # Early out if pasted content is not supported in Supplemental area
1.538 raeburn 1532: if ($folder =~ /^supplemental/) {
1533: unless (&supp_pasteable($url)) {
1534: $notinsupp{$suffix} = 1;
1535: next;
1536: }
1.492 raeburn 1537: }
1.538 raeburn 1538: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/}) {
1539: my $srcd = $1;
1540: my $srcn = $2;
1.492 raeburn 1541: # When paste buffer was populated using an active role in a different course
1.538 raeburn 1542: # check for mdc privilege in the course from which the resource was pasted
1543: if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1544: unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1545: $notincrs{$suffix} = 1;
1546: next;
1547: }
1.491 raeburn 1548: }
1.538 raeburn 1549: $srcdom{$suffix} = $srcd;
1550: $srcnum{$suffix} = $srcn;
1.597 raeburn 1551: } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
1552: ($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg)$})) {
1.596 raeburn 1553: my ($srcd,$srcn) = split(/_/,$cid);
1554: # When paste buffer was populated using an active role in a different course
1555: # check for mdc privilege in the course from which the resource was pasted
1556: if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1557: unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1558: $notincrs{$suffix} = 1;
1559: next;
1560: }
1561: }
1562: $srcdom{$suffix} = $srcd;
1563: $srcnum{$suffix} = $srcn;
1.491 raeburn 1564: }
1.597 raeburn 1565: $srcmapidx{$suffix} = $mapidx;
1.538 raeburn 1566: push(@dopaste,$suffix);
1567: if ($url=~/\.(page|sequence)$/) {
1568: $is_map{$suffix} = 1;
1569: }
1570:
1571: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/([^/]+)}) {
1572: my $oldprefix = $1;
1.492 raeburn 1573: # When pasting content from Main Content to Supplemental Content and vice versa
1574: # URLs will contain different paths (which depend on whether pasted item is
1.597 raeburn 1575: # a folder/page or a document).
1.538 raeburn 1576: if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) {
1577: $prefixchg{$suffix} = 'docstosupp';
1578: } elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) {
1579: $prefixchg{$suffix} = 'supptodocs';
1580: }
1.491 raeburn 1581:
1.492 raeburn 1582: # If pasting an uploaded map, get list of contained uploaded maps.
1.538 raeburn 1583: if ($env{'docs.markedcopy_nested_'.$suffix}) {
1584: my @nested;
1585: my ($type) = ($oldprefix =~ /^(default|supplemental)/);
1586: my @items = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1587: my @deps = map { /\d+:([\d,]+$)/ } @items;
1588: foreach my $dep (@deps) {
1589: if ($dep =~ /,/) {
1590: push(@nested,split(/,/,$dep));
1591: } else {
1592: push(@nested,$dep);
1593: }
1.492 raeburn 1594: }
1.538 raeburn 1595: foreach my $item (@nested) {
1596: if ($env{'form.docs.markedcopy_'.$suffix.'_'.$item} eq 'move') {
1597: push(@{$marktomove{$suffix}},$type.'_'.$item);
1598: }
1.492 raeburn 1599: }
1600: }
1.488 raeburn 1601: }
1602: }
1603:
1.538 raeburn 1604: # Early out if nothing available to paste
1605: if (@dopaste == 0) {
1606: return ();
1607: }
1608:
1609: # Populate message hash and hashes used for main content <=> supplemental content
1610: # changes
1611:
1612: %msgs = &Apache::lonlocal::texthash (
1613: notinsupp => 'Paste failed: content type is not supported within Supplemental Content',
1614: notincrs => 'Paste failed: Item is from a different course which you do not have rights to edit.',
1615: duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.',
1616: );
1617:
1618: %before = (
1619: docstosupp => {
1620: map => 'default',
1621: doc => 'docs',
1622: },
1623: supptodocs => {
1624: map => 'supplemental',
1625: doc => 'supplemental',
1626: },
1627: );
1628:
1629: %after = (
1630: docstosupp => {
1631: map => 'supplemental',
1632: doc => 'supplemental'
1633: },
1634: supptodocs => {
1635: map => 'default',
1636: doc => 'docs',
1637: },
1638: );
1639:
1640: # Retrieve information about all course maps in main content area
1641:
1642: my $allmaps = {};
1643: if ($folder =~ /^default/) {
1644: $allmaps =
1645: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
1646: $env{"course.$env{'request.course.id'}.home"},
1647: $env{'request.course.id'});
1648: }
1649:
1650: my (@toclear,%mapurls,%lockerrs,%msgerrs,%results);
1651:
1652: # Loop over the items to paste
1653: foreach my $suffix (@dopaste) {
1.329 droeschl 1654: # Maps need to be copied first
1.538 raeburn 1655: my (%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies,
1656: %dbcopies,%zombies,%params,%docmoves,%mapmoves,%mapchanges,%newsubdir,
1.597 raeburn 1657: %newurls,%tomove,%resdatacopy);
1.538 raeburn 1658: if (ref($marktomove{$suffix}) eq 'ARRAY') {
1659: map { $tomove{$_} = 1; } @{$marktomove{$suffix}};
1660: }
1661: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1662: my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.596 raeburn 1663: my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.538 raeburn 1664: my $oldurl = $url;
1665: if ($is_map{$suffix}) {
1.491 raeburn 1666: # If pasting a map, check if map contains other maps
1.538 raeburn 1667: my (%hierarchy,%titles);
1668: &contained_map_check($url,$folder,\%removefrommap,\%removeparam,
1669: \%addedmaps,\%hierarchy,\%titles,$allmaps);
1670: if ($url=~ m{^/uploaded/}) {
1671: my $newurl;
1672: unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
1673: ($newurl,my $error) =
1674: &get_newmap_url($url,$folder,$prefixchg{$suffix},$coursedom,
1675: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1676: \$title,$allmaps,\%newurls);
1677: if ($error) {
1678: $allerrors{$suffix} = $error;
1679: next;
1680: }
1681: if ($newurl ne '') {
1682: if ($newurl ne $url) {
1683: if ($newurl =~ /(?:default|supplemental)_(\d+).(?:sequence|page)$/) {
1684: $newsubdir{$url} = $1;
1685: }
1686: $mapchanges{$url} = 1;
1.492 raeburn 1687: }
1.538 raeburn 1688: }
1689: }
1690: if (($srcdom{$suffix} ne $coursedom) ||
1691: ($srcnum{$suffix} ne $coursenum) ||
1692: ($prefixchg{$suffix}) || (($newurl ne '') && ($newurl ne $url))) {
1693: unless (&url_paste_fixups($url,$folder,$prefixchg{$suffix},
1694: $coursedom,$coursenum,$srcdom{$suffix},
1695: $srcnum{$suffix},$allmaps,\%rewrites,
1696: \%retitles,\%copies,\%dbcopies,
1697: \%zombies,\%params,\%mapmoves,
1698: \%mapchanges,\%tomove,\%newsubdir,
1.597 raeburn 1699: \%newurls,\%resdatacopy)) {
1.538 raeburn 1700: $mapmoves{$url} = 1;
1701: }
1702: $url = $newurl;
1703: } elsif ($env{'docs.markedcopy_nested_'.$suffix}) {
1704: &url_paste_fixups($url,$folder,$prefixchg{$suffix},$coursedom,
1705: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1706: $allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies,
1707: \%zombies,\%params,\%mapmoves,\%mapchanges,
1.597 raeburn 1708: \%tomove,\%newsubdir,\%newurls,\%resdatacopy);
1.538 raeburn 1709: }
1710: } elsif ($url=~m {^/res/}) {
1.597 raeburn 1711: # published map can only exist once, so remove from paste buffer when done
1.538 raeburn 1712: push(@toclear,$suffix);
1713: # if pasting published map (main content area only) check map not already in course
1714: if ($folder =~ /^default/) {
1715: if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) {
1716: $duplicate{$suffix} = 1;
1717: next;
1.492 raeburn 1718: }
1.491 raeburn 1719: }
1720: }
1.538 raeburn 1721: }
1722: if ($url=~ m{/(bulletinboard|smppg)$}) {
1723: my $prefix = $1;
1.596 raeburn 1724: my $fromothercrs;
1.538 raeburn 1725: #need to copy the db contents to a new one, unless this is a move.
1726: my %info = (
1727: src => $url,
1728: cdom => $coursedom,
1729: cnum => $coursenum,
1.596 raeburn 1730: );
1731: if (($srcdom{$suffix} =~ /^$match_domain$/) && ($srcnum{$suffix} =~ /^$match_courseid$/)) {
1732: unless (($srcdom{$suffix} eq $coursedom) && ($srcnum{$suffix} eq $coursenum)) {
1733: $fromothercrs = 1;
1734: $info{'cdom'} = $srcdom{$suffix};
1735: $info{'cnum'} = $srcnum{$suffix};
1736: }
1737: }
1738: unless (($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') && (!$fromothercrs)) {
1.538 raeburn 1739: my (%lockerr,$msg);
1740: my ($newurl,$result,$errtext) =
1741: &dbcopy(\%info,$coursedom,$coursenum,\%lockerr);
1742: if ($result eq 'ok') {
1743: $url = $newurl;
1744: $title=&mt('Copy of').' '.$title;
1745: } else {
1746: if ($prefix eq 'smppg') {
1747: $msg = &mt('Paste failed: An error occurred when copying the simple page.').' '.$errtext;
1748: } elsif ($prefix eq 'bulletinboard') {
1.565 bisitz 1749: $msg = &mt('Paste failed: An error occurred when copying the discussion board.').' '.$errtext;
1.538 raeburn 1750: }
1751: $results{$suffix} = $result;
1752: $msgerrs{$suffix} = $msg;
1753: $lockerrs{$suffix} = $lockerr{$prefix};
1754: next;
1755: }
1756: if ($lockerr{$prefix}) {
1757: $lockerrs{$suffix} = $lockerr{$prefix};
1.491 raeburn 1758: }
1.489 raeburn 1759: }
1760: }
1.538 raeburn 1761: $title = &LONCAPA::map::qtunescape($title);
1762: my $ext='false';
1763: if ($url=~m{^http(|s)://}) { $ext='true'; }
1764: if ($env{'docs.markedcopy_supplemental_'.$suffix}) {
1765: if ($folder !~ /^supplemental/) {
1766: (undef,undef,$title) =
1767: &Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental_'.$suffix});
1768: }
1769: } else {
1770: if ($folder=~/^supplemental/) {
1771: $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
1772: $env{'user.domain'}.'___&&&___'.$title;
1.491 raeburn 1773: }
1.533 raeburn 1774: }
1.491 raeburn 1775:
1776: # For uploaded files (excluding pages/sequences) path in copied file is changed
1777: # if paste is from Main to Supplemental (or vice versa), or if pasting between
1778: # courses.
1779:
1.538 raeburn 1780: unless ($is_map{$suffix}) {
1781: my $newidx;
1.492 raeburn 1782: # Now insert the URL at the bottom
1.538 raeburn 1783: $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
1784: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(.+)$}) {
1785: my $relpath = $1;
1786: if ($relpath ne '') {
1787: my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$});
1788: my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/);
1789: my $newprefix = $newloc;
1790: if ($newloc eq 'default') {
1791: $newprefix = 'docs';
1792: }
1793: if ($newdocsdir eq '') {
1794: $newdocsdir = 'default';
1795: }
1796: if (($prefixchg{$suffix}) ||
1797: ($srcdom{$suffix} ne $coursedom) ||
1798: ($srcnum{$suffix} ne $coursenum) ||
1799: ($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) {
1800: my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";
1801: $url =
1802: &Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath,
1803: &Apache::lonnet::getfile($oldurl));
1804: if ($url eq '/adm/notfound.html') {
1805: $msgs{$suffix} = &mt('Paste failed: an error occurred saving the file.');
1806: next;
1807: } else {
1808: my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$});
1809: $newsubpath =~ s{/+$}{/};
1810: $docmoves{$oldurl} = $newsubpath;
1811: }
1.491 raeburn 1812: }
1813: }
1.597 raeburn 1814: } elsif ($url =~ m{^/res/lib/templates/(\w+)\.problem$}) {
1815: my $template = $1;
1816: if ($newidx) {
1817: ©_templated_files($url,$srcdom{$suffix},$srcnum{$suffix},$srcmapidx{$suffix},
1818: $coursedom,$coursenum,$template,$newidx,"$folder.$container");
1819: }
1.491 raeburn 1820: }
1.538 raeburn 1821: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
1822: ':'.$ext.':normal:res';
1823: push(@LONCAPA::map::order,$newidx);
1824: # Store the result
1825: my ($errtext,$fatal) =
1826: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1827: if ($fatal) {
1828: $save_err .= $errtext;
1829: $allresult = 'fail';
1830: }
1.488 raeburn 1831: }
1.538 raeburn 1832:
1.597 raeburn 1833: # Apply any changes to maps, or copy dependencies for uploaded HTML pages, or update
1834: # resourcedata for simpleproblems copied from another course
1.538 raeburn 1835: unless ($allresult eq 'fail') {
1836: my %updated = (
1837: rewrites => \%rewrites,
1838: zombies => \%zombies,
1839: removefrommap => \%removefrommap,
1840: removeparam => \%removeparam,
1841: dbcopies => \%dbcopies,
1.597 raeburn 1842: resdatacopy => \%resdatacopy,
1.538 raeburn 1843: retitles => \%retitles,
1844: );
1845: my %info = (
1846: newsubdir => \%newsubdir,
1847: params => \%params,
1848: );
1849: if ($prefixchg{$suffix}) {
1850: $info{'before'} = $before{$prefixchg{$suffix}};
1851: $info{'after'} = $after{$prefixchg{$suffix}};
1852: }
1853: my %moves = (
1854: copies => \%copies,
1855: docmoves => \%docmoves,
1856: mapmoves => \%mapmoves,
1857: );
1858: (my $result,$msgs{$suffix},my $lockerror) =
1859: &apply_fixups($folder,$is_map{$suffix},$coursedom,$coursenum,$errors,
1860: \%updated,\%info,\%moves,$prefixchg{$suffix},$oldurl,
1861: $url,'paste');
1862: $lockerrors .= $lockerror;
1863: if ($result eq 'ok') {
1864: if ($is_map{$suffix}) {
1865: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1866: $folder.'.'.$container);
1867: if ($fatal) {
1868: $allresult = 'failread';
1869: } else {
1870: if ($#LONCAPA::map::order<1) {
1871: my $idx=&LONCAPA::map::getresidx();
1872: if ($idx<=0) { $idx=1; }
1873: $LONCAPA::map::order[0]=$idx;
1874: $LONCAPA::map::resources[$idx]='';
1875: }
1876: my $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
1877: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
1878: ':'.$ext.':normal:res';
1879: push(@LONCAPA::map::order,$newidx);
1.492 raeburn 1880:
1881: # Store the result
1.538 raeburn 1882: my ($errtext,$fatal) =
1883: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1884: if ($fatal) {
1885: $save_err .= $errtext;
1886: $allresult = 'failstore';
1887: }
1888: }
1889: }
1890: if ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
1891: push(@toclear,$suffix);
1892: }
1893: }
1.492 raeburn 1894: }
1895: }
1.538 raeburn 1896: &clear_from_buffer(\@toclear,\@currpaste);
1897: my $msgsarray;
1898: foreach my $suffix (keys(%msgs)) {
1899: if (ref($msgs{$suffix}) eq 'ARRAY') {
1900: $msgsarray .= join(',',@{$msgs{$suffix}});
1901: }
1902: }
1903: return ($allresult,$save_err,$msgsarray,$lockerrors);
1904: }
1.533 raeburn 1905:
1.538 raeburn 1906: sub do_buffer_empty {
1907: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1908: if (@currpaste == 0) {
1909: return &mt('Clipboard is already empty');
1910: }
1911: my @toclear = &Apache::loncommon::get_env_multiple('form.pasting');
1912: if (@toclear == 0) {
1913: return &mt('Nothing selected to clear from clipboard');
1914: }
1915: my $numdel = &clear_from_buffer(\@toclear,\@currpaste);
1916: if ($numdel) {
1917: return &mt('[quant,_1,item] cleared from clipboard',$numdel);
1918: } else {
1919: return &mt('Clipboard unchanged');
1.492 raeburn 1920: }
1.538 raeburn 1921: return;
1922: }
1923:
1924: sub clear_from_buffer {
1925: my ($toclear,$currpaste) = @_;
1926: return unless ((ref($toclear) eq 'ARRAY') && (ref($currpaste) eq 'ARRAY'));
1927: my %pastebuffer;
1928: map { $pastebuffer{$_} = 1; } @{$currpaste};
1929: my $numdel = 0;
1930: foreach my $suffix (@{$toclear}) {
1931: next if ($suffix =~ /\D/);
1932: next unless (exists($pastebuffer{$suffix}));
1933: my $regexp = 'docs.markedcopy_[a-z]+_'.$suffix;
1934: if (&Apache::lonnet::delenv($regexp,1) eq 'ok') {
1935: delete($pastebuffer{$suffix});
1936: $numdel ++;
1937: }
1938: }
1939: my $newbuffer = join(',',sort(keys(%pastebuffer)));
1940: &Apache::lonnet::appenv({'docs.markedcopies' => $newbuffer});
1941: return $numdel;
1.492 raeburn 1942: }
1943:
1944: sub get_newmap_url {
1945: my ($url,$folder,$prefixchg,$coursedom,$coursenum,$srcdom,$srcnum,
1946: $titleref,$allmaps,$newurls) = @_;
1947: my $newurl;
1948: if ($url=~ m{^/uploaded/}) {
1949: $$titleref=&mt('Copy of').' '.$$titleref;
1950: }
1951: my $now = time;
1952: my $suffix=$$.int(rand(100)).$now;
1953: my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
1954: if ($oldid =~ m{^(/uploaded/$match_domain/$match_courseid/)(\D+)(\d+)$}) {
1955: my $path = $1;
1956: my $prefix = $2;
1957: my $ancestor = $3;
1958: if (length($ancestor) > 10) {
1959: $ancestor = substr($ancestor,-10,10);
1960: }
1961: my $newid;
1962: if ($prefixchg) {
1963: if ($folder =~ /^supplemental/) {
1964: $prefix =~ s/^default/supplemental/;
1965: } else {
1966: $prefix =~ s/^supplemental/default/;
1967: }
1968: }
1969: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
1970: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
1971: } else {
1972: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$now.'.'.$ext;
1973: }
1974: my $counter = 0;
1975: my $is_unique = &uniqueness_check($newurl);
1976: if ($folder =~ /^default/) {
1977: if ($allmaps->{$newurl}) {
1978: $is_unique = 0;
1979: }
1980: }
1981: while ((!$is_unique || $allmaps->{$newurl} || $newurls->{$newurl}) && ($counter < 100)) {
1982: $counter ++;
1983: $suffix ++;
1984: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
1985: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
1986: } else {
1987: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$ancestor.$suffix.'.'.$ext;
1988: }
1989: $is_unique = &uniqueness_check($newurl);
1990: }
1991: if ($is_unique) {
1992: $newurls->{$newurl} = 1;
1993: } else {
1994: if ($url=~/\.page$/) {
1995: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the composite page'));
1996: } else {
1997: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the folder'));
1998: }
1999: }
1.329 droeschl 2000: }
1.492 raeburn 2001: return ($newurl);
1.329 droeschl 2002: }
2003:
1.488 raeburn 2004: sub dbcopy {
1.533 raeburn 2005: my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_;
2006: my ($url,$result,$errtext);
2007: if (ref($dbref) eq 'HASH') {
1.596 raeburn 2008: $url = $dbref->{'src'};
1.533 raeburn 2009: if ($url =~ m{/(smppg|bulletinboard)$}) {
2010: my $prefix = $1;
2011: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2012: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2013: my $db_name;
2014: my $marker = (split(m{/},$url))[4];
2015: $marker=~s/\D//g;
2016: if ($dbref->{'src'} =~ m{/smppg$}) {
2017: $db_name =
2018: &Apache::lonsimplepage::get_db_name($url,$marker,
2019: $dbref->{'cdom'},
2020: $dbref->{'cnum'});
2021: } else {
2022: $db_name = 'bulletinpage_'.$marker;
2023: }
2024: my ($suffix,$freedlock,$error) =
2025: &Apache::lonnet::get_timebased_id($prefix,'num','templated',
2026: $coursedom,$coursenum,
2027: 'concat');
2028: if (!$suffix) {
2029: if ($prefix eq 'smppg') {
2030: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);
2031: } else {
1.565 bisitz 2032: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url);
1.533 raeburn 2033: }
2034: if ($error) {
2035: $errtext .= '<br />'.$error;
2036: }
2037: } else {
2038: #need to copy the db contents to a new one.
2039: my %contents=&Apache::lonnet::dump($db_name,
2040: $dbref->{'cdom'},
2041: $dbref->{'cnum'});
2042: if (exists($contents{'uploaded.photourl'})) {
2043: my $photo = $contents{'uploaded.photourl'};
2044: my ($subdir,$fname) =
2045: ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});
1.596 raeburn 2046: my $newphoto;
1.533 raeburn 2047: if ($fname ne '') {
2048: my $content = &Apache::lonnet::getfile($photo);
2049: unless ($content eq '-1') {
2050: $env{'form.'.$suffix.'.photourl'} = $content;
2051: $newphoto =
2052: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");
2053: delete($env{'form.'.$suffix.'.photourl'});
2054: }
2055: }
2056: if ($newphoto =~ m{^/uploaded/}) {
2057: $contents{'uploaded.photourl'} = $newphoto;
2058: }
2059: }
2060: $db_name =~ s{_\d*$ }{_$suffix}x;
2061: $result=&Apache::lonnet::put($db_name,\%contents,
2062: $coursedom,$coursenum);
2063: if ($result eq 'ok') {
2064: $url =~ s{/(\d*)/(smppg|bulletinboard)$}{/$suffix/$2}x;
2065: }
2066: }
2067: if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) {
1.559 raeburn 2068: $lockerrorsref->{$prefix} =
1.533 raeburn 2069: '<div class="LC_error">'.
2070: &mt('There was a problem removing a lockfile.');
2071: if ($prefix eq 'smppg') {
1.560 raeburn 2072: $lockerrorsref->{$prefix} .=
1.559 raeburn 2073: ' '.&mt('This will prevent creation of additional simple pages in this course.');
1.533 raeburn 2074: } else {
1.565 bisitz 2075: $lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional discussion boards in this course.');
1.533 raeburn 2076: }
1.560 raeburn 2077: $lockerrorsref->{$prefix} .= ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
2078: '<a href="/adm/helpdesk" target="_helpdesk">','</a>').
2079: '</div>';
1.533 raeburn 2080: }
2081: }
2082: } elsif ($url =~ m{/syllabus$}) {
2083: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2084: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2085: if (($dbref->{'cdom'} ne $coursedom) ||
2086: ($dbref->{'cnum'} ne $coursenum)) {
2087: my %contents=&Apache::lonnet::dump('syllabus',
2088: $dbref->{'cdom'},
2089: $dbref->{'cnum'});
2090: $result=&Apache::lonnet::put('syllabus',\%contents,
2091: $coursedom,$coursenum);
2092: }
2093: }
1.488 raeburn 2094: }
2095: }
1.533 raeburn 2096: return ($url,$result,$errtext);
1.488 raeburn 2097: }
2098:
1.597 raeburn 2099: sub copy_templated_files {
2100: my ($srcurl,$srcdom,$srcnum,$srcmapinfo,$coursedom,$coursenum,$template,$newidx,$newmapname) = @_;
2101: my ($srcfolder,$srcid,$srcwaspage) = split(/:/,$srcmapinfo);
2102: my $srccontainer = 'sequence';
2103: if ($srcwaspage) {
2104: $srccontainer = 'page';
2105: }
2106: my $srcsymb = "uploaded/$srcdom/$srcnum/$srcfolder.$srccontainer".
2107: '___'.$srcid.'___'.&Apache::lonnet::declutter($srcurl);
2108: my $srcprefix = $srcdom.'_'.$srcnum.'.'.$srcsymb;
2109: my %srcparms=&Apache::lonnet::dump('resourcedata',$srcdom,$srcnum,$srcprefix);
2110: my $newsymb = "uploaded/$coursedom/$coursenum/$newmapname".'___'.$newidx.'___lib/templates/'.
2111: $template.'.problem';
2112: my $newprefix = $coursedom.'_'.$coursenum.'.'.$newsymb;
2113: if ($template eq 'simpleproblem') {
2114: $srcprefix .= '.0.';
2115: my $weightprefix = $newprefix;
2116: $newprefix .= '.0.';
2117: my @simpleprobqtypes = qw(radio option string essay numerical);
2118: my $qtype=$srcparms{$srcprefix.'questiontype'};
2119: if (grep(/^\Q$qtype\E$/,@simpleprobqtypes)) {
2120: my %newdata;
2121: foreach my $type (@simpleprobqtypes) {
2122: if ($type eq $qtype) {
2123: $newdata{"$weightprefix.$type.weight"}=1;
2124: } else {
2125: $newdata{"$weightprefix.$type.weight"}=0;
2126: }
2127: }
2128: $newdata{$newprefix.'hiddenparts'} = '!'.$qtype;
2129: $newdata{$newprefix.'questiontext'} = $srcparms{$srcprefix.'questiontext'};
2130: $newdata{$newprefix.'hinttext'} = $srcparms{$srcprefix.'hinttext'};
2131: if ($qtype eq 'numerical') {
2132: $newdata{$newprefix.'numericalscript'} = $srcparms{$srcprefix.'numericalscript'};
2133: $newdata{$newprefix.'numericalanswer'} = $srcparms{$srcprefix.'numericalanswer'};
2134: $newdata{$newprefix.'numericaltolerance'} = $srcparms{$srcprefix.'numericaltolerance'};
2135: $newdata{$newprefix.'numericalsigfigs'} = $srcparms{$srcprefix.'numericalsigfigs'};
2136: } elsif (($qtype eq 'option') || ($qtype eq 'radio')) {
2137: my $maxfoils=$srcparms{$srcprefix.'maxfoils'};
2138: unless (defined($maxfoils)) { $maxfoils=10; }
2139: unless ($maxfoils=~/^\d+$/) { $maxfoils=10; }
2140: if ($maxfoils<=0) { $maxfoils=10; }
2141: my $randomize=$srcparms{$srcprefix.'randomize'};
2142: unless (defined($randomize)) { $randomize='yes'; }
2143: unless ($randomize eq 'no') { $randomize='yes'; }
2144: $newdata{$newprefix.'maxfoils'} = $maxfoils;
2145: $newdata{$newprefix.'randomize'} = $randomize;
2146: if ($qtype eq 'option') {
2147: $newdata{$newprefix.'options'} = $srcparms{$srcprefix.'options'};
2148: }
2149: for (my $i=1; $i<=10; $i++) {
2150: $newdata{$newprefix.'value'.$i} = $srcparms{$srcprefix.'value'.$i};
2151: $newdata{$newprefix.'position'.$i} = $srcparms{$srcprefix.'position'.$i};
2152: $newdata{$newprefix.'text'.$i} = $srcparms{$srcprefix.'text'.$i};
2153: }
2154:
2155: } elsif (($qtype eq 'option') || ($qtype eq 'radio')) {
2156: my $maxfoils=$srcparms{$srcprefix.'maxfoils'};
2157: unless (defined($maxfoils)) { $maxfoils=10; }
2158: unless ($maxfoils=~/^\d+$/) { $maxfoils=10; }
2159: if ($maxfoils<=0) { $maxfoils=10; }
2160: my $randomize=$srcparms{$srcprefix.'randomize'};
2161: unless (defined($randomize)) { $randomize='yes'; }
2162: unless ($randomize eq 'no') { $randomize='yes'; }
2163: $newdata{$newprefix.'maxfoils'} = $maxfoils;
2164: $newdata{$newprefix.'randomize'} = $randomize;
2165: if ($qtype eq 'option') {
2166: $newdata{$newprefix.'options'} = $srcparms{$srcprefix.'options'};
2167: }
2168: for (my $i=1; $i<=10; $i++) {
2169: $newdata{$newprefix.'value'.$i} = $srcparms{$srcprefix.'value'.$i};
2170: $newdata{$newprefix.'position'.$i} = $srcparms{$srcprefix.'position'.$i};
2171: $newdata{$newprefix.'text'.$i} = $srcparms{$srcprefix.'text'.$i};
2172: }
2173: } elsif ($qtype eq 'string') {
2174: $newdata{$newprefix.'stringanswer'} = $srcparms{$srcprefix.'stringanswer'};
2175: $newdata{$newprefix.'stringtype'} = $srcparms{$srcprefix.'stringtype'};
2176: }
2177: if (keys(%newdata)) {
2178: my $putres = &Apache::lonnet::cput('resourcedata',\%newdata,$coursedom,
2179: $coursenum);
2180: if ($putres eq 'ok') {
2181: &Apache::lonnet::devalidatecourseresdata($coursenum,$coursedom);
2182: }
2183: }
2184: }
2185: }
2186: }
2187:
1.329 droeschl 2188: sub uniqueness_check {
2189: my ($newurl) = @_;
2190: my $unique = 1;
2191: foreach my $res (@LONCAPA::map::order) {
2192: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2193: $url=&LONCAPA::map::qtescape($url);
2194: if ($newurl eq $url) {
2195: $unique = 0;
1.344 bisitz 2196: last;
1.329 droeschl 2197: }
2198: }
2199: return $unique;
2200: }
2201:
1.488 raeburn 2202: sub contained_map_check {
1.492 raeburn 2203: my ($url,$folder,$removefrommap,$removeparam,$addedmaps,$hierarchy,$titles,
2204: $allmaps) = @_;
1.488 raeburn 2205: my $content = &Apache::lonnet::getfile($url);
2206: unless ($content eq '-1') {
2207: my $parser = HTML::TokeParser->new(\$content);
2208: $parser->attr_encoded(1);
2209: while (my $token = $parser->get_token) {
2210: next if ($token->[0] ne 'S');
2211: if ($token->[1] eq 'resource') {
2212: next if ($token->[2]->{'type'} eq 'zombie');
2213: my $ressrc = $token->[2]->{'src'};
2214: if ($folder =~ /^supplemental/) {
2215: unless (&supp_pasteable($ressrc)) {
1.492 raeburn 2216: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.488 raeburn 2217: next;
2218: }
2219: }
1.492 raeburn 2220: if ($ressrc =~ m{^/(res|uploaded)/.+\.(sequence|page)$}) {
2221: if ($1 eq 'uploaded') {
2222: $hierarchy->{$url}{$token->[2]->{'id'}} = $ressrc;
2223: $titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'};
1.488 raeburn 2224: } else {
1.492 raeburn 2225: if ($allmaps->{$ressrc}) {
1.529 raeburn 2226: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.492 raeburn 2227: } elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') {
2228: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2229: } else {
2230: $addedmaps->{$ressrc} = [$url];
2231: }
1.488 raeburn 2232: }
1.492 raeburn 2233: &contained_map_check($ressrc,$folder,$removefrommap,$removeparam,
2234: $addedmaps,$hierarchy,$titles,$allmaps);
1.488 raeburn 2235: }
1.492 raeburn 2236: } elsif ($token->[1] eq 'param') {
1.488 raeburn 2237: if ($folder =~ /^supplemental/) {
1.492 raeburn 2238: if (ref($removeparam->{$url}{$token->[2]->{'to'}}) eq 'ARRAY') {
2239: push(@{$removeparam->{$url}{$token->[2]->{'to'}}},$token->[2]->{'name'});
2240: } else {
2241: $removeparam->{$url}{$token->[2]->{'to'}} = [$token->[2]->{'name'}];
2242: }
1.488 raeburn 2243: }
2244: }
2245: }
2246: }
2247: return;
2248: }
2249:
2250: sub url_paste_fixups {
1.533 raeburn 2251: my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$fromcdom,$fromcnum,$allmaps,
2252: $rewrites,$retitles,$copies,$dbcopies,$zombies,$params,$mapmoves,
1.597 raeburn 2253: $mapchanges,$tomove,$newsubdir,$newurls,$resdatacopy) = @_;
1.491 raeburn 2254: my $checktitle;
2255: if (($prefixchg) &&
1.492 raeburn 2256: ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) {
1.491 raeburn 2257: $checktitle = 1;
2258: }
1.492 raeburn 2259: my $skip;
2260: if ($oldurl =~ m{^\Q/uploaded/$cdom/$cnum/\E(default|supplemental)(_?\d*)\.(?:page|sequence)$}) {
2261: my $mapid = $1.$2;
2262: if ($tomove->{$mapid}) {
2263: $skip = 1;
2264: }
2265: }
1.491 raeburn 2266: my $file = &Apache::lonnet::getfile($oldurl);
1.488 raeburn 2267: return if ($file eq '-1');
2268: my $parser = HTML::TokeParser->new(\$file);
2269: $parser->attr_encoded(1);
1.491 raeburn 2270: my $changed = 0;
1.488 raeburn 2271: while (my $token = $parser->get_token) {
2272: next if ($token->[0] ne 'S');
2273: if ($token->[1] eq 'resource') {
2274: my $ressrc = $token->[2]->{'src'};
2275: next if ($ressrc eq '');
1.491 raeburn 2276: my $id = $token->[2]->{'id'};
1.492 raeburn 2277: my $title = $token->[2]->{'title'};
1.491 raeburn 2278: if ($checktitle) {
2279: if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1.532 raeburn 2280: $retitles->{$oldurl}{$id} = $ressrc;
1.491 raeburn 2281: }
2282: }
1.488 raeburn 2283: next if ($token->[2]->{'type'} eq 'external');
2284: if ($token->[2]->{'type'} eq 'zombie') {
1.492 raeburn 2285: next if ($skip);
1.532 raeburn 2286: $zombies->{$oldurl}{$id} = $ressrc;
1.491 raeburn 2287: $changed = 1;
2288: } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1.492 raeburn 2289: my $srcdom = $1;
2290: my $srcnum = $2;
1.488 raeburn 2291: my $rem = $3;
1.492 raeburn 2292: my $newurl;
2293: my $mapname;
2294: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
2295: my $prefix = $1;
2296: $mapname = $prefix.$2;
2297: if ($tomove->{$mapname}) {
1.533 raeburn 2298: &url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,
2299: $srcdom,$srcnum,$allmaps,$rewrites,
2300: $retitles,$copies,$dbcopies,$zombies,
2301: $params,$mapmoves,$mapchanges,$tomove,
1.597 raeburn 2302: $newsubdir,$newurls,$resdatacopy);
1.492 raeburn 2303: next;
2304: } else {
2305: ($newurl,my $error) =
2306: &get_newmap_url($ressrc,$folder,$prefixchg,$cdom,$cnum,
2307: $srcdom,$srcnum,\$title,$allmaps,$newurls);
2308: if ($newurl =~ /(?:default|supplemental)_(\d+)\.(?:sequence|page)$/) {
2309: $newsubdir->{$ressrc} = $1;
2310: }
2311: if ($error) {
2312: next;
2313: }
2314: }
2315: }
2316: if (($srcdom ne $cdom) || ($srcnum ne $cnum) || ($prefixchg) ||
2317: ($mapchanges->{$oldurl}) || (($newurl ne '') && ($newurl ne $oldurl))) {
2318:
1.488 raeburn 2319: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
1.532 raeburn 2320: $rewrites->{$oldurl}{$id} = $ressrc;
1.491 raeburn 2321: $mapchanges->{$ressrc} = 1;
1.533 raeburn 2322: unless (&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,
2323: $cnum,$srcdom,$srcnum,$allmaps,
2324: $rewrites,$retitles,$copies,$dbcopies,
2325: $zombies,$params,$mapmoves,$mapchanges,
1.597 raeburn 2326: $tomove,$newsubdir,$newurls,$resdatacopy)) {
1.491 raeburn 2327: $mapmoves->{$ressrc} = 1;
2328: }
2329: $changed = 1;
1.488 raeburn 2330: } else {
1.532 raeburn 2331: $rewrites->{$oldurl}{$id} = $ressrc;
1.488 raeburn 2332: $copies->{$oldurl}{$ressrc} = $id;
1.491 raeburn 2333: $changed = 1;
1.488 raeburn 2334: }
2335: }
1.533 raeburn 2336: } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/.+$}) {
2337: next if ($skip);
1.492 raeburn 2338: my $srcdom = $1;
2339: my $srcnum = $2;
2340: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.532 raeburn 2341: $rewrites->{$oldurl}{$id} = $ressrc;
1.533 raeburn 2342: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2343: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2344: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
2345: $changed = 1;
2346: }
2347: } elsif ($ressrc =~ m{^/adm/$match_domain/$match_username/\d+/(smppg|bulletinboard)$}) {
2348: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum) ||
2349: ($env{'form.docs.markedcopy_options'} ne 'move')) {
2350: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2351: $dbcopies->{$oldurl}{$id}{'cdom'} = $fromcdom;
2352: $dbcopies->{$oldurl}{$id}{'cnum'} = $fromcnum;
1.491 raeburn 2353: $changed = 1;
1.488 raeburn 2354: }
1.597 raeburn 2355: } elsif ($ressrc eq '/res/lib/templates/simpleproblem.problem') {
2356: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum)) {
2357: $resdatacopy->{$oldurl}{$id}{'src'} = $ressrc;
2358: $resdatacopy->{$oldurl}{$id}{'cdom'} = $fromcdom;
2359: $resdatacopy->{$oldurl}{$id}{'cnum'} = $fromcnum;
2360: }
1.488 raeburn 2361: } elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) {
1.492 raeburn 2362: next if ($skip);
2363: my $srcdom = $1;
2364: my $srcnum = $2;
2365: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.533 raeburn 2366: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2367: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2368: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
1.491 raeburn 2369: $changed = 1;
1.488 raeburn 2370: }
2371: }
2372: } elsif ($token->[1] eq 'param') {
1.492 raeburn 2373: next if ($skip);
1.488 raeburn 2374: my $to = $token->[2]->{'to'};
2375: if ($to ne '') {
2376: if (ref($params->{$oldurl}{$to}) eq 'ARRAY') {
1.492 raeburn 2377: push(@{$params->{$oldurl}{$to}},$token->[2]->{'name'});
1.488 raeburn 2378: } else {
2379: @{$params->{$oldurl}{$to}} = ($token->[2]->{'name'});
2380: }
2381: }
2382: }
2383: }
1.491 raeburn 2384: return $changed;
1.488 raeburn 2385: }
2386:
2387: sub apply_fixups {
1.529 raeburn 2388: my ($folder,$is_map,$cdom,$cnum,$errors,$updated,$info,$moves,$prefixchg,
2389: $oldurl,$url,$caller) = @_;
2390: my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles,
1.533 raeburn 2391: %params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs,
1.597 raeburn 2392: %resdatacopy,%lockerrors,$lockmsg);
1.529 raeburn 2393: if (ref($updated) eq 'HASH') {
2394: if (ref($updated->{'rewrites'}) eq 'HASH') {
2395: %rewrites = %{$updated->{'rewrites'}};
2396: }
2397: if (ref($updated->{'zombies'}) eq 'HASH') {
2398: %zombies = %{$updated->{'zombies'}};
2399: }
2400: if (ref($updated->{'removefrommap'}) eq 'HASH') {
2401: %removefrommap = %{$updated->{'removefrommap'}};
2402: }
2403: if (ref($updated->{'removeparam'}) eq 'HASH') {
2404: %removeparam = %{$updated->{'removeparam'}};
2405: }
2406: if (ref($updated->{'dbcopies'}) eq 'HASH') {
2407: %dbcopies = %{$updated->{'dbcopies'}};
2408: }
2409: if (ref($updated->{'retitles'}) eq 'HASH') {
2410: %retitles = %{$updated->{'retitles'}};
2411: }
1.597 raeburn 2412: if (ref($updated->{'resdatacopy'}) eq 'HASH') {
2413: %resdatacopy = %{$updated->{'resdatacopy'}};
2414: }
1.529 raeburn 2415: }
2416: if (ref($info) eq 'HASH') {
2417: if (ref($info->{'newsubdir'}) eq 'HASH') {
2418: %newsubdir = %{$info->{'newsubdir'}};
2419: }
2420: if (ref($info->{'params'}) eq 'HASH') {
2421: %params = %{$info->{'params'}};
2422: }
2423: if (ref($info->{'before'}) eq 'HASH') {
2424: %before = %{$info->{'before'}};
2425: }
2426: if (ref($info->{'after'}) eq 'HASH') {
2427: %after = %{$info->{'after'}};
2428: }
2429: }
2430: if (ref($moves) eq 'HASH') {
2431: if (ref($moves->{'copies'}) eq 'HASH') {
2432: %copies = %{$moves->{'copies'}};
2433: }
2434: if (ref($moves->{'docmoves'}) eq 'HASH') {
2435: %docmoves = %{$moves->{'docmoves'}};
2436: }
2437: if (ref($moves->{'mapmoves'}) eq 'HASH') {
2438: %mapmoves = %{$moves->{'mapmoves'}};
2439: }
2440: }
2441: foreach my $key (keys(%copies),keys(%docmoves)) {
1.491 raeburn 2442: my @allcopies;
1.529 raeburn 2443: if (exists($copies{$key})) {
2444: if (ref($copies{$key}) eq 'HASH') {
2445: my %added;
2446: foreach my $innerkey (keys(%{$copies{$key}})) {
2447: if (($innerkey ne '') && (!$added{$innerkey})) {
2448: push(@allcopies,$innerkey);
2449: $added{$innerkey} = 1;
2450: }
1.491 raeburn 2451: }
1.529 raeburn 2452: undef(%added);
1.491 raeburn 2453: }
2454: }
2455: if ($key eq $oldurl) {
1.529 raeburn 2456: if ((exists($docmoves{$key}))) {
1.532 raeburn 2457: unless (grep(/^\Q$oldurl\E$/,@allcopies)) {
1.491 raeburn 2458: push(@allcopies,$oldurl);
2459: }
2460: }
2461: }
2462: if (@allcopies > 0) {
2463: foreach my $item (@allcopies) {
1.492 raeburn 2464: my ($relpath,$oldsubdir,$fname) =
2465: ($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(default|\d+)/.*/)([^/]+)$});
1.491 raeburn 2466: if ($fname ne '') {
2467: my $content = &Apache::lonnet::getfile($item);
2468: unless ($content eq '-1') {
2469: my $storefn;
1.529 raeburn 2470: if (($key eq $oldurl) && (exists($docmoves{$key}))) {
2471: $storefn = $docmoves{$key};
1.491 raeburn 2472: } else {
2473: $storefn = $relpath;
2474: $storefn =~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 2475: if ($prefixchg && $before{'doc'} && $after{'doc'}) {
2476: $storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/;
1.491 raeburn 2477: }
1.529 raeburn 2478: if ($newsubdir{$key}) {
1.532 raeburn 2479: $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}/#;
1.491 raeburn 2480: }
2481: }
2482: ©_dependencies($item,$storefn,$relpath,$errors,\$content);
2483: my $copyurl =
2484: &Apache::lonclonecourse::writefile($env{'request.course.id'},
2485: $storefn.$fname,$content);
2486: if ($copyurl eq '/adm/notfound.html') {
1.529 raeburn 2487: if (exists($docmoves{$oldurl})) {
1.491 raeburn 2488: return &mt('Paste failed: an error occurred copying the file.');
2489: } elsif (ref($errors) eq 'HASH') {
2490: $errors->{$item} = 1;
1.489 raeburn 2491: }
2492: }
1.488 raeburn 2493: }
2494: }
1.491 raeburn 2495: }
2496: }
2497: }
1.529 raeburn 2498: foreach my $key (keys(%mapmoves)) {
1.491 raeburn 2499: my $storefn=$key;
2500: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 2501: if ($prefixchg && $before{'map'} && $after{'map'}) {
2502: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.491 raeburn 2503: }
1.529 raeburn 2504: if ($newsubdir{$key}) {
2505: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.492 raeburn 2506: }
1.491 raeburn 2507: my $mapcontent = &Apache::lonnet::getfile($key);
2508: if ($mapcontent eq '-1') {
2509: if (ref($errors) eq 'HASH') {
2510: $errors->{$key} = 1;
2511: }
2512: } else {
2513: my $newmap =
2514: &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
2515: $mapcontent);
2516: if ($newmap eq '/adm/notfound.html') {
2517: if (ref($errors) eq 'HASH') {
2518: $errors->{$key} = 1;
1.489 raeburn 2519: }
1.488 raeburn 2520: }
2521: }
2522: }
1.491 raeburn 2523: my %updates;
2524: if ($is_map) {
1.529 raeburn 2525: if (ref($updated) eq 'HASH') {
2526: foreach my $type (keys(%{$updated})) {
2527: if (ref($updated->{$type}) eq 'HASH') {
2528: foreach my $key (keys(%{$updated->{$type}})) {
2529: $updates{$key} = 1;
2530: }
2531: }
2532: }
1.491 raeburn 2533: }
2534: foreach my $key (keys(%updates)) {
1.492 raeburn 2535: my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb);
1.529 raeburn 2536: if (ref($rewrites{$key}) eq 'HASH') {
2537: %torewrite = %{$rewrites{$key}};
1.491 raeburn 2538: }
1.529 raeburn 2539: if (ref($retitles{$key}) eq 'HASH') {
2540: %toretitle = %{$retitles{$key}};
1.491 raeburn 2541: }
1.529 raeburn 2542: if (ref($removefrommap{$key}) eq 'HASH') {
2543: %toremove = %{$removefrommap{$key}};
1.491 raeburn 2544: }
1.529 raeburn 2545: if (ref($removeparam{$key}) eq 'HASH') {
2546: %remparam = %{$removeparam{$key}};
1.492 raeburn 2547: }
1.529 raeburn 2548: if (ref($zombies{$key}) eq 'HASH') {
2549: %zombie = %{$zombies{$key}};
1.491 raeburn 2550: }
1.529 raeburn 2551: if (ref($dbcopies{$key}) eq 'HASH') {
1.533 raeburn 2552: foreach my $idx (keys(%{$dbcopies{$key}})) {
2553: if (ref($dbcopies{$key}{$idx}) eq 'HASH') {
2554: my ($newurl,$result,$errtext) =
2555: &dbcopy($dbcopies{$key}{$idx},$cdom,$cnum,\%lockerrors);
2556: if ($result eq 'ok') {
2557: $newdb{$idx} = $newurl;
2558: } elsif (ref($errors) eq 'HASH') {
2559: $errors->{$key} = 1;
2560: }
2561: push(@msgs,$errtext);
2562: }
1.491 raeburn 2563: }
2564: }
1.597 raeburn 2565: if (ref($resdatacopy{$key}) eq 'HASH') {
2566: if ($newsubdir{$key}) {
2567:
2568: }
2569: foreach my $idx (keys(%{$resdatacopy{$key}})) {
2570: if (ref($resdatacopy{$key}{$idx}) eq 'HASH') {
2571: my $srcurl = $resdatacopy{$key}{$idx}{'src'};
2572: if ($srcurl =~ m{^/res/lib/templates/(\w+)\.problem$}) {
2573: my $template = $1;
2574: if (($resdatacopy{$key}{$idx}{'cdom'} =~ /^$match_domain$/) &&
2575: ($resdatacopy{$key}{$idx}{'cnum'} =~ /^$match_courseid$/)) {
2576: my $srcdom = $resdatacopy{$key}{$idx}{'cdom'};
2577: my $srcnum = $resdatacopy{$key}{$idx}{'cnum'};
2578: my ($newmapname) = ($key =~ m{/([^/]+)$});
2579: my ($srcfolder,$srccontainer) = split(/\./,$newmapname);
2580: my $srcmapinfo = $srcfolder.':'.$idx;
2581: if ($srccontainer eq 'page') {
2582: $srcmapinfo .= ':1';
2583: }
2584: if ($newsubdir{$key}) {
2585: $newmapname =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
2586: }
2587: ©_templated_files($srcurl,$srcdom,$srcnum,$srcmapinfo,$cdom,
2588: $cnum,$template,$idx,$newmapname);
2589: }
2590: }
2591: }
2592: }
2593: }
1.529 raeburn 2594: if (ref($params{$key}) eq 'HASH') {
2595: %currparam = %{$params{$key}};
1.492 raeburn 2596: }
2597: my ($errtext,$fatal) = &LONCAPA::map::mapread($key);
2598: if ($fatal) {
1.533 raeburn 2599: return ($errtext);
1.492 raeburn 2600: }
2601: for (my $i=0; $i<@LONCAPA::map::zombies; $i++) {
2602: if (defined($LONCAPA::map::zombies[$i])) {
2603: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::zombies[$i]);
1.532 raeburn 2604: if ($zombie{$i} eq $src) {
1.492 raeburn 2605: undef($LONCAPA::map::zombies[$i]);
2606: }
2607: }
2608: }
1.529 raeburn 2609: for (my $i=0; $i<@LONCAPA::map::order; $i++) {
2610: my $idx = $LONCAPA::map::order[$i];
2611: if (defined($LONCAPA::map::resources[$idx])) {
1.492 raeburn 2612: my $changed;
1.529 raeburn 2613: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]);
1.538 raeburn 2614: if ((exists($toremove{$idx})) &&
2615: ($toremove{$idx} eq &LONCAPA::map::qtescape($src))) {
1.492 raeburn 2616: splice(@LONCAPA::map::order,$i,1);
1.529 raeburn 2617: if (ref($currparam{$idx}) eq 'ARRAY') {
2618: foreach my $name (@{$currparam{$idx}}) {
2619: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
1.492 raeburn 2620: }
2621: }
2622: next;
2623: }
2624: my $origsrc = $src;
1.532 raeburn 2625: if ((exists($toretitle{$idx})) && ($toretitle{$idx} eq $src)) {
1.492 raeburn 2626: if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
2627: $changed = 1;
1.491 raeburn 2628: }
1.492 raeburn 2629: }
1.532 raeburn 2630: if ((exists($torewrite{$idx})) && ($torewrite{$idx} eq $src)) {
1.492 raeburn 2631: $src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
2632: if ($origsrc =~ m{^/uploaded/}) {
1.529 raeburn 2633: if ($prefixchg && $before{'map'} && $after{'map'}) {
1.492 raeburn 2634: if ($src =~ /\.(page|sequence)$/) {
1.529 raeburn 2635: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'map'}\E#$1$after{'map'}#;
1.492 raeburn 2636: } else {
1.529 raeburn 2637: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
1.488 raeburn 2638: }
1.491 raeburn 2639: }
1.532 raeburn 2640: if ($origsrc =~ /\.(page|sequence)$/) {
2641: if ($newsubdir{$origsrc}) {
1.529 raeburn 2642: $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir{$origsrc}#;
1.491 raeburn 2643: }
1.532 raeburn 2644: } elsif ($newsubdir{$key}) {
2645: $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$key}#;
1.488 raeburn 2646: }
2647: }
1.492 raeburn 2648: $changed = 1;
1.533 raeburn 2649: } elsif ($newdb{$idx} ne '') {
2650: $src = $newdb{$idx};
1.492 raeburn 2651: $changed = 1;
2652: }
2653: if ($changed) {
1.538 raeburn 2654: $LONCAPA::map::resources[$idx] = join(':',($title,&LONCAPA::map::qtunescape($src),$ext,$type));
1.492 raeburn 2655: }
2656: }
2657: }
2658: foreach my $idx (keys(%remparam)) {
2659: if (ref($remparam{$idx}) eq 'ARRAY') {
2660: foreach my $name (@{$remparam{$idx}}) {
2661: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
1.491 raeburn 2662: }
2663: }
2664: }
1.533 raeburn 2665: if (values(%lockerrors) > 0) {
2666: $lockmsg = join('<br />',values(%lockerrors));
2667: }
1.491 raeburn 2668: my $storefn;
2669: if ($key eq $oldurl) {
2670: $storefn = $url;
2671: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
2672: } else {
2673: $storefn = $key;
2674: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 2675: if ($prefixchg && $before{'map'} && $after{'map'}) {
2676: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.491 raeburn 2677: }
1.529 raeburn 2678: if ($newsubdir{$key}) {
2679: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.492 raeburn 2680: }
1.491 raeburn 2681: }
1.492 raeburn 2682: my $report;
2683: if ($folder !~ /^supplemental/) {
2684: $report = 1;
2685: }
1.527 raeburn 2686: (my $outtext,$errtext) =
1.492 raeburn 2687: &LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report);
2688: if ($errtext) {
1.529 raeburn 2689: if ($caller eq 'paste') {
1.533 raeburn 2690: return (&mt('Paste failed: an error occurred saving the folder or page.'));
1.529 raeburn 2691: }
1.491 raeburn 2692: }
2693: }
2694: }
1.533 raeburn 2695: return ('ok',\@msgs,$lockmsg);
1.491 raeburn 2696: }
2697:
2698: sub copy_dependencies {
2699: my ($item,$storefn,$relpath,$errors,$contentref) = @_;
2700: my $content;
2701: if (ref($contentref)) {
2702: $content = $$contentref;
2703: } else {
2704: $content = &Apache::lonnet::getfile($item);
2705: }
2706: unless ($content eq '-1') {
2707: my $mm = new File::MMagic;
2708: my $mimetype = $mm->checktype_contents($content);
2709: if ($mimetype eq 'text/html') {
2710: my (%allfiles,%codebase,$state);
2711: my $res = &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,\$content);
2712: if ($res eq 'ok') {
2713: my ($numexisting,$numpathchanges,$existing);
2714: (undef,$numexisting,$numpathchanges,$existing) =
2715: &Apache::loncommon::ask_for_embedded_content(
2716: '/adm/coursedocs',$state,\%allfiles,\%codebase,
2717: {'error_on_invalid_names' => 1,
2718: 'ignore_remote_references' => 1,
2719: 'docs_url' => $item,
2720: 'context' => 'paste'});
2721: if ($numexisting > 0) {
2722: if (ref($existing) eq 'HASH') {
2723: foreach my $dep (keys(%{$existing})) {
2724: my $depfile = $dep;
2725: unless ($depfile =~ m{^\Q$relpath\E}) {
2726: $depfile = $relpath.$dep;
2727: }
2728: my $depcontent = &Apache::lonnet::getfile($depfile);
2729: unless ($depcontent eq '-1') {
2730: my $storedep = $dep;
2731: $storedep =~ s{^\Q$relpath\E}{};
2732: my $dep_url =
2733: &Apache::lonclonecourse::writefile(
2734: $env{'request.course.id'},
2735: $storefn.$storedep,$depcontent);
2736: if ($dep_url eq '/adm/notfound.html') {
2737: if (ref($errors) eq 'HASH') {
2738: $errors->{$depfile} = 1;
2739: }
2740: } else {
2741: ©_dependencies($depfile,$storefn,$relpath,$errors,\$depcontent);
2742: }
2743: }
2744: }
1.488 raeburn 2745: }
2746: }
2747: }
2748: }
2749: }
2750: return;
2751: }
2752:
1.329 droeschl 2753: my %parameter_type = ( 'randompick' => 'int_pos',
2754: 'hiddenresource' => 'string_yesno',
2755: 'encrypturl' => 'string_yesno',
2756: 'randomorder' => 'string_yesno',);
2757: my $valid_parameters_re = join('|',keys(%parameter_type));
2758: # set parameters
2759: sub update_parameter {
1.537 raeburn 2760: if ($env{'form.changeparms'} eq 'all') {
2761: my (@allidx,@allmapidx,%allchecked,%currchecked);
2762: %allchecked = (
2763: 'hiddenresource' => {},
2764: 'encrypturl' => {},
2765: 'randompick' => {},
2766: 'randomorder' => {},
2767: );
2768: foreach my $which (keys(%allchecked)) {
2769: $env{'form.all'.$which} =~ s/,$//;
2770: if ($which eq 'randompick') {
2771: foreach my $item (split(/,/,$env{'form.all'.$which})) {
2772: my ($res,$value) = split(/:/,$item);
2773: if ($value =~ /^\d+$/) {
2774: $allchecked{$which}{$res} = $value;
2775: }
2776: }
2777: } else {
1.539 raeburn 2778: if ($env{'form.all'.$which}) {
2779: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.all'.$which});
2780: }
1.537 raeburn 2781: }
2782: }
2783: my $haschanges = 0;
2784: foreach my $res (@LONCAPA::map::order) {
2785: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2786: $name=&LONCAPA::map::qtescape($name);
2787: $url=&LONCAPA::map::qtescape($url);
2788: next unless ($name && $url);
2789: my $is_map;
2790: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
2791: $is_map = 1;
2792: }
2793: foreach my $which (keys(%allchecked)) {
2794: if (($which eq 'randompick' || $which eq 'randomorder')) {
2795: next if (!$is_map);
2796: }
2797: my $oldvalue = 0;
2798: my $newvalue = 0;
2799: if ($allchecked{$which}{$res}) {
2800: $newvalue = $allchecked{$which}{$res};
2801: }
2802: my $current = (&LONCAPA::map::getparameter($res,'parameter_'.$which))[0];
2803: if ($which eq 'randompick') {
2804: if ($current =~ /^(\d+)$/) {
2805: $oldvalue = $1;
2806: }
2807: } else {
2808: if ($current =~ /^yes$/i) {
2809: $oldvalue = 1;
2810: }
2811: }
2812: if ($oldvalue ne $newvalue) {
2813: $haschanges = 1;
2814: if ($newvalue) {
2815: my $storeval = 'yes';
2816: if ($which eq 'randompick') {
2817: $storeval = $newvalue;
2818: }
2819: &LONCAPA::map::storeparameter($res,'parameter_'.$which,
2820: $storeval,
2821: $parameter_type{$which});
2822: &remember_parms($res,$which,'set',$storeval);
2823: } elsif ($oldvalue) {
2824: &LONCAPA::map::delparameter($res,'parameter_'.$which);
2825: &remember_parms($res,$which,'del');
2826: }
2827: }
2828: }
2829: }
2830: return $haschanges;
2831: } else {
1.588 raeburn 2832: my $haschanges = 0;
2833: return $haschanges if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
1.329 droeschl 2834:
1.537 raeburn 2835: my $which = $env{'form.changeparms'};
2836: my $idx = $env{'form.setparms'};
1.588 raeburn 2837: my $oldvalue = 0;
2838: my $newvalue = 0;
2839: my $current = (&LONCAPA::map::getparameter($idx,'parameter_'.$which))[0];
2840: if ($which eq 'randompick') {
2841: if ($current =~ /^(\d+)$/) {
2842: $oldvalue = $1;
2843: }
2844: } elsif ($current =~ /^yes$/i) {
2845: $oldvalue = 1;
2846: }
1.537 raeburn 2847: if ($env{'form.'.$which.'_'.$idx}) {
1.588 raeburn 2848: $newvalue = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx}
2849: : 1;
2850: }
2851: if ($oldvalue ne $newvalue) {
2852: $haschanges = 1;
2853: if ($newvalue) {
2854: my $storeval = 'yes';
2855: if ($which eq 'randompick') {
2856: $storeval = $newvalue;
2857: }
2858: &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $storeval,
2859: $parameter_type{$which});
2860: &remember_parms($idx,$which,'set',$storeval);
2861: } else {
2862: &LONCAPA::map::delparameter($idx,'parameter_'.$which);
2863: &remember_parms($idx,$which,'del');
2864: }
1.537 raeburn 2865: }
1.588 raeburn 2866: return $haschanges;
1.329 droeschl 2867: }
2868: }
2869:
2870: sub handle_edit_cmd {
2871: my ($coursenum,$coursedom) =@_;
1.543 raeburn 2872: if ($env{'form.cmd'} eq '') {
2873: return 0;
2874: }
1.329 droeschl 2875: my ($cmd,$idx)=split('_',$env{'form.cmd'});
2876:
2877: my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
2878: my ($title, $url, @rrest) = split(':', $ratstr);
2879:
1.538 raeburn 2880: if ($cmd eq 'remove') {
1.329 droeschl 2881: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
1.463 www 2882: ($url!~/$LONCAPA::assess_page_seq_re/)) {
1.329 droeschl 2883: &Apache::lonnet::removeuploadedurl($url);
2884: } else {
2885: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
2886: }
2887: splice(@LONCAPA::map::order, $idx, 1);
2888:
2889: } elsif ($cmd eq 'cut') {
2890: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
2891: splice(@LONCAPA::map::order, $idx, 1);
2892:
1.344 bisitz 2893: } elsif ($cmd eq 'up'
1.329 droeschl 2894: && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
2895: @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
2896:
2897: } elsif ($cmd eq 'down'
2898: && defined($LONCAPA::map::order[$idx+1])) {
2899: @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
2900:
2901: } elsif ($cmd eq 'rename') {
2902: my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
2903: if ($comment=~/\S/) {
2904: $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
2905: $comment.':'.join(':', $url, @rrest);
2906: }
2907: # Devalidate title cache
2908: my $renamed_url=&LONCAPA::map::qtescape($url);
2909: &Apache::lonnet::devalidate_title_cache($renamed_url);
1.538 raeburn 2910:
1.329 droeschl 2911: } else {
2912: return 0;
2913: }
2914: return 1;
2915: }
2916:
2917: sub editor {
1.458 raeburn 2918: my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
1.598 raeburn 2919: $supplementalflag,$orderhash,$iconpath,$pathitem,$ltitoolsref)=@_;
1.519 raeburn 2920: my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
1.510 raeburn 2921: if ($allowed) {
1.519 raeburn 2922: (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
2923: $is_random_order,$container) =
1.510 raeburn 2924: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
2925: $r->print($breadcrumbtrail);
1.519 raeburn 2926: } elsif ($env{'form.folderpath'} =~ /\:1$/) {
2927: $container = 'page';
2928: } else {
2929: $container = 'sequence';
1.510 raeburn 2930: }
1.484 raeburn 2931:
1.525 raeburn 2932: my $jumpto;
2933:
2934: unless ($supplementalflag) {
1.546 raeburn 2935: $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
1.525 raeburn 2936: }
1.484 raeburn 2937:
2938: unless ($allowed) {
2939: $randompick = -1;
2940: }
2941:
1.329 droeschl 2942: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
2943: $folder.'.'.$container);
2944: return $errtext if ($fatal);
2945:
2946: if ($#LONCAPA::map::order<1) {
2947: my $idx=&LONCAPA::map::getresidx();
2948: if ($idx<=0) { $idx=1; }
2949: $LONCAPA::map::order[0]=$idx;
2950: $LONCAPA::map::resources[$idx]='';
2951: }
1.364 bisitz 2952:
1.329 droeschl 2953: # ------------------------------------------------------------ Process commands
2954:
2955: # ---------------- if they are for this folder and user allowed to make changes
2956: if (($allowed) && ($env{'form.folder'} eq $folder)) {
2957: # set parameters and change order
2958: &snapshotbefore();
2959:
2960: if (&update_parameter()) {
1.588 raeburn 2961: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1.329 droeschl 2962: return $errtext if ($fatal);
2963: }
2964:
2965: if ($env{'form.newpos'} && $env{'form.currentpos'}) {
2966: # change order
2967: my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
2968: splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
2969:
2970: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
2971: return $errtext if ($fatal);
2972: }
1.364 bisitz 2973:
1.329 droeschl 2974: if ($env{'form.pastemarked'}) {
1.491 raeburn 2975: my %paste_errors;
1.533 raeburn 2976: my ($paste_res,$save_error,$pastemsgarray,$lockerror) =
1.492 raeburn 2977: &do_paste_from_buffer($coursenum,$coursedom,$folder,$container,
2978: \%paste_errors);
1.541 raeburn 2979: if (ref($pastemsgarray) eq 'ARRAY') {
2980: if (@{$pastemsgarray} > 0) {
2981: $r->print('<p class="LC_info">'.
2982: join('<br />',@{$pastemsgarray}).
1.533 raeburn 2983: '</p>');
2984: }
1.541 raeburn 2985: }
2986: if ($lockerror) {
2987: $r->print('<p class="LC_error">'.
2988: $lockerror.
2989: '</p>');
2990: }
2991: if ($save_error ne '') {
2992: return $save_error;
2993: }
2994: if ($paste_res) {
2995: my %errortext = &Apache::lonlocal::texthash (
2996: fail => 'Storage of folder contents failed',
2997: failread => 'Reading folder contents failed',
2998: failstore => 'Storage of folder contents failed',
2999: );
3000: if ($errortext{$paste_res}) {
3001: $r->print('<p class="LC_error">'.$errortext{$paste_res}.'</p>');
1.492 raeburn 3002: }
1.329 droeschl 3003: }
1.491 raeburn 3004: if (keys(%paste_errors) > 0) {
1.538 raeburn 3005: $r->print('<p class="LC_warning">'."\n".
1.491 raeburn 3006: &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".
3007: '<ul>'."\n");
3008: foreach my $key (sort(keys(%paste_errors))) {
3009: $r->print('<li>'.$key.'</li>'."\n");
3010: }
3011: $r->print('</ul></p>'."\n");
3012: }
1.538 raeburn 3013: } elsif ($env{'form.clearmarked'}) {
3014: my $output = &do_buffer_empty();
3015: if ($output) {
3016: $r->print('<p class="LC_info">'.$output.'</p>');
3017: }
3018: }
1.329 droeschl 3019:
3020: $r->print($upload_output);
3021:
1.538 raeburn 3022: # Rename, cut, copy or remove a single resource
1.602 ! raeburn 3023: if (&handle_edit_cmd($coursenum,$coursedom)) {
1.492 raeburn 3024: my $contentchg;
1.592 raeburn 3025: if ($env{'form.cmd'} =~ m{^(remove|cut)_}) {
1.492 raeburn 3026: $contentchg = 1;
3027: }
3028: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);
1.329 droeschl 3029: return $errtext if ($fatal);
3030: }
1.538 raeburn 3031:
3032: # Cut, copy and/or remove multiple resources
3033: if ($env{'form.multichange'}) {
3034: my %allchecked = (
3035: cut => {},
3036: remove => {},
3037: );
3038: my $needsupdate;
3039: foreach my $which (keys(%allchecked)) {
3040: $env{'form.multi'.$which} =~ s/,$//;
3041: if ($env{'form.multi'.$which}) {
3042: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.multi'.$which});
3043: if (ref($allchecked{$which}) eq 'HASH') {
3044: $needsupdate += scalar(keys(%{$allchecked{$which}}));
3045: }
3046: }
3047: }
3048: if ($needsupdate) {
3049: my $haschanges = 0;
3050: my %curr_groups = &Apache::longroup::coursegroups();
3051: my $total = scalar(@LONCAPA::map::order) - 1;
3052: for (my $i=$total; $i>=0; $i--) {
3053: my $res = $LONCAPA::map::order[$i];
3054: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3055: $name=&LONCAPA::map::qtescape($name);
3056: $url=&LONCAPA::map::qtescape($url);
1.586 droeschl 3057: next unless $url;
1.538 raeburn 3058: my %denied =
3059: &action_restrictions($coursenum,$coursedom,$url,
3060: $env{'form.folderpath'},\%curr_groups);
3061: foreach my $which (keys(%allchecked)) {
3062: next if ($denied{$which});
3063: next unless ($allchecked{$which}{$res});
3064: if ($which eq 'remove') {
3065: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
3066: ($url!~/$LONCAPA::assess_page_seq_re/)) {
3067: &Apache::lonnet::removeuploadedurl($url);
3068: } else {
3069: &LONCAPA::map::makezombie($res);
3070: }
3071: splice(@LONCAPA::map::order,$i,1);
3072: $haschanges ++;
3073: } elsif ($which eq 'cut') {
3074: &LONCAPA::map::makezombie($res);
3075: splice(@LONCAPA::map::order,$i,1);
3076: $haschanges ++;
3077: }
3078: }
3079: }
3080: if ($haschanges) {
3081: ($errtext,$fatal) =
3082: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
3083: return $errtext if ($fatal);
3084: }
3085: }
3086: }
3087:
1.329 droeschl 3088: # Group import/search
3089: if ($env{'form.importdetail'}) {
3090: my @imports;
3091: foreach my $item (split(/\&/,$env{'form.importdetail'})) {
3092: if (defined($item)) {
3093: my ($name,$url,$residx)=
1.533 raeburn 3094: map { &unescape($_); } split(/\=/,$item);
3095: if ($url =~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
3096: my ($suffix,$errortxt,$locknotfreed) =
3097: &new_timebased_suffix($coursedom,$coursenum,'map',$1,$2);
1.504 raeburn 3098: if ($locknotfreed) {
3099: $r->print($locknotfreed);
3100: }
3101: if ($suffix) {
3102: $url =~ s/_new\./_$suffix./;
3103: } else {
3104: return $errortxt;
3105: }
1.533 raeburn 3106: } elsif ($url =~ m{^/adm/$match_domain/$match_username/new/(smppg|bulletinboard)$}) {
3107: my $type = $1;
3108: my ($suffix,$errortxt,$locknotfreed) =
3109: &new_timebased_suffix($coursedom,$coursenum,$type);
3110: if ($locknotfreed) {
3111: $r->print($locknotfreed);
3112: }
3113: if ($suffix) {
3114: $url =~ s{^(/adm/$match_domain/$match_username)/new}{$1/$suffix};
3115: } else {
3116: return $errortxt;
3117: }
1.598 raeburn 3118: } elsif ($url =~ m{^/adm/$coursedom/$coursenum/new/exttool}) {
3119: my ($suffix,$errortxt,$locknotfreed) =
3120: &new_timebased_suffix($coursedom,$coursenum,'exttool');
3121: if ($locknotfreed) {
3122: $r->print($locknotfreed);
3123: }
3124: if ($suffix) {
3125: $url =~ s{^(/adm/$coursedom/$coursenum)/new}{$1/$suffix};
3126: } else {
3127: return $errortxt;
3128: }
1.534 raeburn 3129: } elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) {
3130: if ($supplementalflag) {
3131: next unless ($1 eq 'supplemental');
3132: if ($folder eq 'supplemental') {
3133: next unless ($2 eq 'default');
3134: } else {
3135: next unless ($folder eq 'supplemental_'.$2);
3136: }
3137: } else {
3138: next unless ($1 eq 'docs');
3139: if ($folder eq 'default') {
3140: next unless ($2 eq 'default');
3141: } else {
3142: next unless ($folder eq 'default_'.$2);
3143: }
3144: }
1.504 raeburn 3145: }
1.329 droeschl 3146: push(@imports, [$name, $url, $residx]);
3147: }
3148: }
1.530 raeburn 3149: ($errtext,$fatal,my $fixuperrors) =
1.529 raeburn 3150: &group_import($coursenum, $coursedom, $folder,$container,
1.598 raeburn 3151: 'londocs',$ltitoolsref,@imports);
1.329 droeschl 3152: return $errtext if ($fatal);
1.529 raeburn 3153: if ($fixuperrors) {
3154: $r->print($fixuperrors);
3155: }
1.329 droeschl 3156: }
3157: # Loading a complete map
3158: if ($env{'form.loadmap'}) {
3159: if ($env{'form.importmap'}=~/\w/) {
3160: foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
3161: my ($title,$url,$ext,$type)=split(/\:/,$res);
3162: my $idx=&LONCAPA::map::getresidx($url);
3163: $LONCAPA::map::resources[$idx]=$res;
3164: $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
3165: }
3166: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.492 raeburn 3167: $folder.'.'.$container,1);
1.329 droeschl 3168: return $errtext if ($fatal);
3169: } else {
3170: $r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
1.364 bisitz 3171:
1.329 droeschl 3172: }
3173: }
3174: &log_differences($plain);
3175: }
3176: # ---------------------------------------------------------------- End commands
3177: # ---------------------------------------------------------------- Print screen
3178: my $idx=0;
3179: my $shown=0;
3180: if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
1.381 bisitz 3181: $r->print('<div class="LC_Box">'.
1.432 raeburn 3182: '<ol class="LC_docs_parameters"><li class="LC_docs_parameters_title">'.&mt('Parameters:').'</li>'.
3183: ($randompick>=0?'<li>'.&mt('randomly pick [quant,_1,resource]',$randompick).'</li>':'').
3184: ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
3185: ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
3186: ($is_random_order?'<li>'.&mt('random order').'</li>':'').
1.431 raeburn 3187: '</ol>');
1.381 bisitz 3188: if ($randompick>=0) {
3189: $r->print('<p class="LC_warning">'
3190: .&mt('Caution: this folder is set to randomly pick a subset'
3191: .' of resources. Adding or removing resources from this'
3192: .' folder will change the set of resources that the'
3193: .' students see, resulting in spurious or missing credit'
3194: .' for completed problems, not limited to ones you'
3195: .' modify. Do not modify the contents of this folder if'
3196: .' it is in active student use.')
3197: .'</p>'
3198: );
3199: }
3200: if ($is_random_order) {
3201: $r->print('<p class="LC_warning">'
3202: .&mt('Caution: this folder is set to randomly order its'
3203: .' contents. Adding or removing resources from this folder'
3204: .' will change the order of resources shown.')
3205: .'</p>'
3206: );
3207: }
3208: $r->print('</div>');
1.364 bisitz 3209: }
1.381 bisitz 3210:
1.538 raeburn 3211: my ($to_show,$output,@allidx,@allmapidx,%filters,%lists,%curr_groups);
3212: %filters = (
1.543 raeburn 3213: canremove => [],
3214: cancut => [],
3215: cancopy => [],
3216: hiddenresource => [],
3217: encrypturl => [],
3218: randomorder => [],
3219: randompick => [],
1.538 raeburn 3220: );
3221: %curr_groups = &Apache::longroup::coursegroups();
1.424 onken 3222: &Apache::loncommon::start_data_table_count(); #setup a row counter
1.381 bisitz 3223: foreach my $res (@LONCAPA::map::order) {
3224: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3225: $name=&LONCAPA::map::qtescape($name);
3226: $url=&LONCAPA::map::qtescape($url);
3227: unless ($name) { $name=(split(/\//,$url))[-1]; }
3228: unless ($name) { $idx++; next; }
1.537 raeburn 3229: push(@allidx,$res);
3230: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
3231: push(@allmapidx,$res);
3232: }
1.381 bisitz 3233: $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
1.501 raeburn 3234: $coursenum,$coursedom,$crstype,
1.538 raeburn 3235: $pathitem,$supplementalflag,$container,
1.598 raeburn 3236: \%filters,\%curr_groups,$ltitoolsref);
1.381 bisitz 3237: $idx++;
3238: $shown++;
1.329 droeschl 3239: }
1.424 onken 3240: &Apache::loncommon::end_data_table_count();
1.510 raeburn 3241:
1.538 raeburn 3242: my $need_save;
1.510 raeburn 3243: if (($allowed) || ($supplementalflag && $folder eq 'supplemental')) {
1.544 raeburn 3244: my $toolslink;
3245: if ($allowed || &Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
3246: $toolslink = '<table><tr><td>'
1.520 raeburn 3247: .&Apache::loncommon::help_open_menu('Navigation Screen',
3248: 'Navigation_Screen',undef,'RAT')
3249: .'</td><td class="LC_middle">'.&mt('Tools:').'</td>'
3250: .'<td align="left"><ul id="LC_toolbar">'
1.525 raeburn 3251: .'<li><a href="/adm/coursedocs?forcesupplement=1&command=editsupp" '
1.520 raeburn 3252: .'id="LC_content_toolbar_edittoplevel" '
3253: .'class="LC_toolbarItem" '
3254: .'title="'.&mt('Supplemental Content Editor').'">'
3255: .'</a></li></ul></td></tr></table><br />';
1.544 raeburn 3256: }
1.510 raeburn 3257: if ($shown) {
3258: if ($allowed) {
3259: $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
3260: .&Apache::loncommon::start_data_table(undef,'contentlist')
3261: .&Apache::loncommon::start_data_table_header_row()
3262: .'<th colspan="2">'.&mt('Move').'</th>'
1.538 raeburn 3263: .'<th colspan="2">'.&mt('Actions').'</th>'
3264: .'<th>'.&mt('Document').'</th>';
1.510 raeburn 3265: if ($folder !~ /^supplemental/) {
3266: $to_show .= '<th colspan="4">'.&mt('Settings').'</th>';
3267: }
1.537 raeburn 3268: $to_show .= &Apache::loncommon::end_data_table_header_row();
3269: if ($folder !~ /^supplemental/) {
1.538 raeburn 3270: $lists{'canhide'} = join(',',@allidx);
3271: $lists{'canrandomlyorder'} = join(',',@allmapidx);
1.543 raeburn 3272: my @possfilters = ('canremove','cancut','cancopy','hiddenresource','encrypturl',
3273: 'randomorder','randompick');
3274: foreach my $item (@possfilters) {
1.538 raeburn 3275: if (ref($filters{$item}) eq 'ARRAY') {
1.543 raeburn 3276: if (@{$filters{$item}} > 0) {
3277: $lists{$item} = join(',',@{$filters{$item}});
3278: }
1.538 raeburn 3279: }
3280: }
1.537 raeburn 3281: if (@allidx > 0) {
3282: my $path;
3283: if ($env{'form.folderpath'}) {
3284: $path =
3285: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3286: }
1.538 raeburn 3287: if (@allidx > 1) {
3288: $to_show .=
3289: &Apache::loncommon::continue_data_table_row().
3290: '<td colspan="2"> </td>'.
3291: '<td>'.
3292: &multiple_check_form('actions',\%lists).
3293: '</td>'.
3294: '<td> </td>'.
3295: '<td> </td>'.
3296: '<td colspan="4">'.
3297: &multiple_check_form('settings',\%lists).
3298: '</td>'.
3299: &Apache::loncommon::end_data_table_row();
3300: $need_save = 1;
3301: }
1.537 raeburn 3302: }
3303: }
3304: $to_show .= $output.' '
1.510 raeburn 3305: .&Apache::loncommon::end_data_table()
3306: .'<br style="line-height:2px;" />'
3307: .&Apache::loncommon::end_scrollbox();
3308: } else {
1.520 raeburn 3309: $to_show .= $toolslink
1.510 raeburn 3310: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3311: .$output.' '
3312: .&Apache::loncommon::end_data_table();
1.393 raeburn 3313: }
1.510 raeburn 3314: } else {
1.520 raeburn 3315: if (!$allowed) {
3316: $to_show .= $toolslink;
3317: }
1.510 raeburn 3318: $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
3319: .'<div class="LC_info" id="contentlist">'
1.550 raeburn 3320: .&mt('Currently empty')
1.510 raeburn 3321: .'</div>'
3322: .&Apache::loncommon::end_scrollbox();
1.393 raeburn 3323: }
3324: } else {
1.510 raeburn 3325: if ($shown) {
3326: $to_show = '<div>'
3327: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3328: .$output
3329: .&Apache::loncommon::end_data_table()
3330: .'</div>';
3331: } else {
3332: $to_show = '<div class="LC_info" id="contentlist">'
1.550 raeburn 3333: .&mt('Currently empty')
1.510 raeburn 3334: .'</div>'
3335: }
1.458 raeburn 3336: }
3337: my $tid = 1;
3338: if ($supplementalflag) {
3339: $tid = 2;
1.329 droeschl 3340: }
3341: if ($allowed) {
1.484 raeburn 3342: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
1.538 raeburn 3343: $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,
3344: $jumpto,$readfile,$need_save,"$folder.$container"));
1.492 raeburn 3345: &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
1.460 raeburn 3346: } else {
3347: $r->print($to_show);
1.329 droeschl 3348: }
3349: return;
3350: }
3351:
1.538 raeburn 3352: sub multiple_check_form {
3353: my ($caller,$listsref) = @_;
3354: return unless (ref($listsref) eq 'HASH');
3355: my $output =
3356: '<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'.
3357: '<span class="LC_nobreak" style="font-size:x-small;font-weight:bold;">'.
3358: '<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>'.
3359: '<div id="multi'.$caller.'" style="display:none;margin:0;padding:0;border:0">'.
3360: '<form action="/adm/coursedocs" method="post" name="cumulative'.$caller.'">'."\n".
3361: '<fieldset id="allfields'.$caller.'" style="display:none"><legend style="font-size:x-small;">'.&mt('check/uncheck all').'</legend>'."\n";
3362: if ($caller eq 'settings') {
3363: $output .=
3364: '<table><tr>'.
3365: '<td class="LC_docs_entry_parameter">'.
3366: '<span class="LC_nobreak"><label>'.
3367: '<input type="checkbox" name="hiddenresourceall" id="hiddenresourceall" onclick="propagateState(this.form,'."'hiddenresource'".')" />'.&mt('Hidden').
3368: '</label></span></td>'.
3369: '<td class="LC_docs_entry_parameter">'.
3370: '<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="" />'.
3371: '</span></td>'.
3372: '</tr>'."\n".
3373: '<tr>'.
3374: '<td class="LC_docs_entry_parameter">'.
3375: '<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').
3376: '</label></span>'.
3377: '</td></tr></table>'."\n";
3378: } else {
3379: $output .=
3380: '<table><tr>'.
3381: '<td class="LC_docs_entry_parameter">'.
3382: '<span class="LC_nobreak LC_docs_remove">'.
3383: '<label><input type="checkbox" name="removeall" id="removeall" onclick="propagateState(this.form,'."'remove'".')" />'.&mt('Remove').
3384: '</label></span></td>'.
3385: '<td class="LC_docs_entry_parameter">'.
3386: '<span class="LC_nobreak LC_docs_cut">'.
3387: '<label><input type="checkbox" name="cut" id="cutall" onclick="propagateState(this.form,'."'cut'".');" />'.&mt('Cut').
3388: '</label></span></td>'."\n".
3389: '<td class="LC_docs_entry_parameter">'.
3390: '<span class="LC_nobreak LC_docs_copy">'.
3391: '<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')" />'.&mt('Copy').
3392: '</label></span></td>'.
3393: '</tr></table>'."\n";
3394: }
3395: $output .=
3396: '</fieldset>'.
3397: '<input type="hidden" name="allidx" value="'.$listsref->{'canhide'}.'" />';
3398: if ($caller eq 'settings') {
3399: $output .=
1.543 raeburn 3400: '<input type="hidden" name="allmapidx" value="'.$listsref->{'canrandomlyorder'}.'" />'."\n".
3401: '<input type="hidden" name="currhiddenresource" value="'.$listsref->{'hiddenresource'}.'" />'."\n".
3402: '<input type="hidden" name="currencrypturl" value="'.$listsref->{'encrypturl'}.'" />'."\n".
3403: '<input type="hidden" name="currrandomorder" value="'.$listsref->{'randomorder'}.'" />'."\n".
3404: '<input type="hidden" name="currrandompick" value="'.$listsref->{'randompick'}.'" />'."\n";
1.538 raeburn 3405: } elsif ($caller eq 'actions') {
3406: $output .=
3407: '<input type="hidden" name="allremoveidx" id="allremoveidx" value="'.$listsref->{'canremove'}.'" />'.
3408: '<input type="hidden" name="allcutidx" id="allcutidx" value="'.$listsref->{'cancut'}.'" />'.
3409: '<input type="hidden" name="allcopyidx" id="allcopyidx" value="'.$listsref->{'cancopy'}.'" />';
3410: }
3411: $output .=
3412: '</form>'.
3413: '</div>';
3414: return $output;
3415: }
3416:
1.329 droeschl 3417: sub process_file_upload {
1.552 raeburn 3418: my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd,$crstype) = @_;
1.329 droeschl 3419: # upload a file, if present
1.552 raeburn 3420: my $filesize = length($env{'form.uploaddoc'});
3421: if (!$filesize) {
3422: $$upload_output = '<div class="LC_error">'.
3423: &mt('Unable to upload [_1]. (size = [_2] bytes)',
3424: '<span class="LC_filename">'.$env{'form.uploaddoc.filename'}.'</span>',
3425: $filesize).'<br />'.
3426: &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'<br />'.
3427: '</div>';
3428: return;
3429: }
3430: my $quotatype = 'unofficial';
3431: if ($crstype eq 'Community') {
1.601 raeburn 3432: $quotatype = 'community';
3433: } elsif ($crstype eq 'Placement') {
3434: $quotatype = 'placement';
1.580 raeburn 3435: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
1.552 raeburn 3436: $quotatype = 'official';
1.573 raeburn 3437: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
3438: $quotatype = 'textbook';
1.552 raeburn 3439: }
3440: if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) {
3441: $filesize = int($filesize/1000); #expressed in kb
3442: $$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course',
1.579 raeburn 3443: $env{'form.uploaddoc.filename'},$filesize,
3444: 'upload',$quotatype);
1.552 raeburn 3445: return if ($$upload_output);
3446: }
1.440 raeburn 3447: my ($parseaction,$showupload,$nextphase,$mimetype);
3448: if ($env{'form.parserflag'}) {
1.329 droeschl 3449: $parseaction = 'parse';
3450: }
3451: my $folder=$env{'form.folder'};
3452: if ($folder eq '') {
3453: $folder='default';
3454: }
3455: if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
3456: my $errtext='';
3457: my $fatal=0;
3458: my $container='sequence';
1.519 raeburn 3459: if ($env{'form.folderpath'} =~ /:1$/) {
1.329 droeschl 3460: $container='page';
3461: }
3462: ($errtext,$fatal)=
1.534 raeburn 3463: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1.329 droeschl 3464: if ($#LONCAPA::map::order<1) {
3465: $LONCAPA::map::order[0]=1;
3466: $LONCAPA::map::resources[1]='';
3467: }
3468: my $destination = 'docs/';
3469: if ($folder =~ /^supplemental/) {
3470: $destination = 'supplemental/';
3471: }
3472: if (($folder eq 'default') || ($folder eq 'supplemental')) {
3473: $destination .= 'default/';
3474: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
3475: $destination .= $2.'/';
3476: }
1.534 raeburn 3477: if ($fatal) {
3478: $$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>';
3479: return;
3480: }
1.440 raeburn 3481: # this is for a course, not a user, so set context to coursedoc.
1.329 droeschl 3482: my $newidx=&LONCAPA::map::getresidx();
3483: $destination .= $newidx;
1.439 raeburn 3484: my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination,
1.329 droeschl 3485: $parseaction,$allfiles,
1.440 raeburn 3486: $codebase,undef,undef,undef,undef,
3487: undef,undef,\$mimetype);
3488: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) {
3489: my $stored = $1;
3490: $showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'.
3491: $stored.'</span>').'</p>';
3492: } else {
3493: my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});
3494:
1.457 raeburn 3495: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>';
1.440 raeburn 3496: return;
3497: }
1.329 droeschl 3498: my $ext='false';
3499: if ($url=~m{^http://}) { $ext='true'; }
3500: $url = &LONCAPA::map::qtunescape($url);
3501: my $comment=$env{'form.comment'};
3502: $comment = &LONCAPA::map::qtunescape($comment);
3503: if ($folder=~/^supplemental/) {
3504: $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
3505: $env{'user.domain'}.'___&&&___'.$comment;
3506: }
3507:
3508: $LONCAPA::map::resources[$newidx]=
3509: $comment.':'.$url.':'.$ext.':normal:res';
3510: $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
3511: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.492 raeburn 3512: $folder.'.'.$container,1);
1.329 droeschl 3513: if ($fatal) {
1.457 raeburn 3514: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>';
1.440 raeburn 3515: return;
1.329 droeschl 3516: } else {
1.440 raeburn 3517: if ($parseaction eq 'parse' && $mimetype eq 'text/html') {
3518: $$upload_output = $showupload;
1.384 raeburn 3519: my $total_embedded = scalar(keys(%{$allfiles}));
1.329 droeschl 3520: if ($total_embedded > 0) {
1.440 raeburn 3521: my $uploadphase = 'upload_embedded';
3522: my $primaryurl = &HTML::Entities::encode($url,'<>&"');
3523: my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx);
3524: my ($embedded,$num) =
3525: &Apache::loncommon::ask_for_embedded_content(
3526: '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url});
3527: if ($embedded) {
3528: if ($num) {
3529: $$upload_output .=
3530: '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
3531: $nextphase = $uploadphase;
3532: } else {
3533: $$upload_output .= $embedded;
3534: }
3535: } else {
3536: $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
3537: }
1.329 droeschl 3538: } else {
1.440 raeburn 3539: $$upload_output .= &mt('No embedded items identified').'<br />';
1.329 droeschl 3540: }
1.457 raeburn 3541: $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
1.578 raeburn 3542: } elsif ((&Apache::loncommon::is_archive_file($mimetype)) &&
3543: ($env{'form.uploaddoc.filename'} =~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i)) {
1.476 raeburn 3544: $nextphase = 'decompress_uploaded';
3545: my $position = scalar(@LONCAPA::map::order)-1;
3546: my $noextract = &return_to_editor();
3547: my $archiveurl = &HTML::Entities::encode($url,'<>&"');
3548: my %archiveitems = (
3549: folderpath => $env{'form.folderpath'},
3550: cmd => $nextphase,
3551: newidx => $newidx,
3552: position => $position,
3553: phase => $nextphase,
1.477 raeburn 3554: comment => $comment,
1.480 raeburn 3555: );
3556: my ($destination,$dir_root) = &embedded_destination($coursenum,$coursedom);
3557: my @current = &get_dir_list($url,$coursenum,$coursedom,$newidx);
1.476 raeburn 3558: $$upload_output = $showupload.
3559: &Apache::loncommon::decompress_form($mimetype,
3560: $archiveurl,'/adm/coursedocs',$noextract,
1.480 raeburn 3561: \%archiveitems,\@current);
1.329 droeschl 3562: }
3563: }
3564: }
1.440 raeburn 3565: return $nextphase;
1.329 droeschl 3566: }
3567:
1.480 raeburn 3568: sub get_dir_list {
3569: my ($url,$coursenum,$coursedom,$newidx) = @_;
3570: my ($destination,$dir_root) = &embedded_destination();
3571: my ($dirlistref,$listerror) =
3572: &Apache::lonnet::dirlist("$dir_root/$destination/$newidx",$coursedom,$coursenum,1);
3573: my @dir_lines;
3574: my $dirptr=16384;
3575: if (ref($dirlistref) eq 'ARRAY') {
3576: foreach my $dir_line (sort
3577: {
3578: my ($afile)=split('&',$a,2);
3579: my ($bfile)=split('&',$b,2);
3580: return (lc($afile) cmp lc($bfile));
3581: } (@{$dirlistref})) {
3582: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
3583: $filename =~ s/\s+$//;
3584: next if ($filename =~ /^\.\.?$/);
3585: my $isdir = 0;
3586: if ($dirptr&$testdir) {
3587: $isdir = 1;
3588: }
3589: push(@dir_lines, [$filename,$dom,$isdir,$size,$mtime,$obs]);
3590: }
3591: }
3592: return @dir_lines;
3593: }
3594:
1.329 droeschl 3595: sub is_supplemental_title {
3596: my ($title) = @_;
3597: return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
3598: }
3599:
3600: # --------------------------------------------------------------- An entry line
3601:
3602: sub entryline {
1.501 raeburn 3603: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
1.598 raeburn 3604: $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups,
3605: $ltitoolsref)=@_;
1.581 raeburn 3606: my ($foldertitle,$renametitle,$oldtitle);
1.329 droeschl 3607: if (&is_supplemental_title($title)) {
1.488 raeburn 3608: ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
1.329 droeschl 3609: } else {
3610: $title=&HTML::Entities::encode($title,'"<>&\'');
3611: $renametitle=$title;
3612: $foldertitle=$title;
3613: }
3614:
3615: my $orderidx=$LONCAPA::map::order[$index];
1.364 bisitz 3616:
1.329 droeschl 3617: $renametitle=~s/\\/\\\\/g;
3618: $renametitle=~s/\"\;/\\\"/g;
1.585 raeburn 3619: $renametitle=~s/"/%22/g;
1.581 raeburn 3620: $renametitle=~s/ /%20/g;
3621: $oldtitle = $renametitle;
1.576 raeburn 3622: $renametitle=~s/\'/\\\'/g;
1.379 bisitz 3623: my $line=&Apache::loncommon::start_data_table_row();
1.538 raeburn 3624: my ($form_start,$form_end,$form_common,$form_param);
1.329 droeschl 3625: # Edit commands
1.535 raeburn 3626: my ($esc_path, $path, $symb);
1.329 droeschl 3627: if ($env{'form.folderpath'}) {
3628: $esc_path=&escape($env{'form.folderpath'});
3629: $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3630: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
3631: }
1.505 raeburn 3632: my $isexternal;
1.510 raeburn 3633: if ($residx) {
1.501 raeburn 3634: my $currurl = $url;
3635: $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.505 raeburn 3636: if ($currurl =~ m{^/adm/wrapper/ext/}) {
3637: $isexternal = 1;
3638: }
1.510 raeburn 3639: if (!$supplementalflag) {
3640: my $path = 'uploaded/'.
3641: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
3642: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
3643: $symb = &Apache::lonnet::encode_symb($path.$folder.".$container",
3644: $residx,
3645: &Apache::lonnet::declutter($currurl));
3646: }
1.501 raeburn 3647: }
1.538 raeburn 3648: my ($renamelink,%lt,$ishash);
3649: if (ref($filtersref) eq 'HASH') {
3650: $ishash = 1;
3651: }
3652:
1.329 droeschl 3653: if ($allowed) {
1.538 raeburn 3654: $form_start = '
3655: <form action="/adm/coursedocs" method="post">
3656: ';
3657: $form_common=(<<END);
3658: <input type="hidden" name="folderpath" value="$path" />
3659: <input type="hidden" name="symb" value="$symb" />
3660: END
3661: $form_param=(<<END);
3662: <input type="hidden" name="setparms" value="$orderidx" />
3663: <input type="hidden" name="changeparms" value="0" />
3664: END
3665: $form_end = '</form>';
3666:
1.329 droeschl 3667: my $incindex=$index+1;
3668: my $selectbox='';
1.471 raeburn 3669: if (($#LONCAPA::map::order>0) &&
1.329 droeschl 3670: ((split(/\:/,
1.344 bisitz 3671: $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
3672: ne '') &&
1.329 droeschl 3673: ((split(/\:/,
1.344 bisitz 3674: $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1.329 droeschl 3675: ne '')) {
3676: $selectbox=
3677: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.373 bisitz 3678: '<select name="newpos" onchange="this.form.submit()">';
1.329 droeschl 3679: for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
3680: if ($i==$incindex) {
1.358 bisitz 3681: $selectbox.='<option value="" selected="selected">('.$i.')</option>';
1.329 droeschl 3682: } else {
3683: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
3684: }
3685: }
3686: $selectbox.='</select>';
3687: }
1.501 raeburn 3688: %lt=&Apache::lonlocal::texthash(
1.329 droeschl 3689: 'up' => 'Move Up',
3690: 'dw' => 'Move Down',
3691: 'rm' => 'Remove',
3692: 'ct' => 'Cut',
3693: 'rn' => 'Rename',
1.501 raeburn 3694: 'cp' => 'Copy',
3695: 'ex' => 'External Resource',
1.598 raeburn 3696: 'et' => 'External Tool',
1.501 raeburn 3697: 'ed' => 'Edit',
3698: 'pr' => 'Preview',
3699: 'sv' => 'Save',
3700: 'ul' => 'URL',
3701: 'ti' => 'Title',
3702: );
1.538 raeburn 3703: my %denied = &action_restrictions($coursenum,$coursedom,$url,
3704: $env{'form.folderpath'},
3705: $currgroups);
1.517 raeburn 3706: my ($copylink,$cutlink,$removelink);
1.329 droeschl 3707: my $skip_confirm = 0;
3708: if ( $folder =~ /^supplemental/
3709: || ($url =~ m{( /smppg$
3710: |/syllabus$
3711: |/aboutme$
3712: |/navmaps$
3713: |/bulletinboard$
1.598 raeburn 3714: |/exttools?$
1.505 raeburn 3715: |\.html$)}x)
3716: || $isexternal) {
1.329 droeschl 3717: $skip_confirm = 1;
3718: }
3719:
1.538 raeburn 3720: if ($denied{'copy'}) {
1.543 raeburn 3721: $copylink=(<<ENDCOPY)
1.507 raeburn 3722: <span style="visibility: hidden;">$lt{'cp'}</span>
3723: ENDCOPY
3724: } else {
1.538 raeburn 3725: my $formname = 'edit_copy_'.$orderidx;
3726: my $js = "javascript:checkForSubmit(document.forms.renameform,'copy','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.329 droeschl 3727: $copylink=(<<ENDCOPY);
1.538 raeburn 3728: <form name="$formname" method="post" action="/adm/coursedocs">
3729: $form_common
1.540 raeburn 3730: <input type="checkbox" name="copy" id="copy_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','copy');" class="LC_hidden" /><a href="$js" class="LC_docs_copy">$lt{'cp'}</a>
1.538 raeburn 3731: $form_end
1.329 droeschl 3732: ENDCOPY
1.538 raeburn 3733: if (($ishash) && (ref($filtersref->{'cancopy'}) eq 'ARRAY')) {
3734: push(@{$filtersref->{'cancopy'}},$orderidx);
3735: }
1.329 droeschl 3736: }
1.538 raeburn 3737: if ($denied{'cut'}) {
1.507 raeburn 3738: $cutlink=(<<ENDCUT);
3739: <span style="visibility: hidden;">$lt{'ct'}</span>
3740: ENDCUT
3741: } else {
1.538 raeburn 3742: my $formname = 'edit_cut_'.$orderidx;
3743: my $js = "javascript:checkForSubmit(document.forms.renameform,'cut','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.329 droeschl 3744: $cutlink=(<<ENDCUT);
1.538 raeburn 3745: <form name="$formname" method="post" action="/adm/coursedocs">
3746: $form_common
1.542 raeburn 3747: <input type="hidden" name="skip_$orderidx" id="skip_cut_$orderidx" value="$skip_confirm" />
1.540 raeburn 3748: <input type="checkbox" name="cut" id="cut_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','cut');" class="LC_hidden" /><a href="$js" class="LC_docs_cut">$lt{'ct'}</a>
1.538 raeburn 3749: $form_end
1.329 droeschl 3750: ENDCUT
1.538 raeburn 3751: if (($ishash) && (ref($filtersref->{'cancut'}) eq 'ARRAY')) {
3752: push(@{$filtersref->{'cancut'}},$orderidx);
3753: }
1.329 droeschl 3754: }
1.538 raeburn 3755: if ($denied{'remove'}) {
1.507 raeburn 3756: $removelink=(<<ENDREM);
3757: <span style="visibility: hidden;">$lt{'rm'}</a>
3758: ENDREM
3759: } else {
1.538 raeburn 3760: my $formname = 'edit_remove_'.$orderidx;
3761: my $js = "javascript:checkForSubmit(document.forms.renameform,'remove','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm);";
1.497 raeburn 3762: $removelink=(<<ENDREM);
1.538 raeburn 3763: <form name="$formname" method="post" action="/adm/coursedocs">
3764: $form_common
1.542 raeburn 3765: <input type="hidden" name="skip_$orderidx" id="skip_remove_$orderidx" value="$skip_confirm" />
1.540 raeburn 3766: <input type="checkbox" name="remove" id="remove_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','remove');" class="LC_hidden" /><a href="$js" class="LC_docs_remove">$lt{'rm'}</a>
1.538 raeburn 3767: $form_end
1.497 raeburn 3768: ENDREM
1.538 raeburn 3769: if (($ishash) && (ref($filtersref->{'canremove'}) eq 'ARRAY')) {
3770: push(@{$filtersref->{'canremove'}},$orderidx);
3771: }
1.497 raeburn 3772: }
1.551 raeburn 3773: $renamelink=(<<ENDREN);
1.581 raeburn 3774: <a href='javascript:changename("$esc_path","$index","$oldtitle");' class="LC_docs_rename">$lt{'rn'}</a>
1.507 raeburn 3775: ENDREN
1.329 droeschl 3776: $line.=(<<END);
3777: <td>
1.379 bisitz 3778: <div class="LC_docs_entry_move">
1.535 raeburn 3779: <a href='/adm/coursedocs?cmd=up_$index&folderpath=$esc_path&symb=$symb'>
1.501 raeburn 3780: <img src="${iconpath}move_up.gif" alt="$lt{'up'}" class="LC_icon" />
1.379 bisitz 3781: </a>
3782: </div>
3783: <div class="LC_docs_entry_move">
1.536 raeburn 3784: <a href='/adm/coursedocs?cmd=down_$index&folderpath=$esc_path&symb=$symb'>
1.501 raeburn 3785: <img src="${iconpath}move_down.gif" alt="$lt{'dw'}" class="LC_icon" />
1.379 bisitz 3786: </a>
3787: </div>
1.329 droeschl 3788: </td>
3789: <td>
3790: $form_start
1.538 raeburn 3791: $form_param
1.478 raeburn 3792: $form_common
1.329 droeschl 3793: $selectbox
3794: $form_end
3795: </td>
1.540 raeburn 3796: <td class="LC_docs_entry_commands LC_nobreak">
1.497 raeburn 3797: $removelink
1.329 droeschl 3798: $cutlink
3799: $copylink
3800: </td>
3801: END
3802: }
3803: # Figure out what kind of a resource this is
3804: my ($extension)=($url=~/\.(\w+)$/);
3805: my $uploaded=($url=~/^\/*uploaded\//);
3806: my $icon=&Apache::loncommon::icon($url);
1.519 raeburn 3807: my $isfolder;
3808: my $ispage;
3809: my $containerarg;
1.329 droeschl 3810: if ($uploaded) {
1.472 raeburn 3811: if (($extension eq 'sequence') || ($extension eq 'page')) {
3812: $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
1.519 raeburn 3813: $containerarg = $1;
1.472 raeburn 3814: if ($extension eq 'sequence') {
3815: $icon=$iconpath.'navmap.folder.closed.gif';
3816: $isfolder=1;
3817: } else {
3818: $icon=$iconpath.'page.gif';
3819: $ispage=1;
3820: }
3821: if ($allowed) {
3822: $url='/adm/coursedocs?';
3823: } else {
3824: $url='/adm/supplemental?';
3825: }
1.329 droeschl 3826: } else {
3827: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
3828: }
3829: }
1.364 bisitz 3830:
1.518 raeburn 3831: my ($editlink,$extresform);
1.329 droeschl 3832: my $orig_url = $url;
1.340 raeburn 3833: $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
1.510 raeburn 3834: $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.501 raeburn 3835: if (!$supplementalflag && $residx && $symb) {
3836: if ((!$isfolder) && (!$ispage)) {
3837: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
3838: $url=&Apache::lonnet::clutter($url);
3839: if ($url=~/^\/*uploaded\//) {
3840: $url=~/\.(\w+)$/;
3841: my $embstyle=&Apache::loncommon::fileembstyle($1);
3842: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
3843: $url='/adm/wrapper'.$url;
3844: } elsif ($embstyle eq 'ssi') {
3845: #do nothing with these
3846: } elsif ($url!~/\.(sequence|page)$/) {
3847: $url='/adm/coursedocs/showdoc'.$url;
3848: }
3849: } elsif ($url=~m|^/ext/|) {
3850: $url='/adm/wrapper'.$url;
1.598 raeburn 3851: } elsif ($url=~m{^/adm/$coursedom/$coursenum/\d+/exttools?$}) {
3852: $url='/adm/wrapper'.$url;
3853: }
1.501 raeburn 3854: if (&Apache::lonnet::symbverify($symb,$url)) {
3855: $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
3856: } else {
3857: $url='';
3858: }
1.329 droeschl 3859: }
3860: }
1.478 raeburn 3861: my ($rand_pick_text,$rand_order_text);
1.519 raeburn 3862: if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') {
1.329 droeschl 3863: my $foldername=&escape($foldertitle);
3864: my $folderpath=$env{'form.folderpath'};
3865: if ($folderpath) { $folderpath.='&' };
1.510 raeburn 3866: if (!$allowed && $supplementalflag) {
1.519 raeburn 3867: $folderpath.=$containerarg.'&'.$foldername;
1.510 raeburn 3868: $url.='folderpath='.&escape($folderpath);
3869: } else {
1.344 bisitz 3870: # Append randompick number, hidden, and encrypted with ":" to foldername,
1.329 droeschl 3871: # so it gets transferred between levels
1.519 raeburn 3872: $folderpath.=$containerarg.'&'.$foldername.
1.510 raeburn 3873: ':'.(&LONCAPA::map::getparameter($orderidx,
1.329 droeschl 3874: 'parameter_randompick'))[0]
3875: .':'.((&LONCAPA::map::getparameter($orderidx,
3876: 'parameter_hiddenresource'))[0]=~/^yes$/i)
3877: .':'.((&LONCAPA::map::getparameter($orderidx,
3878: 'parameter_encrypturl'))[0]=~/^yes$/i)
3879: .':'.((&LONCAPA::map::getparameter($orderidx,
1.519 raeburn 3880: 'parameter_randomorder'))[0]=~/^yes$/i)
3881: .':'.$ispage;
1.510 raeburn 3882: $url.='folderpath='.&escape($folderpath);
3883: my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
3884: 'parameter_randompick'))[0];
3885: my $rpckchk;
3886: if ($rpicknum) {
3887: $rpckchk = ' checked="checked"';
1.543 raeburn 3888: if (($ishash) && (ref($filtersref->{'randompick'}) eq 'ARRAY')) {
3889: push(@{$filtersref->{'randompick'}},$orderidx.':'.$rpicknum);
3890: }
1.510 raeburn 3891: }
1.537 raeburn 3892: my $formname = 'edit_randompick_'.$orderidx;
1.510 raeburn 3893: $rand_pick_text =
1.478 raeburn 3894: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.538 raeburn 3895: $form_param."\n".
1.478 raeburn 3896: $form_common."\n".
1.537 raeburn 3897: '<span class="LC_nobreak"><label><input type="checkbox" name="randompick_'.$orderidx.'" id="randompick_'.$orderidx.'" onclick="'."updatePick(this.form,'$orderidx','check');".'"'.$rpckchk.' /> '.&mt('Randomly Pick').'</label><input type="hidden" name="rpicknum_'.$orderidx.'" id="rpicknum_'.$orderidx.'" value="'.$rpicknum.'" /><span id="randompicknum_'.$orderidx.'">';
1.510 raeburn 3898: if ($rpicknum ne '') {
3899: $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
3900: }
1.537 raeburn 3901: $rand_pick_text .= '</span></span>'.
3902: $form_end;
1.543 raeburn 3903: my $ro_set;
3904: if ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i) {
3905: $ro_set = 'checked="checked"';
3906: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
3907: push(@{$filtersref->{'randomorder'}},$orderidx);
3908: }
3909: }
1.564 raeburn 3910: $formname = 'edit_rorder_'.$orderidx;
1.510 raeburn 3911: $rand_order_text =
1.537 raeburn 3912: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.538 raeburn 3913: $form_param."\n".
1.537 raeburn 3914: $form_common."\n".
1.538 raeburn 3915: '<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.' /> '.&mt('Random Order').' </label></span>'.
1.537 raeburn 3916: $form_end;
1.510 raeburn 3917: }
1.509 raeburn 3918: } elsif ($supplementalflag && !$allowed) {
1.598 raeburn 3919: my $isexttool;
3920: if ($url=~m{^/adm/$coursedom/$coursenum/\d+/exttools?$}) {
3921: $url='/adm/wrapper'.$url;
3922: $isexttool = 1;
3923: }
1.510 raeburn 3924: $url .= ($url =~ /\?/) ? '&':'?';
1.509 raeburn 3925: $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
1.510 raeburn 3926: if ($title) {
3927: $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"');
3928: }
1.598 raeburn 3929: if ((($isexternal) || ($isexttool)) && $orderidx) {
1.510 raeburn 3930: $url .= '&idx='.$orderidx;
3931: }
1.329 droeschl 3932: }
1.519 raeburn 3933: my ($tdalign,$tdwidth);
1.501 raeburn 3934: if ($allowed) {
3935: my $fileloc =
3936: &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
1.510 raeburn 3937: if ($isexternal) {
1.518 raeburn 3938: ($editlink,$extresform) =
1.510 raeburn 3939: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem);
1.598 raeburn 3940: } elsif ($orig_url =~ m{^/adm/$coursedom/$coursenum/\d+/exttools?$}) {
3941: ($editlink,$extresform) =
3942: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
3943: undef,undef,undef,'tool',$coursedom,
3944: $coursenum,$ltitoolsref);
1.511 raeburn 3945: } elsif (!$isfolder && !$ispage) {
1.503 raeburn 3946: my ($cfile,$home,$switchserver,$forceedit,$forceview) =
3947: &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
1.511 raeburn 3948: if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
1.501 raeburn 3949: my $jscall =
3950: &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
3951: $switchserver,
1.503 raeburn 3952: $forceedit,
1.511 raeburn 3953: undef,$symb,
3954: &escape($env{'form.folderpath'}),
1.524 raeburn 3955: $renametitle,'','',1);
1.501 raeburn 3956: if ($jscall) {
1.518 raeburn 3957: $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
3958: $jscall.'" >'.&mt('Edit').'</a> '."\n";
1.501 raeburn 3959: }
3960: }
3961: }
1.519 raeburn 3962: $tdalign = ' align="right" valign="top"';
3963: $tdwidth = ' width="80%"';
1.329 droeschl 3964: }
1.408 raeburn 3965: my $reinit;
3966: if ($crstype eq 'Community') {
3967: $reinit = &mt('(re-initialize community to access)');
3968: } else {
3969: $reinit = &mt('(re-initialize course to access)');
1.519 raeburn 3970: }
3971: $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;
1.472 raeburn 3972: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 3973: $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
3974: } elsif ($url) {
1.484 raeburn 3975: $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
1.470 raeburn 3976: '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
1.469 www 3977: } else {
3978: $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
3979: }
1.519 raeburn 3980: $line.='</span></td><td'.$tdwidth.'>';
1.472 raeburn 3981: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 3982: $line.='<a href="'.$url.'">'.$title.'</a>';
3983: } elsif ($url) {
1.484 raeburn 3984: $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
1.470 raeburn 3985: $title,600,500);
1.469 www 3986: } else {
3987: $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
3988: }
1.518 raeburn 3989: $line.="$extresform</td>";
1.478 raeburn 3990: $rand_pick_text = ' ' if ($rand_pick_text eq '');
3991: $rand_order_text = ' ' if ($rand_order_text eq '');
1.329 droeschl 3992: if (($allowed) && ($folder!~/^supplemental/)) {
3993: my %lt=&Apache::lonlocal::texthash(
3994: 'hd' => 'Hidden',
3995: 'ec' => 'URL hidden');
1.543 raeburn 3996: my ($enctext,$hidtext);
3997: if ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) {
3998: $enctext = ' checked="checked"';
3999: if (($ishash) && (ref($filtersref->{'encrypturl'}) eq 'ARRAY')) {
4000: push(@{$filtersref->{'encrypturl'}},$orderidx);
4001: }
4002: }
4003: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4004: $hidtext = ' checked="checked"';
4005: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4006: push(@{$filtersref->{'hiddenresource'}},$orderidx);
4007: }
4008: }
1.537 raeburn 4009: my $formhidden = 'edit_hiddenresource_'.$orderidx;
4010: my $formurlhidden = 'edit_encrypturl_'.$orderidx;
1.329 droeschl 4011: $line.=(<<ENDPARMS);
4012: <td class="LC_docs_entry_parameter">
1.537 raeburn 4013: <form action="/adm/coursedocs" method="post" name="$formhidden">
1.538 raeburn 4014: $form_param
1.478 raeburn 4015: $form_common
1.538 raeburn 4016: <label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'hiddenresource','settings');" $hidtext /> $lt{'hd'}</label>
1.329 droeschl 4017: $form_end
1.458 raeburn 4018: <br />
1.537 raeburn 4019: <form action="/adm/coursedocs" method="post" name="$formurlhidden">
1.538 raeburn 4020: $form_param
1.478 raeburn 4021: $form_common
1.538 raeburn 4022: <label><input type="checkbox" name="encrypturl_$orderidx" id="encrypturl_$orderidx" onclick="checkForSubmit(this.form,'encrypturl','settings');" $enctext /> $lt{'ec'}</label>
1.329 droeschl 4023: $form_end
4024: </td>
1.478 raeburn 4025: <td class="LC_docs_entry_parameter">$rand_pick_text<br />
4026: $rand_order_text</td>
1.329 droeschl 4027: ENDPARMS
4028: }
1.379 bisitz 4029: $line.=&Apache::loncommon::end_data_table_row();
1.329 droeschl 4030: return $line;
4031: }
4032:
1.538 raeburn 4033: sub action_restrictions {
4034: my ($cnum,$cdom,$url,$folderpath,$currgroups) = @_;
4035: my %denied = (
4036: cut => 0,
4037: copy => 0,
4038: remove => 0,
4039: );
4040: if ($url=~ m{^/res/.+\.(page|sequence)$}) {
4041: # no copy for published maps
4042: $denied{'copy'} = 1;
1.597 raeburn 4043: } elsif ($url=~m{^/res/lib/templates/([^/]+)\.problem$}) {
4044: unless ($1 eq 'simpleproblem') {
4045: $denied{'copy'} = 1;
4046: }
4047: $denied{'cut'} = 1;
1.538 raeburn 4048: } elsif ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") {
4049: if ($folderpath =~ /^default&[^\&]+$/) {
4050: if ((ref($currgroups) eq 'HASH') && (keys(%{$currgroups}) > 0)) {
4051: $denied{'remove'} = 1;
4052: }
4053: $denied{'cut'} = 1;
4054: $denied{'copy'} = 1;
4055: }
4056: } elsif ($url =~ m{^\Q/uploaded/$cdom/$cnum/group_folder_\E(\w+)\.sequence$}) {
4057: my $group = $1;
4058: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+$/) {
4059: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4060: $denied{'remove'} = 1;
4061: }
4062: }
4063: $denied{'cut'} = 1;
4064: $denied{'copy'} = 1;
4065: } elsif ($url =~ m{^\Q/adm/$cdom/$cnum/\E(\w+)/smppg$}) {
4066: my $group = $1;
4067: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&\Qgroup_folder_$group\E\&[^\&]+$/) {
4068: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4069: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4070: if (keys(%groupsettings) > 0) {
4071: $denied{'remove'} = 1;
4072: }
4073: $denied{'cut'} = 1;
4074: $denied{'copy'} = 1;
4075: }
4076: }
4077: } elsif ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&group_folder_(\w+)\&/) {
4078: my $group = $1;
4079: if ($url =~ /group_boards_\Q$group\E/) {
4080: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4081: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4082: if (keys(%groupsettings) > 0) {
4083: if (ref($groupsettings{'functions'}) eq 'HASH') {
4084: if ($groupsettings{'functions'}{'discussion'} eq 'on') {
4085: $denied{'remove'} = 1;
4086: }
4087: }
4088: }
4089: $denied{'cut'} = 1;
4090: $denied{'copy'} = 1;
4091: }
4092: }
4093: }
4094: return %denied;
4095: }
4096:
1.533 raeburn 4097: sub new_timebased_suffix {
1.538 raeburn 4098: my ($dom,$num,$type,$area,$container) = @_;
1.533 raeburn 4099: my ($prefix,$namespace,$idtype,$errtext,$locknotfreed);
1.538 raeburn 4100: if ($type eq 'paste') {
4101: $prefix = $type;
4102: $namespace = 'courseeditor';
1.587 raeburn 4103: $idtype = 'addcode';
1.538 raeburn 4104: } elsif ($type eq 'map') {
1.533 raeburn 4105: $prefix = 'docs';
4106: if ($area eq 'supplemental') {
4107: $prefix = 'supp';
4108: }
4109: $prefix .= $container;
4110: $namespace = 'uploadedmaps';
4111: } else {
4112: $prefix = $type;
4113: $namespace = 'templated';
1.504 raeburn 4114: }
4115: my ($suffix,$freedlock,$error) =
1.587 raeburn 4116: &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num,$idtype);
1.504 raeburn 4117: if (!$suffix) {
1.538 raeburn 4118: if ($type eq 'paste') {
4119: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.');
4120: } elsif ($type eq 'map') {
1.533 raeburn 4121: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
4122: } elsif ($type eq 'smppg') {
4123: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.');
4124: } else {
1.565 bisitz 4125: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new discussion board.');
1.533 raeburn 4126: }
1.504 raeburn 4127: if ($error) {
4128: $errtext .= '<br />'.$error;
4129: }
4130: }
4131: if ($freedlock ne 'ok') {
1.533 raeburn 4132: $locknotfreed =
4133: '<div class="LC_error">'.
4134: &mt('There was a problem removing a lockfile.').' ';
1.538 raeburn 4135: if ($type eq 'paste') {
1.591 raeburn 4136: if ($freedlock eq 'nolock') {
4137: $locknotfreed =
4138: '<div class="LC_error">'.
4139: &mt('A lockfile was not released when you added content to the clipboard earlier in this session.').' '.
4140:
1.593 droeschl 4141: &mt('As a result addition of items to the clipboard will be unavailable until your next log-in.');
1.591 raeburn 4142: } else {
4143: $locknotfreed .=
4144: &mt('This will prevent addition of items to the clipboard until your next log-in.');
4145: }
1.538 raeburn 4146: } elsif ($type eq 'map') {
1.591 raeburn 4147: $locknotfreed .=
4148: &mt('This will prevent creation of additional folders or composite pages in this course.');
1.533 raeburn 4149: } elsif ($type eq 'smppg') {
4150: $locknotfreed .=
4151: &mt('This will prevent creation of additional simple pages in this course.');
4152: } else {
4153: $locknotfreed .=
1.565 bisitz 4154: &mt('This will prevent creation of additional discussion boards in this course.');
1.533 raeburn 4155: }
1.538 raeburn 4156: unless ($type eq 'paste') {
4157: $locknotfreed .=
1.560 raeburn 4158: ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
4159: '<a href="/adm/helpdesk" target="_helpdesk">','</a>');
1.538 raeburn 4160: }
4161: $locknotfreed .= '</div>';
1.504 raeburn 4162: }
4163: return ($suffix,$errtext,$locknotfreed);
4164: }
4165:
1.329 droeschl 4166: =pod
4167:
4168: =item tiehash()
4169:
4170: tie the hash
4171:
4172: =cut
4173:
4174: sub tiehash {
4175: my ($mode)=@_;
4176: $hashtied=0;
4177: if ($env{'request.course.fn'}) {
4178: if ($mode eq 'write') {
4179: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4180: &GDBM_WRCREAT(),0640)) {
4181: $hashtied=2;
4182: }
4183: } else {
4184: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4185: &GDBM_READER(),0640)) {
4186: $hashtied=1;
4187: }
4188: }
1.364 bisitz 4189: }
1.329 droeschl 4190: }
4191:
4192: sub untiehash {
4193: if ($hashtied) { untie %hash; }
4194: $hashtied=0;
4195: return OK;
4196: }
4197:
4198:
4199:
4200:
4201: sub checkonthis {
4202: my ($r,$url,$level,$title)=@_;
4203: $url=&unescape($url);
4204: $alreadyseen{$url}=1;
4205: $r->rflush();
4206: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
4207: $r->print("\n<br />");
4208: if ($level==0) {
4209: $r->print("<br />");
4210: }
4211: for (my $i=0;$i<=$level*5;$i++) {
4212: $r->print(' ');
4213: }
4214: $r->print('<a href="'.$url.'" target="cat">'.
4215: ($title?$title:$url).'</a> ');
4216: if ($url=~/^\/res\//) {
4217: my $result=&Apache::lonnet::repcopy(
4218: &Apache::lonnet::filelocation('',$url));
4219: if ($result eq 'ok') {
4220: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
4221: $r->rflush();
4222: &Apache::lonnet::countacc($url);
4223: $url=~/\.(\w+)$/;
4224: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
4225: $r->print('<br />');
4226: $r->rflush();
4227: for (my $i=0;$i<=$level*5;$i++) {
4228: $r->print(' ');
4229: }
4230: $r->print('- '.&mt('Rendering:').' ');
4231: my ($errorcount,$warningcount)=split(/:/,
4232: &Apache::lonnet::ssi_body($url,
4233: ('grade_target'=>'web',
4234: 'return_only_error_and_warning_counts' => 1)));
4235: if (($errorcount) ||
4236: ($warningcount)) {
4237: if ($errorcount) {
1.369 bisitz 4238: $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1.329 droeschl 4239: &mt('[quant,_1,error]',$errorcount).'</span>');
4240: }
4241: if ($warningcount) {
4242: $r->print('<span class="LC_warning">'.
4243: &mt('[quant,_1,warning]',$warningcount).'</span>');
4244: }
4245: } else {
4246: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
4247: }
4248: $r->rflush();
4249: }
4250: my $dependencies=
4251: &Apache::lonnet::metadata($url,'dependencies');
4252: foreach my $dep (split(/\,/,$dependencies)) {
4253: if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
4254: &checkonthis($r,$dep,$level+1);
4255: }
4256: }
4257: } elsif ($result eq 'unavailable') {
4258: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
4259: } elsif ($result eq 'not_found') {
4260: unless ($url=~/\$/) {
1.521 bisitz 4261: $r->print('<span class="LC_error">'.&mt('not found').'</span>');
1.329 droeschl 4262: } else {
1.366 bisitz 4263: $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1.329 droeschl 4264: }
4265: } else {
4266: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
4267: }
4268: }
4269: }
4270: }
4271:
4272:
4273:
4274: =pod
4275:
4276: =item list_symbs()
4277:
1.485 raeburn 4278: List Content Identifiers
1.329 droeschl 4279:
4280: =cut
4281:
4282: sub list_symbs {
4283: my ($r) = @_;
4284:
1.408 raeburn 4285: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 4286: $r->print(&Apache::loncommon::start_page('List of Content Identifiers'));
4287: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Identifiers'));
4288: $r->print(&startContentScreen('tools'));
1.329 droeschl 4289: my $navmap = Apache::lonnavmaps::navmap->new();
4290: if (!defined($navmap)) {
4291: $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
4292: '<div class="LC_error">'.
4293: &mt('Unable to retrieve information about course contents').
4294: '</div>');
1.408 raeburn 4295: &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
1.329 droeschl 4296: } else {
1.484 raeburn 4297: $r->print('<h4 class="LC_info">'.&mt("$crstype Content Identifiers").'</h4>'.
4298: &Apache::loncommon::start_data_table().
4299: &Apache::loncommon::start_data_table_header_row().
4300: '<th>'.&mt('Title').'</th><th>'.&mt('Identifier').'</th>'.
4301: &Apache::loncommon::end_data_table_header_row()."\n");
4302: my $count;
1.329 droeschl 4303: foreach my $res ($navmap->retrieveResources()) {
1.484 raeburn 4304: $r->print(&Apache::loncommon::start_data_table_row().
4305: '<td>'.$res->compTitle().'</td>'.
4306: '<td>'.$res->symb().'</td>'.
1.521 bisitz 4307: &Apache::loncommon::end_data_table_row());
1.484 raeburn 4308: $count ++;
4309: }
4310: if (!$count) {
4311: $r->print(&Apache::loncommon::start_data_table_row().
4312: '<td colspan="2">'.&mt("$crstype is empty").'</td>'.
4313: &Apache::loncommon::end_data_table_row());
1.329 droeschl 4314: }
1.484 raeburn 4315: $r->print(&Apache::loncommon::end_data_table());
1.329 droeschl 4316: }
1.521 bisitz 4317: $r->print(&endContentScreen());
1.329 droeschl 4318: }
4319:
4320:
4321: sub verifycontent {
4322: my ($r) = @_;
1.408 raeburn 4323: my $crstype = &Apache::loncommon::course_type();
1.549 raeburn 4324: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
4325: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
1.484 raeburn 4326: $r->print(&startContentScreen('tools'));
4327: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
1.329 droeschl 4328: $hashtied=0;
4329: undef %alreadyseen;
4330: %alreadyseen=();
4331: &tiehash();
1.484 raeburn 4332:
1.329 droeschl 4333: foreach my $key (keys(%hash)) {
4334: if ($hash{$key}=~/\.(page|sequence)$/) {
4335: if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
4336: $r->print('<hr /><span class="LC_error">'.
1.419 bisitz 4337: &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
1.329 droeschl 4338: &unescape($hash{$key}).'</span><br />'.
1.419 bisitz 4339: &mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />');
1.329 droeschl 4340: }
4341: }
4342: if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
4343: &checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
4344: }
4345: }
4346: &untiehash();
1.442 www 4347: $r->print('<p class="LC_success">'.&mt('Done').'</p>');
1.521 bisitz 4348: $r->print(&endContentScreen());
1.329 droeschl 4349: }
4350:
4351:
4352: sub devalidateversioncache {
4353: my $src=shift;
4354: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
4355: &Apache::lonnet::clutter($src));
4356: }
4357:
4358: sub checkversions {
4359: my ($r) = @_;
1.408 raeburn 4360: my $crstype = &Apache::loncommon::course_type();
1.571 raeburn 4361: $r->print(&Apache::loncommon::start_page("Check $crstype Resource Versions"));
4362: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Resource Versions"));
1.484 raeburn 4363: $r->print(&startContentScreen('tools'));
1.442 www 4364:
1.329 droeschl 4365: my $header='';
4366: my $startsel='';
4367: my $monthsel='';
4368: my $weeksel='';
4369: my $daysel='';
4370: my $allsel='';
4371: my %changes=();
4372: my $starttime=0;
4373: my $haschanged=0;
4374: my %setversions=&Apache::lonnet::dump('resourceversions',
4375: $env{'course.'.$env{'request.course.id'}.'.domain'},
4376: $env{'course.'.$env{'request.course.id'}.'.num'});
4377:
4378: $hashtied=0;
4379: &tiehash();
4380: my %newsetversions=();
4381: if ($env{'form.setmostrecent'}) {
4382: $haschanged=1;
4383: foreach my $key (keys(%hash)) {
4384: if ($key=~/^ids\_(\/res\/.+)$/) {
4385: $newsetversions{$1}='mostrecent';
4386: &devalidateversioncache($1);
4387: }
4388: }
4389: } elsif ($env{'form.setcurrent'}) {
4390: $haschanged=1;
4391: foreach my $key (keys(%hash)) {
4392: if ($key=~/^ids\_(\/res\/.+)$/) {
4393: my $getvers=&Apache::lonnet::getversion($1);
4394: if ($getvers>0) {
4395: $newsetversions{$1}=$getvers;
4396: &devalidateversioncache($1);
4397: }
4398: }
4399: }
4400: } elsif ($env{'form.setversions'}) {
4401: $haschanged=1;
4402: foreach my $key (keys(%env)) {
4403: if ($key=~/^form\.set_version_(.+)$/) {
4404: my $src=$1;
4405: if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
4406: $newsetversions{$src}=$env{$key};
4407: &devalidateversioncache($src);
4408: }
4409: }
4410: }
4411: }
4412: if ($haschanged) {
4413: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
4414: $env{'course.'.$env{'request.course.id'}.'.domain'},
1.344 bisitz 4415: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
1.479 golterma 4416: $r->print(&Apache::loncommon::confirmwrapper(
4417: &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
1.329 droeschl 4418: } else {
1.479 golterma 4419: $r->print(&Apache::loncommon::confirmwrapper(
4420: &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
1.329 droeschl 4421: }
4422: &mark_hash_old();
4423: }
4424: &changewarning($r,'');
4425: if ($env{'form.timerange'} eq 'all') {
4426: # show all documents
1.549 raeburn 4427: $header=&mt('All content in '.$crstype);
1.521 bisitz 4428: $allsel=' selected="selected"';
1.329 droeschl 4429: foreach my $key (keys(%hash)) {
4430: if ($key=~/^ids\_(\/res\/.+)$/) {
4431: my $src=$1;
4432: $changes{$src}=1;
4433: }
4434: }
4435: } else {
4436: # show documents which changed
4437: %changes=&Apache::lonnet::dump
4438: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
4439: $env{'course.'.$env{'request.course.id'}.'.num'});
4440: my $firstkey=(keys(%changes))[0];
4441: unless ($firstkey=~/^error\:/) {
4442: unless ($env{'form.timerange'}) {
4443: $env{'form.timerange'}=604800;
4444: }
4445: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
4446: .&mt('seconds');
4447: if ($env{'form.timerange'}==-1) {
4448: $seltext='since start of course';
1.521 bisitz 4449: $startsel=' selected="selected"';
1.329 droeschl 4450: $env{'form.timerange'}=time;
4451: }
4452: $starttime=time-$env{'form.timerange'};
4453: if ($env{'form.timerange'}==2592000) {
4454: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 4455: $monthsel=' selected="selected"';
1.329 droeschl 4456: } elsif ($env{'form.timerange'}==604800) {
4457: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 4458: $weeksel=' selected="selected"';
1.329 droeschl 4459: } elsif ($env{'form.timerange'}==86400) {
4460: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 4461: $daysel=' selected="selected"';
1.329 droeschl 4462: }
4463: $header=&mt('Content changed').' '.$seltext;
4464: } else {
4465: $header=&mt('No content modifications yet.');
4466: }
4467: }
4468: %setversions=&Apache::lonnet::dump('resourceversions',
4469: $env{'course.'.$env{'request.course.id'}.'.domain'},
4470: $env{'course.'.$env{'request.course.id'}.'.num'});
4471: my %lt=&Apache::lonlocal::texthash
1.408 raeburn 4472: ('st' => 'Version changes since start of '.$crstype,
1.329 droeschl 4473: 'lm' => 'Version changes since last Month',
4474: 'lw' => 'Version changes since last Week',
4475: 'sy' => 'Version changes since Yesterday',
4476: 'al' => 'All Resources (possibly large output)',
1.484 raeburn 4477: 'cd' => 'Change display',
1.329 droeschl 4478: 'sd' => 'Display',
4479: 'fi' => 'File',
4480: 'md' => 'Modification Date',
4481: 'mr' => 'Most recently published Version',
1.408 raeburn 4482: 've' => 'Version used in '.$crstype,
4483: 'vu' => 'Set Version to be used in '.$crstype,
4484: 'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
1.329 droeschl 4485: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
4486: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.479 golterma 4487: 'di' => 'Differences',
1.484 raeburn 4488: 'save' => 'Save changes',
4489: 'vers' => 'Version choice(s) for specific resources',
1.479 golterma 4490: 'act' => 'Actions');
1.329 droeschl 4491: $r->print(<<ENDHEADERS);
1.484 raeburn 4492: <h4 class="LC_info">$header</h4>
1.329 droeschl 4493: <form action="/adm/coursedocs" method="post">
4494: <input type="hidden" name="versions" value="1" />
1.484 raeburn 4495: <div class="LC_left_float">
1.479 golterma 4496: <fieldset>
1.484 raeburn 4497: <legend>$lt{'cd'}</legend>
1.329 droeschl 4498: <select name="timerange">
1.521 bisitz 4499: <option value='all'$allsel>$lt{'al'}</option>
4500: <option value="-1"$startsel>$lt{'st'}</option>
4501: <option value="2592000"$monthsel>$lt{'lm'}</option>
4502: <option value="604800"$weeksel>$lt{'lw'}</option>
4503: <option value="86400"$daysel>$lt{'sy'}</option>
1.329 droeschl 4504: </select>
4505: <input type="submit" name="display" value="$lt{'sd'}" />
1.484 raeburn 4506: </fieldset>
4507: </div>
4508: <div class="LC_left_float">
4509: <fieldset>
4510: <legend>$lt{'act'}</legend>
4511: $lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" /><br />
4512: $lt{'sc'}: <input type="submit" name="setcurrent" value="Go" />
4513: </fieldset>
4514: </div>
4515: <br clear="all" />
4516: <hr />
4517: <h4>$lt{'vers'}</h4>
1.329 droeschl 4518: ENDHEADERS
1.479 golterma 4519: #number of columns for version history
1.571 raeburn 4520: my %changedbytime;
4521: foreach my $key (keys(%changes)) {
4522: #excludes not versionable problems from resource version history:
4523: next if ($key =~ /^\/res\/lib\/templates/);
4524: my $chg;
4525: if ($env{'form.timerange'} eq 'all') {
4526: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
4527: $chg = &Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate');
4528: } else {
4529: $chg = $changes{$key};
4530: next if ($chg < $starttime);
4531: }
4532: push(@{$changedbytime{$chg}},$key);
4533: }
4534: if (keys(%changedbytime) == 0) {
4535: &untiehash();
4536: $r->print(&mt('No content changes in imported content in specified time frame').
4537: &endContentScreen());
4538: return;
4539: }
1.479 golterma 4540: $r->print(
1.571 raeburn 4541: '<input type="submit" name="setversions" value="'.$lt{'save'}.'" />'.
1.521 bisitz 4542: &Apache::loncommon::start_data_table().
4543: &Apache::loncommon::start_data_table_header_row().
4544: '<th>'.&mt('Resources').'</th>'.
4545: "<th>$lt{'mr'}</th>".
4546: "<th>$lt{'ve'}</th>".
4547: "<th>$lt{'vu'}</th>".
4548: '<th>'.&mt('History').'</th>'.
4549: &Apache::loncommon::end_data_table_header_row()
4550: );
1.571 raeburn 4551: foreach my $chg (sort {$b <=> $a } keys(%changedbytime)) {
4552: foreach my $key (sort(@{$changedbytime{$chg}})) {
4553: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
4554: my $currentversion=&Apache::lonnet::getversion($key);
4555: if ($currentversion<0) {
4556: $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
4557: }
4558: my $linkurl=&Apache::lonnet::clutter($key);
4559: $r->print(
4560: &Apache::loncommon::start_data_table_row().
4561: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br />'.
4562: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
4563: '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br />('.
4564: &Apache::lonlocal::locallocaltime($chg).')</span></td>'.
4565: '<td align="right">'
4566: );
4567: # Used in course
4568: my $usedversion=$hash{'version_'.$linkurl};
4569: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.521 bisitz 4570: if ($usedversion != $currentversion) {
1.479 golterma 4571: $r->print('<span class="LC_warning">'.$usedversion.'</span>');
1.521 bisitz 4572: } else {
1.479 golterma 4573: $r->print($usedversion);
4574: }
1.329 droeschl 4575: } else {
1.521 bisitz 4576: $r->print($currentversion);
1.329 droeschl 4577: }
1.571 raeburn 4578: $r->print('</td><td title="'.$lt{'vu'}.'">');
4579: # Set version
4580: $r->print(&Apache::loncommon::select_form(
4581: $setversions{$linkurl},
4582: 'set_version_'.$linkurl,
4583: {'select_form_order' => ['',1..$currentversion,'mostrecent'],
4584: '' => '',
4585: 'mostrecent' => &mt('most recent'),
4586: map {$_,$_} (1..$currentversion)}));
4587: my $lastold=1;
4588: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
4589: my $url=$root.'.'.$prevvers.'.'.$extension;
4590: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) {
4591: $lastold=$prevvers;
4592: }
4593: }
4594: $r->print('</td>');
4595: # List all available versions
4596: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
4597: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
4598: my $url=$root.'.'.$prevvers.'.'.$extension;
4599: $r->print(
4600: '<span class="LC_nobreak">'
4601: .'<a href="'.&Apache::lonnet::clutter($url).'">'
4602: .&mt('Version [_1]',$prevvers).'</a>'
4603: .' ('.&Apache::lonlocal::locallocaltime(
1.521 bisitz 4604: &Apache::lonnet::metadata($url,'lastrevisiondate'))
1.571 raeburn 4605: .')');
4606: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
4607: $r->print(
4608: ' <a href="/adm/diff?filename='.
4609: &Apache::lonnet::clutter($root.'.'.$extension).
4610: &HTML::Entities::encode('&versionone='.$prevvers,'"<>&').
4611: '" target="diffs">'.&mt('Diffs').'</a>');
4612: }
4613: $r->print('</span><br />');
1.329 droeschl 4614: }
1.571 raeburn 4615: $r->print('</span></td>'.&Apache::loncommon::end_data_table_row());
1.521 bisitz 4616: }
1.329 droeschl 4617: }
1.521 bisitz 4618: $r->print(
4619: &Apache::loncommon::end_data_table().
4620: '<input type="submit" name="setversions" value="'.$lt{'save'}.'" />'.
4621: '</form>'
4622: );
1.329 droeschl 4623:
4624: &untiehash();
1.521 bisitz 4625: $r->print(&endContentScreen());
1.571 raeburn 4626: return;
1.329 droeschl 4627: }
4628:
4629: sub mark_hash_old {
4630: my $retie_hash=0;
4631: if ($hashtied) {
4632: $retie_hash=1;
4633: &untiehash();
4634: }
4635: &tiehash('write');
4636: $hash{'old'}=1;
4637: &untiehash();
4638: if ($retie_hash) { &tiehash(); }
4639: }
4640:
4641: sub is_hash_old {
4642: my $untie_hash=0;
4643: if (!$hashtied) {
4644: $untie_hash=1;
4645: &tiehash();
4646: }
4647: my $return=$hash{'old'};
4648: if ($untie_hash) { &untiehash(); }
4649: return $return;
4650: }
4651:
4652: sub changewarning {
4653: my ($r,$postexec,$message,$url)=@_;
4654: if (!&is_hash_old()) { return; }
4655: my $pathvar='folderpath';
4656: my $path=&escape($env{'form.folderpath'});
4657: if (!defined($url)) {
4658: $url='/adm/coursedocs?'.$pathvar.'='.$path;
4659: }
4660: my $course_type = &Apache::loncommon::course_type();
4661: if (!defined($message)) {
4662: $message='Changes will become active for your current session after [_1], or the next time you log in.';
4663: }
4664: $r->print("\n\n".
1.372 bisitz 4665: '<script type="text/javascript">'."\n".
4666: '// <![CDATA['."\n".
4667: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
4668: '// ]]>'."\n".
1.369 bisitz 4669: '</script>'."\n".
1.375 tempelho 4670: '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
1.329 droeschl 4671: '<input type="hidden" name="orgurl" value="'.$url.
1.372 bisitz 4672: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
1.329 droeschl 4673: &mt($message,' <input type="hidden" name="'.
4674: $env{'request.role'}.'" value="1" /><input type="button" value="'.
1.369 bisitz 4675: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1.372 bisitz 4676: $help{'Caching'}.'</p></form>'."\n\n");
1.329 droeschl 4677: }
4678:
4679:
4680: sub init_breadcrumbs {
1.571 raeburn 4681: my ($form,$text,$help)=@_;
1.329 droeschl 4682: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484 raeburn 4683: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
1.405 bisitz 4684: text=>&Apache::loncommon::course_type().' Editor',
1.329 droeschl 4685: faq=>273,
4686: bug=>'Instructor Interface',
1.571 raeburn 4687: help => $help});
1.329 droeschl 4688: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
4689: text=>$text,
4690: faq=>273,
4691: bug=>'Instructor Interface'});
4692: }
4693:
1.441 www 4694: # subroutine to list form elements
4695: sub create_list_elements {
4696: my @formarr = @_;
4697: my $list = '';
1.501 raeburn 4698: foreach my $button (@formarr){
4699: foreach my $picture (keys(%{$button})) {
4700: $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
1.441 www 4701: }
4702: }
4703: return $list;
4704: }
1.329 droeschl 4705:
1.441 www 4706: # subroutine to create ul from list elements
4707: sub create_form_ul {
4708: my $list = shift;
4709: my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
4710: return $ul;
4711: }
1.329 droeschl 4712:
1.442 www 4713: #
4714: # Start tabs
4715: #
4716:
4717: sub startContentScreen {
1.484 raeburn 4718: my ($mode) = @_;
4719: my $output = '<ul class="LC_TabContentBigger" id="mainnav">';
1.472 raeburn 4720: if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
1.484 raeburn 4721: $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n";
4722: $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n";
4723: $output .= '<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b> '.&mt('Content Index').' </b></a></li>'."\n";
4724: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
4725: } else {
1.549 raeburn 4726: $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 4727: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
4728: $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>'."\n";
4729: '><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>';
4730: }
4731: $output .= "\n".'</ul>'."\n";
4732: $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
4733: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
4734: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
4735: return $output;
1.442 www 4736: }
4737:
4738: #
4739: # End tabs
4740: #
4741:
4742: sub endContentScreen {
1.484 raeburn 4743: return '</div></div></div>';
1.442 www 4744: }
1.329 droeschl 4745:
1.446 www 4746: sub supplemental_base {
1.548 raeburn 4747: return 'supplemental&'.&escape(&mt('Supplemental Content'));
1.446 www 4748: }
4749:
1.329 droeschl 4750: sub handler {
4751: my $r = shift;
4752: &Apache::loncommon::content_type($r,'text/html');
4753: $r->send_http_header;
4754: return OK if $r->header_only;
1.484 raeburn 4755:
4756: # get course data
1.408 raeburn 4757: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 4758: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
4759: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
4760:
4761: # graphics settings
4762: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329 droeschl 4763:
1.443 www 4764: #
1.329 droeschl 4765: # --------------------------------------------- Initialize help topics for this
4766: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
4767: 'Adding_External_Resource','Navigate_Content',
4768: 'Adding_Folders','Docs_Overview', 'Load_Map',
4769: 'Supplemental','Score_Upload_Form','Adding_Pages',
1.501 raeburn 4770: 'Importing_LON-CAPA_Resource','Importing_IMS_Course',
1.571 raeburn 4771: 'Uploading_From_Harddrive','Course_Roster','Web_Page',
1.572 raeburn 4772: 'Dropbox','Simple_Problem') {
1.329 droeschl 4773: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
4774: }
4775: # Composite help files
4776: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
4777: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
4778: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
4779: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
4780: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
4781: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 4782: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 4783: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 4784: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 4785: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1.534 raeburn 4786:
1.472 raeburn 4787: my $allowed;
4788: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
4789: unless ($r->uri eq '/adm/supplemental') {
4790: # does this user have privileges to modify content.
4791: $allowed = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
4792: }
4793:
1.582 raeburn 4794: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']);
4795: if ($allowed && $env{'form.verify'}) {
1.571 raeburn 4796: &init_breadcrumbs('verify','Verify Content','Docs_Verify_Content');
1.329 droeschl 4797: &verifycontent($r);
4798: } elsif ($allowed && $env{'form.listsymbs'}) {
1.484 raeburn 4799: &init_breadcrumbs('listsymbs','List Content IDs');
1.329 droeschl 4800: &list_symbs($r);
4801: } elsif ($allowed && $env{'form.docslog'}) {
4802: &init_breadcrumbs('docslog','Show Log');
1.484 raeburn 4803: my $folder = $env{'form.folder'};
4804: if ($folder eq '') {
4805: $folder='default';
4806: }
4807: &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath);
1.329 droeschl 4808: } elsif ($allowed && $env{'form.versions'}) {
1.571 raeburn 4809: &init_breadcrumbs('versions','Check/Set Resource Versions','Docs_Check_Resource_Versions');
1.329 droeschl 4810: &checkversions($r);
4811: } elsif ($allowed && $env{'form.dumpcourse'}) {
1.568 raeburn 4812: &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329 droeschl 4813: &dumpcourse($r);
4814: } elsif ($allowed && $env{'form.exportcourse'}) {
1.377 bisitz 4815: &init_breadcrumbs('exportcourse','IMS Export');
1.475 raeburn 4816: &Apache::imsexport::exportcourse($r);
1.329 droeschl 4817: } else {
1.445 www 4818: #
4819: # Done catching special calls
1.484 raeburn 4820: # The whole rest is for course and supplemental documents and utilities menu
1.445 www 4821: # Get the parameters that may be needed
4822: #
4823: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.519 raeburn 4824: ['folderpath',
4825: 'forcesupplement','forcestandard',
1.510 raeburn 4826: 'tools','symb','command','supppath']);
1.445 www 4827:
4828: # standard=1: this is a "new-style" course with an uploaded map as top level
4829: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329 droeschl 4830:
4831: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445 www 4832:
1.484 raeburn 4833: # Decide whether this should display supplemental or main content or utilities
1.445 www 4834: # supplementalflag=1: show supplemental documents
4835: # supplementalflag=0: show standard documents
1.484 raeburn 4836: # toolsflag=1: show utilities
1.445 www 4837:
1.561 raeburn 4838: my $unesc_folderpath = &unescape($env{'form.folderpath'});
4839: my $supplementalflag=($unesc_folderpath=~/^supplemental/);
4840: if (($unesc_folderpath=~/^default/) || ($unesc_folderpath eq "")) {
1.445 www 4841: $supplementalflag=0;
4842: }
4843: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
4844: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
4845: unless ($allowed) { $supplementalflag=1; }
4846: unless ($standard) { $supplementalflag=1; }
1.484 raeburn 4847: my $toolsflag=0;
4848: if ($env{'form.tools'}) { $toolsflag=1; }
1.445 www 4849:
1.329 droeschl 4850: my $script='';
4851: my $showdoc=0;
1.457 raeburn 4852: my $addentries = {};
1.475 raeburn 4853: my $container;
1.329 droeschl 4854: my $containertag;
1.508 raeburn 4855: my $pathitem;
1.598 raeburn 4856: my %ltitools;
1.329 droeschl 4857:
1.464 www 4858: # Do we directly jump somewhere?
1.466 www 4859:
1.525 raeburn 4860: if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
1.472 raeburn 4861: if ($env{'form.symb'} ne '') {
1.522 raeburn 4862: $env{'form.folderpath'}=
4863: &Apache::loncommon::symb_to_docspath($env{'form.symb'});
1.530 raeburn 4864: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
1.525 raeburn 4865: $env{'form.command'}.'_'.$env{'form.symb'}});
1.472 raeburn 4866: } elsif ($env{'form.supppath'} ne '') {
4867: $env{'form.folderpath'}=$env{'form.supppath'};
1.530 raeburn 4868: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
1.525 raeburn 4869: $env{'form.command'}.'_'.$env{'form.supppath'}});
1.466 www 4870: }
1.472 raeburn 4871: } elsif ($env{'form.command'} eq 'editdocs') {
1.525 raeburn 4872: $env{'form.folderpath'} = 'default&'.
1.548 raeburn 4873: &escape(&mt('Main Content').':::::');
1.525 raeburn 4874: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
1.472 raeburn 4875: } elsif ($env{'form.command'} eq 'editsupp') {
1.525 raeburn 4876: $env{'form.folderpath'} = 'supplemental&'.
1.538 raeburn 4877: &escape('Supplemental Content');
1.525 raeburn 4878: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
4879: } elsif ($env{'form.command'} eq 'contents') {
4880: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
4881: } elsif ($env{'form.command'} eq 'home') {
4882: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
1.464 www 4883: }
4884:
1.525 raeburn 4885:
1.445 www 4886: # Where do we store these for when we come back?
4887: my $stored_folderpath='docs_folderpath';
4888: if ($supplementalflag) {
4889: $stored_folderpath='docs_sup_folderpath';
4890: }
1.464 www 4891:
1.519 raeburn 4892: # No folderpath, and in edit mode, see if we have something stored
4893: if ((!$env{'form.folderpath'}) && $allowed) {
1.445 www 4894: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.510 raeburn 4895: {'folderpath' => 'scalar'});
1.523 raeburn 4896: unless (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
4897: undef($env{'form.folderpath'});
4898: }
1.329 droeschl 4899: }
1.446 www 4900:
4901: # If we are not allowed to make changes, all we can see are supplemental docs
1.409 raeburn 4902: if (!$allowed) {
1.446 www 4903: unless ($env{'form.folderpath'} =~ /^supplemental/) {
4904: $env{'form.folderpath'} = &supplemental_base();
1.409 raeburn 4905: }
4906: }
1.446 www 4907: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329 droeschl 4908: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446 www 4909: $env{'form.folderpath'} = &supplemental_base()
4910: .'&'.
1.329 droeschl 4911: $env{'form.folderpath'};
4912: }
1.446 www 4913: # If after all of this, we still don't have any paths, make them
1.519 raeburn 4914: unless ($env{'form.folderpath'}) {
1.446 www 4915: if ($supplementalflag) {
4916: $env{'form.folderpath'}=&supplemental_base();
4917: } else {
1.548 raeburn 4918: $env{'form.folderpath'}='default&'.&escape(&mt('Main Content').
1.538 raeburn 4919: ':::::');
1.446 www 4920: }
1.472 raeburn 4921: }
1.446 www 4922:
1.445 www 4923: # Store this
1.484 raeburn 4924: unless ($toolsflag) {
1.510 raeburn 4925: if ($allowed) {
4926: &Apache::loncommon::store_course_settings($stored_folderpath,
1.519 raeburn 4927: {'folderpath' => 'scalar'});
1.510 raeburn 4928: }
1.519 raeburn 4929: my $folderpath;
1.484 raeburn 4930: if ($env{'form.folderpath'}) {
1.519 raeburn 4931: $folderpath = $env{'form.folderpath'};
4932: my (@folders)=split('&',$env{'form.folderpath'});
4933: $env{'form.foldername'}=&unescape(pop(@folders));
4934: if ($env{'form.foldername'} =~ /\:1$/) {
4935: $container = 'page';
4936: } else {
4937: $container = 'sequence';
4938: }
4939: $env{'form.folder'}=pop(@folders);
1.484 raeburn 4940: } else {
1.519 raeburn 4941: if ($env{'form.folder'} eq '' ||
4942: $env{'form.folder'} eq 'supplemental') {
4943: $folderpath='default&'.
1.548 raeburn 4944: &escape(&mt('Main Content').':::::');
1.484 raeburn 4945: }
4946: }
1.519 raeburn 4947: $containertag = '<input type="hidden" name="folderpath" value="" />';
4948: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 4949: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
4950: $showdoc='/'.$1;
4951: }
4952: if ($showdoc) { # got called in sequence from course
4953: $allowed=0;
4954: } else {
4955: if ($allowed) {
4956: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
4957: $script=&Apache::lonratedt::editscript('simple');
1.433 raeburn 4958: }
4959: }
1.329 droeschl 4960: }
4961:
1.344 bisitz 4962: # get personal data
1.329 droeschl 4963: my $uname=$env{'user.name'};
4964: my $udom=$env{'user.domain'};
4965: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
4966:
4967: if ($allowed) {
1.484 raeburn 4968: if ($toolsflag) {
4969: $script .= &inject_data_js();
4970: my ($home,$other,%outhash)=&authorhosts();
4971: if (!$home && $other) {
4972: my @hosts;
4973: foreach my $aurole (keys(%outhash)) {
4974: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
4975: push(@hosts,$outhash{$aurole});
4976: }
4977: }
4978: $script .= &dump_switchserver_js(@hosts);
4979: }
1.458 raeburn 4980: } else {
1.570 raeburn 4981: my $tid = 1;
1.484 raeburn 4982: my @tabids;
4983: if ($supplementalflag) {
4984: @tabids = ('002','ee2','ff2');
1.570 raeburn 4985: $tid = 2;
1.484 raeburn 4986: } else {
4987: @tabids = ('aa1','bb1','cc1','ff1');
1.519 raeburn 4988: unless ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 4989: unshift(@tabids,'001');
4990: push(@tabids,('dd1','ee1'));
4991: }
1.458 raeburn 4992: }
1.484 raeburn 4993: my $tabidstr = join("','",@tabids);
1.598 raeburn 4994: %ltitools = &Apache::lonnet::get_domain_ltitools($coursedom);
1.600 raeburn 4995: my $posslti = keys(%ltitools);
1.598 raeburn 4996: my $exttoolurl = "/adm/$coursedom/$coursenum/new/exttool";
1.600 raeburn 4997: $script .= &editing_js($udom,$uname,$supplementalflag,$posslti).
1.484 raeburn 4998: &history_tab_js().
4999: &inject_data_js().
1.570 raeburn 5000: &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
1.598 raeburn 5001: &Apache::lonextresedit::extedit_javascript(\%ltitools);
1.484 raeburn 5002: $addentries = {
1.485 raeburn 5003: onload => "javascript:resize_scrollbox('contentscroll','1','1');",
1.484 raeburn 5004: };
1.458 raeburn 5005: }
1.538 raeburn 5006: $script .= &paste_popup_js();
1.501 raeburn 5007: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
5008: &mt('Switch server?');
5009:
5010:
1.329 droeschl 5011: }
5012: # -------------------------------------------------------------------- Body tag
1.369 bisitz 5013: $script = '<script type="text/javascript">'."\n"
1.372 bisitz 5014: .'// <![CDATA['."\n"
5015: .$script."\n"
5016: .'// ]]>'."\n"
1.595 musolffc 5017: .'</script>'."\n"
5018: .'<script type="text/javascript"
5019: src="/res/adm/includes/file_upload.js"></script>'."\n";
1.385 bisitz 5020:
5021: # Breadcrumbs
5022: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.510 raeburn 5023:
5024: if ($showdoc) {
5025: $r->print(&Apache::loncommon::start_page("$crstype documents",undef,
5026: {'force_register' => $showdoc,}));
1.571 raeburn 5027: } elsif ($toolsflag) {
5028: &Apache::lonhtmlcommon::add_breadcrumb({
5029: href=>"/adm/coursedocs",text=>"$crstype Contents"});
5030: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script)
5031: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5032: .&Apache::lonhtmlcommon::breadcrumbs(
5033: 'Editing Course Contents')
5034: );
1.510 raeburn 5035: } elsif ($r->uri eq '/adm/supplemental') {
5036: my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
5037: $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
5038: {'bread_crumbs' => $brcrum,}));
5039: } else {
1.392 raeburn 5040: &Apache::lonhtmlcommon::add_breadcrumb({
1.446 www 5041: href=>"/adm/coursedocs",text=>"$crstype Contents"});
5042: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.510 raeburn 5043: {'add_entries' => $addentries}
5044: )
1.392 raeburn 5045: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5046: .&Apache::lonhtmlcommon::breadcrumbs(
1.484 raeburn 5047: 'Editing '.$crstype.' Contents',
1.392 raeburn 5048: 'Docs_Adding_Course_Doc')
5049: );
5050: }
1.364 bisitz 5051:
1.329 droeschl 5052: my %allfiles = ();
5053: my %codebase = ();
1.440 raeburn 5054: my ($upload_result,$upload_output,$uploadphase);
1.329 droeschl 5055: if ($allowed) {
5056: if (($env{'form.uploaddoc.filename'}) &&
5057: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440 raeburn 5058: my $context = $1;
5059: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 5060: undef($hadchanges);
1.440 raeburn 5061: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
1.552 raeburn 5062: \%allfiles,\%codebase,$context,$crstype);
1.329 droeschl 5063: if ($hadchanges) {
5064: &mark_hash_old();
5065: }
1.440 raeburn 5066: $r->print($upload_output);
5067: } elsif ($env{'form.phase'} eq 'upload_embedded') {
5068: # Process file upload - phase two - upload embedded objects
5069: $uploadphase = 'check_embedded';
5070: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
5071: my $state = &embedded_form_elems($uploadphase,$primaryurl,
5072: $env{'form.newidx'});
5073: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5074: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5075: my ($destination,$dir_root) = &embedded_destination();
5076: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
5077: my $actionurl = '/adm/coursedocs';
5078: my ($result,$flag) =
5079: &Apache::loncommon::upload_embedded('coursedoc',$destination,
5080: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
5081: $actionurl);
5082: $r->print($result.&return_to_editor());
5083: } elsif ($env{'form.phase'} eq 'check_embedded') {
5084: # Process file upload - phase three - modify references in HTML file
5085: $uploadphase = 'modified_orightml';
5086: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5087: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5088: my ($destination,$dir_root) = &embedded_destination();
1.482 raeburn 5089: my $result =
5090: &Apache::loncommon::modify_html_refs('coursedoc',$destination,
5091: $docuname,$docudom,undef,
5092: $dir_root);
5093: $r->print($result.&return_to_editor());
1.476 raeburn 5094: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
5095: $uploadphase = 'decompress_phase_one';
5096: $r->print(&decompression_phase_one().
5097: &return_to_editor());
5098: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
5099: $uploadphase = 'decompress_phase_two';
5100: $r->print(&decompression_phase_two().
5101: &return_to_editor());
1.329 droeschl 5102: }
5103: }
5104:
1.484 raeburn 5105: if ($allowed && $toolsflag) {
5106: $r->print(&startContentScreen('tools'));
5107: $r->print(&generate_admin_menu($crstype));
5108: $r->print(&endContentScreen());
5109: } elsif ((!$showdoc) && (!$uploadphase)) {
1.329 droeschl 5110: # -----------------------------------------------------------------------------
5111: my %lt=&Apache::lonlocal::texthash(
5112: 'copm' => 'All documents out of a published map into this folder',
1.501 raeburn 5113: 'upfi' => 'Upload File',
1.553 raeburn 5114: 'upld' => 'Upload Content',
1.329 droeschl 5115: 'srch' => 'Search',
5116: 'impo' => 'Import',
1.487 raeburn 5117: 'lnks' => 'Import from Stored Links',
1.502 raeburn 5118: 'impm' => 'Import from Assembled Map',
1.598 raeburn 5119: 'extr' => 'External Resource',
5120: 'extt' => 'External Tool',
1.329 droeschl 5121: 'selm' => 'Select Map',
5122: 'load' => 'Load Map',
5123: 'newf' => 'New Folder',
5124: 'newp' => 'New Composite Page',
5125: 'syll' => 'Syllabus',
1.425 raeburn 5126: 'navc' => 'Table of Contents',
1.343 biermanm 5127: 'sipa' => 'Simple Course Page',
1.329 droeschl 5128: 'sipr' => 'Simple Problem',
1.534 raeburn 5129: 'webp' => 'Blank Web Page (editable)',
1.329 droeschl 5130: 'drbx' => 'Drop Box',
1.451 www 5131: 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336 schafran 5132: 'bull' => 'Discussion Board',
1.347 weissno 5133: 'mypi' => 'My Personal Information Page',
1.353 weissno 5134: 'grpo' => 'Group Portfolio',
1.329 droeschl 5135: 'rost' => 'Course Roster',
1.528 raeburn 5136: 'abou' => 'Personal Information Page for a User',
1.553 raeburn 5137: 'imsf' => 'IMS Upload',
5138: 'imsl' => 'Upload IMS package',
1.501 raeburn 5139: 'cms' => 'Origin of IMS package',
5140: 'se' => 'Select',
1.329 droeschl 5141: 'file' => 'File',
5142: 'title' => 'Title',
5143: 'comment' => 'Comment',
1.403 raeburn 5144: 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.577 bisitz 5145: 'bb5' => 'Blackboard 5',
5146: 'bb6' => 'Blackboard 6',
5147: 'angel5' => 'ANGEL 5.5',
5148: 'webctce4' => 'WebCT 4 Campus Edition',
5149: );
1.329 droeschl 5150: # -----------------------------------------------------------------------------
1.595 musolffc 5151:
5152: # Calculate free quota space for a user or course. A javascript function checks
5153: # file size to determine if upload should be allowed.
5154: my $quotatype = 'unofficial';
5155: if ($crstype eq 'Community') {
1.601 raeburn 5156: $quotatype = 'community';
5157: } elsif ($crstype eq 'Placement') {
5158: $quotatype = 'placement';
1.595 musolffc 5159: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
5160: $quotatype = 'official';
5161: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
5162: $quotatype = 'textbook';
5163: }
5164: my $disk_quota = &Apache::loncommon::get_user_quota($coursenum,$coursedom,
5165: 'course',$quotatype); # expressed in MB
5166: my $current_disk_usage = 0;
5167: foreach my $subdir ('docs','supplemental') {
5168: $current_disk_usage += &Apache::lonnet::diskusage($coursedom,$coursenum,
5169: "userfiles/$subdir",1); # expressed in kB
5170: }
5171: my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage);
5172:
1.329 droeschl 5173: my $fileupload=(<<FIUP);
5174: $lt{'file'}:<br />
1.595 musolffc 5175: <input type="file" name="uploaddoc" class="flUpload" size="40" />
5176: <input type="hidden" id="free_space" value="$free_space" />
1.329 droeschl 5177: FIUP
5178:
5179: my $checkbox=(<<CHBO);
5180: <!-- <label>$lt{'parse'}?
5181: <input type="checkbox" name="parserflag" />
5182: </label> -->
5183: <label>
5184: <input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
5185: </label>
5186: CHBO
1.501 raeburn 5187: my $imsfolder = $env{'form.folder'};
5188: if ($imsfolder eq '') {
5189: $imsfolder = 'default';
5190: }
5191: my $imspform=(<<IMSFORM);
5192: <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
5193: $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
5194: <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
1.516 raeburn 5195: <fieldset id="uploadimsform" style="display: none;">
1.501 raeburn 5196: <legend>$lt{'imsf'}</legend>
5197: $fileupload
5198: <br />
5199: <p>
5200: $lt{'cms'}:
5201: <select name="source">
5202: <option value="-1" selected="selected">$lt{'se'}</option>
1.577 bisitz 5203: <option value="bb5">$lt{'bb5'}</option>
5204: <option value="bb6">$lt{'bb6'}</option>
5205: <option value="angel5">$lt{'angel5'}</option>
5206: <option value="webctce4">$lt{'webctce4'}</option>
1.501 raeburn 5207: </select>
5208: <input type="hidden" name="folder" value="$imsfolder" />
5209: </p>
5210: <input type="hidden" name="phase" value="one" />
5211: <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" />
5212: </fieldset>
5213: </form>
5214: IMSFORM
1.329 droeschl 5215:
5216: my $fileuploadform=(<<FUFORM);
1.501 raeburn 5217: <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
5218: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
5219: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.516 raeburn 5220: <fieldset id="uploaddocform" style="display: none;">
1.501 raeburn 5221: <legend>$lt{'upfi'}</legend>
1.371 tempelho 5222: <input type="hidden" name="active" value="aa" />
1.595 musolffc 5223: $fileupload
1.329 droeschl 5224: <br />
5225: $lt{'title'}:<br />
1.458 raeburn 5226: <input type="text" size="60" name="comment" />
1.508 raeburn 5227: $pathitem
1.329 droeschl 5228: <input type="hidden" name="cmd" value="upload_default" />
5229: <br />
1.458 raeburn 5230: <span class="LC_nobreak" style="float:left">
1.329 droeschl 5231: $checkbox
5232: </span>
1.501 raeburn 5233: <br clear="all" />
5234: <input type="submit" value="$lt{'upld'}" />
5235: </fieldset>
5236: </form>
1.383 tempelho 5237: FUFORM
1.329 droeschl 5238:
1.502 raeburn 5239: my $importpubform=(<<SEDFFORM);
1.514 raeburn 5240: <a class="LC_menubuttons_link" href="javascript:toggleMap('map');">
1.502 raeburn 5241: $lt{'impm'}</a>$help{'Load_Map'}
5242: <form action="/adm/coursedocs" method="post" name="mapimportform">
1.516 raeburn 5243: <fieldset id="importmapform" style="display: none;">
1.502 raeburn 5244: <legend>$lt{'impm'}</legend>
1.371 tempelho 5245: <input type="hidden" name="active" value="bb" />
1.502 raeburn 5246: $lt{'copm'}<br />
5247: <span class="LC_nobreak">
5248: <input type="text" name="importmap" size="40" value=""
5249: onfocus="this.blur();openbrowser('mapimportform','importmap','sequence,page','');" />
1.516 raeburn 5250: <a href="javascript:openbrowser('mapimportform','importmap','sequence,page','');">$lt{'selm'}</a></span><br />
1.502 raeburn 5251: <input type="submit" name="loadmap" value="$lt{'load'}" />
5252: </fieldset>
5253: </form>
5254:
1.383 tempelho 5255: SEDFFORM
1.502 raeburn 5256: my @importpubforma = (
1.508 raeburn 5257: { '<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 5258: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{impo}.'" onclick="javascript:groupimport();"/>' => "<a class='LC_menubuttons_link' href='javascript:groupimport();'>$lt{'impo'}</a>$help{'Importing_LON-CAPA_Resource'}" },
1.487 raeburn 5259: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{lnks}.'" onclick="javascript:open_StoredLinks_Import();" />' => "<a class='LC_menubuttons_link' href='javascript:open_StoredLinks_Import();'>$lt{'lnks'}</a>" },
1.514 raeburn 5260: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform }
1.383 tempelho 5261: );
1.502 raeburn 5262: $importpubform = &create_form_ul(&create_list_elements(@importpubforma));
1.510 raeburn 5263: my $extresourcesform =
5264: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
5265: $help{'Adding_External_Resource'});
1.598 raeburn 5266: my $exttoolform =
5267: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
5268: $help{'Adding_External_Tool'},undef,
5269: undef,'tool',$coursedom,$coursenum,
5270: \%ltitools);
1.329 droeschl 5271: if ($allowed) {
1.492 raeburn 5272: my $folder = $env{'form.folder'};
5273: if ($folder eq '') {
5274: $folder='default';
5275: }
1.538 raeburn 5276: my $output = &update_paste_buffer($coursenum,$coursedom,$folder);
5277: if ($output) {
5278: $r->print($output);
5279: }
1.337 ehlerst 5280: $r->print(<<HIDDENFORM);
5281: <form name="renameform" method="post" action="/adm/coursedocs">
5282: <input type="hidden" name="title" />
5283: <input type="hidden" name="cmd" />
5284: <input type="hidden" name="markcopy" />
5285: <input type="hidden" name="copyfolder" />
5286: $containertag
5287: </form>
1.484 raeburn 5288:
1.337 ehlerst 5289: HIDDENFORM
1.508 raeburn 5290: $r->print(&makesimpleeditform($pathitem)."\n".
5291: &makedocslogform($pathitem."\n".
1.484 raeburn 5292: '<input type="hidden" name="folder" value="'.
5293: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 5294: }
1.442 www 5295:
5296: # Generate the tabs
1.510 raeburn 5297: my ($mode,$needs_end);
1.472 raeburn 5298: if (($supplementalflag) && (!$allowed)) {
1.510 raeburn 5299: my @folders = split('&',$env{'form.folderpath'});
5300: unless (@folders > 2) {
5301: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
5302: $needs_end = 1;
5303: }
1.472 raeburn 5304: } else {
1.484 raeburn 5305: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.510 raeburn 5306: $needs_end = 1;
1.472 raeburn 5307: }
1.443 www 5308:
1.442 www 5309: #
5310:
5311: my $savefolderpath;
5312:
1.395 raeburn 5313: if ($allowed) {
1.329 droeschl 5314: my $folder=$env{'form.folder'};
1.443 www 5315: if ($folder eq '' || $supplementalflag) {
1.329 droeschl 5316: $folder='default';
1.356 tempelho 5317: $savefolderpath = $env{'form.folderpath'};
1.548 raeburn 5318: $env{'form.folderpath'}='default&'.&escape(&mt('Main Content'));
1.508 raeburn 5319: $pathitem = '<input type="hidden" name="folderpath" value="'.
1.329 droeschl 5320: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
5321: }
5322: my $postexec='';
5323: if ($folder eq 'default') {
1.372 bisitz 5324: $r->print('<script type="text/javascript">'."\n"
5325: .'// <![CDATA['."\n"
5326: .'this.window.name="loncapaclient";'."\n"
5327: .'// ]]>'."\n"
5328: .'</script>'."\n"
1.369 bisitz 5329: );
1.329 droeschl 5330: } else {
5331: #$postexec='self.close();';
5332: }
1.504 raeburn 5333: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
5334: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
1.329 droeschl 5335: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
5336:
5337: my $newnavform=(<<NNFORM);
5338: <form action="/adm/coursedocs" method="post" name="newnav">
1.570 raeburn 5339: <input type="hidden" name="active" value="ee" />
1.508 raeburn 5340: $pathitem
1.329 droeschl 5341: <input type="hidden" name="importdetail"
5342: value="$lt{'navc'}=/adm/navmaps" />
1.423 onken 5343: <a class="LC_menubuttons_link" href="javascript:document.newnav.submit()">$lt{'navc'}</a>
1.329 droeschl 5344: $help{'Navigate_Content'}
5345: </form>
5346: NNFORM
5347: my $newsmppageform=(<<NSPFORM);
5348: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.570 raeburn 5349: <input type="hidden" name="active" value="ee" />
1.508 raeburn 5350: $pathitem
1.329 droeschl 5351: <input type="hidden" name="importdetail" value="" />
1.423 onken 5352: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 5353: $help{'Simple Page'}
1.329 droeschl 5354: </form>
5355: NSPFORM
5356:
5357: my $newsmpproblemform=(<<NSPROBFORM);
5358: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371 tempelho 5359: <input type="hidden" name="active" value="cc" />
1.508 raeburn 5360: $pathitem
1.329 droeschl 5361: <input type="hidden" name="importdetail" value="" />
1.423 onken 5362: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.572 raeburn 5363: $help{'Simple_Problem'}
1.329 droeschl 5364: </form>
5365:
5366: NSPROBFORM
5367:
5368: my $newdropboxform=(<<NDBFORM);
5369: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.371 tempelho 5370: <input type="hidden" name="active" value="cc" />
1.508 raeburn 5371: $pathitem
1.329 droeschl 5372: <input type="hidden" name="importdetail" value="" />
1.423 onken 5373: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.554 raeburn 5374: $help{'Dropbox'}
1.344 bisitz 5375: </form>
1.329 droeschl 5376: NDBFORM
5377:
5378: my $newexuploadform=(<<NEXUFORM);
5379: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.371 tempelho 5380: <input type="hidden" name="active" value="cc" />
1.508 raeburn 5381: $pathitem
1.329 droeschl 5382: <input type="hidden" name="importdetail" value="" />
1.423 onken 5383: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 5384: $help{'Score_Upload_Form'}
5385: </form>
5386: NEXUFORM
5387:
5388: my $newbulform=(<<NBFORM);
5389: <form action="/adm/coursedocs" method="post" name="newbul">
1.570 raeburn 5390: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5391: $pathitem
1.329 droeschl 5392: <input type="hidden" name="importdetail" value="" />
1.423 onken 5393: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 5394: $help{'Bulletin Board'}
5395: </form>
5396: NBFORM
5397:
5398: my $newaboutmeform=(<<NAMFORM);
5399: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.570 raeburn 5400: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5401: $pathitem
1.329 droeschl 5402: <input type="hidden" name="importdetail"
5403: value="$plainname=/adm/$udom/$uname/aboutme" />
1.423 onken 5404: <a class="LC_menubuttons_link" href="javascript:document.newaboutme.submit()">$lt{'mypi'}</a>
1.347 weissno 5405: $help{'My Personal Information Page'}
1.329 droeschl 5406: </form>
5407: NAMFORM
5408:
5409: my $newaboutsomeoneform=(<<NASOFORM);
5410: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.570 raeburn 5411: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5412: $pathitem
1.329 droeschl 5413: <input type="hidden" name="importdetail" value="" />
1.423 onken 5414: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 5415: </form>
5416: NASOFORM
5417:
5418: my $newrosterform=(<<NROSTFORM);
5419: <form action="/adm/coursedocs" method="post" name="newroster">
1.570 raeburn 5420: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5421: $pathitem
1.329 droeschl 5422: <input type="hidden" name="importdetail"
5423: value="$lt{'rost'}=/adm/viewclasslist" />
1.423 onken 5424: <a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a>
1.556 raeburn 5425: $help{'Course_Roster'}
1.329 droeschl 5426: </form>
5427: NROSTFORM
5428:
1.534 raeburn 5429: my $newwebpage;
5430: if ($folder =~ /^default_?(\d*)$/) {
5431: $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
5432: if ($1) {
5433: $newwebpage .= $1;
5434: } else {
5435: $newwebpage .= 'default';
5436: }
5437: $newwebpage .= '/new.html';
5438: }
5439: my $newwebpageform =(<<NWEBFORM);
5440: <form action="/adm/coursedocs" method="post" name="newwebpage">
1.570 raeburn 5441: <input type="hidden" name="active" value="ee" />
1.534 raeburn 5442: $pathitem
5443: <input type="hidden" name="importdetail" value="$newwebpage" />
5444: <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
1.556 raeburn 5445: $help{'Web_Page'}
1.534 raeburn 5446: </form>
5447: NWEBFORM
5448:
5449:
1.342 ehlerst 5450: my $specialdocumentsform;
1.383 tempelho 5451: my @specialdocumentsforma;
1.451 www 5452: my $gradingform;
5453: my @gradingforma;
5454: my $communityform;
5455: my @communityforma;
1.351 ehlerst 5456: my $newfolderform;
1.390 tempelho 5457: my $newfolderb;
1.342 ehlerst 5458:
1.451 www 5459: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 5460:
1.329 droeschl 5461: my $newpageform=(<<NPFORM);
5462: <form action="/adm/coursedocs" method="post" name="newpage">
5463: <input type="hidden" name="folderpath" value="$path" />
5464: <input type="hidden" name="importdetail" value="" />
1.570 raeburn 5465: <input type="hidden" name="active" value="ee" />
1.423 onken 5466: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 5467: $help{'Adding_Pages'}
1.329 droeschl 5468: </form>
5469: NPFORM
1.390 tempelho 5470:
5471:
1.351 ehlerst 5472: $newfolderform=(<<NFFORM);
1.329 droeschl 5473: <form action="/adm/coursedocs" method="post" name="newfolder">
1.508 raeburn 5474: $pathitem
1.329 droeschl 5475: <input type="hidden" name="importdetail" value="" />
1.570 raeburn 5476: <input type="hidden" name="active" value="" />
1.422 onken 5477: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 5478: </form>
5479: NFFORM
5480:
5481: my $newsylform=(<<NSYLFORM);
5482: <form action="/adm/coursedocs" method="post" name="newsyl">
1.570 raeburn 5483: <input type="hidden" name="active" value="ee" />
1.508 raeburn 5484: $pathitem
1.329 droeschl 5485: <input type="hidden" name="importdetail"
5486: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.423 onken 5487: <a class="LC_menubuttons_link" href="javascript:document.newsyl.submit()">$lt{'syll'}</a>
1.329 droeschl 5488: $help{'Syllabus'}
1.383 tempelho 5489:
1.329 droeschl 5490: </form>
5491: NSYLFORM
1.364 bisitz 5492:
1.329 droeschl 5493: my $newgroupfileform=(<<NGFFORM);
5494: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.570 raeburn 5495: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5496: $pathitem
1.329 droeschl 5497: <input type="hidden" name="importdetail"
5498: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.423 onken 5499: <a class="LC_menubuttons_link" href="javascript:document.newgroupfiles.submit()">$lt{'grpo'}</a>
1.353 weissno 5500: $help{'Group Portfolio'}
1.329 droeschl 5501: </form>
5502: NGFFORM
1.383 tempelho 5503: @specialdocumentsforma=(
1.421 onken 5504: {'<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 5505: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.newsyl.submit()" />'=>$newsylform},
1.451 www 5506: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="document.newnav.submit()" />'=>$newnavform},
5507: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
1.534 raeburn 5508: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
1.451 www 5509: );
5510: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
5511:
1.434 raeburn 5512:
5513: my @importdoc = (
1.519 raeburn 5514: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform}
5515: );
1.598 raeburn 5516: if (keys(%ltitools)) {
5517: push(@importdoc,
5518: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extt}.'" onclick="toggleUpload(\'tool\');" />'=>$exttoolform},
5519: );
5520: }
1.519 raeburn 5521: unless ($container eq 'page') {
5522: push(@importdoc,
5523: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform}
5524: );
5525: }
5526: push(@importdoc,
1.558 raeburn 5527: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'doc\');" />'=>$fileuploadform}
1.519 raeburn 5528: );
1.501 raeburn 5529: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
1.434 raeburn 5530:
1.451 www 5531: @gradingforma=(
5532: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
5533: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
5534: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
5535:
5536: );
5537: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
5538:
5539: @communityforma=(
5540: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
5541: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
5542: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
5543: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="document.newroster.submit()" />'=>$newrosterform},
5544: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="document.newgroupfiles.submit()" />'=>$newgroupfileform},
5545: );
5546: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 5547:
1.330 tempelho 5548: my %orderhash = (
1.553 raeburn 5549: 'aa' => ['Upload',$fileuploadform],
5550: 'bb' => ['Import',$importpubform],
5551: 'cc' => ['Grading',$gradingform],
1.330 tempelho 5552: );
1.519 raeburn 5553: unless ($container eq 'page') {
1.434 raeburn 5554: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.484 raeburn 5555: $orderhash{'dd'} = ['Collaboration',$communityform];
1.553 raeburn 5556: $orderhash{'ee'} = ['Other',$specialdocumentsform];
1.434 raeburn 5557: }
5558:
1.341 ehlerst 5559: $hadchanges=0;
1.484 raeburn 5560: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 5561: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.598 raeburn 5562: $supplementalflag,\%orderhash,$iconpath,$pathitem,\%ltitools);
1.443 www 5563: if ($error) {
5564: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
5565: }
5566: if ($hadchanges) {
5567: &mark_hash_old();
5568: }
1.341 ehlerst 5569:
1.443 www 5570: &changewarning($r,'');
5571: }
1.458 raeburn 5572: }
1.442 www 5573:
1.443 www 5574: # Supplemental documents start here
5575:
1.329 droeschl 5576: my $folder=$env{'form.folder'};
1.443 www 5577: unless ($supplementalflag) {
1.329 droeschl 5578: $folder='supplemental';
5579: }
5580: if ($folder =~ /^supplemental$/ &&
5581: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 5582: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 5583: } elsif ($allowed) {
1.356 tempelho 5584: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 5585: }
1.508 raeburn 5586: $pathitem = '<input type="hidden" name="folderpath" value="'.
5587: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.329 droeschl 5588: if ($allowed) {
5589: my $folderseq=
1.504 raeburn 5590: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
1.329 droeschl 5591:
5592: my $supupdocform=(<<SUPDOCFORM);
1.501 raeburn 5593: <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
5594: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
1.383 tempelho 5595: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.516 raeburn 5596: <fieldset id="uploadsuppdocform" style="display: none;">
1.501 raeburn 5597: <legend>$lt{'upfi'}</legend>
1.371 tempelho 5598: <input type="hidden" name="active" value="ee" />
1.329 droeschl 5599: $fileupload
5600: <br />
5601: <br />
5602: <span class="LC_nobreak">
5603: $checkbox
5604: </span>
5605: <br /><br />
5606: $lt{'comment'}:<br />
1.383 tempelho 5607: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 5608: <br />
1.508 raeburn 5609: $pathitem
1.329 droeschl 5610: <input type="hidden" name="cmd" value="upload_supplemental" />
1.501 raeburn 5611: <input type='submit' value="$lt{'upld'}" />
5612: </form>
1.329 droeschl 5613: SUPDOCFORM
5614:
5615: my $supnewfolderform=(<<SNFFORM);
5616: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.570 raeburn 5617: <input type="hidden" name="active" value="" />
1.508 raeburn 5618: $pathitem
1.329 droeschl 5619: <input type="hidden" name="importdetail" value="" />
1.423 onken 5620: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 5621: $help{'Adding_Folders'}
1.329 droeschl 5622: </form>
5623: SNFFORM
1.383 tempelho 5624:
1.510 raeburn 5625: my $supextform =
5626: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
5627: $help{'Adding_External_Resource'});
1.329 droeschl 5628:
1.598 raeburn 5629: my $supexttoolform =
5630: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
5631: $help{'Adding_External_Tool'},
5632: undef,undef,'tool',$coursedom,
5633: $coursenum,\%ltitools);
5634:
1.329 droeschl 5635: my $supnewsylform=(<<SNSFORM);
5636: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 5637: <input type="hidden" name="active" value="ff" />
1.508 raeburn 5638: $pathitem
1.329 droeschl 5639: <input type="hidden" name="importdetail"
5640: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.423 onken 5641: <a class="LC_menubuttons_link" href="javascript:document.supnewsyl.submit()">$lt{'syll'}</a>
1.329 droeschl 5642: $help{'Syllabus'}
5643: </form>
5644: SNSFORM
5645:
5646: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 5647: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 5648: <input type="hidden" name="active" value="ff" />
1.508 raeburn 5649: $pathitem
1.329 droeschl 5650: <input type="hidden" name="importdetail"
5651: value="$plainname=/adm/$udom/$uname/aboutme" />
1.423 onken 5652: <a class="LC_menubuttons_link" href="javascript:document.supnewaboutme.submit()">$lt{'mypi'}</a>
1.347 weissno 5653: $help{'My Personal Information Page'}
1.329 droeschl 5654: </form>
5655: SNAMFORM
5656:
1.534 raeburn 5657: my $supwebpage;
5658: if ($folder =~ /^supplemental_?(\d*)$/) {
5659: $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
5660: if ($1) {
5661: $supwebpage .= $1;
5662: } else {
5663: $supwebpage .= 'default';
5664: }
5665: $supwebpage .= '/new.html';
5666: }
5667: my $supwebpageform =(<<SWEBFORM);
5668: <form action="/adm/coursedocs" method="post" name="supwebpage">
5669: <input type="hidden" name="active" value="cc" />
5670: $pathitem
5671: <input type="hidden" name="importdetail" value="$supwebpage" />
5672: <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
1.556 raeburn 5673: $help{'Web_Page'}
1.534 raeburn 5674: </form>
5675: SWEBFORM
5676:
1.333 muellerd 5677:
1.383 tempelho 5678: my @specialdocs = (
1.417 droeschl 5679: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.supnewsyl.submit()" />'
5680: =>$supnewsylform},
5681: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="document.supnewaboutme.submit()" />'
5682: =>$supnewaboutmeform},
1.534 raeburn 5683: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
5684:
1.383 tempelho 5685: );
1.417 droeschl 5686: my @supimportdoc = (
1.515 raeburn 5687: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleUpload(\'suppext\')" />'
1.598 raeburn 5688: =>$supextform});
5689: if (keys(%ltitools)) {
5690: push(@supimportdoc,
5691: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extt}.'" onclick="javascript:toggleUpload(\'supptool\')" />'
5692: =>$supexttoolform});
5693: }
5694: push(@supimportdoc,
5695: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
1.501 raeburn 5696: =>$supupdocform},
1.598 raeburn 5697: );
1.501 raeburn 5698:
5699: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
1.333 muellerd 5700: my %suporderhash = (
1.390 tempelho 5701: '00' => ['Supnewfolder', $supnewfolderform],
1.553 raeburn 5702: 'ee' => ['Upload',$supupdocform],
5703: 'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 5704: );
1.443 www 5705: if ($supplementalflag) {
1.458 raeburn 5706: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.598 raeburn 5707: $supplementalflag,\%suporderhash,$iconpath,$pathitem,\%ltitools);
1.443 www 5708: if ($error) {
5709: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.557 raeburn 5710: } else {
5711: if ($suppchanges) {
5712: my %servers = &Apache::lonnet::internet_dom_servers($coursedom);
5713: my @ids=&Apache::lonnet::current_machine_ids();
5714: foreach my $server (keys(%servers)) {
5715: next if (grep(/^\Q$server\E$/,@ids));
5716: my $hashid=$coursenum.':'.$coursedom;
1.566 raeburn 5717: my $cachekey = &escape('suppcount').':'.&escape($hashid);
5718: &Apache::lonnet::remote_devalidate_cache($server,[$cachekey]);
1.557 raeburn 5719: }
5720: &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
5721: undef($suppchanges);
5722: }
5723: }
1.393 raeburn 5724: }
1.443 www 5725: } elsif ($supplementalflag) {
1.458 raeburn 5726: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.508 raeburn 5727: $supplementalflag,'',$iconpath,$pathitem);
1.393 raeburn 5728: if ($error) {
5729: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 5730: }
1.393 raeburn 5731: }
1.389 tempelho 5732:
1.510 raeburn 5733: if ($needs_end) {
5734: $r->print(&endContentScreen());
5735: }
1.383 tempelho 5736:
1.329 droeschl 5737: if ($allowed) {
5738: $r->print('
5739: <form method="post" name="extimport" action="/adm/coursedocs">
5740: <input type="hidden" name="title" />
5741: <input type="hidden" name="url" />
5742: <input type="hidden" name="useform" />
5743: <input type="hidden" name="residx" />
5744: </form>');
5745: }
1.484 raeburn 5746: } elsif ($showdoc) {
1.329 droeschl 5747: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 5748: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.498 bisitz 5749: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 5750: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 5751: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 5752: }
5753: }
5754: $r->print(&Apache::loncommon::end_page());
5755: return OK;
1.364 bisitz 5756: }
1.329 droeschl 5757:
1.440 raeburn 5758: sub embedded_form_elems {
5759: my ($phase,$primaryurl,$newidx) = @_;
5760: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
5761: return <<STATE;
5762: <input type="hidden" name="folderpath" value="$folderpath" />
5763: <input type="hidden" name="cmd" value="upload_embedded" />
5764: <input type="hidden" name="newidx" value="$newidx" />
5765: <input type="hidden" name="phase" value="$phase" />
5766: <input type="hidden" name="primaryurl" value="$primaryurl" />
5767: STATE
5768: }
5769:
5770: sub embedded_destination {
5771: my $folder=$env{'form.folder'};
5772: my $destination = 'docs/';
5773: if ($folder =~ /^supplemental/) {
5774: $destination = 'supplemental/';
5775: }
5776: if (($folder eq 'default') || ($folder eq 'supplemental')) {
5777: $destination .= 'default/';
5778: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
5779: $destination .= $2.'/';
5780: }
5781: $destination .= $env{'form.newidx'};
5782: my $dir_root = '/userfiles';
5783: return ($destination,$dir_root);
5784: }
5785:
5786: sub return_to_editor {
5787: my $actionurl = '/adm/coursedocs';
5788: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
5789: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
5790: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
5791: '</a></p>';
5792: }
5793:
1.476 raeburn 5794: sub decompression_info {
5795: my ($destination,$dir_root) = &embedded_destination();
5796: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
5797: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5798: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5799: my $container='sequence';
1.480 raeburn 5800: my ($pathitem,$hiddenelem);
1.583 raeburn 5801: my @hiddens = ('newidx','comment','position','folderpath','archiveurl');
1.519 raeburn 5802: if ($env{'form.folderpath'} =~ /\:1$/) {
1.476 raeburn 5803: $container='page';
5804: }
1.480 raeburn 5805: unshift(@hiddens,$pathitem);
5806: foreach my $item (@hiddens) {
5807: if ($env{'form.'.$item}) {
5808: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
1.583 raeburn 5809: &HTML::Entities::encode($env{'form.'.$item},'<>&"').'" />'."\n";
1.480 raeburn 5810: }
1.477 raeburn 5811: }
1.476 raeburn 5812: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
5813: $hiddenelem);
5814: }
5815:
5816: sub decompression_phase_one {
5817: my ($dir,$file,$warning,$error,$output);
5818: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
5819: &decompression_info();
1.490 raeburn 5820: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 5821: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
5822: } else {
5823: my $file = $1;
1.481 raeburn 5824: $output =
5825: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
5826: $destination,$dir_root,
5827: $hiddenelem);
5828: if ($env{'form.autoextract_camtasia'}) {
5829: $output .= &remove_archive($docudom,$docuname,$container);
5830: }
1.476 raeburn 5831: }
5832: if ($error) {
5833: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
5834: $error.'</p>'."\n";
5835: }
5836: if ($warning) {
5837: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
5838: }
5839: return $output;
5840: }
5841:
5842: sub decompression_phase_two {
5843: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
5844: &decompression_info();
1.481 raeburn 5845: my $output;
1.480 raeburn 5846: if ($env{'form.archivedelete'}) {
1.481 raeburn 5847: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 5848: }
5849: $output .=
1.481 raeburn 5850: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 5851: $destination,$dir_root,$hiddenelem);
5852: return $output;
5853: }
5854:
1.480 raeburn 5855: sub remove_archive {
5856: my ($docudom,$docuname,$container) = @_;
5857: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 5858: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 5859: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
5860: if ($fatal) {
5861: if ($container eq 'page') {
5862: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
5863: } else {
5864: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
5865: }
1.583 raeburn 5866: $delwarning .= ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 5867: } else {
5868: my $currcmd = $env{'form.cmd'};
5869: my $position = $env{'form.position'};
1.583 raeburn 5870: my $archiveidx = $position;
1.563 raeburn 5871: if ($position > 0) {
1.583 raeburn 5872: if (($env{'form.autoextract_camtasia'}) && (scalar(@LONCAPA::map::order) == 2)) {
5873: $archiveidx = $position-1;
5874: }
5875: $env{'form.cmd'} = 'remove_'.$archiveidx;
1.584 raeburn 5876: my ($title,$url,@rrest) =
1.583 raeburn 5877: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$archiveidx]]);
5878: if ($url eq $env{'form.archiveurl'}) {
5879: if (&handle_edit_cmd($docuname,$docudom)) {
5880: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
5881: if ($fatal) {
5882: if ($container eq 'page') {
5883: $delwarning = &mt('An error occurred updating the contents of the current page.');
5884: } else {
5885: $delwarning = &mt('An error occurred updating the contents of the current folder.');
5886: }
1.480 raeburn 5887: } else {
1.583 raeburn 5888: $delresult = &mt('Archive file removed.');
1.480 raeburn 5889: }
5890: }
1.583 raeburn 5891: } else {
5892: $delwarning .= &mt('Archive file had unexpected item number in folder.').
5893: ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 5894: }
5895: }
5896: $env{'form.cmd'} = $currcmd;
5897: }
5898: if ($delwarning) {
5899: $output = '<p class="LC_warning">'.
5900: $delwarning.
5901: '</p>';
5902: }
5903: if ($delresult) {
5904: $output .= '<p class="LC_info">'.
5905: $delresult.
5906: '</p>';
5907: }
1.481 raeburn 5908: return $output;
1.480 raeburn 5909: }
5910:
1.484 raeburn 5911: sub generate_admin_menu {
5912: my ($crstype) = @_;
5913: my $lc_crstype = lc($crstype);
5914: my ($home,$other,%outhash)=&authorhosts();
1.562 bisitz 5915: my %lt= ( # do not translate here
1.484 raeburn 5916: 'vc' => 'Verify Content',
5917: 'cv' => 'Check/Set Resource Versions',
5918: 'ls' => 'List Resource Identifiers',
5919: 'imse' => 'Export contents to IMS Archive',
1.568 raeburn 5920: 'dcd' => "Copy $crstype Content to Authoring Space",
1.562 bisitz 5921: );
1.484 raeburn 5922: my ($candump,$dumpurl);
5923: if ($home + $other > 0) {
5924: $candump = 'F';
5925: if ($home) {
5926: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
5927: } else {
5928: my @hosts;
5929: foreach my $aurole (keys(%outhash)) {
5930: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
5931: push(@hosts,$outhash{$aurole});
1.538 raeburn 5932: }
1.484 raeburn 5933: }
5934: if (@hosts == 1) {
5935: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
5936: '&role='.
5937: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
5938: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
5939: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
5940: } else {
5941: $dumpurl = "javascript:choose_switchserver_window()";
5942: }
5943: }
5944: }
5945: my @menu=
5946: ({ categorytitle=>'Administration',
5947: items =>[
5948: { linktext => $lt{'vc'},
5949: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
5950: permission => 'F',
1.571 raeburn 5951: help => 'Docs_Verify_Content',
1.484 raeburn 5952: icon => 'verify.png',
5953: linktitle => 'Verify contents can be retrieved/rendered',
5954: },
5955: { linktext => $lt{'cv'},
5956: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
5957: permission => 'F',
1.571 raeburn 5958: help => 'Docs_Check_Resource_Versions',
1.484 raeburn 5959: icon => 'resversion.png',
5960: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
5961: },
5962: { linktext => $lt{'ls'},
5963: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
5964: permission => 'F',
5965: #help => '',
5966: icon => 'symbs.png',
5967: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
5968: },
5969: ]
5970: },
5971: { categorytitle=>'Export',
5972: items =>[
5973: { linktext => $lt{'imse'},
5974: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
5975: permission => 'F',
5976: help => 'Docs_Export_Course_Docs',
5977: icon => 'imsexport.png',
5978: linktitle => $lt{'imse'},
5979: },
5980: { linktext => $lt{'dcd'},
5981: url => $dumpurl,
5982: permission => $candump,
1.571 raeburn 5983: help => 'Docs_Dump_Course_Docs',
1.484 raeburn 5984: icon => 'dump.png',
5985: linktitle => $lt{'dcd'},
5986: },
5987: ]
5988: });
5989: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
5990: '<input type="hidden" id="dummy" />'."\n".
5991: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
5992: '</form>';
1.329 droeschl 5993: }
5994:
5995: sub generate_edit_table {
1.538 raeburn 5996: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile,
5997: $need_save,$copyfolder) = @_;
1.406 raeburn 5998: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 5999: my %orderhash = %{$orderhash_ref};
1.344 bisitz 6000: my $form;
1.371 tempelho 6001: my $activetab;
6002: my $active;
1.570 raeburn 6003: if (($env{'form.active'} ne '') && ($env{'form.active'} ne '00')) {
1.371 tempelho 6004: $activetab = $env{'form.active'};
6005: }
1.472 raeburn 6006: my $backicon = $iconpath.'clickhere.gif';
1.525 raeburn 6007: my $backtext = &mt('Exit Editor');
1.458 raeburn 6008: $form = '<div class="LC_Box" style="margin:0;">'.
1.488 raeburn 6009: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
6010: '<li class="goback">'.
1.546 raeburn 6011: '<a href="javascript:toContents('."'$jumpto'".');">'.
1.488 raeburn 6012: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
6013: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
6014: '<li>'.
6015: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
6016: &mt('Undo Delete').'</a></li>'."\n";
6017: if ($env{'form.docslog'}) {
6018: $form .= '<li class="active">';
6019: } else {
6020: $form .= '<li>';
6021: }
6022: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
6023: &mt('History').'</a></li>'."\n";
6024: if ($env{'form.docslog'}) {
6025: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
6026: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 6027: }
1.458 raeburn 6028: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 6029: if($name ne '00'){
1.371 tempelho 6030: if($activetab eq '' || $activetab ne $name){
6031: $active = '';
6032: }elsif($activetab eq $name){
6033: $active = 'class="active"';
6034: }
1.458 raeburn 6035: $form .= '<li style="float:right" '.$active
1.484 raeburn 6036: .' 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 6037: } else {
1.570 raeburn 6038: $form .= '<li style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 6039:
6040: }
1.329 droeschl 6041: }
1.484 raeburn 6042: $form .= '</ul>'."\n";
6043: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 6044:
6045: if ($to_show ne '') {
1.538 raeburn 6046: my $saveform;
6047: if ($need_save) {
6048: my $button = &mt('Make changes');
6049: my $path;
6050: if ($env{'form.folderpath'}) {
6051: $path =
6052: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
6053: }
6054: $saveform = <<"END";
6055: <div id="multisave" style="display:none; clear:both;" >
6056: <form name="saveactions" method="post" action="/adm/coursedocs" onsubmit="return checkSubmits();">
6057: <input type="hidden" name="folderpath" value="$path" />
6058: <input type="hidden" name="symb" value="$env{'form.symb'}" />
6059: <input type="hidden" name="allhiddenresource" value="" />
6060: <input type="hidden" name="allencrypturl" value="" />
6061: <input type="hidden" name="allrandompick" value="" />
6062: <input type="hidden" name="allrandomorder" value="" />
6063: <input type="hidden" name="changeparms" value="" />
6064: <input type="hidden" name="multiremove" value="" />
6065: <input type="hidden" name="multicut" value="" />
6066: <input type="hidden" name="multicopy" value="" />
6067: <input type="hidden" name="multichange" value="" />
6068: <input type="hidden" name="copyfolder" value="$copyfolder" />
6069: <input type="submit" name="savemultiples" value="$button" />
6070: </form>
6071: </div>
6072: END
6073: }
6074: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'.$saveform."\n";
1.458 raeburn 6075: }
1.363 ehlerst 6076: foreach my $field (keys(%orderhash)){
1.390 tempelho 6077: if($field ne '00'){
1.422 onken 6078: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 6079: $active = 'style="display: none;float:left"';
1.422 onken 6080: }elsif($activetab eq $field){
1.458 raeburn 6081: $active = 'style="display:block;float:left"';
1.422 onken 6082: }
6083: $form .= '<div id="'.$field.$tid.'"'
6084: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 6085: .'</div>'."\n";
1.363 ehlerst 6086: }
6087: }
1.484 raeburn 6088: unless ($env{'form.docslog'}) {
6089: $form .= '</div></div>'."\n";
6090: }
1.329 droeschl 6091: return $form;
6092: }
6093:
6094: sub editing_js {
1.600 raeburn 6095: my ($udom,$uname,$supplementalflag,$posslti) = @_;
1.594 damieng 6096: my %js_lt = &Apache::lonlocal::texthash(
1.329 droeschl 6097: p_mnf => 'Name of New Folder',
6098: t_mnf => 'New Folder',
6099: p_mnp => 'Name of New Page',
6100: t_mnp => 'New Page',
1.451 www 6101: p_mxu => 'Title for the External Score',
1.349 biermanm 6102: p_msp => 'Name of Simple Course Page',
1.329 droeschl 6103: p_msb => 'Title for the Problem',
6104: p_mdb => 'Title for the Drop Box',
1.336 schafran 6105: p_mbb => 'Title for the Discussion Board',
1.534 raeburn 6106: p_mwp => 'Title for Web Page',
1.348 weissno 6107: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 6108: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 6109: p_mab_alrt1 => 'Not a valid user:domain',
6110: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
6111: p_chn => 'New Title',
6112: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
6113: p_rmr2a => 'Remove[_99]',
6114: p_rmr2b => '?[_99]',
1.542 raeburn 6115: p_rmr3a => 'Remove those [_2]',
6116: p_rmr3b => 'items?[_2]',
1.329 droeschl 6117: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
6118: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
6119: p_ctr2a => 'Cut[_98]',
1.478 raeburn 6120: p_ctr2b => '?[_98]',
1.542 raeburn 6121: p_ctr3a => 'Cut those[_2]',
6122: p_ctr3b => 'items?[_2]',
1.478 raeburn 6123: rpck => 'Enter number to pick (e.g., 3)',
1.501 raeburn 6124: imsfile => 'You must choose an IMS package for import',
6125: imscms => 'You must select which Course Management System was the source of the IMS package',
6126: invurl => 'Invalid URL',
6127: titbl => 'Title is blank',
1.538 raeburn 6128: more => '(More ...)',
6129: less => '(Less ...)',
1.543 raeburn 6130: noor => 'No actions selected or changes to settings specified.',
6131: noch => 'No changes to settings specified.',
6132: noac => 'No actions selected.',
1.329 droeschl 6133: );
1.594 damieng 6134: &js_escape(\%js_lt);
1.433 raeburn 6135: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 6136: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
6137: my $main_container_page;
1.519 raeburn 6138: if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) {
6139: $main_container_page = 1;
1.434 raeburn 6140: }
1.538 raeburn 6141: my $toplevelmain =
1.548 raeburn 6142: &escape(&mt('Main Content').':::::');
1.446 www 6143: my $toplevelsupp = &supplemental_base();
1.433 raeburn 6144:
1.525 raeburn 6145: my $backtourl;
1.530 raeburn 6146: if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
6147: my $caller = $1;
1.525 raeburn 6148: if ($caller =~ /^supplemental/) {
6149: $backtourl = '/adm/supplemental?folderpath='.&escape($caller);
6150: } else {
6151: my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
6152: $res = &Apache::lonnet::clutter($res);
6153: if (&Apache::lonnet::is_on_map($res)) {
6154: $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($res),'<>&"').'?symb='.
6155: &HTML::Entities::encode($caller,'<>&"');
1.590 raeburn 6156: $backtourl = &Apache::loncommon::escape_single($backtourl);
1.544 raeburn 6157: } else {
6158: $backtourl = '/adm/navmaps';
1.525 raeburn 6159: }
6160: }
6161: } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
6162: $backtourl = '/adm/menu';
6163: } elsif ($supplementalflag) {
1.472 raeburn 6164: $backtourl = '/adm/supplemental';
1.525 raeburn 6165: } else {
6166: $backtourl = '/adm/navmaps';
1.472 raeburn 6167: }
6168:
1.600 raeburn 6169: my $fieldsets = "'ext','doc'";
6170: if ($posslti) {
6171: $fieldsets .= ",'tool'";
6172: }
1.519 raeburn 6173: unless ($main_container_page) {
6174: $fieldsets .=",'ims'";
6175: }
1.501 raeburn 6176: if ($supplementalflag) {
1.600 raeburn 6177: $fieldsets = "'suppext','suppdoc'";
6178: if ($posslti) {
6179: $fieldsets .= ",'supptool'";
6180: }
1.501 raeburn 6181: }
6182:
1.329 droeschl 6183: return <<ENDNEWSCRIPT;
6184: function makenewfolder(targetform,folderseq) {
1.594 damieng 6185: var foldername=prompt('$js_lt{"p_mnf"}','$js_lt{"t_mnf"}');
1.329 droeschl 6186: if (foldername) {
6187: targetform.importdetail.value=escape(foldername)+"="+folderseq;
6188: targetform.submit();
6189: }
6190: }
6191:
6192: function makenewpage(targetform,folderseq) {
1.594 damieng 6193: var pagename=prompt('$js_lt{"p_mnp"}','$js_lt{"t_mnp"}');
1.329 droeschl 6194: if (pagename) {
6195: targetform.importdetail.value=escape(pagename)+"="+folderseq;
6196: targetform.submit();
6197: }
6198: }
6199:
6200: function makeexamupload() {
1.594 damieng 6201: var title=prompt('$js_lt{"p_mxu"}');
1.344 bisitz 6202: if (title) {
1.329 droeschl 6203: this.document.forms.newexamupload.importdetail.value=
6204: escape(title)+'=/res/lib/templates/examupload.problem';
6205: this.document.forms.newexamupload.submit();
6206: }
6207: }
6208:
6209: function makesmppage() {
1.594 damieng 6210: var title=prompt('$js_lt{"p_msp"}');
1.344 bisitz 6211: if (title) {
1.329 droeschl 6212: this.document.forms.newsmppg.importdetail.value=
1.533 raeburn 6213: escape(title)+'=/adm/$udom/$uname/new/smppg';
1.329 droeschl 6214: this.document.forms.newsmppg.submit();
6215: }
6216: }
6217:
1.534 raeburn 6218: function makewebpage(type) {
1.594 damieng 6219: var title=prompt('$js_lt{"p_mwp"}');
1.534 raeburn 6220: var formname;
6221: if (type == 'supp') {
6222: formname = this.document.forms.supwebpage;
6223: } else {
6224: formname = this.document.forms.newwebpage;
6225: }
6226: if (title) {
6227: var webpage = formname.importdetail.value;
6228: formname.importdetail.value = escape(title)+'='+webpage;
6229: formname.submit();
6230: }
6231: }
6232:
1.329 droeschl 6233: function makesmpproblem() {
1.594 damieng 6234: var title=prompt('$js_lt{"p_msb"}');
1.344 bisitz 6235: if (title) {
1.329 droeschl 6236: this.document.forms.newsmpproblem.importdetail.value=
6237: escape(title)+'=/res/lib/templates/simpleproblem.problem';
6238: this.document.forms.newsmpproblem.submit();
6239: }
6240: }
6241:
6242: function makedropbox() {
1.594 damieng 6243: var title=prompt('$js_lt{"p_mdb"}');
1.344 bisitz 6244: if (title) {
1.329 droeschl 6245: this.document.forms.newdropbox.importdetail.value=
6246: escape(title)+'=/res/lib/templates/DropBox.problem';
6247: this.document.forms.newdropbox.submit();
6248: }
6249: }
6250:
6251: function makebulboard() {
1.594 damieng 6252: var title=prompt('$js_lt{"p_mbb"}');
1.329 droeschl 6253: if (title) {
6254: this.document.forms.newbul.importdetail.value=
1.533 raeburn 6255: escape(title)+'=/adm/$udom/$uname/new/bulletinboard';
1.329 droeschl 6256: this.document.forms.newbul.submit();
6257: }
6258: }
6259:
6260: function makeabout() {
1.594 damieng 6261: var user=prompt("$js_lt{'p_mab'}");
1.329 droeschl 6262: if (user) {
6263: var comp=new Array();
6264: comp=user.split(':');
6265: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
6266: if ((comp[0]) && (comp[1])) {
6267: this.document.forms.newaboutsomeone.importdetail.value=
1.594 damieng 6268: '$js_lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.335 ehlerst 6269: this.document.forms.newaboutsomeone.submit();
6270: } else {
1.594 damieng 6271: alert("$js_lt{'p_mab_alrt1'}");
1.329 droeschl 6272: }
1.335 ehlerst 6273: } else {
1.594 damieng 6274: alert("$js_lt{'p_mab_alrt2'}");
1.335 ehlerst 6275: }
6276: }
1.329 droeschl 6277: }
6278:
1.501 raeburn 6279: function toggleUpload(caller) {
6280: var blocks = Array($fieldsets);
6281: for (var i=0; i<blocks.length; i++) {
6282: var disp = 'none';
6283: if (caller == blocks[i]) {
6284: var curr = document.getElementById('upload'+caller+'form').style.display;
6285: if (curr == 'none') {
6286: disp='block';
6287: }
6288: }
6289: document.getElementById('upload'+blocks[i]+'form').style.display=disp;
1.598 raeburn 6290: if ((caller == 'tool') || (caller == 'supptool')) {
6291: if (disp == 'block') {
6292: if (document.getElementById('LC_exttoolid')) {
6293: var toolselector = document.getElementById('LC_exttoolid');
6294: var suppflag = 0;
6295: if (caller == 'supptool') {
6296: suppflag = 1;
6297: }
6298: currForm = document.getElementById('new'+caller);
6299: updateExttool(toolselector,currForm,suppflag);
6300: }
6301: }
6302: }
1.501 raeburn 6303: }
1.502 raeburn 6304: resize_scrollbox('contentscroll','1','1');
6305: return;
6306: }
6307:
1.514 raeburn 6308: function toggleMap(caller) {
1.502 raeburn 6309: var disp = 'none';
1.510 raeburn 6310: if (document.getElementById('importmapform')) {
1.514 raeburn 6311: if (caller == 'map') {
6312: var curr = document.getElementById('importmapform').style.display;
6313: if (curr == 'none') {
6314: disp='block';
6315: }
1.510 raeburn 6316: }
6317: document.getElementById('importmapform').style.display=disp;
6318: resize_scrollbox('contentscroll','1','1');
1.502 raeburn 6319: }
1.501 raeburn 6320: return;
1.329 droeschl 6321: }
6322:
1.501 raeburn 6323: function makeims(imsform) {
6324: if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
1.594 damieng 6325: alert("$js_lt{'imsfile'}");
1.501 raeburn 6326: return;
6327: }
6328: if (imsform.source.selectedIndex == 0) {
1.594 damieng 6329: alert("$js_lt{'imscms'}");
1.501 raeburn 6330: return;
6331: }
6332: newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
6333: imsform.submit();
6334: }
6335:
1.519 raeburn 6336: function changename(folderpath,index,oldtitle) {
1.594 damieng 6337: var title=prompt('$js_lt{"p_chn"}',oldtitle);
1.335 ehlerst 6338: if (title) {
1.538 raeburn 6339: this.document.forms.renameform.markcopy.value='';
1.335 ehlerst 6340: this.document.forms.renameform.title.value=title;
6341: this.document.forms.renameform.cmd.value='rename_'+index;
1.519 raeburn 6342: this.document.forms.renameform.folderpath.value=folderpath;
1.335 ehlerst 6343: this.document.forms.renameform.submit();
6344: }
1.329 droeschl 6345: }
6346:
1.478 raeburn 6347: function updatePick(targetform,index,caller) {
1.537 raeburn 6348: var pickitem;
6349: var picknumitem;
6350: var picknumtext;
6351: if (index == 'all') {
6352: pickitem = document.getElementById('randompickall');
6353: picknumitem = document.getElementById('rpicknumall');
6354: picknumtext = document.getElementById('rpicktextall');
6355: } else {
6356: pickitem = document.getElementById('randompick_'+index);
6357: picknumitem = document.getElementById('rpicknum_'+index);
6358: picknumtext = document.getElementById('randompicknum_'+index);
6359: }
1.478 raeburn 6360: if (pickitem.checked) {
1.594 damieng 6361: var picknum=prompt('$js_lt{"rpck"}',picknumitem.value);
1.478 raeburn 6362: if (picknum == '' || picknum == null) {
6363: if (caller == 'check') {
6364: pickitem.checked=false;
1.537 raeburn 6365: if (index == 'all') {
6366: picknumtext.innerHTML = '';
6367: if (caller == 'link') {
6368: propagateState(targetform,'rpicknum');
6369: }
6370: } else {
1.538 raeburn 6371: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 6372: }
1.478 raeburn 6373: }
6374: } else {
6375: picknum.toString();
6376: var regexdigit=/^\\d+\$/;
6377: if (regexdigit.test(picknum)) {
6378: picknumitem.value = picknum;
1.537 raeburn 6379: if (index == 'all') {
1.538 raeburn 6380: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.cumulativesettings,\\'all\\',\\'link\\');">'+picknum+'</a>';
1.537 raeburn 6381: if (caller == 'link') {
6382: propagateState(targetform,'rpicknum');
6383: }
6384: } else {
6385: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.edit_randompick_'+index+',\\''+index+'\\',\\'link\\');">'+picknum+'</a>';
1.538 raeburn 6386: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 6387: }
1.478 raeburn 6388: } else {
6389: if (caller == 'check') {
1.537 raeburn 6390: if (index == 'all') {
6391: picknumtext.innerHTML = '';
6392: if (caller == 'link') {
6393: propagateState(targetform,'rpicknum');
6394: }
6395: } else {
6396: pickitem.checked=false;
1.538 raeburn 6397: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 6398: }
1.478 raeburn 6399: }
6400: return;
6401: }
6402: }
6403: } else {
1.537 raeburn 6404: picknumitem.value = '';
6405: picknumtext.innerHTML = '';
6406: if (index == 'all') {
6407: if (caller == 'link') {
6408: propagateState(targetform,'rpicknum');
6409: }
6410: } else {
1.538 raeburn 6411: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 6412: }
6413: }
6414: }
6415:
6416: function propagateState(form,param) {
6417: if (document.getElementById(param+'all')) {
6418: var setcheck = 0;
6419: var rpick = 0;
6420: if (param == 'rpicknum') {
6421: if (document.getElementById('randompickall')) {
6422: if (document.getElementById('randompickall').checked) {
6423: if (document.getElementById('rpicknumall')) {
6424: rpick = document.getElementById('rpicknumall').value;
6425: }
6426: }
6427: }
6428: } else {
6429: if (document.getElementById(param+'all').checked) {
6430: setcheck = 1;
6431: }
6432: }
1.538 raeburn 6433: var allidxlist;
6434: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
6435: if (document.getElementById('all'+param+'idx')) {
6436: allidxlist = document.getElementById('all'+param+'idx').value;
6437: }
6438: var actions = new Array ('remove','cut','copy');
6439: for (var i=0; i<actions.length; i++) {
6440: if (actions[i] != param) {
6441: if (document.getElementById(actions[i]+'all')) {
6442: document.getElementById(actions[i]+'all').checked = false;
6443: }
6444: }
6445: }
6446: }
1.537 raeburn 6447: if ((param == 'encrypturl') || (param == 'hiddenresource')) {
1.538 raeburn 6448: allidxlist = form.allidx.value;
6449: }
6450: if ((param == 'randompick') || (param == 'rpicknum') || (param == 'randomorder')) {
6451: allidxlist = form.allmapidx.value;
6452: }
6453: if ((allidxlist != '') && (allidxlist != null)) {
6454: var allidxs = allidxlist.split(',');
6455: if (allidxs.length > 1) {
6456: for (var i=0; i<allidxs.length; i++) {
6457: if (document.getElementById(param+'_'+allidxs[i])) {
6458: if (param == 'rpicknum') {
6459: if (document.getElementById('randompick_'+allidxs[i])) {
6460: if (document.getElementById('randompick_'+allidxs[i]).checked) {
6461: document.getElementById(param+'_'+allidxs[i]).value = rpick;
6462: if (rpick > 0) {
6463: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = ': <a href="javascript:updatePick(document.edit_randompick_'+allidxs[i]+',\\''+allidxs[i]+'\\',\\'link\\')">'+rpick+'</a>';
6464: } else {
6465: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
6466: }
6467: }
6468: }
6469: } else {
1.537 raeburn 6470: if (setcheck == 1) {
6471: document.getElementById(param+'_'+allidxs[i]).checked = true;
6472: } else {
6473: document.getElementById(param+'_'+allidxs[i]).checked = false;
1.538 raeburn 6474: if (param == 'randompick') {
6475: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
6476: }
1.537 raeburn 6477: }
6478: }
6479: }
6480: }
1.538 raeburn 6481: if (setcheck == 1) {
6482: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
6483: var actions = new Array('copy','cut','remove');
6484: for (var i=0; i<actions.length; i++) {
6485: var otheractions;
6486: var otheridxs;
6487: if (actions[i] === param) {
6488: continue;
6489: } else {
6490: if (document.getElementById('all'+actions[i]+'idx')) {
6491: otheractions = document.getElementById('all'+actions[i]+'idx').value;
6492: otheridxs = otheractions.split(',');
6493: if (otheridxs.length > 1) {
6494: for (var j=0; j<otheridxs.length; j++) {
6495: if (document.getElementById(actions[i]+'_'+otheridxs[j])) {
6496: document.getElementById(actions[i]+'_'+otheridxs[j]).checked = false;
6497: }
1.537 raeburn 6498: }
6499: }
6500: }
1.538 raeburn 6501: }
6502: }
6503: }
6504: }
6505: }
6506: }
6507: }
6508: return;
6509: }
6510:
6511: function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder) {
1.539 raeburn 6512: var dosettings;
6513: var doaction;
1.538 raeburn 6514: var control = document.togglemultsettings;
6515: if (context == 'actions') {
6516: control = document.togglemultactions;
1.539 raeburn 6517: doaction = 1;
6518: } else {
6519: dosettings = 1;
1.538 raeburn 6520: }
1.539 raeburn 6521: if (control) {
6522: if (control.showmultpick.length) {
6523: for (var i=0; i<control.showmultpick.length; i++) {
6524: if (control.showmultpick[i].checked) {
6525: if (control.showmultpick[i].value == 1) {
6526: if (context == 'settings') {
6527: dosettings = 0;
6528: } else {
6529: doaction = 0;
1.538 raeburn 6530: }
6531: }
6532: }
1.537 raeburn 6533: }
6534: }
1.539 raeburn 6535: }
6536: if (context == 'settings') {
6537: if (dosettings == 1) {
1.538 raeburn 6538: targetform.changeparms.value=param;
6539: targetform.submit();
6540: }
1.537 raeburn 6541: }
1.539 raeburn 6542: if (context == 'actions') {
6543: if (doaction == 1) {
6544: targetform.cmd.value=param+'_'+index;
6545: targetform.folderpath.value=folderpath;
6546: targetform.markcopy.value=idx+':'+param;
6547: targetform.copyfolder.value=folder+'.'+container;
6548: if (param == 'remove') {
1.594 damieng 6549: if (skip_confirm || confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'" $js_lt{"p_rmr2b"}')) {
1.539 raeburn 6550: targetform.markcopy.value='';
6551: targetform.copyfolder.value='';
6552: targetform.submit();
6553: }
6554: }
6555: if (param == 'cut') {
1.594 damieng 6556: if (skip_confirm || confirm('$js_lt{"p_ctr1a"}\\n$js_lt{"p_ctr1b"}\\n\\n$js_lt{"p_ctr2a"} "'+oldtitle+'" $js_lt{"p_ctr2b"}')) {
1.539 raeburn 6557: targetform.submit();
6558: return;
6559: }
6560: }
6561: if (param == 'copy') {
6562: targetform.submit();
6563: return;
6564: }
6565: targetform.markcopy.value='';
6566: targetform.copyfolder.value='';
6567: targetform.cmd.value='';
6568: targetform.folderpath.value='';
6569: return;
6570: } else {
6571: if (document.getElementById(param+'_'+idx)) {
6572: item = document.getElementById(param+'_'+idx);
6573: if (item.type == 'checkbox') {
6574: if (item.checked) {
6575: item.checked = false;
6576: } else {
6577: item.checked = true;
6578: singleCheck(item,idx,param);
6579: }
6580: }
6581: }
6582: }
6583: }
1.537 raeburn 6584: return;
6585: }
6586:
1.538 raeburn 6587: function singleCheck(caller,idx,action) {
6588: actions = new Array('cut','copy','remove');
6589: if (caller.checked) {
6590: for (var i=0; i<actions.length; i++) {
6591: if (actions[i] != action) {
6592: if (document.getElementById(actions[i]+'_'+idx)) {
6593: if (document.getElementById(actions[i]+'_'+idx).checked) {
6594: document.getElementById(actions[i]+'_'+idx).checked = false;
6595: }
1.537 raeburn 6596: }
6597: }
6598: }
1.478 raeburn 6599: }
1.537 raeburn 6600: return;
1.478 raeburn 6601: }
6602:
1.334 muellerd 6603: function unselectInactive(nav) {
1.335 ehlerst 6604: currentNav = document.getElementById(nav);
6605: currentLis = currentNav.getElementsByTagName('LI');
6606: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 6607: if (currentLis[i].className == 'goback') {
6608: currentLis[i].className = 'goback';
6609: } else {
6610: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 6611: currentLis[i].className = 'right';
1.472 raeburn 6612: } else {
1.374 tempelho 6613: currentLis[i].className = 'i';
1.472 raeburn 6614: }
6615: }
1.335 ehlerst 6616: }
1.332 tempelho 6617: }
6618:
1.334 muellerd 6619: function hideAll(current, nav, data) {
1.335 ehlerst 6620: unselectInactive(nav);
1.570 raeburn 6621: if (current) {
6622: if (current.className == 'right'){
6623: current.className = 'right active'
6624: } else {
6625: current.className = 'active';
6626: }
1.374 tempelho 6627: }
1.335 ehlerst 6628: currentData = document.getElementById(data);
6629: currentDivs = currentData.getElementsByTagName('DIV');
6630: for (i = 0; i < currentDivs.length; i++) {
6631: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 6632: currentDivs[i].style.display = 'none';
1.330 tempelho 6633: }
6634: }
1.335 ehlerst 6635: }
1.330 tempelho 6636:
1.374 tempelho 6637: function openTabs(pageId) {
6638: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 6639: if(tabnav.length > 2 ){
1.389 tempelho 6640: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 6641: currentLis = currentNav.getElementsByTagName('LI');
6642: for(i = 0; i< currentLis.length; i++){
6643: if(currentLis[i].className == 'active') {
1.375 tempelho 6644: funcString = currentLis[i].onclick.toString();
6645: tab = funcString.split('"');
1.420 onken 6646: if(tab.length < 2) {
6647: tab = funcString.split("'");
6648: }
1.375 tempelho 6649: currentData = document.getElementById(tab[1]);
6650: currentData.style.display = 'block';
1.374 tempelho 6651: }
6652: }
6653: }
6654: }
6655:
1.334 muellerd 6656: function showPage(current, pageId, nav, data) {
1.570 raeburn 6657: currstate = current.className;
1.334 muellerd 6658: hideAll(current, nav, data);
1.375 tempelho 6659: openTabs(pageId);
1.334 muellerd 6660: unselectInactive(nav);
1.570 raeburn 6661: if ((currstate == 'active') || (currstate == 'right active')) {
6662: if (currstate == 'active') {
6663: current.className = '';
6664: } else {
6665: current.className = 'right';
6666: }
6667: activeTab = '';
6668: toggleUpload();
6669: toggleMap();
6670: resize_scrollbox('contentscroll','1','0');
6671: return;
6672: } else {
6673: current.className = 'active';
6674: }
1.330 tempelho 6675: currentData = document.getElementById(pageId);
6676: currentData.style.display = 'block';
1.458 raeburn 6677: activeTab = pageId;
1.501 raeburn 6678: toggleUpload();
1.503 raeburn 6679: toggleMap();
1.433 raeburn 6680: if (nav == 'mainnav') {
6681: var storedpath = "$docs_folderpath";
1.434 raeburn 6682: var storedpage = "$main_container_page";
1.433 raeburn 6683: var reg = new RegExp("^supplemental");
6684: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 6685: if (storedpage == 1) {
6686: document.simpleedit.folderpath.value = '';
6687: document.uploaddocument.folderpath.value = '';
6688: } else {
6689: if (reg.test(storedpath)) {
6690: document.simpleedit.folderpath.value = '$toplevelmain';
6691: document.uploaddocument.folderpath.value = '$toplevelmain';
6692: document.newext.folderpath.value = '$toplevelmain';
6693: } else {
6694: document.simpleedit.folderpath.value = storedpath;
6695: document.uploaddocument.folderpath.value = storedpath;
6696: document.newext.folderpath.value = storedpath;
6697: }
1.433 raeburn 6698: }
6699: } else {
1.434 raeburn 6700: if (reg.test(storedpath)) {
6701: document.simpleedit.folderpath.value = storedpath;
6702: document.supuploaddocument.folderpath.value = storedpath;
6703: document.supnewext.folderpath.value = storedpath;
6704: } else {
1.433 raeburn 6705: document.simpleedit.folderpath.value = '$toplevelsupp';
6706: document.supuploaddocument.folderpath.value = '$toplevelsupp';
6707: document.supnewext.folderpath.value = '$toplevelsupp';
6708: }
6709: }
6710: }
1.485 raeburn 6711: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 6712: return false;
6713: }
1.329 droeschl 6714:
1.472 raeburn 6715: function toContents(jumpto) {
6716: var newurl = '$backtourl';
1.525 raeburn 6717: if ((newurl == '/adm/navmaps') && (jumpto != '')) {
1.472 raeburn 6718: newurl = newurl+'?postdata='+jumpto;
6719: }
6720: location.href=newurl;
6721: }
6722:
1.538 raeburn 6723: function togglePick(caller,value) {
6724: var disp = 'none';
6725: if (document.getElementById('multi'+caller)) {
6726: var curr = document.getElementById('multi'+caller).style.display;
6727: if (value == 1) {
6728: disp='block';
6729: }
6730: if (curr == disp) {
6731: return;
6732: }
6733: document.getElementById('multi'+caller).style.display=disp;
6734: if (value == 1) {
1.594 damieng 6735: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.538 raeburn 6736: } else {
6737: document.getElementById('more'+caller).innerHTML = '';
6738: }
6739: if (caller == 'actions') {
6740: setClass(value);
6741: setBoxes(value);
6742: }
6743: }
6744: var showButton = multiSettings();
6745: if (showButton != 1) {
6746: showButton = multiActions();
6747: }
6748: if (document.getElementById('multisave')) {
6749: if (showButton == 1) {
6750: document.getElementById('multisave').style.display='block';
6751: } else {
6752: document.getElementById('multisave').style.display='none';
6753: }
6754: }
6755: resize_scrollbox('contentscroll','1','1');
6756: return;
6757: }
6758:
6759: function toggleCheckUncheck(caller,more) {
6760: if (more == 1) {
1.594 damieng 6761: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',0);" style="text-decoration:none;">$js_lt{'less'}</a>';
1.538 raeburn 6762: document.getElementById('allfields'+caller).style.display='block';
6763: } else {
1.594 damieng 6764: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.538 raeburn 6765: document.getElementById('allfields'+caller).style.display='none';
6766: }
6767: resize_scrollbox('contentscroll','1','1');
6768: }
6769:
6770: function multiSettings() {
6771: var inuse = 0;
6772: var settingsform = document.togglemultsettings;
6773: if (settingsform.showmultpick.length > 1) {
6774: for (var i=0; i<settingsform.showmultpick.length; i++) {
6775: if (settingsform.showmultpick[i].checked) {
6776: if (settingsform.showmultpick[i].value == 1) {
6777: inuse = 1;
6778: }
6779: }
6780: }
6781: }
6782: return inuse;
6783: }
6784:
6785: function multiActions() {
6786: var inuse = 0;
6787: var actionsform = document.togglemultactions;
6788: if (actionsform.showmultpick.length > 1) {
6789: for (var i=0; i<actionsform.showmultpick.length; i++) {
6790: if (actionsform.showmultpick[i].checked) {
6791: if (actionsform.showmultpick[i].value == 1) {
6792: inuse = 1;
6793: }
6794: }
6795: }
6796: }
6797: return inuse;
6798: }
6799:
6800: function checkSubmits() {
6801: var numchanges = 0;
6802: var form = document.saveactions;
6803: var doactions = multiActions();
1.542 raeburn 6804: var cutwarnings = 0;
6805: var remwarnings = 0;
1.538 raeburn 6806: if (doactions == 1) {
6807: var remidxlist = document.cumulativeactions.allremoveidx.value;
6808: if ((remidxlist != '') && (remidxlist != null)) {
6809: var remidxs = remidxlist.split(',');
6810: for (var i=0; i<remidxs.length; i++) {
6811: if (document.getElementById('remove_'+remidxs[i])) {
6812: if (document.getElementById('remove_'+remidxs[i]).checked) {
6813: form.multiremove.value += remidxs[i]+',';
6814: numchanges ++;
1.542 raeburn 6815: if (document.getElementById('skip_remove_'+remidxs[i])) {
6816: if (document.getElementById('skip_remove_'+remidxs[i]).value == 0) {
6817: remwarnings ++;
6818: }
6819: }
1.537 raeburn 6820: }
6821: }
1.538 raeburn 6822: }
6823: }
6824: var cutidxlist = document.cumulativeactions.allcutidx.value;
6825: if ((cutidxlist != '') && (cutidxlist != null)) {
6826: var cutidxs = cutidxlist.split(',');
6827: for (var i=0; i<cutidxs.length; i++) {
6828: if (document.getElementById('cut_'+cutidxs[i])) {
6829: if (document.getElementById('cut_'+cutidxs[i]).checked == true) {
6830: form.multicut.value += cutidxs[i]+',';
6831: numchanges ++;
1.542 raeburn 6832: if (document.getElementById('skip_cut_'+cutidxs[i])) {
6833: if (document.getElementById('skip_cut_'+cutidxs[i]).value == 0) {
6834: cutwarnings ++;
6835: }
6836: }
1.537 raeburn 6837: }
6838: }
6839: }
6840: }
1.538 raeburn 6841: var copyidxlist = document.cumulativeactions.allcopyidx.value;
6842: if ((copyidxlist != '') && (copyidxlist != null)) {
6843: var copyidxs = copyidxlist.split(',');
6844: for (var i=0; i<copyidxs.length; i++) {
6845: if (document.getElementById('copy_'+copyidxs[i])) {
6846: if (document.getElementById('copy_'+copyidxs[i]).checked) {
6847: form.multicopy.value += copyidxs[i]+',';
6848: numchanges ++;
6849: }
6850: }
6851: }
6852: }
6853: if (numchanges > 0) {
6854: form.multichange.value = numchanges;
6855: }
1.537 raeburn 6856: }
1.538 raeburn 6857: var dosettings = multiSettings();
1.543 raeburn 6858: var haschanges = 0;
1.538 raeburn 6859: if (dosettings == 1) {
6860: form.allencrypturl.value = '';
6861: form.allhiddenresource.value = '';
1.543 raeburn 6862: form.changeparms.value = 'all';
6863: var patt=new RegExp(",\$");
1.538 raeburn 6864: var allidxlist = document.cumulativesettings.allidx.value;
6865: if ((allidxlist != '') && (allidxlist != null)) {
6866: var allidxs = allidxlist.split(',');
6867: if (allidxs.length > 1) {
6868: for (var i=0; i<allidxs.length; i++) {
6869: if (document.getElementById('hiddenresource_'+allidxs[i])) {
6870: if (document.getElementById('hiddenresource_'+allidxs[i]).checked) {
6871: form.allhiddenresource.value += allidxs[i]+',';
6872: }
6873: }
6874: if (document.getElementById('encrypturl_'+allidxs[i])) {
6875: if (document.getElementById('encrypturl_'+allidxs[i]).checked) {
6876: form.allencrypturl.value += allidxs[i]+',';
6877: }
6878: }
6879: }
1.543 raeburn 6880: form.allhiddenresource.value = form.allhiddenresource.value.replace(patt,"");
6881: form.allencrypturl.value = form.allencrypturl.value.replace(patt,"");
1.537 raeburn 6882: }
1.538 raeburn 6883: }
6884: form.allrandompick.value = '';
6885: form.allrandomorder.value = '';
6886: var allmapidxlist = document.cumulativesettings.allmapidx.value;
6887: if ((allmapidxlist != '') && (allmapidxlist != null)) {
6888: var allmapidxs = allmapidxlist.split(',');
6889: for (var i=0; i<allmapidxs.length; i++) {
6890: var randompick = document.getElementById('randompick_'+allmapidxs[i]);
6891: var rpicknum = document.getElementById('rpicknum_'+allmapidxs[i]);
6892: var randorder = document.getElementById('randomorder_'+allmapidxs[i]);
6893: if ((randompick.checked) && (rpicknum.value != '')) {
6894: form.allrandompick.value += allmapidxs[i]+':'+rpicknum.value+',';
6895: }
6896: if (randorder.checked) {
6897: form.allrandomorder.value += allmapidxs[i]+',';
6898: }
1.537 raeburn 6899: }
1.543 raeburn 6900: form.allrandompick.value = form.allrandompick.value.replace(patt,"");
6901: form.allrandomorder.value = form.allrandomorder.value.replace(patt,"");
6902: }
6903: if (document.cumulativesettings.currhiddenresource.value != form.allhiddenresource.value) {
6904: haschanges = 1;
6905: }
6906: if (document.cumulativesettings.currencrypturl.value != form.allencrypturl.value) {
6907: haschanges = 1;
6908: }
6909: if (document.cumulativesettings.currrandomorder.value != form.allrandomorder.value) {
6910: haschanges = 1;
6911: }
6912: if (document.cumulativesettings.currrandompick.value != form.allrandompick.value) {
6913: haschanges = 1;
1.537 raeburn 6914: }
6915: }
1.543 raeburn 6916: if (doactions == 1) {
1.542 raeburn 6917: if (numchanges > 0) {
6918: if ((cutwarnings > 0) || (remwarnings > 0)) {
6919: if (remwarnings > 0) {
1.594 damieng 6920: if (!confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr3a"} '+remwarnings+' $js_lt{"p_rmr3b"}')) {
1.542 raeburn 6921: return false;
6922: }
6923: }
6924: if (cutwarnings > 0) {
1.594 damieng 6925: if (!confirm('$js_lt{"p_ctr1a"}\\n$js_lt{"p_ctr1b"}\\n\\n$js_lt{"p_ctr3a"} '+cutwarnings+' $js_lt{"p_ctr3b"}')) {
1.542 raeburn 6926: return false;
6927: }
6928: }
6929: }
6930: form.submit();
6931: return true;
1.543 raeburn 6932: }
6933: }
6934: if (dosettings == 1) {
6935: if (haschanges == 1) {
1.542 raeburn 6936: form.submit();
6937: return true;
6938: }
1.543 raeburn 6939: }
6940: if ((dosettings == 1) && (doactions == 1)) {
1.594 damieng 6941: alert("$js_lt{'noor'}");
1.543 raeburn 6942: } else {
6943: if (dosettings == 1) {
1.594 damieng 6944: alert("$js_lt{'noch'}");
1.543 raeburn 6945: } else {
1.594 damieng 6946: alert("$js_lt{'noac'}");
1.543 raeburn 6947: }
6948: }
1.538 raeburn 6949: return false;
6950: }
6951:
6952: function setClass(value) {
6953: var cutclass = 'LC_docs_cut';
6954: var copyclass = 'LC_docs_copy';
6955: var removeclass = 'LC_docs_remove';
6956: var cutreg = new RegExp("\\\\b"+cutclass+"\\\\b");
6957: var copyreg = new RegExp("\\\\b"+copyclass+"\\\\b");
6958: var removereg = new RegExp("\\\\"+removeclass+"\\\\b");
6959: var links = document.getElementsByTagName('a');
6960: for (var i=0; i<links.length; i++) {
6961: var classes = links[i].className;
6962: if (cutreg.test(classes)) {
6963: links[i].className = cutclass;
6964: if (value == 1) {
6965: links[i].className += " LC_menubuttons_link";
6966: }
6967: } else {
6968: if (copyreg.test(classes)) {
6969: links[i].className = copyclass;
6970: if (value == 1) {
6971: links[i].className += " LC_menubuttons_link";
6972: }
6973: } else {
6974: if (removereg.test(classes)) {
6975: links[i].className = removeclass;
6976: if (value == 1) {
6977: links[i].className += " LC_menubuttons_link";
6978: }
6979: }
6980: }
6981: }
6982: }
6983: return;
1.537 raeburn 6984: }
6985:
1.538 raeburn 6986: function setBoxes(value) {
6987: var remidxlist = document.cumulativeactions.allremoveidx.value;
6988: if ((remidxlist != '') && (remidxlist != null)) {
6989: var remidxs = remidxlist.split(',');
6990: for (var i=0; i<remidxs.length; i++) {
6991: if (document.getElementById('remove_'+remidxs[i])) {
6992: var item = document.getElementById('remove_'+remidxs[i]);
6993: if (value == 1) {
6994: item.className = 'LC_docs_remove';
6995: } else {
6996: item.className = 'LC_hidden';
6997: }
6998: }
6999: }
7000: }
7001: var cutidxlist = document.cumulativeactions.allcutidx.value;
7002: if ((cutidxlist != '') && (cutidxlist != null)) {
7003: var cutidxs = cutidxlist.split(',');
7004: for (var i=0; i<cutidxs.length; i++) {
7005: if (document.getElementById('cut_'+cutidxs[i])) {
7006: var item = document.getElementById('cut_'+cutidxs[i]);
7007: if (value == 1) {
7008: item.className = 'LC_docs_cut';
7009: } else {
7010: item.className = 'LC_hidden';
7011: }
7012: }
1.537 raeburn 7013: }
7014: }
1.538 raeburn 7015: var copyidxlist = document.cumulativeactions.allcopyidx.value;
7016: if ((copyidxlist != '') && (copyidxlist != null)) {
7017: var copyidxs = copyidxlist.split(',');
7018: for (var i=0; i<copyidxs.length; i++) {
7019: if (document.getElementById('copy_'+copyidxs[i])) {
7020: var item = document.getElementById('copy_'+copyidxs[i]);
7021: if (value == 1) {
7022: item.className = 'LC_docs_copy';
7023: } else {
7024: item.className = 'LC_hidden';
7025: }
7026: }
1.537 raeburn 7027: }
7028: }
7029: return;
7030: }
7031:
1.329 droeschl 7032: ENDNEWSCRIPT
7033: }
1.457 raeburn 7034:
1.483 raeburn 7035: sub history_tab_js {
7036: return <<"ENDHIST";
7037: function toggleHistoryDisp(choice) {
7038: document.docslogform.docslog.value = choice;
7039: document.docslogform.submit();
7040: return;
7041: }
7042:
7043: ENDHIST
7044: }
7045:
1.484 raeburn 7046: sub inject_data_js {
7047: return <<ENDINJECT;
7048:
7049: function injectData(current, hiddenField, name, value) {
7050: currentElement = document.getElementById(hiddenField);
7051: currentElement.name = name;
7052: currentElement.value = value;
7053: current.submit();
7054: }
7055:
7056: ENDINJECT
7057: }
7058:
7059: sub dump_switchserver_js {
7060: my @hosts = @_;
1.594 damieng 7061: my %js_lt = &Apache::lonlocal::texthash(
1.574 raeburn 7062: dump => 'Copying content to Authoring Space requires switching server.',
1.484 raeburn 7063: swit => 'Switch server?',
1.594 damieng 7064: );
7065: my %html_js_lt = &Apache::lonlocal::texthash(
7066: swit => 'Switch server?',
1.568 raeburn 7067: duco => 'Copying Content to Authoring Space',
1.484 raeburn 7068: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
7069: chos => 'Choose server',
7070: );
1.594 damieng 7071: &js_escape(\%js_lt);
7072: &html_escape(\%html_js_lt);
7073: &js_escape(\%html_js_lt);
1.484 raeburn 7074: my $role = $env{'request.role'};
7075: my $js = <<"ENDSWJS";
7076: <script type="text/javascript">
7077: function write_switchserver() {
7078: var server;
7079: if (document.setserver.posshosts.length > 0) {
7080: for (var i=0; i<document.setserver.posshosts.length; i++) {
7081: if (document.setserver.posshosts[i].checked) {
7082: server = document.setserver.posshosts[i].value;
7083: }
7084: }
7085: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
7086: }
7087: window.close();
7088: }
7089: </script>
7090:
7091: ENDSWJS
7092:
7093: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
7094: {'only_body' => 1,
7095: 'js_ready' => 1,});
7096: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
7097:
7098: my $hostpicker;
7099: my $count = 0;
7100: foreach my $host (sort(@hosts)) {
7101: my $checked;
7102: if ($count == 0) {
7103: $checked = ' checked="checked"';
7104: }
7105: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
7106: $host.'"'.$checked.' />'.$host.'</label> ';
7107: $count++;
7108: }
7109:
7110: return <<"ENDSWITCHJS";
7111:
7112: function dump_needs_switchserver(url) {
7113: if (url!='' && url!= null) {
1.594 damieng 7114: if (confirm("$js_lt{'dump'}\\n$js_lt{'swit'}")) {
1.484 raeburn 7115: go(url);
7116: }
7117: }
7118: return;
7119: }
7120:
7121: function choose_switchserver_window() {
7122: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
7123: newWindow.document.open();
7124: newWindow.document.writeln('$startpage');
1.594 damieng 7125: newWindow.document.write('<h3>$html_js_lt{'duco'}<\\/h3>\\n'+
7126: '<p>$html_js_lt{'yone'}<\\/p>\\n'+
7127: '<div class="LC_left_float"><fieldset><legend>$html_js_lt{'chos'}<\\/legend>\\n'+
1.484 raeburn 7128: '<form name="setserver" method="post" action="" \\/>\\n'+
7129: '$hostpicker\\n'+
7130: '<br \\/><br \\/>\\n'+
1.594 damieng 7131: '<input type="button" name="makeswitch" value="$html_js_lt{'swit'}" '+
1.484 raeburn 7132: 'onclick="write_switchserver();" \\/>\\n'+
7133: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
7134: newWindow.document.writeln('$endpage');
7135: newWindow.document.close();
7136: newWindow.focus();
7137: }
7138:
7139: ENDSWITCHJS
7140: }
7141:
7142: sub makedocslogform {
7143: my ($formelems,$docslog) = @_;
7144: return <<"LOGSFORM";
7145: <form action="/adm/coursedocs" method="post" name="docslogform">
7146: <input type="hidden" name="docslog" value="$docslog" />
7147: $formelems
7148: </form>
7149: LOGSFORM
7150: }
7151:
7152: sub makesimpleeditform {
7153: my ($formelems) = @_;
7154: return <<"SIMPFORM";
7155: <form name="simpleedit" method="post" action="/adm/coursedocs">
7156: <input type="hidden" name="importdetail" value="" />
7157: $formelems
7158: </form>
7159: SIMPFORM
7160: }
7161:
1.329 droeschl 7162: 1;
7163: __END__
7164:
7165:
7166: =head1 NAME
7167:
7168: Apache::londocs.pm
7169:
7170: =head1 SYNOPSIS
7171:
7172: This is part of the LearningOnline Network with CAPA project
7173: described at http://www.lon-capa.org.
7174:
7175: =head1 SUBROUTINES
7176:
7177: =over
7178:
7179: =item %help=()
7180:
7181: Available help topics
7182:
7183: =item mapread()
7184:
1.344 bisitz 7185: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 7186: @order and @resources, determines status
7187: sets @order - pointer to resources in right order
7188: sets @resources - array with the resources with correct idx
7189:
7190: =item authorhosts()
7191:
7192: Return hash with valid author names
7193:
7194: =item clean()
7195:
7196: =item dumpcourse()
7197:
7198: Actually dump course
7199:
7200: =item group_import()
7201:
7202: Imports the given (name, url) resources into the course
7203: coursenum, coursedom, and folder must precede the list
7204:
7205: =item breadcrumbs()
7206:
7207: =item log_docs()
7208:
7209: =item docs_change_log()
7210:
7211: =item update_paste_buffer()
7212:
7213: =item print_paste_buffer()
7214:
7215: =item do_paste_from_buffer()
7216:
1.538 raeburn 7217: =item do_buffer_empty()
7218:
7219: =item clear_from_buffer()
7220:
1.492 raeburn 7221: =item get_newmap_url()
7222:
7223: =item dbcopy()
7224:
7225: =item uniqueness_check()
7226:
7227: =item contained_map_check()
7228:
7229: =item url_paste_fixups()
7230:
7231: =item apply_fixups()
7232:
7233: =item copy_dependencies()
7234:
1.329 droeschl 7235: =item update_parameter()
7236:
7237: =item handle_edit_cmd()
7238:
7239: =item editor()
7240:
7241: =item process_file_upload()
7242:
7243: =item process_secondary_uploads()
7244:
7245: =item is_supplemental_title()
7246:
7247: =item entryline()
7248:
7249: =item tiehash()
7250:
7251: =item untiehash()
7252:
7253: =item checkonthis()
7254:
7255: check on this
7256:
7257: =item verifycontent()
7258:
7259: Verify Content
7260:
7261: =item devalidateversioncache() & checkversions()
7262:
7263: Check Versions
7264:
7265: =item mark_hash_old()
7266:
7267: =item is_hash_old()
7268:
7269: =item changewarning()
7270:
7271: =item init_breadcrumbs()
7272:
7273: Breadcrumbs for special functions
7274:
1.484 raeburn 7275: =item create_list_elements()
7276:
7277: =item create_form_ul()
7278:
7279: =item startContentScreen()
7280:
7281: =item endContentScreen()
7282:
7283: =item supplemental_base()
7284:
7285: =item embedded_form_elems()
7286:
7287: =item embedded_destination()
7288:
7289: =item return_to_editor()
7290:
7291: =item decompression_info()
7292:
7293: =item decompression_phase_one()
7294:
7295: =item decompression_phase_two()
7296:
7297: =item remove_archive()
7298:
7299: =item generate_admin_menu()
7300:
7301: =item generate_edit_table()
7302:
7303: =item editing_js()
7304:
7305: =item history_tab_js()
7306:
7307: =item inject_data_js()
7308:
7309: =item dump_switchserver_js()
7310:
1.485 raeburn 7311: =item resize_scrollbox_js()
1.484 raeburn 7312:
7313: =item makedocslogform()
7314:
1.485 raeburn 7315: =item makesimpleeditform()
7316:
1.329 droeschl 7317: =back
7318:
7319: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>