Annotation of loncom/interface/londocs.pm, revision 1.484.2.93.2.17
1.329 droeschl 1: # The LearningOnline Network
2: # Documents
3: #
1.484.2.93.2. 7(raebur 4:3): # $Id: londocs.pm,v 1.484.2.93.2.16 2023/10/06 14:21:05 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. 7(raebur 4608:3): my $checkencrypt;
(raeburn 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);
7(raebur 4628:3): my $shownurl = &Apache::lonenc::encrypted($url);
(raeburn 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:): }
7(raebur 4643:3): } else {
4644:3): $url = '';
(raeburn 4645:): }
4646:): unless ($env{'request.role.adv'}) {
4647:): if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4648:): $url = '';
4649:): }
4650:): if (&Apache::lonnet::EXT('resource.0.hiddenresource',$symb) =~ /^yes$/i) {
4651:): $url = '';
4652:): $hiddenres = 1;
4653:): }
4654:): }
7(raebur 4655:3): if (($url ne '') && ($shownsymb ne '')) {
4656:3): $url .= (($url=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
1.484.2.12 raeburn 4657: }
1.484.2.19 raeburn 4658: }
1.484.2.66 raeburn 4659: } elsif ($supplementalflag) {
4660: if ($isexternal) {
4661: if ($url =~ /^([^#]+)#([^#]+)$/) {
4662: $url = $1;
4663: $anchor = $2;
1.484.2.70 raeburn 4664: if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) {
1.484.2.93 raeburn 4665: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.484.2.80 raeburn 4666: if ($hostname ne '') {
4667: $url = 'http://'.$hostname.$url;
4668: }
4669: $url .= (($url =~ /\?/) ? '&':'?').'usehttp=1';
4670: }
1.484.2.70 raeburn 4671: $nomodal = 1;
4672: }
4673: }
4674: } elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
4675: if (($ENV{'SERVER_PORT'} == 443) &&
4676: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
1.484.2.93 raeburn 4677: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.484.2.80 raeburn 4678: if ($hostname ne '') {
4679: $url = 'http://'.$hostname.$url;
4680: }
4681: $url .= (($url =~ /\?/) ? '&':'?').'usehttp=1';
4682: }
1.484.2.70 raeburn 4683: $nomodal = 1;
1.484.2.66 raeburn 4684: }
1.484.2.93.2. 6(raebur 4685:3): } elsif (($uploaded) && ($url ne '/adm/supplemental?') && ($url ne '/adm/coursedocs?')) {
0(raebur 4686:3): my $embstyle=&Apache::loncommon::fileembstyle($extension);
4687:3): unless ($embstyle eq 'ssi') {
4688:3): if (($embstyle eq 'img')
4689:3): || ($embstyle eq 'emb')
4690:3): || ($embstyle eq 'wrp')) {
4691:3): $url='/adm/wrapper'.$url;
4692:3): } elsif ($url !~ /\.(sequence|page)$/) {
4693:3): $url='/adm/coursedocs/showdoc'.$url;
4694:3): }
4695:3): }
4696:3): }
4697:3): unless ($allowed && $env{'request.role.adv'}) {
4698:3): if ($ishidden || (&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4699:3): $hiddenres = 1;
4700:3): }
1.484.2.66 raeburn 4701: }
1.329 droeschl 4702: }
1.484.2.67 raeburn 4703: my ($rand_pick_text,$rand_order_text,$hiddenfolder);
4704: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.484.2.19 raeburn 4705: if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') {
1.329 droeschl 4706: my $foldername=&escape($foldertitle);
4707: my $folderpath=$env{'form.folderpath'};
4708: if ($folderpath) { $folderpath.='&' };
1.484.2.19 raeburn 4709: if (!$allowed && $supplementalflag) {
4710: $folderpath.=$containerarg.'&'.$foldername;
4711: $url.='folderpath='.&escape($folderpath);
1.484.2.93.2. 0(raebur 4712:3): if ($ishidden || (&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4713:3): $hiddenfolder = 1;
4714:3): }
1.484.2.19 raeburn 4715: } else {
4716: my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
4717: 'parameter_randompick'))[0];
1.484.2.67 raeburn 4718: my $randorder = ((&LONCAPA::map::getparameter($orderidx,
4719: 'parameter_randomorder'))[0]=~/^yes$/i);
4720: my $hiddenmap = ((&LONCAPA::map::getparameter($orderidx,
4721: 'parameter_hiddenresource'))[0]=~/^yes$/i);
4722: my $encryptmap = ((&LONCAPA::map::getparameter($orderidx,
4723: 'parameter_encrypturl'))[0]=~/^yes$/i);
4724: unless ($hiddenmap) {
1.484.2.70 raeburn 4725: if (ref($navmapref)) {
4726: unless (ref($$navmapref)) {
4727: $$navmapref = Apache::lonnavmaps::navmap->new();
4728: }
4729: if (ref($$navmapref)) {
4730: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
4731: my @resources = $$navmapref->retrieveResources($folderurl,$filterFunc,1,1);
4732: unless (@resources) {
4733: $hiddenmap = 1;
4734: unless ($env{'request.role.adv'}) {
4735: $url = '';
4736: $hiddenfolder = 1;
4737: }
1.484.2.67 raeburn 4738: }
4739: }
4740: }
4741: }
4742: }
4743: unless ($encryptmap) {
1.484.2.70 raeburn 4744: if ((ref($navmapref)) && (ref($$navmapref))) {
4745: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.encrypturl")) eq 'yes') {
4746: $encryptmap = 1;
4747: }
1.484.2.67 raeburn 4748: }
4749: }
4750:
4751: # Append randompick number, hidden, and encrypted with ":" to foldername,
4752: # so it gets transferred between levels
4753: $folderpath.=$containerarg.'&'.$foldername.
4754: ':'.$rpicknum.':'.$hiddenmap.':'.$encryptmap.':'.$randorder.':'.$ispage;
4755: unless ($url eq '') {
4756: $url.='folderpath='.&escape($folderpath);
4757: }
1.484.2.19 raeburn 4758: my $rpckchk;
4759: if ($rpicknum) {
4760: $rpckchk = ' checked="checked"';
1.484.2.30 raeburn 4761: if (($ishash) && (ref($filtersref->{'randompick'}) eq 'ARRAY')) {
4762: push(@{$filtersref->{'randompick'}},$orderidx.':'.$rpicknum);
4763: }
1.484.2.19 raeburn 4764: }
1.484.2.29 raeburn 4765: my $formname = 'edit_randompick_'.$orderidx;
1.484.2.19 raeburn 4766: $rand_pick_text =
1.478 raeburn 4767: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.484.2.30 raeburn 4768: $form_param."\n".
1.478 raeburn 4769: $form_common."\n".
1.484.2.67 raeburn 4770: '<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 4771: if ($rpicknum ne '') {
4772: $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
4773: }
1.484.2.29 raeburn 4774: $rand_pick_text .= '</span></span>'.
4775: $form_end;
1.484.2.30 raeburn 4776: my $ro_set;
1.484.2.67 raeburn 4777: if ($randorder) {
1.484.2.30 raeburn 4778: $ro_set = 'checked="checked"';
4779: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4780: push(@{$filtersref->{'randomorder'}},$orderidx);
4781: }
4782: }
1.484.2.41 raeburn 4783: $formname = 'edit_rorder_'.$orderidx;
1.484.2.19 raeburn 4784: $rand_order_text =
1.484.2.29 raeburn 4785: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.484.2.30 raeburn 4786: $form_param."\n".
1.484.2.29 raeburn 4787: $form_common."\n".
1.484.2.67 raeburn 4788: '<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 4789: $form_end;
1.484.2.19 raeburn 4790: }
1.484.2.93.2. 6(raebur 4791:3): } elsif ($supplementalflag) {
(raeburn 4792:): my $isexttool;
4793:): if ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4794:): $url='/adm/wrapper'.$url;
4795:): $isexttool = 1;
4796:): }
1.484.2.19 raeburn 4797: $url .= ($url =~ /\?/) ? '&':'?';
1.484.2.18 raeburn 4798: $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
1.484.2.19 raeburn 4799: if ($title) {
1.484.2.93.2. 0(raebur 4800:3): $url .= '&title='.$encodedtitle;
1.484.2.19 raeburn 4801: }
1.484.2.93.2. (raeburn 4802:): if ((($isexternal) || ($isexttool)) && $orderidx) {
1.484.2.19 raeburn 4803: $url .= '&idx='.$orderidx;
4804: }
1.484.2.66 raeburn 4805: if ($anchor ne '') {
4806: $url .= '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4807: }
1.329 droeschl 4808: }
1.484.2.19 raeburn 4809: my ($tdalign,$tdwidth);
1.484.2.12 raeburn 4810: if ($allowed) {
1.484.2.19 raeburn 4811: my $fileloc =
1.484.2.12 raeburn 4812: &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
1.484.2.19 raeburn 4813: if ($isexternal) {
4814: ($editlink,$extresform) =
1.484.2.67 raeburn 4815: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
1.484.2.93.2. (raeburn 4816:): undef,undef,undef,undef,undef,undef,
4817:): undef,$disabled);
4818:): } elsif ($orig_url =~ m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4819:): ($editlink,$extresform) =
4820:): &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
4821:): undef,undef,undef,'tool',$coursedom,
4822:): $coursenum,$ltitoolsref,$disabled);
1.484.2.19 raeburn 4823: } elsif (!$isfolder && !$ispage) {
4824: my ($cfile,$home,$switchserver,$forceedit,$forceview) =
1.484.2.14 raeburn 4825: &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
1.484.2.19 raeburn 4826: if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
1.484.2.66 raeburn 4827: my $suppanchor;
4828: if ($supplementalflag) {
4829: $suppanchor = $anchor;
4830: }
1.484.2.19 raeburn 4831: my $jscall =
1.484.2.12 raeburn 4832: &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
4833: $switchserver,
1.484.2.14 raeburn 4834: $forceedit,
1.484.2.93.2. (raeburn 4835:): undef,$symb,$shownsymb,
1.484.2.19 raeburn 4836: &escape($env{'form.folderpath'}),
1.484.2.80 raeburn 4837: $renametitle,$hostname,
4838: '','',1,$suppanchor);
1.484.2.12 raeburn 4839: if ($jscall) {
1.484.2.19 raeburn 4840: $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
4841: $jscall.'" >'.&mt('Edit').'</a> '."\n";
1.484.2.12 raeburn 4842: }
4843: }
4844: }
1.484.2.19 raeburn 4845: $tdalign = ' align="right" valign="top"';
4846: $tdwidth = ' width="80%"';
1.329 droeschl 4847: }
1.408 raeburn 4848: my $reinit;
4849: if ($crstype eq 'Community') {
4850: $reinit = &mt('(re-initialize community to access)');
4851: } else {
4852: $reinit = &mt('(re-initialize course to access)');
1.484.2.19 raeburn 4853: }
4854: $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;
1.484.2.93.2. 0(raebur 4855:3): my ($link,$nolink);
1.472 raeburn 4856: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.484.2.93.2. 0(raebur 4857:3): if ($allowed && !$env{'request.role.adv'} && !$isfolder && !$ispage) {
4858:3): if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4859:3): $nolink = 1;
4860:3): }
4861:3): }
4862:3): if ($nolink) {
4863:3): $line .= '<img src="'.$icon.'" alt="" class="LC_icon" /></a>';
4864:3): } else {
4865:3): $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
4866:3): }
1.469 www 4867: } elsif ($url) {
1.484.2.66 raeburn 4868: if ($anchor ne '') {
4869: if ($supplementalflag) {
4870: $anchor = '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4871: } else {
4872: $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');
4873: }
4874: }
1.484.2.93.2. 6(raebur 4875:3): if (($nomodal) && ($hostname ne '')) {
1.484.2.80 raeburn 4876: $link = 'http://'.$hostname.$url;
4877: } else {
4878: $link = $url;
4879: }
1.484.2.93.2. 6(raebur 4880:3): my $inhibitmenu;
4881:3): if ((($supplementalflag) && ($allowed) && ($url =~ m{^/adm/wrapper/})) ||
4882:3): (($allowed) && (($url =~ m{^/adm/(viewclasslist|$match_domain/$match_username/aboutme)(\?|$)}) ||
4883:3): ($url =~ m{^/public/$match_domain/$match_courseid/syllabus(\?|$)})))) {
4884:3): $inhibitmenu = 'only_body=1';
4885:3): } else {
4886:3): $inhibitmenu = 'inhibitmenu=yes';
4887:3): }
4888:3): $link = &js_escape($link.(($url=~/\?/)?'&':'?').$inhibitmenu.$anchor);
0(raebur 4889:3): if ($allowed && !$env{'request.role.adv'} && !$isfolder && !$ispage && !$uploaded) {
4890:3): if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4891:3): $nolink = 1;
4892:3): }
4893:3): }
4894:3): if ($nolink) {
4895:3): $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
4896:3): } elsif ($nomodal) {
1.484.2.70 raeburn 4897: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4898: '<img src="'.$icon.'" alt="" class="LC_icon" border="0" /></a>';
4899: } else {
4900: $line.=&Apache::loncommon::modal_link($link,
4901: '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
4902: }
1.469 www 4903: } else {
4904: $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
4905: }
1.484.2.19 raeburn 4906: $line.='</span></td><td'.$tdwidth.'>';
1.472 raeburn 4907: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.484.2.93.2. 0(raebur 4908:3): if ($nolink) {
4909:3): $line.=$title;
4910:3): } else {
4911:3): $line.='<a href="'.$url.'">'.$title.'</a>';
4912:3): }
4913:3): if (!$allowed && $supplementalflag && $canedit && $isfolder) {
4914:3): my $editicon = &Apache::loncommon::lonhttpdurl('/res/adm/pages').'/editmap.png';
4915:3): my $editurl = $url;
4916:3): $editurl =~ s{^\Q/adm/supplemental?\E}{/adm/coursedocs?command=direct&forcesupplement=1&};
4917:3): $line .= ' '.'<a href="'.$editurl.'">'.
4918:3): '<img src="'.$editicon.'" alt="'.&mt('Edit Content').'" title="'.&mt('Edit Content').'" />'.
4919:3): '</a>';
4920:3): }
4921:3): if ((($hiddenfolder) || ($hiddenres)) && (!$allowed) && ($supplementalflag)) {
4922:3): $line.= ' <span class="LC_warning">('.&mt('hidden').')</span> ';
4923:3): }
1.469 www 4924: } elsif ($url) {
1.484.2.93.2. 0(raebur 4925:3): if ($nolink) {
4926:3): $line.=$title;
4927:3): } elsif ($nomodal) {
1.484.2.70 raeburn 4928: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4929: $title.'</a>';
4930: } else {
4931: $line.=&Apache::loncommon::modal_link($link,$title,600,500);
4932: }
1.484.2.67 raeburn 4933: } elsif (($hiddenfolder) || ($hiddenres)) {
1.484.2.72 raeburn 4934: $line.=$title.' <span class="LC_warning LC_docs_reinit_warn">('.&mt('Hidden').')</span>';
1.469 www 4935: } else {
4936: $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
4937: }
1.484.2.19 raeburn 4938: $line.="$extresform</td>";
1.478 raeburn 4939: $rand_pick_text = ' ' if ($rand_pick_text eq '');
4940: $rand_order_text = ' ' if ($rand_order_text eq '');
1.484.2.93.2. 0(raebur 4941:3): if ($uploaded && $url && !$isfolder && !$ispage) {
4942:3): if (($plainurl ne '') && ($env{'request.role.adv'} || $allowed || !$hiddenres)) {
4943:3): &Apache::lonnet::allowuploaded('/adm/coursedoc',$plainurl);
1.484.2.30 raeburn 4944: }
1.484.2.93.2. 0(raebur 4945:3): }
4946:3): if ($allowed) {
4947:3): my %lt=&Apache::lonlocal::texthash(
4948:3): 'hd' => 'Hidden',
4949:3): 'ec' => 'URL hidden');
4950:3): my ($enctext,$hidtext,$formhidden,$formurlhidden);
1.484.2.30 raeburn 4951: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4952: $hidtext = ' checked="checked"';
1.484.2.93.2. (raeburn 4953:): if (($ishash) && (ref($filtersref->{'hiddenresource'}) eq 'ARRAY')) {
1.484.2.30 raeburn 4954: push(@{$filtersref->{'hiddenresource'}},$orderidx);
4955: }
4956: }
1.484.2.93.2. 0(raebur 4957:3): $formhidden = 'edit_hiddenresource_'.$orderidx;
4958:3): $line.=(<<ENDPARMS);
1.329 droeschl 4959: <td class="LC_docs_entry_parameter">
1.484.2.30 raeburn 4960: <form action="/adm/coursedocs" method="post" name="$formhidden">
4961: $form_param
1.478 raeburn 4962: $form_common
1.484.2.67 raeburn 4963: <label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'hiddenresource','settings');" $hidtext $disabled /> $lt{'hd'}</label>
1.329 droeschl 4964: $form_end
1.484.2.93.2. 0(raebur 4965:3): ENDPARMS
4966:3): if ($folder =~/^supplemental/) {
4967:3): $line.= "\n <td>";
4968:3): } else {
4969:3): if ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) {
4970:3): $enctext = ' checked="checked"';
4971:3): if (($ishash) && (ref($filtersref->{'encrypturl'}) eq 'ARRAY')) {
4972:3): push(@{$filtersref->{'encrypturl'}},$orderidx);
4973:3): }
4974:3): }
4975:3): $formurlhidden = 'edit_encrypturl_'.$orderidx;
4976:3): $line.=(<<ENDPARMS);
1.458 raeburn 4977: <br />
1.484.2.29 raeburn 4978: <form action="/adm/coursedocs" method="post" name="$formurlhidden">
1.484.2.30 raeburn 4979: $form_param
1.478 raeburn 4980: $form_common
1.484.2.67 raeburn 4981: <label><input type="checkbox" name="encrypturl_$orderidx" id="encrypturl_$orderidx" onclick="checkForSubmit(this.form,'encrypturl','settings');" $enctext $disabled /> $lt{'ec'}</label>
1.329 droeschl 4982: $form_end
4983: </td>
1.478 raeburn 4984: <td class="LC_docs_entry_parameter">$rand_pick_text<br />
4985: $rand_order_text</td>
1.329 droeschl 4986: ENDPARMS
1.484.2.93.2. 0(raebur 4987:3): }
1.329 droeschl 4988: }
1.379 bisitz 4989: $line.=&Apache::loncommon::end_data_table_row();
1.329 droeschl 4990: return $line;
4991: }
4992:
1.484.2.30 raeburn 4993: sub action_restrictions {
4994: my ($cnum,$cdom,$url,$folderpath,$currgroups) = @_;
4995: my %denied = (
4996: cut => 0,
4997: copy => 0,
4998: remove => 0,
4999: );
5000: if ($url=~ m{^/res/.+\.(page|sequence)$}) {
5001: # no copy for published maps
5002: $denied{'copy'} = 1;
1.484.2.82 raeburn 5003: } elsif ($url=~m{^/res/lib/templates/([^/]+)\.problem$}) {
5004: unless ($1 eq 'simpleproblem') {
5005: $denied{'copy'} = 1;
5006: }
5007: $denied{'cut'} = 1;
1.484.2.30 raeburn 5008: } elsif ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") {
5009: if ($folderpath =~ /^default&[^\&]+$/) {
5010: if ((ref($currgroups) eq 'HASH') && (keys(%{$currgroups}) > 0)) {
5011: $denied{'remove'} = 1;
5012: }
5013: $denied{'cut'} = 1;
5014: $denied{'copy'} = 1;
5015: }
5016: } elsif ($url =~ m{^\Q/uploaded/$cdom/$cnum/group_folder_\E(\w+)\.sequence$}) {
5017: my $group = $1;
5018: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+$/) {
5019: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
5020: $denied{'remove'} = 1;
5021: }
5022: }
5023: $denied{'cut'} = 1;
5024: $denied{'copy'} = 1;
5025: } elsif ($url =~ m{^\Q/adm/$cdom/$cnum/\E(\w+)/smppg$}) {
5026: my $group = $1;
5027: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&\Qgroup_folder_$group\E\&[^\&]+$/) {
5028: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
5029: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
5030: if (keys(%groupsettings) > 0) {
5031: $denied{'remove'} = 1;
5032: }
5033: $denied{'cut'} = 1;
5034: $denied{'copy'} = 1;
5035: }
5036: }
5037: } elsif ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&group_folder_(\w+)\&/) {
5038: my $group = $1;
5039: if ($url =~ /group_boards_\Q$group\E/) {
5040: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
5041: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
5042: if (keys(%groupsettings) > 0) {
5043: if (ref($groupsettings{'functions'}) eq 'HASH') {
5044: if ($groupsettings{'functions'}{'discussion'} eq 'on') {
5045: $denied{'remove'} = 1;
5046: }
5047: }
5048: }
5049: $denied{'cut'} = 1;
5050: $denied{'copy'} = 1;
5051: }
5052: }
5053: }
5054: return %denied;
5055: }
5056:
1.484.2.26 raeburn 5057: sub new_timebased_suffix {
1.484.2.30 raeburn 5058: my ($dom,$num,$type,$area,$container) = @_;
1.484.2.26 raeburn 5059: my ($prefix,$namespace,$idtype,$errtext,$locknotfreed);
1.484.2.30 raeburn 5060: if ($type eq 'paste') {
5061: $prefix = $type;
5062: $namespace = 'courseeditor';
1.484.2.56 raeburn 5063: $idtype = 'addcode';
1.484.2.30 raeburn 5064: } elsif ($type eq 'map') {
1.484.2.26 raeburn 5065: $prefix = 'docs';
5066: if ($area eq 'supplemental') {
5067: $prefix = 'supp';
5068: }
5069: $prefix .= $container;
5070: $namespace = 'uploadedmaps';
5071: } else {
5072: $prefix = $type;
5073: $namespace = 'templated';
1.484.2.15 raeburn 5074: }
5075: my ($suffix,$freedlock,$error) =
1.484.2.56 raeburn 5076: &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num,$idtype);
1.484.2.15 raeburn 5077: if (!$suffix) {
1.484.2.30 raeburn 5078: if ($type eq 'paste') {
5079: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.');
5080: } elsif ($type eq 'map') {
1.484.2.26 raeburn 5081: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
5082: } elsif ($type eq 'smppg') {
5083: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.');
1.484.2.93.2. (raeburn 5084:): } elsif ($type eq 'exttool') {
5085:): $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new external tool.');
1.484.2.26 raeburn 5086: } else {
1.484.2.42 raeburn 5087: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new discussion board.');
1.484.2.26 raeburn 5088: }
1.484.2.15 raeburn 5089: if ($error) {
5090: $errtext .= '<br />'.$error;
5091: }
5092: }
5093: if ($freedlock ne 'ok') {
1.484.2.26 raeburn 5094: $locknotfreed =
5095: '<div class="LC_error">'.
5096: &mt('There was a problem removing a lockfile.').' ';
1.484.2.30 raeburn 5097: if ($type eq 'paste') {
1.484.2.57 raeburn 5098: if ($freedlock eq 'nolock') {
5099: $locknotfreed =
5100: '<div class="LC_error">'.
5101: &mt('A lockfile was not released when you added content to the clipboard earlier in this session.').' '.
5102:
1.484.2.60 raeburn 5103: &mt('As a result addition of items to the clipboard will be unavailable until your next log-in.');
1.484.2.57 raeburn 5104: } else {
5105: $locknotfreed .=
5106: &mt('This will prevent addition of items to the clipboard until your next log-in.');
5107: }
1.484.2.30 raeburn 5108: } elsif ($type eq 'map') {
1.484.2.57 raeburn 5109: $locknotfreed .=
5110: &mt('This will prevent creation of additional folders or composite pages in this course.');
1.484.2.26 raeburn 5111: } elsif ($type eq 'smppg') {
5112: $locknotfreed .=
5113: &mt('This will prevent creation of additional simple pages in this course.');
1.484.2.93.2. (raeburn 5114:): } elsif ($type eq 'exttool') {
5115:): $locknotfreed .=
5116:): &mt('This will prevent creation of additional external tools in this course.');
1.484.2.26 raeburn 5117: } else {
5118: $locknotfreed .=
1.484.2.42 raeburn 5119: &mt('This will prevent creation of additional discussion boards in this course.');
1.484.2.26 raeburn 5120: }
1.484.2.30 raeburn 5121: unless ($type eq 'paste') {
5122: $locknotfreed .=
1.484.2.38 raeburn 5123: ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
5124: '<a href="/adm/helpdesk" target="_helpdesk">','</a>');
1.484.2.30 raeburn 5125: }
5126: $locknotfreed .= '</div>';
1.484.2.15 raeburn 5127: }
5128: return ($suffix,$errtext,$locknotfreed);
5129: }
5130:
1.329 droeschl 5131: =pod
5132:
5133: =item tiehash()
5134:
5135: tie the hash
5136:
5137: =cut
5138:
5139: sub tiehash {
5140: my ($mode)=@_;
5141: $hashtied=0;
5142: if ($env{'request.course.fn'}) {
5143: if ($mode eq 'write') {
5144: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
5145: &GDBM_WRCREAT(),0640)) {
5146: $hashtied=2;
5147: }
5148: } else {
5149: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
5150: &GDBM_READER(),0640)) {
5151: $hashtied=1;
5152: }
5153: }
1.364 bisitz 5154: }
1.329 droeschl 5155: }
5156:
5157: sub untiehash {
5158: if ($hashtied) { untie %hash; }
5159: $hashtied=0;
5160: return OK;
5161: }
5162:
5163:
5164:
5165:
5166: sub checkonthis {
1.484.2.78 raeburn 5167: my ($r,$url,$level,$title,$checkstale)=@_;
1.329 droeschl 5168: $url=&unescape($url);
5169: $alreadyseen{$url}=1;
5170: $r->rflush();
5171: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
5172: $r->print("\n<br />");
5173: if ($level==0) {
5174: $r->print("<br />");
5175: }
5176: for (my $i=0;$i<=$level*5;$i++) {
5177: $r->print(' ');
5178: }
5179: $r->print('<a href="'.$url.'" target="cat">'.
5180: ($title?$title:$url).'</a> ');
5181: if ($url=~/^\/res\//) {
1.484.2.78 raeburn 5182: my $updated;
5183: if (($checkstale) && ($url !~ m{^/res/lib/templates/}) &&
5184: ($url !~ /\.\d+\.\w+$/)) {
5185: $updated = &Apache::lonnet::remove_stale_resfile($url);
5186: }
1.329 droeschl 5187: my $result=&Apache::lonnet::repcopy(
5188: &Apache::lonnet::filelocation('',$url));
5189: if ($result eq 'ok') {
5190: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
1.484.2.78 raeburn 5191: if ($updated) {
5192: $r->print('<br />');
5193: for (my $i=0;$i<=$level*5;$i++) {
5194: $r->print(' ');
5195: }
5196: $r->print('- '.&mt('Outdated copy removed'));
5197: }
1.329 droeschl 5198: $r->rflush();
5199: &Apache::lonnet::countacc($url);
5200: $url=~/\.(\w+)$/;
5201: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
5202: $r->print('<br />');
5203: $r->rflush();
5204: for (my $i=0;$i<=$level*5;$i++) {
5205: $r->print(' ');
5206: }
5207: $r->print('- '.&mt('Rendering:').' ');
5208: my ($errorcount,$warningcount)=split(/:/,
5209: &Apache::lonnet::ssi_body($url,
5210: ('grade_target'=>'web',
5211: 'return_only_error_and_warning_counts' => 1)));
5212: if (($errorcount) ||
5213: ($warningcount)) {
5214: if ($errorcount) {
1.369 bisitz 5215: $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1.329 droeschl 5216: &mt('[quant,_1,error]',$errorcount).'</span>');
5217: }
5218: if ($warningcount) {
5219: $r->print('<span class="LC_warning">'.
5220: &mt('[quant,_1,warning]',$warningcount).'</span>');
5221: }
5222: } else {
5223: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
5224: }
5225: $r->rflush();
5226: }
5227: my $dependencies=
5228: &Apache::lonnet::metadata($url,'dependencies');
5229: foreach my $dep (split(/\,/,$dependencies)) {
5230: if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
1.484.2.78 raeburn 5231: &checkonthis($r,$dep,$level+1,'',$checkstale);
1.329 droeschl 5232: }
5233: }
5234: } elsif ($result eq 'unavailable') {
5235: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
5236: } elsif ($result eq 'not_found') {
5237: unless ($url=~/\$/) {
1.484.2.19 raeburn 5238: $r->print('<span class="LC_error">'.&mt('not found').'</span>');
1.329 droeschl 5239: } else {
1.366 bisitz 5240: $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1.329 droeschl 5241: }
5242: } else {
5243: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
5244: }
1.484.2.78 raeburn 5245: if (($updated) && ($result ne 'ok')) {
5246: $r->print('<br />'.&mt('Outdated copy removed'));
5247: }
1.329 droeschl 5248: }
5249: }
5250: }
5251:
5252:
5253:
5254: =pod
5255:
5256: =item list_symbs()
5257:
1.484.2.3 raeburn 5258: List Content Identifiers
1.329 droeschl 5259:
5260: =cut
5261:
5262: sub list_symbs {
5263: my ($r) = @_;
5264:
1.408 raeburn 5265: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 5266: $r->print(&Apache::loncommon::start_page('List of Content Identifiers'));
5267: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Identifiers'));
5268: $r->print(&startContentScreen('tools'));
1.329 droeschl 5269: my $navmap = Apache::lonnavmaps::navmap->new();
5270: if (!defined($navmap)) {
5271: $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
5272: '<div class="LC_error">'.
5273: &mt('Unable to retrieve information about course contents').
5274: '</div>');
1.408 raeburn 5275: &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
1.329 droeschl 5276: } else {
1.484 raeburn 5277: $r->print('<h4 class="LC_info">'.&mt("$crstype Content Identifiers").'</h4>'.
5278: &Apache::loncommon::start_data_table().
5279: &Apache::loncommon::start_data_table_header_row().
5280: '<th>'.&mt('Title').'</th><th>'.&mt('Identifier').'</th>'.
5281: &Apache::loncommon::end_data_table_header_row()."\n");
5282: my $count;
1.329 droeschl 5283: foreach my $res ($navmap->retrieveResources()) {
1.484 raeburn 5284: $r->print(&Apache::loncommon::start_data_table_row().
5285: '<td>'.$res->compTitle().'</td>'.
5286: '<td>'.$res->symb().'</td>'.
1.484.2.19 raeburn 5287: &Apache::loncommon::end_data_table_row());
1.484 raeburn 5288: $count ++;
5289: }
5290: if (!$count) {
5291: $r->print(&Apache::loncommon::start_data_table_row().
5292: '<td colspan="2">'.&mt("$crstype is empty").'</td>'.
5293: &Apache::loncommon::end_data_table_row());
1.329 droeschl 5294: }
1.484 raeburn 5295: $r->print(&Apache::loncommon::end_data_table());
1.329 droeschl 5296: }
1.484.2.19 raeburn 5297: $r->print(&endContentScreen());
1.329 droeschl 5298: }
5299:
1.484.2.93.2. (raeburn 5300:): sub short_urls {
5301:): my ($r,$canedit) = @_;
5302:): my $crstype = &Apache::loncommon::course_type();
5303:): my $formname = 'shortenurl';
5304:): $r->print(&Apache::loncommon::start_page('Display/Set Shortened URLs'));
5305:): $r->print(&Apache::lonhtmlcommon::breadcrumbs('Shortened URLs'));
5306:): $r->print(&startContentScreen('tools'));
5307:): my ($navmap,$errormsg) =
5308:): &Apache::loncourserespicker::get_navmap_object($crstype,'shorturls');
5309:): my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
5310:): my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
5311:): my (%maps,%resources,%titles);
5312:): if (!ref($navmap)) {
5313:): $r->print($errormsg.
5314:): &endContentScreen());
5315:): return '';
5316:): } else {
5317:): $r->print('<h4 class="LC_info">'.&mt('Tiny URLs for deep-linking into course').'</h4>'."\n");
5318:): $r->rflush();
5319:): my $readonly;
5320:): if ($canedit) {
5321:): my ($numnew,$errors) = &Apache::loncommon::get_requested_shorturls($cdom,$cnum,$navmap);
5322:): if ($numnew) {
5323:): $r->print('<p class="LC_info">'.&mt('Created [quant,_1,URL]',$numnew).'</p>');
5324:): }
5325:): if ((ref($errors) eq 'ARRAY') && (@{$errors} > 0)) {
5326:): $r->print(&mt('The following errors occurred when processing your request to create shortened URLs:').'<br /><ul>');
5327:): foreach my $error (@{$errors}) {
5328:): $r->print('<li>'.$error.'</li>');
5329:): }
5330:): $r->print('</ul><br />');
5331:): }
5332:): } else {
5333:): $readonly = 1;
5334:): }
5335:): my %currtiny = &Apache::lonnet::dump('tiny',$cdom,$cnum);
5336:): $r->print(&Apache::loncourserespicker::create_picker($navmap,'shorturls',$formname,$crstype,undef,
5337:): undef,undef,undef,undef,undef,\%currtiny,$readonly));
5338:): }
5339:): $r->print(&endContentScreen());
5340:): }
5341:):
1.484.2.78 raeburn 5342: sub contentverifyform {
5343: my ($r) = @_;
5344: my $crstype = &Apache::loncommon::course_type();
5345: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
5346: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
5347: $r->print(&startContentScreen('tools'));
5348: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
5349: $r->print('<form method="post" action="/adm/coursedocs"><p>'.
5350: &mt('Include a check if files copied from elsewhere are up to date (will increase verification time)?').
5351: ' <span class="LC_nobreak">'.
5352: '<label><input type="radio" name="checkstale" value="0" checked="checked" />'.
5353: &mt('No').'</label>'.(' 'x2).
5354: '<label><input type="radio" name="checkstale" value="1" />'.
5355: &mt('Yes').'</label></span></p><p>'.
1.484.2.90 raeburn 5356: '<input type="submit" value="'.&mt('Verify Content').' "/>'.
1.484.2.78 raeburn 5357: '<input type="hidden" value="1" name="tools" />'.
5358: '<input type="hidden" value="1" name="verify" /></p></form>');
5359: $r->print(&endContentScreen());
5360: return;
5361: }
1.329 droeschl 5362:
5363: sub verifycontent {
1.484.2.78 raeburn 5364: my ($r,$checkstale) = @_;
1.408 raeburn 5365: my $crstype = &Apache::loncommon::course_type();
1.484.2.34 raeburn 5366: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
5367: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
1.484 raeburn 5368: $r->print(&startContentScreen('tools'));
5369: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
1.329 droeschl 5370: $hashtied=0;
5371: undef %alreadyseen;
5372: %alreadyseen=();
5373: &tiehash();
1.484 raeburn 5374:
1.329 droeschl 5375: foreach my $key (keys(%hash)) {
5376: if ($hash{$key}=~/\.(page|sequence)$/) {
5377: if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
5378: $r->print('<hr /><span class="LC_error">'.
1.419 bisitz 5379: &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
1.329 droeschl 5380: &unescape($hash{$key}).'</span><br />'.
1.419 bisitz 5381: &mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />');
1.329 droeschl 5382: }
5383: }
5384: if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
1.484.2.78 raeburn 5385: &checkonthis($r,$hash{$key},0,$hash{'title_'.$1},$checkstale);
1.329 droeschl 5386: }
5387: }
5388: &untiehash();
1.442 www 5389: $r->print('<p class="LC_success">'.&mt('Done').'</p>');
1.484.2.19 raeburn 5390: $r->print(&endContentScreen());
1.329 droeschl 5391: }
5392:
5393:
5394: sub devalidateversioncache {
5395: my $src=shift;
5396: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
5397: &Apache::lonnet::clutter($src));
5398: }
5399:
5400: sub checkversions {
1.484.2.67 raeburn 5401: my ($r,$canedit) = @_;
1.408 raeburn 5402: my $crstype = &Apache::loncommon::course_type();
1.484.2.44 raeburn 5403: $r->print(&Apache::loncommon::start_page("Check $crstype Resource Versions"));
5404: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Resource Versions"));
1.484 raeburn 5405: $r->print(&startContentScreen('tools'));
1.442 www 5406:
1.329 droeschl 5407: my $header='';
5408: my $startsel='';
5409: my $monthsel='';
5410: my $weeksel='';
5411: my $daysel='';
5412: my $allsel='';
5413: my %changes=();
5414: my $starttime=0;
5415: my $haschanged=0;
5416: my %setversions=&Apache::lonnet::dump('resourceversions',
5417: $env{'course.'.$env{'request.course.id'}.'.domain'},
5418: $env{'course.'.$env{'request.course.id'}.'.num'});
5419:
5420: $hashtied=0;
5421: &tiehash();
1.484.2.67 raeburn 5422: if ($canedit) {
5423: my %newsetversions=();
5424: if ($env{'form.setmostrecent'}) {
5425: $haschanged=1;
5426: foreach my $key (keys(%hash)) {
5427: if ($key=~/^ids\_(\/res\/.+)$/) {
5428: $newsetversions{$1}='mostrecent';
5429: &devalidateversioncache($1);
5430: }
1.329 droeschl 5431: }
1.484.2.67 raeburn 5432: } elsif ($env{'form.setcurrent'}) {
5433: $haschanged=1;
5434: foreach my $key (keys(%hash)) {
5435: if ($key=~/^ids\_(\/res\/.+)$/) {
5436: my $getvers=&Apache::lonnet::getversion($1);
5437: if ($getvers>0) {
5438: $newsetversions{$1}=$getvers;
5439: &devalidateversioncache($1);
5440: }
5441: }
1.329 droeschl 5442: }
1.484.2.67 raeburn 5443: } elsif ($env{'form.setversions'}) {
5444: $haschanged=1;
5445: foreach my $key (keys(%env)) {
5446: if ($key=~/^form\.set_version_(.+)$/) {
5447: my $src=$1;
5448: if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
5449: $newsetversions{$src}=$env{$key};
5450: &devalidateversioncache($src);
5451: }
5452: }
1.329 droeschl 5453: }
1.484.2.67 raeburn 5454: }
5455: if ($haschanged) {
5456: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
5457: $env{'course.'.$env{'request.course.id'}.'.domain'},
5458: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
5459: $r->print(&Apache::loncommon::confirmwrapper(
5460: &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
5461: } else {
5462: $r->print(&Apache::loncommon::confirmwrapper(
5463: &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
5464: }
5465: &mark_hash_old();
5466: }
5467: &changewarning($r,'');
1.329 droeschl 5468: }
5469: if ($env{'form.timerange'} eq 'all') {
5470: # show all documents
1.484.2.34 raeburn 5471: $header=&mt('All content in '.$crstype);
1.484.2.19 raeburn 5472: $allsel=' selected="selected"';
1.329 droeschl 5473: foreach my $key (keys(%hash)) {
5474: if ($key=~/^ids\_(\/res\/.+)$/) {
5475: my $src=$1;
5476: $changes{$src}=1;
5477: }
5478: }
5479: } else {
5480: # show documents which changed
5481: %changes=&Apache::lonnet::dump
5482: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
5483: $env{'course.'.$env{'request.course.id'}.'.num'});
5484: my $firstkey=(keys(%changes))[0];
5485: unless ($firstkey=~/^error\:/) {
5486: unless ($env{'form.timerange'}) {
5487: $env{'form.timerange'}=604800;
5488: }
5489: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
5490: .&mt('seconds');
5491: if ($env{'form.timerange'}==-1) {
5492: $seltext='since start of course';
1.484.2.19 raeburn 5493: $startsel=' selected="selected"';
1.329 droeschl 5494: $env{'form.timerange'}=time;
5495: }
5496: $starttime=time-$env{'form.timerange'};
5497: if ($env{'form.timerange'}==2592000) {
5498: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 5499: $monthsel=' selected="selected"';
1.329 droeschl 5500: } elsif ($env{'form.timerange'}==604800) {
5501: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 5502: $weeksel=' selected="selected"';
1.329 droeschl 5503: } elsif ($env{'form.timerange'}==86400) {
5504: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 5505: $daysel=' selected="selected"';
1.329 droeschl 5506: }
5507: $header=&mt('Content changed').' '.$seltext;
5508: } else {
5509: $header=&mt('No content modifications yet.');
5510: }
5511: }
5512: %setversions=&Apache::lonnet::dump('resourceversions',
5513: $env{'course.'.$env{'request.course.id'}.'.domain'},
5514: $env{'course.'.$env{'request.course.id'}.'.num'});
5515: my %lt=&Apache::lonlocal::texthash
1.408 raeburn 5516: ('st' => 'Version changes since start of '.$crstype,
1.329 droeschl 5517: 'lm' => 'Version changes since last Month',
5518: 'lw' => 'Version changes since last Week',
5519: 'sy' => 'Version changes since Yesterday',
5520: 'al' => 'All Resources (possibly large output)',
1.484 raeburn 5521: 'cd' => 'Change display',
1.329 droeschl 5522: 'sd' => 'Display',
5523: 'fi' => 'File',
5524: 'md' => 'Modification Date',
5525: 'mr' => 'Most recently published Version',
1.408 raeburn 5526: 've' => 'Version used in '.$crstype,
5527: 'vu' => 'Set Version to be used in '.$crstype,
5528: 'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
1.329 droeschl 5529: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
5530: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.479 golterma 5531: 'di' => 'Differences',
1.484 raeburn 5532: 'save' => 'Save changes',
5533: 'vers' => 'Version choice(s) for specific resources',
1.479 golterma 5534: 'act' => 'Actions');
1.484.2.67 raeburn 5535: my ($disabled,$readonly);
5536: unless ($canedit) {
5537: $disabled = 'disabled="disabled"';
5538: $readonly = 1;
5539: }
1.329 droeschl 5540: $r->print(<<ENDHEADERS);
1.484 raeburn 5541: <h4 class="LC_info">$header</h4>
1.329 droeschl 5542: <form action="/adm/coursedocs" method="post">
5543: <input type="hidden" name="versions" value="1" />
1.484 raeburn 5544: <div class="LC_left_float">
1.479 golterma 5545: <fieldset>
1.484 raeburn 5546: <legend>$lt{'cd'}</legend>
1.329 droeschl 5547: <select name="timerange">
1.484.2.19 raeburn 5548: <option value='all'$allsel>$lt{'al'}</option>
5549: <option value="-1"$startsel>$lt{'st'}</option>
5550: <option value="2592000"$monthsel>$lt{'lm'}</option>
5551: <option value="604800"$weeksel>$lt{'lw'}</option>
5552: <option value="86400"$daysel>$lt{'sy'}</option>
1.329 droeschl 5553: </select>
5554: <input type="submit" name="display" value="$lt{'sd'}" />
1.484 raeburn 5555: </fieldset>
5556: </div>
5557: <div class="LC_left_float">
5558: <fieldset>
5559: <legend>$lt{'act'}</legend>
1.484.2.67 raeburn 5560: $lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" $disabled /><br />
5561: $lt{'sc'}: <input type="submit" name="setcurrent" value="Go" $disabled />
1.484 raeburn 5562: </fieldset>
5563: </div>
5564: <br clear="all" />
5565: <hr />
5566: <h4>$lt{'vers'}</h4>
1.329 droeschl 5567: ENDHEADERS
1.479 golterma 5568: #number of columns for version history
1.484.2.44 raeburn 5569: my %changedbytime;
5570: foreach my $key (keys(%changes)) {
5571: #excludes not versionable problems from resource version history:
5572: next if ($key =~ /^\/res\/lib\/templates/);
5573: my $chg;
5574: if ($env{'form.timerange'} eq 'all') {
5575: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
5576: $chg = &Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate');
5577: } else {
5578: $chg = $changes{$key};
5579: next if ($chg < $starttime);
5580: }
5581: push(@{$changedbytime{$chg}},$key);
5582: }
5583: if (keys(%changedbytime) == 0) {
5584: &untiehash();
5585: $r->print(&mt('No content changes in imported content in specified time frame').
5586: &endContentScreen());
5587: return;
5588: }
1.479 golterma 5589: $r->print(
1.484.2.67 raeburn 5590: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.484.2.19 raeburn 5591: &Apache::loncommon::start_data_table().
5592: &Apache::loncommon::start_data_table_header_row().
5593: '<th>'.&mt('Resources').'</th>'.
5594: "<th>$lt{'mr'}</th>".
5595: "<th>$lt{'ve'}</th>".
5596: "<th>$lt{'vu'}</th>".
5597: '<th>'.&mt('History').'</th>'.
5598: &Apache::loncommon::end_data_table_header_row()
5599: );
1.484.2.44 raeburn 5600: foreach my $chg (sort {$b <=> $a } keys(%changedbytime)) {
5601: foreach my $key (sort(@{$changedbytime{$chg}})) {
5602: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
5603: my $currentversion=&Apache::lonnet::getversion($key);
5604: if ($currentversion<0) {
5605: $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
5606: }
5607: my $linkurl=&Apache::lonnet::clutter($key);
5608: $r->print(
5609: &Apache::loncommon::start_data_table_row().
5610: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br />'.
5611: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
5612: '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br />('.
5613: &Apache::lonlocal::locallocaltime($chg).')</span></td>'.
5614: '<td align="right">'
5615: );
5616: # Used in course
5617: my $usedversion=$hash{'version_'.$linkurl};
5618: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.484.2.19 raeburn 5619: if ($usedversion != $currentversion) {
1.479 golterma 5620: $r->print('<span class="LC_warning">'.$usedversion.'</span>');
1.484.2.19 raeburn 5621: } else {
1.479 golterma 5622: $r->print($usedversion);
5623: }
1.329 droeschl 5624: } else {
1.484.2.19 raeburn 5625: $r->print($currentversion);
1.329 droeschl 5626: }
1.484.2.44 raeburn 5627: $r->print('</td><td title="'.$lt{'vu'}.'">');
5628: # Set version
5629: $r->print(&Apache::loncommon::select_form(
5630: $setversions{$linkurl},
5631: 'set_version_'.$linkurl,
5632: {'select_form_order' => ['',1..$currentversion,'mostrecent'],
5633: '' => '',
5634: 'mostrecent' => &mt('most recent'),
1.484.2.67 raeburn 5635: map {$_,$_} (1..$currentversion)},'',$readonly));
1.484.2.44 raeburn 5636: my $lastold=1;
5637: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
5638: my $url=$root.'.'.$prevvers.'.'.$extension;
5639: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) {
5640: $lastold=$prevvers;
5641: }
5642: }
5643: $r->print('</td>');
5644: # List all available versions
5645: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
5646: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
5647: my $url=$root.'.'.$prevvers.'.'.$extension;
1.484.2.19 raeburn 5648: $r->print(
1.484.2.44 raeburn 5649: '<span class="LC_nobreak">'
5650: .'<a href="'.&Apache::lonnet::clutter($url).'">'
5651: .&mt('Version [_1]',$prevvers).'</a>'
5652: .' ('.&Apache::lonlocal::locallocaltime(
5653: &Apache::lonnet::metadata($url,'lastrevisiondate'))
5654: .')');
5655: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
5656: $r->print(
5657: ' <a href="/adm/diff?filename='.
5658: &Apache::lonnet::clutter($root.'.'.$extension).
5659: &HTML::Entities::encode('&versionone='.$prevvers,'"<>&').
5660: '" target="diffs">'.&mt('Diffs').'</a>');
5661: }
5662: $r->print('</span><br />');
1.329 droeschl 5663: }
1.484.2.44 raeburn 5664: $r->print('</span></td>'.&Apache::loncommon::end_data_table_row());
1.484.2.19 raeburn 5665: }
1.329 droeschl 5666: }
1.484.2.19 raeburn 5667: $r->print(
5668: &Apache::loncommon::end_data_table().
1.484.2.67 raeburn 5669: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.484.2.19 raeburn 5670: '</form>'
5671: );
1.329 droeschl 5672:
5673: &untiehash();
1.484.2.19 raeburn 5674: $r->print(&endContentScreen());
1.484.2.44 raeburn 5675: return;
1.329 droeschl 5676: }
5677:
5678: sub mark_hash_old {
5679: my $retie_hash=0;
5680: if ($hashtied) {
5681: $retie_hash=1;
5682: &untiehash();
5683: }
5684: &tiehash('write');
5685: $hash{'old'}=1;
5686: &untiehash();
5687: if ($retie_hash) { &tiehash(); }
5688: }
5689:
5690: sub is_hash_old {
5691: my $untie_hash=0;
5692: if (!$hashtied) {
5693: $untie_hash=1;
5694: &tiehash();
5695: }
5696: my $return=$hash{'old'};
5697: if ($untie_hash) { &untiehash(); }
5698: return $return;
5699: }
5700:
5701: sub changewarning {
5702: my ($r,$postexec,$message,$url)=@_;
5703: if (!&is_hash_old()) { return; }
5704: my $pathvar='folderpath';
5705: my $path=&escape($env{'form.folderpath'});
5706: if (!defined($url)) {
5707: $url='/adm/coursedocs?'.$pathvar.'='.$path;
5708: }
5709: my $course_type = &Apache::loncommon::course_type();
5710: if (!defined($message)) {
5711: $message='Changes will become active for your current session after [_1], or the next time you log in.';
5712: }
1.484.2.93.2. 2(raebur 5713:3): my $windowname = 'loncapaclient';
5714:3): if ($env{'request.lti.login'}) {
5715:3): $windowname .= 'lti';
5716:3): }
1.329 droeschl 5717: $r->print("\n\n".
1.372 bisitz 5718: '<script type="text/javascript">'."\n".
5719: '// <![CDATA['."\n".
5720: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
5721: '// ]]>'."\n".
1.369 bisitz 5722: '</script>'."\n".
1.484.2.93.2. 2(raebur 5723:3): '<form name="reinitform" method="post" action="/adm/roles" target="'.$windowname.'">'.
1.329 droeschl 5724: '<input type="hidden" name="orgurl" value="'.$url.
1.372 bisitz 5725: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
1.329 droeschl 5726: &mt($message,' <input type="hidden" name="'.
5727: $env{'request.role'}.'" value="1" /><input type="button" value="'.
1.369 bisitz 5728: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1.372 bisitz 5729: $help{'Caching'}.'</p></form>'."\n\n");
1.329 droeschl 5730: }
5731:
5732:
5733: sub init_breadcrumbs {
1.484.2.44 raeburn 5734: my ($form,$text,$help)=@_;
1.329 droeschl 5735: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484 raeburn 5736: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
1.405 bisitz 5737: text=>&Apache::loncommon::course_type().' Editor',
1.329 droeschl 5738: faq=>273,
5739: bug=>'Instructor Interface',
1.484.2.44 raeburn 5740: help => $help});
1.329 droeschl 5741: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
5742: text=>$text,
5743: faq=>273,
5744: bug=>'Instructor Interface'});
5745: }
5746:
1.441 www 5747: # subroutine to list form elements
5748: sub create_list_elements {
5749: my @formarr = @_;
5750: my $list = '';
1.484.2.12 raeburn 5751: foreach my $button (@formarr){
5752: foreach my $picture (keys(%{$button})) {
5753: $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
1.441 www 5754: }
5755: }
5756: return $list;
5757: }
1.329 droeschl 5758:
1.441 www 5759: # subroutine to create ul from list elements
5760: sub create_form_ul {
5761: my $list = shift;
5762: my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
5763: return $ul;
5764: }
1.329 droeschl 5765:
1.442 www 5766: #
5767: # Start tabs
5768: #
5769:
5770: sub startContentScreen {
1.484 raeburn 5771: my ($mode) = @_;
5772: my $output = '<ul class="LC_TabContentBigger" id="mainnav">';
1.472 raeburn 5773: if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
1.484 raeburn 5774: $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n";
5775: $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n";
5776: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
5777: } else {
1.484.2.34 raeburn 5778: $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 5779: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
5780: $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>'."\n";
5781: '><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>';
5782: }
5783: $output .= "\n".'</ul>'."\n";
5784: $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
5785: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
5786: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
5787: return $output;
1.442 www 5788: }
5789:
5790: #
5791: # End tabs
5792: #
5793:
5794: sub endContentScreen {
1.484 raeburn 5795: return '</div></div></div>';
1.442 www 5796: }
1.329 droeschl 5797:
1.446 www 5798: sub supplemental_base {
1.484.2.33 raeburn 5799: return 'supplemental&'.&escape(&mt('Supplemental Content'));
1.446 www 5800: }
5801:
1.329 droeschl 5802: sub handler {
5803: my $r = shift;
5804: &Apache::loncommon::content_type($r,'text/html');
5805: $r->send_http_header;
5806: return OK if $r->header_only;
1.484 raeburn 5807:
5808: # get course data
1.408 raeburn 5809: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 5810: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
5811: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5812:
5813: # graphics settings
5814: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329 droeschl 5815:
1.443 www 5816: #
1.329 droeschl 5817: # --------------------------------------------- Initialize help topics for this
5818: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
1.484.2.93.2. (raeburn 5819:): 'Adding_External_Resource','Adding_External_Tool',
5820:): 'Navigate_Content','Adding_Folders','Docs_Overview',
5821:): 'Load_Map','Supplemental','Score_Upload_Form',
5822:): 'Adding_Pages','Importing_LON-CAPA_Resource',
5823:): 'Importing_IMS_Course','Uploading_From_Harddrive',
5824:): 'Course_Roster','Web_Page','Dropbox','Simple_Problem') {
1.329 droeschl 5825: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
5826: }
5827: # Composite help files
5828: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
5829: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
5830: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
5831: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
5832: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
5833: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 5834: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 5835: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 5836: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 5837: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1.484.2.30 raeburn 5838:
1.484.2.67 raeburn 5839: my ($allowed,$canedit,$canview,$disabled);
1.484.2.93.2. 0(raebur 5840:3): # does this user have privileges to modify content.
5841:3): if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
1.472 raeburn 5842: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
1.484.2.93.2. 0(raebur 5843:3): unless ($r->uri eq '/adm/supplemental') {
1.484.2.67 raeburn 5844: $allowed = 1;
1.484.2.93.2. 0(raebur 5845:3): }
5846:3): $canedit = 1;
5847:3): $canview = 1;
5848:3): } elsif (&Apache::lonnet::allowed('cev',$env{'request.course.id'})) {
5849:3): # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
5850:3): unless ($r->uri eq '/adm/supplemental') {
1.484.2.67 raeburn 5851: $allowed = 1;
5852: }
1.484.2.93.2. 0(raebur 5853:3): $canview = 1;
1.484.2.67 raeburn 5854: }
5855: unless ($canedit) {
5856: $disabled = ' disabled="disabled"';
1.472 raeburn 5857: }
1.484.2.53 raeburn 5858: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']);
1.484.2.78 raeburn 5859: if ($env{'form.inhibitmenu'}) {
5860: unless ($env{'form.inhibitmenu'} eq 'yes') {
5861: delete($env{'form.inhibitmenu'});
5862: }
5863: }
5864:
1.484.2.53 raeburn 5865: if ($allowed && $env{'form.verify'}) {
1.484.2.44 raeburn 5866: &init_breadcrumbs('verify','Verify Content','Docs_Verify_Content');
1.484.2.78 raeburn 5867: if (!$canedit) {
5868: &verifycontent($r);
5869: } elsif (($env{'form.checkstale'} ne '') && ($env{'form.checkstale'} =~ /^\d$/)) {
5870: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1&verify=1&checkstale=$env{'form.checkstale'}",
5871: text=>'Results',
5872: faq=>273,
5873: bug=>'Instructor Interface'});
5874: &verifycontent($r,$env{'form.checkstale'});
5875: } else {
5876: &contentverifyform($r);
5877: }
1.329 droeschl 5878: } elsif ($allowed && $env{'form.listsymbs'}) {
1.484 raeburn 5879: &init_breadcrumbs('listsymbs','List Content IDs');
1.329 droeschl 5880: &list_symbs($r);
1.484.2.93.2. (raeburn 5881:): } elsif ($allowed && $env{'form.shorturls'}) {
5882:): &init_breadcrumbs('shorturls','Set/Display Shortened URLs','Docs_Short_URLs');
5883:): &short_urls($r,$canedit);
1.329 droeschl 5884: } elsif ($allowed && $env{'form.docslog'}) {
5885: &init_breadcrumbs('docslog','Show Log');
1.484 raeburn 5886: my $folder = $env{'form.folder'};
5887: if ($folder eq '') {
5888: $folder='default';
5889: }
1.484.2.67 raeburn 5890: &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit);
1.329 droeschl 5891: } elsif ($allowed && $env{'form.versions'}) {
1.484.2.44 raeburn 5892: &init_breadcrumbs('versions','Check/Set Resource Versions','Docs_Check_Resource_Versions');
1.484.2.67 raeburn 5893: &checkversions($r,$canedit);
5894: } elsif ($canedit && $env{'form.dumpcourse'}) {
1.484.2.43 raeburn 5895: &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329 droeschl 5896: &dumpcourse($r);
5897: } elsif ($allowed && $env{'form.exportcourse'}) {
1.377 bisitz 5898: &init_breadcrumbs('exportcourse','IMS Export');
1.475 raeburn 5899: &Apache::imsexport::exportcourse($r);
1.329 droeschl 5900: } else {
1.445 www 5901: #
5902: # Done catching special calls
1.484 raeburn 5903: # The whole rest is for course and supplemental documents and utilities menu
1.445 www 5904: # Get the parameters that may be needed
5905: #
5906: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.484.2.93.2. 0(raebur 5907:3): ['folderpath','title',
1.484.2.19 raeburn 5908: 'forcesupplement','forcestandard',
5909: 'tools','symb','command','supppath']);
1.445 www 5910:
1.484.2.78 raeburn 5911: foreach my $item ('forcesupplement','forcestandard','tools') {
5912: next if ($env{'form.'.$item} eq '');
5913: unless ($env{'form.'.$item} eq '1') {
5914: delete($env{'form.'.$item});
5915: }
5916: }
5917:
5918: if ($env{'form.command'}) {
5919: unless ($env{'form.command'} =~ /^(direct|directnav|editdocs|editsupp|contents|home)$/) {
5920: delete($env{'form.command'});
5921: }
5922: }
5923:
5924: if ($env{'form.symb'}) {
5925: my ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.symb'});
5926: unless (($id =~ /^\d+$/) && (&Apache::lonnet::is_on_map($resurl))) {
5927: delete($env{'form.symb'});
5928: }
5929: }
5930:
1.445 www 5931: # standard=1: this is a "new-style" course with an uploaded map as top level
5932: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329 droeschl 5933:
5934: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445 www 5935:
1.484 raeburn 5936: # Decide whether this should display supplemental or main content or utilities
1.445 www 5937: # supplementalflag=1: show supplemental documents
5938: # supplementalflag=0: show standard documents
1.484 raeburn 5939: # toolsflag=1: show utilities
1.445 www 5940:
1.484.2.39 raeburn 5941: my $unesc_folderpath = &unescape($env{'form.folderpath'});
5942: my $supplementalflag=($unesc_folderpath=~/^supplemental/);
5943: if (($unesc_folderpath=~/^default/) || ($unesc_folderpath eq "")) {
1.445 www 5944: $supplementalflag=0;
5945: }
5946: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
5947: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
1.484.2.93.2. 6(raebur 5948:3): unless (($supplementalflag) ||
5949:3): ($r->uri =~ m{^/adm/coursedocs/showdoc/uploaded/\Q$coursedom\E/\Q$coursenum\E/docs/})) {
5950:3): unless ($allowed) { $supplementalflag=1; }
5951:3): unless ($standard) { $supplementalflag=1; }
5952:3): }
1.484 raeburn 5953: my $toolsflag=0;
5954: if ($env{'form.tools'}) { $toolsflag=1; }
1.445 www 5955:
1.484.2.78 raeburn 5956: if ($env{'form.folderpath'} ne '') {
1.484.2.93.2. 0(raebur 5957:3): &Apache::loncommon::validate_folderpath($supplementalflag,$allowed,$coursenum,$coursedom);
1.484.2.78 raeburn 5958: }
5959:
1.484.2.93.2. 0(raebur 5960:3): my $backto_supppath;
1.484.2.78 raeburn 5961: if ($env{'form.supppath'} ne '') {
1.484.2.93.2. 0(raebur 5962:3): if ($supplementalflag && $allowed) {
5963:3): $backto_supppath = &validate_supppath($coursenum,$coursedom);
5964:3): }
1.484.2.78 raeburn 5965: }
5966:
1.329 droeschl 5967: my $script='';
5968: my $showdoc=0;
1.457 raeburn 5969: my $addentries = {};
1.475 raeburn 5970: my $container;
1.329 droeschl 5971: my $containertag;
1.484.2.17 raeburn 5972: my $pathitem;
1.484.2.93.2. (raeburn 5973:): my %ltitools;
2(raebur 5974:3): my $posslti;
1.484.2.67 raeburn 5975: my $hiddentop;
5976: my $navmap;
5977: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.329 droeschl 5978:
1.464 www 5979: # Do we directly jump somewhere?
1.484.2.21 raeburn 5980: if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
1.472 raeburn 5981: if ($env{'form.symb'} ne '') {
1.484.2.19 raeburn 5982: $env{'form.folderpath'}=
1.484.2.67 raeburn 5983: &Apache::loncommon::symb_to_docspath($env{'form.symb'},\$navmap);
1.484.2.21 raeburn 5984: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
5985: $env{'form.command'}.'_'.$env{'form.symb'}});
1.484.2.93.2. 0(raebur 5986:3): } elsif (($env{'form.supppath'} ne '') && $supplementalflag && $allowed) {
1.472 raeburn 5987: $env{'form.folderpath'}=$env{'form.supppath'};
1.484.2.21 raeburn 5988: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
1.484.2.93.2. 0(raebur 5989:3): $env{'form.command'}.'_'.$backto_supppath});
1.466 www 5990: }
1.472 raeburn 5991: } elsif ($env{'form.command'} eq 'editdocs') {
1.484.2.67 raeburn 5992: $env{'form.folderpath'} = &default_folderpath($coursenum,$coursedom,\$navmap);
1.484.2.21 raeburn 5993: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
1.472 raeburn 5994: } elsif ($env{'form.command'} eq 'editsupp') {
1.484.2.67 raeburn 5995: $env{'form.folderpath'} = &supplemental_base();
1.484.2.21 raeburn 5996: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
5997: } elsif ($env{'form.command'} eq 'contents') {
5998: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
5999: } elsif ($env{'form.command'} eq 'home') {
6000: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
1.464 www 6001: }
6002:
1.484.2.23 raeburn 6003:
1.445 www 6004: # Where do we store these for when we come back?
6005: my $stored_folderpath='docs_folderpath';
6006: if ($supplementalflag) {
6007: $stored_folderpath='docs_sup_folderpath';
6008: }
1.464 www 6009:
1.484.2.19 raeburn 6010: # No folderpath, and in edit mode, see if we have something stored
6011: if ((!$env{'form.folderpath'}) && $allowed) {
1.445 www 6012: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.484.2.19 raeburn 6013: {'folderpath' => 'scalar'});
1.484.2.67 raeburn 6014:
6015: if (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
6016: if ($supplementalflag) {
6017: undef($env{'form.folderpath'}) if ($1 eq 'default');
6018: } else {
6019: undef($env{'form.folderpath'}) if ($1 eq 'supplemental');
6020: }
6021: } else {
1.484.2.19 raeburn 6022: undef($env{'form.folderpath'});
6023: }
1.484.2.92 raeburn 6024: if ($env{'form.folderpath'} ne '') {
1.484.2.93.2. 0(raebur 6025:3): &Apache::loncommon::validate_folderpath($supplementalflag,$allowed,$coursenum,$coursedom);
1.484.2.92 raeburn 6026: }
1.329 droeschl 6027: }
1.484.2.93.2. 6(raebur 6028:3):
6029:3): # If we are not allowed to make changes and this is supplemental content set folderpath
6030:3): if ((!$allowed) && ($supplementalflag)) {
1.446 www 6031: unless ($env{'form.folderpath'} =~ /^supplemental/) {
6032: $env{'form.folderpath'} = &supplemental_base();
1.409 raeburn 6033: }
6034: }
1.446 www 6035: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329 droeschl 6036: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446 www 6037: $env{'form.folderpath'} = &supplemental_base()
6038: .'&'.
1.329 droeschl 6039: $env{'form.folderpath'};
6040: }
1.484.2.67 raeburn 6041: # If allowed and user's role is not advanced check folderpath is not hidden
1.484.2.93.2. 0(raebur 6042:3): my $hidden_and_empty;
6043:3): if (($allowed) && (!$env{'request.role.adv'}) && ($env{'form.folderpath'} ne '')) {
6044:3): my ($folderurl,$foldername,$hiddenfolder);
1.484.2.67 raeburn 6045: my @pathitems = split(/\&/,$env{'form.folderpath'});
6046: my $folder = $pathitems[-2];
6047: if ($folder eq '') {
6048: undef($env{'form.folderpath'});
6049: } else {
6050: $folderurl = "uploaded/$coursedom/$coursenum/$folder";
1.484.2.87 raeburn 6051: if ((split(/\:/,$pathitems[-1]))[5]) {
1.484.2.67 raeburn 6052: $folderurl .= '.page';
6053: } else {
6054: $folderurl .= '.sequence';
6055: }
1.484.2.93.2. 0(raebur 6056:3): if ($supplementalflag) {
6057:3): ($foldername,$hiddenfolder) = ($pathitems[-1] =~ /^([^:]*)::(|1):::$/);
6058:3): $foldername = &HTML::Entities::decode(&unescape($foldername));
6059:3): my ($supplemental) = &Apache::loncommon::get_supplemental($coursenum,$coursedom);
6060:3): if (ref($supplemental) eq 'HASH') {
6061:3): my ($suppmap,$suppmapnum);
6062:3): if ($folder eq 'supplemental') {
6063:3): $suppmap = 'default';
6064:3): $suppmapnum = 0;
6065:3): } elsif ($folder =~ /^supplemental_(\d+)$/) {
6066:3): $suppmap = $1;
6067:3): $suppmapnum = $suppmap;
6068:3): }
6069:3): if ($hiddenfolder) {
6070:3): my $hascontent;
6071:3): foreach my $key (reverse(sort(keys(%{$supplemental->{'ids'}})))) {
6072:3): if ($key =~ m{^\Q/uploaded/$coursedom/$coursenum/supplemental/$suppmap/\E}) {
6073:3): $hascontent = 1;
6074:3): } elsif (ref($supplemental->{'ids'}->{$key}) eq 'ARRAY') {
6075:3): foreach my $id (@{$supplemental->{'ids'}->{$key}}) {
6076:3): if ($id =~ /^$suppmapnum\:/) {
6077:3): $hascontent = 1;
6078:3): last;
6079:3): }
6080:3): }
6081:3): }
6082:3): last if ($hascontent);
6083:3): }
6084:3): unless ($hascontent) {
6085:3): if ($foldername ne '') {
6086:3): $hidden_and_empty = $foldername;
6087:3): } else {
6088:3): $hidden_and_empty = $folder;
6089:3): }
6090:3): }
1.484.2.67 raeburn 6091: }
6092: }
1.484.2.93.2. 0(raebur 6093:3): } else {
6094:3): unless (ref($navmap)) {
6095:3): $navmap = Apache::lonnavmaps::navmap->new();
6096:3): }
6097:3): ($foldername,$hiddenfolder) = ($pathitems[-1] =~ /^([^:]*):|\d+:|1:(|1):|1:|1$/);
6098:3): $foldername = &HTML::Entities::decode(&unescape($foldername));
6099:3): if (ref($navmap)) {
6100:3): if ($hiddenfolder ||
6101:3): (lc($navmap->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes')) {
6102:3): my @resources = $navmap->retrieveResources($folderurl,$filterFunc,1,1);
6103:3): unless (@resources) {
6104:3): if ($foldername ne '') {
6105:3): $hidden_and_empty = $foldername;
6106:3): } else {
6107:3): $hidden_and_empty = $folder;
6108:3): }
6109:3): }
6110:3): }
6111:3): }
6112:3): }
6113:3): if ($hidden_and_empty ne '') {
6114:3): splice(@pathitems,-2);
6115:3): if (@pathitems) {
6116:3): $env{'form.folderpath'} = join('&',@pathitems);
6117:3): } else {
6118:3): undef($env{'form.folderpath'});
6119:3): }
1.484.2.67 raeburn 6120: }
6121: }
6122: }
6123:
1.446 www 6124: # If after all of this, we still don't have any paths, make them
1.484.2.19 raeburn 6125: unless ($env{'form.folderpath'}) {
1.446 www 6126: if ($supplementalflag) {
6127: $env{'form.folderpath'}=&supplemental_base();
1.484.2.67 raeburn 6128: } elsif ($allowed) {
6129: ($env{'form.folderpath'},$hiddentop) = &default_folderpath($coursenum,$coursedom,\$navmap);
1.446 www 6130: }
1.472 raeburn 6131: }
1.446 www 6132:
1.445 www 6133: # Store this
1.484 raeburn 6134: unless ($toolsflag) {
1.484.2.67 raeburn 6135: if (($allowed) && ($env{'form.folderpath'} ne '')) {
1.484.2.19 raeburn 6136: &Apache::loncommon::store_course_settings($stored_folderpath,
6137: {'folderpath' => 'scalar'});
6138: }
6139: my $folderpath;
1.484 raeburn 6140: if ($env{'form.folderpath'}) {
1.484.2.19 raeburn 6141: $folderpath = $env{'form.folderpath'};
6142: my (@folders)=split('&',$env{'form.folderpath'});
6143: $env{'form.foldername'}=&unescape(pop(@folders));
6144: if ($env{'form.foldername'} =~ /\:1$/) {
6145: $container = 'page';
6146: } else {
6147: $container = 'sequence';
6148: }
6149: $env{'form.folder'}=pop(@folders);
1.484 raeburn 6150: } else {
1.484.2.19 raeburn 6151: if ($env{'form.folder'} eq '' ||
6152: $env{'form.folder'} eq 'supplemental') {
1.484.2.67 raeburn 6153: if ($env{'form.folder'} eq 'supplemental') {
6154: $folderpath=&supplemental_base();
6155: } elsif (!$hiddentop) {
6156: $folderpath='default&'.
6157: &escape(&mt('Main Content').':::::');
6158: }
1.484 raeburn 6159: }
6160: }
1.484.2.19 raeburn 6161: $containertag = '<input type="hidden" name="folderpath" value="" />';
6162: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 6163: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
6164: $showdoc='/'.$1;
6165: }
6166: if ($showdoc) { # got called in sequence from course
6167: $allowed=0;
6168: } else {
1.484.2.67 raeburn 6169: if ($canedit) {
1.484 raeburn 6170: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
6171: $script=&Apache::lonratedt::editscript('simple');
1.433 raeburn 6172: }
6173: }
1.329 droeschl 6174: }
6175:
1.344 bisitz 6176: # get personal data
1.329 droeschl 6177: my $uname=$env{'user.name'};
6178: my $udom=$env{'user.domain'};
6179: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
6180:
6181: if ($allowed) {
1.484 raeburn 6182: if ($toolsflag) {
6183: $script .= &inject_data_js();
6184: my ($home,$other,%outhash)=&authorhosts();
6185: if (!$home && $other) {
6186: my @hosts;
6187: foreach my $aurole (keys(%outhash)) {
6188: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
6189: push(@hosts,$outhash{$aurole});
6190: }
6191: }
6192: $script .= &dump_switchserver_js(@hosts);
6193: }
1.458 raeburn 6194: } else {
1.484.2.43 raeburn 6195: my $tid = 1;
1.484 raeburn 6196: my @tabids;
6197: if ($supplementalflag) {
6198: @tabids = ('002','ee2','ff2');
1.484.2.43 raeburn 6199: $tid = 2;
1.484 raeburn 6200: } else {
6201: @tabids = ('aa1','bb1','cc1','ff1');
1.484.2.19 raeburn 6202: unless ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 6203: unshift(@tabids,'001');
6204: push(@tabids,('dd1','ee1'));
6205: }
1.458 raeburn 6206: }
1.484 raeburn 6207: my $tabidstr = join("','",@tabids);
1.484.2.93.2. 2(raebur 6208:3): my (%domtools,%crstools);
6209:3): my %tooltypes = &Apache::loncommon::usable_exttools();
6210:3): if ($tooltypes{'dom'}) {
6211:3): %domtools = &Apache::lonnet::get_domain_lti($coursedom,'consumer');
6212:3): }
6213:3): if ($tooltypes{'crs'}) {
6214:3): %crstools = &Apache::lonnet::get_course_lti($coursenum,$coursedom,'consumer');
6215:3): }
6216:3): %ltitools = (
6217:3): dom => \%domtools,
6218:3): crs => \%crstools,
6219:3): );
6220:3): $posslti = scalar(keys(%domtools)) + scalar(keys(%crstools));
1.484.2.80 raeburn 6221: my $hostname = $r->hostname();
1.484.2.93.2. (raeburn 6222:): $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
1.484.2.80 raeburn 6223: $canedit,$hostname,\$navmap).
1.484 raeburn 6224: &history_tab_js().
6225: &inject_data_js().
1.484.2.43 raeburn 6226: &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
1.484.2.93.2. (raeburn 6227:): &Apache::lonextresedit::extedit_javascript(\%ltitools);
0(raebur 6228:3): my $onload = "javascript:resize_scrollbox('contentscroll','1','1');";
6229:3): if ($hidden_and_empty ne '') {
6230:3): my $alert = &mt("Additional privileges required to edit empty and hidden folder: '[_1]'",
6231:3): $hidden_and_empty);
6232:3): $onload .= "javascript:alert('".&js_escape($alert)."');";
6233:3): }
1.484 raeburn 6234: $addentries = {
1.484.2.93.2. 0(raebur 6235:3): onload => $onload,
1.484 raeburn 6236: };
1.458 raeburn 6237: }
1.484.2.30 raeburn 6238: $script .= &paste_popup_js();
1.484.2.12 raeburn 6239: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
6240: &mt('Switch server?');
1.484.2.19 raeburn 6241:
6242:
1.329 droeschl 6243: }
6244: # -------------------------------------------------------------------- Body tag
1.369 bisitz 6245: $script = '<script type="text/javascript">'."\n"
1.372 bisitz 6246: .'// <![CDATA['."\n"
6247: .$script."\n"
6248: .'// ]]>'."\n"
1.484.2.81 raeburn 6249: .'</script>'."\n"
6250: .'<script type="text/javascript" src="/res/adm/includes/file_upload.js"></script>'."\n";
1.385 bisitz 6251:
6252: # Breadcrumbs
6253: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484.2.19 raeburn 6254:
6255: if ($showdoc) {
1.484.2.93.2. 0(raebur 6256:3): my $args;
6257:3): if ($supplementalflag) {
6258:3): my $title = &HTML::Entities::encode($env{'form.title'},'\'"<>&');
6259:3): my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
6(raebur 6260:3): $args = {'bread_crumbs' => $brcrum,
6261:3): 'bread_crumbs_nomenu' => 1};
0(raebur 6262:3): } else {
6263:3): $args = {'force_register' => $showdoc};
6264:3): }
6265:3): $r->print(&Apache::loncommon::start_page("$crstype documents",undef,$args));
1.484.2.44 raeburn 6266: } elsif ($toolsflag) {
1.484.2.67 raeburn 6267: my ($breadtext,$breadtitle);
6268: $breadtext = "$crstype Editor";
6269: if ($canedit) {
6270: $breadtitle = 'Editing '.$crstype.' Contents';
6271: } else {
6272: $breadtext .= ' (View-only mode)';
6273: $breadtitle = 'Viewing '.$crstype.' Contents';
6274: }
1.484.2.44 raeburn 6275: &Apache::lonhtmlcommon::add_breadcrumb({
1.484.2.67 raeburn 6276: href=>"/adm/coursedocs",text=>$breadtext});
1.484.2.44 raeburn 6277: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script)
6278: .&Apache::loncommon::help_open_menu('','',273,'RAT')
6279: .&Apache::lonhtmlcommon::breadcrumbs(
1.484.2.67 raeburn 6280: $breadtitle)
1.484.2.44 raeburn 6281: );
1.484.2.19 raeburn 6282: } elsif ($r->uri eq '/adm/supplemental') {
1.484.2.93.2. 0(raebur 6283:3): unless ($env{'request.role.adv'}) {
6284:3): unless (&Apache::lonnet::has_unhidden_suppfiles($coursenum,$coursedom)) {
6285:3): $r->internal_redirect('/adm/navmaps');
6286:3): return OK;
6287:3): }
6288:3): }
1.484.2.19 raeburn 6289: my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
1.484.2.93.2. 6(raebur 6290:3): my $args = {'bread_crumbs' => $brcrum};
6291:3): unless (($env{'form.folderpath'} eq '') ||
6292:3): ($env{'form.folder'} eq 'supplemental')) {
6293:3): $args->{'bread_crumbs_nomenu'} = 1;
6294:3): }
1.484.2.19 raeburn 6295: $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
1.484.2.93.2. 6(raebur 6296:3): $args));
1.484.2.19 raeburn 6297: } else {
1.484.2.67 raeburn 6298: my ($breadtext,$breadtitle,$helpitem);
6299: $breadtext = "$crstype Editor";
6300: if ($canedit) {
6301: $breadtitle = 'Editing '.$crstype.' Contents';
6302: $helpitem = 'Docs_Adding_Course_Doc';
6303: } else {
6304: $breadtext .= ' (View-only mode)';
6305: $breadtitle = 'Viewing '.$crstype.' Contents';
6306: $helpitem = 'Docs_Viewing_Course_Doc';
6307: }
1.392 raeburn 6308: &Apache::lonhtmlcommon::add_breadcrumb({
1.484.2.67 raeburn 6309: href=>"/adm/coursedocs",text=>$breadtext});
1.446 www 6310: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.484.2.19 raeburn 6311: {'add_entries' => $addentries}
6312: )
1.392 raeburn 6313: .&Apache::loncommon::help_open_menu('','',273,'RAT')
6314: .&Apache::lonhtmlcommon::breadcrumbs(
1.484.2.67 raeburn 6315: $breadtitle,
6316: $helpitem)
1.392 raeburn 6317: );
6318: }
1.364 bisitz 6319:
1.329 droeschl 6320: my %allfiles = ();
6321: my %codebase = ();
1.440 raeburn 6322: my ($upload_result,$upload_output,$uploadphase);
1.484.2.67 raeburn 6323: if ($canedit) {
1.484.2.93.2. 0(raebur 6324:3): undef($suppchanges);
1.329 droeschl 6325: if (($env{'form.uploaddoc.filename'}) &&
6326: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440 raeburn 6327: my $context = $1;
6328: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 6329: undef($hadchanges);
1.440 raeburn 6330: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
1.484.2.36 raeburn 6331: \%allfiles,\%codebase,$context,$crstype);
1.484.2.73 raeburn 6332: undef($navmap);
1.329 droeschl 6333: if ($hadchanges) {
6334: &mark_hash_old();
6335: }
1.484.2.93.2. 0(raebur 6336:3): if ($suppchanges) {
6337:3): &Apache::lonnet::update_supp_caches($coursedom,$coursenum);
6338:3): undef($suppchanges);
6339:3): }
1.440 raeburn 6340: $r->print($upload_output);
6341: } elsif ($env{'form.phase'} eq 'upload_embedded') {
6342: # Process file upload - phase two - upload embedded objects
6343: $uploadphase = 'check_embedded';
6344: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
6345: my $state = &embedded_form_elems($uploadphase,$primaryurl,
6346: $env{'form.newidx'});
6347: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
6348: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
6349: my ($destination,$dir_root) = &embedded_destination();
6350: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
6351: my $actionurl = '/adm/coursedocs';
6352: my ($result,$flag) =
6353: &Apache::loncommon::upload_embedded('coursedoc',$destination,
6354: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
6355: $actionurl);
6356: $r->print($result.&return_to_editor());
6357: } elsif ($env{'form.phase'} eq 'check_embedded') {
6358: # Process file upload - phase three - modify references in HTML file
6359: $uploadphase = 'modified_orightml';
6360: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
6361: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
6362: my ($destination,$dir_root) = &embedded_destination();
1.482 raeburn 6363: my $result =
6364: &Apache::loncommon::modify_html_refs('coursedoc',$destination,
6365: $docuname,$docudom,undef,
6366: $dir_root);
6367: $r->print($result.&return_to_editor());
1.476 raeburn 6368: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
6369: $uploadphase = 'decompress_phase_one';
6370: $r->print(&decompression_phase_one().
6371: &return_to_editor());
6372: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
6373: $uploadphase = 'decompress_phase_two';
6374: $r->print(&decompression_phase_two().
6375: &return_to_editor());
1.329 droeschl 6376: }
6377: }
6378:
1.484 raeburn 6379: if ($allowed && $toolsflag) {
6380: $r->print(&startContentScreen('tools'));
1.484.2.67 raeburn 6381: $r->print(&generate_admin_menu($crstype,$canedit));
1.484 raeburn 6382: $r->print(&endContentScreen());
6383: } elsif ((!$showdoc) && (!$uploadphase)) {
1.329 droeschl 6384: # -----------------------------------------------------------------------------
6385: my %lt=&Apache::lonlocal::texthash(
6386: 'copm' => 'All documents out of a published map into this folder',
1.484.2.12 raeburn 6387: 'upfi' => 'Upload File',
1.484.2.36 raeburn 6388: 'upld' => 'Upload Content',
1.329 droeschl 6389: 'srch' => 'Search',
6390: 'impo' => 'Import',
1.484.2.19 raeburn 6391: 'lnks' => 'Import from Stored Links',
1.484.2.13 raeburn 6392: 'impm' => 'Import from Assembled Map',
1.484.2.93.2. (raeburn 6393:): 'extr' => 'External Resource',
6394:): 'extt' => 'External Tool',
1.329 droeschl 6395: 'selm' => 'Select Map',
6396: 'load' => 'Load Map',
6397: 'newf' => 'New Folder',
6398: 'newp' => 'New Composite Page',
6399: 'syll' => 'Syllabus',
1.425 raeburn 6400: 'navc' => 'Table of Contents',
1.343 biermanm 6401: 'sipa' => 'Simple Course Page',
1.329 droeschl 6402: 'sipr' => 'Simple Problem',
1.484.2.27 raeburn 6403: 'webp' => 'Blank Web Page (editable)',
1.329 droeschl 6404: 'drbx' => 'Drop Box',
1.451 www 6405: 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336 schafran 6406: 'bull' => 'Discussion Board',
1.347 weissno 6407: 'mypi' => 'My Personal Information Page',
1.353 weissno 6408: 'grpo' => 'Group Portfolio',
1.329 droeschl 6409: 'rost' => 'Course Roster',
1.484.2.22 raeburn 6410: 'abou' => 'Personal Information Page for a User',
1.484.2.36 raeburn 6411: 'imsf' => 'IMS Upload',
6412: 'imsl' => 'Upload IMS package',
1.484.2.12 raeburn 6413: 'cms' => 'Origin of IMS package',
6414: 'se' => 'Select',
1.484.2.19 raeburn 6415: 'file' => 'File',
1.329 droeschl 6416: 'title' => 'Title',
6417: 'comment' => 'Comment',
1.403 raeburn 6418: 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.484.2.50 raeburn 6419: 'bb5' => 'Blackboard 5',
6420: 'bb6' => 'Blackboard 6',
6421: 'angel5' => 'ANGEL 5.5',
6422: 'webctce4' => 'WebCT 4 Campus Edition',
1.484.2.67 raeburn 6423: 'er' => 'Editing rights unavailable for your current role.',
1.484.2.50 raeburn 6424: );
1.329 droeschl 6425: # -----------------------------------------------------------------------------
1.484.2.82 raeburn 6426: # Calculate free quota space for a user or course. A javascript function checks
6427: # file size to determine if upload should be allowed.
1.484.2.64 raeburn 6428: my $quotatype = 'unofficial';
6429: if ($crstype eq 'Community') {
6430: $quotatype = 'community';
6431: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
6432: $quotatype = 'official';
6433: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
6434: $quotatype = 'textbook';
6435: }
6436: my $disk_quota = &Apache::loncommon::get_user_quota($coursenum,$coursedom,
6437: 'course',$quotatype); # expressed in MB
6438: my $current_disk_usage = 0;
6439: foreach my $subdir ('docs','supplemental') {
6440: $current_disk_usage += &Apache::lonnet::diskusage($coursedom,$coursenum,
6441: "userfiles/$subdir",1); # expressed in kB
6442: }
6443: my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage);
6444: my $usage = $current_disk_usage/1024; # in MB
6445: my $quota = $disk_quota;
6446: my $percent;
6447: if ($disk_quota == 0) {
6448: $percent = 100.0;
6449: } else {
1.484.2.69 raeburn 6450: $percent = 100*($usage/$disk_quota);
1.484.2.64 raeburn 6451: }
6452: $usage = sprintf("%.2f",$usage);
6453: $quota = sprintf("%.2f",$quota);
6454: $percent = sprintf("%.0f",$percent);
6455: my $quotainfo = '<p>'.&mt('Currently using [_1] of the [_2] available.',
6456: $percent.'%',$quota.' MB').'</p>';
6457:
1.329 droeschl 6458: my $fileupload=(<<FIUP);
1.484.2.64 raeburn 6459: $quotainfo
1.329 droeschl 6460: $lt{'file'}:<br />
6461: FIUP
6462: my $checkbox=(<<CHBO);
6463: <!-- <label>$lt{'parse'}?
6464: <input type="checkbox" name="parserflag" />
6465: </label> -->
6466: <label>
1.484.2.67 raeburn 6467: <input type="checkbox" name="parserflag" checked="checked" $disabled /> $lt{'parse'}
1.329 droeschl 6468: </label>
6469: CHBO
1.484.2.12 raeburn 6470: my $imsfolder = $env{'form.folder'};
6471: if ($imsfolder eq '') {
1.484.2.19 raeburn 6472: $imsfolder = 'default';
1.484.2.12 raeburn 6473: }
6474: my $imspform=(<<IMSFORM);
6475: <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
6476: $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
6477: <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
1.484.2.19 raeburn 6478: <fieldset id="uploadimsform" style="display: none;">
1.484.2.12 raeburn 6479: <legend>$lt{'imsf'}</legend>
6480: $fileupload
1.484.2.93.2. 3(raebur 6481:3): <input type="file" name="uploaddoc" id="uploaddocims" class="LC_flUpload LC_uploaddoc" size="40" $disabled />
6482:3): <input type="hidden" id="LC_free_space_ims" value="$free_space" />
1.484.2.12 raeburn 6483: <br />
6484: <p>
1.484.2.19 raeburn 6485: $lt{'cms'}:
1.484.2.67 raeburn 6486: <select name="source" $disabled>
1.484.2.12 raeburn 6487: <option value="-1" selected="selected">$lt{'se'}</option>
1.484.2.50 raeburn 6488: <option value="bb5">$lt{'bb5'}</option>
6489: <option value="bb6">$lt{'bb6'}</option>
6490: <option value="angel5">$lt{'angel5'}</option>
6491: <option value="webctce4">$lt{'webctce4'}</option>
1.484.2.12 raeburn 6492: </select>
6493: <input type="hidden" name="folder" value="$imsfolder" />
6494: </p>
6495: <input type="hidden" name="phase" value="one" />
1.484.2.67 raeburn 6496: <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" $disabled />
1.484.2.12 raeburn 6497: </fieldset>
6498: </form>
6499: IMSFORM
6500:
1.484.2.19 raeburn 6501: my $fileuploadform=(<<FUFORM);
1.484.2.12 raeburn 6502: <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
6503: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
6504: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.484.2.19 raeburn 6505: <fieldset id="uploaddocform" style="display: none;">
1.484.2.12 raeburn 6506: <legend>$lt{'upfi'}</legend>
1.371 tempelho 6507: <input type="hidden" name="active" value="aa" />
1.329 droeschl 6508: $fileupload
1.484.2.93.2. 3(raebur 6509:3): <input type="file" name="uploaddoc" class="LC_flUpload" size="40" $disabled />
6510:3): <input type="hidden" id="LC_free_space" value="$free_space" />
1.329 droeschl 6511: <br />
6512: $lt{'title'}:<br />
1.484.2.67 raeburn 6513: <input type="text" size="60" name="comment" $disabled />
1.484.2.17 raeburn 6514: $pathitem
1.329 droeschl 6515: <input type="hidden" name="cmd" value="upload_default" />
6516: <br />
1.458 raeburn 6517: <span class="LC_nobreak" style="float:left">
1.329 droeschl 6518: $checkbox
6519: </span>
1.484.2.12 raeburn 6520: <br clear="all" />
1.484.2.67 raeburn 6521: <input type="submit" value="$lt{'upld'}" $disabled />
1.484.2.12 raeburn 6522: </fieldset>
6523: </form>
1.383 tempelho 6524: FUFORM
1.329 droeschl 6525:
1.484.2.67 raeburn 6526: my $mapimportjs;
6527: if ($canedit) {
6528: $mapimportjs = "javascript:openbrowser('mapimportform','importmap','sequence,page','');";
6529: } else {
6530: $mapimportjs = "javascript:alert('".&js_escape($lt{'er'})."');";
6531: }
1.484.2.19 raeburn 6532: my $importpubform=(<<SEDFFORM);
6533: <a class="LC_menubuttons_link" href="javascript:toggleMap('map');">
1.484.2.13 raeburn 6534: $lt{'impm'}</a>$help{'Load_Map'}
1.484.2.19 raeburn 6535: <form action="/adm/coursedocs" method="post" name="mapimportform">
6536: <fieldset id="importmapform" style="display: none;">
1.484.2.13 raeburn 6537: <legend>$lt{'impm'}</legend>
1.484.2.19 raeburn 6538: <input type="hidden" name="active" value="bb" />
1.484.2.13 raeburn 6539: $lt{'copm'}<br />
6540: <span class="LC_nobreak">
1.484.2.19 raeburn 6541: <input type="text" name="importmap" size="40" value=""
1.484.2.67 raeburn 6542: onfocus="this.blur();$mapimportjs" $disabled />
6543: <a href="$mapimportjs">$lt{'selm'}</a></span><br />
6544: <input type="submit" name="loadmap" value="$lt{'load'}" $disabled />
1.484.2.13 raeburn 6545: </fieldset>
6546: </form>
6547:
1.383 tempelho 6548: SEDFFORM
1.484.2.67 raeburn 6549:
6550: my $fromstoredjs;
6551: if ($canedit) {
6552: $fromstoredjs = 'open_StoredLinks_Import()';
6553: } else {
6554: $fromstoredjs = "alert('".&js_escape($lt{'er'})."')";
6555: }
6556:
1.484.2.19 raeburn 6557: my @importpubforma = (
6558: { '<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 6559: { '<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 6560: { '<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 6561: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform }
6562: );
6563: $importpubform = &create_form_ul(&create_list_elements(@importpubforma));
6564: my $extresourcesform =
6565: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
1.484.2.67 raeburn 6566: $help{'Adding_External_Resource'},
1.484.2.93.2. (raeburn 6567:): undef,undef,undef,undef,undef,undef,$disabled);
6568:): my $exttoolform =
6569:): &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
6570:): $help{'Adding_External_Tool'},undef,
6571:): undef,'tool',$coursedom,$coursenum,
6572:): \%ltitools,$disabled);
1.329 droeschl 6573: if ($allowed) {
1.484.2.7 raeburn 6574: my $folder = $env{'form.folder'};
6575: if ($folder eq '') {
6576: $folder='default';
6577: }
1.484.2.67 raeburn 6578: if ($canedit) {
6579: my $output = &update_paste_buffer($coursenum,$coursedom,$folder);
6580: if ($output) {
6581: $r->print($output);
6582: }
1.484.2.30 raeburn 6583: }
1.337 ehlerst 6584: $r->print(<<HIDDENFORM);
6585: <form name="renameform" method="post" action="/adm/coursedocs">
6586: <input type="hidden" name="title" />
6587: <input type="hidden" name="cmd" />
6588: <input type="hidden" name="markcopy" />
6589: <input type="hidden" name="copyfolder" />
6590: $containertag
6591: </form>
1.484 raeburn 6592:
1.337 ehlerst 6593: HIDDENFORM
1.484.2.17 raeburn 6594: $r->print(&makesimpleeditform($pathitem)."\n".
6595: &makedocslogform($pathitem."\n".
1.484 raeburn 6596: '<input type="hidden" name="folder" value="'.
6597: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 6598: }
1.442 www 6599:
6600: # Generate the tabs
1.484.2.19 raeburn 6601: my ($mode,$needs_end);
1.472 raeburn 6602: if (($supplementalflag) && (!$allowed)) {
1.484.2.19 raeburn 6603: my @folders = split('&',$env{'form.folderpath'});
6604: unless (@folders > 2) {
6605: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
6606: $needs_end = 1;
6607: }
1.472 raeburn 6608: } else {
1.484 raeburn 6609: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484.2.19 raeburn 6610: $needs_end = 1;
1.472 raeburn 6611: }
1.443 www 6612:
1.442 www 6613: #
6614:
6615: my $savefolderpath;
1.484.2.86 raeburn 6616: my $hostname = $r->hostname();
1.442 www 6617:
1.395 raeburn 6618: if ($allowed) {
1.329 droeschl 6619: my $folder=$env{'form.folder'};
1.484.2.67 raeburn 6620: if ((($folder eq '') && (!$hiddentop)) || ($supplementalflag)) {
1.329 droeschl 6621: $folder='default';
1.356 tempelho 6622: $savefolderpath = $env{'form.folderpath'};
1.484.2.33 raeburn 6623: $env{'form.folderpath'}='default&'.&escape(&mt('Main Content'));
1.484.2.17 raeburn 6624: $pathitem = '<input type="hidden" name="folderpath" value="'.
1.329 droeschl 6625: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
6626: }
6627: my $postexec='';
6628: if ($folder eq 'default') {
1.484.2.93.2. 2(raebur 6629:3): my $windowname = 'loncapaclient';
6630:3): if ($env{'request.lti.login'}) {
6631:3): $windowname .= 'lti';
6632:3): }
1.372 bisitz 6633: $r->print('<script type="text/javascript">'."\n"
6634: .'// <![CDATA['."\n"
1.484.2.93.2. 2(raebur 6635:3): .'this.window.name="$windowname";'."\n"
1.372 bisitz 6636: .'// ]]>'."\n"
6637: .'</script>'."\n"
1.369 bisitz 6638: );
1.329 droeschl 6639: } else {
6640: #$postexec='self.close();';
6641: }
1.484.2.15 raeburn 6642: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
6643: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
1.329 droeschl 6644: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
6645:
6646: my $newnavform=(<<NNFORM);
6647: <form action="/adm/coursedocs" method="post" name="newnav">
1.484.2.43 raeburn 6648: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 6649: $pathitem
1.329 droeschl 6650: <input type="hidden" name="importdetail"
6651: value="$lt{'navc'}=/adm/navmaps" />
1.484.2.67 raeburn 6652: <a class="LC_menubuttons_link" href="javascript:makenew(document.newnav);">$lt{'navc'}</a>
1.329 droeschl 6653: $help{'Navigate_Content'}
6654: </form>
6655: NNFORM
6656: my $newsmppageform=(<<NSPFORM);
6657: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.484.2.43 raeburn 6658: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 6659: $pathitem
1.329 droeschl 6660: <input type="hidden" name="importdetail" value="" />
1.423 onken 6661: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 6662: $help{'Simple Page'}
1.329 droeschl 6663: </form>
6664: NSPFORM
6665:
6666: my $newsmpproblemform=(<<NSPROBFORM);
6667: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371 tempelho 6668: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 6669: $pathitem
1.329 droeschl 6670: <input type="hidden" name="importdetail" value="" />
1.423 onken 6671: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.484.2.44 raeburn 6672: $help{'Simple_Problem'}
1.329 droeschl 6673: </form>
6674:
6675: NSPROBFORM
6676:
6677: my $newdropboxform=(<<NDBFORM);
6678: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.371 tempelho 6679: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 6680: $pathitem
1.329 droeschl 6681: <input type="hidden" name="importdetail" value="" />
1.423 onken 6682: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.484.2.36 raeburn 6683: $help{'Dropbox'}
1.344 bisitz 6684: </form>
1.329 droeschl 6685: NDBFORM
6686:
6687: my $newexuploadform=(<<NEXUFORM);
6688: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.371 tempelho 6689: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 6690: $pathitem
1.329 droeschl 6691: <input type="hidden" name="importdetail" value="" />
1.423 onken 6692: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 6693: $help{'Score_Upload_Form'}
6694: </form>
6695: NEXUFORM
6696:
6697: my $newbulform=(<<NBFORM);
6698: <form action="/adm/coursedocs" method="post" name="newbul">
1.484.2.43 raeburn 6699: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 6700: $pathitem
1.329 droeschl 6701: <input type="hidden" name="importdetail" value="" />
1.423 onken 6702: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 6703: $help{'Bulletin Board'}
6704: </form>
6705: NBFORM
6706:
6707: my $newaboutmeform=(<<NAMFORM);
6708: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.484.2.43 raeburn 6709: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 6710: $pathitem
1.329 droeschl 6711: <input type="hidden" name="importdetail"
6712: value="$plainname=/adm/$udom/$uname/aboutme" />
1.484.2.67 raeburn 6713: <a class="LC_menubuttons_link" href="javascript:makenew(document.newaboutme);">$lt{'mypi'}</a>
1.347 weissno 6714: $help{'My Personal Information Page'}
1.329 droeschl 6715: </form>
6716: NAMFORM
6717:
6718: my $newaboutsomeoneform=(<<NASOFORM);
6719: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.484.2.43 raeburn 6720: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 6721: $pathitem
1.329 droeschl 6722: <input type="hidden" name="importdetail" value="" />
1.423 onken 6723: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 6724: </form>
6725: NASOFORM
6726:
6727: my $newrosterform=(<<NROSTFORM);
6728: <form action="/adm/coursedocs" method="post" name="newroster">
1.484.2.43 raeburn 6729: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 6730: $pathitem
1.329 droeschl 6731: <input type="hidden" name="importdetail"
6732: value="$lt{'rost'}=/adm/viewclasslist" />
1.484.2.67 raeburn 6733: <a class="LC_menubuttons_link" href="javascript:makenew(document.newroster);">$lt{'rost'}</a>
1.484.2.37 raeburn 6734: $help{'Course_Roster'}
1.329 droeschl 6735: </form>
6736: NROSTFORM
6737:
1.484.2.27 raeburn 6738: my $newwebpage;
6739: if ($folder =~ /^default_?(\d*)$/) {
6740: $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
6741: if ($1) {
6742: $newwebpage .= $1;
6743: } else {
6744: $newwebpage .= 'default';
6745: }
6746: $newwebpage .= '/new.html';
6747: }
6748: my $newwebpageform =(<<NWEBFORM);
6749: <form action="/adm/coursedocs" method="post" name="newwebpage">
1.484.2.43 raeburn 6750: <input type="hidden" name="active" value="ee" />
1.484.2.27 raeburn 6751: $pathitem
6752: <input type="hidden" name="importdetail" value="$newwebpage" />
6753: <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
1.484.2.36 raeburn 6754: $help{'Web_Page'}
1.484.2.27 raeburn 6755: </form>
6756: NWEBFORM
1.484.2.30 raeburn 6757:
1.484.2.27 raeburn 6758:
1.342 ehlerst 6759: my $specialdocumentsform;
1.383 tempelho 6760: my @specialdocumentsforma;
1.451 www 6761: my $gradingform;
6762: my @gradingforma;
6763: my $communityform;
6764: my @communityforma;
1.351 ehlerst 6765: my $newfolderform;
1.390 tempelho 6766: my $newfolderb;
1.342 ehlerst 6767:
1.451 www 6768: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 6769:
1.329 droeschl 6770: my $newpageform=(<<NPFORM);
6771: <form action="/adm/coursedocs" method="post" name="newpage">
6772: <input type="hidden" name="folderpath" value="$path" />
6773: <input type="hidden" name="importdetail" value="" />
1.484.2.43 raeburn 6774: <input type="hidden" name="active" value="ee" />
1.423 onken 6775: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 6776: $help{'Adding_Pages'}
1.329 droeschl 6777: </form>
6778: NPFORM
1.390 tempelho 6779:
6780:
1.351 ehlerst 6781: $newfolderform=(<<NFFORM);
1.329 droeschl 6782: <form action="/adm/coursedocs" method="post" name="newfolder">
1.484.2.19 raeburn 6783: $pathitem
1.329 droeschl 6784: <input type="hidden" name="importdetail" value="" />
1.484.2.43 raeburn 6785: <input type="hidden" name="active" value="" />
1.422 onken 6786: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 6787: </form>
6788: NFFORM
6789:
6790: my $newsylform=(<<NSYLFORM);
6791: <form action="/adm/coursedocs" method="post" name="newsyl">
1.484.2.43 raeburn 6792: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 6793: $pathitem
1.329 droeschl 6794: <input type="hidden" name="importdetail"
6795: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.484.2.67 raeburn 6796: <a class="LC_menubuttons_link" href="javascript:makenew(document.newsyl);">$lt{'syll'}</a>
1.329 droeschl 6797: $help{'Syllabus'}
1.383 tempelho 6798:
1.329 droeschl 6799: </form>
6800: NSYLFORM
1.364 bisitz 6801:
1.329 droeschl 6802: my $newgroupfileform=(<<NGFFORM);
6803: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.484.2.43 raeburn 6804: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 6805: $pathitem
1.329 droeschl 6806: <input type="hidden" name="importdetail"
6807: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.484.2.67 raeburn 6808: <a class="LC_menubuttons_link" href="javascript:makenew(document.newgroupfiles);">$lt{'grpo'}</a>
1.353 weissno 6809: $help{'Group Portfolio'}
1.329 droeschl 6810: </form>
6811: NGFFORM
1.484.2.89 raeburn 6812: if ($container eq 'page') {
6813: @specialdocumentsforma=(
6814: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
6815: );
6816: } else {
6817: @specialdocumentsforma=(
1.421 onken 6818: {'<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 6819: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.newsyl);" />'=>$newsylform},
6820: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="javascript:makenew(document.newnav);" />'=>$newnavform},
1.451 www 6821: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
1.484.2.27 raeburn 6822: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
1.484.2.89 raeburn 6823: );
6824: }
1.451 www 6825: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
6826:
1.434 raeburn 6827:
6828: my @importdoc = (
1.484.2.19 raeburn 6829: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform}
6830: );
1.484.2.93.2. 2(raebur 6831:3): if ($posslti) {
(raeburn 6832:): push(@importdoc,
6833:): {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="toggleUpload(\'tool\');" />'=>$exttoolform},
6834:): );
6835:): }
1.484.2.19 raeburn 6836: unless ($container eq 'page') {
6837: push(@importdoc,
6838: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform}
6839: );
6840: }
6841: push(@importdoc,
1.484.2.38 raeburn 6842: {'<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 6843: );
1.484.2.12 raeburn 6844: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
1.434 raeburn 6845:
1.451 www 6846: @gradingforma=(
6847: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
6848: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
6849: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
6850:
6851: );
6852: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
6853:
6854: @communityforma=(
6855: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
6856: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
6857: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
1.484.2.67 raeburn 6858: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="javascript:makenew(document.newroster);" />'=>$newrosterform},
6859: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="javascript:makenew(document.newgroupfiles);" />'=>$newgroupfileform},
1.451 www 6860: );
6861: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 6862:
1.330 tempelho 6863: my %orderhash = (
1.484.2.36 raeburn 6864: 'aa' => ['Upload',$fileuploadform],
6865: 'bb' => ['Import',$importpubform],
6866: 'cc' => ['Grading',$gradingform],
1.484.2.89 raeburn 6867: 'ee' => ['Other',$specialdocumentsform],
1.330 tempelho 6868: );
1.484.2.19 raeburn 6869: unless ($container eq 'page') {
1.434 raeburn 6870: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.484 raeburn 6871: $orderhash{'dd'} = ['Collaboration',$communityform];
1.434 raeburn 6872: }
6873:
1.341 ehlerst 6874: $hadchanges=0;
1.484 raeburn 6875: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 6876: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.67 raeburn 6877: $supplementalflag,\%orderhash,$iconpath,$pathitem,
1.484.2.93.2. (raeburn 6878:): \%ltitools,$canedit,$hostname,\$navmap,$hiddentop);
1.484.2.67 raeburn 6879: undef($navmap);
1.443 www 6880: if ($error) {
6881: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
6882: }
6883: if ($hadchanges) {
1.484.2.73 raeburn 6884: unless (&is_hash_old()) {
6885: &mark_hash_old();
6886: }
1.443 www 6887: }
1.341 ehlerst 6888:
1.443 www 6889: &changewarning($r,'');
6890: }
1.458 raeburn 6891: }
1.442 www 6892:
1.443 www 6893: # Supplemental documents start here
6894:
1.329 droeschl 6895: my $folder=$env{'form.folder'};
1.443 www 6896: unless ($supplementalflag) {
1.329 droeschl 6897: $folder='supplemental';
6898: }
1.484.2.93.2. 0(raebur 6899:3): if (($folder eq 'supplemental') &&
1.329 droeschl 6900: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 6901: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 6902: } elsif ($allowed) {
1.356 tempelho 6903: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 6904: }
1.484.2.17 raeburn 6905: $pathitem = '<input type="hidden" name="folderpath" value="'.
6906: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.329 droeschl 6907: if ($allowed) {
6908: my $folderseq=
1.484.2.15 raeburn 6909: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
1.329 droeschl 6910:
6911: my $supupdocform=(<<SUPDOCFORM);
1.484.2.12 raeburn 6912: <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
6913: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
1.383 tempelho 6914: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.484.2.19 raeburn 6915: <fieldset id="uploadsuppdocform" style="display: none;">
1.484.2.12 raeburn 6916: <legend>$lt{'upfi'}</legend>
1.371 tempelho 6917: <input type="hidden" name="active" value="ee" />
1.329 droeschl 6918: $fileupload
1.484.2.93.2. 3(raebur 6919:3): <input type="file" name="uploaddoc" id="uploaddocsupp" class="LC_flUpload LC_uploaddoc" size="40" $disabled />
6920:3): <input type="hidden" id="LC_free_space_supp" value="$free_space" />
1.329 droeschl 6921: <br />
6922: <br />
6923: <span class="LC_nobreak">
6924: $checkbox
6925: </span>
6926: <br /><br />
6927: $lt{'comment'}:<br />
1.383 tempelho 6928: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 6929: <br />
1.484.2.19 raeburn 6930: $pathitem
1.329 droeschl 6931: <input type="hidden" name="cmd" value="upload_supplemental" />
1.484.2.12 raeburn 6932: <input type='submit' value="$lt{'upld'}" />
1.484.2.93.2. 4(raebur 6933:3): </fieldset>
1.484.2.12 raeburn 6934: </form>
1.484.2.19 raeburn 6935: SUPDOCFORM
1.329 droeschl 6936:
6937: my $supnewfolderform=(<<SNFFORM);
6938: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.484.2.43 raeburn 6939: <input type="hidden" name="active" value="" />
1.484.2.17 raeburn 6940: $pathitem
1.329 droeschl 6941: <input type="hidden" name="importdetail" value="" />
1.423 onken 6942: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 6943: $help{'Adding_Folders'}
1.329 droeschl 6944: </form>
6945: SNFFORM
1.383 tempelho 6946:
1.484.2.19 raeburn 6947: my $supextform =
6948: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
1.484.2.67 raeburn 6949: $help{'Adding_External_Resource'},
6950: undef,undef,$disabled);
1.484.2.93.2. (raeburn 6951:): my $supexttoolform =
6952:): &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
6953:): $help{'Adding_External_Tool'},
6954:): undef,undef,'tool',$coursedom,
6955:): $coursenum,\%ltitools,$disabled);
1.329 droeschl 6956:
6957: my $supnewsylform=(<<SNSFORM);
6958: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 6959: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 6960: $pathitem
1.329 droeschl 6961: <input type="hidden" name="importdetail"
6962: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.484.2.67 raeburn 6963: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewsyl);">$lt{'syll'}</a>
1.329 droeschl 6964: $help{'Syllabus'}
6965: </form>
6966: SNSFORM
6967:
6968: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 6969: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 6970: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 6971: $pathitem
1.329 droeschl 6972: <input type="hidden" name="importdetail"
6973: value="$plainname=/adm/$udom/$uname/aboutme" />
1.484.2.67 raeburn 6974: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewaboutme);">$lt{'mypi'}</a>
1.347 weissno 6975: $help{'My Personal Information Page'}
1.329 droeschl 6976: </form>
6977: SNAMFORM
6978:
1.484.2.27 raeburn 6979: my $supwebpage;
6980: if ($folder =~ /^supplemental_?(\d*)$/) {
6981: $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
6982: if ($1) {
6983: $supwebpage .= $1;
6984: } else {
6985: $supwebpage .= 'default';
6986: }
6987: $supwebpage .= '/new.html';
6988: }
6989: my $supwebpageform =(<<SWEBFORM);
6990: <form action="/adm/coursedocs" method="post" name="supwebpage">
6991: <input type="hidden" name="active" value="cc" />
6992: $pathitem
6993: <input type="hidden" name="importdetail" value="$supwebpage" />
6994: <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
1.484.2.36 raeburn 6995: $help{'Web_Page'}
1.484.2.27 raeburn 6996: </form>
6997: SWEBFORM
6998:
1.333 muellerd 6999:
1.383 tempelho 7000: my @specialdocs = (
1.484.2.67 raeburn 7001: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.supnewsyl);" />'
1.417 droeschl 7002: =>$supnewsylform},
1.484.2.67 raeburn 7003: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makenew(document.supnewaboutme);" />'
1.417 droeschl 7004: =>$supnewaboutmeform},
1.484.2.27 raeburn 7005: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
7006:
1.383 tempelho 7007: );
1.417 droeschl 7008: my @supimportdoc = (
1.484.2.19 raeburn 7009: {'<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 7010:): =>$supextform});
7011:): if (keys(%ltitools)) {
7012:): push(@supimportdoc,
7013:): {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="javascript:toggleUpload(\'supptool\')" />'
7014:): =>$supexttoolform});
7015:): }
7016:): push(@supimportdoc,
1.484.2.12 raeburn 7017: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
7018: =>$supupdocform},
1.484.2.93.2. (raeburn 7019:): );
1.484.2.19 raeburn 7020:
1.484.2.12 raeburn 7021: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
1.333 muellerd 7022: my %suporderhash = (
1.390 tempelho 7023: '00' => ['Supnewfolder', $supnewfolderform],
1.484.2.36 raeburn 7024: 'ee' => ['Upload',$supupdocform],
7025: 'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 7026: );
1.443 www 7027: if ($supplementalflag) {
1.484.2.93.2. 0(raebur 7028:3): $suppchanges = 0;
7029:3): my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
7030:3): $supplementalflag,\%suporderhash,$iconpath,$pathitem,
7031:3): \%ltitools,$canedit,$hostname);
7032:3): if ($error) {
7033:3): $r->print('<p><span class="LC_error">'.$error.'</span></p>');
7034:3): }
7035:3): if ($suppchanges) {
7036:3): &Apache::lonnet::update_supp_caches($coursedom,$coursenum);
7037:3): undef($suppchanges);
7038:3): }
1.393 raeburn 7039: }
1.443 www 7040: } elsif ($supplementalflag) {
1.458 raeburn 7041: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.93.2. (raeburn 7042:): $supplementalflag,'',$iconpath,$pathitem,'',$canedit,
7043:): $hostname);
1.393 raeburn 7044: if ($error) {
7045: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 7046: }
1.393 raeburn 7047: }
1.389 tempelho 7048:
1.484.2.19 raeburn 7049: if ($needs_end) {
7050: $r->print(&endContentScreen());
7051: }
1.383 tempelho 7052:
1.329 droeschl 7053: if ($allowed) {
7054: $r->print('
7055: <form method="post" name="extimport" action="/adm/coursedocs">
7056: <input type="hidden" name="title" />
7057: <input type="hidden" name="url" />
7058: <input type="hidden" name="useform" />
7059: <input type="hidden" name="residx" />
7060: </form>');
7061: }
1.484 raeburn 7062: } elsif ($showdoc) {
1.329 droeschl 7063: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 7064: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.484.2.10 raeburn 7065: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 7066: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 7067: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 7068: }
7069: }
7070: $r->print(&Apache::loncommon::end_page());
7071: return OK;
1.364 bisitz 7072: }
1.329 droeschl 7073:
1.440 raeburn 7074: sub embedded_form_elems {
7075: my ($phase,$primaryurl,$newidx) = @_;
7076: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.484.2.78 raeburn 7077: $newidx =~s /\D+//g;
1.440 raeburn 7078: return <<STATE;
7079: <input type="hidden" name="folderpath" value="$folderpath" />
7080: <input type="hidden" name="cmd" value="upload_embedded" />
7081: <input type="hidden" name="newidx" value="$newidx" />
7082: <input type="hidden" name="phase" value="$phase" />
7083: <input type="hidden" name="primaryurl" value="$primaryurl" />
7084: STATE
7085: }
7086:
7087: sub embedded_destination {
7088: my $folder=$env{'form.folder'};
7089: my $destination = 'docs/';
7090: if ($folder =~ /^supplemental/) {
7091: $destination = 'supplemental/';
7092: }
7093: if (($folder eq 'default') || ($folder eq 'supplemental')) {
7094: $destination .= 'default/';
7095: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
7096: $destination .= $2.'/';
7097: }
1.484.2.78 raeburn 7098: my $newidx = $env{'form.newidx'};
7099: $newidx =~s /\D+//g;
7100: if ($newidx) {
7101: $destination .= $newidx;
7102: }
1.440 raeburn 7103: my $dir_root = '/userfiles';
7104: return ($destination,$dir_root);
7105: }
7106:
7107: sub return_to_editor {
7108: my $actionurl = '/adm/coursedocs';
7109: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
7110: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
7111: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
7112: '</a></p>';
7113: }
7114:
1.476 raeburn 7115: sub decompression_info {
7116: my ($destination,$dir_root) = &embedded_destination();
7117: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
7118: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
7119: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
7120: my $container='sequence';
1.480 raeburn 7121: my ($pathitem,$hiddenelem);
1.484.2.54 raeburn 7122: my @hiddens = ('newidx','comment','position','folderpath','archiveurl');
1.484.2.19 raeburn 7123: if ($env{'form.folderpath'} =~ /\:1$/) {
1.476 raeburn 7124: $container='page';
7125: }
1.480 raeburn 7126: unshift(@hiddens,$pathitem);
7127: foreach my $item (@hiddens) {
1.484.2.78 raeburn 7128: if ($item eq 'newidx') {
7129: next if ($env{'form.'.$item} =~ /\D/);
7130: }
1.480 raeburn 7131: if ($env{'form.'.$item}) {
7132: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
1.484.2.54 raeburn 7133: &HTML::Entities::encode($env{'form.'.$item},'<>&"').'" />'."\n";
1.480 raeburn 7134: }
1.477 raeburn 7135: }
1.476 raeburn 7136: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
7137: $hiddenelem);
7138: }
7139:
7140: sub decompression_phase_one {
7141: my ($dir,$file,$warning,$error,$output);
7142: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
7143: &decompression_info();
1.484.2.7 raeburn 7144: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 7145: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
7146: } else {
7147: my $file = $1;
1.481 raeburn 7148: $output =
7149: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
7150: $destination,$dir_root,
7151: $hiddenelem);
7152: if ($env{'form.autoextract_camtasia'}) {
7153: $output .= &remove_archive($docudom,$docuname,$container);
7154: }
1.476 raeburn 7155: }
7156: if ($error) {
7157: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
7158: $error.'</p>'."\n";
7159: }
7160: if ($warning) {
7161: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
7162: }
7163: return $output;
7164: }
7165:
7166: sub decompression_phase_two {
7167: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
7168: &decompression_info();
1.481 raeburn 7169: my $output;
1.480 raeburn 7170: if ($env{'form.archivedelete'}) {
1.481 raeburn 7171: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 7172: }
7173: $output .=
1.481 raeburn 7174: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 7175: $destination,$dir_root,$hiddenelem);
7176: return $output;
7177: }
7178:
1.480 raeburn 7179: sub remove_archive {
7180: my ($docudom,$docuname,$container) = @_;
7181: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 7182: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 7183: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
7184: if ($fatal) {
7185: if ($container eq 'page') {
7186: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
7187: } else {
7188: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
7189: }
1.484.2.54 raeburn 7190: $delwarning .= ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 7191: } else {
7192: my $currcmd = $env{'form.cmd'};
7193: my $position = $env{'form.position'};
1.484.2.54 raeburn 7194: my $archiveidx = $position;
7195: if ($position > 0) {
7196: if (($env{'form.autoextract_camtasia'}) && (scalar(@LONCAPA::map::order) == 2)) {
7197: $archiveidx = $position-1;
7198: }
7199: $env{'form.cmd'} = 'remove_'.$archiveidx;
7200: my ($title,$url,@rrest) =
7201: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$archiveidx]]);
7202: if ($url eq $env{'form.archiveurl'}) {
7203: if (&handle_edit_cmd($docuname,$docudom)) {
7204: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
1.484.2.93.2. 0(raebur 7205:3): if ($suppchanges) {
7206:3): &Apache::lonnet::update_supp_caches($docudom,$docuname);
7207:3): undef($suppchanges);
7208:3): }
1.484.2.54 raeburn 7209: if ($fatal) {
7210: if ($container eq 'page') {
7211: $delwarning = &mt('An error occurred updating the contents of the current page.');
7212: } else {
7213: $delwarning = &mt('An error occurred updating the contents of the current folder.');
7214: }
1.480 raeburn 7215: } else {
1.484.2.54 raeburn 7216: $delresult = &mt('Archive file removed.');
1.480 raeburn 7217: }
7218: }
1.484.2.54 raeburn 7219: } else {
7220: $delwarning .= &mt('Archive file had unexpected item number in folder.').
7221: ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 7222: }
7223: }
7224: $env{'form.cmd'} = $currcmd;
7225: }
7226: if ($delwarning) {
7227: $output = '<p class="LC_warning">'.
7228: $delwarning.
7229: '</p>';
7230: }
7231: if ($delresult) {
7232: $output .= '<p class="LC_info">'.
7233: $delresult.
7234: '</p>';
7235: }
1.481 raeburn 7236: return $output;
1.480 raeburn 7237: }
7238:
1.484 raeburn 7239: sub generate_admin_menu {
1.484.2.67 raeburn 7240: my ($crstype,$canedit) = @_;
1.484 raeburn 7241: my $lc_crstype = lc($crstype);
7242: my ($home,$other,%outhash)=&authorhosts();
1.484.2.43 raeburn 7243: my %lt= ( # do not translate here
1.484 raeburn 7244: 'vc' => 'Verify Content',
7245: 'cv' => 'Check/Set Resource Versions',
7246: 'ls' => 'List Resource Identifiers',
1.484.2.93.2. (raeburn 7247:): 'ct' => 'Display/Set Shortened URLs for Deep-linking',
1.484 raeburn 7248: 'imse' => 'Export contents to IMS Archive',
1.484.2.43 raeburn 7249: 'dcd' => "Copy $crstype Content to Authoring Space",
7250: );
1.484 raeburn 7251: my ($candump,$dumpurl);
7252: if ($home + $other > 0) {
7253: $candump = 'F';
7254: if ($home) {
7255: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
7256: } else {
7257: my @hosts;
7258: foreach my $aurole (keys(%outhash)) {
7259: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
7260: push(@hosts,$outhash{$aurole});
1.484.2.30 raeburn 7261: }
1.484 raeburn 7262: }
7263: if (@hosts == 1) {
7264: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
7265: '&role='.
7266: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
7267: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
7268: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
7269: } else {
7270: $dumpurl = "javascript:choose_switchserver_window()";
7271: }
7272: }
7273: }
7274: my @menu=
7275: ({ categorytitle=>'Administration',
7276: items =>[
7277: { linktext => $lt{'vc'},
7278: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
7279: permission => 'F',
1.484.2.44 raeburn 7280: help => 'Docs_Verify_Content',
1.484 raeburn 7281: icon => 'verify.png',
7282: linktitle => 'Verify contents can be retrieved/rendered',
7283: },
7284: { linktext => $lt{'cv'},
7285: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
7286: permission => 'F',
1.484.2.44 raeburn 7287: help => 'Docs_Check_Resource_Versions',
1.484 raeburn 7288: icon => 'resversion.png',
7289: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
7290: },
7291: { linktext => $lt{'ls'},
7292: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
7293: permission => 'F',
7294: #help => '',
7295: icon => 'symbs.png',
7296: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
7297: },
1.484.2.93.2. (raeburn 7298:): { linktext => $lt{'ct'},
7299:): url => "javascript:injectData(document.courseverify,'dummy','shorturls','$lt{'ct'}')",
7300:): permission => 'F',
7301:): help => 'Docs_Short_URLs',
7302:): icon => 'shorturls.png',
7303:): linktitle => "Set shortened URLs for a resource or folder in your $lc_crstype for use in deep-linking"
7304:): },
1.484 raeburn 7305: ]
1.484.2.67 raeburn 7306: });
7307: if ($canedit) {
7308: push(@menu,
1.484 raeburn 7309: { categorytitle=>'Export',
7310: items =>[
7311: { linktext => $lt{'imse'},
7312: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
7313: permission => 'F',
7314: help => 'Docs_Export_Course_Docs',
7315: icon => 'imsexport.png',
7316: linktitle => $lt{'imse'},
7317: },
7318: { linktext => $lt{'dcd'},
7319: url => $dumpurl,
7320: permission => $candump,
1.484.2.44 raeburn 7321: help => 'Docs_Dump_Course_Docs',
1.484 raeburn 7322: icon => 'dump.png',
7323: linktitle => $lt{'dcd'},
7324: },
7325: ]
7326: });
1.484.2.67 raeburn 7327: }
1.484 raeburn 7328: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
7329: '<input type="hidden" id="dummy" />'."\n".
7330: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
7331: '</form>';
1.329 droeschl 7332: }
7333:
7334: sub generate_edit_table {
1.484.2.30 raeburn 7335: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile,
1.484.2.67 raeburn 7336: $need_save,$copyfolder,$canedit) = @_;
1.406 raeburn 7337: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 7338: my %orderhash = %{$orderhash_ref};
1.484.2.67 raeburn 7339: my ($form, $activetab, $active, $disabled);
1.484.2.43 raeburn 7340: if (($env{'form.active'} ne '') && ($env{'form.active'} ne '00')) {
1.371 tempelho 7341: $activetab = $env{'form.active'};
7342: }
1.484.2.67 raeburn 7343: unless ($canedit) {
7344: $disabled = ' disabled="disabled"';
7345: }
1.472 raeburn 7346: my $backicon = $iconpath.'clickhere.gif';
1.484.2.21 raeburn 7347: my $backtext = &mt('Exit Editor');
1.458 raeburn 7348: $form = '<div class="LC_Box" style="margin:0;">'.
1.484.2.19 raeburn 7349: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
7350: '<li class="goback">'.
1.484.2.32 raeburn 7351: '<a href="javascript:toContents('."'$jumpto'".');">'.
1.484.2.19 raeburn 7352: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
7353: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
7354: '<li>'.
7355: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
7356: &mt('Undo Delete').'</a></li>'."\n";
1.484.2.7 raeburn 7357: if ($env{'form.docslog'}) {
7358: $form .= '<li class="active">';
7359: } else {
7360: $form .= '<li>';
7361: }
7362: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
7363: &mt('History').'</a></li>'."\n";
7364: if ($env{'form.docslog'}) {
7365: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
7366: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 7367: }
1.458 raeburn 7368: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 7369: if($name ne '00'){
1.371 tempelho 7370: if($activetab eq '' || $activetab ne $name){
7371: $active = '';
7372: }elsif($activetab eq $name){
7373: $active = 'class="active"';
7374: }
1.458 raeburn 7375: $form .= '<li style="float:right" '.$active
1.484 raeburn 7376: .' 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 7377: } else {
1.484.2.43 raeburn 7378: $form .= '<li style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 7379:
7380: }
1.329 droeschl 7381: }
1.484 raeburn 7382: $form .= '</ul>'."\n";
7383: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 7384:
7385: if ($to_show ne '') {
1.484.2.30 raeburn 7386: my $saveform;
7387: if ($need_save) {
7388: my $button = &mt('Make changes');
7389: my $path;
7390: if ($env{'form.folderpath'}) {
7391: $path =
7392: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
7393: }
7394: $saveform = <<"END";
7395: <div id="multisave" style="display:none; clear:both;" >
7396: <form name="saveactions" method="post" action="/adm/coursedocs" onsubmit="return checkSubmits();">
7397: <input type="hidden" name="folderpath" value="$path" />
7398: <input type="hidden" name="symb" value="$env{'form.symb'}" />
7399: <input type="hidden" name="allhiddenresource" value="" />
7400: <input type="hidden" name="allencrypturl" value="" />
7401: <input type="hidden" name="allrandompick" value="" />
7402: <input type="hidden" name="allrandomorder" value="" />
7403: <input type="hidden" name="changeparms" value="" />
7404: <input type="hidden" name="multiremove" value="" />
7405: <input type="hidden" name="multicut" value="" />
7406: <input type="hidden" name="multicopy" value="" />
7407: <input type="hidden" name="multichange" value="" />
7408: <input type="hidden" name="copyfolder" value="$copyfolder" />
1.484.2.67 raeburn 7409: <input type="submit" name="savemultiples" value="$button" $disabled />
1.484.2.30 raeburn 7410: </form>
7411: </div>
7412: END
7413: }
7414: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'.$saveform."\n";
1.458 raeburn 7415: }
1.363 ehlerst 7416: foreach my $field (keys(%orderhash)){
1.390 tempelho 7417: if($field ne '00'){
1.422 onken 7418: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 7419: $active = 'style="display: none;float:left"';
1.422 onken 7420: }elsif($activetab eq $field){
1.458 raeburn 7421: $active = 'style="display:block;float:left"';
1.422 onken 7422: }
7423: $form .= '<div id="'.$field.$tid.'"'
7424: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 7425: .'</div>'."\n";
1.363 ehlerst 7426: }
7427: }
1.484 raeburn 7428: unless ($env{'form.docslog'}) {
7429: $form .= '</div></div>'."\n";
7430: }
1.329 droeschl 7431: return $form;
7432: }
7433:
7434: sub editing_js {
1.484.2.93.2. (raeburn 7435:): my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
1.484.2.80 raeburn 7436: $canedit,$hostname,$navmapref) = @_;
1.484.2.61 raeburn 7437: my %js_lt = &Apache::lonlocal::texthash(
1.329 droeschl 7438: p_mnf => 'Name of New Folder',
7439: t_mnf => 'New Folder',
7440: p_mnp => 'Name of New Page',
7441: t_mnp => 'New Page',
1.451 www 7442: p_mxu => 'Title for the External Score',
1.349 biermanm 7443: p_msp => 'Name of Simple Course Page',
1.329 droeschl 7444: p_msb => 'Title for the Problem',
7445: p_mdb => 'Title for the Drop Box',
1.336 schafran 7446: p_mbb => 'Title for the Discussion Board',
1.484.2.27 raeburn 7447: p_mwp => 'Title for Web Page',
1.348 weissno 7448: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 7449: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 7450: p_mab_alrt1 => 'Not a valid user:domain',
7451: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
7452: p_chn => 'New Title',
7453: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
1.484.2.63 raeburn 7454: p_rmr2a => 'Remove',
7455: p_rmr2b => '?',
7456: p_rmr3a => 'Remove those',
7457: p_rmr3b => 'items?',
7458: p_rmr4 => 'WARNING: Removing a resource uploaded to a course cannot be undone via "Undo Delete".',
7459: p_rmr5 => 'Push "Cancel" and then use "Cut" instead if you might need to undo this change.',
1.329 droeschl 7460: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
7461: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
1.484.2.63 raeburn 7462: p_ctr2a => 'Cut',
7463: p_ctr2b => '?',
7464: p_ctr3a => 'Cut those',
7465: p_ctr3b => 'items?',
1.478 raeburn 7466: rpck => 'Enter number to pick (e.g., 3)',
1.484.2.12 raeburn 7467: imsfile => 'You must choose an IMS package for import',
7468: imscms => 'You must select which Course Management System was the source of the IMS package',
7469: invurl => 'Invalid URL',
7470: titbl => 'Title is blank',
1.484.2.30 raeburn 7471: more => '(More ...)',
7472: less => '(Less ...)',
7473: noor => 'No actions selected or changes to settings specified.',
7474: noch => 'No changes to settings specified.',
7475: noac => 'No actions selected.',
1.484.2.67 raeburn 7476: edri => 'Editing rights unavailable for your current role.',
1.329 droeschl 7477: );
7478:
1.484.2.61 raeburn 7479: &js_escape(\%js_lt);
1.433 raeburn 7480: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 7481: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
7482: my $main_container_page;
1.484.2.19 raeburn 7483: if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) {
7484: $main_container_page = 1;
1.434 raeburn 7485: }
1.484.2.67 raeburn 7486: my $backtourl;
7487: my $toplevelmain = &escape(&default_folderpath($coursenum,$coursedom,$navmapref));
1.446 www 7488: my $toplevelsupp = &supplemental_base();
1.433 raeburn 7489:
1.484.2.21 raeburn 7490: if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
7491: my $caller = $1;
7492: if ($caller =~ /^supplemental/) {
7493: $backtourl = '/adm/supplemental?folderpath='.&escape($caller);
7494: } else {
7495: my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
7496: $res = &Apache::lonnet::clutter($res);
7497: if (&Apache::lonnet::is_on_map($res)) {
1.484.2.66 raeburn 7498: my ($url,$anchor);
7499: if ($res =~ /^([^#]+)#([^#]+)$/) {
7500: $url = $1;
7501: $anchor = $2;
7502: if (($caller =~ m{^([^#]+)\Q#$anchor\E$})) {
7503: $caller = $1.&escape('#').$anchor;
7504: }
1.484.2.67 raeburn 7505: } else {
7506: $url = $res;
1.484.2.66 raeburn 7507: }
1.484.2.83 raeburn 7508: $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"');
7509: if ($backtourl =~ m{^\Q/uploaded/$coursedom/$coursenum/\Edefault_\d+\.sequence$}) {
7510: $backtourl .= '?navmap=1';
7511: } else {
7512: $backtourl .= '?symb='.
7513: &HTML::Entities::encode($caller,'<>&"');
7514: }
1.484.2.80 raeburn 7515: if ($backtourl =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
7516: if (($ENV{'SERVER_PORT'} == 443) &&
7517: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
1.484.2.93 raeburn 7518: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.484.2.80 raeburn 7519: if ($hostname ne '') {
7520: $backtourl = 'http://'.$hostname.$backtourl;
7521: }
7522: $backtourl .= (($backtourl =~ /\?/) ? '&':'?').'usehttp=1';
7523: }
7524: }
7525: } elsif ($backtourl =~ m{^/adm/wrapper/ext/(?!https:)}) {
7526: if (($ENV{'SERVER_PORT'} == 443) && ($hostname ne '')) {
1.484.2.93 raeburn 7527: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.484.2.80 raeburn 7528: if ($hostname ne '') {
7529: $backtourl = 'http://'.$hostname.$backtourl;
7530: }
7531: $backtourl .= (($backtourl =~ /\?/) ? '&':'?').'usehttp=1';
7532: }
7533: }
7534: }
1.484.2.66 raeburn 7535: if ($anchor ne '') {
7536: $backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"');
7537: }
1.484.2.57 raeburn 7538: $backtourl = &Apache::loncommon::escape_single($backtourl);
1.484.2.31 raeburn 7539: } else {
7540: $backtourl = '/adm/navmaps';
1.484.2.21 raeburn 7541: }
7542: }
7543: } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
7544: $backtourl = '/adm/menu';
7545: } elsif ($supplementalflag) {
1.484.2.93.2. 0(raebur 7546:3): if (($env{'request.role.adv'}) ||
7547:3): (&Apache::lonnet::has_unhidden_suppfiles($coursenum,$coursedom))) {
7548:3): $backtourl = '/adm/supplemental';
7549:3): } else {
7550:3): $backtourl = '/adm/navmaps';
7551:3): }
1.484.2.21 raeburn 7552: } else {
7553: $backtourl = '/adm/navmaps';
1.472 raeburn 7554: }
7555:
1.484.2.19 raeburn 7556: my $fieldsets = "'ext','doc'";
1.484.2.93.2. (raeburn 7557:): if ($posslti) {
7558:): $fieldsets .= ",'tool'";
7559:): }
1.484.2.19 raeburn 7560: unless ($main_container_page) {
7561: $fieldsets .=",'ims'";
7562: }
1.484.2.12 raeburn 7563: if ($supplementalflag) {
7564: $fieldsets = "'suppext','suppdoc'";
1.484.2.93.2. (raeburn 7565:): if ($posslti) {
7566:): $fieldsets .= ",'supptool'";
7567:): }
1.484.2.12 raeburn 7568: }
7569:
1.484.2.67 raeburn 7570: my $jsmakefunctions;
7571: if ($canedit) {
7572: $jsmakefunctions = <<ENDNEWSCRIPT;
1.329 droeschl 7573: function makenewfolder(targetform,folderseq) {
1.484.2.65 raeburn 7574: var foldername=prompt('$js_lt{"p_mnf"}','$js_lt{"t_mnf"}');
1.329 droeschl 7575: if (foldername) {
1.484.2.91 raeburn 7576: targetform.importdetail.value=encodeURIComponent(foldername)+"="+folderseq;
1.329 droeschl 7577: targetform.submit();
7578: }
7579: }
7580:
7581: function makenewpage(targetform,folderseq) {
1.484.2.61 raeburn 7582: var pagename=prompt('$js_lt{"p_mnp"}','$js_lt{"t_mnp"}');
1.329 droeschl 7583: if (pagename) {
1.484.2.91 raeburn 7584: targetform.importdetail.value=encodeURIComponent(pagename)+"="+folderseq;
1.329 droeschl 7585: targetform.submit();
7586: }
7587: }
7588:
7589: function makeexamupload() {
1.484.2.61 raeburn 7590: var title=prompt('$js_lt{"p_mxu"}');
1.344 bisitz 7591: if (title) {
1.329 droeschl 7592: this.document.forms.newexamupload.importdetail.value=
1.484.2.91 raeburn 7593: encodeURIComponent(title)+'=/res/lib/templates/examupload.problem';
1.329 droeschl 7594: this.document.forms.newexamupload.submit();
7595: }
7596: }
7597:
7598: function makesmppage() {
1.484.2.61 raeburn 7599: var title=prompt('$js_lt{"p_msp"}');
1.344 bisitz 7600: if (title) {
1.329 droeschl 7601: this.document.forms.newsmppg.importdetail.value=
1.484.2.91 raeburn 7602: encodeURIComponent(title)+'=/adm/$udom/$uname/new/smppg';
1.329 droeschl 7603: this.document.forms.newsmppg.submit();
7604: }
7605: }
7606:
1.484.2.27 raeburn 7607: function makewebpage(type) {
1.484.2.61 raeburn 7608: var title=prompt('$js_lt{"p_mwp"}');
1.484.2.27 raeburn 7609: var formname;
7610: if (type == 'supp') {
7611: formname = this.document.forms.supwebpage;
7612: } else {
7613: formname = this.document.forms.newwebpage;
7614: }
7615: if (title) {
7616: var webpage = formname.importdetail.value;
1.484.2.91 raeburn 7617: formname.importdetail.value = encodeURIComponent(title)+'='+webpage;
1.484.2.27 raeburn 7618: formname.submit();
7619: }
7620: }
7621:
1.329 droeschl 7622: function makesmpproblem() {
1.484.2.61 raeburn 7623: var title=prompt('$js_lt{"p_msb"}');
1.344 bisitz 7624: if (title) {
1.329 droeschl 7625: this.document.forms.newsmpproblem.importdetail.value=
1.484.2.91 raeburn 7626: encodeURIComponent(title)+'=/res/lib/templates/simpleproblem.problem';
1.329 droeschl 7627: this.document.forms.newsmpproblem.submit();
7628: }
7629: }
7630:
7631: function makedropbox() {
1.484.2.61 raeburn 7632: var title=prompt('$js_lt{"p_mdb"}');
1.344 bisitz 7633: if (title) {
1.329 droeschl 7634: this.document.forms.newdropbox.importdetail.value=
1.484.2.91 raeburn 7635: encodeURIComponent(title)+'=/res/lib/templates/DropBox.problem';
1.329 droeschl 7636: this.document.forms.newdropbox.submit();
7637: }
7638: }
7639:
7640: function makebulboard() {
1.484.2.61 raeburn 7641: var title=prompt('$js_lt{"p_mbb"}');
1.329 droeschl 7642: if (title) {
7643: this.document.forms.newbul.importdetail.value=
1.484.2.91 raeburn 7644: encodeURIComponent(title)+'=/adm/$udom/$uname/new/bulletinboard';
1.329 droeschl 7645: this.document.forms.newbul.submit();
7646: }
7647: }
7648:
7649: function makeabout() {
1.484.2.61 raeburn 7650: var user=prompt("$js_lt{'p_mab'}");
1.329 droeschl 7651: if (user) {
7652: var comp=new Array();
7653: comp=user.split(':');
7654: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
7655: if ((comp[0]) && (comp[1])) {
7656: this.document.forms.newaboutsomeone.importdetail.value=
1.484.2.61 raeburn 7657: '$js_lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.484.2.67 raeburn 7658: this.document.forms.newaboutsomeone.submit();
7659: } else {
7660: alert("$js_lt{'p_mab_alrt1'}");
7661: }
7662: } else {
7663: alert("$js_lt{'p_mab_alrt2'}");
7664: }
7665: }
1.335 ehlerst 7666: }
1.484.2.67 raeburn 7667:
7668: function makenew(targetform) {
7669: targetform.submit();
1.335 ehlerst 7670: }
1.484.2.67 raeburn 7671:
7672: function changename(folderpath,index,oldtitle) {
7673: var title=prompt('$js_lt{"p_chn"}',oldtitle);
7674: if (title) {
7675: this.document.forms.renameform.markcopy.value='';
7676: this.document.forms.renameform.title.value=title;
7677: this.document.forms.renameform.cmd.value='rename_'+index;
7678: this.document.forms.renameform.folderpath.value=folderpath;
7679: this.document.forms.renameform.submit();
7680: }
1.329 droeschl 7681: }
7682:
1.484.2.67 raeburn 7683: ENDNEWSCRIPT
7684: } else {
7685: $jsmakefunctions = <<ENDNEWSCRIPT;
7686:
7687: function makenewfolder() {
7688: alert("$js_lt{'edri'}");
7689: }
7690:
7691: function makenewpage() {
7692: alert("$js_lt{'edri'}");
7693: }
7694:
7695: function makeexamupload() {
7696: alert("$js_lt{'edri'}");
7697: }
7698:
7699: function makesmppage() {
7700: alert("$js_lt{'edri'}");
7701: }
7702:
7703: function makewebpage(type) {
7704: alert("$js_lt{'edri'}");
7705: }
7706:
7707: function makesmpproblem() {
7708: alert("$js_lt{'edri'}");
7709: }
7710:
7711: function makedropbox() {
7712: alert("$js_lt{'edri'}");
7713: }
7714:
7715: function makebulboard() {
7716: alert("$js_lt{'edri'}");
7717: }
7718:
7719: function makeabout() {
7720: alert("$js_lt{'edri'}");
7721: }
7722:
7723: function changename() {
7724: alert("$js_lt{'edri'}");
7725: }
7726:
7727: function makenew() {
7728: alert("$js_lt{'edri'}");
7729: }
7730:
7731: function groupimport() {
7732: alert("$js_lt{'edri'}");
7733: }
7734:
7735: function groupsearch() {
7736: alert("$js_lt{'edri'}");
7737: }
7738:
7739: function groupopen(url,recover) {
7740: var options="scrollbars=1,resizable=1,menubar=0";
7741: idxflag=1;
7742: idx=open("/adm/groupsort?inhibitmenu=yes&mode=simple&recover="+recover+"&readfile="+url,"idxout",options);
7743: idx.focus();
7744: }
7745:
7746: ENDNEWSCRIPT
7747:
7748: }
7749: return <<ENDSCRIPT;
7750:
7751: $jsmakefunctions
7752:
1.484.2.13 raeburn 7753: function toggleUpload(caller) {
7754: var blocks = Array($fieldsets);
7755: for (var i=0; i<blocks.length; i++) {
7756: var disp = 'none';
7757: if (caller == blocks[i]) {
7758: var curr = document.getElementById('upload'+caller+'form').style.display;
7759: if (curr == 'none') {
7760: disp='block';
7761: }
7762: }
7763: document.getElementById('upload'+blocks[i]+'form').style.display=disp;
1.484.2.93.2. (raeburn 7764:): if ((caller == 'tool') || (caller == 'supptool')) {
7765:): if (disp == 'block') {
7766:): if (document.getElementById('LC_exttoolid')) {
7767:): var toolselector = document.getElementById('LC_exttoolid');
7768:): var suppflag = 0;
7769:): if (caller == 'supptool') {
7770:): suppflag = 1;
7771:): }
7772:): currForm = document.getElementById('new'+caller);
7773:): updateExttool(toolselector,currForm,suppflag);
7774:): }
7775:): }
7776:): }
1.484.2.13 raeburn 7777: }
7778: resize_scrollbox('contentscroll','1','1');
7779: return;
7780: }
7781:
1.484.2.19 raeburn 7782: function toggleMap(caller) {
1.484.2.13 raeburn 7783: var disp = 'none';
1.484.2.19 raeburn 7784: if (document.getElementById('importmapform')) {
7785: if (caller == 'map') {
7786: var curr = document.getElementById('importmapform').style.display;
7787: if (curr == 'none') {
7788: disp='block';
7789: }
1.484.2.12 raeburn 7790: }
1.484.2.19 raeburn 7791: document.getElementById('importmapform').style.display=disp;
7792: resize_scrollbox('contentscroll','1','1');
1.484.2.12 raeburn 7793: }
1.484.2.19 raeburn 7794: return;
1.329 droeschl 7795: }
7796:
1.484.2.12 raeburn 7797: function makeims(imsform) {
7798: if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
1.484.2.61 raeburn 7799: alert("$js_lt{'imsfile'}");
1.484.2.12 raeburn 7800: return;
7801: }
7802: if (imsform.source.selectedIndex == 0) {
1.484.2.61 raeburn 7803: alert("$js_lt{'imscms'}");
1.484.2.12 raeburn 7804: return;
7805: }
7806: newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
7807: imsform.submit();
7808: }
7809:
1.478 raeburn 7810: function updatePick(targetform,index,caller) {
1.484.2.29 raeburn 7811: var pickitem;
7812: var picknumitem;
7813: var picknumtext;
7814: if (index == 'all') {
7815: pickitem = document.getElementById('randompickall');
7816: picknumitem = document.getElementById('rpicknumall');
7817: picknumtext = document.getElementById('rpicktextall');
7818: } else {
7819: pickitem = document.getElementById('randompick_'+index);
7820: picknumitem = document.getElementById('rpicknum_'+index);
7821: picknumtext = document.getElementById('randompicknum_'+index);
7822: }
1.478 raeburn 7823: if (pickitem.checked) {
1.484.2.61 raeburn 7824: var picknum=prompt('$js_lt{"rpck"}',picknumitem.value);
1.478 raeburn 7825: if (picknum == '' || picknum == null) {
7826: if (caller == 'check') {
7827: pickitem.checked=false;
1.484.2.29 raeburn 7828: if (index == 'all') {
7829: picknumtext.innerHTML = '';
7830: if (caller == 'link') {
7831: propagateState(targetform,'rpicknum');
7832: }
7833: } else {
1.484.2.30 raeburn 7834: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 7835: }
1.478 raeburn 7836: }
7837: } else {
7838: picknum.toString();
7839: var regexdigit=/^\\d+\$/;
7840: if (regexdigit.test(picknum)) {
7841: picknumitem.value = picknum;
1.484.2.29 raeburn 7842: if (index == 'all') {
1.484.2.30 raeburn 7843: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.cumulativesettings,\\'all\\',\\'link\\');">'+picknum+'</a>';
1.484.2.29 raeburn 7844: if (caller == 'link') {
7845: propagateState(targetform,'rpicknum');
7846: }
7847: } else {
7848: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.edit_randompick_'+index+',\\''+index+'\\',\\'link\\');">'+picknum+'</a>';
1.484.2.30 raeburn 7849: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 7850: }
1.478 raeburn 7851: } else {
7852: if (caller == 'check') {
1.484.2.29 raeburn 7853: if (index == 'all') {
7854: picknumtext.innerHTML = '';
7855: if (caller == 'link') {
7856: propagateState(targetform,'rpicknum');
7857: }
7858: } else {
7859: pickitem.checked=false;
1.484.2.30 raeburn 7860: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 7861: }
1.478 raeburn 7862: }
7863: return;
7864: }
7865: }
7866: } else {
1.484.2.29 raeburn 7867: picknumitem.value = '';
7868: picknumtext.innerHTML = '';
7869: if (index == 'all') {
7870: if (caller == 'link') {
7871: propagateState(targetform,'rpicknum');
7872: }
7873: } else {
1.484.2.30 raeburn 7874: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 7875: }
7876: }
7877: }
7878:
7879: function propagateState(form,param) {
7880: if (document.getElementById(param+'all')) {
7881: var setcheck = 0;
7882: var rpick = 0;
7883: if (param == 'rpicknum') {
7884: if (document.getElementById('randompickall')) {
7885: if (document.getElementById('randompickall').checked) {
7886: if (document.getElementById('rpicknumall')) {
7887: rpick = document.getElementById('rpicknumall').value;
7888: }
7889: }
7890: }
7891: } else {
7892: if (document.getElementById(param+'all').checked) {
7893: setcheck = 1;
7894: }
7895: }
1.484.2.30 raeburn 7896: var allidxlist;
7897: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
7898: if (document.getElementById('all'+param+'idx')) {
7899: allidxlist = document.getElementById('all'+param+'idx').value;
7900: }
7901: var actions = new Array ('remove','cut','copy');
7902: for (var i=0; i<actions.length; i++) {
7903: if (actions[i] != param) {
7904: if (document.getElementById(actions[i]+'all')) {
7905: document.getElementById(actions[i]+'all').checked = false;
7906: }
7907: }
7908: }
7909: }
1.484.2.29 raeburn 7910: if ((param == 'encrypturl') || (param == 'hiddenresource')) {
1.484.2.30 raeburn 7911: allidxlist = form.allidx.value;
7912: }
7913: if ((param == 'randompick') || (param == 'rpicknum') || (param == 'randomorder')) {
7914: allidxlist = form.allmapidx.value;
7915: }
7916: if ((allidxlist != '') && (allidxlist != null)) {
7917: var allidxs = allidxlist.split(',');
7918: if (allidxs.length > 1) {
7919: for (var i=0; i<allidxs.length; i++) {
7920: if (document.getElementById(param+'_'+allidxs[i])) {
7921: if (param == 'rpicknum') {
7922: if (document.getElementById('randompick_'+allidxs[i])) {
7923: if (document.getElementById('randompick_'+allidxs[i]).checked) {
7924: document.getElementById(param+'_'+allidxs[i]).value = rpick;
7925: if (rpick > 0) {
7926: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = ': <a href="javascript:updatePick(document.edit_randompick_'+allidxs[i]+',\\''+allidxs[i]+'\\',\\'link\\')">'+rpick+'</a>';
7927: } else {
7928: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
7929: }
7930: }
7931: }
7932: } else {
1.484.2.29 raeburn 7933: if (setcheck == 1) {
7934: document.getElementById(param+'_'+allidxs[i]).checked = true;
7935: } else {
7936: document.getElementById(param+'_'+allidxs[i]).checked = false;
1.484.2.30 raeburn 7937: if (param == 'randompick') {
7938: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
7939: }
1.484.2.29 raeburn 7940: }
7941: }
7942: }
7943: }
1.484.2.30 raeburn 7944: if (setcheck == 1) {
7945: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
7946: var actions = new Array('copy','cut','remove');
7947: for (var i=0; i<actions.length; i++) {
7948: var otheractions;
7949: var otheridxs;
7950: if (actions[i] === param) {
7951: continue;
7952: } else {
7953: if (document.getElementById('all'+actions[i]+'idx')) {
7954: otheractions = document.getElementById('all'+actions[i]+'idx').value;
7955: otheridxs = otheractions.split(',');
7956: if (otheridxs.length > 1) {
7957: for (var j=0; j<otheridxs.length; j++) {
7958: if (document.getElementById(actions[i]+'_'+otheridxs[j])) {
7959: document.getElementById(actions[i]+'_'+otheridxs[j]).checked = false;
7960: }
1.484.2.29 raeburn 7961: }
7962: }
7963: }
7964: }
1.484.2.30 raeburn 7965: }
1.484.2.29 raeburn 7966: }
7967: }
7968: }
7969: }
1.478 raeburn 7970: }
1.484.2.29 raeburn 7971: return;
7972: }
7973:
1.484.2.63 raeburn 7974: function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder,confirm_removal) {
1.484.2.67 raeburn 7975: var canedit = '$canedit';
7976: if (canedit == '') {
7977: alert("$js_lt{'edri'}");
7978: return;
7979: }
1.484.2.30 raeburn 7980: var dosettings;
7981: var doaction;
7982: var control = document.togglemultsettings;
7983: if (context == 'actions') {
7984: control = document.togglemultactions;
7985: doaction = 1;
7986: } else {
7987: dosettings = 1;
7988: }
7989: if (control) {
7990: if (control.showmultpick.length) {
7991: for (var i=0; i<control.showmultpick.length; i++) {
7992: if (control.showmultpick[i].checked) {
7993: if (control.showmultpick[i].value == 1) {
7994: if (context == 'settings') {
7995: dosettings = 0;
7996: } else {
7997: doaction = 0;
7998: }
7999: }
8000: }
8001: }
8002: }
8003: }
8004: if (context == 'settings') {
8005: if (dosettings == 1) {
8006: targetform.changeparms.value=param;
8007: targetform.submit();
8008: }
8009: }
8010: if (context == 'actions') {
8011: if (doaction == 1) {
8012: targetform.cmd.value=param+'_'+index;
8013: targetform.folderpath.value=folderpath;
8014: targetform.markcopy.value=idx+':'+param;
8015: targetform.copyfolder.value=folder+'.'+container;
8016: if (param == 'remove') {
1.484.2.63 raeburn 8017: var doremove = 0;
8018: if (skip_confirm) {
8019: if (confirm_removal) {
8020: if (confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'"$js_lt{"p_rmr2b"}')) {
8021: doremove = 1;
8022: }
8023: } else {
8024: doremove = 1;
8025: }
8026: } else {
8027: if (confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'" $js_lt{"p_rmr2b"}')) {
8028: doremove = 1;
8029: }
8030: }
8031: if (doremove) {
1.484.2.30 raeburn 8032: targetform.markcopy.value='';
8033: targetform.copyfolder.value='';
1.484.2.29 raeburn 8034: targetform.submit();
8035: }
8036: }
1.484.2.30 raeburn 8037: if (param == 'cut') {
1.484.2.61 raeburn 8038: 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 8039: targetform.submit();
8040: return;
8041: }
8042: }
8043: if (param == 'copy') {
8044: targetform.submit();
8045: return;
8046: }
8047: targetform.markcopy.value='';
8048: targetform.copyfolder.value='';
8049: targetform.cmd.value='';
8050: targetform.folderpath.value='';
8051: return;
8052: } else {
8053: if (document.getElementById(param+'_'+idx)) {
8054: item = document.getElementById(param+'_'+idx);
8055: if (item.type == 'checkbox') {
8056: if (item.checked) {
8057: item.checked = false;
8058: } else {
8059: item.checked = true;
8060: singleCheck(item,idx,param);
8061: }
8062: }
8063: }
8064: }
8065: }
8066: return;
8067: }
8068:
8069: function singleCheck(caller,idx,action) {
8070: actions = new Array('cut','copy','remove');
8071: if (caller.checked) {
8072: for (var i=0; i<actions.length; i++) {
8073: if (actions[i] != action) {
8074: if (document.getElementById(actions[i]+'_'+idx)) {
8075: if (document.getElementById(actions[i]+'_'+idx).checked) {
8076: document.getElementById(actions[i]+'_'+idx).checked = false;
8077: }
8078: }
8079: }
1.484.2.29 raeburn 8080: }
8081: }
8082: return;
1.478 raeburn 8083: }
8084:
1.334 muellerd 8085: function unselectInactive(nav) {
1.335 ehlerst 8086: currentNav = document.getElementById(nav);
8087: currentLis = currentNav.getElementsByTagName('LI');
8088: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 8089: if (currentLis[i].className == 'goback') {
8090: currentLis[i].className = 'goback';
8091: } else {
8092: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 8093: currentLis[i].className = 'right';
1.472 raeburn 8094: } else {
1.374 tempelho 8095: currentLis[i].className = 'i';
1.472 raeburn 8096: }
8097: }
1.335 ehlerst 8098: }
1.332 tempelho 8099: }
8100:
1.334 muellerd 8101: function hideAll(current, nav, data) {
1.335 ehlerst 8102: unselectInactive(nav);
1.484.2.43 raeburn 8103: if (current) {
8104: if (current.className == 'right'){
1.374 tempelho 8105: current.className = 'right active'
1.484.2.43 raeburn 8106: } else {
1.374 tempelho 8107: current.className = 'active';
1.484.2.43 raeburn 8108: }
1.374 tempelho 8109: }
1.335 ehlerst 8110: currentData = document.getElementById(data);
8111: currentDivs = currentData.getElementsByTagName('DIV');
8112: for (i = 0; i < currentDivs.length; i++) {
8113: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 8114: currentDivs[i].style.display = 'none';
1.330 tempelho 8115: }
8116: }
1.335 ehlerst 8117: }
1.330 tempelho 8118:
1.374 tempelho 8119: function openTabs(pageId) {
8120: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 8121: if(tabnav.length > 2 ){
1.389 tempelho 8122: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 8123: currentLis = currentNav.getElementsByTagName('LI');
8124: for(i = 0; i< currentLis.length; i++){
8125: if(currentLis[i].className == 'active') {
1.375 tempelho 8126: funcString = currentLis[i].onclick.toString();
8127: tab = funcString.split('"');
1.420 onken 8128: if(tab.length < 2) {
8129: tab = funcString.split("'");
8130: }
1.375 tempelho 8131: currentData = document.getElementById(tab[1]);
8132: currentData.style.display = 'block';
1.374 tempelho 8133: }
8134: }
8135: }
8136: }
8137:
1.334 muellerd 8138: function showPage(current, pageId, nav, data) {
1.484.2.43 raeburn 8139: currstate = current.className;
1.334 muellerd 8140: hideAll(current, nav, data);
1.375 tempelho 8141: openTabs(pageId);
1.334 muellerd 8142: unselectInactive(nav);
1.484.2.43 raeburn 8143: if ((currstate == 'active') || (currstate == 'right active')) {
8144: if (currstate == 'active') {
8145: current.className = '';
8146: } else {
8147: current.className = 'right';
8148: }
8149: activeTab = '';
8150: toggleUpload();
8151: toggleMap();
8152: resize_scrollbox('contentscroll','1','0');
8153: return;
8154: } else {
8155: current.className = 'active';
8156: }
1.330 tempelho 8157: currentData = document.getElementById(pageId);
8158: currentData.style.display = 'block';
1.458 raeburn 8159: activeTab = pageId;
1.484.2.12 raeburn 8160: toggleUpload();
1.484.2.14 raeburn 8161: toggleMap();
1.433 raeburn 8162: if (nav == 'mainnav') {
8163: var storedpath = "$docs_folderpath";
1.434 raeburn 8164: var storedpage = "$main_container_page";
1.433 raeburn 8165: var reg = new RegExp("^supplemental");
8166: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 8167: if (storedpage == 1) {
8168: document.simpleedit.folderpath.value = '';
8169: document.uploaddocument.folderpath.value = '';
8170: } else {
8171: if (reg.test(storedpath)) {
8172: document.simpleedit.folderpath.value = '$toplevelmain';
8173: document.uploaddocument.folderpath.value = '$toplevelmain';
8174: document.newext.folderpath.value = '$toplevelmain';
8175: } else {
8176: document.simpleedit.folderpath.value = storedpath;
8177: document.uploaddocument.folderpath.value = storedpath;
8178: document.newext.folderpath.value = storedpath;
8179: }
1.433 raeburn 8180: }
8181: } else {
1.434 raeburn 8182: if (reg.test(storedpath)) {
8183: document.simpleedit.folderpath.value = storedpath;
8184: document.supuploaddocument.folderpath.value = storedpath;
8185: document.supnewext.folderpath.value = storedpath;
8186: } else {
1.433 raeburn 8187: document.simpleedit.folderpath.value = '$toplevelsupp';
8188: document.supuploaddocument.folderpath.value = '$toplevelsupp';
8189: document.supnewext.folderpath.value = '$toplevelsupp';
8190: }
8191: }
8192: }
1.484.2.3 raeburn 8193: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 8194: return false;
8195: }
1.329 droeschl 8196:
1.472 raeburn 8197: function toContents(jumpto) {
8198: var newurl = '$backtourl';
1.484.2.21 raeburn 8199: if ((newurl == '/adm/navmaps') && (jumpto != '')) {
1.472 raeburn 8200: newurl = newurl+'?postdata='+jumpto;
8201: }
8202: location.href=newurl;
8203: }
8204:
1.484.2.30 raeburn 8205: function togglePick(caller,value) {
8206: var disp = 'none';
8207: if (document.getElementById('multi'+caller)) {
8208: var curr = document.getElementById('multi'+caller).style.display;
8209: if (value == 1) {
8210: disp='block';
8211: }
8212: if (curr == disp) {
8213: return;
8214: }
8215: document.getElementById('multi'+caller).style.display=disp;
8216: if (value == 1) {
1.484.2.61 raeburn 8217: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.484.2.30 raeburn 8218: } else {
8219: document.getElementById('more'+caller).innerHTML = '';
8220: }
8221: if (caller == 'actions') {
8222: setClass(value);
8223: setBoxes(value);
8224: }
8225: }
8226: var showButton = multiSettings();
8227: if (showButton != 1) {
8228: showButton = multiActions();
8229: }
8230: if (document.getElementById('multisave')) {
8231: if (showButton == 1) {
8232: document.getElementById('multisave').style.display='block';
8233: } else {
8234: document.getElementById('multisave').style.display='none';
8235: }
8236: }
8237: resize_scrollbox('contentscroll','1','1');
8238: return;
8239: }
8240:
8241: function toggleCheckUncheck(caller,more) {
8242: if (more == 1) {
1.484.2.61 raeburn 8243: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',0);" style="text-decoration:none;">$js_lt{'less'}</a>';
1.484.2.30 raeburn 8244: document.getElementById('allfields'+caller).style.display='block';
8245: } else {
1.484.2.61 raeburn 8246: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.484.2.30 raeburn 8247: document.getElementById('allfields'+caller).style.display='none';
8248: }
8249: resize_scrollbox('contentscroll','1','1');
8250: }
8251:
8252: function multiSettings() {
8253: var inuse = 0;
8254: var settingsform = document.togglemultsettings;
8255: if (settingsform.showmultpick.length > 1) {
8256: for (var i=0; i<settingsform.showmultpick.length; i++) {
8257: if (settingsform.showmultpick[i].checked) {
8258: if (settingsform.showmultpick[i].value == 1) {
8259: inuse = 1;
8260: }
8261: }
8262: }
8263: }
8264: return inuse;
8265: }
8266:
8267: function multiActions() {
8268: var inuse = 0;
8269: var actionsform = document.togglemultactions;
8270: if (actionsform.showmultpick.length > 1) {
8271: for (var i=0; i<actionsform.showmultpick.length; i++) {
8272: if (actionsform.showmultpick[i].checked) {
8273: if (actionsform.showmultpick[i].value == 1) {
8274: inuse = 1;
8275: }
8276: }
8277: }
8278: }
8279: return inuse;
8280: }
8281:
8282: function checkSubmits() {
8283: var numchanges = 0;
8284: var form = document.saveactions;
8285: var doactions = multiActions();
8286: var cutwarnings = 0;
8287: var remwarnings = 0;
1.484.2.63 raeburn 8288: var removalinfo = 0;
1.484.2.30 raeburn 8289: if (doactions == 1) {
8290: var remidxlist = document.cumulativeactions.allremoveidx.value;
8291: if ((remidxlist != '') && (remidxlist != null)) {
8292: var remidxs = remidxlist.split(',');
8293: for (var i=0; i<remidxs.length; i++) {
8294: if (document.getElementById('remove_'+remidxs[i])) {
8295: if (document.getElementById('remove_'+remidxs[i]).checked) {
8296: form.multiremove.value += remidxs[i]+',';
8297: numchanges ++;
8298: if (document.getElementById('skip_remove_'+remidxs[i])) {
8299: if (document.getElementById('skip_remove_'+remidxs[i]).value == 0) {
8300: remwarnings ++;
8301: }
8302: }
1.484.2.63 raeburn 8303: if (document.getElementById('confirm_removal_'+remidxs[i])) {
8304: if (document.getElementById('confirm_removal_'+remidxs[i]).value == 1) {
8305: removalinfo ++;
8306: }
8307: }
1.484.2.30 raeburn 8308: }
8309: }
8310: }
8311: }
8312: var cutidxlist = document.cumulativeactions.allcutidx.value;
8313: if ((cutidxlist != '') && (cutidxlist != null)) {
8314: var cutidxs = cutidxlist.split(',');
8315: for (var i=0; i<cutidxs.length; i++) {
8316: if (document.getElementById('cut_'+cutidxs[i])) {
8317: if (document.getElementById('cut_'+cutidxs[i]).checked == true) {
8318: form.multicut.value += cutidxs[i]+',';
8319: numchanges ++;
8320: if (document.getElementById('skip_cut_'+cutidxs[i])) {
8321: if (document.getElementById('skip_cut_'+cutidxs[i]).value == 0) {
8322: cutwarnings ++;
8323: }
8324: }
8325: }
8326: }
8327: }
8328: }
8329: var copyidxlist = document.cumulativeactions.allcopyidx.value;
8330: if ((copyidxlist != '') && (copyidxlist != null)) {
8331: var copyidxs = copyidxlist.split(',');
8332: for (var i=0; i<copyidxs.length; i++) {
8333: if (document.getElementById('copy_'+copyidxs[i])) {
8334: if (document.getElementById('copy_'+copyidxs[i]).checked) {
8335: form.multicopy.value += copyidxs[i]+',';
8336: numchanges ++;
8337: }
8338: }
8339: }
8340: }
8341: if (numchanges > 0) {
8342: form.multichange.value = numchanges;
8343: }
8344: }
8345: var dosettings = multiSettings();
8346: var haschanges = 0;
8347: if (dosettings == 1) {
8348: form.allencrypturl.value = '';
8349: form.allhiddenresource.value = '';
8350: form.changeparms.value = 'all';
8351: var patt=new RegExp(",\$");
8352: var allidxlist = document.cumulativesettings.allidx.value;
8353: if ((allidxlist != '') && (allidxlist != null)) {
8354: var allidxs = allidxlist.split(',');
8355: if (allidxs.length > 1) {
8356: for (var i=0; i<allidxs.length; i++) {
8357: if (document.getElementById('hiddenresource_'+allidxs[i])) {
8358: if (document.getElementById('hiddenresource_'+allidxs[i]).checked) {
8359: form.allhiddenresource.value += allidxs[i]+',';
8360: }
8361: }
8362: if (document.getElementById('encrypturl_'+allidxs[i])) {
8363: if (document.getElementById('encrypturl_'+allidxs[i]).checked) {
8364: form.allencrypturl.value += allidxs[i]+',';
8365: }
1.484.2.29 raeburn 8366: }
8367: }
1.484.2.30 raeburn 8368: form.allhiddenresource.value = form.allhiddenresource.value.replace(patt,"");
8369: form.allencrypturl.value = form.allencrypturl.value.replace(patt,"");
8370: }
8371: }
8372: form.allrandompick.value = '';
8373: form.allrandomorder.value = '';
8374: var allmapidxlist = document.cumulativesettings.allmapidx.value;
8375: if ((allmapidxlist != '') && (allmapidxlist != null)) {
8376: var allmapidxs = allmapidxlist.split(',');
8377: for (var i=0; i<allmapidxs.length; i++) {
8378: var randompick = document.getElementById('randompick_'+allmapidxs[i]);
8379: var rpicknum = document.getElementById('rpicknum_'+allmapidxs[i]);
8380: var randorder = document.getElementById('randomorder_'+allmapidxs[i]);
8381: if ((randompick.checked) && (rpicknum.value != '')) {
8382: form.allrandompick.value += allmapidxs[i]+':'+rpicknum.value+',';
8383: }
8384: if (randorder.checked) {
8385: form.allrandomorder.value += allmapidxs[i]+',';
8386: }
8387: }
8388: form.allrandompick.value = form.allrandompick.value.replace(patt,"");
8389: form.allrandomorder.value = form.allrandomorder.value.replace(patt,"");
8390: }
8391: if (document.cumulativesettings.currhiddenresource.value != form.allhiddenresource.value) {
8392: haschanges = 1;
8393: }
8394: if (document.cumulativesettings.currencrypturl.value != form.allencrypturl.value) {
8395: haschanges = 1;
8396: }
8397: if (document.cumulativesettings.currrandomorder.value != form.allrandomorder.value) {
8398: haschanges = 1;
8399: }
8400: if (document.cumulativesettings.currrandompick.value != form.allrandompick.value) {
8401: haschanges = 1;
8402: }
8403: }
8404: if (doactions == 1) {
8405: if (numchanges > 0) {
1.484.2.63 raeburn 8406: if ((cutwarnings > 0) || (remwarnings > 0) || (removalinfo > 0)) {
1.484.2.30 raeburn 8407: if (remwarnings > 0) {
1.484.2.61 raeburn 8408: if (!confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr3a"} '+remwarnings+' $js_lt{"p_rmr3b"}')) {
1.484.2.30 raeburn 8409: return false;
8410: }
8411: }
1.484.2.63 raeburn 8412: if (removalinfo > 0) {
8413: if (!confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr3a"} '+removalinfo+' $js_lt{"p_rmr3b"}')) {
8414: return false;
8415: }
8416: }
1.484.2.30 raeburn 8417: if (cutwarnings > 0) {
1.484.2.61 raeburn 8418: 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 8419: return false;
1.484.2.29 raeburn 8420: }
8421: }
8422: }
1.484.2.30 raeburn 8423: form.submit();
8424: return true;
8425: }
8426: }
8427: if (dosettings == 1) {
8428: if (haschanges == 1) {
8429: form.submit();
8430: return true;
1.484.2.29 raeburn 8431: }
8432: }
1.484.2.30 raeburn 8433: if ((dosettings == 1) && (doactions == 1)) {
1.484.2.61 raeburn 8434: alert("$js_lt{'noor'}");
1.484.2.30 raeburn 8435: } else {
8436: if (dosettings == 1) {
1.484.2.61 raeburn 8437: alert("$js_lt{'noch'}");
1.484.2.30 raeburn 8438: } else {
1.484.2.61 raeburn 8439: alert("$js_lt{'noac'}");
1.484.2.30 raeburn 8440: }
8441: }
8442: return false;
8443: }
8444:
8445: function setClass(value) {
8446: var cutclass = 'LC_docs_cut';
8447: var copyclass = 'LC_docs_copy';
8448: var removeclass = 'LC_docs_remove';
8449: var cutreg = new RegExp("\\\\b"+cutclass+"\\\\b");
8450: var copyreg = new RegExp("\\\\b"+copyclass+"\\\\b");
8451: var removereg = new RegExp("\\\\"+removeclass+"\\\\b");
8452: var links = document.getElementsByTagName('a');
8453: for (var i=0; i<links.length; i++) {
8454: var classes = links[i].className;
8455: if (cutreg.test(classes)) {
8456: links[i].className = cutclass;
8457: if (value == 1) {
8458: links[i].className += " LC_menubuttons_link";
1.484.2.29 raeburn 8459: }
1.484.2.30 raeburn 8460: } else {
8461: if (copyreg.test(classes)) {
8462: links[i].className = copyclass;
8463: if (value == 1) {
8464: links[i].className += " LC_menubuttons_link";
8465: }
8466: } else {
8467: if (removereg.test(classes)) {
8468: links[i].className = removeclass;
8469: if (value == 1) {
8470: links[i].className += " LC_menubuttons_link";
8471: }
8472: }
1.484.2.29 raeburn 8473: }
8474: }
8475: }
1.484.2.30 raeburn 8476: return;
1.484.2.29 raeburn 8477: }
8478:
1.484.2.30 raeburn 8479: function setBoxes(value) {
8480: var remidxlist = document.cumulativeactions.allremoveidx.value;
8481: if ((remidxlist != '') && (remidxlist != null)) {
8482: var remidxs = remidxlist.split(',');
8483: for (var i=0; i<remidxs.length; i++) {
8484: if (document.getElementById('remove_'+remidxs[i])) {
8485: var item = document.getElementById('remove_'+remidxs[i]);
8486: if (value == 1) {
8487: item.className = 'LC_docs_remove';
8488: } else {
8489: item.className = 'LC_hidden';
8490: }
8491: }
1.484.2.29 raeburn 8492: }
8493: }
1.484.2.30 raeburn 8494: var cutidxlist = document.cumulativeactions.allcutidx.value;
8495: if ((cutidxlist != '') && (cutidxlist != null)) {
8496: var cutidxs = cutidxlist.split(',');
8497: for (var i=0; i<cutidxs.length; i++) {
8498: if (document.getElementById('cut_'+cutidxs[i])) {
8499: var item = document.getElementById('cut_'+cutidxs[i]);
8500: if (value == 1) {
8501: item.className = 'LC_docs_cut';
8502: } else {
8503: item.className = 'LC_hidden';
8504: }
8505: }
8506: }
8507: }
8508: var copyidxlist = document.cumulativeactions.allcopyidx.value;
8509: if ((copyidxlist != '') && (copyidxlist != null)) {
8510: var copyidxs = copyidxlist.split(',');
8511: for (var i=0; i<copyidxs.length; i++) {
8512: if (document.getElementById('copy_'+copyidxs[i])) {
8513: var item = document.getElementById('copy_'+copyidxs[i]);
8514: if (value == 1) {
8515: item.className = 'LC_docs_copy';
8516: } else {
8517: item.className = 'LC_hidden';
8518: }
8519: }
1.484.2.29 raeburn 8520: }
8521: }
8522: return;
8523: }
8524:
1.484.2.67 raeburn 8525: ENDSCRIPT
1.329 droeschl 8526: }
1.457 raeburn 8527:
1.483 raeburn 8528: sub history_tab_js {
8529: return <<"ENDHIST";
8530: function toggleHistoryDisp(choice) {
8531: document.docslogform.docslog.value = choice;
8532: document.docslogform.submit();
8533: return;
8534: }
8535:
8536: ENDHIST
8537: }
8538:
1.484 raeburn 8539: sub inject_data_js {
8540: return <<ENDINJECT;
8541:
8542: function injectData(current, hiddenField, name, value) {
8543: currentElement = document.getElementById(hiddenField);
8544: currentElement.name = name;
8545: currentElement.value = value;
8546: current.submit();
8547: }
8548:
8549: ENDINJECT
8550: }
8551:
8552: sub dump_switchserver_js {
8553: my @hosts = @_;
1.484.2.61 raeburn 8554: my %js_lt = &Apache::lonlocal::texthash(
1.484.2.46 raeburn 8555: dump => 'Copying content to Authoring Space requires switching server.',
1.484 raeburn 8556: swit => 'Switch server?',
1.484.2.61 raeburn 8557: );
8558: my %html_js_lt = &Apache::lonlocal::texthash(
8559: swit => 'Switch server?',
1.484.2.43 raeburn 8560: duco => 'Copying Content to Authoring Space',
1.484 raeburn 8561: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
8562: chos => 'Choose server',
8563: );
1.484.2.61 raeburn 8564: &js_escape(\%js_lt);
8565: &html_escape(\%html_js_lt);
8566: &js_escape(\%html_js_lt);
1.484 raeburn 8567: my $role = $env{'request.role'};
8568: my $js = <<"ENDSWJS";
8569: <script type="text/javascript">
8570: function write_switchserver() {
8571: var server;
8572: if (document.setserver.posshosts.length > 0) {
8573: for (var i=0; i<document.setserver.posshosts.length; i++) {
8574: if (document.setserver.posshosts[i].checked) {
8575: server = document.setserver.posshosts[i].value;
8576: }
8577: }
8578: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
8579: }
8580: window.close();
8581: }
8582: </script>
8583:
8584: ENDSWJS
8585:
8586: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
8587: {'only_body' => 1,
8588: 'js_ready' => 1,});
8589: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
8590:
8591: my $hostpicker;
8592: my $count = 0;
8593: foreach my $host (sort(@hosts)) {
8594: my $checked;
8595: if ($count == 0) {
8596: $checked = ' checked="checked"';
8597: }
8598: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
8599: $host.'"'.$checked.' />'.$host.'</label> ';
8600: $count++;
8601: }
8602:
8603: return <<"ENDSWITCHJS";
8604:
8605: function dump_needs_switchserver(url) {
8606: if (url!='' && url!= null) {
1.484.2.61 raeburn 8607: if (confirm("$js_lt{'dump'}\\n$js_lt{'swit'}")) {
1.484 raeburn 8608: go(url);
8609: }
8610: }
8611: return;
8612: }
8613:
8614: function choose_switchserver_window() {
8615: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
8616: newWindow.document.open();
8617: newWindow.document.writeln('$startpage');
1.484.2.61 raeburn 8618: newWindow.document.write('<h3>$html_js_lt{'duco'}<\\/h3>\\n'+
8619: '<p>$html_js_lt{'yone'}<\\/p>\\n'+
8620: '<div class="LC_left_float"><fieldset><legend>$html_js_lt{'chos'}<\\/legend>\\n'+
1.484 raeburn 8621: '<form name="setserver" method="post" action="" \\/>\\n'+
8622: '$hostpicker\\n'+
8623: '<br \\/><br \\/>\\n'+
1.484.2.61 raeburn 8624: '<input type="button" name="makeswitch" value="$html_js_lt{'swit'}" '+
1.484 raeburn 8625: 'onclick="write_switchserver();" \\/>\\n'+
8626: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
8627: newWindow.document.writeln('$endpage');
8628: newWindow.document.close();
8629: newWindow.focus();
8630: }
8631:
8632: ENDSWITCHJS
8633: }
8634:
8635: sub makedocslogform {
8636: my ($formelems,$docslog) = @_;
8637: return <<"LOGSFORM";
8638: <form action="/adm/coursedocs" method="post" name="docslogform">
8639: <input type="hidden" name="docslog" value="$docslog" />
8640: $formelems
8641: </form>
8642: LOGSFORM
8643: }
8644:
8645: sub makesimpleeditform {
8646: my ($formelems) = @_;
8647: return <<"SIMPFORM";
8648: <form name="simpleedit" method="post" action="/adm/coursedocs">
8649: <input type="hidden" name="importdetail" value="" />
8650: $formelems
8651: </form>
8652: SIMPFORM
8653: }
8654:
1.329 droeschl 8655: 1;
8656: __END__
8657:
8658:
8659: =head1 NAME
8660:
8661: Apache::londocs.pm
8662:
8663: =head1 SYNOPSIS
8664:
8665: This is part of the LearningOnline Network with CAPA project
8666: described at http://www.lon-capa.org.
8667:
8668: =head1 SUBROUTINES
8669:
8670: =over
8671:
8672: =item %help=()
8673:
8674: Available help topics
8675:
8676: =item mapread()
8677:
1.344 bisitz 8678: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 8679: @order and @resources, determines status
8680: sets @order - pointer to resources in right order
8681: sets @resources - array with the resources with correct idx
8682:
8683: =item authorhosts()
8684:
8685: Return hash with valid author names
8686:
8687: =item clean()
8688:
8689: =item dumpcourse()
8690:
8691: Actually dump course
8692:
8693: =item group_import()
8694:
8695: Imports the given (name, url) resources into the course
8696: coursenum, coursedom, and folder must precede the list
8697:
8698: =item breadcrumbs()
8699:
8700: =item log_docs()
8701:
8702: =item docs_change_log()
8703:
8704: =item update_paste_buffer()
8705:
8706: =item print_paste_buffer()
8707:
8708: =item do_paste_from_buffer()
8709:
1.484.2.30 raeburn 8710: =item do_buffer_empty()
8711:
8712: =item clear_from_buffer()
8713:
1.484.2.7 raeburn 8714: =item get_newmap_url()
8715:
8716: =item dbcopy()
8717:
8718: =item uniqueness_check()
8719:
8720: =item contained_map_check()
8721:
8722: =item url_paste_fixups()
8723:
8724: =item apply_fixups()
8725:
8726: =item copy_dependencies()
8727:
1.329 droeschl 8728: =item update_parameter()
8729:
8730: =item handle_edit_cmd()
8731:
8732: =item editor()
8733:
8734: =item process_file_upload()
8735:
8736: =item process_secondary_uploads()
8737:
8738: =item is_supplemental_title()
8739:
8740: =item entryline()
8741:
8742: =item tiehash()
8743:
8744: =item untiehash()
8745:
8746: =item checkonthis()
8747:
8748: check on this
8749:
8750: =item verifycontent()
8751:
8752: Verify Content
8753:
1.484.2.78 raeburn 8754: =item devalidateversioncache()
8755:
8756: =item checkversions()
1.329 droeschl 8757:
8758: Check Versions
8759:
8760: =item mark_hash_old()
8761:
8762: =item is_hash_old()
8763:
8764: =item changewarning()
8765:
8766: =item init_breadcrumbs()
8767:
8768: Breadcrumbs for special functions
8769:
1.484 raeburn 8770: =item create_list_elements()
8771:
8772: =item create_form_ul()
8773:
8774: =item startContentScreen()
8775:
8776: =item endContentScreen()
8777:
8778: =item supplemental_base()
8779:
8780: =item embedded_form_elems()
8781:
8782: =item embedded_destination()
8783:
8784: =item return_to_editor()
8785:
8786: =item decompression_info()
8787:
8788: =item decompression_phase_one()
8789:
8790: =item decompression_phase_two()
8791:
8792: =item remove_archive()
8793:
8794: =item generate_admin_menu()
8795:
8796: =item generate_edit_table()
8797:
8798: =item editing_js()
8799:
8800: =item history_tab_js()
8801:
8802: =item inject_data_js()
8803:
8804: =item dump_switchserver_js()
8805:
1.484.2.3 raeburn 8806: =item resize_scrollbox_js()
1.484 raeburn 8807:
8808: =item makedocslogform()
8809:
1.484.2.3 raeburn 8810: =item makesimpleeditform()
8811:
1.329 droeschl 8812: =back
8813:
8814: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>