Annotation of loncom/interface/londocs.pm, revision 1.684
1.329 droeschl 1: # The LearningOnline Network
2: # Documents
3: #
1.684 ! raeburn 4: # $Id: londocs.pm,v 1.683 2022/10/19 02:10: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.606 raeburn 46: use Apache::lonhomework();
47: use Apache::lonpublisher();
1.645 raeburn 48: use Apache::lonparmset();
1.651 raeburn 49: use Apache::loncourserespicker();
1.329 droeschl 50: use HTML::Entities;
1.488 raeburn 51: use HTML::TokeParser;
1.329 droeschl 52: use GDBM_File;
1.578 raeburn 53: use File::MMagic;
1.606 raeburn 54: use File::Copy;
1.329 droeschl 55: use Apache::lonlocal;
56: use Cwd;
1.643 raeburn 57: use UUID::Tiny ':std';
1.329 droeschl 58: use LONCAPA qw(:DEFAULT :match);
59:
60: my $iconpath;
61:
62: my %hash;
63:
64: my $hashtied;
65: my %alreadyseen=();
66:
67: my $hadchanges;
1.557 raeburn 68: my $suppchanges;
1.329 droeschl 69:
70:
71: my %help=();
72:
73:
74: sub mapread {
75: my ($coursenum,$coursedom,$map)=@_;
76: return
77: &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
78: $map);
79: }
80:
81: sub storemap {
1.492 raeburn 82: my ($coursenum,$coursedom,$map,$contentchg)=@_;
83: my $report;
84: if (($contentchg) && ($map =~ /^default/)) {
85: $report = 1;
86: }
1.329 droeschl 87: my ($outtext,$errtext)=
88: &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.492 raeburn 89: $map,1,$report);
1.329 droeschl 90: if ($errtext) { return ($errtext,2); }
1.364 bisitz 91:
1.557 raeburn 92: if ($map =~ /^default/) {
93: $hadchanges=1;
1.682 raeburn 94: } elsif ($contentchg) {
1.557 raeburn 95: $suppchanges=1;
96: }
1.329 droeschl 97: return ($errtext,0);
98: }
99:
100:
101:
102: sub authorhosts {
103: my %outhash=();
104: my $home=0;
105: my $other=0;
106: foreach my $key (keys(%env)) {
107: if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
108: my $role=$1;
109: my $realm=$2;
110: my ($start,$end)=split(/\./,$env{$key});
111: if (($start) && ($start>time)) { next; }
112: if (($end) && (time>$end)) { next; }
113: my ($ca,$cd);
114: if ($1 eq 'au') {
115: $ca=$env{'user.name'};
116: $cd=$env{'user.domain'};
117: } else {
118: ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
119: }
120: my $allowed=0;
121: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
122: my @ids=&Apache::lonnet::current_machine_ids();
1.484 raeburn 123: foreach my $id (@ids) {
124: if ($id eq $myhome) {
125: $allowed=1;
126: last;
127: }
128: }
1.329 droeschl 129: if ($allowed) {
130: $home++;
1.484 raeburn 131: $outhash{'home_'.$ca.':'.$cd}=1;
1.329 droeschl 132: } else {
1.484 raeburn 133: $outhash{'otherhome_'.$ca.':'.$cd}=$myhome;
1.329 droeschl 134: $other++;
135: }
136: }
137: }
138: return ($home,$other,%outhash);
139: }
140:
141:
142: sub clean {
143: my ($title)=@_;
144: $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
1.344 bisitz 145: return $title;
1.329 droeschl 146: }
147:
1.617 raeburn 148: sub default_folderpath {
149: my ($coursenum,$coursedom,$navmapref) = @_;
150: return unless ($coursenum && $coursedom && ref($navmapref));
151: # Check if entire course is hidden and/or encrypted
152: my ($hiddenmap,$encryptmap,$folderpath,$hiddentop);
153: my $toplevel = "uploaded/$coursedom/$coursenum/default.sequence";
154: unless (ref($$navmapref)) {
155: $$navmapref = Apache::lonnavmaps::navmap->new();
156: }
157: if (ref($$navmapref)) {
158: if (lc($$navmapref->get_mapparam(undef,$toplevel,"0.hiddenresource")) eq 'yes') {
159: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
160: my @resources = $$navmapref->retrieveResources($toplevel,$filterFunc,1,1);
161: unless (@resources) {
162: $hiddenmap = 1;
163: unless ($env{'request.role.adv'}) {
164: $hiddentop = 1;
165: if ($env{'form.folder'}) {
166: undef($env{'form.folder'});
167: }
168: }
169: }
170: }
171: if (lc($$navmapref->get_mapparam(undef,$toplevel,"0.encrypturl")) eq 'yes') {
172: $encryptmap = 1;
173: }
174: }
175: unless ($hiddentop) {
176: $folderpath='default&'.&escape(&mt('Main Content')).
177: '::'.$hiddenmap.':'.$encryptmap.'::';
178: }
179: if (wantarray) {
180: return ($folderpath,$hiddentop);
181: } else {
182: return $folderpath;
183: }
184: }
1.329 droeschl 185:
1.677 raeburn 186: sub validate_folderpath {
187: my ($supplementalflag) = @_;
188: if ($env{'form.folderpath'} ne '') {
189: my @items = split(/\&/,$env{'form.folderpath'});
190: my $badpath;
191: for (my $i=0; $i<@items; $i++) {
192: my $odd = $i%2;
193: if (($odd) && (!$supplementalflag) && ($items[$i] !~ /^[^:]*:(|\d+):(|1):(|1):(|1):(|1)$/)) {
194: $badpath = 1;
195: } elsif ((!$odd) && ($items[$i] !~ /^(default|supplemental)(|_\d+)$/)) {
196: $badpath = 1;
197: }
198: last if ($badpath);
199: }
200: if ($badpath) {
201: delete($env{'form.folderpath'});
202: }
203: }
204: return;
205: }
206:
207: sub validate_suppath {
208: if ($env{'form.supppath'} ne '') {
209: my @items = split(/\&/,$env{'form.supppath'});
210: my $badpath;
211: for (my $i=0; $i<@items; $i++) {
212: my $odd = $i%2;
213: if ((!$odd) && ($items[$i] !~ /^supplemental(|_\d+)$/)) {
214: $badpath = 1;
215: }
216: last if ($badpath);
217: }
218: if ($badpath) {
219: delete($env{'form.supppath'});
220: }
221: }
222: return;
223: }
224:
1.329 droeschl 225: sub dumpcourse {
226: my ($r) = @_;
1.408 raeburn 227: my $crstype = &Apache::loncommon::course_type();
1.567 raeburn 228: my ($starthash,$js);
229: unless (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
230: $js = <<"ENDJS";
231: <script type="text/javascript">
232: // <![CDATA[
233:
234: function hide_searching() {
235: if (document.getElementById('searching')) {
236: document.getElementById('searching').style.display = 'none';
237: }
238: return;
239: }
240:
241: // ]]>
242: </script>
243: ENDJS
244: $starthash = {
245: add_entries => {'onload' => "hide_searching();"},
246: };
247: }
1.568 raeburn 248: $r->print(&Apache::loncommon::start_page('Copy '.$crstype.' Content to Authoring Space',$js,$starthash)."\n".
249: &Apache::lonhtmlcommon::breadcrumbs('Copy '.$crstype.' Content to Authoring Space')."\n");
1.484 raeburn 250: $r->print(&startContentScreen('tools'));
1.329 droeschl 251: my ($home,$other,%outhash)=&authorhosts();
1.484 raeburn 252: unless ($home) {
253: $r->print(&endContentScreen());
254: return '';
255: }
1.329 droeschl 256: my $origcrsid=$env{'request.course.id'};
257: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
258: if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
259: # Do the dumping
1.484 raeburn 260: unless ($outhash{'home_'.$env{'form.authorspace'}}) {
261: $r->print(&endContentScreen());
262: return '';
263: }
1.531 raeburn 264: my ($ca,$cd)=split(/\:/,$env{'form.authorspace'});
1.329 droeschl 265: $r->print('<h3>'.&mt('Copying Files').'</h3>');
266: my $title=$env{'form.authorfolder'};
267: $title=&clean($title);
1.567 raeburn 268: my ($navmap,$errormsg) =
269: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
270: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
271: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
272: my (%maps,%resources,%titles);
273: if (!ref($navmap)) {
274: $r->print($errormsg.
275: &endContentScreen());
276: return '';
277: } else {
278: &Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles,
279: 'dumpdocs',$cdom,$cnum);
1.329 droeschl 280: }
1.567 raeburn 281: my @todump = &Apache::loncommon::get_env_multiple('form.archive');
282: my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages,
283: %newcontent,%has_simpleprobs);
284: foreach my $item (sort {$a <=> $b} (@todump)) {
285: my $name = $env{'form.namefor_'.$item};
286: if ($resources{$item}) {
287: my ($map,$id,$res) = &Apache::lonnet::decode_symb($resources{$item});
288: if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) {
289: $tocopy{$1} = $name;
290: $display{$item} = $1;
291: $lookup{$1} = $item;
292: } elsif ($res eq 'lib/templates/simpleproblem.problem') {
293: $simpleproblems{$item} = {
294: symb => $resources{$item},
295: name => $name,
296: };
297: $display{$item} = 'simpleproblem_'.$name;
298: if ($map =~ m{^\Quploaded/$cdom/$cnum/\E(.+)$}) {
299: $has_simpleprobs{$1}{$id} = $item;
300: }
301: } elsif ($res =~ m{^adm/$match_domain/$match_username/(\d+)/smppg}) {
302: my $marker = $1;
303: my $db_name = &Apache::lonsimplepage::get_db_name($res,$marker,$cdom,$cnum);
304: $simplepages{$item} = {
305: res => $res,
306: title => $titles{$item},
307: db => $db_name,
308: marker => $marker,
309: symb => $resources{$item},
310: name => $name,
311: };
312: $display{$item} = '/'.$res;
313: }
314: } elsif ($maps{$item}) {
315: if ($maps{$item} =~ m{^\Quploaded/$cdom/$cnum/\E((?:default|supplemental)_\d+\.(?:sequence|page))$}) {
316: $tocopy{$1} = $name;
317: $display{$item} = $1;
318: $lookup{$1} = $item;
319: }
320: } else {
321: next;
322: }
323: }
1.329 droeschl 324: my $crs='/uploaded/'.$env{'request.course.id'}.'/';
325: $crs=~s/\_/\//g;
1.567 raeburn 326: my $mm = new File::MMagic;
327: my $prefix = "/uploaded/$cdom/$cnum/";
328: %replacehash = %tocopy;
329: foreach my $item (sort(keys(%simpleproblems))) {
330: my $content = &Apache::imsexport::simpleproblem($simpleproblems{$item}{'symb'});
331: $newcontent{$display{$item}} = $content;
332: }
333: my $gateway = Apache::lonhtmlgateway->new('web');
334: foreach my $item (sort(keys(%simplepages))) {
335: if (ref($simplepages{$item}) eq 'HASH') {
336: my $pagetitle = $simplepages{$item}{'title'};
337: my %fields = &Apache::lonnet::dump($simplepages{$item}{'db'},$cdom,$cnum);
338: my %contents;
339: foreach my $field (keys(%fields)) {
340: if ($field =~ /^(?:aaa|bbb|ccc)_(\w+)$/) {
341: my $name = $1;
342: my $msg = $fields{$field};
343: if ($name eq 'webreferences') {
344: if ($msg =~ m{^https?://}) {
345: $contents{$name} = '<a href="'.$msg.'"><tt>'.$msg.'</tt></a>';
346: }
347: } else {
348: $msg = &Encode::decode('utf8',$msg);
349: $msg = $gateway->process_outgoing_html($msg,1);
350: $contents{$name} = $msg;
351: }
352: } elsif ($field eq 'uploaded.photourl') {
353: my $marker = $simplepages{$item}{marker};
354: if ($fields{$field} =~ m{^\Q$prefix\E(simplepage/$marker/.+)$}) {
355: my $filepath = $1;
356: my ($relpath,$fname) = ($filepath =~ m{^(.+/)([^/]+)$});
357: if ($fname ne '') {
358: $fname=~s/\.(\w+)$//;
359: my $ext=$1;
360: $fname = &clean($fname);
361: $fname.='.'.$ext;
362: $contents{image} = '<img src="'.$relpath.$fname.'" alt="Image" />';
363: $replacehash{$filepath} = $relpath.$fname;
364: $deps{$item}{$filepath} = 1;
365: }
366: }
367: }
368: }
369: $replacehash{'/'.$simplepages{$item}{'res'}} = $simplepages{$item}{'name'};
370: $lookup{'/'.$simplepages{$item}{'res'}} = $item;
371: my $content = '
372: <html>
373: <head>
374: <title>'.$pagetitle.'</title>
375: </head>
376: <body bgcolor="#ffffff">';
377: if ($contents{title}) {
378: $content .= "\n".'<h2>'.$contents{title}.'</h2>';
379: }
380: if ($contents{image}) {
381: $content .= "\n".$contents{image};
382: }
383: if ($contents{content}) {
384: $content .= '
385: <div class="LC_Box">
1.577 bisitz 386: <h4 class="LC_hcell">'.&mt('Content').'</h4>'.
1.567 raeburn 387: $contents{content}.'
388: </div>';
389: }
390: if ($contents{webreferences}) {
391: $content .= '
392: <div class="LC_Box">
1.577 bisitz 393: <h4 class="LC_hcell">'.&mt('Web References').'</h4>'.
1.567 raeburn 394: $contents{webreferences}.'
395: </div>';
396: }
397: $content .= '
398: </body>
399: </html>
400: ';
401: $newcontent{'/'.$simplepages{$item}{res}} = $content;
402: }
403: }
404: foreach my $item (keys(%tocopy)) {
405: unless ($item=~/\.(sequence|page)$/) {
406: my $currurlpath = $prefix.$item;
407: my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath);
408: &recurse_html($mm,$prefix,$currdirpath,$currurlpath,$item,$lookup{$item},\%replacehash,\%deps);
409: }
410: }
411: foreach my $num (sort {$a <=> $b} (@todump)) {
412: my $src = $display{$num};
413: next if ($src eq '');
414: my @needcopy = ();
415: if ($replacehash{$src}) {
416: push(@needcopy,$src);
417: if (ref($deps{$num}) eq 'HASH') {
418: foreach my $dep (sort(keys(%{$deps{$num}}))) {
419: if ($replacehash{$dep}) {
420: push(@needcopy,$dep);
421: }
422: }
423: }
424: } elsif ($src =~ /^simpleproblem_/) {
425: push(@needcopy,$src);
426: }
427: next if (@needcopy == 0);
428: my ($result,$depresult);
429: for (my $i=0; $i<@needcopy; $i++) {
430: my $item = $needcopy[$i];
431: my $newfilename;
432: if ($simpleproblems{$num}) {
433: $newfilename=$title.'/'.$simpleproblems{$num}{'name'};
434: } else {
435: $newfilename=$title.'/'.$replacehash{$item};
436: }
437: $newfilename=~s/\.(\w+)$//;
438: my $ext=$1;
439: $newfilename=&clean($newfilename);
440: $newfilename.='.'.$ext;
441: my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$});
442: if ($newrelpath ne $replacehash{$item}) {
443: $replacehash{$item} = $newrelpath;
444: }
445: my @dirs=split(/\//,$newfilename);
446: my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
447: my $makepath=$path;
448: my $fail;
449: my $origin;
450: for (my $i=0;$i<$#dirs;$i++) {
451: $makepath.='/'.$dirs[$i];
452: unless (-e $makepath) {
453: unless(mkdir($makepath,0755)) {
454: $fail = &mt('Directory creation failed.');
455: }
456: }
457: }
458: if ($i == 0) {
459: $result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ';
460: } else {
461: $depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '.
462: '<span class="LC_fontsize_small" style="font-weight: bold;">'.
463: &mt('(dependency)').'</span>: ';
464: }
465: if (-e $path.'/'.$newfilename) {
466: $fail = &mt('Destination already exists -- not overwriting.');
467: } else {
468: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
469: if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) ||
470: ($item =~ /^simpleproblem_/)) {
471: print $fh $newcontent{$item};
472: } else {
473: my $fileloc = &Apache::lonnet::filelocation('',$prefix.$item);
474: if (-e $fileloc) {
475: if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
476: if ((($1 eq 'sequence') || ($1 eq 'page')) &&
477: (ref($has_simpleprobs{$item}) eq 'HASH')) {
478: my %changes = %{$has_simpleprobs{$item}};
479: my $content = &Apache::lonclonecourse::rewritefile(
480: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
481: (%replacehash,$crs => '')
482: );
483: my $updatedcontent = '';
484: my $parser = HTML::TokeParser->new(\$content);
485: $parser->attr_encoded(1);
486: while (my $token = $parser->get_token) {
487: if ($token->[0] eq 'S') {
488: if (($token->[1] eq 'resource') &&
489: ($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') &&
490: ($changes{$token->[2]->{'id'}})) {
491: my $id = $token->[2]->{'id'};
492: $updatedcontent .= '<'.$token->[1];
493: foreach my $attrib (@{$token->[3]}) {
494: next unless ($attrib =~ /^(src|type|title|id)$/);
495: if ($attrib eq 'src') {
496: my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/);
497: if ($file) {
498: $updatedcontent .= ' '.$attrib.'="'.$file.'"';
499: } else {
500: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
501: }
502: } else {
503: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
504: }
505: }
506: $updatedcontent .= ' />'."\n";
507: } else {
508: $updatedcontent .= $token->[4]."\n";
509: }
510: } else {
511: $updatedcontent .= $token->[2];
512: }
513: }
514: print $fh $updatedcontent;
515: } else {
516: print $fh &Apache::lonclonecourse::rewritefile(
517: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
518: (%replacehash,$crs => '')
519: );
520: }
521: } else {
522: print $fh
523: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
524: }
525: } else {
526: $fail = &mt('Source does not exist.');
527: }
528: }
529: $fh->close();
530: } else {
531: $fail = &mt('Could not write to destination.');
532: }
533: }
534: my $text;
535: if ($fail) {
536: $text = '<span class="LC_error">'.&mt('fail').(' 'x3).$fail.'</span>';
537: } else {
538: $text = '<span class="LC_success">'.&mt('ok').'</span>';
539: }
540: if ($i == 0) {
541: $result .= $text;
542: } else {
543: $depresult .= $text.'</li>';
544: }
545: }
546: $r->print($result);
547: if ($depresult) {
548: $r->print('<ul>'.$depresult.'</ul>');
549: }
550: }
551: } else {
552: my ($navmap,$errormsg) =
553: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
554: if (!ref($navmap)) {
555: $r->print($errormsg);
556: } else {
557: $r->print('<div id="searching">'.&mt('Searching ...').'</div>');
558: $r->rflush();
559: my ($preamble,$formname);
560: $formname = 'dumpdoc';
561: unless ($home==1) {
562: $preamble = '<div class="LC_left_float">'.
563: '<fieldset><legend>'.
564: &mt('Select the Authoring Space').
565: '</legend><select name="authorspace">';
1.329 droeschl 566: }
1.567 raeburn 567: my @orderspaces = ();
568: foreach my $key (sort(keys(%outhash))) {
569: if ($key=~/^home_(.+)$/) {
570: if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) {
571: unshift(@orderspaces,$1);
572: } else {
573: push(@orderspaces,$1);
574: }
575: }
576: }
1.569 raeburn 577: if ($home>1) {
578: $preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>';
579: }
1.567 raeburn 580: foreach my $user (@orderspaces) {
1.329 droeschl 581: if ($home==1) {
1.567 raeburn 582: $preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />';
1.329 droeschl 583: } else {
1.567 raeburn 584: $preamble .= '<option value="'.$user.'">'.$user.' - '.
585: &Apache::loncommon::plainname(split(/\:/,$user)).'</option>';
586: }
1.329 droeschl 587: }
1.567 raeburn 588: unless ($home==1) {
589: $preamble .= '</select></fieldset></div>'."\n";
1.329 droeschl 590: }
1.567 raeburn 591: my $title=$origcrsdata{'description'};
592: $title=~s/[\/\s]+/\_/gs;
1.329 droeschl 593: $title=&clean($title);
1.567 raeburn 594: $preamble .= '<div class="LC_left_float">'.
595: '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.
596: '<input type="text" size="50" name="authorfolder" value="'.
597: $title.'" />'.
598: '</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n";
599: my %uploadedfiles;
600: &tiehash();
601: foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
602: my ($ext)=($file=~/\.(\w+)$/);
603: # FIXME Check supplemental here
604: my $title=$hash{'title_'.$hash{
605: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
606: if (!$title) {
607: $title=$file;
608: } else {
609: $title=~s|/|_|g;
610: }
611: $title=~s/\.(\w+)$//;
612: $title=&clean($title);
613: $title.='.'.$ext;
614: # $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
615: $uploadedfiles{$file} = $title;
616: }
617: &untiehash();
618: $r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef,
619: undef,undef,$preamble,$home,\%uploadedfiles));
620: }
1.329 droeschl 621: }
1.484 raeburn 622: $r->print(&endContentScreen());
1.329 droeschl 623: }
624:
1.567 raeburn 625: sub recurse_html {
626: my ($mm,$prefix,$currdirpath,$currurlpath,$container,$item,$replacehash,$deps) = @_;
627: return unless ((ref($replacehash) eq 'HASH') && (ref($deps) eq 'HASH'));
628: my (%allfiles,%codebase);
629: if (&Apache::lonnet::extract_embedded_items($currdirpath,\%allfiles,\%codebase) eq 'ok') {
630: if (keys(%allfiles)) {
631: foreach my $dependency (keys(%allfiles)) {
632: next if (($dependency =~ m{^/(res|adm)/}) || ($dependency =~ m{^https?://}));
633: my ($depurl,$relfile,$newcontainer);
634: if ($dependency =~ m{^/}) {
635: if ($dependency =~ m{^\Q$currurlpath/\E(.+)$}) {
636: $relfile = $1;
637: if ($dependency =~ m{^\Q$prefix\E(.+)$}) {
638: $newcontainer = $1;
639: next if ($replacehash->{$newcontainer});
640: }
641: $depurl = $dependency;
642: } else {
643: next;
644: }
645: } else {
646: $relfile = $dependency;
647: $depurl = $currurlpath;
1.630 raeburn 648: $depurl =~ s{[^/]+$}{};
1.567 raeburn 649: $depurl .= $dependency;
1.630 raeburn 650: ($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$});
1.567 raeburn 651: }
652: next if ($relfile eq '');
653: my $newname = $replacehash->{$container};
654: $newname =~ s{[^/]+$}{};
655: $replacehash->{$newcontainer} = $newname.$relfile;
656: $deps->{$item}{$newcontainer} = 1;
657: my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$});
658: my $depfile = &Apache::lonnet::filelocation('',$depurl);
659: my $type = $mm->checktype_filename($depfile);
660: if ($type eq 'text/html') {
661: &recurse_html($mm,$prefix,$depfile,$newurlpath,$newcontainer,$item,$replacehash,$deps);
662: }
663: }
664: }
665: }
666: return;
667: }
668:
1.329 droeschl 669: sub group_import {
1.598 raeburn 670: my ($coursenum, $coursedom, $folder, $container, $caller, $ltitoolsref, @files) = @_;
1.529 raeburn 671: my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap,
672: %removeparam,$importuploaded,$fixuperrors);
673: $allmaps = {};
1.329 droeschl 674: while (@files) {
675: my ($name, $url, $residx) = @{ shift(@files) };
1.344 bisitz 676: if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
1.329 droeschl 677: && ($caller eq 'londocs')
678: && (!&Apache::lonnet::stat_file($url))) {
1.364 bisitz 679:
1.329 droeschl 680: my $errtext = '';
681: my $fatal = 0;
682: my $newmapstr = '<map>'."\n".
683: '<resource id="1" src="" type="start"></resource>'."\n".
684: '<link from="1" to="2" index="1"></link>'."\n".
685: '<resource id="2" src="" type="finish"></resource>'."\n".
686: '</map>';
687: $env{'form.output'}=$newmapstr;
688: my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
689: 'output',$1.$2);
1.534 raeburn 690: if ($result !~ m{^/uploaded/}) {
1.329 droeschl 691: $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
692: $fatal = 2;
693: }
694: if ($fatal) {
695: return ($errtext,$fatal);
696: }
697: }
698: if ($url) {
1.626 raeburn 699: if ($url =~ m{^(/adm/$coursedom/$coursenum/(\d+)/ext\.tool)\:?(.*)$}) {
1.598 raeburn 700: $url = $1;
701: my $marker = $2;
702: my $info = $3;
1.604 raeburn 703: my ($toolid,%toolhash,%toolsettings);
1.642 raeburn 704: my @extras = ('linktext','explanation','crslabel','crstitle','crsappend');
1.598 raeburn 705: my @toolinfo = split(/:/,$info);
706: if ($residx) {
1.604 raeburn 707: %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
1.598 raeburn 708: $toolid = $toolsettings{'id'};
709: } else {
1.604 raeburn 710: $toolid = shift(@toolinfo);
1.598 raeburn 711: }
712: $toolid =~ s/\D//g;
1.604 raeburn 713: ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'},
1.645 raeburn 714: $toolhash{'linktext'},$toolhash{'explanation'},$toolhash{'crslabel'},
715: $toolhash{'crstitle'},$toolhash{'crsappend'},$toolhash{'gradable'}) = @toolinfo;
1.624 raeburn 716: foreach my $item (@extras) {
717: $toolhash{$item} = &unescape($toolhash{$item});
718: }
1.645 raeburn 719: if ($folder =~ /^supplemental/) {
1.648 raeburn 720: delete($toolhash{'gradable'});
721: } else {
722: $toolhash{'gradable'} =~ s/\D+//g;
1.645 raeburn 723: }
1.598 raeburn 724: if (ref($ltitoolsref) eq 'HASH') {
725: if (ref($ltitoolsref->{$toolid}) eq 'HASH') {
1.643 raeburn 726: my @deleted;
1.598 raeburn 727: $toolhash{'id'} = $toolid;
1.628 raeburn 728: if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'tab') ||
729: ($toolhash{'target'} eq 'window')) {
1.604 raeburn 730: if ($toolhash{'target'} eq 'window') {
731: foreach my $item ('width','height') {
732: $toolhash{$item} =~ s/^\s+//;
733: $toolhash{$item} =~ s/\s+$//;
1.624 raeburn 734: if ($toolhash{$item} =~ /\D/) {
735: delete($toolhash{$item});
736: if ($residx) {
737: if ($toolsettings{$item}) {
738: push(@deleted,$item);
739: }
740: }
741: }
1.604 raeburn 742: }
743: }
744: } elsif ($residx) {
745: $toolhash{'target'} = $toolsettings{'target'};
746: if ($toolhash{'target'} eq 'window') {
1.630 raeburn 747: foreach my $item ('width','height') {
1.624 raeburn 748: $toolhash{$item} = $toolsettings{$item};
749: }
1.604 raeburn 750: }
751: } elsif (ref($ltitoolsref->{$toolid}->{'display'}) eq 'HASH') {
752: $toolhash{'target'} = $ltitoolsref->{$toolid}->{'display'}->{'target'};
753: if ($toolhash{'target'} eq 'window') {
754: $toolhash{'width'} = $ltitoolsref->{$toolid}->{'display'}->{'width'};
755: $toolhash{'height'} = $ltitoolsref->{$toolid}->{'display'}->{'height'};
756: }
757: }
1.598 raeburn 758: if ($toolhash{'target'} eq 'iframe') {
1.624 raeburn 759: foreach my $item ('width','height','linktext','explanation') {
760: delete($toolhash{$item});
761: if ($residx) {
762: if ($toolsettings{$item}) {
763: push(@deleted,$item);
764: }
1.604 raeburn 765: }
766: }
1.628 raeburn 767: } elsif ($toolhash{'target'} eq 'tab') {
768: foreach my $item ('width','height') {
769: delete($toolhash{$item});
770: if ($residx) {
771: if ($toolsettings{$item}) {
772: push(@deleted,$item);
773: }
774: }
775: }
1.604 raeburn 776: }
777: if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') {
1.624 raeburn 778: foreach my $item ('label','title','linktext','explanation') {
779: my $crsitem;
780: if (($item eq 'label') || ($item eq 'title')) {
781: $crsitem = 'crs'.$item;
782: } else {
783: $crsitem = $item;
784: }
1.604 raeburn 785: if ($ltitoolsref->{$toolid}->{'crsconf'}->{$item}) {
1.624 raeburn 786: $toolhash{$crsitem} =~ s/^\s+//;
787: $toolhash{$crsitem} =~ s/\s+$//;
788: if ($toolhash{$crsitem} eq '') {
789: delete($toolhash{$crsitem});
1.604 raeburn 790: }
791: } else {
1.624 raeburn 792: delete($toolhash{$crsitem});
1.604 raeburn 793: }
1.624 raeburn 794: if (($residx) && (exists($toolsettings{$crsitem}))) {
795: unless (exists($toolhash{$crsitem})) {
796: push(@deleted,$crsitem);
1.604 raeburn 797: }
798: }
1.598 raeburn 799: }
800: }
1.643 raeburn 801: if ($toolhash{'passback'}) {
802: my $gradesecret = UUID::Tiny::create_uuid_as_string(UUID_V4);
803: $toolhash{'gradesecret'} = $gradesecret;
804: $toolhash{'gradesecretdate'} = time;
805: }
806: if ($toolhash{'roster'}) {
807: my $rostersecret = UUID::Tiny::create_uuid_as_string(UUID_V4);
808: $toolhash{'rostersecret'} = $rostersecret;
809: $toolhash{'rostersecretdate'} = time;
810: }
1.645 raeburn 811: my $changegradable;
812: if (($residx) && ($folder =~ /^default/)) {
1.648 raeburn 813: if ($toolsettings{'gradable'}) {
814: unless (($toolhash{'gradable'}) || (defined($LONCAPA::map::zombies[$residx]))) {
1.645 raeburn 815: push(@deleted,'gradable');
816: $changegradable = 1;
817: }
1.648 raeburn 818: } elsif ($toolhash{'gradable'}) {
819: $changegradable = 1;
820: }
821: if (($caller eq 'londocs') && (defined($LONCAPA::map::zombies[$residx]))) {
1.645 raeburn 822: $changegradable = 1;
1.648 raeburn 823: if ($toolsettings{'gradable'}) {
824: $toolhash{'gradable'} = 1;
825: }
1.645 raeburn 826: }
827: }
1.598 raeburn 828: my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum);
1.604 raeburn 829: if ($putres eq 'ok') {
830: if (@deleted) {
831: &Apache::lonnet::del('exttool_'.$marker,\@deleted,$coursedom,$coursenum);
1.645 raeburn 832: }
833: if (($changegradable) && ($folder =~ /^default/)) {
834: my $val;
835: if ($toolhash{'gradable'}) {
836: $val = 'yes';
837: } else {
838: $val = 'no';
839: }
840: &LONCAPA::map::storeparameter($residx,'parameter_0_gradable',$val,
841: 'string_yesno');
842: &remember_parms($residx,'gradable','set',$val);
843: }
844: } else {
845: return (&mt('Failed to save update to external tool.'),1);
1.604 raeburn 846: }
1.598 raeburn 847: }
848: }
849: }
1.529 raeburn 850: if (($caller eq 'londocs') &&
851: ($folder =~ /^default/)) {
1.534 raeburn 852: if (($url =~ /\.(page|sequence)$/) && (!$donechk)) {
1.529 raeburn 853: my $chome = &Apache::lonnet::homeserver($coursenum,$coursedom);
854: my $cid = $coursedom.'_'.$coursenum;
855: $allmaps =
856: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
857: $chome,$cid);
858: $donechk = 1;
859: }
860: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) {
1.627 raeburn 861: &contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap,
862: \%removeparam,\%addedmaps,\%hierarchy,\%titles,$allmaps);
1.529 raeburn 863: $importuploaded = 1;
864: } elsif ($url =~ m{^/res/.+\.(page|sequence)$}) {
865: next if ($allmaps->{$url});
866: }
867: }
1.344 bisitz 868: if (!$residx
1.329 droeschl 869: || defined($LONCAPA::map::zombies[$residx])) {
870: $residx = &LONCAPA::map::getresidx($url,$residx);
871: push(@LONCAPA::map::order, $residx);
872: }
873: my $ext = 'false';
874: if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
1.534 raeburn 875: if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) {
876: my $filepath = $1;
1.675 raeburn 877: my $fname;
878: if ($name eq '') {
879: $name = &mt('Web Page');
1.534 raeburn 880: $fname = 'web';
881: } else {
1.675 raeburn 882: $fname = $name;
883: $fname=&Apache::lonnet::clean_filename($fname);
884: if ($fname eq '') {
885: $fname = 'web';
886: } elsif (length($fname) > 15) {
887: $fname = substr($fname,0,14);
888: }
1.534 raeburn 889: }
1.675 raeburn 890: my $title = &Apache::loncommon::cleanup_html($name);
1.534 raeburn 891: my $initialtext = &mt('Replace with your own content.');
892: my $newhtml = <<END;
1.545 raeburn 893: <html>
1.534 raeburn 894: <head>
1.675 raeburn 895: <title>$title</title>
1.534 raeburn 896: </head>
897: <body bgcolor="#ffffff">
898: $initialtext
899: </body>
900: </html>
901: END
902: $env{'form.output'}=$newhtml;
1.630 raeburn 903: my $result =
1.534 raeburn 904: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
905: 'output',
906: "$filepath/$residx/$fname.html");
907: if ($result =~ m{^/uploaded/}) {
908: $url = $result;
909: if ($filepath =~ /^supplemental/) {
910: $name = time.'___&&&___'.$env{'user.name'}.'___&&&___'.
911: $env{'user.domain'}.'___&&&___'.$name;
912: }
913: } else {
914: return (&mt('Failed to save new web page.'),1);
915: }
916: }
1.675 raeburn 917: $name = &LONCAPA::map::qtunescape($name);
1.538 raeburn 918: $url = &LONCAPA::map::qtunescape($url);
1.344 bisitz 919: $LONCAPA::map::resources[$residx] =
1.329 droeschl 920: join(':', ($name, $url, $ext, 'normal', 'res'));
921: }
922: }
1.529 raeburn 923: if ($importuploaded) {
924: my %import_errors;
925: my %updated = (
926: removefrommap => \%removefrommap,
927: removeparam => \%removeparam,
928: );
1.533 raeburn 929: my ($result,$msgsarray,$lockerror) =
930: &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
1.529 raeburn 931: if (keys(%import_errors) > 0) {
1.530 raeburn 932: $fixuperrors =
1.529 raeburn 933: '<p span class="LC_warning">'."\n".
934: &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".
935: '<ul>'."\n";
936: foreach my $key (sort(keys(%import_errors))) {
937: $fixuperrors .= '<li>'.$key.'</li>'."\n";
938: }
939: $fixuperrors .= '</ul></p>'."\n";
940: }
1.533 raeburn 941: if (ref($msgsarray) eq 'ARRAY') {
942: if (@{$msgsarray} > 0) {
943: $fixuperrors .= '<p class="LC_info">'.
944: join('<br />',@{$msgsarray}).
945: '</p>';
946: }
947: }
948: if ($lockerror) {
949: $fixuperrors .= '<p class="LC_error">'.
950: $lockerror.
951: '</p>';
952: }
1.529 raeburn 953: }
954: my ($errtext,$fatal) =
955: &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
1.557 raeburn 956: unless ($fatal) {
957: if ($folder =~ /^supplemental/) {
1.561 raeburn 958: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
959: $folder.'.'.$container);
1.557 raeburn 960: }
961: }
1.529 raeburn 962: return ($errtext,$fatal,$fixuperrors);
1.329 droeschl 963: }
964:
965: sub log_docs {
1.494 raeburn 966: return &Apache::lonnet::write_log('course','docslog',@_);
1.329 droeschl 967: }
968:
969: {
970: my @oldresources=();
971: my @oldorder=();
972: my $parmidx;
973: my %parmaction=();
974: my %parmvalue=();
975: my $changedflag;
976:
977: sub snapshotbefore {
978: @oldresources=@LONCAPA::map::resources;
979: @oldorder=@LONCAPA::map::order;
980: $parmidx=undef;
981: %parmaction=();
982: %parmvalue=();
983: $changedflag=0;
984: }
985:
986: sub remember_parms {
987: my ($idx,$parameter,$action,$value)=@_;
988: $parmidx=$idx;
989: $parmaction{$parameter}=$action;
990: $parmvalue{$parameter}=$value;
991: $changedflag=1;
992: }
993:
994: sub log_differences {
995: my ($plain)=@_;
996: my %storehash=('folder' => $plain,
997: 'currentfolder' => $env{'form.folder'});
998: if ($parmidx) {
999: $storehash{'parameter_res'}=$oldresources[$parmidx];
1000: foreach my $parm (keys(%parmaction)) {
1001: $storehash{'parameter_action_'.$parm}=$parmaction{$parm};
1002: $storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
1003: }
1004: }
1005: my $maxidx=$#oldresources;
1006: if ($#LONCAPA::map::resources>$#oldresources) {
1007: $maxidx=$#LONCAPA::map::resources;
1008: }
1009: for (my $idx=0; $idx<=$maxidx; $idx++) {
1010: if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
1011: $storehash{'before_resources_'.$idx}=$oldresources[$idx];
1012: $storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
1013: $changedflag=1;
1014: }
1015: if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
1016: $storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
1017: $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
1018: $changedflag=1;
1019: }
1020: }
1021: $storehash{'maxidx'}=$maxidx;
1022: if ($changedflag) { &log_docs(\%storehash); }
1023: }
1024: }
1025:
1026: sub docs_change_log {
1.611 raeburn 1027: my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit)=@_;
1.486 raeburn 1028: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
1.617 raeburn 1029: my $navmap;
1.483 raeburn 1030: my $js = '<script type="text/javascript">'."\n".
1031: '// <![CDATA['."\n".
1032: &Apache::loncommon::display_filter_js('docslog')."\n".
1.606 raeburn 1033: &editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag,
1.622 raeburn 1034: $coursedom,$coursenum,'','',$canedit,'',\$navmap)."\n".
1.483 raeburn 1035: &history_tab_js()."\n".
1.484 raeburn 1036: &Apache::lonratedt::editscript('simple')."\n".
1.483 raeburn 1037: '// ]]>'."\n".
1038: '</script>'."\n";
1.484 raeburn 1039: $r->print(&Apache::loncommon::start_page('Content Change Log',$js));
1040: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Change Log'));
1.489 raeburn 1041: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484 raeburn 1042: my %orderhash;
1043: my $container='sequence';
1044: my $pathitem;
1.519 raeburn 1045: if ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 1046: $container='page';
1047: }
1.519 raeburn 1048: my $folderpath=$env{'form.folderpath'};
1049: if ($folderpath eq '') {
1.617 raeburn 1050: $folderpath = &default_folderpath($coursenum,$coursedom,\$navmap);
1.519 raeburn 1051: }
1.617 raeburn 1052: undef($navmap);
1.519 raeburn 1053: $pathitem = '<input type="hidden" name="folderpath" value="'.
1054: &HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 1055: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
1056: my $jumpto = $readfile;
1057: $jumpto =~ s{^/}{};
1058: my $tid = 1;
1.489 raeburn 1059: if ($supplementalflag) {
1060: $tid = 2;
1061: }
1.630 raeburn 1062: my ($breadcrumbtrail) =
1.509 raeburn 1063: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
1.484 raeburn 1064: $r->print($breadcrumbtrail.
1065: &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto,
1066: $readfile));
1.329 droeschl 1067: my %docslog=&Apache::lonnet::dump('nohist_docslog',
1068: $env{'course.'.$env{'request.course.id'}.'.domain'},
1069: $env{'course.'.$env{'request.course.id'}.'.num'});
1070:
1071: if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
1072:
1073: my %saveable_parameters = ('show' => 'scalar',);
1074: &Apache::loncommon::store_course_settings('docs_log',
1075: \%saveable_parameters);
1076: &Apache::loncommon::restore_course_settings('docs_log',
1077: \%saveable_parameters);
1078: if (!$env{'form.show'}) { $env{'form.show'}=10; }
1.452 www 1079: # FIXME: internationalization seems wrong here
1.329 droeschl 1080: my %lt=('hiddenresource' => 'Resources hidden',
1081: 'encrypturl' => 'URL hidden',
1082: 'randompick' => 'Randomly pick',
1083: 'randomorder' => 'Randomly ordered',
1.645 raeburn 1084: 'gradable' => 'Grade can be assigned to External Tool',
1.329 droeschl 1085: 'set' => 'set to',
1086: 'del' => 'deleted');
1.484 raeburn 1087: my $filter = &Apache::loncommon::display_filter('docslog')."\n".
1088: $pathitem."\n".
1089: '<input type="hidden" name="folder" value="'.$env{'form.folder'}.'" />'.
1090: (' 'x2).'<input type="submit" value="'.&mt('Display').'" />';
1091: $r->print('<div class="LC_left_float">'.
1092: '<fieldset><legend>'.&mt('Display of Content Changes').'</legend>'."\n".
1093: &makedocslogform($filter,1).
1094: '</fieldset></div><br clear="all" />');
1.329 droeschl 1095: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
1096: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
1097: &mt('After').'</th>'.
1098: &Apache::loncommon::end_data_table_header_row());
1099: my $shown=0;
1100: foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
1101: if ($env{'form.displayfilter'} eq 'currentfolder') {
1102: if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
1103: }
1104: my @changes=keys(%{$docslog{$id}{'logentry'}});
1105: if ($env{'form.displayfilter'} eq 'containing') {
1106: my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
1107: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
1108: foreach my $key (@changes) {
1109: $wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
1110: }
1.344 bisitz 1111: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
1.329 droeschl 1112: }
1113: my $count = 0;
1114: my $time =
1115: &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
1116: my $plainname =
1117: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
1118: $docslog{$id}{'exe_udom'});
1119: my $about_me_link =
1120: &Apache::loncommon::aboutmewrapper($plainname,
1121: $docslog{$id}{'exe_uname'},
1122: $docslog{$id}{'exe_udom'});
1123: my $send_msg_link='';
1124: if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
1125: || ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
1126: $send_msg_link ='<br />'.
1127: &Apache::loncommon::messagewrapper(&mt('Send message'),
1128: $docslog{$id}{'exe_uname'},
1129: $docslog{$id}{'exe_udom'});
1130: }
1131: $r->print(&Apache::loncommon::start_data_table_row());
1132: $r->print('<td>'.$time.'</td>
1133: <td>'.$about_me_link.
1134: '<br /><tt>'.$docslog{$id}{'exe_uname'}.
1135: ':'.$docslog{$id}{'exe_udom'}.'</tt>'.
1136: $send_msg_link.'</td><td>'.
1137: $docslog{$id}{'logentry'}{'folder'}.'</td><td>');
1.488 raeburn 1138: my $is_supp = 0;
1139: if ($docslog{$id}{'logentry'}{'currentfolder'} =~ /^supplemental/) {
1140: $is_supp = 1;
1141: }
1.329 droeschl 1142: # Before
1143: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1144: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
1145: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
1146: if ($oldname ne $newname) {
1.488 raeburn 1147: my $shown = &LONCAPA::map::qtescape($oldname);
1148: if ($is_supp) {
1149: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1150: }
1151: $r->print($shown);
1.329 droeschl 1152: }
1153: }
1154: $r->print('<ul>');
1155: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1156: if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
1.488 raeburn 1157: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]);
1158: if ($is_supp) {
1159: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1160: }
1161: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 1162: }
1163: }
1164: $r->print('</ul>');
1165: # After
1166: $r->print('</td><td>');
1167:
1168: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1169: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
1170: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
1171: if ($oldname ne '' && $oldname ne $newname) {
1.488 raeburn 1172: my $shown = &LONCAPA::map::qtescape($newname);
1173: if ($is_supp) {
1174: $shown = &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($newname));
1175: }
1176: $r->print($shown);
1.329 droeschl 1177: }
1.364 bisitz 1178: }
1.329 droeschl 1179: $r->print('<ul>');
1180: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1181: if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
1.488 raeburn 1182: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]);
1183: if ($is_supp) {
1184: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1185: }
1186: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 1187: }
1188: }
1189: $r->print('</ul>');
1190: if ($docslog{$id}{'logentry'}{'parameter_res'}) {
1191: $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
1.645 raeburn 1192: foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder','gradable') {
1.329 droeschl 1193: if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
1.452 www 1194: # FIXME: internationalization seems wrong here
1.329 droeschl 1195: $r->print('<li>'.
1196: &mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
1197: $docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
1198: .'</li>');
1199: }
1200: }
1201: $r->print('</ul>');
1202: }
1203: # End
1204: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1205: $shown++;
1206: if (!($env{'form.show'} eq &mt('all')
1207: || $shown<=$env{'form.show'})) { last; }
1208: }
1.484 raeburn 1209: $r->print(&Apache::loncommon::end_data_table()."\n".
1210: &makesimpleeditform($pathitem)."\n".
1211: '</div></div>');
1212: $r->print(&endContentScreen());
1.329 droeschl 1213: }
1214:
1215: sub update_paste_buffer {
1.492 raeburn 1216: my ($coursenum,$coursedom,$folder) = @_;
1.591 raeburn 1217: my (@possibles,%removals,%cuts,$output);
1.538 raeburn 1218: if ($env{'form.multiremove'}) {
1219: $env{'form.multiremove'} =~ s/,$//;
1220: map { $removals{$_} = 1; } split(/,/,$env{'form.multiremove'});
1221: }
1222: if (($env{'form.multicopy'}) || ($env{'form.multicut'})) {
1223: if ($env{'form.multicut'}) {
1224: $env{'form.multicut'} =~ s/,$//;
1225: foreach my $item (split(/,/,$env{'form.multicut'})) {
1226: unless ($removals{$item}) {
1227: $cuts{$item} = 1;
1228: push(@possibles,$item.':cut');
1229: }
1230: }
1231: }
1232: if ($env{'form.multicopy'}) {
1233: $env{'form.multicopy'} =~ s/,$//;
1234: foreach my $item (split(/,/,$env{'form.multicopy'})) {
1235: unless ($removals{$item} || $cuts{$item}) {
1236: push(@possibles,$item.':copy');
1237: }
1238: }
1239: }
1240: } elsif ($env{'form.markcopy'}) {
1241: @possibles = split(/,/,$env{'form.markcopy'});
1242: }
1.329 droeschl 1243:
1.538 raeburn 1244: return if (@possibles == 0);
1.329 droeschl 1245: return if (!defined($env{'form.copyfolder'}));
1246:
1247: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1248: $env{'form.copyfolder'});
1.538 raeburn 1249: return if ($fatal);
1250:
1251: my %curr_groups = &Apache::longroup::coursegroups();
1.364 bisitz 1252:
1.538 raeburn 1253: # Retrieve current paste buffer suffixes.
1254: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1255: my (%pasteurls,@newpaste);
1256:
1257: # Construct identifiers for current contents of user's paste buffer
1258: if (@currpaste) {
1259: foreach my $suffix (@currpaste) {
1.667 raeburn 1260: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1261: my $url = $env{'docs.markedcopy_url_'.$suffix};
1262: my $mapidx = $env{'docs.markedcopy_map_'.$suffix};
1263: if (($cid =~ /^$match_domain(?:_)$match_courseid$/) &&
1264: ($url ne '')) {
1265: if ($url eq '/res/lib/templates/simpleproblem.problem') {
1266: $pasteurls{$cid.'_'.$mapidx} = 1;
1267: } elsif ($url =~ m{^/res/$match_domain/$match_username/}) {
1268: $pasteurls{$url} = 1;
1269: } else {
1.669 raeburn 1270: $pasteurls{$cid.'_'.$url} = 1;
1.667 raeburn 1271: }
1272: }
1.538 raeburn 1273: }
1274: }
1275:
1276: # Mark items for copying (skip any items already in user's paste buffer)
1277: my %addtoenv;
1.597 raeburn 1278:
1279: my @pathitems = split(/\&/,$env{'form.folderpath'});
1280: my @folderconf = split(/\:/,$pathitems[-1]);
1.666 raeburn 1281: my $ispage = $folderconf[5];
1.597 raeburn 1282:
1.538 raeburn 1283: foreach my $item (@possibles) {
1284: my ($orderidx,$cmd) = split(/:/,$item);
1285: next if ($orderidx =~ /\D/);
1286: next unless (($cmd eq 'cut') || ($cmd eq 'copy') || ($cmd eq 'remove'));
1.597 raeburn 1287: my $mapidx = $folder.':'.$orderidx.':'.$ispage;
1.538 raeburn 1288: my ($title,$url)=split(':',$LONCAPA::map::resources[$orderidx]);
1289: my %denied = &action_restrictions($coursenum,$coursedom,
1290: &LONCAPA::map::qtescape($url),
1291: $env{'form.folderpath'},\%curr_groups);
1292: next if ($denied{'copy'});
1293: $url=~s{http(:|:)//https(:|:)//}{https$2//};
1.667 raeburn 1294: if ($url eq '/res/lib/templates/simpleproblem.problem') {
1295: next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$mapidx}));
1296: } elsif ($url =~ m{^/res/$match_domain/$match_username/}) {
1297: next if (exists($pasteurls{$url}));
1298: } else {
1299: next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$url}));
1300: }
1.538 raeburn 1301: my ($suffix,$errortxt,$locknotfreed) =
1302: &new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste');
1.591 raeburn 1303: if ($suffix ne '') {
1304: push(@newpaste,$suffix);
1305: } else {
1306: if ($locknotfreed) {
1307: return $locknotfreed;
1308: }
1.538 raeburn 1309: }
1310: if (&is_supplemental_title($title)) {
1311: &Apache::lonnet::appenv({'docs.markedcopy_supplemental_'.$suffix => $title});
1312: ($title) = &Apache::loncommon::parse_supplemental_title($title);
1313: }
1.329 droeschl 1314:
1.538 raeburn 1315: $addtoenv{'docs.markedcopy_title_'.$suffix} = $title,
1316: $addtoenv{'docs.markedcopy_url_'.$suffix} = $url,
1317: $addtoenv{'docs.markedcopy_cmd_'.$suffix} = $cmd,
1318: $addtoenv{'docs.markedcopy_crs_'.$suffix} = $env{'request.course.id'};
1.597 raeburn 1319: $addtoenv{'docs.markedcopy_map_'.$suffix} = $mapidx;
1.538 raeburn 1320: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) {
1321: my $prefix = $1;
1322: my $subdir =$2;
1323: if ($subdir eq '') {
1324: $subdir = $prefix;
1.492 raeburn 1325: }
1.538 raeburn 1326: my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps);
1.627 raeburn 1327: &contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap,
1328: \%removeparam,\%addedmaps,\%hierarchy,\%titles,\%allmaps);
1.538 raeburn 1329: if (ref($hierarchy{$url}) eq 'HASH') {
1330: my ($nested,$nestednames);
1331: &recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames);
1332: $nested =~ s/\&$//;
1333: $nestednames =~ s/\Q___&&&___\E$//;
1334: if ($nested ne '') {
1335: $addtoenv{'docs.markedcopy_nested_'.$suffix} = $nested;
1336: }
1337: if ($nestednames ne '') {
1338: $addtoenv{'docs.markedcopy_nestednames_'.$suffix} = $nestednames;
1339: }
1.492 raeburn 1340: }
1341: }
1.591 raeburn 1342: if ($locknotfreed) {
1343: $output = $locknotfreed;
1344: last;
1345: }
1.492 raeburn 1346: }
1.538 raeburn 1347: if (@newpaste) {
1348: $addtoenv{'docs.markedcopies'} = join(',',(@currpaste,@newpaste));
1349: }
1.492 raeburn 1350: &Apache::lonnet::appenv(\%addtoenv);
1.329 droeschl 1351: delete($env{'form.markcopy'});
1.591 raeburn 1352: return $output;
1.329 droeschl 1353: }
1354:
1.492 raeburn 1355: sub recurse_uploaded_maps {
1356: my ($url,$dir,$hierarchy,$titlesref,$nestref,$namesref) = @_;
1357: if (ref($hierarchy->{$url}) eq 'HASH') {
1358: my @maps = map { $hierarchy->{$url}{$_}; } sort { $a <=> $b } (keys(%{$hierarchy->{$url}}));
1359: my @titles = map { $titlesref->{$url}{$_}; } sort { $a <=> $b } (keys(%{$titlesref->{$url}}));
1360: my (@uploaded,@names,%shorter);
1361: for (my $i=0; $i<@maps; $i++) {
1362: my ($inner) = ($maps[$i] =~ m{^/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_(\d+)\.(?:page|sequence)$});
1363: if ($inner ne '') {
1364: push(@uploaded,$inner);
1365: push(@names,&escape($titles[$i]));
1366: $shorter{$maps[$i]} = $inner;
1367: }
1368: }
1369: $$nestref .= "$dir:".join(',',@uploaded).'&';
1370: $$namesref .= "$dir:".(join(',',@names)).'___&&&___';
1371: foreach my $map (@maps) {
1372: if ($shorter{$map} ne '') {
1373: &recurse_uploaded_maps($map,$shorter{$map},$hierarchy,$titlesref,$nestref,$namesref);
1374: }
1375: }
1376: }
1377: return;
1378: }
1379:
1.329 droeschl 1380: sub print_paste_buffer {
1.492 raeburn 1381: my ($r,$container,$folder,$coursedom,$coursenum) = @_;
1.538 raeburn 1382: return if (!defined($env{'docs.markedcopies'}));
1.329 droeschl 1383:
1.538 raeburn 1384: unless (($env{'form.pastemarked'}) || ($env{'form.clearmarked'})) {
1385: return if ($env{'docs.markedcopies'} eq '');
1.488 raeburn 1386: }
1387:
1.538 raeburn 1388: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1389: my ($pasteitems,@pasteable);
1.575 raeburn 1390: my $clipboardcount = 0;
1.488 raeburn 1391:
1.538 raeburn 1392: # Construct identifiers for current contents of user's paste buffer
1393: foreach my $suffix (@currpaste) {
1394: next if ($suffix =~ /\D/);
1395: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1396: my $url = $env{'docs.markedcopy_url_'.$suffix};
1.597 raeburn 1397: my $mapidx = $env{'docs.markedcopy_map_'.$suffix};
1.538 raeburn 1398: if (($cid =~ /^$match_domain\_$match_courseid$/) &&
1399: ($url ne '')) {
1.575 raeburn 1400: $clipboardcount ++;
1.538 raeburn 1401: my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent,
1.598 raeburn 1402: $canpaste,$nopaste,$othercrs,$areachange,$is_exttool);
1.538 raeburn 1403: my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1];
1404: if ($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
1405: $is_external = 1;
1.626 raeburn 1406: } elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$}) {
1.598 raeburn 1407: $is_exttool = 1;
1.538 raeburn 1408: }
1409: if ($folder =~ /^supplemental/) {
1410: $canpaste = &supp_pasteable($env{'docs.markedcopy_url_'.$suffix});
1411: unless ($canpaste) {
1412: $nopaste = &mt('Paste into Supplemental Content unavailable.');
1413: }
1414: } else {
1415: $canpaste = 1;
1416: }
1417: if ($canpaste) {
1418: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1419: my $srcdom = $1;
1420: my $srcnum = $2;
1421: my $rem = $3;
1422: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
1423: $othercourse = 1;
1424: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1.596 raeburn 1425: $othercrs = '<br />'.&mt('(from another course)');
1.538 raeburn 1426: } else {
1427: $canpaste = 0;
1428: $nopaste = &mt('Paste from another course unavailable.');
1429: }
1430: }
1431: if ($rem =~ m{^(default|supplemental)_?(\d*)\.(?:page|sequence)$}) {
1432: my $prefix = $1;
1433: $parent = $2;
1434: if ($folder !~ /^\Q$prefix\E/) {
1435: $areachange = 1;
1436: }
1437: $is_uploaded_map = 1;
1.492 raeburn 1438: }
1.597 raeburn 1439: } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
1.627 raeburn 1440: ($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg|ext\.tool)$})) {
1.596 raeburn 1441: if ($cid ne $env{'request.course.id'}) {
1442: my ($srcdom,$srcnum) = split(/_/,$cid);
1443: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1.627 raeburn 1444: if (($is_exttool) && ($srcdom ne $coursedom)) {
1445: $canpaste = 0;
1446: $nopaste = &mt('Paste from another domain unavailable.');
1447: } else {
1448: $othercrs = '<br />'.&mt('(from another course)');
1449: }
1.596 raeburn 1450: } else {
1451: $canpaste = 0;
1452: $nopaste = &mt('Paste from another course unavailable.');
1.629 raeburn 1453: }
1.596 raeburn 1454: }
1.492 raeburn 1455: }
1.596 raeburn 1456: if ($canpaste) {
1457: push(@pasteable,$suffix);
1.629 raeburn 1458: }
1.538 raeburn 1459: }
1460: my $buffer;
1.627 raeburn 1461: if ($is_external) {
1.538 raeburn 1462: $buffer = &mt('External Resource').': '.
1463: &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('.
1464: &LONCAPA::map::qtescape($url).')';
1.627 raeburn 1465: } elsif ($is_exttool) {
1466: $buffer = &mt('External Tool').': '.
1467: &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.538 raeburn 1468: } else {
1469: my $icon = &Apache::loncommon::icon($extension);
1470: if ($extension eq 'sequence' &&
1471: $url =~ m{/default_\d+\.sequence$}x) {
1472: $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
1473: $icon .= '/navmap.folder.closed.gif';
1474: }
1.589 raeburn 1475: my $title = $env{'docs.markedcopy_title_'.$suffix};
1476: if ($title eq '') {
1477: ($title) = ($url =~ m{/([^/]+)$});
1478: }
1.538 raeburn 1479: $buffer = '<img src="'.$icon.'" alt="" class="LC_icon" />'.
1480: ': '.
1481: &Apache::loncommon::parse_supplemental_title(
1.589 raeburn 1482: &LONCAPA::map::qtescape($title));
1.538 raeburn 1483: }
1484: $pasteitems .= '<div class="LC_left_float">';
1485: my ($options,$onclick);
1486: if (($canpaste) && (!$areachange) && (!$othercourse) &&
1487: ($env{'docs.markedcopy_cmd_'.$suffix} eq 'cut')) {
1488: if (($is_uploaded_map) ||
1489: ($url =~ /(bulletinboard|smppg)$/) ||
1490: ($url =~ m{^/uploaded/$coursedom/$coursenum/(?:docs|supplemental)/(.+)$})) {
1491: $options = &paste_options($suffix,$is_uploaded_map,$parent);
1492: $onclick= 'onclick="showOptions(this,'."'$suffix'".');" ';
1493: }
1494: }
1495: $pasteitems .= '<label><input type="checkbox" name="pasting" id="pasting_'.$suffix.'" value="'.$suffix.'" '.$onclick.'/>'.$buffer.'</label>';
1496: if ($nopaste) {
1.681 raeburn 1497: $pasteitems .= ' <span class="LC_cusr_emph">'.$nopaste.'</span>';
1.538 raeburn 1498: } else {
1499: if ($othercrs) {
1500: $pasteitems .= $othercrs;
1501: }
1502: if ($options) {
1503: $pasteitems .= $options;
1.492 raeburn 1504: }
1505: }
1.538 raeburn 1506: $pasteitems .= '</div>';
1507: }
1508: }
1509: if ($pasteitems eq '') {
1510: &Apache::lonnet::delenv('docs.markedcopies');
1511: }
1512: my ($pasteform,$form_start,$buttons,$form_end);
1513: if ($pasteitems) {
1514: $pasteitems .= '<div style="padding:0;clear:both;margin:0;border:0"></div>';
1.541 raeburn 1515: $form_start = '<form name="pasteform" action="/adm/coursedocs" method="post" onsubmit="return validateClipboard();">';
1.538 raeburn 1516: if (@pasteable) {
1.575 raeburn 1517: my $value = &mt('Paste to current folder');
1518: if ($container eq 'page') {
1519: $value = &mt('Paste to current page');
1520: }
1521: $buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.(' 'x2);
1522: }
1523: $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.(' 'x2);
1524: if ($clipboardcount > 1) {
1525: $buttons .=
1526: '<span style="text-decoration:line-through">'.(' 'x20).'</span>'.(' 'x2).
1527: '<input type="button" name="checkallclip" value="'.&mt('Check all').'" style="height:20px;" onclick="checkClipboard();" />'.
1528: (' 'x2).
1529: '<input type="button" name="uncheckallclip" value="'.&mt('Uncheck all').'" style="height:20px;" onclick="uncheckClipboard();" />'.
1530: (' 'x2);
1.492 raeburn 1531: }
1.575 raeburn 1532: $form_end = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'.
1533: '</form>';
1.538 raeburn 1534: } else {
1535: $pasteitems = &mt('Clipboard is empty');
1.488 raeburn 1536: }
1.538 raeburn 1537: $r->print($form_start
1538: .'<fieldset>'
1539: .'<legend>'.&mt('Clipboard').(' ' x2).$buttons.'</legend>'
1540: .$pasteitems
1541: .'</fieldset>'
1542: .$form_end);
1543: }
1544:
1545: sub paste_options {
1546: my ($suffix,$is_uploaded_map,$parent) = @_;
1547: my ($copytext,$movetext);
1548: if ($is_uploaded_map) {
1549: $copytext = &mt('Copy to new folder');
1550: $movetext = &mt('Move old');
1551: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /bulletinboard$/) {
1552: $copytext = &mt('Copy to new board');
1553: $movetext = &mt('Move (not posts)');
1554: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /smppg$/) {
1555: $copytext = &mt('Copy to new page');
1556: $movetext = &mt('Move');
1.533 raeburn 1557: } else {
1.538 raeburn 1558: $copytext = &mt('Copy to new file');
1559: $movetext = &mt('Move');
1560: }
1561: my $output = '<br />'.
1562: '<span id="pasteoptionstext_'.$suffix.'" class="LC_fontsize_small LC_nobreak"></span>'.
1563: '<div id="pasteoptions_'.$suffix.'" class="LC_dccid" style="display:none;"><span class="LC_nobreak">'.(' 'x 4).
1564: '<label>'.
1565: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="new" checked="checked" />'.
1566: $copytext.'</label></span>'.(' 'x2).' '.
1567: '<span class="LC_nobreak"><label>'.
1568: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="move" />'.
1569: $movetext.'</label></span>';
1570: if (($is_uploaded_map) && ($env{'docs.markedcopy_nested_'.$suffix})) {
1571: $output .= '<br /><fieldset><legend>'.&mt('Folder to paste contains sub-folders').
1572: '</legend><table border="0">';
1573: my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1574: my @titles = split(/\Q___&&&___\E/,$env{'docs.markedcopy_nestednames_'.$suffix});
1575: my $lastdir = $parent;
1576: my %depths = (
1577: $lastdir => 0,
1578: );
1579: my (%display,%deps);
1580: for (my $i=0; $i<@pastemaps; $i++) {
1581: ($lastdir,my $subfolderstr) = split(/\:/,$pastemaps[$i]);
1582: my ($namedir,$esctitlestr) = split(/\:/,$titles[$i]);
1583: my @subfolders = split(/,/,$subfolderstr);
1584: $deps{$lastdir} = \@subfolders;
1585: my @subfoldertitles = map { &unescape($_); } split(/,/,$esctitlestr);
1586: my $depth = $depths{$lastdir} + 1;
1587: my $offset = int($depth * 4);
1588: my $indent = (' ' x $offset);
1589: for (my $j=0; $j<@subfolders; $j++) {
1590: $depths{$subfolders[$j]} = $depth;
1591: $display{$subfolders[$j]} =
1592: '<tr><td>'.$indent.$subfoldertitles[$j].' </td>'.
1593: '<td><label>'.
1594: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="new" checked="checked" />'.&mt('Copy to new').'</label>'.(' ' x2).
1595: '<label>'.
1596: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="move" />'.
1597: &mt('Move old').'</label>'.
1598: '</td></tr>';
1599: }
1.492 raeburn 1600: }
1.538 raeburn 1601: &recurse_print(\$output,$parent,\%deps,\%display);
1602: $output .= '</table></fieldset>';
1.329 droeschl 1603: }
1.538 raeburn 1604: $output .= '</div>';
1605: return $output;
1.488 raeburn 1606: }
1607:
1.492 raeburn 1608: sub recurse_print {
1.538 raeburn 1609: my ($outputref,$dir,$deps,$display) = @_;
1610: $$outputref .= $display->{$dir}."\n";
1.492 raeburn 1611: if (ref($deps->{$dir}) eq 'ARRAY') {
1612: foreach my $subdir (@{$deps->{$dir}}) {
1.538 raeburn 1613: &recurse_print($outputref,$subdir,$deps,$display);
1.492 raeburn 1614: }
1615: }
1616: }
1617:
1.488 raeburn 1618: sub supp_pasteable {
1619: my ($url) = @_;
1620: if (($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//}) ||
1621: (($url =~ /\.sequence$/) && ($url =~ m{^/uploaded/})) ||
1622: ($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) ||
1623: ($url =~ m{^/adm/$match_domain/$match_username/aboutme}) ||
1.598 raeburn 1624: ($url =~ m{^/public/$match_domain/$match_courseid/syllabus}) ||
1.626 raeburn 1625: ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$})) {
1.488 raeburn 1626: return 1;
1627: }
1628: return;
1.329 droeschl 1629: }
1630:
1.492 raeburn 1631: sub paste_popup_js {
1.594 damieng 1632: my %html_js_lt = &Apache::lonlocal::texthash(
1.538 raeburn 1633: show => 'Show Options',
1634: hide => 'Hide Options',
1.594 damieng 1635: );
1636: my %js_lt = &Apache::lonlocal::texthash(
1.541 raeburn 1637: none => 'No items selected from clipboard.',
1.492 raeburn 1638: );
1.594 damieng 1639: &html_escape(\%html_js_lt);
1640: &js_escape(\%html_js_lt);
1641: &js_escape(\%js_lt);
1.492 raeburn 1642: return <<"END";
1643:
1.538 raeburn 1644: function showPasteOptions(suffix) {
1645: document.getElementById('pasteoptions_'+suffix).style.display='block';
1.594 damieng 1646: document.getElementById('pasteoptionstext_'+suffix).innerHTML = ' <a href="javascript:hidePasteOptions(\\''+suffix+'\\');" class="LC_menubuttons_link">$html_js_lt{'hide'}</a>';
1.492 raeburn 1647: return;
1648: }
1649:
1.538 raeburn 1650: function hidePasteOptions(suffix) {
1651: document.getElementById('pasteoptions_'+suffix).style.display='none';
1.594 damieng 1652: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.538 raeburn 1653: return;
1654: }
1655:
1656: function showOptions(caller,suffix) {
1657: if (document.getElementById('pasteoptionstext_'+suffix)) {
1658: if (caller.checked) {
1.594 damieng 1659: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.538 raeburn 1660: } else {
1661: document.getElementById('pasteoptionstext_'+suffix).innerHTML ='';
1662: }
1663: if (document.getElementById('pasteoptions_'+suffix)) {
1664: document.getElementById('pasteoptions_'+suffix).style.display='none';
1665: }
1666: }
1.492 raeburn 1667: return;
1668: }
1669:
1.541 raeburn 1670: function validateClipboard() {
1671: var numchk = 0;
1672: if (document.pasteform.pasting.length > 1) {
1673: for (var i=0; i<document.pasteform.pasting.length; i++) {
1674: if (document.pasteform.pasting[i].checked) {
1675: numchk ++;
1676: }
1677: }
1678: } else {
1679: if (document.pasteform.pasting.type == 'checkbox') {
1680: if (document.pasteform.pasting.checked) {
1681: numchk ++;
1682: }
1683: }
1684: }
1685: if (numchk > 0) {
1686: return true;
1687: } else {
1.594 damieng 1688: alert("$js_lt{'none'}");
1.541 raeburn 1689: return false;
1690: }
1691: }
1692:
1.575 raeburn 1693: function checkClipboard() {
1694: if (document.pasteform.pasting.length > 1) {
1695: for (var i=0; i<document.pasteform.pasting.length; i++) {
1696: document.pasteform.pasting[i].checked = true;
1697: }
1698: }
1699: return;
1700: }
1701:
1702: function uncheckClipboard() {
1703: if (document.pasteform.pasting.length >1) {
1704: for (var i=0; i<document.pasteform.pasting.length; i++) {
1705: document.pasteform.pasting[i].checked = false;
1706: }
1707: }
1708: return;
1709: }
1710:
1.492 raeburn 1711: END
1712:
1713: }
1714:
1.329 droeschl 1715: sub do_paste_from_buffer {
1.492 raeburn 1716: my ($coursenum,$coursedom,$folder,$container,$errors) = @_;
1.329 droeschl 1717:
1.538 raeburn 1718: # Array of items in paste buffer
1719: my (@currpaste,%pastebuffer,%allerrors);
1720: @currpaste = split(/,/,$env{'docs.markedcopies'});
1721:
1.492 raeburn 1722: # Early out if paste buffer is empty
1.538 raeburn 1723: if (@currpaste == 0) {
1.492 raeburn 1724: return ();
1.538 raeburn 1725: }
1726: map { $pastebuffer{$_} = 1; } @currpaste;
1727:
1728: # Array of items selected items to paste
1729: my @reqpaste = &Apache::loncommon::get_env_multiple('form.pasting');
1730:
1731: # Early out if nothing selected to paste
1732: if (@reqpaste == 0) {
1733: return();
1734: }
1735: my @topaste;
1736: foreach my $suffix (@reqpaste) {
1737: next if ($suffix =~ /\D/);
1738: next unless (exists($pastebuffer{$suffix}));
1739: push(@topaste,$suffix);
1740: }
1741:
1742: # Early out if nothing available to paste
1743: if (@topaste == 0) {
1744: return();
1.329 droeschl 1745: }
1746:
1.627 raeburn 1747: my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%notindom,%duplicate,
1.597 raeburn 1748: %prefixchg,%srcdom,%srcnum,%srcmapidx,%marktomove,$save_err,$lockerrors,$allresult);
1.538 raeburn 1749:
1750: foreach my $suffix (@topaste) {
1751: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1.596 raeburn 1752: my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.597 raeburn 1753: my $mapidx=&LONCAPA::map::qtescape($env{'docs.markedcopy_map_'.$suffix});
1.492 raeburn 1754: # Supplemental content may only include certain types of content
1755: # Early out if pasted content is not supported in Supplemental area
1.538 raeburn 1756: if ($folder =~ /^supplemental/) {
1757: unless (&supp_pasteable($url)) {
1758: $notinsupp{$suffix} = 1;
1759: next;
1760: }
1.492 raeburn 1761: }
1.538 raeburn 1762: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/}) {
1763: my $srcd = $1;
1764: my $srcn = $2;
1.492 raeburn 1765: # When paste buffer was populated using an active role in a different course
1.538 raeburn 1766: # check for mdc privilege in the course from which the resource was pasted
1767: if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1768: unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1769: $notincrs{$suffix} = 1;
1770: next;
1771: }
1.491 raeburn 1772: }
1.538 raeburn 1773: $srcdom{$suffix} = $srcd;
1774: $srcnum{$suffix} = $srcn;
1.597 raeburn 1775: } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
1.632 raeburn 1776: ($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg)$}) ||
1777: ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$})) {
1.596 raeburn 1778: my ($srcd,$srcn) = split(/_/,$cid);
1779: # When paste buffer was populated using an active role in a different course
1780: # check for mdc privilege in the course from which the resource was pasted
1781: if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1782: unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1783: $notincrs{$suffix} = 1;
1784: next;
1785: }
1786: }
1.632 raeburn 1787: # When buffer was populated using an active role in a different course
1788: # disallow pasting of External Tool if course is in a different domain.
1789: if (($url =~ m{/ext\.tool$}) && ($srcd ne $coursedom)) {
1.627 raeburn 1790: $notindom{$suffix} = 1;
1791: next;
1792: }
1.596 raeburn 1793: $srcdom{$suffix} = $srcd;
1794: $srcnum{$suffix} = $srcn;
1.491 raeburn 1795: }
1.597 raeburn 1796: $srcmapidx{$suffix} = $mapidx;
1.538 raeburn 1797: push(@dopaste,$suffix);
1798: if ($url=~/\.(page|sequence)$/) {
1799: $is_map{$suffix} = 1;
1800: }
1801: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/([^/]+)}) {
1802: my $oldprefix = $1;
1.492 raeburn 1803: # When pasting content from Main Content to Supplemental Content and vice versa
1804: # URLs will contain different paths (which depend on whether pasted item is
1.597 raeburn 1805: # a folder/page or a document).
1.538 raeburn 1806: if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) {
1807: $prefixchg{$suffix} = 'docstosupp';
1808: } elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) {
1809: $prefixchg{$suffix} = 'supptodocs';
1810: }
1.491 raeburn 1811:
1.492 raeburn 1812: # If pasting an uploaded map, get list of contained uploaded maps.
1.538 raeburn 1813: if ($env{'docs.markedcopy_nested_'.$suffix}) {
1814: my @nested;
1815: my ($type) = ($oldprefix =~ /^(default|supplemental)/);
1816: my @items = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1817: my @deps = map { /\d+:([\d,]+$)/ } @items;
1818: foreach my $dep (@deps) {
1819: if ($dep =~ /,/) {
1820: push(@nested,split(/,/,$dep));
1821: } else {
1822: push(@nested,$dep);
1823: }
1.492 raeburn 1824: }
1.538 raeburn 1825: foreach my $item (@nested) {
1826: if ($env{'form.docs.markedcopy_'.$suffix.'_'.$item} eq 'move') {
1827: push(@{$marktomove{$suffix}},$type.'_'.$item);
1828: }
1.492 raeburn 1829: }
1830: }
1.488 raeburn 1831: }
1832: }
1833:
1.538 raeburn 1834: # Early out if nothing available to paste
1835: if (@dopaste == 0) {
1836: return ();
1837: }
1838:
1839: # Populate message hash and hashes used for main content <=> supplemental content
1840: # changes
1841:
1842: %msgs = &Apache::lonlocal::texthash (
1843: notinsupp => 'Paste failed: content type is not supported within Supplemental Content',
1844: notincrs => 'Paste failed: Item is from a different course which you do not have rights to edit.',
1.661 raeburn 1845: notindom => 'Paste failed: Item is an external tool from a course in a different domain.',
1.538 raeburn 1846: duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.',
1847: );
1848:
1849: %before = (
1850: docstosupp => {
1851: map => 'default',
1852: doc => 'docs',
1853: },
1854: supptodocs => {
1855: map => 'supplemental',
1856: doc => 'supplemental',
1857: },
1858: );
1859:
1860: %after = (
1861: docstosupp => {
1862: map => 'supplemental',
1863: doc => 'supplemental'
1864: },
1865: supptodocs => {
1866: map => 'default',
1867: doc => 'docs',
1868: },
1869: );
1870:
1871: # Retrieve information about all course maps in main content area
1872:
1873: my $allmaps = {};
1.660 raeburn 1874: my (@toclear,%mapurls,%lockerrs,%msgerrs,%results,$donechk);
1.538 raeburn 1875:
1876: # Loop over the items to paste
1877: foreach my $suffix (@dopaste) {
1.329 droeschl 1878: # Maps need to be copied first
1.538 raeburn 1879: my (%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies,
1880: %dbcopies,%zombies,%params,%docmoves,%mapmoves,%mapchanges,%newsubdir,
1.597 raeburn 1881: %newurls,%tomove,%resdatacopy);
1.538 raeburn 1882: if (ref($marktomove{$suffix}) eq 'ARRAY') {
1883: map { $tomove{$_} = 1; } @{$marktomove{$suffix}};
1884: }
1885: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1886: my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.596 raeburn 1887: my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.538 raeburn 1888: my $oldurl = $url;
1889: if ($is_map{$suffix}) {
1.491 raeburn 1890: # If pasting a map, check if map contains other maps
1.538 raeburn 1891: my (%hierarchy,%titles);
1.660 raeburn 1892: if (($folder =~ /^default/) && (!$donechk)) {
1893: $allmaps =
1894: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
1895: $env{"course.$env{'request.course.id'}.home"},
1896: $env{'request.course.id'});
1897: $donechk = 1;
1898: }
1.627 raeburn 1899: &contained_map_check($url,$folder,$coursenum,$coursedom,
1900: \%removefrommap,\%removeparam,\%addedmaps,
1901: \%hierarchy,\%titles,$allmaps);
1.538 raeburn 1902: if ($url=~ m{^/uploaded/}) {
1903: my $newurl;
1904: unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
1905: ($newurl,my $error) =
1906: &get_newmap_url($url,$folder,$prefixchg{$suffix},$coursedom,
1907: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1908: \$title,$allmaps,\%newurls);
1909: if ($error) {
1910: $allerrors{$suffix} = $error;
1911: next;
1912: }
1913: if ($newurl ne '') {
1914: if ($newurl ne $url) {
1915: if ($newurl =~ /(?:default|supplemental)_(\d+).(?:sequence|page)$/) {
1916: $newsubdir{$url} = $1;
1917: }
1918: $mapchanges{$url} = 1;
1.492 raeburn 1919: }
1.538 raeburn 1920: }
1921: }
1922: if (($srcdom{$suffix} ne $coursedom) ||
1923: ($srcnum{$suffix} ne $coursenum) ||
1924: ($prefixchg{$suffix}) || (($newurl ne '') && ($newurl ne $url))) {
1925: unless (&url_paste_fixups($url,$folder,$prefixchg{$suffix},
1926: $coursedom,$coursenum,$srcdom{$suffix},
1927: $srcnum{$suffix},$allmaps,\%rewrites,
1928: \%retitles,\%copies,\%dbcopies,
1929: \%zombies,\%params,\%mapmoves,
1930: \%mapchanges,\%tomove,\%newsubdir,
1.597 raeburn 1931: \%newurls,\%resdatacopy)) {
1.538 raeburn 1932: $mapmoves{$url} = 1;
1933: }
1934: $url = $newurl;
1935: } elsif ($env{'docs.markedcopy_nested_'.$suffix}) {
1936: &url_paste_fixups($url,$folder,$prefixchg{$suffix},$coursedom,
1937: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1938: $allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies,
1939: \%zombies,\%params,\%mapmoves,\%mapchanges,
1.597 raeburn 1940: \%tomove,\%newsubdir,\%newurls,\%resdatacopy);
1.538 raeburn 1941: }
1942: } elsif ($url=~m {^/res/}) {
1.597 raeburn 1943: # published map can only exist once, so remove from paste buffer when done
1.538 raeburn 1944: push(@toclear,$suffix);
1945: # if pasting published map (main content area only) check map not already in course
1946: if ($folder =~ /^default/) {
1947: if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) {
1948: $duplicate{$suffix} = 1;
1949: next;
1.492 raeburn 1950: }
1.491 raeburn 1951: }
1952: }
1.538 raeburn 1953: }
1.627 raeburn 1954: if ($url=~ m{/(bulletinboard|smppg|ext\.tool)$}) {
1.538 raeburn 1955: my $prefix = $1;
1.648 raeburn 1956: my $fromothercrs;
1.538 raeburn 1957: #need to copy the db contents to a new one, unless this is a move.
1958: my %info = (
1959: src => $url,
1960: cdom => $coursedom,
1961: cnum => $coursenum,
1.596 raeburn 1962: );
1.649 raeburn 1963: if ($prefix eq 'ext.tool') {
1.655 raeburn 1964: if ($prefixchg{$suffix} eq 'docstosupp') {
1.649 raeburn 1965: $info{'delgradable'} = 1;
1966: }
1967: }
1.596 raeburn 1968: if (($srcdom{$suffix} =~ /^$match_domain$/) && ($srcnum{$suffix} =~ /^$match_courseid$/)) {
1969: unless (($srcdom{$suffix} eq $coursedom) && ($srcnum{$suffix} eq $coursenum)) {
1970: $fromothercrs = 1;
1971: $info{'cdom'} = $srcdom{$suffix};
1972: $info{'cnum'} = $srcnum{$suffix};
1973: }
1974: }
1975: unless (($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') && (!$fromothercrs)) {
1.630 raeburn 1976: my (%lockerr,$msg);
1.538 raeburn 1977: my ($newurl,$result,$errtext) =
1978: &dbcopy(\%info,$coursedom,$coursenum,\%lockerr);
1979: if ($result eq 'ok') {
1980: $url = $newurl;
1981: $title=&mt('Copy of').' '.$title;
1982: } else {
1983: if ($prefix eq 'smppg') {
1984: $msg = &mt('Paste failed: An error occurred when copying the simple page.').' '.$errtext;
1985: } elsif ($prefix eq 'bulletinboard') {
1.565 bisitz 1986: $msg = &mt('Paste failed: An error occurred when copying the discussion board.').' '.$errtext;
1.627 raeburn 1987: } elsif ($prefix eq 'ext.tool') {
1988: $msg = &mt('Paste failed: An error occurred when copying the external tool.').' '.$errtext;
1.538 raeburn 1989: }
1990: $results{$suffix} = $result;
1991: $msgerrs{$suffix} = $msg;
1992: $lockerrs{$suffix} = $lockerr{$prefix};
1993: next;
1994: }
1995: if ($lockerr{$prefix}) {
1996: $lockerrs{$suffix} = $lockerr{$prefix};
1.491 raeburn 1997: }
1.489 raeburn 1998: }
1999: }
1.538 raeburn 2000: $title = &LONCAPA::map::qtunescape($title);
2001: my $ext='false';
2002: if ($url=~m{^http(|s)://}) { $ext='true'; }
2003: if ($env{'docs.markedcopy_supplemental_'.$suffix}) {
2004: if ($folder !~ /^supplemental/) {
2005: (undef,undef,$title) =
2006: &Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental_'.$suffix});
2007: }
2008: } else {
2009: if ($folder=~/^supplemental/) {
2010: $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
2011: $env{'user.domain'}.'___&&&___'.$title;
1.491 raeburn 2012: }
1.533 raeburn 2013: }
1.491 raeburn 2014:
2015: # For uploaded files (excluding pages/sequences) path in copied file is changed
2016: # if paste is from Main to Supplemental (or vice versa), or if pasting between
2017: # courses.
2018:
1.538 raeburn 2019: unless ($is_map{$suffix}) {
2020: my $newidx;
1.492 raeburn 2021: # Now insert the URL at the bottom
1.538 raeburn 2022: $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
2023: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(.+)$}) {
2024: my $relpath = $1;
2025: if ($relpath ne '') {
2026: my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$});
2027: my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/);
2028: my $newprefix = $newloc;
2029: if ($newloc eq 'default') {
2030: $newprefix = 'docs';
2031: }
2032: if ($newdocsdir eq '') {
2033: $newdocsdir = 'default';
2034: }
1.630 raeburn 2035: if (($prefixchg{$suffix}) ||
2036: ($srcdom{$suffix} ne $coursedom) ||
1.538 raeburn 2037: ($srcnum{$suffix} ne $coursenum) ||
2038: ($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) {
2039: my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";
2040: $url =
2041: &Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath,
2042: &Apache::lonnet::getfile($oldurl));
2043: if ($url eq '/adm/notfound.html') {
2044: $msgs{$suffix} = &mt('Paste failed: an error occurred saving the file.');
2045: next;
2046: } else {
2047: my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$});
2048: $newsubpath =~ s{/+$}{/};
2049: $docmoves{$oldurl} = $newsubpath;
2050: }
1.491 raeburn 2051: }
2052: }
1.597 raeburn 2053: } elsif ($url =~ m{^/res/lib/templates/(\w+)\.problem$}) {
2054: my $template = $1;
2055: if ($newidx) {
2056: ©_templated_files($url,$srcdom{$suffix},$srcnum{$suffix},$srcmapidx{$suffix},
2057: $coursedom,$coursenum,$template,$newidx,"$folder.$container");
2058: }
1.649 raeburn 2059: } elsif ($url =~ /ext\.tool$/) {
1.655 raeburn 2060: if (($newidx) && ($folder=~/^default/)) {
1.649 raeburn 2061: my $marker = (split(m{/},$url))[4];
2062: my %toolsettings = &Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
2063: my $val = 'no';
2064: if ($toolsettings{'gradable'}) {
2065: $val = 'yes';
2066: }
2067: &LONCAPA::map::storeparameter($newidx,'parameter_0_gradable',$val,
2068: 'string_yesno');
2069: &remember_parms($newidx,'gradable','set',$val);
2070: }
1.491 raeburn 2071: }
1.538 raeburn 2072: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
2073: ':'.$ext.':normal:res';
2074: push(@LONCAPA::map::order,$newidx);
2075: # Store the result
2076: my ($errtext,$fatal) =
2077: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
2078: if ($fatal) {
2079: $save_err .= $errtext;
2080: $allresult = 'fail';
2081: }
1.488 raeburn 2082: }
1.538 raeburn 2083:
1.597 raeburn 2084: # Apply any changes to maps, or copy dependencies for uploaded HTML pages, or update
2085: # resourcedata for simpleproblems copied from another course
1.538 raeburn 2086: unless ($allresult eq 'fail') {
2087: my %updated = (
2088: rewrites => \%rewrites,
2089: zombies => \%zombies,
2090: removefrommap => \%removefrommap,
2091: removeparam => \%removeparam,
2092: dbcopies => \%dbcopies,
1.597 raeburn 2093: resdatacopy => \%resdatacopy,
1.538 raeburn 2094: retitles => \%retitles,
2095: );
2096: my %info = (
2097: newsubdir => \%newsubdir,
2098: params => \%params,
2099: );
2100: if ($prefixchg{$suffix}) {
2101: $info{'before'} = $before{$prefixchg{$suffix}};
2102: $info{'after'} = $after{$prefixchg{$suffix}};
2103: }
2104: my %moves = (
2105: copies => \%copies,
2106: docmoves => \%docmoves,
2107: mapmoves => \%mapmoves,
2108: );
2109: (my $result,$msgs{$suffix},my $lockerror) =
2110: &apply_fixups($folder,$is_map{$suffix},$coursedom,$coursenum,$errors,
2111: \%updated,\%info,\%moves,$prefixchg{$suffix},$oldurl,
2112: $url,'paste');
2113: $lockerrors .= $lockerror;
2114: if ($result eq 'ok') {
2115: if ($is_map{$suffix}) {
2116: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
2117: $folder.'.'.$container);
2118: if ($fatal) {
2119: $allresult = 'failread';
2120: } else {
2121: if ($#LONCAPA::map::order<1) {
2122: my $idx=&LONCAPA::map::getresidx();
2123: if ($idx<=0) { $idx=1; }
2124: $LONCAPA::map::order[0]=$idx;
2125: $LONCAPA::map::resources[$idx]='';
2126: }
2127: my $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
2128: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
2129: ':'.$ext.':normal:res';
2130: push(@LONCAPA::map::order,$newidx);
1.492 raeburn 2131:
2132: # Store the result
1.538 raeburn 2133: my ($errtext,$fatal) =
2134: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
2135: if ($fatal) {
2136: $save_err .= $errtext;
2137: $allresult = 'failstore';
2138: }
2139: }
2140: }
2141: if ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
2142: push(@toclear,$suffix);
2143: }
2144: }
1.492 raeburn 2145: }
2146: }
1.538 raeburn 2147: &clear_from_buffer(\@toclear,\@currpaste);
2148: my $msgsarray;
2149: foreach my $suffix (keys(%msgs)) {
2150: if (ref($msgs{$suffix}) eq 'ARRAY') {
2151: $msgsarray .= join(',',@{$msgs{$suffix}});
2152: }
2153: }
2154: return ($allresult,$save_err,$msgsarray,$lockerrors);
2155: }
1.533 raeburn 2156:
1.538 raeburn 2157: sub do_buffer_empty {
2158: my @currpaste = split(/,/,$env{'docs.markedcopies'});
2159: if (@currpaste == 0) {
2160: return &mt('Clipboard is already empty');
2161: }
2162: my @toclear = &Apache::loncommon::get_env_multiple('form.pasting');
2163: if (@toclear == 0) {
2164: return &mt('Nothing selected to clear from clipboard');
2165: }
2166: my $numdel = &clear_from_buffer(\@toclear,\@currpaste);
2167: if ($numdel) {
2168: return &mt('[quant,_1,item] cleared from clipboard',$numdel);
2169: } else {
2170: return &mt('Clipboard unchanged');
1.492 raeburn 2171: }
1.538 raeburn 2172: return;
2173: }
2174:
2175: sub clear_from_buffer {
2176: my ($toclear,$currpaste) = @_;
2177: return unless ((ref($toclear) eq 'ARRAY') && (ref($currpaste) eq 'ARRAY'));
2178: my %pastebuffer;
2179: map { $pastebuffer{$_} = 1; } @{$currpaste};
2180: my $numdel = 0;
2181: foreach my $suffix (@{$toclear}) {
2182: next if ($suffix =~ /\D/);
2183: next unless (exists($pastebuffer{$suffix}));
2184: my $regexp = 'docs.markedcopy_[a-z]+_'.$suffix;
2185: if (&Apache::lonnet::delenv($regexp,1) eq 'ok') {
2186: delete($pastebuffer{$suffix});
2187: $numdel ++;
2188: }
2189: }
2190: my $newbuffer = join(',',sort(keys(%pastebuffer)));
2191: &Apache::lonnet::appenv({'docs.markedcopies' => $newbuffer});
2192: return $numdel;
1.492 raeburn 2193: }
2194:
2195: sub get_newmap_url {
2196: my ($url,$folder,$prefixchg,$coursedom,$coursenum,$srcdom,$srcnum,
2197: $titleref,$allmaps,$newurls) = @_;
2198: my $newurl;
2199: if ($url=~ m{^/uploaded/}) {
2200: $$titleref=&mt('Copy of').' '.$$titleref;
2201: }
2202: my $now = time;
2203: my $suffix=$$.int(rand(100)).$now;
2204: my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
2205: if ($oldid =~ m{^(/uploaded/$match_domain/$match_courseid/)(\D+)(\d+)$}) {
2206: my $path = $1;
2207: my $prefix = $2;
2208: my $ancestor = $3;
2209: if (length($ancestor) > 10) {
2210: $ancestor = substr($ancestor,-10,10);
2211: }
2212: my $newid;
2213: if ($prefixchg) {
2214: if ($folder =~ /^supplemental/) {
2215: $prefix =~ s/^default/supplemental/;
2216: } else {
2217: $prefix =~ s/^supplemental/default/;
2218: }
2219: }
2220: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
2221: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
2222: } else {
2223: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$now.'.'.$ext;
2224: }
2225: my $counter = 0;
2226: my $is_unique = &uniqueness_check($newurl);
2227: if ($folder =~ /^default/) {
2228: if ($allmaps->{$newurl}) {
2229: $is_unique = 0;
2230: }
2231: }
2232: while ((!$is_unique || $allmaps->{$newurl} || $newurls->{$newurl}) && ($counter < 100)) {
2233: $counter ++;
2234: $suffix ++;
2235: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
2236: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
2237: } else {
2238: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$ancestor.$suffix.'.'.$ext;
2239: }
2240: $is_unique = &uniqueness_check($newurl);
2241: }
2242: if ($is_unique) {
2243: $newurls->{$newurl} = 1;
2244: } else {
2245: if ($url=~/\.page$/) {
2246: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the composite page'));
2247: } else {
2248: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the folder'));
2249: }
2250: }
1.329 droeschl 2251: }
1.492 raeburn 2252: return ($newurl);
1.329 droeschl 2253: }
2254:
1.488 raeburn 2255: sub dbcopy {
1.533 raeburn 2256: my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_;
2257: my ($url,$result,$errtext);
2258: if (ref($dbref) eq 'HASH') {
1.596 raeburn 2259: $url = $dbref->{'src'};
1.627 raeburn 2260: if ($url =~ m{/(smppg|bulletinboard|ext\.tool)$}) {
1.533 raeburn 2261: my $prefix = $1;
1.627 raeburn 2262: if ($prefix eq 'ext.tool') {
2263: $prefix = 'exttool';
2264: }
1.533 raeburn 2265: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2266: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2267: my $db_name;
2268: my $marker = (split(m{/},$url))[4];
2269: $marker=~s/\D//g;
2270: if ($dbref->{'src'} =~ m{/smppg$}) {
2271: $db_name =
2272: &Apache::lonsimplepage::get_db_name($url,$marker,
2273: $dbref->{'cdom'},
2274: $dbref->{'cnum'});
1.627 raeburn 2275: } elsif ($dbref->{'src'} =~ m{/ext\.tool$}) {
2276: $db_name = 'exttool_'.$marker;
1.533 raeburn 2277: } else {
2278: $db_name = 'bulletinpage_'.$marker;
2279: }
2280: my ($suffix,$freedlock,$error) =
2281: &Apache::lonnet::get_timebased_id($prefix,'num','templated',
2282: $coursedom,$coursenum,
2283: 'concat');
2284: if (!$suffix) {
2285: if ($prefix eq 'smppg') {
2286: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);
1.631 raeburn 2287: } elsif ($prefix eq 'exttool') {
2288: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying an external tool [_1].',$url);
1.533 raeburn 2289: } else {
1.565 bisitz 2290: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url);
1.533 raeburn 2291: }
2292: if ($error) {
2293: $errtext .= '<br />'.$error;
2294: }
2295: } else {
2296: #need to copy the db contents to a new one.
2297: my %contents=&Apache::lonnet::dump($db_name,
2298: $dbref->{'cdom'},
2299: $dbref->{'cnum'});
2300: if (exists($contents{'uploaded.photourl'})) {
2301: my $photo = $contents{'uploaded.photourl'};
2302: my ($subdir,$fname) =
2303: ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});
1.596 raeburn 2304: my $newphoto;
1.533 raeburn 2305: if ($fname ne '') {
2306: my $content = &Apache::lonnet::getfile($photo);
2307: unless ($content eq '-1') {
2308: $env{'form.'.$suffix.'.photourl'} = $content;
2309: $newphoto =
2310: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");
2311: delete($env{'form.'.$suffix.'.photourl'});
2312: }
2313: }
2314: if ($newphoto =~ m{^/uploaded/}) {
2315: $contents{'uploaded.photourl'} = $newphoto;
2316: }
2317: }
2318: $db_name =~ s{_\d*$ }{_$suffix}x;
1.649 raeburn 2319: if (($prefix eq 'exttool') && ($dbref->{'delgradable'}) && ($contents{'gradable'})) {
2320: delete($contents{'gradable'});
2321: }
1.533 raeburn 2322: $result=&Apache::lonnet::put($db_name,\%contents,
2323: $coursedom,$coursenum);
2324: if ($result eq 'ok') {
1.627 raeburn 2325: $url =~ s{/(\d*)/(smppg|bulletinboard|ext\.tool)$}{/$suffix/$2}x;
1.533 raeburn 2326: }
2327: }
2328: if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) {
1.559 raeburn 2329: $lockerrorsref->{$prefix} =
1.533 raeburn 2330: '<div class="LC_error">'.
2331: &mt('There was a problem removing a lockfile.');
2332: if ($prefix eq 'smppg') {
1.560 raeburn 2333: $lockerrorsref->{$prefix} .=
1.559 raeburn 2334: ' '.&mt('This will prevent creation of additional simple pages in this course.');
1.627 raeburn 2335: } elsif ($prefix eq 'exttool') {
2336: $lockerrorsref->{$prefix} .=
2337: ' '.&mt('This will prevent addition of more external tools to this course.');
1.533 raeburn 2338: } else {
1.565 bisitz 2339: $lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional discussion boards in this course.');
1.533 raeburn 2340: }
1.560 raeburn 2341: $lockerrorsref->{$prefix} .= ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
2342: '<a href="/adm/helpdesk" target="_helpdesk">','</a>').
2343: '</div>';
1.533 raeburn 2344: }
2345: }
2346: } elsif ($url =~ m{/syllabus$}) {
2347: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2348: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2349: if (($dbref->{'cdom'} ne $coursedom) ||
2350: ($dbref->{'cnum'} ne $coursenum)) {
2351: my %contents=&Apache::lonnet::dump('syllabus',
2352: $dbref->{'cdom'},
2353: $dbref->{'cnum'});
2354: $result=&Apache::lonnet::put('syllabus',\%contents,
2355: $coursedom,$coursenum);
2356: }
2357: }
1.488 raeburn 2358: }
2359: }
1.533 raeburn 2360: return ($url,$result,$errtext);
1.488 raeburn 2361: }
2362:
1.597 raeburn 2363: sub copy_templated_files {
2364: my ($srcurl,$srcdom,$srcnum,$srcmapinfo,$coursedom,$coursenum,$template,$newidx,$newmapname) = @_;
2365: my ($srcfolder,$srcid,$srcwaspage) = split(/:/,$srcmapinfo);
2366: my $srccontainer = 'sequence';
2367: if ($srcwaspage) {
2368: $srccontainer = 'page';
2369: }
2370: my $srcsymb = "uploaded/$srcdom/$srcnum/$srcfolder.$srccontainer".
2371: '___'.$srcid.'___'.&Apache::lonnet::declutter($srcurl);
2372: my $srcprefix = $srcdom.'_'.$srcnum.'.'.$srcsymb;
2373: my %srcparms=&Apache::lonnet::dump('resourcedata',$srcdom,$srcnum,$srcprefix);
2374: my $newsymb = "uploaded/$coursedom/$coursenum/$newmapname".'___'.$newidx.'___lib/templates/'.
2375: $template.'.problem';
2376: my $newprefix = $coursedom.'_'.$coursenum.'.'.$newsymb;
2377: if ($template eq 'simpleproblem') {
2378: $srcprefix .= '.0.';
2379: my $weightprefix = $newprefix;
2380: $newprefix .= '.0.';
2381: my @simpleprobqtypes = qw(radio option string essay numerical);
2382: my $qtype=$srcparms{$srcprefix.'questiontype'};
2383: if (grep(/^\Q$qtype\E$/,@simpleprobqtypes)) {
1.665 raeburn 2384: my %newdata = (
2385: $newprefix.'questiontype' => $qtype,
2386: );
1.597 raeburn 2387: foreach my $type (@simpleprobqtypes) {
2388: if ($type eq $qtype) {
2389: $newdata{"$weightprefix.$type.weight"}=1;
2390: } else {
2391: $newdata{"$weightprefix.$type.weight"}=0;
2392: }
2393: }
2394: $newdata{$newprefix.'hiddenparts'} = '!'.$qtype;
2395: $newdata{$newprefix.'questiontext'} = $srcparms{$srcprefix.'questiontext'};
2396: $newdata{$newprefix.'hinttext'} = $srcparms{$srcprefix.'hinttext'};
2397: if ($qtype eq 'numerical') {
2398: $newdata{$newprefix.'numericalscript'} = $srcparms{$srcprefix.'numericalscript'};
2399: $newdata{$newprefix.'numericalanswer'} = $srcparms{$srcprefix.'numericalanswer'};
2400: $newdata{$newprefix.'numericaltolerance'} = $srcparms{$srcprefix.'numericaltolerance'};
2401: $newdata{$newprefix.'numericalsigfigs'} = $srcparms{$srcprefix.'numericalsigfigs'};
2402: } elsif (($qtype eq 'option') || ($qtype eq 'radio')) {
2403: my $maxfoils=$srcparms{$srcprefix.'maxfoils'};
2404: unless (defined($maxfoils)) { $maxfoils=10; }
2405: unless ($maxfoils=~/^\d+$/) { $maxfoils=10; }
2406: if ($maxfoils<=0) { $maxfoils=10; }
2407: my $randomize=$srcparms{$srcprefix.'randomize'};
2408: unless (defined($randomize)) { $randomize='yes'; }
2409: unless ($randomize eq 'no') { $randomize='yes'; }
2410: $newdata{$newprefix.'maxfoils'} = $maxfoils;
2411: $newdata{$newprefix.'randomize'} = $randomize;
2412: if ($qtype eq 'option') {
2413: $newdata{$newprefix.'options'} = $srcparms{$srcprefix.'options'};
2414: }
2415: for (my $i=1; $i<=10; $i++) {
2416: $newdata{$newprefix.'value'.$i} = $srcparms{$srcprefix.'value'.$i};
2417: $newdata{$newprefix.'position'.$i} = $srcparms{$srcprefix.'position'.$i};
2418: $newdata{$newprefix.'text'.$i} = $srcparms{$srcprefix.'text'.$i};
2419: }
2420:
2421: } elsif (($qtype eq 'option') || ($qtype eq 'radio')) {
2422: my $maxfoils=$srcparms{$srcprefix.'maxfoils'};
2423: unless (defined($maxfoils)) { $maxfoils=10; }
2424: unless ($maxfoils=~/^\d+$/) { $maxfoils=10; }
2425: if ($maxfoils<=0) { $maxfoils=10; }
2426: my $randomize=$srcparms{$srcprefix.'randomize'};
2427: unless (defined($randomize)) { $randomize='yes'; }
2428: unless ($randomize eq 'no') { $randomize='yes'; }
2429: $newdata{$newprefix.'maxfoils'} = $maxfoils;
2430: $newdata{$newprefix.'randomize'} = $randomize;
2431: if ($qtype eq 'option') {
2432: $newdata{$newprefix.'options'} = $srcparms{$srcprefix.'options'};
2433: }
2434: for (my $i=1; $i<=10; $i++) {
2435: $newdata{$newprefix.'value'.$i} = $srcparms{$srcprefix.'value'.$i};
2436: $newdata{$newprefix.'position'.$i} = $srcparms{$srcprefix.'position'.$i};
2437: $newdata{$newprefix.'text'.$i} = $srcparms{$srcprefix.'text'.$i};
2438: }
2439: } elsif ($qtype eq 'string') {
2440: $newdata{$newprefix.'stringanswer'} = $srcparms{$srcprefix.'stringanswer'};
2441: $newdata{$newprefix.'stringtype'} = $srcparms{$srcprefix.'stringtype'};
2442: }
2443: if (keys(%newdata)) {
2444: my $putres = &Apache::lonnet::cput('resourcedata',\%newdata,$coursedom,
2445: $coursenum);
2446: if ($putres eq 'ok') {
2447: &Apache::lonnet::devalidatecourseresdata($coursenum,$coursedom);
2448: }
2449: }
2450: }
2451: }
2452: }
2453:
1.329 droeschl 2454: sub uniqueness_check {
2455: my ($newurl) = @_;
2456: my $unique = 1;
2457: foreach my $res (@LONCAPA::map::order) {
2458: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2459: $url=&LONCAPA::map::qtescape($url);
2460: if ($newurl eq $url) {
2461: $unique = 0;
1.344 bisitz 2462: last;
1.329 droeschl 2463: }
2464: }
2465: return $unique;
2466: }
2467:
1.488 raeburn 2468: sub contained_map_check {
1.627 raeburn 2469: my ($url,$folder,$coursenum,$coursedom,$removefrommap,$removeparam,$addedmaps,
2470: $hierarchy,$titles,$allmaps) = @_;
1.488 raeburn 2471: my $content = &Apache::lonnet::getfile($url);
2472: unless ($content eq '-1') {
2473: my $parser = HTML::TokeParser->new(\$content);
2474: $parser->attr_encoded(1);
2475: while (my $token = $parser->get_token) {
2476: next if ($token->[0] ne 'S');
2477: if ($token->[1] eq 'resource') {
2478: next if ($token->[2]->{'type'} eq 'zombie');
2479: my $ressrc = $token->[2]->{'src'};
1.627 raeburn 2480: if ($ressrc =~ m{^/adm/($match_domain)/$match_courseid/\d+/ext\.tool$}) {
2481: my $srcdom = $1;
2482: unless ($srcdom eq $coursedom) {
2483: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2484: next;
2485: }
2486: } elsif ($folder =~ /^supplemental/) {
1.488 raeburn 2487: unless (&supp_pasteable($ressrc)) {
1.492 raeburn 2488: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.488 raeburn 2489: next;
2490: }
2491: }
1.492 raeburn 2492: if ($ressrc =~ m{^/(res|uploaded)/.+\.(sequence|page)$}) {
2493: if ($1 eq 'uploaded') {
2494: $hierarchy->{$url}{$token->[2]->{'id'}} = $ressrc;
2495: $titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'};
1.488 raeburn 2496: } else {
1.492 raeburn 2497: if ($allmaps->{$ressrc}) {
1.529 raeburn 2498: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.492 raeburn 2499: } elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') {
2500: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2501: } else {
2502: $addedmaps->{$ressrc} = [$url];
2503: }
1.488 raeburn 2504: }
1.627 raeburn 2505: &contained_map_check($ressrc,$folder,$coursenum,$coursedom,$removefrommap,
2506: $removeparam,$addedmaps,$hierarchy,$titles,$allmaps);
1.488 raeburn 2507: }
1.492 raeburn 2508: } elsif ($token->[1] eq 'param') {
1.488 raeburn 2509: if ($folder =~ /^supplemental/) {
1.492 raeburn 2510: if (ref($removeparam->{$url}{$token->[2]->{'to'}}) eq 'ARRAY') {
2511: push(@{$removeparam->{$url}{$token->[2]->{'to'}}},$token->[2]->{'name'});
2512: } else {
2513: $removeparam->{$url}{$token->[2]->{'to'}} = [$token->[2]->{'name'}];
2514: }
1.488 raeburn 2515: }
2516: }
2517: }
2518: }
2519: return;
2520: }
2521:
2522: sub url_paste_fixups {
1.533 raeburn 2523: my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$fromcdom,$fromcnum,$allmaps,
2524: $rewrites,$retitles,$copies,$dbcopies,$zombies,$params,$mapmoves,
1.597 raeburn 2525: $mapchanges,$tomove,$newsubdir,$newurls,$resdatacopy) = @_;
1.491 raeburn 2526: my $checktitle;
2527: if (($prefixchg) &&
1.492 raeburn 2528: ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) {
1.491 raeburn 2529: $checktitle = 1;
2530: }
1.492 raeburn 2531: my $skip;
2532: if ($oldurl =~ m{^\Q/uploaded/$cdom/$cnum/\E(default|supplemental)(_?\d*)\.(?:page|sequence)$}) {
2533: my $mapid = $1.$2;
2534: if ($tomove->{$mapid}) {
2535: $skip = 1;
2536: }
2537: }
1.491 raeburn 2538: my $file = &Apache::lonnet::getfile($oldurl);
1.488 raeburn 2539: return if ($file eq '-1');
2540: my $parser = HTML::TokeParser->new(\$file);
2541: $parser->attr_encoded(1);
1.491 raeburn 2542: my $changed = 0;
1.488 raeburn 2543: while (my $token = $parser->get_token) {
2544: next if ($token->[0] ne 'S');
2545: if ($token->[1] eq 'resource') {
2546: my $ressrc = $token->[2]->{'src'};
2547: next if ($ressrc eq '');
1.491 raeburn 2548: my $id = $token->[2]->{'id'};
1.492 raeburn 2549: my $title = $token->[2]->{'title'};
1.491 raeburn 2550: if ($checktitle) {
2551: if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1.532 raeburn 2552: $retitles->{$oldurl}{$id} = $ressrc;
1.491 raeburn 2553: }
2554: }
1.488 raeburn 2555: next if ($token->[2]->{'type'} eq 'external');
2556: if ($token->[2]->{'type'} eq 'zombie') {
1.492 raeburn 2557: next if ($skip);
1.532 raeburn 2558: $zombies->{$oldurl}{$id} = $ressrc;
1.491 raeburn 2559: $changed = 1;
2560: } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1.492 raeburn 2561: my $srcdom = $1;
2562: my $srcnum = $2;
1.488 raeburn 2563: my $rem = $3;
1.492 raeburn 2564: my $newurl;
2565: my $mapname;
2566: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
2567: my $prefix = $1;
2568: $mapname = $prefix.$2;
2569: if ($tomove->{$mapname}) {
1.533 raeburn 2570: &url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,
2571: $srcdom,$srcnum,$allmaps,$rewrites,
2572: $retitles,$copies,$dbcopies,$zombies,
2573: $params,$mapmoves,$mapchanges,$tomove,
1.597 raeburn 2574: $newsubdir,$newurls,$resdatacopy);
1.492 raeburn 2575: next;
2576: } else {
2577: ($newurl,my $error) =
2578: &get_newmap_url($ressrc,$folder,$prefixchg,$cdom,$cnum,
2579: $srcdom,$srcnum,\$title,$allmaps,$newurls);
2580: if ($newurl =~ /(?:default|supplemental)_(\d+)\.(?:sequence|page)$/) {
2581: $newsubdir->{$ressrc} = $1;
2582: }
2583: if ($error) {
2584: next;
2585: }
2586: }
2587: }
2588: if (($srcdom ne $cdom) || ($srcnum ne $cnum) || ($prefixchg) ||
2589: ($mapchanges->{$oldurl}) || (($newurl ne '') && ($newurl ne $oldurl))) {
2590:
1.488 raeburn 2591: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
1.532 raeburn 2592: $rewrites->{$oldurl}{$id} = $ressrc;
1.491 raeburn 2593: $mapchanges->{$ressrc} = 1;
1.533 raeburn 2594: unless (&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,
2595: $cnum,$srcdom,$srcnum,$allmaps,
2596: $rewrites,$retitles,$copies,$dbcopies,
2597: $zombies,$params,$mapmoves,$mapchanges,
1.597 raeburn 2598: $tomove,$newsubdir,$newurls,$resdatacopy)) {
1.491 raeburn 2599: $mapmoves->{$ressrc} = 1;
2600: }
2601: $changed = 1;
1.488 raeburn 2602: } else {
1.532 raeburn 2603: $rewrites->{$oldurl}{$id} = $ressrc;
1.488 raeburn 2604: $copies->{$oldurl}{$ressrc} = $id;
1.491 raeburn 2605: $changed = 1;
1.488 raeburn 2606: }
2607: }
1.649 raeburn 2608: } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/(.+)$}) {
1.533 raeburn 2609: next if ($skip);
1.492 raeburn 2610: my $srcdom = $1;
2611: my $srcnum = $2;
1.649 raeburn 2612: my $rem = $3;
2613: my ($is_exttool,$exttoolchg);
2614: if ($rem =~ m{\d+/ext\.tool$}) {
1.655 raeburn 2615: $is_exttool = 1;
1.649 raeburn 2616: }
1.492 raeburn 2617: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.532 raeburn 2618: $rewrites->{$oldurl}{$id} = $ressrc;
1.533 raeburn 2619: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2620: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2621: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
2622: $changed = 1;
1.649 raeburn 2623: if ($is_exttool) {
2624: $exttoolchg = 1;
2625: }
2626: } elsif (($rem =~ m{\d+/ext\.tool$}) &&
2627: ($env{'form.docs.markedcopy_options'} ne 'move')) {
2628: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2629: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2630: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
2631: $changed = 1;
2632: $exttoolchg = 1;
2633: }
2634: if (($is_exttool) && ($prefixchg)) {
2635: if ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/default}) {
2636: if ($exttoolchg) {
2637: $dbcopies->{$oldurl}{$id}{'delgradable'} = 1;
2638: }
2639: }
1.533 raeburn 2640: }
2641: } elsif ($ressrc =~ m{^/adm/$match_domain/$match_username/\d+/(smppg|bulletinboard)$}) {
2642: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum) ||
2643: ($env{'form.docs.markedcopy_options'} ne 'move')) {
2644: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2645: $dbcopies->{$oldurl}{$id}{'cdom'} = $fromcdom;
2646: $dbcopies->{$oldurl}{$id}{'cnum'} = $fromcnum;
1.491 raeburn 2647: $changed = 1;
1.488 raeburn 2648: }
1.597 raeburn 2649: } elsif ($ressrc eq '/res/lib/templates/simpleproblem.problem') {
2650: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum)) {
2651: $resdatacopy->{$oldurl}{$id}{'src'} = $ressrc;
2652: $resdatacopy->{$oldurl}{$id}{'cdom'} = $fromcdom;
2653: $resdatacopy->{$oldurl}{$id}{'cnum'} = $fromcnum;
2654: }
1.488 raeburn 2655: } elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) {
1.492 raeburn 2656: next if ($skip);
2657: my $srcdom = $1;
2658: my $srcnum = $2;
2659: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.533 raeburn 2660: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2661: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2662: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
1.491 raeburn 2663: $changed = 1;
1.488 raeburn 2664: }
2665: }
2666: } elsif ($token->[1] eq 'param') {
1.492 raeburn 2667: next if ($skip);
1.488 raeburn 2668: my $to = $token->[2]->{'to'};
2669: if ($to ne '') {
2670: if (ref($params->{$oldurl}{$to}) eq 'ARRAY') {
1.492 raeburn 2671: push(@{$params->{$oldurl}{$to}},$token->[2]->{'name'});
1.488 raeburn 2672: } else {
2673: @{$params->{$oldurl}{$to}} = ($token->[2]->{'name'});
2674: }
2675: }
2676: }
2677: }
1.491 raeburn 2678: return $changed;
1.488 raeburn 2679: }
2680:
2681: sub apply_fixups {
1.529 raeburn 2682: my ($folder,$is_map,$cdom,$cnum,$errors,$updated,$info,$moves,$prefixchg,
2683: $oldurl,$url,$caller) = @_;
2684: my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles,
1.533 raeburn 2685: %params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs,
1.597 raeburn 2686: %resdatacopy,%lockerrors,$lockmsg);
1.529 raeburn 2687: if (ref($updated) eq 'HASH') {
2688: if (ref($updated->{'rewrites'}) eq 'HASH') {
2689: %rewrites = %{$updated->{'rewrites'}};
2690: }
2691: if (ref($updated->{'zombies'}) eq 'HASH') {
2692: %zombies = %{$updated->{'zombies'}};
2693: }
2694: if (ref($updated->{'removefrommap'}) eq 'HASH') {
2695: %removefrommap = %{$updated->{'removefrommap'}};
2696: }
2697: if (ref($updated->{'removeparam'}) eq 'HASH') {
2698: %removeparam = %{$updated->{'removeparam'}};
2699: }
2700: if (ref($updated->{'dbcopies'}) eq 'HASH') {
2701: %dbcopies = %{$updated->{'dbcopies'}};
2702: }
2703: if (ref($updated->{'retitles'}) eq 'HASH') {
2704: %retitles = %{$updated->{'retitles'}};
2705: }
1.597 raeburn 2706: if (ref($updated->{'resdatacopy'}) eq 'HASH') {
2707: %resdatacopy = %{$updated->{'resdatacopy'}};
2708: }
1.529 raeburn 2709: }
2710: if (ref($info) eq 'HASH') {
2711: if (ref($info->{'newsubdir'}) eq 'HASH') {
2712: %newsubdir = %{$info->{'newsubdir'}};
2713: }
2714: if (ref($info->{'params'}) eq 'HASH') {
2715: %params = %{$info->{'params'}};
2716: }
2717: if (ref($info->{'before'}) eq 'HASH') {
2718: %before = %{$info->{'before'}};
2719: }
2720: if (ref($info->{'after'}) eq 'HASH') {
2721: %after = %{$info->{'after'}};
2722: }
2723: }
2724: if (ref($moves) eq 'HASH') {
2725: if (ref($moves->{'copies'}) eq 'HASH') {
2726: %copies = %{$moves->{'copies'}};
2727: }
2728: if (ref($moves->{'docmoves'}) eq 'HASH') {
2729: %docmoves = %{$moves->{'docmoves'}};
2730: }
2731: if (ref($moves->{'mapmoves'}) eq 'HASH') {
2732: %mapmoves = %{$moves->{'mapmoves'}};
2733: }
2734: }
2735: foreach my $key (keys(%copies),keys(%docmoves)) {
1.491 raeburn 2736: my @allcopies;
1.529 raeburn 2737: if (exists($copies{$key})) {
2738: if (ref($copies{$key}) eq 'HASH') {
2739: my %added;
2740: foreach my $innerkey (keys(%{$copies{$key}})) {
2741: if (($innerkey ne '') && (!$added{$innerkey})) {
2742: push(@allcopies,$innerkey);
2743: $added{$innerkey} = 1;
2744: }
1.491 raeburn 2745: }
1.529 raeburn 2746: undef(%added);
1.491 raeburn 2747: }
2748: }
2749: if ($key eq $oldurl) {
1.529 raeburn 2750: if ((exists($docmoves{$key}))) {
1.532 raeburn 2751: unless (grep(/^\Q$oldurl\E$/,@allcopies)) {
1.491 raeburn 2752: push(@allcopies,$oldurl);
2753: }
2754: }
2755: }
2756: if (@allcopies > 0) {
2757: foreach my $item (@allcopies) {
1.492 raeburn 2758: my ($relpath,$oldsubdir,$fname) =
2759: ($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(default|\d+)/.*/)([^/]+)$});
1.491 raeburn 2760: if ($fname ne '') {
2761: my $content = &Apache::lonnet::getfile($item);
2762: unless ($content eq '-1') {
2763: my $storefn;
1.529 raeburn 2764: if (($key eq $oldurl) && (exists($docmoves{$key}))) {
2765: $storefn = $docmoves{$key};
1.491 raeburn 2766: } else {
2767: $storefn = $relpath;
2768: $storefn =~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 2769: if ($prefixchg && $before{'doc'} && $after{'doc'}) {
2770: $storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/;
1.491 raeburn 2771: }
1.529 raeburn 2772: if ($newsubdir{$key}) {
1.532 raeburn 2773: $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}/#;
1.491 raeburn 2774: }
2775: }
2776: ©_dependencies($item,$storefn,$relpath,$errors,\$content);
2777: my $copyurl =
2778: &Apache::lonclonecourse::writefile($env{'request.course.id'},
2779: $storefn.$fname,$content);
2780: if ($copyurl eq '/adm/notfound.html') {
1.529 raeburn 2781: if (exists($docmoves{$oldurl})) {
1.491 raeburn 2782: return &mt('Paste failed: an error occurred copying the file.');
2783: } elsif (ref($errors) eq 'HASH') {
2784: $errors->{$item} = 1;
1.489 raeburn 2785: }
2786: }
1.488 raeburn 2787: }
2788: }
1.491 raeburn 2789: }
2790: }
2791: }
1.529 raeburn 2792: foreach my $key (keys(%mapmoves)) {
1.491 raeburn 2793: my $storefn=$key;
2794: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 2795: if ($prefixchg && $before{'map'} && $after{'map'}) {
2796: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.491 raeburn 2797: }
1.529 raeburn 2798: if ($newsubdir{$key}) {
2799: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.492 raeburn 2800: }
1.491 raeburn 2801: my $mapcontent = &Apache::lonnet::getfile($key);
1.681 raeburn 2802: if (($mapcontent eq '-1') && ($before{'map'} eq 'supplemental') &&
2803: ($after{'map'} eq 'default') &&
2804: ($key =~ m{^/uploaded/$match_domain/$match_courseid/supplemental_\d+\.sequence$})) {
2805: $mapcontent = '<map>'."\n".
2806: '<resource id="1" src="" type="start" />'."\n".
2807: '<link from="1" to="2" index="1" />'."\n".
2808: '<resource id="2" src="" type="finish" />'."\n".
2809: '</map>';
2810: }
1.491 raeburn 2811: if ($mapcontent eq '-1') {
2812: if (ref($errors) eq 'HASH') {
2813: $errors->{$key} = 1;
2814: }
2815: } else {
2816: my $newmap =
2817: &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
2818: $mapcontent);
2819: if ($newmap eq '/adm/notfound.html') {
2820: if (ref($errors) eq 'HASH') {
2821: $errors->{$key} = 1;
1.489 raeburn 2822: }
1.488 raeburn 2823: }
2824: }
2825: }
1.491 raeburn 2826: my %updates;
2827: if ($is_map) {
1.529 raeburn 2828: if (ref($updated) eq 'HASH') {
2829: foreach my $type (keys(%{$updated})) {
2830: if (ref($updated->{$type}) eq 'HASH') {
2831: foreach my $key (keys(%{$updated->{$type}})) {
2832: $updates{$key} = 1;
2833: }
2834: }
2835: }
1.491 raeburn 2836: }
2837: foreach my $key (keys(%updates)) {
1.492 raeburn 2838: my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb);
1.529 raeburn 2839: if (ref($rewrites{$key}) eq 'HASH') {
2840: %torewrite = %{$rewrites{$key}};
1.491 raeburn 2841: }
1.529 raeburn 2842: if (ref($retitles{$key}) eq 'HASH') {
2843: %toretitle = %{$retitles{$key}};
1.491 raeburn 2844: }
1.529 raeburn 2845: if (ref($removefrommap{$key}) eq 'HASH') {
2846: %toremove = %{$removefrommap{$key}};
1.491 raeburn 2847: }
1.529 raeburn 2848: if (ref($removeparam{$key}) eq 'HASH') {
2849: %remparam = %{$removeparam{$key}};
1.492 raeburn 2850: }
1.529 raeburn 2851: if (ref($zombies{$key}) eq 'HASH') {
2852: %zombie = %{$zombies{$key}};
1.491 raeburn 2853: }
1.529 raeburn 2854: if (ref($dbcopies{$key}) eq 'HASH') {
1.533 raeburn 2855: foreach my $idx (keys(%{$dbcopies{$key}})) {
2856: if (ref($dbcopies{$key}{$idx}) eq 'HASH') {
2857: my ($newurl,$result,$errtext) =
2858: &dbcopy($dbcopies{$key}{$idx},$cdom,$cnum,\%lockerrors);
2859: if ($result eq 'ok') {
2860: $newdb{$idx} = $newurl;
2861: } elsif (ref($errors) eq 'HASH') {
2862: $errors->{$key} = 1;
2863: }
2864: push(@msgs,$errtext);
2865: }
1.491 raeburn 2866: }
2867: }
1.597 raeburn 2868: if (ref($resdatacopy{$key}) eq 'HASH') {
1.664 raeburn 2869: my ($gotnewmapname,$newmapname,$srcfolder,$srccontainer);
1.597 raeburn 2870: foreach my $idx (keys(%{$resdatacopy{$key}})) {
2871: if (ref($resdatacopy{$key}{$idx}) eq 'HASH') {
2872: my $srcurl = $resdatacopy{$key}{$idx}{'src'};
2873: if ($srcurl =~ m{^/res/lib/templates/(\w+)\.problem$}) {
2874: my $template = $1;
2875: if (($resdatacopy{$key}{$idx}{'cdom'} =~ /^$match_domain$/) &&
2876: ($resdatacopy{$key}{$idx}{'cnum'} =~ /^$match_courseid$/)) {
2877: my $srcdom = $resdatacopy{$key}{$idx}{'cdom'};
2878: my $srcnum = $resdatacopy{$key}{$idx}{'cnum'};
1.664 raeburn 2879: unless ($gotnewmapname) {
2880: ($newmapname) = ($key =~ m{/([^/]+)$});
2881: ($srcfolder,$srccontainer) = split(/\./,$newmapname);
2882: if ($newsubdir{$key}) {
2883: $newmapname =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
2884: }
2885: $gotnewmapname = 1;
2886: }
1.597 raeburn 2887: my $srcmapinfo = $srcfolder.':'.$idx;
2888: if ($srccontainer eq 'page') {
2889: $srcmapinfo .= ':1';
2890: }
2891: ©_templated_files($srcurl,$srcdom,$srcnum,$srcmapinfo,$cdom,
2892: $cnum,$template,$idx,$newmapname);
2893: }
2894: }
2895: }
2896: }
2897: }
1.529 raeburn 2898: if (ref($params{$key}) eq 'HASH') {
2899: %currparam = %{$params{$key}};
1.492 raeburn 2900: }
2901: my ($errtext,$fatal) = &LONCAPA::map::mapread($key);
2902: if ($fatal) {
1.533 raeburn 2903: return ($errtext);
1.492 raeburn 2904: }
2905: for (my $i=0; $i<@LONCAPA::map::zombies; $i++) {
2906: if (defined($LONCAPA::map::zombies[$i])) {
2907: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::zombies[$i]);
1.532 raeburn 2908: if ($zombie{$i} eq $src) {
1.492 raeburn 2909: undef($LONCAPA::map::zombies[$i]);
2910: }
2911: }
2912: }
1.646 raeburn 2913: my $total = scalar(@LONCAPA::map::order) - 1;
2914: for (my $i=$total; $i>=0; $i--) {
1.529 raeburn 2915: my $idx = $LONCAPA::map::order[$i];
2916: if (defined($LONCAPA::map::resources[$idx])) {
1.492 raeburn 2917: my $changed;
1.529 raeburn 2918: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]);
1.538 raeburn 2919: if ((exists($toremove{$idx})) &&
2920: ($toremove{$idx} eq &LONCAPA::map::qtescape($src))) {
1.492 raeburn 2921: splice(@LONCAPA::map::order,$i,1);
1.529 raeburn 2922: if (ref($currparam{$idx}) eq 'ARRAY') {
2923: foreach my $name (@{$currparam{$idx}}) {
1.647 raeburn 2924: &LONCAPA::map::delparameter($idx,$name);
1.492 raeburn 2925: }
2926: }
2927: next;
2928: }
2929: my $origsrc = $src;
1.532 raeburn 2930: if ((exists($toretitle{$idx})) && ($toretitle{$idx} eq $src)) {
1.492 raeburn 2931: if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
2932: $changed = 1;
1.491 raeburn 2933: }
1.492 raeburn 2934: }
1.532 raeburn 2935: if ((exists($torewrite{$idx})) && ($torewrite{$idx} eq $src)) {
1.492 raeburn 2936: $src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
2937: if ($origsrc =~ m{^/uploaded/}) {
1.529 raeburn 2938: if ($prefixchg && $before{'map'} && $after{'map'}) {
1.492 raeburn 2939: if ($src =~ /\.(page|sequence)$/) {
1.529 raeburn 2940: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'map'}\E#$1$after{'map'}#;
1.492 raeburn 2941: } else {
1.529 raeburn 2942: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
1.488 raeburn 2943: }
1.491 raeburn 2944: }
1.532 raeburn 2945: if ($origsrc =~ /\.(page|sequence)$/) {
2946: if ($newsubdir{$origsrc}) {
1.529 raeburn 2947: $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir{$origsrc}#;
1.491 raeburn 2948: }
1.532 raeburn 2949: } elsif ($newsubdir{$key}) {
2950: $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$key}#;
1.488 raeburn 2951: }
2952: }
1.492 raeburn 2953: $changed = 1;
1.533 raeburn 2954: } elsif ($newdb{$idx} ne '') {
2955: $src = $newdb{$idx};
1.492 raeburn 2956: $changed = 1;
2957: }
2958: if ($changed) {
1.538 raeburn 2959: $LONCAPA::map::resources[$idx] = join(':',($title,&LONCAPA::map::qtunescape($src),$ext,$type));
1.492 raeburn 2960: }
2961: }
2962: }
2963: foreach my $idx (keys(%remparam)) {
2964: if (ref($remparam{$idx}) eq 'ARRAY') {
2965: foreach my $name (@{$remparam{$idx}}) {
1.647 raeburn 2966: &LONCAPA::map::delparameter($idx,$name);
1.491 raeburn 2967: }
2968: }
2969: }
1.533 raeburn 2970: if (values(%lockerrors) > 0) {
2971: $lockmsg = join('<br />',values(%lockerrors));
2972: }
1.491 raeburn 2973: my $storefn;
2974: if ($key eq $oldurl) {
2975: $storefn = $url;
2976: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
2977: } else {
2978: $storefn = $key;
2979: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 2980: if ($prefixchg && $before{'map'} && $after{'map'}) {
2981: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.491 raeburn 2982: }
1.529 raeburn 2983: if ($newsubdir{$key}) {
2984: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.492 raeburn 2985: }
1.491 raeburn 2986: }
1.492 raeburn 2987: my $report;
2988: if ($folder !~ /^supplemental/) {
2989: $report = 1;
2990: }
1.527 raeburn 2991: (my $outtext,$errtext) =
1.492 raeburn 2992: &LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report);
2993: if ($errtext) {
1.529 raeburn 2994: if ($caller eq 'paste') {
1.533 raeburn 2995: return (&mt('Paste failed: an error occurred saving the folder or page.'));
1.529 raeburn 2996: }
1.491 raeburn 2997: }
2998: }
2999: }
1.533 raeburn 3000: return ('ok',\@msgs,$lockmsg);
1.491 raeburn 3001: }
3002:
3003: sub copy_dependencies {
3004: my ($item,$storefn,$relpath,$errors,$contentref) = @_;
3005: my $content;
3006: if (ref($contentref)) {
3007: $content = $$contentref;
3008: } else {
3009: $content = &Apache::lonnet::getfile($item);
3010: }
3011: unless ($content eq '-1') {
3012: my $mm = new File::MMagic;
3013: my $mimetype = $mm->checktype_contents($content);
3014: if ($mimetype eq 'text/html') {
3015: my (%allfiles,%codebase,$state);
3016: my $res = &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,\$content);
3017: if ($res eq 'ok') {
3018: my ($numexisting,$numpathchanges,$existing);
3019: (undef,$numexisting,$numpathchanges,$existing) =
3020: &Apache::loncommon::ask_for_embedded_content(
3021: '/adm/coursedocs',$state,\%allfiles,\%codebase,
3022: {'error_on_invalid_names' => 1,
3023: 'ignore_remote_references' => 1,
3024: 'docs_url' => $item,
3025: 'context' => 'paste'});
3026: if ($numexisting > 0) {
3027: if (ref($existing) eq 'HASH') {
3028: foreach my $dep (keys(%{$existing})) {
3029: my $depfile = $dep;
3030: unless ($depfile =~ m{^\Q$relpath\E}) {
3031: $depfile = $relpath.$dep;
3032: }
3033: my $depcontent = &Apache::lonnet::getfile($depfile);
3034: unless ($depcontent eq '-1') {
3035: my $storedep = $dep;
3036: $storedep =~ s{^\Q$relpath\E}{};
3037: my $dep_url =
3038: &Apache::lonclonecourse::writefile(
3039: $env{'request.course.id'},
3040: $storefn.$storedep,$depcontent);
3041: if ($dep_url eq '/adm/notfound.html') {
3042: if (ref($errors) eq 'HASH') {
3043: $errors->{$depfile} = 1;
3044: }
3045: } else {
3046: ©_dependencies($depfile,$storefn,$relpath,$errors,\$depcontent);
3047: }
3048: }
3049: }
1.488 raeburn 3050: }
3051: }
3052: }
3053: }
3054: }
3055: return;
3056: }
3057:
1.329 droeschl 3058: my %parameter_type = ( 'randompick' => 'int_pos',
3059: 'hiddenresource' => 'string_yesno',
3060: 'encrypturl' => 'string_yesno',
3061: 'randomorder' => 'string_yesno',);
3062: my $valid_parameters_re = join('|',keys(%parameter_type));
3063: # set parameters
3064: sub update_parameter {
1.537 raeburn 3065: if ($env{'form.changeparms'} eq 'all') {
3066: my (@allidx,@allmapidx,%allchecked,%currchecked);
3067: %allchecked = (
3068: 'hiddenresource' => {},
3069: 'encrypturl' => {},
3070: 'randompick' => {},
3071: 'randomorder' => {},
3072: );
3073: foreach my $which (keys(%allchecked)) {
1.630 raeburn 3074: $env{'form.all'.$which} =~ s/,$//;
1.537 raeburn 3075: if ($which eq 'randompick') {
3076: foreach my $item (split(/,/,$env{'form.all'.$which})) {
3077: my ($res,$value) = split(/:/,$item);
3078: if ($value =~ /^\d+$/) {
3079: $allchecked{$which}{$res} = $value;
3080: }
3081: }
3082: } else {
1.539 raeburn 3083: if ($env{'form.all'.$which}) {
3084: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.all'.$which});
3085: }
1.537 raeburn 3086: }
3087: }
3088: my $haschanges = 0;
3089: foreach my $res (@LONCAPA::map::order) {
3090: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3091: $name=&LONCAPA::map::qtescape($name);
3092: $url=&LONCAPA::map::qtescape($url);
3093: next unless ($name && $url);
3094: my $is_map;
3095: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
3096: $is_map = 1;
3097: }
3098: foreach my $which (keys(%allchecked)) {
3099: if (($which eq 'randompick' || $which eq 'randomorder')) {
3100: next if (!$is_map);
3101: }
3102: my $oldvalue = 0;
3103: my $newvalue = 0;
3104: if ($allchecked{$which}{$res}) {
3105: $newvalue = $allchecked{$which}{$res};
3106: }
3107: my $current = (&LONCAPA::map::getparameter($res,'parameter_'.$which))[0];
3108: if ($which eq 'randompick') {
3109: if ($current =~ /^(\d+)$/) {
3110: $oldvalue = $1;
3111: }
3112: } else {
3113: if ($current =~ /^yes$/i) {
3114: $oldvalue = 1;
3115: }
3116: }
3117: if ($oldvalue ne $newvalue) {
3118: $haschanges = 1;
3119: if ($newvalue) {
3120: my $storeval = 'yes';
3121: if ($which eq 'randompick') {
3122: $storeval = $newvalue;
3123: }
3124: &LONCAPA::map::storeparameter($res,'parameter_'.$which,
3125: $storeval,
3126: $parameter_type{$which});
3127: &remember_parms($res,$which,'set',$storeval);
3128: } elsif ($oldvalue) {
3129: &LONCAPA::map::delparameter($res,'parameter_'.$which);
3130: &remember_parms($res,$which,'del');
3131: }
3132: }
3133: }
3134: }
3135: return $haschanges;
3136: } else {
1.588 raeburn 3137: my $haschanges = 0;
3138: return $haschanges if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
1.329 droeschl 3139:
1.537 raeburn 3140: my $which = $env{'form.changeparms'};
3141: my $idx = $env{'form.setparms'};
1.588 raeburn 3142: my $oldvalue = 0;
3143: my $newvalue = 0;
3144: my $current = (&LONCAPA::map::getparameter($idx,'parameter_'.$which))[0];
3145: if ($which eq 'randompick') {
3146: if ($current =~ /^(\d+)$/) {
3147: $oldvalue = $1;
3148: }
3149: } elsif ($current =~ /^yes$/i) {
3150: $oldvalue = 1;
3151: }
1.537 raeburn 3152: if ($env{'form.'.$which.'_'.$idx}) {
1.588 raeburn 3153: $newvalue = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx}
3154: : 1;
3155: }
3156: if ($oldvalue ne $newvalue) {
3157: $haschanges = 1;
3158: if ($newvalue) {
3159: my $storeval = 'yes';
3160: if ($which eq 'randompick') {
3161: $storeval = $newvalue;
3162: }
3163: &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $storeval,
3164: $parameter_type{$which});
3165: &remember_parms($idx,$which,'set',$storeval);
3166: } else {
3167: &LONCAPA::map::delparameter($idx,'parameter_'.$which);
3168: &remember_parms($idx,$which,'del');
3169: }
1.537 raeburn 3170: }
1.588 raeburn 3171: return $haschanges;
1.329 droeschl 3172: }
3173: }
3174:
3175: sub handle_edit_cmd {
3176: my ($coursenum,$coursedom) =@_;
1.633 raeburn 3177: my $haschanges = 0;
1.543 raeburn 3178: if ($env{'form.cmd'} eq '') {
1.633 raeburn 3179: return $haschanges;
1.543 raeburn 3180: }
1.329 droeschl 3181: my ($cmd,$idx)=split('_',$env{'form.cmd'});
3182:
3183: my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
3184: my ($title, $url, @rrest) = split(':', $ratstr);
3185:
1.538 raeburn 3186: if ($cmd eq 'remove') {
1.329 droeschl 3187: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
1.463 www 3188: ($url!~/$LONCAPA::assess_page_seq_re/)) {
1.329 droeschl 3189: &Apache::lonnet::removeuploadedurl($url);
3190: } else {
3191: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
3192: }
3193: splice(@LONCAPA::map::order, $idx, 1);
1.633 raeburn 3194: $haschanges = 1;
1.329 droeschl 3195: } elsif ($cmd eq 'cut') {
3196: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
3197: splice(@LONCAPA::map::order, $idx, 1);
1.633 raeburn 3198: $haschanges = 1;
1.344 bisitz 3199: } elsif ($cmd eq 'up'
1.329 droeschl 3200: && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
3201: @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
1.633 raeburn 3202: $haschanges = 1;
1.329 droeschl 3203: } elsif ($cmd eq 'down'
3204: && defined($LONCAPA::map::order[$idx+1])) {
3205: @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
1.633 raeburn 3206: $haschanges = 1;
1.329 droeschl 3207: } elsif ($cmd eq 'rename') {
3208: my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
3209: if ($comment=~/\S/) {
3210: $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
3211: $comment.':'.join(':', $url, @rrest);
3212: }
3213: # Devalidate title cache
3214: my $renamed_url=&LONCAPA::map::qtescape($url);
3215: &Apache::lonnet::devalidate_title_cache($renamed_url);
1.633 raeburn 3216: $haschanges = 1;
3217: } elsif ($cmd eq 'setalias') {
3218: my $newvalue = $env{'form.alias'};
3219: if ($newvalue ne '') {
3220: unless (Apache::lonnet::get_symb_from_alias($newvalue)) {
3221: &LONCAPA::map::storeparameter($idx,'parameter_0_mapalias',$newvalue,
3222: 'string');
3223: &remember_parms($idx,'mapalias','set',$newvalue);
3224: $haschanges = 1;
3225: }
3226: }
3227: } elsif ($cmd eq 'delalias') {
3228: my $current = (&LONCAPA::map::getparameter($idx,'parameter_0_mapalias'))[0];
3229: if ($current ne '') {
3230: &LONCAPA::map::delparameter($idx,'parameter_0_mapalias');
3231: &remember_parms($idx,'mapalias','del');
3232: $haschanges = 1;
3233: }
1.329 droeschl 3234: }
1.633 raeburn 3235: return $haschanges;
1.329 droeschl 3236: }
3237:
3238: sub editor {
1.458 raeburn 3239: my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
1.615 raeburn 3240: $supplementalflag,$orderhash,$iconpath,$pathitem,$ltitoolsref,
1.622 raeburn 3241: $canedit,$hostname,$navmapref,$hiddentop)=@_;
1.519 raeburn 3242: my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
1.510 raeburn 3243: if ($allowed) {
1.519 raeburn 3244: (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
3245: $is_random_order,$container) =
1.510 raeburn 3246: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
3247: $r->print($breadcrumbtrail);
1.519 raeburn 3248: } elsif ($env{'form.folderpath'} =~ /\:1$/) {
3249: $container = 'page';
3250: } else {
3251: $container = 'sequence';
1.510 raeburn 3252: }
1.484 raeburn 3253:
1.525 raeburn 3254: my $jumpto;
3255:
3256: unless ($supplementalflag) {
1.546 raeburn 3257: $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
1.525 raeburn 3258: }
1.484 raeburn 3259:
3260: unless ($allowed) {
3261: $randompick = -1;
3262: }
3263:
1.615 raeburn 3264: my ($errtext,$fatal);
3265: if (($folder eq '') && (!$supplementalflag)) {
3266: if (@LONCAPA::map::order) {
3267: undef(@LONCAPA::map::order);
3268: undef(@LONCAPA::map::resources);
3269: undef(@LONCAPA::map::resparms);
3270: undef(@LONCAPA::map::zombies);
3271: }
3272: $folder = 'default';
3273: $container = 'sequence';
3274: } else {
3275: ($errtext,$fatal) = &mapread($coursenum,$coursedom,
3276: $folder.'.'.$container);
3277: return $errtext if ($fatal);
3278: }
1.329 droeschl 3279:
1.682 raeburn 3280: my (%supphidden,%suppids,$suppmapid);
3281:
1.329 droeschl 3282: if ($#LONCAPA::map::order<1) {
3283: my $idx=&LONCAPA::map::getresidx();
3284: if ($idx<=0) { $idx=1; }
3285: $LONCAPA::map::order[0]=$idx;
3286: $LONCAPA::map::resources[$idx]='';
1.682 raeburn 3287: } elsif ($supplementalflag && !$allowed) {
3288: my ($supplemental) = &Apache::lonnet::get_supplemental($coursenum,$coursedom);
3289: if (ref($supplemental) eq 'HASH') {
3290: if (ref($supplemental->{'hidden'}) eq 'HASH') {
3291: %supphidden = %{$supplemental->{'hidden'}};
3292: }
3293: if (ref($supplemental->{'ids'}) eq 'HASH') {
3294: %suppids = %{$supplemental->{'ids'}};
3295: }
3296: }
3297: if ($folder eq 'supplemental') {
3298: $suppmapid = 0;
3299: } elsif ($folder =~ /^supplemental_(\d+)$/) {
3300: $suppmapid = $1;
3301: }
1.329 droeschl 3302: }
1.364 bisitz 3303:
1.329 droeschl 3304: # ------------------------------------------------------------ Process commands
3305:
3306: # ---------------- if they are for this folder and user allowed to make changes
1.611 raeburn 3307: if (($allowed && $canedit) && ($env{'form.folder'} eq $folder)) {
1.329 droeschl 3308: # set parameters and change order
3309: &snapshotbefore();
3310:
3311: if (&update_parameter()) {
1.588 raeburn 3312: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1.329 droeschl 3313: return $errtext if ($fatal);
3314: }
3315:
3316: if ($env{'form.newpos'} && $env{'form.currentpos'}) {
3317: # change order
3318: my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
3319: splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
3320:
3321: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
3322: return $errtext if ($fatal);
3323: }
1.364 bisitz 3324:
1.329 droeschl 3325: if ($env{'form.pastemarked'}) {
1.491 raeburn 3326: my %paste_errors;
1.533 raeburn 3327: my ($paste_res,$save_error,$pastemsgarray,$lockerror) =
1.492 raeburn 3328: &do_paste_from_buffer($coursenum,$coursedom,$folder,$container,
3329: \%paste_errors);
1.541 raeburn 3330: if (ref($pastemsgarray) eq 'ARRAY') {
3331: if (@{$pastemsgarray} > 0) {
3332: $r->print('<p class="LC_info">'.
3333: join('<br />',@{$pastemsgarray}).
1.533 raeburn 3334: '</p>');
3335: }
1.541 raeburn 3336: }
3337: if ($lockerror) {
3338: $r->print('<p class="LC_error">'.
3339: $lockerror.
3340: '</p>');
3341: }
3342: if ($save_error ne '') {
3343: return $save_error;
3344: }
3345: if ($paste_res) {
3346: my %errortext = &Apache::lonlocal::texthash (
3347: fail => 'Storage of folder contents failed',
3348: failread => 'Reading folder contents failed',
3349: failstore => 'Storage of folder contents failed',
3350: );
3351: if ($errortext{$paste_res}) {
3352: $r->print('<p class="LC_error">'.$errortext{$paste_res}.'</p>');
1.492 raeburn 3353: }
1.329 droeschl 3354: }
1.491 raeburn 3355: if (keys(%paste_errors) > 0) {
1.538 raeburn 3356: $r->print('<p class="LC_warning">'."\n".
1.491 raeburn 3357: &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".
3358: '<ul>'."\n");
3359: foreach my $key (sort(keys(%paste_errors))) {
3360: $r->print('<li>'.$key.'</li>'."\n");
3361: }
3362: $r->print('</ul></p>'."\n");
3363: }
1.538 raeburn 3364: } elsif ($env{'form.clearmarked'}) {
3365: my $output = &do_buffer_empty();
3366: if ($output) {
3367: $r->print('<p class="LC_info">'.$output.'</p>');
3368: }
3369: }
1.329 droeschl 3370:
3371: $r->print($upload_output);
3372:
1.538 raeburn 3373: # Rename, cut, copy or remove a single resource
1.602 raeburn 3374: if (&handle_edit_cmd($coursenum,$coursedom)) {
1.492 raeburn 3375: my $contentchg;
1.633 raeburn 3376: if ($env{'form.cmd'} =~ m{^(remove|cut|setalias|delalias)_}) {
1.492 raeburn 3377: $contentchg = 1;
3378: }
3379: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);
1.329 droeschl 3380: return $errtext if ($fatal);
3381: }
1.538 raeburn 3382:
3383: # Cut, copy and/or remove multiple resources
3384: if ($env{'form.multichange'}) {
3385: my %allchecked = (
3386: cut => {},
3387: remove => {},
3388: );
3389: my $needsupdate;
3390: foreach my $which (keys(%allchecked)) {
3391: $env{'form.multi'.$which} =~ s/,$//;
3392: if ($env{'form.multi'.$which}) {
3393: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.multi'.$which});
3394: if (ref($allchecked{$which}) eq 'HASH') {
3395: $needsupdate += scalar(keys(%{$allchecked{$which}}));
3396: }
3397: }
3398: }
3399: if ($needsupdate) {
3400: my $haschanges = 0;
3401: my %curr_groups = &Apache::longroup::coursegroups();
3402: my $total = scalar(@LONCAPA::map::order) - 1;
3403: for (my $i=$total; $i>=0; $i--) {
3404: my $res = $LONCAPA::map::order[$i];
3405: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3406: $name=&LONCAPA::map::qtescape($name);
3407: $url=&LONCAPA::map::qtescape($url);
1.586 droeschl 3408: next unless $url;
1.538 raeburn 3409: my %denied =
3410: &action_restrictions($coursenum,$coursedom,$url,
3411: $env{'form.folderpath'},\%curr_groups);
3412: foreach my $which (keys(%allchecked)) {
3413: next if ($denied{$which});
3414: next unless ($allchecked{$which}{$res});
3415: if ($which eq 'remove') {
3416: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
3417: ($url!~/$LONCAPA::assess_page_seq_re/)) {
3418: &Apache::lonnet::removeuploadedurl($url);
3419: } else {
3420: &LONCAPA::map::makezombie($res);
3421: }
3422: splice(@LONCAPA::map::order,$i,1);
3423: $haschanges ++;
3424: } elsif ($which eq 'cut') {
3425: &LONCAPA::map::makezombie($res);
3426: splice(@LONCAPA::map::order,$i,1);
3427: $haschanges ++;
3428: }
3429: }
3430: }
3431: if ($haschanges) {
3432: ($errtext,$fatal) =
3433: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
3434: return $errtext if ($fatal);
3435: }
3436: }
3437: }
3438:
1.329 droeschl 3439: # Group import/search
3440: if ($env{'form.importdetail'}) {
3441: my @imports;
3442: foreach my $item (split(/\&/,$env{'form.importdetail'})) {
3443: if (defined($item)) {
3444: my ($name,$url,$residx)=
1.533 raeburn 3445: map { &unescape($_); } split(/\=/,$item);
3446: if ($url =~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
3447: my ($suffix,$errortxt,$locknotfreed) =
3448: &new_timebased_suffix($coursedom,$coursenum,'map',$1,$2);
1.504 raeburn 3449: if ($locknotfreed) {
3450: $r->print($locknotfreed);
3451: }
3452: if ($suffix) {
3453: $url =~ s/_new\./_$suffix./;
3454: } else {
3455: return $errortxt;
3456: }
1.533 raeburn 3457: } elsif ($url =~ m{^/adm/$match_domain/$match_username/new/(smppg|bulletinboard)$}) {
3458: my $type = $1;
3459: my ($suffix,$errortxt,$locknotfreed) =
3460: &new_timebased_suffix($coursedom,$coursenum,$type);
3461: if ($locknotfreed) {
3462: $r->print($locknotfreed);
3463: }
3464: if ($suffix) {
3465: $url =~ s{^(/adm/$match_domain/$match_username)/new}{$1/$suffix};
3466: } else {
3467: return $errortxt;
3468: }
1.626 raeburn 3469: } elsif ($url =~ m{^/adm/$coursedom/$coursenum/new/ext\.tool}) {
1.598 raeburn 3470: my ($suffix,$errortxt,$locknotfreed) =
3471: &new_timebased_suffix($coursedom,$coursenum,'exttool');
3472: if ($locknotfreed) {
3473: $r->print($locknotfreed);
3474: }
3475: if ($suffix) {
3476: $url =~ s{^(/adm/$coursedom/$coursenum)/new}{$1/$suffix};
3477: } else {
3478: return $errortxt;
3479: }
1.534 raeburn 3480: } elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) {
3481: if ($supplementalflag) {
3482: next unless ($1 eq 'supplemental');
3483: if ($folder eq 'supplemental') {
3484: next unless ($2 eq 'default');
3485: } else {
3486: next unless ($folder eq 'supplemental_'.$2);
3487: }
3488: } else {
3489: next unless ($1 eq 'docs');
3490: if ($folder eq 'default') {
3491: next unless ($2 eq 'default');
3492: } else {
3493: next unless ($folder eq 'default_'.$2);
3494: }
3495: }
1.504 raeburn 3496: }
1.329 droeschl 3497: push(@imports, [$name, $url, $residx]);
3498: }
3499: }
1.530 raeburn 3500: ($errtext,$fatal,my $fixuperrors) =
1.529 raeburn 3501: &group_import($coursenum, $coursedom, $folder,$container,
1.598 raeburn 3502: 'londocs',$ltitoolsref,@imports);
1.329 droeschl 3503: return $errtext if ($fatal);
1.529 raeburn 3504: if ($fixuperrors) {
3505: $r->print($fixuperrors);
3506: }
1.329 droeschl 3507: }
3508: # Loading a complete map
3509: if ($env{'form.loadmap'}) {
3510: if ($env{'form.importmap'}=~/\w/) {
3511: foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
3512: my ($title,$url,$ext,$type)=split(/\:/,$res);
3513: my $idx=&LONCAPA::map::getresidx($url);
3514: $LONCAPA::map::resources[$idx]=$res;
3515: $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
3516: }
3517: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.492 raeburn 3518: $folder.'.'.$container,1);
1.329 droeschl 3519: return $errtext if ($fatal);
3520: } else {
3521: $r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
1.364 bisitz 3522:
1.329 droeschl 3523: }
3524: }
3525: &log_differences($plain);
3526: }
3527: # ---------------------------------------------------------------- End commands
3528: # ---------------------------------------------------------------- Print screen
3529: my $idx=0;
3530: my $shown=0;
3531: if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
1.381 bisitz 3532: $r->print('<div class="LC_Box">'.
1.432 raeburn 3533: '<ol class="LC_docs_parameters"><li class="LC_docs_parameters_title">'.&mt('Parameters:').'</li>'.
3534: ($randompick>=0?'<li>'.&mt('randomly pick [quant,_1,resource]',$randompick).'</li>':'').
3535: ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
3536: ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
3537: ($is_random_order?'<li>'.&mt('random order').'</li>':'').
1.431 raeburn 3538: '</ol>');
1.381 bisitz 3539: if ($randompick>=0) {
3540: $r->print('<p class="LC_warning">'
3541: .&mt('Caution: this folder is set to randomly pick a subset'
3542: .' of resources. Adding or removing resources from this'
3543: .' folder will change the set of resources that the'
3544: .' students see, resulting in spurious or missing credit'
3545: .' for completed problems, not limited to ones you'
3546: .' modify. Do not modify the contents of this folder if'
3547: .' it is in active student use.')
3548: .'</p>'
3549: );
3550: }
3551: if ($is_random_order) {
3552: $r->print('<p class="LC_warning">'
3553: .&mt('Caution: this folder is set to randomly order its'
3554: .' contents. Adding or removing resources from this folder'
3555: .' will change the order of resources shown.')
3556: .'</p>'
3557: );
3558: }
3559: $r->print('</div>');
1.364 bisitz 3560: }
1.381 bisitz 3561:
1.538 raeburn 3562: my ($to_show,$output,@allidx,@allmapidx,%filters,%lists,%curr_groups);
3563: %filters = (
1.543 raeburn 3564: canremove => [],
3565: cancut => [],
3566: cancopy => [],
3567: hiddenresource => [],
3568: encrypturl => [],
3569: randomorder => [],
3570: randompick => [],
1.538 raeburn 3571: );
3572: %curr_groups = &Apache::longroup::coursegroups();
1.424 onken 3573: &Apache::loncommon::start_data_table_count(); #setup a row counter
1.381 bisitz 3574: foreach my $res (@LONCAPA::map::order) {
3575: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3576: $name=&LONCAPA::map::qtescape($name);
3577: $url=&LONCAPA::map::qtescape($url);
3578: unless ($name) { $name=(split(/\//,$url))[-1]; }
3579: unless ($name) { $idx++; next; }
1.537 raeburn 3580: push(@allidx,$res);
3581: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
3582: push(@allmapidx,$res);
3583: }
1.617 raeburn 3584:
1.682 raeburn 3585: if (($supplementalflag) && (!$allowed) && (!$env{'request.role.adv'})) {
3586: next if ($supphidden{$suppmapid.':'.$res});
3587: }
1.381 bisitz 3588: $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
1.501 raeburn 3589: $coursenum,$coursedom,$crstype,
1.538 raeburn 3590: $pathitem,$supplementalflag,$container,
1.620 raeburn 3591: \%filters,\%curr_groups,$ltitoolsref,$canedit,
1.682 raeburn 3592: $isencrypted,$navmapref,$hostname,
3593: \%supphidden,\%suppids,$suppmapid);
1.381 bisitz 3594: $idx++;
3595: $shown++;
1.329 droeschl 3596: }
1.424 onken 3597: &Apache::loncommon::end_data_table_count();
1.510 raeburn 3598:
1.538 raeburn 3599: my $need_save;
1.611 raeburn 3600: if ($allowed || ($supplementalflag && $folder eq 'supplemental')) {
1.544 raeburn 3601: my $toolslink;
1.682 raeburn 3602: if ($allowed || $canedit) {
3603: my $helpitem = 'Navigation_Screen';
3604: if (!$allowed) {
3605: $helpitem = 'Supplemental_Navigation';
3606: }
1.544 raeburn 3607: $toolslink = '<table><tr><td>'
1.520 raeburn 3608: .&Apache::loncommon::help_open_menu('Navigation Screen',
1.682 raeburn 3609: $helpitem,undef,'RAT')
1.520 raeburn 3610: .'</td><td class="LC_middle">'.&mt('Tools:').'</td>'
3611: .'<td align="left"><ul id="LC_toolbar">'
1.525 raeburn 3612: .'<li><a href="/adm/coursedocs?forcesupplement=1&command=editsupp" '
1.520 raeburn 3613: .'id="LC_content_toolbar_edittoplevel" '
3614: .'class="LC_toolbarItem" '
3615: .'title="'.&mt('Supplemental Content Editor').'">'
3616: .'</a></li></ul></td></tr></table><br />';
1.544 raeburn 3617: }
1.510 raeburn 3618: if ($shown) {
3619: if ($allowed) {
3620: $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
3621: .&Apache::loncommon::start_data_table(undef,'contentlist')
3622: .&Apache::loncommon::start_data_table_header_row()
3623: .'<th colspan="2">'.&mt('Move').'</th>'
1.633 raeburn 3624: .'<th colspan="3">'.&mt('Actions').'</th>'
1.682 raeburn 3625: .'<th>'.&mt('Document').'</th>'
3626: .'<th colspan="2">'.&mt('Settings').'</th>'
3627: .&Apache::loncommon::end_data_table_header_row();
1.537 raeburn 3628: if ($folder !~ /^supplemental/) {
1.538 raeburn 3629: $lists{'canhide'} = join(',',@allidx);
3630: $lists{'canrandomlyorder'} = join(',',@allmapidx);
1.543 raeburn 3631: my @possfilters = ('canremove','cancut','cancopy','hiddenresource','encrypturl',
3632: 'randomorder','randompick');
3633: foreach my $item (@possfilters) {
1.538 raeburn 3634: if (ref($filters{$item}) eq 'ARRAY') {
1.543 raeburn 3635: if (@{$filters{$item}} > 0) {
3636: $lists{$item} = join(',',@{$filters{$item}});
3637: }
1.538 raeburn 3638: }
3639: }
1.537 raeburn 3640: if (@allidx > 0) {
3641: my $path;
3642: if ($env{'form.folderpath'}) {
1.630 raeburn 3643: $path =
1.537 raeburn 3644: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3645: }
1.538 raeburn 3646: if (@allidx > 1) {
1.630 raeburn 3647: $to_show .=
1.538 raeburn 3648: &Apache::loncommon::continue_data_table_row().
3649: '<td colspan="2"> </td>'.
3650: '<td>'.
1.611 raeburn 3651: &multiple_check_form('actions',\%lists,$canedit).
1.538 raeburn 3652: '</td>'.
1.633 raeburn 3653: '<td colspan="3"> </td>'.
3654: '<td colspan="2">'.
1.611 raeburn 3655: &multiple_check_form('settings',\%lists,$canedit).
1.538 raeburn 3656: '</td>'.
3657: &Apache::loncommon::end_data_table_row();
3658: $need_save = 1;
3659: }
1.537 raeburn 3660: }
3661: }
3662: $to_show .= $output.' '
1.510 raeburn 3663: .&Apache::loncommon::end_data_table()
3664: .'<br style="line-height:2px;" />'
3665: .&Apache::loncommon::end_scrollbox();
3666: } else {
1.520 raeburn 3667: $to_show .= $toolslink
1.510 raeburn 3668: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3669: .$output.' '
3670: .&Apache::loncommon::end_data_table();
1.393 raeburn 3671: }
1.510 raeburn 3672: } else {
1.520 raeburn 3673: if (!$allowed) {
3674: $to_show .= $toolslink;
3675: }
1.615 raeburn 3676: my $noresmsg;
3677: if ($allowed && $hiddentop && !$supplementalflag) {
3678: $noresmsg = &mt('Main Content Hidden');
3679: } else {
3680: $noresmsg = &mt('Currently empty');
3681: }
1.510 raeburn 3682: $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
3683: .'<div class="LC_info" id="contentlist">'
1.615 raeburn 3684: .$noresmsg
1.510 raeburn 3685: .'</div>'
3686: .&Apache::loncommon::end_scrollbox();
1.393 raeburn 3687: }
3688: } else {
1.510 raeburn 3689: if ($shown) {
3690: $to_show = '<div>'
3691: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3692: .$output
3693: .&Apache::loncommon::end_data_table()
3694: .'</div>';
3695: } else {
3696: $to_show = '<div class="LC_info" id="contentlist">'
1.550 raeburn 3697: .&mt('Currently empty')
1.510 raeburn 3698: .'</div>'
3699: }
1.458 raeburn 3700: }
3701: my $tid = 1;
3702: if ($supplementalflag) {
3703: $tid = 2;
1.329 droeschl 3704: }
3705: if ($allowed) {
1.484 raeburn 3706: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
1.538 raeburn 3707: $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,
1.611 raeburn 3708: $jumpto,$readfile,$need_save,"$folder.$container",$canedit));
3709: if ($canedit) {
3710: &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
3711: }
1.460 raeburn 3712: } else {
3713: $r->print($to_show);
1.329 droeschl 3714: }
3715: return;
3716: }
3717:
1.538 raeburn 3718: sub multiple_check_form {
1.611 raeburn 3719: my ($caller,$listsref,$canedit) = @_;
1.538 raeburn 3720: return unless (ref($listsref) eq 'HASH');
1.611 raeburn 3721: my $disabled;
3722: unless ($canedit) {
3723: $disabled = 'disabled="disabled"';
3724: }
1.538 raeburn 3725: my $output =
3726: '<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'.
3727: '<span class="LC_nobreak" style="font-size:x-small;font-weight:bold;">'.
3728: '<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>'.
3729: '<div id="multi'.$caller.'" style="display:none;margin:0;padding:0;border:0">'.
3730: '<form action="/adm/coursedocs" method="post" name="cumulative'.$caller.'">'."\n".
3731: '<fieldset id="allfields'.$caller.'" style="display:none"><legend style="font-size:x-small;">'.&mt('check/uncheck all').'</legend>'."\n";
3732: if ($caller eq 'settings') {
3733: $output .=
3734: '<table><tr>'.
3735: '<td class="LC_docs_entry_parameter">'.
3736: '<span class="LC_nobreak"><label>'.
1.611 raeburn 3737: '<input type="checkbox" name="hiddenresourceall" id="hiddenresourceall" onclick="propagateState(this.form,'."'hiddenresource'".')"'.$disabled.' />'.&mt('Hidden').
1.538 raeburn 3738: '</label></span></td>'.
3739: '<td class="LC_docs_entry_parameter">'.
1.611 raeburn 3740: '<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'".');"'.$disabled.' />'.&mt('Randomly Pick').'</label><span id="rpicktextall"></span><input type="hidden" name="rpicknumall" id="rpicknumall" value="" />'.
1.538 raeburn 3741: '</span></td>'.
3742: '</tr>'."\n".
3743: '<tr>'.
3744: '<td class="LC_docs_entry_parameter">'.
1.611 raeburn 3745: '<span class="LC_nobreak"><label><input type="checkbox" name="encrypturlall" id="encrypturlall" onclick="propagateState(this.form,'."'encrypturl'".')"'.$disabled.' />'.&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'".')"'.$disabled.' />'.&mt('Random Order').
1.538 raeburn 3746: '</label></span>'.
3747: '</td></tr></table>'."\n";
3748: } else {
3749: $output .=
3750: '<table><tr>'.
3751: '<td class="LC_docs_entry_parameter">'.
3752: '<span class="LC_nobreak LC_docs_remove">'.
1.611 raeburn 3753: '<label><input type="checkbox" name="removeall" id="removeall" onclick="propagateState(this.form,'."'remove'".')"'.$disabled.' />'.&mt('Remove').
1.538 raeburn 3754: '</label></span></td>'.
3755: '<td class="LC_docs_entry_parameter">'.
3756: '<span class="LC_nobreak LC_docs_cut">'.
1.611 raeburn 3757: '<label><input type="checkbox" name="cut" id="cutall" onclick="propagateState(this.form,'."'cut'".');"'.$disabled.' />'.&mt('Cut').
1.538 raeburn 3758: '</label></span></td>'."\n".
3759: '<td class="LC_docs_entry_parameter">'.
3760: '<span class="LC_nobreak LC_docs_copy">'.
1.611 raeburn 3761: '<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')"'. $disabled.' />'.&mt('Copy').
1.538 raeburn 3762: '</label></span></td>'.
3763: '</tr></table>'."\n";
3764: }
3765: $output .=
3766: '</fieldset>'.
3767: '<input type="hidden" name="allidx" value="'.$listsref->{'canhide'}.'" />';
3768: if ($caller eq 'settings') {
3769: $output .=
1.543 raeburn 3770: '<input type="hidden" name="allmapidx" value="'.$listsref->{'canrandomlyorder'}.'" />'."\n".
3771: '<input type="hidden" name="currhiddenresource" value="'.$listsref->{'hiddenresource'}.'" />'."\n".
3772: '<input type="hidden" name="currencrypturl" value="'.$listsref->{'encrypturl'}.'" />'."\n".
3773: '<input type="hidden" name="currrandomorder" value="'.$listsref->{'randomorder'}.'" />'."\n".
3774: '<input type="hidden" name="currrandompick" value="'.$listsref->{'randompick'}.'" />'."\n";
1.538 raeburn 3775: } elsif ($caller eq 'actions') {
3776: $output .=
3777: '<input type="hidden" name="allremoveidx" id="allremoveidx" value="'.$listsref->{'canremove'}.'" />'.
3778: '<input type="hidden" name="allcutidx" id="allcutidx" value="'.$listsref->{'cancut'}.'" />'.
3779: '<input type="hidden" name="allcopyidx" id="allcopyidx" value="'.$listsref->{'cancopy'}.'" />';
3780: }
3781: $output .=
3782: '</form>'.
3783: '</div>';
3784: return $output;
3785: }
3786:
1.329 droeschl 3787: sub process_file_upload {
1.552 raeburn 3788: my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd,$crstype) = @_;
1.329 droeschl 3789: # upload a file, if present
1.552 raeburn 3790: my $filesize = length($env{'form.uploaddoc'});
3791: if (!$filesize) {
3792: $$upload_output = '<div class="LC_error">'.
3793: &mt('Unable to upload [_1]. (size = [_2] bytes)',
3794: '<span class="LC_filename">'.$env{'form.uploaddoc.filename'}.'</span>',
3795: $filesize).'<br />'.
3796: &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'<br />'.
3797: '</div>';
3798: return;
3799: }
3800: my $quotatype = 'unofficial';
3801: if ($crstype eq 'Community') {
1.601 raeburn 3802: $quotatype = 'community';
3803: } elsif ($crstype eq 'Placement') {
3804: $quotatype = 'placement';
1.580 raeburn 3805: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
1.552 raeburn 3806: $quotatype = 'official';
1.573 raeburn 3807: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
3808: $quotatype = 'textbook';
1.552 raeburn 3809: }
3810: if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) {
3811: $filesize = int($filesize/1000); #expressed in kb
3812: $$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course',
1.579 raeburn 3813: $env{'form.uploaddoc.filename'},$filesize,
3814: 'upload',$quotatype);
1.552 raeburn 3815: return if ($$upload_output);
3816: }
1.440 raeburn 3817: my ($parseaction,$showupload,$nextphase,$mimetype);
3818: if ($env{'form.parserflag'}) {
1.329 droeschl 3819: $parseaction = 'parse';
3820: }
3821: my $folder=$env{'form.folder'};
3822: if ($folder eq '') {
3823: $folder='default';
3824: }
3825: if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
3826: my $errtext='';
3827: my $fatal=0;
3828: my $container='sequence';
1.519 raeburn 3829: if ($env{'form.folderpath'} =~ /:1$/) {
1.329 droeschl 3830: $container='page';
3831: }
3832: ($errtext,$fatal)=
1.534 raeburn 3833: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1.329 droeschl 3834: if ($#LONCAPA::map::order<1) {
3835: $LONCAPA::map::order[0]=1;
3836: $LONCAPA::map::resources[1]='';
3837: }
3838: my $destination = 'docs/';
3839: if ($folder =~ /^supplemental/) {
3840: $destination = 'supplemental/';
3841: }
3842: if (($folder eq 'default') || ($folder eq 'supplemental')) {
3843: $destination .= 'default/';
3844: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
3845: $destination .= $2.'/';
3846: }
1.534 raeburn 3847: if ($fatal) {
3848: $$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>';
3849: return;
3850: }
1.440 raeburn 3851: # this is for a course, not a user, so set context to coursedoc.
1.329 droeschl 3852: my $newidx=&LONCAPA::map::getresidx();
3853: $destination .= $newidx;
1.439 raeburn 3854: my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination,
1.329 droeschl 3855: $parseaction,$allfiles,
1.440 raeburn 3856: $codebase,undef,undef,undef,undef,
3857: undef,undef,\$mimetype);
3858: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) {
3859: my $stored = $1;
3860: $showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'.
3861: $stored.'</span>').'</p>';
3862: } else {
3863: my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});
3864:
1.457 raeburn 3865: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>';
1.440 raeburn 3866: return;
3867: }
1.329 droeschl 3868: my $ext='false';
3869: if ($url=~m{^http://}) { $ext='true'; }
3870: $url = &LONCAPA::map::qtunescape($url);
3871: my $comment=$env{'form.comment'};
3872: $comment = &LONCAPA::map::qtunescape($comment);
3873: if ($folder=~/^supplemental/) {
3874: $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
3875: $env{'user.domain'}.'___&&&___'.$comment;
3876: }
3877:
3878: $LONCAPA::map::resources[$newidx]=
3879: $comment.':'.$url.':'.$ext.':normal:res';
3880: $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
3881: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.492 raeburn 3882: $folder.'.'.$container,1);
1.329 droeschl 3883: if ($fatal) {
1.457 raeburn 3884: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>';
1.440 raeburn 3885: return;
1.329 droeschl 3886: } else {
1.440 raeburn 3887: if ($parseaction eq 'parse' && $mimetype eq 'text/html') {
3888: $$upload_output = $showupload;
1.384 raeburn 3889: my $total_embedded = scalar(keys(%{$allfiles}));
1.329 droeschl 3890: if ($total_embedded > 0) {
1.440 raeburn 3891: my $uploadphase = 'upload_embedded';
3892: my $primaryurl = &HTML::Entities::encode($url,'<>&"');
3893: my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx);
1.630 raeburn 3894: my ($embedded,$num) =
1.440 raeburn 3895: &Apache::loncommon::ask_for_embedded_content(
3896: '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url});
3897: if ($embedded) {
3898: if ($num) {
3899: $$upload_output .=
3900: '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
3901: $nextphase = $uploadphase;
3902: } else {
3903: $$upload_output .= $embedded;
3904: }
3905: } else {
3906: $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
3907: }
1.329 droeschl 3908: } else {
1.440 raeburn 3909: $$upload_output .= &mt('No embedded items identified').'<br />';
1.329 droeschl 3910: }
1.457 raeburn 3911: $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
1.578 raeburn 3912: } elsif ((&Apache::loncommon::is_archive_file($mimetype)) &&
3913: ($env{'form.uploaddoc.filename'} =~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i)) {
1.476 raeburn 3914: $nextphase = 'decompress_uploaded';
3915: my $position = scalar(@LONCAPA::map::order)-1;
3916: my $noextract = &return_to_editor();
3917: my $archiveurl = &HTML::Entities::encode($url,'<>&"');
3918: my %archiveitems = (
3919: folderpath => $env{'form.folderpath'},
3920: cmd => $nextphase,
3921: newidx => $newidx,
3922: position => $position,
3923: phase => $nextphase,
1.477 raeburn 3924: comment => $comment,
1.480 raeburn 3925: );
3926: my ($destination,$dir_root) = &embedded_destination($coursenum,$coursedom);
3927: my @current = &get_dir_list($url,$coursenum,$coursedom,$newidx);
1.476 raeburn 3928: $$upload_output = $showupload.
3929: &Apache::loncommon::decompress_form($mimetype,
3930: $archiveurl,'/adm/coursedocs',$noextract,
1.480 raeburn 3931: \%archiveitems,\@current);
1.329 droeschl 3932: }
3933: }
3934: }
1.440 raeburn 3935: return $nextphase;
1.329 droeschl 3936: }
3937:
1.480 raeburn 3938: sub get_dir_list {
3939: my ($url,$coursenum,$coursedom,$newidx) = @_;
3940: my ($destination,$dir_root) = &embedded_destination();
3941: my ($dirlistref,$listerror) =
3942: &Apache::lonnet::dirlist("$dir_root/$destination/$newidx",$coursedom,$coursenum,1);
3943: my @dir_lines;
3944: my $dirptr=16384;
3945: if (ref($dirlistref) eq 'ARRAY') {
3946: foreach my $dir_line (sort
3947: {
3948: my ($afile)=split('&',$a,2);
3949: my ($bfile)=split('&',$b,2);
3950: return (lc($afile) cmp lc($bfile));
3951: } (@{$dirlistref})) {
3952: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
3953: $filename =~ s/\s+$//;
3954: next if ($filename =~ /^\.\.?$/);
3955: my $isdir = 0;
3956: if ($dirptr&$testdir) {
3957: $isdir = 1;
3958: }
3959: push(@dir_lines, [$filename,$dom,$isdir,$size,$mtime,$obs]);
3960: }
3961: }
3962: return @dir_lines;
3963: }
3964:
1.329 droeschl 3965: sub is_supplemental_title {
3966: my ($title) = @_;
3967: return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
3968: }
3969:
3970: # --------------------------------------------------------------- An entry line
3971:
3972: sub entryline {
1.501 raeburn 3973: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
1.598 raeburn 3974: $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups,
1.682 raeburn 3975: $ltitoolsref,$canedit,$isencrypted,$navmapref,$hostname,
3976: $supphidden,$suppids,$suppmapid)=@_;
1.581 raeburn 3977: my ($foldertitle,$renametitle,$oldtitle);
1.329 droeschl 3978: if (&is_supplemental_title($title)) {
1.488 raeburn 3979: ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
1.329 droeschl 3980: } else {
3981: $title=&HTML::Entities::encode($title,'"<>&\'');
3982: $renametitle=$title;
3983: $foldertitle=$title;
3984: }
3985:
1.611 raeburn 3986: my ($disabled,$readonly,$js_lt);
3987: unless ($canedit) {
3988: $disabled = 'disabled="disabled"';
3989: $readonly = 1;
3990: }
3991:
1.329 droeschl 3992: my $orderidx=$LONCAPA::map::order[$index];
1.364 bisitz 3993:
1.329 droeschl 3994: $renametitle=~s/\\/\\\\/g;
3995: $renametitle=~s/\"\;/\\\"/g;
1.585 raeburn 3996: $renametitle=~s/"/%22/g;
1.581 raeburn 3997: $renametitle=~s/ /%20/g;
3998: $oldtitle = $renametitle;
1.576 raeburn 3999: $renametitle=~s/\'/\\\'/g;
1.379 bisitz 4000: my $line=&Apache::loncommon::start_data_table_row();
1.538 raeburn 4001: my ($form_start,$form_end,$form_common,$form_param);
1.329 droeschl 4002: # Edit commands
1.679 raeburn 4003: my ($esc_path, $path, $symb, $shownsymb, $curralias);
1.329 droeschl 4004: if ($env{'form.folderpath'}) {
4005: $esc_path=&escape($env{'form.folderpath'});
4006: $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
4007: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
4008: }
1.505 raeburn 4009: my $isexternal;
1.510 raeburn 4010: if ($residx) {
1.501 raeburn 4011: my $currurl = $url;
4012: $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.505 raeburn 4013: if ($currurl =~ m{^/adm/wrapper/ext/}) {
4014: $isexternal = 1;
4015: }
1.510 raeburn 4016: if (!$supplementalflag) {
4017: my $path = 'uploaded/'.
4018: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
4019: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
4020: $symb = &Apache::lonnet::encode_symb($path.$folder.".$container",
4021: $residx,
4022: &Apache::lonnet::declutter($currurl));
4023: }
1.501 raeburn 4024: }
1.538 raeburn 4025: my ($renamelink,%lt,$ishash);
4026: if (ref($filtersref) eq 'HASH') {
4027: $ishash = 1;
4028: }
4029:
1.329 droeschl 4030: if ($allowed) {
1.538 raeburn 4031: $form_start = '
4032: <form action="/adm/coursedocs" method="post">
4033: ';
4034: $form_common=(<<END);
4035: <input type="hidden" name="folderpath" value="$path" />
4036: <input type="hidden" name="symb" value="$symb" />
4037: END
4038: $form_param=(<<END);
4039: <input type="hidden" name="setparms" value="$orderidx" />
4040: <input type="hidden" name="changeparms" value="0" />
4041: END
4042: $form_end = '</form>';
4043:
1.329 droeschl 4044: my $incindex=$index+1;
4045: my $selectbox='';
1.471 raeburn 4046: if (($#LONCAPA::map::order>0) &&
1.329 droeschl 4047: ((split(/\:/,
1.344 bisitz 4048: $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
4049: ne '') &&
1.329 droeschl 4050: ((split(/\:/,
1.344 bisitz 4051: $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1.329 droeschl 4052: ne '')) {
4053: $selectbox=
4054: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.611 raeburn 4055: '<select name="newpos" onchange="this.form.submit()"'.$disabled.'>';
1.329 droeschl 4056: for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
4057: if ($i==$incindex) {
1.358 bisitz 4058: $selectbox.='<option value="" selected="selected">('.$i.')</option>';
1.329 droeschl 4059: } else {
4060: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
4061: }
4062: }
4063: $selectbox.='</select>';
4064: }
1.501 raeburn 4065: %lt=&Apache::lonlocal::texthash(
1.329 droeschl 4066: 'up' => 'Move Up',
4067: 'dw' => 'Move Down',
4068: 'rm' => 'Remove',
4069: 'ct' => 'Cut',
4070: 'rn' => 'Rename',
1.501 raeburn 4071: 'cp' => 'Copy',
1.633 raeburn 4072: 'da' => 'Unset alias',
4073: 'sa' => 'Set alias',
1.501 raeburn 4074: 'ex' => 'External Resource',
1.598 raeburn 4075: 'et' => 'External Tool',
1.501 raeburn 4076: 'ed' => 'Edit',
4077: 'pr' => 'Preview',
4078: 'sv' => 'Save',
4079: 'ul' => 'URL',
1.611 raeburn 4080: 'ti' => 'Title',
1.618 raeburn 4081: 'er' => 'Editing rights unavailable for your current role.',
1.501 raeburn 4082: );
1.538 raeburn 4083: my %denied = &action_restrictions($coursenum,$coursedom,$url,
4084: $env{'form.folderpath'},
4085: $currgroups);
1.517 raeburn 4086: my ($copylink,$cutlink,$removelink);
1.329 droeschl 4087: my $skip_confirm = 0;
1.603 raeburn 4088: my $confirm_removal = 0;
1.329 droeschl 4089: if ( $folder =~ /^supplemental/
4090: || ($url =~ m{( /smppg$
4091: |/syllabus$
4092: |/aboutme$
4093: |/navmaps$
4094: |/bulletinboard$
1.626 raeburn 4095: |/ext\.tool$
1.505 raeburn 4096: |\.html$)}x)
4097: || $isexternal) {
1.329 droeschl 4098: $skip_confirm = 1;
4099: }
1.603 raeburn 4100: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
4101: ($url!~/$LONCAPA::assess_page_seq_re/)) {
4102: $confirm_removal = 1;
4103: }
1.633 raeburn 4104: if ($url =~ /$LONCAPA::assess_re/) {
4105: $curralias = (&LONCAPA::map::getparameter($orderidx,'parameter_0_mapalias'))[0];
4106: }
1.329 droeschl 4107:
1.538 raeburn 4108: if ($denied{'copy'}) {
1.543 raeburn 4109: $copylink=(<<ENDCOPY)
1.507 raeburn 4110: <span style="visibility: hidden;">$lt{'cp'}</span>
4111: ENDCOPY
4112: } else {
1.538 raeburn 4113: my $formname = 'edit_copy_'.$orderidx;
4114: my $js = "javascript:checkForSubmit(document.forms.renameform,'copy','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.329 droeschl 4115: $copylink=(<<ENDCOPY);
1.538 raeburn 4116: <form name="$formname" method="post" action="/adm/coursedocs">
4117: $form_common
1.611 raeburn 4118: <input type="checkbox" name="copy" id="copy_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','copy');" class="LC_hidden" $disabled /><a href="$js" class="LC_docs_copy">$lt{'cp'}</a>
1.538 raeburn 4119: $form_end
1.329 droeschl 4120: ENDCOPY
1.538 raeburn 4121: if (($ishash) && (ref($filtersref->{'cancopy'}) eq 'ARRAY')) {
4122: push(@{$filtersref->{'cancopy'}},$orderidx);
4123: }
1.329 droeschl 4124: }
1.538 raeburn 4125: if ($denied{'cut'}) {
1.507 raeburn 4126: $cutlink=(<<ENDCUT);
4127: <span style="visibility: hidden;">$lt{'ct'}</span>
4128: ENDCUT
4129: } else {
1.538 raeburn 4130: my $formname = 'edit_cut_'.$orderidx;
4131: my $js = "javascript:checkForSubmit(document.forms.renameform,'cut','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.329 droeschl 4132: $cutlink=(<<ENDCUT);
1.538 raeburn 4133: <form name="$formname" method="post" action="/adm/coursedocs">
4134: $form_common
1.542 raeburn 4135: <input type="hidden" name="skip_$orderidx" id="skip_cut_$orderidx" value="$skip_confirm" />
1.611 raeburn 4136: <input type="checkbox" name="cut" id="cut_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','cut');" class="LC_hidden" $disabled /><a href="$js" class="LC_docs_cut">$lt{'ct'}</a>
1.538 raeburn 4137: $form_end
1.329 droeschl 4138: ENDCUT
1.538 raeburn 4139: if (($ishash) && (ref($filtersref->{'cancut'}) eq 'ARRAY')) {
4140: push(@{$filtersref->{'cancut'}},$orderidx);
4141: }
1.329 droeschl 4142: }
1.538 raeburn 4143: if ($denied{'remove'}) {
1.507 raeburn 4144: $removelink=(<<ENDREM);
4145: <span style="visibility: hidden;">$lt{'rm'}</a>
4146: ENDREM
4147: } else {
1.538 raeburn 4148: my $formname = 'edit_remove_'.$orderidx;
1.603 raeburn 4149: my $js = "javascript:checkForSubmit(document.forms.renameform,'remove','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder',$confirm_removal);";
1.497 raeburn 4150: $removelink=(<<ENDREM);
1.538 raeburn 4151: <form name="$formname" method="post" action="/adm/coursedocs">
4152: $form_common
1.542 raeburn 4153: <input type="hidden" name="skip_$orderidx" id="skip_remove_$orderidx" value="$skip_confirm" />
1.603 raeburn 4154: <input type="hidden" name="confirm_rem_$orderidx" id="confirm_removal_$orderidx" value="$confirm_removal" />
1.611 raeburn 4155: <input type="checkbox" name="remove" id="remove_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','remove');" class="LC_hidden" $disabled /><a href="$js" class="LC_docs_remove">$lt{'rm'}</a>
1.538 raeburn 4156: $form_end
1.497 raeburn 4157: ENDREM
1.538 raeburn 4158: if (($ishash) && (ref($filtersref->{'canremove'}) eq 'ARRAY')) {
4159: push(@{$filtersref->{'canremove'}},$orderidx);
4160: }
1.497 raeburn 4161: }
1.551 raeburn 4162: $renamelink=(<<ENDREN);
1.581 raeburn 4163: <a href='javascript:changename("$esc_path","$index","$oldtitle");' class="LC_docs_rename">$lt{'rn'}</a>
1.507 raeburn 4164: ENDREN
1.611 raeburn 4165: my ($uplink,$downlink);
4166: if ($canedit) {
4167: $uplink = "/adm/coursedocs?cmd=up_$index&folderpath=$esc_path&symb=$symb";
4168: $downlink = "/adm/coursedocs?cmd=down_$index&folderpath=$esc_path&symb=$symb";
4169: } else {
4170: $uplink = "javascript:alert('".&js_escape($lt{'er'})."');";
4171: $downlink = $uplink;
4172: }
1.329 droeschl 4173: $line.=(<<END);
4174: <td>
1.379 bisitz 4175: <div class="LC_docs_entry_move">
1.611 raeburn 4176: <a href="$uplink">
1.501 raeburn 4177: <img src="${iconpath}move_up.gif" alt="$lt{'up'}" class="LC_icon" />
1.379 bisitz 4178: </a>
4179: </div>
4180: <div class="LC_docs_entry_move">
1.611 raeburn 4181: <a href="$downlink">
1.501 raeburn 4182: <img src="${iconpath}move_down.gif" alt="$lt{'dw'}" class="LC_icon" />
1.379 bisitz 4183: </a>
4184: </div>
1.329 droeschl 4185: </td>
4186: <td>
4187: $form_start
1.538 raeburn 4188: $form_param
1.478 raeburn 4189: $form_common
1.329 droeschl 4190: $selectbox
4191: $form_end
4192: </td>
1.540 raeburn 4193: <td class="LC_docs_entry_commands LC_nobreak">
1.497 raeburn 4194: $removelink
1.329 droeschl 4195: $cutlink
4196: $copylink
4197: </td>
4198: END
4199: }
4200: # Figure out what kind of a resource this is
4201: my ($extension)=($url=~/\.(\w+)$/);
4202: my $uploaded=($url=~/^\/*uploaded\//);
4203: my $icon=&Apache::loncommon::icon($url);
1.519 raeburn 4204: my $isfolder;
4205: my $ispage;
4206: my $containerarg;
1.615 raeburn 4207: my $folderurl;
1.329 droeschl 4208: if ($uploaded) {
1.472 raeburn 4209: if (($extension eq 'sequence') || ($extension eq 'page')) {
4210: $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
1.519 raeburn 4211: $containerarg = $1;
1.472 raeburn 4212: if ($extension eq 'sequence') {
4213: $icon=$iconpath.'navmap.folder.closed.gif';
4214: $isfolder=1;
4215: } else {
4216: $icon=$iconpath.'page.gif';
4217: $ispage=1;
4218: }
1.615 raeburn 4219: $folderurl = &Apache::lonnet::declutter($url);
1.472 raeburn 4220: if ($allowed) {
4221: $url='/adm/coursedocs?';
4222: } else {
4223: $url='/adm/supplemental?';
4224: }
1.329 droeschl 4225: } else {
4226: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
4227: }
4228: }
1.364 bisitz 4229:
1.621 raeburn 4230: my ($editlink,$extresform,$anchor,$hiddenres,$nomodal);
1.329 droeschl 4231: my $orig_url = $url;
1.340 raeburn 4232: $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
1.668 raeburn 4233: if ($container eq 'page') {
4234: $url=~s{^http(|s)(:|:)//}{/ext/};
4235: } else {
4236: $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
4237: }
1.501 raeburn 4238: if (!$supplementalflag && $residx && $symb) {
4239: if ((!$isfolder) && (!$ispage)) {
4240: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
1.668 raeburn 4241: if (($url =~ m{^ext/}) && ($container eq 'page')) {
4242: $url=&Apache::lonnet::clutter_with_no_wrapper($url);
4243: } else {
4244: $url=&Apache::lonnet::clutter($url);
4245: }
1.501 raeburn 4246: if ($url=~/^\/*uploaded\//) {
4247: $url=~/\.(\w+)$/;
4248: my $embstyle=&Apache::loncommon::fileembstyle($1);
4249: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
4250: $url='/adm/wrapper'.$url;
4251: } elsif ($embstyle eq 'ssi') {
4252: #do nothing with these
4253: } elsif ($url!~/\.(sequence|page)$/) {
4254: $url='/adm/coursedocs/showdoc'.$url;
4255: }
1.623 raeburn 4256: } elsif ($url=~m{^(|/adm/wrapper)/ext/([^#]+)}) {
4257: my $wrapped = $1;
4258: my $exturl = $2;
1.668 raeburn 4259: if (($wrapped eq '') && ($container ne 'page')) {
1.623 raeburn 4260: $url='/adm/wrapper'.$url;
4261: }
4262: if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) {
4263: $nomodal = 1;
4264: }
1.626 raeburn 4265: } elsif ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
1.598 raeburn 4266: $url='/adm/wrapper'.$url;
1.621 raeburn 4267: } elsif ($url eq "/public/$coursedom/$coursenum/syllabus") {
4268: if (($ENV{'SERVER_PORT'} == 443) &&
4269: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
1.678 raeburn 4270: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.657 raeburn 4271: $url .= '?usehttp=1';
4272: }
1.621 raeburn 4273: $nomodal = 1;
4274: }
1.598 raeburn 4275: }
1.680 raeburn 4276: my ($checkencrypt,$shownurl);
4277: if (!$env{'request.role.adv'}) {
1.615 raeburn 4278: if (((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) ||
1.680 raeburn 4279: ($isencrypted) || (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i)) {
1.615 raeburn 4280: $checkencrypt = 1;
1.620 raeburn 4281: } elsif (ref($navmapref)) {
1.615 raeburn 4282: unless (ref($$navmapref)) {
4283: $$navmapref = Apache::lonnavmaps::navmap->new();
4284: }
4285: if (ref($$navmapref)) {
4286: if (lc($$navmapref->get_mapparam($symb,undef,"0.encrypturl")) eq 'yes') {
1.680 raeburn 4287: $checkencrypt = 1;
1.615 raeburn 4288: }
4289: }
4290: }
1.680 raeburn 4291: }
4292: if ($checkencrypt) {
4293: my $currenc = $env{'request.enc'};
4294: $env{'request.enc'} = 1;
4295: $shownsymb = &Apache::lonenc::encrypted($symb);
4296: $shownurl = &Apache::lonenc::encrypted($url);
4297: if (&Apache::lonnet::symbverify($symb,$url)) {
4298: $url = $shownurl;
4299: } else {
4300: $url = '';
4301: }
4302: $env{'request.enc'} = $currenc;
4303: } elsif (&Apache::lonnet::symbverify($symb,$url)) {
4304: $shownsymb = $symb;
4305: if ($isexternal) {
4306: $url =~ s/\#[^#]+$//;
4307: if ($container eq 'page') {
4308: $url = &Apache::lonnet::clutter($url);
1.613 raeburn 4309: }
1.612 raeburn 4310: }
1.680 raeburn 4311: $shownurl = $url;
4312: }
4313: unless ($env{'request.role.adv'}) {
4314: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4315: $url = '';
4316: }
4317: if (&Apache::lonnet::EXT('resource.0.hiddenresource',$symb) =~ /^yes$/i) {
4318: $url = '';
4319: $hiddenres = 1;
4320: }
4321: }
4322: if ($url ne '') {
4323: $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
1.501 raeburn 4324: }
1.329 droeschl 4325: }
1.621 raeburn 4326: } elsif ($supplementalflag) {
1.610 raeburn 4327: if ($isexternal) {
4328: if ($url =~ /^([^#]+)#([^#]+)$/) {
4329: $url = $1;
4330: $anchor = $2;
1.623 raeburn 4331: if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) {
1.678 raeburn 4332: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.657 raeburn 4333: if ($hostname ne '') {
4334: $url = 'http://'.$hostname.$url;
4335: }
4336: $url .= (($url =~ /\?/) ? '&':'?').'usehttp=1';
1.623 raeburn 4337: }
4338: $nomodal = 1;
4339: }
1.610 raeburn 4340: }
1.621 raeburn 4341: } elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
4342: if (($ENV{'SERVER_PORT'} == 443) &&
4343: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
1.678 raeburn 4344: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.657 raeburn 4345: if ($hostname ne '') {
4346: $url = 'http://'.$hostname.$url;
4347: }
4348: $url .= (($url =~ /\?/) ? '&':'?').'usehttp=1';
1.622 raeburn 4349: }
1.621 raeburn 4350: $nomodal = 1;
4351: }
1.610 raeburn 4352: }
1.329 droeschl 4353: }
1.615 raeburn 4354: my ($rand_pick_text,$rand_order_text,$hiddenfolder);
1.617 raeburn 4355: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.519 raeburn 4356: if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') {
1.329 droeschl 4357: my $foldername=&escape($foldertitle);
4358: my $folderpath=$env{'form.folderpath'};
4359: if ($folderpath) { $folderpath.='&' };
1.510 raeburn 4360: if (!$allowed && $supplementalflag) {
1.519 raeburn 4361: $folderpath.=$containerarg.'&'.$foldername;
1.510 raeburn 4362: $url.='folderpath='.&escape($folderpath);
1.682 raeburn 4363: if (ref($supphidden) eq 'HASH') {
4364: if ($supphidden->{$suppmapid.':'.$residx}) {
4365: $hiddenfolder = 1;
4366: }
4367: }
1.510 raeburn 4368: } else {
1.617 raeburn 4369: my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
4370: 'parameter_randompick'))[0];
4371: my $randorder = ((&LONCAPA::map::getparameter($orderidx,
4372: 'parameter_randomorder'))[0]=~/^yes$/i);
4373: my $hiddenmap = ((&LONCAPA::map::getparameter($orderidx,
4374: 'parameter_hiddenresource'))[0]=~/^yes$/i);
4375: my $encryptmap = ((&LONCAPA::map::getparameter($orderidx,
4376: 'parameter_encrypturl'))[0]=~/^yes$/i);
4377: unless ($hiddenmap) {
1.620 raeburn 4378: if (ref($navmapref)) {
4379: unless (ref($$navmapref)) {
4380: $$navmapref = Apache::lonnavmaps::navmap->new();
4381: }
4382: if (ref($$navmapref)) {
4383: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
4384: my @resources = $$navmapref->retrieveResources($folderurl,$filterFunc,1,1);
4385: unless (@resources) {
4386: $hiddenmap = 1;
4387: unless ($env{'request.role.adv'}) {
4388: $url = '';
4389: $hiddenfolder = 1;
4390: }
1.617 raeburn 4391: }
1.615 raeburn 4392: }
4393: }
4394: }
4395: }
1.617 raeburn 4396: unless ($encryptmap) {
1.620 raeburn 4397: if ((ref($navmapref)) && (ref($$navmapref))) {
4398: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.encrypturl")) eq 'yes') {
4399: $encryptmap = 1;
4400: }
1.617 raeburn 4401: }
4402: }
1.630 raeburn 4403:
1.617 raeburn 4404: # Append randompick number, hidden, and encrypted with ":" to foldername,
4405: # so it gets transferred between levels
4406: $folderpath.=$containerarg.'&'.$foldername.
4407: ':'.$rpicknum.':'.$hiddenmap.':'.$encryptmap.':'.$randorder.':'.$ispage;
1.615 raeburn 4408: unless ($url eq '') {
1.612 raeburn 4409: $url.='folderpath='.&escape($folderpath);
4410: }
1.510 raeburn 4411: my $rpckchk;
4412: if ($rpicknum) {
4413: $rpckchk = ' checked="checked"';
1.543 raeburn 4414: if (($ishash) && (ref($filtersref->{'randompick'}) eq 'ARRAY')) {
4415: push(@{$filtersref->{'randompick'}},$orderidx.':'.$rpicknum);
4416: }
1.510 raeburn 4417: }
1.537 raeburn 4418: my $formname = 'edit_randompick_'.$orderidx;
1.510 raeburn 4419: $rand_pick_text =
1.478 raeburn 4420: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.538 raeburn 4421: $form_param."\n".
1.478 raeburn 4422: $form_common."\n".
1.611 raeburn 4423: '<span class="LC_nobreak"><label><input type="checkbox" name="randompick_'.$orderidx.'" id="randompick_'.$orderidx.'" onclick="'."updatePick(this.form,'$orderidx','check');".'"'.$rpckchk.$disabled.' /> '.&mt('Randomly Pick').'</label><input type="hidden" name="rpicknum_'.$orderidx.'" id="rpicknum_'.$orderidx.'" value="'.$rpicknum.'" /><span id="randompicknum_'.$orderidx.'">';
1.510 raeburn 4424: if ($rpicknum ne '') {
4425: $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
4426: }
1.537 raeburn 4427: $rand_pick_text .= '</span></span>'.
4428: $form_end;
1.543 raeburn 4429: my $ro_set;
1.617 raeburn 4430: if ($randorder) {
1.543 raeburn 4431: $ro_set = 'checked="checked"';
4432: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4433: push(@{$filtersref->{'randomorder'}},$orderidx);
4434: }
4435: }
1.564 raeburn 4436: $formname = 'edit_rorder_'.$orderidx;
1.510 raeburn 4437: $rand_order_text =
1.537 raeburn 4438: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.538 raeburn 4439: $form_param."\n".
1.537 raeburn 4440: $form_common."\n".
1.611 raeburn 4441: '<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.$disabled.' /> '.&mt('Random Order').' </label></span>'.
1.537 raeburn 4442: $form_end;
1.510 raeburn 4443: }
1.509 raeburn 4444: } elsif ($supplementalflag && !$allowed) {
1.598 raeburn 4445: my $isexttool;
1.626 raeburn 4446: if ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
1.598 raeburn 4447: $url='/adm/wrapper'.$url;
4448: $isexttool = 1;
4449: }
1.510 raeburn 4450: $url .= ($url =~ /\?/) ? '&':'?';
1.509 raeburn 4451: $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
1.510 raeburn 4452: if ($title) {
4453: $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"');
4454: }
1.598 raeburn 4455: if ((($isexternal) || ($isexttool)) && $orderidx) {
1.510 raeburn 4456: $url .= '&idx='.$orderidx;
4457: }
1.610 raeburn 4458: if ($anchor ne '') {
4459: $url .= '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4460: }
1.682 raeburn 4461: if (ref($supphidden) eq 'HASH') {
4462: if ($supphidden->{$suppmapid.':'.$residx}) {
4463: $hiddenres = 1;
4464: }
4465: }
1.329 droeschl 4466: }
1.519 raeburn 4467: my ($tdalign,$tdwidth);
1.501 raeburn 4468: if ($allowed) {
1.630 raeburn 4469: my $fileloc =
1.501 raeburn 4470: &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
1.510 raeburn 4471: if ($isexternal) {
1.630 raeburn 4472: ($editlink,$extresform) =
1.611 raeburn 4473: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
4474: undef,undef,undef,undef,undef,undef,
4475: undef,$disabled);
1.626 raeburn 4476: } elsif ($orig_url =~ m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
1.598 raeburn 4477: ($editlink,$extresform) =
4478: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
4479: undef,undef,undef,'tool',$coursedom,
1.611 raeburn 4480: $coursenum,$ltitoolsref,$disabled);
1.511 raeburn 4481: } elsif (!$isfolder && !$ispage) {
1.503 raeburn 4482: my ($cfile,$home,$switchserver,$forceedit,$forceview) =
4483: &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
1.511 raeburn 4484: if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
1.610 raeburn 4485: my $suppanchor;
4486: if ($supplementalflag) {
4487: $suppanchor = $anchor;
4488: }
1.630 raeburn 4489: my $jscall =
1.501 raeburn 4490: &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
4491: $switchserver,
1.503 raeburn 4492: $forceedit,
1.679 raeburn 4493: undef,$symb,$shownsymb,
1.511 raeburn 4494: &escape($env{'form.folderpath'}),
1.622 raeburn 4495: $renametitle,$hostname,
4496: '','',1,$suppanchor);
1.501 raeburn 4497: if ($jscall) {
1.518 raeburn 4498: $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
4499: $jscall.'" >'.&mt('Edit').'</a> '."\n";
1.501 raeburn 4500: }
4501: }
4502: }
1.519 raeburn 4503: $tdalign = ' align="right" valign="top"';
4504: $tdwidth = ' width="80%"';
1.329 droeschl 4505: }
1.408 raeburn 4506: my $reinit;
4507: if ($crstype eq 'Community') {
4508: $reinit = &mt('(re-initialize community to access)');
4509: } else {
4510: $reinit = &mt('(re-initialize course to access)');
1.519 raeburn 4511: }
4512: $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;
1.650 raeburn 4513: if ($orig_url =~ /$LONCAPA::assess_re/) {
1.633 raeburn 4514: $line.= '<br />';
4515: if ($curralias ne '') {
4516: $line.='<span class="LC_nobreak"><a href="javascript:delalias('."'$esc_path','$orderidx'".');" class="LC_docs_alias">'.
4517: $lt{'da'}.'</a></span>';
4518: } else {
4519: $line.='<span class="LC_nobreak"><a href="javascript:setalias('."'$esc_path','$orderidx'".');" class="LC_docs_alias">'.
4520: $lt{'sa'}.'</a></span>';
4521: }
4522: }
4523: $line.='</td><td>';
1.621 raeburn 4524: my $link;
1.472 raeburn 4525: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 4526: $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
4527: } elsif ($url) {
1.610 raeburn 4528: if ($anchor ne '') {
4529: if ($supplementalflag) {
4530: $anchor = '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4531: } else {
4532: $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');
4533: }
4534: }
1.622 raeburn 4535: if ((!$supplementalflag) && ($nomodal) && ($hostname ne '')) {
4536: $link = 'http://'.$hostname.$url;
4537: } else {
4538: $link = $url;
4539: }
1.659 raeburn 4540: $link = &js_escape($link.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.$anchor);
1.621 raeburn 4541: if ($nomodal) {
4542: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4543: '<img src="'.$icon.'" alt="" class="LC_icon" border="0" /></a>';
4544: } else {
4545: $line.=&Apache::loncommon::modal_link($link,
4546: '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
4547: }
1.469 www 4548: } else {
4549: $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
4550: }
1.519 raeburn 4551: $line.='</span></td><td'.$tdwidth.'>';
1.472 raeburn 4552: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 4553: $line.='<a href="'.$url.'">'.$title.'</a>';
1.682 raeburn 4554: if (!$allowed && $supplementalflag && $canedit && $isfolder) {
4555: my $editicon = &Apache::loncommon::lonhttpdurl('/res/adm/pages').'/editmap.png';
4556: my $editurl = $url;
4557: $editurl =~ s{^\Q/adm/supplemental?\E}{/adm/coursedocs?command=direct&forcesupplement=1&};
4558: $line .= ' '.'<a href="'.$editurl.'">'.
4559: '<img src="'.$editicon.'" alt="'.&mt('Edit Content').'" title="'.&mt('Edit Content').'" />'.
4560: '</a>';
4561: }
4562: if ((($hiddenfolder) || ($hiddenres)) && (!$allowed) && ($supplementalflag)) {
4563: $line.= ' <span class="LC_warning">('.&mt('hidden').')</span> ';
4564: }
1.469 www 4565: } elsif ($url) {
1.621 raeburn 4566: if ($nomodal) {
4567: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4568: $title.'</a>';
4569: } else {
4570: $line.=&Apache::loncommon::modal_link($link,$title,600,500);
4571: }
1.617 raeburn 4572: } elsif (($hiddenfolder) || ($hiddenres)) {
1.632 raeburn 4573: $line.=$title.' <span class="LC_warning LC_docs_reinit_warn">('.&mt('Hidden').')</span>';
1.469 www 4574: } else {
4575: $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
4576: }
1.633 raeburn 4577: if (($allowed) && ($curralias ne '')) {
4578: $line .= '<br /><span class="LC_docs_alias_name">('.$curralias.')</span>';
4579: } else {
4580: $line .= $extresform;
4581: }
4582: $line .= '</td>';
1.478 raeburn 4583: $rand_pick_text = ' ' if ($rand_pick_text eq '');
4584: $rand_order_text = ' ' if ($rand_order_text eq '');
1.682 raeburn 4585: if ($allowed) {
4586: my %lt=&Apache::lonlocal::texthash(
4587: 'hd' => 'Hidden',
4588: 'ec' => 'URL hidden');
4589: my ($enctext,$hidtext,$formhidden,$formurlhidden);
1.543 raeburn 4590: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4591: $hidtext = ' checked="checked"';
4592: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4593: push(@{$filtersref->{'hiddenresource'}},$orderidx);
4594: }
4595: }
1.682 raeburn 4596: $formhidden = 'edit_hiddenresource_'.$orderidx;
4597: $line.=(<<ENDPARMS);
1.329 droeschl 4598: <td class="LC_docs_entry_parameter">
1.537 raeburn 4599: <form action="/adm/coursedocs" method="post" name="$formhidden">
1.538 raeburn 4600: $form_param
1.478 raeburn 4601: $form_common
1.611 raeburn 4602: <label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'hiddenresource','settings');" $hidtext $disabled /> $lt{'hd'}</label>
1.329 droeschl 4603: $form_end
1.682 raeburn 4604: ENDPARMS
4605: if ($folder =~/^supplemental/) {
4606: $line.= "\n <td>";
4607: } else {
4608: if ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) {
4609: $enctext = ' checked="checked"';
4610: if (($ishash) && (ref($filtersref->{'encrypturl'}) eq 'ARRAY')) {
4611: push(@{$filtersref->{'encrypturl'}},$orderidx);
4612: }
4613: }
4614: $formurlhidden = 'edit_encrypturl_'.$orderidx;
4615: $line.=(<<ENDPARMS);
1.458 raeburn 4616: <br />
1.537 raeburn 4617: <form action="/adm/coursedocs" method="post" name="$formurlhidden">
1.538 raeburn 4618: $form_param
1.478 raeburn 4619: $form_common
1.611 raeburn 4620: <label><input type="checkbox" name="encrypturl_$orderidx" id="encrypturl_$orderidx" onclick="checkForSubmit(this.form,'encrypturl','settings');" $enctext $disabled /> $lt{'ec'}</label>
1.329 droeschl 4621: $form_end
4622: </td>
1.478 raeburn 4623: <td class="LC_docs_entry_parameter">$rand_pick_text<br />
4624: $rand_order_text</td>
1.329 droeschl 4625: ENDPARMS
1.682 raeburn 4626: }
1.329 droeschl 4627: }
1.379 bisitz 4628: $line.=&Apache::loncommon::end_data_table_row();
1.329 droeschl 4629: return $line;
4630: }
4631:
1.538 raeburn 4632: sub action_restrictions {
4633: my ($cnum,$cdom,$url,$folderpath,$currgroups) = @_;
4634: my %denied = (
4635: cut => 0,
4636: copy => 0,
4637: remove => 0,
4638: );
4639: if ($url=~ m{^/res/.+\.(page|sequence)$}) {
4640: # no copy for published maps
4641: $denied{'copy'} = 1;
1.597 raeburn 4642: } elsif ($url=~m{^/res/lib/templates/([^/]+)\.problem$}) {
4643: unless ($1 eq 'simpleproblem') {
4644: $denied{'copy'} = 1;
4645: }
4646: $denied{'cut'} = 1;
1.538 raeburn 4647: } elsif ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") {
4648: if ($folderpath =~ /^default&[^\&]+$/) {
4649: if ((ref($currgroups) eq 'HASH') && (keys(%{$currgroups}) > 0)) {
4650: $denied{'remove'} = 1;
4651: }
4652: $denied{'cut'} = 1;
4653: $denied{'copy'} = 1;
4654: }
4655: } elsif ($url =~ m{^\Q/uploaded/$cdom/$cnum/group_folder_\E(\w+)\.sequence$}) {
4656: my $group = $1;
4657: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+$/) {
4658: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4659: $denied{'remove'} = 1;
4660: }
4661: }
4662: $denied{'cut'} = 1;
4663: $denied{'copy'} = 1;
4664: } elsif ($url =~ m{^\Q/adm/$cdom/$cnum/\E(\w+)/smppg$}) {
4665: my $group = $1;
4666: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&\Qgroup_folder_$group\E\&[^\&]+$/) {
4667: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4668: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4669: if (keys(%groupsettings) > 0) {
4670: $denied{'remove'} = 1;
4671: }
4672: $denied{'cut'} = 1;
4673: $denied{'copy'} = 1;
4674: }
4675: }
4676: } elsif ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&group_folder_(\w+)\&/) {
4677: my $group = $1;
4678: if ($url =~ /group_boards_\Q$group\E/) {
4679: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4680: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4681: if (keys(%groupsettings) > 0) {
4682: if (ref($groupsettings{'functions'}) eq 'HASH') {
4683: if ($groupsettings{'functions'}{'discussion'} eq 'on') {
4684: $denied{'remove'} = 1;
4685: }
4686: }
4687: }
4688: $denied{'cut'} = 1;
4689: $denied{'copy'} = 1;
4690: }
4691: }
4692: }
4693: return %denied;
4694: }
4695:
1.533 raeburn 4696: sub new_timebased_suffix {
1.538 raeburn 4697: my ($dom,$num,$type,$area,$container) = @_;
1.533 raeburn 4698: my ($prefix,$namespace,$idtype,$errtext,$locknotfreed);
1.538 raeburn 4699: if ($type eq 'paste') {
4700: $prefix = $type;
4701: $namespace = 'courseeditor';
1.587 raeburn 4702: $idtype = 'addcode';
1.538 raeburn 4703: } elsif ($type eq 'map') {
1.533 raeburn 4704: $prefix = 'docs';
4705: if ($area eq 'supplemental') {
4706: $prefix = 'supp';
4707: }
4708: $prefix .= $container;
4709: $namespace = 'uploadedmaps';
4710: } else {
4711: $prefix = $type;
4712: $namespace = 'templated';
1.504 raeburn 4713: }
4714: my ($suffix,$freedlock,$error) =
1.587 raeburn 4715: &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num,$idtype);
1.504 raeburn 4716: if (!$suffix) {
1.538 raeburn 4717: if ($type eq 'paste') {
4718: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.');
4719: } elsif ($type eq 'map') {
1.533 raeburn 4720: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
4721: } elsif ($type eq 'smppg') {
4722: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.');
1.626 raeburn 4723: } elsif ($type eq 'exttool') {
4724: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new external tool.');
1.533 raeburn 4725: } else {
1.565 bisitz 4726: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new discussion board.');
1.533 raeburn 4727: }
1.504 raeburn 4728: if ($error) {
4729: $errtext .= '<br />'.$error;
4730: }
4731: }
4732: if ($freedlock ne 'ok') {
1.630 raeburn 4733: $locknotfreed =
1.533 raeburn 4734: '<div class="LC_error">'.
4735: &mt('There was a problem removing a lockfile.').' ';
1.538 raeburn 4736: if ($type eq 'paste') {
1.591 raeburn 4737: if ($freedlock eq 'nolock') {
4738: $locknotfreed =
4739: '<div class="LC_error">'.
4740: &mt('A lockfile was not released when you added content to the clipboard earlier in this session.').' '.
4741:
1.593 droeschl 4742: &mt('As a result addition of items to the clipboard will be unavailable until your next log-in.');
1.591 raeburn 4743: } else {
4744: $locknotfreed .=
4745: &mt('This will prevent addition of items to the clipboard until your next log-in.');
4746: }
1.538 raeburn 4747: } elsif ($type eq 'map') {
1.591 raeburn 4748: $locknotfreed .=
4749: &mt('This will prevent creation of additional folders or composite pages in this course.');
1.533 raeburn 4750: } elsif ($type eq 'smppg') {
4751: $locknotfreed .=
4752: &mt('This will prevent creation of additional simple pages in this course.');
1.626 raeburn 4753: } elsif ($type eq 'exttool') {
4754: $locknotfreed .=
4755: &mt('This will prevent creation of additional external tools in this course.');
1.533 raeburn 4756: } else {
4757: $locknotfreed .=
1.565 bisitz 4758: &mt('This will prevent creation of additional discussion boards in this course.');
1.533 raeburn 4759: }
1.538 raeburn 4760: unless ($type eq 'paste') {
4761: $locknotfreed .=
1.560 raeburn 4762: ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
4763: '<a href="/adm/helpdesk" target="_helpdesk">','</a>');
1.538 raeburn 4764: }
4765: $locknotfreed .= '</div>';
1.504 raeburn 4766: }
4767: return ($suffix,$errtext,$locknotfreed);
4768: }
4769:
1.329 droeschl 4770: =pod
4771:
4772: =item tiehash()
4773:
4774: tie the hash
4775:
4776: =cut
4777:
4778: sub tiehash {
4779: my ($mode)=@_;
4780: $hashtied=0;
4781: if ($env{'request.course.fn'}) {
4782: if ($mode eq 'write') {
4783: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4784: &GDBM_WRCREAT(),0640)) {
4785: $hashtied=2;
4786: }
4787: } else {
4788: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4789: &GDBM_READER(),0640)) {
4790: $hashtied=1;
4791: }
4792: }
1.364 bisitz 4793: }
1.329 droeschl 4794: }
4795:
4796: sub untiehash {
4797: if ($hashtied) { untie %hash; }
4798: $hashtied=0;
4799: return OK;
4800: }
4801:
4802:
4803:
4804:
4805: sub checkonthis {
1.637 raeburn 4806: my ($r,$url,$level,$title,$checkstale)=@_;
1.329 droeschl 4807: $url=&unescape($url);
4808: $alreadyseen{$url}=1;
4809: $r->rflush();
4810: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
4811: $r->print("\n<br />");
4812: if ($level==0) {
4813: $r->print("<br />");
4814: }
4815: for (my $i=0;$i<=$level*5;$i++) {
4816: $r->print(' ');
4817: }
4818: $r->print('<a href="'.$url.'" target="cat">'.
4819: ($title?$title:$url).'</a> ');
4820: if ($url=~/^\/res\//) {
1.637 raeburn 4821: my $updated;
4822: if (($checkstale) && ($url !~ m{^/res/lib/templates/}) &&
4823: ($url !~ /\.\d+\.\w+$/)) {
4824: $updated = &Apache::lonnet::remove_stale_resfile($url);
4825: }
1.329 droeschl 4826: my $result=&Apache::lonnet::repcopy(
4827: &Apache::lonnet::filelocation('',$url));
4828: if ($result eq 'ok') {
4829: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
1.637 raeburn 4830: if ($updated) {
4831: $r->print('<br />');
4832: for (my $i=0;$i<=$level*5;$i++) {
4833: $r->print(' ');
4834: }
4835: $r->print('- '.&mt('Outdated copy removed'));
4836: }
1.329 droeschl 4837: $r->rflush();
4838: &Apache::lonnet::countacc($url);
4839: $url=~/\.(\w+)$/;
4840: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
4841: $r->print('<br />');
4842: $r->rflush();
4843: for (my $i=0;$i<=$level*5;$i++) {
4844: $r->print(' ');
4845: }
4846: $r->print('- '.&mt('Rendering:').' ');
4847: my ($errorcount,$warningcount)=split(/:/,
4848: &Apache::lonnet::ssi_body($url,
4849: ('grade_target'=>'web',
4850: 'return_only_error_and_warning_counts' => 1)));
4851: if (($errorcount) ||
4852: ($warningcount)) {
4853: if ($errorcount) {
1.369 bisitz 4854: $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1.329 droeschl 4855: &mt('[quant,_1,error]',$errorcount).'</span>');
4856: }
4857: if ($warningcount) {
4858: $r->print('<span class="LC_warning">'.
4859: &mt('[quant,_1,warning]',$warningcount).'</span>');
4860: }
4861: } else {
4862: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
4863: }
4864: $r->rflush();
4865: }
4866: my $dependencies=
4867: &Apache::lonnet::metadata($url,'dependencies');
4868: foreach my $dep (split(/\,/,$dependencies)) {
4869: if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
1.637 raeburn 4870: &checkonthis($r,$dep,$level+1,'',$checkstale);
1.329 droeschl 4871: }
4872: }
4873: } elsif ($result eq 'unavailable') {
4874: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
4875: } elsif ($result eq 'not_found') {
4876: unless ($url=~/\$/) {
1.521 bisitz 4877: $r->print('<span class="LC_error">'.&mt('not found').'</span>');
1.329 droeschl 4878: } else {
1.366 bisitz 4879: $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1.329 droeschl 4880: }
4881: } else {
4882: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
4883: }
1.637 raeburn 4884: if (($updated) && ($result ne 'ok')) {
4885: $r->print('<br />'.&mt('Outdated copy removed'));
4886: }
1.329 droeschl 4887: }
4888: }
4889: }
4890:
4891:
4892:
4893: =pod
4894:
4895: =item list_symbs()
4896:
1.485 raeburn 4897: List Content Identifiers
1.329 droeschl 4898:
4899: =cut
4900:
4901: sub list_symbs {
4902: my ($r) = @_;
4903:
1.408 raeburn 4904: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 4905: $r->print(&Apache::loncommon::start_page('List of Content Identifiers'));
4906: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Identifiers'));
4907: $r->print(&startContentScreen('tools'));
1.329 droeschl 4908: my $navmap = Apache::lonnavmaps::navmap->new();
4909: if (!defined($navmap)) {
4910: $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
4911: '<div class="LC_error">'.
4912: &mt('Unable to retrieve information about course contents').
4913: '</div>');
1.408 raeburn 4914: &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
1.329 droeschl 4915: } else {
1.484 raeburn 4916: $r->print('<h4 class="LC_info">'.&mt("$crstype Content Identifiers").'</h4>'.
4917: &Apache::loncommon::start_data_table().
4918: &Apache::loncommon::start_data_table_header_row().
4919: '<th>'.&mt('Title').'</th><th>'.&mt('Identifier').'</th>'.
4920: &Apache::loncommon::end_data_table_header_row()."\n");
4921: my $count;
1.329 droeschl 4922: foreach my $res ($navmap->retrieveResources()) {
1.484 raeburn 4923: $r->print(&Apache::loncommon::start_data_table_row().
4924: '<td>'.$res->compTitle().'</td>'.
4925: '<td>'.$res->symb().'</td>'.
1.521 bisitz 4926: &Apache::loncommon::end_data_table_row());
1.484 raeburn 4927: $count ++;
4928: }
4929: if (!$count) {
4930: $r->print(&Apache::loncommon::start_data_table_row().
4931: '<td colspan="2">'.&mt("$crstype is empty").'</td>'.
4932: &Apache::loncommon::end_data_table_row());
1.329 droeschl 4933: }
1.484 raeburn 4934: $r->print(&Apache::loncommon::end_data_table());
1.329 droeschl 4935: }
1.521 bisitz 4936: $r->print(&endContentScreen());
1.329 droeschl 4937: }
4938:
1.651 raeburn 4939: sub short_urls {
4940: my ($r,$canedit) = @_;
4941: my $crstype = &Apache::loncommon::course_type();
4942: my $formname = 'shortenurl';
4943: $r->print(&Apache::loncommon::start_page('Display/Set Shortened URLs'));
4944: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Shortened URLs'));
4945: $r->print(&startContentScreen('tools'));
4946: my ($navmap,$errormsg) =
4947: &Apache::loncourserespicker::get_navmap_object($crstype,'shorturls');
4948: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
4949: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4950: my (%maps,%resources,%titles);
4951: if (!ref($navmap)) {
4952: $r->print($errormsg.
4953: &endContentScreen());
4954: return '';
4955: } else {
1.652 raeburn 4956: $r->print('<h4 class="LC_info">'.&mt('Tiny URLs for deep-linking into course').'</h4>'."\n");
1.651 raeburn 4957: $r->rflush();
4958: my $readonly;
4959: if ($canedit) {
1.671 raeburn 4960: my ($numnew,$errors) = &Apache::loncommon::get_requested_shorturls($cdom,$cnum,$navmap);
1.651 raeburn 4961: if ($numnew) {
4962: $r->print('<p class="LC_info">'.&mt('Created [quant,_1,URL]',$numnew).'</p>');
4963: }
4964: if ((ref($errors) eq 'ARRAY') && (@{$errors} > 0)) {
4965: $r->print(&mt('The following errors occurred when processing your request to create shortened URLs:').'<br /><ul>');
4966: foreach my $error (@{$errors}) {
4967: $r->print('<li>'.$error.'</li>');
4968: }
4969: $r->print('</ul><br />');
4970: }
4971: } else {
4972: $readonly = 1;
4973: }
4974: my %currtiny = &Apache::lonnet::dump('tiny',$cdom,$cnum);
4975: $r->print(&Apache::loncourserespicker::create_picker($navmap,'shorturls',$formname,$crstype,undef,
4976: undef,undef,undef,undef,undef,\%currtiny,$readonly));
4977: }
4978: $r->print(&endContentScreen());
4979: }
4980:
1.637 raeburn 4981: sub contentverifyform {
4982: my ($r) = @_;
4983: my $crstype = &Apache::loncommon::course_type();
4984: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
4985: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
4986: $r->print(&startContentScreen('tools'));
4987: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
4988: $r->print('<form method="post" action="/adm/coursedocs"><p>'.
4989: &mt('Include a check if files copied from elsewhere are up to date (will increase verification time)?').
4990: ' <span class="LC_nobreak">'.
4991: '<label><input type="radio" name="checkstale" value="0" checked="checked" />'.
4992: &mt('No').'</label>'.(' 'x2).
4993: '<label><input type="radio" name="checkstale" value="1" />'.
4994: &mt('Yes').'</label></span></p><p>'.
1.674 raeburn 4995: '<input type="submit" value="'.&mt('Verify Content').' "/>'.
1.637 raeburn 4996: '<input type="hidden" value="1" name="tools" />'.
4997: '<input type="hidden" value="1" name="verify" /></p></form>');
4998: $r->print(&endContentScreen());
4999: return;
5000: }
1.329 droeschl 5001:
5002: sub verifycontent {
1.637 raeburn 5003: my ($r,$checkstale) = @_;
1.408 raeburn 5004: my $crstype = &Apache::loncommon::course_type();
1.549 raeburn 5005: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
5006: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
1.484 raeburn 5007: $r->print(&startContentScreen('tools'));
5008: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
1.329 droeschl 5009: $hashtied=0;
5010: undef %alreadyseen;
5011: %alreadyseen=();
5012: &tiehash();
1.484 raeburn 5013:
1.329 droeschl 5014: foreach my $key (keys(%hash)) {
5015: if ($hash{$key}=~/\.(page|sequence)$/) {
5016: if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
5017: $r->print('<hr /><span class="LC_error">'.
1.419 bisitz 5018: &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
1.329 droeschl 5019: &unescape($hash{$key}).'</span><br />'.
1.419 bisitz 5020: &mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />');
1.329 droeschl 5021: }
5022: }
5023: if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
1.637 raeburn 5024: &checkonthis($r,$hash{$key},0,$hash{'title_'.$1},$checkstale);
1.329 droeschl 5025: }
5026: }
5027: &untiehash();
1.442 www 5028: $r->print('<p class="LC_success">'.&mt('Done').'</p>');
1.521 bisitz 5029: $r->print(&endContentScreen());
1.329 droeschl 5030: }
5031:
5032: sub devalidateversioncache {
5033: my $src=shift;
5034: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
5035: &Apache::lonnet::clutter($src));
5036: }
5037:
5038: sub checkversions {
1.611 raeburn 5039: my ($r,$canedit) = @_;
1.408 raeburn 5040: my $crstype = &Apache::loncommon::course_type();
1.571 raeburn 5041: $r->print(&Apache::loncommon::start_page("Check $crstype Resource Versions"));
5042: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Resource Versions"));
1.484 raeburn 5043: $r->print(&startContentScreen('tools'));
1.442 www 5044:
1.329 droeschl 5045: my $header='';
5046: my $startsel='';
5047: my $monthsel='';
5048: my $weeksel='';
5049: my $daysel='';
5050: my $allsel='';
5051: my %changes=();
5052: my $starttime=0;
5053: my $haschanged=0;
5054: my %setversions=&Apache::lonnet::dump('resourceversions',
5055: $env{'course.'.$env{'request.course.id'}.'.domain'},
5056: $env{'course.'.$env{'request.course.id'}.'.num'});
5057:
5058: $hashtied=0;
5059: &tiehash();
1.611 raeburn 5060: if ($canedit) {
5061: my %newsetversions=();
5062: if ($env{'form.setmostrecent'}) {
5063: $haschanged=1;
5064: foreach my $key (keys(%hash)) {
5065: if ($key=~/^ids\_(\/res\/.+)$/) {
5066: $newsetversions{$1}='mostrecent';
5067: &devalidateversioncache($1);
5068: }
5069: }
5070: } elsif ($env{'form.setcurrent'}) {
5071: $haschanged=1;
5072: foreach my $key (keys(%hash)) {
5073: if ($key=~/^ids\_(\/res\/.+)$/) {
5074: my $getvers=&Apache::lonnet::getversion($1);
5075: if ($getvers>0) {
5076: $newsetversions{$1}=$getvers;
5077: &devalidateversioncache($1);
5078: }
5079: }
1.329 droeschl 5080: }
1.611 raeburn 5081: } elsif ($env{'form.setversions'}) {
5082: $haschanged=1;
5083: foreach my $key (keys(%env)) {
5084: if ($key=~/^form\.set_version_(.+)$/) {
5085: my $src=$1;
5086: if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
5087: $newsetversions{$src}=$env{$key};
5088: &devalidateversioncache($src);
5089: }
5090: }
1.329 droeschl 5091: }
1.611 raeburn 5092: }
5093: if ($haschanged) {
5094: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
5095: $env{'course.'.$env{'request.course.id'}.'.domain'},
5096: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
5097: $r->print(&Apache::loncommon::confirmwrapper(
5098: &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
5099: } else {
5100: $r->print(&Apache::loncommon::confirmwrapper(
5101: &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
1.329 droeschl 5102: }
1.611 raeburn 5103: &mark_hash_old();
5104: }
5105: &changewarning($r,'');
1.329 droeschl 5106: }
5107: if ($env{'form.timerange'} eq 'all') {
5108: # show all documents
1.549 raeburn 5109: $header=&mt('All content in '.$crstype);
1.521 bisitz 5110: $allsel=' selected="selected"';
1.329 droeschl 5111: foreach my $key (keys(%hash)) {
5112: if ($key=~/^ids\_(\/res\/.+)$/) {
5113: my $src=$1;
5114: $changes{$src}=1;
5115: }
5116: }
5117: } else {
5118: # show documents which changed
5119: %changes=&Apache::lonnet::dump
5120: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
5121: $env{'course.'.$env{'request.course.id'}.'.num'});
5122: my $firstkey=(keys(%changes))[0];
5123: unless ($firstkey=~/^error\:/) {
5124: unless ($env{'form.timerange'}) {
5125: $env{'form.timerange'}=604800;
5126: }
5127: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
5128: .&mt('seconds');
5129: if ($env{'form.timerange'}==-1) {
5130: $seltext='since start of course';
1.521 bisitz 5131: $startsel=' selected="selected"';
1.329 droeschl 5132: $env{'form.timerange'}=time;
5133: }
5134: $starttime=time-$env{'form.timerange'};
5135: if ($env{'form.timerange'}==2592000) {
5136: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 5137: $monthsel=' selected="selected"';
1.329 droeschl 5138: } elsif ($env{'form.timerange'}==604800) {
5139: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 5140: $weeksel=' selected="selected"';
1.329 droeschl 5141: } elsif ($env{'form.timerange'}==86400) {
5142: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 5143: $daysel=' selected="selected"';
1.329 droeschl 5144: }
5145: $header=&mt('Content changed').' '.$seltext;
5146: } else {
5147: $header=&mt('No content modifications yet.');
5148: }
5149: }
5150: %setversions=&Apache::lonnet::dump('resourceversions',
5151: $env{'course.'.$env{'request.course.id'}.'.domain'},
5152: $env{'course.'.$env{'request.course.id'}.'.num'});
5153: my %lt=&Apache::lonlocal::texthash
1.408 raeburn 5154: ('st' => 'Version changes since start of '.$crstype,
1.329 droeschl 5155: 'lm' => 'Version changes since last Month',
5156: 'lw' => 'Version changes since last Week',
5157: 'sy' => 'Version changes since Yesterday',
5158: 'al' => 'All Resources (possibly large output)',
1.484 raeburn 5159: 'cd' => 'Change display',
1.329 droeschl 5160: 'sd' => 'Display',
5161: 'fi' => 'File',
5162: 'md' => 'Modification Date',
5163: 'mr' => 'Most recently published Version',
1.408 raeburn 5164: 've' => 'Version used in '.$crstype,
5165: 'vu' => 'Set Version to be used in '.$crstype,
5166: 'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
1.329 droeschl 5167: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
5168: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.479 golterma 5169: 'di' => 'Differences',
1.484 raeburn 5170: 'save' => 'Save changes',
5171: 'vers' => 'Version choice(s) for specific resources',
1.479 golterma 5172: 'act' => 'Actions');
1.611 raeburn 5173: my ($disabled,$readonly);
5174: unless ($canedit) {
5175: $disabled = 'disabled="disabled"';
5176: $readonly = 1;
5177: }
1.329 droeschl 5178: $r->print(<<ENDHEADERS);
1.484 raeburn 5179: <h4 class="LC_info">$header</h4>
1.329 droeschl 5180: <form action="/adm/coursedocs" method="post">
5181: <input type="hidden" name="versions" value="1" />
1.484 raeburn 5182: <div class="LC_left_float">
1.479 golterma 5183: <fieldset>
1.484 raeburn 5184: <legend>$lt{'cd'}</legend>
1.329 droeschl 5185: <select name="timerange">
1.521 bisitz 5186: <option value='all'$allsel>$lt{'al'}</option>
5187: <option value="-1"$startsel>$lt{'st'}</option>
5188: <option value="2592000"$monthsel>$lt{'lm'}</option>
5189: <option value="604800"$weeksel>$lt{'lw'}</option>
5190: <option value="86400"$daysel>$lt{'sy'}</option>
1.329 droeschl 5191: </select>
5192: <input type="submit" name="display" value="$lt{'sd'}" />
1.484 raeburn 5193: </fieldset>
5194: </div>
5195: <div class="LC_left_float">
5196: <fieldset>
5197: <legend>$lt{'act'}</legend>
1.611 raeburn 5198: $lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" $disabled /><br />
5199: $lt{'sc'}: <input type="submit" name="setcurrent" value="Go" $disabled />
1.484 raeburn 5200: </fieldset>
5201: </div>
5202: <br clear="all" />
5203: <hr />
5204: <h4>$lt{'vers'}</h4>
1.329 droeschl 5205: ENDHEADERS
1.479 golterma 5206: #number of columns for version history
1.571 raeburn 5207: my %changedbytime;
5208: foreach my $key (keys(%changes)) {
5209: #excludes not versionable problems from resource version history:
5210: next if ($key =~ /^\/res\/lib\/templates/);
5211: my $chg;
5212: if ($env{'form.timerange'} eq 'all') {
5213: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
5214: $chg = &Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate');
5215: } else {
5216: $chg = $changes{$key};
5217: next if ($chg < $starttime);
5218: }
5219: push(@{$changedbytime{$chg}},$key);
5220: }
5221: if (keys(%changedbytime) == 0) {
5222: &untiehash();
5223: $r->print(&mt('No content changes in imported content in specified time frame').
5224: &endContentScreen());
5225: return;
5226: }
1.479 golterma 5227: $r->print(
1.611 raeburn 5228: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.521 bisitz 5229: &Apache::loncommon::start_data_table().
5230: &Apache::loncommon::start_data_table_header_row().
5231: '<th>'.&mt('Resources').'</th>'.
5232: "<th>$lt{'mr'}</th>".
5233: "<th>$lt{'ve'}</th>".
5234: "<th>$lt{'vu'}</th>".
5235: '<th>'.&mt('History').'</th>'.
5236: &Apache::loncommon::end_data_table_header_row()
5237: );
1.571 raeburn 5238: foreach my $chg (sort {$b <=> $a } keys(%changedbytime)) {
5239: foreach my $key (sort(@{$changedbytime{$chg}})) {
5240: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
5241: my $currentversion=&Apache::lonnet::getversion($key);
5242: if ($currentversion<0) {
5243: $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
5244: }
5245: my $linkurl=&Apache::lonnet::clutter($key);
5246: $r->print(
5247: &Apache::loncommon::start_data_table_row().
5248: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br />'.
5249: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
5250: '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br />('.
5251: &Apache::lonlocal::locallocaltime($chg).')</span></td>'.
5252: '<td align="right">'
5253: );
5254: # Used in course
5255: my $usedversion=$hash{'version_'.$linkurl};
5256: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.521 bisitz 5257: if ($usedversion != $currentversion) {
1.479 golterma 5258: $r->print('<span class="LC_warning">'.$usedversion.'</span>');
1.521 bisitz 5259: } else {
1.479 golterma 5260: $r->print($usedversion);
5261: }
1.329 droeschl 5262: } else {
1.521 bisitz 5263: $r->print($currentversion);
1.329 droeschl 5264: }
1.571 raeburn 5265: $r->print('</td><td title="'.$lt{'vu'}.'">');
5266: # Set version
5267: $r->print(&Apache::loncommon::select_form(
5268: $setversions{$linkurl},
5269: 'set_version_'.$linkurl,
5270: {'select_form_order' => ['',1..$currentversion,'mostrecent'],
5271: '' => '',
5272: 'mostrecent' => &mt('most recent'),
1.611 raeburn 5273: map {$_,$_} (1..$currentversion)},'',$readonly));
1.571 raeburn 5274: my $lastold=1;
5275: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
5276: my $url=$root.'.'.$prevvers.'.'.$extension;
5277: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) {
5278: $lastold=$prevvers;
5279: }
5280: }
5281: $r->print('</td>');
5282: # List all available versions
5283: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
5284: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
5285: my $url=$root.'.'.$prevvers.'.'.$extension;
5286: $r->print(
5287: '<span class="LC_nobreak">'
5288: .'<a href="'.&Apache::lonnet::clutter($url).'">'
5289: .&mt('Version [_1]',$prevvers).'</a>'
5290: .' ('.&Apache::lonlocal::locallocaltime(
1.521 bisitz 5291: &Apache::lonnet::metadata($url,'lastrevisiondate'))
1.571 raeburn 5292: .')');
5293: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
5294: $r->print(
5295: ' <a href="/adm/diff?filename='.
5296: &Apache::lonnet::clutter($root.'.'.$extension).
5297: &HTML::Entities::encode('&versionone='.$prevvers,'"<>&').
5298: '" target="diffs">'.&mt('Diffs').'</a>');
5299: }
5300: $r->print('</span><br />');
1.329 droeschl 5301: }
1.571 raeburn 5302: $r->print('</span></td>'.&Apache::loncommon::end_data_table_row());
1.521 bisitz 5303: }
1.329 droeschl 5304: }
1.521 bisitz 5305: $r->print(
5306: &Apache::loncommon::end_data_table().
1.611 raeburn 5307: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.521 bisitz 5308: '</form>'
5309: );
1.329 droeschl 5310:
5311: &untiehash();
1.521 bisitz 5312: $r->print(&endContentScreen());
1.571 raeburn 5313: return;
1.329 droeschl 5314: }
5315:
5316: sub mark_hash_old {
5317: my $retie_hash=0;
5318: if ($hashtied) {
5319: $retie_hash=1;
5320: &untiehash();
5321: }
5322: &tiehash('write');
5323: $hash{'old'}=1;
5324: &untiehash();
5325: if ($retie_hash) { &tiehash(); }
5326: }
5327:
5328: sub is_hash_old {
5329: my $untie_hash=0;
5330: if (!$hashtied) {
5331: $untie_hash=1;
5332: &tiehash();
5333: }
5334: my $return=$hash{'old'};
5335: if ($untie_hash) { &untiehash(); }
5336: return $return;
5337: }
5338:
5339: sub changewarning {
5340: my ($r,$postexec,$message,$url)=@_;
5341: if (!&is_hash_old()) { return; }
5342: my $pathvar='folderpath';
5343: my $path=&escape($env{'form.folderpath'});
5344: if (!defined($url)) {
5345: $url='/adm/coursedocs?'.$pathvar.'='.$path;
5346: }
5347: my $course_type = &Apache::loncommon::course_type();
5348: if (!defined($message)) {
5349: $message='Changes will become active for your current session after [_1], or the next time you log in.';
5350: }
1.653 raeburn 5351: my $windowname = 'loncapaclient';
5352: if ($env{'request.lti.login'}) {
5353: $windowname .= 'lti';
5354: }
1.329 droeschl 5355: $r->print("\n\n".
1.372 bisitz 5356: '<script type="text/javascript">'."\n".
5357: '// <![CDATA['."\n".
5358: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
5359: '// ]]>'."\n".
1.369 bisitz 5360: '</script>'."\n".
1.653 raeburn 5361: '<form name="reinitform" method="post" action="/adm/roles" target="'.$windowname.'">'.
1.329 droeschl 5362: '<input type="hidden" name="orgurl" value="'.$url.
1.372 bisitz 5363: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
1.329 droeschl 5364: &mt($message,' <input type="hidden" name="'.
5365: $env{'request.role'}.'" value="1" /><input type="button" value="'.
1.369 bisitz 5366: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1.372 bisitz 5367: $help{'Caching'}.'</p></form>'."\n\n");
1.329 droeschl 5368: }
5369:
5370:
5371: sub init_breadcrumbs {
1.571 raeburn 5372: my ($form,$text,$help)=@_;
1.329 droeschl 5373: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484 raeburn 5374: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
1.405 bisitz 5375: text=>&Apache::loncommon::course_type().' Editor',
1.329 droeschl 5376: faq=>273,
5377: bug=>'Instructor Interface',
1.571 raeburn 5378: help => $help});
1.329 droeschl 5379: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
5380: text=>$text,
5381: faq=>273,
5382: bug=>'Instructor Interface'});
5383: }
5384:
1.441 www 5385: # subroutine to list form elements
5386: sub create_list_elements {
5387: my @formarr = @_;
5388: my $list = '';
1.501 raeburn 5389: foreach my $button (@formarr){
5390: foreach my $picture (keys(%{$button})) {
5391: $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
1.441 www 5392: }
5393: }
5394: return $list;
5395: }
1.329 droeschl 5396:
1.441 www 5397: # subroutine to create ul from list elements
5398: sub create_form_ul {
5399: my $list = shift;
5400: my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
5401: return $ul;
5402: }
1.329 droeschl 5403:
1.442 www 5404: #
5405: # Start tabs
5406: #
5407:
5408: sub startContentScreen {
1.484 raeburn 5409: my ($mode) = @_;
5410: my $output = '<ul class="LC_TabContentBigger" id="mainnav">';
1.472 raeburn 5411: if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
1.484 raeburn 5412: $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n";
5413: $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n";
5414: $output .= '<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b> '.&mt('Content Index').' </b></a></li>'."\n";
5415: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
5416: } else {
1.549 raeburn 5417: $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 5418: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
5419: $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>'."\n";
5420: '><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>';
5421: }
5422: $output .= "\n".'</ul>'."\n";
5423: $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
5424: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
5425: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
5426: return $output;
1.442 www 5427: }
5428:
5429: #
5430: # End tabs
5431: #
5432:
5433: sub endContentScreen {
1.484 raeburn 5434: return '</div></div></div>';
1.442 www 5435: }
1.329 droeschl 5436:
1.446 www 5437: sub supplemental_base {
1.548 raeburn 5438: return 'supplemental&'.&escape(&mt('Supplemental Content'));
1.446 www 5439: }
5440:
1.329 droeschl 5441: sub handler {
5442: my $r = shift;
5443: &Apache::loncommon::content_type($r,'text/html');
5444: $r->send_http_header;
5445: return OK if $r->header_only;
1.484 raeburn 5446:
5447: # get course data
1.408 raeburn 5448: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 5449: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
5450: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5451:
1.606 raeburn 5452: # get docroot
5453: my $londocroot = $r->dir_config('lonDocRoot');
5454:
1.484 raeburn 5455: # graphics settings
5456: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329 droeschl 5457:
1.443 www 5458: #
1.329 droeschl 5459: # --------------------------------------------- Initialize help topics for this
5460: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
1.627 raeburn 5461: 'Adding_External_Resource','Adding_External_Tool',
5462: 'Navigate_Content','Adding_Folders','Docs_Overview',
5463: 'Load_Map','Supplemental','Score_Upload_Form',
5464: 'Adding_Pages','Importing_LON-CAPA_Resource',
5465: 'Importing_IMS_Course','Uploading_From_Harddrive',
5466: 'Course_Roster','Web_Page','Dropbox','Simple_Problem') {
1.329 droeschl 5467: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
5468: }
5469: # Composite help files
5470: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
5471: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
5472: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
5473: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
5474: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
5475: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 5476: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 5477: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 5478: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 5479: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1.534 raeburn 5480:
1.611 raeburn 5481: my ($allowed,$canedit,$canview,$noendpage,$disabled);
1.682 raeburn 5482: # does this user have privileges to modify content.
5483: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
1.472 raeburn 5484: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
1.682 raeburn 5485: unless ($r->uri eq '/adm/supplemental') {
1.611 raeburn 5486: $allowed = 1;
1.682 raeburn 5487: }
5488: $canedit = 1;
5489: $canview = 1;
5490: } elsif (&Apache::lonnet::allowed('cev',$env{'request.course.id'})) {
5491: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
5492: unless ($r->uri eq '/adm/supplemental') {
1.611 raeburn 5493: $allowed = 1;
5494: }
1.682 raeburn 5495: $canview = 1;
1.611 raeburn 5496: }
5497: unless ($canedit) {
5498: $disabled = ' disabled="disabled"';
1.472 raeburn 5499: }
1.582 raeburn 5500: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']);
1.635 raeburn 5501: if ($env{'form.inhibitmenu'}) {
5502: unless ($env{'form.inhibitmenu'} eq 'yes') {
5503: delete($env{'form.inhibitmenu'});
5504: }
5505: }
5506:
1.582 raeburn 5507: if ($allowed && $env{'form.verify'}) {
1.571 raeburn 5508: &init_breadcrumbs('verify','Verify Content','Docs_Verify_Content');
1.637 raeburn 5509: if (!$canedit) {
5510: &verifycontent($r);
5511: } elsif (($env{'form.checkstale'} ne '') && ($env{'form.checkstale'} =~ /^\d$/)) {
5512: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1&verify=1&checkstale=$env{'form.checkstale'}",
5513: text=>'Results',
5514: faq=>273,
5515: bug=>'Instructor Interface'});
5516: &verifycontent($r,$env{'form.checkstale'});
5517: } else {
5518: &contentverifyform($r);
5519: }
1.329 droeschl 5520: } elsif ($allowed && $env{'form.listsymbs'}) {
1.484 raeburn 5521: &init_breadcrumbs('listsymbs','List Content IDs');
1.329 droeschl 5522: &list_symbs($r);
1.651 raeburn 5523: } elsif ($allowed && $env{'form.shorturls'}) {
5524: &init_breadcrumbs('shorturls','Set/Display Shortened URLs','Docs_Short_URLs');
5525: &short_urls($r,$canedit);
1.329 droeschl 5526: } elsif ($allowed && $env{'form.docslog'}) {
5527: &init_breadcrumbs('docslog','Show Log');
1.484 raeburn 5528: my $folder = $env{'form.folder'};
5529: if ($folder eq '') {
5530: $folder='default';
5531: }
1.611 raeburn 5532: &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit);
1.329 droeschl 5533: } elsif ($allowed && $env{'form.versions'}) {
1.571 raeburn 5534: &init_breadcrumbs('versions','Check/Set Resource Versions','Docs_Check_Resource_Versions');
1.611 raeburn 5535: &checkversions($r,$canedit);
5536: } elsif ($canedit && $env{'form.dumpcourse'}) {
1.568 raeburn 5537: &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329 droeschl 5538: &dumpcourse($r);
1.611 raeburn 5539: } elsif ($canedit && $env{'form.exportcourse'}) {
1.377 bisitz 5540: &init_breadcrumbs('exportcourse','IMS Export');
1.475 raeburn 5541: &Apache::imsexport::exportcourse($r);
1.329 droeschl 5542: } else {
1.611 raeburn 5543: if ($canedit && $env{'form.authorrole'}) {
1.606 raeburn 5544: $noendpage = 1;
5545: my ($redirect,$error) = &makenewproblem($r,$coursedom,$coursenum);
5546: if ($redirect) {
5547: if (($env{'form.newresourceadd'}) && ($env{'form.folderpath'})) {
5548: my $container = 'sequence';
5549: my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
5550: $is_random_order,$container) =
5551: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
5552: my (@folders)=split('&',$env{'form.folderpath'});
5553: $env{'form.foldername'}=&unescape(pop(@folders));
5554: my $folder=pop(@folders);
5555: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
5556: $folder.'.'.$container);
5557: my $warning;
5558: if ($fatal) {
5559: if ($container eq 'page') {
5560: $warning = &mt('An error occurred retrieving the contents of the current page.');
5561: } else {
5562: $warning = &mt('An error occurred retrieving the contents of the current folder.');
5563: }
5564: } else {
5565: my $url = $redirect;
5566: my $srcfile = $londocroot.$url;
5567: $url =~ s{^/priv/}{/res/};
5568: my $targetfile = $londocroot.$url;
5569: my $nokeyref = &Apache::lonpublisher::getnokey($r->dir_config('lonIncludes'));
5570: my $output = &Apache::lonpublisher::batchpublish($r,$srcfile,$targetfile,$nokeyref,1);
5571: $env{'form.folder'} = $folder;
5572: &snapshotbefore();
5573: my $title = &LONCAPA::map::qtunescape($env{'form.newresourcetitle'});
5574: my $ext = 'false';
5575: my $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
5576: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
5577: ':'.$ext.':normal:res';
5578: push(@LONCAPA::map::order,$newidx);
5579: &LONCAPA::map::storeparameter($newidx,'parameter_hiddenresource','yes',
5580: 'string_yesno');
5581: &remember_parms($newidx,'hiddenresource','set','yes');
5582: ($errtext,$fatal) =
5583: &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
5584: &log_differences($plain);
5585: &mark_hash_old();
5586: $r->internal_redirect($redirect);
5587: return OK;
5588: }
1.654 raeburn 5589: } else {
5590: $r->internal_redirect($redirect);
1.606 raeburn 5591: }
5592: }
5593: }
1.445 www 5594: #
5595: # Done catching special calls
1.484 raeburn 5596: # The whole rest is for course and supplemental documents and utilities menu
1.445 www 5597: # Get the parameters that may be needed
5598: #
5599: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.682 raeburn 5600: ['folderpath','title',
1.519 raeburn 5601: 'forcesupplement','forcestandard',
1.510 raeburn 5602: 'tools','symb','command','supppath']);
1.445 www 5603:
1.635 raeburn 5604: foreach my $item ('forcesupplement','forcestandard','tools') {
5605: next if ($env{'form.'.$item} eq '');
5606: unless ($env{'form.'.$item} eq '1') {
5607: delete($env{'form.'.$item});
5608: }
5609: }
5610:
5611: if ($env{'form.command'}) {
5612: unless ($env{'form.command'} =~ /^(direct|directnav|editdocs|editsupp|contents|home)$/) {
5613: delete($env{'form.command'});
5614: }
5615: }
5616:
5617: if ($env{'form.symb'}) {
5618: my ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.symb'});
5619: unless (($id =~ /^\d+$/) && (&Apache::lonnet::is_on_map($resurl))) {
5620: delete($env{'form.symb'});
5621: }
5622: }
5623:
1.445 www 5624: # standard=1: this is a "new-style" course with an uploaded map as top level
5625: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329 droeschl 5626:
5627: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445 www 5628:
1.484 raeburn 5629: # Decide whether this should display supplemental or main content or utilities
1.445 www 5630: # supplementalflag=1: show supplemental documents
5631: # supplementalflag=0: show standard documents
1.484 raeburn 5632: # toolsflag=1: show utilities
1.445 www 5633:
1.561 raeburn 5634: my $unesc_folderpath = &unescape($env{'form.folderpath'});
5635: my $supplementalflag=($unesc_folderpath=~/^supplemental/);
5636: if (($unesc_folderpath=~/^default/) || ($unesc_folderpath eq "")) {
1.445 www 5637: $supplementalflag=0;
5638: }
5639: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
5640: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
5641: unless ($allowed) { $supplementalflag=1; }
5642: unless ($standard) { $supplementalflag=1; }
1.484 raeburn 5643: my $toolsflag=0;
5644: if ($env{'form.tools'}) { $toolsflag=1; }
1.445 www 5645:
1.635 raeburn 5646: if ($env{'form.folderpath'} ne '') {
1.677 raeburn 5647: &validate_folderpath($supplementalflag);
1.635 raeburn 5648: }
5649:
5650: if ($env{'form.supppath'} ne '') {
1.677 raeburn 5651: &validate_suppath();
1.635 raeburn 5652: }
5653:
1.329 droeschl 5654: my $script='';
5655: my $showdoc=0;
1.457 raeburn 5656: my $addentries = {};
1.475 raeburn 5657: my $container;
1.329 droeschl 5658: my $containertag;
1.508 raeburn 5659: my $pathitem;
1.598 raeburn 5660: my %ltitools;
1.617 raeburn 5661: my $hiddentop;
1.615 raeburn 5662: my $navmap;
1.617 raeburn 5663: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.329 droeschl 5664:
1.464 www 5665: # Do we directly jump somewhere?
1.525 raeburn 5666: if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
1.472 raeburn 5667: if ($env{'form.symb'} ne '') {
1.522 raeburn 5668: $env{'form.folderpath'}=
1.617 raeburn 5669: &Apache::loncommon::symb_to_docspath($env{'form.symb'},\$navmap);
1.530 raeburn 5670: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
1.525 raeburn 5671: $env{'form.command'}.'_'.$env{'form.symb'}});
1.472 raeburn 5672: } elsif ($env{'form.supppath'} ne '') {
5673: $env{'form.folderpath'}=$env{'form.supppath'};
1.530 raeburn 5674: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
1.525 raeburn 5675: $env{'form.command'}.'_'.$env{'form.supppath'}});
1.466 www 5676: }
1.472 raeburn 5677: } elsif ($env{'form.command'} eq 'editdocs') {
1.617 raeburn 5678: $env{'form.folderpath'} = &default_folderpath($coursenum,$coursedom,\$navmap);
1.525 raeburn 5679: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
1.472 raeburn 5680: } elsif ($env{'form.command'} eq 'editsupp') {
1.617 raeburn 5681: $env{'form.folderpath'} = &supplemental_base();
1.525 raeburn 5682: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
5683: } elsif ($env{'form.command'} eq 'contents') {
5684: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
5685: } elsif ($env{'form.command'} eq 'home') {
5686: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
1.464 www 5687: }
5688:
1.525 raeburn 5689:
1.445 www 5690: # Where do we store these for when we come back?
5691: my $stored_folderpath='docs_folderpath';
5692: if ($supplementalflag) {
5693: $stored_folderpath='docs_sup_folderpath';
5694: }
1.464 www 5695:
1.519 raeburn 5696: # No folderpath, and in edit mode, see if we have something stored
5697: if ((!$env{'form.folderpath'}) && $allowed) {
1.445 www 5698: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.510 raeburn 5699: {'folderpath' => 'scalar'});
1.615 raeburn 5700:
5701: if (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
5702: if ($supplementalflag) {
5703: undef($env{'form.folderpath'}) if ($1 eq 'default');
5704: } else {
5705: undef($env{'form.folderpath'}) if ($1 eq 'supplemental');
5706: }
5707: } else {
1.523 raeburn 5708: undef($env{'form.folderpath'});
5709: }
1.677 raeburn 5710: if ($env{'form.folderpath'} ne '') {
5711: &validate_folderpath($supplementalflag);
5712: }
1.329 droeschl 5713: }
1.446 www 5714:
5715: # If we are not allowed to make changes, all we can see are supplemental docs
1.409 raeburn 5716: if (!$allowed) {
1.446 www 5717: unless ($env{'form.folderpath'} =~ /^supplemental/) {
5718: $env{'form.folderpath'} = &supplemental_base();
1.409 raeburn 5719: }
5720: }
1.446 www 5721: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329 droeschl 5722: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446 www 5723: $env{'form.folderpath'} = &supplemental_base()
5724: .'&'.
1.329 droeschl 5725: $env{'form.folderpath'};
5726: }
1.615 raeburn 5727: # If allowed and user's role is not advanced check folderpath is not hidden
5728: if (($allowed) && (!$env{'request.role.adv'}) &&
5729: ($env{'form.folderpath'} ne '') && (!$supplementalflag)) {
5730: my $folderurl;
5731: my @pathitems = split(/\&/,$env{'form.folderpath'});
1.617 raeburn 5732: my $folder = $pathitems[-2];
5733: if ($folder eq '') {
5734: undef($env{'form.folderpath'});
5735: } else {
5736: $folderurl = "uploaded/$coursedom/$coursenum/$folder";
1.666 raeburn 5737: if ((split(/\:/,$pathitems[-1]))[5]) {
1.615 raeburn 5738: $folderurl .= '.page';
5739: } else {
5740: $folderurl .= '.sequence';
5741: }
1.617 raeburn 5742: unless (ref($navmap)) {
5743: $navmap = Apache::lonnavmaps::navmap->new();
5744: }
1.615 raeburn 5745: if (ref($navmap)) {
5746: if (lc($navmap->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
1.617 raeburn 5747: my @resources = $navmap->retrieveResources($folderurl,$filterFunc,1,1);
5748: unless (@resources) {
5749: undef($env{'form.folderpath'});
5750: }
1.615 raeburn 5751: }
5752: }
5753: }
5754: }
5755:
5756:
1.446 www 5757: # If after all of this, we still don't have any paths, make them
1.519 raeburn 5758: unless ($env{'form.folderpath'}) {
1.446 www 5759: if ($supplementalflag) {
5760: $env{'form.folderpath'}=&supplemental_base();
1.617 raeburn 5761: } elsif ($allowed) {
5762: ($env{'form.folderpath'},$hiddentop) = &default_folderpath($coursenum,$coursedom,\$navmap);
1.446 www 5763: }
1.472 raeburn 5764: }
1.446 www 5765:
1.445 www 5766: # Store this
1.484 raeburn 5767: unless ($toolsflag) {
1.615 raeburn 5768: if (($allowed) && ($env{'form.folderpath'} ne '')) {
1.510 raeburn 5769: &Apache::loncommon::store_course_settings($stored_folderpath,
1.519 raeburn 5770: {'folderpath' => 'scalar'});
1.510 raeburn 5771: }
1.519 raeburn 5772: my $folderpath;
1.484 raeburn 5773: if ($env{'form.folderpath'}) {
1.519 raeburn 5774: $folderpath = $env{'form.folderpath'};
5775: my (@folders)=split('&',$env{'form.folderpath'});
5776: $env{'form.foldername'}=&unescape(pop(@folders));
5777: if ($env{'form.foldername'} =~ /\:1$/) {
5778: $container = 'page';
5779: } else {
5780: $container = 'sequence';
5781: }
5782: $env{'form.folder'}=pop(@folders);
1.484 raeburn 5783: } else {
1.519 raeburn 5784: if ($env{'form.folder'} eq '' ||
5785: $env{'form.folder'} eq 'supplemental') {
1.617 raeburn 5786: if ($env{'form.folder'} eq 'supplemental') {
5787: $folderpath=&supplemental_base();
5788: } elsif (!$hiddentop) {
5789: $folderpath='default&'.
5790: &escape(&mt('Main Content').':::::');
5791: }
1.484 raeburn 5792: }
5793: }
1.519 raeburn 5794: $containertag = '<input type="hidden" name="folderpath" value="" />';
5795: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 5796: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
5797: $showdoc='/'.$1;
5798: }
5799: if ($showdoc) { # got called in sequence from course
5800: $allowed=0;
5801: } else {
1.611 raeburn 5802: if ($canedit) {
1.484 raeburn 5803: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
5804: $script=&Apache::lonratedt::editscript('simple');
1.433 raeburn 5805: }
5806: }
1.329 droeschl 5807: }
5808:
1.344 bisitz 5809: # get personal data
1.329 droeschl 5810: my $uname=$env{'user.name'};
5811: my $udom=$env{'user.domain'};
5812: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
5813:
5814: if ($allowed) {
1.484 raeburn 5815: if ($toolsflag) {
5816: $script .= &inject_data_js();
5817: my ($home,$other,%outhash)=&authorhosts();
5818: if (!$home && $other) {
5819: my @hosts;
5820: foreach my $aurole (keys(%outhash)) {
5821: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
5822: push(@hosts,$outhash{$aurole});
5823: }
5824: }
5825: $script .= &dump_switchserver_js(@hosts);
5826: }
1.458 raeburn 5827: } else {
1.570 raeburn 5828: my $tid = 1;
1.484 raeburn 5829: my @tabids;
5830: if ($supplementalflag) {
1.655 raeburn 5831: @tabids = ('002','dd2','ee2','ff2');
1.570 raeburn 5832: $tid = 2;
1.484 raeburn 5833: } else {
5834: @tabids = ('aa1','bb1','cc1','ff1');
1.519 raeburn 5835: unless ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 5836: unshift(@tabids,'001');
5837: push(@tabids,('dd1','ee1'));
5838: }
1.458 raeburn 5839: }
1.484 raeburn 5840: my $tabidstr = join("','",@tabids);
1.644 raeburn 5841: %ltitools = &Apache::lonnet::get_domain_lti($coursedom,'consumer');
1.600 raeburn 5842: my $posslti = keys(%ltitools);
1.622 raeburn 5843: my $hostname = $r->hostname();
1.606 raeburn 5844: $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
1.622 raeburn 5845: $londocroot,$canedit,$hostname,\$navmap).
1.484 raeburn 5846: &history_tab_js().
5847: &inject_data_js().
1.570 raeburn 5848: &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
1.598 raeburn 5849: &Apache::lonextresedit::extedit_javascript(\%ltitools);
1.484 raeburn 5850: $addentries = {
1.485 raeburn 5851: onload => "javascript:resize_scrollbox('contentscroll','1','1');",
1.484 raeburn 5852: };
1.458 raeburn 5853: }
1.538 raeburn 5854: $script .= &paste_popup_js();
1.501 raeburn 5855: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
5856: &mt('Switch server?');
5857:
5858:
1.329 droeschl 5859: }
5860: # -------------------------------------------------------------------- Body tag
1.369 bisitz 5861: $script = '<script type="text/javascript">'."\n"
1.372 bisitz 5862: .'// <![CDATA['."\n"
5863: .$script."\n"
5864: .'// ]]>'."\n"
1.595 musolffc 5865: .'</script>'."\n"
5866: .'<script type="text/javascript"
5867: src="/res/adm/includes/file_upload.js"></script>'."\n";
1.385 bisitz 5868:
5869: # Breadcrumbs
5870: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.510 raeburn 5871:
5872: if ($showdoc) {
1.682 raeburn 5873: my $args;
5874: if ($supplementalflag) {
5875: my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$env{'form.title'},1);
5876: $args = {'bread_crumbs' => $brcrum};
5877: } else {
5878: $args = {'force_register' => $showdoc};
5879: }
5880: $r->print(&Apache::loncommon::start_page("$crstype documents",undef,$args));
1.571 raeburn 5881: } elsif ($toolsflag) {
1.611 raeburn 5882: my ($breadtext,$breadtitle);
1.617 raeburn 5883: $breadtext = "$crstype Editor";
1.611 raeburn 5884: if ($canedit) {
5885: $breadtitle = 'Editing '.$crstype.' Contents';
5886: } else {
5887: $breadtext .= ' (View-only mode)';
5888: $breadtitle = 'Viewing '.$crstype.' Contents';
5889: }
1.571 raeburn 5890: &Apache::lonhtmlcommon::add_breadcrumb({
1.611 raeburn 5891: href=>"/adm/coursedocs",text=>$breadtext});
1.571 raeburn 5892: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script)
5893: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5894: .&Apache::lonhtmlcommon::breadcrumbs(
1.611 raeburn 5895: $breadtitle)
1.571 raeburn 5896: );
1.510 raeburn 5897: } elsif ($r->uri eq '/adm/supplemental') {
1.682 raeburn 5898: unless ($env{'request.role.adv'}) {
5899: unless (&Apache::lonnet::has_unhidden_suppfiles($coursenum,$coursedom)) {
5900: $r->internal_redirect('/adm/navmaps');
5901: return OK;
5902: }
5903: }
1.510 raeburn 5904: my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
5905: $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
5906: {'bread_crumbs' => $brcrum,}));
5907: } else {
1.611 raeburn 5908: my ($breadtext,$breadtitle,$helpitem);
1.617 raeburn 5909: $breadtext = "$crstype Editor";
1.611 raeburn 5910: if ($canedit) {
5911: $breadtitle = 'Editing '.$crstype.' Contents';
5912: $helpitem = 'Docs_Adding_Course_Doc';
5913: } else {
5914: $breadtext .= ' (View-only mode)';
5915: $breadtitle = 'Viewing '.$crstype.' Contents';
5916: $helpitem = 'Docs_Viewing_Course_Doc';
5917: }
1.392 raeburn 5918: &Apache::lonhtmlcommon::add_breadcrumb({
1.611 raeburn 5919: href=>"/adm/coursedocs",text=>$breadtext});
1.446 www 5920: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.510 raeburn 5921: {'add_entries' => $addentries}
5922: )
1.392 raeburn 5923: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5924: .&Apache::lonhtmlcommon::breadcrumbs(
1.611 raeburn 5925: $breadtitle,
5926: $helpitem)
1.392 raeburn 5927: );
5928: }
1.364 bisitz 5929:
1.329 droeschl 5930: my %allfiles = ();
5931: my %codebase = ();
1.440 raeburn 5932: my ($upload_result,$upload_output,$uploadphase);
1.611 raeburn 5933: if ($canedit) {
1.684 ! raeburn 5934: undef($suppchanges);
1.329 droeschl 5935: if (($env{'form.uploaddoc.filename'}) &&
5936: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440 raeburn 5937: my $context = $1;
5938: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 5939: undef($hadchanges);
1.440 raeburn 5940: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
1.552 raeburn 5941: \%allfiles,\%codebase,$context,$crstype);
1.638 raeburn 5942: undef($navmap);
1.329 droeschl 5943: if ($hadchanges) {
5944: &mark_hash_old();
5945: }
1.684 ! raeburn 5946: if ($suppchanges) {
! 5947: &Apache::lonnet::update_supp_caches($coursedom,$coursenum);
! 5948: undef($suppchanges);
! 5949: }
1.440 raeburn 5950: $r->print($upload_output);
5951: } elsif ($env{'form.phase'} eq 'upload_embedded') {
5952: # Process file upload - phase two - upload embedded objects
5953: $uploadphase = 'check_embedded';
5954: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
5955: my $state = &embedded_form_elems($uploadphase,$primaryurl,
5956: $env{'form.newidx'});
5957: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5958: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5959: my ($destination,$dir_root) = &embedded_destination();
5960: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
5961: my $actionurl = '/adm/coursedocs';
1.630 raeburn 5962: my ($result,$flag) =
1.440 raeburn 5963: &Apache::loncommon::upload_embedded('coursedoc',$destination,
5964: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
5965: $actionurl);
5966: $r->print($result.&return_to_editor());
5967: } elsif ($env{'form.phase'} eq 'check_embedded') {
5968: # Process file upload - phase three - modify references in HTML file
5969: $uploadphase = 'modified_orightml';
5970: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5971: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5972: my ($destination,$dir_root) = &embedded_destination();
1.630 raeburn 5973: my $result =
1.482 raeburn 5974: &Apache::loncommon::modify_html_refs('coursedoc',$destination,
5975: $docuname,$docudom,undef,
5976: $dir_root);
1.630 raeburn 5977: $r->print($result.&return_to_editor());
1.476 raeburn 5978: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
5979: $uploadphase = 'decompress_phase_one';
5980: $r->print(&decompression_phase_one().
5981: &return_to_editor());
5982: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
5983: $uploadphase = 'decompress_phase_two';
5984: $r->print(&decompression_phase_two().
5985: &return_to_editor());
1.329 droeschl 5986: }
5987: }
5988:
1.484 raeburn 5989: if ($allowed && $toolsflag) {
5990: $r->print(&startContentScreen('tools'));
1.611 raeburn 5991: $r->print(&generate_admin_menu($crstype,$canedit));
1.484 raeburn 5992: $r->print(&endContentScreen());
5993: } elsif ((!$showdoc) && (!$uploadphase)) {
1.329 droeschl 5994: # -----------------------------------------------------------------------------
5995: my %lt=&Apache::lonlocal::texthash(
5996: 'copm' => 'All documents out of a published map into this folder',
1.501 raeburn 5997: 'upfi' => 'Upload File',
1.553 raeburn 5998: 'upld' => 'Upload Content',
1.329 droeschl 5999: 'srch' => 'Search',
6000: 'impo' => 'Import',
1.487 raeburn 6001: 'lnks' => 'Import from Stored Links',
1.502 raeburn 6002: 'impm' => 'Import from Assembled Map',
1.630 raeburn 6003: 'imcr' => 'Import from Course Resources',
1.598 raeburn 6004: 'extr' => 'External Resource',
6005: 'extt' => 'External Tool',
1.329 droeschl 6006: 'selm' => 'Select Map',
6007: 'load' => 'Load Map',
6008: 'newf' => 'New Folder',
6009: 'newp' => 'New Composite Page',
6010: 'syll' => 'Syllabus',
1.425 raeburn 6011: 'navc' => 'Table of Contents',
1.343 biermanm 6012: 'sipa' => 'Simple Course Page',
1.329 droeschl 6013: 'sipr' => 'Simple Problem',
1.630 raeburn 6014: 'webp' => 'Blank Web Page (editable)',
1.606 raeburn 6015: 'stpr' => 'Standard Problem',
6016: 'news' => 'New sub-directory',
6017: 'crpr' => 'Create Problem',
1.329 droeschl 6018: 'drbx' => 'Drop Box',
1.451 www 6019: 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336 schafran 6020: 'bull' => 'Discussion Board',
1.347 weissno 6021: 'mypi' => 'My Personal Information Page',
1.353 weissno 6022: 'grpo' => 'Group Portfolio',
1.329 droeschl 6023: 'rost' => 'Course Roster',
1.528 raeburn 6024: 'abou' => 'Personal Information Page for a User',
1.553 raeburn 6025: 'imsf' => 'IMS Upload',
6026: 'imsl' => 'Upload IMS package',
1.501 raeburn 6027: 'cms' => 'Origin of IMS package',
6028: 'se' => 'Select',
1.329 droeschl 6029: 'file' => 'File',
6030: 'title' => 'Title',
1.606 raeburn 6031: 'addp' => 'Add Placeholder to course?',
6032: 'uste' => 'Use Template?',
6033: 'fnam' => 'File Name:',
6034: 'loca' => 'Location:',
6035: 'dire' => 'Directory:',
6036: 'cate' => 'Category:',
6037: 'tmpl' => 'Template:',
1.329 droeschl 6038: 'comment' => 'Comment',
1.403 raeburn 6039: 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.577 bisitz 6040: 'bb5' => 'Blackboard 5',
6041: 'bb6' => 'Blackboard 6',
6042: 'angel5' => 'ANGEL 5.5',
6043: 'webctce4' => 'WebCT 4 Campus Edition',
1.606 raeburn 6044: 'yes' => 'Yes',
6045: 'no' => 'No',
1.618 raeburn 6046: 'er' => 'Editing rights unavailable for your current role.',
1.577 bisitz 6047: );
1.329 droeschl 6048: # -----------------------------------------------------------------------------
1.595 musolffc 6049:
6050: # Calculate free quota space for a user or course. A javascript function checks
6051: # file size to determine if upload should be allowed.
6052: my $quotatype = 'unofficial';
6053: if ($crstype eq 'Community') {
1.601 raeburn 6054: $quotatype = 'community';
6055: } elsif ($crstype eq 'Placement') {
6056: $quotatype = 'placement';
1.595 musolffc 6057: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
6058: $quotatype = 'official';
6059: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
6060: $quotatype = 'textbook';
6061: }
6062: my $disk_quota = &Apache::loncommon::get_user_quota($coursenum,$coursedom,
6063: 'course',$quotatype); # expressed in MB
6064: my $current_disk_usage = 0;
6065: foreach my $subdir ('docs','supplemental') {
6066: $current_disk_usage += &Apache::lonnet::diskusage($coursedom,$coursenum,
6067: "userfiles/$subdir",1); # expressed in kB
6068: }
6069: my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage);
1.605 raeburn 6070: my $usage = $current_disk_usage/1024; # in MB
6071: my $quota = $disk_quota;
6072: my $percent;
6073: if ($disk_quota == 0) {
6074: $percent = 100.0;
6075: } else {
1.619 raeburn 6076: $percent = 100*($usage/$disk_quota);
1.605 raeburn 6077: }
6078: $usage = sprintf("%.2f",$usage);
6079: $quota = sprintf("%.2f",$quota);
6080: $percent = sprintf("%.0f",$percent);
6081: my $quotainfo = '<p>'.&mt('Currently using [_1] of the [_2] available.',
6082: $percent.'%',$quota.' MB').'</p>';
1.595 musolffc 6083:
1.329 droeschl 6084: my $fileupload=(<<FIUP);
1.605 raeburn 6085: $quotainfo
1.329 droeschl 6086: $lt{'file'}:<br />
1.662 raeburn 6087: <input type="file" name="uploaddoc" class="LC_flUpload" size="40" $disabled />
1.663 raeburn 6088: <input type="hidden" id="LC_free_space" value="$free_space" />
1.329 droeschl 6089: FIUP
6090:
6091: my $checkbox=(<<CHBO);
6092: <!-- <label>$lt{'parse'}?
6093: <input type="checkbox" name="parserflag" />
6094: </label> -->
6095: <label>
1.611 raeburn 6096: <input type="checkbox" name="parserflag" checked="checked" $disabled /> $lt{'parse'}
1.329 droeschl 6097: </label>
6098: CHBO
1.501 raeburn 6099: my $imsfolder = $env{'form.folder'};
6100: if ($imsfolder eq '') {
6101: $imsfolder = 'default';
6102: }
6103: my $imspform=(<<IMSFORM);
6104: <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
6105: $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
6106: <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
1.516 raeburn 6107: <fieldset id="uploadimsform" style="display: none;">
1.501 raeburn 6108: <legend>$lt{'imsf'}</legend>
6109: $fileupload
6110: <br />
6111: <p>
6112: $lt{'cms'}:
1.611 raeburn 6113: <select name="source" $disabled>
1.501 raeburn 6114: <option value="-1" selected="selected">$lt{'se'}</option>
1.577 bisitz 6115: <option value="bb5">$lt{'bb5'}</option>
6116: <option value="bb6">$lt{'bb6'}</option>
6117: <option value="angel5">$lt{'angel5'}</option>
6118: <option value="webctce4">$lt{'webctce4'}</option>
1.501 raeburn 6119: </select>
6120: <input type="hidden" name="folder" value="$imsfolder" />
6121: </p>
6122: <input type="hidden" name="phase" value="one" />
1.611 raeburn 6123: <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" $disabled />
1.501 raeburn 6124: </fieldset>
6125: </form>
6126: IMSFORM
1.329 droeschl 6127:
6128: my $fileuploadform=(<<FUFORM);
1.501 raeburn 6129: <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
6130: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
6131: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.516 raeburn 6132: <fieldset id="uploaddocform" style="display: none;">
1.501 raeburn 6133: <legend>$lt{'upfi'}</legend>
1.371 tempelho 6134: <input type="hidden" name="active" value="aa" />
1.595 musolffc 6135: $fileupload
1.329 droeschl 6136: <br />
6137: $lt{'title'}:<br />
1.611 raeburn 6138: <input type="text" size="60" name="comment" $disabled />
1.508 raeburn 6139: $pathitem
1.329 droeschl 6140: <input type="hidden" name="cmd" value="upload_default" />
6141: <br />
1.458 raeburn 6142: <span class="LC_nobreak" style="float:left">
1.329 droeschl 6143: $checkbox
6144: </span>
1.501 raeburn 6145: <br clear="all" />
1.611 raeburn 6146: <input type="submit" value="$lt{'upld'}" $disabled />
1.501 raeburn 6147: </fieldset>
6148: </form>
1.383 tempelho 6149: FUFORM
1.329 droeschl 6150:
1.611 raeburn 6151: my $mapimportjs;
6152: if ($canedit) {
6153: $mapimportjs = "javascript:openbrowser('mapimportform','importmap','sequence,page','');";
6154: } else {
6155: $mapimportjs = "javascript:alert('".&js_escape($lt{'er'})."');";
6156: }
1.502 raeburn 6157: my $importpubform=(<<SEDFFORM);
1.514 raeburn 6158: <a class="LC_menubuttons_link" href="javascript:toggleMap('map');">
1.502 raeburn 6159: $lt{'impm'}</a>$help{'Load_Map'}
6160: <form action="/adm/coursedocs" method="post" name="mapimportform">
1.516 raeburn 6161: <fieldset id="importmapform" style="display: none;">
1.502 raeburn 6162: <legend>$lt{'impm'}</legend>
1.371 tempelho 6163: <input type="hidden" name="active" value="bb" />
1.502 raeburn 6164: $lt{'copm'}<br />
6165: <span class="LC_nobreak">
6166: <input type="text" name="importmap" size="40" value=""
1.611 raeburn 6167: onfocus="this.blur();$mapimportjs" $disabled />
6168: <a href="$mapimportjs">$lt{'selm'}</a></span><br />
6169: <input type="submit" name="loadmap" value="$lt{'load'}" $disabled />
1.502 raeburn 6170: </fieldset>
6171: </form>
6172:
1.383 tempelho 6173: SEDFFORM
1.606 raeburn 6174: my $importcrsresform;
1.608 raeburn 6175: my ($numdirs,$pickfile) =
6176: &Apache::loncommon::import_crsauthor_form('crsresimportform','coursepath','coursefile',
6177: "resize_scrollbox('contentscroll','1','0');",
6178: undef,'res');
1.606 raeburn 6179: if ($pickfile) {
6180: $importcrsresform=(<<CRSFORM);
6181: <a class="LC_menubuttons_link" href="javascript:toggleImportCrsres('res','$numdirs');">
6182: $lt{'imcr'}</a>$help{'Course_Resources'}
6183: <form action="/adm/coursedocs" method="post" name="crsresimportform" onsubmit="return validImportCrsRes();">
6184: <fieldset id="importcrsresform" style="display: none;">
6185: <legend>$lt{'imcr'}</legend>
6186: <input type="hidden" name="active" value="bb" />
6187: $pickfile
6188: <p>
1.611 raeburn 6189: $lt{'title'}: <input type="textbox" name="crsrestitle" value="" $disabled />
1.606 raeburn 6190: </p>
6191: <input type="hidden" name="importdetail" value="" />
1.611 raeburn 6192: <input type="submit" name="crsres" value="$lt{'impo'}" $disabled />
1.606 raeburn 6193: </fieldset>
6194: </form>
6195: CRSFORM
6196: }
6197:
1.611 raeburn 6198: my $fromstoredjs;
6199: if ($canedit) {
6200: $fromstoredjs = 'open_StoredLinks_Import()';
6201: } else {
6202: $fromstoredjs = "alert('".&js_escape($lt{'er'})."')";
6203: }
6204:
1.502 raeburn 6205: my @importpubforma = (
1.508 raeburn 6206: { '<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 6207: { '<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.611 raeburn 6208: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{lnks}.'" onclick="javascript:'.$fromstoredjs.';" />' => '<a class="LC_menubuttons_link" href="javascript:'.$fromstoredjs.';">'.$lt{'lnks'}.'</a>' },
1.606 raeburn 6209: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform },
6210: );
6211: if ($pickfile) {
6212: push(@importpubforma,{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{imcr}.'" onclick="javascript:toggleImportCrsres(\'res\','."'$numdirs'".');"/>' => $importcrsresform});
6213: }
1.502 raeburn 6214: $importpubform = &create_form_ul(&create_list_elements(@importpubforma));
1.510 raeburn 6215: my $extresourcesform =
6216: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
1.611 raeburn 6217: $help{'Adding_External_Resource'},
6218: undef,undef,undef,undef,undef,undef,$disabled);
1.598 raeburn 6219: my $exttoolform =
6220: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
6221: $help{'Adding_External_Tool'},undef,
6222: undef,'tool',$coursedom,$coursenum,
1.611 raeburn 6223: \%ltitools,$disabled);
1.329 droeschl 6224: if ($allowed) {
1.492 raeburn 6225: my $folder = $env{'form.folder'};
6226: if ($folder eq '') {
6227: $folder='default';
6228: }
1.615 raeburn 6229: if ($canedit) {
6230: my $output = &update_paste_buffer($coursenum,$coursedom,$folder);
6231: if ($output) {
6232: $r->print($output);
6233: }
1.538 raeburn 6234: }
1.337 ehlerst 6235: $r->print(<<HIDDENFORM);
6236: <form name="renameform" method="post" action="/adm/coursedocs">
6237: <input type="hidden" name="title" />
6238: <input type="hidden" name="cmd" />
6239: <input type="hidden" name="markcopy" />
6240: <input type="hidden" name="copyfolder" />
6241: $containertag
6242: </form>
1.633 raeburn 6243: <form name="aliasform" method="post" action="/adm/coursedocs">
6244: <input type="hidden" name="alias" />
6245: <input type="hidden" name="cmd" />
6246: $containertag
6247: </form>
1.484 raeburn 6248:
1.337 ehlerst 6249: HIDDENFORM
1.508 raeburn 6250: $r->print(&makesimpleeditform($pathitem)."\n".
6251: &makedocslogform($pathitem."\n".
1.484 raeburn 6252: '<input type="hidden" name="folder" value="'.
6253: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 6254: }
1.442 www 6255:
6256: # Generate the tabs
1.510 raeburn 6257: my ($mode,$needs_end);
1.472 raeburn 6258: if (($supplementalflag) && (!$allowed)) {
1.510 raeburn 6259: my @folders = split('&',$env{'form.folderpath'});
6260: unless (@folders > 2) {
6261: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
6262: $needs_end = 1;
6263: }
1.472 raeburn 6264: } else {
1.484 raeburn 6265: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.510 raeburn 6266: $needs_end = 1;
1.472 raeburn 6267: }
1.443 www 6268:
1.442 www 6269: #
1.622 raeburn 6270: my $hostname = $r->hostname();
1.442 www 6271: my $savefolderpath;
6272:
1.395 raeburn 6273: if ($allowed) {
1.329 droeschl 6274: my $folder=$env{'form.folder'};
1.615 raeburn 6275: if ((($folder eq '') && (!$hiddentop)) || ($supplementalflag)) {
1.329 droeschl 6276: $folder='default';
1.356 tempelho 6277: $savefolderpath = $env{'form.folderpath'};
1.548 raeburn 6278: $env{'form.folderpath'}='default&'.&escape(&mt('Main Content'));
1.508 raeburn 6279: $pathitem = '<input type="hidden" name="folderpath" value="'.
1.329 droeschl 6280: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
6281: }
6282: my $postexec='';
6283: if ($folder eq 'default') {
1.653 raeburn 6284: my $windowname = 'loncapaclient';
6285: if ($env{'request.lti.login'}) {
6286: $windowname .= 'lti';
6287: }
1.372 bisitz 6288: $r->print('<script type="text/javascript">'."\n"
6289: .'// <![CDATA['."\n"
1.653 raeburn 6290: .'this.window.name="'.$windowname.'";'."\n"
1.372 bisitz 6291: .'// ]]>'."\n"
6292: .'</script>'."\n"
1.369 bisitz 6293: );
1.329 droeschl 6294: } else {
6295: #$postexec='self.close();';
6296: }
1.504 raeburn 6297: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
6298: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
1.329 droeschl 6299: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
6300:
6301: my $newnavform=(<<NNFORM);
6302: <form action="/adm/coursedocs" method="post" name="newnav">
1.655 raeburn 6303: <input type="hidden" name="active" value="ff" />
1.508 raeburn 6304: $pathitem
1.329 droeschl 6305: <input type="hidden" name="importdetail"
6306: value="$lt{'navc'}=/adm/navmaps" />
1.611 raeburn 6307: <a class="LC_menubuttons_link" href="javascript:makenew(document.newnav);">$lt{'navc'}</a>
1.329 droeschl 6308: $help{'Navigate_Content'}
6309: </form>
6310: NNFORM
6311: my $newsmppageform=(<<NSPFORM);
6312: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.655 raeburn 6313: <input type="hidden" name="active" value="ff" />
1.508 raeburn 6314: $pathitem
1.329 droeschl 6315: <input type="hidden" name="importdetail" value="" />
1.423 onken 6316: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 6317: $help{'Simple Page'}
1.329 droeschl 6318: </form>
6319: NSPFORM
6320:
6321: my $newsmpproblemform=(<<NSPROBFORM);
6322: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.655 raeburn 6323: <input type="hidden" name="active" value="dd" />
1.508 raeburn 6324: $pathitem
1.329 droeschl 6325: <input type="hidden" name="importdetail" value="" />
1.423 onken 6326: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.572 raeburn 6327: $help{'Simple_Problem'}
1.329 droeschl 6328: </form>
6329:
6330: NSPROBFORM
6331:
6332: my $newdropboxform=(<<NDBFORM);
6333: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.655 raeburn 6334: <input type="hidden" name="active" value="dd" />
1.508 raeburn 6335: $pathitem
1.329 droeschl 6336: <input type="hidden" name="importdetail" value="" />
1.423 onken 6337: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.554 raeburn 6338: $help{'Dropbox'}
1.344 bisitz 6339: </form>
1.329 droeschl 6340: NDBFORM
6341:
6342: my $newexuploadform=(<<NEXUFORM);
6343: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.655 raeburn 6344: <input type="hidden" name="active" value="dd" />
1.508 raeburn 6345: $pathitem
1.329 droeschl 6346: <input type="hidden" name="importdetail" value="" />
1.423 onken 6347: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 6348: $help{'Score_Upload_Form'}
6349: </form>
6350: NEXUFORM
6351:
6352: my $newbulform=(<<NBFORM);
6353: <form action="/adm/coursedocs" method="post" name="newbul">
1.655 raeburn 6354: <input type="hidden" name="active" value="ee" />
1.508 raeburn 6355: $pathitem
1.329 droeschl 6356: <input type="hidden" name="importdetail" value="" />
1.423 onken 6357: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 6358: $help{'Bulletin Board'}
6359: </form>
6360: NBFORM
6361:
6362: my $newaboutmeform=(<<NAMFORM);
6363: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.655 raeburn 6364: <input type="hidden" name="active" value="ee" />
1.508 raeburn 6365: $pathitem
1.329 droeschl 6366: <input type="hidden" name="importdetail"
6367: value="$plainname=/adm/$udom/$uname/aboutme" />
1.611 raeburn 6368: <a class="LC_menubuttons_link" href="javascript:makenew(document.newaboutme);">$lt{'mypi'}</a>
1.347 weissno 6369: $help{'My Personal Information Page'}
1.329 droeschl 6370: </form>
6371: NAMFORM
6372:
6373: my $newaboutsomeoneform=(<<NASOFORM);
6374: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.655 raeburn 6375: <input type="hidden" name="active" value="ee" />
1.508 raeburn 6376: $pathitem
1.329 droeschl 6377: <input type="hidden" name="importdetail" value="" />
1.423 onken 6378: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 6379: </form>
6380: NASOFORM
6381:
6382: my $newrosterform=(<<NROSTFORM);
6383: <form action="/adm/coursedocs" method="post" name="newroster">
1.655 raeburn 6384: <input type="hidden" name="active" value="ee" />
1.508 raeburn 6385: $pathitem
1.329 droeschl 6386: <input type="hidden" name="importdetail"
6387: value="$lt{'rost'}=/adm/viewclasslist" />
1.611 raeburn 6388: <a class="LC_menubuttons_link" href="javascript:makenew(document.newroster);">$lt{'rost'}</a>
1.556 raeburn 6389: $help{'Course_Roster'}
1.329 droeschl 6390: </form>
6391: NROSTFORM
6392:
1.534 raeburn 6393: my $newwebpage;
6394: if ($folder =~ /^default_?(\d*)$/) {
6395: $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
6396: if ($1) {
6397: $newwebpage .= $1;
6398: } else {
6399: $newwebpage .= 'default';
6400: }
6401: $newwebpage .= '/new.html';
6402: }
6403: my $newwebpageform =(<<NWEBFORM);
6404: <form action="/adm/coursedocs" method="post" name="newwebpage">
1.655 raeburn 6405: <input type="hidden" name="active" value="ff" />
1.534 raeburn 6406: $pathitem
6407: <input type="hidden" name="importdetail" value="$newwebpage" />
6408: <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
1.556 raeburn 6409: $help{'Web_Page'}
1.534 raeburn 6410: </form>
6411: NWEBFORM
1.604 raeburn 6412:
1.606 raeburn 6413: my @ids=&Apache::lonnet::current_machine_ids();
6414: my %select_menus;
6415: my $numauthor = 0;
6416: my $numcrsdirs = 0;
6417: my $toppath = "/priv/$env{'user.domain'}/$env{'user.name'}";
6418: if ($env{'user.author'}) {
6419: $numauthor ++;
6420: $select_menus{'author'}->{'text'} = &Apache::lonnet::plaintext('au');
6421: if (grep(/^\Q$env{'user.home'}\E$/,@ids)) {
6422: my $is_home = 1;
6423: my %subdirs;
1.608 raeburn 6424: &Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs);
1.606 raeburn 6425: $select_menus{'author'}->{'default'} = '/';
6426: $select_menus{'author'}->{'select2'}->{'/'} = '/';
6427: my @ordered = ('/');
6428: foreach my $relpath (sort { lc($a) cmp lc($b) } (keys(%subdirs))) {
6429: $select_menus{'author'}->{'select2'}->{$relpath} = $relpath;
6430: push(@ordered,$relpath);
6431: }
6432: $select_menus{'author'}->{'order'} = \@ordered;
6433: } else {
6434: $select_menus{'author'}->{'select2'}->{'switch'} = &mt('Switch server required');
6435: $select_menus{'author'}->{'default'} = 'switch';
6436: $select_menus{'author'}->{'order'} = ['switch'];
6437: }
6438: }
6439: my %roleshash = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles',
6440: ['active'],['ca','aa']);
6441: my $crshome = $env{'course.'.$env{'request.course.id'}.'.home'};
6442: my %by_roletype;
6443: if (keys(%roleshash)) {
6444: foreach my $entry (keys(%roleshash)) {
6445: my ($auname,$audom,$roletype) = split(/:/,$entry);
6446: my $key = $entry;
6447: $key =~ s/:/___/g;
6448: $by_roletype{$roletype}{$auname.'___'.$audom} = 1;
6449: $select_menus{$key}->{'text'} = &Apache::lonnet::plaintext($roletype)." ($audom/$auname)";
6450: my $rolehome = &Apache::lonnet::homeserver($auname,$audom);
6451: if (grep(/^\Q$rolehome\E$/,@ids)) {
6452: my $is_home = 1;
6453: my (%subdirs,@ordered);
6454: my $toppath="/priv/$audom/$auname";
1.608 raeburn 6455: &Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs);
1.606 raeburn 6456: $select_menus{$key}->{'default'} = '/';
6457: $select_menus{$key}->{'select2'}->{'/'} = '/';
6458: my @ordered = ('/');
6459: foreach my $relpath (sort { lc($a) cmp lc($b) } (keys(%subdirs))) {
6460: $select_menus{$key}->{'select2'}->{$relpath} = $relpath;
6461: push(@ordered,$relpath);
6462: }
6463: $select_menus{$key}->{'order'} = \@ordered;
6464: } else {
6465: $select_menus{$key}->{'select2'}->{'switch'} = &mt('Switch server required');
6466: $select_menus{$key}->{'default'} = 'switch';
6467: $select_menus{$key}->{'order'} = ['switch'];
6468: }
6469: $numauthor ++;
6470: }
6471: }
1.631 raeburn 6472: my ($pickdir,$showtitle);
1.606 raeburn 6473: if ($numauthor) {
6474: my @order;
6475: my $defrole;
6476: if ($env{'user.author'}) {
6477: push(@order,'author');
6478: $defrole = 'author';
6479: }
6480: if (keys(%by_roletype)) {
6481: foreach my $possrole ('ca','aa') {
6482: if (ref($by_roletype{$possrole}) eq 'HASH') {
6483: foreach my $author (sort { lc($a) cmp lc($b) } (keys(%{$by_roletype{$possrole}}))) {
6484: unless ($defrole) {
6485: $defrole = $author;
6486: }
6487: push(@order,$author.'___'.$possrole);
6488: }
6489: }
6490: }
6491: }
6492: $select_menus{'course'}->{'text'} = &mt('Course Resource');
6493: if (grep(/^\Q$crshome\E$/,@ids)) {
6494: my $is_home = 1;
6495: my %subdirs;
6496: my $toppath="/priv/$coursedom/$coursenum";
1.608 raeburn 6497: &Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs);
1.606 raeburn 6498: $numcrsdirs = keys(%subdirs);
6499: $select_menus{'course'}->{'default'} = '/';
6500: $select_menus{'course'}->{'select2'}->{'/'} = '/';
6501: my @ordered = ('/');
6502: foreach my $relpath (sort { lc($a) cmp lc($b) } (keys(%subdirs))) {
6503: $select_menus{'course'}->{'select2'}->{$relpath} = $relpath;
6504: push(@ordered,$relpath);
6505: }
6506: $select_menus{'course'}->{'order'} = \@ordered;
6507: } else {
6508: $select_menus{'course'}->{'select2'}->{'switch'} = &mt('Switch server required');
6509: $select_menus{'course'}->{'default'} = 'switch';
6510: $select_menus{'course'}->{'order'} = ['switch'];
6511: }
6512: push(@order,'course');
6513: $pickdir = $lt{'loca'}.
6514: &Apache::loncommon::linked_select_forms('courseresform','<br />'.$lt{'dire'},
6515: $defrole,'authorrole','authorpath',
6516: \%select_menus,\@order,'toggleCrsResTitle();',
6517: '','priv').'<br />';
6518: $showtitle = 'none';
6519: } else {
6520: my $is_home;
6521: $showtitle = 'inline';
6522: if (grep(/^\Q$crshome\E$/,@ids)) {
6523: $is_home = 1;
6524: $pickdir .= '<input type="hidden" name="authorrole" value="course" />';
6525: my $toppath="/priv/$coursedom/$coursenum'}";
6526: my %subdirs;
1.608 raeburn 6527: &Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs);
1.606 raeburn 6528: $numcrsdirs = keys(%subdirs);
6529: if ($numcrsdirs) {
6530: $pickdir .= &mt('Directory: ').'<select name="authorpath">'."\n".
6531: '<option value="/">/</option>'."\n";
6532: foreach my $key (sort { lc($a) cmp lc($b) } (keys(%subdirs))) {
1.608 raeburn 6533: $pickdir .= '<option value="'.$key.'">'.$key.'</option>'."\n";
1.606 raeburn 6534: }
6535: $pickdir .= '</select>';
6536: } else {
6537: $pickdir .= '<input type="hidden" name="authorpath" value="/" />'."\n";
6538: }
6539: }
6540: }
6541:
6542: my %seltemplate_menus;
6543: my @files = &Apache::lonhomework::get_template_list('problem');
6544: my @noexamplelink = ('blank.problem','blank.library','script.library');
6545: my $currentcategory = '';
6546: my @ordered = ('');
6547: my %templatehelp;
6548: my $defcategory = '';
6549: my @catorder = ($defcategory);
6550: $seltemplate_menus{$defcategory}->{'order'} = [''];
6551: $seltemplate_menus{$defcategory}->{'text'} = '';
6552: foreach my $file (@files) {
6553: if (ref($file) eq 'ARRAY') {
6554: my ($path,$title,$category,$help) = @{$file};
6555: next if ($title !~ /\S/);
6556: if (&js_escape($category) ne $currentcategory) {
6557: $currentcategory = &js_escape($category);
6558: push(@catorder,&js_escape($currentcategory));
6559: $seltemplate_menus{$currentcategory}->{'text'} = $category;
6560: $seltemplate_menus{$currentcategory}->{'default'} = '';
6561: $seltemplate_menus{$currentcategory}->{'select2'}->{''} = '';
6562: push(@{$seltemplate_menus{$currentcategory}->{'order'}},'');
6563: }
6564: if ($path) {
6565: $seltemplate_menus{$currentcategory}->{'select2'}->{&js_escape($path)} = $title;
6566: push(@{$seltemplate_menus{$currentcategory}->{'order'}},&js_escape($path));
6567: if ($help) {
6568: $templatehelp{$path} = $help;
6569: }
6570: }
6571: }
6572: }
6573:
6574: my $templates = $lt{'cate'}.' '.
6575: &Apache::loncommon::linked_select_forms('courseresform','<br />'.$lt{'tmpl'}.' ',
6576: $defcategory,'tempcategory','template',
6577: \%seltemplate_menus,\@catorder,
6578: "resize_scrollbox('contentscroll','1','0');",
6579: "toggleExampleText();",'template').'<br />';
6580: my $templatepreview = '<a href="#" target="sample" onclick="javascript:getExample(600,420,\'yes\',true); return false;">'.
6581: '<span id="newresexample">'.&mt('Example').'<span></a>';
6582: my $crsresform=(<<RESFORM);
6583: <a class="LC_menubuttons_link" href="javascript:toggleCrsRes('res','$numauthor','$numcrsdirs');">
6584: $lt{'stpr'}</a>$help{'Course_Resource'}
6585: <form action="/adm/coursedocs" method="post" name="courseresform">
6586: <fieldset id="crsresform" style="display:none;">
6587: <legend>$lt{'stpr'}</legend>
1.655 raeburn 6588: <input type="hidden" name="active" value="bb" />
1.606 raeburn 6589: <p>
6590: $pickdir
6591: <span class="LC_nobreak">$lt{'news'}?
1.611 raeburn 6592: <label><input type="radio" name="newsubdir" value="0" onclick="toggleNewsubdir(this.form);" checked="checked" $disabled />No</label>
1.606 raeburn 6593:
1.611 raeburn 6594: <label><input type="radio" name="newsubdir" value="1" onclick="toggleNewsubdir(this.form);" $disabled />Yes</label>
1.606 raeburn 6595: </span><span id="newsubdir"></span>
6596: <input type="hidden" name="newsubdirname" id="newsubdirname" value="" autocomplete="off" />
6597: </p>
6598: $lt{'fnam'}
1.611 raeburn 6599: <input type="text" size="20" name="newresourcename" autocomplete="off" $disabled />
1.606 raeburn 6600: <p>
6601: <div id="newresource" style="display:$showtitle">
6602: $lt{'addp'}
1.611 raeburn 6603: <label><input type="radio" name="newresourceadd" value="0" checked="checked" onclick="toggleNewInCourse(this.form);" $disabled />
1.606 raeburn 6604: $lt{'no'}</label>
1.611 raeburn 6605: <label><input type="radio" name="newresourceadd" value="1" onclick="toggleNewInCourse(this.form);" $disabled />
1.606 raeburn 6606: $lt{'yes'}</label>
6607: <span id="newrestitle"></span>
1.611 raeburn 6608: <input type="hidden" size="20" name="newresourcetitle" id="newresourcetitle" autocomplete="off" $disabled />
1.606 raeburn 6609: </div>
6610: </p>
6611: <p>
6612: $lt{'uste'}
1.611 raeburn 6613: <label><input type="radio" name="newresusetemp" value="0" checked="checked" onclick="toggleWithTemplate(this.form);" $disabled />
1.606 raeburn 6614: $lt{'no'}</label>
1.611 raeburn 6615: <label><input type="radio" name="newresusetemp" value="1" onclick="toggleWithTemplate(this.form);" $disabled />
1.606 raeburn 6616: $lt{'yes'}</label>
6617: <div id="newrestemplate" style="display:none">
6618: $templates
6619: $templatepreview
6620: </div>
6621: </p>
6622: <span class="LC_nobreak">
6623: <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
1.611 raeburn 6624: <input type="submit" name="newcrs" value="$lt{'crpr'}" $disabled />
1.606 raeburn 6625: </span>
6626: </fieldset>
6627: </form>
6628:
6629: RESFORM
1.534 raeburn 6630:
1.342 ehlerst 6631: my $specialdocumentsform;
1.383 tempelho 6632: my @specialdocumentsforma;
1.451 www 6633: my $gradingform;
6634: my @gradingforma;
6635: my $communityform;
6636: my @communityforma;
1.351 ehlerst 6637: my $newfolderform;
1.390 tempelho 6638: my $newfolderb;
1.342 ehlerst 6639:
1.451 www 6640: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 6641:
1.329 droeschl 6642: my $newpageform=(<<NPFORM);
6643: <form action="/adm/coursedocs" method="post" name="newpage">
6644: <input type="hidden" name="folderpath" value="$path" />
6645: <input type="hidden" name="importdetail" value="" />
1.570 raeburn 6646: <input type="hidden" name="active" value="ee" />
1.423 onken 6647: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 6648: $help{'Adding_Pages'}
1.329 droeschl 6649: </form>
6650: NPFORM
1.390 tempelho 6651:
6652:
1.351 ehlerst 6653: $newfolderform=(<<NFFORM);
1.329 droeschl 6654: <form action="/adm/coursedocs" method="post" name="newfolder">
1.508 raeburn 6655: $pathitem
1.329 droeschl 6656: <input type="hidden" name="importdetail" value="" />
1.570 raeburn 6657: <input type="hidden" name="active" value="" />
1.422 onken 6658: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 6659: </form>
6660: NFFORM
6661:
6662: my $newsylform=(<<NSYLFORM);
6663: <form action="/adm/coursedocs" method="post" name="newsyl">
1.570 raeburn 6664: <input type="hidden" name="active" value="ee" />
1.508 raeburn 6665: $pathitem
1.329 droeschl 6666: <input type="hidden" name="importdetail"
6667: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.611 raeburn 6668: <a class="LC_menubuttons_link" href="javascript:makenew(document.newsyl);">$lt{'syll'}</a>
1.329 droeschl 6669: $help{'Syllabus'}
1.383 tempelho 6670:
1.329 droeschl 6671: </form>
6672: NSYLFORM
1.364 bisitz 6673:
1.329 droeschl 6674: my $newgroupfileform=(<<NGFFORM);
6675: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.655 raeburn 6676: <input type="hidden" name="active" value="ee" />
1.508 raeburn 6677: $pathitem
1.329 droeschl 6678: <input type="hidden" name="importdetail"
6679: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.611 raeburn 6680: <a class="LC_menubuttons_link" href="javascript:makenew(document.newgroupfiles);">$lt{'grpo'}</a>
1.353 weissno 6681: $help{'Group Portfolio'}
1.329 droeschl 6682: </form>
6683: NGFFORM
1.672 raeburn 6684: if ($container eq 'page') {
6685: @specialdocumentsforma=(
6686: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
6687: );
6688: } else {
6689: @specialdocumentsforma=(
1.421 onken 6690: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/page.png" alt="'.$lt{newp}.'" onclick="javascript:makenewpage(document.newpage,\''.$pageseq.'\');" />'=>$newpageform},
1.618 raeburn 6691: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.newsyl);" />'=>$newsylform},
1.611 raeburn 6692: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="javascript:makenew(document.newnav);" />'=>$newnavform},
1.451 www 6693: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
1.534 raeburn 6694: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
1.672 raeburn 6695: );
6696: }
1.451 www 6697: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
6698:
1.655 raeburn 6699: my @external = (
6700: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleExternal(\'ext\');" />'=>$extresourcesform}
1.519 raeburn 6701: );
1.598 raeburn 6702: if (keys(%ltitools)) {
1.655 raeburn 6703: push(@external,
6704: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="toggleExternal(\'tool\');" />'=>$exttoolform},
6705: );
1.598 raeburn 6706: }
1.655 raeburn 6707: my $externalform = &create_form_ul(&create_list_elements(@external));
6708:
6709: my @importdoc = ();
1.519 raeburn 6710: unless ($container eq 'page') {
6711: push(@importdoc,
6712: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform}
6713: );
6714: }
6715: push(@importdoc,
1.558 raeburn 6716: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'doc\');" />'=>$fileuploadform}
1.519 raeburn 6717: );
1.501 raeburn 6718: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
1.434 raeburn 6719:
1.451 www 6720: @gradingforma=(
6721: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
6722: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
6723: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
1.606 raeburn 6724: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{stpr}.'" onclick="javascript:toggleCrsRes(\'res\','."'$numauthor','$numcrsdirs'".');" />'=>$crsresform},
1.451 www 6725: );
6726: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
6727:
6728: @communityforma=(
6729: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
6730: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
6731: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
1.611 raeburn 6732: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="javascript:makenew(document.newroster);" />'=>$newrosterform},
6733: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="javascript:makenew(document.newgroupfiles);" />'=>$newgroupfileform},
1.451 www 6734: );
6735: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 6736:
1.330 tempelho 6737: my %orderhash = (
1.553 raeburn 6738: 'aa' => ['Upload',$fileuploadform],
6739: 'bb' => ['Import',$importpubform],
1.655 raeburn 6740: 'cc' => ['External',$externalform],
6741: 'dd' => ['Grading',$gradingform],
1.673 raeburn 6742: 'ff' => ['Other',$specialdocumentsform],
1.330 tempelho 6743: );
1.519 raeburn 6744: unless ($container eq 'page') {
1.434 raeburn 6745: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.655 raeburn 6746: $orderhash{'ee'} = ['Collaboration',$communityform];
1.434 raeburn 6747: }
6748:
1.341 ehlerst 6749: $hadchanges=0;
1.484 raeburn 6750: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 6751: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.615 raeburn 6752: $supplementalflag,\%orderhash,$iconpath,$pathitem,
1.622 raeburn 6753: \%ltitools,$canedit,$hostname,\$navmap,$hiddentop);
1.617 raeburn 6754: undef($navmap);
1.443 www 6755: if ($error) {
6756: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
6757: }
1.639 raeburn 6758: if ($hadchanges) {
6759: unless (&is_hash_old()) {
1.638 raeburn 6760: &mark_hash_old();
6761: }
6762: }
1.341 ehlerst 6763:
1.443 www 6764: &changewarning($r,'');
6765: }
1.458 raeburn 6766: }
1.442 www 6767:
1.443 www 6768: # Supplemental documents start here
6769:
1.329 droeschl 6770: my $folder=$env{'form.folder'};
1.443 www 6771: unless ($supplementalflag) {
1.329 droeschl 6772: $folder='supplemental';
6773: }
6774: if ($folder =~ /^supplemental$/ &&
6775: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 6776: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 6777: } elsif ($allowed) {
1.356 tempelho 6778: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 6779: }
1.508 raeburn 6780: $pathitem = '<input type="hidden" name="folderpath" value="'.
6781: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.329 droeschl 6782: if ($allowed) {
6783: my $folderseq=
1.504 raeburn 6784: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
1.329 droeschl 6785:
6786: my $supupdocform=(<<SUPDOCFORM);
1.501 raeburn 6787: <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
6788: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
1.383 tempelho 6789: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.516 raeburn 6790: <fieldset id="uploadsuppdocform" style="display: none;">
1.501 raeburn 6791: <legend>$lt{'upfi'}</legend>
1.630 raeburn 6792: <input type="hidden" name="active" value="ee" />
1.329 droeschl 6793: $fileupload
6794: <br />
6795: <br />
6796: <span class="LC_nobreak">
6797: $checkbox
6798: </span>
6799: <br /><br />
6800: $lt{'comment'}:<br />
1.383 tempelho 6801: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 6802: <br />
1.508 raeburn 6803: $pathitem
1.329 droeschl 6804: <input type="hidden" name="cmd" value="upload_supplemental" />
1.501 raeburn 6805: <input type='submit' value="$lt{'upld'}" />
6806: </form>
1.329 droeschl 6807: SUPDOCFORM
6808:
6809: my $supnewfolderform=(<<SNFFORM);
6810: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.570 raeburn 6811: <input type="hidden" name="active" value="" />
1.508 raeburn 6812: $pathitem
1.329 droeschl 6813: <input type="hidden" name="importdetail" value="" />
1.423 onken 6814: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 6815: $help{'Adding_Folders'}
1.329 droeschl 6816: </form>
6817: SNFFORM
1.383 tempelho 6818:
1.510 raeburn 6819: my $supextform =
6820: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
1.611 raeburn 6821: $help{'Adding_External_Resource'},
6822: undef,undef,undef,undef,undef,undef,
6823: $disabled);
1.329 droeschl 6824:
1.598 raeburn 6825: my $supexttoolform =
6826: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
6827: $help{'Adding_External_Tool'},
6828: undef,undef,'tool',$coursedom,
1.611 raeburn 6829: $coursenum,\%ltitools,$disabled);
1.598 raeburn 6830:
1.329 droeschl 6831: my $supnewsylform=(<<SNSFORM);
6832: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 6833: <input type="hidden" name="active" value="ff" />
1.508 raeburn 6834: $pathitem
1.329 droeschl 6835: <input type="hidden" name="importdetail"
6836: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.611 raeburn 6837: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewsyl);">$lt{'syll'}</a>
1.329 droeschl 6838: $help{'Syllabus'}
6839: </form>
6840: SNSFORM
6841:
6842: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 6843: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 6844: <input type="hidden" name="active" value="ff" />
1.508 raeburn 6845: $pathitem
1.329 droeschl 6846: <input type="hidden" name="importdetail"
6847: value="$plainname=/adm/$udom/$uname/aboutme" />
1.611 raeburn 6848: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewaboutme);">$lt{'mypi'}</a>
1.347 weissno 6849: $help{'My Personal Information Page'}
1.329 droeschl 6850: </form>
6851: SNAMFORM
6852:
1.534 raeburn 6853: my $supwebpage;
6854: if ($folder =~ /^supplemental_?(\d*)$/) {
6855: $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
6856: if ($1) {
6857: $supwebpage .= $1;
6858: } else {
6859: $supwebpage .= 'default';
6860: }
6861: $supwebpage .= '/new.html';
6862: }
6863: my $supwebpageform =(<<SWEBFORM);
6864: <form action="/adm/coursedocs" method="post" name="supwebpage">
6865: <input type="hidden" name="active" value="cc" />
6866: $pathitem
6867: <input type="hidden" name="importdetail" value="$supwebpage" />
6868: <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
1.556 raeburn 6869: $help{'Web_Page'}
1.534 raeburn 6870: </form>
6871: SWEBFORM
6872:
1.333 muellerd 6873:
1.383 tempelho 6874: my @specialdocs = (
1.618 raeburn 6875: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.supnewsyl);" />'
1.417 droeschl 6876: =>$supnewsylform},
1.611 raeburn 6877: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makenew(document.supnewaboutme);" />'
1.417 droeschl 6878: =>$supnewaboutmeform},
1.534 raeburn 6879: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
6880:
1.383 tempelho 6881: );
1.655 raeburn 6882: my @supexternal = (
6883: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleExternal(\'suppext\')" />'
6884: =>$supextform});
1.598 raeburn 6885: if (keys(%ltitools)) {
1.655 raeburn 6886: push(@supexternal,
6887: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="javascript:toggleExternal(\'supptool\')" />'
1.598 raeburn 6888: =>$supexttoolform});
6889: }
1.655 raeburn 6890: my @supimportdoc = (
1.598 raeburn 6891: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
1.501 raeburn 6892: =>$supupdocform},
1.598 raeburn 6893: );
1.501 raeburn 6894:
6895: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
1.333 muellerd 6896: my %suporderhash = (
1.390 tempelho 6897: '00' => ['Supnewfolder', $supnewfolderform],
1.655 raeburn 6898: 'dd' => ['Upload',$supupdocform],
6899: 'ee' => ['External',&create_form_ul(&create_list_elements(@supexternal))],
1.553 raeburn 6900: 'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 6901: );
1.443 www 6902: if ($supplementalflag) {
1.682 raeburn 6903: $suppchanges = 0;
6904: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
6905: $supplementalflag,\%suporderhash,$iconpath,$pathitem,
6906: \%ltitools,$canedit,$hostname);
6907: if ($error) {
6908: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
6909: }
6910: if ($suppchanges) {
1.684 ! raeburn 6911: &Apache::lonnet::update_supp_caches($coursedom,$coursenum);
1.682 raeburn 6912: undef($suppchanges);
6913: }
1.393 raeburn 6914: }
1.443 www 6915: } elsif ($supplementalflag) {
1.458 raeburn 6916: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.682 raeburn 6917: $supplementalflag,'',$iconpath,$pathitem,'',$canedit,
6918: $hostname);
1.393 raeburn 6919: if ($error) {
6920: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 6921: }
1.393 raeburn 6922: }
1.389 tempelho 6923:
1.510 raeburn 6924: if ($needs_end) {
6925: $r->print(&endContentScreen());
6926: }
1.383 tempelho 6927:
1.329 droeschl 6928: if ($allowed) {
6929: $r->print('
6930: <form method="post" name="extimport" action="/adm/coursedocs">
6931: <input type="hidden" name="title" />
6932: <input type="hidden" name="url" />
6933: <input type="hidden" name="useform" />
6934: <input type="hidden" name="residx" />
6935: </form>');
6936: }
1.484 raeburn 6937: } elsif ($showdoc) {
1.329 droeschl 6938: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 6939: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.498 bisitz 6940: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 6941: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 6942: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 6943: }
6944: }
1.630 raeburn 6945: unless ($noendpage) {
1.606 raeburn 6946: $r->print(&Apache::loncommon::end_page());
6947: }
1.329 droeschl 6948: return OK;
1.364 bisitz 6949: }
1.329 droeschl 6950:
1.440 raeburn 6951: sub embedded_form_elems {
6952: my ($phase,$primaryurl,$newidx) = @_;
6953: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.634 raeburn 6954: $newidx =~s /\D+//g;
1.440 raeburn 6955: return <<STATE;
6956: <input type="hidden" name="folderpath" value="$folderpath" />
6957: <input type="hidden" name="cmd" value="upload_embedded" />
6958: <input type="hidden" name="newidx" value="$newidx" />
6959: <input type="hidden" name="phase" value="$phase" />
6960: <input type="hidden" name="primaryurl" value="$primaryurl" />
6961: STATE
6962: }
6963:
6964: sub embedded_destination {
6965: my $folder=$env{'form.folder'};
6966: my $destination = 'docs/';
6967: if ($folder =~ /^supplemental/) {
6968: $destination = 'supplemental/';
6969: }
6970: if (($folder eq 'default') || ($folder eq 'supplemental')) {
6971: $destination .= 'default/';
6972: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
6973: $destination .= $2.'/';
6974: }
1.634 raeburn 6975: my $newidx = $env{'form.newidx'};
6976: $newidx =~s /\D+//g;
6977: if ($newidx) {
6978: $destination .= $newidx;
6979: }
1.440 raeburn 6980: my $dir_root = '/userfiles';
6981: return ($destination,$dir_root);
6982: }
6983:
6984: sub return_to_editor {
6985: my $actionurl = '/adm/coursedocs';
6986: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
6987: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
6988: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
6989: '</a></p>';
6990: }
6991:
1.476 raeburn 6992: sub decompression_info {
6993: my ($destination,$dir_root) = &embedded_destination();
6994: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
6995: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
6996: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
6997: my $container='sequence';
1.480 raeburn 6998: my ($pathitem,$hiddenelem);
1.583 raeburn 6999: my @hiddens = ('newidx','comment','position','folderpath','archiveurl');
1.519 raeburn 7000: if ($env{'form.folderpath'} =~ /\:1$/) {
1.476 raeburn 7001: $container='page';
7002: }
1.480 raeburn 7003: unshift(@hiddens,$pathitem);
7004: foreach my $item (@hiddens) {
1.634 raeburn 7005: if ($item eq 'newidx') {
7006: next if ($env{'form.'.$item} =~ /\D/);
7007: }
1.480 raeburn 7008: if ($env{'form.'.$item}) {
7009: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
1.583 raeburn 7010: &HTML::Entities::encode($env{'form.'.$item},'<>&"').'" />'."\n";
1.480 raeburn 7011: }
1.477 raeburn 7012: }
1.476 raeburn 7013: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
7014: $hiddenelem);
7015: }
7016:
7017: sub decompression_phase_one {
7018: my ($dir,$file,$warning,$error,$output);
7019: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
7020: &decompression_info();
1.490 raeburn 7021: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 7022: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
7023: } else {
7024: my $file = $1;
1.630 raeburn 7025: $output =
1.481 raeburn 7026: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
7027: $destination,$dir_root,
7028: $hiddenelem);
7029: if ($env{'form.autoextract_camtasia'}) {
7030: $output .= &remove_archive($docudom,$docuname,$container);
7031: }
1.476 raeburn 7032: }
7033: if ($error) {
7034: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
7035: $error.'</p>'."\n";
7036: }
7037: if ($warning) {
7038: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
7039: }
7040: return $output;
7041: }
7042:
7043: sub decompression_phase_two {
7044: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
7045: &decompression_info();
1.481 raeburn 7046: my $output;
1.480 raeburn 7047: if ($env{'form.archivedelete'}) {
1.481 raeburn 7048: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 7049: }
7050: $output .=
1.481 raeburn 7051: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 7052: $destination,$dir_root,$hiddenelem);
7053: return $output;
7054: }
7055:
1.480 raeburn 7056: sub remove_archive {
7057: my ($docudom,$docuname,$container) = @_;
7058: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 7059: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 7060: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
7061: if ($fatal) {
7062: if ($container eq 'page') {
7063: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
7064: } else {
7065: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
7066: }
1.583 raeburn 7067: $delwarning .= ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 7068: } else {
7069: my $currcmd = $env{'form.cmd'};
7070: my $position = $env{'form.position'};
1.583 raeburn 7071: my $archiveidx = $position;
1.563 raeburn 7072: if ($position > 0) {
1.583 raeburn 7073: if (($env{'form.autoextract_camtasia'}) && (scalar(@LONCAPA::map::order) == 2)) {
7074: $archiveidx = $position-1;
7075: }
7076: $env{'form.cmd'} = 'remove_'.$archiveidx;
1.584 raeburn 7077: my ($title,$url,@rrest) =
1.583 raeburn 7078: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$archiveidx]]);
7079: if ($url eq $env{'form.archiveurl'}) {
7080: if (&handle_edit_cmd($docuname,$docudom)) {
7081: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
1.684 ! raeburn 7082: if ($suppchanges) {
! 7083: &Apache::lonnet::update_supp_caches($docudom,$docuname);
! 7084: undef($suppchanges);
! 7085: }
1.583 raeburn 7086: if ($fatal) {
7087: if ($container eq 'page') {
7088: $delwarning = &mt('An error occurred updating the contents of the current page.');
7089: } else {
7090: $delwarning = &mt('An error occurred updating the contents of the current folder.');
7091: }
1.480 raeburn 7092: } else {
1.583 raeburn 7093: $delresult = &mt('Archive file removed.');
1.480 raeburn 7094: }
7095: }
1.583 raeburn 7096: } else {
7097: $delwarning .= &mt('Archive file had unexpected item number in folder.').
7098: ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 7099: }
7100: }
7101: $env{'form.cmd'} = $currcmd;
7102: }
7103: if ($delwarning) {
7104: $output = '<p class="LC_warning">'.
7105: $delwarning.
7106: '</p>';
7107: }
7108: if ($delresult) {
7109: $output .= '<p class="LC_info">'.
7110: $delresult.
7111: '</p>';
7112: }
1.481 raeburn 7113: return $output;
1.480 raeburn 7114: }
7115:
1.484 raeburn 7116: sub generate_admin_menu {
1.611 raeburn 7117: my ($crstype,$canedit) = @_;
1.484 raeburn 7118: my $lc_crstype = lc($crstype);
7119: my ($home,$other,%outhash)=&authorhosts();
1.562 bisitz 7120: my %lt= ( # do not translate here
1.484 raeburn 7121: 'vc' => 'Verify Content',
7122: 'cv' => 'Check/Set Resource Versions',
7123: 'ls' => 'List Resource Identifiers',
1.651 raeburn 7124: 'ct' => 'Display/Set Shortened URLs for Deep-linking',
1.484 raeburn 7125: 'imse' => 'Export contents to IMS Archive',
1.568 raeburn 7126: 'dcd' => "Copy $crstype Content to Authoring Space",
1.562 bisitz 7127: );
1.484 raeburn 7128: my ($candump,$dumpurl);
7129: if ($home + $other > 0) {
7130: $candump = 'F';
7131: if ($home) {
7132: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
7133: } else {
7134: my @hosts;
7135: foreach my $aurole (keys(%outhash)) {
7136: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
7137: push(@hosts,$outhash{$aurole});
1.538 raeburn 7138: }
1.484 raeburn 7139: }
7140: if (@hosts == 1) {
7141: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
7142: '&role='.
7143: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
7144: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
7145: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
7146: } else {
7147: $dumpurl = "javascript:choose_switchserver_window()";
7148: }
7149: }
7150: }
7151: my @menu=
7152: ({ categorytitle=>'Administration',
7153: items =>[
7154: { linktext => $lt{'vc'},
7155: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
7156: permission => 'F',
1.571 raeburn 7157: help => 'Docs_Verify_Content',
1.484 raeburn 7158: icon => 'verify.png',
7159: linktitle => 'Verify contents can be retrieved/rendered',
7160: },
7161: { linktext => $lt{'cv'},
7162: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
7163: permission => 'F',
1.571 raeburn 7164: help => 'Docs_Check_Resource_Versions',
1.484 raeburn 7165: icon => 'resversion.png',
7166: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
7167: },
7168: { linktext => $lt{'ls'},
7169: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
7170: permission => 'F',
7171: #help => '',
7172: icon => 'symbs.png',
7173: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
7174: },
1.651 raeburn 7175: { linktext => $lt{'ct'},
7176: url => "javascript:injectData(document.courseverify,'dummy','shorturls','$lt{'ct'}')",
7177: permission => 'F',
7178: help => 'Docs_Short_URLs',
7179: icon => 'shorturls.png',
7180: linktitle => "Set shortened URLs for a resource or folder in your $lc_crstype for use in deep-linking"
7181: },
1.484 raeburn 7182: ]
1.611 raeburn 7183: });
7184: if ($canedit) {
7185: push(@menu,
1.484 raeburn 7186: { categorytitle=>'Export',
7187: items =>[
7188: { linktext => $lt{'imse'},
7189: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
7190: permission => 'F',
7191: help => 'Docs_Export_Course_Docs',
7192: icon => 'imsexport.png',
7193: linktitle => $lt{'imse'},
7194: },
7195: { linktext => $lt{'dcd'},
7196: url => $dumpurl,
7197: permission => $candump,
1.571 raeburn 7198: help => 'Docs_Dump_Course_Docs',
1.484 raeburn 7199: icon => 'dump.png',
7200: linktitle => $lt{'dcd'},
7201: },
7202: ]
7203: });
1.611 raeburn 7204: }
1.484 raeburn 7205: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
7206: '<input type="hidden" id="dummy" />'."\n".
7207: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
7208: '</form>';
1.329 droeschl 7209: }
7210:
7211: sub generate_edit_table {
1.538 raeburn 7212: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile,
1.611 raeburn 7213: $need_save,$copyfolder,$canedit) = @_;
1.406 raeburn 7214: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 7215: my %orderhash = %{$orderhash_ref};
1.611 raeburn 7216: my ($form, $activetab, $active, $disabled);
1.570 raeburn 7217: if (($env{'form.active'} ne '') && ($env{'form.active'} ne '00')) {
1.371 tempelho 7218: $activetab = $env{'form.active'};
7219: }
1.611 raeburn 7220: unless ($canedit) {
7221: $disabled = ' disabled="disabled"';
7222: }
1.472 raeburn 7223: my $backicon = $iconpath.'clickhere.gif';
1.525 raeburn 7224: my $backtext = &mt('Exit Editor');
1.458 raeburn 7225: $form = '<div class="LC_Box" style="margin:0;">'.
1.488 raeburn 7226: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
7227: '<li class="goback">'.
1.546 raeburn 7228: '<a href="javascript:toContents('."'$jumpto'".');">'.
1.488 raeburn 7229: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
7230: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
7231: '<li>'.
7232: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
7233: &mt('Undo Delete').'</a></li>'."\n";
7234: if ($env{'form.docslog'}) {
7235: $form .= '<li class="active">';
7236: } else {
7237: $form .= '<li>';
7238: }
7239: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
7240: &mt('History').'</a></li>'."\n";
7241: if ($env{'form.docslog'}) {
7242: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
7243: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 7244: }
1.458 raeburn 7245: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 7246: if($name ne '00'){
1.371 tempelho 7247: if($activetab eq '' || $activetab ne $name){
7248: $active = '';
7249: }elsif($activetab eq $name){
7250: $active = 'class="active"';
7251: }
1.458 raeburn 7252: $form .= '<li style="float:right" '.$active
1.484 raeburn 7253: .' 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 7254: } else {
1.570 raeburn 7255: $form .= '<li style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 7256:
7257: }
1.329 droeschl 7258: }
1.484 raeburn 7259: $form .= '</ul>'."\n";
7260: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 7261:
7262: if ($to_show ne '') {
1.538 raeburn 7263: my $saveform;
7264: if ($need_save) {
7265: my $button = &mt('Make changes');
7266: my $path;
7267: if ($env{'form.folderpath'}) {
7268: $path =
7269: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
7270: }
7271: $saveform = <<"END";
7272: <div id="multisave" style="display:none; clear:both;" >
7273: <form name="saveactions" method="post" action="/adm/coursedocs" onsubmit="return checkSubmits();">
7274: <input type="hidden" name="folderpath" value="$path" />
7275: <input type="hidden" name="symb" value="$env{'form.symb'}" />
7276: <input type="hidden" name="allhiddenresource" value="" />
7277: <input type="hidden" name="allencrypturl" value="" />
7278: <input type="hidden" name="allrandompick" value="" />
7279: <input type="hidden" name="allrandomorder" value="" />
7280: <input type="hidden" name="changeparms" value="" />
7281: <input type="hidden" name="multiremove" value="" />
7282: <input type="hidden" name="multicut" value="" />
7283: <input type="hidden" name="multicopy" value="" />
7284: <input type="hidden" name="multichange" value="" />
7285: <input type="hidden" name="copyfolder" value="$copyfolder" />
1.611 raeburn 7286: <input type="submit" name="savemultiples" value="$button" $disabled />
1.538 raeburn 7287: </form>
7288: </div>
7289: END
7290: }
7291: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'.$saveform."\n";
1.458 raeburn 7292: }
1.363 ehlerst 7293: foreach my $field (keys(%orderhash)){
1.390 tempelho 7294: if($field ne '00'){
1.422 onken 7295: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 7296: $active = 'style="display: none;float:left"';
1.422 onken 7297: }elsif($activetab eq $field){
1.458 raeburn 7298: $active = 'style="display:block;float:left"';
1.422 onken 7299: }
7300: $form .= '<div id="'.$field.$tid.'"'
7301: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 7302: .'</div>'."\n";
1.363 ehlerst 7303: }
7304: }
1.484 raeburn 7305: unless ($env{'form.docslog'}) {
7306: $form .= '</div></div>'."\n";
7307: }
1.329 droeschl 7308: return $form;
7309: }
7310:
7311: sub editing_js {
1.622 raeburn 7312: my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
7313: $londocroot,$canedit,$hostname,$navmapref) = @_;
1.594 damieng 7314: my %js_lt = &Apache::lonlocal::texthash(
1.329 droeschl 7315: p_mnf => 'Name of New Folder',
7316: t_mnf => 'New Folder',
7317: p_mnp => 'Name of New Page',
7318: t_mnp => 'New Page',
1.451 www 7319: p_mxu => 'Title for the External Score',
1.349 biermanm 7320: p_msp => 'Name of Simple Course Page',
1.329 droeschl 7321: p_msb => 'Title for the Problem',
7322: p_mdb => 'Title for the Drop Box',
1.336 schafran 7323: p_mbb => 'Title for the Discussion Board',
1.604 raeburn 7324: p_mwp => 'Title for Web Page',
1.606 raeburn 7325: p_mnr => 'Title for the Resource',
1.348 weissno 7326: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 7327: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 7328: p_mab_alrt1 => 'Not a valid user:domain',
7329: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
7330: p_chn => 'New Title',
7331: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
1.603 raeburn 7332: p_rmr2a => 'Remove',
7333: p_rmr2b => '?',
7334: p_rmr3a => 'Remove those',
7335: p_rmr3b => 'items?',
7336: p_rmr4 => 'WARNING: Removing a resource uploaded to a course cannot be undone via "Undo Delete".',
7337: p_rmr5 => 'Push "Cancel" and then use "Cut" instead if you might need to undo this change.',
1.329 droeschl 7338: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
7339: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
1.603 raeburn 7340: p_ctr2a => 'Cut',
7341: p_ctr2b => '?',
7342: p_ctr3a => 'Cut those',
7343: p_ctr3b => 'items?',
1.633 raeburn 7344: setal => 'Enter a (unique) alias',
7345: delal => 'Are you sure you want to eliminate the alias?',
1.478 raeburn 7346: rpck => 'Enter number to pick (e.g., 3)',
1.501 raeburn 7347: imsfile => 'You must choose an IMS package for import',
7348: imscms => 'You must select which Course Management System was the source of the IMS package',
7349: invurl => 'Invalid URL',
7350: titbl => 'Title is blank',
1.538 raeburn 7351: more => '(More ...)',
7352: less => '(Less ...)',
1.543 raeburn 7353: noor => 'No actions selected or changes to settings specified.',
7354: noch => 'No changes to settings specified.',
7355: noac => 'No actions selected.',
1.606 raeburn 7356: nofi => 'No file selected',
7357: tinc => 'Title in course',
7358: sunm => 'Sub-directory name',
1.618 raeburn 7359: edri => 'Editing rights unavailable for your current role.',
1.329 droeschl 7360: );
1.594 damieng 7361: &js_escape(\%js_lt);
1.433 raeburn 7362: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 7363: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
7364: my $main_container_page;
1.519 raeburn 7365: if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) {
7366: $main_container_page = 1;
1.434 raeburn 7367: }
1.617 raeburn 7368: my $backtourl;
7369: my $toplevelmain = &escape(&default_folderpath($coursenum,$coursedom,$navmapref));
1.446 www 7370: my $toplevelsupp = &supplemental_base();
1.433 raeburn 7371:
1.530 raeburn 7372: if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
7373: my $caller = $1;
1.525 raeburn 7374: if ($caller =~ /^supplemental/) {
7375: $backtourl = '/adm/supplemental?folderpath='.&escape($caller);
7376: } else {
7377: my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
7378: $res = &Apache::lonnet::clutter($res);
7379: if (&Apache::lonnet::is_on_map($res)) {
1.609 raeburn 7380: my ($url,$anchor);
7381: if ($res =~ /^([^#]+)#([^#]+)$/) {
7382: $url = $1;
7383: $anchor = $2;
7384: if (($caller =~ m{^([^#]+)\Q#$anchor\E$})) {
7385: $caller = $1.&escape('#').$anchor;
7386: }
1.614 raeburn 7387: } else {
7388: $url = $res;
1.609 raeburn 7389: }
1.640 raeburn 7390: $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"');
7391: if ($backtourl =~ m{^\Q/uploaded/$coursedom/$coursenum/\Edefault_\d+\.sequence$}) {
7392: $backtourl .= '?navmap=1';
7393: } else {
7394: $backtourl .= '?symb='.
7395: &HTML::Entities::encode($caller,'<>&"');
7396: }
1.622 raeburn 7397: if ($backtourl =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
7398: if (($ENV{'SERVER_PORT'} == 443) &&
7399: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
1.678 raeburn 7400: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.657 raeburn 7401: if ($hostname ne '') {
7402: $backtourl = 'http://'.$hostname.$backtourl;
7403: }
7404: $backtourl .= (($backtourl =~ /\?/) ? '&':'?').'usehttp=1';
1.622 raeburn 7405: }
7406: }
1.623 raeburn 7407: } elsif ($backtourl =~ m{^/adm/wrapper/ext/(?!https:)}) {
7408: if (($ENV{'SERVER_PORT'} == 443) && ($hostname ne '')) {
1.678 raeburn 7409: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.658 raeburn 7410: if ($hostname ne '') {
7411: $backtourl = 'http://'.$hostname.$backtourl;
7412: }
7413: $backtourl .= (($backtourl =~ /\?/) ? '&':'?').'usehttp=1';
1.657 raeburn 7414: }
1.623 raeburn 7415: }
1.622 raeburn 7416: }
1.609 raeburn 7417: if ($anchor ne '') {
7418: $backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"');
7419: }
1.590 raeburn 7420: $backtourl = &Apache::loncommon::escape_single($backtourl);
1.544 raeburn 7421: } else {
7422: $backtourl = '/adm/navmaps';
1.525 raeburn 7423: }
7424: }
7425: } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
7426: $backtourl = '/adm/menu';
7427: } elsif ($supplementalflag) {
1.682 raeburn 7428: if (($env{'request.role.adv'}) ||
7429: (&Apache::lonnet::has_unhidden_suppfiles($coursenum,$coursedom))) {
7430: $backtourl = '/adm/supplemental';
7431: } else {
7432: $backtourl = '/adm/navmaps';
7433: }
1.525 raeburn 7434: } else {
7435: $backtourl = '/adm/navmaps';
1.472 raeburn 7436: }
7437:
1.655 raeburn 7438: my $fieldsets = "'doc'";
1.519 raeburn 7439: unless ($main_container_page) {
7440: $fieldsets .=",'ims'";
7441: }
1.655 raeburn 7442: my $extfieldsets = "'ext'";
7443: if ($posslti) {
7444: $extfieldsets .= ",'tool'";
7445: }
1.501 raeburn 7446: if ($supplementalflag) {
1.655 raeburn 7447: $fieldsets = "'suppdoc'";
7448: $extfieldsets = "'suppext'";
1.600 raeburn 7449: if ($posslti) {
1.655 raeburn 7450: $extfieldsets .= ",'supptool'";
1.600 raeburn 7451: }
1.501 raeburn 7452: }
1.655 raeburn 7453:
1.611 raeburn 7454: my $jsmakefunctions;
7455: if ($canedit) {
7456: $jsmakefunctions = <<ENDNEWSCRIPT;
1.329 droeschl 7457: function makenewfolder(targetform,folderseq) {
1.594 damieng 7458: var foldername=prompt('$js_lt{"p_mnf"}','$js_lt{"t_mnf"}');
1.329 droeschl 7459: if (foldername) {
1.676 raeburn 7460: targetform.importdetail.value=encodeURIComponent(foldername)+"="+folderseq;
1.329 droeschl 7461: targetform.submit();
7462: }
7463: }
7464:
7465: function makenewpage(targetform,folderseq) {
1.594 damieng 7466: var pagename=prompt('$js_lt{"p_mnp"}','$js_lt{"t_mnp"}');
1.329 droeschl 7467: if (pagename) {
1.676 raeburn 7468: targetform.importdetail.value=encodeURIComponent(pagename)+"="+folderseq;
1.329 droeschl 7469: targetform.submit();
7470: }
7471: }
7472:
7473: function makeexamupload() {
1.594 damieng 7474: var title=prompt('$js_lt{"p_mxu"}');
1.344 bisitz 7475: if (title) {
1.329 droeschl 7476: this.document.forms.newexamupload.importdetail.value=
1.676 raeburn 7477: encodeURIComponent(title)+'=/res/lib/templates/examupload.problem';
1.329 droeschl 7478: this.document.forms.newexamupload.submit();
7479: }
7480: }
7481:
7482: function makesmppage() {
1.594 damieng 7483: var title=prompt('$js_lt{"p_msp"}');
1.344 bisitz 7484: if (title) {
1.329 droeschl 7485: this.document.forms.newsmppg.importdetail.value=
1.676 raeburn 7486: encodeURIComponent(title)+'=/adm/$udom/$uname/new/smppg';
1.329 droeschl 7487: this.document.forms.newsmppg.submit();
7488: }
7489: }
7490:
1.534 raeburn 7491: function makewebpage(type) {
1.594 damieng 7492: var title=prompt('$js_lt{"p_mwp"}');
1.534 raeburn 7493: var formname;
7494: if (type == 'supp') {
7495: formname = this.document.forms.supwebpage;
7496: } else {
7497: formname = this.document.forms.newwebpage;
7498: }
7499: if (title) {
7500: var webpage = formname.importdetail.value;
1.675 raeburn 7501: formname.importdetail.value = encodeURIComponent(title)+'='+webpage;
1.534 raeburn 7502: formname.submit();
7503: }
7504: }
7505:
1.329 droeschl 7506: function makesmpproblem() {
1.594 damieng 7507: var title=prompt('$js_lt{"p_msb"}');
1.344 bisitz 7508: if (title) {
1.329 droeschl 7509: this.document.forms.newsmpproblem.importdetail.value=
1.676 raeburn 7510: encodeURIComponent(title)+'=/res/lib/templates/simpleproblem.problem';
1.329 droeschl 7511: this.document.forms.newsmpproblem.submit();
7512: }
7513: }
7514:
7515: function makedropbox() {
1.594 damieng 7516: var title=prompt('$js_lt{"p_mdb"}');
1.344 bisitz 7517: if (title) {
1.329 droeschl 7518: this.document.forms.newdropbox.importdetail.value=
1.676 raeburn 7519: encodeURIComponent(title)+'=/res/lib/templates/DropBox.problem';
1.329 droeschl 7520: this.document.forms.newdropbox.submit();
7521: }
7522: }
7523:
7524: function makebulboard() {
1.594 damieng 7525: var title=prompt('$js_lt{"p_mbb"}');
1.329 droeschl 7526: if (title) {
7527: this.document.forms.newbul.importdetail.value=
1.676 raeburn 7528: encodeURIComponent(title)+'=/adm/$udom/$uname/new/bulletinboard';
1.329 droeschl 7529: this.document.forms.newbul.submit();
7530: }
7531: }
7532:
7533: function makeabout() {
1.594 damieng 7534: var user=prompt("$js_lt{'p_mab'}");
1.329 droeschl 7535: if (user) {
7536: var comp=new Array();
7537: comp=user.split(':');
7538: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
7539: if ((comp[0]) && (comp[1])) {
7540: this.document.forms.newaboutsomeone.importdetail.value=
1.594 damieng 7541: '$js_lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.611 raeburn 7542: this.document.forms.newaboutsomeone.submit();
7543: } else {
7544: alert("$js_lt{'p_mab_alrt1'}");
7545: }
7546: } else {
7547: alert("$js_lt{'p_mab_alrt2'}");
7548: }
7549: }
7550: }
7551:
7552: function makenew(targetform) {
7553: targetform.submit();
7554: }
7555:
7556: function changename(folderpath,index,oldtitle) {
7557: var title=prompt('$js_lt{"p_chn"}',oldtitle);
7558: if (title) {
7559: this.document.forms.renameform.markcopy.value='';
7560: this.document.forms.renameform.title.value=title;
7561: this.document.forms.renameform.cmd.value='rename_'+index;
7562: this.document.forms.renameform.folderpath.value=folderpath;
7563: this.document.forms.renameform.submit();
7564: }
7565: }
7566:
1.633 raeburn 7567: function setalias(folderpath,index) {
7568: var alias = prompt('$js_lt{"setal"}');
7569: if ((alias != null) && (alias != '')) {
7570: this.document.forms.aliasform.alias.value=alias;
7571: this.document.forms.aliasform.cmd.value='setalias_'+index;
7572: this.document.forms.aliasform.folderpath.value=folderpath;
7573: this.document.forms.aliasform.submit();
7574: }
7575: }
7576:
7577: function delalias(folderpath,index) {
7578: if (confirm('$js_lt{"delal"}')) {
7579: this.document.forms.aliasform.cmd.value='delalias_'+index;
7580: this.document.forms.aliasform.folderpath.value=folderpath;
7581: this.document.forms.aliasform.submit();
7582: }
7583: }
7584:
1.611 raeburn 7585: ENDNEWSCRIPT
7586: } else {
7587: $jsmakefunctions = <<ENDNEWSCRIPT;
7588:
7589: function makenewfolder() {
7590: alert("$js_lt{'edri'}");
7591: }
7592:
7593: function makenewpage() {
7594: alert("$js_lt{'edri'}");
7595: }
7596:
7597: function makeexamupload() {
7598: alert("$js_lt{'edri'}");
7599: }
7600:
7601: function makesmppage() {
7602: alert("$js_lt{'edri'}");
7603: }
7604:
7605: function makewebpage(type) {
7606: alert("$js_lt{'edri'}");
7607: }
7608:
7609: function makesmpproblem() {
7610: alert("$js_lt{'edri'}");
7611: }
7612:
7613: function makedropbox() {
7614: alert("$js_lt{'edri'}");
7615: }
7616:
7617: function makebulboard() {
7618: alert("$js_lt{'edri'}");
7619: }
7620:
7621: function makeabout() {
7622: alert("$js_lt{'edri'}");
7623: }
7624:
7625: function changename() {
7626: alert("$js_lt{'edri'}");
7627: }
7628:
1.633 raeburn 7629: function setalias() {
7630: alert("$js_lt{'edri'}");
7631: }
7632:
7633: function delalias() {
7634: alert("$js_lt{'edri'}");
7635: }
7636:
1.611 raeburn 7637: function makenew() {
7638: alert("$js_lt{'edri'}");
7639: }
7640:
7641: function groupimport() {
7642: alert("$js_lt{'edri'}");
1.335 ehlerst 7643: }
1.611 raeburn 7644:
7645: function groupsearch() {
7646: alert("$js_lt{'edri'}");
1.335 ehlerst 7647: }
1.611 raeburn 7648:
7649: function groupopen(url,recover) {
7650: var options="scrollbars=1,resizable=1,menubar=0";
7651: idxflag=1;
7652: idx=open("/adm/groupsort?inhibitmenu=yes&mode=simple&recover="+recover+"&readfile="+url,"idxout",options);
7653: idx.focus();
1.329 droeschl 7654: }
7655:
1.611 raeburn 7656: ENDNEWSCRIPT
7657:
7658: }
7659: return <<ENDSCRIPT;
7660:
7661: $jsmakefunctions
7662:
1.501 raeburn 7663: function toggleUpload(caller) {
7664: var blocks = Array($fieldsets);
7665: for (var i=0; i<blocks.length; i++) {
7666: var disp = 'none';
7667: if (caller == blocks[i]) {
7668: var curr = document.getElementById('upload'+caller+'form').style.display;
7669: if (curr == 'none') {
7670: disp='block';
7671: }
7672: }
7673: document.getElementById('upload'+blocks[i]+'form').style.display=disp;
1.655 raeburn 7674: }
7675: resize_scrollbox('contentscroll','1','1');
7676: return;
7677: }
7678:
7679: function toggleExternal(caller) {
7680: var blocks = Array($extfieldsets);
7681: for (var i=0; i<blocks.length; i++) {
7682: var disp = 'none';
7683: if (caller == blocks[i]) {
7684: var curr = document.getElementById('external'+caller+'form').style.display;
7685: if (curr == 'none') {
7686: disp='block';
7687: }
7688: }
7689: document.getElementById('external'+blocks[i]+'form').style.display=disp;
1.598 raeburn 7690: if ((caller == 'tool') || (caller == 'supptool')) {
7691: if (disp == 'block') {
1.655 raeburn 7692: if (document.getElementById('LC_exttoolid')) {
7693: var toolselector = document.getElementById('LC_exttoolid');
1.598 raeburn 7694: var suppflag = 0;
7695: if (caller == 'supptool') {
7696: suppflag = 1;
7697: }
7698: currForm = document.getElementById('new'+caller);
1.655 raeburn 7699: updateExttool(toolselector,currForm,suppflag);
1.598 raeburn 7700: }
7701: }
7702: }
1.501 raeburn 7703: }
1.502 raeburn 7704: resize_scrollbox('contentscroll','1','1');
7705: return;
7706: }
7707:
1.514 raeburn 7708: function toggleMap(caller) {
1.502 raeburn 7709: var disp = 'none';
1.510 raeburn 7710: if (document.getElementById('importmapform')) {
1.514 raeburn 7711: if (caller == 'map') {
7712: var curr = document.getElementById('importmapform').style.display;
7713: if (curr == 'none') {
7714: disp='block';
7715: }
1.510 raeburn 7716: }
7717: document.getElementById('importmapform').style.display=disp;
7718: resize_scrollbox('contentscroll','1','1');
1.502 raeburn 7719: }
1.501 raeburn 7720: return;
1.329 droeschl 7721: }
7722:
1.606 raeburn 7723: function toggleCrsRes(caller,numauthorrole,numcrsdirs) {
7724: var disp = 'none';
7725: if (document.getElementById('crsresform')) {
7726: if (caller == 'res') {
7727: var curr = document.getElementById('crsresform').style.display;
7728: if (curr == 'none') {
7729: disp='block';
7730: numauthor = parseInt(numauthorrole);
7731: if (numauthor > 0) {
7732: document.courseresform.authorrole.selectedIndex = 0;
7733: select1priv_changed();
7734: document.courseresform.authorpath.selectedIndex = 0;
7735: document.courseresform.newresourceadd.selectedIndex = 0;
7736: toggleNewInCourse(document.courseresform);
7737: if (document.getElementById('newresource')) {
7738: document.getElementById('newresource').style.display = 'none';
7739: }
7740: } else {
7741: if (numcrsdirs) {
7742: document.courseresform.authorpath.selectedIndex = 0;
7743: }
7744: }
7745: if (document.courseresform.newresusetemp.length) {
7746: document.courseresform.newresusetemp[0].checked = true;
7747: toggleWithTemplate(document.courseresform);
7748: }
7749: document.courseresform.newresourcename.value = '';
7750: }
7751: }
7752: if (document.courseresform.newsubdir.length) {
7753: for (var j=0; j<document.courseresform.newsubdir.length; j++) {
7754: if (document.courseresform.newsubdir[j].value == 0) {
7755: document.courseresform.newsubdir[j].checked = true;
7756: }
7757: break;
7758: }
7759: if (document.getElementById('newsubdirname')) {
7760: document.getElementById('newsubdirname').type = "hidden";
7761: document.getElementById('newsubdirname').value = "";
7762: }
7763: if (document.getElementById('newsubdir')) {
7764: document.getElementById('newsubdir').innerHTML = "";
7765: }
7766: }
7767: document.getElementById('crsresform').style.display=disp;
7768: resize_scrollbox('contentscroll','1','0');
7769: }
7770: return;
7771: }
7772:
7773: function toggleNewsubdir(form) {
7774: if (form.newsubdir.length) {
7775: for (var j=0; j<form.newsubdir.length; j++) {
7776: if (form.newsubdir[j].checked) {
7777: if (document.getElementById('newsubdirname')) {
7778: if (form.newsubdir[j].value == '1') {
7779: document.getElementById('newsubdirname').type = "text";
7780: if (document.getElementById('newsubdir')) {
7781: document.getElementById('newsubdir').innerHTML = '<br />$js_lt{'sunm'}';
7782: }
7783: } else {
7784: document.getElementById('newsubdirname').type = "hidden";
7785: document.getElementById('newsubdirname').value = "";
7786: document.getElementById('newsubdir').innerHTML = "";
7787: }
7788: }
7789: break;
7790: }
7791: }
7792: }
7793: }
7794:
7795: function toggleCrsResTitle() {
7796: if (document.getElementById('newresource')) {
7797: if (document.courseresform.authorrole.options[document.courseresform.authorrole.selectedIndex].value == 'course') {
7798: document.getElementById('newresource').style.display = 'inline';
7799: document.courseresform.newresourceadd[0].checked = true;
7800: toggleNewInCourse(document.courseresform);
7801: } else {
7802: document.getElementById('newresource').style.display = 'none';
7803: }
7804: }
7805: }
7806:
7807: function toggleNewInCourse(form) {
7808: if (form.newresourceadd.length) {
7809: for (var i=0; i<form.newresourceadd.length; i++) {
7810: if (form.newresourceadd[i].checked) {
7811: if (document.getElementById('newresourcetitle')) {
7812: if (form.newresourceadd[i].value == '1') {
7813: document.getElementById('newresourcetitle').type = 'text';
7814: if (document.getElementById('newrestitle')) {
7815: document.getElementById('newrestitle').innerHTML = "<br />$js_lt{'tinc'}";
7816: }
7817: } else {
7818: document.getElementById('newresourcetitle').type = 'hidden';
7819: document.getElementById('newresourcetitle').value = '';
7820: if (document.getElementById('newrestitle')) {
7821: document.getElementById('newrestitle').innerHTML = '';
7822: }
7823: }
7824: }
7825: break;
7826: }
7827: }
7828: }
7829: }
7830:
7831: function toggleWithTemplate(form) {
7832: if (form.newresusetemp.length) {
7833: for (var i=0; i<form.newresusetemp.length; i++) {
7834: if (form.newresusetemp[i].checked) {
7835: if (document.getElementById('newrestemplate')) {
7836: if (form.newresusetemp[i].value == '1') {
7837: document.getElementById('newrestemplate').style.display = 'inline';
7838: toggleExampleText();
7839: } else {
7840: form.tempcategory.selectedIndex = 0;
7841: select1template_changed();
7842: document.getElementById('newrestemplate').style.display = 'none';
7843: }
7844: }
7845: }
7846: }
7847: }
7848: }
7849:
7850: function toggleExampleText() {
7851: if (document.getElementById('newresexample')) {
7852: var url = document.courseresform.template.options[document.courseresform.template.selectedIndex].value;
7853: if (url == '') {
7854: document.getElementById('newresexample').style.fontWeight = 'normal';
7855: } else {
7856: document.getElementById('newresexample').style.fontWeight = 'bold';
7857: }
7858: }
7859: }
7860:
7861: function getExample(width,height,scrolling,transparency) {
7862: var url;
7863: if (document.courseresform.newresusetemp.length) {
7864: for (var i=0; i<document.courseresform.newresusetemp.length; i++) {
7865: if (document.courseresform.newresusetemp[i].checked) {
7866: if (document.courseresform.newresusetemp[i].value == '1') {
7867: var url = document.courseresform.template.options[document.courseresform.template.selectedIndex].value;
7868: if (url == '') {
7869: alert('Pick a category and template');
7870: } else {
7871: url = url.replace("$londocroot","");
7872: url += '?inhibitmenu=yes';
7873: }
7874: }
7875: break;
7876: }
7877: }
7878: }
7879: if (url != '') {
7880: openMyModal(url,width,height,scrolling,transparency,'');
7881: }
7882: }
7883:
7884: function toggleImportCrsres(caller,dircount) {
7885: var disp = 'none';
7886: if (document.getElementById('importcrsresform')) {
7887: if (caller == 'res') {
7888: var numdirs = parseInt(dircount);
7889: var curr = document.getElementById('importcrsresform').style.display;
7890: if (curr == 'none') {
7891: disp='block';
7892: if (numdirs > 1) {
7893: select1res_changed();
7894: }
7895: }
7896: }
7897: document.getElementById('importcrsresform').style.display=disp;
7898: resize_scrollbox('contentscroll','1','0');
7899: }
7900: return;
7901: }
7902:
1.501 raeburn 7903: function makeims(imsform) {
7904: if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
1.594 damieng 7905: alert("$js_lt{'imsfile'}");
1.501 raeburn 7906: return;
7907: }
7908: if (imsform.source.selectedIndex == 0) {
1.594 damieng 7909: alert("$js_lt{'imscms'}");
1.501 raeburn 7910: return;
7911: }
7912: newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
7913: imsform.submit();
7914: }
7915:
1.478 raeburn 7916: function updatePick(targetform,index,caller) {
1.537 raeburn 7917: var pickitem;
7918: var picknumitem;
7919: var picknumtext;
7920: if (index == 'all') {
7921: pickitem = document.getElementById('randompickall');
7922: picknumitem = document.getElementById('rpicknumall');
7923: picknumtext = document.getElementById('rpicktextall');
7924: } else {
7925: pickitem = document.getElementById('randompick_'+index);
7926: picknumitem = document.getElementById('rpicknum_'+index);
7927: picknumtext = document.getElementById('randompicknum_'+index);
7928: }
1.478 raeburn 7929: if (pickitem.checked) {
1.594 damieng 7930: var picknum=prompt('$js_lt{"rpck"}',picknumitem.value);
1.478 raeburn 7931: if (picknum == '' || picknum == null) {
7932: if (caller == 'check') {
7933: pickitem.checked=false;
1.537 raeburn 7934: if (index == 'all') {
7935: picknumtext.innerHTML = '';
7936: if (caller == 'link') {
7937: propagateState(targetform,'rpicknum');
7938: }
7939: } else {
1.538 raeburn 7940: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 7941: }
1.478 raeburn 7942: }
7943: } else {
7944: picknum.toString();
7945: var regexdigit=/^\\d+\$/;
7946: if (regexdigit.test(picknum)) {
7947: picknumitem.value = picknum;
1.537 raeburn 7948: if (index == 'all') {
1.538 raeburn 7949: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.cumulativesettings,\\'all\\',\\'link\\');">'+picknum+'</a>';
1.537 raeburn 7950: if (caller == 'link') {
7951: propagateState(targetform,'rpicknum');
7952: }
7953: } else {
7954: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.edit_randompick_'+index+',\\''+index+'\\',\\'link\\');">'+picknum+'</a>';
1.538 raeburn 7955: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 7956: }
1.478 raeburn 7957: } else {
7958: if (caller == 'check') {
1.537 raeburn 7959: if (index == 'all') {
7960: picknumtext.innerHTML = '';
7961: if (caller == 'link') {
7962: propagateState(targetform,'rpicknum');
7963: }
7964: } else {
7965: pickitem.checked=false;
1.538 raeburn 7966: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 7967: }
1.478 raeburn 7968: }
7969: return;
7970: }
7971: }
7972: } else {
1.537 raeburn 7973: picknumitem.value = '';
7974: picknumtext.innerHTML = '';
7975: if (index == 'all') {
7976: if (caller == 'link') {
7977: propagateState(targetform,'rpicknum');
7978: }
7979: } else {
1.538 raeburn 7980: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 7981: }
7982: }
7983: }
7984:
7985: function propagateState(form,param) {
7986: if (document.getElementById(param+'all')) {
7987: var setcheck = 0;
7988: var rpick = 0;
7989: if (param == 'rpicknum') {
7990: if (document.getElementById('randompickall')) {
7991: if (document.getElementById('randompickall').checked) {
7992: if (document.getElementById('rpicknumall')) {
7993: rpick = document.getElementById('rpicknumall').value;
7994: }
7995: }
7996: }
7997: } else {
7998: if (document.getElementById(param+'all').checked) {
7999: setcheck = 1;
8000: }
8001: }
1.538 raeburn 8002: var allidxlist;
8003: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
8004: if (document.getElementById('all'+param+'idx')) {
8005: allidxlist = document.getElementById('all'+param+'idx').value;
8006: }
8007: var actions = new Array ('remove','cut','copy');
8008: for (var i=0; i<actions.length; i++) {
8009: if (actions[i] != param) {
8010: if (document.getElementById(actions[i]+'all')) {
8011: document.getElementById(actions[i]+'all').checked = false;
8012: }
8013: }
8014: }
8015: }
1.537 raeburn 8016: if ((param == 'encrypturl') || (param == 'hiddenresource')) {
1.538 raeburn 8017: allidxlist = form.allidx.value;
8018: }
8019: if ((param == 'randompick') || (param == 'rpicknum') || (param == 'randomorder')) {
8020: allidxlist = form.allmapidx.value;
8021: }
8022: if ((allidxlist != '') && (allidxlist != null)) {
8023: var allidxs = allidxlist.split(',');
8024: if (allidxs.length > 1) {
8025: for (var i=0; i<allidxs.length; i++) {
8026: if (document.getElementById(param+'_'+allidxs[i])) {
8027: if (param == 'rpicknum') {
8028: if (document.getElementById('randompick_'+allidxs[i])) {
8029: if (document.getElementById('randompick_'+allidxs[i]).checked) {
8030: document.getElementById(param+'_'+allidxs[i]).value = rpick;
8031: if (rpick > 0) {
8032: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = ': <a href="javascript:updatePick(document.edit_randompick_'+allidxs[i]+',\\''+allidxs[i]+'\\',\\'link\\')">'+rpick+'</a>';
8033: } else {
8034: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
8035: }
8036: }
8037: }
8038: } else {
1.537 raeburn 8039: if (setcheck == 1) {
8040: document.getElementById(param+'_'+allidxs[i]).checked = true;
8041: } else {
8042: document.getElementById(param+'_'+allidxs[i]).checked = false;
1.538 raeburn 8043: if (param == 'randompick') {
8044: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
8045: }
1.537 raeburn 8046: }
8047: }
8048: }
8049: }
1.538 raeburn 8050: if (setcheck == 1) {
8051: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
8052: var actions = new Array('copy','cut','remove');
8053: for (var i=0; i<actions.length; i++) {
8054: var otheractions;
8055: var otheridxs;
8056: if (actions[i] === param) {
8057: continue;
8058: } else {
8059: if (document.getElementById('all'+actions[i]+'idx')) {
8060: otheractions = document.getElementById('all'+actions[i]+'idx').value;
8061: otheridxs = otheractions.split(',');
8062: if (otheridxs.length > 1) {
8063: for (var j=0; j<otheridxs.length; j++) {
8064: if (document.getElementById(actions[i]+'_'+otheridxs[j])) {
8065: document.getElementById(actions[i]+'_'+otheridxs[j]).checked = false;
8066: }
1.537 raeburn 8067: }
8068: }
8069: }
1.538 raeburn 8070: }
8071: }
8072: }
8073: }
8074: }
8075: }
8076: }
8077: return;
8078: }
8079:
1.603 raeburn 8080: function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder,confirm_removal) {
1.611 raeburn 8081: var canedit = '$canedit';
8082: if (canedit == '') {
8083: alert("$js_lt{'edri'}");
8084: return;
8085: }
1.539 raeburn 8086: var dosettings;
8087: var doaction;
1.538 raeburn 8088: var control = document.togglemultsettings;
8089: if (context == 'actions') {
8090: control = document.togglemultactions;
1.539 raeburn 8091: doaction = 1;
8092: } else {
8093: dosettings = 1;
1.538 raeburn 8094: }
1.539 raeburn 8095: if (control) {
8096: if (control.showmultpick.length) {
8097: for (var i=0; i<control.showmultpick.length; i++) {
8098: if (control.showmultpick[i].checked) {
8099: if (control.showmultpick[i].value == 1) {
8100: if (context == 'settings') {
8101: dosettings = 0;
8102: } else {
8103: doaction = 0;
1.538 raeburn 8104: }
8105: }
8106: }
1.537 raeburn 8107: }
8108: }
1.539 raeburn 8109: }
8110: if (context == 'settings') {
8111: if (dosettings == 1) {
1.538 raeburn 8112: targetform.changeparms.value=param;
8113: targetform.submit();
8114: }
1.537 raeburn 8115: }
1.539 raeburn 8116: if (context == 'actions') {
8117: if (doaction == 1) {
8118: targetform.cmd.value=param+'_'+index;
8119: targetform.folderpath.value=folderpath;
8120: targetform.markcopy.value=idx+':'+param;
8121: targetform.copyfolder.value=folder+'.'+container;
8122: if (param == 'remove') {
1.603 raeburn 8123: var doremove = 0;
8124: if (skip_confirm) {
8125: if (confirm_removal) {
8126: if (confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'"$js_lt{"p_rmr2b"}')) {
8127: doremove = 1;
8128: }
8129: } else {
8130: doremove = 1;
8131: }
8132: } else {
8133: if (confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'" $js_lt{"p_rmr2b"}')) {
8134: doremove = 1;
8135: }
8136: }
8137: if (doremove) {
1.539 raeburn 8138: targetform.markcopy.value='';
8139: targetform.copyfolder.value='';
8140: targetform.submit();
8141: }
8142: }
8143: if (param == 'cut') {
1.594 damieng 8144: 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 8145: targetform.submit();
8146: return;
8147: }
8148: }
8149: if (param == 'copy') {
8150: targetform.submit();
8151: return;
8152: }
8153: targetform.markcopy.value='';
8154: targetform.copyfolder.value='';
8155: targetform.cmd.value='';
8156: targetform.folderpath.value='';
8157: return;
8158: } else {
8159: if (document.getElementById(param+'_'+idx)) {
8160: item = document.getElementById(param+'_'+idx);
8161: if (item.type == 'checkbox') {
8162: if (item.checked) {
8163: item.checked = false;
8164: } else {
8165: item.checked = true;
8166: singleCheck(item,idx,param);
8167: }
8168: }
8169: }
8170: }
8171: }
1.537 raeburn 8172: return;
8173: }
8174:
1.538 raeburn 8175: function singleCheck(caller,idx,action) {
8176: actions = new Array('cut','copy','remove');
8177: if (caller.checked) {
8178: for (var i=0; i<actions.length; i++) {
8179: if (actions[i] != action) {
8180: if (document.getElementById(actions[i]+'_'+idx)) {
8181: if (document.getElementById(actions[i]+'_'+idx).checked) {
8182: document.getElementById(actions[i]+'_'+idx).checked = false;
8183: }
1.537 raeburn 8184: }
8185: }
8186: }
1.478 raeburn 8187: }
1.537 raeburn 8188: return;
1.478 raeburn 8189: }
8190:
1.334 muellerd 8191: function unselectInactive(nav) {
1.335 ehlerst 8192: currentNav = document.getElementById(nav);
8193: currentLis = currentNav.getElementsByTagName('LI');
8194: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 8195: if (currentLis[i].className == 'goback') {
8196: currentLis[i].className = 'goback';
8197: } else {
8198: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 8199: currentLis[i].className = 'right';
1.472 raeburn 8200: } else {
1.374 tempelho 8201: currentLis[i].className = 'i';
1.472 raeburn 8202: }
8203: }
1.335 ehlerst 8204: }
1.332 tempelho 8205: }
8206:
1.334 muellerd 8207: function hideAll(current, nav, data) {
1.335 ehlerst 8208: unselectInactive(nav);
1.570 raeburn 8209: if (current) {
8210: if (current.className == 'right'){
8211: current.className = 'right active'
8212: } else {
8213: current.className = 'active';
8214: }
1.374 tempelho 8215: }
1.335 ehlerst 8216: currentData = document.getElementById(data);
8217: currentDivs = currentData.getElementsByTagName('DIV');
8218: for (i = 0; i < currentDivs.length; i++) {
8219: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 8220: currentDivs[i].style.display = 'none';
1.330 tempelho 8221: }
8222: }
1.335 ehlerst 8223: }
1.330 tempelho 8224:
1.374 tempelho 8225: function openTabs(pageId) {
8226: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 8227: if(tabnav.length > 2 ){
1.389 tempelho 8228: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 8229: currentLis = currentNav.getElementsByTagName('LI');
8230: for(i = 0; i< currentLis.length; i++){
8231: if(currentLis[i].className == 'active') {
1.375 tempelho 8232: funcString = currentLis[i].onclick.toString();
8233: tab = funcString.split('"');
1.420 onken 8234: if(tab.length < 2) {
8235: tab = funcString.split("'");
8236: }
1.375 tempelho 8237: currentData = document.getElementById(tab[1]);
8238: currentData.style.display = 'block';
1.374 tempelho 8239: }
8240: }
8241: }
8242: }
8243:
1.334 muellerd 8244: function showPage(current, pageId, nav, data) {
1.570 raeburn 8245: currstate = current.className;
1.334 muellerd 8246: hideAll(current, nav, data);
1.375 tempelho 8247: openTabs(pageId);
1.334 muellerd 8248: unselectInactive(nav);
1.570 raeburn 8249: if ((currstate == 'active') || (currstate == 'right active')) {
8250: if (currstate == 'active') {
8251: current.className = '';
8252: } else {
8253: current.className = 'right';
8254: }
8255: activeTab = '';
1.656 raeburn 8256: toggleExternal();
1.570 raeburn 8257: toggleUpload();
8258: toggleMap();
1.606 raeburn 8259: toggleCrsRes();
8260: toggleImportCrsres();
1.570 raeburn 8261: resize_scrollbox('contentscroll','1','0');
8262: return;
8263: } else {
8264: current.className = 'active';
8265: }
1.330 tempelho 8266: currentData = document.getElementById(pageId);
8267: currentData.style.display = 'block';
1.458 raeburn 8268: activeTab = pageId;
1.656 raeburn 8269: toggleExternal();
1.501 raeburn 8270: toggleUpload();
1.503 raeburn 8271: toggleMap();
1.606 raeburn 8272: toggleCrsRes();
8273: toggleImportCrsres();
1.433 raeburn 8274: if (nav == 'mainnav') {
8275: var storedpath = "$docs_folderpath";
1.434 raeburn 8276: var storedpage = "$main_container_page";
1.433 raeburn 8277: var reg = new RegExp("^supplemental");
8278: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 8279: if (storedpage == 1) {
8280: document.simpleedit.folderpath.value = '';
8281: document.uploaddocument.folderpath.value = '';
8282: } else {
8283: if (reg.test(storedpath)) {
8284: document.simpleedit.folderpath.value = '$toplevelmain';
8285: document.uploaddocument.folderpath.value = '$toplevelmain';
8286: document.newext.folderpath.value = '$toplevelmain';
8287: } else {
8288: document.simpleedit.folderpath.value = storedpath;
8289: document.uploaddocument.folderpath.value = storedpath;
8290: document.newext.folderpath.value = storedpath;
8291: }
1.433 raeburn 8292: }
8293: } else {
1.434 raeburn 8294: if (reg.test(storedpath)) {
8295: document.simpleedit.folderpath.value = storedpath;
8296: document.supuploaddocument.folderpath.value = storedpath;
8297: document.supnewext.folderpath.value = storedpath;
8298: } else {
1.433 raeburn 8299: document.simpleedit.folderpath.value = '$toplevelsupp';
8300: document.supuploaddocument.folderpath.value = '$toplevelsupp';
8301: document.supnewext.folderpath.value = '$toplevelsupp';
8302: }
8303: }
8304: }
1.485 raeburn 8305: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 8306: return false;
8307: }
1.329 droeschl 8308:
1.472 raeburn 8309: function toContents(jumpto) {
8310: var newurl = '$backtourl';
1.525 raeburn 8311: if ((newurl == '/adm/navmaps') && (jumpto != '')) {
1.472 raeburn 8312: newurl = newurl+'?postdata='+jumpto;
8313: }
8314: location.href=newurl;
8315: }
8316:
1.538 raeburn 8317: function togglePick(caller,value) {
8318: var disp = 'none';
8319: if (document.getElementById('multi'+caller)) {
8320: var curr = document.getElementById('multi'+caller).style.display;
8321: if (value == 1) {
8322: disp='block';
8323: }
8324: if (curr == disp) {
8325: return;
8326: }
8327: document.getElementById('multi'+caller).style.display=disp;
8328: if (value == 1) {
1.594 damieng 8329: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.538 raeburn 8330: } else {
8331: document.getElementById('more'+caller).innerHTML = '';
8332: }
8333: if (caller == 'actions') {
8334: setClass(value);
8335: setBoxes(value);
8336: }
8337: }
8338: var showButton = multiSettings();
8339: if (showButton != 1) {
8340: showButton = multiActions();
8341: }
8342: if (document.getElementById('multisave')) {
8343: if (showButton == 1) {
8344: document.getElementById('multisave').style.display='block';
8345: } else {
8346: document.getElementById('multisave').style.display='none';
8347: }
8348: }
8349: resize_scrollbox('contentscroll','1','1');
8350: return;
8351: }
8352:
8353: function toggleCheckUncheck(caller,more) {
8354: if (more == 1) {
1.594 damieng 8355: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',0);" style="text-decoration:none;">$js_lt{'less'}</a>';
1.538 raeburn 8356: document.getElementById('allfields'+caller).style.display='block';
8357: } else {
1.594 damieng 8358: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.538 raeburn 8359: document.getElementById('allfields'+caller).style.display='none';
8360: }
8361: resize_scrollbox('contentscroll','1','1');
8362: }
8363:
8364: function multiSettings() {
8365: var inuse = 0;
8366: var settingsform = document.togglemultsettings;
8367: if (settingsform.showmultpick.length > 1) {
8368: for (var i=0; i<settingsform.showmultpick.length; i++) {
8369: if (settingsform.showmultpick[i].checked) {
8370: if (settingsform.showmultpick[i].value == 1) {
8371: inuse = 1;
8372: }
8373: }
8374: }
8375: }
8376: return inuse;
8377: }
8378:
8379: function multiActions() {
8380: var inuse = 0;
8381: var actionsform = document.togglemultactions;
8382: if (actionsform.showmultpick.length > 1) {
8383: for (var i=0; i<actionsform.showmultpick.length; i++) {
8384: if (actionsform.showmultpick[i].checked) {
8385: if (actionsform.showmultpick[i].value == 1) {
8386: inuse = 1;
8387: }
8388: }
8389: }
8390: }
8391: return inuse;
8392: }
8393:
8394: function checkSubmits() {
8395: var numchanges = 0;
8396: var form = document.saveactions;
8397: var doactions = multiActions();
1.542 raeburn 8398: var cutwarnings = 0;
8399: var remwarnings = 0;
1.603 raeburn 8400: var removalinfo = 0;
1.538 raeburn 8401: if (doactions == 1) {
8402: var remidxlist = document.cumulativeactions.allremoveidx.value;
8403: if ((remidxlist != '') && (remidxlist != null)) {
8404: var remidxs = remidxlist.split(',');
8405: for (var i=0; i<remidxs.length; i++) {
8406: if (document.getElementById('remove_'+remidxs[i])) {
8407: if (document.getElementById('remove_'+remidxs[i]).checked) {
8408: form.multiremove.value += remidxs[i]+',';
8409: numchanges ++;
1.542 raeburn 8410: if (document.getElementById('skip_remove_'+remidxs[i])) {
8411: if (document.getElementById('skip_remove_'+remidxs[i]).value == 0) {
8412: remwarnings ++;
8413: }
8414: }
1.603 raeburn 8415: if (document.getElementById('confirm_removal_'+remidxs[i])) {
8416: if (document.getElementById('confirm_removal_'+remidxs[i]).value == 1) {
8417: removalinfo ++;
8418: }
8419: }
1.537 raeburn 8420: }
8421: }
1.538 raeburn 8422: }
8423: }
8424: var cutidxlist = document.cumulativeactions.allcutidx.value;
8425: if ((cutidxlist != '') && (cutidxlist != null)) {
8426: var cutidxs = cutidxlist.split(',');
8427: for (var i=0; i<cutidxs.length; i++) {
8428: if (document.getElementById('cut_'+cutidxs[i])) {
8429: if (document.getElementById('cut_'+cutidxs[i]).checked == true) {
8430: form.multicut.value += cutidxs[i]+',';
8431: numchanges ++;
1.542 raeburn 8432: if (document.getElementById('skip_cut_'+cutidxs[i])) {
8433: if (document.getElementById('skip_cut_'+cutidxs[i]).value == 0) {
8434: cutwarnings ++;
8435: }
8436: }
1.537 raeburn 8437: }
8438: }
8439: }
8440: }
1.538 raeburn 8441: var copyidxlist = document.cumulativeactions.allcopyidx.value;
8442: if ((copyidxlist != '') && (copyidxlist != null)) {
8443: var copyidxs = copyidxlist.split(',');
8444: for (var i=0; i<copyidxs.length; i++) {
8445: if (document.getElementById('copy_'+copyidxs[i])) {
8446: if (document.getElementById('copy_'+copyidxs[i]).checked) {
8447: form.multicopy.value += copyidxs[i]+',';
8448: numchanges ++;
8449: }
8450: }
8451: }
8452: }
8453: if (numchanges > 0) {
8454: form.multichange.value = numchanges;
8455: }
1.537 raeburn 8456: }
1.538 raeburn 8457: var dosettings = multiSettings();
1.543 raeburn 8458: var haschanges = 0;
1.538 raeburn 8459: if (dosettings == 1) {
8460: form.allencrypturl.value = '';
8461: form.allhiddenresource.value = '';
1.543 raeburn 8462: form.changeparms.value = 'all';
8463: var patt=new RegExp(",\$");
1.538 raeburn 8464: var allidxlist = document.cumulativesettings.allidx.value;
8465: if ((allidxlist != '') && (allidxlist != null)) {
8466: var allidxs = allidxlist.split(',');
8467: if (allidxs.length > 1) {
8468: for (var i=0; i<allidxs.length; i++) {
8469: if (document.getElementById('hiddenresource_'+allidxs[i])) {
8470: if (document.getElementById('hiddenresource_'+allidxs[i]).checked) {
8471: form.allhiddenresource.value += allidxs[i]+',';
8472: }
8473: }
8474: if (document.getElementById('encrypturl_'+allidxs[i])) {
8475: if (document.getElementById('encrypturl_'+allidxs[i]).checked) {
8476: form.allencrypturl.value += allidxs[i]+',';
8477: }
8478: }
8479: }
1.543 raeburn 8480: form.allhiddenresource.value = form.allhiddenresource.value.replace(patt,"");
8481: form.allencrypturl.value = form.allencrypturl.value.replace(patt,"");
1.537 raeburn 8482: }
1.538 raeburn 8483: }
8484: form.allrandompick.value = '';
8485: form.allrandomorder.value = '';
8486: var allmapidxlist = document.cumulativesettings.allmapidx.value;
8487: if ((allmapidxlist != '') && (allmapidxlist != null)) {
8488: var allmapidxs = allmapidxlist.split(',');
8489: for (var i=0; i<allmapidxs.length; i++) {
8490: var randompick = document.getElementById('randompick_'+allmapidxs[i]);
8491: var rpicknum = document.getElementById('rpicknum_'+allmapidxs[i]);
8492: var randorder = document.getElementById('randomorder_'+allmapidxs[i]);
8493: if ((randompick.checked) && (rpicknum.value != '')) {
8494: form.allrandompick.value += allmapidxs[i]+':'+rpicknum.value+',';
8495: }
8496: if (randorder.checked) {
8497: form.allrandomorder.value += allmapidxs[i]+',';
8498: }
1.537 raeburn 8499: }
1.543 raeburn 8500: form.allrandompick.value = form.allrandompick.value.replace(patt,"");
8501: form.allrandomorder.value = form.allrandomorder.value.replace(patt,"");
8502: }
8503: if (document.cumulativesettings.currhiddenresource.value != form.allhiddenresource.value) {
8504: haschanges = 1;
8505: }
8506: if (document.cumulativesettings.currencrypturl.value != form.allencrypturl.value) {
8507: haschanges = 1;
8508: }
8509: if (document.cumulativesettings.currrandomorder.value != form.allrandomorder.value) {
8510: haschanges = 1;
8511: }
8512: if (document.cumulativesettings.currrandompick.value != form.allrandompick.value) {
8513: haschanges = 1;
1.537 raeburn 8514: }
8515: }
1.543 raeburn 8516: if (doactions == 1) {
1.542 raeburn 8517: if (numchanges > 0) {
1.603 raeburn 8518: if ((cutwarnings > 0) || (remwarnings > 0) || (removalinfo > 0)) {
1.542 raeburn 8519: if (remwarnings > 0) {
1.594 damieng 8520: if (!confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr3a"} '+remwarnings+' $js_lt{"p_rmr3b"}')) {
1.542 raeburn 8521: return false;
8522: }
8523: }
1.603 raeburn 8524: if (removalinfo > 0) {
8525: if (!confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr3a"} '+removalinfo+' $js_lt{"p_rmr3b"}')) {
8526: return false;
8527: }
8528: }
1.542 raeburn 8529: if (cutwarnings > 0) {
1.594 damieng 8530: 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 8531: return false;
8532: }
8533: }
8534: }
8535: form.submit();
8536: return true;
1.543 raeburn 8537: }
8538: }
8539: if (dosettings == 1) {
8540: if (haschanges == 1) {
1.542 raeburn 8541: form.submit();
8542: return true;
8543: }
1.543 raeburn 8544: }
8545: if ((dosettings == 1) && (doactions == 1)) {
1.594 damieng 8546: alert("$js_lt{'noor'}");
1.543 raeburn 8547: } else {
8548: if (dosettings == 1) {
1.594 damieng 8549: alert("$js_lt{'noch'}");
1.543 raeburn 8550: } else {
1.594 damieng 8551: alert("$js_lt{'noac'}");
1.543 raeburn 8552: }
8553: }
1.538 raeburn 8554: return false;
8555: }
8556:
8557: function setClass(value) {
8558: var cutclass = 'LC_docs_cut';
8559: var copyclass = 'LC_docs_copy';
8560: var removeclass = 'LC_docs_remove';
8561: var cutreg = new RegExp("\\\\b"+cutclass+"\\\\b");
8562: var copyreg = new RegExp("\\\\b"+copyclass+"\\\\b");
8563: var removereg = new RegExp("\\\\"+removeclass+"\\\\b");
8564: var links = document.getElementsByTagName('a');
8565: for (var i=0; i<links.length; i++) {
8566: var classes = links[i].className;
8567: if (cutreg.test(classes)) {
8568: links[i].className = cutclass;
8569: if (value == 1) {
8570: links[i].className += " LC_menubuttons_link";
8571: }
8572: } else {
8573: if (copyreg.test(classes)) {
8574: links[i].className = copyclass;
8575: if (value == 1) {
8576: links[i].className += " LC_menubuttons_link";
8577: }
8578: } else {
8579: if (removereg.test(classes)) {
8580: links[i].className = removeclass;
8581: if (value == 1) {
8582: links[i].className += " LC_menubuttons_link";
8583: }
8584: }
8585: }
8586: }
8587: }
8588: return;
1.537 raeburn 8589: }
8590:
1.538 raeburn 8591: function setBoxes(value) {
8592: var remidxlist = document.cumulativeactions.allremoveidx.value;
8593: if ((remidxlist != '') && (remidxlist != null)) {
8594: var remidxs = remidxlist.split(',');
8595: for (var i=0; i<remidxs.length; i++) {
8596: if (document.getElementById('remove_'+remidxs[i])) {
8597: var item = document.getElementById('remove_'+remidxs[i]);
8598: if (value == 1) {
8599: item.className = 'LC_docs_remove';
8600: } else {
8601: item.className = 'LC_hidden';
8602: }
8603: }
8604: }
8605: }
8606: var cutidxlist = document.cumulativeactions.allcutidx.value;
8607: if ((cutidxlist != '') && (cutidxlist != null)) {
8608: var cutidxs = cutidxlist.split(',');
8609: for (var i=0; i<cutidxs.length; i++) {
8610: if (document.getElementById('cut_'+cutidxs[i])) {
8611: var item = document.getElementById('cut_'+cutidxs[i]);
8612: if (value == 1) {
8613: item.className = 'LC_docs_cut';
8614: } else {
8615: item.className = 'LC_hidden';
8616: }
8617: }
1.537 raeburn 8618: }
8619: }
1.538 raeburn 8620: var copyidxlist = document.cumulativeactions.allcopyidx.value;
8621: if ((copyidxlist != '') && (copyidxlist != null)) {
8622: var copyidxs = copyidxlist.split(',');
8623: for (var i=0; i<copyidxs.length; i++) {
8624: if (document.getElementById('copy_'+copyidxs[i])) {
8625: var item = document.getElementById('copy_'+copyidxs[i]);
8626: if (value == 1) {
8627: item.className = 'LC_docs_copy';
8628: } else {
8629: item.className = 'LC_hidden';
8630: }
8631: }
1.537 raeburn 8632: }
8633: }
8634: return;
8635: }
8636:
1.606 raeburn 8637: function validImportCrsRes() {
8638: var path = document.crsresimportform.coursepath.options[document.crsresimportform.coursepath.selectedIndex].value;
8639: var fname = document.crsresimportform.coursefile.options[document.crsresimportform.coursefile.selectedIndex].value;
8640: if ((fname == '') || (fname == null)) {
8641: alert("$js_lt{'nofi'}");
8642: return false;
8643: }
8644: var url = '/res/$coursedom/$coursenum/';
8645: if (path && path != '/') {
8646: url += path+'/';
8647: }
8648: if (fname != '') {
8649: url += fname;
8650: }
8651: var title = document.crsresimportform.crsrestitle.value;
1.676 raeburn 8652: document.crsresimportform.importdetail.value=encodeURIComponent(title)+'='+encodeURIComponent(url);
1.606 raeburn 8653: return true;
8654: }
8655:
8656: function validateNewRes(caller) {
8657: if (caller == 'single') {
8658: var role = document.courseresform.authorrole.options[document.courseresform.authorrole.selectedIndex].value;
8659: var authorpath = document.courseresform.authorpath.options[document.courseresform.authorpath.selectedIndex].value;
8660: var resname = document.courseresform.newresourcename.value;
8661: }
8662: }
8663:
1.611 raeburn 8664: ENDSCRIPT
1.329 droeschl 8665: }
1.457 raeburn 8666:
1.483 raeburn 8667: sub history_tab_js {
8668: return <<"ENDHIST";
8669: function toggleHistoryDisp(choice) {
8670: document.docslogform.docslog.value = choice;
8671: document.docslogform.submit();
8672: return;
8673: }
8674:
8675: ENDHIST
8676: }
8677:
1.484 raeburn 8678: sub inject_data_js {
8679: return <<ENDINJECT;
8680:
8681: function injectData(current, hiddenField, name, value) {
8682: currentElement = document.getElementById(hiddenField);
8683: currentElement.name = name;
8684: currentElement.value = value;
8685: current.submit();
8686: }
8687:
8688: ENDINJECT
8689: }
8690:
8691: sub dump_switchserver_js {
8692: my @hosts = @_;
1.594 damieng 8693: my %js_lt = &Apache::lonlocal::texthash(
1.574 raeburn 8694: dump => 'Copying content to Authoring Space requires switching server.',
1.484 raeburn 8695: swit => 'Switch server?',
1.594 damieng 8696: );
8697: my %html_js_lt = &Apache::lonlocal::texthash(
8698: swit => 'Switch server?',
1.568 raeburn 8699: duco => 'Copying Content to Authoring Space',
1.484 raeburn 8700: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
8701: chos => 'Choose server',
8702: );
1.594 damieng 8703: &js_escape(\%js_lt);
8704: &html_escape(\%html_js_lt);
8705: &js_escape(\%html_js_lt);
1.484 raeburn 8706: my $role = $env{'request.role'};
8707: my $js = <<"ENDSWJS";
8708: <script type="text/javascript">
8709: function write_switchserver() {
8710: var server;
8711: if (document.setserver.posshosts.length > 0) {
8712: for (var i=0; i<document.setserver.posshosts.length; i++) {
8713: if (document.setserver.posshosts[i].checked) {
8714: server = document.setserver.posshosts[i].value;
8715: }
8716: }
8717: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
8718: }
8719: window.close();
8720: }
8721: </script>
8722:
8723: ENDSWJS
8724:
8725: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
8726: {'only_body' => 1,
8727: 'js_ready' => 1,});
8728: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
8729:
8730: my $hostpicker;
8731: my $count = 0;
8732: foreach my $host (sort(@hosts)) {
8733: my $checked;
8734: if ($count == 0) {
8735: $checked = ' checked="checked"';
8736: }
8737: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
8738: $host.'"'.$checked.' />'.$host.'</label> ';
8739: $count++;
8740: }
8741:
8742: return <<"ENDSWITCHJS";
8743:
8744: function dump_needs_switchserver(url) {
8745: if (url!='' && url!= null) {
1.594 damieng 8746: if (confirm("$js_lt{'dump'}\\n$js_lt{'swit'}")) {
1.484 raeburn 8747: go(url);
8748: }
8749: }
8750: return;
8751: }
8752:
8753: function choose_switchserver_window() {
8754: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
8755: newWindow.document.open();
8756: newWindow.document.writeln('$startpage');
1.594 damieng 8757: newWindow.document.write('<h3>$html_js_lt{'duco'}<\\/h3>\\n'+
8758: '<p>$html_js_lt{'yone'}<\\/p>\\n'+
8759: '<div class="LC_left_float"><fieldset><legend>$html_js_lt{'chos'}<\\/legend>\\n'+
1.484 raeburn 8760: '<form name="setserver" method="post" action="" \\/>\\n'+
8761: '$hostpicker\\n'+
8762: '<br \\/><br \\/>\\n'+
1.594 damieng 8763: '<input type="button" name="makeswitch" value="$html_js_lt{'swit'}" '+
1.484 raeburn 8764: 'onclick="write_switchserver();" \\/>\\n'+
8765: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
8766: newWindow.document.writeln('$endpage');
8767: newWindow.document.close();
8768: newWindow.focus();
8769: }
8770:
8771: ENDSWITCHJS
8772: }
8773:
8774: sub makedocslogform {
8775: my ($formelems,$docslog) = @_;
8776: return <<"LOGSFORM";
8777: <form action="/adm/coursedocs" method="post" name="docslogform">
8778: <input type="hidden" name="docslog" value="$docslog" />
8779: $formelems
8780: </form>
8781: LOGSFORM
8782: }
8783:
8784: sub makesimpleeditform {
8785: my ($formelems) = @_;
8786: return <<"SIMPFORM";
8787: <form name="simpleedit" method="post" action="/adm/coursedocs">
8788: <input type="hidden" name="importdetail" value="" />
8789: $formelems
8790: </form>
8791: SIMPFORM
8792: }
8793:
1.606 raeburn 8794: sub makenewproblem {
8795: my ($r,$coursedom,$coursenum) = @_;
8796: # Creating a new problem
8797: my ($redirect,$error);
8798: if ($env{'form.authorrole'}) {
8799: my ($newsubdir,$filename);
8800: if ($env{'form.newsubdir'}) {
8801: if ($env{'form.newsubdirname'} ne '') {
8802: $newsubdir = $env{'form.newsubdirname'};
1.654 raeburn 8803: }
1.606 raeburn 8804: }
8805: if ($env{'form.newresourcename'}) {
8806: $filename = $env{'form.newresourcename'};
8807: $filename =~ s/\.(\d+)(\.\w+)$/$2/;
8808: $filename =~ s/`//g;
8809: $filename =~ s{/\.\./}{_}g;
8810: $filename =~ s/\.+/./g;
8811: $filename =~ s{/+}{_}g;
8812: if ($filename ne '') {
8813: my ($name,$ext) = ($filename =~ /(.+)\.([^.]+)$/);
8814: if (($ext) && ($ext ne '.problem')) {
8815: $filename = $name.'.problem';
8816: } elsif ($ext eq '') {
8817: $filename .= '.problem';
8818: }
8819: my $docroot = $r->dir_config('lonDocRoot');
8820: my @ids=&Apache::lonnet::current_machine_ids();
8821: if ($env{'form.authorrole'} eq 'author') {
8822: if ($env{'user.author'}) {
8823: if ($env{'user.home'} && grep(/^\Q$env{'user.home'}\E$/,@ids)) {
8824: my $url = "/priv/$env{'user.domain'}/$env{'user.name'}";
8825: my $path = $docroot.$url;
8826: my $subdir = $env{'form.authorpath'};
8827: $redirect = &finishnewprob($url,$path,$subdir,$newsubdir,$filename);
8828: }
8829: }
8830: } elsif ($env{'form.authorrole'} eq 'course') {
8831: my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
8832: if ($chome && grep(/^\Q$chome\E$/,@ids)) {
8833: my $url = "/priv/$coursedom/$coursenum";
8834: my $path=$docroot.$url;
8835: my $subdir = $env{'form.authorpath'};
8836: $redirect = &finishnewprob($url,$path,$subdir,$newsubdir,$filename);
8837: if ($redirect) {
8838: my $rightsfile = 'default.rights';
8839: my $sourcerights = "$path/$rightsfile";
8840: my $targetrights = $docroot."/res/$coursedom/$coursenum/$rightsfile";
8841: my $now = time;
8842: if (!-e $sourcerights) {
8843: my $cid = $coursedom.'_'.$coursenum;
8844: if (open(my $fh,">$sourcerights")) {
8845: print $fh <<END;
8846: <accessrule effect="deny" realm="" type="course" role="" />
8847: <accessrule effect="allow" realm="$cid" type="course" role="" />
8848: END
8849: close($fh);
8850: }
8851: }
8852: if (!-e "$sourcerights.meta") {
8853: if (open(my $fh,">$sourcerights.meta")) {
8854: my $author=$env{'environment.firstname'}.' '.
8855: $env{'environment.middlename'}.' '.
8856: $env{'environment.lastname'}.' '.
8857: $env{'environment.generation'};
8858: $author =~ s/\s+$//;
8859: print $fh <<"END";
8860:
8861: <abstract></abstract>
8862: <author>$author</author>
8863: <authorspace>$coursenum:$coursedom</authorspace>
8864: <copyright>private</copyright>
8865: <creationdate>$now</creationdate>
8866: <customdistributionfile></customdistributionfile>
8867: <dependencies></dependencies>
8868: <domain>$coursedom</domain>
8869: <highestgradelevel>0</highestgradelevel>
8870: <keywords></keywords>
8871: <language>notset </language>
8872: <lastrevisiondate>$now</lastrevisiondate>
8873: <lowestgradelevel>0</lowestgradelevel>
8874: <mime>rights</mime>
8875: <modifyinguser>$env{'user.name'}:$env{'user.domain'}</modifyinguser>
8876: <notes></notes>
8877: <obsolete></obsolete>
8878: <obsoletereplacement></obsoletereplacement>
8879: <owner>$coursenum:$coursedom</owner>
8880: <rule>deny:::course,allow:$cid::course</rule>
8881: <sourceavail></sourceavail>
8882: <standards></standards>
8883: <subject></subject>
8884: <title></title>
8885: END
1.654 raeburn 8886: close($fh);
8887: }
8888: }
8889: if ((-e $sourcerights) && (-e "$sourcerights.meta")) {
8890: if (!-e "$docroot/res/$coursedom") {
8891: mkdir("$docroot/res/$coursedom",0755);
1.606 raeburn 8892: }
1.654 raeburn 8893: if (!-e "$docroot/res/$coursedom/$coursenum") {
8894: mkdir("$docroot/res/$coursedom/$coursenum",0755);
8895: }
8896: if ((-e "$docroot/res/$coursedom/$coursenum") && (!-e $targetrights)) {
8897: my $nokeyref = &Apache::lonpublisher::getnokey($r->dir_config('lonIncludes'));
8898: my $output = &Apache::lonpublisher::batchpublish($r,$sourcerights,$targetrights,$nokeyref,1);
1.606 raeburn 8899: }
8900: }
1.654 raeburn 8901: my $source = $docroot.$redirect;
8902: if (!-e "$source.meta") {
8903: my $cid = $coursedom.'_'.$coursenum;
8904: my $now = time;
8905: if (open(my $fh,">$source.meta")) {
8906: my $author=$env{'environment.firstname'}.' '.
8907: $env{'environment.middlename'}.' '.
8908: $env{'environment.lastname'}.' '.
8909: $env{'environment.generation'};
8910: $author =~ s/\s+$//;
8911: my $title = $env{'form.newresourcetitle'};
8912: $title =~ s/^\s+|\s+$//g;
8913: print $fh <<END;
1.606 raeburn 8914:
8915: <abstract></abstract>
8916: <author>$author</author>
8917: <authorspace>$coursenum:$coursedom</authorspace>
8918: <copyright>custom</copyright>
8919: <creationdate>$now</creationdate>
8920: <customdistributionfile>/res/$coursedom/$coursenum/default.rights</customdistributionfile>
8921: <dependencies></dependencies>
8922: <domain>$coursedom</domain>
8923: <highestgradelevel>0</highestgradelevel>
8924: <keywords></keywords>
8925: <language>notset </language>
8926: <lastrevisiondate>$now</lastrevisiondate>
8927: <lowestgradelevel>0</lowestgradelevel>
8928: <mime>problem</mime>
8929: <modifyinguser>$coursenum:$coursedom</modifyinguser>
8930: <notes></notes>
8931: <obsolete></obsolete>
8932: <obsoletereplacement></obsoletereplacement>
8933: <owner>$coursenum:$coursedom</owner>
8934: <sourceavail></sourceavail>
8935: <standards></standards>
8936: <subject></subject>
8937: <title>$title</title>
8938: END
1.654 raeburn 8939: close($fh);
1.606 raeburn 8940: }
8941: }
8942: }
8943: }
8944: } else {
8945: my ($auname,$audom,$role) = split('___',$env{'form.authorrole'});
8946: my $rolehome = &Apache::lonnet::homeserver($auname,$audom);
8947: if (grep(/^\Q$rolehome\E$/,@ids)) {
8948: my $now = time;
8949: if (exists($env{'user.role.'.$role.'./'.$audom.'/'.$auname})) {
8950: my ($start,$end) = split(/\./,$env{'user.role.'.$role.'./'.$audom.'/'.$auname});
8951: if (($start <= $now) && (($end == 0) || ($end >= $now))) {
8952: my $url = "/priv/$audom/$auname";
8953: my $path = $r->dir_config('lonDocRoot').$url;
8954: my $subdir = $env{'form.authorpath'};
8955: $redirect = &finishnewprob($url,$path,$subdir,$newsubdir,$filename);
8956: }
8957: }
8958: }
8959: }
8960: }
8961: }
8962: }
8963: return ($redirect,$error);
8964: }
8965:
8966: sub finishnewprob {
1.654 raeburn 8967: my ($url,$path,$subdir,$newsubdir,$filename,$context) = @_;
1.607 raeburn 8968: unless (-d $path) {
8969: unless (mkdir($path,02770)) {
8970: return;
8971: }
8972: }
1.606 raeburn 8973: my $redirect;
8974: if ($subdir ne '/') {
8975: $subdir = &cleandir($subdir);
8976: if (($subdir ne '') && (-d "$path/$subdir")) {
8977: $path .= "/$subdir";
8978: $url .= "/$subdir";
8979: }
8980: }
8981: my $dest;
8982: if ($newsubdir ne '') {
8983: $newsubdir = &cleandir($newsubdir);
8984: }
8985: if ($newsubdir ne '') {
8986: if (-d "$path/$newsubdir") {
8987: $dest = "$path/$newsubdir/$filename";
8988: } else {
8989: my $dirok;
8990: unless (-e "$path/$newsubdir") {
8991: if (mkdir("$path/$newsubdir",02770)) {
8992: if (chmod(02770,"$path/$newsubdir")) {
8993: $dirok = 1;
8994: }
8995: }
8996: }
8997: if ($dirok) {
8998: $dest = "$path/$newsubdir/$filename";
8999: }
9000: }
9001: if (($dest ne '') && (!-e $dest)) {
9002: $redirect = "$url/$newsubdir/$filename";
9003: }
9004: } else {
9005: $dest = "$path/$filename";
9006: if (($dest ne '') && (!-e $dest)) {
9007: $redirect = "$url/$filename";
9008: }
9009: }
1.654 raeburn 9010: if ((!-e $dest) && ($context ne 'upload')) {
9011: my $template = $env{'form.template'};
9012: my $copyfrom;
9013: if ($template ne '') {
9014: my %templates;
9015: my @files = &Apache::lonhomework::get_template_list('problem');
9016: foreach my $poss (@files) {
9017: if (ref($poss) eq 'ARRAY') {
9018: if ($template eq $poss->[0]) {
9019: $templates{$template} = 1;
9020: last;
9021: }
9022: }
9023: }
9024: if ($templates{$template}) {
9025: $copyfrom = $template;
9026: }
9027: }
9028: if ($filename =~ /\.problem$/) {
9029: unless ($copyfrom) {
9030: $copyfrom = $Apache::lonnet::perlvar{'lonIncludes'}.'/templates/blank.problem';
9031: }
9032: &File::Copy::copy($copyfrom,$dest);
9033: }
9034: }
1.606 raeburn 9035: return $redirect;
9036: }
9037:
9038: sub cleandir {
9039: my ($dir) = @_;
9040: $dir =~ s/^\s+//;
9041: $dir =~ s/\s+$//;
9042: $dir =~ s/\.+//g;
9043: $dir =~ s/[\#\?&%\":]//g;
9044: return $dir;
9045: }
9046:
1.329 droeschl 9047: 1;
9048: __END__
9049:
9050:
9051: =head1 NAME
9052:
9053: Apache::londocs.pm
9054:
9055: =head1 SYNOPSIS
9056:
9057: This is part of the LearningOnline Network with CAPA project
9058: described at http://www.lon-capa.org.
9059:
9060: =head1 SUBROUTINES
9061:
9062: =over
9063:
9064: =item %help=()
9065:
9066: Available help topics
9067:
9068: =item mapread()
9069:
1.344 bisitz 9070: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 9071: @order and @resources, determines status
9072: sets @order - pointer to resources in right order
9073: sets @resources - array with the resources with correct idx
9074:
9075: =item authorhosts()
9076:
9077: Return hash with valid author names
9078:
9079: =item clean()
9080:
9081: =item dumpcourse()
9082:
9083: Actually dump course
9084:
9085: =item group_import()
9086:
9087: Imports the given (name, url) resources into the course
9088: coursenum, coursedom, and folder must precede the list
9089:
9090: =item breadcrumbs()
9091:
9092: =item log_docs()
9093:
9094: =item docs_change_log()
9095:
9096: =item update_paste_buffer()
9097:
9098: =item print_paste_buffer()
9099:
9100: =item do_paste_from_buffer()
9101:
1.538 raeburn 9102: =item do_buffer_empty()
9103:
9104: =item clear_from_buffer()
9105:
1.492 raeburn 9106: =item get_newmap_url()
9107:
9108: =item dbcopy()
9109:
9110: =item uniqueness_check()
9111:
9112: =item contained_map_check()
9113:
9114: =item url_paste_fixups()
9115:
9116: =item apply_fixups()
9117:
9118: =item copy_dependencies()
9119:
1.329 droeschl 9120: =item update_parameter()
9121:
9122: =item handle_edit_cmd()
9123:
9124: =item editor()
9125:
9126: =item process_file_upload()
9127:
9128: =item process_secondary_uploads()
9129:
9130: =item is_supplemental_title()
9131:
9132: =item entryline()
9133:
9134: =item tiehash()
9135:
9136: =item untiehash()
9137:
9138: =item checkonthis()
9139:
9140: check on this
9141:
9142: =item verifycontent()
9143:
9144: Verify Content
9145:
1.636 raeburn 9146: =item devalidateversioncache()
9147:
9148: =item checkversions()
1.329 droeschl 9149:
9150: Check Versions
9151:
9152: =item mark_hash_old()
9153:
9154: =item is_hash_old()
9155:
9156: =item changewarning()
9157:
9158: =item init_breadcrumbs()
9159:
9160: Breadcrumbs for special functions
9161:
1.484 raeburn 9162: =item create_list_elements()
9163:
9164: =item create_form_ul()
9165:
9166: =item startContentScreen()
9167:
9168: =item endContentScreen()
9169:
9170: =item supplemental_base()
9171:
9172: =item embedded_form_elems()
9173:
9174: =item embedded_destination()
9175:
9176: =item return_to_editor()
9177:
9178: =item decompression_info()
9179:
9180: =item decompression_phase_one()
9181:
9182: =item decompression_phase_two()
9183:
9184: =item remove_archive()
9185:
9186: =item generate_admin_menu()
9187:
9188: =item generate_edit_table()
9189:
9190: =item editing_js()
9191:
9192: =item history_tab_js()
9193:
9194: =item inject_data_js()
9195:
9196: =item dump_switchserver_js()
9197:
1.485 raeburn 9198: =item resize_scrollbox_js()
1.484 raeburn 9199:
9200: =item makedocslogform()
9201:
1.485 raeburn 9202: =item makesimpleeditform()
9203:
1.329 droeschl 9204: =back
9205:
9206: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>