Annotation of loncom/interface/londocs.pm, revision 1.484.2.93.2.16
1.329 droeschl 1: # The LearningOnline Network
2: # Documents
3: #
1.484.2.93.2. 6(raebur 4:3): # $Id: londocs.pm,v 1.484.2.93.2.15 2023/09/06 13:35:14 raeburn Exp $
1.329 droeschl 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29: package Apache::londocs;
30:
31: use strict;
32: use Apache::Constants qw(:common :http);
33: use Apache::imsexport;
34: use Apache::lonnet;
35: use Apache::loncommon;
1.383 tempelho 36: use Apache::lonhtmlcommon;
1.329 droeschl 37: use LONCAPA::map();
38: use Apache::lonratedt();
39: use Apache::lonxml;
40: use Apache::lonclonecourse;
41: use Apache::lonnavmaps;
1.472 raeburn 42: use Apache::lonnavdisplay();
1.484.2.19 raeburn 43: use Apache::lonextresedit();
1.484.2.43 raeburn 44: use Apache::lontemplate();
45: use Apache::lonsimplepage();
1.484.2.93.2. (raeburn 46:): use Apache::loncourserespicker();
1.329 droeschl 47: use HTML::Entities;
1.484.2.7 raeburn 48: use HTML::TokeParser;
1.329 droeschl 49: use GDBM_File;
1.484.2.51 raeburn 50: use File::MMagic;
1.329 droeschl 51: use Apache::lonlocal;
52: use Cwd;
1.484.2.93.2. 2(raebur 53:3): use UUID::Tiny ':std';
1.329 droeschl 54: use LONCAPA qw(:DEFAULT :match);
55:
56: my $iconpath;
57:
58: my %hash;
59:
60: my $hashtied;
61: my %alreadyseen=();
62:
63: my $hadchanges;
1.484.2.37 raeburn 64: my $suppchanges;
1.329 droeschl 65:
66:
67: my %help=();
68:
69:
70: sub mapread {
71: my ($coursenum,$coursedom,$map)=@_;
72: return
73: &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
74: $map);
75: }
76:
77: sub storemap {
1.484.2.7 raeburn 78: my ($coursenum,$coursedom,$map,$contentchg)=@_;
79: my $report;
80: if (($contentchg) && ($map =~ /^default/)) {
81: $report = 1;
82: }
1.329 droeschl 83: my ($outtext,$errtext)=
84: &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.484.2.7 raeburn 85: $map,1,$report);
1.329 droeschl 86: if ($errtext) { return ($errtext,2); }
1.364 bisitz 87:
1.484.2.37 raeburn 88: if ($map =~ /^default/) {
89: $hadchanges=1;
1.484.2.93.2. 0(raebur 90:3): } elsif ($contentchg) {
1.484.2.37 raeburn 91: $suppchanges=1;
92: }
1.329 droeschl 93: return ($errtext,0);
94: }
95:
96:
97:
98: sub authorhosts {
99: my %outhash=();
100: my $home=0;
101: my $other=0;
102: foreach my $key (keys(%env)) {
103: if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
104: my $role=$1;
105: my $realm=$2;
106: my ($start,$end)=split(/\./,$env{$key});
107: if (($start) && ($start>time)) { next; }
108: if (($end) && (time>$end)) { next; }
109: my ($ca,$cd);
110: if ($1 eq 'au') {
111: $ca=$env{'user.name'};
112: $cd=$env{'user.domain'};
113: } else {
114: ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
115: }
116: my $allowed=0;
117: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
118: my @ids=&Apache::lonnet::current_machine_ids();
1.484 raeburn 119: foreach my $id (@ids) {
120: if ($id eq $myhome) {
121: $allowed=1;
122: last;
123: }
124: }
1.329 droeschl 125: if ($allowed) {
126: $home++;
1.484 raeburn 127: $outhash{'home_'.$ca.':'.$cd}=1;
1.329 droeschl 128: } else {
1.484 raeburn 129: $outhash{'otherhome_'.$ca.':'.$cd}=$myhome;
1.329 droeschl 130: $other++;
131: }
132: }
133: }
134: return ($home,$other,%outhash);
135: }
136:
137:
138: sub clean {
139: my ($title)=@_;
140: $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
1.344 bisitz 141: return $title;
1.329 droeschl 142: }
143:
1.484.2.67 raeburn 144: sub default_folderpath {
145: my ($coursenum,$coursedom,$navmapref) = @_;
146: return unless ($coursenum && $coursedom && ref($navmapref));
147: # Check if entire course is hidden and/or encrypted
148: my ($hiddenmap,$encryptmap,$folderpath,$hiddentop);
149: my $toplevel = "uploaded/$coursedom/$coursenum/default.sequence";
150: unless (ref($$navmapref)) {
151: $$navmapref = Apache::lonnavmaps::navmap->new();
152: }
153: if (ref($$navmapref)) {
154: if (lc($$navmapref->get_mapparam(undef,$toplevel,"0.hiddenresource")) eq 'yes') {
155: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
156: my @resources = $$navmapref->retrieveResources($toplevel,$filterFunc,1,1);
157: unless (@resources) {
158: $hiddenmap = 1;
159: unless ($env{'request.role.adv'}) {
160: $hiddentop = 1;
161: if ($env{'form.folder'}) {
162: undef($env{'form.folder'});
163: }
164: }
165: }
166: }
167: if (lc($$navmapref->get_mapparam(undef,$toplevel,"0.encrypturl")) eq 'yes') {
168: $encryptmap = 1;
169: }
170: }
171: unless ($hiddentop) {
172: $folderpath='default&'.&escape(&mt('Main Content')).
173: '::'.$hiddenmap.':'.$encryptmap.'::';
174: }
175: if (wantarray) {
176: return ($folderpath,$hiddentop);
177: } else {
178: return $folderpath;
179: }
180: }
1.329 droeschl 181:
1.484.2.93.2. 0(raebur 182:3): sub validate_supppath {
183:3): my ($coursenum,$coursedom) = @_;
184:3): my $backto;
1.484.2.92 raeburn 185: if ($env{'form.supppath'} ne '') {
186: my @items = split(/\&/,$env{'form.supppath'});
1.484.2.93.2. 0(raebur 187:3): my ($badpath,$got_supp,$supppath,%supphidden,%suppids);
1.484.2.92 raeburn 188: for (my $i=0; $i<@items; $i++) {
189: my $odd = $i%2;
190: if ((!$odd) && ($items[$i] !~ /^supplemental(|_\d+)$/)) {
191: $badpath = 1;
1.484.2.93.2. 0(raebur 192:3): last;
193:3): } elsif ($odd) {
194:3): my $suffix;
195:3): my $idx = $i-1;
196:3): if ($items[$i] =~ /^([^:]*)::(|1):::$/) {
197:3): $backto .= '&'.$1;
198:3): } elsif ($items[$idx] eq 'supplemental') {
199:3): $backto .= '&'.$items[$i];
200:3): } else {
201:3): $backto .= '&'.$items[$i];
202:3): my $is_hidden;
203:3): unless ($got_supp) {
204:3): my ($supplemental) = &Apache::loncommon::get_supplemental($coursenum,$coursedom);
205:3): if (ref($supplemental) eq 'HASH') {
206:3): if (ref($supplemental->{'hidden'}) eq 'HASH') {
207:3): %supphidden = %{$supplemental->{'hidden'}};
208:3): }
209:3): if (ref($supplemental->{'ids'}) eq 'HASH') {
210:3): %suppids = %{$supplemental->{'ids'}};
211:3): }
212:3): }
213:3): $got_supp = 1;
214:3): }
215:3): if (ref($suppids{"/uploaded/$coursedom/$coursenum/$items[$idx].sequence"}) eq 'ARRAY') {
216:3): my $mapid = $suppids{"/uploaded/$coursedom/$coursenum/$items[$idx].sequence"}->[0];
217:3): if ($supphidden{$mapid}) {
218:3): $is_hidden = 1;
219:3): }
220:3): }
221:3): $suffix = '::'.$is_hidden.':::';
222:3): }
223:3): $supppath .= '&'.$items[$i].$suffix;
224:3): } else {
225:3): $supppath .= '&'.$items[$i];
226:3): $backto .= '&'.$items[$i];
1.484.2.92 raeburn 227: }
228: }
229: if ($badpath) {
230: delete($env{'form.supppath'});
1.484.2.93.2. 0(raebur 231:3): } else {
232:3): $supppath =~ s/^\&//;
233:3): $backto =~ s/^\&//;
234:3): $env{'form.supppath'} = $supppath;
1.484.2.92 raeburn 235: }
236: }
1.484.2.93.2. 0(raebur 237:3): return $backto;
1.484.2.92 raeburn 238: }
239:
1.329 droeschl 240: sub dumpcourse {
241: my ($r) = @_;
1.408 raeburn 242: my $crstype = &Apache::loncommon::course_type();
1.484.2.43 raeburn 243: my ($starthash,$js);
244: unless (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
245: $js = <<"ENDJS";
246: <script type="text/javascript">
247: // <![CDATA[
248:
249: function hide_searching() {
250: if (document.getElementById('searching')) {
251: document.getElementById('searching').style.display = 'none';
252: }
253: return;
254: }
255:
256: // ]]>
257: </script>
258: ENDJS
259: $starthash = {
260: add_entries => {'onload' => "hide_searching();"},
261: };
262: }
263: $r->print(&Apache::loncommon::start_page('Copy '.$crstype.' Content to Authoring Space',$js,$starthash)."\n".
264: &Apache::lonhtmlcommon::breadcrumbs('Copy '.$crstype.' Content to Authoring Space')."\n");
1.484 raeburn 265: $r->print(&startContentScreen('tools'));
1.329 droeschl 266: my ($home,$other,%outhash)=&authorhosts();
1.484 raeburn 267: unless ($home) {
268: $r->print(&endContentScreen());
269: return '';
270: }
1.329 droeschl 271: my $origcrsid=$env{'request.course.id'};
272: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
273: if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
274: # Do the dumping
1.484 raeburn 275: unless ($outhash{'home_'.$env{'form.authorspace'}}) {
276: $r->print(&endContentScreen());
277: return '';
278: }
1.484.2.24 raeburn 279: my ($ca,$cd)=split(/\:/,$env{'form.authorspace'});
1.329 droeschl 280: $r->print('<h3>'.&mt('Copying Files').'</h3>');
281: my $title=$env{'form.authorfolder'};
282: $title=&clean($title);
1.484.2.43 raeburn 283: my ($navmap,$errormsg) =
284: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
285: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
286: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
287: my (%maps,%resources,%titles);
288: if (!ref($navmap)) {
289: $r->print($errormsg.
290: &endContentScreen());
291: return '';
292: } else {
293: &Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles,
294: 'dumpdocs',$cdom,$cnum);
295: }
296: my @todump = &Apache::loncommon::get_env_multiple('form.archive');
297: my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages,
298: %newcontent,%has_simpleprobs);
299: foreach my $item (sort {$a <=> $b} (@todump)) {
300: my $name = $env{'form.namefor_'.$item};
301: if ($resources{$item}) {
302: my ($map,$id,$res) = &Apache::lonnet::decode_symb($resources{$item});
303: if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) {
304: $tocopy{$1} = $name;
305: $display{$item} = $1;
306: $lookup{$1} = $item;
307: } elsif ($res eq 'lib/templates/simpleproblem.problem') {
308: $simpleproblems{$item} = {
309: symb => $resources{$item},
310: name => $name,
311: };
312: $display{$item} = 'simpleproblem_'.$name;
313: if ($map =~ m{^\Quploaded/$cdom/$cnum/\E(.+)$}) {
314: $has_simpleprobs{$1}{$id} = $item;
315: }
316: } elsif ($res =~ m{^adm/$match_domain/$match_username/(\d+)/smppg}) {
317: my $marker = $1;
318: my $db_name = &Apache::lonsimplepage::get_db_name($res,$marker,$cdom,$cnum);
319: $simplepages{$item} = {
320: res => $res,
321: title => $titles{$item},
322: db => $db_name,
323: marker => $marker,
324: symb => $resources{$item},
325: name => $name,
326: };
327: $display{$item} = '/'.$res;
328: }
329: } elsif ($maps{$item}) {
330: if ($maps{$item} =~ m{^\Quploaded/$cdom/$cnum/\E((?:default|supplemental)_\d+\.(?:sequence|page))$}) {
331: $tocopy{$1} = $name;
332: $display{$item} = $1;
333: $lookup{$1} = $item;
334: }
335: } else {
336: next;
337: }
338: }
1.329 droeschl 339: my $crs='/uploaded/'.$env{'request.course.id'}.'/';
340: $crs=~s/\_/\//g;
1.484.2.43 raeburn 341: my $mm = new File::MMagic;
342: my $prefix = "/uploaded/$cdom/$cnum/";
343: %replacehash = %tocopy;
344: foreach my $item (sort(keys(%simpleproblems))) {
345: my $content = &Apache::imsexport::simpleproblem($simpleproblems{$item}{'symb'});
346: $newcontent{$display{$item}} = $content;
347: }
348: my $gateway = Apache::lonhtmlgateway->new('web');
349: foreach my $item (sort(keys(%simplepages))) {
350: if (ref($simplepages{$item}) eq 'HASH') {
351: my $pagetitle = $simplepages{$item}{'title'};
352: my %fields = &Apache::lonnet::dump($simplepages{$item}{'db'},$cdom,$cnum);
353: my %contents;
354: foreach my $field (keys(%fields)) {
355: if ($field =~ /^(?:aaa|bbb|ccc)_(\w+)$/) {
356: my $name = $1;
357: my $msg = $fields{$field};
358: if ($name eq 'webreferences') {
359: if ($msg =~ m{^https?://}) {
360: $contents{$name} = '<a href="'.$msg.'"><tt>'.$msg.'</tt></a>';
361: }
362: } else {
363: $msg = &Encode::decode('utf8',$msg);
364: $msg = $gateway->process_outgoing_html($msg,1);
365: $contents{$name} = $msg;
366: }
367: } elsif ($field eq 'uploaded.photourl') {
368: my $marker = $simplepages{$item}{marker};
369: if ($fields{$field} =~ m{^\Q$prefix\E(simplepage/$marker/.+)$}) {
370: my $filepath = $1;
371: my ($relpath,$fname) = ($filepath =~ m{^(.+/)([^/]+)$});
372: if ($fname ne '') {
373: $fname=~s/\.(\w+)$//;
374: my $ext=$1;
375: $fname = &clean($fname);
376: $fname.='.'.$ext;
377: $contents{image} = '<img src="'.$relpath.$fname.'" alt="Image" />';
378: $replacehash{$filepath} = $relpath.$fname;
379: $deps{$item}{$filepath} = 1;
380: }
381: }
382: }
383: }
384: $replacehash{'/'.$simplepages{$item}{'res'}} = $simplepages{$item}{'name'};
385: $lookup{'/'.$simplepages{$item}{'res'}} = $item;
386: my $content = '
387: <html>
388: <head>
389: <title>'.$pagetitle.'</title>
390: </head>
391: <body bgcolor="#ffffff">';
392: if ($contents{title}) {
393: $content .= "\n".'<h2>'.$contents{title}.'</h2>';
394: }
395: if ($contents{image}) {
396: $content .= "\n".$contents{image};
397: }
398: if ($contents{content}) {
399: $content .= '
400: <div class="LC_Box">
1.484.2.50 raeburn 401: <h4 class="LC_hcell">'.&mt('Content').'</h4>'.
1.484.2.43 raeburn 402: $contents{content}.'
403: </div>';
404: }
405: if ($contents{webreferences}) {
406: $content .= '
407: <div class="LC_Box">
1.484.2.50 raeburn 408: <h4 class="LC_hcell">'.&mt('Web References').'</h4>'.
1.484.2.43 raeburn 409: $contents{webreferences}.'
410: </div>';
411: }
412: $content .= '
413: </body>
414: </html>
415: ';
416: $newcontent{'/'.$simplepages{$item}{res}} = $content;
417: }
418: }
419: foreach my $item (keys(%tocopy)) {
420: unless ($item=~/\.(sequence|page)$/) {
421: my $currurlpath = $prefix.$item;
422: my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath);
423: &recurse_html($mm,$prefix,$currdirpath,$currurlpath,$item,$lookup{$item},\%replacehash,\%deps);
424: }
425: }
426: foreach my $num (sort {$a <=> $b} (@todump)) {
427: my $src = $display{$num};
428: next if ($src eq '');
429: my @needcopy = ();
430: if ($replacehash{$src}) {
431: push(@needcopy,$src);
432: if (ref($deps{$num}) eq 'HASH') {
433: foreach my $dep (sort(keys(%{$deps{$num}}))) {
434: if ($replacehash{$dep}) {
435: push(@needcopy,$dep);
436: }
437: }
438: }
439: } elsif ($src =~ /^simpleproblem_/) {
440: push(@needcopy,$src);
441: }
442: next if (@needcopy == 0);
443: my ($result,$depresult);
444: for (my $i=0; $i<@needcopy; $i++) {
445: my $item = $needcopy[$i];
446: my $newfilename;
447: if ($simpleproblems{$num}) {
448: $newfilename=$title.'/'.$simpleproblems{$num}{'name'};
449: } else {
450: $newfilename=$title.'/'.$replacehash{$item};
451: }
452: $newfilename=~s/\.(\w+)$//;
453: my $ext=$1;
454: $newfilename=&clean($newfilename);
455: $newfilename.='.'.$ext;
456: my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$});
457: if ($newrelpath ne $replacehash{$item}) {
458: $replacehash{$item} = $newrelpath;
459: }
460: my @dirs=split(/\//,$newfilename);
461: my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
462: my $makepath=$path;
463: my $fail;
464: my $origin;
465: for (my $i=0;$i<$#dirs;$i++) {
466: $makepath.='/'.$dirs[$i];
467: unless (-e $makepath) {
468: unless(mkdir($makepath,0755)) {
469: $fail = &mt('Directory creation failed.');
470: }
471: }
472: }
473: if ($i == 0) {
474: $result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ';
475: } else {
476: $depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '.
477: '<span class="LC_fontsize_small" style="font-weight: bold;">'.
478: &mt('(dependency)').'</span>: ';
479: }
480: if (-e $path.'/'.$newfilename) {
481: $fail = &mt('Destination already exists -- not overwriting.');
482: } else {
483: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
484: if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) ||
485: ($item =~ /^simpleproblem_/)) {
486: print $fh $newcontent{$item};
487: } else {
488: my $fileloc = &Apache::lonnet::filelocation('',$prefix.$item);
489: if (-e $fileloc) {
490: if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
491: if ((($1 eq 'sequence') || ($1 eq 'page')) &&
492: (ref($has_simpleprobs{$item}) eq 'HASH')) {
493: my %changes = %{$has_simpleprobs{$item}};
494: my $content = &Apache::lonclonecourse::rewritefile(
495: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
496: (%replacehash,$crs => '')
497: );
498: my $updatedcontent = '';
499: my $parser = HTML::TokeParser->new(\$content);
500: $parser->attr_encoded(1);
501: while (my $token = $parser->get_token) {
502: if ($token->[0] eq 'S') {
503: if (($token->[1] eq 'resource') &&
504: ($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') &&
505: ($changes{$token->[2]->{'id'}})) {
506: my $id = $token->[2]->{'id'};
507: $updatedcontent .= '<'.$token->[1];
508: foreach my $attrib (@{$token->[3]}) {
509: next unless ($attrib =~ /^(src|type|title|id)$/);
510: if ($attrib eq 'src') {
511: my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/);
512: if ($file) {
513: $updatedcontent .= ' '.$attrib.'="'.$file.'"';
514: } else {
515: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
516: }
517: } else {
518: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
519: }
520: }
521: $updatedcontent .= ' />'."\n";
522: } else {
523: $updatedcontent .= $token->[4]."\n";
524: }
525: } else {
526: $updatedcontent .= $token->[2];
527: }
528: }
529: print $fh $updatedcontent;
530: } else {
531: print $fh &Apache::lonclonecourse::rewritefile(
532: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
533: (%replacehash,$crs => '')
534: );
535: }
536: } else {
537: print $fh
538: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
539: }
540: } else {
541: $fail = &mt('Source does not exist.');
542: }
543: }
544: $fh->close();
545: } else {
546: $fail = &mt('Could not write to destination.');
547: }
548: }
549: my $text;
550: if ($fail) {
551: $text = '<span class="LC_error">'.&mt('fail').(' 'x3).$fail.'</span>';
552: } else {
553: $text = '<span class="LC_success">'.&mt('ok').'</span>';
554: }
555: if ($i == 0) {
556: $result .= $text;
557: } else {
558: $depresult .= $text.'</li>';
559: }
560: }
561: $r->print($result);
562: if ($depresult) {
563: $r->print('<ul>'.$depresult.'</ul>');
564: }
565: }
1.329 droeschl 566: } else {
1.484.2.43 raeburn 567: my ($navmap,$errormsg) =
568: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
569: if (!ref($navmap)) {
570: $r->print($errormsg);
571: } else {
572: $r->print('<div id="searching">'.&mt('Searching ...').'</div>');
573: $r->rflush();
574: my ($preamble,$formname);
575: $formname = 'dumpdoc';
576: unless ($home==1) {
577: $preamble = '<div class="LC_left_float">'.
578: '<fieldset><legend>'.
579: &mt('Select the Authoring Space').
580: '</legend><select name="authorspace">';
581: }
582: my @orderspaces = ();
583: foreach my $key (sort(keys(%outhash))) {
584: if ($key=~/^home_(.+)$/) {
585: if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) {
586: unshift(@orderspaces,$1);
587: } else {
588: push(@orderspaces,$1);
589: }
590: }
591: }
592: if ($home>1) {
593: $preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>';
594: }
595: foreach my $user (@orderspaces) {
596: if ($home==1) {
597: $preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />';
598: } else {
599: $preamble .= '<option value="'.$user.'">'.$user.' - '.
600: &Apache::loncommon::plainname(split(/\:/,$user)).'</option>';
601: }
602: }
603: unless ($home==1) {
604: $preamble .= '</select></fieldset></div>'."\n";
605: }
606: my $title=$origcrsdata{'description'};
607: $title=~s/[\/\s]+/\_/gs;
608: $title=&clean($title);
609: $preamble .= '<div class="LC_left_float">'.
610: '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.
611: '<input type="text" size="50" name="authorfolder" value="'.
612: $title.'" />'.
613: '</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n";
614: my %uploadedfiles;
615: &tiehash();
616: foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
617: my ($ext)=($file=~/\.(\w+)$/);
618: # FIXME Check supplemental here
619: my $title=$hash{'title_'.$hash{
620: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
621: if (!$title) {
622: $title=$file;
623: } else {
624: $title=~s|/|_|g;
625: }
626: $title=~s/\.(\w+)$//;
627: $title=&clean($title);
628: $title.='.'.$ext;
629: # $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
630: $uploadedfiles{$file} = $title;
631: }
632: &untiehash();
633: $r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef,
634: undef,undef,$preamble,$home,\%uploadedfiles));
635: }
1.329 droeschl 636: }
1.484 raeburn 637: $r->print(&endContentScreen());
1.329 droeschl 638: }
639:
1.484.2.43 raeburn 640: sub recurse_html {
641: my ($mm,$prefix,$currdirpath,$currurlpath,$container,$item,$replacehash,$deps) = @_;
642: return unless ((ref($replacehash) eq 'HASH') && (ref($deps) eq 'HASH'));
643: my (%allfiles,%codebase);
644: if (&Apache::lonnet::extract_embedded_items($currdirpath,\%allfiles,\%codebase) eq 'ok') {
645: if (keys(%allfiles)) {
646: foreach my $dependency (keys(%allfiles)) {
647: next if (($dependency =~ m{^/(res|adm)/}) || ($dependency =~ m{^https?://}));
648: my ($depurl,$relfile,$newcontainer);
649: if ($dependency =~ m{^/}) {
650: if ($dependency =~ m{^\Q$currurlpath/\E(.+)$}) {
651: $relfile = $1;
652: if ($dependency =~ m{^\Q$prefix\E(.+)$}) {
653: $newcontainer = $1;
654: next if ($replacehash->{$newcontainer});
655: }
656: $depurl = $dependency;
657: } else {
658: next;
659: }
660: } else {
661: $relfile = $dependency;
662: $depurl = $currurlpath;
663: $depurl =~ s{[^/]+$}{};
664: $depurl .= $dependency;
665: ($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$});
666: }
667: next if ($relfile eq '');
668: my $newname = $replacehash->{$container};
669: $newname =~ s{[^/]+$}{};
670: $replacehash->{$newcontainer} = $newname.$relfile;
671: $deps->{$item}{$newcontainer} = 1;
672: my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$});
673: my $depfile = &Apache::lonnet::filelocation('',$depurl);
674: my $type = $mm->checktype_filename($depfile);
675: if ($type eq 'text/html') {
676: &recurse_html($mm,$prefix,$depfile,$newurlpath,$newcontainer,$item,$replacehash,$deps);
677: }
678: }
679: }
680: }
681: return;
682: }
683:
1.329 droeschl 684: sub group_import {
1.484.2.93.2. (raeburn 685:): my ($coursenum, $coursedom, $folder, $container, $caller, $ltitoolsref, @files) = @_;
1.484.2.23 raeburn 686: my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap,
687: %removeparam,$importuploaded,$fixuperrors);
688: $allmaps = {};
1.329 droeschl 689: while (@files) {
690: my ($name, $url, $residx) = @{ shift(@files) };
1.344 bisitz 691: if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
1.329 droeschl 692: && ($caller eq 'londocs')
693: && (!&Apache::lonnet::stat_file($url))) {
1.364 bisitz 694:
1.329 droeschl 695: my $errtext = '';
696: my $fatal = 0;
697: my $newmapstr = '<map>'."\n".
698: '<resource id="1" src="" type="start"></resource>'."\n".
699: '<link from="1" to="2" index="1"></link>'."\n".
700: '<resource id="2" src="" type="finish"></resource>'."\n".
701: '</map>';
702: $env{'form.output'}=$newmapstr;
703: my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
704: 'output',$1.$2);
1.484.2.27 raeburn 705: if ($result !~ m{^/uploaded/}) {
1.329 droeschl 706: $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
707: $fatal = 2;
708: }
709: if ($fatal) {
710: return ($errtext,$fatal);
711: }
712: }
713: if ($url) {
1.484.2.93.2. (raeburn 714:): if ($url =~ m{^(/adm/$coursedom/$coursenum/(\d+)/ext\.tool)\:?(.*)$}) {
715:): $url = $1;
716:): my $marker = $2;
717:): my $info = $3;
2(raebur 718:3): my ($toolid,$toolprefix,$tooltype,%toolhash,%toolsettings);
(raeburn 719:): my @extras = ('linktext','explanation','crslabel','crstitle','crsappend');
720:): my @toolinfo = split(/:/,$info);
721:): if ($residx) {
722:): %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
723:): $toolid = $toolsettings{'id'};
724:): } else {
725:): $toolid = shift(@toolinfo);
726:): }
2(raebur 727:3): if ($toolid =~ /^c/) {
728:3): $tooltype = 'crs';
729:3): $toolprefix = 'c';
730:3): } else {
731:3): $tooltype = 'dom';
732:3): }
(raeburn 733:): $toolid =~ s/\D//g;
734:): ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'},
2(raebur 735:3): $toolhash{'linktext'},$toolhash{'explanation'},$toolhash{'crslabel'},
736:3): $toolhash{'crstitle'},$toolhash{'crsappend'},$toolhash{'gradable'}) = @toolinfo;
(raeburn 737:): foreach my $item (@extras) {
738:): $toolhash{$item} = &unescape($toolhash{$item});
739:): }
2(raebur 740:3): if ($folder =~ /^supplemental/) {
741:3): delete($toolhash{'gradable'});
742:3): } else {
743:3): $toolhash{'gradable'} =~ s/\D+//g;
744:3): }
(raeburn 745:): if (ref($ltitoolsref) eq 'HASH') {
2(raebur 746:3): if (ref($ltitoolsref->{$tooltype}) eq 'HASH') {
747:3): if (ref($ltitoolsref->{$tooltype}->{$toolid}) eq 'HASH') {
748:3): my %tools = %{$ltitoolsref->{$tooltype}->{$toolid}};
749:3): my @deleted;
750:3): $toolhash{'id'} = $toolprefix.$toolid;
751:3): if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'tab') ||
752:3): ($toolhash{'target'} eq 'window')) {
753:3): if ($toolhash{'target'} eq 'window') {
754:3): foreach my $item ('width','height') {
755:3): $toolhash{$item} =~ s/^\s+//;
756:3): $toolhash{$item} =~ s/\s+$//;
757:3): if ($toolhash{$item} =~ /\D/) {
758:3): delete($toolhash{$item});
759:3): if ($residx) {
760:3): if ($toolsettings{$item}) {
761:3): push(@deleted,$item);
762:3): }
(raeburn 763:): }
764:): }
765:): }
766:): }
2(raebur 767:3): } elsif ($residx) {
768:3): $toolhash{'target'} = $toolsettings{'target'};
769:3): if ($toolhash{'target'} eq 'window') {
770:3): foreach my $item ('width','height') {
771:3): $toolhash{$item} = $toolsettings{$item};
772:3): }
773:3): }
774:3): } elsif (ref($tools{'display'}) eq 'HASH') {
775:3): $toolhash{'target'} = $tools{'display'}{'target'};
776:3): if ($toolhash{'target'} eq 'window') {
777:3): $toolhash{'width'} = $tools{'display'}{'width'};
778:3): $toolhash{'height'} = $tools{'display'}{'height'};
(raeburn 779:): }
780:): }
2(raebur 781:3): if ($toolhash{'target'} eq 'iframe') {
782:3): foreach my $item ('width','height','linktext','explanation') {
783:3): delete($toolhash{$item});
784:3): if ($residx) {
785:3): if ($toolsettings{$item}) {
786:3): push(@deleted,$item);
787:3): }
(raeburn 788:): }
789:): }
2(raebur 790:3): } elsif ($toolhash{'target'} eq 'tab') {
791:3): foreach my $item ('width','height') {
792:3): delete($toolhash{$item});
793:3): if ($residx) {
794:3): if ($toolsettings{$item}) {
795:3): push(@deleted,$item);
796:3): }
(raeburn 797:): }
798:): }
799:): }
2(raebur 800:3): if (ref($tools{'crsconf'}) eq 'HASH') {
801:3): foreach my $item ('label','title','linktext','explanation') {
802:3): my $crsitem;
803:3): if (($item eq 'label') || ($item eq 'title')) {
804:3): $crsitem = 'crs'.$item;
805:3): } else {
806:3): $crsitem = $item;
807:3): }
808:3): if ($tools{'crsconf'}{$item}) {
809:3): $toolhash{$crsitem} =~ s/^\s+//;
810:3): $toolhash{$crsitem} =~ s/\s+$//;
811:3): if ($toolhash{$crsitem} eq '') {
812:3): delete($toolhash{$crsitem});
813:3): }
814:3): } else {
(raeburn 815:): delete($toolhash{$crsitem});
816:): }
2(raebur 817:3): if (($residx) && (exists($toolsettings{$crsitem}))) {
818:3): unless (exists($toolhash{$crsitem})) {
819:3): push(@deleted,$crsitem);
820:3): }
821:3): }
(raeburn 822:): }
2(raebur 823:3): }
824:3): if ($toolhash{'passback'}) {
825:3): my $gradesecret = UUID::Tiny::create_uuid_as_string(UUID_V4);
826:3): $toolhash{'gradesecret'} = $gradesecret;
827:3): $toolhash{'gradesecretdate'} = time;
828:3): }
829:3): if ($toolhash{'roster'}) {
830:3): my $rostersecret = UUID::Tiny::create_uuid_as_string(UUID_V4);
831:3): $toolhash{'rostersecret'} = $rostersecret;
832:3): $toolhash{'rostersecretdate'} = time;
833:3): }
834:3): my $changegradable;
835:3): if (($residx) && ($folder =~ /^default/)) {
836:3): if ($toolsettings{'gradable'}) {
837:3): unless (($toolhash{'gradable'}) || (defined($LONCAPA::map::zombies[$residx]))) {
838:3): push(@deleted,'gradable');
839:3): $changegradable = 1;
840:3): }
841:3): } elsif ($toolhash{'gradable'}) {
842:3): $changegradable = 1;
843:3): }
844:3): if (($caller eq 'londocs') && (defined($LONCAPA::map::zombies[$residx]))) {
845:3): $changegradable = 1;
846:3): if ($toolsettings{'gradable'}) {
847:3): $toolhash{'gradable'} = 1;
(raeburn 848:): }
849:): }
850:): }
2(raebur 851:3): my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum);
852:3): if ($putres eq 'ok') {
853:3): if (@deleted) {
854:3): &Apache::lonnet::del('exttool_'.$marker,\@deleted,$coursedom,$coursenum);
855:3): }
856:3): if (($changegradable) && ($folder =~ /^default/)) {
857:3): my $val;
858:3): if ($toolhash{'gradable'}) {
859:3): $val = 'yes';
860:3): } else {
861:3): $val = 'no';
862:3): }
863:3): &LONCAPA::map::storeparameter($residx,'parameter_0_gradable',$val,
864:3): 'string_yesno');
865:3): &remember_parms($residx,'gradable','set',$val);
866:3): }
867:3): } else {
868:3): return (&mt('Failed to save update to external tool.'),1);
(raeburn 869:): }
870:): }
871:): }
872:): }
873:): }
1.484.2.23 raeburn 874: if (($caller eq 'londocs') &&
875: ($folder =~ /^default/)) {
1.484.2.27 raeburn 876: if (($url =~ /\.(page|sequence)$/) && (!$donechk)) {
1.484.2.23 raeburn 877: my $chome = &Apache::lonnet::homeserver($coursenum,$coursedom);
878: my $cid = $coursedom.'_'.$coursenum;
879: $allmaps =
880: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
881: $chome,$cid);
882: $donechk = 1;
883: }
884: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) {
1.484.2.93.2. (raeburn 885:): &contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap,
886:): \%removeparam,\%addedmaps,\%hierarchy,\%titles,$allmaps);
1.484.2.23 raeburn 887: $importuploaded = 1;
888: } elsif ($url =~ m{^/res/.+\.(page|sequence)$}) {
889: next if ($allmaps->{$url});
890: }
891: }
1.344 bisitz 892: if (!$residx
1.329 droeschl 893: || defined($LONCAPA::map::zombies[$residx])) {
894: $residx = &LONCAPA::map::getresidx($url,$residx);
895: push(@LONCAPA::map::order, $residx);
896: }
897: my $ext = 'false';
898: if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
1.484.2.27 raeburn 899: if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) {
900: my $filepath = $1;
1.484.2.91 raeburn 901: my $fname;
902: if ($name eq '') {
903: $name = &mt('Web Page');
1.484.2.27 raeburn 904: $fname = 'web';
905: } else {
1.484.2.91 raeburn 906: $fname = $name;
907: $fname=&Apache::lonnet::clean_filename($fname);
908: if ($fname eq '') {
909: $fname = 'web';
910: } elsif (length($fname) > 15) {
911: $fname = substr($fname,0,14);
912: }
1.484.2.27 raeburn 913: }
1.484.2.91 raeburn 914: my $title = &Apache::loncommon::cleanup_html($name);
1.484.2.27 raeburn 915: my $initialtext = &mt('Replace with your own content.');
916: my $newhtml = <<END;
1.484.2.31 raeburn 917: <html>
1.484.2.27 raeburn 918: <head>
1.484.2.91 raeburn 919: <title>$title</title>
1.484.2.27 raeburn 920: </head>
921: <body bgcolor="#ffffff">
922: $initialtext
923: </body>
924: </html>
925: END
926: $env{'form.output'}=$newhtml;
927: my $result =
928: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
929: 'output',
930: "$filepath/$residx/$fname.html");
931: if ($result =~ m{^/uploaded/}) {
932: $url = $result;
933: if ($filepath =~ /^supplemental/) {
934: $name = time.'___&&&___'.$env{'user.name'}.'___&&&___'.
935: $env{'user.domain'}.'___&&&___'.$name;
936: }
937: } else {
938: return (&mt('Failed to save new web page.'),1);
939: }
940: }
1.484.2.91 raeburn 941: $name = &LONCAPA::map::qtunescape($name);
1.484.2.30 raeburn 942: $url = &LONCAPA::map::qtunescape($url);
1.344 bisitz 943: $LONCAPA::map::resources[$residx] =
1.329 droeschl 944: join(':', ($name, $url, $ext, 'normal', 'res'));
945: }
946: }
1.484.2.23 raeburn 947: if ($importuploaded) {
948: my %import_errors;
949: my %updated = (
950: removefrommap => \%removefrommap,
951: removeparam => \%removeparam,
952: );
1.484.2.26 raeburn 953: my ($result,$msgsarray,$lockerror) =
954: &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
1.484.2.23 raeburn 955: if (keys(%import_errors) > 0) {
956: $fixuperrors =
957: '<p span class="LC_warning">'."\n".
958: &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".
959: '<ul>'."\n";
960: foreach my $key (sort(keys(%import_errors))) {
961: $fixuperrors .= '<li>'.$key.'</li>'."\n";
962: }
963: $fixuperrors .= '</ul></p>'."\n";
964: }
1.484.2.26 raeburn 965: if (ref($msgsarray) eq 'ARRAY') {
966: if (@{$msgsarray} > 0) {
967: $fixuperrors .= '<p class="LC_info">'.
968: join('<br />',@{$msgsarray}).
969: '</p>';
970: }
971: }
972: if ($lockerror) {
973: $fixuperrors .= '<p class="LC_error">'.
974: $lockerror.
975: '</p>';
976: }
1.484.2.23 raeburn 977: }
978: my ($errtext,$fatal) =
979: &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
1.484.2.37 raeburn 980: unless ($fatal) {
981: if ($folder =~ /^supplemental/) {
1.484.2.39 raeburn 982: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
983: $folder.'.'.$container);
1.484.2.37 raeburn 984: }
985: }
1.484.2.23 raeburn 986: return ($errtext,$fatal,$fixuperrors);
1.329 droeschl 987: }
988:
989: sub log_docs {
1.484.2.8 raeburn 990: return &Apache::lonnet::write_log('course','docslog',@_);
1.329 droeschl 991: }
992:
993: {
994: my @oldresources=();
995: my @oldorder=();
996: my $parmidx;
997: my %parmaction=();
998: my %parmvalue=();
999: my $changedflag;
1000:
1001: sub snapshotbefore {
1002: @oldresources=@LONCAPA::map::resources;
1003: @oldorder=@LONCAPA::map::order;
1004: $parmidx=undef;
1005: %parmaction=();
1006: %parmvalue=();
1007: $changedflag=0;
1008: }
1009:
1010: sub remember_parms {
1011: my ($idx,$parameter,$action,$value)=@_;
1012: $parmidx=$idx;
1013: $parmaction{$parameter}=$action;
1014: $parmvalue{$parameter}=$value;
1015: $changedflag=1;
1016: }
1017:
1018: sub log_differences {
1019: my ($plain)=@_;
1020: my %storehash=('folder' => $plain,
1021: 'currentfolder' => $env{'form.folder'});
1022: if ($parmidx) {
1023: $storehash{'parameter_res'}=$oldresources[$parmidx];
1024: foreach my $parm (keys(%parmaction)) {
1025: $storehash{'parameter_action_'.$parm}=$parmaction{$parm};
1026: $storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
1027: }
1028: }
1029: my $maxidx=$#oldresources;
1030: if ($#LONCAPA::map::resources>$#oldresources) {
1031: $maxidx=$#LONCAPA::map::resources;
1032: }
1033: for (my $idx=0; $idx<=$maxidx; $idx++) {
1034: if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
1035: $storehash{'before_resources_'.$idx}=$oldresources[$idx];
1036: $storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
1037: $changedflag=1;
1038: }
1039: if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
1040: $storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
1041: $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
1042: $changedflag=1;
1043: }
1044: }
1045: $storehash{'maxidx'}=$maxidx;
1046: if ($changedflag) { &log_docs(\%storehash); }
1047: }
1048: }
1049:
1050: sub docs_change_log {
1.484.2.67 raeburn 1051: my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit)=@_;
1.484.2.6 raeburn 1052: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
1.484.2.67 raeburn 1053: my $navmap;
1.483 raeburn 1054: my $js = '<script type="text/javascript">'."\n".
1055: '// <![CDATA['."\n".
1056: &Apache::loncommon::display_filter_js('docslog')."\n".
1.484.2.67 raeburn 1057: &editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag,
1.484.2.93.2. 2(raebur 1058:3): $coursedom,$coursenum,'','',$canedit,'',\$navmap)."\n".
1.483 raeburn 1059: &history_tab_js()."\n".
1.484 raeburn 1060: &Apache::lonratedt::editscript('simple')."\n".
1.483 raeburn 1061: '// ]]>'."\n".
1062: '</script>'."\n";
1.484 raeburn 1063: $r->print(&Apache::loncommon::start_page('Content Change Log',$js));
1064: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Change Log'));
1.484.2.7 raeburn 1065: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484 raeburn 1066: my %orderhash;
1067: my $container='sequence';
1068: my $pathitem;
1.484.2.19 raeburn 1069: if ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 1070: $container='page';
1071: }
1.484.2.19 raeburn 1072: my $folderpath=$env{'form.folderpath'};
1073: if ($folderpath eq '') {
1.484.2.67 raeburn 1074: $folderpath = &default_folderpath($coursenum,$coursedom,\$navmap);
1.484.2.19 raeburn 1075: }
1.484.2.67 raeburn 1076: undef($navmap);
1.484.2.19 raeburn 1077: $pathitem = '<input type="hidden" name="folderpath" value="'.
1078: &HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 1079: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
1080: my $jumpto = $readfile;
1081: $jumpto =~ s{^/}{};
1082: my $tid = 1;
1.484.2.7 raeburn 1083: if ($supplementalflag) {
1084: $tid = 2;
1085: }
1.484.2.19 raeburn 1086: my ($breadcrumbtrail) =
1.484.2.18 raeburn 1087: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
1.484 raeburn 1088: $r->print($breadcrumbtrail.
1089: &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto,
1090: $readfile));
1.329 droeschl 1091: my %docslog=&Apache::lonnet::dump('nohist_docslog',
1092: $env{'course.'.$env{'request.course.id'}.'.domain'},
1093: $env{'course.'.$env{'request.course.id'}.'.num'});
1094:
1095: if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
1096:
1097: my %saveable_parameters = ('show' => 'scalar',);
1098: &Apache::loncommon::store_course_settings('docs_log',
1099: \%saveable_parameters);
1100: &Apache::loncommon::restore_course_settings('docs_log',
1101: \%saveable_parameters);
1102: if (!$env{'form.show'}) { $env{'form.show'}=10; }
1.452 www 1103: # FIXME: internationalization seems wrong here
1.329 droeschl 1104: my %lt=('hiddenresource' => 'Resources hidden',
1105: 'encrypturl' => 'URL hidden',
1106: 'randompick' => 'Randomly pick',
1107: 'randomorder' => 'Randomly ordered',
1.484.2.93.2. 2(raebur 1108:3): 'gradable' => 'Grade can be assigned to External Tool',
1.329 droeschl 1109: 'set' => 'set to',
1110: 'del' => 'deleted');
1.484 raeburn 1111: my $filter = &Apache::loncommon::display_filter('docslog')."\n".
1112: $pathitem."\n".
1113: '<input type="hidden" name="folder" value="'.$env{'form.folder'}.'" />'.
1114: (' 'x2).'<input type="submit" value="'.&mt('Display').'" />';
1115: $r->print('<div class="LC_left_float">'.
1116: '<fieldset><legend>'.&mt('Display of Content Changes').'</legend>'."\n".
1117: &makedocslogform($filter,1).
1118: '</fieldset></div><br clear="all" />');
1.329 droeschl 1119: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
1120: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
1121: &mt('After').'</th>'.
1122: &Apache::loncommon::end_data_table_header_row());
1123: my $shown=0;
1124: foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
1125: if ($env{'form.displayfilter'} eq 'currentfolder') {
1126: if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
1127: }
1128: my @changes=keys(%{$docslog{$id}{'logentry'}});
1129: if ($env{'form.displayfilter'} eq 'containing') {
1130: my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
1131: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
1132: foreach my $key (@changes) {
1133: $wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
1134: }
1.344 bisitz 1135: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
1.329 droeschl 1136: }
1137: my $count = 0;
1138: my $time =
1139: &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
1140: my $plainname =
1141: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
1142: $docslog{$id}{'exe_udom'});
1143: my $about_me_link =
1144: &Apache::loncommon::aboutmewrapper($plainname,
1145: $docslog{$id}{'exe_uname'},
1146: $docslog{$id}{'exe_udom'});
1147: my $send_msg_link='';
1148: if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
1149: || ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
1150: $send_msg_link ='<br />'.
1151: &Apache::loncommon::messagewrapper(&mt('Send message'),
1152: $docslog{$id}{'exe_uname'},
1153: $docslog{$id}{'exe_udom'});
1154: }
1155: $r->print(&Apache::loncommon::start_data_table_row());
1156: $r->print('<td>'.$time.'</td>
1157: <td>'.$about_me_link.
1158: '<br /><tt>'.$docslog{$id}{'exe_uname'}.
1159: ':'.$docslog{$id}{'exe_udom'}.'</tt>'.
1160: $send_msg_link.'</td><td>'.
1161: $docslog{$id}{'logentry'}{'folder'}.'</td><td>');
1.484.2.19 raeburn 1162: my $is_supp = 0;
1.484.2.7 raeburn 1163: if ($docslog{$id}{'logentry'}{'currentfolder'} =~ /^supplemental/) {
1164: $is_supp = 1;
1165: }
1.329 droeschl 1166: # Before
1167: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1168: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
1169: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
1170: if ($oldname ne $newname) {
1.484.2.7 raeburn 1171: my $shown = &LONCAPA::map::qtescape($oldname);
1172: if ($is_supp) {
1173: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1174: }
1175: $r->print($shown);
1.329 droeschl 1176: }
1177: }
1178: $r->print('<ul>');
1179: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1180: if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
1.484.2.7 raeburn 1181: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]);
1182: if ($is_supp) {
1183: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1184: }
1.484.2.19 raeburn 1185: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 1186: }
1187: }
1188: $r->print('</ul>');
1189: # After
1190: $r->print('</td><td>');
1191:
1192: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1193: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
1194: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
1195: if ($oldname ne '' && $oldname ne $newname) {
1.484.2.7 raeburn 1196: my $shown = &LONCAPA::map::qtescape($newname);
1197: if ($is_supp) {
1198: $shown = &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($newname));
1199: }
1200: $r->print($shown);
1.329 droeschl 1201: }
1.364 bisitz 1202: }
1.329 droeschl 1203: $r->print('<ul>');
1204: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1205: if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
1.484.2.7 raeburn 1206: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]);
1207: if ($is_supp) {
1208: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1209: }
1210: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 1211: }
1212: }
1213: $r->print('</ul>');
1214: if ($docslog{$id}{'logentry'}{'parameter_res'}) {
1.484.2.93.2. (raeburn 1215:): my ($title,$url) = split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'},3);
1216:): if ($title eq '') {
1217:): ($title) = ($url =~ m{/([^/]+)$});
1(raebur 1218:3): } elsif ($is_supp) {
1219:3): $title = &Apache::loncommon::parse_supplemental_title($title);
(raeburn 1220:): }
1221:): $r->print(&LONCAPA::map::qtescape($title).':<ul>');
2(raebur 1222:3): foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder','gradable') {
1.329 droeschl 1223: if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
1.452 www 1224: # FIXME: internationalization seems wrong here
1.329 droeschl 1225: $r->print('<li>'.
1226: &mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
1227: $docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
1228: .'</li>');
1229: }
1230: }
1231: $r->print('</ul>');
1232: }
1233: # End
1234: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1235: $shown++;
1236: if (!($env{'form.show'} eq &mt('all')
1237: || $shown<=$env{'form.show'})) { last; }
1238: }
1.484 raeburn 1239: $r->print(&Apache::loncommon::end_data_table()."\n".
1240: &makesimpleeditform($pathitem)."\n".
1241: '</div></div>');
1242: $r->print(&endContentScreen());
1.329 droeschl 1243: }
1244:
1245: sub update_paste_buffer {
1.484.2.7 raeburn 1246: my ($coursenum,$coursedom,$folder) = @_;
1.484.2.57 raeburn 1247: my (@possibles,%removals,%cuts,$output);
1.484.2.30 raeburn 1248: if ($env{'form.multiremove'}) {
1249: $env{'form.multiremove'} =~ s/,$//;
1250: map { $removals{$_} = 1; } split(/,/,$env{'form.multiremove'});
1251: }
1252: if (($env{'form.multicopy'}) || ($env{'form.multicut'})) {
1253: if ($env{'form.multicut'}) {
1254: $env{'form.multicut'} =~ s/,$//;
1255: foreach my $item (split(/,/,$env{'form.multicut'})) {
1256: unless ($removals{$item}) {
1257: $cuts{$item} = 1;
1258: push(@possibles,$item.':cut');
1259: }
1260: }
1261: }
1262: if ($env{'form.multicopy'}) {
1263: $env{'form.multicopy'} =~ s/,$//;
1264: foreach my $item (split(/,/,$env{'form.multicopy'})) {
1265: unless ($removals{$item} || $cuts{$item}) {
1266: push(@possibles,$item.':copy');
1267: }
1268: }
1269: }
1270: } elsif ($env{'form.markcopy'}) {
1271: @possibles = split(/,/,$env{'form.markcopy'});
1272: }
1.329 droeschl 1273:
1.484.2.30 raeburn 1274: return if (@possibles == 0);
1.329 droeschl 1275: return if (!defined($env{'form.copyfolder'}));
1276:
1277: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1278: $env{'form.copyfolder'});
1279: return if ($fatal);
1280:
1.484.2.30 raeburn 1281: my %curr_groups = &Apache::longroup::coursegroups();
1282:
1283: # Retrieve current paste buffer suffixes.
1284: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1285: my (%pasteurls,@newpaste);
1286:
1287: # Construct identifiers for current contents of user's paste buffer
1288: if (@currpaste) {
1289: foreach my $suffix (@currpaste) {
1.484.2.87 raeburn 1290: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1291: my $url = $env{'docs.markedcopy_url_'.$suffix};
1292: my $mapidx = $env{'docs.markedcopy_map_'.$suffix};
1293: if (($cid =~ /^$match_domain(?:_)$match_courseid$/) &&
1294: ($url ne '')) {
1295: if ($url eq '/res/lib/templates/simpleproblem.problem') {
1296: $pasteurls{$cid.'_'.$mapidx} = 1;
1297: } elsif ($url =~ m{^/res/$match_domain/$match_username/}) {
1298: $pasteurls{$url} = 1;
1299: } else {
1300: $pasteurls{$cid.'_'.$url} = 1;
1301: }
1302: }
1.484.2.30 raeburn 1303: }
1304: }
1305:
1306: # Mark items for copying (skip any items already in user's paste buffer)
1307: my %addtoenv;
1.484.2.82 raeburn 1308:
1309: my @pathitems = split(/\&/,$env{'form.folderpath'});
1310: my @folderconf = split(/\:/,$pathitems[-1]);
1.484.2.87 raeburn 1311: my $ispage = $folderconf[5];
1.484.2.82 raeburn 1312:
1.484.2.30 raeburn 1313: foreach my $item (@possibles) {
1314: my ($orderidx,$cmd) = split(/:/,$item);
1315: next if ($orderidx =~ /\D/);
1316: next unless (($cmd eq 'cut') || ($cmd eq 'copy') || ($cmd eq 'remove'));
1.484.2.82 raeburn 1317: my $mapidx = $folder.':'.$orderidx.':'.$ispage;
1.484.2.30 raeburn 1318: my ($title,$url)=split(':',$LONCAPA::map::resources[$orderidx]);
1319: my %denied = &action_restrictions($coursenum,$coursedom,
1320: &LONCAPA::map::qtescape($url),
1321: $env{'form.folderpath'},\%curr_groups);
1322: next if ($denied{'copy'});
1323: $url=~s{http(:|:)//https(:|:)//}{https$2//};
1.484.2.87 raeburn 1324: if ($url eq '/res/lib/templates/simpleproblem.problem') {
1325: next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$mapidx}));
1326: } elsif ($url =~ m{^/res/$match_domain/$match_username/}) {
1327: next if (exists($pasteurls{$url}));
1328: } else {
1329: next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$url}));
1330: }
1.484.2.30 raeburn 1331: my ($suffix,$errortxt,$locknotfreed) =
1332: &new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste');
1.484.2.57 raeburn 1333: if ($suffix ne '') {
1334: push(@newpaste,$suffix);
1335: } else {
1336: if ($locknotfreed) {
1337: return $locknotfreed;
1338: }
1.484.2.30 raeburn 1339: }
1340: if (&is_supplemental_title($title)) {
1341: &Apache::lonnet::appenv({'docs.markedcopy_supplemental_'.$suffix => $title});
1342: ($title) = &Apache::loncommon::parse_supplemental_title($title);
1343: }
1344:
1345: $addtoenv{'docs.markedcopy_title_'.$suffix} = $title,
1346: $addtoenv{'docs.markedcopy_url_'.$suffix} = $url,
1347: $addtoenv{'docs.markedcopy_cmd_'.$suffix} = $cmd,
1348: $addtoenv{'docs.markedcopy_crs_'.$suffix} = $env{'request.course.id'};
1.484.2.82 raeburn 1349: $addtoenv{'docs.markedcopy_map_'.$suffix} = $mapidx;
1.484.2.30 raeburn 1350: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) {
1351: my $prefix = $1;
1352: my $subdir =$2;
1353: if ($subdir eq '') {
1354: $subdir = $prefix;
1.484.2.7 raeburn 1355: }
1.484.2.30 raeburn 1356: my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps);
1.484.2.93.2. (raeburn 1357:): &contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap,
1358:): \%removeparam,\%addedmaps,\%hierarchy,\%titles,\%allmaps);
1.484.2.30 raeburn 1359: if (ref($hierarchy{$url}) eq 'HASH') {
1360: my ($nested,$nestednames);
1361: &recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames);
1362: $nested =~ s/\&$//;
1363: $nestednames =~ s/\Q___&&&___\E$//;
1364: if ($nested ne '') {
1365: $addtoenv{'docs.markedcopy_nested_'.$suffix} = $nested;
1366: }
1367: if ($nestednames ne '') {
1368: $addtoenv{'docs.markedcopy_nestednames_'.$suffix} = $nestednames;
1369: }
1.484.2.7 raeburn 1370: }
1371: }
1.484.2.57 raeburn 1372: if ($locknotfreed) {
1373: $output = $locknotfreed;
1374: last;
1375: }
1.484.2.7 raeburn 1376: }
1.484.2.30 raeburn 1377: if (@newpaste) {
1378: $addtoenv{'docs.markedcopies'} = join(',',(@currpaste,@newpaste));
1379: }
1.484.2.7 raeburn 1380: &Apache::lonnet::appenv(\%addtoenv);
1.329 droeschl 1381: delete($env{'form.markcopy'});
1.484.2.57 raeburn 1382: return $output;
1.329 droeschl 1383: }
1384:
1.484.2.7 raeburn 1385: sub recurse_uploaded_maps {
1386: my ($url,$dir,$hierarchy,$titlesref,$nestref,$namesref) = @_;
1387: if (ref($hierarchy->{$url}) eq 'HASH') {
1388: my @maps = map { $hierarchy->{$url}{$_}; } sort { $a <=> $b } (keys(%{$hierarchy->{$url}}));
1389: my @titles = map { $titlesref->{$url}{$_}; } sort { $a <=> $b } (keys(%{$titlesref->{$url}}));
1390: my (@uploaded,@names,%shorter);
1391: for (my $i=0; $i<@maps; $i++) {
1392: my ($inner) = ($maps[$i] =~ m{^/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_(\d+)\.(?:page|sequence)$});
1393: if ($inner ne '') {
1394: push(@uploaded,$inner);
1395: push(@names,&escape($titles[$i]));
1396: $shorter{$maps[$i]} = $inner;
1397: }
1398: }
1399: $$nestref .= "$dir:".join(',',@uploaded).'&';
1400: $$namesref .= "$dir:".(join(',',@names)).'___&&&___';
1401: foreach my $map (@maps) {
1402: if ($shorter{$map} ne '') {
1403: &recurse_uploaded_maps($map,$shorter{$map},$hierarchy,$titlesref,$nestref,$namesref);
1404: }
1405: }
1406: }
1407: return;
1408: }
1409:
1.329 droeschl 1410: sub print_paste_buffer {
1.484.2.7 raeburn 1411: my ($r,$container,$folder,$coursedom,$coursenum) = @_;
1.484.2.30 raeburn 1412: return if (!defined($env{'docs.markedcopies'}));
1.329 droeschl 1413:
1.484.2.30 raeburn 1414: unless (($env{'form.pastemarked'}) || ($env{'form.clearmarked'})) {
1415: return if ($env{'docs.markedcopies'} eq '');
1.484.2.7 raeburn 1416: }
1417:
1.484.2.30 raeburn 1418: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1.484.2.93.2. 5(raebur 1419:3): my ($pasteitems,@pasteable,$same_institution,$checkedsameinst);
1.484.2.47 raeburn 1420: my $clipboardcount = 0;
1.484.2.7 raeburn 1421:
1.484.2.30 raeburn 1422: # Construct identifiers for current contents of user's paste buffer
1423: foreach my $suffix (@currpaste) {
1424: next if ($suffix =~ /\D/);
1425: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1426: my $url = $env{'docs.markedcopy_url_'.$suffix};
1.484.2.82 raeburn 1427: my $mapidx = $env{'docs.markedcopy_map_'.$suffix};
1.484.2.30 raeburn 1428: if (($cid =~ /^$match_domain\_$match_courseid$/) &&
1429: ($url ne '')) {
1.484.2.47 raeburn 1430: $clipboardcount ++;
1.484.2.30 raeburn 1431: my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent,
1.484.2.93.2. 5(raebur 1432:3): $canpaste,$nopaste,$othercrs,$areachange,$is_exttool,$toolcdom,
1433:3): $toolcnum,$marker);
1.484.2.30 raeburn 1434: my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1];
1435: if ($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
1436: $is_external = 1;
1.484.2.93.2. 5(raebur 1437:3): } elsif ($url =~ m{^/adm/($match_domain)/($match_courseid)/(\d+)/ext\.tool$}) {
1438:3): ($toolcdom,$toolcnum,$marker) = ($1,$2,$3);
(raeburn 1439:): $is_exttool = 1;
1.484.2.7 raeburn 1440: }
1.484.2.30 raeburn 1441: if ($folder =~ /^supplemental/) {
1442: $canpaste = &supp_pasteable($env{'docs.markedcopy_url_'.$suffix});
1443: unless ($canpaste) {
1444: $nopaste = &mt('Paste into Supplemental Content unavailable.');
1.484.2.7 raeburn 1445: }
1.484.2.30 raeburn 1446: } else {
1447: $canpaste = 1;
1.484.2.7 raeburn 1448: }
1.484.2.30 raeburn 1449: if ($canpaste) {
1450: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1451: my $srcdom = $1;
1452: my $srcnum = $2;
1453: my $rem = $3;
1454: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
1455: $othercourse = 1;
1456: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1.484.2.76 raeburn 1457: $othercrs = '<br />'.&mt('(from another course)');
1.484.2.30 raeburn 1458: } else {
1459: $canpaste = 0;
1460: $nopaste = &mt('Paste from another course unavailable.');
1.484.2.7 raeburn 1461: }
1462: }
1.484.2.30 raeburn 1463: if ($rem =~ m{^(default|supplemental)_?(\d*)\.(?:page|sequence)$}) {
1464: my $prefix = $1;
1465: $parent = $2;
1466: if ($folder !~ /^\Q$prefix\E/) {
1467: $areachange = 1;
1468: }
1469: $is_uploaded_map = 1;
1470: }
1.484.2.82 raeburn 1471: } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
1.484.2.93.2. (raeburn 1472:): ($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg|ext\.tool)$})) {
1.484.2.76 raeburn 1473: if ($cid ne $env{'request.course.id'}) {
1474: my ($srcdom,$srcnum) = split(/_/,$cid);
1475: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1.484.2.93.2. 5(raebur 1476:3): if ($is_exttool) {
1477:3): if ($toolcdom ne $coursedom) {
1478:3): $canpaste = 0;
1479:3): $nopaste = &mt('Paste from another domain unavailable.');
1480:3): } elsif ($toolcnum ne $coursenum) {
1481:3): my %toolsettings =
1482:3): &Apache::lonnet::dump('exttool_'.$marker,$toolcdom,$toolcnum);
1483:3): my %tooltypes = &Apache::loncommon::usable_exttools();
1484:3): if ((($toolsettings{'id'} =~ /^c\d+$/) && (!$tooltypes{'crs'})) ||
1485:3): (($toolsettings{'id'} =~ /^\d+$/) && (!$tooltypes{'dom'}))) {
1486:3): $canpaste = 0;
1487:3): $nopaste = &mt('Paste from another course unavailable.');
1488:3): } elsif ($toolsettings{'id'} =~ /^c\d+$/) {
1489:3): unless ($checkedsameinst) {
1490:3): my $primary_id = &Apache::lonnet::domain($coursedom,'primary');
1491:3): my $intdom = &Apache::lonnet::internet_dom($primary_id);
1492:3): if ($intdom ne '') {
1493:3): my $internet_names =
1494:3): &Apache::lonnet::get_internet_names($Apache::lonnet::perlvar{'lonHostID'});
1495:3): if (ref($internet_names) eq 'ARRAY') {
1496:3): if (grep(/^\Q$intdom\E$/,@{$internet_names})) {
1497:3): $same_institution = 1;
1498:3): }
1499:3): }
1500:3): }
1501:3): $checkedsameinst = 1;
1502:3): }
1503:3): if ($same_institution) {
1504:3): $othercrs = '<br />'.&mt('(from another course)');
1505:3): } else {
1506:3): $nopaste = &mt('Paste from another course unavailable.');
1507:3): }
1508:3): } else {
1509:3): $othercrs = '<br />'.&mt('(from another course)');
1510:3): }
1511:3): }
(raeburn 1512:): }
1.484.2.76 raeburn 1513: } else {
1514: $canpaste = 0;
1515: $nopaste = &mt('Paste from another course unavailable.');
1516: }
1517: }
1518: }
1519: if ($canpaste) {
1520: push(@pasteable,$suffix);
1.484.2.30 raeburn 1521: }
1522: }
1523: my $buffer;
1524: if ($is_external) {
1525: $buffer = &mt('External Resource').': '.
1526: &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('.
1527: &LONCAPA::map::qtescape($url).')';
1.484.2.93.2. (raeburn 1528:): } elsif ($is_exttool) {
1529:): $buffer = &mt('External Tool').': '.
1530:): &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.484.2.30 raeburn 1531: } else {
1532: my $icon = &Apache::loncommon::icon($extension);
1533: if ($extension eq 'sequence' &&
1534: $url =~ m{/default_\d+\.sequence$}x) {
1535: $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
1536: $icon .= '/navmap.folder.closed.gif';
1537: }
1.484.2.57 raeburn 1538: my $title = $env{'docs.markedcopy_title_'.$suffix};
1539: if ($title eq '') {
1540: ($title) = ($url =~ m{/([^/]+)$});
1541: }
1.484.2.30 raeburn 1542: $buffer = '<img src="'.$icon.'" alt="" class="LC_icon" />'.
1543: ': '.
1544: &Apache::loncommon::parse_supplemental_title(
1.484.2.57 raeburn 1545: &LONCAPA::map::qtescape($title));
1.484.2.30 raeburn 1546: }
1547: $pasteitems .= '<div class="LC_left_float">';
1548: my ($options,$onclick);
1549: if (($canpaste) && (!$areachange) && (!$othercourse) &&
1550: ($env{'docs.markedcopy_cmd_'.$suffix} eq 'cut')) {
1551: if (($is_uploaded_map) ||
1552: ($url =~ /(bulletinboard|smppg)$/) ||
1553: ($url =~ m{^/uploaded/$coursedom/$coursenum/(?:docs|supplemental)/(.+)$})) {
1554: $options = &paste_options($suffix,$is_uploaded_map,$parent);
1555: $onclick= 'onclick="showOptions(this,'."'$suffix'".');" ';
1556: }
1557: }
1558: $pasteitems .= '<label><input type="checkbox" name="pasting" id="pasting_'.$suffix.'" value="'.$suffix.'" '.$onclick.'/>'.$buffer.'</label>';
1559: if ($nopaste) {
1.484.2.93.2. (raeburn 1560:): $pasteitems .= ' <span class="LC_cusr_emph">'.$nopaste.'</span>';
1.484.2.30 raeburn 1561: } else {
1562: if ($othercrs) {
1563: $pasteitems .= $othercrs;
1564: }
1565: if ($options) {
1566: $pasteitems .= $options;
1.484.2.7 raeburn 1567: }
1568: }
1.484.2.30 raeburn 1569: $pasteitems .= '</div>';
1570: }
1571: }
1572: if ($pasteitems eq '') {
1573: &Apache::lonnet::delenv('docs.markedcopies');
1574: }
1575: my ($pasteform,$form_start,$buttons,$form_end);
1576: if ($pasteitems) {
1577: $pasteitems .= '<div style="padding:0;clear:both;margin:0;border:0"></div>';
1578: $form_start = '<form name="pasteform" action="/adm/coursedocs" method="post" onsubmit="return validateClipboard();">';
1579: if (@pasteable) {
1.484.2.47 raeburn 1580: my $value = &mt('Paste to current folder');
1581: if ($container eq 'page') {
1582: $value = &mt('Paste to current page');
1583: }
1584: $buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.(' 'x2);
1585: }
1.484.2.93.2. (raeburn 1586:): $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.(' 'x2);
1.484.2.47 raeburn 1587: if ($clipboardcount > 1) {
1588: $buttons .=
1589: '<span style="text-decoration:line-through">'.(' 'x20).'</span>'.(' 'x2).
1590: '<input type="button" name="checkallclip" value="'.&mt('Check all').'" style="height:20px;" onclick="checkClipboard();" />'.
1591: (' 'x2).
1592: '<input type="button" name="uncheckallclip" value="'.&mt('Uncheck all').'" style="height:20px;" onclick="uncheckClipboard();" />'.
1593: (' 'x2);
1.484.2.7 raeburn 1594: }
1.484.2.48 raeburn 1595: $form_end = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'.
1596: '</form>';
1.484.2.30 raeburn 1597: } else {
1598: $pasteitems = &mt('Clipboard is empty');
1599: }
1600: $r->print($form_start
1601: .'<fieldset>'
1602: .'<legend>'.&mt('Clipboard').(' ' x2).$buttons.'</legend>'
1603: .$pasteitems
1604: .'</fieldset>'
1605: .$form_end);
1606: }
1607:
1608: sub paste_options {
1609: my ($suffix,$is_uploaded_map,$parent) = @_;
1610: my ($copytext,$movetext);
1611: if ($is_uploaded_map) {
1612: $copytext = &mt('Copy to new folder');
1613: $movetext = &mt('Move old');
1614: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /bulletinboard$/) {
1615: $copytext = &mt('Copy to new board');
1616: $movetext = &mt('Move (not posts)');
1617: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /smppg$/) {
1618: $copytext = &mt('Copy to new page');
1619: $movetext = &mt('Move');
1.484.2.7 raeburn 1620: } else {
1.484.2.30 raeburn 1621: $copytext = &mt('Copy to new file');
1622: $movetext = &mt('Move');
1623: }
1624: my $output = '<br />'.
1625: '<span id="pasteoptionstext_'.$suffix.'" class="LC_fontsize_small LC_nobreak"></span>'.
1626: '<div id="pasteoptions_'.$suffix.'" class="LC_dccid" style="display:none;"><span class="LC_nobreak">'.(' 'x 4).
1627: '<label>'.
1628: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="new" checked="checked" />'.
1629: $copytext.'</label></span>'.(' 'x2).' '.
1630: '<span class="LC_nobreak"><label>'.
1631: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="move" />'.
1632: $movetext.'</label></span>';
1633: if (($is_uploaded_map) && ($env{'docs.markedcopy_nested_'.$suffix})) {
1634: $output .= '<br /><fieldset><legend>'.&mt('Folder to paste contains sub-folders').
1635: '</legend><table border="0">';
1636: my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1637: my @titles = split(/\Q___&&&___\E/,$env{'docs.markedcopy_nestednames_'.$suffix});
1638: my $lastdir = $parent;
1639: my %depths = (
1640: $lastdir => 0,
1641: );
1642: my (%display,%deps);
1643: for (my $i=0; $i<@pastemaps; $i++) {
1644: ($lastdir,my $subfolderstr) = split(/\:/,$pastemaps[$i]);
1645: my ($namedir,$esctitlestr) = split(/\:/,$titles[$i]);
1646: my @subfolders = split(/,/,$subfolderstr);
1647: $deps{$lastdir} = \@subfolders;
1648: my @subfoldertitles = map { &unescape($_); } split(/,/,$esctitlestr);
1649: my $depth = $depths{$lastdir} + 1;
1650: my $offset = int($depth * 4);
1651: my $indent = (' ' x $offset);
1652: for (my $j=0; $j<@subfolders; $j++) {
1653: $depths{$subfolders[$j]} = $depth;
1654: $display{$subfolders[$j]} =
1655: '<tr><td>'.$indent.$subfoldertitles[$j].' </td>'.
1656: '<td><label>'.
1657: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="new" checked="checked" />'.&mt('Copy to new').'</label>'.(' ' x2).
1658: '<label>'.
1659: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="move" />'.
1660: &mt('Move old').'</label>'.
1661: '</td></tr>';
1662: }
1663: }
1664: &recurse_print(\$output,$parent,\%deps,\%display);
1665: $output .= '</table></fieldset>';
1.329 droeschl 1666: }
1.484.2.30 raeburn 1667: $output .= '</div>';
1668: return $output;
1.329 droeschl 1669: }
1670:
1.484.2.7 raeburn 1671: sub recurse_print {
1.484.2.30 raeburn 1672: my ($outputref,$dir,$deps,$display) = @_;
1673: $$outputref .= $display->{$dir}."\n";
1.484.2.7 raeburn 1674: if (ref($deps->{$dir}) eq 'ARRAY') {
1675: foreach my $subdir (@{$deps->{$dir}}) {
1.484.2.30 raeburn 1676: &recurse_print($outputref,$subdir,$deps,$display);
1.484.2.7 raeburn 1677: }
1678: }
1679: }
1680:
1681: sub supp_pasteable {
1682: my ($url) = @_;
1683: if (($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//}) ||
1684: (($url =~ /\.sequence$/) && ($url =~ m{^/uploaded/})) ||
1685: ($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) ||
1686: ($url =~ m{^/adm/$match_domain/$match_username/aboutme}) ||
1.484.2.93.2. (raeburn 1687:): ($url =~ m{^/public/$match_domain/$match_courseid/syllabus}) ||
1688:): ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$})) {
1.484.2.7 raeburn 1689: return 1;
1690: }
1691: return;
1692: }
1693:
1694: sub paste_popup_js {
1.484.2.61 raeburn 1695: my %html_js_lt = &Apache::lonlocal::texthash(
1.484.2.30 raeburn 1696: show => 'Show Options',
1697: hide => 'Hide Options',
1.484.2.61 raeburn 1698: );
1699: my %js_lt = &Apache::lonlocal::texthash(
1.484.2.30 raeburn 1700: none => 'No items selected from clipboard.',
1.484.2.7 raeburn 1701: );
1.484.2.61 raeburn 1702: &html_escape(\%html_js_lt);
1703: &js_escape(\%html_js_lt);
1704: &js_escape(\%js_lt);
1.484.2.7 raeburn 1705: return <<"END";
1706:
1.484.2.30 raeburn 1707: function showPasteOptions(suffix) {
1708: document.getElementById('pasteoptions_'+suffix).style.display='block';
1.484.2.61 raeburn 1709: document.getElementById('pasteoptionstext_'+suffix).innerHTML = ' <a href="javascript:hidePasteOptions(\\''+suffix+'\\');" class="LC_menubuttons_link">$html_js_lt{'hide'}</a>';
1.484.2.7 raeburn 1710: return;
1711: }
1712:
1.484.2.30 raeburn 1713: function hidePasteOptions(suffix) {
1714: document.getElementById('pasteoptions_'+suffix).style.display='none';
1.484.2.61 raeburn 1715: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.484.2.7 raeburn 1716: return;
1717: }
1718:
1.484.2.30 raeburn 1719: function showOptions(caller,suffix) {
1720: if (document.getElementById('pasteoptionstext_'+suffix)) {
1721: if (caller.checked) {
1.484.2.61 raeburn 1722: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.484.2.30 raeburn 1723: } else {
1724: document.getElementById('pasteoptionstext_'+suffix).innerHTML ='';
1725: }
1726: if (document.getElementById('pasteoptions_'+suffix)) {
1727: document.getElementById('pasteoptions_'+suffix).style.display='none';
1728: }
1729: }
1730: return;
1731: }
1.484.2.7 raeburn 1732:
1.484.2.30 raeburn 1733: function validateClipboard() {
1734: var numchk = 0;
1735: if (document.pasteform.pasting.length > 1) {
1736: for (var i=0; i<document.pasteform.pasting.length; i++) {
1737: if (document.pasteform.pasting[i].checked) {
1738: numchk ++;
1739: }
1740: }
1741: } else {
1742: if (document.pasteform.pasting.type == 'checkbox') {
1743: if (document.pasteform.pasting.checked) {
1744: numchk ++;
1745: }
1746: }
1747: }
1748: if (numchk > 0) {
1749: return true;
1750: } else {
1.484.2.61 raeburn 1751: alert("$js_lt{'none'}");
1.484.2.30 raeburn 1752: return false;
1753: }
1.484.2.7 raeburn 1754: }
1755:
1.484.2.47 raeburn 1756: function checkClipboard() {
1757: if (document.pasteform.pasting.length > 1) {
1758: for (var i=0; i<document.pasteform.pasting.length; i++) {
1759: document.pasteform.pasting[i].checked = true;
1760: }
1761: }
1762: return;
1763: }
1764:
1765: function uncheckClipboard() {
1766: if (document.pasteform.pasting.length >1) {
1767: for (var i=0; i<document.pasteform.pasting.length; i++) {
1768: document.pasteform.pasting[i].checked = false;
1769: }
1770: }
1771: return;
1772: }
1773:
1.484.2.30 raeburn 1774: END
1775:
1776: }
1.484.2.7 raeburn 1777:
1.329 droeschl 1778: sub do_paste_from_buffer {
1.484.2.7 raeburn 1779: my ($coursenum,$coursedom,$folder,$container,$errors) = @_;
1.329 droeschl 1780:
1.484.2.30 raeburn 1781: # Array of items in paste buffer
1782: my (@currpaste,%pastebuffer,%allerrors);
1783: @currpaste = split(/,/,$env{'docs.markedcopies'});
1784:
1.484.2.7 raeburn 1785: # Early out if paste buffer is empty
1.484.2.30 raeburn 1786: if (@currpaste == 0) {
1.484.2.7 raeburn 1787: return ();
1.484.2.30 raeburn 1788: }
1789: map { $pastebuffer{$_} = 1; } @currpaste;
1790:
1791: # Array of items selected items to paste
1792: my @reqpaste = &Apache::loncommon::get_env_multiple('form.pasting');
1793:
1794: # Early out if nothing selected to paste
1795: if (@reqpaste == 0) {
1796: return();
1797: }
1798: my @topaste;
1799: foreach my $suffix (@reqpaste) {
1800: next if ($suffix =~ /\D/);
1801: next unless (exists($pastebuffer{$suffix}));
1802: push(@topaste,$suffix);
1.484.2.7 raeburn 1803: }
1804:
1.484.2.30 raeburn 1805: # Early out if nothing available to paste
1806: if (@topaste == 0) {
1807: return();
1.329 droeschl 1808: }
1809:
1.484.2.93.2. 5(raebur 1810:3): my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%notindom,
1811:3): %othcrstool,%duplicate,%prefixchg,%srcdom,%srcnum,%srcmapidx,
1812:3): %marktomove,$save_err,$lockerrors,$allresult,%currcrsltitools,
1813:3): %currltititles,$currltimax,$gotcrsltitools);
1814:3): $currltimax = 0;
1815:3): $gotcrsltitools = 0;
1.484.2.30 raeburn 1816: foreach my $suffix (@topaste) {
1817: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1.484.2.76 raeburn 1818: my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.484.2.82 raeburn 1819: my $mapidx=&LONCAPA::map::qtescape($env{'docs.markedcopy_map_'.$suffix});
1.484.2.30 raeburn 1820: # Supplemental content may only include certain types of content
1821: # Early out if pasted content is not supported in Supplemental area
1822: if ($folder =~ /^supplemental/) {
1823: unless (&supp_pasteable($url)) {
1824: $notinsupp{$suffix} = 1;
1825: next;
1826: }
1827: }
1828: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/}) {
1829: my $srcd = $1;
1830: my $srcn = $2;
1.484.2.7 raeburn 1831: # When paste buffer was populated using an active role in a different course
1.484.2.30 raeburn 1832: # check for mdc privilege in the course from which the resource was pasted
1833: if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1834: unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1835: $notincrs{$suffix} = 1;
1836: next;
1837: }
1.329 droeschl 1838: }
1.484.2.30 raeburn 1839: $srcdom{$suffix} = $srcd;
1840: $srcnum{$suffix} = $srcn;
1.484.2.93.2. 2(raebur 1841:3): } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
1842:3): ($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg)$}) ||
1843:3): ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$})) {
(raeburn 1844:): my ($srcd,$srcn) = split(/_/,$cid);
1845:): # When paste buffer was populated using an active role in a different course
1846:): # check for mdc privilege in the course from which the resource was pasted
1847:): if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1848:): unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1849:): $notincrs{$suffix} = 1;
1850:): next;
1851:): }
1852:): }
1853:): # When buffer was populated using an active role in a different course
5(raebur 1854:3): # disallow pasting of External Tool if course is in a different domain,
1855:3): # or if External Tool use is not permitted in this course.
1856:3): if ($url =~ m{^/adm/($match_domain)/($match_courseid)/(\d+)/ext\.tool$}) {
1857:3): my ($toolcdom,$toolcnum,$marker) = ($1,$2,$3);
1858:3): if ($toolcdom ne $coursedom) {
1859:3): $notindom{$suffix} = 1;
1860:3): next;
1861:3): } elsif ($toolcnum ne $coursenum) {
1862:3): my %toolsettings =
1863:3): &Apache::lonnet::dump('exttool_'.$marker,$toolcdom,$toolcnum);
1864:3): my %tooltypes = &Apache::loncommon::usable_exttools();
1865:3): if ((($toolsettings{'id'} =~ /^c\d+$/) && (!$tooltypes{'crs'})) ||
1866:3): (($toolsettings{'id'} =~ /^\d+$/) && (!$tooltypes{'dom'}))) {
1867:3): $othcrstool{$suffix} = 1;
1868:3): next;
1869:3): }
1870:3): if ($toolsettings{'id'} =~ /^c\d+$/) {
1871:3): unless ($gotcrsltitools) {
1872:3): %currcrsltitools =
1873:3): &Apache::lonnet::get_course_lti($coursenum,$coursedom,'consumer');
1874:3): foreach my $item (sort(keys(%currcrsltitools))) {
1875:3): if (ref($currcrsltitools{$item}) eq 'HASH') {
1876:3): $currltimax ++;
1877:3): if (ref($currltititles{$currcrsltitools{$item}{'title'}}) eq 'ARRAY') {
1878:3): push(@{$currltititles{$currcrsltitools{$item}{'title'}}},$item);
1879:3): } else {
1880:3): $currltititles{$currcrsltitools{$item}{'title'}} = [$item];
1881:3): }
1882:3): }
1883:3): }
1884:3): $gotcrsltitools = 1;
1885:3): }
1886:3): }
1887:3): }
(raeburn 1888:): }
1889:): $srcdom{$suffix} = $srcd;
1890:): $srcnum{$suffix} = $srcn;
1.484.2.30 raeburn 1891: }
1.484.2.82 raeburn 1892: $srcmapidx{$suffix} = $mapidx;
1.484.2.30 raeburn 1893: push(@dopaste,$suffix);
1894: if ($url=~/\.(page|sequence)$/) {
1895: $is_map{$suffix} = 1;
1.329 droeschl 1896: }
1.484.2.30 raeburn 1897: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/([^/]+)}) {
1898: my $oldprefix = $1;
1.484.2.19 raeburn 1899: # When pasting content from Main Content to Supplemental Content and vice versa
1.484.2.7 raeburn 1900: # URLs will contain different paths (which depend on whether pasted item is
1.484.2.82 raeburn 1901: # a folder/page or a document).
1.484.2.30 raeburn 1902: if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) {
1903: $prefixchg{$suffix} = 'docstosupp';
1904: } elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) {
1905: $prefixchg{$suffix} = 'supptodocs';
1906: }
1.484.2.7 raeburn 1907:
1908: # If pasting an uploaded map, get list of contained uploaded maps.
1.484.2.30 raeburn 1909: if ($env{'docs.markedcopy_nested_'.$suffix}) {
1910: my @nested;
1911: my ($type) = ($oldprefix =~ /^(default|supplemental)/);
1912: my @items = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1913: my @deps = map { /\d+:([\d,]+$)/ } @items;
1914: foreach my $dep (@deps) {
1915: if ($dep =~ /,/) {
1916: push(@nested,split(/,/,$dep));
1917: } else {
1918: push(@nested,$dep);
1919: }
1.484.2.7 raeburn 1920: }
1.484.2.30 raeburn 1921: foreach my $item (@nested) {
1922: if ($env{'form.docs.markedcopy_'.$suffix.'_'.$item} eq 'move') {
1923: push(@{$marktomove{$suffix}},$type.'_'.$item);
1924: }
1.484.2.7 raeburn 1925: }
1926: }
1.329 droeschl 1927: }
1.484.2.7 raeburn 1928: }
1929:
1.484.2.30 raeburn 1930: # Early out if nothing available to paste
1931: if (@dopaste == 0) {
1932: return ();
1933: }
1934:
1935: # Populate message hash and hashes used for main content <=> supplemental content
1936: # changes
1937:
1938: %msgs = &Apache::lonlocal::texthash (
1939: notinsupp => 'Paste failed: content type is not supported within Supplemental Content',
1940: notincrs => 'Paste failed: Item is from a different course which you do not have rights to edit.',
1.484.2.93.2. 2(raebur 1941:3): notindom => 'Paste failed: Item is an external tool from a course in a different domain.',
5(raebur 1942:3): othcrstool => 'Paste failed: Item is an external tool from a different course, for which use is not allowed in this course.',
1.484.2.30 raeburn 1943: duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.',
1944: );
1945:
1946: %before = (
1947: docstosupp => {
1948: map => 'default',
1949: doc => 'docs',
1950: },
1951: supptodocs => {
1952: map => 'supplemental',
1953: doc => 'supplemental',
1954: },
1955: );
1956:
1957: %after = (
1958: docstosupp => {
1959: map => 'supplemental',
1960: doc => 'supplemental'
1961: },
1962: supptodocs => {
1963: map => 'default',
1964: doc => 'docs',
1965: },
1966: );
1967:
1968: # Retrieve information about all course maps in main content area
1969:
1970: my $allmaps = {};
1.484.2.93.2. 5(raebur 1971:3): my (@toclear,%mapurls,%lockerrs,%msgerrs,%results,$donechk,
1972:3): @updatetoolsenc,$updatetoolscache,$checkedsameinst,
1973:3): $same_institution);
1.484.2.30 raeburn 1974:
1975: # Loop over the items to paste
1976: foreach my $suffix (@dopaste) {
1.484.2.7 raeburn 1977: # Maps need to be copied first
1.484.2.30 raeburn 1978: my (%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies,
1979: %dbcopies,%zombies,%params,%docmoves,%mapmoves,%mapchanges,%newsubdir,
1.484.2.82 raeburn 1980: %newurls,%tomove,%resdatacopy);
1.484.2.30 raeburn 1981: if (ref($marktomove{$suffix}) eq 'ARRAY') {
1982: map { $tomove{$_} = 1; } @{$marktomove{$suffix}};
1983: }
1984: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1985: my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.484.2.76 raeburn 1986: my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.484.2.30 raeburn 1987: my $oldurl = $url;
1988: if ($is_map{$suffix}) {
1.484.2.7 raeburn 1989: # If pasting a map, check if map contains other maps
1.484.2.30 raeburn 1990: my (%hierarchy,%titles);
1.484.2.79 raeburn 1991: if (($folder =~ /^default/) && (!$donechk)) {
1992: $allmaps =
1993: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
1994: $env{"course.$env{'request.course.id'}.home"},
1995: $env{'request.course.id'});
1996: $donechk = 1;
1997: }
1.484.2.93.2. (raeburn 1998:): &contained_map_check($url,$folder,$coursenum,$coursedom,
1999:): \%removefrommap,\%removeparam,\%addedmaps,
2000:): \%hierarchy,\%titles,$allmaps);
1.484.2.30 raeburn 2001: if ($url=~ m{^/uploaded/}) {
2002: my $newurl;
2003: unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
2004: ($newurl,my $error) =
2005: &get_newmap_url($url,$folder,$prefixchg{$suffix},$coursedom,
2006: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
2007: \$title,$allmaps,\%newurls);
2008: if ($error) {
2009: $allerrors{$suffix} = $error;
2010: next;
2011: }
2012: if ($newurl ne '') {
2013: if ($newurl ne $url) {
2014: if ($newurl =~ /(?:default|supplemental)_(\d+).(?:sequence|page)$/) {
2015: $newsubdir{$url} = $1;
2016: }
2017: $mapchanges{$url} = 1;
1.484.2.7 raeburn 2018: }
2019: }
2020: }
1.484.2.30 raeburn 2021: if (($srcdom{$suffix} ne $coursedom) ||
2022: ($srcnum{$suffix} ne $coursenum) ||
2023: ($prefixchg{$suffix}) || (($newurl ne '') && ($newurl ne $url))) {
2024: unless (&url_paste_fixups($url,$folder,$prefixchg{$suffix},
2025: $coursedom,$coursenum,$srcdom{$suffix},
2026: $srcnum{$suffix},$allmaps,\%rewrites,
2027: \%retitles,\%copies,\%dbcopies,
2028: \%zombies,\%params,\%mapmoves,
2029: \%mapchanges,\%tomove,\%newsubdir,
1.484.2.82 raeburn 2030: \%newurls,\%resdatacopy)) {
1.484.2.30 raeburn 2031: $mapmoves{$url} = 1;
2032: }
2033: $url = $newurl;
2034: } elsif ($env{'docs.markedcopy_nested_'.$suffix}) {
2035: &url_paste_fixups($url,$folder,$prefixchg{$suffix},$coursedom,
2036: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
2037: $allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies,
2038: \%zombies,\%params,\%mapmoves,\%mapchanges,
1.484.2.82 raeburn 2039: \%tomove,\%newsubdir,\%newurls,\%resdatacopy);
1.484.2.30 raeburn 2040: }
2041: } elsif ($url=~m {^/res/}) {
1.484.2.82 raeburn 2042: # published map can only exist once, so remove from paste buffer when done
1.484.2.30 raeburn 2043: push(@toclear,$suffix);
2044: # if pasting published map (main content area only) check map not already in course
2045: if ($folder =~ /^default/) {
2046: if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) {
2047: $duplicate{$suffix} = 1;
2048: next;
2049: }
1.484.2.7 raeburn 2050: }
2051: }
2052: }
1.484.2.93.2. (raeburn 2053:): if ($url=~ m{/(bulletinboard|smppg|ext\.tool)$}) {
1.484.2.30 raeburn 2054: my $prefix = $1;
1.484.2.76 raeburn 2055: my $fromothercrs;
1.484.2.30 raeburn 2056: #need to copy the db contents to a new one, unless this is a move.
2057: my %info = (
2058: src => $url,
2059: cdom => $coursedom,
2060: cnum => $coursenum,
1.484.2.76 raeburn 2061: );
1.484.2.93.2. 2(raebur 2062:3): if ($prefix eq 'ext.tool') {
2063:3): if ($prefixchg{$suffix} eq 'docstosupp') {
2064:3): $info{'delgradable'} = 1;
2065:3): }
2066:3): }
1.484.2.76 raeburn 2067: if (($srcdom{$suffix} =~ /^$match_domain$/) && ($srcnum{$suffix} =~ /^$match_courseid$/)) {
2068: unless (($srcdom{$suffix} eq $coursedom) && ($srcnum{$suffix} eq $coursenum)) {
2069: $fromothercrs = 1;
2070: $info{'cdom'} = $srcdom{$suffix};
2071: $info{'cnum'} = $srcnum{$suffix};
1.484.2.93.2. 5(raebur 2072:3): unless ($checkedsameinst) {
2073:3): my $primary_id = &Apache::lonnet::domain($coursedom,'primary');
2074:3): my $intdom = &Apache::lonnet::internet_dom($primary_id);
2075:3): if ($intdom ne '') {
2076:3): my $internet_names =
2077:3): &Apache::lonnet::get_internet_names($Apache::lonnet::perlvar{'lonHostID'});
2078:3): if (ref($internet_names) eq 'ARRAY') {
2079:3): if (grep(/^\Q$intdom\E$/,@{$internet_names})) {
2080:3): $same_institution = 1;
2081:3): }
2082:3): }
2083:3): }
2084:3): $checkedsameinst = 1;
2085:3): }
1.484.2.76 raeburn 2086: }
2087: }
2088: unless (($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') && (!$fromothercrs)) {
1.484.2.30 raeburn 2089: my (%lockerr,$msg);
2090: my ($newurl,$result,$errtext) =
1.484.2.93.2. 5(raebur 2091:3): &dbcopy(\%info,$coursedom,$coursenum,\%lockerr,\%currltititles,
2092:3): \$currltimax,\@updatetoolsenc,\$updatetoolscache,$same_institution);
1.484.2.30 raeburn 2093: if ($result eq 'ok') {
2094: $url = $newurl;
2095: $title=&mt('Copy of').' '.$title;
2096: } else {
2097: if ($prefix eq 'smppg') {
2098: $msg = &mt('Paste failed: An error occurred when copying the simple page.').' '.$errtext;
2099: } elsif ($prefix eq 'bulletinboard') {
1.484.2.42 raeburn 2100: $msg = &mt('Paste failed: An error occurred when copying the discussion board.').' '.$errtext;
1.484.2.93.2. (raeburn 2101:): } elsif ($prefix eq 'ext.tool') {
2102:): $msg = &mt('Paste failed: An error occurred when copying the external tool.').' '.$errtext;
1.484.2.30 raeburn 2103: }
2104: $results{$suffix} = $result;
2105: $msgerrs{$suffix} = $msg;
2106: $lockerrs{$suffix} = $lockerr{$prefix};
2107: next;
2108: }
2109: if ($lockerr{$prefix}) {
2110: $lockerrs{$suffix} = $lockerr{$prefix};
1.484.2.26 raeburn 2111: }
1.484.2.7 raeburn 2112: }
1.484.2.30 raeburn 2113: }
2114: $title = &LONCAPA::map::qtunescape($title);
2115: my $ext='false';
2116: if ($url=~m{^http(|s)://}) { $ext='true'; }
2117: if ($env{'docs.markedcopy_supplemental_'.$suffix}) {
2118: if ($folder !~ /^supplemental/) {
2119: (undef,undef,$title) =
2120: &Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental_'.$suffix});
2121: }
2122: } else {
2123: if ($folder=~/^supplemental/) {
2124: $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
2125: $env{'user.domain'}.'___&&&___'.$title;
1.484.2.26 raeburn 2126: }
2127: }
1.484.2.7 raeburn 2128:
2129: # For uploaded files (excluding pages/sequences) path in copied file is changed
2130: # if paste is from Main to Supplemental (or vice versa), or if pasting between
2131: # courses.
2132:
1.484.2.30 raeburn 2133: unless ($is_map{$suffix}) {
2134: my $newidx;
1.329 droeschl 2135: # Now insert the URL at the bottom
1.484.2.30 raeburn 2136: $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
2137: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(.+)$}) {
2138: my $relpath = $1;
2139: if ($relpath ne '') {
2140: my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$});
2141: my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/);
2142: my $newprefix = $newloc;
2143: if ($newloc eq 'default') {
2144: $newprefix = 'docs';
2145: }
2146: if ($newdocsdir eq '') {
2147: $newdocsdir = 'default';
2148: }
2149: if (($prefixchg{$suffix}) ||
2150: ($srcdom{$suffix} ne $coursedom) ||
2151: ($srcnum{$suffix} ne $coursenum) ||
2152: ($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) {
2153: my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";
2154: $url =
2155: &Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath,
2156: &Apache::lonnet::getfile($oldurl));
2157: if ($url eq '/adm/notfound.html') {
2158: $msgs{$suffix} = &mt('Paste failed: an error occurred saving the file.');
2159: next;
2160: } else {
2161: my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$});
2162: $newsubpath =~ s{/+$}{/};
2163: $docmoves{$oldurl} = $newsubpath;
2164: }
1.484.2.7 raeburn 2165: }
2166: }
1.484.2.82 raeburn 2167: } elsif ($url =~ m{^/res/lib/templates/(\w+)\.problem$}) {
2168: my $template = $1;
2169: if ($newidx) {
2170: ©_templated_files($url,$srcdom{$suffix},$srcnum{$suffix},$srcmapidx{$suffix},
2171: $coursedom,$coursenum,$template,$newidx,"$folder.$container");
2172: }
1.484.2.93.2. 2(raebur 2173:3): } elsif ($url =~ /ext\.tool$/) {
2174:3): if (($newidx) && ($folder=~/^default/)) {
2175:3): my $marker = (split(m{/},$url))[4];
2176:3): my %toolsettings = &Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
2177:3): my $val = 'no';
2178:3): if ($toolsettings{'gradable'}) {
2179:3): $val = 'yes';
2180:3): }
2181:3): &LONCAPA::map::storeparameter($newidx,'parameter_0_gradable',$val,
2182:3): 'string_yesno');
2183:3): &remember_parms($newidx,'gradable','set',$val);
2184:3): }
1.484.2.7 raeburn 2185: }
1.484.2.30 raeburn 2186: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
2187: ':'.$ext.':normal:res';
2188: push(@LONCAPA::map::order,$newidx);
2189: # Store the result
2190: my ($errtext,$fatal) =
2191: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
2192: if ($fatal) {
2193: $save_err .= $errtext;
2194: $allresult = 'fail';
1.484.2.7 raeburn 2195: }
1.329 droeschl 2196: }
1.484.2.30 raeburn 2197:
1.484.2.82 raeburn 2198: # Apply any changes to maps, or copy dependencies for uploaded HTML pages, or update
2199: # resourcedata for simpleproblems copied from another course
1.484.2.30 raeburn 2200: unless ($allresult eq 'fail') {
2201: my %updated = (
2202: rewrites => \%rewrites,
2203: zombies => \%zombies,
2204: removefrommap => \%removefrommap,
2205: removeparam => \%removeparam,
2206: dbcopies => \%dbcopies,
1.484.2.82 raeburn 2207: resdatacopy => \%resdatacopy,
1.484.2.30 raeburn 2208: retitles => \%retitles,
2209: );
2210: my %info = (
2211: newsubdir => \%newsubdir,
2212: params => \%params,
2213: );
2214: if ($prefixchg{$suffix}) {
2215: $info{'before'} = $before{$prefixchg{$suffix}};
2216: $info{'after'} = $after{$prefixchg{$suffix}};
2217: }
2218: my %moves = (
2219: copies => \%copies,
2220: docmoves => \%docmoves,
2221: mapmoves => \%mapmoves,
2222: );
2223: (my $result,$msgs{$suffix},my $lockerror) =
2224: &apply_fixups($folder,$is_map{$suffix},$coursedom,$coursenum,$errors,
2225: \%updated,\%info,\%moves,$prefixchg{$suffix},$oldurl,
2226: $url,'paste');
2227: $lockerrors .= $lockerror;
2228: if ($result eq 'ok') {
2229: if ($is_map{$suffix}) {
2230: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
2231: $folder.'.'.$container);
2232: if ($fatal) {
2233: $allresult = 'failread';
2234: } else {
2235: if ($#LONCAPA::map::order<1) {
2236: my $idx=&LONCAPA::map::getresidx();
2237: if ($idx<=0) { $idx=1; }
2238: $LONCAPA::map::order[0]=$idx;
2239: $LONCAPA::map::resources[$idx]='';
2240: }
2241: my $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
2242: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
2243: ':'.$ext.':normal:res';
2244: push(@LONCAPA::map::order,$newidx);
1.484.2.7 raeburn 2245:
2246: # Store the result
1.484.2.30 raeburn 2247: my ($errtext,$fatal) =
2248: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
2249: if ($fatal) {
2250: $save_err .= $errtext;
2251: $allresult = 'failstore';
2252: }
2253: }
2254: }
2255: if ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
2256: push(@toclear,$suffix);
2257: }
2258: }
1.329 droeschl 2259: }
2260: }
1.484.2.93.2. 5(raebur 2261:3): if (($updatetoolscache) || (@updatetoolsenc)) {
2262:3): &update_ltitools_caches($coursedom,$coursenum,$updatetoolscache,
2263:3): \@updatetoolsenc);
2264:3): }
1.484.2.30 raeburn 2265: &clear_from_buffer(\@toclear,\@currpaste);
2266: my $msgsarray;
2267: foreach my $suffix (keys(%msgs)) {
2268: if (ref($msgs{$suffix}) eq 'ARRAY') {
2269: $msgsarray .= join(',',@{$msgs{$suffix}});
2270: }
2271: }
2272: return ($allresult,$save_err,$msgsarray,$lockerrors);
2273: }
2274:
2275: sub do_buffer_empty {
2276: my @currpaste = split(/,/,$env{'docs.markedcopies'});
2277: if (@currpaste == 0) {
2278: return &mt('Clipboard is already empty');
2279: }
2280: my @toclear = &Apache::loncommon::get_env_multiple('form.pasting');
2281: if (@toclear == 0) {
2282: return &mt('Nothing selected to clear from clipboard');
2283: }
2284: my $numdel = &clear_from_buffer(\@toclear,\@currpaste);
2285: if ($numdel) {
2286: return &mt('[quant,_1,item] cleared from clipboard',$numdel);
2287: } else {
2288: return &mt('Clipboard unchanged');
1.484.2.7 raeburn 2289: }
1.484.2.30 raeburn 2290: return;
2291: }
2292:
2293: sub clear_from_buffer {
2294: my ($toclear,$currpaste) = @_;
2295: return unless ((ref($toclear) eq 'ARRAY') && (ref($currpaste) eq 'ARRAY'));
2296: my %pastebuffer;
2297: map { $pastebuffer{$_} = 1; } @{$currpaste};
2298: my $numdel = 0;
2299: foreach my $suffix (@{$toclear}) {
2300: next if ($suffix =~ /\D/);
2301: next unless (exists($pastebuffer{$suffix}));
2302: my $regexp = 'docs.markedcopy_[a-z]+_'.$suffix;
2303: if (&Apache::lonnet::delenv($regexp,1) eq 'ok') {
2304: delete($pastebuffer{$suffix});
2305: $numdel ++;
2306: }
2307: }
2308: my $newbuffer = join(',',sort(keys(%pastebuffer)));
2309: &Apache::lonnet::appenv({'docs.markedcopies' => $newbuffer});
2310: return $numdel;
1.484.2.7 raeburn 2311: }
2312:
1.484.2.93.2. 5(raebur 2313:3): sub update_ltitools_caches {
2314:3): my ($coursedom,$coursenum,$updatetoolscache,$updatetoolsenc) = @_;
2315:3): my $hashid=$coursedom.'_'.$coursenum;
2316:3): if ($updatetoolscache) {
2317:3): &Apache::lonnet::devalidate_cache_new('courseltitools',$hashid);
2318:3): }
2319:3): if ((ref($updatetoolsenc) eq 'ARRAY') &&
2320:3): (@{$updatetoolsenc})) {
2321:3): my @ids=&Apache::lonnet::current_machine_ids();
2322:3): my $updatedone;
2323:3): foreach my $lonhost (@{$updatetoolsenc}) {
2324:3): if (grep(/^\Q$lonhost\E$/,@ids)) {
2325:3): unless ($updatedone) {
2326:3): &Apache::lonnet::devalidate_cache_new('crsltitoolsenc',$hashid);
2327:3): }
2328:3): $updatedone = 1;
2329:3): } else {
2330:3): &Apache::lonnet::remote_devalidate_cache($lonhost,["crsltitoolsenc:$hashid"]);
2331:3): }
2332:3): }
2333:3): }
2334:3): return;
2335:3): }
2336:3):
1.484.2.7 raeburn 2337: sub get_newmap_url {
2338: my ($url,$folder,$prefixchg,$coursedom,$coursenum,$srcdom,$srcnum,
2339: $titleref,$allmaps,$newurls) = @_;
2340: my $newurl;
2341: if ($url=~ m{^/uploaded/}) {
2342: $$titleref=&mt('Copy of').' '.$$titleref;
2343: }
2344: my $now = time;
2345: my $suffix=$$.int(rand(100)).$now;
2346: my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
2347: if ($oldid =~ m{^(/uploaded/$match_domain/$match_courseid/)(\D+)(\d+)$}) {
2348: my $path = $1;
2349: my $prefix = $2;
2350: my $ancestor = $3;
2351: if (length($ancestor) > 10) {
2352: $ancestor = substr($ancestor,-10,10);
2353: }
2354: my $newid;
2355: if ($prefixchg) {
2356: if ($folder =~ /^supplemental/) {
2357: $prefix =~ s/^default/supplemental/;
2358: } else {
2359: $prefix =~ s/^supplemental/default/;
2360: }
2361: }
2362: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
2363: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
2364: } else {
2365: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$now.'.'.$ext;
2366: }
2367: my $counter = 0;
2368: my $is_unique = &uniqueness_check($newurl);
2369: if ($folder =~ /^default/) {
2370: if ($allmaps->{$newurl}) {
2371: $is_unique = 0;
2372: }
2373: }
2374: while ((!$is_unique || $allmaps->{$newurl} || $newurls->{$newurl}) && ($counter < 100)) {
2375: $counter ++;
2376: $suffix ++;
2377: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
2378: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
2379: } else {
2380: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$ancestor.$suffix.'.'.$ext;
2381: }
2382: $is_unique = &uniqueness_check($newurl);
2383: }
2384: if ($is_unique) {
2385: $newurls->{$newurl} = 1;
2386: } else {
2387: if ($url=~/\.page$/) {
2388: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the composite page'));
2389: } else {
2390: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the folder'));
2391: }
2392: }
2393: }
2394: return ($newurl);
2395: }
2396:
2397: sub dbcopy {
1.484.2.93.2. 5(raebur 2398:3): my ($dbref,$coursedom,$coursenum,$lockerrorsref,$currltititles,
2399:3): $currltimax,$updatetoolsenc,$updatetoolscache,$same_institution) = @_;
1.484.2.26 raeburn 2400: my ($url,$result,$errtext);
2401: if (ref($dbref) eq 'HASH') {
1.484.2.71 raeburn 2402: $url = $dbref->{'src'};
1.484.2.93.2. (raeburn 2403:): if ($url =~ m{/(smppg|bulletinboard|ext\.tool)$}) {
1.484.2.26 raeburn 2404: my $prefix = $1;
1.484.2.93.2. (raeburn 2405:): if ($prefix eq 'ext.tool') {
2406:): $prefix = 'exttool';
2407:): }
1.484.2.26 raeburn 2408: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2409: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2410: my $db_name;
2411: my $marker = (split(m{/},$url))[4];
2412: $marker=~s/\D//g;
2413: if ($dbref->{'src'} =~ m{/smppg$}) {
2414: $db_name =
2415: &Apache::lonsimplepage::get_db_name($url,$marker,
2416: $dbref->{'cdom'},
2417: $dbref->{'cnum'});
1.484.2.93.2. (raeburn 2418:): } elsif ($dbref->{'src'} =~ m{/ext\.tool$}) {
2419:): $db_name = 'exttool_'.$marker;
1.484.2.26 raeburn 2420: } else {
2421: $db_name = 'bulletinpage_'.$marker;
2422: }
2423: my ($suffix,$freedlock,$error) =
2424: &Apache::lonnet::get_timebased_id($prefix,'num','templated',
2425: $coursedom,$coursenum,
2426: 'concat');
2427: if (!$suffix) {
2428: if ($prefix eq 'smppg') {
2429: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);
1.484.2.93.2. (raeburn 2430:): } elsif ($prefix eq 'exttool') {
2431:): $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying an external tool [_1].',$url);
1.484.2.26 raeburn 2432: } else {
1.484.2.42 raeburn 2433: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url);
1.484.2.26 raeburn 2434: }
2435: if ($error) {
2436: $errtext .= '<br />'.$error;
2437: }
2438: } else {
2439: #need to copy the db contents to a new one.
2440: my %contents=&Apache::lonnet::dump($db_name,
2441: $dbref->{'cdom'},
2442: $dbref->{'cnum'});
1.484.2.93.2. 5(raebur 2443:3): my ($toolcopyerror,$toolpassback,$toolroster,%toolinfo,$oldtoolid,$defincrs);
2444:3): if ($url eq '/adm/'.$dbref->{'cdom'}.'/'.$dbref->{'cnum'}."/$marker/ext.tool") {
2445:3): if ($contents{'id'} =~ /^(|c)(\d+)$/) {
2446:3): $oldtoolid = $2;
2447:3): if ($1 eq 'c') {
2448:3): $defincrs = 1;
2449:3): %toolinfo =
2450:3): &Apache::lonnet::get('ltitools',[$oldtoolid],$dbref->{'cdom'},$dbref->{'cnum'});
2451:3): } else {
2452:3): %toolinfo= &Apache::lonnet::get_domain_lti($dbref->{'cdom'},'consumer');
2453:3): }
2454:3): if (ref($toolinfo{$oldtoolid}) eq 'HASH') {
2455:3): if ($toolinfo{$oldtoolid}{'passback'}) {
2456:3): $toolpassback = 1;
2457:3): }
2458:3): if ($toolinfo{$oldtoolid}{'roster'}) {
2459:3): $toolroster = 1;
2460:3): }
2461:3): } else {
2462:3): $toolcopyerror = 1;
2463:3): $errtext = &mt('Could not retrieve original settings for pasted external tool.');
2464:3): }
2465:3): }
2466:3): unless (($dbref->{'cnum'} eq $coursenum) && ($dbref->{'cdom'} eq $coursedom)) {
2467:3): $url = "/adm/$coursedom/$coursenum/$marker/ext.tool";
2468:3): if ($contents{'crstitle'} ne '') {
2469:3): $contents{'crstitle'} = $env{'course.'.$coursedom.'_'.$coursenum.'.description'};
2470:3): }
2471:3): if (($defincrs) && (!$toolcopyerror)) {
2472:3): my %newtool;
2473:3): my $oldcdom = $dbref->{'cdom'};
2474:3): my $oldcnum = $dbref->{'cnum'};
2475:3): my $title = $toolinfo{$oldtoolid}{'title'};
2476:3): if (ref($currltititles) eq 'HASH') {
2477:3): if (exists($currltititles->{$title})) {
2478:3): $title .= ' (copied from another course)';
2479:3): }
2480:3): }
2481:3): my ($newid,$iderror) =
2482:3): &Apache::lonnet::get_ltitools_id('course',$coursedom,$coursenum,$title);
2483:3): if ($newid =~ /^\d+$/) {
2484:3): %{$newtool{$newid}} = %{$toolinfo{$oldtoolid}};
2485:3): $newtool{$newid}{'title'} = $title;
2486:3): if (ref($currltimax)) {
2487:3): $newtool{$newid}{'order'} = $$currltimax;
2488:3): }
2489:3): if ($newtool{$newid}{'image'} =~ m{^\Q/uploaded/$oldcdom/$oldcnum/toollogo/$oldtoolid/\E([^/]+)$}) {
2490:3): my $fname = $1;
2491:3): my $content = &Apache::lonnet::getfile($newtool{$newid}{'image'});
2492:3): if ($content eq '-1') {
2493:3): delete($newtool{$newid}{'image'});
2494:3): } else {
2495:3): $env{'form.'.$suffix.'.image'} = $content;
2496:3): my $newlogo =
2497:3): &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.image',"toollogo/$newid/$fname");
2498:3): delete($env{'form.'.$suffix.'.image'});
2499:3): if ($newlogo =~ m{^/uploaded/}) {
2500:3): $newtool{$newid}{'image'} = $newlogo;
2501:3): } else {
2502:3): delete($newtool{$newid}{'image'});
2503:3): }
2504:3): }
2505:3): }
2506:3): my $newusable;
2507:3): if ($same_institution) {
2508:3): my %oldtoolsenc = &Apache::lonnet::eget('nohist_toolsenc',[$oldtoolid],$oldcdom,$oldcnum);
2509:3): if (ref($oldtoolsenc{$oldtoolid}) eq 'HASH') {
2510:3): my %newtoolsenc;
2511:3): %{$newtoolsenc{$newid}} = %{$oldtoolsenc{$oldtoolid}};
2512:3): my $putres = &Apache::lonnet::put('nohist_toolsenc',\%newtoolsenc,$coursedom,$coursenum,1);
2513:3): if ($putres eq 'ok') {
2514:3): if (ref($updatetoolsenc) eq 'ARRAY') {
2515:3): my $newhome = &Apache::lonnet::homeserver($coursenum,$coursedom);
2516:3): unless (grep(/^\Q$newhome\E$/,@{$updatetoolsenc})) {
2517:3): push(@{$updatetoolsenc},$newhome);
2518:3): }
2519:3): }
2520:3): $newusable = 1;
2521:3): }
2522:3): }
2523:3): }
2524:3): if ($newtool{$newid}{'usable'}) {
2525:3): unless ($newusable) {
2526:3): delete($newtool{$newid}{'usable'});
2527:3): }
2528:3): }
2529:3): my $putres = &Apache::lonnet::put('ltitools',\%newtool,$coursedom,$coursenum);
2530:3): if ($putres eq 'ok') {
2531:3): $contents{'id'} = "c$newid";
2532:3): if (ref($updatetoolscache)) {
2533:3): $$updatetoolscache ++;
2534:3): }
2535:3): if (ref($currltititles->{$title}) eq 'ARRAY') {
2536:3): push(@{$currltititles->{$title}},$newid);
2537:3): } else {
2538:3): $currltititles->{$title} = [$newid];
2539:3): }
2540:3): if (ref($currltimax)) {
2541:3): $$currltimax ++;
2542:3): }
2543:3): } else {
2544:3): $toolcopyerror = 1;
2545:3): $errtext = &mt('Unable to save external tool definition in Course Settings.');
2546:3): }
2547:3): } else {
2548:3): $toolcopyerror = 1;
2549:3): $errtext = &mt('Unable to retrieve new tool ID when adding external tool definition to Course Settings.');
2550:3): }
2551:3): }
2552:3): }
2553:3): }
1.484.2.26 raeburn 2554: if (exists($contents{'uploaded.photourl'})) {
2555: my $photo = $contents{'uploaded.photourl'};
2556: my ($subdir,$fname) =
2557: ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});
2558: my $newphoto;
2559: if ($fname ne '') {
2560: my $content = &Apache::lonnet::getfile($photo);
2561: unless ($content eq '-1') {
2562: $env{'form.'.$suffix.'.photourl'} = $content;
2563: $newphoto =
2564: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");
2565: delete($env{'form.'.$suffix.'.photourl'});
2566: }
2567: }
2568: if ($newphoto =~ m{^/uploaded/}) {
2569: $contents{'uploaded.photourl'} = $newphoto;
2570: }
2571: }
2572: $db_name =~ s{_\d*$ }{_$suffix}x;
1.484.2.93.2. 5(raebur 2573:3): if ($prefix eq 'exttool') {
2574:3): unless ($toolcopyerror) {
2575:3): foreach my $key ('oldgradesecret','gradesecret','gradesecretdate','oldrostersecret','rostersecret','rostersecretdate') {
2576:3): if (exists($contents{$key})) {
2577:3): delete($contents{$key});
2578:3): }
2579:3): }
2580:3): if ($dbref->{'delgradable'}) {
2581:3): if (exists($contents{'gradable'})) {
2582:3): delete($contents{'gradable'});
2583:3): }
2584:3): }
2585:3): if ($toolpassback) {
2586:3): if ($contents{'gradable'}) {
2587:3): my $gradesecret = UUID::Tiny::create_uuid_as_string(UUID_V4);
2588:3): $contents{'gradesecret'} = $gradesecret;
2589:3): $contents{'gradesecretdate'} = time;
2590:3): }
2591:3): }
2592:3): if ($toolroster) {
2593:3): my $rostersecret = UUID::Tiny::create_uuid_as_string(UUID_V4);
2594:3): $contents{'rostersecret'} = $rostersecret;
2595:3): $contents{'rostersecretdate'} = time;
2596:3): }
2597:3): }
2(raebur 2598:3): }
5(raebur 2599:3): if (($prefix eq 'exttool') && ($toolcopyerror)) {
2600:3): $result = 'error';
2601:3): } else {
2602:3): $result=&Apache::lonnet::put($db_name,\%contents,
2603:3): $coursedom,$coursenum);
2604:3): if ($result eq 'ok') {
2605:3): $url =~ s{/(\d*)/(smppg|bulletinboard|ext\.tool)$}{/$suffix/$2}x;
2606:3): }
1.484.2.26 raeburn 2607: }
2608: }
2609: if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) {
2610: $lockerrorsref->{$prefix} =
2611: '<div class="LC_error">'.
2612: &mt('There was a problem removing a lockfile.');
2613: if ($prefix eq 'smppg') {
2614: $lockerrorsref->{$prefix} .=
1.484.2.38 raeburn 2615: ' '.&mt('This will prevent creation of additional simple pages in this course.');
1.484.2.93.2. (raeburn 2616:): } elsif ($prefix eq 'exttool') {
2617:): $lockerrorsref->{$prefix} .=
2618:): ' '.&mt('This will prevent addition of more external tools to this course.');
1.484.2.26 raeburn 2619: } else {
1.484.2.42 raeburn 2620: $lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional discussion boards in this course.');
1.484.2.26 raeburn 2621: }
1.484.2.38 raeburn 2622: $lockerrorsref->{$prefix} .= ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
2623: '<a href="/adm/helpdesk" target="_helpdesk">','</a>').
2624: '</div>';
1.484.2.26 raeburn 2625: }
2626: }
2627: } elsif ($url =~ m{/syllabus$}) {
2628: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2629: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2630: if (($dbref->{'cdom'} ne $coursedom) ||
2631: ($dbref->{'cnum'} ne $coursenum)) {
2632: my %contents=&Apache::lonnet::dump('syllabus',
2633: $dbref->{'cdom'},
2634: $dbref->{'cnum'});
2635: $result=&Apache::lonnet::put('syllabus',\%contents,
2636: $coursedom,$coursenum);
2637: }
2638: }
1.484.2.7 raeburn 2639: }
2640: }
1.484.2.26 raeburn 2641: return ($url,$result,$errtext);
1.329 droeschl 2642: }
2643:
1.484.2.82 raeburn 2644: sub copy_templated_files {
2645: my ($srcurl,$srcdom,$srcnum,$srcmapinfo,$coursedom,$coursenum,$template,$newidx,$newmapname) = @_;
2646: my ($srcfolder,$srcid,$srcwaspage) = split(/:/,$srcmapinfo);
2647: my $srccontainer = 'sequence';
2648: if ($srcwaspage) {
2649: $srccontainer = 'page';
2650: }
2651: my $srcsymb = "uploaded/$srcdom/$srcnum/$srcfolder.$srccontainer".
2652: '___'.$srcid.'___'.&Apache::lonnet::declutter($srcurl);
2653: my $srcprefix = $srcdom.'_'.$srcnum.'.'.$srcsymb;
2654: my %srcparms=&Apache::lonnet::dump('resourcedata',$srcdom,$srcnum,$srcprefix);
2655: my $newsymb = "uploaded/$coursedom/$coursenum/$newmapname".'___'.$newidx.'___lib/templates/'.
2656: $template.'.problem';
2657: my $newprefix = $coursedom.'_'.$coursenum.'.'.$newsymb;
2658: if ($template eq 'simpleproblem') {
2659: $srcprefix .= '.0.';
2660: my $weightprefix = $newprefix;
2661: $newprefix .= '.0.';
2662: my @simpleprobqtypes = qw(radio option string essay numerical);
2663: my $qtype=$srcparms{$srcprefix.'questiontype'};
2664: if (grep(/^\Q$qtype\E$/,@simpleprobqtypes)) {
2665: my %newdata = (
2666: $newprefix.'questiontype' => $qtype,
1.484.2.84 raeburn 2667: );
1.484.2.82 raeburn 2668: foreach my $type (@simpleprobqtypes) {
2669: if ($type eq $qtype) {
2670: $newdata{"$weightprefix.$type.weight"}=1;
2671: } else {
2672: $newdata{"$weightprefix.$type.weight"}=0;
2673: }
2674: }
2675: $newdata{$newprefix.'hiddenparts'} = '!'.$qtype;
2676: $newdata{$newprefix.'questiontext'} = $srcparms{$srcprefix.'questiontext'};
2677: $newdata{$newprefix.'hinttext'} = $srcparms{$srcprefix.'hinttext'};
2678: if ($qtype eq 'numerical') {
2679: $newdata{$newprefix.'numericalscript'} = $srcparms{$srcprefix.'numericalscript'};
2680: $newdata{$newprefix.'numericalanswer'} = $srcparms{$srcprefix.'numericalanswer'};
2681: $newdata{$newprefix.'numericaltolerance'} = $srcparms{$srcprefix.'numericaltolerance'};
2682: $newdata{$newprefix.'numericalsigfigs'} = $srcparms{$srcprefix.'numericalsigfigs'};
2683: } elsif (($qtype eq 'option') || ($qtype eq 'radio')) {
2684: my $maxfoils=$srcparms{$srcprefix.'maxfoils'};
2685: unless (defined($maxfoils)) { $maxfoils=10; }
2686: unless ($maxfoils=~/^\d+$/) { $maxfoils=10; }
2687: if ($maxfoils<=0) { $maxfoils=10; }
2688: my $randomize=$srcparms{$srcprefix.'randomize'};
2689: unless (defined($randomize)) { $randomize='yes'; }
2690: unless ($randomize eq 'no') { $randomize='yes'; }
2691: $newdata{$newprefix.'maxfoils'} = $maxfoils;
2692: $newdata{$newprefix.'randomize'} = $randomize;
2693: if ($qtype eq 'option') {
2694: $newdata{$newprefix.'options'} = $srcparms{$srcprefix.'options'};
2695: }
2696: for (my $i=1; $i<=10; $i++) {
2697: $newdata{$newprefix.'value'.$i} = $srcparms{$srcprefix.'value'.$i};
2698: $newdata{$newprefix.'position'.$i} = $srcparms{$srcprefix.'position'.$i};
2699: $newdata{$newprefix.'text'.$i} = $srcparms{$srcprefix.'text'.$i};
2700: }
2701:
2702: } elsif (($qtype eq 'option') || ($qtype eq 'radio')) {
2703: my $maxfoils=$srcparms{$srcprefix.'maxfoils'};
2704: unless (defined($maxfoils)) { $maxfoils=10; }
2705: unless ($maxfoils=~/^\d+$/) { $maxfoils=10; }
2706: if ($maxfoils<=0) { $maxfoils=10; }
2707: my $randomize=$srcparms{$srcprefix.'randomize'};
2708: unless (defined($randomize)) { $randomize='yes'; }
2709: unless ($randomize eq 'no') { $randomize='yes'; }
2710: $newdata{$newprefix.'maxfoils'} = $maxfoils;
2711: $newdata{$newprefix.'randomize'} = $randomize;
2712: if ($qtype eq 'option') {
2713: $newdata{$newprefix.'options'} = $srcparms{$srcprefix.'options'};
2714: }
2715: for (my $i=1; $i<=10; $i++) {
2716: $newdata{$newprefix.'value'.$i} = $srcparms{$srcprefix.'value'.$i};
2717: $newdata{$newprefix.'position'.$i} = $srcparms{$srcprefix.'position'.$i};
2718: $newdata{$newprefix.'text'.$i} = $srcparms{$srcprefix.'text'.$i};
2719: }
2720: } elsif ($qtype eq 'string') {
2721: $newdata{$newprefix.'stringanswer'} = $srcparms{$srcprefix.'stringanswer'};
2722: $newdata{$newprefix.'stringtype'} = $srcparms{$srcprefix.'stringtype'};
2723: }
2724: if (keys(%newdata)) {
2725: my $putres = &Apache::lonnet::cput('resourcedata',\%newdata,$coursedom,
2726: $coursenum);
2727: if ($putres eq 'ok') {
2728: &Apache::lonnet::devalidatecourseresdata($coursenum,$coursedom);
2729: }
2730: }
2731: }
2732: }
2733: }
2734:
1.329 droeschl 2735: sub uniqueness_check {
2736: my ($newurl) = @_;
2737: my $unique = 1;
2738: foreach my $res (@LONCAPA::map::order) {
2739: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2740: $url=&LONCAPA::map::qtescape($url);
2741: if ($newurl eq $url) {
2742: $unique = 0;
1.344 bisitz 2743: last;
1.329 droeschl 2744: }
2745: }
2746: return $unique;
2747: }
2748:
1.484.2.7 raeburn 2749: sub contained_map_check {
1.484.2.93.2. (raeburn 2750:): my ($url,$folder,$coursenum,$coursedom,$removefrommap,$removeparam,$addedmaps,
2751:): $hierarchy,$titles,$allmaps) = @_;
1.484.2.7 raeburn 2752: my $content = &Apache::lonnet::getfile($url);
2753: unless ($content eq '-1') {
2754: my $parser = HTML::TokeParser->new(\$content);
2755: $parser->attr_encoded(1);
2756: while (my $token = $parser->get_token) {
2757: next if ($token->[0] ne 'S');
2758: if ($token->[1] eq 'resource') {
2759: next if ($token->[2]->{'type'} eq 'zombie');
2760: my $ressrc = $token->[2]->{'src'};
1.484.2.93.2. 5(raebur 2761:3): if ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/(\d+)/ext\.tool$}) {
2762:3): my ($srcdom,$srcnum,$marker) = ($1,$2,$3);
2(raebur 2763:3): unless ($srcdom eq $coursedom) {
2764:3): $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2765:3): next;
2766:3): }
5(raebur 2767:3): unless ($srcnum eq $coursenum) {
2768:3): my %toolsettings =
2769:3): &Apache::lonnet::dump('exttool_'.$marker,$srcdom,$srcnum);
2770:3): my %tooltypes = &Apache::loncommon::usable_exttools();
2771:3): if ((($toolsettings{'id'} =~ /^c\d+$/) && (!$tooltypes{'crs'})) ||
2772:3): (($toolsettings{'id'} =~ /^\d+$/) && (!$tooltypes{'dom'}))) {
2773:3): $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2774:3): next;
2775:3): }
2776:3): }
2(raebur 2777:3): } elsif ($folder =~ /^supplemental/) {
1.484.2.7 raeburn 2778: unless (&supp_pasteable($ressrc)) {
2779: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2780: next;
2781: }
2782: }
2783: if ($ressrc =~ m{^/(res|uploaded)/.+\.(sequence|page)$}) {
2784: if ($1 eq 'uploaded') {
2785: $hierarchy->{$url}{$token->[2]->{'id'}} = $ressrc;
2786: $titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'};
2787: } else {
2788: if ($allmaps->{$ressrc}) {
1.484.2.23 raeburn 2789: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.484.2.7 raeburn 2790: } elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') {
2791: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2792: } else {
2793: $addedmaps->{$ressrc} = [$url];
2794: }
2795: }
1.484.2.93.2. (raeburn 2796:): &contained_map_check($ressrc,$folder,$coursenum,$coursedom,
2797:): $removefrommap,$removeparam,
1.484.2.7 raeburn 2798: $addedmaps,$hierarchy,$titles,$allmaps);
2799: }
2800: } elsif ($token->[1] eq 'param') {
2801: if ($folder =~ /^supplemental/) {
2802: if (ref($removeparam->{$url}{$token->[2]->{'to'}}) eq 'ARRAY') {
2803: push(@{$removeparam->{$url}{$token->[2]->{'to'}}},$token->[2]->{'name'});
2804: } else {
1.484.2.19 raeburn 2805: $removeparam->{$url}{$token->[2]->{'to'}} = [$token->[2]->{'name'}];
1.484.2.7 raeburn 2806: }
2807: }
2808: }
2809: }
2810: }
2811: return;
2812: }
2813:
2814: sub url_paste_fixups {
1.484.2.26 raeburn 2815: my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$fromcdom,$fromcnum,$allmaps,
2816: $rewrites,$retitles,$copies,$dbcopies,$zombies,$params,$mapmoves,
1.484.2.82 raeburn 2817: $mapchanges,$tomove,$newsubdir,$newurls,$resdatacopy) = @_;
1.484.2.7 raeburn 2818: my $checktitle;
2819: if (($prefixchg) &&
2820: ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) {
2821: $checktitle = 1;
2822: }
2823: my $skip;
2824: if ($oldurl =~ m{^\Q/uploaded/$cdom/$cnum/\E(default|supplemental)(_?\d*)\.(?:page|sequence)$}) {
2825: my $mapid = $1.$2;
2826: if ($tomove->{$mapid}) {
2827: $skip = 1;
2828: }
2829: }
2830: my $file = &Apache::lonnet::getfile($oldurl);
2831: return if ($file eq '-1');
2832: my $parser = HTML::TokeParser->new(\$file);
2833: $parser->attr_encoded(1);
2834: my $changed = 0;
2835: while (my $token = $parser->get_token) {
2836: next if ($token->[0] ne 'S');
2837: if ($token->[1] eq 'resource') {
2838: my $ressrc = $token->[2]->{'src'};
2839: next if ($ressrc eq '');
2840: my $id = $token->[2]->{'id'};
2841: my $title = $token->[2]->{'title'};
2842: if ($checktitle) {
2843: if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1.484.2.25 raeburn 2844: $retitles->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2845: }
2846: }
2847: next if ($token->[2]->{'type'} eq 'external');
2848: if ($token->[2]->{'type'} eq 'zombie') {
1.484.2.30 raeburn 2849: next if ($skip);
1.484.2.25 raeburn 2850: $zombies->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2851: $changed = 1;
2852: } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
2853: my $srcdom = $1;
2854: my $srcnum = $2;
2855: my $rem = $3;
2856: my $newurl;
2857: my $mapname;
2858: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
2859: my $prefix = $1;
2860: $mapname = $prefix.$2;
2861: if ($tomove->{$mapname}) {
1.484.2.26 raeburn 2862: &url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,
2863: $srcdom,$srcnum,$allmaps,$rewrites,
2864: $retitles,$copies,$dbcopies,$zombies,
2865: $params,$mapmoves,$mapchanges,$tomove,
1.484.2.82 raeburn 2866: $newsubdir,$newurls,$resdatacopy);
1.484.2.7 raeburn 2867: next;
2868: } else {
2869: ($newurl,my $error) =
2870: &get_newmap_url($ressrc,$folder,$prefixchg,$cdom,$cnum,
2871: $srcdom,$srcnum,\$title,$allmaps,$newurls);
2872: if ($newurl =~ /(?:default|supplemental)_(\d+)\.(?:sequence|page)$/) {
2873: $newsubdir->{$ressrc} = $1;
2874: }
2875: if ($error) {
2876: next;
2877: }
2878: }
2879: }
2880: if (($srcdom ne $cdom) || ($srcnum ne $cnum) || ($prefixchg) ||
2881: ($mapchanges->{$oldurl}) || (($newurl ne '') && ($newurl ne $oldurl))) {
1.484.2.19 raeburn 2882:
1.484.2.7 raeburn 2883: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
1.484.2.25 raeburn 2884: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2885: $mapchanges->{$ressrc} = 1;
1.484.2.26 raeburn 2886: unless (&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,
2887: $cnum,$srcdom,$srcnum,$allmaps,
2888: $rewrites,$retitles,$copies,$dbcopies,
2889: $zombies,$params,$mapmoves,$mapchanges,
1.484.2.82 raeburn 2890: $tomove,$newsubdir,$newurls,$resdatacopy)) {
1.484.2.7 raeburn 2891: $mapmoves->{$ressrc} = 1;
2892: }
2893: $changed = 1;
2894: } else {
1.484.2.25 raeburn 2895: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2896: $copies->{$oldurl}{$ressrc} = $id;
2897: $changed = 1;
2898: }
2899: }
1.484.2.93.2. 2(raebur 2900:3): } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/(.+)$}) {
1.484.2.30 raeburn 2901: next if ($skip);
1.484.2.7 raeburn 2902: my $srcdom = $1;
2903: my $srcnum = $2;
1.484.2.93.2. 2(raebur 2904:3): my $rem = $3;
2905:3): my ($is_exttool,$exttoolchg);
2906:3): if ($rem =~ m{\d+/ext\.tool$}) {
2907:3): $is_exttool = 1;
2908:3): }
1.484.2.7 raeburn 2909: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.484.2.25 raeburn 2910: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.26 raeburn 2911: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2912: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2913: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
2914: $changed = 1;
1.484.2.93.2. 2(raebur 2915:3): if ($is_exttool) {
2916:3): $exttoolchg = 1;
2917:3): }
2918:3): } elsif (($is_exttool) &&
2919:3): ($env{'form.docs.markedcopy_options'} ne 'move')) {
2920:3): $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2921:3): $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2922:3): $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
2923:3): $changed = 1;
2924:3): $exttoolchg = 1;
2925:3): }
2926:3): if (($is_exttool) && ($prefixchg)) {
2927:3): if ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/default}) {
2928:3): if ($exttoolchg) {
2929:3): $dbcopies->{$oldurl}{$id}{'delgradable'} = 1;
2930:3): }
2931:3): }
1.484.2.26 raeburn 2932: }
2933: } elsif ($ressrc =~ m{^/adm/$match_domain/$match_username/\d+/(smppg|bulletinboard)$}) {
2934: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum) ||
2935: ($env{'form.docs.markedcopy_options'} ne 'move')) {
2936: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2937: $dbcopies->{$oldurl}{$id}{'cdom'} = $fromcdom;
2938: $dbcopies->{$oldurl}{$id}{'cnum'} = $fromcnum;
1.484.2.7 raeburn 2939: $changed = 1;
2940: }
1.484.2.82 raeburn 2941: } elsif ($ressrc eq '/res/lib/templates/simpleproblem.problem') {
2942: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum)) {
2943: $resdatacopy->{$oldurl}{$id}{'src'} = $ressrc;
2944: $resdatacopy->{$oldurl}{$id}{'cdom'} = $fromcdom;
2945: $resdatacopy->{$oldurl}{$id}{'cnum'} = $fromcnum;
2946: }
1.484.2.7 raeburn 2947: } elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) {
2948: next if ($skip);
2949: my $srcdom = $1;
2950: my $srcnum = $2;
2951: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.484.2.26 raeburn 2952: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2953: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2954: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
1.484.2.7 raeburn 2955: $changed = 1;
2956: }
2957: }
2958: } elsif ($token->[1] eq 'param') {
2959: next if ($skip);
1.484.2.19 raeburn 2960: my $to = $token->[2]->{'to'};
1.484.2.7 raeburn 2961: if ($to ne '') {
2962: if (ref($params->{$oldurl}{$to}) eq 'ARRAY') {
2963: push(@{$params->{$oldurl}{$to}},$token->[2]->{'name'});
2964: } else {
2965: @{$params->{$oldurl}{$to}} = ($token->[2]->{'name'});
2966: }
2967: }
2968: }
2969: }
2970: return $changed;
2971: }
2972:
2973: sub apply_fixups {
1.484.2.23 raeburn 2974: my ($folder,$is_map,$cdom,$cnum,$errors,$updated,$info,$moves,$prefixchg,
2975: $oldurl,$url,$caller) = @_;
2976: my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles,
1.484.2.26 raeburn 2977: %params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs,
1.484.2.93.2. 5(raebur 2978:3): %resdatacopy,%lockerrors,$lockmsg,%currcrsltitools,$gotcrsltitools,
2979:3): %currltititles,$currltimax);
2980:3): $currltimax = 0;
1.484.2.23 raeburn 2981: if (ref($updated) eq 'HASH') {
2982: if (ref($updated->{'rewrites'}) eq 'HASH') {
2983: %rewrites = %{$updated->{'rewrites'}};
2984: }
2985: if (ref($updated->{'zombies'}) eq 'HASH') {
2986: %zombies = %{$updated->{'zombies'}};
2987: }
2988: if (ref($updated->{'removefrommap'}) eq 'HASH') {
2989: %removefrommap = %{$updated->{'removefrommap'}};
2990: }
2991: if (ref($updated->{'removeparam'}) eq 'HASH') {
2992: %removeparam = %{$updated->{'removeparam'}};
2993: }
2994: if (ref($updated->{'dbcopies'}) eq 'HASH') {
2995: %dbcopies = %{$updated->{'dbcopies'}};
2996: }
2997: if (ref($updated->{'retitles'}) eq 'HASH') {
2998: %retitles = %{$updated->{'retitles'}};
2999: }
1.484.2.82 raeburn 3000: if (ref($updated->{'resdatacopy'}) eq 'HASH') {
3001: %resdatacopy = %{$updated->{'resdatacopy'}};
3002: }
1.484.2.23 raeburn 3003: }
3004: if (ref($info) eq 'HASH') {
3005: if (ref($info->{'newsubdir'}) eq 'HASH') {
3006: %newsubdir = %{$info->{'newsubdir'}};
3007: }
3008: if (ref($info->{'params'}) eq 'HASH') {
3009: %params = %{$info->{'params'}};
3010: }
3011: if (ref($info->{'before'}) eq 'HASH') {
3012: %before = %{$info->{'before'}};
3013: }
3014: if (ref($info->{'after'}) eq 'HASH') {
3015: %after = %{$info->{'after'}};
3016: }
3017: }
3018: if (ref($moves) eq 'HASH') {
3019: if (ref($moves->{'copies'}) eq 'HASH') {
3020: %copies = %{$moves->{'copies'}};
3021: }
3022: if (ref($moves->{'docmoves'}) eq 'HASH') {
3023: %docmoves = %{$moves->{'docmoves'}};
3024: }
3025: if (ref($moves->{'mapmoves'}) eq 'HASH') {
3026: %mapmoves = %{$moves->{'mapmoves'}};
3027: }
3028: }
3029: foreach my $key (keys(%copies),keys(%docmoves)) {
1.484.2.7 raeburn 3030: my @allcopies;
1.484.2.23 raeburn 3031: if (exists($copies{$key})) {
3032: if (ref($copies{$key}) eq 'HASH') {
3033: my %added;
3034: foreach my $innerkey (keys(%{$copies{$key}})) {
3035: if (($innerkey ne '') && (!$added{$innerkey})) {
3036: push(@allcopies,$innerkey);
3037: $added{$innerkey} = 1;
3038: }
1.484.2.7 raeburn 3039: }
1.484.2.23 raeburn 3040: undef(%added);
1.484.2.7 raeburn 3041: }
3042: }
3043: if ($key eq $oldurl) {
1.484.2.23 raeburn 3044: if ((exists($docmoves{$key}))) {
1.484.2.25 raeburn 3045: unless (grep(/^\Q$oldurl\E$/,@allcopies)) {
1.484.2.7 raeburn 3046: push(@allcopies,$oldurl);
3047: }
3048: }
3049: }
3050: if (@allcopies > 0) {
3051: foreach my $item (@allcopies) {
1.484.2.19 raeburn 3052: my ($relpath,$oldsubdir,$fname) =
1.484.2.7 raeburn 3053: ($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(default|\d+)/.*/)([^/]+)$});
3054: if ($fname ne '') {
3055: my $content = &Apache::lonnet::getfile($item);
3056: unless ($content eq '-1') {
3057: my $storefn;
1.484.2.23 raeburn 3058: if (($key eq $oldurl) && (exists($docmoves{$key}))) {
3059: $storefn = $docmoves{$key};
1.484.2.7 raeburn 3060: } else {
3061: $storefn = $relpath;
3062: $storefn =~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 3063: if ($prefixchg && $before{'doc'} && $after{'doc'}) {
3064: $storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/;
1.484.2.7 raeburn 3065: }
1.484.2.23 raeburn 3066: if ($newsubdir{$key}) {
1.484.2.25 raeburn 3067: $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}/#;
1.484.2.7 raeburn 3068: }
3069: }
3070: ©_dependencies($item,$storefn,$relpath,$errors,\$content);
1.484.2.19 raeburn 3071: my $copyurl =
1.484.2.7 raeburn 3072: &Apache::lonclonecourse::writefile($env{'request.course.id'},
3073: $storefn.$fname,$content);
3074: if ($copyurl eq '/adm/notfound.html') {
1.484.2.23 raeburn 3075: if (exists($docmoves{$oldurl})) {
1.484.2.7 raeburn 3076: return &mt('Paste failed: an error occurred copying the file.');
3077: } elsif (ref($errors) eq 'HASH') {
3078: $errors->{$item} = 1;
3079: }
3080: }
3081: }
3082: }
3083: }
3084: }
3085: }
1.484.2.23 raeburn 3086: foreach my $key (keys(%mapmoves)) {
1.484.2.7 raeburn 3087: my $storefn=$key;
3088: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 3089: if ($prefixchg && $before{'map'} && $after{'map'}) {
3090: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.484.2.7 raeburn 3091: }
1.484.2.23 raeburn 3092: if ($newsubdir{$key}) {
3093: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.484.2.7 raeburn 3094: }
3095: my $mapcontent = &Apache::lonnet::getfile($key);
1.484.2.93.2. (raeburn 3096:): if (($mapcontent eq '-1') && ($before{'map'} eq 'supplemental') &&
3097:): ($after{'map'} eq 'default') &&
3098:): ($key =~ m{^/uploaded/$match_domain/$match_courseid/supplemental_\d+\.sequence$})) {
3099:): $mapcontent = '<map>'."\n".
3100:): '<resource id="1" src="" type="start" />'."\n".
3101:): '<link from="1" to="2" index="1" />'."\n".
3102:): '<resource id="2" src="" type="finish" />'."\n".
3103:): '</map>';
3104:): }
1.484.2.7 raeburn 3105: if ($mapcontent eq '-1') {
3106: if (ref($errors) eq 'HASH') {
3107: $errors->{$key} = 1;
3108: }
3109: } else {
3110: my $newmap =
3111: &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
3112: $mapcontent);
3113: if ($newmap eq '/adm/notfound.html') {
3114: if (ref($errors) eq 'HASH') {
3115: $errors->{$key} = 1;
3116: }
3117: }
3118: }
3119: }
3120: my %updates;
3121: if ($is_map) {
1.484.2.23 raeburn 3122: if (ref($updated) eq 'HASH') {
3123: foreach my $type (keys(%{$updated})) {
3124: if (ref($updated->{$type}) eq 'HASH') {
3125: foreach my $key (keys(%{$updated->{$type}})) {
3126: $updates{$key} = 1;
3127: }
3128: }
3129: }
1.484.2.7 raeburn 3130: }
1.484.2.93.2. 5(raebur 3131:3): my ($updatetoolscache,@updatetoolsenc,$same_institution,$checkedsameinst);
1.484.2.7 raeburn 3132: foreach my $key (keys(%updates)) {
3133: my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb);
1.484.2.23 raeburn 3134: if (ref($rewrites{$key}) eq 'HASH') {
3135: %torewrite = %{$rewrites{$key}};
1.484.2.7 raeburn 3136: }
1.484.2.23 raeburn 3137: if (ref($retitles{$key}) eq 'HASH') {
3138: %toretitle = %{$retitles{$key}};
1.484.2.7 raeburn 3139: }
1.484.2.23 raeburn 3140: if (ref($removefrommap{$key}) eq 'HASH') {
3141: %toremove = %{$removefrommap{$key}};
1.484.2.7 raeburn 3142: }
1.484.2.23 raeburn 3143: if (ref($removeparam{$key}) eq 'HASH') {
3144: %remparam = %{$removeparam{$key}};
1.484.2.7 raeburn 3145: }
1.484.2.23 raeburn 3146: if (ref($zombies{$key}) eq 'HASH') {
3147: %zombie = %{$zombies{$key}};
1.484.2.7 raeburn 3148: }
1.484.2.23 raeburn 3149: if (ref($dbcopies{$key}) eq 'HASH') {
1.484.2.26 raeburn 3150: foreach my $idx (keys(%{$dbcopies{$key}})) {
3151: if (ref($dbcopies{$key}{$idx}) eq 'HASH') {
1.484.2.93.2. 5(raebur 3152:3): my $oldurl = $dbcopies{$key}{$idx}{'src'};
3153:3): my $oldcdom = $dbcopies{$key}{$idx}{'cdom'};
3154:3): my $oldcnum = $dbcopies{$key}{$idx}{'cnum'};
3155:3): my $oldmarker;
3156:3): if ($oldurl =~ m{^\Q/adm/$oldcdom/$oldcnum/\E(\d+)/ext\.tool$}) {
3157:3): $oldmarker = $1;
3158:3): unless (($gotcrsltitools) ||
3159:3): (($oldcnum eq $cnum) && ($oldcdom eq $cdom))) {
3160:3): my %oldtoolsettings=&Apache::lonnet::dump('exttool_'.$oldmarker,$oldcdom,$oldcnum);
3161:3): if ($oldtoolsettings{'id'} =~ /^c\d+$/) {
3162:3): unless ($gotcrsltitools) {
3163:3): %currcrsltitools =
3164:3): &Apache::lonnet::get_course_lti($cnum,$cdom,'consumer');
3165:3): foreach my $item (sort(keys(%currcrsltitools))) {
3166:3): if (ref($currcrsltitools{$item}) eq 'HASH') {
3167:3): $currltimax ++;
3168:3): if (ref($currltititles{$currcrsltitools{$item}{'title'}}) eq 'ARRAY') {
3169:3): push(@{$currltititles{$currcrsltitools{$item}{'title'}}},$item);
3170:3): } else {
3171:3): $currltititles{$currcrsltitools{$item}{'title'}} = [$item];
3172:3): }
3173:3): }
3174:3): }
3175:3): $gotcrsltitools = 1;
3176:3): }
3177:3): unless ($checkedsameinst) {
3178:3): my $primary_id = &Apache::lonnet::domain($cdom,'primary');
3179:3): my $intdom = &Apache::lonnet::internet_dom($primary_id);
3180:3): if ($intdom ne '') {
3181:3): my $internet_names =
3182:3): &Apache::lonnet::get_internet_names($Apache::lonnet::perlvar{'lonHostID'});
3183:3): if (ref($internet_names) eq 'ARRAY') {
3184:3): if (grep(/^\Q$intdom\E$/,@{$internet_names})) {
3185:3): $same_institution = 1;
3186:3): }
3187:3): }
3188:3): }
3189:3): $checkedsameinst = 1;
3190:3): }
3191:3): }
3192:3): }
3193:3): }
1.484.2.26 raeburn 3194: my ($newurl,$result,$errtext) =
1.484.2.93.2. 5(raebur 3195:3): &dbcopy($dbcopies{$key}{$idx},$cdom,$cnum,\%lockerrors,\%currltititles,
3196:3): \$currltimax,\@updatetoolsenc,\$updatetoolscache,$same_institution);
1.484.2.26 raeburn 3197: if ($result eq 'ok') {
3198: $newdb{$idx} = $newurl;
1.484.2.93.2. 5(raebur 3199:3): if ($newurl =~ /ext\.tool$/) {
3200:3): if ($torewrite{$idx} eq "/adm/$oldcdom/$oldcnum/$oldmarker/ext.tool") {
3201:3): if ($newurl =~ m{^\Q/adm/$cdom/$cnum/\E(\d+)/ext.tool$}) {
3202:3): my $newmarker = $1;
3203:3): unless ($oldmarker eq $newmarker) {
3204:3): $torewrite{$idx} = "/adm/$oldcdom/$oldcnum/$newmarker/ext.tool";
3205:3): }
3206:3): }
3207:3): }
3208:3): }
1.484.2.26 raeburn 3209: } elsif (ref($errors) eq 'HASH') {
3210: $errors->{$key} = 1;
3211: }
3212: push(@msgs,$errtext);
3213: }
1.484.2.7 raeburn 3214: }
3215: }
1.484.2.82 raeburn 3216: if (ref($resdatacopy{$key}) eq 'HASH') {
3217: my ($gotnewmapname,$newmapname,$srcfolder,$srccontainer);
3218: foreach my $idx (keys(%{$resdatacopy{$key}})) {
3219: if (ref($resdatacopy{$key}{$idx}) eq 'HASH') {
3220: my $srcurl = $resdatacopy{$key}{$idx}{'src'};
3221: if ($srcurl =~ m{^/res/lib/templates/(\w+)\.problem$}) {
3222: my $template = $1;
3223: if (($resdatacopy{$key}{$idx}{'cdom'} =~ /^$match_domain$/) &&
3224: ($resdatacopy{$key}{$idx}{'cnum'} =~ /^$match_courseid$/)) {
3225: my $srcdom = $resdatacopy{$key}{$idx}{'cdom'};
3226: my $srcnum = $resdatacopy{$key}{$idx}{'cnum'};
3227: unless ($gotnewmapname) {
3228: ($newmapname) = ($key =~ m{/([^/]+)$});
3229: ($srcfolder,$srccontainer) = split(/\./,$newmapname);
3230: if ($newsubdir{$key}) {
3231: $newmapname =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
3232: }
3233: $gotnewmapname = 1;
3234: }
3235: my $srcmapinfo = $srcfolder.':'.$idx;
3236: if ($srccontainer eq 'page') {
3237: $srcmapinfo .= ':1';
3238: }
3239: ©_templated_files($srcurl,$srcdom,$srcnum,$srcmapinfo,$cdom,
3240: $cnum,$template,$idx,$newmapname);
3241: }
3242: }
3243: }
3244: }
3245: }
1.484.2.23 raeburn 3246: if (ref($params{$key}) eq 'HASH') {
3247: %currparam = %{$params{$key}};
1.484.2.7 raeburn 3248: }
3249: my ($errtext,$fatal) = &LONCAPA::map::mapread($key);
3250: if ($fatal) {
1.484.2.26 raeburn 3251: return ($errtext);
1.484.2.7 raeburn 3252: }
3253: for (my $i=0; $i<@LONCAPA::map::zombies; $i++) {
3254: if (defined($LONCAPA::map::zombies[$i])) {
3255: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::zombies[$i]);
1.484.2.25 raeburn 3256: if ($zombie{$i} eq $src) {
1.484.2.7 raeburn 3257: undef($LONCAPA::map::zombies[$i]);
3258: }
3259: }
3260: }
1.484.2.77 raeburn 3261: my $total = scalar(@LONCAPA::map::order) - 1;
3262: for (my $i=$total; $i>=0; $i--) {
1.484.2.23 raeburn 3263: my $idx = $LONCAPA::map::order[$i];
3264: if (defined($LONCAPA::map::resources[$idx])) {
1.484.2.7 raeburn 3265: my $changed;
1.484.2.23 raeburn 3266: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]);
1.484.2.30 raeburn 3267: if ((exists($toremove{$idx})) &&
3268: ($toremove{$idx} eq &LONCAPA::map::qtescape($src))) {
1.484.2.7 raeburn 3269: splice(@LONCAPA::map::order,$i,1);
1.484.2.23 raeburn 3270: if (ref($currparam{$idx}) eq 'ARRAY') {
3271: foreach my $name (@{$currparam{$idx}}) {
1.484.2.77 raeburn 3272: &LONCAPA::map::delparameter($idx,$name);
1.484.2.7 raeburn 3273: }
3274: }
3275: next;
3276: }
3277: my $origsrc = $src;
1.484.2.25 raeburn 3278: if ((exists($toretitle{$idx})) && ($toretitle{$idx} eq $src)) {
1.484.2.7 raeburn 3279: if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
3280: $changed = 1;
3281: }
3282: }
1.484.2.25 raeburn 3283: if ((exists($torewrite{$idx})) && ($torewrite{$idx} eq $src)) {
1.484.2.7 raeburn 3284: $src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
3285: if ($origsrc =~ m{^/uploaded/}) {
1.484.2.23 raeburn 3286: if ($prefixchg && $before{'map'} && $after{'map'}) {
1.484.2.7 raeburn 3287: if ($src =~ /\.(page|sequence)$/) {
1.484.2.23 raeburn 3288: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'map'}\E#$1$after{'map'}#;
1.484.2.7 raeburn 3289: } else {
1.484.2.23 raeburn 3290: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
1.484.2.7 raeburn 3291: }
3292: }
1.484.2.25 raeburn 3293: if ($origsrc =~ /\.(page|sequence)$/) {
3294: if ($newsubdir{$origsrc}) {
1.484.2.23 raeburn 3295: $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir{$origsrc}#;
1.484.2.7 raeburn 3296: }
1.484.2.25 raeburn 3297: } elsif ($newsubdir{$key}) {
3298: $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$key}#;
1.484.2.7 raeburn 3299: }
3300: }
3301: $changed = 1;
1.484.2.26 raeburn 3302: } elsif ($newdb{$idx} ne '') {
3303: $src = $newdb{$idx};
1.484.2.7 raeburn 3304: $changed = 1;
3305: }
3306: if ($changed) {
1.484.2.30 raeburn 3307: $LONCAPA::map::resources[$idx] = join(':',($title,&LONCAPA::map::qtunescape($src),$ext,$type));
1.484.2.7 raeburn 3308: }
3309: }
3310: }
3311: foreach my $idx (keys(%remparam)) {
3312: if (ref($remparam{$idx}) eq 'ARRAY') {
1.484.2.19 raeburn 3313: foreach my $name (@{$remparam{$idx}}) {
1.484.2.77 raeburn 3314: &LONCAPA::map::delparameter($idx,$name);
1.484.2.7 raeburn 3315: }
3316: }
3317: }
1.484.2.26 raeburn 3318: if (values(%lockerrors) > 0) {
3319: $lockmsg = join('<br />',values(%lockerrors));
3320: }
1.484.2.7 raeburn 3321: my $storefn;
3322: if ($key eq $oldurl) {
3323: $storefn = $url;
3324: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
3325: } else {
3326: $storefn = $key;
3327: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 3328: if ($prefixchg && $before{'map'} && $after{'map'}) {
3329: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.484.2.7 raeburn 3330: }
1.484.2.23 raeburn 3331: if ($newsubdir{$key}) {
3332: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.484.2.7 raeburn 3333: }
3334: }
3335: my $report;
3336: if ($folder !~ /^supplemental/) {
3337: $report = 1;
3338: }
1.484.2.20 raeburn 3339: (my $outtext,$errtext) =
1.484.2.7 raeburn 3340: &LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report);
3341: if ($errtext) {
1.484.2.23 raeburn 3342: if ($caller eq 'paste') {
1.484.2.26 raeburn 3343: return (&mt('Paste failed: an error occurred saving the folder or page.'));
1.484.2.23 raeburn 3344: }
1.484.2.7 raeburn 3345: }
3346: }
1.484.2.93.2. 5(raebur 3347:3): if (($updatetoolscache) || (@updatetoolsenc)) {
3348:3): &update_ltitools_caches($cdom,$cnum,$updatetoolscache,
3349:3): \@updatetoolsenc);
3350:3): }
1.484.2.7 raeburn 3351: }
1.484.2.26 raeburn 3352: return ('ok',\@msgs,$lockmsg);
1.484.2.7 raeburn 3353: }
3354:
3355: sub copy_dependencies {
3356: my ($item,$storefn,$relpath,$errors,$contentref) = @_;
3357: my $content;
3358: if (ref($contentref)) {
3359: $content = $$contentref;
3360: } else {
3361: $content = &Apache::lonnet::getfile($item);
3362: }
3363: unless ($content eq '-1') {
3364: my $mm = new File::MMagic;
3365: my $mimetype = $mm->checktype_contents($content);
3366: if ($mimetype eq 'text/html') {
3367: my (%allfiles,%codebase,$state);
3368: my $res = &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,\$content);
3369: if ($res eq 'ok') {
3370: my ($numexisting,$numpathchanges,$existing);
3371: (undef,$numexisting,$numpathchanges,$existing) =
3372: &Apache::loncommon::ask_for_embedded_content(
3373: '/adm/coursedocs',$state,\%allfiles,\%codebase,
3374: {'error_on_invalid_names' => 1,
3375: 'ignore_remote_references' => 1,
3376: 'docs_url' => $item,
3377: 'context' => 'paste'});
3378: if ($numexisting > 0) {
3379: if (ref($existing) eq 'HASH') {
3380: foreach my $dep (keys(%{$existing})) {
3381: my $depfile = $dep;
3382: unless ($depfile =~ m{^\Q$relpath\E}) {
3383: $depfile = $relpath.$dep;
3384: }
3385: my $depcontent = &Apache::lonnet::getfile($depfile);
3386: unless ($depcontent eq '-1') {
3387: my $storedep = $dep;
3388: $storedep =~ s{^\Q$relpath\E}{};
3389: my $dep_url =
3390: &Apache::lonclonecourse::writefile(
3391: $env{'request.course.id'},
3392: $storefn.$storedep,$depcontent);
3393: if ($dep_url eq '/adm/notfound.html') {
3394: if (ref($errors) eq 'HASH') {
3395: $errors->{$depfile} = 1;
3396: }
3397: } else {
3398: ©_dependencies($depfile,$storefn,$relpath,$errors,\$depcontent);
3399: }
3400: }
3401: }
3402: }
3403: }
3404: }
3405: }
3406: }
3407: return;
3408: }
3409:
1.329 droeschl 3410: my %parameter_type = ( 'randompick' => 'int_pos',
3411: 'hiddenresource' => 'string_yesno',
3412: 'encrypturl' => 'string_yesno',
3413: 'randomorder' => 'string_yesno',);
3414: my $valid_parameters_re = join('|',keys(%parameter_type));
3415: # set parameters
3416: sub update_parameter {
1.484.2.29 raeburn 3417: if ($env{'form.changeparms'} eq 'all') {
3418: my (@allidx,@allmapidx,%allchecked,%currchecked);
3419: %allchecked = (
3420: 'hiddenresource' => {},
3421: 'encrypturl' => {},
3422: 'randompick' => {},
3423: 'randomorder' => {},
3424: );
3425: foreach my $which (keys(%allchecked)) {
3426: $env{'form.all'.$which} =~ s/,$//;
3427: if ($which eq 'randompick') {
3428: foreach my $item (split(/,/,$env{'form.all'.$which})) {
3429: my ($res,$value) = split(/:/,$item);
3430: if ($value =~ /^\d+$/) {
3431: $allchecked{$which}{$res} = $value;
3432: }
3433: }
3434: } else {
1.484.2.30 raeburn 3435: if ($env{'form.all'.$which}) {
3436: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.all'.$which});
3437: }
1.484.2.29 raeburn 3438: }
3439: }
3440: my $haschanges = 0;
3441: foreach my $res (@LONCAPA::map::order) {
3442: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3443: $name=&LONCAPA::map::qtescape($name);
3444: $url=&LONCAPA::map::qtescape($url);
1.484.2.93.2. (raeburn 3445:): next unless $url;
1.484.2.29 raeburn 3446: my $is_map;
3447: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
3448: $is_map = 1;
3449: }
3450: foreach my $which (keys(%allchecked)) {
3451: if (($which eq 'randompick' || $which eq 'randomorder')) {
3452: next if (!$is_map);
3453: }
3454: my $oldvalue = 0;
3455: my $newvalue = 0;
3456: if ($allchecked{$which}{$res}) {
3457: $newvalue = $allchecked{$which}{$res};
3458: }
3459: my $current = (&LONCAPA::map::getparameter($res,'parameter_'.$which))[0];
3460: if ($which eq 'randompick') {
3461: if ($current =~ /^(\d+)$/) {
3462: $oldvalue = $1;
3463: }
3464: } else {
3465: if ($current =~ /^yes$/i) {
3466: $oldvalue = 1;
3467: }
3468: }
3469: if ($oldvalue ne $newvalue) {
3470: $haschanges = 1;
3471: if ($newvalue) {
3472: my $storeval = 'yes';
3473: if ($which eq 'randompick') {
3474: $storeval = $newvalue;
3475: }
3476: &LONCAPA::map::storeparameter($res,'parameter_'.$which,
3477: $storeval,
3478: $parameter_type{$which});
3479: &remember_parms($res,$which,'set',$storeval);
3480: } elsif ($oldvalue) {
3481: &LONCAPA::map::delparameter($res,'parameter_'.$which);
3482: &remember_parms($res,$which,'del');
3483: }
3484: }
3485: }
3486: }
3487: return $haschanges;
1.329 droeschl 3488: } else {
1.484.2.59 raeburn 3489: my $haschanges = 0;
3490: return $haschanges if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
1.364 bisitz 3491:
1.484.2.29 raeburn 3492: my $which = $env{'form.changeparms'};
3493: my $idx = $env{'form.setparms'};
1.484.2.59 raeburn 3494: my $oldvalue = 0;
3495: my $newvalue = 0;
3496: my $current = (&LONCAPA::map::getparameter($idx,'parameter_'.$which))[0];
3497: if ($which eq 'randompick') {
3498: if ($current =~ /^(\d+)$/) {
3499: $oldvalue = $1;
3500: }
3501: } elsif ($current =~ /^yes$/i) {
3502: $oldvalue = 1;
3503: }
1.484.2.29 raeburn 3504: if ($env{'form.'.$which.'_'.$idx}) {
1.484.2.59 raeburn 3505: $newvalue = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx}
3506: : 1;
1.484.2.29 raeburn 3507: }
1.484.2.59 raeburn 3508: if ($oldvalue ne $newvalue) {
3509: $haschanges = 1;
3510: if ($newvalue) {
3511: my $storeval = 'yes';
3512: if ($which eq 'randompick') {
3513: $storeval = $newvalue;
3514: }
3515: &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $storeval,
3516: $parameter_type{$which});
3517: &remember_parms($idx,$which,'set',$storeval);
3518: } else {
3519: &LONCAPA::map::delparameter($idx,'parameter_'.$which);
3520: &remember_parms($idx,$which,'del');
3521: }
3522: }
3523: return $haschanges;
1.329 droeschl 3524: }
1.484.2.59 raeburn 3525: return;
1.329 droeschl 3526: }
3527:
3528: sub handle_edit_cmd {
3529: my ($coursenum,$coursedom) =@_;
1.484.2.93.2. 2(raebur 3530:3): my $haschanges = 0;
1.484.2.30 raeburn 3531: if ($env{'form.cmd'} eq '') {
1.484.2.93.2. 2(raebur 3532:3): return $haschanges;
1.484.2.30 raeburn 3533: }
1.329 droeschl 3534: my ($cmd,$idx)=split('_',$env{'form.cmd'});
3535:
3536: my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
3537: my ($title, $url, @rrest) = split(':', $ratstr);
3538:
1.484.2.30 raeburn 3539: if ($cmd eq 'remove') {
1.329 droeschl 3540: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
1.463 www 3541: ($url!~/$LONCAPA::assess_page_seq_re/)) {
1.329 droeschl 3542: &Apache::lonnet::removeuploadedurl($url);
3543: } else {
3544: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
3545: }
3546: splice(@LONCAPA::map::order, $idx, 1);
1.484.2.93.2. 2(raebur 3547:3): $haschanges = 1;
1.329 droeschl 3548: } elsif ($cmd eq 'cut') {
3549: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
3550: splice(@LONCAPA::map::order, $idx, 1);
1.484.2.93.2. 2(raebur 3551:3): $haschanges = 1;
1.344 bisitz 3552: } elsif ($cmd eq 'up'
1.329 droeschl 3553: && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
3554: @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
1.484.2.93.2. 2(raebur 3555:3): $haschanges = 1;
1.329 droeschl 3556: } elsif ($cmd eq 'down'
3557: && defined($LONCAPA::map::order[$idx+1])) {
3558: @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
1.484.2.93.2. 2(raebur 3559:3): $haschanges = 1;
1.329 droeschl 3560: } elsif ($cmd eq 'rename') {
3561: my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
3562: if ($comment=~/\S/) {
3563: $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
3564: $comment.':'.join(':', $url, @rrest);
3565: }
3566: # Devalidate title cache
3567: my $renamed_url=&LONCAPA::map::qtescape($url);
3568: &Apache::lonnet::devalidate_title_cache($renamed_url);
1.484.2.93.2. 2(raebur 3569:3): $haschanges = 1;
1.329 droeschl 3570: }
1.484.2.93.2. 2(raebur 3571:3): return $haschanges;
1.329 droeschl 3572: }
3573:
3574: sub editor {
1.458 raeburn 3575: my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
1.484.2.93.2. (raeburn 3576:): $supplementalflag,$orderhash,$iconpath,$pathitem,$ltitoolsref,
3577:): $canedit,$hostname,$navmapref,$hiddentop)=@_;
1.484.2.19 raeburn 3578: my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
3579: if ($allowed) {
3580: (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
3581: $is_random_order,$container) =
3582: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
3583: $r->print($breadcrumbtrail);
3584: } elsif ($env{'form.folderpath'} =~ /\:1$/) {
3585: $container = 'page';
3586: } else {
3587: $container = 'sequence';
3588: }
1.484 raeburn 3589:
1.484.2.21 raeburn 3590: my $jumpto;
3591:
3592: unless ($supplementalflag) {
1.484.2.32 raeburn 3593: $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
1.484.2.21 raeburn 3594: }
1.484 raeburn 3595:
3596: unless ($allowed) {
3597: $randompick = -1;
3598: }
3599:
1.484.2.67 raeburn 3600: my ($errtext,$fatal);
3601: if (($folder eq '') && (!$supplementalflag)) {
3602: if (@LONCAPA::map::order) {
3603: undef(@LONCAPA::map::order);
3604: undef(@LONCAPA::map::resources);
3605: undef(@LONCAPA::map::resparms);
3606: undef(@LONCAPA::map::zombies);
3607: }
3608: $folder = 'default';
3609: $container = 'sequence';
3610: } else {
3611: ($errtext,$fatal) = &mapread($coursenum,$coursedom,
3612: $folder.'.'.$container);
3613: return $errtext if ($fatal);
3614: }
1.329 droeschl 3615:
3616: if ($#LONCAPA::map::order<1) {
3617: my $idx=&LONCAPA::map::getresidx();
3618: if ($idx<=0) { $idx=1; }
3619: $LONCAPA::map::order[0]=$idx;
3620: $LONCAPA::map::resources[$idx]='';
3621: }
1.364 bisitz 3622:
1.329 droeschl 3623: # ------------------------------------------------------------ Process commands
3624:
3625: # ---------------- if they are for this folder and user allowed to make changes
1.484.2.67 raeburn 3626: if (($allowed && $canedit) && ($env{'form.folder'} eq $folder)) {
1.329 droeschl 3627: # set parameters and change order
3628: &snapshotbefore();
3629:
3630: if (&update_parameter()) {
1.484.2.59 raeburn 3631: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1.329 droeschl 3632: return $errtext if ($fatal);
3633: }
3634:
3635: if ($env{'form.newpos'} && $env{'form.currentpos'}) {
3636: # change order
3637: my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
3638: splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
3639:
3640: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
3641: return $errtext if ($fatal);
3642: }
1.364 bisitz 3643:
1.329 droeschl 3644: if ($env{'form.pastemarked'}) {
1.484.2.7 raeburn 3645: my %paste_errors;
1.484.2.26 raeburn 3646: my ($paste_res,$save_error,$pastemsgarray,$lockerror) =
1.484.2.7 raeburn 3647: &do_paste_from_buffer($coursenum,$coursedom,$folder,$container,
3648: \%paste_errors);
1.484.2.30 raeburn 3649: if (ref($pastemsgarray) eq 'ARRAY') {
3650: if (@{$pastemsgarray} > 0) {
3651: $r->print('<p class="LC_info">'.
3652: join('<br />',@{$pastemsgarray}).
1.484.2.26 raeburn 3653: '</p>');
3654: }
1.484.2.30 raeburn 3655: }
3656: if ($lockerror) {
3657: $r->print('<p class="LC_error">'.
3658: $lockerror.
3659: '</p>');
3660: }
3661: if ($save_error ne '') {
3662: return $save_error;
3663: }
3664: if ($paste_res) {
3665: my %errortext = &Apache::lonlocal::texthash (
3666: fail => 'Storage of folder contents failed',
3667: failread => 'Reading folder contents failed',
3668: failstore => 'Storage of folder contents failed',
3669: );
3670: if ($errortext{$paste_res}) {
3671: $r->print('<p class="LC_error">'.$errortext{$paste_res}.'</p>');
1.484.2.7 raeburn 3672: }
1.329 droeschl 3673: }
1.484.2.7 raeburn 3674: if (keys(%paste_errors) > 0) {
1.484.2.30 raeburn 3675: $r->print('<p class="LC_warning">'."\n".
1.484.2.7 raeburn 3676: &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".
3677: '<ul>'."\n");
3678: foreach my $key (sort(keys(%paste_errors))) {
3679: $r->print('<li>'.$key.'</li>'."\n");
3680: }
3681: $r->print('</ul></p>'."\n");
3682: }
1.484.2.30 raeburn 3683: } elsif ($env{'form.clearmarked'}) {
3684: my $output = &do_buffer_empty();
3685: if ($output) {
3686: $r->print('<p class="LC_info">'.$output.'</p>');
3687: }
3688: }
1.329 droeschl 3689:
3690: $r->print($upload_output);
3691:
1.484.2.30 raeburn 3692: # Rename, cut, copy or remove a single resource
1.484.2.63 raeburn 3693: if (&handle_edit_cmd($coursenum,$coursedom)) {
1.484.2.7 raeburn 3694: my $contentchg;
1.484.2.58 raeburn 3695: if ($env{'form.cmd'} =~ m{^(remove|cut)_}) {
1.484.2.7 raeburn 3696: $contentchg = 1;
3697: }
3698: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);
1.329 droeschl 3699: return $errtext if ($fatal);
3700: }
1.484.2.30 raeburn 3701:
3702: # Cut, copy and/or remove multiple resources
3703: if ($env{'form.multichange'}) {
3704: my %allchecked = (
3705: cut => {},
3706: remove => {},
3707: );
3708: my $needsupdate;
3709: foreach my $which (keys(%allchecked)) {
3710: $env{'form.multi'.$which} =~ s/,$//;
3711: if ($env{'form.multi'.$which}) {
3712: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.multi'.$which});
3713: if (ref($allchecked{$which}) eq 'HASH') {
3714: $needsupdate += scalar(keys(%{$allchecked{$which}}));
3715: }
3716: }
3717: }
3718: if ($needsupdate) {
3719: my $haschanges = 0;
3720: my %curr_groups = &Apache::longroup::coursegroups();
3721: my $total = scalar(@LONCAPA::map::order) - 1;
3722: for (my $i=$total; $i>=0; $i--) {
3723: my $res = $LONCAPA::map::order[$i];
3724: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3725: $name=&LONCAPA::map::qtescape($name);
3726: $url=&LONCAPA::map::qtescape($url);
1.484.2.57 raeburn 3727: next unless $url;
1.484.2.30 raeburn 3728: my %denied =
3729: &action_restrictions($coursenum,$coursedom,$url,
3730: $env{'form.folderpath'},\%curr_groups);
3731: foreach my $which (keys(%allchecked)) {
3732: next if ($denied{$which});
3733: next unless ($allchecked{$which}{$res});
3734: if ($which eq 'remove') {
3735: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
3736: ($url!~/$LONCAPA::assess_page_seq_re/)) {
3737: &Apache::lonnet::removeuploadedurl($url);
3738: } else {
3739: &LONCAPA::map::makezombie($res);
3740: }
3741: splice(@LONCAPA::map::order,$i,1);
3742: $haschanges ++;
3743: } elsif ($which eq 'cut') {
3744: &LONCAPA::map::makezombie($res);
3745: splice(@LONCAPA::map::order,$i,1);
3746: $haschanges ++;
3747: }
3748: }
3749: }
3750: if ($haschanges) {
3751: ($errtext,$fatal) =
3752: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
3753: return $errtext if ($fatal);
3754: }
3755: }
3756: }
3757:
1.329 droeschl 3758: # Group import/search
3759: if ($env{'form.importdetail'}) {
3760: my @imports;
3761: foreach my $item (split(/\&/,$env{'form.importdetail'})) {
3762: if (defined($item)) {
3763: my ($name,$url,$residx)=
1.484.2.26 raeburn 3764: map { &unescape($_); } split(/\=/,$item);
3765: if ($url =~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
1.484.2.30 raeburn 3766: my ($suffix,$errortxt,$locknotfreed) =
1.484.2.26 raeburn 3767: &new_timebased_suffix($coursedom,$coursenum,'map',$1,$2);
1.484.2.15 raeburn 3768: if ($locknotfreed) {
3769: $r->print($locknotfreed);
3770: }
3771: if ($suffix) {
1.484.2.19 raeburn 3772: $url =~ s/_new\./_$suffix./;
1.484.2.15 raeburn 3773: } else {
3774: return $errortxt;
3775: }
1.484.2.26 raeburn 3776: } elsif ($url =~ m{^/adm/$match_domain/$match_username/new/(smppg|bulletinboard)$}) {
3777: my $type = $1;
3778: my ($suffix,$errortxt,$locknotfreed) =
3779: &new_timebased_suffix($coursedom,$coursenum,$type);
3780: if ($locknotfreed) {
3781: $r->print($locknotfreed);
3782: }
3783: if ($suffix) {
3784: $url =~ s{^(/adm/$match_domain/$match_username)/new}{$1/$suffix};
3785: } else {
3786: return $errortxt;
3787: }
1.484.2.93.2. (raeburn 3788:): } elsif ($url =~ m{^/adm/$coursedom/$coursenum/new/ext\.tool}) {
3789:): my ($suffix,$errortxt,$locknotfreed) =
3790:): &new_timebased_suffix($coursedom,$coursenum,'exttool');
3791:): if ($locknotfreed) {
3792:): $r->print($locknotfreed);
3793:): }
3794:): if ($suffix) {
3795:): $url =~ s{^(/adm/$coursedom/$coursenum)/new}{$1/$suffix};
3796:): } else {
3797:): return $errortxt;
3798:): }
1.484.2.27 raeburn 3799: } elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) {
3800: if ($supplementalflag) {
3801: next unless ($1 eq 'supplemental');
3802: if ($folder eq 'supplemental') {
3803: next unless ($2 eq 'default');
3804: } else {
3805: next unless ($folder eq 'supplemental_'.$2);
3806: }
3807: } else {
3808: next unless ($1 eq 'docs');
3809: if ($folder eq 'default') {
3810: next unless ($2 eq 'default');
3811: } else {
3812: next unless ($folder eq 'default_'.$2);
3813: }
3814: }
1.484.2.15 raeburn 3815: }
1.329 droeschl 3816: push(@imports, [$name, $url, $residx]);
3817: }
3818: }
1.484.2.23 raeburn 3819: ($errtext,$fatal,my $fixuperrors) =
3820: &group_import($coursenum, $coursedom, $folder,$container,
1.484.2.93.2. (raeburn 3821:): 'londocs',$ltitoolsref,@imports);
1.329 droeschl 3822: return $errtext if ($fatal);
1.484.2.23 raeburn 3823: if ($fixuperrors) {
3824: $r->print($fixuperrors);
3825: }
1.329 droeschl 3826: }
3827: # Loading a complete map
3828: if ($env{'form.loadmap'}) {
3829: if ($env{'form.importmap'}=~/\w/) {
3830: foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
3831: my ($title,$url,$ext,$type)=split(/\:/,$res);
3832: my $idx=&LONCAPA::map::getresidx($url);
3833: $LONCAPA::map::resources[$idx]=$res;
3834: $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
3835: }
3836: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.484.2.7 raeburn 3837: $folder.'.'.$container,1);
1.329 droeschl 3838: return $errtext if ($fatal);
3839: } else {
3840: $r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
1.364 bisitz 3841:
1.329 droeschl 3842: }
3843: }
3844: &log_differences($plain);
3845: }
3846: # ---------------------------------------------------------------- End commands
3847: # ---------------------------------------------------------------- Print screen
3848: my $idx=0;
3849: my $shown=0;
3850: if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
1.381 bisitz 3851: $r->print('<div class="LC_Box">'.
1.432 raeburn 3852: '<ol class="LC_docs_parameters"><li class="LC_docs_parameters_title">'.&mt('Parameters:').'</li>'.
3853: ($randompick>=0?'<li>'.&mt('randomly pick [quant,_1,resource]',$randompick).'</li>':'').
3854: ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
3855: ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
3856: ($is_random_order?'<li>'.&mt('random order').'</li>':'').
1.431 raeburn 3857: '</ol>');
1.381 bisitz 3858: if ($randompick>=0) {
3859: $r->print('<p class="LC_warning">'
3860: .&mt('Caution: this folder is set to randomly pick a subset'
3861: .' of resources. Adding or removing resources from this'
3862: .' folder will change the set of resources that the'
3863: .' students see, resulting in spurious or missing credit'
3864: .' for completed problems, not limited to ones you'
3865: .' modify. Do not modify the contents of this folder if'
3866: .' it is in active student use.')
3867: .'</p>'
3868: );
3869: }
3870: if ($is_random_order) {
3871: $r->print('<p class="LC_warning">'
3872: .&mt('Caution: this folder is set to randomly order its'
3873: .' contents. Adding or removing resources from this folder'
3874: .' will change the order of resources shown.')
3875: .'</p>'
3876: );
3877: }
3878: $r->print('</div>');
1.364 bisitz 3879: }
1.381 bisitz 3880:
1.484.2.93.2. 0(raebur 3881:3): if ((!$allowed) && ($folder =~ /^supplemental_\d+$/)) {
3882:3): my ($supplemental) = &Apache::loncommon::get_supplemental($coursenum,$coursedom);
3883:3): if (ref($supplemental) eq 'HASH') {
3884:3): if ((ref($supplemental->{'hidden'}) eq 'HASH') &&
3885:3): (ref($supplemental->{'ids'}) eq 'HASH')) {
3886:3): if (ref($supplemental->{'ids'}->{"/uploaded/$coursedom/$coursenum/$folder.$container"}) eq 'ARRAY') {
3887:3): my $mapnum = $supplemental->{'ids'}->{"/uploaded/$coursedom/$coursenum/$folder.$container"}->[0];
3888:3): if ($supplemental->{'hidden'}->{$mapnum}) {
3889:3): $ishidden = 1;
3890:3): }
3891:3): }
3892:3): }
3893:3): }
3894:3): }
3895:3):
1.484.2.30 raeburn 3896: my ($to_show,$output,@allidx,@allmapidx,%filters,%lists,%curr_groups);
3897: %filters = (
3898: canremove => [],
3899: cancut => [],
3900: cancopy => [],
3901: hiddenresource => [],
3902: encrypturl => [],
3903: randomorder => [],
3904: randompick => [],
3905: );
3906: %curr_groups = &Apache::longroup::coursegroups();
1.424 onken 3907: &Apache::loncommon::start_data_table_count(); #setup a row counter
1.381 bisitz 3908: foreach my $res (@LONCAPA::map::order) {
3909: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3910: $name=&LONCAPA::map::qtescape($name);
3911: $url=&LONCAPA::map::qtescape($url);
3912: unless ($name) { $name=(split(/\//,$url))[-1]; }
3913: unless ($name) { $idx++; next; }
1.484.2.29 raeburn 3914: push(@allidx,$res);
3915: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
3916: push(@allmapidx,$res);
3917: }
1.484.2.67 raeburn 3918:
1.484.2.93.2. 0(raebur 3919:3): if (($supplementalflag) && (!$allowed) && (!$env{'request.role.adv'})) {
3920:3): if (($ishidden) || ((&LONCAPA::map::getparameter($res,'parameter_hiddenresource'))[0]=~/^yes$/i)) {
3921:3): $idx++;
3922:3): next;
3923:3): }
3924:3): }
1.381 bisitz 3925: $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
1.484.2.12 raeburn 3926: $coursenum,$coursedom,$crstype,
1.484.2.30 raeburn 3927: $pathitem,$supplementalflag,$container,
1.484.2.93.2. (raeburn 3928:): \%filters,\%curr_groups,$ltitoolsref,$canedit,
0(raebur 3929:3): $isencrypted,$ishidden,$navmapref,$hostname);
1.381 bisitz 3930: $idx++;
3931: $shown++;
1.329 droeschl 3932: }
1.424 onken 3933: &Apache::loncommon::end_data_table_count();
1.484.2.19 raeburn 3934:
1.484.2.30 raeburn 3935: my $need_save;
1.484.2.67 raeburn 3936: if ($allowed || ($supplementalflag && $folder eq 'supplemental')) {
1.484.2.31 raeburn 3937: my $toolslink;
1.484.2.93.2. 0(raebur 3938:3): if ($allowed || $canedit) {
3939:3): my $helpitem = 'Navigation_Screen';
3940:3): if (!$allowed) {
3941:3): $helpitem = 'Supplemental_Navigation';
3942:3): }
1.484.2.31 raeburn 3943: $toolslink = '<table><tr><td>'
1.484.2.19 raeburn 3944: .&Apache::loncommon::help_open_menu('Navigation Screen',
1.484.2.93.2. 0(raebur 3945:3): $helpitem,undef,'RAT')
1.484.2.19 raeburn 3946: .'</td><td class="LC_middle">'.&mt('Tools:').'</td>'
3947: .'<td align="left"><ul id="LC_toolbar">'
1.484.2.21 raeburn 3948: .'<li><a href="/adm/coursedocs?forcesupplement=1&command=editsupp" '
1.484.2.19 raeburn 3949: .'id="LC_content_toolbar_edittoplevel" '
3950: .'class="LC_toolbarItem" '
3951: .'title="'.&mt('Supplemental Content Editor').'">'
3952: .'</a></li></ul></td></tr></table><br />';
1.484.2.31 raeburn 3953: }
1.484.2.19 raeburn 3954: if ($shown) {
3955: if ($allowed) {
3956: $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
3957: .&Apache::loncommon::start_data_table(undef,'contentlist')
3958: .&Apache::loncommon::start_data_table_header_row()
3959: .'<th colspan="2">'.&mt('Move').'</th>'
1.484.2.30 raeburn 3960: .'<th colspan="2">'.&mt('Actions').'</th>'
1.484.2.93.2. 0(raebur 3961:3): .'<th>'.&mt('Document').'</th>'
3962:3): .'<th colspan="2">'.&mt('Settings').'</th>'
3963:3): .&Apache::loncommon::end_data_table_header_row();
1.484.2.29 raeburn 3964: if ($folder !~ /^supplemental/) {
1.484.2.30 raeburn 3965: $lists{'canhide'} = join(',',@allidx);
3966: $lists{'canrandomlyorder'} = join(',',@allmapidx);
3967: my @possfilters = ('canremove','cancut','cancopy','hiddenresource','encrypturl',
3968: 'randomorder','randompick');
3969: foreach my $item (@possfilters) {
3970: if (ref($filters{$item}) eq 'ARRAY') {
3971: if (@{$filters{$item}} > 0) {
3972: $lists{$item} = join(',',@{$filters{$item}});
3973: }
3974: }
3975: }
1.484.2.29 raeburn 3976: if (@allidx > 0) {
3977: my $path;
3978: if ($env{'form.folderpath'}) {
3979: $path =
3980: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3981: }
1.484.2.30 raeburn 3982: if (@allidx > 1) {
3983: $to_show .=
3984: &Apache::loncommon::continue_data_table_row().
3985: '<td colspan="2"> </td>'.
3986: '<td>'.
1.484.2.67 raeburn 3987: &multiple_check_form('actions',\%lists,$canedit).
1.484.2.30 raeburn 3988: '</td>'.
3989: '<td> </td>'.
3990: '<td> </td>'.
1.484.2.93.2. 0(raebur 3991:3): '<td colspan="2">'.
1.484.2.67 raeburn 3992: &multiple_check_form('settings',\%lists,$canedit).
1.484.2.30 raeburn 3993: '</td>'.
3994: &Apache::loncommon::end_data_table_row();
3995: $need_save = 1;
3996: }
1.484.2.29 raeburn 3997: }
3998: }
3999: $to_show .= $output.' '
1.484.2.19 raeburn 4000: .&Apache::loncommon::end_data_table()
4001: .'<br style="line-height:2px;" />'
4002: .&Apache::loncommon::end_scrollbox();
4003: } else {
4004: $to_show .= $toolslink
4005: .&Apache::loncommon::start_data_table('LC_tableOfContent')
4006: .$output.' '
4007: .&Apache::loncommon::end_data_table();
4008: }
4009: } else {
4010: if (!$allowed) {
4011: $to_show .= $toolslink;
1.393 raeburn 4012: }
1.484.2.67 raeburn 4013: my $noresmsg;
4014: if ($allowed && $hiddentop && !$supplementalflag) {
4015: $noresmsg = &mt('Main Content Hidden');
4016: } else {
4017: $noresmsg = &mt('Currently empty');
4018: }
1.484.2.19 raeburn 4019: $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
4020: .'<div class="LC_info" id="contentlist">'
1.484.2.67 raeburn 4021: .$noresmsg
1.484.2.19 raeburn 4022: .'</div>'
4023: .&Apache::loncommon::end_scrollbox();
1.393 raeburn 4024: }
4025: } else {
1.484.2.19 raeburn 4026: if ($shown) {
4027: $to_show = '<div>'
4028: .&Apache::loncommon::start_data_table('LC_tableOfContent')
4029: .$output
4030: .&Apache::loncommon::end_data_table()
4031: .'</div>';
4032: } else {
4033: $to_show = '<div class="LC_info" id="contentlist">'
1.484.2.34 raeburn 4034: .&mt('Currently empty')
1.484.2.19 raeburn 4035: .'</div>'
4036: }
1.458 raeburn 4037: }
4038: my $tid = 1;
4039: if ($supplementalflag) {
4040: $tid = 2;
1.329 droeschl 4041: }
4042: if ($allowed) {
1.484 raeburn 4043: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
1.484.2.30 raeburn 4044: $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,
1.484.2.67 raeburn 4045: $jumpto,$readfile,$need_save,"$folder.$container",$canedit));
1.484.2.68 raeburn 4046: if ($canedit) {
1.484.2.67 raeburn 4047: &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
4048: }
1.460 raeburn 4049: } else {
4050: $r->print($to_show);
1.329 droeschl 4051: }
4052: return;
4053: }
4054:
1.484.2.30 raeburn 4055: sub multiple_check_form {
1.484.2.67 raeburn 4056: my ($caller,$listsref,$canedit) = @_;
1.484.2.30 raeburn 4057: return unless (ref($listsref) eq 'HASH');
1.484.2.67 raeburn 4058: my $disabled;
4059: unless ($canedit) {
1.484.2.93.2. 2(raebur 4060:3): $disabled = ' disabled="disabled"';
1.484.2.67 raeburn 4061: }
1.484.2.30 raeburn 4062: my $output =
4063: '<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'.
4064: '<span class="LC_nobreak" style="font-size:x-small;font-weight:bold;">'.
4065: '<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>'.
4066: '<div id="multi'.$caller.'" style="display:none;margin:0;padding:0;border:0">'.
4067: '<form action="/adm/coursedocs" method="post" name="cumulative'.$caller.'">'."\n".
4068: '<fieldset id="allfields'.$caller.'" style="display:none"><legend style="font-size:x-small;">'.&mt('check/uncheck all').'</legend>'."\n";
4069: if ($caller eq 'settings') {
4070: $output .=
4071: '<table><tr>'.
4072: '<td class="LC_docs_entry_parameter">'.
4073: '<span class="LC_nobreak"><label>'.
1.484.2.67 raeburn 4074: '<input type="checkbox" name="hiddenresourceall" id="hiddenresourceall" onclick="propagateState(this.form,'."'hiddenresource'".')"'.$disabled.' />'.&mt('Hidden').
1.484.2.30 raeburn 4075: '</label></span></td>'.
4076: '<td class="LC_docs_entry_parameter">'.
1.484.2.67 raeburn 4077: '<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.484.2.30 raeburn 4078: '</span></td>'.
4079: '</tr>'."\n".
4080: '<tr>'.
4081: '<td class="LC_docs_entry_parameter">'.
1.484.2.67 raeburn 4082: '<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.484.2.30 raeburn 4083: '</label></span>'.
4084: '</td></tr></table>'."\n";
4085: } else {
4086: $output .=
4087: '<table><tr>'.
4088: '<td class="LC_docs_entry_parameter">'.
4089: '<span class="LC_nobreak LC_docs_remove">'.
1.484.2.67 raeburn 4090: '<label><input type="checkbox" name="removeall" id="removeall" onclick="propagateState(this.form,'."'remove'".')"'.$disabled.' />'.&mt('Remove').
1.484.2.30 raeburn 4091: '</label></span></td>'.
4092: '<td class="LC_docs_entry_parameter">'.
4093: '<span class="LC_nobreak LC_docs_cut">'.
1.484.2.67 raeburn 4094: '<label><input type="checkbox" name="cut" id="cutall" onclick="propagateState(this.form,'."'cut'".');"'.$disabled.' />'.&mt('Cut').
1.484.2.30 raeburn 4095: '</label></span></td>'."\n".
4096: '<td class="LC_docs_entry_parameter">'.
4097: '<span class="LC_nobreak LC_docs_copy">'.
1.484.2.67 raeburn 4098: '<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')"'.$disabled.' />'.&mt('Copy').
1.484.2.30 raeburn 4099: '</label></span></td>'.
4100: '</tr></table>'."\n";
4101: }
4102: $output .=
4103: '</fieldset>'.
4104: '<input type="hidden" name="allidx" value="'.$listsref->{'canhide'}.'" />';
4105: if ($caller eq 'settings') {
4106: $output .=
4107: '<input type="hidden" name="allmapidx" value="'.$listsref->{'canrandomlyorder'}.'" />'."\n".
4108: '<input type="hidden" name="currhiddenresource" value="'.$listsref->{'hiddenresource'}.'" />'."\n".
4109: '<input type="hidden" name="currencrypturl" value="'.$listsref->{'encrypturl'}.'" />'."\n".
4110: '<input type="hidden" name="currrandomorder" value="'.$listsref->{'randomorder'}.'" />'."\n".
4111: '<input type="hidden" name="currrandompick" value="'.$listsref->{'randompick'}.'" />'."\n";
4112: } elsif ($caller eq 'actions') {
4113: $output .=
4114: '<input type="hidden" name="allremoveidx" id="allremoveidx" value="'.$listsref->{'canremove'}.'" />'.
4115: '<input type="hidden" name="allcutidx" id="allcutidx" value="'.$listsref->{'cancut'}.'" />'.
4116: '<input type="hidden" name="allcopyidx" id="allcopyidx" value="'.$listsref->{'cancopy'}.'" />';
4117: }
4118: $output .=
4119: '</form>'.
4120: '</div>';
4121: return $output;
4122: }
4123:
1.329 droeschl 4124: sub process_file_upload {
1.484.2.36 raeburn 4125: my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd,$crstype) = @_;
1.329 droeschl 4126: # upload a file, if present
1.484.2.36 raeburn 4127: my $filesize = length($env{'form.uploaddoc'});
4128: if (!$filesize) {
4129: $$upload_output = '<div class="LC_error">'.
4130: &mt('Unable to upload [_1]. (size = [_2] bytes)',
4131: '<span class="LC_filename">'.$env{'form.uploaddoc.filename'}.'</span>',
4132: $filesize).'<br />'.
4133: &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'<br />'.
4134: '</div>';
4135: return;
4136: }
4137: my $quotatype = 'unofficial';
4138: if ($crstype eq 'Community') {
4139: $quotatype = 'community';
1.484.2.51 raeburn 4140: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
1.484.2.36 raeburn 4141: $quotatype = 'official';
1.484.2.45 raeburn 4142: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
4143: $quotatype = 'textbook';
1.484.2.36 raeburn 4144: }
4145: if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) {
4146: $filesize = int($filesize/1000); #expressed in kb
4147: $$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course',
1.484.2.51 raeburn 4148: $env{'form.uploaddoc.filename'},$filesize,
4149: 'upload',$quotatype);
1.484.2.36 raeburn 4150: return if ($$upload_output);
4151: }
1.440 raeburn 4152: my ($parseaction,$showupload,$nextphase,$mimetype);
4153: if ($env{'form.parserflag'}) {
1.329 droeschl 4154: $parseaction = 'parse';
4155: }
4156: my $folder=$env{'form.folder'};
4157: if ($folder eq '') {
4158: $folder='default';
4159: }
4160: if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
4161: my $errtext='';
4162: my $fatal=0;
4163: my $container='sequence';
1.484.2.19 raeburn 4164: if ($env{'form.folderpath'} =~ /:1$/) {
1.329 droeschl 4165: $container='page';
4166: }
4167: ($errtext,$fatal)=
1.484.2.27 raeburn 4168: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1.329 droeschl 4169: if ($#LONCAPA::map::order<1) {
4170: $LONCAPA::map::order[0]=1;
4171: $LONCAPA::map::resources[1]='';
4172: }
4173: my $destination = 'docs/';
4174: if ($folder =~ /^supplemental/) {
4175: $destination = 'supplemental/';
4176: }
4177: if (($folder eq 'default') || ($folder eq 'supplemental')) {
4178: $destination .= 'default/';
4179: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
4180: $destination .= $2.'/';
4181: }
1.484.2.27 raeburn 4182: if ($fatal) {
4183: $$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>';
4184: return;
4185: }
1.440 raeburn 4186: # this is for a course, not a user, so set context to coursedoc.
1.329 droeschl 4187: my $newidx=&LONCAPA::map::getresidx();
4188: $destination .= $newidx;
1.439 raeburn 4189: my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination,
1.329 droeschl 4190: $parseaction,$allfiles,
1.440 raeburn 4191: $codebase,undef,undef,undef,undef,
4192: undef,undef,\$mimetype);
4193: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) {
4194: my $stored = $1;
4195: $showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'.
4196: $stored.'</span>').'</p>';
4197: } else {
4198: my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});
4199:
1.457 raeburn 4200: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>';
1.440 raeburn 4201: return;
4202: }
1.329 droeschl 4203: my $ext='false';
4204: if ($url=~m{^http://}) { $ext='true'; }
4205: $url = &LONCAPA::map::qtunescape($url);
4206: my $comment=$env{'form.comment'};
4207: $comment = &LONCAPA::map::qtunescape($comment);
4208: if ($folder=~/^supplemental/) {
4209: $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
4210: $env{'user.domain'}.'___&&&___'.$comment;
4211: }
4212:
4213: $LONCAPA::map::resources[$newidx]=
4214: $comment.':'.$url.':'.$ext.':normal:res';
4215: $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
4216: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.484.2.7 raeburn 4217: $folder.'.'.$container,1);
1.329 droeschl 4218: if ($fatal) {
1.457 raeburn 4219: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>';
1.440 raeburn 4220: return;
1.329 droeschl 4221: } else {
1.440 raeburn 4222: if ($parseaction eq 'parse' && $mimetype eq 'text/html') {
4223: $$upload_output = $showupload;
1.384 raeburn 4224: my $total_embedded = scalar(keys(%{$allfiles}));
1.329 droeschl 4225: if ($total_embedded > 0) {
1.440 raeburn 4226: my $uploadphase = 'upload_embedded';
4227: my $primaryurl = &HTML::Entities::encode($url,'<>&"');
4228: my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx);
4229: my ($embedded,$num) =
4230: &Apache::loncommon::ask_for_embedded_content(
4231: '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url});
4232: if ($embedded) {
4233: if ($num) {
4234: $$upload_output .=
4235: '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
4236: $nextphase = $uploadphase;
4237: } else {
4238: $$upload_output .= $embedded;
4239: }
4240: } else {
4241: $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
4242: }
1.329 droeschl 4243: } else {
1.440 raeburn 4244: $$upload_output .= &mt('No embedded items identified').'<br />';
1.329 droeschl 4245: }
1.457 raeburn 4246: $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
1.484.2.51 raeburn 4247: } elsif ((&Apache::loncommon::is_archive_file($mimetype)) &&
4248: ($env{'form.uploaddoc.filename'} =~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i)) {
1.476 raeburn 4249: $nextphase = 'decompress_uploaded';
4250: my $position = scalar(@LONCAPA::map::order)-1;
4251: my $noextract = &return_to_editor();
4252: my $archiveurl = &HTML::Entities::encode($url,'<>&"');
4253: my %archiveitems = (
4254: folderpath => $env{'form.folderpath'},
4255: cmd => $nextphase,
4256: newidx => $newidx,
4257: position => $position,
4258: phase => $nextphase,
1.477 raeburn 4259: comment => $comment,
1.480 raeburn 4260: );
4261: my ($destination,$dir_root) = &embedded_destination($coursenum,$coursedom);
4262: my @current = &get_dir_list($url,$coursenum,$coursedom,$newidx);
1.476 raeburn 4263: $$upload_output = $showupload.
4264: &Apache::loncommon::decompress_form($mimetype,
4265: $archiveurl,'/adm/coursedocs',$noextract,
1.480 raeburn 4266: \%archiveitems,\@current);
1.329 droeschl 4267: }
4268: }
4269: }
1.440 raeburn 4270: return $nextphase;
1.329 droeschl 4271: }
4272:
1.480 raeburn 4273: sub get_dir_list {
4274: my ($url,$coursenum,$coursedom,$newidx) = @_;
4275: my ($destination,$dir_root) = &embedded_destination();
4276: my ($dirlistref,$listerror) =
4277: &Apache::lonnet::dirlist("$dir_root/$destination/$newidx",$coursedom,$coursenum,1);
4278: my @dir_lines;
4279: my $dirptr=16384;
4280: if (ref($dirlistref) eq 'ARRAY') {
4281: foreach my $dir_line (sort
4282: {
4283: my ($afile)=split('&',$a,2);
4284: my ($bfile)=split('&',$b,2);
4285: return (lc($afile) cmp lc($bfile));
4286: } (@{$dirlistref})) {
4287: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
4288: $filename =~ s/\s+$//;
4289: next if ($filename =~ /^\.\.?$/);
4290: my $isdir = 0;
4291: if ($dirptr&$testdir) {
4292: $isdir = 1;
4293: }
4294: push(@dir_lines, [$filename,$dom,$isdir,$size,$mtime,$obs]);
4295: }
4296: }
4297: return @dir_lines;
4298: }
4299:
1.329 droeschl 4300: sub is_supplemental_title {
4301: my ($title) = @_;
4302: return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
4303: }
4304:
4305: # --------------------------------------------------------------- An entry line
4306:
4307: sub entryline {
1.484.2.12 raeburn 4308: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
1.484.2.67 raeburn 4309: $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups,
1.484.2.93.2. 0(raebur 4310:3): $ltitoolsref,$canedit,$isencrypted,$ishidden,$navmapref,$hostname)=@_;
4311:3): my ($foldertitle,$renametitle,$oldtitle,$encodedtitle);
1.329 droeschl 4312: if (&is_supplemental_title($title)) {
1.484.2.7 raeburn 4313: ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
1.484.2.93.2. 0(raebur 4314:3): $encodedtitle=$title;
1.329 droeschl 4315: } else {
4316: $title=&HTML::Entities::encode($title,'"<>&\'');
1.484.2.93.2. 0(raebur 4317:3): $encodedtitle=$title;
1.329 droeschl 4318: $renametitle=$title;
4319: $foldertitle=$title;
4320: }
4321:
1.484.2.67 raeburn 4322: my ($disabled,$readonly,$js_lt);
4323: unless ($canedit) {
4324: $disabled = 'disabled="disabled"';
4325: $readonly = 1;
4326: }
4327:
1.329 droeschl 4328: my $orderidx=$LONCAPA::map::order[$index];
1.364 bisitz 4329:
1.329 droeschl 4330: $renametitle=~s/\\/\\\\/g;
4331: $renametitle=~s/\"\;/\\\"/g;
1.484.2.55 raeburn 4332: $renametitle=~s/"/%22/g;
1.329 droeschl 4333: $renametitle=~s/ /%20/g;
1.484.2.52 raeburn 4334: $oldtitle = $renametitle;
4335: $renametitle=~s/\'\;/\\\'/g;
1.379 bisitz 4336: my $line=&Apache::loncommon::start_data_table_row();
1.484.2.30 raeburn 4337: my ($form_start,$form_end,$form_common,$form_param);
1.329 droeschl 4338: # Edit commands
1.484.2.93.2. (raeburn 4339:): my ($esc_path, $path, $symb, $shownsymb);
1.329 droeschl 4340: if ($env{'form.folderpath'}) {
4341: $esc_path=&escape($env{'form.folderpath'});
4342: $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
4343: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
4344: }
1.484.2.16 raeburn 4345: my $isexternal;
1.484.2.19 raeburn 4346: if ($residx) {
1.484.2.12 raeburn 4347: my $currurl = $url;
4348: $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.484.2.16 raeburn 4349: if ($currurl =~ m{^/adm/wrapper/ext/}) {
4350: $isexternal = 1;
4351: }
1.484.2.19 raeburn 4352: if (!$supplementalflag) {
4353: my $path = 'uploaded/'.
4354: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
4355: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
4356: $symb = &Apache::lonnet::encode_symb($path.$folder.".$container",
4357: $residx,
4358: &Apache::lonnet::declutter($currurl));
4359: }
1.484.2.12 raeburn 4360: }
1.484.2.30 raeburn 4361: my ($renamelink,%lt,$ishash);
4362: if (ref($filtersref) eq 'HASH') {
4363: $ishash = 1;
4364: }
4365:
1.329 droeschl 4366: if ($allowed) {
1.484.2.30 raeburn 4367: $form_start = '
4368: <form action="/adm/coursedocs" method="post">
4369: ';
4370: $form_common=(<<END);
4371: <input type="hidden" name="folderpath" value="$path" />
4372: <input type="hidden" name="symb" value="$symb" />
4373: END
4374: $form_param=(<<END);
4375: <input type="hidden" name="setparms" value="$orderidx" />
4376: <input type="hidden" name="changeparms" value="0" />
4377: END
4378: $form_end = '</form>';
4379:
1.329 droeschl 4380: my $incindex=$index+1;
4381: my $selectbox='';
1.471 raeburn 4382: if (($#LONCAPA::map::order>0) &&
1.329 droeschl 4383: ((split(/\:/,
1.344 bisitz 4384: $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
4385: ne '') &&
1.329 droeschl 4386: ((split(/\:/,
1.344 bisitz 4387: $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1.329 droeschl 4388: ne '')) {
4389: $selectbox=
4390: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.484.2.67 raeburn 4391: '<select name="newpos" onchange="this.form.submit()"'.$disabled.'>';
1.329 droeschl 4392: for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
4393: if ($i==$incindex) {
1.358 bisitz 4394: $selectbox.='<option value="" selected="selected">('.$i.')</option>';
1.329 droeschl 4395: } else {
4396: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
4397: }
4398: }
4399: $selectbox.='</select>';
4400: }
1.484.2.12 raeburn 4401: %lt=&Apache::lonlocal::texthash(
1.329 droeschl 4402: 'up' => 'Move Up',
4403: 'dw' => 'Move Down',
4404: 'rm' => 'Remove',
4405: 'ct' => 'Cut',
4406: 'rn' => 'Rename',
1.484.2.12 raeburn 4407: 'cp' => 'Copy',
4408: 'ex' => 'External Resource',
1.484.2.93.2. (raeburn 4409:): 'et' => 'External Tool',
1.484.2.12 raeburn 4410: 'ed' => 'Edit',
4411: 'pr' => 'Preview',
4412: 'sv' => 'Save',
4413: 'ul' => 'URL',
1.484.2.67 raeburn 4414: 'ti' => 'Title',
4415: 'er' => 'Editing rights unavailable for your current role.',
1.484.2.12 raeburn 4416: );
1.484.2.30 raeburn 4417: my %denied = &action_restrictions($coursenum,$coursedom,$url,
4418: $env{'form.folderpath'},
4419: $currgroups);
1.484.2.19 raeburn 4420: my ($copylink,$cutlink,$removelink);
1.329 droeschl 4421: my $skip_confirm = 0;
1.484.2.63 raeburn 4422: my $confirm_removal = 0;
1.329 droeschl 4423: if ( $folder =~ /^supplemental/
4424: || ($url =~ m{( /smppg$
4425: |/syllabus$
4426: |/aboutme$
4427: |/navmaps$
4428: |/bulletinboard$
1.484.2.93.2. (raeburn 4429:): |/ext\.tool$
1.484.2.16 raeburn 4430: |\.html$)}x)
1.484.2.19 raeburn 4431: || $isexternal) {
1.329 droeschl 4432: $skip_confirm = 1;
4433: }
1.484.2.63 raeburn 4434: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
4435: ($url!~/$LONCAPA::assess_page_seq_re/)) {
4436: $confirm_removal = 1;
4437: }
1.484.2.19 raeburn 4438:
1.484.2.30 raeburn 4439: if ($denied{'copy'}) {
4440: $copylink=(<<ENDCOPY)
1.484.2.16 raeburn 4441: <span style="visibility: hidden;">$lt{'cp'}</span>
4442: ENDCOPY
4443: } else {
1.484.2.30 raeburn 4444: my $formname = 'edit_copy_'.$orderidx;
4445: my $js = "javascript:checkForSubmit(document.forms.renameform,'copy','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.484.2.19 raeburn 4446: $copylink=(<<ENDCOPY);
1.484.2.30 raeburn 4447: <form name="$formname" method="post" action="/adm/coursedocs">
4448: $form_common
1.484.2.67 raeburn 4449: <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.484.2.30 raeburn 4450: $form_end
1.329 droeschl 4451: ENDCOPY
1.484.2.30 raeburn 4452: if (($ishash) && (ref($filtersref->{'cancopy'}) eq 'ARRAY')) {
4453: push(@{$filtersref->{'cancopy'}},$orderidx);
4454: }
1.329 droeschl 4455: }
1.484.2.30 raeburn 4456: if ($denied{'cut'}) {
1.484.2.16 raeburn 4457: $cutlink=(<<ENDCUT);
4458: <span style="visibility: hidden;">$lt{'ct'}</span>
4459: ENDCUT
4460: } else {
1.484.2.30 raeburn 4461: my $formname = 'edit_cut_'.$orderidx;
4462: my $js = "javascript:checkForSubmit(document.forms.renameform,'cut','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.484.2.19 raeburn 4463: $cutlink=(<<ENDCUT);
1.484.2.30 raeburn 4464: <form name="$formname" method="post" action="/adm/coursedocs">
4465: $form_common
4466: <input type="hidden" name="skip_$orderidx" id="skip_cut_$orderidx" value="$skip_confirm" />
1.484.2.67 raeburn 4467: <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.484.2.30 raeburn 4468: $form_end
1.329 droeschl 4469: ENDCUT
1.484.2.30 raeburn 4470: if (($ishash) && (ref($filtersref->{'cancut'}) eq 'ARRAY')) {
4471: push(@{$filtersref->{'cancut'}},$orderidx);
4472: }
1.329 droeschl 4473: }
1.484.2.30 raeburn 4474: if ($denied{'remove'}) {
1.484.2.16 raeburn 4475: $removelink=(<<ENDREM);
4476: <span style="visibility: hidden;">$lt{'rm'}</a>
4477: ENDREM
4478: } else {
1.484.2.30 raeburn 4479: my $formname = 'edit_remove_'.$orderidx;
1.484.2.63 raeburn 4480: my $js = "javascript:checkForSubmit(document.forms.renameform,'remove','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder',$confirm_removal);";
1.484.2.9 raeburn 4481: $removelink=(<<ENDREM);
1.484.2.30 raeburn 4482: <form name="$formname" method="post" action="/adm/coursedocs">
4483: $form_common
4484: <input type="hidden" name="skip_$orderidx" id="skip_remove_$orderidx" value="$skip_confirm" />
1.484.2.63 raeburn 4485: <input type="hidden" name="confirm_rem_$orderidx" id="confirm_removal_$orderidx" value="$confirm_removal" />
1.484.2.67 raeburn 4486: <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.484.2.30 raeburn 4487: $form_end
1.484.2.9 raeburn 4488: ENDREM
1.484.2.30 raeburn 4489: if (($ishash) && (ref($filtersref->{'canremove'}) eq 'ARRAY')) {
4490: push(@{$filtersref->{'canremove'}},$orderidx);
4491: }
1.484.2.9 raeburn 4492: }
1.484.2.35 raeburn 4493: $renamelink=(<<ENDREN);
1.484.2.52 raeburn 4494: <a href='javascript:changename("$esc_path","$index","$oldtitle");' class="LC_docs_rename">$lt{'rn'}</a>
1.484.2.16 raeburn 4495: ENDREN
1.484.2.67 raeburn 4496: my ($uplink,$downlink);
4497: if ($canedit) {
4498: $uplink = "/adm/coursedocs?cmd=up_$index&folderpath=$esc_path&symb=$symb";
4499: $downlink = "/adm/coursedocs?cmd=down_$index&folderpath=$esc_path&symb=$symb";
4500: } else {
4501: $uplink = "javascript:alert('".&js_escape($lt{'er'})."');";
4502: $downlink = $uplink;
4503: }
1.329 droeschl 4504: $line.=(<<END);
4505: <td>
1.379 bisitz 4506: <div class="LC_docs_entry_move">
1.484.2.67 raeburn 4507: <a href="$uplink">
1.484.2.12 raeburn 4508: <img src="${iconpath}move_up.gif" alt="$lt{'up'}" class="LC_icon" />
1.379 bisitz 4509: </a>
4510: </div>
4511: <div class="LC_docs_entry_move">
1.484.2.67 raeburn 4512: <a href="$downlink">
1.484.2.12 raeburn 4513: <img src="${iconpath}move_down.gif" alt="$lt{'dw'}" class="LC_icon" />
1.379 bisitz 4514: </a>
4515: </div>
1.329 droeschl 4516: </td>
4517: <td>
4518: $form_start
1.484.2.30 raeburn 4519: $form_param
1.478 raeburn 4520: $form_common
1.329 droeschl 4521: $selectbox
4522: $form_end
4523: </td>
1.484.2.30 raeburn 4524: <td class="LC_docs_entry_commands LC_nobreak">
1.484.2.9 raeburn 4525: $removelink
1.329 droeschl 4526: $cutlink
4527: $copylink
4528: </td>
4529: END
4530: }
4531: # Figure out what kind of a resource this is
4532: my ($extension)=($url=~/\.(\w+)$/);
4533: my $uploaded=($url=~/^\/*uploaded\//);
4534: my $icon=&Apache::loncommon::icon($url);
1.484.2.19 raeburn 4535: my $isfolder;
4536: my $ispage;
4537: my $containerarg;
1.484.2.67 raeburn 4538: my $folderurl;
1.484.2.93.2. 0(raebur 4539:3): my $plainurl;
1.329 droeschl 4540: if ($uploaded) {
1.472 raeburn 4541: if (($extension eq 'sequence') || ($extension eq 'page')) {
4542: $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
1.484.2.19 raeburn 4543: $containerarg = $1;
1.472 raeburn 4544: if ($extension eq 'sequence') {
4545: $icon=$iconpath.'navmap.folder.closed.gif';
4546: $isfolder=1;
4547: } else {
4548: $icon=$iconpath.'page.gif';
4549: $ispage=1;
4550: }
1.484.2.67 raeburn 4551: $folderurl = &Apache::lonnet::declutter($url);
1.472 raeburn 4552: if ($allowed) {
4553: $url='/adm/coursedocs?';
4554: } else {
4555: $url='/adm/supplemental?';
4556: }
1.329 droeschl 4557: } else {
1.484.2.93.2. 0(raebur 4558:3): $plainurl = $url;
1.329 droeschl 4559: }
4560: }
1.364 bisitz 4561:
1.484.2.70 raeburn 4562: my ($editlink,$extresform,$anchor,$hiddenres,$nomodal);
1.329 droeschl 4563: my $orig_url = $url;
1.340 raeburn 4564: $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
1.484.2.87 raeburn 4565: if ($container eq 'page') {
4566: $url=~s{^http(|s)(:|:)//}{/ext/};
4567: } else {
4568: $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
4569: }
1.484.2.12 raeburn 4570: if (!$supplementalflag && $residx && $symb) {
4571: if ((!$isfolder) && (!$ispage)) {
4572: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
1.484.2.87 raeburn 4573: if (($url =~ m{^ext/}) && ($container eq 'page')) {
4574: $url=&Apache::lonnet::clutter_with_no_wrapper($url);
4575: } else {
4576: $url=&Apache::lonnet::clutter($url);
4577: }
1.484.2.12 raeburn 4578: if ($url=~/^\/*uploaded\//) {
4579: $url=~/\.(\w+)$/;
4580: my $embstyle=&Apache::loncommon::fileembstyle($1);
4581: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
4582: $url='/adm/wrapper'.$url;
4583: } elsif ($embstyle eq 'ssi') {
4584: #do nothing with these
4585: } elsif ($url!~/\.(sequence|page)$/) {
4586: $url='/adm/coursedocs/showdoc'.$url;
4587: }
1.484.2.70 raeburn 4588: } elsif ($url=~m{^(|/adm/wrapper)/ext/([^#]+)}) {
4589: my $wrapped = $1;
4590: my $exturl = $2;
1.484.2.87 raeburn 4591: if (($wrapped eq '') && ($container ne 'page')) {
1.484.2.70 raeburn 4592: $url='/adm/wrapper'.$url;
4593: }
4594: if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) {
4595: $nomodal = 1;
4596: }
1.484.2.93.2. (raeburn 4597:): } elsif ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4598:): $url='/adm/wrapper'.$url;
1.484.2.70 raeburn 4599: } elsif ($url eq "/public/$coursedom/$coursenum/syllabus") {
4600: if (($ENV{'SERVER_PORT'} == 443) &&
4601: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
1.484.2.93 raeburn 4602: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.484.2.80 raeburn 4603: $url .= '?usehttp=1';
4604: }
1.484.2.70 raeburn 4605: $nomodal = 1;
4606: }
1.484.2.19 raeburn 4607: }
1.484.2.93.2. (raeburn 4608:): my ($checkencrypt,$shownurl);
4609:): if (!$env{'request.role.adv'}) {
1.484.2.67 raeburn 4610: if (((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) ||
1.484.2.93.2. (raeburn 4611:): ($isencrypted) || (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i)) {
1.484.2.67 raeburn 4612: $checkencrypt = 1;
1.484.2.70 raeburn 4613: } elsif (ref($navmapref)) {
1.484.2.67 raeburn 4614: unless (ref($$navmapref)) {
4615: $$navmapref = Apache::lonnavmaps::navmap->new();
4616: }
4617: if (ref($$navmapref)) {
4618: if (lc($$navmapref->get_mapparam($symb,undef,"0.encrypturl")) eq 'yes') {
4619: $checkencrypt = 1;
4620: }
4621: }
4622: }
1.484.2.93.2. (raeburn 4623:): }
4624:): if ($checkencrypt) {
4625:): my $currenc = $env{'request.enc'};
4626:): $env{'request.enc'} = 1;
4627:): $shownsymb = &Apache::lonenc::encrypted($symb);
4628:): $shownurl = &Apache::lonenc::encrypted($url);
4629:): if (&Apache::lonnet::symbverify($symb,$url)) {
4630:): $url = $shownurl;
1.484.2.67 raeburn 4631: } else {
1.484.2.93.2. (raeburn 4632:): $url = '';
1.484.2.67 raeburn 4633: }
1.484.2.93.2. (raeburn 4634:): $env{'request.enc'} = $currenc;
4635:): } elsif (&Apache::lonnet::symbverify($symb,$url)) {
4636:): $shownsymb = $symb;
4637:): if ($isexternal) {
4638:): $url =~ s/\#[^#]+$//;
4639:): if ($container eq 'page') {
4640:): $url = &Apache::lonnet::clutter($url);
4641:): }
4642:): }
4643:): $shownurl = $url;
4644:): }
4645:): unless ($env{'request.role.adv'}) {
4646:): if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4647:): $url = '';
4648:): }
4649:): if (&Apache::lonnet::EXT('resource.0.hiddenresource',$symb) =~ /^yes$/i) {
4650:): $url = '';
4651:): $hiddenres = 1;
4652:): }
4653:): }
4654:): if ($url ne '') {
4655:): $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
1.484.2.12 raeburn 4656: }
1.484.2.19 raeburn 4657: }
1.484.2.66 raeburn 4658: } elsif ($supplementalflag) {
4659: if ($isexternal) {
4660: if ($url =~ /^([^#]+)#([^#]+)$/) {
4661: $url = $1;
4662: $anchor = $2;
1.484.2.70 raeburn 4663: if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) {
1.484.2.93 raeburn 4664: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.484.2.80 raeburn 4665: if ($hostname ne '') {
4666: $url = 'http://'.$hostname.$url;
4667: }
4668: $url .= (($url =~ /\?/) ? '&':'?').'usehttp=1';
4669: }
1.484.2.70 raeburn 4670: $nomodal = 1;
4671: }
4672: }
4673: } elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
4674: if (($ENV{'SERVER_PORT'} == 443) &&
4675: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
1.484.2.93 raeburn 4676: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.484.2.80 raeburn 4677: if ($hostname ne '') {
4678: $url = 'http://'.$hostname.$url;
4679: }
4680: $url .= (($url =~ /\?/) ? '&':'?').'usehttp=1';
4681: }
1.484.2.70 raeburn 4682: $nomodal = 1;
1.484.2.66 raeburn 4683: }
1.484.2.93.2. 6(raebur 4684:3): } elsif (($uploaded) && ($url ne '/adm/supplemental?') && ($url ne '/adm/coursedocs?')) {
0(raebur 4685:3): my $embstyle=&Apache::loncommon::fileembstyle($extension);
4686:3): unless ($embstyle eq 'ssi') {
4687:3): if (($embstyle eq 'img')
4688:3): || ($embstyle eq 'emb')
4689:3): || ($embstyle eq 'wrp')) {
4690:3): $url='/adm/wrapper'.$url;
4691:3): } elsif ($url !~ /\.(sequence|page)$/) {
4692:3): $url='/adm/coursedocs/showdoc'.$url;
4693:3): }
4694:3): }
4695:3): }
4696:3): unless ($allowed && $env{'request.role.adv'}) {
4697:3): if ($ishidden || (&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4698:3): $hiddenres = 1;
4699:3): }
1.484.2.66 raeburn 4700: }
1.329 droeschl 4701: }
1.484.2.67 raeburn 4702: my ($rand_pick_text,$rand_order_text,$hiddenfolder);
4703: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.484.2.19 raeburn 4704: if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') {
1.329 droeschl 4705: my $foldername=&escape($foldertitle);
4706: my $folderpath=$env{'form.folderpath'};
4707: if ($folderpath) { $folderpath.='&' };
1.484.2.19 raeburn 4708: if (!$allowed && $supplementalflag) {
4709: $folderpath.=$containerarg.'&'.$foldername;
4710: $url.='folderpath='.&escape($folderpath);
1.484.2.93.2. 0(raebur 4711:3): if ($ishidden || (&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4712:3): $hiddenfolder = 1;
4713:3): }
1.484.2.19 raeburn 4714: } else {
4715: my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
4716: 'parameter_randompick'))[0];
1.484.2.67 raeburn 4717: my $randorder = ((&LONCAPA::map::getparameter($orderidx,
4718: 'parameter_randomorder'))[0]=~/^yes$/i);
4719: my $hiddenmap = ((&LONCAPA::map::getparameter($orderidx,
4720: 'parameter_hiddenresource'))[0]=~/^yes$/i);
4721: my $encryptmap = ((&LONCAPA::map::getparameter($orderidx,
4722: 'parameter_encrypturl'))[0]=~/^yes$/i);
4723: unless ($hiddenmap) {
1.484.2.70 raeburn 4724: if (ref($navmapref)) {
4725: unless (ref($$navmapref)) {
4726: $$navmapref = Apache::lonnavmaps::navmap->new();
4727: }
4728: if (ref($$navmapref)) {
4729: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
4730: my @resources = $$navmapref->retrieveResources($folderurl,$filterFunc,1,1);
4731: unless (@resources) {
4732: $hiddenmap = 1;
4733: unless ($env{'request.role.adv'}) {
4734: $url = '';
4735: $hiddenfolder = 1;
4736: }
1.484.2.67 raeburn 4737: }
4738: }
4739: }
4740: }
4741: }
4742: unless ($encryptmap) {
1.484.2.70 raeburn 4743: if ((ref($navmapref)) && (ref($$navmapref))) {
4744: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.encrypturl")) eq 'yes') {
4745: $encryptmap = 1;
4746: }
1.484.2.67 raeburn 4747: }
4748: }
4749:
4750: # Append randompick number, hidden, and encrypted with ":" to foldername,
4751: # so it gets transferred between levels
4752: $folderpath.=$containerarg.'&'.$foldername.
4753: ':'.$rpicknum.':'.$hiddenmap.':'.$encryptmap.':'.$randorder.':'.$ispage;
4754: unless ($url eq '') {
4755: $url.='folderpath='.&escape($folderpath);
4756: }
1.484.2.19 raeburn 4757: my $rpckchk;
4758: if ($rpicknum) {
4759: $rpckchk = ' checked="checked"';
1.484.2.30 raeburn 4760: if (($ishash) && (ref($filtersref->{'randompick'}) eq 'ARRAY')) {
4761: push(@{$filtersref->{'randompick'}},$orderidx.':'.$rpicknum);
4762: }
1.484.2.19 raeburn 4763: }
1.484.2.29 raeburn 4764: my $formname = 'edit_randompick_'.$orderidx;
1.484.2.19 raeburn 4765: $rand_pick_text =
1.478 raeburn 4766: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.484.2.30 raeburn 4767: $form_param."\n".
1.478 raeburn 4768: $form_common."\n".
1.484.2.67 raeburn 4769: '<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.484.2.19 raeburn 4770: if ($rpicknum ne '') {
4771: $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
4772: }
1.484.2.29 raeburn 4773: $rand_pick_text .= '</span></span>'.
4774: $form_end;
1.484.2.30 raeburn 4775: my $ro_set;
1.484.2.67 raeburn 4776: if ($randorder) {
1.484.2.30 raeburn 4777: $ro_set = 'checked="checked"';
4778: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4779: push(@{$filtersref->{'randomorder'}},$orderidx);
4780: }
4781: }
1.484.2.41 raeburn 4782: $formname = 'edit_rorder_'.$orderidx;
1.484.2.19 raeburn 4783: $rand_order_text =
1.484.2.29 raeburn 4784: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.484.2.30 raeburn 4785: $form_param."\n".
1.484.2.29 raeburn 4786: $form_common."\n".
1.484.2.67 raeburn 4787: '<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.484.2.29 raeburn 4788: $form_end;
1.484.2.19 raeburn 4789: }
1.484.2.93.2. 6(raebur 4790:3): } elsif ($supplementalflag) {
(raeburn 4791:): my $isexttool;
4792:): if ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4793:): $url='/adm/wrapper'.$url;
4794:): $isexttool = 1;
4795:): }
1.484.2.19 raeburn 4796: $url .= ($url =~ /\?/) ? '&':'?';
1.484.2.18 raeburn 4797: $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
1.484.2.19 raeburn 4798: if ($title) {
1.484.2.93.2. 0(raebur 4799:3): $url .= '&title='.$encodedtitle;
1.484.2.19 raeburn 4800: }
1.484.2.93.2. (raeburn 4801:): if ((($isexternal) || ($isexttool)) && $orderidx) {
1.484.2.19 raeburn 4802: $url .= '&idx='.$orderidx;
4803: }
1.484.2.66 raeburn 4804: if ($anchor ne '') {
4805: $url .= '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4806: }
1.329 droeschl 4807: }
1.484.2.19 raeburn 4808: my ($tdalign,$tdwidth);
1.484.2.12 raeburn 4809: if ($allowed) {
1.484.2.19 raeburn 4810: my $fileloc =
1.484.2.12 raeburn 4811: &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
1.484.2.19 raeburn 4812: if ($isexternal) {
4813: ($editlink,$extresform) =
1.484.2.67 raeburn 4814: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
1.484.2.93.2. (raeburn 4815:): undef,undef,undef,undef,undef,undef,
4816:): undef,$disabled);
4817:): } elsif ($orig_url =~ m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4818:): ($editlink,$extresform) =
4819:): &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
4820:): undef,undef,undef,'tool',$coursedom,
4821:): $coursenum,$ltitoolsref,$disabled);
1.484.2.19 raeburn 4822: } elsif (!$isfolder && !$ispage) {
4823: my ($cfile,$home,$switchserver,$forceedit,$forceview) =
1.484.2.14 raeburn 4824: &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
1.484.2.19 raeburn 4825: if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
1.484.2.66 raeburn 4826: my $suppanchor;
4827: if ($supplementalflag) {
4828: $suppanchor = $anchor;
4829: }
1.484.2.19 raeburn 4830: my $jscall =
1.484.2.12 raeburn 4831: &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
4832: $switchserver,
1.484.2.14 raeburn 4833: $forceedit,
1.484.2.93.2. (raeburn 4834:): undef,$symb,$shownsymb,
1.484.2.19 raeburn 4835: &escape($env{'form.folderpath'}),
1.484.2.80 raeburn 4836: $renametitle,$hostname,
4837: '','',1,$suppanchor);
1.484.2.12 raeburn 4838: if ($jscall) {
1.484.2.19 raeburn 4839: $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
4840: $jscall.'" >'.&mt('Edit').'</a> '."\n";
1.484.2.12 raeburn 4841: }
4842: }
4843: }
1.484.2.19 raeburn 4844: $tdalign = ' align="right" valign="top"';
4845: $tdwidth = ' width="80%"';
1.329 droeschl 4846: }
1.408 raeburn 4847: my $reinit;
4848: if ($crstype eq 'Community') {
4849: $reinit = &mt('(re-initialize community to access)');
4850: } else {
4851: $reinit = &mt('(re-initialize course to access)');
1.484.2.19 raeburn 4852: }
4853: $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;
1.484.2.93.2. 0(raebur 4854:3): my ($link,$nolink);
1.472 raeburn 4855: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.484.2.93.2. 0(raebur 4856:3): if ($allowed && !$env{'request.role.adv'} && !$isfolder && !$ispage) {
4857:3): if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4858:3): $nolink = 1;
4859:3): }
4860:3): }
4861:3): if ($nolink) {
4862:3): $line .= '<img src="'.$icon.'" alt="" class="LC_icon" /></a>';
4863:3): } else {
4864:3): $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
4865:3): }
1.469 www 4866: } elsif ($url) {
1.484.2.66 raeburn 4867: if ($anchor ne '') {
4868: if ($supplementalflag) {
4869: $anchor = '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4870: } else {
4871: $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');
4872: }
4873: }
1.484.2.93.2. 6(raebur 4874:3): if (($nomodal) && ($hostname ne '')) {
1.484.2.80 raeburn 4875: $link = 'http://'.$hostname.$url;
4876: } else {
4877: $link = $url;
4878: }
1.484.2.93.2. 6(raebur 4879:3): my $inhibitmenu;
4880:3): if ((($supplementalflag) && ($allowed) && ($url =~ m{^/adm/wrapper/})) ||
4881:3): (($allowed) && (($url =~ m{^/adm/(viewclasslist|$match_domain/$match_username/aboutme)(\?|$)}) ||
4882:3): ($url =~ m{^/public/$match_domain/$match_courseid/syllabus(\?|$)})))) {
4883:3): $inhibitmenu = 'only_body=1';
4884:3): } else {
4885:3): $inhibitmenu = 'inhibitmenu=yes';
4886:3): }
4887:3): $link = &js_escape($link.(($url=~/\?/)?'&':'?').$inhibitmenu.$anchor);
0(raebur 4888:3): if ($allowed && !$env{'request.role.adv'} && !$isfolder && !$ispage && !$uploaded) {
4889:3): if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4890:3): $nolink = 1;
4891:3): }
4892:3): }
4893:3): if ($nolink) {
4894:3): $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
4895:3): } elsif ($nomodal) {
1.484.2.70 raeburn 4896: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4897: '<img src="'.$icon.'" alt="" class="LC_icon" border="0" /></a>';
4898: } else {
4899: $line.=&Apache::loncommon::modal_link($link,
4900: '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
4901: }
1.469 www 4902: } else {
4903: $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
4904: }
1.484.2.19 raeburn 4905: $line.='</span></td><td'.$tdwidth.'>';
1.472 raeburn 4906: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.484.2.93.2. 0(raebur 4907:3): if ($nolink) {
4908:3): $line.=$title;
4909:3): } else {
4910:3): $line.='<a href="'.$url.'">'.$title.'</a>';
4911:3): }
4912:3): if (!$allowed && $supplementalflag && $canedit && $isfolder) {
4913:3): my $editicon = &Apache::loncommon::lonhttpdurl('/res/adm/pages').'/editmap.png';
4914:3): my $editurl = $url;
4915:3): $editurl =~ s{^\Q/adm/supplemental?\E}{/adm/coursedocs?command=direct&forcesupplement=1&};
4916:3): $line .= ' '.'<a href="'.$editurl.'">'.
4917:3): '<img src="'.$editicon.'" alt="'.&mt('Edit Content').'" title="'.&mt('Edit Content').'" />'.
4918:3): '</a>';
4919:3): }
4920:3): if ((($hiddenfolder) || ($hiddenres)) && (!$allowed) && ($supplementalflag)) {
4921:3): $line.= ' <span class="LC_warning">('.&mt('hidden').')</span> ';
4922:3): }
1.469 www 4923: } elsif ($url) {
1.484.2.93.2. 0(raebur 4924:3): if ($nolink) {
4925:3): $line.=$title;
4926:3): } elsif ($nomodal) {
1.484.2.70 raeburn 4927: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4928: $title.'</a>';
4929: } else {
4930: $line.=&Apache::loncommon::modal_link($link,$title,600,500);
4931: }
1.484.2.67 raeburn 4932: } elsif (($hiddenfolder) || ($hiddenres)) {
1.484.2.72 raeburn 4933: $line.=$title.' <span class="LC_warning LC_docs_reinit_warn">('.&mt('Hidden').')</span>';
1.469 www 4934: } else {
4935: $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
4936: }
1.484.2.19 raeburn 4937: $line.="$extresform</td>";
1.478 raeburn 4938: $rand_pick_text = ' ' if ($rand_pick_text eq '');
4939: $rand_order_text = ' ' if ($rand_order_text eq '');
1.484.2.93.2. 0(raebur 4940:3): if ($uploaded && $url && !$isfolder && !$ispage) {
4941:3): if (($plainurl ne '') && ($env{'request.role.adv'} || $allowed || !$hiddenres)) {
4942:3): &Apache::lonnet::allowuploaded('/adm/coursedoc',$plainurl);
1.484.2.30 raeburn 4943: }
1.484.2.93.2. 0(raebur 4944:3): }
4945:3): if ($allowed) {
4946:3): my %lt=&Apache::lonlocal::texthash(
4947:3): 'hd' => 'Hidden',
4948:3): 'ec' => 'URL hidden');
4949:3): my ($enctext,$hidtext,$formhidden,$formurlhidden);
1.484.2.30 raeburn 4950: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4951: $hidtext = ' checked="checked"';
1.484.2.93.2. (raeburn 4952:): if (($ishash) && (ref($filtersref->{'hiddenresource'}) eq 'ARRAY')) {
1.484.2.30 raeburn 4953: push(@{$filtersref->{'hiddenresource'}},$orderidx);
4954: }
4955: }
1.484.2.93.2. 0(raebur 4956:3): $formhidden = 'edit_hiddenresource_'.$orderidx;
4957:3): $line.=(<<ENDPARMS);
1.329 droeschl 4958: <td class="LC_docs_entry_parameter">
1.484.2.30 raeburn 4959: <form action="/adm/coursedocs" method="post" name="$formhidden">
4960: $form_param
1.478 raeburn 4961: $form_common
1.484.2.67 raeburn 4962: <label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'hiddenresource','settings');" $hidtext $disabled /> $lt{'hd'}</label>
1.329 droeschl 4963: $form_end
1.484.2.93.2. 0(raebur 4964:3): ENDPARMS
4965:3): if ($folder =~/^supplemental/) {
4966:3): $line.= "\n <td>";
4967:3): } else {
4968:3): if ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) {
4969:3): $enctext = ' checked="checked"';
4970:3): if (($ishash) && (ref($filtersref->{'encrypturl'}) eq 'ARRAY')) {
4971:3): push(@{$filtersref->{'encrypturl'}},$orderidx);
4972:3): }
4973:3): }
4974:3): $formurlhidden = 'edit_encrypturl_'.$orderidx;
4975:3): $line.=(<<ENDPARMS);
1.458 raeburn 4976: <br />
1.484.2.29 raeburn 4977: <form action="/adm/coursedocs" method="post" name="$formurlhidden">
1.484.2.30 raeburn 4978: $form_param
1.478 raeburn 4979: $form_common
1.484.2.67 raeburn 4980: <label><input type="checkbox" name="encrypturl_$orderidx" id="encrypturl_$orderidx" onclick="checkForSubmit(this.form,'encrypturl','settings');" $enctext $disabled /> $lt{'ec'}</label>
1.329 droeschl 4981: $form_end
4982: </td>
1.478 raeburn 4983: <td class="LC_docs_entry_parameter">$rand_pick_text<br />
4984: $rand_order_text</td>
1.329 droeschl 4985: ENDPARMS
1.484.2.93.2. 0(raebur 4986:3): }
1.329 droeschl 4987: }
1.379 bisitz 4988: $line.=&Apache::loncommon::end_data_table_row();
1.329 droeschl 4989: return $line;
4990: }
4991:
1.484.2.30 raeburn 4992: sub action_restrictions {
4993: my ($cnum,$cdom,$url,$folderpath,$currgroups) = @_;
4994: my %denied = (
4995: cut => 0,
4996: copy => 0,
4997: remove => 0,
4998: );
4999: if ($url=~ m{^/res/.+\.(page|sequence)$}) {
5000: # no copy for published maps
5001: $denied{'copy'} = 1;
1.484.2.82 raeburn 5002: } elsif ($url=~m{^/res/lib/templates/([^/]+)\.problem$}) {
5003: unless ($1 eq 'simpleproblem') {
5004: $denied{'copy'} = 1;
5005: }
5006: $denied{'cut'} = 1;
1.484.2.30 raeburn 5007: } elsif ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") {
5008: if ($folderpath =~ /^default&[^\&]+$/) {
5009: if ((ref($currgroups) eq 'HASH') && (keys(%{$currgroups}) > 0)) {
5010: $denied{'remove'} = 1;
5011: }
5012: $denied{'cut'} = 1;
5013: $denied{'copy'} = 1;
5014: }
5015: } elsif ($url =~ m{^\Q/uploaded/$cdom/$cnum/group_folder_\E(\w+)\.sequence$}) {
5016: my $group = $1;
5017: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+$/) {
5018: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
5019: $denied{'remove'} = 1;
5020: }
5021: }
5022: $denied{'cut'} = 1;
5023: $denied{'copy'} = 1;
5024: } elsif ($url =~ m{^\Q/adm/$cdom/$cnum/\E(\w+)/smppg$}) {
5025: my $group = $1;
5026: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&\Qgroup_folder_$group\E\&[^\&]+$/) {
5027: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
5028: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
5029: if (keys(%groupsettings) > 0) {
5030: $denied{'remove'} = 1;
5031: }
5032: $denied{'cut'} = 1;
5033: $denied{'copy'} = 1;
5034: }
5035: }
5036: } elsif ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&group_folder_(\w+)\&/) {
5037: my $group = $1;
5038: if ($url =~ /group_boards_\Q$group\E/) {
5039: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
5040: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
5041: if (keys(%groupsettings) > 0) {
5042: if (ref($groupsettings{'functions'}) eq 'HASH') {
5043: if ($groupsettings{'functions'}{'discussion'} eq 'on') {
5044: $denied{'remove'} = 1;
5045: }
5046: }
5047: }
5048: $denied{'cut'} = 1;
5049: $denied{'copy'} = 1;
5050: }
5051: }
5052: }
5053: return %denied;
5054: }
5055:
1.484.2.26 raeburn 5056: sub new_timebased_suffix {
1.484.2.30 raeburn 5057: my ($dom,$num,$type,$area,$container) = @_;
1.484.2.26 raeburn 5058: my ($prefix,$namespace,$idtype,$errtext,$locknotfreed);
1.484.2.30 raeburn 5059: if ($type eq 'paste') {
5060: $prefix = $type;
5061: $namespace = 'courseeditor';
1.484.2.56 raeburn 5062: $idtype = 'addcode';
1.484.2.30 raeburn 5063: } elsif ($type eq 'map') {
1.484.2.26 raeburn 5064: $prefix = 'docs';
5065: if ($area eq 'supplemental') {
5066: $prefix = 'supp';
5067: }
5068: $prefix .= $container;
5069: $namespace = 'uploadedmaps';
5070: } else {
5071: $prefix = $type;
5072: $namespace = 'templated';
1.484.2.15 raeburn 5073: }
5074: my ($suffix,$freedlock,$error) =
1.484.2.56 raeburn 5075: &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num,$idtype);
1.484.2.15 raeburn 5076: if (!$suffix) {
1.484.2.30 raeburn 5077: if ($type eq 'paste') {
5078: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.');
5079: } elsif ($type eq 'map') {
1.484.2.26 raeburn 5080: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
5081: } elsif ($type eq 'smppg') {
5082: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.');
1.484.2.93.2. (raeburn 5083:): } elsif ($type eq 'exttool') {
5084:): $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new external tool.');
1.484.2.26 raeburn 5085: } else {
1.484.2.42 raeburn 5086: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new discussion board.');
1.484.2.26 raeburn 5087: }
1.484.2.15 raeburn 5088: if ($error) {
5089: $errtext .= '<br />'.$error;
5090: }
5091: }
5092: if ($freedlock ne 'ok') {
1.484.2.26 raeburn 5093: $locknotfreed =
5094: '<div class="LC_error">'.
5095: &mt('There was a problem removing a lockfile.').' ';
1.484.2.30 raeburn 5096: if ($type eq 'paste') {
1.484.2.57 raeburn 5097: if ($freedlock eq 'nolock') {
5098: $locknotfreed =
5099: '<div class="LC_error">'.
5100: &mt('A lockfile was not released when you added content to the clipboard earlier in this session.').' '.
5101:
1.484.2.60 raeburn 5102: &mt('As a result addition of items to the clipboard will be unavailable until your next log-in.');
1.484.2.57 raeburn 5103: } else {
5104: $locknotfreed .=
5105: &mt('This will prevent addition of items to the clipboard until your next log-in.');
5106: }
1.484.2.30 raeburn 5107: } elsif ($type eq 'map') {
1.484.2.57 raeburn 5108: $locknotfreed .=
5109: &mt('This will prevent creation of additional folders or composite pages in this course.');
1.484.2.26 raeburn 5110: } elsif ($type eq 'smppg') {
5111: $locknotfreed .=
5112: &mt('This will prevent creation of additional simple pages in this course.');
1.484.2.93.2. (raeburn 5113:): } elsif ($type eq 'exttool') {
5114:): $locknotfreed .=
5115:): &mt('This will prevent creation of additional external tools in this course.');
1.484.2.26 raeburn 5116: } else {
5117: $locknotfreed .=
1.484.2.42 raeburn 5118: &mt('This will prevent creation of additional discussion boards in this course.');
1.484.2.26 raeburn 5119: }
1.484.2.30 raeburn 5120: unless ($type eq 'paste') {
5121: $locknotfreed .=
1.484.2.38 raeburn 5122: ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
5123: '<a href="/adm/helpdesk" target="_helpdesk">','</a>');
1.484.2.30 raeburn 5124: }
5125: $locknotfreed .= '</div>';
1.484.2.15 raeburn 5126: }
5127: return ($suffix,$errtext,$locknotfreed);
5128: }
5129:
1.329 droeschl 5130: =pod
5131:
5132: =item tiehash()
5133:
5134: tie the hash
5135:
5136: =cut
5137:
5138: sub tiehash {
5139: my ($mode)=@_;
5140: $hashtied=0;
5141: if ($env{'request.course.fn'}) {
5142: if ($mode eq 'write') {
5143: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
5144: &GDBM_WRCREAT(),0640)) {
5145: $hashtied=2;
5146: }
5147: } else {
5148: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
5149: &GDBM_READER(),0640)) {
5150: $hashtied=1;
5151: }
5152: }
1.364 bisitz 5153: }
1.329 droeschl 5154: }
5155:
5156: sub untiehash {
5157: if ($hashtied) { untie %hash; }
5158: $hashtied=0;
5159: return OK;
5160: }
5161:
5162:
5163:
5164:
5165: sub checkonthis {
1.484.2.78 raeburn 5166: my ($r,$url,$level,$title,$checkstale)=@_;
1.329 droeschl 5167: $url=&unescape($url);
5168: $alreadyseen{$url}=1;
5169: $r->rflush();
5170: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
5171: $r->print("\n<br />");
5172: if ($level==0) {
5173: $r->print("<br />");
5174: }
5175: for (my $i=0;$i<=$level*5;$i++) {
5176: $r->print(' ');
5177: }
5178: $r->print('<a href="'.$url.'" target="cat">'.
5179: ($title?$title:$url).'</a> ');
5180: if ($url=~/^\/res\//) {
1.484.2.78 raeburn 5181: my $updated;
5182: if (($checkstale) && ($url !~ m{^/res/lib/templates/}) &&
5183: ($url !~ /\.\d+\.\w+$/)) {
5184: $updated = &Apache::lonnet::remove_stale_resfile($url);
5185: }
1.329 droeschl 5186: my $result=&Apache::lonnet::repcopy(
5187: &Apache::lonnet::filelocation('',$url));
5188: if ($result eq 'ok') {
5189: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
1.484.2.78 raeburn 5190: if ($updated) {
5191: $r->print('<br />');
5192: for (my $i=0;$i<=$level*5;$i++) {
5193: $r->print(' ');
5194: }
5195: $r->print('- '.&mt('Outdated copy removed'));
5196: }
1.329 droeschl 5197: $r->rflush();
5198: &Apache::lonnet::countacc($url);
5199: $url=~/\.(\w+)$/;
5200: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
5201: $r->print('<br />');
5202: $r->rflush();
5203: for (my $i=0;$i<=$level*5;$i++) {
5204: $r->print(' ');
5205: }
5206: $r->print('- '.&mt('Rendering:').' ');
5207: my ($errorcount,$warningcount)=split(/:/,
5208: &Apache::lonnet::ssi_body($url,
5209: ('grade_target'=>'web',
5210: 'return_only_error_and_warning_counts' => 1)));
5211: if (($errorcount) ||
5212: ($warningcount)) {
5213: if ($errorcount) {
1.369 bisitz 5214: $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1.329 droeschl 5215: &mt('[quant,_1,error]',$errorcount).'</span>');
5216: }
5217: if ($warningcount) {
5218: $r->print('<span class="LC_warning">'.
5219: &mt('[quant,_1,warning]',$warningcount).'</span>');
5220: }
5221: } else {
5222: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
5223: }
5224: $r->rflush();
5225: }
5226: my $dependencies=
5227: &Apache::lonnet::metadata($url,'dependencies');
5228: foreach my $dep (split(/\,/,$dependencies)) {
5229: if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
1.484.2.78 raeburn 5230: &checkonthis($r,$dep,$level+1,'',$checkstale);
1.329 droeschl 5231: }
5232: }
5233: } elsif ($result eq 'unavailable') {
5234: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
5235: } elsif ($result eq 'not_found') {
5236: unless ($url=~/\$/) {
1.484.2.19 raeburn 5237: $r->print('<span class="LC_error">'.&mt('not found').'</span>');
1.329 droeschl 5238: } else {
1.366 bisitz 5239: $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1.329 droeschl 5240: }
5241: } else {
5242: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
5243: }
1.484.2.78 raeburn 5244: if (($updated) && ($result ne 'ok')) {
5245: $r->print('<br />'.&mt('Outdated copy removed'));
5246: }
1.329 droeschl 5247: }
5248: }
5249: }
5250:
5251:
5252:
5253: =pod
5254:
5255: =item list_symbs()
5256:
1.484.2.3 raeburn 5257: List Content Identifiers
1.329 droeschl 5258:
5259: =cut
5260:
5261: sub list_symbs {
5262: my ($r) = @_;
5263:
1.408 raeburn 5264: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 5265: $r->print(&Apache::loncommon::start_page('List of Content Identifiers'));
5266: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Identifiers'));
5267: $r->print(&startContentScreen('tools'));
1.329 droeschl 5268: my $navmap = Apache::lonnavmaps::navmap->new();
5269: if (!defined($navmap)) {
5270: $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
5271: '<div class="LC_error">'.
5272: &mt('Unable to retrieve information about course contents').
5273: '</div>');
1.408 raeburn 5274: &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
1.329 droeschl 5275: } else {
1.484 raeburn 5276: $r->print('<h4 class="LC_info">'.&mt("$crstype Content Identifiers").'</h4>'.
5277: &Apache::loncommon::start_data_table().
5278: &Apache::loncommon::start_data_table_header_row().
5279: '<th>'.&mt('Title').'</th><th>'.&mt('Identifier').'</th>'.
5280: &Apache::loncommon::end_data_table_header_row()."\n");
5281: my $count;
1.329 droeschl 5282: foreach my $res ($navmap->retrieveResources()) {
1.484 raeburn 5283: $r->print(&Apache::loncommon::start_data_table_row().
5284: '<td>'.$res->compTitle().'</td>'.
5285: '<td>'.$res->symb().'</td>'.
1.484.2.19 raeburn 5286: &Apache::loncommon::end_data_table_row());
1.484 raeburn 5287: $count ++;
5288: }
5289: if (!$count) {
5290: $r->print(&Apache::loncommon::start_data_table_row().
5291: '<td colspan="2">'.&mt("$crstype is empty").'</td>'.
5292: &Apache::loncommon::end_data_table_row());
1.329 droeschl 5293: }
1.484 raeburn 5294: $r->print(&Apache::loncommon::end_data_table());
1.329 droeschl 5295: }
1.484.2.19 raeburn 5296: $r->print(&endContentScreen());
1.329 droeschl 5297: }
5298:
1.484.2.93.2. (raeburn 5299:): sub short_urls {
5300:): my ($r,$canedit) = @_;
5301:): my $crstype = &Apache::loncommon::course_type();
5302:): my $formname = 'shortenurl';
5303:): $r->print(&Apache::loncommon::start_page('Display/Set Shortened URLs'));
5304:): $r->print(&Apache::lonhtmlcommon::breadcrumbs('Shortened URLs'));
5305:): $r->print(&startContentScreen('tools'));
5306:): my ($navmap,$errormsg) =
5307:): &Apache::loncourserespicker::get_navmap_object($crstype,'shorturls');
5308:): my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
5309:): my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
5310:): my (%maps,%resources,%titles);
5311:): if (!ref($navmap)) {
5312:): $r->print($errormsg.
5313:): &endContentScreen());
5314:): return '';
5315:): } else {
5316:): $r->print('<h4 class="LC_info">'.&mt('Tiny URLs for deep-linking into course').'</h4>'."\n");
5317:): $r->rflush();
5318:): my $readonly;
5319:): if ($canedit) {
5320:): my ($numnew,$errors) = &Apache::loncommon::get_requested_shorturls($cdom,$cnum,$navmap);
5321:): if ($numnew) {
5322:): $r->print('<p class="LC_info">'.&mt('Created [quant,_1,URL]',$numnew).'</p>');
5323:): }
5324:): if ((ref($errors) eq 'ARRAY') && (@{$errors} > 0)) {
5325:): $r->print(&mt('The following errors occurred when processing your request to create shortened URLs:').'<br /><ul>');
5326:): foreach my $error (@{$errors}) {
5327:): $r->print('<li>'.$error.'</li>');
5328:): }
5329:): $r->print('</ul><br />');
5330:): }
5331:): } else {
5332:): $readonly = 1;
5333:): }
5334:): my %currtiny = &Apache::lonnet::dump('tiny',$cdom,$cnum);
5335:): $r->print(&Apache::loncourserespicker::create_picker($navmap,'shorturls',$formname,$crstype,undef,
5336:): undef,undef,undef,undef,undef,\%currtiny,$readonly));
5337:): }
5338:): $r->print(&endContentScreen());
5339:): }
5340:):
1.484.2.78 raeburn 5341: sub contentverifyform {
5342: my ($r) = @_;
5343: my $crstype = &Apache::loncommon::course_type();
5344: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
5345: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
5346: $r->print(&startContentScreen('tools'));
5347: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
5348: $r->print('<form method="post" action="/adm/coursedocs"><p>'.
5349: &mt('Include a check if files copied from elsewhere are up to date (will increase verification time)?').
5350: ' <span class="LC_nobreak">'.
5351: '<label><input type="radio" name="checkstale" value="0" checked="checked" />'.
5352: &mt('No').'</label>'.(' 'x2).
5353: '<label><input type="radio" name="checkstale" value="1" />'.
5354: &mt('Yes').'</label></span></p><p>'.
1.484.2.90 raeburn 5355: '<input type="submit" value="'.&mt('Verify Content').' "/>'.
1.484.2.78 raeburn 5356: '<input type="hidden" value="1" name="tools" />'.
5357: '<input type="hidden" value="1" name="verify" /></p></form>');
5358: $r->print(&endContentScreen());
5359: return;
5360: }
1.329 droeschl 5361:
5362: sub verifycontent {
1.484.2.78 raeburn 5363: my ($r,$checkstale) = @_;
1.408 raeburn 5364: my $crstype = &Apache::loncommon::course_type();
1.484.2.34 raeburn 5365: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
5366: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
1.484 raeburn 5367: $r->print(&startContentScreen('tools'));
5368: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
1.329 droeschl 5369: $hashtied=0;
5370: undef %alreadyseen;
5371: %alreadyseen=();
5372: &tiehash();
1.484 raeburn 5373:
1.329 droeschl 5374: foreach my $key (keys(%hash)) {
5375: if ($hash{$key}=~/\.(page|sequence)$/) {
5376: if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
5377: $r->print('<hr /><span class="LC_error">'.
1.419 bisitz 5378: &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
1.329 droeschl 5379: &unescape($hash{$key}).'</span><br />'.
1.419 bisitz 5380: &mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />');
1.329 droeschl 5381: }
5382: }
5383: if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
1.484.2.78 raeburn 5384: &checkonthis($r,$hash{$key},0,$hash{'title_'.$1},$checkstale);
1.329 droeschl 5385: }
5386: }
5387: &untiehash();
1.442 www 5388: $r->print('<p class="LC_success">'.&mt('Done').'</p>');
1.484.2.19 raeburn 5389: $r->print(&endContentScreen());
1.329 droeschl 5390: }
5391:
5392:
5393: sub devalidateversioncache {
5394: my $src=shift;
5395: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
5396: &Apache::lonnet::clutter($src));
5397: }
5398:
5399: sub checkversions {
1.484.2.67 raeburn 5400: my ($r,$canedit) = @_;
1.408 raeburn 5401: my $crstype = &Apache::loncommon::course_type();
1.484.2.44 raeburn 5402: $r->print(&Apache::loncommon::start_page("Check $crstype Resource Versions"));
5403: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Resource Versions"));
1.484 raeburn 5404: $r->print(&startContentScreen('tools'));
1.442 www 5405:
1.329 droeschl 5406: my $header='';
5407: my $startsel='';
5408: my $monthsel='';
5409: my $weeksel='';
5410: my $daysel='';
5411: my $allsel='';
5412: my %changes=();
5413: my $starttime=0;
5414: my $haschanged=0;
5415: my %setversions=&Apache::lonnet::dump('resourceversions',
5416: $env{'course.'.$env{'request.course.id'}.'.domain'},
5417: $env{'course.'.$env{'request.course.id'}.'.num'});
5418:
5419: $hashtied=0;
5420: &tiehash();
1.484.2.67 raeburn 5421: if ($canedit) {
5422: my %newsetversions=();
5423: if ($env{'form.setmostrecent'}) {
5424: $haschanged=1;
5425: foreach my $key (keys(%hash)) {
5426: if ($key=~/^ids\_(\/res\/.+)$/) {
5427: $newsetversions{$1}='mostrecent';
5428: &devalidateversioncache($1);
5429: }
1.329 droeschl 5430: }
1.484.2.67 raeburn 5431: } elsif ($env{'form.setcurrent'}) {
5432: $haschanged=1;
5433: foreach my $key (keys(%hash)) {
5434: if ($key=~/^ids\_(\/res\/.+)$/) {
5435: my $getvers=&Apache::lonnet::getversion($1);
5436: if ($getvers>0) {
5437: $newsetversions{$1}=$getvers;
5438: &devalidateversioncache($1);
5439: }
5440: }
1.329 droeschl 5441: }
1.484.2.67 raeburn 5442: } elsif ($env{'form.setversions'}) {
5443: $haschanged=1;
5444: foreach my $key (keys(%env)) {
5445: if ($key=~/^form\.set_version_(.+)$/) {
5446: my $src=$1;
5447: if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
5448: $newsetversions{$src}=$env{$key};
5449: &devalidateversioncache($src);
5450: }
5451: }
1.329 droeschl 5452: }
1.484.2.67 raeburn 5453: }
5454: if ($haschanged) {
5455: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
5456: $env{'course.'.$env{'request.course.id'}.'.domain'},
5457: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
5458: $r->print(&Apache::loncommon::confirmwrapper(
5459: &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
5460: } else {
5461: $r->print(&Apache::loncommon::confirmwrapper(
5462: &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
5463: }
5464: &mark_hash_old();
5465: }
5466: &changewarning($r,'');
1.329 droeschl 5467: }
5468: if ($env{'form.timerange'} eq 'all') {
5469: # show all documents
1.484.2.34 raeburn 5470: $header=&mt('All content in '.$crstype);
1.484.2.19 raeburn 5471: $allsel=' selected="selected"';
1.329 droeschl 5472: foreach my $key (keys(%hash)) {
5473: if ($key=~/^ids\_(\/res\/.+)$/) {
5474: my $src=$1;
5475: $changes{$src}=1;
5476: }
5477: }
5478: } else {
5479: # show documents which changed
5480: %changes=&Apache::lonnet::dump
5481: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
5482: $env{'course.'.$env{'request.course.id'}.'.num'});
5483: my $firstkey=(keys(%changes))[0];
5484: unless ($firstkey=~/^error\:/) {
5485: unless ($env{'form.timerange'}) {
5486: $env{'form.timerange'}=604800;
5487: }
5488: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
5489: .&mt('seconds');
5490: if ($env{'form.timerange'}==-1) {
5491: $seltext='since start of course';
1.484.2.19 raeburn 5492: $startsel=' selected="selected"';
1.329 droeschl 5493: $env{'form.timerange'}=time;
5494: }
5495: $starttime=time-$env{'form.timerange'};
5496: if ($env{'form.timerange'}==2592000) {
5497: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 5498: $monthsel=' selected="selected"';
1.329 droeschl 5499: } elsif ($env{'form.timerange'}==604800) {
5500: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 5501: $weeksel=' selected="selected"';
1.329 droeschl 5502: } elsif ($env{'form.timerange'}==86400) {
5503: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 5504: $daysel=' selected="selected"';
1.329 droeschl 5505: }
5506: $header=&mt('Content changed').' '.$seltext;
5507: } else {
5508: $header=&mt('No content modifications yet.');
5509: }
5510: }
5511: %setversions=&Apache::lonnet::dump('resourceversions',
5512: $env{'course.'.$env{'request.course.id'}.'.domain'},
5513: $env{'course.'.$env{'request.course.id'}.'.num'});
5514: my %lt=&Apache::lonlocal::texthash
1.408 raeburn 5515: ('st' => 'Version changes since start of '.$crstype,
1.329 droeschl 5516: 'lm' => 'Version changes since last Month',
5517: 'lw' => 'Version changes since last Week',
5518: 'sy' => 'Version changes since Yesterday',
5519: 'al' => 'All Resources (possibly large output)',
1.484 raeburn 5520: 'cd' => 'Change display',
1.329 droeschl 5521: 'sd' => 'Display',
5522: 'fi' => 'File',
5523: 'md' => 'Modification Date',
5524: 'mr' => 'Most recently published Version',
1.408 raeburn 5525: 've' => 'Version used in '.$crstype,
5526: 'vu' => 'Set Version to be used in '.$crstype,
5527: 'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
1.329 droeschl 5528: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
5529: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.479 golterma 5530: 'di' => 'Differences',
1.484 raeburn 5531: 'save' => 'Save changes',
5532: 'vers' => 'Version choice(s) for specific resources',
1.479 golterma 5533: 'act' => 'Actions');
1.484.2.67 raeburn 5534: my ($disabled,$readonly);
5535: unless ($canedit) {
5536: $disabled = 'disabled="disabled"';
5537: $readonly = 1;
5538: }
1.329 droeschl 5539: $r->print(<<ENDHEADERS);
1.484 raeburn 5540: <h4 class="LC_info">$header</h4>
1.329 droeschl 5541: <form action="/adm/coursedocs" method="post">
5542: <input type="hidden" name="versions" value="1" />
1.484 raeburn 5543: <div class="LC_left_float">
1.479 golterma 5544: <fieldset>
1.484 raeburn 5545: <legend>$lt{'cd'}</legend>
1.329 droeschl 5546: <select name="timerange">
1.484.2.19 raeburn 5547: <option value='all'$allsel>$lt{'al'}</option>
5548: <option value="-1"$startsel>$lt{'st'}</option>
5549: <option value="2592000"$monthsel>$lt{'lm'}</option>
5550: <option value="604800"$weeksel>$lt{'lw'}</option>
5551: <option value="86400"$daysel>$lt{'sy'}</option>
1.329 droeschl 5552: </select>
5553: <input type="submit" name="display" value="$lt{'sd'}" />
1.484 raeburn 5554: </fieldset>
5555: </div>
5556: <div class="LC_left_float">
5557: <fieldset>
5558: <legend>$lt{'act'}</legend>
1.484.2.67 raeburn 5559: $lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" $disabled /><br />
5560: $lt{'sc'}: <input type="submit" name="setcurrent" value="Go" $disabled />
1.484 raeburn 5561: </fieldset>
5562: </div>
5563: <br clear="all" />
5564: <hr />
5565: <h4>$lt{'vers'}</h4>
1.329 droeschl 5566: ENDHEADERS
1.479 golterma 5567: #number of columns for version history
1.484.2.44 raeburn 5568: my %changedbytime;
5569: foreach my $key (keys(%changes)) {
5570: #excludes not versionable problems from resource version history:
5571: next if ($key =~ /^\/res\/lib\/templates/);
5572: my $chg;
5573: if ($env{'form.timerange'} eq 'all') {
5574: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
5575: $chg = &Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate');
5576: } else {
5577: $chg = $changes{$key};
5578: next if ($chg < $starttime);
5579: }
5580: push(@{$changedbytime{$chg}},$key);
5581: }
5582: if (keys(%changedbytime) == 0) {
5583: &untiehash();
5584: $r->print(&mt('No content changes in imported content in specified time frame').
5585: &endContentScreen());
5586: return;
5587: }
1.479 golterma 5588: $r->print(
1.484.2.67 raeburn 5589: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.484.2.19 raeburn 5590: &Apache::loncommon::start_data_table().
5591: &Apache::loncommon::start_data_table_header_row().
5592: '<th>'.&mt('Resources').'</th>'.
5593: "<th>$lt{'mr'}</th>".
5594: "<th>$lt{'ve'}</th>".
5595: "<th>$lt{'vu'}</th>".
5596: '<th>'.&mt('History').'</th>'.
5597: &Apache::loncommon::end_data_table_header_row()
5598: );
1.484.2.44 raeburn 5599: foreach my $chg (sort {$b <=> $a } keys(%changedbytime)) {
5600: foreach my $key (sort(@{$changedbytime{$chg}})) {
5601: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
5602: my $currentversion=&Apache::lonnet::getversion($key);
5603: if ($currentversion<0) {
5604: $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
5605: }
5606: my $linkurl=&Apache::lonnet::clutter($key);
5607: $r->print(
5608: &Apache::loncommon::start_data_table_row().
5609: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br />'.
5610: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
5611: '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br />('.
5612: &Apache::lonlocal::locallocaltime($chg).')</span></td>'.
5613: '<td align="right">'
5614: );
5615: # Used in course
5616: my $usedversion=$hash{'version_'.$linkurl};
5617: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.484.2.19 raeburn 5618: if ($usedversion != $currentversion) {
1.479 golterma 5619: $r->print('<span class="LC_warning">'.$usedversion.'</span>');
1.484.2.19 raeburn 5620: } else {
1.479 golterma 5621: $r->print($usedversion);
5622: }
1.329 droeschl 5623: } else {
1.484.2.19 raeburn 5624: $r->print($currentversion);
1.329 droeschl 5625: }
1.484.2.44 raeburn 5626: $r->print('</td><td title="'.$lt{'vu'}.'">');
5627: # Set version
5628: $r->print(&Apache::loncommon::select_form(
5629: $setversions{$linkurl},
5630: 'set_version_'.$linkurl,
5631: {'select_form_order' => ['',1..$currentversion,'mostrecent'],
5632: '' => '',
5633: 'mostrecent' => &mt('most recent'),
1.484.2.67 raeburn 5634: map {$_,$_} (1..$currentversion)},'',$readonly));
1.484.2.44 raeburn 5635: my $lastold=1;
5636: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
5637: my $url=$root.'.'.$prevvers.'.'.$extension;
5638: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) {
5639: $lastold=$prevvers;
5640: }
5641: }
5642: $r->print('</td>');
5643: # List all available versions
5644: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
5645: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
5646: my $url=$root.'.'.$prevvers.'.'.$extension;
1.484.2.19 raeburn 5647: $r->print(
1.484.2.44 raeburn 5648: '<span class="LC_nobreak">'
5649: .'<a href="'.&Apache::lonnet::clutter($url).'">'
5650: .&mt('Version [_1]',$prevvers).'</a>'
5651: .' ('.&Apache::lonlocal::locallocaltime(
5652: &Apache::lonnet::metadata($url,'lastrevisiondate'))
5653: .')');
5654: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
5655: $r->print(
5656: ' <a href="/adm/diff?filename='.
5657: &Apache::lonnet::clutter($root.'.'.$extension).
5658: &HTML::Entities::encode('&versionone='.$prevvers,'"<>&').
5659: '" target="diffs">'.&mt('Diffs').'</a>');
5660: }
5661: $r->print('</span><br />');
1.329 droeschl 5662: }
1.484.2.44 raeburn 5663: $r->print('</span></td>'.&Apache::loncommon::end_data_table_row());
1.484.2.19 raeburn 5664: }
1.329 droeschl 5665: }
1.484.2.19 raeburn 5666: $r->print(
5667: &Apache::loncommon::end_data_table().
1.484.2.67 raeburn 5668: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.484.2.19 raeburn 5669: '</form>'
5670: );
1.329 droeschl 5671:
5672: &untiehash();
1.484.2.19 raeburn 5673: $r->print(&endContentScreen());
1.484.2.44 raeburn 5674: return;
1.329 droeschl 5675: }
5676:
5677: sub mark_hash_old {
5678: my $retie_hash=0;
5679: if ($hashtied) {
5680: $retie_hash=1;
5681: &untiehash();
5682: }
5683: &tiehash('write');
5684: $hash{'old'}=1;
5685: &untiehash();
5686: if ($retie_hash) { &tiehash(); }
5687: }
5688:
5689: sub is_hash_old {
5690: my $untie_hash=0;
5691: if (!$hashtied) {
5692: $untie_hash=1;
5693: &tiehash();
5694: }
5695: my $return=$hash{'old'};
5696: if ($untie_hash) { &untiehash(); }
5697: return $return;
5698: }
5699:
5700: sub changewarning {
5701: my ($r,$postexec,$message,$url)=@_;
5702: if (!&is_hash_old()) { return; }
5703: my $pathvar='folderpath';
5704: my $path=&escape($env{'form.folderpath'});
5705: if (!defined($url)) {
5706: $url='/adm/coursedocs?'.$pathvar.'='.$path;
5707: }
5708: my $course_type = &Apache::loncommon::course_type();
5709: if (!defined($message)) {
5710: $message='Changes will become active for your current session after [_1], or the next time you log in.';
5711: }
1.484.2.93.2. 2(raebur 5712:3): my $windowname = 'loncapaclient';
5713:3): if ($env{'request.lti.login'}) {
5714:3): $windowname .= 'lti';
5715:3): }
1.329 droeschl 5716: $r->print("\n\n".
1.372 bisitz 5717: '<script type="text/javascript">'."\n".
5718: '// <![CDATA['."\n".
5719: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
5720: '// ]]>'."\n".
1.369 bisitz 5721: '</script>'."\n".
1.484.2.93.2. 2(raebur 5722:3): '<form name="reinitform" method="post" action="/adm/roles" target="'.$windowname.'">'.
1.329 droeschl 5723: '<input type="hidden" name="orgurl" value="'.$url.
1.372 bisitz 5724: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
1.329 droeschl 5725: &mt($message,' <input type="hidden" name="'.
5726: $env{'request.role'}.'" value="1" /><input type="button" value="'.
1.369 bisitz 5727: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1.372 bisitz 5728: $help{'Caching'}.'</p></form>'."\n\n");
1.329 droeschl 5729: }
5730:
5731:
5732: sub init_breadcrumbs {
1.484.2.44 raeburn 5733: my ($form,$text,$help)=@_;
1.329 droeschl 5734: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484 raeburn 5735: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
1.405 bisitz 5736: text=>&Apache::loncommon::course_type().' Editor',
1.329 droeschl 5737: faq=>273,
5738: bug=>'Instructor Interface',
1.484.2.44 raeburn 5739: help => $help});
1.329 droeschl 5740: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
5741: text=>$text,
5742: faq=>273,
5743: bug=>'Instructor Interface'});
5744: }
5745:
1.441 www 5746: # subroutine to list form elements
5747: sub create_list_elements {
5748: my @formarr = @_;
5749: my $list = '';
1.484.2.12 raeburn 5750: foreach my $button (@formarr){
5751: foreach my $picture (keys(%{$button})) {
5752: $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
1.441 www 5753: }
5754: }
5755: return $list;
5756: }
1.329 droeschl 5757:
1.441 www 5758: # subroutine to create ul from list elements
5759: sub create_form_ul {
5760: my $list = shift;
5761: my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
5762: return $ul;
5763: }
1.329 droeschl 5764:
1.442 www 5765: #
5766: # Start tabs
5767: #
5768:
5769: sub startContentScreen {
1.484 raeburn 5770: my ($mode) = @_;
5771: my $output = '<ul class="LC_TabContentBigger" id="mainnav">';
1.472 raeburn 5772: if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
1.484 raeburn 5773: $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n";
5774: $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n";
5775: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
5776: } else {
1.484.2.34 raeburn 5777: $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 5778: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
5779: $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>'."\n";
5780: '><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>';
5781: }
5782: $output .= "\n".'</ul>'."\n";
5783: $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
5784: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
5785: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
5786: return $output;
1.442 www 5787: }
5788:
5789: #
5790: # End tabs
5791: #
5792:
5793: sub endContentScreen {
1.484 raeburn 5794: return '</div></div></div>';
1.442 www 5795: }
1.329 droeschl 5796:
1.446 www 5797: sub supplemental_base {
1.484.2.33 raeburn 5798: return 'supplemental&'.&escape(&mt('Supplemental Content'));
1.446 www 5799: }
5800:
1.329 droeschl 5801: sub handler {
5802: my $r = shift;
5803: &Apache::loncommon::content_type($r,'text/html');
5804: $r->send_http_header;
5805: return OK if $r->header_only;
1.484 raeburn 5806:
5807: # get course data
1.408 raeburn 5808: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 5809: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
5810: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5811:
5812: # graphics settings
5813: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329 droeschl 5814:
1.443 www 5815: #
1.329 droeschl 5816: # --------------------------------------------- Initialize help topics for this
5817: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
1.484.2.93.2. (raeburn 5818:): 'Adding_External_Resource','Adding_External_Tool',
5819:): 'Navigate_Content','Adding_Folders','Docs_Overview',
5820:): 'Load_Map','Supplemental','Score_Upload_Form',
5821:): 'Adding_Pages','Importing_LON-CAPA_Resource',
5822:): 'Importing_IMS_Course','Uploading_From_Harddrive',
5823:): 'Course_Roster','Web_Page','Dropbox','Simple_Problem') {
1.329 droeschl 5824: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
5825: }
5826: # Composite help files
5827: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
5828: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
5829: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
5830: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
5831: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
5832: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 5833: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 5834: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 5835: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 5836: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1.484.2.30 raeburn 5837:
1.484.2.67 raeburn 5838: my ($allowed,$canedit,$canview,$disabled);
1.484.2.93.2. 0(raebur 5839:3): # does this user have privileges to modify content.
5840:3): if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
1.472 raeburn 5841: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
1.484.2.93.2. 0(raebur 5842:3): unless ($r->uri eq '/adm/supplemental') {
1.484.2.67 raeburn 5843: $allowed = 1;
1.484.2.93.2. 0(raebur 5844:3): }
5845:3): $canedit = 1;
5846:3): $canview = 1;
5847:3): } elsif (&Apache::lonnet::allowed('cev',$env{'request.course.id'})) {
5848:3): # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
5849:3): unless ($r->uri eq '/adm/supplemental') {
1.484.2.67 raeburn 5850: $allowed = 1;
5851: }
1.484.2.93.2. 0(raebur 5852:3): $canview = 1;
1.484.2.67 raeburn 5853: }
5854: unless ($canedit) {
5855: $disabled = ' disabled="disabled"';
1.472 raeburn 5856: }
1.484.2.53 raeburn 5857: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']);
1.484.2.78 raeburn 5858: if ($env{'form.inhibitmenu'}) {
5859: unless ($env{'form.inhibitmenu'} eq 'yes') {
5860: delete($env{'form.inhibitmenu'});
5861: }
5862: }
5863:
1.484.2.53 raeburn 5864: if ($allowed && $env{'form.verify'}) {
1.484.2.44 raeburn 5865: &init_breadcrumbs('verify','Verify Content','Docs_Verify_Content');
1.484.2.78 raeburn 5866: if (!$canedit) {
5867: &verifycontent($r);
5868: } elsif (($env{'form.checkstale'} ne '') && ($env{'form.checkstale'} =~ /^\d$/)) {
5869: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1&verify=1&checkstale=$env{'form.checkstale'}",
5870: text=>'Results',
5871: faq=>273,
5872: bug=>'Instructor Interface'});
5873: &verifycontent($r,$env{'form.checkstale'});
5874: } else {
5875: &contentverifyform($r);
5876: }
1.329 droeschl 5877: } elsif ($allowed && $env{'form.listsymbs'}) {
1.484 raeburn 5878: &init_breadcrumbs('listsymbs','List Content IDs');
1.329 droeschl 5879: &list_symbs($r);
1.484.2.93.2. (raeburn 5880:): } elsif ($allowed && $env{'form.shorturls'}) {
5881:): &init_breadcrumbs('shorturls','Set/Display Shortened URLs','Docs_Short_URLs');
5882:): &short_urls($r,$canedit);
1.329 droeschl 5883: } elsif ($allowed && $env{'form.docslog'}) {
5884: &init_breadcrumbs('docslog','Show Log');
1.484 raeburn 5885: my $folder = $env{'form.folder'};
5886: if ($folder eq '') {
5887: $folder='default';
5888: }
1.484.2.67 raeburn 5889: &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit);
1.329 droeschl 5890: } elsif ($allowed && $env{'form.versions'}) {
1.484.2.44 raeburn 5891: &init_breadcrumbs('versions','Check/Set Resource Versions','Docs_Check_Resource_Versions');
1.484.2.67 raeburn 5892: &checkversions($r,$canedit);
5893: } elsif ($canedit && $env{'form.dumpcourse'}) {
1.484.2.43 raeburn 5894: &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329 droeschl 5895: &dumpcourse($r);
5896: } elsif ($allowed && $env{'form.exportcourse'}) {
1.377 bisitz 5897: &init_breadcrumbs('exportcourse','IMS Export');
1.475 raeburn 5898: &Apache::imsexport::exportcourse($r);
1.329 droeschl 5899: } else {
1.445 www 5900: #
5901: # Done catching special calls
1.484 raeburn 5902: # The whole rest is for course and supplemental documents and utilities menu
1.445 www 5903: # Get the parameters that may be needed
5904: #
5905: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.484.2.93.2. 0(raebur 5906:3): ['folderpath','title',
1.484.2.19 raeburn 5907: 'forcesupplement','forcestandard',
5908: 'tools','symb','command','supppath']);
1.445 www 5909:
1.484.2.78 raeburn 5910: foreach my $item ('forcesupplement','forcestandard','tools') {
5911: next if ($env{'form.'.$item} eq '');
5912: unless ($env{'form.'.$item} eq '1') {
5913: delete($env{'form.'.$item});
5914: }
5915: }
5916:
5917: if ($env{'form.command'}) {
5918: unless ($env{'form.command'} =~ /^(direct|directnav|editdocs|editsupp|contents|home)$/) {
5919: delete($env{'form.command'});
5920: }
5921: }
5922:
5923: if ($env{'form.symb'}) {
5924: my ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.symb'});
5925: unless (($id =~ /^\d+$/) && (&Apache::lonnet::is_on_map($resurl))) {
5926: delete($env{'form.symb'});
5927: }
5928: }
5929:
1.445 www 5930: # standard=1: this is a "new-style" course with an uploaded map as top level
5931: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329 droeschl 5932:
5933: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445 www 5934:
1.484 raeburn 5935: # Decide whether this should display supplemental or main content or utilities
1.445 www 5936: # supplementalflag=1: show supplemental documents
5937: # supplementalflag=0: show standard documents
1.484 raeburn 5938: # toolsflag=1: show utilities
1.445 www 5939:
1.484.2.39 raeburn 5940: my $unesc_folderpath = &unescape($env{'form.folderpath'});
5941: my $supplementalflag=($unesc_folderpath=~/^supplemental/);
5942: if (($unesc_folderpath=~/^default/) || ($unesc_folderpath eq "")) {
1.445 www 5943: $supplementalflag=0;
5944: }
5945: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
5946: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
1.484.2.93.2. 6(raebur 5947:3): unless (($supplementalflag) ||
5948:3): ($r->uri =~ m{^/adm/coursedocs/showdoc/uploaded/\Q$coursedom\E/\Q$coursenum\E/docs/})) {
5949:3): unless ($allowed) { $supplementalflag=1; }
5950:3): unless ($standard) { $supplementalflag=1; }
5951:3): }
1.484 raeburn 5952: my $toolsflag=0;
5953: if ($env{'form.tools'}) { $toolsflag=1; }
1.445 www 5954:
1.484.2.78 raeburn 5955: if ($env{'form.folderpath'} ne '') {
1.484.2.93.2. 0(raebur 5956:3): &Apache::loncommon::validate_folderpath($supplementalflag,$allowed,$coursenum,$coursedom);
1.484.2.78 raeburn 5957: }
5958:
1.484.2.93.2. 0(raebur 5959:3): my $backto_supppath;
1.484.2.78 raeburn 5960: if ($env{'form.supppath'} ne '') {
1.484.2.93.2. 0(raebur 5961:3): if ($supplementalflag && $allowed) {
5962:3): $backto_supppath = &validate_supppath($coursenum,$coursedom);
5963:3): }
1.484.2.78 raeburn 5964: }
5965:
1.329 droeschl 5966: my $script='';
5967: my $showdoc=0;
1.457 raeburn 5968: my $addentries = {};
1.475 raeburn 5969: my $container;
1.329 droeschl 5970: my $containertag;
1.484.2.17 raeburn 5971: my $pathitem;
1.484.2.93.2. (raeburn 5972:): my %ltitools;
2(raebur 5973:3): my $posslti;
1.484.2.67 raeburn 5974: my $hiddentop;
5975: my $navmap;
5976: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.329 droeschl 5977:
1.464 www 5978: # Do we directly jump somewhere?
1.484.2.21 raeburn 5979: if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
1.472 raeburn 5980: if ($env{'form.symb'} ne '') {
1.484.2.19 raeburn 5981: $env{'form.folderpath'}=
1.484.2.67 raeburn 5982: &Apache::loncommon::symb_to_docspath($env{'form.symb'},\$navmap);
1.484.2.21 raeburn 5983: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
5984: $env{'form.command'}.'_'.$env{'form.symb'}});
1.484.2.93.2. 0(raebur 5985:3): } elsif (($env{'form.supppath'} ne '') && $supplementalflag && $allowed) {
1.472 raeburn 5986: $env{'form.folderpath'}=$env{'form.supppath'};
1.484.2.21 raeburn 5987: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
1.484.2.93.2. 0(raebur 5988:3): $env{'form.command'}.'_'.$backto_supppath});
1.466 www 5989: }
1.472 raeburn 5990: } elsif ($env{'form.command'} eq 'editdocs') {
1.484.2.67 raeburn 5991: $env{'form.folderpath'} = &default_folderpath($coursenum,$coursedom,\$navmap);
1.484.2.21 raeburn 5992: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
1.472 raeburn 5993: } elsif ($env{'form.command'} eq 'editsupp') {
1.484.2.67 raeburn 5994: $env{'form.folderpath'} = &supplemental_base();
1.484.2.21 raeburn 5995: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
5996: } elsif ($env{'form.command'} eq 'contents') {
5997: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
5998: } elsif ($env{'form.command'} eq 'home') {
5999: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
1.464 www 6000: }
6001:
1.484.2.23 raeburn 6002:
1.445 www 6003: # Where do we store these for when we come back?
6004: my $stored_folderpath='docs_folderpath';
6005: if ($supplementalflag) {
6006: $stored_folderpath='docs_sup_folderpath';
6007: }
1.464 www 6008:
1.484.2.19 raeburn 6009: # No folderpath, and in edit mode, see if we have something stored
6010: if ((!$env{'form.folderpath'}) && $allowed) {
1.445 www 6011: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.484.2.19 raeburn 6012: {'folderpath' => 'scalar'});
1.484.2.67 raeburn 6013:
6014: if (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
6015: if ($supplementalflag) {
6016: undef($env{'form.folderpath'}) if ($1 eq 'default');
6017: } else {
6018: undef($env{'form.folderpath'}) if ($1 eq 'supplemental');
6019: }
6020: } else {
1.484.2.19 raeburn 6021: undef($env{'form.folderpath'});
6022: }
1.484.2.92 raeburn 6023: if ($env{'form.folderpath'} ne '') {
1.484.2.93.2. 0(raebur 6024:3): &Apache::loncommon::validate_folderpath($supplementalflag,$allowed,$coursenum,$coursedom);
1.484.2.92 raeburn 6025: }
1.329 droeschl 6026: }
1.484.2.93.2. 6(raebur 6027:3):
6028:3): # If we are not allowed to make changes and this is supplemental content set folderpath
6029:3): if ((!$allowed) && ($supplementalflag)) {
1.446 www 6030: unless ($env{'form.folderpath'} =~ /^supplemental/) {
6031: $env{'form.folderpath'} = &supplemental_base();
1.409 raeburn 6032: }
6033: }
1.446 www 6034: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329 droeschl 6035: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446 www 6036: $env{'form.folderpath'} = &supplemental_base()
6037: .'&'.
1.329 droeschl 6038: $env{'form.folderpath'};
6039: }
1.484.2.67 raeburn 6040: # If allowed and user's role is not advanced check folderpath is not hidden
1.484.2.93.2. 0(raebur 6041:3): my $hidden_and_empty;
6042:3): if (($allowed) && (!$env{'request.role.adv'}) && ($env{'form.folderpath'} ne '')) {
6043:3): my ($folderurl,$foldername,$hiddenfolder);
1.484.2.67 raeburn 6044: my @pathitems = split(/\&/,$env{'form.folderpath'});
6045: my $folder = $pathitems[-2];
6046: if ($folder eq '') {
6047: undef($env{'form.folderpath'});
6048: } else {
6049: $folderurl = "uploaded/$coursedom/$coursenum/$folder";
1.484.2.87 raeburn 6050: if ((split(/\:/,$pathitems[-1]))[5]) {
1.484.2.67 raeburn 6051: $folderurl .= '.page';
6052: } else {
6053: $folderurl .= '.sequence';
6054: }
1.484.2.93.2. 0(raebur 6055:3): if ($supplementalflag) {
6056:3): ($foldername,$hiddenfolder) = ($pathitems[-1] =~ /^([^:]*)::(|1):::$/);
6057:3): $foldername = &HTML::Entities::decode(&unescape($foldername));
6058:3): my ($supplemental) = &Apache::loncommon::get_supplemental($coursenum,$coursedom);
6059:3): if (ref($supplemental) eq 'HASH') {
6060:3): my ($suppmap,$suppmapnum);
6061:3): if ($folder eq 'supplemental') {
6062:3): $suppmap = 'default';
6063:3): $suppmapnum = 0;
6064:3): } elsif ($folder =~ /^supplemental_(\d+)$/) {
6065:3): $suppmap = $1;
6066:3): $suppmapnum = $suppmap;
6067:3): }
6068:3): if ($hiddenfolder) {
6069:3): my $hascontent;
6070:3): foreach my $key (reverse(sort(keys(%{$supplemental->{'ids'}})))) {
6071:3): if ($key =~ m{^\Q/uploaded/$coursedom/$coursenum/supplemental/$suppmap/\E}) {
6072:3): $hascontent = 1;
6073:3): } elsif (ref($supplemental->{'ids'}->{$key}) eq 'ARRAY') {
6074:3): foreach my $id (@{$supplemental->{'ids'}->{$key}}) {
6075:3): if ($id =~ /^$suppmapnum\:/) {
6076:3): $hascontent = 1;
6077:3): last;
6078:3): }
6079:3): }
6080:3): }
6081:3): last if ($hascontent);
6082:3): }
6083:3): unless ($hascontent) {
6084:3): if ($foldername ne '') {
6085:3): $hidden_and_empty = $foldername;
6086:3): } else {
6087:3): $hidden_and_empty = $folder;
6088:3): }
6089:3): }
1.484.2.67 raeburn 6090: }
6091: }
1.484.2.93.2. 0(raebur 6092:3): } else {
6093:3): unless (ref($navmap)) {
6094:3): $navmap = Apache::lonnavmaps::navmap->new();
6095:3): }
6096:3): ($foldername,$hiddenfolder) = ($pathitems[-1] =~ /^([^:]*):|\d+:|1:(|1):|1:|1$/);
6097:3): $foldername = &HTML::Entities::decode(&unescape($foldername));
6098:3): if (ref($navmap)) {
6099:3): if ($hiddenfolder ||
6100:3): (lc($navmap->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes')) {
6101:3): my @resources = $navmap->retrieveResources($folderurl,$filterFunc,1,1);
6102:3): unless (@resources) {
6103:3): if ($foldername ne '') {
6104:3): $hidden_and_empty = $foldername;
6105:3): } else {
6106:3): $hidden_and_empty = $folder;
6107:3): }
6108:3): }
6109:3): }
6110:3): }
6111:3): }
6112:3): if ($hidden_and_empty ne '') {
6113:3): splice(@pathitems,-2);
6114:3): if (@pathitems) {
6115:3): $env{'form.folderpath'} = join('&',@pathitems);
6116:3): } else {
6117:3): undef($env{'form.folderpath'});
6118:3): }
1.484.2.67 raeburn 6119: }
6120: }
6121: }
6122:
1.446 www 6123: # If after all of this, we still don't have any paths, make them
1.484.2.19 raeburn 6124: unless ($env{'form.folderpath'}) {
1.446 www 6125: if ($supplementalflag) {
6126: $env{'form.folderpath'}=&supplemental_base();
1.484.2.67 raeburn 6127: } elsif ($allowed) {
6128: ($env{'form.folderpath'},$hiddentop) = &default_folderpath($coursenum,$coursedom,\$navmap);
1.446 www 6129: }
1.472 raeburn 6130: }
1.446 www 6131:
1.445 www 6132: # Store this
1.484 raeburn 6133: unless ($toolsflag) {
1.484.2.67 raeburn 6134: if (($allowed) && ($env{'form.folderpath'} ne '')) {
1.484.2.19 raeburn 6135: &Apache::loncommon::store_course_settings($stored_folderpath,
6136: {'folderpath' => 'scalar'});
6137: }
6138: my $folderpath;
1.484 raeburn 6139: if ($env{'form.folderpath'}) {
1.484.2.19 raeburn 6140: $folderpath = $env{'form.folderpath'};
6141: my (@folders)=split('&',$env{'form.folderpath'});
6142: $env{'form.foldername'}=&unescape(pop(@folders));
6143: if ($env{'form.foldername'} =~ /\:1$/) {
6144: $container = 'page';
6145: } else {
6146: $container = 'sequence';
6147: }
6148: $env{'form.folder'}=pop(@folders);
1.484 raeburn 6149: } else {
1.484.2.19 raeburn 6150: if ($env{'form.folder'} eq '' ||
6151: $env{'form.folder'} eq 'supplemental') {
1.484.2.67 raeburn 6152: if ($env{'form.folder'} eq 'supplemental') {
6153: $folderpath=&supplemental_base();
6154: } elsif (!$hiddentop) {
6155: $folderpath='default&'.
6156: &escape(&mt('Main Content').':::::');
6157: }
1.484 raeburn 6158: }
6159: }
1.484.2.19 raeburn 6160: $containertag = '<input type="hidden" name="folderpath" value="" />';
6161: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 6162: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
6163: $showdoc='/'.$1;
6164: }
6165: if ($showdoc) { # got called in sequence from course
6166: $allowed=0;
6167: } else {
1.484.2.67 raeburn 6168: if ($canedit) {
1.484 raeburn 6169: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
6170: $script=&Apache::lonratedt::editscript('simple');
1.433 raeburn 6171: }
6172: }
1.329 droeschl 6173: }
6174:
1.344 bisitz 6175: # get personal data
1.329 droeschl 6176: my $uname=$env{'user.name'};
6177: my $udom=$env{'user.domain'};
6178: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
6179:
6180: if ($allowed) {
1.484 raeburn 6181: if ($toolsflag) {
6182: $script .= &inject_data_js();
6183: my ($home,$other,%outhash)=&authorhosts();
6184: if (!$home && $other) {
6185: my @hosts;
6186: foreach my $aurole (keys(%outhash)) {
6187: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
6188: push(@hosts,$outhash{$aurole});
6189: }
6190: }
6191: $script .= &dump_switchserver_js(@hosts);
6192: }
1.458 raeburn 6193: } else {
1.484.2.43 raeburn 6194: my $tid = 1;
1.484 raeburn 6195: my @tabids;
6196: if ($supplementalflag) {
6197: @tabids = ('002','ee2','ff2');
1.484.2.43 raeburn 6198: $tid = 2;
1.484 raeburn 6199: } else {
6200: @tabids = ('aa1','bb1','cc1','ff1');
1.484.2.19 raeburn 6201: unless ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 6202: unshift(@tabids,'001');
6203: push(@tabids,('dd1','ee1'));
6204: }
1.458 raeburn 6205: }
1.484 raeburn 6206: my $tabidstr = join("','",@tabids);
1.484.2.93.2. 2(raebur 6207:3): my (%domtools,%crstools);
6208:3): my %tooltypes = &Apache::loncommon::usable_exttools();
6209:3): if ($tooltypes{'dom'}) {
6210:3): %domtools = &Apache::lonnet::get_domain_lti($coursedom,'consumer');
6211:3): }
6212:3): if ($tooltypes{'crs'}) {
6213:3): %crstools = &Apache::lonnet::get_course_lti($coursenum,$coursedom,'consumer');
6214:3): }
6215:3): %ltitools = (
6216:3): dom => \%domtools,
6217:3): crs => \%crstools,
6218:3): );
6219:3): $posslti = scalar(keys(%domtools)) + scalar(keys(%crstools));
1.484.2.80 raeburn 6220: my $hostname = $r->hostname();
1.484.2.93.2. (raeburn 6221:): $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
1.484.2.80 raeburn 6222: $canedit,$hostname,\$navmap).
1.484 raeburn 6223: &history_tab_js().
6224: &inject_data_js().
1.484.2.43 raeburn 6225: &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
1.484.2.93.2. (raeburn 6226:): &Apache::lonextresedit::extedit_javascript(\%ltitools);
0(raebur 6227:3): my $onload = "javascript:resize_scrollbox('contentscroll','1','1');";
6228:3): if ($hidden_and_empty ne '') {
6229:3): my $alert = &mt("Additional privileges required to edit empty and hidden folder: '[_1]'",
6230:3): $hidden_and_empty);
6231:3): $onload .= "javascript:alert('".&js_escape($alert)."');";
6232:3): }
1.484 raeburn 6233: $addentries = {
1.484.2.93.2. 0(raebur 6234:3): onload => $onload,
1.484 raeburn 6235: };
1.458 raeburn 6236: }
1.484.2.30 raeburn 6237: $script .= &paste_popup_js();
1.484.2.12 raeburn 6238: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
6239: &mt('Switch server?');
1.484.2.19 raeburn 6240:
6241:
1.329 droeschl 6242: }
6243: # -------------------------------------------------------------------- Body tag
1.369 bisitz 6244: $script = '<script type="text/javascript">'."\n"
1.372 bisitz 6245: .'// <![CDATA['."\n"
6246: .$script."\n"
6247: .'// ]]>'."\n"
1.484.2.81 raeburn 6248: .'</script>'."\n"
6249: .'<script type="text/javascript" src="/res/adm/includes/file_upload.js"></script>'."\n";
1.385 bisitz 6250:
6251: # Breadcrumbs
6252: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484.2.19 raeburn 6253:
6254: if ($showdoc) {
1.484.2.93.2. 0(raebur 6255:3): my $args;
6256:3): if ($supplementalflag) {
6257:3): my $title = &HTML::Entities::encode($env{'form.title'},'\'"<>&');
6258:3): my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
6(raebur 6259:3): $args = {'bread_crumbs' => $brcrum,
6260:3): 'bread_crumbs_nomenu' => 1};
0(raebur 6261:3): } else {
6262:3): $args = {'force_register' => $showdoc};
6263:3): }
6264:3): $r->print(&Apache::loncommon::start_page("$crstype documents",undef,$args));
1.484.2.44 raeburn 6265: } elsif ($toolsflag) {
1.484.2.67 raeburn 6266: my ($breadtext,$breadtitle);
6267: $breadtext = "$crstype Editor";
6268: if ($canedit) {
6269: $breadtitle = 'Editing '.$crstype.' Contents';
6270: } else {
6271: $breadtext .= ' (View-only mode)';
6272: $breadtitle = 'Viewing '.$crstype.' Contents';
6273: }
1.484.2.44 raeburn 6274: &Apache::lonhtmlcommon::add_breadcrumb({
1.484.2.67 raeburn 6275: href=>"/adm/coursedocs",text=>$breadtext});
1.484.2.44 raeburn 6276: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script)
6277: .&Apache::loncommon::help_open_menu('','',273,'RAT')
6278: .&Apache::lonhtmlcommon::breadcrumbs(
1.484.2.67 raeburn 6279: $breadtitle)
1.484.2.44 raeburn 6280: );
1.484.2.19 raeburn 6281: } elsif ($r->uri eq '/adm/supplemental') {
1.484.2.93.2. 0(raebur 6282:3): unless ($env{'request.role.adv'}) {
6283:3): unless (&Apache::lonnet::has_unhidden_suppfiles($coursenum,$coursedom)) {
6284:3): $r->internal_redirect('/adm/navmaps');
6285:3): return OK;
6286:3): }
6287:3): }
1.484.2.19 raeburn 6288: my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
1.484.2.93.2. 6(raebur 6289:3): my $args = {'bread_crumbs' => $brcrum};
6290:3): unless (($env{'form.folderpath'} eq '') ||
6291:3): ($env{'form.folder'} eq 'supplemental')) {
6292:3): $args->{'bread_crumbs_nomenu'} = 1;
6293:3): }
1.484.2.19 raeburn 6294: $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
1.484.2.93.2. 6(raebur 6295:3): $args));
1.484.2.19 raeburn 6296: } else {
1.484.2.67 raeburn 6297: my ($breadtext,$breadtitle,$helpitem);
6298: $breadtext = "$crstype Editor";
6299: if ($canedit) {
6300: $breadtitle = 'Editing '.$crstype.' Contents';
6301: $helpitem = 'Docs_Adding_Course_Doc';
6302: } else {
6303: $breadtext .= ' (View-only mode)';
6304: $breadtitle = 'Viewing '.$crstype.' Contents';
6305: $helpitem = 'Docs_Viewing_Course_Doc';
6306: }
1.392 raeburn 6307: &Apache::lonhtmlcommon::add_breadcrumb({
1.484.2.67 raeburn 6308: href=>"/adm/coursedocs",text=>$breadtext});
1.446 www 6309: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.484.2.19 raeburn 6310: {'add_entries' => $addentries}
6311: )
1.392 raeburn 6312: .&Apache::loncommon::help_open_menu('','',273,'RAT')
6313: .&Apache::lonhtmlcommon::breadcrumbs(
1.484.2.67 raeburn 6314: $breadtitle,
6315: $helpitem)
1.392 raeburn 6316: );
6317: }
1.364 bisitz 6318:
1.329 droeschl 6319: my %allfiles = ();
6320: my %codebase = ();
1.440 raeburn 6321: my ($upload_result,$upload_output,$uploadphase);
1.484.2.67 raeburn 6322: if ($canedit) {
1.484.2.93.2. 0(raebur 6323:3): undef($suppchanges);
1.329 droeschl 6324: if (($env{'form.uploaddoc.filename'}) &&
6325: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440 raeburn 6326: my $context = $1;
6327: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 6328: undef($hadchanges);
1.440 raeburn 6329: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
1.484.2.36 raeburn 6330: \%allfiles,\%codebase,$context,$crstype);
1.484.2.73 raeburn 6331: undef($navmap);
1.329 droeschl 6332: if ($hadchanges) {
6333: &mark_hash_old();
6334: }
1.484.2.93.2. 0(raebur 6335:3): if ($suppchanges) {
6336:3): &Apache::lonnet::update_supp_caches($coursedom,$coursenum);
6337:3): undef($suppchanges);
6338:3): }
1.440 raeburn 6339: $r->print($upload_output);
6340: } elsif ($env{'form.phase'} eq 'upload_embedded') {
6341: # Process file upload - phase two - upload embedded objects
6342: $uploadphase = 'check_embedded';
6343: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
6344: my $state = &embedded_form_elems($uploadphase,$primaryurl,
6345: $env{'form.newidx'});
6346: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
6347: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
6348: my ($destination,$dir_root) = &embedded_destination();
6349: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
6350: my $actionurl = '/adm/coursedocs';
6351: my ($result,$flag) =
6352: &Apache::loncommon::upload_embedded('coursedoc',$destination,
6353: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
6354: $actionurl);
6355: $r->print($result.&return_to_editor());
6356: } elsif ($env{'form.phase'} eq 'check_embedded') {
6357: # Process file upload - phase three - modify references in HTML file
6358: $uploadphase = 'modified_orightml';
6359: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
6360: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
6361: my ($destination,$dir_root) = &embedded_destination();
1.482 raeburn 6362: my $result =
6363: &Apache::loncommon::modify_html_refs('coursedoc',$destination,
6364: $docuname,$docudom,undef,
6365: $dir_root);
6366: $r->print($result.&return_to_editor());
1.476 raeburn 6367: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
6368: $uploadphase = 'decompress_phase_one';
6369: $r->print(&decompression_phase_one().
6370: &return_to_editor());
6371: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
6372: $uploadphase = 'decompress_phase_two';
6373: $r->print(&decompression_phase_two().
6374: &return_to_editor());
1.329 droeschl 6375: }
6376: }
6377:
1.484 raeburn 6378: if ($allowed && $toolsflag) {
6379: $r->print(&startContentScreen('tools'));
1.484.2.67 raeburn 6380: $r->print(&generate_admin_menu($crstype,$canedit));
1.484 raeburn 6381: $r->print(&endContentScreen());
6382: } elsif ((!$showdoc) && (!$uploadphase)) {
1.329 droeschl 6383: # -----------------------------------------------------------------------------
6384: my %lt=&Apache::lonlocal::texthash(
6385: 'copm' => 'All documents out of a published map into this folder',
1.484.2.12 raeburn 6386: 'upfi' => 'Upload File',
1.484.2.36 raeburn 6387: 'upld' => 'Upload Content',
1.329 droeschl 6388: 'srch' => 'Search',
6389: 'impo' => 'Import',
1.484.2.19 raeburn 6390: 'lnks' => 'Import from Stored Links',
1.484.2.13 raeburn 6391: 'impm' => 'Import from Assembled Map',
1.484.2.93.2. (raeburn 6392:): 'extr' => 'External Resource',
6393:): 'extt' => 'External Tool',
1.329 droeschl 6394: 'selm' => 'Select Map',
6395: 'load' => 'Load Map',
6396: 'newf' => 'New Folder',
6397: 'newp' => 'New Composite Page',
6398: 'syll' => 'Syllabus',
1.425 raeburn 6399: 'navc' => 'Table of Contents',
1.343 biermanm 6400: 'sipa' => 'Simple Course Page',
1.329 droeschl 6401: 'sipr' => 'Simple Problem',
1.484.2.27 raeburn 6402: 'webp' => 'Blank Web Page (editable)',
1.329 droeschl 6403: 'drbx' => 'Drop Box',
1.451 www 6404: 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336 schafran 6405: 'bull' => 'Discussion Board',
1.347 weissno 6406: 'mypi' => 'My Personal Information Page',
1.353 weissno 6407: 'grpo' => 'Group Portfolio',
1.329 droeschl 6408: 'rost' => 'Course Roster',
1.484.2.22 raeburn 6409: 'abou' => 'Personal Information Page for a User',
1.484.2.36 raeburn 6410: 'imsf' => 'IMS Upload',
6411: 'imsl' => 'Upload IMS package',
1.484.2.12 raeburn 6412: 'cms' => 'Origin of IMS package',
6413: 'se' => 'Select',
1.484.2.19 raeburn 6414: 'file' => 'File',
1.329 droeschl 6415: 'title' => 'Title',
6416: 'comment' => 'Comment',
1.403 raeburn 6417: 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.484.2.50 raeburn 6418: 'bb5' => 'Blackboard 5',
6419: 'bb6' => 'Blackboard 6',
6420: 'angel5' => 'ANGEL 5.5',
6421: 'webctce4' => 'WebCT 4 Campus Edition',
1.484.2.67 raeburn 6422: 'er' => 'Editing rights unavailable for your current role.',
1.484.2.50 raeburn 6423: );
1.329 droeschl 6424: # -----------------------------------------------------------------------------
1.484.2.82 raeburn 6425: # Calculate free quota space for a user or course. A javascript function checks
6426: # file size to determine if upload should be allowed.
1.484.2.64 raeburn 6427: my $quotatype = 'unofficial';
6428: if ($crstype eq 'Community') {
6429: $quotatype = 'community';
6430: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
6431: $quotatype = 'official';
6432: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
6433: $quotatype = 'textbook';
6434: }
6435: my $disk_quota = &Apache::loncommon::get_user_quota($coursenum,$coursedom,
6436: 'course',$quotatype); # expressed in MB
6437: my $current_disk_usage = 0;
6438: foreach my $subdir ('docs','supplemental') {
6439: $current_disk_usage += &Apache::lonnet::diskusage($coursedom,$coursenum,
6440: "userfiles/$subdir",1); # expressed in kB
6441: }
6442: my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage);
6443: my $usage = $current_disk_usage/1024; # in MB
6444: my $quota = $disk_quota;
6445: my $percent;
6446: if ($disk_quota == 0) {
6447: $percent = 100.0;
6448: } else {
1.484.2.69 raeburn 6449: $percent = 100*($usage/$disk_quota);
1.484.2.64 raeburn 6450: }
6451: $usage = sprintf("%.2f",$usage);
6452: $quota = sprintf("%.2f",$quota);
6453: $percent = sprintf("%.0f",$percent);
6454: my $quotainfo = '<p>'.&mt('Currently using [_1] of the [_2] available.',
6455: $percent.'%',$quota.' MB').'</p>';
6456:
1.329 droeschl 6457: my $fileupload=(<<FIUP);
1.484.2.64 raeburn 6458: $quotainfo
1.329 droeschl 6459: $lt{'file'}:<br />
6460: FIUP
6461: my $checkbox=(<<CHBO);
6462: <!-- <label>$lt{'parse'}?
6463: <input type="checkbox" name="parserflag" />
6464: </label> -->
6465: <label>
1.484.2.67 raeburn 6466: <input type="checkbox" name="parserflag" checked="checked" $disabled /> $lt{'parse'}
1.329 droeschl 6467: </label>
6468: CHBO
1.484.2.12 raeburn 6469: my $imsfolder = $env{'form.folder'};
6470: if ($imsfolder eq '') {
1.484.2.19 raeburn 6471: $imsfolder = 'default';
1.484.2.12 raeburn 6472: }
6473: my $imspform=(<<IMSFORM);
6474: <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
6475: $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
6476: <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
1.484.2.19 raeburn 6477: <fieldset id="uploadimsform" style="display: none;">
1.484.2.12 raeburn 6478: <legend>$lt{'imsf'}</legend>
6479: $fileupload
1.484.2.93.2. 3(raebur 6480:3): <input type="file" name="uploaddoc" id="uploaddocims" class="LC_flUpload LC_uploaddoc" size="40" $disabled />
6481:3): <input type="hidden" id="LC_free_space_ims" value="$free_space" />
1.484.2.12 raeburn 6482: <br />
6483: <p>
1.484.2.19 raeburn 6484: $lt{'cms'}:
1.484.2.67 raeburn 6485: <select name="source" $disabled>
1.484.2.12 raeburn 6486: <option value="-1" selected="selected">$lt{'se'}</option>
1.484.2.50 raeburn 6487: <option value="bb5">$lt{'bb5'}</option>
6488: <option value="bb6">$lt{'bb6'}</option>
6489: <option value="angel5">$lt{'angel5'}</option>
6490: <option value="webctce4">$lt{'webctce4'}</option>
1.484.2.12 raeburn 6491: </select>
6492: <input type="hidden" name="folder" value="$imsfolder" />
6493: </p>
6494: <input type="hidden" name="phase" value="one" />
1.484.2.67 raeburn 6495: <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" $disabled />
1.484.2.12 raeburn 6496: </fieldset>
6497: </form>
6498: IMSFORM
6499:
1.484.2.19 raeburn 6500: my $fileuploadform=(<<FUFORM);
1.484.2.12 raeburn 6501: <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
6502: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
6503: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.484.2.19 raeburn 6504: <fieldset id="uploaddocform" style="display: none;">
1.484.2.12 raeburn 6505: <legend>$lt{'upfi'}</legend>
1.371 tempelho 6506: <input type="hidden" name="active" value="aa" />
1.329 droeschl 6507: $fileupload
1.484.2.93.2. 3(raebur 6508:3): <input type="file" name="uploaddoc" class="LC_flUpload" size="40" $disabled />
6509:3): <input type="hidden" id="LC_free_space" value="$free_space" />
1.329 droeschl 6510: <br />
6511: $lt{'title'}:<br />
1.484.2.67 raeburn 6512: <input type="text" size="60" name="comment" $disabled />
1.484.2.17 raeburn 6513: $pathitem
1.329 droeschl 6514: <input type="hidden" name="cmd" value="upload_default" />
6515: <br />
1.458 raeburn 6516: <span class="LC_nobreak" style="float:left">
1.329 droeschl 6517: $checkbox
6518: </span>
1.484.2.12 raeburn 6519: <br clear="all" />
1.484.2.67 raeburn 6520: <input type="submit" value="$lt{'upld'}" $disabled />
1.484.2.12 raeburn 6521: </fieldset>
6522: </form>
1.383 tempelho 6523: FUFORM
1.329 droeschl 6524:
1.484.2.67 raeburn 6525: my $mapimportjs;
6526: if ($canedit) {
6527: $mapimportjs = "javascript:openbrowser('mapimportform','importmap','sequence,page','');";
6528: } else {
6529: $mapimportjs = "javascript:alert('".&js_escape($lt{'er'})."');";
6530: }
1.484.2.19 raeburn 6531: my $importpubform=(<<SEDFFORM);
6532: <a class="LC_menubuttons_link" href="javascript:toggleMap('map');">
1.484.2.13 raeburn 6533: $lt{'impm'}</a>$help{'Load_Map'}
1.484.2.19 raeburn 6534: <form action="/adm/coursedocs" method="post" name="mapimportform">
6535: <fieldset id="importmapform" style="display: none;">
1.484.2.13 raeburn 6536: <legend>$lt{'impm'}</legend>
1.484.2.19 raeburn 6537: <input type="hidden" name="active" value="bb" />
1.484.2.13 raeburn 6538: $lt{'copm'}<br />
6539: <span class="LC_nobreak">
1.484.2.19 raeburn 6540: <input type="text" name="importmap" size="40" value=""
1.484.2.67 raeburn 6541: onfocus="this.blur();$mapimportjs" $disabled />
6542: <a href="$mapimportjs">$lt{'selm'}</a></span><br />
6543: <input type="submit" name="loadmap" value="$lt{'load'}" $disabled />
1.484.2.13 raeburn 6544: </fieldset>
6545: </form>
6546:
1.383 tempelho 6547: SEDFFORM
1.484.2.67 raeburn 6548:
6549: my $fromstoredjs;
6550: if ($canedit) {
6551: $fromstoredjs = 'open_StoredLinks_Import()';
6552: } else {
6553: $fromstoredjs = "alert('".&js_escape($lt{'er'})."')";
6554: }
6555:
1.484.2.19 raeburn 6556: my @importpubforma = (
6557: { '<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 6558: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{impo}.'" onclick="javascript:groupimport();"/>' => "<a class='LC_menubuttons_link' href='javascript:groupimport();'>$lt{'impo'}</a>$help{'Importing_LON-CAPA_Resource'}" },
1.484.2.67 raeburn 6559: { '<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.484.2.19 raeburn 6560: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform }
6561: );
6562: $importpubform = &create_form_ul(&create_list_elements(@importpubforma));
6563: my $extresourcesform =
6564: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
1.484.2.67 raeburn 6565: $help{'Adding_External_Resource'},
1.484.2.93.2. (raeburn 6566:): undef,undef,undef,undef,undef,undef,$disabled);
6567:): my $exttoolform =
6568:): &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
6569:): $help{'Adding_External_Tool'},undef,
6570:): undef,'tool',$coursedom,$coursenum,
6571:): \%ltitools,$disabled);
1.329 droeschl 6572: if ($allowed) {
1.484.2.7 raeburn 6573: my $folder = $env{'form.folder'};
6574: if ($folder eq '') {
6575: $folder='default';
6576: }
1.484.2.67 raeburn 6577: if ($canedit) {
6578: my $output = &update_paste_buffer($coursenum,$coursedom,$folder);
6579: if ($output) {
6580: $r->print($output);
6581: }
1.484.2.30 raeburn 6582: }
1.337 ehlerst 6583: $r->print(<<HIDDENFORM);
6584: <form name="renameform" method="post" action="/adm/coursedocs">
6585: <input type="hidden" name="title" />
6586: <input type="hidden" name="cmd" />
6587: <input type="hidden" name="markcopy" />
6588: <input type="hidden" name="copyfolder" />
6589: $containertag
6590: </form>
1.484 raeburn 6591:
1.337 ehlerst 6592: HIDDENFORM
1.484.2.17 raeburn 6593: $r->print(&makesimpleeditform($pathitem)."\n".
6594: &makedocslogform($pathitem."\n".
1.484 raeburn 6595: '<input type="hidden" name="folder" value="'.
6596: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 6597: }
1.442 www 6598:
6599: # Generate the tabs
1.484.2.19 raeburn 6600: my ($mode,$needs_end);
1.472 raeburn 6601: if (($supplementalflag) && (!$allowed)) {
1.484.2.19 raeburn 6602: my @folders = split('&',$env{'form.folderpath'});
6603: unless (@folders > 2) {
6604: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
6605: $needs_end = 1;
6606: }
1.472 raeburn 6607: } else {
1.484 raeburn 6608: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484.2.19 raeburn 6609: $needs_end = 1;
1.472 raeburn 6610: }
1.443 www 6611:
1.442 www 6612: #
6613:
6614: my $savefolderpath;
1.484.2.86 raeburn 6615: my $hostname = $r->hostname();
1.442 www 6616:
1.395 raeburn 6617: if ($allowed) {
1.329 droeschl 6618: my $folder=$env{'form.folder'};
1.484.2.67 raeburn 6619: if ((($folder eq '') && (!$hiddentop)) || ($supplementalflag)) {
1.329 droeschl 6620: $folder='default';
1.356 tempelho 6621: $savefolderpath = $env{'form.folderpath'};
1.484.2.33 raeburn 6622: $env{'form.folderpath'}='default&'.&escape(&mt('Main Content'));
1.484.2.17 raeburn 6623: $pathitem = '<input type="hidden" name="folderpath" value="'.
1.329 droeschl 6624: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
6625: }
6626: my $postexec='';
6627: if ($folder eq 'default') {
1.484.2.93.2. 2(raebur 6628:3): my $windowname = 'loncapaclient';
6629:3): if ($env{'request.lti.login'}) {
6630:3): $windowname .= 'lti';
6631:3): }
1.372 bisitz 6632: $r->print('<script type="text/javascript">'."\n"
6633: .'// <![CDATA['."\n"
1.484.2.93.2. 2(raebur 6634:3): .'this.window.name="$windowname";'."\n"
1.372 bisitz 6635: .'// ]]>'."\n"
6636: .'</script>'."\n"
1.369 bisitz 6637: );
1.329 droeschl 6638: } else {
6639: #$postexec='self.close();';
6640: }
1.484.2.15 raeburn 6641: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
6642: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
1.329 droeschl 6643: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
6644:
6645: my $newnavform=(<<NNFORM);
6646: <form action="/adm/coursedocs" method="post" name="newnav">
1.484.2.43 raeburn 6647: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 6648: $pathitem
1.329 droeschl 6649: <input type="hidden" name="importdetail"
6650: value="$lt{'navc'}=/adm/navmaps" />
1.484.2.67 raeburn 6651: <a class="LC_menubuttons_link" href="javascript:makenew(document.newnav);">$lt{'navc'}</a>
1.329 droeschl 6652: $help{'Navigate_Content'}
6653: </form>
6654: NNFORM
6655: my $newsmppageform=(<<NSPFORM);
6656: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.484.2.43 raeburn 6657: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 6658: $pathitem
1.329 droeschl 6659: <input type="hidden" name="importdetail" value="" />
1.423 onken 6660: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 6661: $help{'Simple Page'}
1.329 droeschl 6662: </form>
6663: NSPFORM
6664:
6665: my $newsmpproblemform=(<<NSPROBFORM);
6666: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371 tempelho 6667: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 6668: $pathitem
1.329 droeschl 6669: <input type="hidden" name="importdetail" value="" />
1.423 onken 6670: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.484.2.44 raeburn 6671: $help{'Simple_Problem'}
1.329 droeschl 6672: </form>
6673:
6674: NSPROBFORM
6675:
6676: my $newdropboxform=(<<NDBFORM);
6677: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.371 tempelho 6678: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 6679: $pathitem
1.329 droeschl 6680: <input type="hidden" name="importdetail" value="" />
1.423 onken 6681: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.484.2.36 raeburn 6682: $help{'Dropbox'}
1.344 bisitz 6683: </form>
1.329 droeschl 6684: NDBFORM
6685:
6686: my $newexuploadform=(<<NEXUFORM);
6687: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.371 tempelho 6688: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 6689: $pathitem
1.329 droeschl 6690: <input type="hidden" name="importdetail" value="" />
1.423 onken 6691: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 6692: $help{'Score_Upload_Form'}
6693: </form>
6694: NEXUFORM
6695:
6696: my $newbulform=(<<NBFORM);
6697: <form action="/adm/coursedocs" method="post" name="newbul">
1.484.2.43 raeburn 6698: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 6699: $pathitem
1.329 droeschl 6700: <input type="hidden" name="importdetail" value="" />
1.423 onken 6701: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 6702: $help{'Bulletin Board'}
6703: </form>
6704: NBFORM
6705:
6706: my $newaboutmeform=(<<NAMFORM);
6707: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.484.2.43 raeburn 6708: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 6709: $pathitem
1.329 droeschl 6710: <input type="hidden" name="importdetail"
6711: value="$plainname=/adm/$udom/$uname/aboutme" />
1.484.2.67 raeburn 6712: <a class="LC_menubuttons_link" href="javascript:makenew(document.newaboutme);">$lt{'mypi'}</a>
1.347 weissno 6713: $help{'My Personal Information Page'}
1.329 droeschl 6714: </form>
6715: NAMFORM
6716:
6717: my $newaboutsomeoneform=(<<NASOFORM);
6718: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.484.2.43 raeburn 6719: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 6720: $pathitem
1.329 droeschl 6721: <input type="hidden" name="importdetail" value="" />
1.423 onken 6722: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 6723: </form>
6724: NASOFORM
6725:
6726: my $newrosterform=(<<NROSTFORM);
6727: <form action="/adm/coursedocs" method="post" name="newroster">
1.484.2.43 raeburn 6728: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 6729: $pathitem
1.329 droeschl 6730: <input type="hidden" name="importdetail"
6731: value="$lt{'rost'}=/adm/viewclasslist" />
1.484.2.67 raeburn 6732: <a class="LC_menubuttons_link" href="javascript:makenew(document.newroster);">$lt{'rost'}</a>
1.484.2.37 raeburn 6733: $help{'Course_Roster'}
1.329 droeschl 6734: </form>
6735: NROSTFORM
6736:
1.484.2.27 raeburn 6737: my $newwebpage;
6738: if ($folder =~ /^default_?(\d*)$/) {
6739: $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
6740: if ($1) {
6741: $newwebpage .= $1;
6742: } else {
6743: $newwebpage .= 'default';
6744: }
6745: $newwebpage .= '/new.html';
6746: }
6747: my $newwebpageform =(<<NWEBFORM);
6748: <form action="/adm/coursedocs" method="post" name="newwebpage">
1.484.2.43 raeburn 6749: <input type="hidden" name="active" value="ee" />
1.484.2.27 raeburn 6750: $pathitem
6751: <input type="hidden" name="importdetail" value="$newwebpage" />
6752: <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
1.484.2.36 raeburn 6753: $help{'Web_Page'}
1.484.2.27 raeburn 6754: </form>
6755: NWEBFORM
1.484.2.30 raeburn 6756:
1.484.2.27 raeburn 6757:
1.342 ehlerst 6758: my $specialdocumentsform;
1.383 tempelho 6759: my @specialdocumentsforma;
1.451 www 6760: my $gradingform;
6761: my @gradingforma;
6762: my $communityform;
6763: my @communityforma;
1.351 ehlerst 6764: my $newfolderform;
1.390 tempelho 6765: my $newfolderb;
1.342 ehlerst 6766:
1.451 www 6767: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 6768:
1.329 droeschl 6769: my $newpageform=(<<NPFORM);
6770: <form action="/adm/coursedocs" method="post" name="newpage">
6771: <input type="hidden" name="folderpath" value="$path" />
6772: <input type="hidden" name="importdetail" value="" />
1.484.2.43 raeburn 6773: <input type="hidden" name="active" value="ee" />
1.423 onken 6774: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 6775: $help{'Adding_Pages'}
1.329 droeschl 6776: </form>
6777: NPFORM
1.390 tempelho 6778:
6779:
1.351 ehlerst 6780: $newfolderform=(<<NFFORM);
1.329 droeschl 6781: <form action="/adm/coursedocs" method="post" name="newfolder">
1.484.2.19 raeburn 6782: $pathitem
1.329 droeschl 6783: <input type="hidden" name="importdetail" value="" />
1.484.2.43 raeburn 6784: <input type="hidden" name="active" value="" />
1.422 onken 6785: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 6786: </form>
6787: NFFORM
6788:
6789: my $newsylform=(<<NSYLFORM);
6790: <form action="/adm/coursedocs" method="post" name="newsyl">
1.484.2.43 raeburn 6791: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 6792: $pathitem
1.329 droeschl 6793: <input type="hidden" name="importdetail"
6794: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.484.2.67 raeburn 6795: <a class="LC_menubuttons_link" href="javascript:makenew(document.newsyl);">$lt{'syll'}</a>
1.329 droeschl 6796: $help{'Syllabus'}
1.383 tempelho 6797:
1.329 droeschl 6798: </form>
6799: NSYLFORM
1.364 bisitz 6800:
1.329 droeschl 6801: my $newgroupfileform=(<<NGFFORM);
6802: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.484.2.43 raeburn 6803: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 6804: $pathitem
1.329 droeschl 6805: <input type="hidden" name="importdetail"
6806: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.484.2.67 raeburn 6807: <a class="LC_menubuttons_link" href="javascript:makenew(document.newgroupfiles);">$lt{'grpo'}</a>
1.353 weissno 6808: $help{'Group Portfolio'}
1.329 droeschl 6809: </form>
6810: NGFFORM
1.484.2.89 raeburn 6811: if ($container eq 'page') {
6812: @specialdocumentsforma=(
6813: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
6814: );
6815: } else {
6816: @specialdocumentsforma=(
1.421 onken 6817: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/page.png" alt="'.$lt{newp}.'" onclick="javascript:makenewpage(document.newpage,\''.$pageseq.'\');" />'=>$newpageform},
1.484.2.67 raeburn 6818: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.newsyl);" />'=>$newsylform},
6819: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="javascript:makenew(document.newnav);" />'=>$newnavform},
1.451 www 6820: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
1.484.2.27 raeburn 6821: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
1.484.2.89 raeburn 6822: );
6823: }
1.451 www 6824: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
6825:
1.434 raeburn 6826:
6827: my @importdoc = (
1.484.2.19 raeburn 6828: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform}
6829: );
1.484.2.93.2. 2(raebur 6830:3): if ($posslti) {
(raeburn 6831:): push(@importdoc,
6832:): {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="toggleUpload(\'tool\');" />'=>$exttoolform},
6833:): );
6834:): }
1.484.2.19 raeburn 6835: unless ($container eq 'page') {
6836: push(@importdoc,
6837: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform}
6838: );
6839: }
6840: push(@importdoc,
1.484.2.38 raeburn 6841: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'doc\');" />'=>$fileuploadform}
1.484.2.19 raeburn 6842: );
1.484.2.12 raeburn 6843: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
1.434 raeburn 6844:
1.451 www 6845: @gradingforma=(
6846: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
6847: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
6848: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
6849:
6850: );
6851: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
6852:
6853: @communityforma=(
6854: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
6855: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
6856: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
1.484.2.67 raeburn 6857: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="javascript:makenew(document.newroster);" />'=>$newrosterform},
6858: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="javascript:makenew(document.newgroupfiles);" />'=>$newgroupfileform},
1.451 www 6859: );
6860: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 6861:
1.330 tempelho 6862: my %orderhash = (
1.484.2.36 raeburn 6863: 'aa' => ['Upload',$fileuploadform],
6864: 'bb' => ['Import',$importpubform],
6865: 'cc' => ['Grading',$gradingform],
1.484.2.89 raeburn 6866: 'ee' => ['Other',$specialdocumentsform],
1.330 tempelho 6867: );
1.484.2.19 raeburn 6868: unless ($container eq 'page') {
1.434 raeburn 6869: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.484 raeburn 6870: $orderhash{'dd'} = ['Collaboration',$communityform];
1.434 raeburn 6871: }
6872:
1.341 ehlerst 6873: $hadchanges=0;
1.484 raeburn 6874: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 6875: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.67 raeburn 6876: $supplementalflag,\%orderhash,$iconpath,$pathitem,
1.484.2.93.2. (raeburn 6877:): \%ltitools,$canedit,$hostname,\$navmap,$hiddentop);
1.484.2.67 raeburn 6878: undef($navmap);
1.443 www 6879: if ($error) {
6880: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
6881: }
6882: if ($hadchanges) {
1.484.2.73 raeburn 6883: unless (&is_hash_old()) {
6884: &mark_hash_old();
6885: }
1.443 www 6886: }
1.341 ehlerst 6887:
1.443 www 6888: &changewarning($r,'');
6889: }
1.458 raeburn 6890: }
1.442 www 6891:
1.443 www 6892: # Supplemental documents start here
6893:
1.329 droeschl 6894: my $folder=$env{'form.folder'};
1.443 www 6895: unless ($supplementalflag) {
1.329 droeschl 6896: $folder='supplemental';
6897: }
1.484.2.93.2. 0(raebur 6898:3): if (($folder eq 'supplemental') &&
1.329 droeschl 6899: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 6900: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 6901: } elsif ($allowed) {
1.356 tempelho 6902: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 6903: }
1.484.2.17 raeburn 6904: $pathitem = '<input type="hidden" name="folderpath" value="'.
6905: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.329 droeschl 6906: if ($allowed) {
6907: my $folderseq=
1.484.2.15 raeburn 6908: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
1.329 droeschl 6909:
6910: my $supupdocform=(<<SUPDOCFORM);
1.484.2.12 raeburn 6911: <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
6912: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
1.383 tempelho 6913: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.484.2.19 raeburn 6914: <fieldset id="uploadsuppdocform" style="display: none;">
1.484.2.12 raeburn 6915: <legend>$lt{'upfi'}</legend>
1.371 tempelho 6916: <input type="hidden" name="active" value="ee" />
1.329 droeschl 6917: $fileupload
1.484.2.93.2. 3(raebur 6918:3): <input type="file" name="uploaddoc" id="uploaddocsupp" class="LC_flUpload LC_uploaddoc" size="40" $disabled />
6919:3): <input type="hidden" id="LC_free_space_supp" value="$free_space" />
1.329 droeschl 6920: <br />
6921: <br />
6922: <span class="LC_nobreak">
6923: $checkbox
6924: </span>
6925: <br /><br />
6926: $lt{'comment'}:<br />
1.383 tempelho 6927: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 6928: <br />
1.484.2.19 raeburn 6929: $pathitem
1.329 droeschl 6930: <input type="hidden" name="cmd" value="upload_supplemental" />
1.484.2.12 raeburn 6931: <input type='submit' value="$lt{'upld'}" />
1.484.2.93.2. 4(raebur 6932:3): </fieldset>
1.484.2.12 raeburn 6933: </form>
1.484.2.19 raeburn 6934: SUPDOCFORM
1.329 droeschl 6935:
6936: my $supnewfolderform=(<<SNFFORM);
6937: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.484.2.43 raeburn 6938: <input type="hidden" name="active" value="" />
1.484.2.17 raeburn 6939: $pathitem
1.329 droeschl 6940: <input type="hidden" name="importdetail" value="" />
1.423 onken 6941: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 6942: $help{'Adding_Folders'}
1.329 droeschl 6943: </form>
6944: SNFFORM
1.383 tempelho 6945:
1.484.2.19 raeburn 6946: my $supextform =
6947: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
1.484.2.67 raeburn 6948: $help{'Adding_External_Resource'},
6949: undef,undef,$disabled);
1.484.2.93.2. (raeburn 6950:): my $supexttoolform =
6951:): &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
6952:): $help{'Adding_External_Tool'},
6953:): undef,undef,'tool',$coursedom,
6954:): $coursenum,\%ltitools,$disabled);
1.329 droeschl 6955:
6956: my $supnewsylform=(<<SNSFORM);
6957: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 6958: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 6959: $pathitem
1.329 droeschl 6960: <input type="hidden" name="importdetail"
6961: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.484.2.67 raeburn 6962: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewsyl);">$lt{'syll'}</a>
1.329 droeschl 6963: $help{'Syllabus'}
6964: </form>
6965: SNSFORM
6966:
6967: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 6968: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 6969: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 6970: $pathitem
1.329 droeschl 6971: <input type="hidden" name="importdetail"
6972: value="$plainname=/adm/$udom/$uname/aboutme" />
1.484.2.67 raeburn 6973: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewaboutme);">$lt{'mypi'}</a>
1.347 weissno 6974: $help{'My Personal Information Page'}
1.329 droeschl 6975: </form>
6976: SNAMFORM
6977:
1.484.2.27 raeburn 6978: my $supwebpage;
6979: if ($folder =~ /^supplemental_?(\d*)$/) {
6980: $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
6981: if ($1) {
6982: $supwebpage .= $1;
6983: } else {
6984: $supwebpage .= 'default';
6985: }
6986: $supwebpage .= '/new.html';
6987: }
6988: my $supwebpageform =(<<SWEBFORM);
6989: <form action="/adm/coursedocs" method="post" name="supwebpage">
6990: <input type="hidden" name="active" value="cc" />
6991: $pathitem
6992: <input type="hidden" name="importdetail" value="$supwebpage" />
6993: <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
1.484.2.36 raeburn 6994: $help{'Web_Page'}
1.484.2.27 raeburn 6995: </form>
6996: SWEBFORM
6997:
1.333 muellerd 6998:
1.383 tempelho 6999: my @specialdocs = (
1.484.2.67 raeburn 7000: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.supnewsyl);" />'
1.417 droeschl 7001: =>$supnewsylform},
1.484.2.67 raeburn 7002: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makenew(document.supnewaboutme);" />'
1.417 droeschl 7003: =>$supnewaboutmeform},
1.484.2.27 raeburn 7004: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
7005:
1.383 tempelho 7006: );
1.417 droeschl 7007: my @supimportdoc = (
1.484.2.19 raeburn 7008: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleUpload(\'suppext\')" />'
1.484.2.93.2. (raeburn 7009:): =>$supextform});
7010:): if (keys(%ltitools)) {
7011:): push(@supimportdoc,
7012:): {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="javascript:toggleUpload(\'supptool\')" />'
7013:): =>$supexttoolform});
7014:): }
7015:): push(@supimportdoc,
1.484.2.12 raeburn 7016: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
7017: =>$supupdocform},
1.484.2.93.2. (raeburn 7018:): );
1.484.2.19 raeburn 7019:
1.484.2.12 raeburn 7020: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
1.333 muellerd 7021: my %suporderhash = (
1.390 tempelho 7022: '00' => ['Supnewfolder', $supnewfolderform],
1.484.2.36 raeburn 7023: 'ee' => ['Upload',$supupdocform],
7024: 'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 7025: );
1.443 www 7026: if ($supplementalflag) {
1.484.2.93.2. 0(raebur 7027:3): $suppchanges = 0;
7028:3): my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
7029:3): $supplementalflag,\%suporderhash,$iconpath,$pathitem,
7030:3): \%ltitools,$canedit,$hostname);
7031:3): if ($error) {
7032:3): $r->print('<p><span class="LC_error">'.$error.'</span></p>');
7033:3): }
7034:3): if ($suppchanges) {
7035:3): &Apache::lonnet::update_supp_caches($coursedom,$coursenum);
7036:3): undef($suppchanges);
7037:3): }
1.393 raeburn 7038: }
1.443 www 7039: } elsif ($supplementalflag) {
1.458 raeburn 7040: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.93.2. (raeburn 7041:): $supplementalflag,'',$iconpath,$pathitem,'',$canedit,
7042:): $hostname);
1.393 raeburn 7043: if ($error) {
7044: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 7045: }
1.393 raeburn 7046: }
1.389 tempelho 7047:
1.484.2.19 raeburn 7048: if ($needs_end) {
7049: $r->print(&endContentScreen());
7050: }
1.383 tempelho 7051:
1.329 droeschl 7052: if ($allowed) {
7053: $r->print('
7054: <form method="post" name="extimport" action="/adm/coursedocs">
7055: <input type="hidden" name="title" />
7056: <input type="hidden" name="url" />
7057: <input type="hidden" name="useform" />
7058: <input type="hidden" name="residx" />
7059: </form>');
7060: }
1.484 raeburn 7061: } elsif ($showdoc) {
1.329 droeschl 7062: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 7063: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.484.2.10 raeburn 7064: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 7065: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 7066: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 7067: }
7068: }
7069: $r->print(&Apache::loncommon::end_page());
7070: return OK;
1.364 bisitz 7071: }
1.329 droeschl 7072:
1.440 raeburn 7073: sub embedded_form_elems {
7074: my ($phase,$primaryurl,$newidx) = @_;
7075: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.484.2.78 raeburn 7076: $newidx =~s /\D+//g;
1.440 raeburn 7077: return <<STATE;
7078: <input type="hidden" name="folderpath" value="$folderpath" />
7079: <input type="hidden" name="cmd" value="upload_embedded" />
7080: <input type="hidden" name="newidx" value="$newidx" />
7081: <input type="hidden" name="phase" value="$phase" />
7082: <input type="hidden" name="primaryurl" value="$primaryurl" />
7083: STATE
7084: }
7085:
7086: sub embedded_destination {
7087: my $folder=$env{'form.folder'};
7088: my $destination = 'docs/';
7089: if ($folder =~ /^supplemental/) {
7090: $destination = 'supplemental/';
7091: }
7092: if (($folder eq 'default') || ($folder eq 'supplemental')) {
7093: $destination .= 'default/';
7094: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
7095: $destination .= $2.'/';
7096: }
1.484.2.78 raeburn 7097: my $newidx = $env{'form.newidx'};
7098: $newidx =~s /\D+//g;
7099: if ($newidx) {
7100: $destination .= $newidx;
7101: }
1.440 raeburn 7102: my $dir_root = '/userfiles';
7103: return ($destination,$dir_root);
7104: }
7105:
7106: sub return_to_editor {
7107: my $actionurl = '/adm/coursedocs';
7108: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
7109: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
7110: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
7111: '</a></p>';
7112: }
7113:
1.476 raeburn 7114: sub decompression_info {
7115: my ($destination,$dir_root) = &embedded_destination();
7116: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
7117: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
7118: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
7119: my $container='sequence';
1.480 raeburn 7120: my ($pathitem,$hiddenelem);
1.484.2.54 raeburn 7121: my @hiddens = ('newidx','comment','position','folderpath','archiveurl');
1.484.2.19 raeburn 7122: if ($env{'form.folderpath'} =~ /\:1$/) {
1.476 raeburn 7123: $container='page';
7124: }
1.480 raeburn 7125: unshift(@hiddens,$pathitem);
7126: foreach my $item (@hiddens) {
1.484.2.78 raeburn 7127: if ($item eq 'newidx') {
7128: next if ($env{'form.'.$item} =~ /\D/);
7129: }
1.480 raeburn 7130: if ($env{'form.'.$item}) {
7131: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
1.484.2.54 raeburn 7132: &HTML::Entities::encode($env{'form.'.$item},'<>&"').'" />'."\n";
1.480 raeburn 7133: }
1.477 raeburn 7134: }
1.476 raeburn 7135: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
7136: $hiddenelem);
7137: }
7138:
7139: sub decompression_phase_one {
7140: my ($dir,$file,$warning,$error,$output);
7141: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
7142: &decompression_info();
1.484.2.7 raeburn 7143: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 7144: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
7145: } else {
7146: my $file = $1;
1.481 raeburn 7147: $output =
7148: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
7149: $destination,$dir_root,
7150: $hiddenelem);
7151: if ($env{'form.autoextract_camtasia'}) {
7152: $output .= &remove_archive($docudom,$docuname,$container);
7153: }
1.476 raeburn 7154: }
7155: if ($error) {
7156: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
7157: $error.'</p>'."\n";
7158: }
7159: if ($warning) {
7160: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
7161: }
7162: return $output;
7163: }
7164:
7165: sub decompression_phase_two {
7166: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
7167: &decompression_info();
1.481 raeburn 7168: my $output;
1.480 raeburn 7169: if ($env{'form.archivedelete'}) {
1.481 raeburn 7170: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 7171: }
7172: $output .=
1.481 raeburn 7173: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 7174: $destination,$dir_root,$hiddenelem);
7175: return $output;
7176: }
7177:
1.480 raeburn 7178: sub remove_archive {
7179: my ($docudom,$docuname,$container) = @_;
7180: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 7181: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 7182: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
7183: if ($fatal) {
7184: if ($container eq 'page') {
7185: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
7186: } else {
7187: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
7188: }
1.484.2.54 raeburn 7189: $delwarning .= ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 7190: } else {
7191: my $currcmd = $env{'form.cmd'};
7192: my $position = $env{'form.position'};
1.484.2.54 raeburn 7193: my $archiveidx = $position;
7194: if ($position > 0) {
7195: if (($env{'form.autoextract_camtasia'}) && (scalar(@LONCAPA::map::order) == 2)) {
7196: $archiveidx = $position-1;
7197: }
7198: $env{'form.cmd'} = 'remove_'.$archiveidx;
7199: my ($title,$url,@rrest) =
7200: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$archiveidx]]);
7201: if ($url eq $env{'form.archiveurl'}) {
7202: if (&handle_edit_cmd($docuname,$docudom)) {
7203: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
1.484.2.93.2. 0(raebur 7204:3): if ($suppchanges) {
7205:3): &Apache::lonnet::update_supp_caches($docudom,$docuname);
7206:3): undef($suppchanges);
7207:3): }
1.484.2.54 raeburn 7208: if ($fatal) {
7209: if ($container eq 'page') {
7210: $delwarning = &mt('An error occurred updating the contents of the current page.');
7211: } else {
7212: $delwarning = &mt('An error occurred updating the contents of the current folder.');
7213: }
1.480 raeburn 7214: } else {
1.484.2.54 raeburn 7215: $delresult = &mt('Archive file removed.');
1.480 raeburn 7216: }
7217: }
1.484.2.54 raeburn 7218: } else {
7219: $delwarning .= &mt('Archive file had unexpected item number in folder.').
7220: ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 7221: }
7222: }
7223: $env{'form.cmd'} = $currcmd;
7224: }
7225: if ($delwarning) {
7226: $output = '<p class="LC_warning">'.
7227: $delwarning.
7228: '</p>';
7229: }
7230: if ($delresult) {
7231: $output .= '<p class="LC_info">'.
7232: $delresult.
7233: '</p>';
7234: }
1.481 raeburn 7235: return $output;
1.480 raeburn 7236: }
7237:
1.484 raeburn 7238: sub generate_admin_menu {
1.484.2.67 raeburn 7239: my ($crstype,$canedit) = @_;
1.484 raeburn 7240: my $lc_crstype = lc($crstype);
7241: my ($home,$other,%outhash)=&authorhosts();
1.484.2.43 raeburn 7242: my %lt= ( # do not translate here
1.484 raeburn 7243: 'vc' => 'Verify Content',
7244: 'cv' => 'Check/Set Resource Versions',
7245: 'ls' => 'List Resource Identifiers',
1.484.2.93.2. (raeburn 7246:): 'ct' => 'Display/Set Shortened URLs for Deep-linking',
1.484 raeburn 7247: 'imse' => 'Export contents to IMS Archive',
1.484.2.43 raeburn 7248: 'dcd' => "Copy $crstype Content to Authoring Space",
7249: );
1.484 raeburn 7250: my ($candump,$dumpurl);
7251: if ($home + $other > 0) {
7252: $candump = 'F';
7253: if ($home) {
7254: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
7255: } else {
7256: my @hosts;
7257: foreach my $aurole (keys(%outhash)) {
7258: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
7259: push(@hosts,$outhash{$aurole});
1.484.2.30 raeburn 7260: }
1.484 raeburn 7261: }
7262: if (@hosts == 1) {
7263: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
7264: '&role='.
7265: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
7266: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
7267: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
7268: } else {
7269: $dumpurl = "javascript:choose_switchserver_window()";
7270: }
7271: }
7272: }
7273: my @menu=
7274: ({ categorytitle=>'Administration',
7275: items =>[
7276: { linktext => $lt{'vc'},
7277: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
7278: permission => 'F',
1.484.2.44 raeburn 7279: help => 'Docs_Verify_Content',
1.484 raeburn 7280: icon => 'verify.png',
7281: linktitle => 'Verify contents can be retrieved/rendered',
7282: },
7283: { linktext => $lt{'cv'},
7284: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
7285: permission => 'F',
1.484.2.44 raeburn 7286: help => 'Docs_Check_Resource_Versions',
1.484 raeburn 7287: icon => 'resversion.png',
7288: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
7289: },
7290: { linktext => $lt{'ls'},
7291: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
7292: permission => 'F',
7293: #help => '',
7294: icon => 'symbs.png',
7295: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
7296: },
1.484.2.93.2. (raeburn 7297:): { linktext => $lt{'ct'},
7298:): url => "javascript:injectData(document.courseverify,'dummy','shorturls','$lt{'ct'}')",
7299:): permission => 'F',
7300:): help => 'Docs_Short_URLs',
7301:): icon => 'shorturls.png',
7302:): linktitle => "Set shortened URLs for a resource or folder in your $lc_crstype for use in deep-linking"
7303:): },
1.484 raeburn 7304: ]
1.484.2.67 raeburn 7305: });
7306: if ($canedit) {
7307: push(@menu,
1.484 raeburn 7308: { categorytitle=>'Export',
7309: items =>[
7310: { linktext => $lt{'imse'},
7311: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
7312: permission => 'F',
7313: help => 'Docs_Export_Course_Docs',
7314: icon => 'imsexport.png',
7315: linktitle => $lt{'imse'},
7316: },
7317: { linktext => $lt{'dcd'},
7318: url => $dumpurl,
7319: permission => $candump,
1.484.2.44 raeburn 7320: help => 'Docs_Dump_Course_Docs',
1.484 raeburn 7321: icon => 'dump.png',
7322: linktitle => $lt{'dcd'},
7323: },
7324: ]
7325: });
1.484.2.67 raeburn 7326: }
1.484 raeburn 7327: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
7328: '<input type="hidden" id="dummy" />'."\n".
7329: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
7330: '</form>';
1.329 droeschl 7331: }
7332:
7333: sub generate_edit_table {
1.484.2.30 raeburn 7334: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile,
1.484.2.67 raeburn 7335: $need_save,$copyfolder,$canedit) = @_;
1.406 raeburn 7336: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 7337: my %orderhash = %{$orderhash_ref};
1.484.2.67 raeburn 7338: my ($form, $activetab, $active, $disabled);
1.484.2.43 raeburn 7339: if (($env{'form.active'} ne '') && ($env{'form.active'} ne '00')) {
1.371 tempelho 7340: $activetab = $env{'form.active'};
7341: }
1.484.2.67 raeburn 7342: unless ($canedit) {
7343: $disabled = ' disabled="disabled"';
7344: }
1.472 raeburn 7345: my $backicon = $iconpath.'clickhere.gif';
1.484.2.21 raeburn 7346: my $backtext = &mt('Exit Editor');
1.458 raeburn 7347: $form = '<div class="LC_Box" style="margin:0;">'.
1.484.2.19 raeburn 7348: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
7349: '<li class="goback">'.
1.484.2.32 raeburn 7350: '<a href="javascript:toContents('."'$jumpto'".');">'.
1.484.2.19 raeburn 7351: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
7352: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
7353: '<li>'.
7354: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
7355: &mt('Undo Delete').'</a></li>'."\n";
1.484.2.7 raeburn 7356: if ($env{'form.docslog'}) {
7357: $form .= '<li class="active">';
7358: } else {
7359: $form .= '<li>';
7360: }
7361: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
7362: &mt('History').'</a></li>'."\n";
7363: if ($env{'form.docslog'}) {
7364: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
7365: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 7366: }
1.458 raeburn 7367: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 7368: if($name ne '00'){
1.371 tempelho 7369: if($activetab eq '' || $activetab ne $name){
7370: $active = '';
7371: }elsif($activetab eq $name){
7372: $active = 'class="active"';
7373: }
1.458 raeburn 7374: $form .= '<li style="float:right" '.$active
1.484 raeburn 7375: .' 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 7376: } else {
1.484.2.43 raeburn 7377: $form .= '<li style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 7378:
7379: }
1.329 droeschl 7380: }
1.484 raeburn 7381: $form .= '</ul>'."\n";
7382: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 7383:
7384: if ($to_show ne '') {
1.484.2.30 raeburn 7385: my $saveform;
7386: if ($need_save) {
7387: my $button = &mt('Make changes');
7388: my $path;
7389: if ($env{'form.folderpath'}) {
7390: $path =
7391: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
7392: }
7393: $saveform = <<"END";
7394: <div id="multisave" style="display:none; clear:both;" >
7395: <form name="saveactions" method="post" action="/adm/coursedocs" onsubmit="return checkSubmits();">
7396: <input type="hidden" name="folderpath" value="$path" />
7397: <input type="hidden" name="symb" value="$env{'form.symb'}" />
7398: <input type="hidden" name="allhiddenresource" value="" />
7399: <input type="hidden" name="allencrypturl" value="" />
7400: <input type="hidden" name="allrandompick" value="" />
7401: <input type="hidden" name="allrandomorder" value="" />
7402: <input type="hidden" name="changeparms" value="" />
7403: <input type="hidden" name="multiremove" value="" />
7404: <input type="hidden" name="multicut" value="" />
7405: <input type="hidden" name="multicopy" value="" />
7406: <input type="hidden" name="multichange" value="" />
7407: <input type="hidden" name="copyfolder" value="$copyfolder" />
1.484.2.67 raeburn 7408: <input type="submit" name="savemultiples" value="$button" $disabled />
1.484.2.30 raeburn 7409: </form>
7410: </div>
7411: END
7412: }
7413: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'.$saveform."\n";
1.458 raeburn 7414: }
1.363 ehlerst 7415: foreach my $field (keys(%orderhash)){
1.390 tempelho 7416: if($field ne '00'){
1.422 onken 7417: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 7418: $active = 'style="display: none;float:left"';
1.422 onken 7419: }elsif($activetab eq $field){
1.458 raeburn 7420: $active = 'style="display:block;float:left"';
1.422 onken 7421: }
7422: $form .= '<div id="'.$field.$tid.'"'
7423: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 7424: .'</div>'."\n";
1.363 ehlerst 7425: }
7426: }
1.484 raeburn 7427: unless ($env{'form.docslog'}) {
7428: $form .= '</div></div>'."\n";
7429: }
1.329 droeschl 7430: return $form;
7431: }
7432:
7433: sub editing_js {
1.484.2.93.2. (raeburn 7434:): my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
1.484.2.80 raeburn 7435: $canedit,$hostname,$navmapref) = @_;
1.484.2.61 raeburn 7436: my %js_lt = &Apache::lonlocal::texthash(
1.329 droeschl 7437: p_mnf => 'Name of New Folder',
7438: t_mnf => 'New Folder',
7439: p_mnp => 'Name of New Page',
7440: t_mnp => 'New Page',
1.451 www 7441: p_mxu => 'Title for the External Score',
1.349 biermanm 7442: p_msp => 'Name of Simple Course Page',
1.329 droeschl 7443: p_msb => 'Title for the Problem',
7444: p_mdb => 'Title for the Drop Box',
1.336 schafran 7445: p_mbb => 'Title for the Discussion Board',
1.484.2.27 raeburn 7446: p_mwp => 'Title for Web Page',
1.348 weissno 7447: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 7448: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 7449: p_mab_alrt1 => 'Not a valid user:domain',
7450: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
7451: p_chn => 'New Title',
7452: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
1.484.2.63 raeburn 7453: p_rmr2a => 'Remove',
7454: p_rmr2b => '?',
7455: p_rmr3a => 'Remove those',
7456: p_rmr3b => 'items?',
7457: p_rmr4 => 'WARNING: Removing a resource uploaded to a course cannot be undone via "Undo Delete".',
7458: p_rmr5 => 'Push "Cancel" and then use "Cut" instead if you might need to undo this change.',
1.329 droeschl 7459: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
7460: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
1.484.2.63 raeburn 7461: p_ctr2a => 'Cut',
7462: p_ctr2b => '?',
7463: p_ctr3a => 'Cut those',
7464: p_ctr3b => 'items?',
1.478 raeburn 7465: rpck => 'Enter number to pick (e.g., 3)',
1.484.2.12 raeburn 7466: imsfile => 'You must choose an IMS package for import',
7467: imscms => 'You must select which Course Management System was the source of the IMS package',
7468: invurl => 'Invalid URL',
7469: titbl => 'Title is blank',
1.484.2.30 raeburn 7470: more => '(More ...)',
7471: less => '(Less ...)',
7472: noor => 'No actions selected or changes to settings specified.',
7473: noch => 'No changes to settings specified.',
7474: noac => 'No actions selected.',
1.484.2.67 raeburn 7475: edri => 'Editing rights unavailable for your current role.',
1.329 droeschl 7476: );
7477:
1.484.2.61 raeburn 7478: &js_escape(\%js_lt);
1.433 raeburn 7479: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 7480: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
7481: my $main_container_page;
1.484.2.19 raeburn 7482: if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) {
7483: $main_container_page = 1;
1.434 raeburn 7484: }
1.484.2.67 raeburn 7485: my $backtourl;
7486: my $toplevelmain = &escape(&default_folderpath($coursenum,$coursedom,$navmapref));
1.446 www 7487: my $toplevelsupp = &supplemental_base();
1.433 raeburn 7488:
1.484.2.21 raeburn 7489: if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
7490: my $caller = $1;
7491: if ($caller =~ /^supplemental/) {
7492: $backtourl = '/adm/supplemental?folderpath='.&escape($caller);
7493: } else {
7494: my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
7495: $res = &Apache::lonnet::clutter($res);
7496: if (&Apache::lonnet::is_on_map($res)) {
1.484.2.66 raeburn 7497: my ($url,$anchor);
7498: if ($res =~ /^([^#]+)#([^#]+)$/) {
7499: $url = $1;
7500: $anchor = $2;
7501: if (($caller =~ m{^([^#]+)\Q#$anchor\E$})) {
7502: $caller = $1.&escape('#').$anchor;
7503: }
1.484.2.67 raeburn 7504: } else {
7505: $url = $res;
1.484.2.66 raeburn 7506: }
1.484.2.83 raeburn 7507: $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"');
7508: if ($backtourl =~ m{^\Q/uploaded/$coursedom/$coursenum/\Edefault_\d+\.sequence$}) {
7509: $backtourl .= '?navmap=1';
7510: } else {
7511: $backtourl .= '?symb='.
7512: &HTML::Entities::encode($caller,'<>&"');
7513: }
1.484.2.80 raeburn 7514: if ($backtourl =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
7515: if (($ENV{'SERVER_PORT'} == 443) &&
7516: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
1.484.2.93 raeburn 7517: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.484.2.80 raeburn 7518: if ($hostname ne '') {
7519: $backtourl = 'http://'.$hostname.$backtourl;
7520: }
7521: $backtourl .= (($backtourl =~ /\?/) ? '&':'?').'usehttp=1';
7522: }
7523: }
7524: } elsif ($backtourl =~ m{^/adm/wrapper/ext/(?!https:)}) {
7525: if (($ENV{'SERVER_PORT'} == 443) && ($hostname ne '')) {
1.484.2.93 raeburn 7526: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.484.2.80 raeburn 7527: if ($hostname ne '') {
7528: $backtourl = 'http://'.$hostname.$backtourl;
7529: }
7530: $backtourl .= (($backtourl =~ /\?/) ? '&':'?').'usehttp=1';
7531: }
7532: }
7533: }
1.484.2.66 raeburn 7534: if ($anchor ne '') {
7535: $backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"');
7536: }
1.484.2.57 raeburn 7537: $backtourl = &Apache::loncommon::escape_single($backtourl);
1.484.2.31 raeburn 7538: } else {
7539: $backtourl = '/adm/navmaps';
1.484.2.21 raeburn 7540: }
7541: }
7542: } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
7543: $backtourl = '/adm/menu';
7544: } elsif ($supplementalflag) {
1.484.2.93.2. 0(raebur 7545:3): if (($env{'request.role.adv'}) ||
7546:3): (&Apache::lonnet::has_unhidden_suppfiles($coursenum,$coursedom))) {
7547:3): $backtourl = '/adm/supplemental';
7548:3): } else {
7549:3): $backtourl = '/adm/navmaps';
7550:3): }
1.484.2.21 raeburn 7551: } else {
7552: $backtourl = '/adm/navmaps';
1.472 raeburn 7553: }
7554:
1.484.2.19 raeburn 7555: my $fieldsets = "'ext','doc'";
1.484.2.93.2. (raeburn 7556:): if ($posslti) {
7557:): $fieldsets .= ",'tool'";
7558:): }
1.484.2.19 raeburn 7559: unless ($main_container_page) {
7560: $fieldsets .=",'ims'";
7561: }
1.484.2.12 raeburn 7562: if ($supplementalflag) {
7563: $fieldsets = "'suppext','suppdoc'";
1.484.2.93.2. (raeburn 7564:): if ($posslti) {
7565:): $fieldsets .= ",'supptool'";
7566:): }
1.484.2.12 raeburn 7567: }
7568:
1.484.2.67 raeburn 7569: my $jsmakefunctions;
7570: if ($canedit) {
7571: $jsmakefunctions = <<ENDNEWSCRIPT;
1.329 droeschl 7572: function makenewfolder(targetform,folderseq) {
1.484.2.65 raeburn 7573: var foldername=prompt('$js_lt{"p_mnf"}','$js_lt{"t_mnf"}');
1.329 droeschl 7574: if (foldername) {
1.484.2.91 raeburn 7575: targetform.importdetail.value=encodeURIComponent(foldername)+"="+folderseq;
1.329 droeschl 7576: targetform.submit();
7577: }
7578: }
7579:
7580: function makenewpage(targetform,folderseq) {
1.484.2.61 raeburn 7581: var pagename=prompt('$js_lt{"p_mnp"}','$js_lt{"t_mnp"}');
1.329 droeschl 7582: if (pagename) {
1.484.2.91 raeburn 7583: targetform.importdetail.value=encodeURIComponent(pagename)+"="+folderseq;
1.329 droeschl 7584: targetform.submit();
7585: }
7586: }
7587:
7588: function makeexamupload() {
1.484.2.61 raeburn 7589: var title=prompt('$js_lt{"p_mxu"}');
1.344 bisitz 7590: if (title) {
1.329 droeschl 7591: this.document.forms.newexamupload.importdetail.value=
1.484.2.91 raeburn 7592: encodeURIComponent(title)+'=/res/lib/templates/examupload.problem';
1.329 droeschl 7593: this.document.forms.newexamupload.submit();
7594: }
7595: }
7596:
7597: function makesmppage() {
1.484.2.61 raeburn 7598: var title=prompt('$js_lt{"p_msp"}');
1.344 bisitz 7599: if (title) {
1.329 droeschl 7600: this.document.forms.newsmppg.importdetail.value=
1.484.2.91 raeburn 7601: encodeURIComponent(title)+'=/adm/$udom/$uname/new/smppg';
1.329 droeschl 7602: this.document.forms.newsmppg.submit();
7603: }
7604: }
7605:
1.484.2.27 raeburn 7606: function makewebpage(type) {
1.484.2.61 raeburn 7607: var title=prompt('$js_lt{"p_mwp"}');
1.484.2.27 raeburn 7608: var formname;
7609: if (type == 'supp') {
7610: formname = this.document.forms.supwebpage;
7611: } else {
7612: formname = this.document.forms.newwebpage;
7613: }
7614: if (title) {
7615: var webpage = formname.importdetail.value;
1.484.2.91 raeburn 7616: formname.importdetail.value = encodeURIComponent(title)+'='+webpage;
1.484.2.27 raeburn 7617: formname.submit();
7618: }
7619: }
7620:
1.329 droeschl 7621: function makesmpproblem() {
1.484.2.61 raeburn 7622: var title=prompt('$js_lt{"p_msb"}');
1.344 bisitz 7623: if (title) {
1.329 droeschl 7624: this.document.forms.newsmpproblem.importdetail.value=
1.484.2.91 raeburn 7625: encodeURIComponent(title)+'=/res/lib/templates/simpleproblem.problem';
1.329 droeschl 7626: this.document.forms.newsmpproblem.submit();
7627: }
7628: }
7629:
7630: function makedropbox() {
1.484.2.61 raeburn 7631: var title=prompt('$js_lt{"p_mdb"}');
1.344 bisitz 7632: if (title) {
1.329 droeschl 7633: this.document.forms.newdropbox.importdetail.value=
1.484.2.91 raeburn 7634: encodeURIComponent(title)+'=/res/lib/templates/DropBox.problem';
1.329 droeschl 7635: this.document.forms.newdropbox.submit();
7636: }
7637: }
7638:
7639: function makebulboard() {
1.484.2.61 raeburn 7640: var title=prompt('$js_lt{"p_mbb"}');
1.329 droeschl 7641: if (title) {
7642: this.document.forms.newbul.importdetail.value=
1.484.2.91 raeburn 7643: encodeURIComponent(title)+'=/adm/$udom/$uname/new/bulletinboard';
1.329 droeschl 7644: this.document.forms.newbul.submit();
7645: }
7646: }
7647:
7648: function makeabout() {
1.484.2.61 raeburn 7649: var user=prompt("$js_lt{'p_mab'}");
1.329 droeschl 7650: if (user) {
7651: var comp=new Array();
7652: comp=user.split(':');
7653: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
7654: if ((comp[0]) && (comp[1])) {
7655: this.document.forms.newaboutsomeone.importdetail.value=
1.484.2.61 raeburn 7656: '$js_lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.484.2.67 raeburn 7657: this.document.forms.newaboutsomeone.submit();
7658: } else {
7659: alert("$js_lt{'p_mab_alrt1'}");
7660: }
7661: } else {
7662: alert("$js_lt{'p_mab_alrt2'}");
7663: }
7664: }
1.335 ehlerst 7665: }
1.484.2.67 raeburn 7666:
7667: function makenew(targetform) {
7668: targetform.submit();
1.335 ehlerst 7669: }
1.484.2.67 raeburn 7670:
7671: function changename(folderpath,index,oldtitle) {
7672: var title=prompt('$js_lt{"p_chn"}',oldtitle);
7673: if (title) {
7674: this.document.forms.renameform.markcopy.value='';
7675: this.document.forms.renameform.title.value=title;
7676: this.document.forms.renameform.cmd.value='rename_'+index;
7677: this.document.forms.renameform.folderpath.value=folderpath;
7678: this.document.forms.renameform.submit();
7679: }
1.329 droeschl 7680: }
7681:
1.484.2.67 raeburn 7682: ENDNEWSCRIPT
7683: } else {
7684: $jsmakefunctions = <<ENDNEWSCRIPT;
7685:
7686: function makenewfolder() {
7687: alert("$js_lt{'edri'}");
7688: }
7689:
7690: function makenewpage() {
7691: alert("$js_lt{'edri'}");
7692: }
7693:
7694: function makeexamupload() {
7695: alert("$js_lt{'edri'}");
7696: }
7697:
7698: function makesmppage() {
7699: alert("$js_lt{'edri'}");
7700: }
7701:
7702: function makewebpage(type) {
7703: alert("$js_lt{'edri'}");
7704: }
7705:
7706: function makesmpproblem() {
7707: alert("$js_lt{'edri'}");
7708: }
7709:
7710: function makedropbox() {
7711: alert("$js_lt{'edri'}");
7712: }
7713:
7714: function makebulboard() {
7715: alert("$js_lt{'edri'}");
7716: }
7717:
7718: function makeabout() {
7719: alert("$js_lt{'edri'}");
7720: }
7721:
7722: function changename() {
7723: alert("$js_lt{'edri'}");
7724: }
7725:
7726: function makenew() {
7727: alert("$js_lt{'edri'}");
7728: }
7729:
7730: function groupimport() {
7731: alert("$js_lt{'edri'}");
7732: }
7733:
7734: function groupsearch() {
7735: alert("$js_lt{'edri'}");
7736: }
7737:
7738: function groupopen(url,recover) {
7739: var options="scrollbars=1,resizable=1,menubar=0";
7740: idxflag=1;
7741: idx=open("/adm/groupsort?inhibitmenu=yes&mode=simple&recover="+recover+"&readfile="+url,"idxout",options);
7742: idx.focus();
7743: }
7744:
7745: ENDNEWSCRIPT
7746:
7747: }
7748: return <<ENDSCRIPT;
7749:
7750: $jsmakefunctions
7751:
1.484.2.13 raeburn 7752: function toggleUpload(caller) {
7753: var blocks = Array($fieldsets);
7754: for (var i=0; i<blocks.length; i++) {
7755: var disp = 'none';
7756: if (caller == blocks[i]) {
7757: var curr = document.getElementById('upload'+caller+'form').style.display;
7758: if (curr == 'none') {
7759: disp='block';
7760: }
7761: }
7762: document.getElementById('upload'+blocks[i]+'form').style.display=disp;
1.484.2.93.2. (raeburn 7763:): if ((caller == 'tool') || (caller == 'supptool')) {
7764:): if (disp == 'block') {
7765:): if (document.getElementById('LC_exttoolid')) {
7766:): var toolselector = document.getElementById('LC_exttoolid');
7767:): var suppflag = 0;
7768:): if (caller == 'supptool') {
7769:): suppflag = 1;
7770:): }
7771:): currForm = document.getElementById('new'+caller);
7772:): updateExttool(toolselector,currForm,suppflag);
7773:): }
7774:): }
7775:): }
1.484.2.13 raeburn 7776: }
7777: resize_scrollbox('contentscroll','1','1');
7778: return;
7779: }
7780:
1.484.2.19 raeburn 7781: function toggleMap(caller) {
1.484.2.13 raeburn 7782: var disp = 'none';
1.484.2.19 raeburn 7783: if (document.getElementById('importmapform')) {
7784: if (caller == 'map') {
7785: var curr = document.getElementById('importmapform').style.display;
7786: if (curr == 'none') {
7787: disp='block';
7788: }
1.484.2.12 raeburn 7789: }
1.484.2.19 raeburn 7790: document.getElementById('importmapform').style.display=disp;
7791: resize_scrollbox('contentscroll','1','1');
1.484.2.12 raeburn 7792: }
1.484.2.19 raeburn 7793: return;
1.329 droeschl 7794: }
7795:
1.484.2.12 raeburn 7796: function makeims(imsform) {
7797: if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
1.484.2.61 raeburn 7798: alert("$js_lt{'imsfile'}");
1.484.2.12 raeburn 7799: return;
7800: }
7801: if (imsform.source.selectedIndex == 0) {
1.484.2.61 raeburn 7802: alert("$js_lt{'imscms'}");
1.484.2.12 raeburn 7803: return;
7804: }
7805: newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
7806: imsform.submit();
7807: }
7808:
1.478 raeburn 7809: function updatePick(targetform,index,caller) {
1.484.2.29 raeburn 7810: var pickitem;
7811: var picknumitem;
7812: var picknumtext;
7813: if (index == 'all') {
7814: pickitem = document.getElementById('randompickall');
7815: picknumitem = document.getElementById('rpicknumall');
7816: picknumtext = document.getElementById('rpicktextall');
7817: } else {
7818: pickitem = document.getElementById('randompick_'+index);
7819: picknumitem = document.getElementById('rpicknum_'+index);
7820: picknumtext = document.getElementById('randompicknum_'+index);
7821: }
1.478 raeburn 7822: if (pickitem.checked) {
1.484.2.61 raeburn 7823: var picknum=prompt('$js_lt{"rpck"}',picknumitem.value);
1.478 raeburn 7824: if (picknum == '' || picknum == null) {
7825: if (caller == 'check') {
7826: pickitem.checked=false;
1.484.2.29 raeburn 7827: if (index == 'all') {
7828: picknumtext.innerHTML = '';
7829: if (caller == 'link') {
7830: propagateState(targetform,'rpicknum');
7831: }
7832: } else {
1.484.2.30 raeburn 7833: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 7834: }
1.478 raeburn 7835: }
7836: } else {
7837: picknum.toString();
7838: var regexdigit=/^\\d+\$/;
7839: if (regexdigit.test(picknum)) {
7840: picknumitem.value = picknum;
1.484.2.29 raeburn 7841: if (index == 'all') {
1.484.2.30 raeburn 7842: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.cumulativesettings,\\'all\\',\\'link\\');">'+picknum+'</a>';
1.484.2.29 raeburn 7843: if (caller == 'link') {
7844: propagateState(targetform,'rpicknum');
7845: }
7846: } else {
7847: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.edit_randompick_'+index+',\\''+index+'\\',\\'link\\');">'+picknum+'</a>';
1.484.2.30 raeburn 7848: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 7849: }
1.478 raeburn 7850: } else {
7851: if (caller == 'check') {
1.484.2.29 raeburn 7852: if (index == 'all') {
7853: picknumtext.innerHTML = '';
7854: if (caller == 'link') {
7855: propagateState(targetform,'rpicknum');
7856: }
7857: } else {
7858: pickitem.checked=false;
1.484.2.30 raeburn 7859: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 7860: }
1.478 raeburn 7861: }
7862: return;
7863: }
7864: }
7865: } else {
1.484.2.29 raeburn 7866: picknumitem.value = '';
7867: picknumtext.innerHTML = '';
7868: if (index == 'all') {
7869: if (caller == 'link') {
7870: propagateState(targetform,'rpicknum');
7871: }
7872: } else {
1.484.2.30 raeburn 7873: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 7874: }
7875: }
7876: }
7877:
7878: function propagateState(form,param) {
7879: if (document.getElementById(param+'all')) {
7880: var setcheck = 0;
7881: var rpick = 0;
7882: if (param == 'rpicknum') {
7883: if (document.getElementById('randompickall')) {
7884: if (document.getElementById('randompickall').checked) {
7885: if (document.getElementById('rpicknumall')) {
7886: rpick = document.getElementById('rpicknumall').value;
7887: }
7888: }
7889: }
7890: } else {
7891: if (document.getElementById(param+'all').checked) {
7892: setcheck = 1;
7893: }
7894: }
1.484.2.30 raeburn 7895: var allidxlist;
7896: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
7897: if (document.getElementById('all'+param+'idx')) {
7898: allidxlist = document.getElementById('all'+param+'idx').value;
7899: }
7900: var actions = new Array ('remove','cut','copy');
7901: for (var i=0; i<actions.length; i++) {
7902: if (actions[i] != param) {
7903: if (document.getElementById(actions[i]+'all')) {
7904: document.getElementById(actions[i]+'all').checked = false;
7905: }
7906: }
7907: }
7908: }
1.484.2.29 raeburn 7909: if ((param == 'encrypturl') || (param == 'hiddenresource')) {
1.484.2.30 raeburn 7910: allidxlist = form.allidx.value;
7911: }
7912: if ((param == 'randompick') || (param == 'rpicknum') || (param == 'randomorder')) {
7913: allidxlist = form.allmapidx.value;
7914: }
7915: if ((allidxlist != '') && (allidxlist != null)) {
7916: var allidxs = allidxlist.split(',');
7917: if (allidxs.length > 1) {
7918: for (var i=0; i<allidxs.length; i++) {
7919: if (document.getElementById(param+'_'+allidxs[i])) {
7920: if (param == 'rpicknum') {
7921: if (document.getElementById('randompick_'+allidxs[i])) {
7922: if (document.getElementById('randompick_'+allidxs[i]).checked) {
7923: document.getElementById(param+'_'+allidxs[i]).value = rpick;
7924: if (rpick > 0) {
7925: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = ': <a href="javascript:updatePick(document.edit_randompick_'+allidxs[i]+',\\''+allidxs[i]+'\\',\\'link\\')">'+rpick+'</a>';
7926: } else {
7927: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
7928: }
7929: }
7930: }
7931: } else {
1.484.2.29 raeburn 7932: if (setcheck == 1) {
7933: document.getElementById(param+'_'+allidxs[i]).checked = true;
7934: } else {
7935: document.getElementById(param+'_'+allidxs[i]).checked = false;
1.484.2.30 raeburn 7936: if (param == 'randompick') {
7937: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
7938: }
1.484.2.29 raeburn 7939: }
7940: }
7941: }
7942: }
1.484.2.30 raeburn 7943: if (setcheck == 1) {
7944: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
7945: var actions = new Array('copy','cut','remove');
7946: for (var i=0; i<actions.length; i++) {
7947: var otheractions;
7948: var otheridxs;
7949: if (actions[i] === param) {
7950: continue;
7951: } else {
7952: if (document.getElementById('all'+actions[i]+'idx')) {
7953: otheractions = document.getElementById('all'+actions[i]+'idx').value;
7954: otheridxs = otheractions.split(',');
7955: if (otheridxs.length > 1) {
7956: for (var j=0; j<otheridxs.length; j++) {
7957: if (document.getElementById(actions[i]+'_'+otheridxs[j])) {
7958: document.getElementById(actions[i]+'_'+otheridxs[j]).checked = false;
7959: }
1.484.2.29 raeburn 7960: }
7961: }
7962: }
7963: }
1.484.2.30 raeburn 7964: }
1.484.2.29 raeburn 7965: }
7966: }
7967: }
7968: }
1.478 raeburn 7969: }
1.484.2.29 raeburn 7970: return;
7971: }
7972:
1.484.2.63 raeburn 7973: function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder,confirm_removal) {
1.484.2.67 raeburn 7974: var canedit = '$canedit';
7975: if (canedit == '') {
7976: alert("$js_lt{'edri'}");
7977: return;
7978: }
1.484.2.30 raeburn 7979: var dosettings;
7980: var doaction;
7981: var control = document.togglemultsettings;
7982: if (context == 'actions') {
7983: control = document.togglemultactions;
7984: doaction = 1;
7985: } else {
7986: dosettings = 1;
7987: }
7988: if (control) {
7989: if (control.showmultpick.length) {
7990: for (var i=0; i<control.showmultpick.length; i++) {
7991: if (control.showmultpick[i].checked) {
7992: if (control.showmultpick[i].value == 1) {
7993: if (context == 'settings') {
7994: dosettings = 0;
7995: } else {
7996: doaction = 0;
7997: }
7998: }
7999: }
8000: }
8001: }
8002: }
8003: if (context == 'settings') {
8004: if (dosettings == 1) {
8005: targetform.changeparms.value=param;
8006: targetform.submit();
8007: }
8008: }
8009: if (context == 'actions') {
8010: if (doaction == 1) {
8011: targetform.cmd.value=param+'_'+index;
8012: targetform.folderpath.value=folderpath;
8013: targetform.markcopy.value=idx+':'+param;
8014: targetform.copyfolder.value=folder+'.'+container;
8015: if (param == 'remove') {
1.484.2.63 raeburn 8016: var doremove = 0;
8017: if (skip_confirm) {
8018: if (confirm_removal) {
8019: if (confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'"$js_lt{"p_rmr2b"}')) {
8020: doremove = 1;
8021: }
8022: } else {
8023: doremove = 1;
8024: }
8025: } else {
8026: if (confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'" $js_lt{"p_rmr2b"}')) {
8027: doremove = 1;
8028: }
8029: }
8030: if (doremove) {
1.484.2.30 raeburn 8031: targetform.markcopy.value='';
8032: targetform.copyfolder.value='';
1.484.2.29 raeburn 8033: targetform.submit();
8034: }
8035: }
1.484.2.30 raeburn 8036: if (param == 'cut') {
1.484.2.61 raeburn 8037: 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.484.2.30 raeburn 8038: targetform.submit();
8039: return;
8040: }
8041: }
8042: if (param == 'copy') {
8043: targetform.submit();
8044: return;
8045: }
8046: targetform.markcopy.value='';
8047: targetform.copyfolder.value='';
8048: targetform.cmd.value='';
8049: targetform.folderpath.value='';
8050: return;
8051: } else {
8052: if (document.getElementById(param+'_'+idx)) {
8053: item = document.getElementById(param+'_'+idx);
8054: if (item.type == 'checkbox') {
8055: if (item.checked) {
8056: item.checked = false;
8057: } else {
8058: item.checked = true;
8059: singleCheck(item,idx,param);
8060: }
8061: }
8062: }
8063: }
8064: }
8065: return;
8066: }
8067:
8068: function singleCheck(caller,idx,action) {
8069: actions = new Array('cut','copy','remove');
8070: if (caller.checked) {
8071: for (var i=0; i<actions.length; i++) {
8072: if (actions[i] != action) {
8073: if (document.getElementById(actions[i]+'_'+idx)) {
8074: if (document.getElementById(actions[i]+'_'+idx).checked) {
8075: document.getElementById(actions[i]+'_'+idx).checked = false;
8076: }
8077: }
8078: }
1.484.2.29 raeburn 8079: }
8080: }
8081: return;
1.478 raeburn 8082: }
8083:
1.334 muellerd 8084: function unselectInactive(nav) {
1.335 ehlerst 8085: currentNav = document.getElementById(nav);
8086: currentLis = currentNav.getElementsByTagName('LI');
8087: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 8088: if (currentLis[i].className == 'goback') {
8089: currentLis[i].className = 'goback';
8090: } else {
8091: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 8092: currentLis[i].className = 'right';
1.472 raeburn 8093: } else {
1.374 tempelho 8094: currentLis[i].className = 'i';
1.472 raeburn 8095: }
8096: }
1.335 ehlerst 8097: }
1.332 tempelho 8098: }
8099:
1.334 muellerd 8100: function hideAll(current, nav, data) {
1.335 ehlerst 8101: unselectInactive(nav);
1.484.2.43 raeburn 8102: if (current) {
8103: if (current.className == 'right'){
1.374 tempelho 8104: current.className = 'right active'
1.484.2.43 raeburn 8105: } else {
1.374 tempelho 8106: current.className = 'active';
1.484.2.43 raeburn 8107: }
1.374 tempelho 8108: }
1.335 ehlerst 8109: currentData = document.getElementById(data);
8110: currentDivs = currentData.getElementsByTagName('DIV');
8111: for (i = 0; i < currentDivs.length; i++) {
8112: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 8113: currentDivs[i].style.display = 'none';
1.330 tempelho 8114: }
8115: }
1.335 ehlerst 8116: }
1.330 tempelho 8117:
1.374 tempelho 8118: function openTabs(pageId) {
8119: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 8120: if(tabnav.length > 2 ){
1.389 tempelho 8121: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 8122: currentLis = currentNav.getElementsByTagName('LI');
8123: for(i = 0; i< currentLis.length; i++){
8124: if(currentLis[i].className == 'active') {
1.375 tempelho 8125: funcString = currentLis[i].onclick.toString();
8126: tab = funcString.split('"');
1.420 onken 8127: if(tab.length < 2) {
8128: tab = funcString.split("'");
8129: }
1.375 tempelho 8130: currentData = document.getElementById(tab[1]);
8131: currentData.style.display = 'block';
1.374 tempelho 8132: }
8133: }
8134: }
8135: }
8136:
1.334 muellerd 8137: function showPage(current, pageId, nav, data) {
1.484.2.43 raeburn 8138: currstate = current.className;
1.334 muellerd 8139: hideAll(current, nav, data);
1.375 tempelho 8140: openTabs(pageId);
1.334 muellerd 8141: unselectInactive(nav);
1.484.2.43 raeburn 8142: if ((currstate == 'active') || (currstate == 'right active')) {
8143: if (currstate == 'active') {
8144: current.className = '';
8145: } else {
8146: current.className = 'right';
8147: }
8148: activeTab = '';
8149: toggleUpload();
8150: toggleMap();
8151: resize_scrollbox('contentscroll','1','0');
8152: return;
8153: } else {
8154: current.className = 'active';
8155: }
1.330 tempelho 8156: currentData = document.getElementById(pageId);
8157: currentData.style.display = 'block';
1.458 raeburn 8158: activeTab = pageId;
1.484.2.12 raeburn 8159: toggleUpload();
1.484.2.14 raeburn 8160: toggleMap();
1.433 raeburn 8161: if (nav == 'mainnav') {
8162: var storedpath = "$docs_folderpath";
1.434 raeburn 8163: var storedpage = "$main_container_page";
1.433 raeburn 8164: var reg = new RegExp("^supplemental");
8165: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 8166: if (storedpage == 1) {
8167: document.simpleedit.folderpath.value = '';
8168: document.uploaddocument.folderpath.value = '';
8169: } else {
8170: if (reg.test(storedpath)) {
8171: document.simpleedit.folderpath.value = '$toplevelmain';
8172: document.uploaddocument.folderpath.value = '$toplevelmain';
8173: document.newext.folderpath.value = '$toplevelmain';
8174: } else {
8175: document.simpleedit.folderpath.value = storedpath;
8176: document.uploaddocument.folderpath.value = storedpath;
8177: document.newext.folderpath.value = storedpath;
8178: }
1.433 raeburn 8179: }
8180: } else {
1.434 raeburn 8181: if (reg.test(storedpath)) {
8182: document.simpleedit.folderpath.value = storedpath;
8183: document.supuploaddocument.folderpath.value = storedpath;
8184: document.supnewext.folderpath.value = storedpath;
8185: } else {
1.433 raeburn 8186: document.simpleedit.folderpath.value = '$toplevelsupp';
8187: document.supuploaddocument.folderpath.value = '$toplevelsupp';
8188: document.supnewext.folderpath.value = '$toplevelsupp';
8189: }
8190: }
8191: }
1.484.2.3 raeburn 8192: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 8193: return false;
8194: }
1.329 droeschl 8195:
1.472 raeburn 8196: function toContents(jumpto) {
8197: var newurl = '$backtourl';
1.484.2.21 raeburn 8198: if ((newurl == '/adm/navmaps') && (jumpto != '')) {
1.472 raeburn 8199: newurl = newurl+'?postdata='+jumpto;
8200: }
8201: location.href=newurl;
8202: }
8203:
1.484.2.30 raeburn 8204: function togglePick(caller,value) {
8205: var disp = 'none';
8206: if (document.getElementById('multi'+caller)) {
8207: var curr = document.getElementById('multi'+caller).style.display;
8208: if (value == 1) {
8209: disp='block';
8210: }
8211: if (curr == disp) {
8212: return;
8213: }
8214: document.getElementById('multi'+caller).style.display=disp;
8215: if (value == 1) {
1.484.2.61 raeburn 8216: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.484.2.30 raeburn 8217: } else {
8218: document.getElementById('more'+caller).innerHTML = '';
8219: }
8220: if (caller == 'actions') {
8221: setClass(value);
8222: setBoxes(value);
8223: }
8224: }
8225: var showButton = multiSettings();
8226: if (showButton != 1) {
8227: showButton = multiActions();
8228: }
8229: if (document.getElementById('multisave')) {
8230: if (showButton == 1) {
8231: document.getElementById('multisave').style.display='block';
8232: } else {
8233: document.getElementById('multisave').style.display='none';
8234: }
8235: }
8236: resize_scrollbox('contentscroll','1','1');
8237: return;
8238: }
8239:
8240: function toggleCheckUncheck(caller,more) {
8241: if (more == 1) {
1.484.2.61 raeburn 8242: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',0);" style="text-decoration:none;">$js_lt{'less'}</a>';
1.484.2.30 raeburn 8243: document.getElementById('allfields'+caller).style.display='block';
8244: } else {
1.484.2.61 raeburn 8245: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.484.2.30 raeburn 8246: document.getElementById('allfields'+caller).style.display='none';
8247: }
8248: resize_scrollbox('contentscroll','1','1');
8249: }
8250:
8251: function multiSettings() {
8252: var inuse = 0;
8253: var settingsform = document.togglemultsettings;
8254: if (settingsform.showmultpick.length > 1) {
8255: for (var i=0; i<settingsform.showmultpick.length; i++) {
8256: if (settingsform.showmultpick[i].checked) {
8257: if (settingsform.showmultpick[i].value == 1) {
8258: inuse = 1;
8259: }
8260: }
8261: }
8262: }
8263: return inuse;
8264: }
8265:
8266: function multiActions() {
8267: var inuse = 0;
8268: var actionsform = document.togglemultactions;
8269: if (actionsform.showmultpick.length > 1) {
8270: for (var i=0; i<actionsform.showmultpick.length; i++) {
8271: if (actionsform.showmultpick[i].checked) {
8272: if (actionsform.showmultpick[i].value == 1) {
8273: inuse = 1;
8274: }
8275: }
8276: }
8277: }
8278: return inuse;
8279: }
8280:
8281: function checkSubmits() {
8282: var numchanges = 0;
8283: var form = document.saveactions;
8284: var doactions = multiActions();
8285: var cutwarnings = 0;
8286: var remwarnings = 0;
1.484.2.63 raeburn 8287: var removalinfo = 0;
1.484.2.30 raeburn 8288: if (doactions == 1) {
8289: var remidxlist = document.cumulativeactions.allremoveidx.value;
8290: if ((remidxlist != '') && (remidxlist != null)) {
8291: var remidxs = remidxlist.split(',');
8292: for (var i=0; i<remidxs.length; i++) {
8293: if (document.getElementById('remove_'+remidxs[i])) {
8294: if (document.getElementById('remove_'+remidxs[i]).checked) {
8295: form.multiremove.value += remidxs[i]+',';
8296: numchanges ++;
8297: if (document.getElementById('skip_remove_'+remidxs[i])) {
8298: if (document.getElementById('skip_remove_'+remidxs[i]).value == 0) {
8299: remwarnings ++;
8300: }
8301: }
1.484.2.63 raeburn 8302: if (document.getElementById('confirm_removal_'+remidxs[i])) {
8303: if (document.getElementById('confirm_removal_'+remidxs[i]).value == 1) {
8304: removalinfo ++;
8305: }
8306: }
1.484.2.30 raeburn 8307: }
8308: }
8309: }
8310: }
8311: var cutidxlist = document.cumulativeactions.allcutidx.value;
8312: if ((cutidxlist != '') && (cutidxlist != null)) {
8313: var cutidxs = cutidxlist.split(',');
8314: for (var i=0; i<cutidxs.length; i++) {
8315: if (document.getElementById('cut_'+cutidxs[i])) {
8316: if (document.getElementById('cut_'+cutidxs[i]).checked == true) {
8317: form.multicut.value += cutidxs[i]+',';
8318: numchanges ++;
8319: if (document.getElementById('skip_cut_'+cutidxs[i])) {
8320: if (document.getElementById('skip_cut_'+cutidxs[i]).value == 0) {
8321: cutwarnings ++;
8322: }
8323: }
8324: }
8325: }
8326: }
8327: }
8328: var copyidxlist = document.cumulativeactions.allcopyidx.value;
8329: if ((copyidxlist != '') && (copyidxlist != null)) {
8330: var copyidxs = copyidxlist.split(',');
8331: for (var i=0; i<copyidxs.length; i++) {
8332: if (document.getElementById('copy_'+copyidxs[i])) {
8333: if (document.getElementById('copy_'+copyidxs[i]).checked) {
8334: form.multicopy.value += copyidxs[i]+',';
8335: numchanges ++;
8336: }
8337: }
8338: }
8339: }
8340: if (numchanges > 0) {
8341: form.multichange.value = numchanges;
8342: }
8343: }
8344: var dosettings = multiSettings();
8345: var haschanges = 0;
8346: if (dosettings == 1) {
8347: form.allencrypturl.value = '';
8348: form.allhiddenresource.value = '';
8349: form.changeparms.value = 'all';
8350: var patt=new RegExp(",\$");
8351: var allidxlist = document.cumulativesettings.allidx.value;
8352: if ((allidxlist != '') && (allidxlist != null)) {
8353: var allidxs = allidxlist.split(',');
8354: if (allidxs.length > 1) {
8355: for (var i=0; i<allidxs.length; i++) {
8356: if (document.getElementById('hiddenresource_'+allidxs[i])) {
8357: if (document.getElementById('hiddenresource_'+allidxs[i]).checked) {
8358: form.allhiddenresource.value += allidxs[i]+',';
8359: }
8360: }
8361: if (document.getElementById('encrypturl_'+allidxs[i])) {
8362: if (document.getElementById('encrypturl_'+allidxs[i]).checked) {
8363: form.allencrypturl.value += allidxs[i]+',';
8364: }
1.484.2.29 raeburn 8365: }
8366: }
1.484.2.30 raeburn 8367: form.allhiddenresource.value = form.allhiddenresource.value.replace(patt,"");
8368: form.allencrypturl.value = form.allencrypturl.value.replace(patt,"");
8369: }
8370: }
8371: form.allrandompick.value = '';
8372: form.allrandomorder.value = '';
8373: var allmapidxlist = document.cumulativesettings.allmapidx.value;
8374: if ((allmapidxlist != '') && (allmapidxlist != null)) {
8375: var allmapidxs = allmapidxlist.split(',');
8376: for (var i=0; i<allmapidxs.length; i++) {
8377: var randompick = document.getElementById('randompick_'+allmapidxs[i]);
8378: var rpicknum = document.getElementById('rpicknum_'+allmapidxs[i]);
8379: var randorder = document.getElementById('randomorder_'+allmapidxs[i]);
8380: if ((randompick.checked) && (rpicknum.value != '')) {
8381: form.allrandompick.value += allmapidxs[i]+':'+rpicknum.value+',';
8382: }
8383: if (randorder.checked) {
8384: form.allrandomorder.value += allmapidxs[i]+',';
8385: }
8386: }
8387: form.allrandompick.value = form.allrandompick.value.replace(patt,"");
8388: form.allrandomorder.value = form.allrandomorder.value.replace(patt,"");
8389: }
8390: if (document.cumulativesettings.currhiddenresource.value != form.allhiddenresource.value) {
8391: haschanges = 1;
8392: }
8393: if (document.cumulativesettings.currencrypturl.value != form.allencrypturl.value) {
8394: haschanges = 1;
8395: }
8396: if (document.cumulativesettings.currrandomorder.value != form.allrandomorder.value) {
8397: haschanges = 1;
8398: }
8399: if (document.cumulativesettings.currrandompick.value != form.allrandompick.value) {
8400: haschanges = 1;
8401: }
8402: }
8403: if (doactions == 1) {
8404: if (numchanges > 0) {
1.484.2.63 raeburn 8405: if ((cutwarnings > 0) || (remwarnings > 0) || (removalinfo > 0)) {
1.484.2.30 raeburn 8406: if (remwarnings > 0) {
1.484.2.61 raeburn 8407: if (!confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr3a"} '+remwarnings+' $js_lt{"p_rmr3b"}')) {
1.484.2.30 raeburn 8408: return false;
8409: }
8410: }
1.484.2.63 raeburn 8411: if (removalinfo > 0) {
8412: if (!confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr3a"} '+removalinfo+' $js_lt{"p_rmr3b"}')) {
8413: return false;
8414: }
8415: }
1.484.2.30 raeburn 8416: if (cutwarnings > 0) {
1.484.2.61 raeburn 8417: if (!confirm('$js_lt{"p_ctr1a"}\\n$js_lt{"p_ctr1b"}\\n\\n$js_lt{"p_ctr3a"} '+cutwarnings+' $js_lt{"p_ctr3b"}')) {
1.484.2.30 raeburn 8418: return false;
1.484.2.29 raeburn 8419: }
8420: }
8421: }
1.484.2.30 raeburn 8422: form.submit();
8423: return true;
8424: }
8425: }
8426: if (dosettings == 1) {
8427: if (haschanges == 1) {
8428: form.submit();
8429: return true;
1.484.2.29 raeburn 8430: }
8431: }
1.484.2.30 raeburn 8432: if ((dosettings == 1) && (doactions == 1)) {
1.484.2.61 raeburn 8433: alert("$js_lt{'noor'}");
1.484.2.30 raeburn 8434: } else {
8435: if (dosettings == 1) {
1.484.2.61 raeburn 8436: alert("$js_lt{'noch'}");
1.484.2.30 raeburn 8437: } else {
1.484.2.61 raeburn 8438: alert("$js_lt{'noac'}");
1.484.2.30 raeburn 8439: }
8440: }
8441: return false;
8442: }
8443:
8444: function setClass(value) {
8445: var cutclass = 'LC_docs_cut';
8446: var copyclass = 'LC_docs_copy';
8447: var removeclass = 'LC_docs_remove';
8448: var cutreg = new RegExp("\\\\b"+cutclass+"\\\\b");
8449: var copyreg = new RegExp("\\\\b"+copyclass+"\\\\b");
8450: var removereg = new RegExp("\\\\"+removeclass+"\\\\b");
8451: var links = document.getElementsByTagName('a');
8452: for (var i=0; i<links.length; i++) {
8453: var classes = links[i].className;
8454: if (cutreg.test(classes)) {
8455: links[i].className = cutclass;
8456: if (value == 1) {
8457: links[i].className += " LC_menubuttons_link";
1.484.2.29 raeburn 8458: }
1.484.2.30 raeburn 8459: } else {
8460: if (copyreg.test(classes)) {
8461: links[i].className = copyclass;
8462: if (value == 1) {
8463: links[i].className += " LC_menubuttons_link";
8464: }
8465: } else {
8466: if (removereg.test(classes)) {
8467: links[i].className = removeclass;
8468: if (value == 1) {
8469: links[i].className += " LC_menubuttons_link";
8470: }
8471: }
1.484.2.29 raeburn 8472: }
8473: }
8474: }
1.484.2.30 raeburn 8475: return;
1.484.2.29 raeburn 8476: }
8477:
1.484.2.30 raeburn 8478: function setBoxes(value) {
8479: var remidxlist = document.cumulativeactions.allremoveidx.value;
8480: if ((remidxlist != '') && (remidxlist != null)) {
8481: var remidxs = remidxlist.split(',');
8482: for (var i=0; i<remidxs.length; i++) {
8483: if (document.getElementById('remove_'+remidxs[i])) {
8484: var item = document.getElementById('remove_'+remidxs[i]);
8485: if (value == 1) {
8486: item.className = 'LC_docs_remove';
8487: } else {
8488: item.className = 'LC_hidden';
8489: }
8490: }
1.484.2.29 raeburn 8491: }
8492: }
1.484.2.30 raeburn 8493: var cutidxlist = document.cumulativeactions.allcutidx.value;
8494: if ((cutidxlist != '') && (cutidxlist != null)) {
8495: var cutidxs = cutidxlist.split(',');
8496: for (var i=0; i<cutidxs.length; i++) {
8497: if (document.getElementById('cut_'+cutidxs[i])) {
8498: var item = document.getElementById('cut_'+cutidxs[i]);
8499: if (value == 1) {
8500: item.className = 'LC_docs_cut';
8501: } else {
8502: item.className = 'LC_hidden';
8503: }
8504: }
8505: }
8506: }
8507: var copyidxlist = document.cumulativeactions.allcopyidx.value;
8508: if ((copyidxlist != '') && (copyidxlist != null)) {
8509: var copyidxs = copyidxlist.split(',');
8510: for (var i=0; i<copyidxs.length; i++) {
8511: if (document.getElementById('copy_'+copyidxs[i])) {
8512: var item = document.getElementById('copy_'+copyidxs[i]);
8513: if (value == 1) {
8514: item.className = 'LC_docs_copy';
8515: } else {
8516: item.className = 'LC_hidden';
8517: }
8518: }
1.484.2.29 raeburn 8519: }
8520: }
8521: return;
8522: }
8523:
1.484.2.67 raeburn 8524: ENDSCRIPT
1.329 droeschl 8525: }
1.457 raeburn 8526:
1.483 raeburn 8527: sub history_tab_js {
8528: return <<"ENDHIST";
8529: function toggleHistoryDisp(choice) {
8530: document.docslogform.docslog.value = choice;
8531: document.docslogform.submit();
8532: return;
8533: }
8534:
8535: ENDHIST
8536: }
8537:
1.484 raeburn 8538: sub inject_data_js {
8539: return <<ENDINJECT;
8540:
8541: function injectData(current, hiddenField, name, value) {
8542: currentElement = document.getElementById(hiddenField);
8543: currentElement.name = name;
8544: currentElement.value = value;
8545: current.submit();
8546: }
8547:
8548: ENDINJECT
8549: }
8550:
8551: sub dump_switchserver_js {
8552: my @hosts = @_;
1.484.2.61 raeburn 8553: my %js_lt = &Apache::lonlocal::texthash(
1.484.2.46 raeburn 8554: dump => 'Copying content to Authoring Space requires switching server.',
1.484 raeburn 8555: swit => 'Switch server?',
1.484.2.61 raeburn 8556: );
8557: my %html_js_lt = &Apache::lonlocal::texthash(
8558: swit => 'Switch server?',
1.484.2.43 raeburn 8559: duco => 'Copying Content to Authoring Space',
1.484 raeburn 8560: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
8561: chos => 'Choose server',
8562: );
1.484.2.61 raeburn 8563: &js_escape(\%js_lt);
8564: &html_escape(\%html_js_lt);
8565: &js_escape(\%html_js_lt);
1.484 raeburn 8566: my $role = $env{'request.role'};
8567: my $js = <<"ENDSWJS";
8568: <script type="text/javascript">
8569: function write_switchserver() {
8570: var server;
8571: if (document.setserver.posshosts.length > 0) {
8572: for (var i=0; i<document.setserver.posshosts.length; i++) {
8573: if (document.setserver.posshosts[i].checked) {
8574: server = document.setserver.posshosts[i].value;
8575: }
8576: }
8577: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
8578: }
8579: window.close();
8580: }
8581: </script>
8582:
8583: ENDSWJS
8584:
8585: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
8586: {'only_body' => 1,
8587: 'js_ready' => 1,});
8588: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
8589:
8590: my $hostpicker;
8591: my $count = 0;
8592: foreach my $host (sort(@hosts)) {
8593: my $checked;
8594: if ($count == 0) {
8595: $checked = ' checked="checked"';
8596: }
8597: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
8598: $host.'"'.$checked.' />'.$host.'</label> ';
8599: $count++;
8600: }
8601:
8602: return <<"ENDSWITCHJS";
8603:
8604: function dump_needs_switchserver(url) {
8605: if (url!='' && url!= null) {
1.484.2.61 raeburn 8606: if (confirm("$js_lt{'dump'}\\n$js_lt{'swit'}")) {
1.484 raeburn 8607: go(url);
8608: }
8609: }
8610: return;
8611: }
8612:
8613: function choose_switchserver_window() {
8614: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
8615: newWindow.document.open();
8616: newWindow.document.writeln('$startpage');
1.484.2.61 raeburn 8617: newWindow.document.write('<h3>$html_js_lt{'duco'}<\\/h3>\\n'+
8618: '<p>$html_js_lt{'yone'}<\\/p>\\n'+
8619: '<div class="LC_left_float"><fieldset><legend>$html_js_lt{'chos'}<\\/legend>\\n'+
1.484 raeburn 8620: '<form name="setserver" method="post" action="" \\/>\\n'+
8621: '$hostpicker\\n'+
8622: '<br \\/><br \\/>\\n'+
1.484.2.61 raeburn 8623: '<input type="button" name="makeswitch" value="$html_js_lt{'swit'}" '+
1.484 raeburn 8624: 'onclick="write_switchserver();" \\/>\\n'+
8625: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
8626: newWindow.document.writeln('$endpage');
8627: newWindow.document.close();
8628: newWindow.focus();
8629: }
8630:
8631: ENDSWITCHJS
8632: }
8633:
8634: sub makedocslogform {
8635: my ($formelems,$docslog) = @_;
8636: return <<"LOGSFORM";
8637: <form action="/adm/coursedocs" method="post" name="docslogform">
8638: <input type="hidden" name="docslog" value="$docslog" />
8639: $formelems
8640: </form>
8641: LOGSFORM
8642: }
8643:
8644: sub makesimpleeditform {
8645: my ($formelems) = @_;
8646: return <<"SIMPFORM";
8647: <form name="simpleedit" method="post" action="/adm/coursedocs">
8648: <input type="hidden" name="importdetail" value="" />
8649: $formelems
8650: </form>
8651: SIMPFORM
8652: }
8653:
1.329 droeschl 8654: 1;
8655: __END__
8656:
8657:
8658: =head1 NAME
8659:
8660: Apache::londocs.pm
8661:
8662: =head1 SYNOPSIS
8663:
8664: This is part of the LearningOnline Network with CAPA project
8665: described at http://www.lon-capa.org.
8666:
8667: =head1 SUBROUTINES
8668:
8669: =over
8670:
8671: =item %help=()
8672:
8673: Available help topics
8674:
8675: =item mapread()
8676:
1.344 bisitz 8677: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 8678: @order and @resources, determines status
8679: sets @order - pointer to resources in right order
8680: sets @resources - array with the resources with correct idx
8681:
8682: =item authorhosts()
8683:
8684: Return hash with valid author names
8685:
8686: =item clean()
8687:
8688: =item dumpcourse()
8689:
8690: Actually dump course
8691:
8692: =item group_import()
8693:
8694: Imports the given (name, url) resources into the course
8695: coursenum, coursedom, and folder must precede the list
8696:
8697: =item breadcrumbs()
8698:
8699: =item log_docs()
8700:
8701: =item docs_change_log()
8702:
8703: =item update_paste_buffer()
8704:
8705: =item print_paste_buffer()
8706:
8707: =item do_paste_from_buffer()
8708:
1.484.2.30 raeburn 8709: =item do_buffer_empty()
8710:
8711: =item clear_from_buffer()
8712:
1.484.2.7 raeburn 8713: =item get_newmap_url()
8714:
8715: =item dbcopy()
8716:
8717: =item uniqueness_check()
8718:
8719: =item contained_map_check()
8720:
8721: =item url_paste_fixups()
8722:
8723: =item apply_fixups()
8724:
8725: =item copy_dependencies()
8726:
1.329 droeschl 8727: =item update_parameter()
8728:
8729: =item handle_edit_cmd()
8730:
8731: =item editor()
8732:
8733: =item process_file_upload()
8734:
8735: =item process_secondary_uploads()
8736:
8737: =item is_supplemental_title()
8738:
8739: =item entryline()
8740:
8741: =item tiehash()
8742:
8743: =item untiehash()
8744:
8745: =item checkonthis()
8746:
8747: check on this
8748:
8749: =item verifycontent()
8750:
8751: Verify Content
8752:
1.484.2.78 raeburn 8753: =item devalidateversioncache()
8754:
8755: =item checkversions()
1.329 droeschl 8756:
8757: Check Versions
8758:
8759: =item mark_hash_old()
8760:
8761: =item is_hash_old()
8762:
8763: =item changewarning()
8764:
8765: =item init_breadcrumbs()
8766:
8767: Breadcrumbs for special functions
8768:
1.484 raeburn 8769: =item create_list_elements()
8770:
8771: =item create_form_ul()
8772:
8773: =item startContentScreen()
8774:
8775: =item endContentScreen()
8776:
8777: =item supplemental_base()
8778:
8779: =item embedded_form_elems()
8780:
8781: =item embedded_destination()
8782:
8783: =item return_to_editor()
8784:
8785: =item decompression_info()
8786:
8787: =item decompression_phase_one()
8788:
8789: =item decompression_phase_two()
8790:
8791: =item remove_archive()
8792:
8793: =item generate_admin_menu()
8794:
8795: =item generate_edit_table()
8796:
8797: =item editing_js()
8798:
8799: =item history_tab_js()
8800:
8801: =item inject_data_js()
8802:
8803: =item dump_switchserver_js()
8804:
1.484.2.3 raeburn 8805: =item resize_scrollbox_js()
1.484 raeburn 8806:
8807: =item makedocslogform()
8808:
1.484.2.3 raeburn 8809: =item makesimpleeditform()
8810:
1.329 droeschl 8811: =back
8812:
8813: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>