Annotation of loncom/interface/londocs.pm, revision 1.484.2.93.2.13
1.329 droeschl 1: # The LearningOnline Network
2: # Documents
3: #
1.484.2.93.2. 3(raebur 4:3): # $Id: londocs.pm,v 1.484.2.93.2.12 2023/07/06 02:04:21 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'});
1419: my ($pasteitems,@pasteable);
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. (raeburn 1432:): $canpaste,$nopaste,$othercrs,$areachange,$is_exttool);
1.484.2.30 raeburn 1433: my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1];
1434: if ($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
1435: $is_external = 1;
1.484.2.93.2. (raeburn 1436:): } elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$}) {
1437:): $is_exttool = 1;
1.484.2.7 raeburn 1438: }
1.484.2.30 raeburn 1439: if ($folder =~ /^supplemental/) {
1440: $canpaste = &supp_pasteable($env{'docs.markedcopy_url_'.$suffix});
1441: unless ($canpaste) {
1442: $nopaste = &mt('Paste into Supplemental Content unavailable.');
1.484.2.7 raeburn 1443: }
1.484.2.30 raeburn 1444: } else {
1445: $canpaste = 1;
1.484.2.7 raeburn 1446: }
1.484.2.30 raeburn 1447: if ($canpaste) {
1448: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1449: my $srcdom = $1;
1450: my $srcnum = $2;
1451: my $rem = $3;
1452: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
1453: $othercourse = 1;
1454: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1.484.2.76 raeburn 1455: $othercrs = '<br />'.&mt('(from another course)');
1.484.2.30 raeburn 1456: } else {
1457: $canpaste = 0;
1458: $nopaste = &mt('Paste from another course unavailable.');
1.484.2.7 raeburn 1459: }
1460: }
1.484.2.30 raeburn 1461: if ($rem =~ m{^(default|supplemental)_?(\d*)\.(?:page|sequence)$}) {
1462: my $prefix = $1;
1463: $parent = $2;
1464: if ($folder !~ /^\Q$prefix\E/) {
1465: $areachange = 1;
1466: }
1467: $is_uploaded_map = 1;
1468: }
1.484.2.82 raeburn 1469: } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
1.484.2.93.2. (raeburn 1470:): ($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg|ext\.tool)$})) {
1.484.2.76 raeburn 1471: if ($cid ne $env{'request.course.id'}) {
1472: my ($srcdom,$srcnum) = split(/_/,$cid);
1473: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1.484.2.93.2. (raeburn 1474:): if (($is_exttool) && ($srcdom ne $coursedom)) {
1475:): $canpaste = 0;
1476:): $nopaste = &mt('Paste from another domain unavailable.');
1477:): } else {
1478:): $othercrs = '<br />'.&mt('(from another course)');
1479:): }
1.484.2.76 raeburn 1480: } else {
1481: $canpaste = 0;
1482: $nopaste = &mt('Paste from another course unavailable.');
1483: }
1484: }
1485: }
1486: if ($canpaste) {
1487: push(@pasteable,$suffix);
1.484.2.30 raeburn 1488: }
1489: }
1490: my $buffer;
1491: if ($is_external) {
1492: $buffer = &mt('External Resource').': '.
1493: &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('.
1494: &LONCAPA::map::qtescape($url).')';
1.484.2.93.2. (raeburn 1495:): } elsif ($is_exttool) {
1496:): $buffer = &mt('External Tool').': '.
1497:): &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.484.2.30 raeburn 1498: } else {
1499: my $icon = &Apache::loncommon::icon($extension);
1500: if ($extension eq 'sequence' &&
1501: $url =~ m{/default_\d+\.sequence$}x) {
1502: $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
1503: $icon .= '/navmap.folder.closed.gif';
1504: }
1.484.2.57 raeburn 1505: my $title = $env{'docs.markedcopy_title_'.$suffix};
1506: if ($title eq '') {
1507: ($title) = ($url =~ m{/([^/]+)$});
1508: }
1.484.2.30 raeburn 1509: $buffer = '<img src="'.$icon.'" alt="" class="LC_icon" />'.
1510: ': '.
1511: &Apache::loncommon::parse_supplemental_title(
1.484.2.57 raeburn 1512: &LONCAPA::map::qtescape($title));
1.484.2.30 raeburn 1513: }
1514: $pasteitems .= '<div class="LC_left_float">';
1515: my ($options,$onclick);
1516: if (($canpaste) && (!$areachange) && (!$othercourse) &&
1517: ($env{'docs.markedcopy_cmd_'.$suffix} eq 'cut')) {
1518: if (($is_uploaded_map) ||
1519: ($url =~ /(bulletinboard|smppg)$/) ||
1520: ($url =~ m{^/uploaded/$coursedom/$coursenum/(?:docs|supplemental)/(.+)$})) {
1521: $options = &paste_options($suffix,$is_uploaded_map,$parent);
1522: $onclick= 'onclick="showOptions(this,'."'$suffix'".');" ';
1523: }
1524: }
1525: $pasteitems .= '<label><input type="checkbox" name="pasting" id="pasting_'.$suffix.'" value="'.$suffix.'" '.$onclick.'/>'.$buffer.'</label>';
1526: if ($nopaste) {
1.484.2.93.2. (raeburn 1527:): $pasteitems .= ' <span class="LC_cusr_emph">'.$nopaste.'</span>';
1.484.2.30 raeburn 1528: } else {
1529: if ($othercrs) {
1530: $pasteitems .= $othercrs;
1531: }
1532: if ($options) {
1533: $pasteitems .= $options;
1.484.2.7 raeburn 1534: }
1535: }
1.484.2.30 raeburn 1536: $pasteitems .= '</div>';
1537: }
1538: }
1539: if ($pasteitems eq '') {
1540: &Apache::lonnet::delenv('docs.markedcopies');
1541: }
1542: my ($pasteform,$form_start,$buttons,$form_end);
1543: if ($pasteitems) {
1544: $pasteitems .= '<div style="padding:0;clear:both;margin:0;border:0"></div>';
1545: $form_start = '<form name="pasteform" action="/adm/coursedocs" method="post" onsubmit="return validateClipboard();">';
1546: if (@pasteable) {
1.484.2.47 raeburn 1547: my $value = &mt('Paste to current folder');
1548: if ($container eq 'page') {
1549: $value = &mt('Paste to current page');
1550: }
1551: $buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.(' 'x2);
1552: }
1.484.2.93.2. (raeburn 1553:): $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.(' 'x2);
1.484.2.47 raeburn 1554: if ($clipboardcount > 1) {
1555: $buttons .=
1556: '<span style="text-decoration:line-through">'.(' 'x20).'</span>'.(' 'x2).
1557: '<input type="button" name="checkallclip" value="'.&mt('Check all').'" style="height:20px;" onclick="checkClipboard();" />'.
1558: (' 'x2).
1559: '<input type="button" name="uncheckallclip" value="'.&mt('Uncheck all').'" style="height:20px;" onclick="uncheckClipboard();" />'.
1560: (' 'x2);
1.484.2.7 raeburn 1561: }
1.484.2.48 raeburn 1562: $form_end = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'.
1563: '</form>';
1.484.2.30 raeburn 1564: } else {
1565: $pasteitems = &mt('Clipboard is empty');
1566: }
1567: $r->print($form_start
1568: .'<fieldset>'
1569: .'<legend>'.&mt('Clipboard').(' ' x2).$buttons.'</legend>'
1570: .$pasteitems
1571: .'</fieldset>'
1572: .$form_end);
1573: }
1574:
1575: sub paste_options {
1576: my ($suffix,$is_uploaded_map,$parent) = @_;
1577: my ($copytext,$movetext);
1578: if ($is_uploaded_map) {
1579: $copytext = &mt('Copy to new folder');
1580: $movetext = &mt('Move old');
1581: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /bulletinboard$/) {
1582: $copytext = &mt('Copy to new board');
1583: $movetext = &mt('Move (not posts)');
1584: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /smppg$/) {
1585: $copytext = &mt('Copy to new page');
1586: $movetext = &mt('Move');
1.484.2.7 raeburn 1587: } else {
1.484.2.30 raeburn 1588: $copytext = &mt('Copy to new file');
1589: $movetext = &mt('Move');
1590: }
1591: my $output = '<br />'.
1592: '<span id="pasteoptionstext_'.$suffix.'" class="LC_fontsize_small LC_nobreak"></span>'.
1593: '<div id="pasteoptions_'.$suffix.'" class="LC_dccid" style="display:none;"><span class="LC_nobreak">'.(' 'x 4).
1594: '<label>'.
1595: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="new" checked="checked" />'.
1596: $copytext.'</label></span>'.(' 'x2).' '.
1597: '<span class="LC_nobreak"><label>'.
1598: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="move" />'.
1599: $movetext.'</label></span>';
1600: if (($is_uploaded_map) && ($env{'docs.markedcopy_nested_'.$suffix})) {
1601: $output .= '<br /><fieldset><legend>'.&mt('Folder to paste contains sub-folders').
1602: '</legend><table border="0">';
1603: my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1604: my @titles = split(/\Q___&&&___\E/,$env{'docs.markedcopy_nestednames_'.$suffix});
1605: my $lastdir = $parent;
1606: my %depths = (
1607: $lastdir => 0,
1608: );
1609: my (%display,%deps);
1610: for (my $i=0; $i<@pastemaps; $i++) {
1611: ($lastdir,my $subfolderstr) = split(/\:/,$pastemaps[$i]);
1612: my ($namedir,$esctitlestr) = split(/\:/,$titles[$i]);
1613: my @subfolders = split(/,/,$subfolderstr);
1614: $deps{$lastdir} = \@subfolders;
1615: my @subfoldertitles = map { &unescape($_); } split(/,/,$esctitlestr);
1616: my $depth = $depths{$lastdir} + 1;
1617: my $offset = int($depth * 4);
1618: my $indent = (' ' x $offset);
1619: for (my $j=0; $j<@subfolders; $j++) {
1620: $depths{$subfolders[$j]} = $depth;
1621: $display{$subfolders[$j]} =
1622: '<tr><td>'.$indent.$subfoldertitles[$j].' </td>'.
1623: '<td><label>'.
1624: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="new" checked="checked" />'.&mt('Copy to new').'</label>'.(' ' x2).
1625: '<label>'.
1626: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="move" />'.
1627: &mt('Move old').'</label>'.
1628: '</td></tr>';
1629: }
1630: }
1631: &recurse_print(\$output,$parent,\%deps,\%display);
1632: $output .= '</table></fieldset>';
1.329 droeschl 1633: }
1.484.2.30 raeburn 1634: $output .= '</div>';
1635: return $output;
1.329 droeschl 1636: }
1637:
1.484.2.7 raeburn 1638: sub recurse_print {
1.484.2.30 raeburn 1639: my ($outputref,$dir,$deps,$display) = @_;
1640: $$outputref .= $display->{$dir}."\n";
1.484.2.7 raeburn 1641: if (ref($deps->{$dir}) eq 'ARRAY') {
1642: foreach my $subdir (@{$deps->{$dir}}) {
1.484.2.30 raeburn 1643: &recurse_print($outputref,$subdir,$deps,$display);
1.484.2.7 raeburn 1644: }
1645: }
1646: }
1647:
1648: sub supp_pasteable {
1649: my ($url) = @_;
1650: if (($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//}) ||
1651: (($url =~ /\.sequence$/) && ($url =~ m{^/uploaded/})) ||
1652: ($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) ||
1653: ($url =~ m{^/adm/$match_domain/$match_username/aboutme}) ||
1.484.2.93.2. (raeburn 1654:): ($url =~ m{^/public/$match_domain/$match_courseid/syllabus}) ||
1655:): ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$})) {
1.484.2.7 raeburn 1656: return 1;
1657: }
1658: return;
1659: }
1660:
1661: sub paste_popup_js {
1.484.2.61 raeburn 1662: my %html_js_lt = &Apache::lonlocal::texthash(
1.484.2.30 raeburn 1663: show => 'Show Options',
1664: hide => 'Hide Options',
1.484.2.61 raeburn 1665: );
1666: my %js_lt = &Apache::lonlocal::texthash(
1.484.2.30 raeburn 1667: none => 'No items selected from clipboard.',
1.484.2.7 raeburn 1668: );
1.484.2.61 raeburn 1669: &html_escape(\%html_js_lt);
1670: &js_escape(\%html_js_lt);
1671: &js_escape(\%js_lt);
1.484.2.7 raeburn 1672: return <<"END";
1673:
1.484.2.30 raeburn 1674: function showPasteOptions(suffix) {
1675: document.getElementById('pasteoptions_'+suffix).style.display='block';
1.484.2.61 raeburn 1676: document.getElementById('pasteoptionstext_'+suffix).innerHTML = ' <a href="javascript:hidePasteOptions(\\''+suffix+'\\');" class="LC_menubuttons_link">$html_js_lt{'hide'}</a>';
1.484.2.7 raeburn 1677: return;
1678: }
1679:
1.484.2.30 raeburn 1680: function hidePasteOptions(suffix) {
1681: document.getElementById('pasteoptions_'+suffix).style.display='none';
1.484.2.61 raeburn 1682: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.484.2.7 raeburn 1683: return;
1684: }
1685:
1.484.2.30 raeburn 1686: function showOptions(caller,suffix) {
1687: if (document.getElementById('pasteoptionstext_'+suffix)) {
1688: if (caller.checked) {
1.484.2.61 raeburn 1689: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.484.2.30 raeburn 1690: } else {
1691: document.getElementById('pasteoptionstext_'+suffix).innerHTML ='';
1692: }
1693: if (document.getElementById('pasteoptions_'+suffix)) {
1694: document.getElementById('pasteoptions_'+suffix).style.display='none';
1695: }
1696: }
1697: return;
1698: }
1.484.2.7 raeburn 1699:
1.484.2.30 raeburn 1700: function validateClipboard() {
1701: var numchk = 0;
1702: if (document.pasteform.pasting.length > 1) {
1703: for (var i=0; i<document.pasteform.pasting.length; i++) {
1704: if (document.pasteform.pasting[i].checked) {
1705: numchk ++;
1706: }
1707: }
1708: } else {
1709: if (document.pasteform.pasting.type == 'checkbox') {
1710: if (document.pasteform.pasting.checked) {
1711: numchk ++;
1712: }
1713: }
1714: }
1715: if (numchk > 0) {
1716: return true;
1717: } else {
1.484.2.61 raeburn 1718: alert("$js_lt{'none'}");
1.484.2.30 raeburn 1719: return false;
1720: }
1.484.2.7 raeburn 1721: }
1722:
1.484.2.47 raeburn 1723: function checkClipboard() {
1724: if (document.pasteform.pasting.length > 1) {
1725: for (var i=0; i<document.pasteform.pasting.length; i++) {
1726: document.pasteform.pasting[i].checked = true;
1727: }
1728: }
1729: return;
1730: }
1731:
1732: function uncheckClipboard() {
1733: if (document.pasteform.pasting.length >1) {
1734: for (var i=0; i<document.pasteform.pasting.length; i++) {
1735: document.pasteform.pasting[i].checked = false;
1736: }
1737: }
1738: return;
1739: }
1740:
1.484.2.30 raeburn 1741: END
1742:
1743: }
1.484.2.7 raeburn 1744:
1.329 droeschl 1745: sub do_paste_from_buffer {
1.484.2.7 raeburn 1746: my ($coursenum,$coursedom,$folder,$container,$errors) = @_;
1.329 droeschl 1747:
1.484.2.30 raeburn 1748: # Array of items in paste buffer
1749: my (@currpaste,%pastebuffer,%allerrors);
1750: @currpaste = split(/,/,$env{'docs.markedcopies'});
1751:
1.484.2.7 raeburn 1752: # Early out if paste buffer is empty
1.484.2.30 raeburn 1753: if (@currpaste == 0) {
1.484.2.7 raeburn 1754: return ();
1.484.2.30 raeburn 1755: }
1756: map { $pastebuffer{$_} = 1; } @currpaste;
1757:
1758: # Array of items selected items to paste
1759: my @reqpaste = &Apache::loncommon::get_env_multiple('form.pasting');
1760:
1761: # Early out if nothing selected to paste
1762: if (@reqpaste == 0) {
1763: return();
1764: }
1765: my @topaste;
1766: foreach my $suffix (@reqpaste) {
1767: next if ($suffix =~ /\D/);
1768: next unless (exists($pastebuffer{$suffix}));
1769: push(@topaste,$suffix);
1.484.2.7 raeburn 1770: }
1771:
1.484.2.30 raeburn 1772: # Early out if nothing available to paste
1773: if (@topaste == 0) {
1774: return();
1.329 droeschl 1775: }
1776:
1.484.2.93.2. (raeburn 1777:): my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%notindom,%duplicate,
1.484.2.82 raeburn 1778: %prefixchg,%srcdom,%srcnum,%srcmapidx,%marktomove,$save_err,$lockerrors,$allresult);
1.484.2.7 raeburn 1779:
1.484.2.30 raeburn 1780: foreach my $suffix (@topaste) {
1781: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1.484.2.76 raeburn 1782: my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.484.2.82 raeburn 1783: my $mapidx=&LONCAPA::map::qtescape($env{'docs.markedcopy_map_'.$suffix});
1.484.2.30 raeburn 1784: # Supplemental content may only include certain types of content
1785: # Early out if pasted content is not supported in Supplemental area
1786: if ($folder =~ /^supplemental/) {
1787: unless (&supp_pasteable($url)) {
1788: $notinsupp{$suffix} = 1;
1789: next;
1790: }
1791: }
1792: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/}) {
1793: my $srcd = $1;
1794: my $srcn = $2;
1.484.2.7 raeburn 1795: # When paste buffer was populated using an active role in a different course
1.484.2.30 raeburn 1796: # check for mdc privilege in the course from which the resource was pasted
1797: if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1798: unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1799: $notincrs{$suffix} = 1;
1800: next;
1801: }
1.329 droeschl 1802: }
1.484.2.30 raeburn 1803: $srcdom{$suffix} = $srcd;
1804: $srcnum{$suffix} = $srcn;
1.484.2.93.2. 2(raebur 1805:3): } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
1806:3): ($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg)$}) ||
1807:3): ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$})) {
(raeburn 1808:): my ($srcd,$srcn) = split(/_/,$cid);
1809:): # When paste buffer was populated using an active role in a different course
1810:): # check for mdc privilege in the course from which the resource was pasted
1811:): if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1812:): unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1813:): $notincrs{$suffix} = 1;
1814:): next;
1815:): }
1816:): }
1817:): # When buffer was populated using an active role in a different course
1818:): # disallow pasting of External Tool if course is in a different domain.
2(raebur 1819:3): if (($url =~ m{/ext\.tool$}) && ($srcd ne $coursedom)) {
(raeburn 1820:): $notindom{$suffix} = 1;
1821:): next;
1822:): }
1823:): $srcdom{$suffix} = $srcd;
1824:): $srcnum{$suffix} = $srcn;
1.484.2.30 raeburn 1825: }
1.484.2.82 raeburn 1826: $srcmapidx{$suffix} = $mapidx;
1.484.2.30 raeburn 1827: push(@dopaste,$suffix);
1828: if ($url=~/\.(page|sequence)$/) {
1829: $is_map{$suffix} = 1;
1.329 droeschl 1830: }
1.484.2.30 raeburn 1831: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/([^/]+)}) {
1832: my $oldprefix = $1;
1.484.2.19 raeburn 1833: # When pasting content from Main Content to Supplemental Content and vice versa
1.484.2.7 raeburn 1834: # URLs will contain different paths (which depend on whether pasted item is
1.484.2.82 raeburn 1835: # a folder/page or a document).
1.484.2.30 raeburn 1836: if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) {
1837: $prefixchg{$suffix} = 'docstosupp';
1838: } elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) {
1839: $prefixchg{$suffix} = 'supptodocs';
1840: }
1.484.2.7 raeburn 1841:
1842: # If pasting an uploaded map, get list of contained uploaded maps.
1.484.2.30 raeburn 1843: if ($env{'docs.markedcopy_nested_'.$suffix}) {
1844: my @nested;
1845: my ($type) = ($oldprefix =~ /^(default|supplemental)/);
1846: my @items = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1847: my @deps = map { /\d+:([\d,]+$)/ } @items;
1848: foreach my $dep (@deps) {
1849: if ($dep =~ /,/) {
1850: push(@nested,split(/,/,$dep));
1851: } else {
1852: push(@nested,$dep);
1853: }
1.484.2.7 raeburn 1854: }
1.484.2.30 raeburn 1855: foreach my $item (@nested) {
1856: if ($env{'form.docs.markedcopy_'.$suffix.'_'.$item} eq 'move') {
1857: push(@{$marktomove{$suffix}},$type.'_'.$item);
1858: }
1.484.2.7 raeburn 1859: }
1860: }
1.329 droeschl 1861: }
1.484.2.7 raeburn 1862: }
1863:
1.484.2.30 raeburn 1864: # Early out if nothing available to paste
1865: if (@dopaste == 0) {
1866: return ();
1867: }
1868:
1869: # Populate message hash and hashes used for main content <=> supplemental content
1870: # changes
1871:
1872: %msgs = &Apache::lonlocal::texthash (
1873: notinsupp => 'Paste failed: content type is not supported within Supplemental Content',
1874: notincrs => 'Paste failed: Item is from a different course which you do not have rights to edit.',
1.484.2.93.2. 2(raebur 1875:3): notindom => 'Paste failed: Item is an external tool from a course in a different domain.',
1.484.2.30 raeburn 1876: duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.',
1877: );
1878:
1879: %before = (
1880: docstosupp => {
1881: map => 'default',
1882: doc => 'docs',
1883: },
1884: supptodocs => {
1885: map => 'supplemental',
1886: doc => 'supplemental',
1887: },
1888: );
1889:
1890: %after = (
1891: docstosupp => {
1892: map => 'supplemental',
1893: doc => 'supplemental'
1894: },
1895: supptodocs => {
1896: map => 'default',
1897: doc => 'docs',
1898: },
1899: );
1900:
1901: # Retrieve information about all course maps in main content area
1902:
1903: my $allmaps = {};
1.484.2.79 raeburn 1904: my (@toclear,%mapurls,%lockerrs,%msgerrs,%results,$donechk);
1.484.2.30 raeburn 1905:
1906: # Loop over the items to paste
1907: foreach my $suffix (@dopaste) {
1.484.2.7 raeburn 1908: # Maps need to be copied first
1.484.2.30 raeburn 1909: my (%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies,
1910: %dbcopies,%zombies,%params,%docmoves,%mapmoves,%mapchanges,%newsubdir,
1.484.2.82 raeburn 1911: %newurls,%tomove,%resdatacopy);
1.484.2.30 raeburn 1912: if (ref($marktomove{$suffix}) eq 'ARRAY') {
1913: map { $tomove{$_} = 1; } @{$marktomove{$suffix}};
1914: }
1915: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1916: my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.484.2.76 raeburn 1917: my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.484.2.30 raeburn 1918: my $oldurl = $url;
1919: if ($is_map{$suffix}) {
1.484.2.7 raeburn 1920: # If pasting a map, check if map contains other maps
1.484.2.30 raeburn 1921: my (%hierarchy,%titles);
1.484.2.79 raeburn 1922: if (($folder =~ /^default/) && (!$donechk)) {
1923: $allmaps =
1924: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
1925: $env{"course.$env{'request.course.id'}.home"},
1926: $env{'request.course.id'});
1927: $donechk = 1;
1928: }
1.484.2.93.2. (raeburn 1929:): &contained_map_check($url,$folder,$coursenum,$coursedom,
1930:): \%removefrommap,\%removeparam,\%addedmaps,
1931:): \%hierarchy,\%titles,$allmaps);
1.484.2.30 raeburn 1932: if ($url=~ m{^/uploaded/}) {
1933: my $newurl;
1934: unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
1935: ($newurl,my $error) =
1936: &get_newmap_url($url,$folder,$prefixchg{$suffix},$coursedom,
1937: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1938: \$title,$allmaps,\%newurls);
1939: if ($error) {
1940: $allerrors{$suffix} = $error;
1941: next;
1942: }
1943: if ($newurl ne '') {
1944: if ($newurl ne $url) {
1945: if ($newurl =~ /(?:default|supplemental)_(\d+).(?:sequence|page)$/) {
1946: $newsubdir{$url} = $1;
1947: }
1948: $mapchanges{$url} = 1;
1.484.2.7 raeburn 1949: }
1950: }
1951: }
1.484.2.30 raeburn 1952: if (($srcdom{$suffix} ne $coursedom) ||
1953: ($srcnum{$suffix} ne $coursenum) ||
1954: ($prefixchg{$suffix}) || (($newurl ne '') && ($newurl ne $url))) {
1955: unless (&url_paste_fixups($url,$folder,$prefixchg{$suffix},
1956: $coursedom,$coursenum,$srcdom{$suffix},
1957: $srcnum{$suffix},$allmaps,\%rewrites,
1958: \%retitles,\%copies,\%dbcopies,
1959: \%zombies,\%params,\%mapmoves,
1960: \%mapchanges,\%tomove,\%newsubdir,
1.484.2.82 raeburn 1961: \%newurls,\%resdatacopy)) {
1.484.2.30 raeburn 1962: $mapmoves{$url} = 1;
1963: }
1964: $url = $newurl;
1965: } elsif ($env{'docs.markedcopy_nested_'.$suffix}) {
1966: &url_paste_fixups($url,$folder,$prefixchg{$suffix},$coursedom,
1967: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1968: $allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies,
1969: \%zombies,\%params,\%mapmoves,\%mapchanges,
1.484.2.82 raeburn 1970: \%tomove,\%newsubdir,\%newurls,\%resdatacopy);
1.484.2.30 raeburn 1971: }
1972: } elsif ($url=~m {^/res/}) {
1.484.2.82 raeburn 1973: # published map can only exist once, so remove from paste buffer when done
1.484.2.30 raeburn 1974: push(@toclear,$suffix);
1975: # if pasting published map (main content area only) check map not already in course
1976: if ($folder =~ /^default/) {
1977: if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) {
1978: $duplicate{$suffix} = 1;
1979: next;
1980: }
1.484.2.7 raeburn 1981: }
1982: }
1983: }
1.484.2.93.2. (raeburn 1984:): if ($url=~ m{/(bulletinboard|smppg|ext\.tool)$}) {
1.484.2.30 raeburn 1985: my $prefix = $1;
1.484.2.76 raeburn 1986: my $fromothercrs;
1.484.2.30 raeburn 1987: #need to copy the db contents to a new one, unless this is a move.
1988: my %info = (
1989: src => $url,
1990: cdom => $coursedom,
1991: cnum => $coursenum,
1.484.2.76 raeburn 1992: );
1.484.2.93.2. 2(raebur 1993:3): if ($prefix eq 'ext.tool') {
1994:3): if ($prefixchg{$suffix} eq 'docstosupp') {
1995:3): $info{'delgradable'} = 1;
1996:3): }
1997:3): }
1.484.2.76 raeburn 1998: if (($srcdom{$suffix} =~ /^$match_domain$/) && ($srcnum{$suffix} =~ /^$match_courseid$/)) {
1999: unless (($srcdom{$suffix} eq $coursedom) && ($srcnum{$suffix} eq $coursenum)) {
2000: $fromothercrs = 1;
2001: $info{'cdom'} = $srcdom{$suffix};
2002: $info{'cnum'} = $srcnum{$suffix};
2003: }
2004: }
2005: unless (($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') && (!$fromothercrs)) {
1.484.2.30 raeburn 2006: my (%lockerr,$msg);
2007: my ($newurl,$result,$errtext) =
2008: &dbcopy(\%info,$coursedom,$coursenum,\%lockerr);
2009: if ($result eq 'ok') {
2010: $url = $newurl;
2011: $title=&mt('Copy of').' '.$title;
2012: } else {
2013: if ($prefix eq 'smppg') {
2014: $msg = &mt('Paste failed: An error occurred when copying the simple page.').' '.$errtext;
2015: } elsif ($prefix eq 'bulletinboard') {
1.484.2.42 raeburn 2016: $msg = &mt('Paste failed: An error occurred when copying the discussion board.').' '.$errtext;
1.484.2.93.2. (raeburn 2017:): } elsif ($prefix eq 'ext.tool') {
2018:): $msg = &mt('Paste failed: An error occurred when copying the external tool.').' '.$errtext;
1.484.2.30 raeburn 2019: }
2020: $results{$suffix} = $result;
2021: $msgerrs{$suffix} = $msg;
2022: $lockerrs{$suffix} = $lockerr{$prefix};
2023: next;
2024: }
2025: if ($lockerr{$prefix}) {
2026: $lockerrs{$suffix} = $lockerr{$prefix};
1.484.2.26 raeburn 2027: }
1.484.2.7 raeburn 2028: }
1.484.2.30 raeburn 2029: }
2030: $title = &LONCAPA::map::qtunescape($title);
2031: my $ext='false';
2032: if ($url=~m{^http(|s)://}) { $ext='true'; }
2033: if ($env{'docs.markedcopy_supplemental_'.$suffix}) {
2034: if ($folder !~ /^supplemental/) {
2035: (undef,undef,$title) =
2036: &Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental_'.$suffix});
2037: }
2038: } else {
2039: if ($folder=~/^supplemental/) {
2040: $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
2041: $env{'user.domain'}.'___&&&___'.$title;
1.484.2.26 raeburn 2042: }
2043: }
1.484.2.7 raeburn 2044:
2045: # For uploaded files (excluding pages/sequences) path in copied file is changed
2046: # if paste is from Main to Supplemental (or vice versa), or if pasting between
2047: # courses.
2048:
1.484.2.30 raeburn 2049: unless ($is_map{$suffix}) {
2050: my $newidx;
1.329 droeschl 2051: # Now insert the URL at the bottom
1.484.2.30 raeburn 2052: $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
2053: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(.+)$}) {
2054: my $relpath = $1;
2055: if ($relpath ne '') {
2056: my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$});
2057: my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/);
2058: my $newprefix = $newloc;
2059: if ($newloc eq 'default') {
2060: $newprefix = 'docs';
2061: }
2062: if ($newdocsdir eq '') {
2063: $newdocsdir = 'default';
2064: }
2065: if (($prefixchg{$suffix}) ||
2066: ($srcdom{$suffix} ne $coursedom) ||
2067: ($srcnum{$suffix} ne $coursenum) ||
2068: ($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) {
2069: my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";
2070: $url =
2071: &Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath,
2072: &Apache::lonnet::getfile($oldurl));
2073: if ($url eq '/adm/notfound.html') {
2074: $msgs{$suffix} = &mt('Paste failed: an error occurred saving the file.');
2075: next;
2076: } else {
2077: my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$});
2078: $newsubpath =~ s{/+$}{/};
2079: $docmoves{$oldurl} = $newsubpath;
2080: }
1.484.2.7 raeburn 2081: }
2082: }
1.484.2.82 raeburn 2083: } elsif ($url =~ m{^/res/lib/templates/(\w+)\.problem$}) {
2084: my $template = $1;
2085: if ($newidx) {
2086: ©_templated_files($url,$srcdom{$suffix},$srcnum{$suffix},$srcmapidx{$suffix},
2087: $coursedom,$coursenum,$template,$newidx,"$folder.$container");
2088: }
1.484.2.93.2. 2(raebur 2089:3): } elsif ($url =~ /ext\.tool$/) {
2090:3): if (($newidx) && ($folder=~/^default/)) {
2091:3): my $marker = (split(m{/},$url))[4];
2092:3): my %toolsettings = &Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
2093:3): my $val = 'no';
2094:3): if ($toolsettings{'gradable'}) {
2095:3): $val = 'yes';
2096:3): }
2097:3): &LONCAPA::map::storeparameter($newidx,'parameter_0_gradable',$val,
2098:3): 'string_yesno');
2099:3): &remember_parms($newidx,'gradable','set',$val);
2100:3): }
1.484.2.7 raeburn 2101: }
1.484.2.30 raeburn 2102: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
2103: ':'.$ext.':normal:res';
2104: push(@LONCAPA::map::order,$newidx);
2105: # Store the result
2106: my ($errtext,$fatal) =
2107: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
2108: if ($fatal) {
2109: $save_err .= $errtext;
2110: $allresult = 'fail';
1.484.2.7 raeburn 2111: }
1.329 droeschl 2112: }
1.484.2.30 raeburn 2113:
1.484.2.82 raeburn 2114: # Apply any changes to maps, or copy dependencies for uploaded HTML pages, or update
2115: # resourcedata for simpleproblems copied from another course
1.484.2.30 raeburn 2116: unless ($allresult eq 'fail') {
2117: my %updated = (
2118: rewrites => \%rewrites,
2119: zombies => \%zombies,
2120: removefrommap => \%removefrommap,
2121: removeparam => \%removeparam,
2122: dbcopies => \%dbcopies,
1.484.2.82 raeburn 2123: resdatacopy => \%resdatacopy,
1.484.2.30 raeburn 2124: retitles => \%retitles,
2125: );
2126: my %info = (
2127: newsubdir => \%newsubdir,
2128: params => \%params,
2129: );
2130: if ($prefixchg{$suffix}) {
2131: $info{'before'} = $before{$prefixchg{$suffix}};
2132: $info{'after'} = $after{$prefixchg{$suffix}};
2133: }
2134: my %moves = (
2135: copies => \%copies,
2136: docmoves => \%docmoves,
2137: mapmoves => \%mapmoves,
2138: );
2139: (my $result,$msgs{$suffix},my $lockerror) =
2140: &apply_fixups($folder,$is_map{$suffix},$coursedom,$coursenum,$errors,
2141: \%updated,\%info,\%moves,$prefixchg{$suffix},$oldurl,
2142: $url,'paste');
2143: $lockerrors .= $lockerror;
2144: if ($result eq 'ok') {
2145: if ($is_map{$suffix}) {
2146: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
2147: $folder.'.'.$container);
2148: if ($fatal) {
2149: $allresult = 'failread';
2150: } else {
2151: if ($#LONCAPA::map::order<1) {
2152: my $idx=&LONCAPA::map::getresidx();
2153: if ($idx<=0) { $idx=1; }
2154: $LONCAPA::map::order[0]=$idx;
2155: $LONCAPA::map::resources[$idx]='';
2156: }
2157: my $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
2158: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
2159: ':'.$ext.':normal:res';
2160: push(@LONCAPA::map::order,$newidx);
1.484.2.7 raeburn 2161:
2162: # Store the result
1.484.2.30 raeburn 2163: my ($errtext,$fatal) =
2164: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
2165: if ($fatal) {
2166: $save_err .= $errtext;
2167: $allresult = 'failstore';
2168: }
2169: }
2170: }
2171: if ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
2172: push(@toclear,$suffix);
2173: }
2174: }
1.329 droeschl 2175: }
2176: }
1.484.2.30 raeburn 2177: &clear_from_buffer(\@toclear,\@currpaste);
2178: my $msgsarray;
2179: foreach my $suffix (keys(%msgs)) {
2180: if (ref($msgs{$suffix}) eq 'ARRAY') {
2181: $msgsarray .= join(',',@{$msgs{$suffix}});
2182: }
2183: }
2184: return ($allresult,$save_err,$msgsarray,$lockerrors);
2185: }
2186:
2187: sub do_buffer_empty {
2188: my @currpaste = split(/,/,$env{'docs.markedcopies'});
2189: if (@currpaste == 0) {
2190: return &mt('Clipboard is already empty');
2191: }
2192: my @toclear = &Apache::loncommon::get_env_multiple('form.pasting');
2193: if (@toclear == 0) {
2194: return &mt('Nothing selected to clear from clipboard');
2195: }
2196: my $numdel = &clear_from_buffer(\@toclear,\@currpaste);
2197: if ($numdel) {
2198: return &mt('[quant,_1,item] cleared from clipboard',$numdel);
2199: } else {
2200: return &mt('Clipboard unchanged');
1.484.2.7 raeburn 2201: }
1.484.2.30 raeburn 2202: return;
2203: }
2204:
2205: sub clear_from_buffer {
2206: my ($toclear,$currpaste) = @_;
2207: return unless ((ref($toclear) eq 'ARRAY') && (ref($currpaste) eq 'ARRAY'));
2208: my %pastebuffer;
2209: map { $pastebuffer{$_} = 1; } @{$currpaste};
2210: my $numdel = 0;
2211: foreach my $suffix (@{$toclear}) {
2212: next if ($suffix =~ /\D/);
2213: next unless (exists($pastebuffer{$suffix}));
2214: my $regexp = 'docs.markedcopy_[a-z]+_'.$suffix;
2215: if (&Apache::lonnet::delenv($regexp,1) eq 'ok') {
2216: delete($pastebuffer{$suffix});
2217: $numdel ++;
2218: }
2219: }
2220: my $newbuffer = join(',',sort(keys(%pastebuffer)));
2221: &Apache::lonnet::appenv({'docs.markedcopies' => $newbuffer});
2222: return $numdel;
1.484.2.7 raeburn 2223: }
2224:
2225: sub get_newmap_url {
2226: my ($url,$folder,$prefixchg,$coursedom,$coursenum,$srcdom,$srcnum,
2227: $titleref,$allmaps,$newurls) = @_;
2228: my $newurl;
2229: if ($url=~ m{^/uploaded/}) {
2230: $$titleref=&mt('Copy of').' '.$$titleref;
2231: }
2232: my $now = time;
2233: my $suffix=$$.int(rand(100)).$now;
2234: my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
2235: if ($oldid =~ m{^(/uploaded/$match_domain/$match_courseid/)(\D+)(\d+)$}) {
2236: my $path = $1;
2237: my $prefix = $2;
2238: my $ancestor = $3;
2239: if (length($ancestor) > 10) {
2240: $ancestor = substr($ancestor,-10,10);
2241: }
2242: my $newid;
2243: if ($prefixchg) {
2244: if ($folder =~ /^supplemental/) {
2245: $prefix =~ s/^default/supplemental/;
2246: } else {
2247: $prefix =~ s/^supplemental/default/;
2248: }
2249: }
2250: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
2251: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
2252: } else {
2253: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$now.'.'.$ext;
2254: }
2255: my $counter = 0;
2256: my $is_unique = &uniqueness_check($newurl);
2257: if ($folder =~ /^default/) {
2258: if ($allmaps->{$newurl}) {
2259: $is_unique = 0;
2260: }
2261: }
2262: while ((!$is_unique || $allmaps->{$newurl} || $newurls->{$newurl}) && ($counter < 100)) {
2263: $counter ++;
2264: $suffix ++;
2265: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
2266: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
2267: } else {
2268: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$ancestor.$suffix.'.'.$ext;
2269: }
2270: $is_unique = &uniqueness_check($newurl);
2271: }
2272: if ($is_unique) {
2273: $newurls->{$newurl} = 1;
2274: } else {
2275: if ($url=~/\.page$/) {
2276: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the composite page'));
2277: } else {
2278: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the folder'));
2279: }
2280: }
2281: }
2282: return ($newurl);
2283: }
2284:
2285: sub dbcopy {
1.484.2.26 raeburn 2286: my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_;
2287: my ($url,$result,$errtext);
2288: if (ref($dbref) eq 'HASH') {
1.484.2.71 raeburn 2289: $url = $dbref->{'src'};
1.484.2.93.2. (raeburn 2290:): if ($url =~ m{/(smppg|bulletinboard|ext\.tool)$}) {
1.484.2.26 raeburn 2291: my $prefix = $1;
1.484.2.93.2. (raeburn 2292:): if ($prefix eq 'ext.tool') {
2293:): $prefix = 'exttool';
2294:): }
1.484.2.26 raeburn 2295: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2296: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2297: my $db_name;
2298: my $marker = (split(m{/},$url))[4];
2299: $marker=~s/\D//g;
2300: if ($dbref->{'src'} =~ m{/smppg$}) {
2301: $db_name =
2302: &Apache::lonsimplepage::get_db_name($url,$marker,
2303: $dbref->{'cdom'},
2304: $dbref->{'cnum'});
1.484.2.93.2. (raeburn 2305:): } elsif ($dbref->{'src'} =~ m{/ext\.tool$}) {
2306:): $db_name = 'exttool_'.$marker;
1.484.2.26 raeburn 2307: } else {
2308: $db_name = 'bulletinpage_'.$marker;
2309: }
2310: my ($suffix,$freedlock,$error) =
2311: &Apache::lonnet::get_timebased_id($prefix,'num','templated',
2312: $coursedom,$coursenum,
2313: 'concat');
2314: if (!$suffix) {
2315: if ($prefix eq 'smppg') {
2316: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);
1.484.2.93.2. (raeburn 2317:): } elsif ($prefix eq 'exttool') {
2318:): $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying an external tool [_1].',$url);
1.484.2.26 raeburn 2319: } else {
1.484.2.42 raeburn 2320: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url);
1.484.2.26 raeburn 2321: }
2322: if ($error) {
2323: $errtext .= '<br />'.$error;
2324: }
2325: } else {
2326: #need to copy the db contents to a new one.
2327: my %contents=&Apache::lonnet::dump($db_name,
2328: $dbref->{'cdom'},
2329: $dbref->{'cnum'});
2330: if (exists($contents{'uploaded.photourl'})) {
2331: my $photo = $contents{'uploaded.photourl'};
2332: my ($subdir,$fname) =
2333: ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});
2334: my $newphoto;
2335: if ($fname ne '') {
2336: my $content = &Apache::lonnet::getfile($photo);
2337: unless ($content eq '-1') {
2338: $env{'form.'.$suffix.'.photourl'} = $content;
2339: $newphoto =
2340: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");
2341: delete($env{'form.'.$suffix.'.photourl'});
2342: }
2343: }
2344: if ($newphoto =~ m{^/uploaded/}) {
2345: $contents{'uploaded.photourl'} = $newphoto;
2346: }
2347: }
2348: $db_name =~ s{_\d*$ }{_$suffix}x;
1.484.2.93.2. 2(raebur 2349:3): if (($prefix eq 'exttool') && ($dbref->{'delgradable'}) && ($contents{'gradable'})) {
2350:3): delete($contents{'gradable'});
2351:3): }
1.484.2.26 raeburn 2352: $result=&Apache::lonnet::put($db_name,\%contents,
2353: $coursedom,$coursenum);
2354: if ($result eq 'ok') {
1.484.2.93.2. (raeburn 2355:): $url =~ s{/(\d*)/(smppg|bulletinboard|ext\.tool)$}{/$suffix/$2}x;
1.484.2.26 raeburn 2356: }
2357: }
2358: if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) {
2359: $lockerrorsref->{$prefix} =
2360: '<div class="LC_error">'.
2361: &mt('There was a problem removing a lockfile.');
2362: if ($prefix eq 'smppg') {
2363: $lockerrorsref->{$prefix} .=
1.484.2.38 raeburn 2364: ' '.&mt('This will prevent creation of additional simple pages in this course.');
1.484.2.93.2. (raeburn 2365:): } elsif ($prefix eq 'exttool') {
2366:): $lockerrorsref->{$prefix} .=
2367:): ' '.&mt('This will prevent addition of more external tools to this course.');
1.484.2.26 raeburn 2368: } else {
1.484.2.42 raeburn 2369: $lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional discussion boards in this course.');
1.484.2.26 raeburn 2370: }
1.484.2.38 raeburn 2371: $lockerrorsref->{$prefix} .= ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
2372: '<a href="/adm/helpdesk" target="_helpdesk">','</a>').
2373: '</div>';
1.484.2.26 raeburn 2374: }
2375: }
2376: } elsif ($url =~ m{/syllabus$}) {
2377: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2378: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2379: if (($dbref->{'cdom'} ne $coursedom) ||
2380: ($dbref->{'cnum'} ne $coursenum)) {
2381: my %contents=&Apache::lonnet::dump('syllabus',
2382: $dbref->{'cdom'},
2383: $dbref->{'cnum'});
2384: $result=&Apache::lonnet::put('syllabus',\%contents,
2385: $coursedom,$coursenum);
2386: }
2387: }
1.484.2.7 raeburn 2388: }
2389: }
1.484.2.26 raeburn 2390: return ($url,$result,$errtext);
1.329 droeschl 2391: }
2392:
1.484.2.82 raeburn 2393: sub copy_templated_files {
2394: my ($srcurl,$srcdom,$srcnum,$srcmapinfo,$coursedom,$coursenum,$template,$newidx,$newmapname) = @_;
2395: my ($srcfolder,$srcid,$srcwaspage) = split(/:/,$srcmapinfo);
2396: my $srccontainer = 'sequence';
2397: if ($srcwaspage) {
2398: $srccontainer = 'page';
2399: }
2400: my $srcsymb = "uploaded/$srcdom/$srcnum/$srcfolder.$srccontainer".
2401: '___'.$srcid.'___'.&Apache::lonnet::declutter($srcurl);
2402: my $srcprefix = $srcdom.'_'.$srcnum.'.'.$srcsymb;
2403: my %srcparms=&Apache::lonnet::dump('resourcedata',$srcdom,$srcnum,$srcprefix);
2404: my $newsymb = "uploaded/$coursedom/$coursenum/$newmapname".'___'.$newidx.'___lib/templates/'.
2405: $template.'.problem';
2406: my $newprefix = $coursedom.'_'.$coursenum.'.'.$newsymb;
2407: if ($template eq 'simpleproblem') {
2408: $srcprefix .= '.0.';
2409: my $weightprefix = $newprefix;
2410: $newprefix .= '.0.';
2411: my @simpleprobqtypes = qw(radio option string essay numerical);
2412: my $qtype=$srcparms{$srcprefix.'questiontype'};
2413: if (grep(/^\Q$qtype\E$/,@simpleprobqtypes)) {
2414: my %newdata = (
2415: $newprefix.'questiontype' => $qtype,
1.484.2.84 raeburn 2416: );
1.484.2.82 raeburn 2417: foreach my $type (@simpleprobqtypes) {
2418: if ($type eq $qtype) {
2419: $newdata{"$weightprefix.$type.weight"}=1;
2420: } else {
2421: $newdata{"$weightprefix.$type.weight"}=0;
2422: }
2423: }
2424: $newdata{$newprefix.'hiddenparts'} = '!'.$qtype;
2425: $newdata{$newprefix.'questiontext'} = $srcparms{$srcprefix.'questiontext'};
2426: $newdata{$newprefix.'hinttext'} = $srcparms{$srcprefix.'hinttext'};
2427: if ($qtype eq 'numerical') {
2428: $newdata{$newprefix.'numericalscript'} = $srcparms{$srcprefix.'numericalscript'};
2429: $newdata{$newprefix.'numericalanswer'} = $srcparms{$srcprefix.'numericalanswer'};
2430: $newdata{$newprefix.'numericaltolerance'} = $srcparms{$srcprefix.'numericaltolerance'};
2431: $newdata{$newprefix.'numericalsigfigs'} = $srcparms{$srcprefix.'numericalsigfigs'};
2432: } elsif (($qtype eq 'option') || ($qtype eq 'radio')) {
2433: my $maxfoils=$srcparms{$srcprefix.'maxfoils'};
2434: unless (defined($maxfoils)) { $maxfoils=10; }
2435: unless ($maxfoils=~/^\d+$/) { $maxfoils=10; }
2436: if ($maxfoils<=0) { $maxfoils=10; }
2437: my $randomize=$srcparms{$srcprefix.'randomize'};
2438: unless (defined($randomize)) { $randomize='yes'; }
2439: unless ($randomize eq 'no') { $randomize='yes'; }
2440: $newdata{$newprefix.'maxfoils'} = $maxfoils;
2441: $newdata{$newprefix.'randomize'} = $randomize;
2442: if ($qtype eq 'option') {
2443: $newdata{$newprefix.'options'} = $srcparms{$srcprefix.'options'};
2444: }
2445: for (my $i=1; $i<=10; $i++) {
2446: $newdata{$newprefix.'value'.$i} = $srcparms{$srcprefix.'value'.$i};
2447: $newdata{$newprefix.'position'.$i} = $srcparms{$srcprefix.'position'.$i};
2448: $newdata{$newprefix.'text'.$i} = $srcparms{$srcprefix.'text'.$i};
2449: }
2450:
2451: } elsif (($qtype eq 'option') || ($qtype eq 'radio')) {
2452: my $maxfoils=$srcparms{$srcprefix.'maxfoils'};
2453: unless (defined($maxfoils)) { $maxfoils=10; }
2454: unless ($maxfoils=~/^\d+$/) { $maxfoils=10; }
2455: if ($maxfoils<=0) { $maxfoils=10; }
2456: my $randomize=$srcparms{$srcprefix.'randomize'};
2457: unless (defined($randomize)) { $randomize='yes'; }
2458: unless ($randomize eq 'no') { $randomize='yes'; }
2459: $newdata{$newprefix.'maxfoils'} = $maxfoils;
2460: $newdata{$newprefix.'randomize'} = $randomize;
2461: if ($qtype eq 'option') {
2462: $newdata{$newprefix.'options'} = $srcparms{$srcprefix.'options'};
2463: }
2464: for (my $i=1; $i<=10; $i++) {
2465: $newdata{$newprefix.'value'.$i} = $srcparms{$srcprefix.'value'.$i};
2466: $newdata{$newprefix.'position'.$i} = $srcparms{$srcprefix.'position'.$i};
2467: $newdata{$newprefix.'text'.$i} = $srcparms{$srcprefix.'text'.$i};
2468: }
2469: } elsif ($qtype eq 'string') {
2470: $newdata{$newprefix.'stringanswer'} = $srcparms{$srcprefix.'stringanswer'};
2471: $newdata{$newprefix.'stringtype'} = $srcparms{$srcprefix.'stringtype'};
2472: }
2473: if (keys(%newdata)) {
2474: my $putres = &Apache::lonnet::cput('resourcedata',\%newdata,$coursedom,
2475: $coursenum);
2476: if ($putres eq 'ok') {
2477: &Apache::lonnet::devalidatecourseresdata($coursenum,$coursedom);
2478: }
2479: }
2480: }
2481: }
2482: }
2483:
1.329 droeschl 2484: sub uniqueness_check {
2485: my ($newurl) = @_;
2486: my $unique = 1;
2487: foreach my $res (@LONCAPA::map::order) {
2488: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2489: $url=&LONCAPA::map::qtescape($url);
2490: if ($newurl eq $url) {
2491: $unique = 0;
1.344 bisitz 2492: last;
1.329 droeschl 2493: }
2494: }
2495: return $unique;
2496: }
2497:
1.484.2.7 raeburn 2498: sub contained_map_check {
1.484.2.93.2. (raeburn 2499:): my ($url,$folder,$coursenum,$coursedom,$removefrommap,$removeparam,$addedmaps,
2500:): $hierarchy,$titles,$allmaps) = @_;
1.484.2.7 raeburn 2501: my $content = &Apache::lonnet::getfile($url);
2502: unless ($content eq '-1') {
2503: my $parser = HTML::TokeParser->new(\$content);
2504: $parser->attr_encoded(1);
2505: while (my $token = $parser->get_token) {
2506: next if ($token->[0] ne 'S');
2507: if ($token->[1] eq 'resource') {
2508: next if ($token->[2]->{'type'} eq 'zombie');
2509: my $ressrc = $token->[2]->{'src'};
1.484.2.93.2. 2(raebur 2510:3): if ($ressrc =~ m{^/adm/($match_domain)/$match_courseid/\d+/ext\.tool$}) {
2511:3): my $srcdom = $1;
2512:3): unless ($srcdom eq $coursedom) {
2513:3): $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2514:3): next;
2515:3): }
2516:3): } elsif ($folder =~ /^supplemental/) {
1.484.2.7 raeburn 2517: unless (&supp_pasteable($ressrc)) {
2518: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2519: next;
2520: }
2521: }
2522: if ($ressrc =~ m{^/(res|uploaded)/.+\.(sequence|page)$}) {
2523: if ($1 eq 'uploaded') {
2524: $hierarchy->{$url}{$token->[2]->{'id'}} = $ressrc;
2525: $titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'};
2526: } else {
2527: if ($allmaps->{$ressrc}) {
1.484.2.23 raeburn 2528: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.484.2.7 raeburn 2529: } elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') {
2530: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2531: } else {
2532: $addedmaps->{$ressrc} = [$url];
2533: }
2534: }
1.484.2.93.2. (raeburn 2535:): &contained_map_check($ressrc,$folder,$coursenum,$coursedom,
2536:): $removefrommap,$removeparam,
1.484.2.7 raeburn 2537: $addedmaps,$hierarchy,$titles,$allmaps);
2538: }
2539: } elsif ($token->[1] eq 'param') {
2540: if ($folder =~ /^supplemental/) {
2541: if (ref($removeparam->{$url}{$token->[2]->{'to'}}) eq 'ARRAY') {
2542: push(@{$removeparam->{$url}{$token->[2]->{'to'}}},$token->[2]->{'name'});
2543: } else {
1.484.2.19 raeburn 2544: $removeparam->{$url}{$token->[2]->{'to'}} = [$token->[2]->{'name'}];
1.484.2.7 raeburn 2545: }
2546: }
2547: }
2548: }
2549: }
2550: return;
2551: }
2552:
2553: sub url_paste_fixups {
1.484.2.26 raeburn 2554: my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$fromcdom,$fromcnum,$allmaps,
2555: $rewrites,$retitles,$copies,$dbcopies,$zombies,$params,$mapmoves,
1.484.2.82 raeburn 2556: $mapchanges,$tomove,$newsubdir,$newurls,$resdatacopy) = @_;
1.484.2.7 raeburn 2557: my $checktitle;
2558: if (($prefixchg) &&
2559: ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) {
2560: $checktitle = 1;
2561: }
2562: my $skip;
2563: if ($oldurl =~ m{^\Q/uploaded/$cdom/$cnum/\E(default|supplemental)(_?\d*)\.(?:page|sequence)$}) {
2564: my $mapid = $1.$2;
2565: if ($tomove->{$mapid}) {
2566: $skip = 1;
2567: }
2568: }
2569: my $file = &Apache::lonnet::getfile($oldurl);
2570: return if ($file eq '-1');
2571: my $parser = HTML::TokeParser->new(\$file);
2572: $parser->attr_encoded(1);
2573: my $changed = 0;
2574: while (my $token = $parser->get_token) {
2575: next if ($token->[0] ne 'S');
2576: if ($token->[1] eq 'resource') {
2577: my $ressrc = $token->[2]->{'src'};
2578: next if ($ressrc eq '');
2579: my $id = $token->[2]->{'id'};
2580: my $title = $token->[2]->{'title'};
2581: if ($checktitle) {
2582: if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1.484.2.25 raeburn 2583: $retitles->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2584: }
2585: }
2586: next if ($token->[2]->{'type'} eq 'external');
2587: if ($token->[2]->{'type'} eq 'zombie') {
1.484.2.30 raeburn 2588: next if ($skip);
1.484.2.25 raeburn 2589: $zombies->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2590: $changed = 1;
2591: } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
2592: my $srcdom = $1;
2593: my $srcnum = $2;
2594: my $rem = $3;
2595: my $newurl;
2596: my $mapname;
2597: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
2598: my $prefix = $1;
2599: $mapname = $prefix.$2;
2600: if ($tomove->{$mapname}) {
1.484.2.26 raeburn 2601: &url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,
2602: $srcdom,$srcnum,$allmaps,$rewrites,
2603: $retitles,$copies,$dbcopies,$zombies,
2604: $params,$mapmoves,$mapchanges,$tomove,
1.484.2.82 raeburn 2605: $newsubdir,$newurls,$resdatacopy);
1.484.2.7 raeburn 2606: next;
2607: } else {
2608: ($newurl,my $error) =
2609: &get_newmap_url($ressrc,$folder,$prefixchg,$cdom,$cnum,
2610: $srcdom,$srcnum,\$title,$allmaps,$newurls);
2611: if ($newurl =~ /(?:default|supplemental)_(\d+)\.(?:sequence|page)$/) {
2612: $newsubdir->{$ressrc} = $1;
2613: }
2614: if ($error) {
2615: next;
2616: }
2617: }
2618: }
2619: if (($srcdom ne $cdom) || ($srcnum ne $cnum) || ($prefixchg) ||
2620: ($mapchanges->{$oldurl}) || (($newurl ne '') && ($newurl ne $oldurl))) {
1.484.2.19 raeburn 2621:
1.484.2.7 raeburn 2622: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
1.484.2.25 raeburn 2623: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2624: $mapchanges->{$ressrc} = 1;
1.484.2.26 raeburn 2625: unless (&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,
2626: $cnum,$srcdom,$srcnum,$allmaps,
2627: $rewrites,$retitles,$copies,$dbcopies,
2628: $zombies,$params,$mapmoves,$mapchanges,
1.484.2.82 raeburn 2629: $tomove,$newsubdir,$newurls,$resdatacopy)) {
1.484.2.7 raeburn 2630: $mapmoves->{$ressrc} = 1;
2631: }
2632: $changed = 1;
2633: } else {
1.484.2.25 raeburn 2634: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2635: $copies->{$oldurl}{$ressrc} = $id;
2636: $changed = 1;
2637: }
2638: }
1.484.2.93.2. 2(raebur 2639:3): } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/(.+)$}) {
1.484.2.30 raeburn 2640: next if ($skip);
1.484.2.7 raeburn 2641: my $srcdom = $1;
2642: my $srcnum = $2;
1.484.2.93.2. 2(raebur 2643:3): my $rem = $3;
2644:3): my ($is_exttool,$exttoolchg);
2645:3): if ($rem =~ m{\d+/ext\.tool$}) {
2646:3): $is_exttool = 1;
2647:3): }
1.484.2.7 raeburn 2648: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.484.2.25 raeburn 2649: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.26 raeburn 2650: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2651: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2652: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
2653: $changed = 1;
1.484.2.93.2. 2(raebur 2654:3): if ($is_exttool) {
2655:3): $exttoolchg = 1;
2656:3): }
2657:3): } elsif (($is_exttool) &&
2658:3): ($env{'form.docs.markedcopy_options'} ne 'move')) {
2659:3): $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2660:3): $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2661:3): $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
2662:3): $changed = 1;
2663:3): $exttoolchg = 1;
2664:3): }
2665:3): if (($is_exttool) && ($prefixchg)) {
2666:3): if ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/default}) {
2667:3): if ($exttoolchg) {
2668:3): $dbcopies->{$oldurl}{$id}{'delgradable'} = 1;
2669:3): }
2670:3): }
1.484.2.26 raeburn 2671: }
2672: } elsif ($ressrc =~ m{^/adm/$match_domain/$match_username/\d+/(smppg|bulletinboard)$}) {
2673: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum) ||
2674: ($env{'form.docs.markedcopy_options'} ne 'move')) {
2675: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2676: $dbcopies->{$oldurl}{$id}{'cdom'} = $fromcdom;
2677: $dbcopies->{$oldurl}{$id}{'cnum'} = $fromcnum;
1.484.2.7 raeburn 2678: $changed = 1;
2679: }
1.484.2.82 raeburn 2680: } elsif ($ressrc eq '/res/lib/templates/simpleproblem.problem') {
2681: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum)) {
2682: $resdatacopy->{$oldurl}{$id}{'src'} = $ressrc;
2683: $resdatacopy->{$oldurl}{$id}{'cdom'} = $fromcdom;
2684: $resdatacopy->{$oldurl}{$id}{'cnum'} = $fromcnum;
2685: }
1.484.2.7 raeburn 2686: } elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) {
2687: next if ($skip);
2688: my $srcdom = $1;
2689: my $srcnum = $2;
2690: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.484.2.26 raeburn 2691: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2692: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2693: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
1.484.2.7 raeburn 2694: $changed = 1;
2695: }
2696: }
2697: } elsif ($token->[1] eq 'param') {
2698: next if ($skip);
1.484.2.19 raeburn 2699: my $to = $token->[2]->{'to'};
1.484.2.7 raeburn 2700: if ($to ne '') {
2701: if (ref($params->{$oldurl}{$to}) eq 'ARRAY') {
2702: push(@{$params->{$oldurl}{$to}},$token->[2]->{'name'});
2703: } else {
2704: @{$params->{$oldurl}{$to}} = ($token->[2]->{'name'});
2705: }
2706: }
2707: }
2708: }
2709: return $changed;
2710: }
2711:
2712: sub apply_fixups {
1.484.2.23 raeburn 2713: my ($folder,$is_map,$cdom,$cnum,$errors,$updated,$info,$moves,$prefixchg,
2714: $oldurl,$url,$caller) = @_;
2715: my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles,
1.484.2.26 raeburn 2716: %params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs,
1.484.2.82 raeburn 2717: %resdatacopy,%lockerrors,$lockmsg);
1.484.2.23 raeburn 2718: if (ref($updated) eq 'HASH') {
2719: if (ref($updated->{'rewrites'}) eq 'HASH') {
2720: %rewrites = %{$updated->{'rewrites'}};
2721: }
2722: if (ref($updated->{'zombies'}) eq 'HASH') {
2723: %zombies = %{$updated->{'zombies'}};
2724: }
2725: if (ref($updated->{'removefrommap'}) eq 'HASH') {
2726: %removefrommap = %{$updated->{'removefrommap'}};
2727: }
2728: if (ref($updated->{'removeparam'}) eq 'HASH') {
2729: %removeparam = %{$updated->{'removeparam'}};
2730: }
2731: if (ref($updated->{'dbcopies'}) eq 'HASH') {
2732: %dbcopies = %{$updated->{'dbcopies'}};
2733: }
2734: if (ref($updated->{'retitles'}) eq 'HASH') {
2735: %retitles = %{$updated->{'retitles'}};
2736: }
1.484.2.82 raeburn 2737: if (ref($updated->{'resdatacopy'}) eq 'HASH') {
2738: %resdatacopy = %{$updated->{'resdatacopy'}};
2739: }
1.484.2.23 raeburn 2740: }
2741: if (ref($info) eq 'HASH') {
2742: if (ref($info->{'newsubdir'}) eq 'HASH') {
2743: %newsubdir = %{$info->{'newsubdir'}};
2744: }
2745: if (ref($info->{'params'}) eq 'HASH') {
2746: %params = %{$info->{'params'}};
2747: }
2748: if (ref($info->{'before'}) eq 'HASH') {
2749: %before = %{$info->{'before'}};
2750: }
2751: if (ref($info->{'after'}) eq 'HASH') {
2752: %after = %{$info->{'after'}};
2753: }
2754: }
2755: if (ref($moves) eq 'HASH') {
2756: if (ref($moves->{'copies'}) eq 'HASH') {
2757: %copies = %{$moves->{'copies'}};
2758: }
2759: if (ref($moves->{'docmoves'}) eq 'HASH') {
2760: %docmoves = %{$moves->{'docmoves'}};
2761: }
2762: if (ref($moves->{'mapmoves'}) eq 'HASH') {
2763: %mapmoves = %{$moves->{'mapmoves'}};
2764: }
2765: }
2766: foreach my $key (keys(%copies),keys(%docmoves)) {
1.484.2.7 raeburn 2767: my @allcopies;
1.484.2.23 raeburn 2768: if (exists($copies{$key})) {
2769: if (ref($copies{$key}) eq 'HASH') {
2770: my %added;
2771: foreach my $innerkey (keys(%{$copies{$key}})) {
2772: if (($innerkey ne '') && (!$added{$innerkey})) {
2773: push(@allcopies,$innerkey);
2774: $added{$innerkey} = 1;
2775: }
1.484.2.7 raeburn 2776: }
1.484.2.23 raeburn 2777: undef(%added);
1.484.2.7 raeburn 2778: }
2779: }
2780: if ($key eq $oldurl) {
1.484.2.23 raeburn 2781: if ((exists($docmoves{$key}))) {
1.484.2.25 raeburn 2782: unless (grep(/^\Q$oldurl\E$/,@allcopies)) {
1.484.2.7 raeburn 2783: push(@allcopies,$oldurl);
2784: }
2785: }
2786: }
2787: if (@allcopies > 0) {
2788: foreach my $item (@allcopies) {
1.484.2.19 raeburn 2789: my ($relpath,$oldsubdir,$fname) =
1.484.2.7 raeburn 2790: ($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(default|\d+)/.*/)([^/]+)$});
2791: if ($fname ne '') {
2792: my $content = &Apache::lonnet::getfile($item);
2793: unless ($content eq '-1') {
2794: my $storefn;
1.484.2.23 raeburn 2795: if (($key eq $oldurl) && (exists($docmoves{$key}))) {
2796: $storefn = $docmoves{$key};
1.484.2.7 raeburn 2797: } else {
2798: $storefn = $relpath;
2799: $storefn =~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 2800: if ($prefixchg && $before{'doc'} && $after{'doc'}) {
2801: $storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/;
1.484.2.7 raeburn 2802: }
1.484.2.23 raeburn 2803: if ($newsubdir{$key}) {
1.484.2.25 raeburn 2804: $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}/#;
1.484.2.7 raeburn 2805: }
2806: }
2807: ©_dependencies($item,$storefn,$relpath,$errors,\$content);
1.484.2.19 raeburn 2808: my $copyurl =
1.484.2.7 raeburn 2809: &Apache::lonclonecourse::writefile($env{'request.course.id'},
2810: $storefn.$fname,$content);
2811: if ($copyurl eq '/adm/notfound.html') {
1.484.2.23 raeburn 2812: if (exists($docmoves{$oldurl})) {
1.484.2.7 raeburn 2813: return &mt('Paste failed: an error occurred copying the file.');
2814: } elsif (ref($errors) eq 'HASH') {
2815: $errors->{$item} = 1;
2816: }
2817: }
2818: }
2819: }
2820: }
2821: }
2822: }
1.484.2.23 raeburn 2823: foreach my $key (keys(%mapmoves)) {
1.484.2.7 raeburn 2824: my $storefn=$key;
2825: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 2826: if ($prefixchg && $before{'map'} && $after{'map'}) {
2827: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.484.2.7 raeburn 2828: }
1.484.2.23 raeburn 2829: if ($newsubdir{$key}) {
2830: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.484.2.7 raeburn 2831: }
2832: my $mapcontent = &Apache::lonnet::getfile($key);
1.484.2.93.2. (raeburn 2833:): if (($mapcontent eq '-1') && ($before{'map'} eq 'supplemental') &&
2834:): ($after{'map'} eq 'default') &&
2835:): ($key =~ m{^/uploaded/$match_domain/$match_courseid/supplemental_\d+\.sequence$})) {
2836:): $mapcontent = '<map>'."\n".
2837:): '<resource id="1" src="" type="start" />'."\n".
2838:): '<link from="1" to="2" index="1" />'."\n".
2839:): '<resource id="2" src="" type="finish" />'."\n".
2840:): '</map>';
2841:): }
1.484.2.7 raeburn 2842: if ($mapcontent eq '-1') {
2843: if (ref($errors) eq 'HASH') {
2844: $errors->{$key} = 1;
2845: }
2846: } else {
2847: my $newmap =
2848: &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
2849: $mapcontent);
2850: if ($newmap eq '/adm/notfound.html') {
2851: if (ref($errors) eq 'HASH') {
2852: $errors->{$key} = 1;
2853: }
2854: }
2855: }
2856: }
2857: my %updates;
2858: if ($is_map) {
1.484.2.23 raeburn 2859: if (ref($updated) eq 'HASH') {
2860: foreach my $type (keys(%{$updated})) {
2861: if (ref($updated->{$type}) eq 'HASH') {
2862: foreach my $key (keys(%{$updated->{$type}})) {
2863: $updates{$key} = 1;
2864: }
2865: }
2866: }
1.484.2.7 raeburn 2867: }
2868: foreach my $key (keys(%updates)) {
2869: my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb);
1.484.2.23 raeburn 2870: if (ref($rewrites{$key}) eq 'HASH') {
2871: %torewrite = %{$rewrites{$key}};
1.484.2.7 raeburn 2872: }
1.484.2.23 raeburn 2873: if (ref($retitles{$key}) eq 'HASH') {
2874: %toretitle = %{$retitles{$key}};
1.484.2.7 raeburn 2875: }
1.484.2.23 raeburn 2876: if (ref($removefrommap{$key}) eq 'HASH') {
2877: %toremove = %{$removefrommap{$key}};
1.484.2.7 raeburn 2878: }
1.484.2.23 raeburn 2879: if (ref($removeparam{$key}) eq 'HASH') {
2880: %remparam = %{$removeparam{$key}};
1.484.2.7 raeburn 2881: }
1.484.2.23 raeburn 2882: if (ref($zombies{$key}) eq 'HASH') {
2883: %zombie = %{$zombies{$key}};
1.484.2.7 raeburn 2884: }
1.484.2.23 raeburn 2885: if (ref($dbcopies{$key}) eq 'HASH') {
1.484.2.26 raeburn 2886: foreach my $idx (keys(%{$dbcopies{$key}})) {
2887: if (ref($dbcopies{$key}{$idx}) eq 'HASH') {
2888: my ($newurl,$result,$errtext) =
2889: &dbcopy($dbcopies{$key}{$idx},$cdom,$cnum,\%lockerrors);
2890: if ($result eq 'ok') {
2891: $newdb{$idx} = $newurl;
2892: } elsif (ref($errors) eq 'HASH') {
2893: $errors->{$key} = 1;
2894: }
2895: push(@msgs,$errtext);
2896: }
1.484.2.7 raeburn 2897: }
2898: }
1.484.2.82 raeburn 2899: if (ref($resdatacopy{$key}) eq 'HASH') {
2900: my ($gotnewmapname,$newmapname,$srcfolder,$srccontainer);
2901: foreach my $idx (keys(%{$resdatacopy{$key}})) {
2902: if (ref($resdatacopy{$key}{$idx}) eq 'HASH') {
2903: my $srcurl = $resdatacopy{$key}{$idx}{'src'};
2904: if ($srcurl =~ m{^/res/lib/templates/(\w+)\.problem$}) {
2905: my $template = $1;
2906: if (($resdatacopy{$key}{$idx}{'cdom'} =~ /^$match_domain$/) &&
2907: ($resdatacopy{$key}{$idx}{'cnum'} =~ /^$match_courseid$/)) {
2908: my $srcdom = $resdatacopy{$key}{$idx}{'cdom'};
2909: my $srcnum = $resdatacopy{$key}{$idx}{'cnum'};
2910: unless ($gotnewmapname) {
2911: ($newmapname) = ($key =~ m{/([^/]+)$});
2912: ($srcfolder,$srccontainer) = split(/\./,$newmapname);
2913: if ($newsubdir{$key}) {
2914: $newmapname =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
2915: }
2916: $gotnewmapname = 1;
2917: }
2918: my $srcmapinfo = $srcfolder.':'.$idx;
2919: if ($srccontainer eq 'page') {
2920: $srcmapinfo .= ':1';
2921: }
2922: ©_templated_files($srcurl,$srcdom,$srcnum,$srcmapinfo,$cdom,
2923: $cnum,$template,$idx,$newmapname);
2924: }
2925: }
2926: }
2927: }
2928: }
1.484.2.23 raeburn 2929: if (ref($params{$key}) eq 'HASH') {
2930: %currparam = %{$params{$key}};
1.484.2.7 raeburn 2931: }
2932: my ($errtext,$fatal) = &LONCAPA::map::mapread($key);
2933: if ($fatal) {
1.484.2.26 raeburn 2934: return ($errtext);
1.484.2.7 raeburn 2935: }
2936: for (my $i=0; $i<@LONCAPA::map::zombies; $i++) {
2937: if (defined($LONCAPA::map::zombies[$i])) {
2938: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::zombies[$i]);
1.484.2.25 raeburn 2939: if ($zombie{$i} eq $src) {
1.484.2.7 raeburn 2940: undef($LONCAPA::map::zombies[$i]);
2941: }
2942: }
2943: }
1.484.2.77 raeburn 2944: my $total = scalar(@LONCAPA::map::order) - 1;
2945: for (my $i=$total; $i>=0; $i--) {
1.484.2.23 raeburn 2946: my $idx = $LONCAPA::map::order[$i];
2947: if (defined($LONCAPA::map::resources[$idx])) {
1.484.2.7 raeburn 2948: my $changed;
1.484.2.23 raeburn 2949: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]);
1.484.2.30 raeburn 2950: if ((exists($toremove{$idx})) &&
2951: ($toremove{$idx} eq &LONCAPA::map::qtescape($src))) {
1.484.2.7 raeburn 2952: splice(@LONCAPA::map::order,$i,1);
1.484.2.23 raeburn 2953: if (ref($currparam{$idx}) eq 'ARRAY') {
2954: foreach my $name (@{$currparam{$idx}}) {
1.484.2.77 raeburn 2955: &LONCAPA::map::delparameter($idx,$name);
1.484.2.7 raeburn 2956: }
2957: }
2958: next;
2959: }
2960: my $origsrc = $src;
1.484.2.25 raeburn 2961: if ((exists($toretitle{$idx})) && ($toretitle{$idx} eq $src)) {
1.484.2.7 raeburn 2962: if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
2963: $changed = 1;
2964: }
2965: }
1.484.2.25 raeburn 2966: if ((exists($torewrite{$idx})) && ($torewrite{$idx} eq $src)) {
1.484.2.7 raeburn 2967: $src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
2968: if ($origsrc =~ m{^/uploaded/}) {
1.484.2.23 raeburn 2969: if ($prefixchg && $before{'map'} && $after{'map'}) {
1.484.2.7 raeburn 2970: if ($src =~ /\.(page|sequence)$/) {
1.484.2.23 raeburn 2971: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'map'}\E#$1$after{'map'}#;
1.484.2.7 raeburn 2972: } else {
1.484.2.23 raeburn 2973: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
1.484.2.7 raeburn 2974: }
2975: }
1.484.2.25 raeburn 2976: if ($origsrc =~ /\.(page|sequence)$/) {
2977: if ($newsubdir{$origsrc}) {
1.484.2.23 raeburn 2978: $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir{$origsrc}#;
1.484.2.7 raeburn 2979: }
1.484.2.25 raeburn 2980: } elsif ($newsubdir{$key}) {
2981: $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$key}#;
1.484.2.7 raeburn 2982: }
2983: }
2984: $changed = 1;
1.484.2.26 raeburn 2985: } elsif ($newdb{$idx} ne '') {
2986: $src = $newdb{$idx};
1.484.2.7 raeburn 2987: $changed = 1;
2988: }
2989: if ($changed) {
1.484.2.30 raeburn 2990: $LONCAPA::map::resources[$idx] = join(':',($title,&LONCAPA::map::qtunescape($src),$ext,$type));
1.484.2.7 raeburn 2991: }
2992: }
2993: }
2994: foreach my $idx (keys(%remparam)) {
2995: if (ref($remparam{$idx}) eq 'ARRAY') {
1.484.2.19 raeburn 2996: foreach my $name (@{$remparam{$idx}}) {
1.484.2.77 raeburn 2997: &LONCAPA::map::delparameter($idx,$name);
1.484.2.7 raeburn 2998: }
2999: }
3000: }
1.484.2.26 raeburn 3001: if (values(%lockerrors) > 0) {
3002: $lockmsg = join('<br />',values(%lockerrors));
3003: }
1.484.2.7 raeburn 3004: my $storefn;
3005: if ($key eq $oldurl) {
3006: $storefn = $url;
3007: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
3008: } else {
3009: $storefn = $key;
3010: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 3011: if ($prefixchg && $before{'map'} && $after{'map'}) {
3012: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.484.2.7 raeburn 3013: }
1.484.2.23 raeburn 3014: if ($newsubdir{$key}) {
3015: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.484.2.7 raeburn 3016: }
3017: }
3018: my $report;
3019: if ($folder !~ /^supplemental/) {
3020: $report = 1;
3021: }
1.484.2.20 raeburn 3022: (my $outtext,$errtext) =
1.484.2.7 raeburn 3023: &LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report);
3024: if ($errtext) {
1.484.2.23 raeburn 3025: if ($caller eq 'paste') {
1.484.2.26 raeburn 3026: return (&mt('Paste failed: an error occurred saving the folder or page.'));
1.484.2.23 raeburn 3027: }
1.484.2.7 raeburn 3028: }
3029: }
3030: }
1.484.2.26 raeburn 3031: return ('ok',\@msgs,$lockmsg);
1.484.2.7 raeburn 3032: }
3033:
3034: sub copy_dependencies {
3035: my ($item,$storefn,$relpath,$errors,$contentref) = @_;
3036: my $content;
3037: if (ref($contentref)) {
3038: $content = $$contentref;
3039: } else {
3040: $content = &Apache::lonnet::getfile($item);
3041: }
3042: unless ($content eq '-1') {
3043: my $mm = new File::MMagic;
3044: my $mimetype = $mm->checktype_contents($content);
3045: if ($mimetype eq 'text/html') {
3046: my (%allfiles,%codebase,$state);
3047: my $res = &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,\$content);
3048: if ($res eq 'ok') {
3049: my ($numexisting,$numpathchanges,$existing);
3050: (undef,$numexisting,$numpathchanges,$existing) =
3051: &Apache::loncommon::ask_for_embedded_content(
3052: '/adm/coursedocs',$state,\%allfiles,\%codebase,
3053: {'error_on_invalid_names' => 1,
3054: 'ignore_remote_references' => 1,
3055: 'docs_url' => $item,
3056: 'context' => 'paste'});
3057: if ($numexisting > 0) {
3058: if (ref($existing) eq 'HASH') {
3059: foreach my $dep (keys(%{$existing})) {
3060: my $depfile = $dep;
3061: unless ($depfile =~ m{^\Q$relpath\E}) {
3062: $depfile = $relpath.$dep;
3063: }
3064: my $depcontent = &Apache::lonnet::getfile($depfile);
3065: unless ($depcontent eq '-1') {
3066: my $storedep = $dep;
3067: $storedep =~ s{^\Q$relpath\E}{};
3068: my $dep_url =
3069: &Apache::lonclonecourse::writefile(
3070: $env{'request.course.id'},
3071: $storefn.$storedep,$depcontent);
3072: if ($dep_url eq '/adm/notfound.html') {
3073: if (ref($errors) eq 'HASH') {
3074: $errors->{$depfile} = 1;
3075: }
3076: } else {
3077: ©_dependencies($depfile,$storefn,$relpath,$errors,\$depcontent);
3078: }
3079: }
3080: }
3081: }
3082: }
3083: }
3084: }
3085: }
3086: return;
3087: }
3088:
1.329 droeschl 3089: my %parameter_type = ( 'randompick' => 'int_pos',
3090: 'hiddenresource' => 'string_yesno',
3091: 'encrypturl' => 'string_yesno',
3092: 'randomorder' => 'string_yesno',);
3093: my $valid_parameters_re = join('|',keys(%parameter_type));
3094: # set parameters
3095: sub update_parameter {
1.484.2.29 raeburn 3096: if ($env{'form.changeparms'} eq 'all') {
3097: my (@allidx,@allmapidx,%allchecked,%currchecked);
3098: %allchecked = (
3099: 'hiddenresource' => {},
3100: 'encrypturl' => {},
3101: 'randompick' => {},
3102: 'randomorder' => {},
3103: );
3104: foreach my $which (keys(%allchecked)) {
3105: $env{'form.all'.$which} =~ s/,$//;
3106: if ($which eq 'randompick') {
3107: foreach my $item (split(/,/,$env{'form.all'.$which})) {
3108: my ($res,$value) = split(/:/,$item);
3109: if ($value =~ /^\d+$/) {
3110: $allchecked{$which}{$res} = $value;
3111: }
3112: }
3113: } else {
1.484.2.30 raeburn 3114: if ($env{'form.all'.$which}) {
3115: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.all'.$which});
3116: }
1.484.2.29 raeburn 3117: }
3118: }
3119: my $haschanges = 0;
3120: foreach my $res (@LONCAPA::map::order) {
3121: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3122: $name=&LONCAPA::map::qtescape($name);
3123: $url=&LONCAPA::map::qtescape($url);
1.484.2.93.2. (raeburn 3124:): next unless $url;
1.484.2.29 raeburn 3125: my $is_map;
3126: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
3127: $is_map = 1;
3128: }
3129: foreach my $which (keys(%allchecked)) {
3130: if (($which eq 'randompick' || $which eq 'randomorder')) {
3131: next if (!$is_map);
3132: }
3133: my $oldvalue = 0;
3134: my $newvalue = 0;
3135: if ($allchecked{$which}{$res}) {
3136: $newvalue = $allchecked{$which}{$res};
3137: }
3138: my $current = (&LONCAPA::map::getparameter($res,'parameter_'.$which))[0];
3139: if ($which eq 'randompick') {
3140: if ($current =~ /^(\d+)$/) {
3141: $oldvalue = $1;
3142: }
3143: } else {
3144: if ($current =~ /^yes$/i) {
3145: $oldvalue = 1;
3146: }
3147: }
3148: if ($oldvalue ne $newvalue) {
3149: $haschanges = 1;
3150: if ($newvalue) {
3151: my $storeval = 'yes';
3152: if ($which eq 'randompick') {
3153: $storeval = $newvalue;
3154: }
3155: &LONCAPA::map::storeparameter($res,'parameter_'.$which,
3156: $storeval,
3157: $parameter_type{$which});
3158: &remember_parms($res,$which,'set',$storeval);
3159: } elsif ($oldvalue) {
3160: &LONCAPA::map::delparameter($res,'parameter_'.$which);
3161: &remember_parms($res,$which,'del');
3162: }
3163: }
3164: }
3165: }
3166: return $haschanges;
1.329 droeschl 3167: } else {
1.484.2.59 raeburn 3168: my $haschanges = 0;
3169: return $haschanges if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
1.364 bisitz 3170:
1.484.2.29 raeburn 3171: my $which = $env{'form.changeparms'};
3172: my $idx = $env{'form.setparms'};
1.484.2.59 raeburn 3173: my $oldvalue = 0;
3174: my $newvalue = 0;
3175: my $current = (&LONCAPA::map::getparameter($idx,'parameter_'.$which))[0];
3176: if ($which eq 'randompick') {
3177: if ($current =~ /^(\d+)$/) {
3178: $oldvalue = $1;
3179: }
3180: } elsif ($current =~ /^yes$/i) {
3181: $oldvalue = 1;
3182: }
1.484.2.29 raeburn 3183: if ($env{'form.'.$which.'_'.$idx}) {
1.484.2.59 raeburn 3184: $newvalue = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx}
3185: : 1;
1.484.2.29 raeburn 3186: }
1.484.2.59 raeburn 3187: if ($oldvalue ne $newvalue) {
3188: $haschanges = 1;
3189: if ($newvalue) {
3190: my $storeval = 'yes';
3191: if ($which eq 'randompick') {
3192: $storeval = $newvalue;
3193: }
3194: &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $storeval,
3195: $parameter_type{$which});
3196: &remember_parms($idx,$which,'set',$storeval);
3197: } else {
3198: &LONCAPA::map::delparameter($idx,'parameter_'.$which);
3199: &remember_parms($idx,$which,'del');
3200: }
3201: }
3202: return $haschanges;
1.329 droeschl 3203: }
1.484.2.59 raeburn 3204: return;
1.329 droeschl 3205: }
3206:
3207: sub handle_edit_cmd {
3208: my ($coursenum,$coursedom) =@_;
1.484.2.93.2. 2(raebur 3209:3): my $haschanges = 0;
1.484.2.30 raeburn 3210: if ($env{'form.cmd'} eq '') {
1.484.2.93.2. 2(raebur 3211:3): return $haschanges;
1.484.2.30 raeburn 3212: }
1.329 droeschl 3213: my ($cmd,$idx)=split('_',$env{'form.cmd'});
3214:
3215: my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
3216: my ($title, $url, @rrest) = split(':', $ratstr);
3217:
1.484.2.30 raeburn 3218: if ($cmd eq 'remove') {
1.329 droeschl 3219: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
1.463 www 3220: ($url!~/$LONCAPA::assess_page_seq_re/)) {
1.329 droeschl 3221: &Apache::lonnet::removeuploadedurl($url);
3222: } else {
3223: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
3224: }
3225: splice(@LONCAPA::map::order, $idx, 1);
1.484.2.93.2. 2(raebur 3226:3): $haschanges = 1;
1.329 droeschl 3227: } elsif ($cmd eq 'cut') {
3228: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
3229: splice(@LONCAPA::map::order, $idx, 1);
1.484.2.93.2. 2(raebur 3230:3): $haschanges = 1;
1.344 bisitz 3231: } elsif ($cmd eq 'up'
1.329 droeschl 3232: && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
3233: @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
1.484.2.93.2. 2(raebur 3234:3): $haschanges = 1;
1.329 droeschl 3235: } elsif ($cmd eq 'down'
3236: && defined($LONCAPA::map::order[$idx+1])) {
3237: @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
1.484.2.93.2. 2(raebur 3238:3): $haschanges = 1;
1.329 droeschl 3239: } elsif ($cmd eq 'rename') {
3240: my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
3241: if ($comment=~/\S/) {
3242: $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
3243: $comment.':'.join(':', $url, @rrest);
3244: }
3245: # Devalidate title cache
3246: my $renamed_url=&LONCAPA::map::qtescape($url);
3247: &Apache::lonnet::devalidate_title_cache($renamed_url);
1.484.2.93.2. 2(raebur 3248:3): $haschanges = 1;
1.329 droeschl 3249: }
1.484.2.93.2. 2(raebur 3250:3): return $haschanges;
1.329 droeschl 3251: }
3252:
3253: sub editor {
1.458 raeburn 3254: my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
1.484.2.93.2. (raeburn 3255:): $supplementalflag,$orderhash,$iconpath,$pathitem,$ltitoolsref,
3256:): $canedit,$hostname,$navmapref,$hiddentop)=@_;
1.484.2.19 raeburn 3257: my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
3258: if ($allowed) {
3259: (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
3260: $is_random_order,$container) =
3261: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
3262: $r->print($breadcrumbtrail);
3263: } elsif ($env{'form.folderpath'} =~ /\:1$/) {
3264: $container = 'page';
3265: } else {
3266: $container = 'sequence';
3267: }
1.484 raeburn 3268:
1.484.2.21 raeburn 3269: my $jumpto;
3270:
3271: unless ($supplementalflag) {
1.484.2.32 raeburn 3272: $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
1.484.2.21 raeburn 3273: }
1.484 raeburn 3274:
3275: unless ($allowed) {
3276: $randompick = -1;
3277: }
3278:
1.484.2.67 raeburn 3279: my ($errtext,$fatal);
3280: if (($folder eq '') && (!$supplementalflag)) {
3281: if (@LONCAPA::map::order) {
3282: undef(@LONCAPA::map::order);
3283: undef(@LONCAPA::map::resources);
3284: undef(@LONCAPA::map::resparms);
3285: undef(@LONCAPA::map::zombies);
3286: }
3287: $folder = 'default';
3288: $container = 'sequence';
3289: } else {
3290: ($errtext,$fatal) = &mapread($coursenum,$coursedom,
3291: $folder.'.'.$container);
3292: return $errtext if ($fatal);
3293: }
1.329 droeschl 3294:
3295: if ($#LONCAPA::map::order<1) {
3296: my $idx=&LONCAPA::map::getresidx();
3297: if ($idx<=0) { $idx=1; }
3298: $LONCAPA::map::order[0]=$idx;
3299: $LONCAPA::map::resources[$idx]='';
3300: }
1.364 bisitz 3301:
1.329 droeschl 3302: # ------------------------------------------------------------ Process commands
3303:
3304: # ---------------- if they are for this folder and user allowed to make changes
1.484.2.67 raeburn 3305: if (($allowed && $canedit) && ($env{'form.folder'} eq $folder)) {
1.329 droeschl 3306: # set parameters and change order
3307: &snapshotbefore();
3308:
3309: if (&update_parameter()) {
1.484.2.59 raeburn 3310: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1.329 droeschl 3311: return $errtext if ($fatal);
3312: }
3313:
3314: if ($env{'form.newpos'} && $env{'form.currentpos'}) {
3315: # change order
3316: my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
3317: splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
3318:
3319: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
3320: return $errtext if ($fatal);
3321: }
1.364 bisitz 3322:
1.329 droeschl 3323: if ($env{'form.pastemarked'}) {
1.484.2.7 raeburn 3324: my %paste_errors;
1.484.2.26 raeburn 3325: my ($paste_res,$save_error,$pastemsgarray,$lockerror) =
1.484.2.7 raeburn 3326: &do_paste_from_buffer($coursenum,$coursedom,$folder,$container,
3327: \%paste_errors);
1.484.2.30 raeburn 3328: if (ref($pastemsgarray) eq 'ARRAY') {
3329: if (@{$pastemsgarray} > 0) {
3330: $r->print('<p class="LC_info">'.
3331: join('<br />',@{$pastemsgarray}).
1.484.2.26 raeburn 3332: '</p>');
3333: }
1.484.2.30 raeburn 3334: }
3335: if ($lockerror) {
3336: $r->print('<p class="LC_error">'.
3337: $lockerror.
3338: '</p>');
3339: }
3340: if ($save_error ne '') {
3341: return $save_error;
3342: }
3343: if ($paste_res) {
3344: my %errortext = &Apache::lonlocal::texthash (
3345: fail => 'Storage of folder contents failed',
3346: failread => 'Reading folder contents failed',
3347: failstore => 'Storage of folder contents failed',
3348: );
3349: if ($errortext{$paste_res}) {
3350: $r->print('<p class="LC_error">'.$errortext{$paste_res}.'</p>');
1.484.2.7 raeburn 3351: }
1.329 droeschl 3352: }
1.484.2.7 raeburn 3353: if (keys(%paste_errors) > 0) {
1.484.2.30 raeburn 3354: $r->print('<p class="LC_warning">'."\n".
1.484.2.7 raeburn 3355: &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".
3356: '<ul>'."\n");
3357: foreach my $key (sort(keys(%paste_errors))) {
3358: $r->print('<li>'.$key.'</li>'."\n");
3359: }
3360: $r->print('</ul></p>'."\n");
3361: }
1.484.2.30 raeburn 3362: } elsif ($env{'form.clearmarked'}) {
3363: my $output = &do_buffer_empty();
3364: if ($output) {
3365: $r->print('<p class="LC_info">'.$output.'</p>');
3366: }
3367: }
1.329 droeschl 3368:
3369: $r->print($upload_output);
3370:
1.484.2.30 raeburn 3371: # Rename, cut, copy or remove a single resource
1.484.2.63 raeburn 3372: if (&handle_edit_cmd($coursenum,$coursedom)) {
1.484.2.7 raeburn 3373: my $contentchg;
1.484.2.58 raeburn 3374: if ($env{'form.cmd'} =~ m{^(remove|cut)_}) {
1.484.2.7 raeburn 3375: $contentchg = 1;
3376: }
3377: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);
1.329 droeschl 3378: return $errtext if ($fatal);
3379: }
1.484.2.30 raeburn 3380:
3381: # Cut, copy and/or remove multiple resources
3382: if ($env{'form.multichange'}) {
3383: my %allchecked = (
3384: cut => {},
3385: remove => {},
3386: );
3387: my $needsupdate;
3388: foreach my $which (keys(%allchecked)) {
3389: $env{'form.multi'.$which} =~ s/,$//;
3390: if ($env{'form.multi'.$which}) {
3391: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.multi'.$which});
3392: if (ref($allchecked{$which}) eq 'HASH') {
3393: $needsupdate += scalar(keys(%{$allchecked{$which}}));
3394: }
3395: }
3396: }
3397: if ($needsupdate) {
3398: my $haschanges = 0;
3399: my %curr_groups = &Apache::longroup::coursegroups();
3400: my $total = scalar(@LONCAPA::map::order) - 1;
3401: for (my $i=$total; $i>=0; $i--) {
3402: my $res = $LONCAPA::map::order[$i];
3403: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3404: $name=&LONCAPA::map::qtescape($name);
3405: $url=&LONCAPA::map::qtescape($url);
1.484.2.57 raeburn 3406: next unless $url;
1.484.2.30 raeburn 3407: my %denied =
3408: &action_restrictions($coursenum,$coursedom,$url,
3409: $env{'form.folderpath'},\%curr_groups);
3410: foreach my $which (keys(%allchecked)) {
3411: next if ($denied{$which});
3412: next unless ($allchecked{$which}{$res});
3413: if ($which eq 'remove') {
3414: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
3415: ($url!~/$LONCAPA::assess_page_seq_re/)) {
3416: &Apache::lonnet::removeuploadedurl($url);
3417: } else {
3418: &LONCAPA::map::makezombie($res);
3419: }
3420: splice(@LONCAPA::map::order,$i,1);
3421: $haschanges ++;
3422: } elsif ($which eq 'cut') {
3423: &LONCAPA::map::makezombie($res);
3424: splice(@LONCAPA::map::order,$i,1);
3425: $haschanges ++;
3426: }
3427: }
3428: }
3429: if ($haschanges) {
3430: ($errtext,$fatal) =
3431: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
3432: return $errtext if ($fatal);
3433: }
3434: }
3435: }
3436:
1.329 droeschl 3437: # Group import/search
3438: if ($env{'form.importdetail'}) {
3439: my @imports;
3440: foreach my $item (split(/\&/,$env{'form.importdetail'})) {
3441: if (defined($item)) {
3442: my ($name,$url,$residx)=
1.484.2.26 raeburn 3443: map { &unescape($_); } split(/\=/,$item);
3444: if ($url =~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
1.484.2.30 raeburn 3445: my ($suffix,$errortxt,$locknotfreed) =
1.484.2.26 raeburn 3446: &new_timebased_suffix($coursedom,$coursenum,'map',$1,$2);
1.484.2.15 raeburn 3447: if ($locknotfreed) {
3448: $r->print($locknotfreed);
3449: }
3450: if ($suffix) {
1.484.2.19 raeburn 3451: $url =~ s/_new\./_$suffix./;
1.484.2.15 raeburn 3452: } else {
3453: return $errortxt;
3454: }
1.484.2.26 raeburn 3455: } elsif ($url =~ m{^/adm/$match_domain/$match_username/new/(smppg|bulletinboard)$}) {
3456: my $type = $1;
3457: my ($suffix,$errortxt,$locknotfreed) =
3458: &new_timebased_suffix($coursedom,$coursenum,$type);
3459: if ($locknotfreed) {
3460: $r->print($locknotfreed);
3461: }
3462: if ($suffix) {
3463: $url =~ s{^(/adm/$match_domain/$match_username)/new}{$1/$suffix};
3464: } else {
3465: return $errortxt;
3466: }
1.484.2.93.2. (raeburn 3467:): } elsif ($url =~ m{^/adm/$coursedom/$coursenum/new/ext\.tool}) {
3468:): my ($suffix,$errortxt,$locknotfreed) =
3469:): &new_timebased_suffix($coursedom,$coursenum,'exttool');
3470:): if ($locknotfreed) {
3471:): $r->print($locknotfreed);
3472:): }
3473:): if ($suffix) {
3474:): $url =~ s{^(/adm/$coursedom/$coursenum)/new}{$1/$suffix};
3475:): } else {
3476:): return $errortxt;
3477:): }
1.484.2.27 raeburn 3478: } elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) {
3479: if ($supplementalflag) {
3480: next unless ($1 eq 'supplemental');
3481: if ($folder eq 'supplemental') {
3482: next unless ($2 eq 'default');
3483: } else {
3484: next unless ($folder eq 'supplemental_'.$2);
3485: }
3486: } else {
3487: next unless ($1 eq 'docs');
3488: if ($folder eq 'default') {
3489: next unless ($2 eq 'default');
3490: } else {
3491: next unless ($folder eq 'default_'.$2);
3492: }
3493: }
1.484.2.15 raeburn 3494: }
1.329 droeschl 3495: push(@imports, [$name, $url, $residx]);
3496: }
3497: }
1.484.2.23 raeburn 3498: ($errtext,$fatal,my $fixuperrors) =
3499: &group_import($coursenum, $coursedom, $folder,$container,
1.484.2.93.2. (raeburn 3500:): 'londocs',$ltitoolsref,@imports);
1.329 droeschl 3501: return $errtext if ($fatal);
1.484.2.23 raeburn 3502: if ($fixuperrors) {
3503: $r->print($fixuperrors);
3504: }
1.329 droeschl 3505: }
3506: # Loading a complete map
3507: if ($env{'form.loadmap'}) {
3508: if ($env{'form.importmap'}=~/\w/) {
3509: foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
3510: my ($title,$url,$ext,$type)=split(/\:/,$res);
3511: my $idx=&LONCAPA::map::getresidx($url);
3512: $LONCAPA::map::resources[$idx]=$res;
3513: $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
3514: }
3515: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.484.2.7 raeburn 3516: $folder.'.'.$container,1);
1.329 droeschl 3517: return $errtext if ($fatal);
3518: } else {
3519: $r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
1.364 bisitz 3520:
1.329 droeschl 3521: }
3522: }
3523: &log_differences($plain);
3524: }
3525: # ---------------------------------------------------------------- End commands
3526: # ---------------------------------------------------------------- Print screen
3527: my $idx=0;
3528: my $shown=0;
3529: if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
1.381 bisitz 3530: $r->print('<div class="LC_Box">'.
1.432 raeburn 3531: '<ol class="LC_docs_parameters"><li class="LC_docs_parameters_title">'.&mt('Parameters:').'</li>'.
3532: ($randompick>=0?'<li>'.&mt('randomly pick [quant,_1,resource]',$randompick).'</li>':'').
3533: ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
3534: ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
3535: ($is_random_order?'<li>'.&mt('random order').'</li>':'').
1.431 raeburn 3536: '</ol>');
1.381 bisitz 3537: if ($randompick>=0) {
3538: $r->print('<p class="LC_warning">'
3539: .&mt('Caution: this folder is set to randomly pick a subset'
3540: .' of resources. Adding or removing resources from this'
3541: .' folder will change the set of resources that the'
3542: .' students see, resulting in spurious or missing credit'
3543: .' for completed problems, not limited to ones you'
3544: .' modify. Do not modify the contents of this folder if'
3545: .' it is in active student use.')
3546: .'</p>'
3547: );
3548: }
3549: if ($is_random_order) {
3550: $r->print('<p class="LC_warning">'
3551: .&mt('Caution: this folder is set to randomly order its'
3552: .' contents. Adding or removing resources from this folder'
3553: .' will change the order of resources shown.')
3554: .'</p>'
3555: );
3556: }
3557: $r->print('</div>');
1.364 bisitz 3558: }
1.381 bisitz 3559:
1.484.2.93.2. 0(raebur 3560:3): if ((!$allowed) && ($folder =~ /^supplemental_\d+$/)) {
3561:3): my ($supplemental) = &Apache::loncommon::get_supplemental($coursenum,$coursedom);
3562:3): if (ref($supplemental) eq 'HASH') {
3563:3): if ((ref($supplemental->{'hidden'}) eq 'HASH') &&
3564:3): (ref($supplemental->{'ids'}) eq 'HASH')) {
3565:3): if (ref($supplemental->{'ids'}->{"/uploaded/$coursedom/$coursenum/$folder.$container"}) eq 'ARRAY') {
3566:3): my $mapnum = $supplemental->{'ids'}->{"/uploaded/$coursedom/$coursenum/$folder.$container"}->[0];
3567:3): if ($supplemental->{'hidden'}->{$mapnum}) {
3568:3): $ishidden = 1;
3569:3): }
3570:3): }
3571:3): }
3572:3): }
3573:3): }
3574:3):
1.484.2.30 raeburn 3575: my ($to_show,$output,@allidx,@allmapidx,%filters,%lists,%curr_groups);
3576: %filters = (
3577: canremove => [],
3578: cancut => [],
3579: cancopy => [],
3580: hiddenresource => [],
3581: encrypturl => [],
3582: randomorder => [],
3583: randompick => [],
3584: );
3585: %curr_groups = &Apache::longroup::coursegroups();
1.424 onken 3586: &Apache::loncommon::start_data_table_count(); #setup a row counter
1.381 bisitz 3587: foreach my $res (@LONCAPA::map::order) {
3588: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3589: $name=&LONCAPA::map::qtescape($name);
3590: $url=&LONCAPA::map::qtescape($url);
3591: unless ($name) { $name=(split(/\//,$url))[-1]; }
3592: unless ($name) { $idx++; next; }
1.484.2.29 raeburn 3593: push(@allidx,$res);
3594: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
3595: push(@allmapidx,$res);
3596: }
1.484.2.67 raeburn 3597:
1.484.2.93.2. 0(raebur 3598:3): if (($supplementalflag) && (!$allowed) && (!$env{'request.role.adv'})) {
3599:3): if (($ishidden) || ((&LONCAPA::map::getparameter($res,'parameter_hiddenresource'))[0]=~/^yes$/i)) {
3600:3): $idx++;
3601:3): next;
3602:3): }
3603:3): }
1.381 bisitz 3604: $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
1.484.2.12 raeburn 3605: $coursenum,$coursedom,$crstype,
1.484.2.30 raeburn 3606: $pathitem,$supplementalflag,$container,
1.484.2.93.2. (raeburn 3607:): \%filters,\%curr_groups,$ltitoolsref,$canedit,
0(raebur 3608:3): $isencrypted,$ishidden,$navmapref,$hostname);
1.381 bisitz 3609: $idx++;
3610: $shown++;
1.329 droeschl 3611: }
1.424 onken 3612: &Apache::loncommon::end_data_table_count();
1.484.2.19 raeburn 3613:
1.484.2.30 raeburn 3614: my $need_save;
1.484.2.67 raeburn 3615: if ($allowed || ($supplementalflag && $folder eq 'supplemental')) {
1.484.2.31 raeburn 3616: my $toolslink;
1.484.2.93.2. 0(raebur 3617:3): if ($allowed || $canedit) {
3618:3): my $helpitem = 'Navigation_Screen';
3619:3): if (!$allowed) {
3620:3): $helpitem = 'Supplemental_Navigation';
3621:3): }
1.484.2.31 raeburn 3622: $toolslink = '<table><tr><td>'
1.484.2.19 raeburn 3623: .&Apache::loncommon::help_open_menu('Navigation Screen',
1.484.2.93.2. 0(raebur 3624:3): $helpitem,undef,'RAT')
1.484.2.19 raeburn 3625: .'</td><td class="LC_middle">'.&mt('Tools:').'</td>'
3626: .'<td align="left"><ul id="LC_toolbar">'
1.484.2.21 raeburn 3627: .'<li><a href="/adm/coursedocs?forcesupplement=1&command=editsupp" '
1.484.2.19 raeburn 3628: .'id="LC_content_toolbar_edittoplevel" '
3629: .'class="LC_toolbarItem" '
3630: .'title="'.&mt('Supplemental Content Editor').'">'
3631: .'</a></li></ul></td></tr></table><br />';
1.484.2.31 raeburn 3632: }
1.484.2.19 raeburn 3633: if ($shown) {
3634: if ($allowed) {
3635: $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
3636: .&Apache::loncommon::start_data_table(undef,'contentlist')
3637: .&Apache::loncommon::start_data_table_header_row()
3638: .'<th colspan="2">'.&mt('Move').'</th>'
1.484.2.30 raeburn 3639: .'<th colspan="2">'.&mt('Actions').'</th>'
1.484.2.93.2. 0(raebur 3640:3): .'<th>'.&mt('Document').'</th>'
3641:3): .'<th colspan="2">'.&mt('Settings').'</th>'
3642:3): .&Apache::loncommon::end_data_table_header_row();
1.484.2.29 raeburn 3643: if ($folder !~ /^supplemental/) {
1.484.2.30 raeburn 3644: $lists{'canhide'} = join(',',@allidx);
3645: $lists{'canrandomlyorder'} = join(',',@allmapidx);
3646: my @possfilters = ('canremove','cancut','cancopy','hiddenresource','encrypturl',
3647: 'randomorder','randompick');
3648: foreach my $item (@possfilters) {
3649: if (ref($filters{$item}) eq 'ARRAY') {
3650: if (@{$filters{$item}} > 0) {
3651: $lists{$item} = join(',',@{$filters{$item}});
3652: }
3653: }
3654: }
1.484.2.29 raeburn 3655: if (@allidx > 0) {
3656: my $path;
3657: if ($env{'form.folderpath'}) {
3658: $path =
3659: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3660: }
1.484.2.30 raeburn 3661: if (@allidx > 1) {
3662: $to_show .=
3663: &Apache::loncommon::continue_data_table_row().
3664: '<td colspan="2"> </td>'.
3665: '<td>'.
1.484.2.67 raeburn 3666: &multiple_check_form('actions',\%lists,$canedit).
1.484.2.30 raeburn 3667: '</td>'.
3668: '<td> </td>'.
3669: '<td> </td>'.
1.484.2.93.2. 0(raebur 3670:3): '<td colspan="2">'.
1.484.2.67 raeburn 3671: &multiple_check_form('settings',\%lists,$canedit).
1.484.2.30 raeburn 3672: '</td>'.
3673: &Apache::loncommon::end_data_table_row();
3674: $need_save = 1;
3675: }
1.484.2.29 raeburn 3676: }
3677: }
3678: $to_show .= $output.' '
1.484.2.19 raeburn 3679: .&Apache::loncommon::end_data_table()
3680: .'<br style="line-height:2px;" />'
3681: .&Apache::loncommon::end_scrollbox();
3682: } else {
3683: $to_show .= $toolslink
3684: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3685: .$output.' '
3686: .&Apache::loncommon::end_data_table();
3687: }
3688: } else {
3689: if (!$allowed) {
3690: $to_show .= $toolslink;
1.393 raeburn 3691: }
1.484.2.67 raeburn 3692: my $noresmsg;
3693: if ($allowed && $hiddentop && !$supplementalflag) {
3694: $noresmsg = &mt('Main Content Hidden');
3695: } else {
3696: $noresmsg = &mt('Currently empty');
3697: }
1.484.2.19 raeburn 3698: $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
3699: .'<div class="LC_info" id="contentlist">'
1.484.2.67 raeburn 3700: .$noresmsg
1.484.2.19 raeburn 3701: .'</div>'
3702: .&Apache::loncommon::end_scrollbox();
1.393 raeburn 3703: }
3704: } else {
1.484.2.19 raeburn 3705: if ($shown) {
3706: $to_show = '<div>'
3707: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3708: .$output
3709: .&Apache::loncommon::end_data_table()
3710: .'</div>';
3711: } else {
3712: $to_show = '<div class="LC_info" id="contentlist">'
1.484.2.34 raeburn 3713: .&mt('Currently empty')
1.484.2.19 raeburn 3714: .'</div>'
3715: }
1.458 raeburn 3716: }
3717: my $tid = 1;
3718: if ($supplementalflag) {
3719: $tid = 2;
1.329 droeschl 3720: }
3721: if ($allowed) {
1.484 raeburn 3722: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
1.484.2.30 raeburn 3723: $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,
1.484.2.67 raeburn 3724: $jumpto,$readfile,$need_save,"$folder.$container",$canedit));
1.484.2.68 raeburn 3725: if ($canedit) {
1.484.2.67 raeburn 3726: &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
3727: }
1.460 raeburn 3728: } else {
3729: $r->print($to_show);
1.329 droeschl 3730: }
3731: return;
3732: }
3733:
1.484.2.30 raeburn 3734: sub multiple_check_form {
1.484.2.67 raeburn 3735: my ($caller,$listsref,$canedit) = @_;
1.484.2.30 raeburn 3736: return unless (ref($listsref) eq 'HASH');
1.484.2.67 raeburn 3737: my $disabled;
3738: unless ($canedit) {
1.484.2.93.2. 2(raebur 3739:3): $disabled = ' disabled="disabled"';
1.484.2.67 raeburn 3740: }
1.484.2.30 raeburn 3741: my $output =
3742: '<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'.
3743: '<span class="LC_nobreak" style="font-size:x-small;font-weight:bold;">'.
3744: '<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>'.
3745: '<div id="multi'.$caller.'" style="display:none;margin:0;padding:0;border:0">'.
3746: '<form action="/adm/coursedocs" method="post" name="cumulative'.$caller.'">'."\n".
3747: '<fieldset id="allfields'.$caller.'" style="display:none"><legend style="font-size:x-small;">'.&mt('check/uncheck all').'</legend>'."\n";
3748: if ($caller eq 'settings') {
3749: $output .=
3750: '<table><tr>'.
3751: '<td class="LC_docs_entry_parameter">'.
3752: '<span class="LC_nobreak"><label>'.
1.484.2.67 raeburn 3753: '<input type="checkbox" name="hiddenresourceall" id="hiddenresourceall" onclick="propagateState(this.form,'."'hiddenresource'".')"'.$disabled.' />'.&mt('Hidden').
1.484.2.30 raeburn 3754: '</label></span></td>'.
3755: '<td class="LC_docs_entry_parameter">'.
1.484.2.67 raeburn 3756: '<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 3757: '</span></td>'.
3758: '</tr>'."\n".
3759: '<tr>'.
3760: '<td class="LC_docs_entry_parameter">'.
1.484.2.67 raeburn 3761: '<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 3762: '</label></span>'.
3763: '</td></tr></table>'."\n";
3764: } else {
3765: $output .=
3766: '<table><tr>'.
3767: '<td class="LC_docs_entry_parameter">'.
3768: '<span class="LC_nobreak LC_docs_remove">'.
1.484.2.67 raeburn 3769: '<label><input type="checkbox" name="removeall" id="removeall" onclick="propagateState(this.form,'."'remove'".')"'.$disabled.' />'.&mt('Remove').
1.484.2.30 raeburn 3770: '</label></span></td>'.
3771: '<td class="LC_docs_entry_parameter">'.
3772: '<span class="LC_nobreak LC_docs_cut">'.
1.484.2.67 raeburn 3773: '<label><input type="checkbox" name="cut" id="cutall" onclick="propagateState(this.form,'."'cut'".');"'.$disabled.' />'.&mt('Cut').
1.484.2.30 raeburn 3774: '</label></span></td>'."\n".
3775: '<td class="LC_docs_entry_parameter">'.
3776: '<span class="LC_nobreak LC_docs_copy">'.
1.484.2.67 raeburn 3777: '<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')"'.$disabled.' />'.&mt('Copy').
1.484.2.30 raeburn 3778: '</label></span></td>'.
3779: '</tr></table>'."\n";
3780: }
3781: $output .=
3782: '</fieldset>'.
3783: '<input type="hidden" name="allidx" value="'.$listsref->{'canhide'}.'" />';
3784: if ($caller eq 'settings') {
3785: $output .=
3786: '<input type="hidden" name="allmapidx" value="'.$listsref->{'canrandomlyorder'}.'" />'."\n".
3787: '<input type="hidden" name="currhiddenresource" value="'.$listsref->{'hiddenresource'}.'" />'."\n".
3788: '<input type="hidden" name="currencrypturl" value="'.$listsref->{'encrypturl'}.'" />'."\n".
3789: '<input type="hidden" name="currrandomorder" value="'.$listsref->{'randomorder'}.'" />'."\n".
3790: '<input type="hidden" name="currrandompick" value="'.$listsref->{'randompick'}.'" />'."\n";
3791: } elsif ($caller eq 'actions') {
3792: $output .=
3793: '<input type="hidden" name="allremoveidx" id="allremoveidx" value="'.$listsref->{'canremove'}.'" />'.
3794: '<input type="hidden" name="allcutidx" id="allcutidx" value="'.$listsref->{'cancut'}.'" />'.
3795: '<input type="hidden" name="allcopyidx" id="allcopyidx" value="'.$listsref->{'cancopy'}.'" />';
3796: }
3797: $output .=
3798: '</form>'.
3799: '</div>';
3800: return $output;
3801: }
3802:
1.329 droeschl 3803: sub process_file_upload {
1.484.2.36 raeburn 3804: my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd,$crstype) = @_;
1.329 droeschl 3805: # upload a file, if present
1.484.2.36 raeburn 3806: my $filesize = length($env{'form.uploaddoc'});
3807: if (!$filesize) {
3808: $$upload_output = '<div class="LC_error">'.
3809: &mt('Unable to upload [_1]. (size = [_2] bytes)',
3810: '<span class="LC_filename">'.$env{'form.uploaddoc.filename'}.'</span>',
3811: $filesize).'<br />'.
3812: &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'<br />'.
3813: '</div>';
3814: return;
3815: }
3816: my $quotatype = 'unofficial';
3817: if ($crstype eq 'Community') {
3818: $quotatype = 'community';
1.484.2.51 raeburn 3819: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
1.484.2.36 raeburn 3820: $quotatype = 'official';
1.484.2.45 raeburn 3821: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
3822: $quotatype = 'textbook';
1.484.2.36 raeburn 3823: }
3824: if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) {
3825: $filesize = int($filesize/1000); #expressed in kb
3826: $$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course',
1.484.2.51 raeburn 3827: $env{'form.uploaddoc.filename'},$filesize,
3828: 'upload',$quotatype);
1.484.2.36 raeburn 3829: return if ($$upload_output);
3830: }
1.440 raeburn 3831: my ($parseaction,$showupload,$nextphase,$mimetype);
3832: if ($env{'form.parserflag'}) {
1.329 droeschl 3833: $parseaction = 'parse';
3834: }
3835: my $folder=$env{'form.folder'};
3836: if ($folder eq '') {
3837: $folder='default';
3838: }
3839: if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
3840: my $errtext='';
3841: my $fatal=0;
3842: my $container='sequence';
1.484.2.19 raeburn 3843: if ($env{'form.folderpath'} =~ /:1$/) {
1.329 droeschl 3844: $container='page';
3845: }
3846: ($errtext,$fatal)=
1.484.2.27 raeburn 3847: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1.329 droeschl 3848: if ($#LONCAPA::map::order<1) {
3849: $LONCAPA::map::order[0]=1;
3850: $LONCAPA::map::resources[1]='';
3851: }
3852: my $destination = 'docs/';
3853: if ($folder =~ /^supplemental/) {
3854: $destination = 'supplemental/';
3855: }
3856: if (($folder eq 'default') || ($folder eq 'supplemental')) {
3857: $destination .= 'default/';
3858: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
3859: $destination .= $2.'/';
3860: }
1.484.2.27 raeburn 3861: if ($fatal) {
3862: $$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>';
3863: return;
3864: }
1.440 raeburn 3865: # this is for a course, not a user, so set context to coursedoc.
1.329 droeschl 3866: my $newidx=&LONCAPA::map::getresidx();
3867: $destination .= $newidx;
1.439 raeburn 3868: my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination,
1.329 droeschl 3869: $parseaction,$allfiles,
1.440 raeburn 3870: $codebase,undef,undef,undef,undef,
3871: undef,undef,\$mimetype);
3872: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) {
3873: my $stored = $1;
3874: $showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'.
3875: $stored.'</span>').'</p>';
3876: } else {
3877: my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});
3878:
1.457 raeburn 3879: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>';
1.440 raeburn 3880: return;
3881: }
1.329 droeschl 3882: my $ext='false';
3883: if ($url=~m{^http://}) { $ext='true'; }
3884: $url = &LONCAPA::map::qtunescape($url);
3885: my $comment=$env{'form.comment'};
3886: $comment = &LONCAPA::map::qtunescape($comment);
3887: if ($folder=~/^supplemental/) {
3888: $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
3889: $env{'user.domain'}.'___&&&___'.$comment;
3890: }
3891:
3892: $LONCAPA::map::resources[$newidx]=
3893: $comment.':'.$url.':'.$ext.':normal:res';
3894: $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
3895: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.484.2.7 raeburn 3896: $folder.'.'.$container,1);
1.329 droeschl 3897: if ($fatal) {
1.457 raeburn 3898: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>';
1.440 raeburn 3899: return;
1.329 droeschl 3900: } else {
1.440 raeburn 3901: if ($parseaction eq 'parse' && $mimetype eq 'text/html') {
3902: $$upload_output = $showupload;
1.384 raeburn 3903: my $total_embedded = scalar(keys(%{$allfiles}));
1.329 droeschl 3904: if ($total_embedded > 0) {
1.440 raeburn 3905: my $uploadphase = 'upload_embedded';
3906: my $primaryurl = &HTML::Entities::encode($url,'<>&"');
3907: my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx);
3908: my ($embedded,$num) =
3909: &Apache::loncommon::ask_for_embedded_content(
3910: '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url});
3911: if ($embedded) {
3912: if ($num) {
3913: $$upload_output .=
3914: '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
3915: $nextphase = $uploadphase;
3916: } else {
3917: $$upload_output .= $embedded;
3918: }
3919: } else {
3920: $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
3921: }
1.329 droeschl 3922: } else {
1.440 raeburn 3923: $$upload_output .= &mt('No embedded items identified').'<br />';
1.329 droeschl 3924: }
1.457 raeburn 3925: $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
1.484.2.51 raeburn 3926: } elsif ((&Apache::loncommon::is_archive_file($mimetype)) &&
3927: ($env{'form.uploaddoc.filename'} =~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i)) {
1.476 raeburn 3928: $nextphase = 'decompress_uploaded';
3929: my $position = scalar(@LONCAPA::map::order)-1;
3930: my $noextract = &return_to_editor();
3931: my $archiveurl = &HTML::Entities::encode($url,'<>&"');
3932: my %archiveitems = (
3933: folderpath => $env{'form.folderpath'},
3934: cmd => $nextphase,
3935: newidx => $newidx,
3936: position => $position,
3937: phase => $nextphase,
1.477 raeburn 3938: comment => $comment,
1.480 raeburn 3939: );
3940: my ($destination,$dir_root) = &embedded_destination($coursenum,$coursedom);
3941: my @current = &get_dir_list($url,$coursenum,$coursedom,$newidx);
1.476 raeburn 3942: $$upload_output = $showupload.
3943: &Apache::loncommon::decompress_form($mimetype,
3944: $archiveurl,'/adm/coursedocs',$noextract,
1.480 raeburn 3945: \%archiveitems,\@current);
1.329 droeschl 3946: }
3947: }
3948: }
1.440 raeburn 3949: return $nextphase;
1.329 droeschl 3950: }
3951:
1.480 raeburn 3952: sub get_dir_list {
3953: my ($url,$coursenum,$coursedom,$newidx) = @_;
3954: my ($destination,$dir_root) = &embedded_destination();
3955: my ($dirlistref,$listerror) =
3956: &Apache::lonnet::dirlist("$dir_root/$destination/$newidx",$coursedom,$coursenum,1);
3957: my @dir_lines;
3958: my $dirptr=16384;
3959: if (ref($dirlistref) eq 'ARRAY') {
3960: foreach my $dir_line (sort
3961: {
3962: my ($afile)=split('&',$a,2);
3963: my ($bfile)=split('&',$b,2);
3964: return (lc($afile) cmp lc($bfile));
3965: } (@{$dirlistref})) {
3966: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
3967: $filename =~ s/\s+$//;
3968: next if ($filename =~ /^\.\.?$/);
3969: my $isdir = 0;
3970: if ($dirptr&$testdir) {
3971: $isdir = 1;
3972: }
3973: push(@dir_lines, [$filename,$dom,$isdir,$size,$mtime,$obs]);
3974: }
3975: }
3976: return @dir_lines;
3977: }
3978:
1.329 droeschl 3979: sub is_supplemental_title {
3980: my ($title) = @_;
3981: return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
3982: }
3983:
3984: # --------------------------------------------------------------- An entry line
3985:
3986: sub entryline {
1.484.2.12 raeburn 3987: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
1.484.2.67 raeburn 3988: $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups,
1.484.2.93.2. 0(raebur 3989:3): $ltitoolsref,$canedit,$isencrypted,$ishidden,$navmapref,$hostname)=@_;
3990:3): my ($foldertitle,$renametitle,$oldtitle,$encodedtitle);
1.329 droeschl 3991: if (&is_supplemental_title($title)) {
1.484.2.7 raeburn 3992: ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
1.484.2.93.2. 0(raebur 3993:3): $encodedtitle=$title;
1.329 droeschl 3994: } else {
3995: $title=&HTML::Entities::encode($title,'"<>&\'');
1.484.2.93.2. 0(raebur 3996:3): $encodedtitle=$title;
1.329 droeschl 3997: $renametitle=$title;
3998: $foldertitle=$title;
3999: }
4000:
1.484.2.67 raeburn 4001: my ($disabled,$readonly,$js_lt);
4002: unless ($canedit) {
4003: $disabled = 'disabled="disabled"';
4004: $readonly = 1;
4005: }
4006:
1.329 droeschl 4007: my $orderidx=$LONCAPA::map::order[$index];
1.364 bisitz 4008:
1.329 droeschl 4009: $renametitle=~s/\\/\\\\/g;
4010: $renametitle=~s/\"\;/\\\"/g;
1.484.2.55 raeburn 4011: $renametitle=~s/"/%22/g;
1.329 droeschl 4012: $renametitle=~s/ /%20/g;
1.484.2.52 raeburn 4013: $oldtitle = $renametitle;
4014: $renametitle=~s/\'\;/\\\'/g;
1.379 bisitz 4015: my $line=&Apache::loncommon::start_data_table_row();
1.484.2.30 raeburn 4016: my ($form_start,$form_end,$form_common,$form_param);
1.329 droeschl 4017: # Edit commands
1.484.2.93.2. (raeburn 4018:): my ($esc_path, $path, $symb, $shownsymb);
1.329 droeschl 4019: if ($env{'form.folderpath'}) {
4020: $esc_path=&escape($env{'form.folderpath'});
4021: $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
4022: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
4023: }
1.484.2.16 raeburn 4024: my $isexternal;
1.484.2.19 raeburn 4025: if ($residx) {
1.484.2.12 raeburn 4026: my $currurl = $url;
4027: $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.484.2.16 raeburn 4028: if ($currurl =~ m{^/adm/wrapper/ext/}) {
4029: $isexternal = 1;
4030: }
1.484.2.19 raeburn 4031: if (!$supplementalflag) {
4032: my $path = 'uploaded/'.
4033: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
4034: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
4035: $symb = &Apache::lonnet::encode_symb($path.$folder.".$container",
4036: $residx,
4037: &Apache::lonnet::declutter($currurl));
4038: }
1.484.2.12 raeburn 4039: }
1.484.2.30 raeburn 4040: my ($renamelink,%lt,$ishash);
4041: if (ref($filtersref) eq 'HASH') {
4042: $ishash = 1;
4043: }
4044:
1.329 droeschl 4045: if ($allowed) {
1.484.2.30 raeburn 4046: $form_start = '
4047: <form action="/adm/coursedocs" method="post">
4048: ';
4049: $form_common=(<<END);
4050: <input type="hidden" name="folderpath" value="$path" />
4051: <input type="hidden" name="symb" value="$symb" />
4052: END
4053: $form_param=(<<END);
4054: <input type="hidden" name="setparms" value="$orderidx" />
4055: <input type="hidden" name="changeparms" value="0" />
4056: END
4057: $form_end = '</form>';
4058:
1.329 droeschl 4059: my $incindex=$index+1;
4060: my $selectbox='';
1.471 raeburn 4061: if (($#LONCAPA::map::order>0) &&
1.329 droeschl 4062: ((split(/\:/,
1.344 bisitz 4063: $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
4064: ne '') &&
1.329 droeschl 4065: ((split(/\:/,
1.344 bisitz 4066: $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1.329 droeschl 4067: ne '')) {
4068: $selectbox=
4069: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.484.2.67 raeburn 4070: '<select name="newpos" onchange="this.form.submit()"'.$disabled.'>';
1.329 droeschl 4071: for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
4072: if ($i==$incindex) {
1.358 bisitz 4073: $selectbox.='<option value="" selected="selected">('.$i.')</option>';
1.329 droeschl 4074: } else {
4075: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
4076: }
4077: }
4078: $selectbox.='</select>';
4079: }
1.484.2.12 raeburn 4080: %lt=&Apache::lonlocal::texthash(
1.329 droeschl 4081: 'up' => 'Move Up',
4082: 'dw' => 'Move Down',
4083: 'rm' => 'Remove',
4084: 'ct' => 'Cut',
4085: 'rn' => 'Rename',
1.484.2.12 raeburn 4086: 'cp' => 'Copy',
4087: 'ex' => 'External Resource',
1.484.2.93.2. (raeburn 4088:): 'et' => 'External Tool',
1.484.2.12 raeburn 4089: 'ed' => 'Edit',
4090: 'pr' => 'Preview',
4091: 'sv' => 'Save',
4092: 'ul' => 'URL',
1.484.2.67 raeburn 4093: 'ti' => 'Title',
4094: 'er' => 'Editing rights unavailable for your current role.',
1.484.2.12 raeburn 4095: );
1.484.2.30 raeburn 4096: my %denied = &action_restrictions($coursenum,$coursedom,$url,
4097: $env{'form.folderpath'},
4098: $currgroups);
1.484.2.19 raeburn 4099: my ($copylink,$cutlink,$removelink);
1.329 droeschl 4100: my $skip_confirm = 0;
1.484.2.63 raeburn 4101: my $confirm_removal = 0;
1.329 droeschl 4102: if ( $folder =~ /^supplemental/
4103: || ($url =~ m{( /smppg$
4104: |/syllabus$
4105: |/aboutme$
4106: |/navmaps$
4107: |/bulletinboard$
1.484.2.93.2. (raeburn 4108:): |/ext\.tool$
1.484.2.16 raeburn 4109: |\.html$)}x)
1.484.2.19 raeburn 4110: || $isexternal) {
1.329 droeschl 4111: $skip_confirm = 1;
4112: }
1.484.2.63 raeburn 4113: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
4114: ($url!~/$LONCAPA::assess_page_seq_re/)) {
4115: $confirm_removal = 1;
4116: }
1.484.2.19 raeburn 4117:
1.484.2.30 raeburn 4118: if ($denied{'copy'}) {
4119: $copylink=(<<ENDCOPY)
1.484.2.16 raeburn 4120: <span style="visibility: hidden;">$lt{'cp'}</span>
4121: ENDCOPY
4122: } else {
1.484.2.30 raeburn 4123: my $formname = 'edit_copy_'.$orderidx;
4124: my $js = "javascript:checkForSubmit(document.forms.renameform,'copy','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.484.2.19 raeburn 4125: $copylink=(<<ENDCOPY);
1.484.2.30 raeburn 4126: <form name="$formname" method="post" action="/adm/coursedocs">
4127: $form_common
1.484.2.67 raeburn 4128: <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 4129: $form_end
1.329 droeschl 4130: ENDCOPY
1.484.2.30 raeburn 4131: if (($ishash) && (ref($filtersref->{'cancopy'}) eq 'ARRAY')) {
4132: push(@{$filtersref->{'cancopy'}},$orderidx);
4133: }
1.329 droeschl 4134: }
1.484.2.30 raeburn 4135: if ($denied{'cut'}) {
1.484.2.16 raeburn 4136: $cutlink=(<<ENDCUT);
4137: <span style="visibility: hidden;">$lt{'ct'}</span>
4138: ENDCUT
4139: } else {
1.484.2.30 raeburn 4140: my $formname = 'edit_cut_'.$orderidx;
4141: my $js = "javascript:checkForSubmit(document.forms.renameform,'cut','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.484.2.19 raeburn 4142: $cutlink=(<<ENDCUT);
1.484.2.30 raeburn 4143: <form name="$formname" method="post" action="/adm/coursedocs">
4144: $form_common
4145: <input type="hidden" name="skip_$orderidx" id="skip_cut_$orderidx" value="$skip_confirm" />
1.484.2.67 raeburn 4146: <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 4147: $form_end
1.329 droeschl 4148: ENDCUT
1.484.2.30 raeburn 4149: if (($ishash) && (ref($filtersref->{'cancut'}) eq 'ARRAY')) {
4150: push(@{$filtersref->{'cancut'}},$orderidx);
4151: }
1.329 droeschl 4152: }
1.484.2.30 raeburn 4153: if ($denied{'remove'}) {
1.484.2.16 raeburn 4154: $removelink=(<<ENDREM);
4155: <span style="visibility: hidden;">$lt{'rm'}</a>
4156: ENDREM
4157: } else {
1.484.2.30 raeburn 4158: my $formname = 'edit_remove_'.$orderidx;
1.484.2.63 raeburn 4159: 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 4160: $removelink=(<<ENDREM);
1.484.2.30 raeburn 4161: <form name="$formname" method="post" action="/adm/coursedocs">
4162: $form_common
4163: <input type="hidden" name="skip_$orderidx" id="skip_remove_$orderidx" value="$skip_confirm" />
1.484.2.63 raeburn 4164: <input type="hidden" name="confirm_rem_$orderidx" id="confirm_removal_$orderidx" value="$confirm_removal" />
1.484.2.67 raeburn 4165: <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 4166: $form_end
1.484.2.9 raeburn 4167: ENDREM
1.484.2.30 raeburn 4168: if (($ishash) && (ref($filtersref->{'canremove'}) eq 'ARRAY')) {
4169: push(@{$filtersref->{'canremove'}},$orderidx);
4170: }
1.484.2.9 raeburn 4171: }
1.484.2.35 raeburn 4172: $renamelink=(<<ENDREN);
1.484.2.52 raeburn 4173: <a href='javascript:changename("$esc_path","$index","$oldtitle");' class="LC_docs_rename">$lt{'rn'}</a>
1.484.2.16 raeburn 4174: ENDREN
1.484.2.67 raeburn 4175: my ($uplink,$downlink);
4176: if ($canedit) {
4177: $uplink = "/adm/coursedocs?cmd=up_$index&folderpath=$esc_path&symb=$symb";
4178: $downlink = "/adm/coursedocs?cmd=down_$index&folderpath=$esc_path&symb=$symb";
4179: } else {
4180: $uplink = "javascript:alert('".&js_escape($lt{'er'})."');";
4181: $downlink = $uplink;
4182: }
1.329 droeschl 4183: $line.=(<<END);
4184: <td>
1.379 bisitz 4185: <div class="LC_docs_entry_move">
1.484.2.67 raeburn 4186: <a href="$uplink">
1.484.2.12 raeburn 4187: <img src="${iconpath}move_up.gif" alt="$lt{'up'}" class="LC_icon" />
1.379 bisitz 4188: </a>
4189: </div>
4190: <div class="LC_docs_entry_move">
1.484.2.67 raeburn 4191: <a href="$downlink">
1.484.2.12 raeburn 4192: <img src="${iconpath}move_down.gif" alt="$lt{'dw'}" class="LC_icon" />
1.379 bisitz 4193: </a>
4194: </div>
1.329 droeschl 4195: </td>
4196: <td>
4197: $form_start
1.484.2.30 raeburn 4198: $form_param
1.478 raeburn 4199: $form_common
1.329 droeschl 4200: $selectbox
4201: $form_end
4202: </td>
1.484.2.30 raeburn 4203: <td class="LC_docs_entry_commands LC_nobreak">
1.484.2.9 raeburn 4204: $removelink
1.329 droeschl 4205: $cutlink
4206: $copylink
4207: </td>
4208: END
4209: }
4210: # Figure out what kind of a resource this is
4211: my ($extension)=($url=~/\.(\w+)$/);
4212: my $uploaded=($url=~/^\/*uploaded\//);
4213: my $icon=&Apache::loncommon::icon($url);
1.484.2.19 raeburn 4214: my $isfolder;
4215: my $ispage;
4216: my $containerarg;
1.484.2.67 raeburn 4217: my $folderurl;
1.484.2.93.2. 0(raebur 4218:3): my $plainurl;
1.329 droeschl 4219: if ($uploaded) {
1.472 raeburn 4220: if (($extension eq 'sequence') || ($extension eq 'page')) {
4221: $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
1.484.2.19 raeburn 4222: $containerarg = $1;
1.472 raeburn 4223: if ($extension eq 'sequence') {
4224: $icon=$iconpath.'navmap.folder.closed.gif';
4225: $isfolder=1;
4226: } else {
4227: $icon=$iconpath.'page.gif';
4228: $ispage=1;
4229: }
1.484.2.67 raeburn 4230: $folderurl = &Apache::lonnet::declutter($url);
1.472 raeburn 4231: if ($allowed) {
4232: $url='/adm/coursedocs?';
4233: } else {
4234: $url='/adm/supplemental?';
4235: }
1.329 droeschl 4236: } else {
1.484.2.93.2. 0(raebur 4237:3): $plainurl = $url;
1.329 droeschl 4238: }
4239: }
1.364 bisitz 4240:
1.484.2.70 raeburn 4241: my ($editlink,$extresform,$anchor,$hiddenres,$nomodal);
1.329 droeschl 4242: my $orig_url = $url;
1.340 raeburn 4243: $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
1.484.2.87 raeburn 4244: if ($container eq 'page') {
4245: $url=~s{^http(|s)(:|:)//}{/ext/};
4246: } else {
4247: $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
4248: }
1.484.2.12 raeburn 4249: if (!$supplementalflag && $residx && $symb) {
4250: if ((!$isfolder) && (!$ispage)) {
4251: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
1.484.2.87 raeburn 4252: if (($url =~ m{^ext/}) && ($container eq 'page')) {
4253: $url=&Apache::lonnet::clutter_with_no_wrapper($url);
4254: } else {
4255: $url=&Apache::lonnet::clutter($url);
4256: }
1.484.2.12 raeburn 4257: if ($url=~/^\/*uploaded\//) {
4258: $url=~/\.(\w+)$/;
4259: my $embstyle=&Apache::loncommon::fileembstyle($1);
4260: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
4261: $url='/adm/wrapper'.$url;
4262: } elsif ($embstyle eq 'ssi') {
4263: #do nothing with these
4264: } elsif ($url!~/\.(sequence|page)$/) {
4265: $url='/adm/coursedocs/showdoc'.$url;
4266: }
1.484.2.70 raeburn 4267: } elsif ($url=~m{^(|/adm/wrapper)/ext/([^#]+)}) {
4268: my $wrapped = $1;
4269: my $exturl = $2;
1.484.2.87 raeburn 4270: if (($wrapped eq '') && ($container ne 'page')) {
1.484.2.70 raeburn 4271: $url='/adm/wrapper'.$url;
4272: }
4273: if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) {
4274: $nomodal = 1;
4275: }
1.484.2.93.2. (raeburn 4276:): } elsif ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4277:): $url='/adm/wrapper'.$url;
1.484.2.70 raeburn 4278: } elsif ($url eq "/public/$coursedom/$coursenum/syllabus") {
4279: if (($ENV{'SERVER_PORT'} == 443) &&
4280: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
1.484.2.93 raeburn 4281: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.484.2.80 raeburn 4282: $url .= '?usehttp=1';
4283: }
1.484.2.70 raeburn 4284: $nomodal = 1;
4285: }
1.484.2.19 raeburn 4286: }
1.484.2.93.2. (raeburn 4287:): my ($checkencrypt,$shownurl);
4288:): if (!$env{'request.role.adv'}) {
1.484.2.67 raeburn 4289: if (((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) ||
1.484.2.93.2. (raeburn 4290:): ($isencrypted) || (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i)) {
1.484.2.67 raeburn 4291: $checkencrypt = 1;
1.484.2.70 raeburn 4292: } elsif (ref($navmapref)) {
1.484.2.67 raeburn 4293: unless (ref($$navmapref)) {
4294: $$navmapref = Apache::lonnavmaps::navmap->new();
4295: }
4296: if (ref($$navmapref)) {
4297: if (lc($$navmapref->get_mapparam($symb,undef,"0.encrypturl")) eq 'yes') {
4298: $checkencrypt = 1;
4299: }
4300: }
4301: }
1.484.2.93.2. (raeburn 4302:): }
4303:): if ($checkencrypt) {
4304:): my $currenc = $env{'request.enc'};
4305:): $env{'request.enc'} = 1;
4306:): $shownsymb = &Apache::lonenc::encrypted($symb);
4307:): $shownurl = &Apache::lonenc::encrypted($url);
4308:): if (&Apache::lonnet::symbverify($symb,$url)) {
4309:): $url = $shownurl;
1.484.2.67 raeburn 4310: } else {
1.484.2.93.2. (raeburn 4311:): $url = '';
1.484.2.67 raeburn 4312: }
1.484.2.93.2. (raeburn 4313:): $env{'request.enc'} = $currenc;
4314:): } elsif (&Apache::lonnet::symbverify($symb,$url)) {
4315:): $shownsymb = $symb;
4316:): if ($isexternal) {
4317:): $url =~ s/\#[^#]+$//;
4318:): if ($container eq 'page') {
4319:): $url = &Apache::lonnet::clutter($url);
4320:): }
4321:): }
4322:): $shownurl = $url;
4323:): }
4324:): unless ($env{'request.role.adv'}) {
4325:): if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4326:): $url = '';
4327:): }
4328:): if (&Apache::lonnet::EXT('resource.0.hiddenresource',$symb) =~ /^yes$/i) {
4329:): $url = '';
4330:): $hiddenres = 1;
4331:): }
4332:): }
4333:): if ($url ne '') {
4334:): $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
1.484.2.12 raeburn 4335: }
1.484.2.19 raeburn 4336: }
1.484.2.66 raeburn 4337: } elsif ($supplementalflag) {
4338: if ($isexternal) {
4339: if ($url =~ /^([^#]+)#([^#]+)$/) {
4340: $url = $1;
4341: $anchor = $2;
1.484.2.70 raeburn 4342: if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) {
1.484.2.93 raeburn 4343: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.484.2.80 raeburn 4344: if ($hostname ne '') {
4345: $url = 'http://'.$hostname.$url;
4346: }
4347: $url .= (($url =~ /\?/) ? '&':'?').'usehttp=1';
4348: }
1.484.2.70 raeburn 4349: $nomodal = 1;
4350: }
4351: }
4352: } elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
4353: if (($ENV{'SERVER_PORT'} == 443) &&
4354: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
1.484.2.93 raeburn 4355: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.484.2.80 raeburn 4356: if ($hostname ne '') {
4357: $url = 'http://'.$hostname.$url;
4358: }
4359: $url .= (($url =~ /\?/) ? '&':'?').'usehttp=1';
4360: }
1.484.2.70 raeburn 4361: $nomodal = 1;
1.484.2.66 raeburn 4362: }
1.484.2.93.2. 0(raebur 4363:3): } elsif (($uploaded) && (!$allowed) && ($url ne '/adm/supplemental?')) {
4364:3): my $embstyle=&Apache::loncommon::fileembstyle($extension);
4365:3): unless ($embstyle eq 'ssi') {
4366:3): if (($embstyle eq 'img')
4367:3): || ($embstyle eq 'emb')
4368:3): || ($embstyle eq 'wrp')) {
4369:3): $url='/adm/wrapper'.$url;
4370:3): } elsif ($url !~ /\.(sequence|page)$/) {
4371:3): $url='/adm/coursedocs/showdoc'.$url;
4372:3): }
4373:3): }
4374:3): }
4375:3): unless ($allowed && $env{'request.role.adv'}) {
4376:3): if ($ishidden || (&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4377:3): $hiddenres = 1;
4378:3): }
1.484.2.66 raeburn 4379: }
1.329 droeschl 4380: }
1.484.2.67 raeburn 4381: my ($rand_pick_text,$rand_order_text,$hiddenfolder);
4382: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.484.2.19 raeburn 4383: if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') {
1.329 droeschl 4384: my $foldername=&escape($foldertitle);
4385: my $folderpath=$env{'form.folderpath'};
4386: if ($folderpath) { $folderpath.='&' };
1.484.2.19 raeburn 4387: if (!$allowed && $supplementalflag) {
4388: $folderpath.=$containerarg.'&'.$foldername;
4389: $url.='folderpath='.&escape($folderpath);
1.484.2.93.2. 0(raebur 4390:3): if ($ishidden || (&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4391:3): $hiddenfolder = 1;
4392:3): }
1.484.2.19 raeburn 4393: } else {
4394: my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
4395: 'parameter_randompick'))[0];
1.484.2.67 raeburn 4396: my $randorder = ((&LONCAPA::map::getparameter($orderidx,
4397: 'parameter_randomorder'))[0]=~/^yes$/i);
4398: my $hiddenmap = ((&LONCAPA::map::getparameter($orderidx,
4399: 'parameter_hiddenresource'))[0]=~/^yes$/i);
4400: my $encryptmap = ((&LONCAPA::map::getparameter($orderidx,
4401: 'parameter_encrypturl'))[0]=~/^yes$/i);
4402: unless ($hiddenmap) {
1.484.2.70 raeburn 4403: if (ref($navmapref)) {
4404: unless (ref($$navmapref)) {
4405: $$navmapref = Apache::lonnavmaps::navmap->new();
4406: }
4407: if (ref($$navmapref)) {
4408: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
4409: my @resources = $$navmapref->retrieveResources($folderurl,$filterFunc,1,1);
4410: unless (@resources) {
4411: $hiddenmap = 1;
4412: unless ($env{'request.role.adv'}) {
4413: $url = '';
4414: $hiddenfolder = 1;
4415: }
1.484.2.67 raeburn 4416: }
4417: }
4418: }
4419: }
4420: }
4421: unless ($encryptmap) {
1.484.2.70 raeburn 4422: if ((ref($navmapref)) && (ref($$navmapref))) {
4423: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.encrypturl")) eq 'yes') {
4424: $encryptmap = 1;
4425: }
1.484.2.67 raeburn 4426: }
4427: }
4428:
4429: # Append randompick number, hidden, and encrypted with ":" to foldername,
4430: # so it gets transferred between levels
4431: $folderpath.=$containerarg.'&'.$foldername.
4432: ':'.$rpicknum.':'.$hiddenmap.':'.$encryptmap.':'.$randorder.':'.$ispage;
4433: unless ($url eq '') {
4434: $url.='folderpath='.&escape($folderpath);
4435: }
1.484.2.19 raeburn 4436: my $rpckchk;
4437: if ($rpicknum) {
4438: $rpckchk = ' checked="checked"';
1.484.2.30 raeburn 4439: if (($ishash) && (ref($filtersref->{'randompick'}) eq 'ARRAY')) {
4440: push(@{$filtersref->{'randompick'}},$orderidx.':'.$rpicknum);
4441: }
1.484.2.19 raeburn 4442: }
1.484.2.29 raeburn 4443: my $formname = 'edit_randompick_'.$orderidx;
1.484.2.19 raeburn 4444: $rand_pick_text =
1.478 raeburn 4445: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.484.2.30 raeburn 4446: $form_param."\n".
1.478 raeburn 4447: $form_common."\n".
1.484.2.67 raeburn 4448: '<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 4449: if ($rpicknum ne '') {
4450: $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
4451: }
1.484.2.29 raeburn 4452: $rand_pick_text .= '</span></span>'.
4453: $form_end;
1.484.2.30 raeburn 4454: my $ro_set;
1.484.2.67 raeburn 4455: if ($randorder) {
1.484.2.30 raeburn 4456: $ro_set = 'checked="checked"';
4457: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4458: push(@{$filtersref->{'randomorder'}},$orderidx);
4459: }
4460: }
1.484.2.41 raeburn 4461: $formname = 'edit_rorder_'.$orderidx;
1.484.2.19 raeburn 4462: $rand_order_text =
1.484.2.29 raeburn 4463: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.484.2.30 raeburn 4464: $form_param."\n".
1.484.2.29 raeburn 4465: $form_common."\n".
1.484.2.67 raeburn 4466: '<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 4467: $form_end;
1.484.2.19 raeburn 4468: }
1.484.2.18 raeburn 4469: } elsif ($supplementalflag && !$allowed) {
1.484.2.93.2. (raeburn 4470:): my $isexttool;
4471:): if ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4472:): $url='/adm/wrapper'.$url;
4473:): $isexttool = 1;
4474:): }
1.484.2.19 raeburn 4475: $url .= ($url =~ /\?/) ? '&':'?';
1.484.2.18 raeburn 4476: $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
1.484.2.19 raeburn 4477: if ($title) {
1.484.2.93.2. 0(raebur 4478:3): $url .= '&title='.$encodedtitle;
1.484.2.19 raeburn 4479: }
1.484.2.93.2. (raeburn 4480:): if ((($isexternal) || ($isexttool)) && $orderidx) {
1.484.2.19 raeburn 4481: $url .= '&idx='.$orderidx;
4482: }
1.484.2.66 raeburn 4483: if ($anchor ne '') {
4484: $url .= '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4485: }
1.329 droeschl 4486: }
1.484.2.19 raeburn 4487: my ($tdalign,$tdwidth);
1.484.2.12 raeburn 4488: if ($allowed) {
1.484.2.19 raeburn 4489: my $fileloc =
1.484.2.12 raeburn 4490: &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
1.484.2.19 raeburn 4491: if ($isexternal) {
4492: ($editlink,$extresform) =
1.484.2.67 raeburn 4493: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
1.484.2.93.2. (raeburn 4494:): undef,undef,undef,undef,undef,undef,
4495:): undef,$disabled);
4496:): } elsif ($orig_url =~ m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4497:): ($editlink,$extresform) =
4498:): &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
4499:): undef,undef,undef,'tool',$coursedom,
4500:): $coursenum,$ltitoolsref,$disabled);
1.484.2.19 raeburn 4501: } elsif (!$isfolder && !$ispage) {
4502: my ($cfile,$home,$switchserver,$forceedit,$forceview) =
1.484.2.14 raeburn 4503: &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
1.484.2.19 raeburn 4504: if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
1.484.2.66 raeburn 4505: my $suppanchor;
4506: if ($supplementalflag) {
4507: $suppanchor = $anchor;
4508: }
1.484.2.19 raeburn 4509: my $jscall =
1.484.2.12 raeburn 4510: &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
4511: $switchserver,
1.484.2.14 raeburn 4512: $forceedit,
1.484.2.93.2. (raeburn 4513:): undef,$symb,$shownsymb,
1.484.2.19 raeburn 4514: &escape($env{'form.folderpath'}),
1.484.2.80 raeburn 4515: $renametitle,$hostname,
4516: '','',1,$suppanchor);
1.484.2.12 raeburn 4517: if ($jscall) {
1.484.2.19 raeburn 4518: $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
4519: $jscall.'" >'.&mt('Edit').'</a> '."\n";
1.484.2.12 raeburn 4520: }
4521: }
4522: }
1.484.2.19 raeburn 4523: $tdalign = ' align="right" valign="top"';
4524: $tdwidth = ' width="80%"';
1.329 droeschl 4525: }
1.408 raeburn 4526: my $reinit;
4527: if ($crstype eq 'Community') {
4528: $reinit = &mt('(re-initialize community to access)');
4529: } else {
4530: $reinit = &mt('(re-initialize course to access)');
1.484.2.19 raeburn 4531: }
4532: $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;
1.484.2.93.2. 0(raebur 4533:3): my ($link,$nolink);
1.472 raeburn 4534: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.484.2.93.2. 0(raebur 4535:3): if ($allowed && !$env{'request.role.adv'} && !$isfolder && !$ispage) {
4536:3): if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4537:3): $nolink = 1;
4538:3): }
4539:3): }
4540:3): if ($nolink) {
4541:3): $line .= '<img src="'.$icon.'" alt="" class="LC_icon" /></a>';
4542:3): } else {
4543:3): $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
4544:3): }
1.469 www 4545: } elsif ($url) {
1.484.2.66 raeburn 4546: if ($anchor ne '') {
4547: if ($supplementalflag) {
4548: $anchor = '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4549: } else {
4550: $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');
4551: }
4552: }
1.484.2.80 raeburn 4553: if ((!$supplementalflag) && ($nomodal) && ($hostname ne '')) {
4554: $link = 'http://'.$hostname.$url;
4555: } else {
4556: $link = $url;
4557: }
4558: $link = &js_escape($link.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.$anchor);
1.484.2.93.2. 0(raebur 4559:3): if ($allowed && !$env{'request.role.adv'} && !$isfolder && !$ispage && !$uploaded) {
4560:3): if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4561:3): $nolink = 1;
4562:3): }
4563:3): }
4564:3): if ($nolink) {
4565:3): $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
4566:3): } elsif ($nomodal) {
1.484.2.70 raeburn 4567: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4568: '<img src="'.$icon.'" alt="" class="LC_icon" border="0" /></a>';
4569: } else {
4570: $line.=&Apache::loncommon::modal_link($link,
4571: '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
4572: }
1.469 www 4573: } else {
4574: $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
4575: }
1.484.2.19 raeburn 4576: $line.='</span></td><td'.$tdwidth.'>';
1.472 raeburn 4577: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.484.2.93.2. 0(raebur 4578:3): if ($nolink) {
4579:3): $line.=$title;
4580:3): } else {
4581:3): $line.='<a href="'.$url.'">'.$title.'</a>';
4582:3): }
4583:3): if (!$allowed && $supplementalflag && $canedit && $isfolder) {
4584:3): my $editicon = &Apache::loncommon::lonhttpdurl('/res/adm/pages').'/editmap.png';
4585:3): my $editurl = $url;
4586:3): $editurl =~ s{^\Q/adm/supplemental?\E}{/adm/coursedocs?command=direct&forcesupplement=1&};
4587:3): $line .= ' '.'<a href="'.$editurl.'">'.
4588:3): '<img src="'.$editicon.'" alt="'.&mt('Edit Content').'" title="'.&mt('Edit Content').'" />'.
4589:3): '</a>';
4590:3): }
4591:3): if ((($hiddenfolder) || ($hiddenres)) && (!$allowed) && ($supplementalflag)) {
4592:3): $line.= ' <span class="LC_warning">('.&mt('hidden').')</span> ';
4593:3): }
1.469 www 4594: } elsif ($url) {
1.484.2.93.2. 0(raebur 4595:3): if ($nolink) {
4596:3): $line.=$title;
4597:3): } elsif ($nomodal) {
1.484.2.70 raeburn 4598: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4599: $title.'</a>';
4600: } else {
4601: $line.=&Apache::loncommon::modal_link($link,$title,600,500);
4602: }
1.484.2.67 raeburn 4603: } elsif (($hiddenfolder) || ($hiddenres)) {
1.484.2.72 raeburn 4604: $line.=$title.' <span class="LC_warning LC_docs_reinit_warn">('.&mt('Hidden').')</span>';
1.469 www 4605: } else {
4606: $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
4607: }
1.484.2.19 raeburn 4608: $line.="$extresform</td>";
1.478 raeburn 4609: $rand_pick_text = ' ' if ($rand_pick_text eq '');
4610: $rand_order_text = ' ' if ($rand_order_text eq '');
1.484.2.93.2. 0(raebur 4611:3): if ($uploaded && $url && !$isfolder && !$ispage) {
4612:3): if (($plainurl ne '') && ($env{'request.role.adv'} || $allowed || !$hiddenres)) {
4613:3): &Apache::lonnet::allowuploaded('/adm/coursedoc',$plainurl);
1.484.2.30 raeburn 4614: }
1.484.2.93.2. 0(raebur 4615:3): }
4616:3): if ($allowed) {
4617:3): my %lt=&Apache::lonlocal::texthash(
4618:3): 'hd' => 'Hidden',
4619:3): 'ec' => 'URL hidden');
4620:3): my ($enctext,$hidtext,$formhidden,$formurlhidden);
1.484.2.30 raeburn 4621: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4622: $hidtext = ' checked="checked"';
1.484.2.93.2. (raeburn 4623:): if (($ishash) && (ref($filtersref->{'hiddenresource'}) eq 'ARRAY')) {
1.484.2.30 raeburn 4624: push(@{$filtersref->{'hiddenresource'}},$orderidx);
4625: }
4626: }
1.484.2.93.2. 0(raebur 4627:3): $formhidden = 'edit_hiddenresource_'.$orderidx;
4628:3): $line.=(<<ENDPARMS);
1.329 droeschl 4629: <td class="LC_docs_entry_parameter">
1.484.2.30 raeburn 4630: <form action="/adm/coursedocs" method="post" name="$formhidden">
4631: $form_param
1.478 raeburn 4632: $form_common
1.484.2.67 raeburn 4633: <label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'hiddenresource','settings');" $hidtext $disabled /> $lt{'hd'}</label>
1.329 droeschl 4634: $form_end
1.484.2.93.2. 0(raebur 4635:3): ENDPARMS
4636:3): if ($folder =~/^supplemental/) {
4637:3): $line.= "\n <td>";
4638:3): } else {
4639:3): if ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) {
4640:3): $enctext = ' checked="checked"';
4641:3): if (($ishash) && (ref($filtersref->{'encrypturl'}) eq 'ARRAY')) {
4642:3): push(@{$filtersref->{'encrypturl'}},$orderidx);
4643:3): }
4644:3): }
4645:3): $formurlhidden = 'edit_encrypturl_'.$orderidx;
4646:3): $line.=(<<ENDPARMS);
1.458 raeburn 4647: <br />
1.484.2.29 raeburn 4648: <form action="/adm/coursedocs" method="post" name="$formurlhidden">
1.484.2.30 raeburn 4649: $form_param
1.478 raeburn 4650: $form_common
1.484.2.67 raeburn 4651: <label><input type="checkbox" name="encrypturl_$orderidx" id="encrypturl_$orderidx" onclick="checkForSubmit(this.form,'encrypturl','settings');" $enctext $disabled /> $lt{'ec'}</label>
1.329 droeschl 4652: $form_end
4653: </td>
1.478 raeburn 4654: <td class="LC_docs_entry_parameter">$rand_pick_text<br />
4655: $rand_order_text</td>
1.329 droeschl 4656: ENDPARMS
1.484.2.93.2. 0(raebur 4657:3): }
1.329 droeschl 4658: }
1.379 bisitz 4659: $line.=&Apache::loncommon::end_data_table_row();
1.329 droeschl 4660: return $line;
4661: }
4662:
1.484.2.30 raeburn 4663: sub action_restrictions {
4664: my ($cnum,$cdom,$url,$folderpath,$currgroups) = @_;
4665: my %denied = (
4666: cut => 0,
4667: copy => 0,
4668: remove => 0,
4669: );
4670: if ($url=~ m{^/res/.+\.(page|sequence)$}) {
4671: # no copy for published maps
4672: $denied{'copy'} = 1;
1.484.2.82 raeburn 4673: } elsif ($url=~m{^/res/lib/templates/([^/]+)\.problem$}) {
4674: unless ($1 eq 'simpleproblem') {
4675: $denied{'copy'} = 1;
4676: }
4677: $denied{'cut'} = 1;
1.484.2.30 raeburn 4678: } elsif ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") {
4679: if ($folderpath =~ /^default&[^\&]+$/) {
4680: if ((ref($currgroups) eq 'HASH') && (keys(%{$currgroups}) > 0)) {
4681: $denied{'remove'} = 1;
4682: }
4683: $denied{'cut'} = 1;
4684: $denied{'copy'} = 1;
4685: }
4686: } elsif ($url =~ m{^\Q/uploaded/$cdom/$cnum/group_folder_\E(\w+)\.sequence$}) {
4687: my $group = $1;
4688: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+$/) {
4689: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4690: $denied{'remove'} = 1;
4691: }
4692: }
4693: $denied{'cut'} = 1;
4694: $denied{'copy'} = 1;
4695: } elsif ($url =~ m{^\Q/adm/$cdom/$cnum/\E(\w+)/smppg$}) {
4696: my $group = $1;
4697: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&\Qgroup_folder_$group\E\&[^\&]+$/) {
4698: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4699: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4700: if (keys(%groupsettings) > 0) {
4701: $denied{'remove'} = 1;
4702: }
4703: $denied{'cut'} = 1;
4704: $denied{'copy'} = 1;
4705: }
4706: }
4707: } elsif ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&group_folder_(\w+)\&/) {
4708: my $group = $1;
4709: if ($url =~ /group_boards_\Q$group\E/) {
4710: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4711: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4712: if (keys(%groupsettings) > 0) {
4713: if (ref($groupsettings{'functions'}) eq 'HASH') {
4714: if ($groupsettings{'functions'}{'discussion'} eq 'on') {
4715: $denied{'remove'} = 1;
4716: }
4717: }
4718: }
4719: $denied{'cut'} = 1;
4720: $denied{'copy'} = 1;
4721: }
4722: }
4723: }
4724: return %denied;
4725: }
4726:
1.484.2.26 raeburn 4727: sub new_timebased_suffix {
1.484.2.30 raeburn 4728: my ($dom,$num,$type,$area,$container) = @_;
1.484.2.26 raeburn 4729: my ($prefix,$namespace,$idtype,$errtext,$locknotfreed);
1.484.2.30 raeburn 4730: if ($type eq 'paste') {
4731: $prefix = $type;
4732: $namespace = 'courseeditor';
1.484.2.56 raeburn 4733: $idtype = 'addcode';
1.484.2.30 raeburn 4734: } elsif ($type eq 'map') {
1.484.2.26 raeburn 4735: $prefix = 'docs';
4736: if ($area eq 'supplemental') {
4737: $prefix = 'supp';
4738: }
4739: $prefix .= $container;
4740: $namespace = 'uploadedmaps';
4741: } else {
4742: $prefix = $type;
4743: $namespace = 'templated';
1.484.2.15 raeburn 4744: }
4745: my ($suffix,$freedlock,$error) =
1.484.2.56 raeburn 4746: &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num,$idtype);
1.484.2.15 raeburn 4747: if (!$suffix) {
1.484.2.30 raeburn 4748: if ($type eq 'paste') {
4749: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.');
4750: } elsif ($type eq 'map') {
1.484.2.26 raeburn 4751: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
4752: } elsif ($type eq 'smppg') {
4753: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.');
1.484.2.93.2. (raeburn 4754:): } elsif ($type eq 'exttool') {
4755:): $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new external tool.');
1.484.2.26 raeburn 4756: } else {
1.484.2.42 raeburn 4757: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new discussion board.');
1.484.2.26 raeburn 4758: }
1.484.2.15 raeburn 4759: if ($error) {
4760: $errtext .= '<br />'.$error;
4761: }
4762: }
4763: if ($freedlock ne 'ok') {
1.484.2.26 raeburn 4764: $locknotfreed =
4765: '<div class="LC_error">'.
4766: &mt('There was a problem removing a lockfile.').' ';
1.484.2.30 raeburn 4767: if ($type eq 'paste') {
1.484.2.57 raeburn 4768: if ($freedlock eq 'nolock') {
4769: $locknotfreed =
4770: '<div class="LC_error">'.
4771: &mt('A lockfile was not released when you added content to the clipboard earlier in this session.').' '.
4772:
1.484.2.60 raeburn 4773: &mt('As a result addition of items to the clipboard will be unavailable until your next log-in.');
1.484.2.57 raeburn 4774: } else {
4775: $locknotfreed .=
4776: &mt('This will prevent addition of items to the clipboard until your next log-in.');
4777: }
1.484.2.30 raeburn 4778: } elsif ($type eq 'map') {
1.484.2.57 raeburn 4779: $locknotfreed .=
4780: &mt('This will prevent creation of additional folders or composite pages in this course.');
1.484.2.26 raeburn 4781: } elsif ($type eq 'smppg') {
4782: $locknotfreed .=
4783: &mt('This will prevent creation of additional simple pages in this course.');
1.484.2.93.2. (raeburn 4784:): } elsif ($type eq 'exttool') {
4785:): $locknotfreed .=
4786:): &mt('This will prevent creation of additional external tools in this course.');
1.484.2.26 raeburn 4787: } else {
4788: $locknotfreed .=
1.484.2.42 raeburn 4789: &mt('This will prevent creation of additional discussion boards in this course.');
1.484.2.26 raeburn 4790: }
1.484.2.30 raeburn 4791: unless ($type eq 'paste') {
4792: $locknotfreed .=
1.484.2.38 raeburn 4793: ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
4794: '<a href="/adm/helpdesk" target="_helpdesk">','</a>');
1.484.2.30 raeburn 4795: }
4796: $locknotfreed .= '</div>';
1.484.2.15 raeburn 4797: }
4798: return ($suffix,$errtext,$locknotfreed);
4799: }
4800:
1.329 droeschl 4801: =pod
4802:
4803: =item tiehash()
4804:
4805: tie the hash
4806:
4807: =cut
4808:
4809: sub tiehash {
4810: my ($mode)=@_;
4811: $hashtied=0;
4812: if ($env{'request.course.fn'}) {
4813: if ($mode eq 'write') {
4814: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4815: &GDBM_WRCREAT(),0640)) {
4816: $hashtied=2;
4817: }
4818: } else {
4819: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4820: &GDBM_READER(),0640)) {
4821: $hashtied=1;
4822: }
4823: }
1.364 bisitz 4824: }
1.329 droeschl 4825: }
4826:
4827: sub untiehash {
4828: if ($hashtied) { untie %hash; }
4829: $hashtied=0;
4830: return OK;
4831: }
4832:
4833:
4834:
4835:
4836: sub checkonthis {
1.484.2.78 raeburn 4837: my ($r,$url,$level,$title,$checkstale)=@_;
1.329 droeschl 4838: $url=&unescape($url);
4839: $alreadyseen{$url}=1;
4840: $r->rflush();
4841: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
4842: $r->print("\n<br />");
4843: if ($level==0) {
4844: $r->print("<br />");
4845: }
4846: for (my $i=0;$i<=$level*5;$i++) {
4847: $r->print(' ');
4848: }
4849: $r->print('<a href="'.$url.'" target="cat">'.
4850: ($title?$title:$url).'</a> ');
4851: if ($url=~/^\/res\//) {
1.484.2.78 raeburn 4852: my $updated;
4853: if (($checkstale) && ($url !~ m{^/res/lib/templates/}) &&
4854: ($url !~ /\.\d+\.\w+$/)) {
4855: $updated = &Apache::lonnet::remove_stale_resfile($url);
4856: }
1.329 droeschl 4857: my $result=&Apache::lonnet::repcopy(
4858: &Apache::lonnet::filelocation('',$url));
4859: if ($result eq 'ok') {
4860: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
1.484.2.78 raeburn 4861: if ($updated) {
4862: $r->print('<br />');
4863: for (my $i=0;$i<=$level*5;$i++) {
4864: $r->print(' ');
4865: }
4866: $r->print('- '.&mt('Outdated copy removed'));
4867: }
1.329 droeschl 4868: $r->rflush();
4869: &Apache::lonnet::countacc($url);
4870: $url=~/\.(\w+)$/;
4871: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
4872: $r->print('<br />');
4873: $r->rflush();
4874: for (my $i=0;$i<=$level*5;$i++) {
4875: $r->print(' ');
4876: }
4877: $r->print('- '.&mt('Rendering:').' ');
4878: my ($errorcount,$warningcount)=split(/:/,
4879: &Apache::lonnet::ssi_body($url,
4880: ('grade_target'=>'web',
4881: 'return_only_error_and_warning_counts' => 1)));
4882: if (($errorcount) ||
4883: ($warningcount)) {
4884: if ($errorcount) {
1.369 bisitz 4885: $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1.329 droeschl 4886: &mt('[quant,_1,error]',$errorcount).'</span>');
4887: }
4888: if ($warningcount) {
4889: $r->print('<span class="LC_warning">'.
4890: &mt('[quant,_1,warning]',$warningcount).'</span>');
4891: }
4892: } else {
4893: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
4894: }
4895: $r->rflush();
4896: }
4897: my $dependencies=
4898: &Apache::lonnet::metadata($url,'dependencies');
4899: foreach my $dep (split(/\,/,$dependencies)) {
4900: if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
1.484.2.78 raeburn 4901: &checkonthis($r,$dep,$level+1,'',$checkstale);
1.329 droeschl 4902: }
4903: }
4904: } elsif ($result eq 'unavailable') {
4905: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
4906: } elsif ($result eq 'not_found') {
4907: unless ($url=~/\$/) {
1.484.2.19 raeburn 4908: $r->print('<span class="LC_error">'.&mt('not found').'</span>');
1.329 droeschl 4909: } else {
1.366 bisitz 4910: $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1.329 droeschl 4911: }
4912: } else {
4913: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
4914: }
1.484.2.78 raeburn 4915: if (($updated) && ($result ne 'ok')) {
4916: $r->print('<br />'.&mt('Outdated copy removed'));
4917: }
1.329 droeschl 4918: }
4919: }
4920: }
4921:
4922:
4923:
4924: =pod
4925:
4926: =item list_symbs()
4927:
1.484.2.3 raeburn 4928: List Content Identifiers
1.329 droeschl 4929:
4930: =cut
4931:
4932: sub list_symbs {
4933: my ($r) = @_;
4934:
1.408 raeburn 4935: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 4936: $r->print(&Apache::loncommon::start_page('List of Content Identifiers'));
4937: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Identifiers'));
4938: $r->print(&startContentScreen('tools'));
1.329 droeschl 4939: my $navmap = Apache::lonnavmaps::navmap->new();
4940: if (!defined($navmap)) {
4941: $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
4942: '<div class="LC_error">'.
4943: &mt('Unable to retrieve information about course contents').
4944: '</div>');
1.408 raeburn 4945: &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
1.329 droeschl 4946: } else {
1.484 raeburn 4947: $r->print('<h4 class="LC_info">'.&mt("$crstype Content Identifiers").'</h4>'.
4948: &Apache::loncommon::start_data_table().
4949: &Apache::loncommon::start_data_table_header_row().
4950: '<th>'.&mt('Title').'</th><th>'.&mt('Identifier').'</th>'.
4951: &Apache::loncommon::end_data_table_header_row()."\n");
4952: my $count;
1.329 droeschl 4953: foreach my $res ($navmap->retrieveResources()) {
1.484 raeburn 4954: $r->print(&Apache::loncommon::start_data_table_row().
4955: '<td>'.$res->compTitle().'</td>'.
4956: '<td>'.$res->symb().'</td>'.
1.484.2.19 raeburn 4957: &Apache::loncommon::end_data_table_row());
1.484 raeburn 4958: $count ++;
4959: }
4960: if (!$count) {
4961: $r->print(&Apache::loncommon::start_data_table_row().
4962: '<td colspan="2">'.&mt("$crstype is empty").'</td>'.
4963: &Apache::loncommon::end_data_table_row());
1.329 droeschl 4964: }
1.484 raeburn 4965: $r->print(&Apache::loncommon::end_data_table());
1.329 droeschl 4966: }
1.484.2.19 raeburn 4967: $r->print(&endContentScreen());
1.329 droeschl 4968: }
4969:
1.484.2.93.2. (raeburn 4970:): sub short_urls {
4971:): my ($r,$canedit) = @_;
4972:): my $crstype = &Apache::loncommon::course_type();
4973:): my $formname = 'shortenurl';
4974:): $r->print(&Apache::loncommon::start_page('Display/Set Shortened URLs'));
4975:): $r->print(&Apache::lonhtmlcommon::breadcrumbs('Shortened URLs'));
4976:): $r->print(&startContentScreen('tools'));
4977:): my ($navmap,$errormsg) =
4978:): &Apache::loncourserespicker::get_navmap_object($crstype,'shorturls');
4979:): my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
4980:): my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4981:): my (%maps,%resources,%titles);
4982:): if (!ref($navmap)) {
4983:): $r->print($errormsg.
4984:): &endContentScreen());
4985:): return '';
4986:): } else {
4987:): $r->print('<h4 class="LC_info">'.&mt('Tiny URLs for deep-linking into course').'</h4>'."\n");
4988:): $r->rflush();
4989:): my $readonly;
4990:): if ($canedit) {
4991:): my ($numnew,$errors) = &Apache::loncommon::get_requested_shorturls($cdom,$cnum,$navmap);
4992:): if ($numnew) {
4993:): $r->print('<p class="LC_info">'.&mt('Created [quant,_1,URL]',$numnew).'</p>');
4994:): }
4995:): if ((ref($errors) eq 'ARRAY') && (@{$errors} > 0)) {
4996:): $r->print(&mt('The following errors occurred when processing your request to create shortened URLs:').'<br /><ul>');
4997:): foreach my $error (@{$errors}) {
4998:): $r->print('<li>'.$error.'</li>');
4999:): }
5000:): $r->print('</ul><br />');
5001:): }
5002:): } else {
5003:): $readonly = 1;
5004:): }
5005:): my %currtiny = &Apache::lonnet::dump('tiny',$cdom,$cnum);
5006:): $r->print(&Apache::loncourserespicker::create_picker($navmap,'shorturls',$formname,$crstype,undef,
5007:): undef,undef,undef,undef,undef,\%currtiny,$readonly));
5008:): }
5009:): $r->print(&endContentScreen());
5010:): }
5011:):
1.484.2.78 raeburn 5012: sub contentverifyform {
5013: my ($r) = @_;
5014: my $crstype = &Apache::loncommon::course_type();
5015: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
5016: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
5017: $r->print(&startContentScreen('tools'));
5018: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
5019: $r->print('<form method="post" action="/adm/coursedocs"><p>'.
5020: &mt('Include a check if files copied from elsewhere are up to date (will increase verification time)?').
5021: ' <span class="LC_nobreak">'.
5022: '<label><input type="radio" name="checkstale" value="0" checked="checked" />'.
5023: &mt('No').'</label>'.(' 'x2).
5024: '<label><input type="radio" name="checkstale" value="1" />'.
5025: &mt('Yes').'</label></span></p><p>'.
1.484.2.90 raeburn 5026: '<input type="submit" value="'.&mt('Verify Content').' "/>'.
1.484.2.78 raeburn 5027: '<input type="hidden" value="1" name="tools" />'.
5028: '<input type="hidden" value="1" name="verify" /></p></form>');
5029: $r->print(&endContentScreen());
5030: return;
5031: }
1.329 droeschl 5032:
5033: sub verifycontent {
1.484.2.78 raeburn 5034: my ($r,$checkstale) = @_;
1.408 raeburn 5035: my $crstype = &Apache::loncommon::course_type();
1.484.2.34 raeburn 5036: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
5037: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
1.484 raeburn 5038: $r->print(&startContentScreen('tools'));
5039: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
1.329 droeschl 5040: $hashtied=0;
5041: undef %alreadyseen;
5042: %alreadyseen=();
5043: &tiehash();
1.484 raeburn 5044:
1.329 droeschl 5045: foreach my $key (keys(%hash)) {
5046: if ($hash{$key}=~/\.(page|sequence)$/) {
5047: if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
5048: $r->print('<hr /><span class="LC_error">'.
1.419 bisitz 5049: &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
1.329 droeschl 5050: &unescape($hash{$key}).'</span><br />'.
1.419 bisitz 5051: &mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />');
1.329 droeschl 5052: }
5053: }
5054: if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
1.484.2.78 raeburn 5055: &checkonthis($r,$hash{$key},0,$hash{'title_'.$1},$checkstale);
1.329 droeschl 5056: }
5057: }
5058: &untiehash();
1.442 www 5059: $r->print('<p class="LC_success">'.&mt('Done').'</p>');
1.484.2.19 raeburn 5060: $r->print(&endContentScreen());
1.329 droeschl 5061: }
5062:
5063:
5064: sub devalidateversioncache {
5065: my $src=shift;
5066: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
5067: &Apache::lonnet::clutter($src));
5068: }
5069:
5070: sub checkversions {
1.484.2.67 raeburn 5071: my ($r,$canedit) = @_;
1.408 raeburn 5072: my $crstype = &Apache::loncommon::course_type();
1.484.2.44 raeburn 5073: $r->print(&Apache::loncommon::start_page("Check $crstype Resource Versions"));
5074: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Resource Versions"));
1.484 raeburn 5075: $r->print(&startContentScreen('tools'));
1.442 www 5076:
1.329 droeschl 5077: my $header='';
5078: my $startsel='';
5079: my $monthsel='';
5080: my $weeksel='';
5081: my $daysel='';
5082: my $allsel='';
5083: my %changes=();
5084: my $starttime=0;
5085: my $haschanged=0;
5086: my %setversions=&Apache::lonnet::dump('resourceversions',
5087: $env{'course.'.$env{'request.course.id'}.'.domain'},
5088: $env{'course.'.$env{'request.course.id'}.'.num'});
5089:
5090: $hashtied=0;
5091: &tiehash();
1.484.2.67 raeburn 5092: if ($canedit) {
5093: my %newsetversions=();
5094: if ($env{'form.setmostrecent'}) {
5095: $haschanged=1;
5096: foreach my $key (keys(%hash)) {
5097: if ($key=~/^ids\_(\/res\/.+)$/) {
5098: $newsetversions{$1}='mostrecent';
5099: &devalidateversioncache($1);
5100: }
1.329 droeschl 5101: }
1.484.2.67 raeburn 5102: } elsif ($env{'form.setcurrent'}) {
5103: $haschanged=1;
5104: foreach my $key (keys(%hash)) {
5105: if ($key=~/^ids\_(\/res\/.+)$/) {
5106: my $getvers=&Apache::lonnet::getversion($1);
5107: if ($getvers>0) {
5108: $newsetversions{$1}=$getvers;
5109: &devalidateversioncache($1);
5110: }
5111: }
1.329 droeschl 5112: }
1.484.2.67 raeburn 5113: } elsif ($env{'form.setversions'}) {
5114: $haschanged=1;
5115: foreach my $key (keys(%env)) {
5116: if ($key=~/^form\.set_version_(.+)$/) {
5117: my $src=$1;
5118: if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
5119: $newsetversions{$src}=$env{$key};
5120: &devalidateversioncache($src);
5121: }
5122: }
1.329 droeschl 5123: }
1.484.2.67 raeburn 5124: }
5125: if ($haschanged) {
5126: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
5127: $env{'course.'.$env{'request.course.id'}.'.domain'},
5128: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
5129: $r->print(&Apache::loncommon::confirmwrapper(
5130: &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
5131: } else {
5132: $r->print(&Apache::loncommon::confirmwrapper(
5133: &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
5134: }
5135: &mark_hash_old();
5136: }
5137: &changewarning($r,'');
1.329 droeschl 5138: }
5139: if ($env{'form.timerange'} eq 'all') {
5140: # show all documents
1.484.2.34 raeburn 5141: $header=&mt('All content in '.$crstype);
1.484.2.19 raeburn 5142: $allsel=' selected="selected"';
1.329 droeschl 5143: foreach my $key (keys(%hash)) {
5144: if ($key=~/^ids\_(\/res\/.+)$/) {
5145: my $src=$1;
5146: $changes{$src}=1;
5147: }
5148: }
5149: } else {
5150: # show documents which changed
5151: %changes=&Apache::lonnet::dump
5152: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
5153: $env{'course.'.$env{'request.course.id'}.'.num'});
5154: my $firstkey=(keys(%changes))[0];
5155: unless ($firstkey=~/^error\:/) {
5156: unless ($env{'form.timerange'}) {
5157: $env{'form.timerange'}=604800;
5158: }
5159: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
5160: .&mt('seconds');
5161: if ($env{'form.timerange'}==-1) {
5162: $seltext='since start of course';
1.484.2.19 raeburn 5163: $startsel=' selected="selected"';
1.329 droeschl 5164: $env{'form.timerange'}=time;
5165: }
5166: $starttime=time-$env{'form.timerange'};
5167: if ($env{'form.timerange'}==2592000) {
5168: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 5169: $monthsel=' selected="selected"';
1.329 droeschl 5170: } elsif ($env{'form.timerange'}==604800) {
5171: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 5172: $weeksel=' selected="selected"';
1.329 droeschl 5173: } elsif ($env{'form.timerange'}==86400) {
5174: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 5175: $daysel=' selected="selected"';
1.329 droeschl 5176: }
5177: $header=&mt('Content changed').' '.$seltext;
5178: } else {
5179: $header=&mt('No content modifications yet.');
5180: }
5181: }
5182: %setversions=&Apache::lonnet::dump('resourceversions',
5183: $env{'course.'.$env{'request.course.id'}.'.domain'},
5184: $env{'course.'.$env{'request.course.id'}.'.num'});
5185: my %lt=&Apache::lonlocal::texthash
1.408 raeburn 5186: ('st' => 'Version changes since start of '.$crstype,
1.329 droeschl 5187: 'lm' => 'Version changes since last Month',
5188: 'lw' => 'Version changes since last Week',
5189: 'sy' => 'Version changes since Yesterday',
5190: 'al' => 'All Resources (possibly large output)',
1.484 raeburn 5191: 'cd' => 'Change display',
1.329 droeschl 5192: 'sd' => 'Display',
5193: 'fi' => 'File',
5194: 'md' => 'Modification Date',
5195: 'mr' => 'Most recently published Version',
1.408 raeburn 5196: 've' => 'Version used in '.$crstype,
5197: 'vu' => 'Set Version to be used in '.$crstype,
5198: 'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
1.329 droeschl 5199: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
5200: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.479 golterma 5201: 'di' => 'Differences',
1.484 raeburn 5202: 'save' => 'Save changes',
5203: 'vers' => 'Version choice(s) for specific resources',
1.479 golterma 5204: 'act' => 'Actions');
1.484.2.67 raeburn 5205: my ($disabled,$readonly);
5206: unless ($canedit) {
5207: $disabled = 'disabled="disabled"';
5208: $readonly = 1;
5209: }
1.329 droeschl 5210: $r->print(<<ENDHEADERS);
1.484 raeburn 5211: <h4 class="LC_info">$header</h4>
1.329 droeschl 5212: <form action="/adm/coursedocs" method="post">
5213: <input type="hidden" name="versions" value="1" />
1.484 raeburn 5214: <div class="LC_left_float">
1.479 golterma 5215: <fieldset>
1.484 raeburn 5216: <legend>$lt{'cd'}</legend>
1.329 droeschl 5217: <select name="timerange">
1.484.2.19 raeburn 5218: <option value='all'$allsel>$lt{'al'}</option>
5219: <option value="-1"$startsel>$lt{'st'}</option>
5220: <option value="2592000"$monthsel>$lt{'lm'}</option>
5221: <option value="604800"$weeksel>$lt{'lw'}</option>
5222: <option value="86400"$daysel>$lt{'sy'}</option>
1.329 droeschl 5223: </select>
5224: <input type="submit" name="display" value="$lt{'sd'}" />
1.484 raeburn 5225: </fieldset>
5226: </div>
5227: <div class="LC_left_float">
5228: <fieldset>
5229: <legend>$lt{'act'}</legend>
1.484.2.67 raeburn 5230: $lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" $disabled /><br />
5231: $lt{'sc'}: <input type="submit" name="setcurrent" value="Go" $disabled />
1.484 raeburn 5232: </fieldset>
5233: </div>
5234: <br clear="all" />
5235: <hr />
5236: <h4>$lt{'vers'}</h4>
1.329 droeschl 5237: ENDHEADERS
1.479 golterma 5238: #number of columns for version history
1.484.2.44 raeburn 5239: my %changedbytime;
5240: foreach my $key (keys(%changes)) {
5241: #excludes not versionable problems from resource version history:
5242: next if ($key =~ /^\/res\/lib\/templates/);
5243: my $chg;
5244: if ($env{'form.timerange'} eq 'all') {
5245: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
5246: $chg = &Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate');
5247: } else {
5248: $chg = $changes{$key};
5249: next if ($chg < $starttime);
5250: }
5251: push(@{$changedbytime{$chg}},$key);
5252: }
5253: if (keys(%changedbytime) == 0) {
5254: &untiehash();
5255: $r->print(&mt('No content changes in imported content in specified time frame').
5256: &endContentScreen());
5257: return;
5258: }
1.479 golterma 5259: $r->print(
1.484.2.67 raeburn 5260: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.484.2.19 raeburn 5261: &Apache::loncommon::start_data_table().
5262: &Apache::loncommon::start_data_table_header_row().
5263: '<th>'.&mt('Resources').'</th>'.
5264: "<th>$lt{'mr'}</th>".
5265: "<th>$lt{'ve'}</th>".
5266: "<th>$lt{'vu'}</th>".
5267: '<th>'.&mt('History').'</th>'.
5268: &Apache::loncommon::end_data_table_header_row()
5269: );
1.484.2.44 raeburn 5270: foreach my $chg (sort {$b <=> $a } keys(%changedbytime)) {
5271: foreach my $key (sort(@{$changedbytime{$chg}})) {
5272: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
5273: my $currentversion=&Apache::lonnet::getversion($key);
5274: if ($currentversion<0) {
5275: $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
5276: }
5277: my $linkurl=&Apache::lonnet::clutter($key);
5278: $r->print(
5279: &Apache::loncommon::start_data_table_row().
5280: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br />'.
5281: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
5282: '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br />('.
5283: &Apache::lonlocal::locallocaltime($chg).')</span></td>'.
5284: '<td align="right">'
5285: );
5286: # Used in course
5287: my $usedversion=$hash{'version_'.$linkurl};
5288: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.484.2.19 raeburn 5289: if ($usedversion != $currentversion) {
1.479 golterma 5290: $r->print('<span class="LC_warning">'.$usedversion.'</span>');
1.484.2.19 raeburn 5291: } else {
1.479 golterma 5292: $r->print($usedversion);
5293: }
1.329 droeschl 5294: } else {
1.484.2.19 raeburn 5295: $r->print($currentversion);
1.329 droeschl 5296: }
1.484.2.44 raeburn 5297: $r->print('</td><td title="'.$lt{'vu'}.'">');
5298: # Set version
5299: $r->print(&Apache::loncommon::select_form(
5300: $setversions{$linkurl},
5301: 'set_version_'.$linkurl,
5302: {'select_form_order' => ['',1..$currentversion,'mostrecent'],
5303: '' => '',
5304: 'mostrecent' => &mt('most recent'),
1.484.2.67 raeburn 5305: map {$_,$_} (1..$currentversion)},'',$readonly));
1.484.2.44 raeburn 5306: my $lastold=1;
5307: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
5308: my $url=$root.'.'.$prevvers.'.'.$extension;
5309: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) {
5310: $lastold=$prevvers;
5311: }
5312: }
5313: $r->print('</td>');
5314: # List all available versions
5315: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
5316: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
5317: my $url=$root.'.'.$prevvers.'.'.$extension;
1.484.2.19 raeburn 5318: $r->print(
1.484.2.44 raeburn 5319: '<span class="LC_nobreak">'
5320: .'<a href="'.&Apache::lonnet::clutter($url).'">'
5321: .&mt('Version [_1]',$prevvers).'</a>'
5322: .' ('.&Apache::lonlocal::locallocaltime(
5323: &Apache::lonnet::metadata($url,'lastrevisiondate'))
5324: .')');
5325: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
5326: $r->print(
5327: ' <a href="/adm/diff?filename='.
5328: &Apache::lonnet::clutter($root.'.'.$extension).
5329: &HTML::Entities::encode('&versionone='.$prevvers,'"<>&').
5330: '" target="diffs">'.&mt('Diffs').'</a>');
5331: }
5332: $r->print('</span><br />');
1.329 droeschl 5333: }
1.484.2.44 raeburn 5334: $r->print('</span></td>'.&Apache::loncommon::end_data_table_row());
1.484.2.19 raeburn 5335: }
1.329 droeschl 5336: }
1.484.2.19 raeburn 5337: $r->print(
5338: &Apache::loncommon::end_data_table().
1.484.2.67 raeburn 5339: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.484.2.19 raeburn 5340: '</form>'
5341: );
1.329 droeschl 5342:
5343: &untiehash();
1.484.2.19 raeburn 5344: $r->print(&endContentScreen());
1.484.2.44 raeburn 5345: return;
1.329 droeschl 5346: }
5347:
5348: sub mark_hash_old {
5349: my $retie_hash=0;
5350: if ($hashtied) {
5351: $retie_hash=1;
5352: &untiehash();
5353: }
5354: &tiehash('write');
5355: $hash{'old'}=1;
5356: &untiehash();
5357: if ($retie_hash) { &tiehash(); }
5358: }
5359:
5360: sub is_hash_old {
5361: my $untie_hash=0;
5362: if (!$hashtied) {
5363: $untie_hash=1;
5364: &tiehash();
5365: }
5366: my $return=$hash{'old'};
5367: if ($untie_hash) { &untiehash(); }
5368: return $return;
5369: }
5370:
5371: sub changewarning {
5372: my ($r,$postexec,$message,$url)=@_;
5373: if (!&is_hash_old()) { return; }
5374: my $pathvar='folderpath';
5375: my $path=&escape($env{'form.folderpath'});
5376: if (!defined($url)) {
5377: $url='/adm/coursedocs?'.$pathvar.'='.$path;
5378: }
5379: my $course_type = &Apache::loncommon::course_type();
5380: if (!defined($message)) {
5381: $message='Changes will become active for your current session after [_1], or the next time you log in.';
5382: }
1.484.2.93.2. 2(raebur 5383:3): my $windowname = 'loncapaclient';
5384:3): if ($env{'request.lti.login'}) {
5385:3): $windowname .= 'lti';
5386:3): }
1.329 droeschl 5387: $r->print("\n\n".
1.372 bisitz 5388: '<script type="text/javascript">'."\n".
5389: '// <![CDATA['."\n".
5390: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
5391: '// ]]>'."\n".
1.369 bisitz 5392: '</script>'."\n".
1.484.2.93.2. 2(raebur 5393:3): '<form name="reinitform" method="post" action="/adm/roles" target="'.$windowname.'">'.
1.329 droeschl 5394: '<input type="hidden" name="orgurl" value="'.$url.
1.372 bisitz 5395: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
1.329 droeschl 5396: &mt($message,' <input type="hidden" name="'.
5397: $env{'request.role'}.'" value="1" /><input type="button" value="'.
1.369 bisitz 5398: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1.372 bisitz 5399: $help{'Caching'}.'</p></form>'."\n\n");
1.329 droeschl 5400: }
5401:
5402:
5403: sub init_breadcrumbs {
1.484.2.44 raeburn 5404: my ($form,$text,$help)=@_;
1.329 droeschl 5405: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484 raeburn 5406: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
1.405 bisitz 5407: text=>&Apache::loncommon::course_type().' Editor',
1.329 droeschl 5408: faq=>273,
5409: bug=>'Instructor Interface',
1.484.2.44 raeburn 5410: help => $help});
1.329 droeschl 5411: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
5412: text=>$text,
5413: faq=>273,
5414: bug=>'Instructor Interface'});
5415: }
5416:
1.441 www 5417: # subroutine to list form elements
5418: sub create_list_elements {
5419: my @formarr = @_;
5420: my $list = '';
1.484.2.12 raeburn 5421: foreach my $button (@formarr){
5422: foreach my $picture (keys(%{$button})) {
5423: $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
1.441 www 5424: }
5425: }
5426: return $list;
5427: }
1.329 droeschl 5428:
1.441 www 5429: # subroutine to create ul from list elements
5430: sub create_form_ul {
5431: my $list = shift;
5432: my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
5433: return $ul;
5434: }
1.329 droeschl 5435:
1.442 www 5436: #
5437: # Start tabs
5438: #
5439:
5440: sub startContentScreen {
1.484 raeburn 5441: my ($mode) = @_;
5442: my $output = '<ul class="LC_TabContentBigger" id="mainnav">';
1.472 raeburn 5443: if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
1.484 raeburn 5444: $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n";
5445: $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n";
5446: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
5447: } else {
1.484.2.34 raeburn 5448: $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 5449: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
5450: $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>'."\n";
5451: '><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>';
5452: }
5453: $output .= "\n".'</ul>'."\n";
5454: $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
5455: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
5456: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
5457: return $output;
1.442 www 5458: }
5459:
5460: #
5461: # End tabs
5462: #
5463:
5464: sub endContentScreen {
1.484 raeburn 5465: return '</div></div></div>';
1.442 www 5466: }
1.329 droeschl 5467:
1.446 www 5468: sub supplemental_base {
1.484.2.33 raeburn 5469: return 'supplemental&'.&escape(&mt('Supplemental Content'));
1.446 www 5470: }
5471:
1.329 droeschl 5472: sub handler {
5473: my $r = shift;
5474: &Apache::loncommon::content_type($r,'text/html');
5475: $r->send_http_header;
5476: return OK if $r->header_only;
1.484 raeburn 5477:
5478: # get course data
1.408 raeburn 5479: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 5480: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
5481: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5482:
5483: # graphics settings
5484: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329 droeschl 5485:
1.443 www 5486: #
1.329 droeschl 5487: # --------------------------------------------- Initialize help topics for this
5488: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
1.484.2.93.2. (raeburn 5489:): 'Adding_External_Resource','Adding_External_Tool',
5490:): 'Navigate_Content','Adding_Folders','Docs_Overview',
5491:): 'Load_Map','Supplemental','Score_Upload_Form',
5492:): 'Adding_Pages','Importing_LON-CAPA_Resource',
5493:): 'Importing_IMS_Course','Uploading_From_Harddrive',
5494:): 'Course_Roster','Web_Page','Dropbox','Simple_Problem') {
1.329 droeschl 5495: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
5496: }
5497: # Composite help files
5498: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
5499: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
5500: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
5501: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
5502: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
5503: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 5504: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 5505: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 5506: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 5507: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1.484.2.30 raeburn 5508:
1.484.2.67 raeburn 5509: my ($allowed,$canedit,$canview,$disabled);
1.484.2.93.2. 0(raebur 5510:3): # does this user have privileges to modify content.
5511:3): if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
1.472 raeburn 5512: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
1.484.2.93.2. 0(raebur 5513:3): unless ($r->uri eq '/adm/supplemental') {
1.484.2.67 raeburn 5514: $allowed = 1;
1.484.2.93.2. 0(raebur 5515:3): }
5516:3): $canedit = 1;
5517:3): $canview = 1;
5518:3): } elsif (&Apache::lonnet::allowed('cev',$env{'request.course.id'})) {
5519:3): # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
5520:3): unless ($r->uri eq '/adm/supplemental') {
1.484.2.67 raeburn 5521: $allowed = 1;
5522: }
1.484.2.93.2. 0(raebur 5523:3): $canview = 1;
1.484.2.67 raeburn 5524: }
5525: unless ($canedit) {
5526: $disabled = ' disabled="disabled"';
1.472 raeburn 5527: }
1.484.2.53 raeburn 5528: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']);
1.484.2.78 raeburn 5529: if ($env{'form.inhibitmenu'}) {
5530: unless ($env{'form.inhibitmenu'} eq 'yes') {
5531: delete($env{'form.inhibitmenu'});
5532: }
5533: }
5534:
1.484.2.53 raeburn 5535: if ($allowed && $env{'form.verify'}) {
1.484.2.44 raeburn 5536: &init_breadcrumbs('verify','Verify Content','Docs_Verify_Content');
1.484.2.78 raeburn 5537: if (!$canedit) {
5538: &verifycontent($r);
5539: } elsif (($env{'form.checkstale'} ne '') && ($env{'form.checkstale'} =~ /^\d$/)) {
5540: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1&verify=1&checkstale=$env{'form.checkstale'}",
5541: text=>'Results',
5542: faq=>273,
5543: bug=>'Instructor Interface'});
5544: &verifycontent($r,$env{'form.checkstale'});
5545: } else {
5546: &contentverifyform($r);
5547: }
1.329 droeschl 5548: } elsif ($allowed && $env{'form.listsymbs'}) {
1.484 raeburn 5549: &init_breadcrumbs('listsymbs','List Content IDs');
1.329 droeschl 5550: &list_symbs($r);
1.484.2.93.2. (raeburn 5551:): } elsif ($allowed && $env{'form.shorturls'}) {
5552:): &init_breadcrumbs('shorturls','Set/Display Shortened URLs','Docs_Short_URLs');
5553:): &short_urls($r,$canedit);
1.329 droeschl 5554: } elsif ($allowed && $env{'form.docslog'}) {
5555: &init_breadcrumbs('docslog','Show Log');
1.484 raeburn 5556: my $folder = $env{'form.folder'};
5557: if ($folder eq '') {
5558: $folder='default';
5559: }
1.484.2.67 raeburn 5560: &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit);
1.329 droeschl 5561: } elsif ($allowed && $env{'form.versions'}) {
1.484.2.44 raeburn 5562: &init_breadcrumbs('versions','Check/Set Resource Versions','Docs_Check_Resource_Versions');
1.484.2.67 raeburn 5563: &checkversions($r,$canedit);
5564: } elsif ($canedit && $env{'form.dumpcourse'}) {
1.484.2.43 raeburn 5565: &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329 droeschl 5566: &dumpcourse($r);
5567: } elsif ($allowed && $env{'form.exportcourse'}) {
1.377 bisitz 5568: &init_breadcrumbs('exportcourse','IMS Export');
1.475 raeburn 5569: &Apache::imsexport::exportcourse($r);
1.329 droeschl 5570: } else {
1.445 www 5571: #
5572: # Done catching special calls
1.484 raeburn 5573: # The whole rest is for course and supplemental documents and utilities menu
1.445 www 5574: # Get the parameters that may be needed
5575: #
5576: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.484.2.93.2. 0(raebur 5577:3): ['folderpath','title',
1.484.2.19 raeburn 5578: 'forcesupplement','forcestandard',
5579: 'tools','symb','command','supppath']);
1.445 www 5580:
1.484.2.78 raeburn 5581: foreach my $item ('forcesupplement','forcestandard','tools') {
5582: next if ($env{'form.'.$item} eq '');
5583: unless ($env{'form.'.$item} eq '1') {
5584: delete($env{'form.'.$item});
5585: }
5586: }
5587:
5588: if ($env{'form.command'}) {
5589: unless ($env{'form.command'} =~ /^(direct|directnav|editdocs|editsupp|contents|home)$/) {
5590: delete($env{'form.command'});
5591: }
5592: }
5593:
5594: if ($env{'form.symb'}) {
5595: my ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.symb'});
5596: unless (($id =~ /^\d+$/) && (&Apache::lonnet::is_on_map($resurl))) {
5597: delete($env{'form.symb'});
5598: }
5599: }
5600:
1.445 www 5601: # standard=1: this is a "new-style" course with an uploaded map as top level
5602: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329 droeschl 5603:
5604: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445 www 5605:
1.484 raeburn 5606: # Decide whether this should display supplemental or main content or utilities
1.445 www 5607: # supplementalflag=1: show supplemental documents
5608: # supplementalflag=0: show standard documents
1.484 raeburn 5609: # toolsflag=1: show utilities
1.445 www 5610:
1.484.2.39 raeburn 5611: my $unesc_folderpath = &unescape($env{'form.folderpath'});
5612: my $supplementalflag=($unesc_folderpath=~/^supplemental/);
5613: if (($unesc_folderpath=~/^default/) || ($unesc_folderpath eq "")) {
1.445 www 5614: $supplementalflag=0;
5615: }
5616: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
5617: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
5618: unless ($allowed) { $supplementalflag=1; }
5619: unless ($standard) { $supplementalflag=1; }
1.484 raeburn 5620: my $toolsflag=0;
5621: if ($env{'form.tools'}) { $toolsflag=1; }
1.445 www 5622:
1.484.2.78 raeburn 5623: if ($env{'form.folderpath'} ne '') {
1.484.2.93.2. 0(raebur 5624:3): &Apache::loncommon::validate_folderpath($supplementalflag,$allowed,$coursenum,$coursedom);
1.484.2.78 raeburn 5625: }
5626:
1.484.2.93.2. 0(raebur 5627:3): my $backto_supppath;
1.484.2.78 raeburn 5628: if ($env{'form.supppath'} ne '') {
1.484.2.93.2. 0(raebur 5629:3): if ($supplementalflag && $allowed) {
5630:3): $backto_supppath = &validate_supppath($coursenum,$coursedom);
5631:3): }
1.484.2.78 raeburn 5632: }
5633:
1.329 droeschl 5634: my $script='';
5635: my $showdoc=0;
1.457 raeburn 5636: my $addentries = {};
1.475 raeburn 5637: my $container;
1.329 droeschl 5638: my $containertag;
1.484.2.17 raeburn 5639: my $pathitem;
1.484.2.93.2. (raeburn 5640:): my %ltitools;
2(raebur 5641:3): my $posslti;
1.484.2.67 raeburn 5642: my $hiddentop;
5643: my $navmap;
5644: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.329 droeschl 5645:
1.464 www 5646: # Do we directly jump somewhere?
1.484.2.21 raeburn 5647: if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
1.472 raeburn 5648: if ($env{'form.symb'} ne '') {
1.484.2.19 raeburn 5649: $env{'form.folderpath'}=
1.484.2.67 raeburn 5650: &Apache::loncommon::symb_to_docspath($env{'form.symb'},\$navmap);
1.484.2.21 raeburn 5651: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
5652: $env{'form.command'}.'_'.$env{'form.symb'}});
1.484.2.93.2. 0(raebur 5653:3): } elsif (($env{'form.supppath'} ne '') && $supplementalflag && $allowed) {
1.472 raeburn 5654: $env{'form.folderpath'}=$env{'form.supppath'};
1.484.2.21 raeburn 5655: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
1.484.2.93.2. 0(raebur 5656:3): $env{'form.command'}.'_'.$backto_supppath});
1.466 www 5657: }
1.472 raeburn 5658: } elsif ($env{'form.command'} eq 'editdocs') {
1.484.2.67 raeburn 5659: $env{'form.folderpath'} = &default_folderpath($coursenum,$coursedom,\$navmap);
1.484.2.21 raeburn 5660: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
1.472 raeburn 5661: } elsif ($env{'form.command'} eq 'editsupp') {
1.484.2.67 raeburn 5662: $env{'form.folderpath'} = &supplemental_base();
1.484.2.21 raeburn 5663: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
5664: } elsif ($env{'form.command'} eq 'contents') {
5665: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
5666: } elsif ($env{'form.command'} eq 'home') {
5667: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
1.464 www 5668: }
5669:
1.484.2.23 raeburn 5670:
1.445 www 5671: # Where do we store these for when we come back?
5672: my $stored_folderpath='docs_folderpath';
5673: if ($supplementalflag) {
5674: $stored_folderpath='docs_sup_folderpath';
5675: }
1.464 www 5676:
1.484.2.19 raeburn 5677: # No folderpath, and in edit mode, see if we have something stored
5678: if ((!$env{'form.folderpath'}) && $allowed) {
1.445 www 5679: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.484.2.19 raeburn 5680: {'folderpath' => 'scalar'});
1.484.2.67 raeburn 5681:
5682: if (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
5683: if ($supplementalflag) {
5684: undef($env{'form.folderpath'}) if ($1 eq 'default');
5685: } else {
5686: undef($env{'form.folderpath'}) if ($1 eq 'supplemental');
5687: }
5688: } else {
1.484.2.19 raeburn 5689: undef($env{'form.folderpath'});
5690: }
1.484.2.92 raeburn 5691: if ($env{'form.folderpath'} ne '') {
1.484.2.93.2. 0(raebur 5692:3): &Apache::loncommon::validate_folderpath($supplementalflag,$allowed,$coursenum,$coursedom);
1.484.2.92 raeburn 5693: }
1.329 droeschl 5694: }
1.446 www 5695:
5696: # If we are not allowed to make changes, all we can see are supplemental docs
1.409 raeburn 5697: if (!$allowed) {
1.446 www 5698: unless ($env{'form.folderpath'} =~ /^supplemental/) {
5699: $env{'form.folderpath'} = &supplemental_base();
1.409 raeburn 5700: }
5701: }
1.446 www 5702: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329 droeschl 5703: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446 www 5704: $env{'form.folderpath'} = &supplemental_base()
5705: .'&'.
1.329 droeschl 5706: $env{'form.folderpath'};
5707: }
1.484.2.67 raeburn 5708: # If allowed and user's role is not advanced check folderpath is not hidden
1.484.2.93.2. 0(raebur 5709:3): my $hidden_and_empty;
5710:3): if (($allowed) && (!$env{'request.role.adv'}) && ($env{'form.folderpath'} ne '')) {
5711:3): my ($folderurl,$foldername,$hiddenfolder);
1.484.2.67 raeburn 5712: my @pathitems = split(/\&/,$env{'form.folderpath'});
5713: my $folder = $pathitems[-2];
5714: if ($folder eq '') {
5715: undef($env{'form.folderpath'});
5716: } else {
5717: $folderurl = "uploaded/$coursedom/$coursenum/$folder";
1.484.2.87 raeburn 5718: if ((split(/\:/,$pathitems[-1]))[5]) {
1.484.2.67 raeburn 5719: $folderurl .= '.page';
5720: } else {
5721: $folderurl .= '.sequence';
5722: }
1.484.2.93.2. 0(raebur 5723:3): if ($supplementalflag) {
5724:3): ($foldername,$hiddenfolder) = ($pathitems[-1] =~ /^([^:]*)::(|1):::$/);
5725:3): $foldername = &HTML::Entities::decode(&unescape($foldername));
5726:3): my ($supplemental) = &Apache::loncommon::get_supplemental($coursenum,$coursedom);
5727:3): if (ref($supplemental) eq 'HASH') {
5728:3): my ($suppmap,$suppmapnum);
5729:3): if ($folder eq 'supplemental') {
5730:3): $suppmap = 'default';
5731:3): $suppmapnum = 0;
5732:3): } elsif ($folder =~ /^supplemental_(\d+)$/) {
5733:3): $suppmap = $1;
5734:3): $suppmapnum = $suppmap;
5735:3): }
5736:3): if ($hiddenfolder) {
5737:3): my $hascontent;
5738:3): foreach my $key (reverse(sort(keys(%{$supplemental->{'ids'}})))) {
5739:3): if ($key =~ m{^\Q/uploaded/$coursedom/$coursenum/supplemental/$suppmap/\E}) {
5740:3): $hascontent = 1;
5741:3): } elsif (ref($supplemental->{'ids'}->{$key}) eq 'ARRAY') {
5742:3): foreach my $id (@{$supplemental->{'ids'}->{$key}}) {
5743:3): if ($id =~ /^$suppmapnum\:/) {
5744:3): $hascontent = 1;
5745:3): last;
5746:3): }
5747:3): }
5748:3): }
5749:3): last if ($hascontent);
5750:3): }
5751:3): unless ($hascontent) {
5752:3): if ($foldername ne '') {
5753:3): $hidden_and_empty = $foldername;
5754:3): } else {
5755:3): $hidden_and_empty = $folder;
5756:3): }
5757:3): }
1.484.2.67 raeburn 5758: }
5759: }
1.484.2.93.2. 0(raebur 5760:3): } else {
5761:3): unless (ref($navmap)) {
5762:3): $navmap = Apache::lonnavmaps::navmap->new();
5763:3): }
5764:3): ($foldername,$hiddenfolder) = ($pathitems[-1] =~ /^([^:]*):|\d+:|1:(|1):|1:|1$/);
5765:3): $foldername = &HTML::Entities::decode(&unescape($foldername));
5766:3): if (ref($navmap)) {
5767:3): if ($hiddenfolder ||
5768:3): (lc($navmap->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes')) {
5769:3): my @resources = $navmap->retrieveResources($folderurl,$filterFunc,1,1);
5770:3): unless (@resources) {
5771:3): if ($foldername ne '') {
5772:3): $hidden_and_empty = $foldername;
5773:3): } else {
5774:3): $hidden_and_empty = $folder;
5775:3): }
5776:3): }
5777:3): }
5778:3): }
5779:3): }
5780:3): if ($hidden_and_empty ne '') {
5781:3): splice(@pathitems,-2);
5782:3): if (@pathitems) {
5783:3): $env{'form.folderpath'} = join('&',@pathitems);
5784:3): } else {
5785:3): undef($env{'form.folderpath'});
5786:3): }
1.484.2.67 raeburn 5787: }
5788: }
5789: }
5790:
1.446 www 5791: # If after all of this, we still don't have any paths, make them
1.484.2.19 raeburn 5792: unless ($env{'form.folderpath'}) {
1.446 www 5793: if ($supplementalflag) {
5794: $env{'form.folderpath'}=&supplemental_base();
1.484.2.67 raeburn 5795: } elsif ($allowed) {
5796: ($env{'form.folderpath'},$hiddentop) = &default_folderpath($coursenum,$coursedom,\$navmap);
1.446 www 5797: }
1.472 raeburn 5798: }
1.446 www 5799:
1.445 www 5800: # Store this
1.484 raeburn 5801: unless ($toolsflag) {
1.484.2.67 raeburn 5802: if (($allowed) && ($env{'form.folderpath'} ne '')) {
1.484.2.19 raeburn 5803: &Apache::loncommon::store_course_settings($stored_folderpath,
5804: {'folderpath' => 'scalar'});
5805: }
5806: my $folderpath;
1.484 raeburn 5807: if ($env{'form.folderpath'}) {
1.484.2.19 raeburn 5808: $folderpath = $env{'form.folderpath'};
5809: my (@folders)=split('&',$env{'form.folderpath'});
5810: $env{'form.foldername'}=&unescape(pop(@folders));
5811: if ($env{'form.foldername'} =~ /\:1$/) {
5812: $container = 'page';
5813: } else {
5814: $container = 'sequence';
5815: }
5816: $env{'form.folder'}=pop(@folders);
1.484 raeburn 5817: } else {
1.484.2.19 raeburn 5818: if ($env{'form.folder'} eq '' ||
5819: $env{'form.folder'} eq 'supplemental') {
1.484.2.67 raeburn 5820: if ($env{'form.folder'} eq 'supplemental') {
5821: $folderpath=&supplemental_base();
5822: } elsif (!$hiddentop) {
5823: $folderpath='default&'.
5824: &escape(&mt('Main Content').':::::');
5825: }
1.484 raeburn 5826: }
5827: }
1.484.2.19 raeburn 5828: $containertag = '<input type="hidden" name="folderpath" value="" />';
5829: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 5830: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
5831: $showdoc='/'.$1;
5832: }
5833: if ($showdoc) { # got called in sequence from course
5834: $allowed=0;
5835: } else {
1.484.2.67 raeburn 5836: if ($canedit) {
1.484 raeburn 5837: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
5838: $script=&Apache::lonratedt::editscript('simple');
1.433 raeburn 5839: }
5840: }
1.329 droeschl 5841: }
5842:
1.344 bisitz 5843: # get personal data
1.329 droeschl 5844: my $uname=$env{'user.name'};
5845: my $udom=$env{'user.domain'};
5846: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
5847:
5848: if ($allowed) {
1.484 raeburn 5849: if ($toolsflag) {
5850: $script .= &inject_data_js();
5851: my ($home,$other,%outhash)=&authorhosts();
5852: if (!$home && $other) {
5853: my @hosts;
5854: foreach my $aurole (keys(%outhash)) {
5855: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
5856: push(@hosts,$outhash{$aurole});
5857: }
5858: }
5859: $script .= &dump_switchserver_js(@hosts);
5860: }
1.458 raeburn 5861: } else {
1.484.2.43 raeburn 5862: my $tid = 1;
1.484 raeburn 5863: my @tabids;
5864: if ($supplementalflag) {
5865: @tabids = ('002','ee2','ff2');
1.484.2.43 raeburn 5866: $tid = 2;
1.484 raeburn 5867: } else {
5868: @tabids = ('aa1','bb1','cc1','ff1');
1.484.2.19 raeburn 5869: unless ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 5870: unshift(@tabids,'001');
5871: push(@tabids,('dd1','ee1'));
5872: }
1.458 raeburn 5873: }
1.484 raeburn 5874: my $tabidstr = join("','",@tabids);
1.484.2.93.2. 2(raebur 5875:3): my (%domtools,%crstools);
5876:3): my %tooltypes = &Apache::loncommon::usable_exttools();
5877:3): if ($tooltypes{'dom'}) {
5878:3): %domtools = &Apache::lonnet::get_domain_lti($coursedom,'consumer');
5879:3): }
5880:3): if ($tooltypes{'crs'}) {
5881:3): %crstools = &Apache::lonnet::get_course_lti($coursenum,$coursedom,'consumer');
5882:3): }
5883:3): %ltitools = (
5884:3): dom => \%domtools,
5885:3): crs => \%crstools,
5886:3): );
5887:3): $posslti = scalar(keys(%domtools)) + scalar(keys(%crstools));
1.484.2.80 raeburn 5888: my $hostname = $r->hostname();
1.484.2.93.2. (raeburn 5889:): $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
1.484.2.80 raeburn 5890: $canedit,$hostname,\$navmap).
1.484 raeburn 5891: &history_tab_js().
5892: &inject_data_js().
1.484.2.43 raeburn 5893: &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
1.484.2.93.2. (raeburn 5894:): &Apache::lonextresedit::extedit_javascript(\%ltitools);
0(raebur 5895:3): my $onload = "javascript:resize_scrollbox('contentscroll','1','1');";
5896:3): if ($hidden_and_empty ne '') {
5897:3): my $alert = &mt("Additional privileges required to edit empty and hidden folder: '[_1]'",
5898:3): $hidden_and_empty);
5899:3): $onload .= "javascript:alert('".&js_escape($alert)."');";
5900:3): }
1.484 raeburn 5901: $addentries = {
1.484.2.93.2. 0(raebur 5902:3): onload => $onload,
1.484 raeburn 5903: };
1.458 raeburn 5904: }
1.484.2.30 raeburn 5905: $script .= &paste_popup_js();
1.484.2.12 raeburn 5906: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
5907: &mt('Switch server?');
1.484.2.19 raeburn 5908:
5909:
1.329 droeschl 5910: }
5911: # -------------------------------------------------------------------- Body tag
1.369 bisitz 5912: $script = '<script type="text/javascript">'."\n"
1.372 bisitz 5913: .'// <![CDATA['."\n"
5914: .$script."\n"
5915: .'// ]]>'."\n"
1.484.2.81 raeburn 5916: .'</script>'."\n"
5917: .'<script type="text/javascript" src="/res/adm/includes/file_upload.js"></script>'."\n";
1.385 bisitz 5918:
5919: # Breadcrumbs
5920: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484.2.19 raeburn 5921:
5922: if ($showdoc) {
1.484.2.93.2. 0(raebur 5923:3): my $args;
5924:3): if ($supplementalflag) {
5925:3): my $title = &HTML::Entities::encode($env{'form.title'},'\'"<>&');
5926:3): my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
5927:3): $args = {'bread_crumbs' => $brcrum};
5928:3): } else {
5929:3): $args = {'force_register' => $showdoc};
5930:3): }
5931:3): $r->print(&Apache::loncommon::start_page("$crstype documents",undef,$args));
1.484.2.44 raeburn 5932: } elsif ($toolsflag) {
1.484.2.67 raeburn 5933: my ($breadtext,$breadtitle);
5934: $breadtext = "$crstype Editor";
5935: if ($canedit) {
5936: $breadtitle = 'Editing '.$crstype.' Contents';
5937: } else {
5938: $breadtext .= ' (View-only mode)';
5939: $breadtitle = 'Viewing '.$crstype.' Contents';
5940: }
1.484.2.44 raeburn 5941: &Apache::lonhtmlcommon::add_breadcrumb({
1.484.2.67 raeburn 5942: href=>"/adm/coursedocs",text=>$breadtext});
1.484.2.44 raeburn 5943: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script)
5944: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5945: .&Apache::lonhtmlcommon::breadcrumbs(
1.484.2.67 raeburn 5946: $breadtitle)
1.484.2.44 raeburn 5947: );
1.484.2.19 raeburn 5948: } elsif ($r->uri eq '/adm/supplemental') {
1.484.2.93.2. 0(raebur 5949:3): unless ($env{'request.role.adv'}) {
5950:3): unless (&Apache::lonnet::has_unhidden_suppfiles($coursenum,$coursedom)) {
5951:3): $r->internal_redirect('/adm/navmaps');
5952:3): return OK;
5953:3): }
5954:3): }
1.484.2.19 raeburn 5955: my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
5956: $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
5957: {'bread_crumbs' => $brcrum,}));
5958: } else {
1.484.2.67 raeburn 5959: my ($breadtext,$breadtitle,$helpitem);
5960: $breadtext = "$crstype Editor";
5961: if ($canedit) {
5962: $breadtitle = 'Editing '.$crstype.' Contents';
5963: $helpitem = 'Docs_Adding_Course_Doc';
5964: } else {
5965: $breadtext .= ' (View-only mode)';
5966: $breadtitle = 'Viewing '.$crstype.' Contents';
5967: $helpitem = 'Docs_Viewing_Course_Doc';
5968: }
1.392 raeburn 5969: &Apache::lonhtmlcommon::add_breadcrumb({
1.484.2.67 raeburn 5970: href=>"/adm/coursedocs",text=>$breadtext});
1.446 www 5971: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.484.2.19 raeburn 5972: {'add_entries' => $addentries}
5973: )
1.392 raeburn 5974: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5975: .&Apache::lonhtmlcommon::breadcrumbs(
1.484.2.67 raeburn 5976: $breadtitle,
5977: $helpitem)
1.392 raeburn 5978: );
5979: }
1.364 bisitz 5980:
1.329 droeschl 5981: my %allfiles = ();
5982: my %codebase = ();
1.440 raeburn 5983: my ($upload_result,$upload_output,$uploadphase);
1.484.2.67 raeburn 5984: if ($canedit) {
1.484.2.93.2. 0(raebur 5985:3): undef($suppchanges);
1.329 droeschl 5986: if (($env{'form.uploaddoc.filename'}) &&
5987: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440 raeburn 5988: my $context = $1;
5989: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 5990: undef($hadchanges);
1.440 raeburn 5991: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
1.484.2.36 raeburn 5992: \%allfiles,\%codebase,$context,$crstype);
1.484.2.73 raeburn 5993: undef($navmap);
1.329 droeschl 5994: if ($hadchanges) {
5995: &mark_hash_old();
5996: }
1.484.2.93.2. 0(raebur 5997:3): if ($suppchanges) {
5998:3): &Apache::lonnet::update_supp_caches($coursedom,$coursenum);
5999:3): undef($suppchanges);
6000:3): }
1.440 raeburn 6001: $r->print($upload_output);
6002: } elsif ($env{'form.phase'} eq 'upload_embedded') {
6003: # Process file upload - phase two - upload embedded objects
6004: $uploadphase = 'check_embedded';
6005: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
6006: my $state = &embedded_form_elems($uploadphase,$primaryurl,
6007: $env{'form.newidx'});
6008: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
6009: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
6010: my ($destination,$dir_root) = &embedded_destination();
6011: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
6012: my $actionurl = '/adm/coursedocs';
6013: my ($result,$flag) =
6014: &Apache::loncommon::upload_embedded('coursedoc',$destination,
6015: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
6016: $actionurl);
6017: $r->print($result.&return_to_editor());
6018: } elsif ($env{'form.phase'} eq 'check_embedded') {
6019: # Process file upload - phase three - modify references in HTML file
6020: $uploadphase = 'modified_orightml';
6021: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
6022: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
6023: my ($destination,$dir_root) = &embedded_destination();
1.482 raeburn 6024: my $result =
6025: &Apache::loncommon::modify_html_refs('coursedoc',$destination,
6026: $docuname,$docudom,undef,
6027: $dir_root);
6028: $r->print($result.&return_to_editor());
1.476 raeburn 6029: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
6030: $uploadphase = 'decompress_phase_one';
6031: $r->print(&decompression_phase_one().
6032: &return_to_editor());
6033: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
6034: $uploadphase = 'decompress_phase_two';
6035: $r->print(&decompression_phase_two().
6036: &return_to_editor());
1.329 droeschl 6037: }
6038: }
6039:
1.484 raeburn 6040: if ($allowed && $toolsflag) {
6041: $r->print(&startContentScreen('tools'));
1.484.2.67 raeburn 6042: $r->print(&generate_admin_menu($crstype,$canedit));
1.484 raeburn 6043: $r->print(&endContentScreen());
6044: } elsif ((!$showdoc) && (!$uploadphase)) {
1.329 droeschl 6045: # -----------------------------------------------------------------------------
6046: my %lt=&Apache::lonlocal::texthash(
6047: 'copm' => 'All documents out of a published map into this folder',
1.484.2.12 raeburn 6048: 'upfi' => 'Upload File',
1.484.2.36 raeburn 6049: 'upld' => 'Upload Content',
1.329 droeschl 6050: 'srch' => 'Search',
6051: 'impo' => 'Import',
1.484.2.19 raeburn 6052: 'lnks' => 'Import from Stored Links',
1.484.2.13 raeburn 6053: 'impm' => 'Import from Assembled Map',
1.484.2.93.2. (raeburn 6054:): 'extr' => 'External Resource',
6055:): 'extt' => 'External Tool',
1.329 droeschl 6056: 'selm' => 'Select Map',
6057: 'load' => 'Load Map',
6058: 'newf' => 'New Folder',
6059: 'newp' => 'New Composite Page',
6060: 'syll' => 'Syllabus',
1.425 raeburn 6061: 'navc' => 'Table of Contents',
1.343 biermanm 6062: 'sipa' => 'Simple Course Page',
1.329 droeschl 6063: 'sipr' => 'Simple Problem',
1.484.2.27 raeburn 6064: 'webp' => 'Blank Web Page (editable)',
1.329 droeschl 6065: 'drbx' => 'Drop Box',
1.451 www 6066: 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336 schafran 6067: 'bull' => 'Discussion Board',
1.347 weissno 6068: 'mypi' => 'My Personal Information Page',
1.353 weissno 6069: 'grpo' => 'Group Portfolio',
1.329 droeschl 6070: 'rost' => 'Course Roster',
1.484.2.22 raeburn 6071: 'abou' => 'Personal Information Page for a User',
1.484.2.36 raeburn 6072: 'imsf' => 'IMS Upload',
6073: 'imsl' => 'Upload IMS package',
1.484.2.12 raeburn 6074: 'cms' => 'Origin of IMS package',
6075: 'se' => 'Select',
1.484.2.19 raeburn 6076: 'file' => 'File',
1.329 droeschl 6077: 'title' => 'Title',
6078: 'comment' => 'Comment',
1.403 raeburn 6079: 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.484.2.50 raeburn 6080: 'bb5' => 'Blackboard 5',
6081: 'bb6' => 'Blackboard 6',
6082: 'angel5' => 'ANGEL 5.5',
6083: 'webctce4' => 'WebCT 4 Campus Edition',
1.484.2.67 raeburn 6084: 'er' => 'Editing rights unavailable for your current role.',
1.484.2.50 raeburn 6085: );
1.329 droeschl 6086: # -----------------------------------------------------------------------------
1.484.2.82 raeburn 6087: # Calculate free quota space for a user or course. A javascript function checks
6088: # file size to determine if upload should be allowed.
1.484.2.64 raeburn 6089: my $quotatype = 'unofficial';
6090: if ($crstype eq 'Community') {
6091: $quotatype = 'community';
6092: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
6093: $quotatype = 'official';
6094: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
6095: $quotatype = 'textbook';
6096: }
6097: my $disk_quota = &Apache::loncommon::get_user_quota($coursenum,$coursedom,
6098: 'course',$quotatype); # expressed in MB
6099: my $current_disk_usage = 0;
6100: foreach my $subdir ('docs','supplemental') {
6101: $current_disk_usage += &Apache::lonnet::diskusage($coursedom,$coursenum,
6102: "userfiles/$subdir",1); # expressed in kB
6103: }
6104: my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage);
6105: my $usage = $current_disk_usage/1024; # in MB
6106: my $quota = $disk_quota;
6107: my $percent;
6108: if ($disk_quota == 0) {
6109: $percent = 100.0;
6110: } else {
1.484.2.69 raeburn 6111: $percent = 100*($usage/$disk_quota);
1.484.2.64 raeburn 6112: }
6113: $usage = sprintf("%.2f",$usage);
6114: $quota = sprintf("%.2f",$quota);
6115: $percent = sprintf("%.0f",$percent);
6116: my $quotainfo = '<p>'.&mt('Currently using [_1] of the [_2] available.',
6117: $percent.'%',$quota.' MB').'</p>';
6118:
1.329 droeschl 6119: my $fileupload=(<<FIUP);
1.484.2.64 raeburn 6120: $quotainfo
1.329 droeschl 6121: $lt{'file'}:<br />
6122: FIUP
6123: my $checkbox=(<<CHBO);
6124: <!-- <label>$lt{'parse'}?
6125: <input type="checkbox" name="parserflag" />
6126: </label> -->
6127: <label>
1.484.2.67 raeburn 6128: <input type="checkbox" name="parserflag" checked="checked" $disabled /> $lt{'parse'}
1.329 droeschl 6129: </label>
6130: CHBO
1.484.2.12 raeburn 6131: my $imsfolder = $env{'form.folder'};
6132: if ($imsfolder eq '') {
1.484.2.19 raeburn 6133: $imsfolder = 'default';
1.484.2.12 raeburn 6134: }
6135: my $imspform=(<<IMSFORM);
6136: <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
6137: $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
6138: <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
1.484.2.19 raeburn 6139: <fieldset id="uploadimsform" style="display: none;">
1.484.2.12 raeburn 6140: <legend>$lt{'imsf'}</legend>
6141: $fileupload
1.484.2.93.2. 3(raebur 6142:3): <input type="file" name="uploaddoc" id="uploaddocims" class="LC_flUpload LC_uploaddoc" size="40" $disabled />
6143:3): <input type="hidden" id="LC_free_space_ims" value="$free_space" />
1.484.2.12 raeburn 6144: <br />
6145: <p>
1.484.2.19 raeburn 6146: $lt{'cms'}:
1.484.2.67 raeburn 6147: <select name="source" $disabled>
1.484.2.12 raeburn 6148: <option value="-1" selected="selected">$lt{'se'}</option>
1.484.2.50 raeburn 6149: <option value="bb5">$lt{'bb5'}</option>
6150: <option value="bb6">$lt{'bb6'}</option>
6151: <option value="angel5">$lt{'angel5'}</option>
6152: <option value="webctce4">$lt{'webctce4'}</option>
1.484.2.12 raeburn 6153: </select>
6154: <input type="hidden" name="folder" value="$imsfolder" />
6155: </p>
6156: <input type="hidden" name="phase" value="one" />
1.484.2.67 raeburn 6157: <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" $disabled />
1.484.2.12 raeburn 6158: </fieldset>
6159: </form>
6160: IMSFORM
6161:
1.484.2.19 raeburn 6162: my $fileuploadform=(<<FUFORM);
1.484.2.12 raeburn 6163: <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
6164: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
6165: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.484.2.19 raeburn 6166: <fieldset id="uploaddocform" style="display: none;">
1.484.2.12 raeburn 6167: <legend>$lt{'upfi'}</legend>
1.371 tempelho 6168: <input type="hidden" name="active" value="aa" />
1.329 droeschl 6169: $fileupload
1.484.2.93.2. 3(raebur 6170:3): <input type="file" name="uploaddoc" class="LC_flUpload" size="40" $disabled />
6171:3): <input type="hidden" id="LC_free_space" value="$free_space" />
1.329 droeschl 6172: <br />
6173: $lt{'title'}:<br />
1.484.2.67 raeburn 6174: <input type="text" size="60" name="comment" $disabled />
1.484.2.17 raeburn 6175: $pathitem
1.329 droeschl 6176: <input type="hidden" name="cmd" value="upload_default" />
6177: <br />
1.458 raeburn 6178: <span class="LC_nobreak" style="float:left">
1.329 droeschl 6179: $checkbox
6180: </span>
1.484.2.12 raeburn 6181: <br clear="all" />
1.484.2.67 raeburn 6182: <input type="submit" value="$lt{'upld'}" $disabled />
1.484.2.12 raeburn 6183: </fieldset>
6184: </form>
1.383 tempelho 6185: FUFORM
1.329 droeschl 6186:
1.484.2.67 raeburn 6187: my $mapimportjs;
6188: if ($canedit) {
6189: $mapimportjs = "javascript:openbrowser('mapimportform','importmap','sequence,page','');";
6190: } else {
6191: $mapimportjs = "javascript:alert('".&js_escape($lt{'er'})."');";
6192: }
1.484.2.19 raeburn 6193: my $importpubform=(<<SEDFFORM);
6194: <a class="LC_menubuttons_link" href="javascript:toggleMap('map');">
1.484.2.13 raeburn 6195: $lt{'impm'}</a>$help{'Load_Map'}
1.484.2.19 raeburn 6196: <form action="/adm/coursedocs" method="post" name="mapimportform">
6197: <fieldset id="importmapform" style="display: none;">
1.484.2.13 raeburn 6198: <legend>$lt{'impm'}</legend>
1.484.2.19 raeburn 6199: <input type="hidden" name="active" value="bb" />
1.484.2.13 raeburn 6200: $lt{'copm'}<br />
6201: <span class="LC_nobreak">
1.484.2.19 raeburn 6202: <input type="text" name="importmap" size="40" value=""
1.484.2.67 raeburn 6203: onfocus="this.blur();$mapimportjs" $disabled />
6204: <a href="$mapimportjs">$lt{'selm'}</a></span><br />
6205: <input type="submit" name="loadmap" value="$lt{'load'}" $disabled />
1.484.2.13 raeburn 6206: </fieldset>
6207: </form>
6208:
1.383 tempelho 6209: SEDFFORM
1.484.2.67 raeburn 6210:
6211: my $fromstoredjs;
6212: if ($canedit) {
6213: $fromstoredjs = 'open_StoredLinks_Import()';
6214: } else {
6215: $fromstoredjs = "alert('".&js_escape($lt{'er'})."')";
6216: }
6217:
1.484.2.19 raeburn 6218: my @importpubforma = (
6219: { '<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 6220: { '<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 6221: { '<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 6222: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform }
6223: );
6224: $importpubform = &create_form_ul(&create_list_elements(@importpubforma));
6225: my $extresourcesform =
6226: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
1.484.2.67 raeburn 6227: $help{'Adding_External_Resource'},
1.484.2.93.2. (raeburn 6228:): undef,undef,undef,undef,undef,undef,$disabled);
6229:): my $exttoolform =
6230:): &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
6231:): $help{'Adding_External_Tool'},undef,
6232:): undef,'tool',$coursedom,$coursenum,
6233:): \%ltitools,$disabled);
1.329 droeschl 6234: if ($allowed) {
1.484.2.7 raeburn 6235: my $folder = $env{'form.folder'};
6236: if ($folder eq '') {
6237: $folder='default';
6238: }
1.484.2.67 raeburn 6239: if ($canedit) {
6240: my $output = &update_paste_buffer($coursenum,$coursedom,$folder);
6241: if ($output) {
6242: $r->print($output);
6243: }
1.484.2.30 raeburn 6244: }
1.337 ehlerst 6245: $r->print(<<HIDDENFORM);
6246: <form name="renameform" method="post" action="/adm/coursedocs">
6247: <input type="hidden" name="title" />
6248: <input type="hidden" name="cmd" />
6249: <input type="hidden" name="markcopy" />
6250: <input type="hidden" name="copyfolder" />
6251: $containertag
6252: </form>
1.484 raeburn 6253:
1.337 ehlerst 6254: HIDDENFORM
1.484.2.17 raeburn 6255: $r->print(&makesimpleeditform($pathitem)."\n".
6256: &makedocslogform($pathitem."\n".
1.484 raeburn 6257: '<input type="hidden" name="folder" value="'.
6258: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 6259: }
1.442 www 6260:
6261: # Generate the tabs
1.484.2.19 raeburn 6262: my ($mode,$needs_end);
1.472 raeburn 6263: if (($supplementalflag) && (!$allowed)) {
1.484.2.19 raeburn 6264: my @folders = split('&',$env{'form.folderpath'});
6265: unless (@folders > 2) {
6266: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
6267: $needs_end = 1;
6268: }
1.472 raeburn 6269: } else {
1.484 raeburn 6270: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484.2.19 raeburn 6271: $needs_end = 1;
1.472 raeburn 6272: }
1.443 www 6273:
1.442 www 6274: #
6275:
6276: my $savefolderpath;
1.484.2.86 raeburn 6277: my $hostname = $r->hostname();
1.442 www 6278:
1.395 raeburn 6279: if ($allowed) {
1.329 droeschl 6280: my $folder=$env{'form.folder'};
1.484.2.67 raeburn 6281: if ((($folder eq '') && (!$hiddentop)) || ($supplementalflag)) {
1.329 droeschl 6282: $folder='default';
1.356 tempelho 6283: $savefolderpath = $env{'form.folderpath'};
1.484.2.33 raeburn 6284: $env{'form.folderpath'}='default&'.&escape(&mt('Main Content'));
1.484.2.17 raeburn 6285: $pathitem = '<input type="hidden" name="folderpath" value="'.
1.329 droeschl 6286: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
6287: }
6288: my $postexec='';
6289: if ($folder eq 'default') {
1.484.2.93.2. 2(raebur 6290:3): my $windowname = 'loncapaclient';
6291:3): if ($env{'request.lti.login'}) {
6292:3): $windowname .= 'lti';
6293:3): }
1.372 bisitz 6294: $r->print('<script type="text/javascript">'."\n"
6295: .'// <![CDATA['."\n"
1.484.2.93.2. 2(raebur 6296:3): .'this.window.name="$windowname";'."\n"
1.372 bisitz 6297: .'// ]]>'."\n"
6298: .'</script>'."\n"
1.369 bisitz 6299: );
1.329 droeschl 6300: } else {
6301: #$postexec='self.close();';
6302: }
1.484.2.15 raeburn 6303: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
6304: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
1.329 droeschl 6305: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
6306:
6307: my $newnavform=(<<NNFORM);
6308: <form action="/adm/coursedocs" method="post" name="newnav">
1.484.2.43 raeburn 6309: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 6310: $pathitem
1.329 droeschl 6311: <input type="hidden" name="importdetail"
6312: value="$lt{'navc'}=/adm/navmaps" />
1.484.2.67 raeburn 6313: <a class="LC_menubuttons_link" href="javascript:makenew(document.newnav);">$lt{'navc'}</a>
1.329 droeschl 6314: $help{'Navigate_Content'}
6315: </form>
6316: NNFORM
6317: my $newsmppageform=(<<NSPFORM);
6318: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.484.2.43 raeburn 6319: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 6320: $pathitem
1.329 droeschl 6321: <input type="hidden" name="importdetail" value="" />
1.423 onken 6322: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 6323: $help{'Simple Page'}
1.329 droeschl 6324: </form>
6325: NSPFORM
6326:
6327: my $newsmpproblemform=(<<NSPROBFORM);
6328: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371 tempelho 6329: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 6330: $pathitem
1.329 droeschl 6331: <input type="hidden" name="importdetail" value="" />
1.423 onken 6332: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.484.2.44 raeburn 6333: $help{'Simple_Problem'}
1.329 droeschl 6334: </form>
6335:
6336: NSPROBFORM
6337:
6338: my $newdropboxform=(<<NDBFORM);
6339: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.371 tempelho 6340: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 6341: $pathitem
1.329 droeschl 6342: <input type="hidden" name="importdetail" value="" />
1.423 onken 6343: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.484.2.36 raeburn 6344: $help{'Dropbox'}
1.344 bisitz 6345: </form>
1.329 droeschl 6346: NDBFORM
6347:
6348: my $newexuploadform=(<<NEXUFORM);
6349: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.371 tempelho 6350: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 6351: $pathitem
1.329 droeschl 6352: <input type="hidden" name="importdetail" value="" />
1.423 onken 6353: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 6354: $help{'Score_Upload_Form'}
6355: </form>
6356: NEXUFORM
6357:
6358: my $newbulform=(<<NBFORM);
6359: <form action="/adm/coursedocs" method="post" name="newbul">
1.484.2.43 raeburn 6360: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 6361: $pathitem
1.329 droeschl 6362: <input type="hidden" name="importdetail" value="" />
1.423 onken 6363: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 6364: $help{'Bulletin Board'}
6365: </form>
6366: NBFORM
6367:
6368: my $newaboutmeform=(<<NAMFORM);
6369: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.484.2.43 raeburn 6370: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 6371: $pathitem
1.329 droeschl 6372: <input type="hidden" name="importdetail"
6373: value="$plainname=/adm/$udom/$uname/aboutme" />
1.484.2.67 raeburn 6374: <a class="LC_menubuttons_link" href="javascript:makenew(document.newaboutme);">$lt{'mypi'}</a>
1.347 weissno 6375: $help{'My Personal Information Page'}
1.329 droeschl 6376: </form>
6377: NAMFORM
6378:
6379: my $newaboutsomeoneform=(<<NASOFORM);
6380: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.484.2.43 raeburn 6381: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 6382: $pathitem
1.329 droeschl 6383: <input type="hidden" name="importdetail" value="" />
1.423 onken 6384: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 6385: </form>
6386: NASOFORM
6387:
6388: my $newrosterform=(<<NROSTFORM);
6389: <form action="/adm/coursedocs" method="post" name="newroster">
1.484.2.43 raeburn 6390: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 6391: $pathitem
1.329 droeschl 6392: <input type="hidden" name="importdetail"
6393: value="$lt{'rost'}=/adm/viewclasslist" />
1.484.2.67 raeburn 6394: <a class="LC_menubuttons_link" href="javascript:makenew(document.newroster);">$lt{'rost'}</a>
1.484.2.37 raeburn 6395: $help{'Course_Roster'}
1.329 droeschl 6396: </form>
6397: NROSTFORM
6398:
1.484.2.27 raeburn 6399: my $newwebpage;
6400: if ($folder =~ /^default_?(\d*)$/) {
6401: $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
6402: if ($1) {
6403: $newwebpage .= $1;
6404: } else {
6405: $newwebpage .= 'default';
6406: }
6407: $newwebpage .= '/new.html';
6408: }
6409: my $newwebpageform =(<<NWEBFORM);
6410: <form action="/adm/coursedocs" method="post" name="newwebpage">
1.484.2.43 raeburn 6411: <input type="hidden" name="active" value="ee" />
1.484.2.27 raeburn 6412: $pathitem
6413: <input type="hidden" name="importdetail" value="$newwebpage" />
6414: <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
1.484.2.36 raeburn 6415: $help{'Web_Page'}
1.484.2.27 raeburn 6416: </form>
6417: NWEBFORM
1.484.2.30 raeburn 6418:
1.484.2.27 raeburn 6419:
1.342 ehlerst 6420: my $specialdocumentsform;
1.383 tempelho 6421: my @specialdocumentsforma;
1.451 www 6422: my $gradingform;
6423: my @gradingforma;
6424: my $communityform;
6425: my @communityforma;
1.351 ehlerst 6426: my $newfolderform;
1.390 tempelho 6427: my $newfolderb;
1.342 ehlerst 6428:
1.451 www 6429: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 6430:
1.329 droeschl 6431: my $newpageform=(<<NPFORM);
6432: <form action="/adm/coursedocs" method="post" name="newpage">
6433: <input type="hidden" name="folderpath" value="$path" />
6434: <input type="hidden" name="importdetail" value="" />
1.484.2.43 raeburn 6435: <input type="hidden" name="active" value="ee" />
1.423 onken 6436: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 6437: $help{'Adding_Pages'}
1.329 droeschl 6438: </form>
6439: NPFORM
1.390 tempelho 6440:
6441:
1.351 ehlerst 6442: $newfolderform=(<<NFFORM);
1.329 droeschl 6443: <form action="/adm/coursedocs" method="post" name="newfolder">
1.484.2.19 raeburn 6444: $pathitem
1.329 droeschl 6445: <input type="hidden" name="importdetail" value="" />
1.484.2.43 raeburn 6446: <input type="hidden" name="active" value="" />
1.422 onken 6447: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 6448: </form>
6449: NFFORM
6450:
6451: my $newsylform=(<<NSYLFORM);
6452: <form action="/adm/coursedocs" method="post" name="newsyl">
1.484.2.43 raeburn 6453: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 6454: $pathitem
1.329 droeschl 6455: <input type="hidden" name="importdetail"
6456: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.484.2.67 raeburn 6457: <a class="LC_menubuttons_link" href="javascript:makenew(document.newsyl);">$lt{'syll'}</a>
1.329 droeschl 6458: $help{'Syllabus'}
1.383 tempelho 6459:
1.329 droeschl 6460: </form>
6461: NSYLFORM
1.364 bisitz 6462:
1.329 droeschl 6463: my $newgroupfileform=(<<NGFFORM);
6464: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.484.2.43 raeburn 6465: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 6466: $pathitem
1.329 droeschl 6467: <input type="hidden" name="importdetail"
6468: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.484.2.67 raeburn 6469: <a class="LC_menubuttons_link" href="javascript:makenew(document.newgroupfiles);">$lt{'grpo'}</a>
1.353 weissno 6470: $help{'Group Portfolio'}
1.329 droeschl 6471: </form>
6472: NGFFORM
1.484.2.89 raeburn 6473: if ($container eq 'page') {
6474: @specialdocumentsforma=(
6475: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
6476: );
6477: } else {
6478: @specialdocumentsforma=(
1.421 onken 6479: {'<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 6480: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.newsyl);" />'=>$newsylform},
6481: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="javascript:makenew(document.newnav);" />'=>$newnavform},
1.451 www 6482: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
1.484.2.27 raeburn 6483: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
1.484.2.89 raeburn 6484: );
6485: }
1.451 www 6486: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
6487:
1.434 raeburn 6488:
6489: my @importdoc = (
1.484.2.19 raeburn 6490: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform}
6491: );
1.484.2.93.2. 2(raebur 6492:3): if ($posslti) {
(raeburn 6493:): push(@importdoc,
6494:): {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="toggleUpload(\'tool\');" />'=>$exttoolform},
6495:): );
6496:): }
1.484.2.19 raeburn 6497: unless ($container eq 'page') {
6498: push(@importdoc,
6499: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform}
6500: );
6501: }
6502: push(@importdoc,
1.484.2.38 raeburn 6503: {'<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 6504: );
1.484.2.12 raeburn 6505: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
1.434 raeburn 6506:
1.451 www 6507: @gradingforma=(
6508: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
6509: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
6510: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
6511:
6512: );
6513: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
6514:
6515: @communityforma=(
6516: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
6517: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
6518: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
1.484.2.67 raeburn 6519: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="javascript:makenew(document.newroster);" />'=>$newrosterform},
6520: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="javascript:makenew(document.newgroupfiles);" />'=>$newgroupfileform},
1.451 www 6521: );
6522: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 6523:
1.330 tempelho 6524: my %orderhash = (
1.484.2.36 raeburn 6525: 'aa' => ['Upload',$fileuploadform],
6526: 'bb' => ['Import',$importpubform],
6527: 'cc' => ['Grading',$gradingform],
1.484.2.89 raeburn 6528: 'ee' => ['Other',$specialdocumentsform],
1.330 tempelho 6529: );
1.484.2.19 raeburn 6530: unless ($container eq 'page') {
1.434 raeburn 6531: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.484 raeburn 6532: $orderhash{'dd'} = ['Collaboration',$communityform];
1.434 raeburn 6533: }
6534:
1.341 ehlerst 6535: $hadchanges=0;
1.484 raeburn 6536: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 6537: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.67 raeburn 6538: $supplementalflag,\%orderhash,$iconpath,$pathitem,
1.484.2.93.2. (raeburn 6539:): \%ltitools,$canedit,$hostname,\$navmap,$hiddentop);
1.484.2.67 raeburn 6540: undef($navmap);
1.443 www 6541: if ($error) {
6542: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
6543: }
6544: if ($hadchanges) {
1.484.2.73 raeburn 6545: unless (&is_hash_old()) {
6546: &mark_hash_old();
6547: }
1.443 www 6548: }
1.341 ehlerst 6549:
1.443 www 6550: &changewarning($r,'');
6551: }
1.458 raeburn 6552: }
1.442 www 6553:
1.443 www 6554: # Supplemental documents start here
6555:
1.329 droeschl 6556: my $folder=$env{'form.folder'};
1.443 www 6557: unless ($supplementalflag) {
1.329 droeschl 6558: $folder='supplemental';
6559: }
1.484.2.93.2. 0(raebur 6560:3): if (($folder eq 'supplemental') &&
1.329 droeschl 6561: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 6562: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 6563: } elsif ($allowed) {
1.356 tempelho 6564: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 6565: }
1.484.2.17 raeburn 6566: $pathitem = '<input type="hidden" name="folderpath" value="'.
6567: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.329 droeschl 6568: if ($allowed) {
6569: my $folderseq=
1.484.2.15 raeburn 6570: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
1.329 droeschl 6571:
6572: my $supupdocform=(<<SUPDOCFORM);
1.484.2.12 raeburn 6573: <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
6574: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
1.383 tempelho 6575: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.484.2.19 raeburn 6576: <fieldset id="uploadsuppdocform" style="display: none;">
1.484.2.12 raeburn 6577: <legend>$lt{'upfi'}</legend>
1.371 tempelho 6578: <input type="hidden" name="active" value="ee" />
1.329 droeschl 6579: $fileupload
1.484.2.93.2. 3(raebur 6580:3): <input type="file" name="uploaddoc" id="uploaddocsupp" class="LC_flUpload LC_uploaddoc" size="40" $disabled />
6581:3): <input type="hidden" id="LC_free_space_supp" value="$free_space" />
1.329 droeschl 6582: <br />
6583: <br />
6584: <span class="LC_nobreak">
6585: $checkbox
6586: </span>
6587: <br /><br />
6588: $lt{'comment'}:<br />
1.383 tempelho 6589: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 6590: <br />
1.484.2.19 raeburn 6591: $pathitem
1.329 droeschl 6592: <input type="hidden" name="cmd" value="upload_supplemental" />
1.484.2.12 raeburn 6593: <input type='submit' value="$lt{'upld'}" />
6594: </form>
1.484.2.19 raeburn 6595: SUPDOCFORM
1.329 droeschl 6596:
6597: my $supnewfolderform=(<<SNFFORM);
6598: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.484.2.43 raeburn 6599: <input type="hidden" name="active" value="" />
1.484.2.17 raeburn 6600: $pathitem
1.329 droeschl 6601: <input type="hidden" name="importdetail" value="" />
1.423 onken 6602: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 6603: $help{'Adding_Folders'}
1.329 droeschl 6604: </form>
6605: SNFFORM
1.383 tempelho 6606:
1.484.2.19 raeburn 6607: my $supextform =
6608: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
1.484.2.67 raeburn 6609: $help{'Adding_External_Resource'},
6610: undef,undef,$disabled);
1.484.2.93.2. (raeburn 6611:): my $supexttoolform =
6612:): &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
6613:): $help{'Adding_External_Tool'},
6614:): undef,undef,'tool',$coursedom,
6615:): $coursenum,\%ltitools,$disabled);
1.329 droeschl 6616:
6617: my $supnewsylform=(<<SNSFORM);
6618: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 6619: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 6620: $pathitem
1.329 droeschl 6621: <input type="hidden" name="importdetail"
6622: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.484.2.67 raeburn 6623: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewsyl);">$lt{'syll'}</a>
1.329 droeschl 6624: $help{'Syllabus'}
6625: </form>
6626: SNSFORM
6627:
6628: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 6629: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 6630: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 6631: $pathitem
1.329 droeschl 6632: <input type="hidden" name="importdetail"
6633: value="$plainname=/adm/$udom/$uname/aboutme" />
1.484.2.67 raeburn 6634: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewaboutme);">$lt{'mypi'}</a>
1.347 weissno 6635: $help{'My Personal Information Page'}
1.329 droeschl 6636: </form>
6637: SNAMFORM
6638:
1.484.2.27 raeburn 6639: my $supwebpage;
6640: if ($folder =~ /^supplemental_?(\d*)$/) {
6641: $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
6642: if ($1) {
6643: $supwebpage .= $1;
6644: } else {
6645: $supwebpage .= 'default';
6646: }
6647: $supwebpage .= '/new.html';
6648: }
6649: my $supwebpageform =(<<SWEBFORM);
6650: <form action="/adm/coursedocs" method="post" name="supwebpage">
6651: <input type="hidden" name="active" value="cc" />
6652: $pathitem
6653: <input type="hidden" name="importdetail" value="$supwebpage" />
6654: <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
1.484.2.36 raeburn 6655: $help{'Web_Page'}
1.484.2.27 raeburn 6656: </form>
6657: SWEBFORM
6658:
1.333 muellerd 6659:
1.383 tempelho 6660: my @specialdocs = (
1.484.2.67 raeburn 6661: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.supnewsyl);" />'
1.417 droeschl 6662: =>$supnewsylform},
1.484.2.67 raeburn 6663: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makenew(document.supnewaboutme);" />'
1.417 droeschl 6664: =>$supnewaboutmeform},
1.484.2.27 raeburn 6665: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
6666:
1.383 tempelho 6667: );
1.417 droeschl 6668: my @supimportdoc = (
1.484.2.19 raeburn 6669: {'<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 6670:): =>$supextform});
6671:): if (keys(%ltitools)) {
6672:): push(@supimportdoc,
6673:): {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="javascript:toggleUpload(\'supptool\')" />'
6674:): =>$supexttoolform});
6675:): }
6676:): push(@supimportdoc,
1.484.2.12 raeburn 6677: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
6678: =>$supupdocform},
1.484.2.93.2. (raeburn 6679:): );
1.484.2.19 raeburn 6680:
1.484.2.12 raeburn 6681: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
1.333 muellerd 6682: my %suporderhash = (
1.390 tempelho 6683: '00' => ['Supnewfolder', $supnewfolderform],
1.484.2.36 raeburn 6684: 'ee' => ['Upload',$supupdocform],
6685: 'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 6686: );
1.443 www 6687: if ($supplementalflag) {
1.484.2.93.2. 0(raebur 6688:3): $suppchanges = 0;
6689:3): my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
6690:3): $supplementalflag,\%suporderhash,$iconpath,$pathitem,
6691:3): \%ltitools,$canedit,$hostname);
6692:3): if ($error) {
6693:3): $r->print('<p><span class="LC_error">'.$error.'</span></p>');
6694:3): }
6695:3): if ($suppchanges) {
6696:3): &Apache::lonnet::update_supp_caches($coursedom,$coursenum);
6697:3): undef($suppchanges);
6698:3): }
1.393 raeburn 6699: }
1.443 www 6700: } elsif ($supplementalflag) {
1.458 raeburn 6701: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.93.2. (raeburn 6702:): $supplementalflag,'',$iconpath,$pathitem,'',$canedit,
6703:): $hostname);
1.393 raeburn 6704: if ($error) {
6705: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 6706: }
1.393 raeburn 6707: }
1.389 tempelho 6708:
1.484.2.19 raeburn 6709: if ($needs_end) {
6710: $r->print(&endContentScreen());
6711: }
1.383 tempelho 6712:
1.329 droeschl 6713: if ($allowed) {
6714: $r->print('
6715: <form method="post" name="extimport" action="/adm/coursedocs">
6716: <input type="hidden" name="title" />
6717: <input type="hidden" name="url" />
6718: <input type="hidden" name="useform" />
6719: <input type="hidden" name="residx" />
6720: </form>');
6721: }
1.484 raeburn 6722: } elsif ($showdoc) {
1.329 droeschl 6723: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 6724: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.484.2.10 raeburn 6725: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 6726: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 6727: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 6728: }
6729: }
6730: $r->print(&Apache::loncommon::end_page());
6731: return OK;
1.364 bisitz 6732: }
1.329 droeschl 6733:
1.440 raeburn 6734: sub embedded_form_elems {
6735: my ($phase,$primaryurl,$newidx) = @_;
6736: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.484.2.78 raeburn 6737: $newidx =~s /\D+//g;
1.440 raeburn 6738: return <<STATE;
6739: <input type="hidden" name="folderpath" value="$folderpath" />
6740: <input type="hidden" name="cmd" value="upload_embedded" />
6741: <input type="hidden" name="newidx" value="$newidx" />
6742: <input type="hidden" name="phase" value="$phase" />
6743: <input type="hidden" name="primaryurl" value="$primaryurl" />
6744: STATE
6745: }
6746:
6747: sub embedded_destination {
6748: my $folder=$env{'form.folder'};
6749: my $destination = 'docs/';
6750: if ($folder =~ /^supplemental/) {
6751: $destination = 'supplemental/';
6752: }
6753: if (($folder eq 'default') || ($folder eq 'supplemental')) {
6754: $destination .= 'default/';
6755: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
6756: $destination .= $2.'/';
6757: }
1.484.2.78 raeburn 6758: my $newidx = $env{'form.newidx'};
6759: $newidx =~s /\D+//g;
6760: if ($newidx) {
6761: $destination .= $newidx;
6762: }
1.440 raeburn 6763: my $dir_root = '/userfiles';
6764: return ($destination,$dir_root);
6765: }
6766:
6767: sub return_to_editor {
6768: my $actionurl = '/adm/coursedocs';
6769: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
6770: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
6771: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
6772: '</a></p>';
6773: }
6774:
1.476 raeburn 6775: sub decompression_info {
6776: my ($destination,$dir_root) = &embedded_destination();
6777: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
6778: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
6779: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
6780: my $container='sequence';
1.480 raeburn 6781: my ($pathitem,$hiddenelem);
1.484.2.54 raeburn 6782: my @hiddens = ('newidx','comment','position','folderpath','archiveurl');
1.484.2.19 raeburn 6783: if ($env{'form.folderpath'} =~ /\:1$/) {
1.476 raeburn 6784: $container='page';
6785: }
1.480 raeburn 6786: unshift(@hiddens,$pathitem);
6787: foreach my $item (@hiddens) {
1.484.2.78 raeburn 6788: if ($item eq 'newidx') {
6789: next if ($env{'form.'.$item} =~ /\D/);
6790: }
1.480 raeburn 6791: if ($env{'form.'.$item}) {
6792: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
1.484.2.54 raeburn 6793: &HTML::Entities::encode($env{'form.'.$item},'<>&"').'" />'."\n";
1.480 raeburn 6794: }
1.477 raeburn 6795: }
1.476 raeburn 6796: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
6797: $hiddenelem);
6798: }
6799:
6800: sub decompression_phase_one {
6801: my ($dir,$file,$warning,$error,$output);
6802: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
6803: &decompression_info();
1.484.2.7 raeburn 6804: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 6805: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
6806: } else {
6807: my $file = $1;
1.481 raeburn 6808: $output =
6809: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
6810: $destination,$dir_root,
6811: $hiddenelem);
6812: if ($env{'form.autoextract_camtasia'}) {
6813: $output .= &remove_archive($docudom,$docuname,$container);
6814: }
1.476 raeburn 6815: }
6816: if ($error) {
6817: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
6818: $error.'</p>'."\n";
6819: }
6820: if ($warning) {
6821: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
6822: }
6823: return $output;
6824: }
6825:
6826: sub decompression_phase_two {
6827: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
6828: &decompression_info();
1.481 raeburn 6829: my $output;
1.480 raeburn 6830: if ($env{'form.archivedelete'}) {
1.481 raeburn 6831: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 6832: }
6833: $output .=
1.481 raeburn 6834: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 6835: $destination,$dir_root,$hiddenelem);
6836: return $output;
6837: }
6838:
1.480 raeburn 6839: sub remove_archive {
6840: my ($docudom,$docuname,$container) = @_;
6841: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 6842: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 6843: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
6844: if ($fatal) {
6845: if ($container eq 'page') {
6846: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
6847: } else {
6848: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
6849: }
1.484.2.54 raeburn 6850: $delwarning .= ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 6851: } else {
6852: my $currcmd = $env{'form.cmd'};
6853: my $position = $env{'form.position'};
1.484.2.54 raeburn 6854: my $archiveidx = $position;
6855: if ($position > 0) {
6856: if (($env{'form.autoextract_camtasia'}) && (scalar(@LONCAPA::map::order) == 2)) {
6857: $archiveidx = $position-1;
6858: }
6859: $env{'form.cmd'} = 'remove_'.$archiveidx;
6860: my ($title,$url,@rrest) =
6861: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$archiveidx]]);
6862: if ($url eq $env{'form.archiveurl'}) {
6863: if (&handle_edit_cmd($docuname,$docudom)) {
6864: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
1.484.2.93.2. 0(raebur 6865:3): if ($suppchanges) {
6866:3): &Apache::lonnet::update_supp_caches($docudom,$docuname);
6867:3): undef($suppchanges);
6868:3): }
1.484.2.54 raeburn 6869: if ($fatal) {
6870: if ($container eq 'page') {
6871: $delwarning = &mt('An error occurred updating the contents of the current page.');
6872: } else {
6873: $delwarning = &mt('An error occurred updating the contents of the current folder.');
6874: }
1.480 raeburn 6875: } else {
1.484.2.54 raeburn 6876: $delresult = &mt('Archive file removed.');
1.480 raeburn 6877: }
6878: }
1.484.2.54 raeburn 6879: } else {
6880: $delwarning .= &mt('Archive file had unexpected item number in folder.').
6881: ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 6882: }
6883: }
6884: $env{'form.cmd'} = $currcmd;
6885: }
6886: if ($delwarning) {
6887: $output = '<p class="LC_warning">'.
6888: $delwarning.
6889: '</p>';
6890: }
6891: if ($delresult) {
6892: $output .= '<p class="LC_info">'.
6893: $delresult.
6894: '</p>';
6895: }
1.481 raeburn 6896: return $output;
1.480 raeburn 6897: }
6898:
1.484 raeburn 6899: sub generate_admin_menu {
1.484.2.67 raeburn 6900: my ($crstype,$canedit) = @_;
1.484 raeburn 6901: my $lc_crstype = lc($crstype);
6902: my ($home,$other,%outhash)=&authorhosts();
1.484.2.43 raeburn 6903: my %lt= ( # do not translate here
1.484 raeburn 6904: 'vc' => 'Verify Content',
6905: 'cv' => 'Check/Set Resource Versions',
6906: 'ls' => 'List Resource Identifiers',
1.484.2.93.2. (raeburn 6907:): 'ct' => 'Display/Set Shortened URLs for Deep-linking',
1.484 raeburn 6908: 'imse' => 'Export contents to IMS Archive',
1.484.2.43 raeburn 6909: 'dcd' => "Copy $crstype Content to Authoring Space",
6910: );
1.484 raeburn 6911: my ($candump,$dumpurl);
6912: if ($home + $other > 0) {
6913: $candump = 'F';
6914: if ($home) {
6915: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
6916: } else {
6917: my @hosts;
6918: foreach my $aurole (keys(%outhash)) {
6919: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
6920: push(@hosts,$outhash{$aurole});
1.484.2.30 raeburn 6921: }
1.484 raeburn 6922: }
6923: if (@hosts == 1) {
6924: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
6925: '&role='.
6926: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
6927: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
6928: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
6929: } else {
6930: $dumpurl = "javascript:choose_switchserver_window()";
6931: }
6932: }
6933: }
6934: my @menu=
6935: ({ categorytitle=>'Administration',
6936: items =>[
6937: { linktext => $lt{'vc'},
6938: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
6939: permission => 'F',
1.484.2.44 raeburn 6940: help => 'Docs_Verify_Content',
1.484 raeburn 6941: icon => 'verify.png',
6942: linktitle => 'Verify contents can be retrieved/rendered',
6943: },
6944: { linktext => $lt{'cv'},
6945: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
6946: permission => 'F',
1.484.2.44 raeburn 6947: help => 'Docs_Check_Resource_Versions',
1.484 raeburn 6948: icon => 'resversion.png',
6949: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
6950: },
6951: { linktext => $lt{'ls'},
6952: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
6953: permission => 'F',
6954: #help => '',
6955: icon => 'symbs.png',
6956: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
6957: },
1.484.2.93.2. (raeburn 6958:): { linktext => $lt{'ct'},
6959:): url => "javascript:injectData(document.courseverify,'dummy','shorturls','$lt{'ct'}')",
6960:): permission => 'F',
6961:): help => 'Docs_Short_URLs',
6962:): icon => 'shorturls.png',
6963:): linktitle => "Set shortened URLs for a resource or folder in your $lc_crstype for use in deep-linking"
6964:): },
1.484 raeburn 6965: ]
1.484.2.67 raeburn 6966: });
6967: if ($canedit) {
6968: push(@menu,
1.484 raeburn 6969: { categorytitle=>'Export',
6970: items =>[
6971: { linktext => $lt{'imse'},
6972: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
6973: permission => 'F',
6974: help => 'Docs_Export_Course_Docs',
6975: icon => 'imsexport.png',
6976: linktitle => $lt{'imse'},
6977: },
6978: { linktext => $lt{'dcd'},
6979: url => $dumpurl,
6980: permission => $candump,
1.484.2.44 raeburn 6981: help => 'Docs_Dump_Course_Docs',
1.484 raeburn 6982: icon => 'dump.png',
6983: linktitle => $lt{'dcd'},
6984: },
6985: ]
6986: });
1.484.2.67 raeburn 6987: }
1.484 raeburn 6988: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
6989: '<input type="hidden" id="dummy" />'."\n".
6990: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
6991: '</form>';
1.329 droeschl 6992: }
6993:
6994: sub generate_edit_table {
1.484.2.30 raeburn 6995: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile,
1.484.2.67 raeburn 6996: $need_save,$copyfolder,$canedit) = @_;
1.406 raeburn 6997: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 6998: my %orderhash = %{$orderhash_ref};
1.484.2.67 raeburn 6999: my ($form, $activetab, $active, $disabled);
1.484.2.43 raeburn 7000: if (($env{'form.active'} ne '') && ($env{'form.active'} ne '00')) {
1.371 tempelho 7001: $activetab = $env{'form.active'};
7002: }
1.484.2.67 raeburn 7003: unless ($canedit) {
7004: $disabled = ' disabled="disabled"';
7005: }
1.472 raeburn 7006: my $backicon = $iconpath.'clickhere.gif';
1.484.2.21 raeburn 7007: my $backtext = &mt('Exit Editor');
1.458 raeburn 7008: $form = '<div class="LC_Box" style="margin:0;">'.
1.484.2.19 raeburn 7009: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
7010: '<li class="goback">'.
1.484.2.32 raeburn 7011: '<a href="javascript:toContents('."'$jumpto'".');">'.
1.484.2.19 raeburn 7012: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
7013: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
7014: '<li>'.
7015: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
7016: &mt('Undo Delete').'</a></li>'."\n";
1.484.2.7 raeburn 7017: if ($env{'form.docslog'}) {
7018: $form .= '<li class="active">';
7019: } else {
7020: $form .= '<li>';
7021: }
7022: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
7023: &mt('History').'</a></li>'."\n";
7024: if ($env{'form.docslog'}) {
7025: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
7026: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 7027: }
1.458 raeburn 7028: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 7029: if($name ne '00'){
1.371 tempelho 7030: if($activetab eq '' || $activetab ne $name){
7031: $active = '';
7032: }elsif($activetab eq $name){
7033: $active = 'class="active"';
7034: }
1.458 raeburn 7035: $form .= '<li style="float:right" '.$active
1.484 raeburn 7036: .' 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 7037: } else {
1.484.2.43 raeburn 7038: $form .= '<li style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 7039:
7040: }
1.329 droeschl 7041: }
1.484 raeburn 7042: $form .= '</ul>'."\n";
7043: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 7044:
7045: if ($to_show ne '') {
1.484.2.30 raeburn 7046: my $saveform;
7047: if ($need_save) {
7048: my $button = &mt('Make changes');
7049: my $path;
7050: if ($env{'form.folderpath'}) {
7051: $path =
7052: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
7053: }
7054: $saveform = <<"END";
7055: <div id="multisave" style="display:none; clear:both;" >
7056: <form name="saveactions" method="post" action="/adm/coursedocs" onsubmit="return checkSubmits();">
7057: <input type="hidden" name="folderpath" value="$path" />
7058: <input type="hidden" name="symb" value="$env{'form.symb'}" />
7059: <input type="hidden" name="allhiddenresource" value="" />
7060: <input type="hidden" name="allencrypturl" value="" />
7061: <input type="hidden" name="allrandompick" value="" />
7062: <input type="hidden" name="allrandomorder" value="" />
7063: <input type="hidden" name="changeparms" value="" />
7064: <input type="hidden" name="multiremove" value="" />
7065: <input type="hidden" name="multicut" value="" />
7066: <input type="hidden" name="multicopy" value="" />
7067: <input type="hidden" name="multichange" value="" />
7068: <input type="hidden" name="copyfolder" value="$copyfolder" />
1.484.2.67 raeburn 7069: <input type="submit" name="savemultiples" value="$button" $disabled />
1.484.2.30 raeburn 7070: </form>
7071: </div>
7072: END
7073: }
7074: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'.$saveform."\n";
1.458 raeburn 7075: }
1.363 ehlerst 7076: foreach my $field (keys(%orderhash)){
1.390 tempelho 7077: if($field ne '00'){
1.422 onken 7078: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 7079: $active = 'style="display: none;float:left"';
1.422 onken 7080: }elsif($activetab eq $field){
1.458 raeburn 7081: $active = 'style="display:block;float:left"';
1.422 onken 7082: }
7083: $form .= '<div id="'.$field.$tid.'"'
7084: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 7085: .'</div>'."\n";
1.363 ehlerst 7086: }
7087: }
1.484 raeburn 7088: unless ($env{'form.docslog'}) {
7089: $form .= '</div></div>'."\n";
7090: }
1.329 droeschl 7091: return $form;
7092: }
7093:
7094: sub editing_js {
1.484.2.93.2. (raeburn 7095:): my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
1.484.2.80 raeburn 7096: $canedit,$hostname,$navmapref) = @_;
1.484.2.61 raeburn 7097: my %js_lt = &Apache::lonlocal::texthash(
1.329 droeschl 7098: p_mnf => 'Name of New Folder',
7099: t_mnf => 'New Folder',
7100: p_mnp => 'Name of New Page',
7101: t_mnp => 'New Page',
1.451 www 7102: p_mxu => 'Title for the External Score',
1.349 biermanm 7103: p_msp => 'Name of Simple Course Page',
1.329 droeschl 7104: p_msb => 'Title for the Problem',
7105: p_mdb => 'Title for the Drop Box',
1.336 schafran 7106: p_mbb => 'Title for the Discussion Board',
1.484.2.27 raeburn 7107: p_mwp => 'Title for Web Page',
1.348 weissno 7108: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 7109: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 7110: p_mab_alrt1 => 'Not a valid user:domain',
7111: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
7112: p_chn => 'New Title',
7113: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
1.484.2.63 raeburn 7114: p_rmr2a => 'Remove',
7115: p_rmr2b => '?',
7116: p_rmr3a => 'Remove those',
7117: p_rmr3b => 'items?',
7118: p_rmr4 => 'WARNING: Removing a resource uploaded to a course cannot be undone via "Undo Delete".',
7119: p_rmr5 => 'Push "Cancel" and then use "Cut" instead if you might need to undo this change.',
1.329 droeschl 7120: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
7121: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
1.484.2.63 raeburn 7122: p_ctr2a => 'Cut',
7123: p_ctr2b => '?',
7124: p_ctr3a => 'Cut those',
7125: p_ctr3b => 'items?',
1.478 raeburn 7126: rpck => 'Enter number to pick (e.g., 3)',
1.484.2.12 raeburn 7127: imsfile => 'You must choose an IMS package for import',
7128: imscms => 'You must select which Course Management System was the source of the IMS package',
7129: invurl => 'Invalid URL',
7130: titbl => 'Title is blank',
1.484.2.30 raeburn 7131: more => '(More ...)',
7132: less => '(Less ...)',
7133: noor => 'No actions selected or changes to settings specified.',
7134: noch => 'No changes to settings specified.',
7135: noac => 'No actions selected.',
1.484.2.67 raeburn 7136: edri => 'Editing rights unavailable for your current role.',
1.329 droeschl 7137: );
7138:
1.484.2.61 raeburn 7139: &js_escape(\%js_lt);
1.433 raeburn 7140: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 7141: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
7142: my $main_container_page;
1.484.2.19 raeburn 7143: if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) {
7144: $main_container_page = 1;
1.434 raeburn 7145: }
1.484.2.67 raeburn 7146: my $backtourl;
7147: my $toplevelmain = &escape(&default_folderpath($coursenum,$coursedom,$navmapref));
1.446 www 7148: my $toplevelsupp = &supplemental_base();
1.433 raeburn 7149:
1.484.2.21 raeburn 7150: if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
7151: my $caller = $1;
7152: if ($caller =~ /^supplemental/) {
7153: $backtourl = '/adm/supplemental?folderpath='.&escape($caller);
7154: } else {
7155: my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
7156: $res = &Apache::lonnet::clutter($res);
7157: if (&Apache::lonnet::is_on_map($res)) {
1.484.2.66 raeburn 7158: my ($url,$anchor);
7159: if ($res =~ /^([^#]+)#([^#]+)$/) {
7160: $url = $1;
7161: $anchor = $2;
7162: if (($caller =~ m{^([^#]+)\Q#$anchor\E$})) {
7163: $caller = $1.&escape('#').$anchor;
7164: }
1.484.2.67 raeburn 7165: } else {
7166: $url = $res;
1.484.2.66 raeburn 7167: }
1.484.2.83 raeburn 7168: $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"');
7169: if ($backtourl =~ m{^\Q/uploaded/$coursedom/$coursenum/\Edefault_\d+\.sequence$}) {
7170: $backtourl .= '?navmap=1';
7171: } else {
7172: $backtourl .= '?symb='.
7173: &HTML::Entities::encode($caller,'<>&"');
7174: }
1.484.2.80 raeburn 7175: if ($backtourl =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
7176: if (($ENV{'SERVER_PORT'} == 443) &&
7177: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
1.484.2.93 raeburn 7178: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.484.2.80 raeburn 7179: if ($hostname ne '') {
7180: $backtourl = 'http://'.$hostname.$backtourl;
7181: }
7182: $backtourl .= (($backtourl =~ /\?/) ? '&':'?').'usehttp=1';
7183: }
7184: }
7185: } elsif ($backtourl =~ m{^/adm/wrapper/ext/(?!https:)}) {
7186: if (($ENV{'SERVER_PORT'} == 443) && ($hostname ne '')) {
1.484.2.93 raeburn 7187: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.484.2.80 raeburn 7188: if ($hostname ne '') {
7189: $backtourl = 'http://'.$hostname.$backtourl;
7190: }
7191: $backtourl .= (($backtourl =~ /\?/) ? '&':'?').'usehttp=1';
7192: }
7193: }
7194: }
1.484.2.66 raeburn 7195: if ($anchor ne '') {
7196: $backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"');
7197: }
1.484.2.57 raeburn 7198: $backtourl = &Apache::loncommon::escape_single($backtourl);
1.484.2.31 raeburn 7199: } else {
7200: $backtourl = '/adm/navmaps';
1.484.2.21 raeburn 7201: }
7202: }
7203: } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
7204: $backtourl = '/adm/menu';
7205: } elsif ($supplementalflag) {
1.484.2.93.2. 0(raebur 7206:3): if (($env{'request.role.adv'}) ||
7207:3): (&Apache::lonnet::has_unhidden_suppfiles($coursenum,$coursedom))) {
7208:3): $backtourl = '/adm/supplemental';
7209:3): } else {
7210:3): $backtourl = '/adm/navmaps';
7211:3): }
1.484.2.21 raeburn 7212: } else {
7213: $backtourl = '/adm/navmaps';
1.472 raeburn 7214: }
7215:
1.484.2.19 raeburn 7216: my $fieldsets = "'ext','doc'";
1.484.2.93.2. (raeburn 7217:): if ($posslti) {
7218:): $fieldsets .= ",'tool'";
7219:): }
1.484.2.19 raeburn 7220: unless ($main_container_page) {
7221: $fieldsets .=",'ims'";
7222: }
1.484.2.12 raeburn 7223: if ($supplementalflag) {
7224: $fieldsets = "'suppext','suppdoc'";
1.484.2.93.2. (raeburn 7225:): if ($posslti) {
7226:): $fieldsets .= ",'supptool'";
7227:): }
1.484.2.12 raeburn 7228: }
7229:
1.484.2.67 raeburn 7230: my $jsmakefunctions;
7231: if ($canedit) {
7232: $jsmakefunctions = <<ENDNEWSCRIPT;
1.329 droeschl 7233: function makenewfolder(targetform,folderseq) {
1.484.2.65 raeburn 7234: var foldername=prompt('$js_lt{"p_mnf"}','$js_lt{"t_mnf"}');
1.329 droeschl 7235: if (foldername) {
1.484.2.91 raeburn 7236: targetform.importdetail.value=encodeURIComponent(foldername)+"="+folderseq;
1.329 droeschl 7237: targetform.submit();
7238: }
7239: }
7240:
7241: function makenewpage(targetform,folderseq) {
1.484.2.61 raeburn 7242: var pagename=prompt('$js_lt{"p_mnp"}','$js_lt{"t_mnp"}');
1.329 droeschl 7243: if (pagename) {
1.484.2.91 raeburn 7244: targetform.importdetail.value=encodeURIComponent(pagename)+"="+folderseq;
1.329 droeschl 7245: targetform.submit();
7246: }
7247: }
7248:
7249: function makeexamupload() {
1.484.2.61 raeburn 7250: var title=prompt('$js_lt{"p_mxu"}');
1.344 bisitz 7251: if (title) {
1.329 droeschl 7252: this.document.forms.newexamupload.importdetail.value=
1.484.2.91 raeburn 7253: encodeURIComponent(title)+'=/res/lib/templates/examupload.problem';
1.329 droeschl 7254: this.document.forms.newexamupload.submit();
7255: }
7256: }
7257:
7258: function makesmppage() {
1.484.2.61 raeburn 7259: var title=prompt('$js_lt{"p_msp"}');
1.344 bisitz 7260: if (title) {
1.329 droeschl 7261: this.document.forms.newsmppg.importdetail.value=
1.484.2.91 raeburn 7262: encodeURIComponent(title)+'=/adm/$udom/$uname/new/smppg';
1.329 droeschl 7263: this.document.forms.newsmppg.submit();
7264: }
7265: }
7266:
1.484.2.27 raeburn 7267: function makewebpage(type) {
1.484.2.61 raeburn 7268: var title=prompt('$js_lt{"p_mwp"}');
1.484.2.27 raeburn 7269: var formname;
7270: if (type == 'supp') {
7271: formname = this.document.forms.supwebpage;
7272: } else {
7273: formname = this.document.forms.newwebpage;
7274: }
7275: if (title) {
7276: var webpage = formname.importdetail.value;
1.484.2.91 raeburn 7277: formname.importdetail.value = encodeURIComponent(title)+'='+webpage;
1.484.2.27 raeburn 7278: formname.submit();
7279: }
7280: }
7281:
1.329 droeschl 7282: function makesmpproblem() {
1.484.2.61 raeburn 7283: var title=prompt('$js_lt{"p_msb"}');
1.344 bisitz 7284: if (title) {
1.329 droeschl 7285: this.document.forms.newsmpproblem.importdetail.value=
1.484.2.91 raeburn 7286: encodeURIComponent(title)+'=/res/lib/templates/simpleproblem.problem';
1.329 droeschl 7287: this.document.forms.newsmpproblem.submit();
7288: }
7289: }
7290:
7291: function makedropbox() {
1.484.2.61 raeburn 7292: var title=prompt('$js_lt{"p_mdb"}');
1.344 bisitz 7293: if (title) {
1.329 droeschl 7294: this.document.forms.newdropbox.importdetail.value=
1.484.2.91 raeburn 7295: encodeURIComponent(title)+'=/res/lib/templates/DropBox.problem';
1.329 droeschl 7296: this.document.forms.newdropbox.submit();
7297: }
7298: }
7299:
7300: function makebulboard() {
1.484.2.61 raeburn 7301: var title=prompt('$js_lt{"p_mbb"}');
1.329 droeschl 7302: if (title) {
7303: this.document.forms.newbul.importdetail.value=
1.484.2.91 raeburn 7304: encodeURIComponent(title)+'=/adm/$udom/$uname/new/bulletinboard';
1.329 droeschl 7305: this.document.forms.newbul.submit();
7306: }
7307: }
7308:
7309: function makeabout() {
1.484.2.61 raeburn 7310: var user=prompt("$js_lt{'p_mab'}");
1.329 droeschl 7311: if (user) {
7312: var comp=new Array();
7313: comp=user.split(':');
7314: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
7315: if ((comp[0]) && (comp[1])) {
7316: this.document.forms.newaboutsomeone.importdetail.value=
1.484.2.61 raeburn 7317: '$js_lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.484.2.67 raeburn 7318: this.document.forms.newaboutsomeone.submit();
7319: } else {
7320: alert("$js_lt{'p_mab_alrt1'}");
7321: }
7322: } else {
7323: alert("$js_lt{'p_mab_alrt2'}");
7324: }
7325: }
1.335 ehlerst 7326: }
1.484.2.67 raeburn 7327:
7328: function makenew(targetform) {
7329: targetform.submit();
1.335 ehlerst 7330: }
1.484.2.67 raeburn 7331:
7332: function changename(folderpath,index,oldtitle) {
7333: var title=prompt('$js_lt{"p_chn"}',oldtitle);
7334: if (title) {
7335: this.document.forms.renameform.markcopy.value='';
7336: this.document.forms.renameform.title.value=title;
7337: this.document.forms.renameform.cmd.value='rename_'+index;
7338: this.document.forms.renameform.folderpath.value=folderpath;
7339: this.document.forms.renameform.submit();
7340: }
1.329 droeschl 7341: }
7342:
1.484.2.67 raeburn 7343: ENDNEWSCRIPT
7344: } else {
7345: $jsmakefunctions = <<ENDNEWSCRIPT;
7346:
7347: function makenewfolder() {
7348: alert("$js_lt{'edri'}");
7349: }
7350:
7351: function makenewpage() {
7352: alert("$js_lt{'edri'}");
7353: }
7354:
7355: function makeexamupload() {
7356: alert("$js_lt{'edri'}");
7357: }
7358:
7359: function makesmppage() {
7360: alert("$js_lt{'edri'}");
7361: }
7362:
7363: function makewebpage(type) {
7364: alert("$js_lt{'edri'}");
7365: }
7366:
7367: function makesmpproblem() {
7368: alert("$js_lt{'edri'}");
7369: }
7370:
7371: function makedropbox() {
7372: alert("$js_lt{'edri'}");
7373: }
7374:
7375: function makebulboard() {
7376: alert("$js_lt{'edri'}");
7377: }
7378:
7379: function makeabout() {
7380: alert("$js_lt{'edri'}");
7381: }
7382:
7383: function changename() {
7384: alert("$js_lt{'edri'}");
7385: }
7386:
7387: function makenew() {
7388: alert("$js_lt{'edri'}");
7389: }
7390:
7391: function groupimport() {
7392: alert("$js_lt{'edri'}");
7393: }
7394:
7395: function groupsearch() {
7396: alert("$js_lt{'edri'}");
7397: }
7398:
7399: function groupopen(url,recover) {
7400: var options="scrollbars=1,resizable=1,menubar=0";
7401: idxflag=1;
7402: idx=open("/adm/groupsort?inhibitmenu=yes&mode=simple&recover="+recover+"&readfile="+url,"idxout",options);
7403: idx.focus();
7404: }
7405:
7406: ENDNEWSCRIPT
7407:
7408: }
7409: return <<ENDSCRIPT;
7410:
7411: $jsmakefunctions
7412:
1.484.2.13 raeburn 7413: function toggleUpload(caller) {
7414: var blocks = Array($fieldsets);
7415: for (var i=0; i<blocks.length; i++) {
7416: var disp = 'none';
7417: if (caller == blocks[i]) {
7418: var curr = document.getElementById('upload'+caller+'form').style.display;
7419: if (curr == 'none') {
7420: disp='block';
7421: }
7422: }
7423: document.getElementById('upload'+blocks[i]+'form').style.display=disp;
1.484.2.93.2. (raeburn 7424:): if ((caller == 'tool') || (caller == 'supptool')) {
7425:): if (disp == 'block') {
7426:): if (document.getElementById('LC_exttoolid')) {
7427:): var toolselector = document.getElementById('LC_exttoolid');
7428:): var suppflag = 0;
7429:): if (caller == 'supptool') {
7430:): suppflag = 1;
7431:): }
7432:): currForm = document.getElementById('new'+caller);
7433:): updateExttool(toolselector,currForm,suppflag);
7434:): }
7435:): }
7436:): }
1.484.2.13 raeburn 7437: }
7438: resize_scrollbox('contentscroll','1','1');
7439: return;
7440: }
7441:
1.484.2.19 raeburn 7442: function toggleMap(caller) {
1.484.2.13 raeburn 7443: var disp = 'none';
1.484.2.19 raeburn 7444: if (document.getElementById('importmapform')) {
7445: if (caller == 'map') {
7446: var curr = document.getElementById('importmapform').style.display;
7447: if (curr == 'none') {
7448: disp='block';
7449: }
1.484.2.12 raeburn 7450: }
1.484.2.19 raeburn 7451: document.getElementById('importmapform').style.display=disp;
7452: resize_scrollbox('contentscroll','1','1');
1.484.2.12 raeburn 7453: }
1.484.2.19 raeburn 7454: return;
1.329 droeschl 7455: }
7456:
1.484.2.12 raeburn 7457: function makeims(imsform) {
7458: if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
1.484.2.61 raeburn 7459: alert("$js_lt{'imsfile'}");
1.484.2.12 raeburn 7460: return;
7461: }
7462: if (imsform.source.selectedIndex == 0) {
1.484.2.61 raeburn 7463: alert("$js_lt{'imscms'}");
1.484.2.12 raeburn 7464: return;
7465: }
7466: newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
7467: imsform.submit();
7468: }
7469:
1.478 raeburn 7470: function updatePick(targetform,index,caller) {
1.484.2.29 raeburn 7471: var pickitem;
7472: var picknumitem;
7473: var picknumtext;
7474: if (index == 'all') {
7475: pickitem = document.getElementById('randompickall');
7476: picknumitem = document.getElementById('rpicknumall');
7477: picknumtext = document.getElementById('rpicktextall');
7478: } else {
7479: pickitem = document.getElementById('randompick_'+index);
7480: picknumitem = document.getElementById('rpicknum_'+index);
7481: picknumtext = document.getElementById('randompicknum_'+index);
7482: }
1.478 raeburn 7483: if (pickitem.checked) {
1.484.2.61 raeburn 7484: var picknum=prompt('$js_lt{"rpck"}',picknumitem.value);
1.478 raeburn 7485: if (picknum == '' || picknum == null) {
7486: if (caller == 'check') {
7487: pickitem.checked=false;
1.484.2.29 raeburn 7488: if (index == 'all') {
7489: picknumtext.innerHTML = '';
7490: if (caller == 'link') {
7491: propagateState(targetform,'rpicknum');
7492: }
7493: } else {
1.484.2.30 raeburn 7494: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 7495: }
1.478 raeburn 7496: }
7497: } else {
7498: picknum.toString();
7499: var regexdigit=/^\\d+\$/;
7500: if (regexdigit.test(picknum)) {
7501: picknumitem.value = picknum;
1.484.2.29 raeburn 7502: if (index == 'all') {
1.484.2.30 raeburn 7503: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.cumulativesettings,\\'all\\',\\'link\\');">'+picknum+'</a>';
1.484.2.29 raeburn 7504: if (caller == 'link') {
7505: propagateState(targetform,'rpicknum');
7506: }
7507: } else {
7508: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.edit_randompick_'+index+',\\''+index+'\\',\\'link\\');">'+picknum+'</a>';
1.484.2.30 raeburn 7509: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 7510: }
1.478 raeburn 7511: } else {
7512: if (caller == 'check') {
1.484.2.29 raeburn 7513: if (index == 'all') {
7514: picknumtext.innerHTML = '';
7515: if (caller == 'link') {
7516: propagateState(targetform,'rpicknum');
7517: }
7518: } else {
7519: pickitem.checked=false;
1.484.2.30 raeburn 7520: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 7521: }
1.478 raeburn 7522: }
7523: return;
7524: }
7525: }
7526: } else {
1.484.2.29 raeburn 7527: picknumitem.value = '';
7528: picknumtext.innerHTML = '';
7529: if (index == 'all') {
7530: if (caller == 'link') {
7531: propagateState(targetform,'rpicknum');
7532: }
7533: } else {
1.484.2.30 raeburn 7534: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 7535: }
7536: }
7537: }
7538:
7539: function propagateState(form,param) {
7540: if (document.getElementById(param+'all')) {
7541: var setcheck = 0;
7542: var rpick = 0;
7543: if (param == 'rpicknum') {
7544: if (document.getElementById('randompickall')) {
7545: if (document.getElementById('randompickall').checked) {
7546: if (document.getElementById('rpicknumall')) {
7547: rpick = document.getElementById('rpicknumall').value;
7548: }
7549: }
7550: }
7551: } else {
7552: if (document.getElementById(param+'all').checked) {
7553: setcheck = 1;
7554: }
7555: }
1.484.2.30 raeburn 7556: var allidxlist;
7557: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
7558: if (document.getElementById('all'+param+'idx')) {
7559: allidxlist = document.getElementById('all'+param+'idx').value;
7560: }
7561: var actions = new Array ('remove','cut','copy');
7562: for (var i=0; i<actions.length; i++) {
7563: if (actions[i] != param) {
7564: if (document.getElementById(actions[i]+'all')) {
7565: document.getElementById(actions[i]+'all').checked = false;
7566: }
7567: }
7568: }
7569: }
1.484.2.29 raeburn 7570: if ((param == 'encrypturl') || (param == 'hiddenresource')) {
1.484.2.30 raeburn 7571: allidxlist = form.allidx.value;
7572: }
7573: if ((param == 'randompick') || (param == 'rpicknum') || (param == 'randomorder')) {
7574: allidxlist = form.allmapidx.value;
7575: }
7576: if ((allidxlist != '') && (allidxlist != null)) {
7577: var allidxs = allidxlist.split(',');
7578: if (allidxs.length > 1) {
7579: for (var i=0; i<allidxs.length; i++) {
7580: if (document.getElementById(param+'_'+allidxs[i])) {
7581: if (param == 'rpicknum') {
7582: if (document.getElementById('randompick_'+allidxs[i])) {
7583: if (document.getElementById('randompick_'+allidxs[i]).checked) {
7584: document.getElementById(param+'_'+allidxs[i]).value = rpick;
7585: if (rpick > 0) {
7586: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = ': <a href="javascript:updatePick(document.edit_randompick_'+allidxs[i]+',\\''+allidxs[i]+'\\',\\'link\\')">'+rpick+'</a>';
7587: } else {
7588: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
7589: }
7590: }
7591: }
7592: } else {
1.484.2.29 raeburn 7593: if (setcheck == 1) {
7594: document.getElementById(param+'_'+allidxs[i]).checked = true;
7595: } else {
7596: document.getElementById(param+'_'+allidxs[i]).checked = false;
1.484.2.30 raeburn 7597: if (param == 'randompick') {
7598: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
7599: }
1.484.2.29 raeburn 7600: }
7601: }
7602: }
7603: }
1.484.2.30 raeburn 7604: if (setcheck == 1) {
7605: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
7606: var actions = new Array('copy','cut','remove');
7607: for (var i=0; i<actions.length; i++) {
7608: var otheractions;
7609: var otheridxs;
7610: if (actions[i] === param) {
7611: continue;
7612: } else {
7613: if (document.getElementById('all'+actions[i]+'idx')) {
7614: otheractions = document.getElementById('all'+actions[i]+'idx').value;
7615: otheridxs = otheractions.split(',');
7616: if (otheridxs.length > 1) {
7617: for (var j=0; j<otheridxs.length; j++) {
7618: if (document.getElementById(actions[i]+'_'+otheridxs[j])) {
7619: document.getElementById(actions[i]+'_'+otheridxs[j]).checked = false;
7620: }
1.484.2.29 raeburn 7621: }
7622: }
7623: }
7624: }
1.484.2.30 raeburn 7625: }
1.484.2.29 raeburn 7626: }
7627: }
7628: }
7629: }
1.478 raeburn 7630: }
1.484.2.29 raeburn 7631: return;
7632: }
7633:
1.484.2.63 raeburn 7634: function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder,confirm_removal) {
1.484.2.67 raeburn 7635: var canedit = '$canedit';
7636: if (canedit == '') {
7637: alert("$js_lt{'edri'}");
7638: return;
7639: }
1.484.2.30 raeburn 7640: var dosettings;
7641: var doaction;
7642: var control = document.togglemultsettings;
7643: if (context == 'actions') {
7644: control = document.togglemultactions;
7645: doaction = 1;
7646: } else {
7647: dosettings = 1;
7648: }
7649: if (control) {
7650: if (control.showmultpick.length) {
7651: for (var i=0; i<control.showmultpick.length; i++) {
7652: if (control.showmultpick[i].checked) {
7653: if (control.showmultpick[i].value == 1) {
7654: if (context == 'settings') {
7655: dosettings = 0;
7656: } else {
7657: doaction = 0;
7658: }
7659: }
7660: }
7661: }
7662: }
7663: }
7664: if (context == 'settings') {
7665: if (dosettings == 1) {
7666: targetform.changeparms.value=param;
7667: targetform.submit();
7668: }
7669: }
7670: if (context == 'actions') {
7671: if (doaction == 1) {
7672: targetform.cmd.value=param+'_'+index;
7673: targetform.folderpath.value=folderpath;
7674: targetform.markcopy.value=idx+':'+param;
7675: targetform.copyfolder.value=folder+'.'+container;
7676: if (param == 'remove') {
1.484.2.63 raeburn 7677: var doremove = 0;
7678: if (skip_confirm) {
7679: if (confirm_removal) {
7680: if (confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'"$js_lt{"p_rmr2b"}')) {
7681: doremove = 1;
7682: }
7683: } else {
7684: doremove = 1;
7685: }
7686: } else {
7687: if (confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'" $js_lt{"p_rmr2b"}')) {
7688: doremove = 1;
7689: }
7690: }
7691: if (doremove) {
1.484.2.30 raeburn 7692: targetform.markcopy.value='';
7693: targetform.copyfolder.value='';
1.484.2.29 raeburn 7694: targetform.submit();
7695: }
7696: }
1.484.2.30 raeburn 7697: if (param == 'cut') {
1.484.2.61 raeburn 7698: 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 7699: targetform.submit();
7700: return;
7701: }
7702: }
7703: if (param == 'copy') {
7704: targetform.submit();
7705: return;
7706: }
7707: targetform.markcopy.value='';
7708: targetform.copyfolder.value='';
7709: targetform.cmd.value='';
7710: targetform.folderpath.value='';
7711: return;
7712: } else {
7713: if (document.getElementById(param+'_'+idx)) {
7714: item = document.getElementById(param+'_'+idx);
7715: if (item.type == 'checkbox') {
7716: if (item.checked) {
7717: item.checked = false;
7718: } else {
7719: item.checked = true;
7720: singleCheck(item,idx,param);
7721: }
7722: }
7723: }
7724: }
7725: }
7726: return;
7727: }
7728:
7729: function singleCheck(caller,idx,action) {
7730: actions = new Array('cut','copy','remove');
7731: if (caller.checked) {
7732: for (var i=0; i<actions.length; i++) {
7733: if (actions[i] != action) {
7734: if (document.getElementById(actions[i]+'_'+idx)) {
7735: if (document.getElementById(actions[i]+'_'+idx).checked) {
7736: document.getElementById(actions[i]+'_'+idx).checked = false;
7737: }
7738: }
7739: }
1.484.2.29 raeburn 7740: }
7741: }
7742: return;
1.478 raeburn 7743: }
7744:
1.334 muellerd 7745: function unselectInactive(nav) {
1.335 ehlerst 7746: currentNav = document.getElementById(nav);
7747: currentLis = currentNav.getElementsByTagName('LI');
7748: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 7749: if (currentLis[i].className == 'goback') {
7750: currentLis[i].className = 'goback';
7751: } else {
7752: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 7753: currentLis[i].className = 'right';
1.472 raeburn 7754: } else {
1.374 tempelho 7755: currentLis[i].className = 'i';
1.472 raeburn 7756: }
7757: }
1.335 ehlerst 7758: }
1.332 tempelho 7759: }
7760:
1.334 muellerd 7761: function hideAll(current, nav, data) {
1.335 ehlerst 7762: unselectInactive(nav);
1.484.2.43 raeburn 7763: if (current) {
7764: if (current.className == 'right'){
1.374 tempelho 7765: current.className = 'right active'
1.484.2.43 raeburn 7766: } else {
1.374 tempelho 7767: current.className = 'active';
1.484.2.43 raeburn 7768: }
1.374 tempelho 7769: }
1.335 ehlerst 7770: currentData = document.getElementById(data);
7771: currentDivs = currentData.getElementsByTagName('DIV');
7772: for (i = 0; i < currentDivs.length; i++) {
7773: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 7774: currentDivs[i].style.display = 'none';
1.330 tempelho 7775: }
7776: }
1.335 ehlerst 7777: }
1.330 tempelho 7778:
1.374 tempelho 7779: function openTabs(pageId) {
7780: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 7781: if(tabnav.length > 2 ){
1.389 tempelho 7782: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 7783: currentLis = currentNav.getElementsByTagName('LI');
7784: for(i = 0; i< currentLis.length; i++){
7785: if(currentLis[i].className == 'active') {
1.375 tempelho 7786: funcString = currentLis[i].onclick.toString();
7787: tab = funcString.split('"');
1.420 onken 7788: if(tab.length < 2) {
7789: tab = funcString.split("'");
7790: }
1.375 tempelho 7791: currentData = document.getElementById(tab[1]);
7792: currentData.style.display = 'block';
1.374 tempelho 7793: }
7794: }
7795: }
7796: }
7797:
1.334 muellerd 7798: function showPage(current, pageId, nav, data) {
1.484.2.43 raeburn 7799: currstate = current.className;
1.334 muellerd 7800: hideAll(current, nav, data);
1.375 tempelho 7801: openTabs(pageId);
1.334 muellerd 7802: unselectInactive(nav);
1.484.2.43 raeburn 7803: if ((currstate == 'active') || (currstate == 'right active')) {
7804: if (currstate == 'active') {
7805: current.className = '';
7806: } else {
7807: current.className = 'right';
7808: }
7809: activeTab = '';
7810: toggleUpload();
7811: toggleMap();
7812: resize_scrollbox('contentscroll','1','0');
7813: return;
7814: } else {
7815: current.className = 'active';
7816: }
1.330 tempelho 7817: currentData = document.getElementById(pageId);
7818: currentData.style.display = 'block';
1.458 raeburn 7819: activeTab = pageId;
1.484.2.12 raeburn 7820: toggleUpload();
1.484.2.14 raeburn 7821: toggleMap();
1.433 raeburn 7822: if (nav == 'mainnav') {
7823: var storedpath = "$docs_folderpath";
1.434 raeburn 7824: var storedpage = "$main_container_page";
1.433 raeburn 7825: var reg = new RegExp("^supplemental");
7826: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 7827: if (storedpage == 1) {
7828: document.simpleedit.folderpath.value = '';
7829: document.uploaddocument.folderpath.value = '';
7830: } else {
7831: if (reg.test(storedpath)) {
7832: document.simpleedit.folderpath.value = '$toplevelmain';
7833: document.uploaddocument.folderpath.value = '$toplevelmain';
7834: document.newext.folderpath.value = '$toplevelmain';
7835: } else {
7836: document.simpleedit.folderpath.value = storedpath;
7837: document.uploaddocument.folderpath.value = storedpath;
7838: document.newext.folderpath.value = storedpath;
7839: }
1.433 raeburn 7840: }
7841: } else {
1.434 raeburn 7842: if (reg.test(storedpath)) {
7843: document.simpleedit.folderpath.value = storedpath;
7844: document.supuploaddocument.folderpath.value = storedpath;
7845: document.supnewext.folderpath.value = storedpath;
7846: } else {
1.433 raeburn 7847: document.simpleedit.folderpath.value = '$toplevelsupp';
7848: document.supuploaddocument.folderpath.value = '$toplevelsupp';
7849: document.supnewext.folderpath.value = '$toplevelsupp';
7850: }
7851: }
7852: }
1.484.2.3 raeburn 7853: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 7854: return false;
7855: }
1.329 droeschl 7856:
1.472 raeburn 7857: function toContents(jumpto) {
7858: var newurl = '$backtourl';
1.484.2.21 raeburn 7859: if ((newurl == '/adm/navmaps') && (jumpto != '')) {
1.472 raeburn 7860: newurl = newurl+'?postdata='+jumpto;
7861: }
7862: location.href=newurl;
7863: }
7864:
1.484.2.30 raeburn 7865: function togglePick(caller,value) {
7866: var disp = 'none';
7867: if (document.getElementById('multi'+caller)) {
7868: var curr = document.getElementById('multi'+caller).style.display;
7869: if (value == 1) {
7870: disp='block';
7871: }
7872: if (curr == disp) {
7873: return;
7874: }
7875: document.getElementById('multi'+caller).style.display=disp;
7876: if (value == 1) {
1.484.2.61 raeburn 7877: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.484.2.30 raeburn 7878: } else {
7879: document.getElementById('more'+caller).innerHTML = '';
7880: }
7881: if (caller == 'actions') {
7882: setClass(value);
7883: setBoxes(value);
7884: }
7885: }
7886: var showButton = multiSettings();
7887: if (showButton != 1) {
7888: showButton = multiActions();
7889: }
7890: if (document.getElementById('multisave')) {
7891: if (showButton == 1) {
7892: document.getElementById('multisave').style.display='block';
7893: } else {
7894: document.getElementById('multisave').style.display='none';
7895: }
7896: }
7897: resize_scrollbox('contentscroll','1','1');
7898: return;
7899: }
7900:
7901: function toggleCheckUncheck(caller,more) {
7902: if (more == 1) {
1.484.2.61 raeburn 7903: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',0);" style="text-decoration:none;">$js_lt{'less'}</a>';
1.484.2.30 raeburn 7904: document.getElementById('allfields'+caller).style.display='block';
7905: } else {
1.484.2.61 raeburn 7906: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.484.2.30 raeburn 7907: document.getElementById('allfields'+caller).style.display='none';
7908: }
7909: resize_scrollbox('contentscroll','1','1');
7910: }
7911:
7912: function multiSettings() {
7913: var inuse = 0;
7914: var settingsform = document.togglemultsettings;
7915: if (settingsform.showmultpick.length > 1) {
7916: for (var i=0; i<settingsform.showmultpick.length; i++) {
7917: if (settingsform.showmultpick[i].checked) {
7918: if (settingsform.showmultpick[i].value == 1) {
7919: inuse = 1;
7920: }
7921: }
7922: }
7923: }
7924: return inuse;
7925: }
7926:
7927: function multiActions() {
7928: var inuse = 0;
7929: var actionsform = document.togglemultactions;
7930: if (actionsform.showmultpick.length > 1) {
7931: for (var i=0; i<actionsform.showmultpick.length; i++) {
7932: if (actionsform.showmultpick[i].checked) {
7933: if (actionsform.showmultpick[i].value == 1) {
7934: inuse = 1;
7935: }
7936: }
7937: }
7938: }
7939: return inuse;
7940: }
7941:
7942: function checkSubmits() {
7943: var numchanges = 0;
7944: var form = document.saveactions;
7945: var doactions = multiActions();
7946: var cutwarnings = 0;
7947: var remwarnings = 0;
1.484.2.63 raeburn 7948: var removalinfo = 0;
1.484.2.30 raeburn 7949: if (doactions == 1) {
7950: var remidxlist = document.cumulativeactions.allremoveidx.value;
7951: if ((remidxlist != '') && (remidxlist != null)) {
7952: var remidxs = remidxlist.split(',');
7953: for (var i=0; i<remidxs.length; i++) {
7954: if (document.getElementById('remove_'+remidxs[i])) {
7955: if (document.getElementById('remove_'+remidxs[i]).checked) {
7956: form.multiremove.value += remidxs[i]+',';
7957: numchanges ++;
7958: if (document.getElementById('skip_remove_'+remidxs[i])) {
7959: if (document.getElementById('skip_remove_'+remidxs[i]).value == 0) {
7960: remwarnings ++;
7961: }
7962: }
1.484.2.63 raeburn 7963: if (document.getElementById('confirm_removal_'+remidxs[i])) {
7964: if (document.getElementById('confirm_removal_'+remidxs[i]).value == 1) {
7965: removalinfo ++;
7966: }
7967: }
1.484.2.30 raeburn 7968: }
7969: }
7970: }
7971: }
7972: var cutidxlist = document.cumulativeactions.allcutidx.value;
7973: if ((cutidxlist != '') && (cutidxlist != null)) {
7974: var cutidxs = cutidxlist.split(',');
7975: for (var i=0; i<cutidxs.length; i++) {
7976: if (document.getElementById('cut_'+cutidxs[i])) {
7977: if (document.getElementById('cut_'+cutidxs[i]).checked == true) {
7978: form.multicut.value += cutidxs[i]+',';
7979: numchanges ++;
7980: if (document.getElementById('skip_cut_'+cutidxs[i])) {
7981: if (document.getElementById('skip_cut_'+cutidxs[i]).value == 0) {
7982: cutwarnings ++;
7983: }
7984: }
7985: }
7986: }
7987: }
7988: }
7989: var copyidxlist = document.cumulativeactions.allcopyidx.value;
7990: if ((copyidxlist != '') && (copyidxlist != null)) {
7991: var copyidxs = copyidxlist.split(',');
7992: for (var i=0; i<copyidxs.length; i++) {
7993: if (document.getElementById('copy_'+copyidxs[i])) {
7994: if (document.getElementById('copy_'+copyidxs[i]).checked) {
7995: form.multicopy.value += copyidxs[i]+',';
7996: numchanges ++;
7997: }
7998: }
7999: }
8000: }
8001: if (numchanges > 0) {
8002: form.multichange.value = numchanges;
8003: }
8004: }
8005: var dosettings = multiSettings();
8006: var haschanges = 0;
8007: if (dosettings == 1) {
8008: form.allencrypturl.value = '';
8009: form.allhiddenresource.value = '';
8010: form.changeparms.value = 'all';
8011: var patt=new RegExp(",\$");
8012: var allidxlist = document.cumulativesettings.allidx.value;
8013: if ((allidxlist != '') && (allidxlist != null)) {
8014: var allidxs = allidxlist.split(',');
8015: if (allidxs.length > 1) {
8016: for (var i=0; i<allidxs.length; i++) {
8017: if (document.getElementById('hiddenresource_'+allidxs[i])) {
8018: if (document.getElementById('hiddenresource_'+allidxs[i]).checked) {
8019: form.allhiddenresource.value += allidxs[i]+',';
8020: }
8021: }
8022: if (document.getElementById('encrypturl_'+allidxs[i])) {
8023: if (document.getElementById('encrypturl_'+allidxs[i]).checked) {
8024: form.allencrypturl.value += allidxs[i]+',';
8025: }
1.484.2.29 raeburn 8026: }
8027: }
1.484.2.30 raeburn 8028: form.allhiddenresource.value = form.allhiddenresource.value.replace(patt,"");
8029: form.allencrypturl.value = form.allencrypturl.value.replace(patt,"");
8030: }
8031: }
8032: form.allrandompick.value = '';
8033: form.allrandomorder.value = '';
8034: var allmapidxlist = document.cumulativesettings.allmapidx.value;
8035: if ((allmapidxlist != '') && (allmapidxlist != null)) {
8036: var allmapidxs = allmapidxlist.split(',');
8037: for (var i=0; i<allmapidxs.length; i++) {
8038: var randompick = document.getElementById('randompick_'+allmapidxs[i]);
8039: var rpicknum = document.getElementById('rpicknum_'+allmapidxs[i]);
8040: var randorder = document.getElementById('randomorder_'+allmapidxs[i]);
8041: if ((randompick.checked) && (rpicknum.value != '')) {
8042: form.allrandompick.value += allmapidxs[i]+':'+rpicknum.value+',';
8043: }
8044: if (randorder.checked) {
8045: form.allrandomorder.value += allmapidxs[i]+',';
8046: }
8047: }
8048: form.allrandompick.value = form.allrandompick.value.replace(patt,"");
8049: form.allrandomorder.value = form.allrandomorder.value.replace(patt,"");
8050: }
8051: if (document.cumulativesettings.currhiddenresource.value != form.allhiddenresource.value) {
8052: haschanges = 1;
8053: }
8054: if (document.cumulativesettings.currencrypturl.value != form.allencrypturl.value) {
8055: haschanges = 1;
8056: }
8057: if (document.cumulativesettings.currrandomorder.value != form.allrandomorder.value) {
8058: haschanges = 1;
8059: }
8060: if (document.cumulativesettings.currrandompick.value != form.allrandompick.value) {
8061: haschanges = 1;
8062: }
8063: }
8064: if (doactions == 1) {
8065: if (numchanges > 0) {
1.484.2.63 raeburn 8066: if ((cutwarnings > 0) || (remwarnings > 0) || (removalinfo > 0)) {
1.484.2.30 raeburn 8067: if (remwarnings > 0) {
1.484.2.61 raeburn 8068: if (!confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr3a"} '+remwarnings+' $js_lt{"p_rmr3b"}')) {
1.484.2.30 raeburn 8069: return false;
8070: }
8071: }
1.484.2.63 raeburn 8072: if (removalinfo > 0) {
8073: if (!confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr3a"} '+removalinfo+' $js_lt{"p_rmr3b"}')) {
8074: return false;
8075: }
8076: }
1.484.2.30 raeburn 8077: if (cutwarnings > 0) {
1.484.2.61 raeburn 8078: 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 8079: return false;
1.484.2.29 raeburn 8080: }
8081: }
8082: }
1.484.2.30 raeburn 8083: form.submit();
8084: return true;
8085: }
8086: }
8087: if (dosettings == 1) {
8088: if (haschanges == 1) {
8089: form.submit();
8090: return true;
1.484.2.29 raeburn 8091: }
8092: }
1.484.2.30 raeburn 8093: if ((dosettings == 1) && (doactions == 1)) {
1.484.2.61 raeburn 8094: alert("$js_lt{'noor'}");
1.484.2.30 raeburn 8095: } else {
8096: if (dosettings == 1) {
1.484.2.61 raeburn 8097: alert("$js_lt{'noch'}");
1.484.2.30 raeburn 8098: } else {
1.484.2.61 raeburn 8099: alert("$js_lt{'noac'}");
1.484.2.30 raeburn 8100: }
8101: }
8102: return false;
8103: }
8104:
8105: function setClass(value) {
8106: var cutclass = 'LC_docs_cut';
8107: var copyclass = 'LC_docs_copy';
8108: var removeclass = 'LC_docs_remove';
8109: var cutreg = new RegExp("\\\\b"+cutclass+"\\\\b");
8110: var copyreg = new RegExp("\\\\b"+copyclass+"\\\\b");
8111: var removereg = new RegExp("\\\\"+removeclass+"\\\\b");
8112: var links = document.getElementsByTagName('a');
8113: for (var i=0; i<links.length; i++) {
8114: var classes = links[i].className;
8115: if (cutreg.test(classes)) {
8116: links[i].className = cutclass;
8117: if (value == 1) {
8118: links[i].className += " LC_menubuttons_link";
1.484.2.29 raeburn 8119: }
1.484.2.30 raeburn 8120: } else {
8121: if (copyreg.test(classes)) {
8122: links[i].className = copyclass;
8123: if (value == 1) {
8124: links[i].className += " LC_menubuttons_link";
8125: }
8126: } else {
8127: if (removereg.test(classes)) {
8128: links[i].className = removeclass;
8129: if (value == 1) {
8130: links[i].className += " LC_menubuttons_link";
8131: }
8132: }
1.484.2.29 raeburn 8133: }
8134: }
8135: }
1.484.2.30 raeburn 8136: return;
1.484.2.29 raeburn 8137: }
8138:
1.484.2.30 raeburn 8139: function setBoxes(value) {
8140: var remidxlist = document.cumulativeactions.allremoveidx.value;
8141: if ((remidxlist != '') && (remidxlist != null)) {
8142: var remidxs = remidxlist.split(',');
8143: for (var i=0; i<remidxs.length; i++) {
8144: if (document.getElementById('remove_'+remidxs[i])) {
8145: var item = document.getElementById('remove_'+remidxs[i]);
8146: if (value == 1) {
8147: item.className = 'LC_docs_remove';
8148: } else {
8149: item.className = 'LC_hidden';
8150: }
8151: }
1.484.2.29 raeburn 8152: }
8153: }
1.484.2.30 raeburn 8154: var cutidxlist = document.cumulativeactions.allcutidx.value;
8155: if ((cutidxlist != '') && (cutidxlist != null)) {
8156: var cutidxs = cutidxlist.split(',');
8157: for (var i=0; i<cutidxs.length; i++) {
8158: if (document.getElementById('cut_'+cutidxs[i])) {
8159: var item = document.getElementById('cut_'+cutidxs[i]);
8160: if (value == 1) {
8161: item.className = 'LC_docs_cut';
8162: } else {
8163: item.className = 'LC_hidden';
8164: }
8165: }
8166: }
8167: }
8168: var copyidxlist = document.cumulativeactions.allcopyidx.value;
8169: if ((copyidxlist != '') && (copyidxlist != null)) {
8170: var copyidxs = copyidxlist.split(',');
8171: for (var i=0; i<copyidxs.length; i++) {
8172: if (document.getElementById('copy_'+copyidxs[i])) {
8173: var item = document.getElementById('copy_'+copyidxs[i]);
8174: if (value == 1) {
8175: item.className = 'LC_docs_copy';
8176: } else {
8177: item.className = 'LC_hidden';
8178: }
8179: }
1.484.2.29 raeburn 8180: }
8181: }
8182: return;
8183: }
8184:
1.484.2.67 raeburn 8185: ENDSCRIPT
1.329 droeschl 8186: }
1.457 raeburn 8187:
1.483 raeburn 8188: sub history_tab_js {
8189: return <<"ENDHIST";
8190: function toggleHistoryDisp(choice) {
8191: document.docslogform.docslog.value = choice;
8192: document.docslogform.submit();
8193: return;
8194: }
8195:
8196: ENDHIST
8197: }
8198:
1.484 raeburn 8199: sub inject_data_js {
8200: return <<ENDINJECT;
8201:
8202: function injectData(current, hiddenField, name, value) {
8203: currentElement = document.getElementById(hiddenField);
8204: currentElement.name = name;
8205: currentElement.value = value;
8206: current.submit();
8207: }
8208:
8209: ENDINJECT
8210: }
8211:
8212: sub dump_switchserver_js {
8213: my @hosts = @_;
1.484.2.61 raeburn 8214: my %js_lt = &Apache::lonlocal::texthash(
1.484.2.46 raeburn 8215: dump => 'Copying content to Authoring Space requires switching server.',
1.484 raeburn 8216: swit => 'Switch server?',
1.484.2.61 raeburn 8217: );
8218: my %html_js_lt = &Apache::lonlocal::texthash(
8219: swit => 'Switch server?',
1.484.2.43 raeburn 8220: duco => 'Copying Content to Authoring Space',
1.484 raeburn 8221: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
8222: chos => 'Choose server',
8223: );
1.484.2.61 raeburn 8224: &js_escape(\%js_lt);
8225: &html_escape(\%html_js_lt);
8226: &js_escape(\%html_js_lt);
1.484 raeburn 8227: my $role = $env{'request.role'};
8228: my $js = <<"ENDSWJS";
8229: <script type="text/javascript">
8230: function write_switchserver() {
8231: var server;
8232: if (document.setserver.posshosts.length > 0) {
8233: for (var i=0; i<document.setserver.posshosts.length; i++) {
8234: if (document.setserver.posshosts[i].checked) {
8235: server = document.setserver.posshosts[i].value;
8236: }
8237: }
8238: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
8239: }
8240: window.close();
8241: }
8242: </script>
8243:
8244: ENDSWJS
8245:
8246: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
8247: {'only_body' => 1,
8248: 'js_ready' => 1,});
8249: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
8250:
8251: my $hostpicker;
8252: my $count = 0;
8253: foreach my $host (sort(@hosts)) {
8254: my $checked;
8255: if ($count == 0) {
8256: $checked = ' checked="checked"';
8257: }
8258: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
8259: $host.'"'.$checked.' />'.$host.'</label> ';
8260: $count++;
8261: }
8262:
8263: return <<"ENDSWITCHJS";
8264:
8265: function dump_needs_switchserver(url) {
8266: if (url!='' && url!= null) {
1.484.2.61 raeburn 8267: if (confirm("$js_lt{'dump'}\\n$js_lt{'swit'}")) {
1.484 raeburn 8268: go(url);
8269: }
8270: }
8271: return;
8272: }
8273:
8274: function choose_switchserver_window() {
8275: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
8276: newWindow.document.open();
8277: newWindow.document.writeln('$startpage');
1.484.2.61 raeburn 8278: newWindow.document.write('<h3>$html_js_lt{'duco'}<\\/h3>\\n'+
8279: '<p>$html_js_lt{'yone'}<\\/p>\\n'+
8280: '<div class="LC_left_float"><fieldset><legend>$html_js_lt{'chos'}<\\/legend>\\n'+
1.484 raeburn 8281: '<form name="setserver" method="post" action="" \\/>\\n'+
8282: '$hostpicker\\n'+
8283: '<br \\/><br \\/>\\n'+
1.484.2.61 raeburn 8284: '<input type="button" name="makeswitch" value="$html_js_lt{'swit'}" '+
1.484 raeburn 8285: 'onclick="write_switchserver();" \\/>\\n'+
8286: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
8287: newWindow.document.writeln('$endpage');
8288: newWindow.document.close();
8289: newWindow.focus();
8290: }
8291:
8292: ENDSWITCHJS
8293: }
8294:
8295: sub makedocslogform {
8296: my ($formelems,$docslog) = @_;
8297: return <<"LOGSFORM";
8298: <form action="/adm/coursedocs" method="post" name="docslogform">
8299: <input type="hidden" name="docslog" value="$docslog" />
8300: $formelems
8301: </form>
8302: LOGSFORM
8303: }
8304:
8305: sub makesimpleeditform {
8306: my ($formelems) = @_;
8307: return <<"SIMPFORM";
8308: <form name="simpleedit" method="post" action="/adm/coursedocs">
8309: <input type="hidden" name="importdetail" value="" />
8310: $formelems
8311: </form>
8312: SIMPFORM
8313: }
8314:
1.329 droeschl 8315: 1;
8316: __END__
8317:
8318:
8319: =head1 NAME
8320:
8321: Apache::londocs.pm
8322:
8323: =head1 SYNOPSIS
8324:
8325: This is part of the LearningOnline Network with CAPA project
8326: described at http://www.lon-capa.org.
8327:
8328: =head1 SUBROUTINES
8329:
8330: =over
8331:
8332: =item %help=()
8333:
8334: Available help topics
8335:
8336: =item mapread()
8337:
1.344 bisitz 8338: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 8339: @order and @resources, determines status
8340: sets @order - pointer to resources in right order
8341: sets @resources - array with the resources with correct idx
8342:
8343: =item authorhosts()
8344:
8345: Return hash with valid author names
8346:
8347: =item clean()
8348:
8349: =item dumpcourse()
8350:
8351: Actually dump course
8352:
8353: =item group_import()
8354:
8355: Imports the given (name, url) resources into the course
8356: coursenum, coursedom, and folder must precede the list
8357:
8358: =item breadcrumbs()
8359:
8360: =item log_docs()
8361:
8362: =item docs_change_log()
8363:
8364: =item update_paste_buffer()
8365:
8366: =item print_paste_buffer()
8367:
8368: =item do_paste_from_buffer()
8369:
1.484.2.30 raeburn 8370: =item do_buffer_empty()
8371:
8372: =item clear_from_buffer()
8373:
1.484.2.7 raeburn 8374: =item get_newmap_url()
8375:
8376: =item dbcopy()
8377:
8378: =item uniqueness_check()
8379:
8380: =item contained_map_check()
8381:
8382: =item url_paste_fixups()
8383:
8384: =item apply_fixups()
8385:
8386: =item copy_dependencies()
8387:
1.329 droeschl 8388: =item update_parameter()
8389:
8390: =item handle_edit_cmd()
8391:
8392: =item editor()
8393:
8394: =item process_file_upload()
8395:
8396: =item process_secondary_uploads()
8397:
8398: =item is_supplemental_title()
8399:
8400: =item entryline()
8401:
8402: =item tiehash()
8403:
8404: =item untiehash()
8405:
8406: =item checkonthis()
8407:
8408: check on this
8409:
8410: =item verifycontent()
8411:
8412: Verify Content
8413:
1.484.2.78 raeburn 8414: =item devalidateversioncache()
8415:
8416: =item checkversions()
1.329 droeschl 8417:
8418: Check Versions
8419:
8420: =item mark_hash_old()
8421:
8422: =item is_hash_old()
8423:
8424: =item changewarning()
8425:
8426: =item init_breadcrumbs()
8427:
8428: Breadcrumbs for special functions
8429:
1.484 raeburn 8430: =item create_list_elements()
8431:
8432: =item create_form_ul()
8433:
8434: =item startContentScreen()
8435:
8436: =item endContentScreen()
8437:
8438: =item supplemental_base()
8439:
8440: =item embedded_form_elems()
8441:
8442: =item embedded_destination()
8443:
8444: =item return_to_editor()
8445:
8446: =item decompression_info()
8447:
8448: =item decompression_phase_one()
8449:
8450: =item decompression_phase_two()
8451:
8452: =item remove_archive()
8453:
8454: =item generate_admin_menu()
8455:
8456: =item generate_edit_table()
8457:
8458: =item editing_js()
8459:
8460: =item history_tab_js()
8461:
8462: =item inject_data_js()
8463:
8464: =item dump_switchserver_js()
8465:
1.484.2.3 raeburn 8466: =item resize_scrollbox_js()
1.484 raeburn 8467:
8468: =item makedocslogform()
8469:
1.484.2.3 raeburn 8470: =item makesimpleeditform()
8471:
1.329 droeschl 8472: =back
8473:
8474: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>