Annotation of loncom/interface/londocs.pm, revision 1.683
1.329 droeschl 1: # The LearningOnline Network
2: # Documents
3: #
1.683 ! raeburn 4: # $Id: londocs.pm,v 1.682 2022/10/19 00:03:10 raeburn Exp $
1.329 droeschl 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29: package Apache::londocs;
30:
31: use strict;
32: use Apache::Constants qw(:common :http);
33: use Apache::imsexport;
34: use Apache::lonnet;
35: use Apache::loncommon;
1.383 tempelho 36: use Apache::lonhtmlcommon;
1.329 droeschl 37: use LONCAPA::map();
38: use Apache::lonratedt();
39: use Apache::lonxml;
40: use Apache::lonclonecourse;
41: use Apache::lonnavmaps;
1.472 raeburn 42: use Apache::lonnavdisplay();
1.510 raeburn 43: use Apache::lonextresedit();
1.567 raeburn 44: use Apache::lontemplate();
45: use Apache::lonsimplepage();
1.606 raeburn 46: use Apache::lonhomework();
47: use Apache::lonpublisher();
1.645 raeburn 48: use Apache::lonparmset();
1.651 raeburn 49: use Apache::loncourserespicker();
1.329 droeschl 50: use HTML::Entities;
1.488 raeburn 51: use HTML::TokeParser;
1.329 droeschl 52: use GDBM_File;
1.578 raeburn 53: use File::MMagic;
1.606 raeburn 54: use File::Copy;
1.329 droeschl 55: use Apache::lonlocal;
56: use Cwd;
1.643 raeburn 57: use UUID::Tiny ':std';
1.329 droeschl 58: use LONCAPA qw(:DEFAULT :match);
59:
60: my $iconpath;
61:
62: my %hash;
63:
64: my $hashtied;
65: my %alreadyseen=();
66:
67: my $hadchanges;
1.557 raeburn 68: my $suppchanges;
1.329 droeschl 69:
70:
71: my %help=();
72:
73:
74: sub mapread {
75: my ($coursenum,$coursedom,$map)=@_;
76: return
77: &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
78: $map);
79: }
80:
81: sub storemap {
1.492 raeburn 82: my ($coursenum,$coursedom,$map,$contentchg)=@_;
83: my $report;
84: if (($contentchg) && ($map =~ /^default/)) {
85: $report = 1;
86: }
1.329 droeschl 87: my ($outtext,$errtext)=
88: &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.492 raeburn 89: $map,1,$report);
1.329 droeschl 90: if ($errtext) { return ($errtext,2); }
1.364 bisitz 91:
1.557 raeburn 92: if ($map =~ /^default/) {
93: $hadchanges=1;
1.682 raeburn 94: } elsif ($contentchg) {
1.557 raeburn 95: $suppchanges=1;
96: }
1.329 droeschl 97: return ($errtext,0);
98: }
99:
100:
101:
102: sub authorhosts {
103: my %outhash=();
104: my $home=0;
105: my $other=0;
106: foreach my $key (keys(%env)) {
107: if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
108: my $role=$1;
109: my $realm=$2;
110: my ($start,$end)=split(/\./,$env{$key});
111: if (($start) && ($start>time)) { next; }
112: if (($end) && (time>$end)) { next; }
113: my ($ca,$cd);
114: if ($1 eq 'au') {
115: $ca=$env{'user.name'};
116: $cd=$env{'user.domain'};
117: } else {
118: ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
119: }
120: my $allowed=0;
121: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
122: my @ids=&Apache::lonnet::current_machine_ids();
1.484 raeburn 123: foreach my $id (@ids) {
124: if ($id eq $myhome) {
125: $allowed=1;
126: last;
127: }
128: }
1.329 droeschl 129: if ($allowed) {
130: $home++;
1.484 raeburn 131: $outhash{'home_'.$ca.':'.$cd}=1;
1.329 droeschl 132: } else {
1.484 raeburn 133: $outhash{'otherhome_'.$ca.':'.$cd}=$myhome;
1.329 droeschl 134: $other++;
135: }
136: }
137: }
138: return ($home,$other,%outhash);
139: }
140:
141:
142: sub clean {
143: my ($title)=@_;
144: $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
1.344 bisitz 145: return $title;
1.329 droeschl 146: }
147:
1.617 raeburn 148: sub default_folderpath {
149: my ($coursenum,$coursedom,$navmapref) = @_;
150: return unless ($coursenum && $coursedom && ref($navmapref));
151: # Check if entire course is hidden and/or encrypted
152: my ($hiddenmap,$encryptmap,$folderpath,$hiddentop);
153: my $toplevel = "uploaded/$coursedom/$coursenum/default.sequence";
154: unless (ref($$navmapref)) {
155: $$navmapref = Apache::lonnavmaps::navmap->new();
156: }
157: if (ref($$navmapref)) {
158: if (lc($$navmapref->get_mapparam(undef,$toplevel,"0.hiddenresource")) eq 'yes') {
159: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
160: my @resources = $$navmapref->retrieveResources($toplevel,$filterFunc,1,1);
161: unless (@resources) {
162: $hiddenmap = 1;
163: unless ($env{'request.role.adv'}) {
164: $hiddentop = 1;
165: if ($env{'form.folder'}) {
166: undef($env{'form.folder'});
167: }
168: }
169: }
170: }
171: if (lc($$navmapref->get_mapparam(undef,$toplevel,"0.encrypturl")) eq 'yes') {
172: $encryptmap = 1;
173: }
174: }
175: unless ($hiddentop) {
176: $folderpath='default&'.&escape(&mt('Main Content')).
177: '::'.$hiddenmap.':'.$encryptmap.'::';
178: }
179: if (wantarray) {
180: return ($folderpath,$hiddentop);
181: } else {
182: return $folderpath;
183: }
184: }
1.329 droeschl 185:
1.677 raeburn 186: sub validate_folderpath {
187: my ($supplementalflag) = @_;
188: if ($env{'form.folderpath'} ne '') {
189: my @items = split(/\&/,$env{'form.folderpath'});
190: my $badpath;
191: for (my $i=0; $i<@items; $i++) {
192: my $odd = $i%2;
193: if (($odd) && (!$supplementalflag) && ($items[$i] !~ /^[^:]*:(|\d+):(|1):(|1):(|1):(|1)$/)) {
194: $badpath = 1;
195: } elsif ((!$odd) && ($items[$i] !~ /^(default|supplemental)(|_\d+)$/)) {
196: $badpath = 1;
197: }
198: last if ($badpath);
199: }
200: if ($badpath) {
201: delete($env{'form.folderpath'});
202: }
203: }
204: return;
205: }
206:
207: sub validate_suppath {
208: if ($env{'form.supppath'} ne '') {
209: my @items = split(/\&/,$env{'form.supppath'});
210: my $badpath;
211: for (my $i=0; $i<@items; $i++) {
212: my $odd = $i%2;
213: if ((!$odd) && ($items[$i] !~ /^supplemental(|_\d+)$/)) {
214: $badpath = 1;
215: }
216: last if ($badpath);
217: }
218: if ($badpath) {
219: delete($env{'form.supppath'});
220: }
221: }
222: return;
223: }
224:
1.329 droeschl 225: sub dumpcourse {
226: my ($r) = @_;
1.408 raeburn 227: my $crstype = &Apache::loncommon::course_type();
1.567 raeburn 228: my ($starthash,$js);
229: unless (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
230: $js = <<"ENDJS";
231: <script type="text/javascript">
232: // <![CDATA[
233:
234: function hide_searching() {
235: if (document.getElementById('searching')) {
236: document.getElementById('searching').style.display = 'none';
237: }
238: return;
239: }
240:
241: // ]]>
242: </script>
243: ENDJS
244: $starthash = {
245: add_entries => {'onload' => "hide_searching();"},
246: };
247: }
1.568 raeburn 248: $r->print(&Apache::loncommon::start_page('Copy '.$crstype.' Content to Authoring Space',$js,$starthash)."\n".
249: &Apache::lonhtmlcommon::breadcrumbs('Copy '.$crstype.' Content to Authoring Space')."\n");
1.484 raeburn 250: $r->print(&startContentScreen('tools'));
1.329 droeschl 251: my ($home,$other,%outhash)=&authorhosts();
1.484 raeburn 252: unless ($home) {
253: $r->print(&endContentScreen());
254: return '';
255: }
1.329 droeschl 256: my $origcrsid=$env{'request.course.id'};
257: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
258: if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
259: # Do the dumping
1.484 raeburn 260: unless ($outhash{'home_'.$env{'form.authorspace'}}) {
261: $r->print(&endContentScreen());
262: return '';
263: }
1.531 raeburn 264: my ($ca,$cd)=split(/\:/,$env{'form.authorspace'});
1.329 droeschl 265: $r->print('<h3>'.&mt('Copying Files').'</h3>');
266: my $title=$env{'form.authorfolder'};
267: $title=&clean($title);
1.567 raeburn 268: my ($navmap,$errormsg) =
269: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
270: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
271: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
272: my (%maps,%resources,%titles);
273: if (!ref($navmap)) {
274: $r->print($errormsg.
275: &endContentScreen());
276: return '';
277: } else {
278: &Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles,
279: 'dumpdocs',$cdom,$cnum);
1.329 droeschl 280: }
1.567 raeburn 281: my @todump = &Apache::loncommon::get_env_multiple('form.archive');
282: my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages,
283: %newcontent,%has_simpleprobs);
284: foreach my $item (sort {$a <=> $b} (@todump)) {
285: my $name = $env{'form.namefor_'.$item};
286: if ($resources{$item}) {
287: my ($map,$id,$res) = &Apache::lonnet::decode_symb($resources{$item});
288: if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) {
289: $tocopy{$1} = $name;
290: $display{$item} = $1;
291: $lookup{$1} = $item;
292: } elsif ($res eq 'lib/templates/simpleproblem.problem') {
293: $simpleproblems{$item} = {
294: symb => $resources{$item},
295: name => $name,
296: };
297: $display{$item} = 'simpleproblem_'.$name;
298: if ($map =~ m{^\Quploaded/$cdom/$cnum/\E(.+)$}) {
299: $has_simpleprobs{$1}{$id} = $item;
300: }
301: } elsif ($res =~ m{^adm/$match_domain/$match_username/(\d+)/smppg}) {
302: my $marker = $1;
303: my $db_name = &Apache::lonsimplepage::get_db_name($res,$marker,$cdom,$cnum);
304: $simplepages{$item} = {
305: res => $res,
306: title => $titles{$item},
307: db => $db_name,
308: marker => $marker,
309: symb => $resources{$item},
310: name => $name,
311: };
312: $display{$item} = '/'.$res;
313: }
314: } elsif ($maps{$item}) {
315: if ($maps{$item} =~ m{^\Quploaded/$cdom/$cnum/\E((?:default|supplemental)_\d+\.(?:sequence|page))$}) {
316: $tocopy{$1} = $name;
317: $display{$item} = $1;
318: $lookup{$1} = $item;
319: }
320: } else {
321: next;
322: }
323: }
1.329 droeschl 324: my $crs='/uploaded/'.$env{'request.course.id'}.'/';
325: $crs=~s/\_/\//g;
1.567 raeburn 326: my $mm = new File::MMagic;
327: my $prefix = "/uploaded/$cdom/$cnum/";
328: %replacehash = %tocopy;
329: foreach my $item (sort(keys(%simpleproblems))) {
330: my $content = &Apache::imsexport::simpleproblem($simpleproblems{$item}{'symb'});
331: $newcontent{$display{$item}} = $content;
332: }
333: my $gateway = Apache::lonhtmlgateway->new('web');
334: foreach my $item (sort(keys(%simplepages))) {
335: if (ref($simplepages{$item}) eq 'HASH') {
336: my $pagetitle = $simplepages{$item}{'title'};
337: my %fields = &Apache::lonnet::dump($simplepages{$item}{'db'},$cdom,$cnum);
338: my %contents;
339: foreach my $field (keys(%fields)) {
340: if ($field =~ /^(?:aaa|bbb|ccc)_(\w+)$/) {
341: my $name = $1;
342: my $msg = $fields{$field};
343: if ($name eq 'webreferences') {
344: if ($msg =~ m{^https?://}) {
345: $contents{$name} = '<a href="'.$msg.'"><tt>'.$msg.'</tt></a>';
346: }
347: } else {
348: $msg = &Encode::decode('utf8',$msg);
349: $msg = $gateway->process_outgoing_html($msg,1);
350: $contents{$name} = $msg;
351: }
352: } elsif ($field eq 'uploaded.photourl') {
353: my $marker = $simplepages{$item}{marker};
354: if ($fields{$field} =~ m{^\Q$prefix\E(simplepage/$marker/.+)$}) {
355: my $filepath = $1;
356: my ($relpath,$fname) = ($filepath =~ m{^(.+/)([^/]+)$});
357: if ($fname ne '') {
358: $fname=~s/\.(\w+)$//;
359: my $ext=$1;
360: $fname = &clean($fname);
361: $fname.='.'.$ext;
362: $contents{image} = '<img src="'.$relpath.$fname.'" alt="Image" />';
363: $replacehash{$filepath} = $relpath.$fname;
364: $deps{$item}{$filepath} = 1;
365: }
366: }
367: }
368: }
369: $replacehash{'/'.$simplepages{$item}{'res'}} = $simplepages{$item}{'name'};
370: $lookup{'/'.$simplepages{$item}{'res'}} = $item;
371: my $content = '
372: <html>
373: <head>
374: <title>'.$pagetitle.'</title>
375: </head>
376: <body bgcolor="#ffffff">';
377: if ($contents{title}) {
378: $content .= "\n".'<h2>'.$contents{title}.'</h2>';
379: }
380: if ($contents{image}) {
381: $content .= "\n".$contents{image};
382: }
383: if ($contents{content}) {
384: $content .= '
385: <div class="LC_Box">
1.577 bisitz 386: <h4 class="LC_hcell">'.&mt('Content').'</h4>'.
1.567 raeburn 387: $contents{content}.'
388: </div>';
389: }
390: if ($contents{webreferences}) {
391: $content .= '
392: <div class="LC_Box">
1.577 bisitz 393: <h4 class="LC_hcell">'.&mt('Web References').'</h4>'.
1.567 raeburn 394: $contents{webreferences}.'
395: </div>';
396: }
397: $content .= '
398: </body>
399: </html>
400: ';
401: $newcontent{'/'.$simplepages{$item}{res}} = $content;
402: }
403: }
404: foreach my $item (keys(%tocopy)) {
405: unless ($item=~/\.(sequence|page)$/) {
406: my $currurlpath = $prefix.$item;
407: my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath);
408: &recurse_html($mm,$prefix,$currdirpath,$currurlpath,$item,$lookup{$item},\%replacehash,\%deps);
409: }
410: }
411: foreach my $num (sort {$a <=> $b} (@todump)) {
412: my $src = $display{$num};
413: next if ($src eq '');
414: my @needcopy = ();
415: if ($replacehash{$src}) {
416: push(@needcopy,$src);
417: if (ref($deps{$num}) eq 'HASH') {
418: foreach my $dep (sort(keys(%{$deps{$num}}))) {
419: if ($replacehash{$dep}) {
420: push(@needcopy,$dep);
421: }
422: }
423: }
424: } elsif ($src =~ /^simpleproblem_/) {
425: push(@needcopy,$src);
426: }
427: next if (@needcopy == 0);
428: my ($result,$depresult);
429: for (my $i=0; $i<@needcopy; $i++) {
430: my $item = $needcopy[$i];
431: my $newfilename;
432: if ($simpleproblems{$num}) {
433: $newfilename=$title.'/'.$simpleproblems{$num}{'name'};
434: } else {
435: $newfilename=$title.'/'.$replacehash{$item};
436: }
437: $newfilename=~s/\.(\w+)$//;
438: my $ext=$1;
439: $newfilename=&clean($newfilename);
440: $newfilename.='.'.$ext;
441: my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$});
442: if ($newrelpath ne $replacehash{$item}) {
443: $replacehash{$item} = $newrelpath;
444: }
445: my @dirs=split(/\//,$newfilename);
446: my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
447: my $makepath=$path;
448: my $fail;
449: my $origin;
450: for (my $i=0;$i<$#dirs;$i++) {
451: $makepath.='/'.$dirs[$i];
452: unless (-e $makepath) {
453: unless(mkdir($makepath,0755)) {
454: $fail = &mt('Directory creation failed.');
455: }
456: }
457: }
458: if ($i == 0) {
459: $result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ';
460: } else {
461: $depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '.
462: '<span class="LC_fontsize_small" style="font-weight: bold;">'.
463: &mt('(dependency)').'</span>: ';
464: }
465: if (-e $path.'/'.$newfilename) {
466: $fail = &mt('Destination already exists -- not overwriting.');
467: } else {
468: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
469: if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) ||
470: ($item =~ /^simpleproblem_/)) {
471: print $fh $newcontent{$item};
472: } else {
473: my $fileloc = &Apache::lonnet::filelocation('',$prefix.$item);
474: if (-e $fileloc) {
475: if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
476: if ((($1 eq 'sequence') || ($1 eq 'page')) &&
477: (ref($has_simpleprobs{$item}) eq 'HASH')) {
478: my %changes = %{$has_simpleprobs{$item}};
479: my $content = &Apache::lonclonecourse::rewritefile(
480: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
481: (%replacehash,$crs => '')
482: );
483: my $updatedcontent = '';
484: my $parser = HTML::TokeParser->new(\$content);
485: $parser->attr_encoded(1);
486: while (my $token = $parser->get_token) {
487: if ($token->[0] eq 'S') {
488: if (($token->[1] eq 'resource') &&
489: ($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') &&
490: ($changes{$token->[2]->{'id'}})) {
491: my $id = $token->[2]->{'id'};
492: $updatedcontent .= '<'.$token->[1];
493: foreach my $attrib (@{$token->[3]}) {
494: next unless ($attrib =~ /^(src|type|title|id)$/);
495: if ($attrib eq 'src') {
496: my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/);
497: if ($file) {
498: $updatedcontent .= ' '.$attrib.'="'.$file.'"';
499: } else {
500: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
501: }
502: } else {
503: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
504: }
505: }
506: $updatedcontent .= ' />'."\n";
507: } else {
508: $updatedcontent .= $token->[4]."\n";
509: }
510: } else {
511: $updatedcontent .= $token->[2];
512: }
513: }
514: print $fh $updatedcontent;
515: } else {
516: print $fh &Apache::lonclonecourse::rewritefile(
517: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
518: (%replacehash,$crs => '')
519: );
520: }
521: } else {
522: print $fh
523: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
524: }
525: } else {
526: $fail = &mt('Source does not exist.');
527: }
528: }
529: $fh->close();
530: } else {
531: $fail = &mt('Could not write to destination.');
532: }
533: }
534: my $text;
535: if ($fail) {
536: $text = '<span class="LC_error">'.&mt('fail').(' 'x3).$fail.'</span>';
537: } else {
538: $text = '<span class="LC_success">'.&mt('ok').'</span>';
539: }
540: if ($i == 0) {
541: $result .= $text;
542: } else {
543: $depresult .= $text.'</li>';
544: }
545: }
546: $r->print($result);
547: if ($depresult) {
548: $r->print('<ul>'.$depresult.'</ul>');
549: }
550: }
551: } else {
552: my ($navmap,$errormsg) =
553: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
554: if (!ref($navmap)) {
555: $r->print($errormsg);
556: } else {
557: $r->print('<div id="searching">'.&mt('Searching ...').'</div>');
558: $r->rflush();
559: my ($preamble,$formname);
560: $formname = 'dumpdoc';
561: unless ($home==1) {
562: $preamble = '<div class="LC_left_float">'.
563: '<fieldset><legend>'.
564: &mt('Select the Authoring Space').
565: '</legend><select name="authorspace">';
1.329 droeschl 566: }
1.567 raeburn 567: my @orderspaces = ();
568: foreach my $key (sort(keys(%outhash))) {
569: if ($key=~/^home_(.+)$/) {
570: if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) {
571: unshift(@orderspaces,$1);
572: } else {
573: push(@orderspaces,$1);
574: }
575: }
576: }
1.569 raeburn 577: if ($home>1) {
578: $preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>';
579: }
1.567 raeburn 580: foreach my $user (@orderspaces) {
1.329 droeschl 581: if ($home==1) {
1.567 raeburn 582: $preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />';
1.329 droeschl 583: } else {
1.567 raeburn 584: $preamble .= '<option value="'.$user.'">'.$user.' - '.
585: &Apache::loncommon::plainname(split(/\:/,$user)).'</option>';
586: }
1.329 droeschl 587: }
1.567 raeburn 588: unless ($home==1) {
589: $preamble .= '</select></fieldset></div>'."\n";
1.329 droeschl 590: }
1.567 raeburn 591: my $title=$origcrsdata{'description'};
592: $title=~s/[\/\s]+/\_/gs;
1.329 droeschl 593: $title=&clean($title);
1.567 raeburn 594: $preamble .= '<div class="LC_left_float">'.
595: '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.
596: '<input type="text" size="50" name="authorfolder" value="'.
597: $title.'" />'.
598: '</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n";
599: my %uploadedfiles;
600: &tiehash();
601: foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
602: my ($ext)=($file=~/\.(\w+)$/);
603: # FIXME Check supplemental here
604: my $title=$hash{'title_'.$hash{
605: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
606: if (!$title) {
607: $title=$file;
608: } else {
609: $title=~s|/|_|g;
610: }
611: $title=~s/\.(\w+)$//;
612: $title=&clean($title);
613: $title.='.'.$ext;
614: # $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
615: $uploadedfiles{$file} = $title;
616: }
617: &untiehash();
618: $r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef,
619: undef,undef,$preamble,$home,\%uploadedfiles));
620: }
1.329 droeschl 621: }
1.484 raeburn 622: $r->print(&endContentScreen());
1.329 droeschl 623: }
624:
1.567 raeburn 625: sub recurse_html {
626: my ($mm,$prefix,$currdirpath,$currurlpath,$container,$item,$replacehash,$deps) = @_;
627: return unless ((ref($replacehash) eq 'HASH') && (ref($deps) eq 'HASH'));
628: my (%allfiles,%codebase);
629: if (&Apache::lonnet::extract_embedded_items($currdirpath,\%allfiles,\%codebase) eq 'ok') {
630: if (keys(%allfiles)) {
631: foreach my $dependency (keys(%allfiles)) {
632: next if (($dependency =~ m{^/(res|adm)/}) || ($dependency =~ m{^https?://}));
633: my ($depurl,$relfile,$newcontainer);
634: if ($dependency =~ m{^/}) {
635: if ($dependency =~ m{^\Q$currurlpath/\E(.+)$}) {
636: $relfile = $1;
637: if ($dependency =~ m{^\Q$prefix\E(.+)$}) {
638: $newcontainer = $1;
639: next if ($replacehash->{$newcontainer});
640: }
641: $depurl = $dependency;
642: } else {
643: next;
644: }
645: } else {
646: $relfile = $dependency;
647: $depurl = $currurlpath;
1.630 raeburn 648: $depurl =~ s{[^/]+$}{};
1.567 raeburn 649: $depurl .= $dependency;
1.630 raeburn 650: ($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$});
1.567 raeburn 651: }
652: next if ($relfile eq '');
653: my $newname = $replacehash->{$container};
654: $newname =~ s{[^/]+$}{};
655: $replacehash->{$newcontainer} = $newname.$relfile;
656: $deps->{$item}{$newcontainer} = 1;
657: my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$});
658: my $depfile = &Apache::lonnet::filelocation('',$depurl);
659: my $type = $mm->checktype_filename($depfile);
660: if ($type eq 'text/html') {
661: &recurse_html($mm,$prefix,$depfile,$newurlpath,$newcontainer,$item,$replacehash,$deps);
662: }
663: }
664: }
665: }
666: return;
667: }
668:
1.329 droeschl 669: sub group_import {
1.598 raeburn 670: my ($coursenum, $coursedom, $folder, $container, $caller, $ltitoolsref, @files) = @_;
1.529 raeburn 671: my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap,
672: %removeparam,$importuploaded,$fixuperrors);
673: $allmaps = {};
1.329 droeschl 674: while (@files) {
675: my ($name, $url, $residx) = @{ shift(@files) };
1.344 bisitz 676: if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
1.329 droeschl 677: && ($caller eq 'londocs')
678: && (!&Apache::lonnet::stat_file($url))) {
1.364 bisitz 679:
1.329 droeschl 680: my $errtext = '';
681: my $fatal = 0;
682: my $newmapstr = '<map>'."\n".
683: '<resource id="1" src="" type="start"></resource>'."\n".
684: '<link from="1" to="2" index="1"></link>'."\n".
685: '<resource id="2" src="" type="finish"></resource>'."\n".
686: '</map>';
687: $env{'form.output'}=$newmapstr;
688: my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
689: 'output',$1.$2);
1.534 raeburn 690: if ($result !~ m{^/uploaded/}) {
1.329 droeschl 691: $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
692: $fatal = 2;
693: }
694: if ($fatal) {
695: return ($errtext,$fatal);
696: }
697: }
698: if ($url) {
1.626 raeburn 699: if ($url =~ m{^(/adm/$coursedom/$coursenum/(\d+)/ext\.tool)\:?(.*)$}) {
1.598 raeburn 700: $url = $1;
701: my $marker = $2;
702: my $info = $3;
1.604 raeburn 703: my ($toolid,%toolhash,%toolsettings);
1.642 raeburn 704: my @extras = ('linktext','explanation','crslabel','crstitle','crsappend');
1.598 raeburn 705: my @toolinfo = split(/:/,$info);
706: if ($residx) {
1.604 raeburn 707: %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
1.598 raeburn 708: $toolid = $toolsettings{'id'};
709: } else {
1.604 raeburn 710: $toolid = shift(@toolinfo);
1.598 raeburn 711: }
712: $toolid =~ s/\D//g;
1.604 raeburn 713: ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'},
1.645 raeburn 714: $toolhash{'linktext'},$toolhash{'explanation'},$toolhash{'crslabel'},
715: $toolhash{'crstitle'},$toolhash{'crsappend'},$toolhash{'gradable'}) = @toolinfo;
1.624 raeburn 716: foreach my $item (@extras) {
717: $toolhash{$item} = &unescape($toolhash{$item});
718: }
1.645 raeburn 719: if ($folder =~ /^supplemental/) {
1.648 raeburn 720: delete($toolhash{'gradable'});
721: } else {
722: $toolhash{'gradable'} =~ s/\D+//g;
1.645 raeburn 723: }
1.598 raeburn 724: if (ref($ltitoolsref) eq 'HASH') {
725: if (ref($ltitoolsref->{$toolid}) eq 'HASH') {
1.643 raeburn 726: my @deleted;
1.598 raeburn 727: $toolhash{'id'} = $toolid;
1.628 raeburn 728: if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'tab') ||
729: ($toolhash{'target'} eq 'window')) {
1.604 raeburn 730: if ($toolhash{'target'} eq 'window') {
731: foreach my $item ('width','height') {
732: $toolhash{$item} =~ s/^\s+//;
733: $toolhash{$item} =~ s/\s+$//;
1.624 raeburn 734: if ($toolhash{$item} =~ /\D/) {
735: delete($toolhash{$item});
736: if ($residx) {
737: if ($toolsettings{$item}) {
738: push(@deleted,$item);
739: }
740: }
741: }
1.604 raeburn 742: }
743: }
744: } elsif ($residx) {
745: $toolhash{'target'} = $toolsettings{'target'};
746: if ($toolhash{'target'} eq 'window') {
1.630 raeburn 747: foreach my $item ('width','height') {
1.624 raeburn 748: $toolhash{$item} = $toolsettings{$item};
749: }
1.604 raeburn 750: }
751: } elsif (ref($ltitoolsref->{$toolid}->{'display'}) eq 'HASH') {
752: $toolhash{'target'} = $ltitoolsref->{$toolid}->{'display'}->{'target'};
753: if ($toolhash{'target'} eq 'window') {
754: $toolhash{'width'} = $ltitoolsref->{$toolid}->{'display'}->{'width'};
755: $toolhash{'height'} = $ltitoolsref->{$toolid}->{'display'}->{'height'};
756: }
757: }
1.598 raeburn 758: if ($toolhash{'target'} eq 'iframe') {
1.624 raeburn 759: foreach my $item ('width','height','linktext','explanation') {
760: delete($toolhash{$item});
761: if ($residx) {
762: if ($toolsettings{$item}) {
763: push(@deleted,$item);
764: }
1.604 raeburn 765: }
766: }
1.628 raeburn 767: } elsif ($toolhash{'target'} eq 'tab') {
768: foreach my $item ('width','height') {
769: delete($toolhash{$item});
770: if ($residx) {
771: if ($toolsettings{$item}) {
772: push(@deleted,$item);
773: }
774: }
775: }
1.604 raeburn 776: }
777: if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') {
1.624 raeburn 778: foreach my $item ('label','title','linktext','explanation') {
779: my $crsitem;
780: if (($item eq 'label') || ($item eq 'title')) {
781: $crsitem = 'crs'.$item;
782: } else {
783: $crsitem = $item;
784: }
1.604 raeburn 785: if ($ltitoolsref->{$toolid}->{'crsconf'}->{$item}) {
1.624 raeburn 786: $toolhash{$crsitem} =~ s/^\s+//;
787: $toolhash{$crsitem} =~ s/\s+$//;
788: if ($toolhash{$crsitem} eq '') {
789: delete($toolhash{$crsitem});
1.604 raeburn 790: }
791: } else {
1.624 raeburn 792: delete($toolhash{$crsitem});
1.604 raeburn 793: }
1.624 raeburn 794: if (($residx) && (exists($toolsettings{$crsitem}))) {
795: unless (exists($toolhash{$crsitem})) {
796: push(@deleted,$crsitem);
1.604 raeburn 797: }
798: }
1.598 raeburn 799: }
800: }
1.643 raeburn 801: if ($toolhash{'passback'}) {
802: my $gradesecret = UUID::Tiny::create_uuid_as_string(UUID_V4);
803: $toolhash{'gradesecret'} = $gradesecret;
804: $toolhash{'gradesecretdate'} = time;
805: }
806: if ($toolhash{'roster'}) {
807: my $rostersecret = UUID::Tiny::create_uuid_as_string(UUID_V4);
808: $toolhash{'rostersecret'} = $rostersecret;
809: $toolhash{'rostersecretdate'} = time;
810: }
1.645 raeburn 811: my $changegradable;
812: if (($residx) && ($folder =~ /^default/)) {
1.648 raeburn 813: if ($toolsettings{'gradable'}) {
814: unless (($toolhash{'gradable'}) || (defined($LONCAPA::map::zombies[$residx]))) {
1.645 raeburn 815: push(@deleted,'gradable');
816: $changegradable = 1;
817: }
1.648 raeburn 818: } elsif ($toolhash{'gradable'}) {
819: $changegradable = 1;
820: }
821: if (($caller eq 'londocs') && (defined($LONCAPA::map::zombies[$residx]))) {
1.645 raeburn 822: $changegradable = 1;
1.648 raeburn 823: if ($toolsettings{'gradable'}) {
824: $toolhash{'gradable'} = 1;
825: }
1.645 raeburn 826: }
827: }
1.598 raeburn 828: my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum);
1.604 raeburn 829: if ($putres eq 'ok') {
830: if (@deleted) {
831: &Apache::lonnet::del('exttool_'.$marker,\@deleted,$coursedom,$coursenum);
1.645 raeburn 832: }
833: if (($changegradable) && ($folder =~ /^default/)) {
834: my $val;
835: if ($toolhash{'gradable'}) {
836: $val = 'yes';
837: } else {
838: $val = 'no';
839: }
840: &LONCAPA::map::storeparameter($residx,'parameter_0_gradable',$val,
841: 'string_yesno');
842: &remember_parms($residx,'gradable','set',$val);
843: }
844: } else {
845: return (&mt('Failed to save update to external tool.'),1);
1.604 raeburn 846: }
1.598 raeburn 847: }
848: }
849: }
1.529 raeburn 850: if (($caller eq 'londocs') &&
851: ($folder =~ /^default/)) {
1.534 raeburn 852: if (($url =~ /\.(page|sequence)$/) && (!$donechk)) {
1.529 raeburn 853: my $chome = &Apache::lonnet::homeserver($coursenum,$coursedom);
854: my $cid = $coursedom.'_'.$coursenum;
855: $allmaps =
856: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
857: $chome,$cid);
858: $donechk = 1;
859: }
860: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) {
1.627 raeburn 861: &contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap,
862: \%removeparam,\%addedmaps,\%hierarchy,\%titles,$allmaps);
1.529 raeburn 863: $importuploaded = 1;
864: } elsif ($url =~ m{^/res/.+\.(page|sequence)$}) {
865: next if ($allmaps->{$url});
866: }
867: }
1.344 bisitz 868: if (!$residx
1.329 droeschl 869: || defined($LONCAPA::map::zombies[$residx])) {
870: $residx = &LONCAPA::map::getresidx($url,$residx);
871: push(@LONCAPA::map::order, $residx);
872: }
873: my $ext = 'false';
874: if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
1.534 raeburn 875: if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) {
876: my $filepath = $1;
1.675 raeburn 877: my $fname;
878: if ($name eq '') {
879: $name = &mt('Web Page');
1.534 raeburn 880: $fname = 'web';
881: } else {
1.675 raeburn 882: $fname = $name;
883: $fname=&Apache::lonnet::clean_filename($fname);
884: if ($fname eq '') {
885: $fname = 'web';
886: } elsif (length($fname) > 15) {
887: $fname = substr($fname,0,14);
888: }
1.534 raeburn 889: }
1.675 raeburn 890: my $title = &Apache::loncommon::cleanup_html($name);
1.534 raeburn 891: my $initialtext = &mt('Replace with your own content.');
892: my $newhtml = <<END;
1.545 raeburn 893: <html>
1.534 raeburn 894: <head>
1.675 raeburn 895: <title>$title</title>
1.534 raeburn 896: </head>
897: <body bgcolor="#ffffff">
898: $initialtext
899: </body>
900: </html>
901: END
902: $env{'form.output'}=$newhtml;
1.630 raeburn 903: my $result =
1.534 raeburn 904: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
905: 'output',
906: "$filepath/$residx/$fname.html");
907: if ($result =~ m{^/uploaded/}) {
908: $url = $result;
909: if ($filepath =~ /^supplemental/) {
910: $name = time.'___&&&___'.$env{'user.name'}.'___&&&___'.
911: $env{'user.domain'}.'___&&&___'.$name;
912: }
913: } else {
914: return (&mt('Failed to save new web page.'),1);
915: }
916: }
1.675 raeburn 917: $name = &LONCAPA::map::qtunescape($name);
1.538 raeburn 918: $url = &LONCAPA::map::qtunescape($url);
1.344 bisitz 919: $LONCAPA::map::resources[$residx] =
1.329 droeschl 920: join(':', ($name, $url, $ext, 'normal', 'res'));
921: }
922: }
1.529 raeburn 923: if ($importuploaded) {
924: my %import_errors;
925: my %updated = (
926: removefrommap => \%removefrommap,
927: removeparam => \%removeparam,
928: );
1.533 raeburn 929: my ($result,$msgsarray,$lockerror) =
930: &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
1.529 raeburn 931: if (keys(%import_errors) > 0) {
1.530 raeburn 932: $fixuperrors =
1.529 raeburn 933: '<p span class="LC_warning">'."\n".
934: &mt('The following files are either dependencies of a web page or references within a folder and/or composite page for which errors occurred during import:')."\n".
935: '<ul>'."\n";
936: foreach my $key (sort(keys(%import_errors))) {
937: $fixuperrors .= '<li>'.$key.'</li>'."\n";
938: }
939: $fixuperrors .= '</ul></p>'."\n";
940: }
1.533 raeburn 941: if (ref($msgsarray) eq 'ARRAY') {
942: if (@{$msgsarray} > 0) {
943: $fixuperrors .= '<p class="LC_info">'.
944: join('<br />',@{$msgsarray}).
945: '</p>';
946: }
947: }
948: if ($lockerror) {
949: $fixuperrors .= '<p class="LC_error">'.
950: $lockerror.
951: '</p>';
952: }
1.529 raeburn 953: }
954: my ($errtext,$fatal) =
955: &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
1.557 raeburn 956: unless ($fatal) {
957: if ($folder =~ /^supplemental/) {
1.561 raeburn 958: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
959: $folder.'.'.$container);
1.557 raeburn 960: }
961: }
1.529 raeburn 962: return ($errtext,$fatal,$fixuperrors);
1.329 droeschl 963: }
964:
965: sub log_docs {
1.494 raeburn 966: return &Apache::lonnet::write_log('course','docslog',@_);
1.329 droeschl 967: }
968:
969: {
970: my @oldresources=();
971: my @oldorder=();
972: my $parmidx;
973: my %parmaction=();
974: my %parmvalue=();
975: my $changedflag;
976:
977: sub snapshotbefore {
978: @oldresources=@LONCAPA::map::resources;
979: @oldorder=@LONCAPA::map::order;
980: $parmidx=undef;
981: %parmaction=();
982: %parmvalue=();
983: $changedflag=0;
984: }
985:
986: sub remember_parms {
987: my ($idx,$parameter,$action,$value)=@_;
988: $parmidx=$idx;
989: $parmaction{$parameter}=$action;
990: $parmvalue{$parameter}=$value;
991: $changedflag=1;
992: }
993:
994: sub log_differences {
995: my ($plain)=@_;
996: my %storehash=('folder' => $plain,
997: 'currentfolder' => $env{'form.folder'});
998: if ($parmidx) {
999: $storehash{'parameter_res'}=$oldresources[$parmidx];
1000: foreach my $parm (keys(%parmaction)) {
1001: $storehash{'parameter_action_'.$parm}=$parmaction{$parm};
1002: $storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
1003: }
1004: }
1005: my $maxidx=$#oldresources;
1006: if ($#LONCAPA::map::resources>$#oldresources) {
1007: $maxidx=$#LONCAPA::map::resources;
1008: }
1009: for (my $idx=0; $idx<=$maxidx; $idx++) {
1010: if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
1011: $storehash{'before_resources_'.$idx}=$oldresources[$idx];
1012: $storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
1013: $changedflag=1;
1014: }
1015: if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
1016: $storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
1017: $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
1018: $changedflag=1;
1019: }
1020: }
1021: $storehash{'maxidx'}=$maxidx;
1022: if ($changedflag) { &log_docs(\%storehash); }
1023: }
1024: }
1025:
1026: sub docs_change_log {
1.611 raeburn 1027: my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit)=@_;
1.486 raeburn 1028: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
1.617 raeburn 1029: my $navmap;
1.483 raeburn 1030: my $js = '<script type="text/javascript">'."\n".
1031: '// <![CDATA['."\n".
1032: &Apache::loncommon::display_filter_js('docslog')."\n".
1.606 raeburn 1033: &editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag,
1.622 raeburn 1034: $coursedom,$coursenum,'','',$canedit,'',\$navmap)."\n".
1.483 raeburn 1035: &history_tab_js()."\n".
1.484 raeburn 1036: &Apache::lonratedt::editscript('simple')."\n".
1.483 raeburn 1037: '// ]]>'."\n".
1038: '</script>'."\n";
1.484 raeburn 1039: $r->print(&Apache::loncommon::start_page('Content Change Log',$js));
1040: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Change Log'));
1.489 raeburn 1041: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484 raeburn 1042: my %orderhash;
1043: my $container='sequence';
1044: my $pathitem;
1.519 raeburn 1045: if ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 1046: $container='page';
1047: }
1.519 raeburn 1048: my $folderpath=$env{'form.folderpath'};
1049: if ($folderpath eq '') {
1.617 raeburn 1050: $folderpath = &default_folderpath($coursenum,$coursedom,\$navmap);
1.519 raeburn 1051: }
1.617 raeburn 1052: undef($navmap);
1.519 raeburn 1053: $pathitem = '<input type="hidden" name="folderpath" value="'.
1054: &HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 1055: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
1056: my $jumpto = $readfile;
1057: $jumpto =~ s{^/}{};
1058: my $tid = 1;
1.489 raeburn 1059: if ($supplementalflag) {
1060: $tid = 2;
1061: }
1.630 raeburn 1062: my ($breadcrumbtrail) =
1.509 raeburn 1063: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
1.484 raeburn 1064: $r->print($breadcrumbtrail.
1065: &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto,
1066: $readfile));
1.329 droeschl 1067: my %docslog=&Apache::lonnet::dump('nohist_docslog',
1068: $env{'course.'.$env{'request.course.id'}.'.domain'},
1069: $env{'course.'.$env{'request.course.id'}.'.num'});
1070:
1071: if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
1072:
1073: my %saveable_parameters = ('show' => 'scalar',);
1074: &Apache::loncommon::store_course_settings('docs_log',
1075: \%saveable_parameters);
1076: &Apache::loncommon::restore_course_settings('docs_log',
1077: \%saveable_parameters);
1078: if (!$env{'form.show'}) { $env{'form.show'}=10; }
1.452 www 1079: # FIXME: internationalization seems wrong here
1.329 droeschl 1080: my %lt=('hiddenresource' => 'Resources hidden',
1081: 'encrypturl' => 'URL hidden',
1082: 'randompick' => 'Randomly pick',
1083: 'randomorder' => 'Randomly ordered',
1.645 raeburn 1084: 'gradable' => 'Grade can be assigned to External Tool',
1.329 droeschl 1085: 'set' => 'set to',
1086: 'del' => 'deleted');
1.484 raeburn 1087: my $filter = &Apache::loncommon::display_filter('docslog')."\n".
1088: $pathitem."\n".
1089: '<input type="hidden" name="folder" value="'.$env{'form.folder'}.'" />'.
1090: (' 'x2).'<input type="submit" value="'.&mt('Display').'" />';
1091: $r->print('<div class="LC_left_float">'.
1092: '<fieldset><legend>'.&mt('Display of Content Changes').'</legend>'."\n".
1093: &makedocslogform($filter,1).
1094: '</fieldset></div><br clear="all" />');
1.329 droeschl 1095: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
1096: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
1097: &mt('After').'</th>'.
1098: &Apache::loncommon::end_data_table_header_row());
1099: my $shown=0;
1100: foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
1101: if ($env{'form.displayfilter'} eq 'currentfolder') {
1102: if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
1103: }
1104: my @changes=keys(%{$docslog{$id}{'logentry'}});
1105: if ($env{'form.displayfilter'} eq 'containing') {
1106: my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
1107: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
1108: foreach my $key (@changes) {
1109: $wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
1110: }
1.344 bisitz 1111: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
1.329 droeschl 1112: }
1113: my $count = 0;
1114: my $time =
1115: &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
1116: my $plainname =
1117: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
1118: $docslog{$id}{'exe_udom'});
1119: my $about_me_link =
1120: &Apache::loncommon::aboutmewrapper($plainname,
1121: $docslog{$id}{'exe_uname'},
1122: $docslog{$id}{'exe_udom'});
1123: my $send_msg_link='';
1124: if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
1125: || ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
1126: $send_msg_link ='<br />'.
1127: &Apache::loncommon::messagewrapper(&mt('Send message'),
1128: $docslog{$id}{'exe_uname'},
1129: $docslog{$id}{'exe_udom'});
1130: }
1131: $r->print(&Apache::loncommon::start_data_table_row());
1132: $r->print('<td>'.$time.'</td>
1133: <td>'.$about_me_link.
1134: '<br /><tt>'.$docslog{$id}{'exe_uname'}.
1135: ':'.$docslog{$id}{'exe_udom'}.'</tt>'.
1136: $send_msg_link.'</td><td>'.
1137: $docslog{$id}{'logentry'}{'folder'}.'</td><td>');
1.488 raeburn 1138: my $is_supp = 0;
1139: if ($docslog{$id}{'logentry'}{'currentfolder'} =~ /^supplemental/) {
1140: $is_supp = 1;
1141: }
1.329 droeschl 1142: # Before
1143: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1144: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
1145: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
1146: if ($oldname ne $newname) {
1.488 raeburn 1147: my $shown = &LONCAPA::map::qtescape($oldname);
1148: if ($is_supp) {
1149: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1150: }
1151: $r->print($shown);
1.329 droeschl 1152: }
1153: }
1154: $r->print('<ul>');
1155: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1156: if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
1.488 raeburn 1157: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]);
1158: if ($is_supp) {
1159: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1160: }
1161: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 1162: }
1163: }
1164: $r->print('</ul>');
1165: # After
1166: $r->print('</td><td>');
1167:
1168: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1169: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
1170: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
1171: if ($oldname ne '' && $oldname ne $newname) {
1.488 raeburn 1172: my $shown = &LONCAPA::map::qtescape($newname);
1173: if ($is_supp) {
1174: $shown = &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($newname));
1175: }
1176: $r->print($shown);
1.329 droeschl 1177: }
1.364 bisitz 1178: }
1.329 droeschl 1179: $r->print('<ul>');
1180: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1181: if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
1.488 raeburn 1182: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]);
1183: if ($is_supp) {
1184: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1185: }
1186: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 1187: }
1188: }
1189: $r->print('</ul>');
1190: if ($docslog{$id}{'logentry'}{'parameter_res'}) {
1191: $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
1.645 raeburn 1192: foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder','gradable') {
1.329 droeschl 1193: if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
1.452 www 1194: # FIXME: internationalization seems wrong here
1.329 droeschl 1195: $r->print('<li>'.
1196: &mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
1197: $docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
1198: .'</li>');
1199: }
1200: }
1201: $r->print('</ul>');
1202: }
1203: # End
1204: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1205: $shown++;
1206: if (!($env{'form.show'} eq &mt('all')
1207: || $shown<=$env{'form.show'})) { last; }
1208: }
1.484 raeburn 1209: $r->print(&Apache::loncommon::end_data_table()."\n".
1210: &makesimpleeditform($pathitem)."\n".
1211: '</div></div>');
1212: $r->print(&endContentScreen());
1.329 droeschl 1213: }
1214:
1215: sub update_paste_buffer {
1.492 raeburn 1216: my ($coursenum,$coursedom,$folder) = @_;
1.591 raeburn 1217: my (@possibles,%removals,%cuts,$output);
1.538 raeburn 1218: if ($env{'form.multiremove'}) {
1219: $env{'form.multiremove'} =~ s/,$//;
1220: map { $removals{$_} = 1; } split(/,/,$env{'form.multiremove'});
1221: }
1222: if (($env{'form.multicopy'}) || ($env{'form.multicut'})) {
1223: if ($env{'form.multicut'}) {
1224: $env{'form.multicut'} =~ s/,$//;
1225: foreach my $item (split(/,/,$env{'form.multicut'})) {
1226: unless ($removals{$item}) {
1227: $cuts{$item} = 1;
1228: push(@possibles,$item.':cut');
1229: }
1230: }
1231: }
1232: if ($env{'form.multicopy'}) {
1233: $env{'form.multicopy'} =~ s/,$//;
1234: foreach my $item (split(/,/,$env{'form.multicopy'})) {
1235: unless ($removals{$item} || $cuts{$item}) {
1236: push(@possibles,$item.':copy');
1237: }
1238: }
1239: }
1240: } elsif ($env{'form.markcopy'}) {
1241: @possibles = split(/,/,$env{'form.markcopy'});
1242: }
1.329 droeschl 1243:
1.538 raeburn 1244: return if (@possibles == 0);
1.329 droeschl 1245: return if (!defined($env{'form.copyfolder'}));
1246:
1247: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1248: $env{'form.copyfolder'});
1.538 raeburn 1249: return if ($fatal);
1250:
1251: my %curr_groups = &Apache::longroup::coursegroups();
1.364 bisitz 1252:
1.538 raeburn 1253: # Retrieve current paste buffer suffixes.
1254: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1255: my (%pasteurls,@newpaste);
1256:
1257: # Construct identifiers for current contents of user's paste buffer
1258: if (@currpaste) {
1259: foreach my $suffix (@currpaste) {
1.667 raeburn 1260: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1261: my $url = $env{'docs.markedcopy_url_'.$suffix};
1262: my $mapidx = $env{'docs.markedcopy_map_'.$suffix};
1263: if (($cid =~ /^$match_domain(?:_)$match_courseid$/) &&
1264: ($url ne '')) {
1265: if ($url eq '/res/lib/templates/simpleproblem.problem') {
1266: $pasteurls{$cid.'_'.$mapidx} = 1;
1267: } elsif ($url =~ m{^/res/$match_domain/$match_username/}) {
1268: $pasteurls{$url} = 1;
1269: } else {
1.669 raeburn 1270: $pasteurls{$cid.'_'.$url} = 1;
1.667 raeburn 1271: }
1272: }
1.538 raeburn 1273: }
1274: }
1275:
1276: # Mark items for copying (skip any items already in user's paste buffer)
1277: my %addtoenv;
1.597 raeburn 1278:
1279: my @pathitems = split(/\&/,$env{'form.folderpath'});
1280: my @folderconf = split(/\:/,$pathitems[-1]);
1.666 raeburn 1281: my $ispage = $folderconf[5];
1.597 raeburn 1282:
1.538 raeburn 1283: foreach my $item (@possibles) {
1284: my ($orderidx,$cmd) = split(/:/,$item);
1285: next if ($orderidx =~ /\D/);
1286: next unless (($cmd eq 'cut') || ($cmd eq 'copy') || ($cmd eq 'remove'));
1.597 raeburn 1287: my $mapidx = $folder.':'.$orderidx.':'.$ispage;
1.538 raeburn 1288: my ($title,$url)=split(':',$LONCAPA::map::resources[$orderidx]);
1289: my %denied = &action_restrictions($coursenum,$coursedom,
1290: &LONCAPA::map::qtescape($url),
1291: $env{'form.folderpath'},\%curr_groups);
1292: next if ($denied{'copy'});
1293: $url=~s{http(:|:)//https(:|:)//}{https$2//};
1.667 raeburn 1294: if ($url eq '/res/lib/templates/simpleproblem.problem') {
1295: next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$mapidx}));
1296: } elsif ($url =~ m{^/res/$match_domain/$match_username/}) {
1297: next if (exists($pasteurls{$url}));
1298: } else {
1299: next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$url}));
1300: }
1.538 raeburn 1301: my ($suffix,$errortxt,$locknotfreed) =
1302: &new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste');
1.591 raeburn 1303: if ($suffix ne '') {
1304: push(@newpaste,$suffix);
1305: } else {
1306: if ($locknotfreed) {
1307: return $locknotfreed;
1308: }
1.538 raeburn 1309: }
1310: if (&is_supplemental_title($title)) {
1311: &Apache::lonnet::appenv({'docs.markedcopy_supplemental_'.$suffix => $title});
1312: ($title) = &Apache::loncommon::parse_supplemental_title($title);
1313: }
1.329 droeschl 1314:
1.538 raeburn 1315: $addtoenv{'docs.markedcopy_title_'.$suffix} = $title,
1316: $addtoenv{'docs.markedcopy_url_'.$suffix} = $url,
1317: $addtoenv{'docs.markedcopy_cmd_'.$suffix} = $cmd,
1318: $addtoenv{'docs.markedcopy_crs_'.$suffix} = $env{'request.course.id'};
1.597 raeburn 1319: $addtoenv{'docs.markedcopy_map_'.$suffix} = $mapidx;
1.538 raeburn 1320: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) {
1321: my $prefix = $1;
1322: my $subdir =$2;
1323: if ($subdir eq '') {
1324: $subdir = $prefix;
1.492 raeburn 1325: }
1.538 raeburn 1326: my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps);
1.627 raeburn 1327: &contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap,
1328: \%removeparam,\%addedmaps,\%hierarchy,\%titles,\%allmaps);
1.538 raeburn 1329: if (ref($hierarchy{$url}) eq 'HASH') {
1330: my ($nested,$nestednames);
1331: &recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames);
1332: $nested =~ s/\&$//;
1333: $nestednames =~ s/\Q___&&&___\E$//;
1334: if ($nested ne '') {
1335: $addtoenv{'docs.markedcopy_nested_'.$suffix} = $nested;
1336: }
1337: if ($nestednames ne '') {
1338: $addtoenv{'docs.markedcopy_nestednames_'.$suffix} = $nestednames;
1339: }
1.492 raeburn 1340: }
1341: }
1.591 raeburn 1342: if ($locknotfreed) {
1343: $output = $locknotfreed;
1344: last;
1345: }
1.492 raeburn 1346: }
1.538 raeburn 1347: if (@newpaste) {
1348: $addtoenv{'docs.markedcopies'} = join(',',(@currpaste,@newpaste));
1349: }
1.492 raeburn 1350: &Apache::lonnet::appenv(\%addtoenv);
1.329 droeschl 1351: delete($env{'form.markcopy'});
1.591 raeburn 1352: return $output;
1.329 droeschl 1353: }
1354:
1.492 raeburn 1355: sub recurse_uploaded_maps {
1356: my ($url,$dir,$hierarchy,$titlesref,$nestref,$namesref) = @_;
1357: if (ref($hierarchy->{$url}) eq 'HASH') {
1358: my @maps = map { $hierarchy->{$url}{$_}; } sort { $a <=> $b } (keys(%{$hierarchy->{$url}}));
1359: my @titles = map { $titlesref->{$url}{$_}; } sort { $a <=> $b } (keys(%{$titlesref->{$url}}));
1360: my (@uploaded,@names,%shorter);
1361: for (my $i=0; $i<@maps; $i++) {
1362: my ($inner) = ($maps[$i] =~ m{^/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_(\d+)\.(?:page|sequence)$});
1363: if ($inner ne '') {
1364: push(@uploaded,$inner);
1365: push(@names,&escape($titles[$i]));
1366: $shorter{$maps[$i]} = $inner;
1367: }
1368: }
1369: $$nestref .= "$dir:".join(',',@uploaded).'&';
1370: $$namesref .= "$dir:".(join(',',@names)).'___&&&___';
1371: foreach my $map (@maps) {
1372: if ($shorter{$map} ne '') {
1373: &recurse_uploaded_maps($map,$shorter{$map},$hierarchy,$titlesref,$nestref,$namesref);
1374: }
1375: }
1376: }
1377: return;
1378: }
1379:
1.329 droeschl 1380: sub print_paste_buffer {
1.492 raeburn 1381: my ($r,$container,$folder,$coursedom,$coursenum) = @_;
1.538 raeburn 1382: return if (!defined($env{'docs.markedcopies'}));
1.329 droeschl 1383:
1.538 raeburn 1384: unless (($env{'form.pastemarked'}) || ($env{'form.clearmarked'})) {
1385: return if ($env{'docs.markedcopies'} eq '');
1.488 raeburn 1386: }
1387:
1.538 raeburn 1388: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1389: my ($pasteitems,@pasteable);
1.575 raeburn 1390: my $clipboardcount = 0;
1.488 raeburn 1391:
1.538 raeburn 1392: # Construct identifiers for current contents of user's paste buffer
1393: foreach my $suffix (@currpaste) {
1394: next if ($suffix =~ /\D/);
1395: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1396: my $url = $env{'docs.markedcopy_url_'.$suffix};
1.597 raeburn 1397: my $mapidx = $env{'docs.markedcopy_map_'.$suffix};
1.538 raeburn 1398: if (($cid =~ /^$match_domain\_$match_courseid$/) &&
1399: ($url ne '')) {
1.575 raeburn 1400: $clipboardcount ++;
1.538 raeburn 1401: my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent,
1.598 raeburn 1402: $canpaste,$nopaste,$othercrs,$areachange,$is_exttool);
1.538 raeburn 1403: my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1];
1404: if ($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
1405: $is_external = 1;
1.626 raeburn 1406: } elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$}) {
1.598 raeburn 1407: $is_exttool = 1;
1.538 raeburn 1408: }
1409: if ($folder =~ /^supplemental/) {
1410: $canpaste = &supp_pasteable($env{'docs.markedcopy_url_'.$suffix});
1411: unless ($canpaste) {
1412: $nopaste = &mt('Paste into Supplemental Content unavailable.');
1413: }
1414: } else {
1415: $canpaste = 1;
1416: }
1417: if ($canpaste) {
1418: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1419: my $srcdom = $1;
1420: my $srcnum = $2;
1421: my $rem = $3;
1422: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
1423: $othercourse = 1;
1424: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1.596 raeburn 1425: $othercrs = '<br />'.&mt('(from another course)');
1.538 raeburn 1426: } else {
1427: $canpaste = 0;
1428: $nopaste = &mt('Paste from another course unavailable.');
1429: }
1430: }
1431: if ($rem =~ m{^(default|supplemental)_?(\d*)\.(?:page|sequence)$}) {
1432: my $prefix = $1;
1433: $parent = $2;
1434: if ($folder !~ /^\Q$prefix\E/) {
1435: $areachange = 1;
1436: }
1437: $is_uploaded_map = 1;
1.492 raeburn 1438: }
1.597 raeburn 1439: } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
1.627 raeburn 1440: ($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg|ext\.tool)$})) {
1.596 raeburn 1441: if ($cid ne $env{'request.course.id'}) {
1442: my ($srcdom,$srcnum) = split(/_/,$cid);
1443: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1.627 raeburn 1444: if (($is_exttool) && ($srcdom ne $coursedom)) {
1445: $canpaste = 0;
1446: $nopaste = &mt('Paste from another domain unavailable.');
1447: } else {
1448: $othercrs = '<br />'.&mt('(from another course)');
1449: }
1.596 raeburn 1450: } else {
1451: $canpaste = 0;
1452: $nopaste = &mt('Paste from another course unavailable.');
1.629 raeburn 1453: }
1.596 raeburn 1454: }
1.492 raeburn 1455: }
1.596 raeburn 1456: if ($canpaste) {
1457: push(@pasteable,$suffix);
1.629 raeburn 1458: }
1.538 raeburn 1459: }
1460: my $buffer;
1.627 raeburn 1461: if ($is_external) {
1.538 raeburn 1462: $buffer = &mt('External Resource').': '.
1463: &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('.
1464: &LONCAPA::map::qtescape($url).')';
1.627 raeburn 1465: } elsif ($is_exttool) {
1466: $buffer = &mt('External Tool').': '.
1467: &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.538 raeburn 1468: } else {
1469: my $icon = &Apache::loncommon::icon($extension);
1470: if ($extension eq 'sequence' &&
1471: $url =~ m{/default_\d+\.sequence$}x) {
1472: $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
1473: $icon .= '/navmap.folder.closed.gif';
1474: }
1.589 raeburn 1475: my $title = $env{'docs.markedcopy_title_'.$suffix};
1476: if ($title eq '') {
1477: ($title) = ($url =~ m{/([^/]+)$});
1478: }
1.538 raeburn 1479: $buffer = '<img src="'.$icon.'" alt="" class="LC_icon" />'.
1480: ': '.
1481: &Apache::loncommon::parse_supplemental_title(
1.589 raeburn 1482: &LONCAPA::map::qtescape($title));
1.538 raeburn 1483: }
1484: $pasteitems .= '<div class="LC_left_float">';
1485: my ($options,$onclick);
1486: if (($canpaste) && (!$areachange) && (!$othercourse) &&
1487: ($env{'docs.markedcopy_cmd_'.$suffix} eq 'cut')) {
1488: if (($is_uploaded_map) ||
1489: ($url =~ /(bulletinboard|smppg)$/) ||
1490: ($url =~ m{^/uploaded/$coursedom/$coursenum/(?:docs|supplemental)/(.+)$})) {
1491: $options = &paste_options($suffix,$is_uploaded_map,$parent);
1492: $onclick= 'onclick="showOptions(this,'."'$suffix'".');" ';
1493: }
1494: }
1495: $pasteitems .= '<label><input type="checkbox" name="pasting" id="pasting_'.$suffix.'" value="'.$suffix.'" '.$onclick.'/>'.$buffer.'</label>';
1496: if ($nopaste) {
1.681 raeburn 1497: $pasteitems .= ' <span class="LC_cusr_emph">'.$nopaste.'</span>';
1.538 raeburn 1498: } else {
1499: if ($othercrs) {
1500: $pasteitems .= $othercrs;
1501: }
1502: if ($options) {
1503: $pasteitems .= $options;
1.492 raeburn 1504: }
1505: }
1.538 raeburn 1506: $pasteitems .= '</div>';
1507: }
1508: }
1509: if ($pasteitems eq '') {
1510: &Apache::lonnet::delenv('docs.markedcopies');
1511: }
1512: my ($pasteform,$form_start,$buttons,$form_end);
1513: if ($pasteitems) {
1514: $pasteitems .= '<div style="padding:0;clear:both;margin:0;border:0"></div>';
1.541 raeburn 1515: $form_start = '<form name="pasteform" action="/adm/coursedocs" method="post" onsubmit="return validateClipboard();">';
1.538 raeburn 1516: if (@pasteable) {
1.575 raeburn 1517: my $value = &mt('Paste to current folder');
1518: if ($container eq 'page') {
1519: $value = &mt('Paste to current page');
1520: }
1521: $buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.(' 'x2);
1522: }
1523: $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.(' 'x2);
1524: if ($clipboardcount > 1) {
1525: $buttons .=
1526: '<span style="text-decoration:line-through">'.(' 'x20).'</span>'.(' 'x2).
1527: '<input type="button" name="checkallclip" value="'.&mt('Check all').'" style="height:20px;" onclick="checkClipboard();" />'.
1528: (' 'x2).
1529: '<input type="button" name="uncheckallclip" value="'.&mt('Uncheck all').'" style="height:20px;" onclick="uncheckClipboard();" />'.
1530: (' 'x2);
1.492 raeburn 1531: }
1.575 raeburn 1532: $form_end = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'.
1533: '</form>';
1.538 raeburn 1534: } else {
1535: $pasteitems = &mt('Clipboard is empty');
1.488 raeburn 1536: }
1.538 raeburn 1537: $r->print($form_start
1538: .'<fieldset>'
1539: .'<legend>'.&mt('Clipboard').(' ' x2).$buttons.'</legend>'
1540: .$pasteitems
1541: .'</fieldset>'
1542: .$form_end);
1543: }
1544:
1545: sub paste_options {
1546: my ($suffix,$is_uploaded_map,$parent) = @_;
1547: my ($copytext,$movetext);
1548: if ($is_uploaded_map) {
1549: $copytext = &mt('Copy to new folder');
1550: $movetext = &mt('Move old');
1551: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /bulletinboard$/) {
1552: $copytext = &mt('Copy to new board');
1553: $movetext = &mt('Move (not posts)');
1554: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /smppg$/) {
1555: $copytext = &mt('Copy to new page');
1556: $movetext = &mt('Move');
1.533 raeburn 1557: } else {
1.538 raeburn 1558: $copytext = &mt('Copy to new file');
1559: $movetext = &mt('Move');
1560: }
1561: my $output = '<br />'.
1562: '<span id="pasteoptionstext_'.$suffix.'" class="LC_fontsize_small LC_nobreak"></span>'.
1563: '<div id="pasteoptions_'.$suffix.'" class="LC_dccid" style="display:none;"><span class="LC_nobreak">'.(' 'x 4).
1564: '<label>'.
1565: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="new" checked="checked" />'.
1566: $copytext.'</label></span>'.(' 'x2).' '.
1567: '<span class="LC_nobreak"><label>'.
1568: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="move" />'.
1569: $movetext.'</label></span>';
1570: if (($is_uploaded_map) && ($env{'docs.markedcopy_nested_'.$suffix})) {
1571: $output .= '<br /><fieldset><legend>'.&mt('Folder to paste contains sub-folders').
1572: '</legend><table border="0">';
1573: my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1574: my @titles = split(/\Q___&&&___\E/,$env{'docs.markedcopy_nestednames_'.$suffix});
1575: my $lastdir = $parent;
1576: my %depths = (
1577: $lastdir => 0,
1578: );
1579: my (%display,%deps);
1580: for (my $i=0; $i<@pastemaps; $i++) {
1581: ($lastdir,my $subfolderstr) = split(/\:/,$pastemaps[$i]);
1582: my ($namedir,$esctitlestr) = split(/\:/,$titles[$i]);
1583: my @subfolders = split(/,/,$subfolderstr);
1584: $deps{$lastdir} = \@subfolders;
1585: my @subfoldertitles = map { &unescape($_); } split(/,/,$esctitlestr);
1586: my $depth = $depths{$lastdir} + 1;
1587: my $offset = int($depth * 4);
1588: my $indent = (' ' x $offset);
1589: for (my $j=0; $j<@subfolders; $j++) {
1590: $depths{$subfolders[$j]} = $depth;
1591: $display{$subfolders[$j]} =
1592: '<tr><td>'.$indent.$subfoldertitles[$j].' </td>'.
1593: '<td><label>'.
1594: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="new" checked="checked" />'.&mt('Copy to new').'</label>'.(' ' x2).
1595: '<label>'.
1596: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="move" />'.
1597: &mt('Move old').'</label>'.
1598: '</td></tr>';
1599: }
1.492 raeburn 1600: }
1.538 raeburn 1601: &recurse_print(\$output,$parent,\%deps,\%display);
1602: $output .= '</table></fieldset>';
1.329 droeschl 1603: }
1.538 raeburn 1604: $output .= '</div>';
1605: return $output;
1.488 raeburn 1606: }
1607:
1.492 raeburn 1608: sub recurse_print {
1.538 raeburn 1609: my ($outputref,$dir,$deps,$display) = @_;
1610: $$outputref .= $display->{$dir}."\n";
1.492 raeburn 1611: if (ref($deps->{$dir}) eq 'ARRAY') {
1612: foreach my $subdir (@{$deps->{$dir}}) {
1.538 raeburn 1613: &recurse_print($outputref,$subdir,$deps,$display);
1.492 raeburn 1614: }
1615: }
1616: }
1617:
1.488 raeburn 1618: sub supp_pasteable {
1619: my ($url) = @_;
1620: if (($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//}) ||
1621: (($url =~ /\.sequence$/) && ($url =~ m{^/uploaded/})) ||
1622: ($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) ||
1623: ($url =~ m{^/adm/$match_domain/$match_username/aboutme}) ||
1.598 raeburn 1624: ($url =~ m{^/public/$match_domain/$match_courseid/syllabus}) ||
1.626 raeburn 1625: ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$})) {
1.488 raeburn 1626: return 1;
1627: }
1628: return;
1.329 droeschl 1629: }
1630:
1.492 raeburn 1631: sub paste_popup_js {
1.594 damieng 1632: my %html_js_lt = &Apache::lonlocal::texthash(
1.538 raeburn 1633: show => 'Show Options',
1634: hide => 'Hide Options',
1.594 damieng 1635: );
1636: my %js_lt = &Apache::lonlocal::texthash(
1.541 raeburn 1637: none => 'No items selected from clipboard.',
1.492 raeburn 1638: );
1.594 damieng 1639: &html_escape(\%html_js_lt);
1640: &js_escape(\%html_js_lt);
1641: &js_escape(\%js_lt);
1.492 raeburn 1642: return <<"END";
1643:
1.538 raeburn 1644: function showPasteOptions(suffix) {
1645: document.getElementById('pasteoptions_'+suffix).style.display='block';
1.594 damieng 1646: document.getElementById('pasteoptionstext_'+suffix).innerHTML = ' <a href="javascript:hidePasteOptions(\\''+suffix+'\\');" class="LC_menubuttons_link">$html_js_lt{'hide'}</a>';
1.492 raeburn 1647: return;
1648: }
1649:
1.538 raeburn 1650: function hidePasteOptions(suffix) {
1651: document.getElementById('pasteoptions_'+suffix).style.display='none';
1.594 damieng 1652: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.538 raeburn 1653: return;
1654: }
1655:
1656: function showOptions(caller,suffix) {
1657: if (document.getElementById('pasteoptionstext_'+suffix)) {
1658: if (caller.checked) {
1.594 damieng 1659: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.538 raeburn 1660: } else {
1661: document.getElementById('pasteoptionstext_'+suffix).innerHTML ='';
1662: }
1663: if (document.getElementById('pasteoptions_'+suffix)) {
1664: document.getElementById('pasteoptions_'+suffix).style.display='none';
1665: }
1666: }
1.492 raeburn 1667: return;
1668: }
1669:
1.541 raeburn 1670: function validateClipboard() {
1671: var numchk = 0;
1672: if (document.pasteform.pasting.length > 1) {
1673: for (var i=0; i<document.pasteform.pasting.length; i++) {
1674: if (document.pasteform.pasting[i].checked) {
1675: numchk ++;
1676: }
1677: }
1678: } else {
1679: if (document.pasteform.pasting.type == 'checkbox') {
1680: if (document.pasteform.pasting.checked) {
1681: numchk ++;
1682: }
1683: }
1684: }
1685: if (numchk > 0) {
1686: return true;
1687: } else {
1.594 damieng 1688: alert("$js_lt{'none'}");
1.541 raeburn 1689: return false;
1690: }
1691: }
1692:
1.575 raeburn 1693: function checkClipboard() {
1694: if (document.pasteform.pasting.length > 1) {
1695: for (var i=0; i<document.pasteform.pasting.length; i++) {
1696: document.pasteform.pasting[i].checked = true;
1697: }
1698: }
1699: return;
1700: }
1701:
1702: function uncheckClipboard() {
1703: if (document.pasteform.pasting.length >1) {
1704: for (var i=0; i<document.pasteform.pasting.length; i++) {
1705: document.pasteform.pasting[i].checked = false;
1706: }
1707: }
1708: return;
1709: }
1710:
1.492 raeburn 1711: END
1712:
1713: }
1714:
1.329 droeschl 1715: sub do_paste_from_buffer {
1.492 raeburn 1716: my ($coursenum,$coursedom,$folder,$container,$errors) = @_;
1.329 droeschl 1717:
1.538 raeburn 1718: # Array of items in paste buffer
1719: my (@currpaste,%pastebuffer,%allerrors);
1720: @currpaste = split(/,/,$env{'docs.markedcopies'});
1721:
1.492 raeburn 1722: # Early out if paste buffer is empty
1.538 raeburn 1723: if (@currpaste == 0) {
1.492 raeburn 1724: return ();
1.538 raeburn 1725: }
1726: map { $pastebuffer{$_} = 1; } @currpaste;
1727:
1728: # Array of items selected items to paste
1729: my @reqpaste = &Apache::loncommon::get_env_multiple('form.pasting');
1730:
1731: # Early out if nothing selected to paste
1732: if (@reqpaste == 0) {
1733: return();
1734: }
1735: my @topaste;
1736: foreach my $suffix (@reqpaste) {
1737: next if ($suffix =~ /\D/);
1738: next unless (exists($pastebuffer{$suffix}));
1739: push(@topaste,$suffix);
1740: }
1741:
1742: # Early out if nothing available to paste
1743: if (@topaste == 0) {
1744: return();
1.329 droeschl 1745: }
1746:
1.627 raeburn 1747: my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%notindom,%duplicate,
1.597 raeburn 1748: %prefixchg,%srcdom,%srcnum,%srcmapidx,%marktomove,$save_err,$lockerrors,$allresult);
1.538 raeburn 1749:
1750: foreach my $suffix (@topaste) {
1751: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1.596 raeburn 1752: my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.597 raeburn 1753: my $mapidx=&LONCAPA::map::qtescape($env{'docs.markedcopy_map_'.$suffix});
1.492 raeburn 1754: # Supplemental content may only include certain types of content
1755: # Early out if pasted content is not supported in Supplemental area
1.538 raeburn 1756: if ($folder =~ /^supplemental/) {
1757: unless (&supp_pasteable($url)) {
1758: $notinsupp{$suffix} = 1;
1759: next;
1760: }
1.492 raeburn 1761: }
1.538 raeburn 1762: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/}) {
1763: my $srcd = $1;
1764: my $srcn = $2;
1.492 raeburn 1765: # When paste buffer was populated using an active role in a different course
1.538 raeburn 1766: # check for mdc privilege in the course from which the resource was pasted
1767: if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1768: unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1769: $notincrs{$suffix} = 1;
1770: next;
1771: }
1.491 raeburn 1772: }
1.538 raeburn 1773: $srcdom{$suffix} = $srcd;
1774: $srcnum{$suffix} = $srcn;
1.597 raeburn 1775: } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
1.632 raeburn 1776: ($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg)$}) ||
1777: ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$})) {
1.596 raeburn 1778: my ($srcd,$srcn) = split(/_/,$cid);
1779: # When paste buffer was populated using an active role in a different course
1780: # check for mdc privilege in the course from which the resource was pasted
1781: if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1782: unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1783: $notincrs{$suffix} = 1;
1784: next;
1785: }
1786: }
1.632 raeburn 1787: # When buffer was populated using an active role in a different course
1788: # disallow pasting of External Tool if course is in a different domain.
1789: if (($url =~ m{/ext\.tool$}) && ($srcd ne $coursedom)) {
1.627 raeburn 1790: $notindom{$suffix} = 1;
1791: next;
1792: }
1.596 raeburn 1793: $srcdom{$suffix} = $srcd;
1794: $srcnum{$suffix} = $srcn;
1.491 raeburn 1795: }
1.597 raeburn 1796: $srcmapidx{$suffix} = $mapidx;
1.538 raeburn 1797: push(@dopaste,$suffix);
1798: if ($url=~/\.(page|sequence)$/) {
1799: $is_map{$suffix} = 1;
1800: }
1801: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/([^/]+)}) {
1802: my $oldprefix = $1;
1.492 raeburn 1803: # When pasting content from Main Content to Supplemental Content and vice versa
1804: # URLs will contain different paths (which depend on whether pasted item is
1.597 raeburn 1805: # a folder/page or a document).
1.538 raeburn 1806: if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) {
1807: $prefixchg{$suffix} = 'docstosupp';
1808: } elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) {
1809: $prefixchg{$suffix} = 'supptodocs';
1810: }
1.491 raeburn 1811:
1.492 raeburn 1812: # If pasting an uploaded map, get list of contained uploaded maps.
1.538 raeburn 1813: if ($env{'docs.markedcopy_nested_'.$suffix}) {
1814: my @nested;
1815: my ($type) = ($oldprefix =~ /^(default|supplemental)/);
1816: my @items = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1817: my @deps = map { /\d+:([\d,]+$)/ } @items;
1818: foreach my $dep (@deps) {
1819: if ($dep =~ /,/) {
1820: push(@nested,split(/,/,$dep));
1821: } else {
1822: push(@nested,$dep);
1823: }
1.492 raeburn 1824: }
1.538 raeburn 1825: foreach my $item (@nested) {
1826: if ($env{'form.docs.markedcopy_'.$suffix.'_'.$item} eq 'move') {
1827: push(@{$marktomove{$suffix}},$type.'_'.$item);
1828: }
1.492 raeburn 1829: }
1830: }
1.488 raeburn 1831: }
1832: }
1833:
1.538 raeburn 1834: # Early out if nothing available to paste
1835: if (@dopaste == 0) {
1836: return ();
1837: }
1838:
1839: # Populate message hash and hashes used for main content <=> supplemental content
1840: # changes
1841:
1842: %msgs = &Apache::lonlocal::texthash (
1843: notinsupp => 'Paste failed: content type is not supported within Supplemental Content',
1844: notincrs => 'Paste failed: Item is from a different course which you do not have rights to edit.',
1.661 raeburn 1845: notindom => 'Paste failed: Item is an external tool from a course in a different domain.',
1.538 raeburn 1846: duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.',
1847: );
1848:
1849: %before = (
1850: docstosupp => {
1851: map => 'default',
1852: doc => 'docs',
1853: },
1854: supptodocs => {
1855: map => 'supplemental',
1856: doc => 'supplemental',
1857: },
1858: );
1859:
1860: %after = (
1861: docstosupp => {
1862: map => 'supplemental',
1863: doc => 'supplemental'
1864: },
1865: supptodocs => {
1866: map => 'default',
1867: doc => 'docs',
1868: },
1869: );
1870:
1871: # Retrieve information about all course maps in main content area
1872:
1873: my $allmaps = {};
1.660 raeburn 1874: my (@toclear,%mapurls,%lockerrs,%msgerrs,%results,$donechk);
1.538 raeburn 1875:
1876: # Loop over the items to paste
1877: foreach my $suffix (@dopaste) {
1.329 droeschl 1878: # Maps need to be copied first
1.538 raeburn 1879: my (%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies,
1880: %dbcopies,%zombies,%params,%docmoves,%mapmoves,%mapchanges,%newsubdir,
1.597 raeburn 1881: %newurls,%tomove,%resdatacopy);
1.538 raeburn 1882: if (ref($marktomove{$suffix}) eq 'ARRAY') {
1883: map { $tomove{$_} = 1; } @{$marktomove{$suffix}};
1884: }
1885: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1886: my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.596 raeburn 1887: my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.538 raeburn 1888: my $oldurl = $url;
1889: if ($is_map{$suffix}) {
1.491 raeburn 1890: # If pasting a map, check if map contains other maps
1.538 raeburn 1891: my (%hierarchy,%titles);
1.660 raeburn 1892: if (($folder =~ /^default/) && (!$donechk)) {
1893: $allmaps =
1894: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
1895: $env{"course.$env{'request.course.id'}.home"},
1896: $env{'request.course.id'});
1897: $donechk = 1;
1898: }
1.627 raeburn 1899: &contained_map_check($url,$folder,$coursenum,$coursedom,
1900: \%removefrommap,\%removeparam,\%addedmaps,
1901: \%hierarchy,\%titles,$allmaps);
1.538 raeburn 1902: if ($url=~ m{^/uploaded/}) {
1903: my $newurl;
1904: unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
1905: ($newurl,my $error) =
1906: &get_newmap_url($url,$folder,$prefixchg{$suffix},$coursedom,
1907: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1908: \$title,$allmaps,\%newurls);
1909: if ($error) {
1910: $allerrors{$suffix} = $error;
1911: next;
1912: }
1913: if ($newurl ne '') {
1914: if ($newurl ne $url) {
1915: if ($newurl =~ /(?:default|supplemental)_(\d+).(?:sequence|page)$/) {
1916: $newsubdir{$url} = $1;
1917: }
1918: $mapchanges{$url} = 1;
1.492 raeburn 1919: }
1.538 raeburn 1920: }
1921: }
1922: if (($srcdom{$suffix} ne $coursedom) ||
1923: ($srcnum{$suffix} ne $coursenum) ||
1924: ($prefixchg{$suffix}) || (($newurl ne '') && ($newurl ne $url))) {
1925: unless (&url_paste_fixups($url,$folder,$prefixchg{$suffix},
1926: $coursedom,$coursenum,$srcdom{$suffix},
1927: $srcnum{$suffix},$allmaps,\%rewrites,
1928: \%retitles,\%copies,\%dbcopies,
1929: \%zombies,\%params,\%mapmoves,
1930: \%mapchanges,\%tomove,\%newsubdir,
1.597 raeburn 1931: \%newurls,\%resdatacopy)) {
1.538 raeburn 1932: $mapmoves{$url} = 1;
1933: }
1934: $url = $newurl;
1935: } elsif ($env{'docs.markedcopy_nested_'.$suffix}) {
1936: &url_paste_fixups($url,$folder,$prefixchg{$suffix},$coursedom,
1937: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1938: $allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies,
1939: \%zombies,\%params,\%mapmoves,\%mapchanges,
1.597 raeburn 1940: \%tomove,\%newsubdir,\%newurls,\%resdatacopy);
1.538 raeburn 1941: }
1942: } elsif ($url=~m {^/res/}) {
1.597 raeburn 1943: # published map can only exist once, so remove from paste buffer when done
1.538 raeburn 1944: push(@toclear,$suffix);
1945: # if pasting published map (main content area only) check map not already in course
1946: if ($folder =~ /^default/) {
1947: if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) {
1948: $duplicate{$suffix} = 1;
1949: next;
1.492 raeburn 1950: }
1.491 raeburn 1951: }
1952: }
1.538 raeburn 1953: }
1.627 raeburn 1954: if ($url=~ m{/(bulletinboard|smppg|ext\.tool)$}) {
1.538 raeburn 1955: my $prefix = $1;
1.648 raeburn 1956: my $fromothercrs;
1.538 raeburn 1957: #need to copy the db contents to a new one, unless this is a move.
1958: my %info = (
1959: src => $url,
1960: cdom => $coursedom,
1961: cnum => $coursenum,
1.596 raeburn 1962: );
1.649 raeburn 1963: if ($prefix eq 'ext.tool') {
1.655 raeburn 1964: if ($prefixchg{$suffix} eq 'docstosupp') {
1.649 raeburn 1965: $info{'delgradable'} = 1;
1966: }
1967: }
1.596 raeburn 1968: if (($srcdom{$suffix} =~ /^$match_domain$/) && ($srcnum{$suffix} =~ /^$match_courseid$/)) {
1969: unless (($srcdom{$suffix} eq $coursedom) && ($srcnum{$suffix} eq $coursenum)) {
1970: $fromothercrs = 1;
1971: $info{'cdom'} = $srcdom{$suffix};
1972: $info{'cnum'} = $srcnum{$suffix};
1973: }
1974: }
1975: unless (($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') && (!$fromothercrs)) {
1.630 raeburn 1976: my (%lockerr,$msg);
1.538 raeburn 1977: my ($newurl,$result,$errtext) =
1978: &dbcopy(\%info,$coursedom,$coursenum,\%lockerr);
1979: if ($result eq 'ok') {
1980: $url = $newurl;
1981: $title=&mt('Copy of').' '.$title;
1982: } else {
1983: if ($prefix eq 'smppg') {
1984: $msg = &mt('Paste failed: An error occurred when copying the simple page.').' '.$errtext;
1985: } elsif ($prefix eq 'bulletinboard') {
1.565 bisitz 1986: $msg = &mt('Paste failed: An error occurred when copying the discussion board.').' '.$errtext;
1.627 raeburn 1987: } elsif ($prefix eq 'ext.tool') {
1988: $msg = &mt('Paste failed: An error occurred when copying the external tool.').' '.$errtext;
1.538 raeburn 1989: }
1990: $results{$suffix} = $result;
1991: $msgerrs{$suffix} = $msg;
1992: $lockerrs{$suffix} = $lockerr{$prefix};
1993: next;
1994: }
1995: if ($lockerr{$prefix}) {
1996: $lockerrs{$suffix} = $lockerr{$prefix};
1.491 raeburn 1997: }
1.489 raeburn 1998: }
1999: }
1.538 raeburn 2000: $title = &LONCAPA::map::qtunescape($title);
2001: my $ext='false';
2002: if ($url=~m{^http(|s)://}) { $ext='true'; }
2003: if ($env{'docs.markedcopy_supplemental_'.$suffix}) {
2004: if ($folder !~ /^supplemental/) {
2005: (undef,undef,$title) =
2006: &Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental_'.$suffix});
2007: }
2008: } else {
2009: if ($folder=~/^supplemental/) {
2010: $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
2011: $env{'user.domain'}.'___&&&___'.$title;
1.491 raeburn 2012: }
1.533 raeburn 2013: }
1.491 raeburn 2014:
2015: # For uploaded files (excluding pages/sequences) path in copied file is changed
2016: # if paste is from Main to Supplemental (or vice versa), or if pasting between
2017: # courses.
2018:
1.538 raeburn 2019: unless ($is_map{$suffix}) {
2020: my $newidx;
1.492 raeburn 2021: # Now insert the URL at the bottom
1.538 raeburn 2022: $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
2023: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(.+)$}) {
2024: my $relpath = $1;
2025: if ($relpath ne '') {
2026: my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$});
2027: my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/);
2028: my $newprefix = $newloc;
2029: if ($newloc eq 'default') {
2030: $newprefix = 'docs';
2031: }
2032: if ($newdocsdir eq '') {
2033: $newdocsdir = 'default';
2034: }
1.630 raeburn 2035: if (($prefixchg{$suffix}) ||
2036: ($srcdom{$suffix} ne $coursedom) ||
1.538 raeburn 2037: ($srcnum{$suffix} ne $coursenum) ||
2038: ($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) {
2039: my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";
2040: $url =
2041: &Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath,
2042: &Apache::lonnet::getfile($oldurl));
2043: if ($url eq '/adm/notfound.html') {
2044: $msgs{$suffix} = &mt('Paste failed: an error occurred saving the file.');
2045: next;
2046: } else {
2047: my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$});
2048: $newsubpath =~ s{/+$}{/};
2049: $docmoves{$oldurl} = $newsubpath;
2050: }
1.491 raeburn 2051: }
2052: }
1.597 raeburn 2053: } elsif ($url =~ m{^/res/lib/templates/(\w+)\.problem$}) {
2054: my $template = $1;
2055: if ($newidx) {
2056: ©_templated_files($url,$srcdom{$suffix},$srcnum{$suffix},$srcmapidx{$suffix},
2057: $coursedom,$coursenum,$template,$newidx,"$folder.$container");
2058: }
1.649 raeburn 2059: } elsif ($url =~ /ext\.tool$/) {
1.655 raeburn 2060: if (($newidx) && ($folder=~/^default/)) {
1.649 raeburn 2061: my $marker = (split(m{/},$url))[4];
2062: my %toolsettings = &Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
2063: my $val = 'no';
2064: if ($toolsettings{'gradable'}) {
2065: $val = 'yes';
2066: }
2067: &LONCAPA::map::storeparameter($newidx,'parameter_0_gradable',$val,
2068: 'string_yesno');
2069: &remember_parms($newidx,'gradable','set',$val);
2070: }
1.491 raeburn 2071: }
1.538 raeburn 2072: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
2073: ':'.$ext.':normal:res';
2074: push(@LONCAPA::map::order,$newidx);
2075: # Store the result
2076: my ($errtext,$fatal) =
2077: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
2078: if ($fatal) {
2079: $save_err .= $errtext;
2080: $allresult = 'fail';
2081: }
1.488 raeburn 2082: }
1.538 raeburn 2083:
1.597 raeburn 2084: # Apply any changes to maps, or copy dependencies for uploaded HTML pages, or update
2085: # resourcedata for simpleproblems copied from another course
1.538 raeburn 2086: unless ($allresult eq 'fail') {
2087: my %updated = (
2088: rewrites => \%rewrites,
2089: zombies => \%zombies,
2090: removefrommap => \%removefrommap,
2091: removeparam => \%removeparam,
2092: dbcopies => \%dbcopies,
1.597 raeburn 2093: resdatacopy => \%resdatacopy,
1.538 raeburn 2094: retitles => \%retitles,
2095: );
2096: my %info = (
2097: newsubdir => \%newsubdir,
2098: params => \%params,
2099: );
2100: if ($prefixchg{$suffix}) {
2101: $info{'before'} = $before{$prefixchg{$suffix}};
2102: $info{'after'} = $after{$prefixchg{$suffix}};
2103: }
2104: my %moves = (
2105: copies => \%copies,
2106: docmoves => \%docmoves,
2107: mapmoves => \%mapmoves,
2108: );
2109: (my $result,$msgs{$suffix},my $lockerror) =
2110: &apply_fixups($folder,$is_map{$suffix},$coursedom,$coursenum,$errors,
2111: \%updated,\%info,\%moves,$prefixchg{$suffix},$oldurl,
2112: $url,'paste');
2113: $lockerrors .= $lockerror;
2114: if ($result eq 'ok') {
2115: if ($is_map{$suffix}) {
2116: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
2117: $folder.'.'.$container);
2118: if ($fatal) {
2119: $allresult = 'failread';
2120: } else {
2121: if ($#LONCAPA::map::order<1) {
2122: my $idx=&LONCAPA::map::getresidx();
2123: if ($idx<=0) { $idx=1; }
2124: $LONCAPA::map::order[0]=$idx;
2125: $LONCAPA::map::resources[$idx]='';
2126: }
2127: my $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
2128: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
2129: ':'.$ext.':normal:res';
2130: push(@LONCAPA::map::order,$newidx);
1.492 raeburn 2131:
2132: # Store the result
1.538 raeburn 2133: my ($errtext,$fatal) =
2134: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
2135: if ($fatal) {
2136: $save_err .= $errtext;
2137: $allresult = 'failstore';
2138: }
2139: }
2140: }
2141: if ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
2142: push(@toclear,$suffix);
2143: }
2144: }
1.492 raeburn 2145: }
2146: }
1.538 raeburn 2147: &clear_from_buffer(\@toclear,\@currpaste);
2148: my $msgsarray;
2149: foreach my $suffix (keys(%msgs)) {
2150: if (ref($msgs{$suffix}) eq 'ARRAY') {
2151: $msgsarray .= join(',',@{$msgs{$suffix}});
2152: }
2153: }
2154: return ($allresult,$save_err,$msgsarray,$lockerrors);
2155: }
1.533 raeburn 2156:
1.538 raeburn 2157: sub do_buffer_empty {
2158: my @currpaste = split(/,/,$env{'docs.markedcopies'});
2159: if (@currpaste == 0) {
2160: return &mt('Clipboard is already empty');
2161: }
2162: my @toclear = &Apache::loncommon::get_env_multiple('form.pasting');
2163: if (@toclear == 0) {
2164: return &mt('Nothing selected to clear from clipboard');
2165: }
2166: my $numdel = &clear_from_buffer(\@toclear,\@currpaste);
2167: if ($numdel) {
2168: return &mt('[quant,_1,item] cleared from clipboard',$numdel);
2169: } else {
2170: return &mt('Clipboard unchanged');
1.492 raeburn 2171: }
1.538 raeburn 2172: return;
2173: }
2174:
2175: sub clear_from_buffer {
2176: my ($toclear,$currpaste) = @_;
2177: return unless ((ref($toclear) eq 'ARRAY') && (ref($currpaste) eq 'ARRAY'));
2178: my %pastebuffer;
2179: map { $pastebuffer{$_} = 1; } @{$currpaste};
2180: my $numdel = 0;
2181: foreach my $suffix (@{$toclear}) {
2182: next if ($suffix =~ /\D/);
2183: next unless (exists($pastebuffer{$suffix}));
2184: my $regexp = 'docs.markedcopy_[a-z]+_'.$suffix;
2185: if (&Apache::lonnet::delenv($regexp,1) eq 'ok') {
2186: delete($pastebuffer{$suffix});
2187: $numdel ++;
2188: }
2189: }
2190: my $newbuffer = join(',',sort(keys(%pastebuffer)));
2191: &Apache::lonnet::appenv({'docs.markedcopies' => $newbuffer});
2192: return $numdel;
1.492 raeburn 2193: }
2194:
2195: sub get_newmap_url {
2196: my ($url,$folder,$prefixchg,$coursedom,$coursenum,$srcdom,$srcnum,
2197: $titleref,$allmaps,$newurls) = @_;
2198: my $newurl;
2199: if ($url=~ m{^/uploaded/}) {
2200: $$titleref=&mt('Copy of').' '.$$titleref;
2201: }
2202: my $now = time;
2203: my $suffix=$$.int(rand(100)).$now;
2204: my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
2205: if ($oldid =~ m{^(/uploaded/$match_domain/$match_courseid/)(\D+)(\d+)$}) {
2206: my $path = $1;
2207: my $prefix = $2;
2208: my $ancestor = $3;
2209: if (length($ancestor) > 10) {
2210: $ancestor = substr($ancestor,-10,10);
2211: }
2212: my $newid;
2213: if ($prefixchg) {
2214: if ($folder =~ /^supplemental/) {
2215: $prefix =~ s/^default/supplemental/;
2216: } else {
2217: $prefix =~ s/^supplemental/default/;
2218: }
2219: }
2220: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
2221: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
2222: } else {
2223: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$now.'.'.$ext;
2224: }
2225: my $counter = 0;
2226: my $is_unique = &uniqueness_check($newurl);
2227: if ($folder =~ /^default/) {
2228: if ($allmaps->{$newurl}) {
2229: $is_unique = 0;
2230: }
2231: }
2232: while ((!$is_unique || $allmaps->{$newurl} || $newurls->{$newurl}) && ($counter < 100)) {
2233: $counter ++;
2234: $suffix ++;
2235: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
2236: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
2237: } else {
2238: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$ancestor.$suffix.'.'.$ext;
2239: }
2240: $is_unique = &uniqueness_check($newurl);
2241: }
2242: if ($is_unique) {
2243: $newurls->{$newurl} = 1;
2244: } else {
2245: if ($url=~/\.page$/) {
2246: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the composite page'));
2247: } else {
2248: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the folder'));
2249: }
2250: }
1.329 droeschl 2251: }
1.492 raeburn 2252: return ($newurl);
1.329 droeschl 2253: }
2254:
1.488 raeburn 2255: sub dbcopy {
1.533 raeburn 2256: my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_;
2257: my ($url,$result,$errtext);
2258: if (ref($dbref) eq 'HASH') {
1.596 raeburn 2259: $url = $dbref->{'src'};
1.627 raeburn 2260: if ($url =~ m{/(smppg|bulletinboard|ext\.tool)$}) {
1.533 raeburn 2261: my $prefix = $1;
1.627 raeburn 2262: if ($prefix eq 'ext.tool') {
2263: $prefix = 'exttool';
2264: }
1.533 raeburn 2265: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2266: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2267: my $db_name;
2268: my $marker = (split(m{/},$url))[4];
2269: $marker=~s/\D//g;
2270: if ($dbref->{'src'} =~ m{/smppg$}) {
2271: $db_name =
2272: &Apache::lonsimplepage::get_db_name($url,$marker,
2273: $dbref->{'cdom'},
2274: $dbref->{'cnum'});
1.627 raeburn 2275: } elsif ($dbref->{'src'} =~ m{/ext\.tool$}) {
2276: $db_name = 'exttool_'.$marker;
1.533 raeburn 2277: } else {
2278: $db_name = 'bulletinpage_'.$marker;
2279: }
2280: my ($suffix,$freedlock,$error) =
2281: &Apache::lonnet::get_timebased_id($prefix,'num','templated',
2282: $coursedom,$coursenum,
2283: 'concat');
2284: if (!$suffix) {
2285: if ($prefix eq 'smppg') {
2286: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);
1.631 raeburn 2287: } elsif ($prefix eq 'exttool') {
2288: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying an external tool [_1].',$url);
1.533 raeburn 2289: } else {
1.565 bisitz 2290: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url);
1.533 raeburn 2291: }
2292: if ($error) {
2293: $errtext .= '<br />'.$error;
2294: }
2295: } else {
2296: #need to copy the db contents to a new one.
2297: my %contents=&Apache::lonnet::dump($db_name,
2298: $dbref->{'cdom'},
2299: $dbref->{'cnum'});
2300: if (exists($contents{'uploaded.photourl'})) {
2301: my $photo = $contents{'uploaded.photourl'};
2302: my ($subdir,$fname) =
2303: ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});
1.596 raeburn 2304: my $newphoto;
1.533 raeburn 2305: if ($fname ne '') {
2306: my $content = &Apache::lonnet::getfile($photo);
2307: unless ($content eq '-1') {
2308: $env{'form.'.$suffix.'.photourl'} = $content;
2309: $newphoto =
2310: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");
2311: delete($env{'form.'.$suffix.'.photourl'});
2312: }
2313: }
2314: if ($newphoto =~ m{^/uploaded/}) {
2315: $contents{'uploaded.photourl'} = $newphoto;
2316: }
2317: }
2318: $db_name =~ s{_\d*$ }{_$suffix}x;
1.649 raeburn 2319: if (($prefix eq 'exttool') && ($dbref->{'delgradable'}) && ($contents{'gradable'})) {
2320: delete($contents{'gradable'});
2321: }
1.533 raeburn 2322: $result=&Apache::lonnet::put($db_name,\%contents,
2323: $coursedom,$coursenum);
2324: if ($result eq 'ok') {
1.627 raeburn 2325: $url =~ s{/(\d*)/(smppg|bulletinboard|ext\.tool)$}{/$suffix/$2}x;
1.533 raeburn 2326: }
2327: }
2328: if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) {
1.559 raeburn 2329: $lockerrorsref->{$prefix} =
1.533 raeburn 2330: '<div class="LC_error">'.
2331: &mt('There was a problem removing a lockfile.');
2332: if ($prefix eq 'smppg') {
1.560 raeburn 2333: $lockerrorsref->{$prefix} .=
1.559 raeburn 2334: ' '.&mt('This will prevent creation of additional simple pages in this course.');
1.627 raeburn 2335: } elsif ($prefix eq 'exttool') {
2336: $lockerrorsref->{$prefix} .=
2337: ' '.&mt('This will prevent addition of more external tools to this course.');
1.533 raeburn 2338: } else {
1.565 bisitz 2339: $lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional discussion boards in this course.');
1.533 raeburn 2340: }
1.560 raeburn 2341: $lockerrorsref->{$prefix} .= ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
2342: '<a href="/adm/helpdesk" target="_helpdesk">','</a>').
2343: '</div>';
1.533 raeburn 2344: }
2345: }
2346: } elsif ($url =~ m{/syllabus$}) {
2347: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2348: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2349: if (($dbref->{'cdom'} ne $coursedom) ||
2350: ($dbref->{'cnum'} ne $coursenum)) {
2351: my %contents=&Apache::lonnet::dump('syllabus',
2352: $dbref->{'cdom'},
2353: $dbref->{'cnum'});
2354: $result=&Apache::lonnet::put('syllabus',\%contents,
2355: $coursedom,$coursenum);
2356: }
2357: }
1.488 raeburn 2358: }
2359: }
1.533 raeburn 2360: return ($url,$result,$errtext);
1.488 raeburn 2361: }
2362:
1.597 raeburn 2363: sub copy_templated_files {
2364: my ($srcurl,$srcdom,$srcnum,$srcmapinfo,$coursedom,$coursenum,$template,$newidx,$newmapname) = @_;
2365: my ($srcfolder,$srcid,$srcwaspage) = split(/:/,$srcmapinfo);
2366: my $srccontainer = 'sequence';
2367: if ($srcwaspage) {
2368: $srccontainer = 'page';
2369: }
2370: my $srcsymb = "uploaded/$srcdom/$srcnum/$srcfolder.$srccontainer".
2371: '___'.$srcid.'___'.&Apache::lonnet::declutter($srcurl);
2372: my $srcprefix = $srcdom.'_'.$srcnum.'.'.$srcsymb;
2373: my %srcparms=&Apache::lonnet::dump('resourcedata',$srcdom,$srcnum,$srcprefix);
2374: my $newsymb = "uploaded/$coursedom/$coursenum/$newmapname".'___'.$newidx.'___lib/templates/'.
2375: $template.'.problem';
2376: my $newprefix = $coursedom.'_'.$coursenum.'.'.$newsymb;
2377: if ($template eq 'simpleproblem') {
2378: $srcprefix .= '.0.';
2379: my $weightprefix = $newprefix;
2380: $newprefix .= '.0.';
2381: my @simpleprobqtypes = qw(radio option string essay numerical);
2382: my $qtype=$srcparms{$srcprefix.'questiontype'};
2383: if (grep(/^\Q$qtype\E$/,@simpleprobqtypes)) {
1.665 raeburn 2384: my %newdata = (
2385: $newprefix.'questiontype' => $qtype,
2386: );
1.597 raeburn 2387: foreach my $type (@simpleprobqtypes) {
2388: if ($type eq $qtype) {
2389: $newdata{"$weightprefix.$type.weight"}=1;
2390: } else {
2391: $newdata{"$weightprefix.$type.weight"}=0;
2392: }
2393: }
2394: $newdata{$newprefix.'hiddenparts'} = '!'.$qtype;
2395: $newdata{$newprefix.'questiontext'} = $srcparms{$srcprefix.'questiontext'};
2396: $newdata{$newprefix.'hinttext'} = $srcparms{$srcprefix.'hinttext'};
2397: if ($qtype eq 'numerical') {
2398: $newdata{$newprefix.'numericalscript'} = $srcparms{$srcprefix.'numericalscript'};
2399: $newdata{$newprefix.'numericalanswer'} = $srcparms{$srcprefix.'numericalanswer'};
2400: $newdata{$newprefix.'numericaltolerance'} = $srcparms{$srcprefix.'numericaltolerance'};
2401: $newdata{$newprefix.'numericalsigfigs'} = $srcparms{$srcprefix.'numericalsigfigs'};
2402: } elsif (($qtype eq 'option') || ($qtype eq 'radio')) {
2403: my $maxfoils=$srcparms{$srcprefix.'maxfoils'};
2404: unless (defined($maxfoils)) { $maxfoils=10; }
2405: unless ($maxfoils=~/^\d+$/) { $maxfoils=10; }
2406: if ($maxfoils<=0) { $maxfoils=10; }
2407: my $randomize=$srcparms{$srcprefix.'randomize'};
2408: unless (defined($randomize)) { $randomize='yes'; }
2409: unless ($randomize eq 'no') { $randomize='yes'; }
2410: $newdata{$newprefix.'maxfoils'} = $maxfoils;
2411: $newdata{$newprefix.'randomize'} = $randomize;
2412: if ($qtype eq 'option') {
2413: $newdata{$newprefix.'options'} = $srcparms{$srcprefix.'options'};
2414: }
2415: for (my $i=1; $i<=10; $i++) {
2416: $newdata{$newprefix.'value'.$i} = $srcparms{$srcprefix.'value'.$i};
2417: $newdata{$newprefix.'position'.$i} = $srcparms{$srcprefix.'position'.$i};
2418: $newdata{$newprefix.'text'.$i} = $srcparms{$srcprefix.'text'.$i};
2419: }
2420:
2421: } elsif (($qtype eq 'option') || ($qtype eq 'radio')) {
2422: my $maxfoils=$srcparms{$srcprefix.'maxfoils'};
2423: unless (defined($maxfoils)) { $maxfoils=10; }
2424: unless ($maxfoils=~/^\d+$/) { $maxfoils=10; }
2425: if ($maxfoils<=0) { $maxfoils=10; }
2426: my $randomize=$srcparms{$srcprefix.'randomize'};
2427: unless (defined($randomize)) { $randomize='yes'; }
2428: unless ($randomize eq 'no') { $randomize='yes'; }
2429: $newdata{$newprefix.'maxfoils'} = $maxfoils;
2430: $newdata{$newprefix.'randomize'} = $randomize;
2431: if ($qtype eq 'option') {
2432: $newdata{$newprefix.'options'} = $srcparms{$srcprefix.'options'};
2433: }
2434: for (my $i=1; $i<=10; $i++) {
2435: $newdata{$newprefix.'value'.$i} = $srcparms{$srcprefix.'value'.$i};
2436: $newdata{$newprefix.'position'.$i} = $srcparms{$srcprefix.'position'.$i};
2437: $newdata{$newprefix.'text'.$i} = $srcparms{$srcprefix.'text'.$i};
2438: }
2439: } elsif ($qtype eq 'string') {
2440: $newdata{$newprefix.'stringanswer'} = $srcparms{$srcprefix.'stringanswer'};
2441: $newdata{$newprefix.'stringtype'} = $srcparms{$srcprefix.'stringtype'};
2442: }
2443: if (keys(%newdata)) {
2444: my $putres = &Apache::lonnet::cput('resourcedata',\%newdata,$coursedom,
2445: $coursenum);
2446: if ($putres eq 'ok') {
2447: &Apache::lonnet::devalidatecourseresdata($coursenum,$coursedom);
2448: }
2449: }
2450: }
2451: }
2452: }
2453:
1.329 droeschl 2454: sub uniqueness_check {
2455: my ($newurl) = @_;
2456: my $unique = 1;
2457: foreach my $res (@LONCAPA::map::order) {
2458: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2459: $url=&LONCAPA::map::qtescape($url);
2460: if ($newurl eq $url) {
2461: $unique = 0;
1.344 bisitz 2462: last;
1.329 droeschl 2463: }
2464: }
2465: return $unique;
2466: }
2467:
1.488 raeburn 2468: sub contained_map_check {
1.627 raeburn 2469: my ($url,$folder,$coursenum,$coursedom,$removefrommap,$removeparam,$addedmaps,
2470: $hierarchy,$titles,$allmaps) = @_;
1.488 raeburn 2471: my $content = &Apache::lonnet::getfile($url);
2472: unless ($content eq '-1') {
2473: my $parser = HTML::TokeParser->new(\$content);
2474: $parser->attr_encoded(1);
2475: while (my $token = $parser->get_token) {
2476: next if ($token->[0] ne 'S');
2477: if ($token->[1] eq 'resource') {
2478: next if ($token->[2]->{'type'} eq 'zombie');
2479: my $ressrc = $token->[2]->{'src'};
1.627 raeburn 2480: if ($ressrc =~ m{^/adm/($match_domain)/$match_courseid/\d+/ext\.tool$}) {
2481: my $srcdom = $1;
2482: unless ($srcdom eq $coursedom) {
2483: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2484: next;
2485: }
2486: } elsif ($folder =~ /^supplemental/) {
1.488 raeburn 2487: unless (&supp_pasteable($ressrc)) {
1.492 raeburn 2488: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.488 raeburn 2489: next;
2490: }
2491: }
1.492 raeburn 2492: if ($ressrc =~ m{^/(res|uploaded)/.+\.(sequence|page)$}) {
2493: if ($1 eq 'uploaded') {
2494: $hierarchy->{$url}{$token->[2]->{'id'}} = $ressrc;
2495: $titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'};
1.488 raeburn 2496: } else {
1.492 raeburn 2497: if ($allmaps->{$ressrc}) {
1.529 raeburn 2498: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.492 raeburn 2499: } elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') {
2500: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2501: } else {
2502: $addedmaps->{$ressrc} = [$url];
2503: }
1.488 raeburn 2504: }
1.627 raeburn 2505: &contained_map_check($ressrc,$folder,$coursenum,$coursedom,$removefrommap,
2506: $removeparam,$addedmaps,$hierarchy,$titles,$allmaps);
1.488 raeburn 2507: }
1.492 raeburn 2508: } elsif ($token->[1] eq 'param') {
1.488 raeburn 2509: if ($folder =~ /^supplemental/) {
1.492 raeburn 2510: if (ref($removeparam->{$url}{$token->[2]->{'to'}}) eq 'ARRAY') {
2511: push(@{$removeparam->{$url}{$token->[2]->{'to'}}},$token->[2]->{'name'});
2512: } else {
2513: $removeparam->{$url}{$token->[2]->{'to'}} = [$token->[2]->{'name'}];
2514: }
1.488 raeburn 2515: }
2516: }
2517: }
2518: }
2519: return;
2520: }
2521:
2522: sub url_paste_fixups {
1.533 raeburn 2523: my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$fromcdom,$fromcnum,$allmaps,
2524: $rewrites,$retitles,$copies,$dbcopies,$zombies,$params,$mapmoves,
1.597 raeburn 2525: $mapchanges,$tomove,$newsubdir,$newurls,$resdatacopy) = @_;
1.491 raeburn 2526: my $checktitle;
2527: if (($prefixchg) &&
1.492 raeburn 2528: ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) {
1.491 raeburn 2529: $checktitle = 1;
2530: }
1.492 raeburn 2531: my $skip;
2532: if ($oldurl =~ m{^\Q/uploaded/$cdom/$cnum/\E(default|supplemental)(_?\d*)\.(?:page|sequence)$}) {
2533: my $mapid = $1.$2;
2534: if ($tomove->{$mapid}) {
2535: $skip = 1;
2536: }
2537: }
1.491 raeburn 2538: my $file = &Apache::lonnet::getfile($oldurl);
1.488 raeburn 2539: return if ($file eq '-1');
2540: my $parser = HTML::TokeParser->new(\$file);
2541: $parser->attr_encoded(1);
1.491 raeburn 2542: my $changed = 0;
1.488 raeburn 2543: while (my $token = $parser->get_token) {
2544: next if ($token->[0] ne 'S');
2545: if ($token->[1] eq 'resource') {
2546: my $ressrc = $token->[2]->{'src'};
2547: next if ($ressrc eq '');
1.491 raeburn 2548: my $id = $token->[2]->{'id'};
1.492 raeburn 2549: my $title = $token->[2]->{'title'};
1.491 raeburn 2550: if ($checktitle) {
2551: if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1.532 raeburn 2552: $retitles->{$oldurl}{$id} = $ressrc;
1.491 raeburn 2553: }
2554: }
1.488 raeburn 2555: next if ($token->[2]->{'type'} eq 'external');
2556: if ($token->[2]->{'type'} eq 'zombie') {
1.492 raeburn 2557: next if ($skip);
1.532 raeburn 2558: $zombies->{$oldurl}{$id} = $ressrc;
1.491 raeburn 2559: $changed = 1;
2560: } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1.492 raeburn 2561: my $srcdom = $1;
2562: my $srcnum = $2;
1.488 raeburn 2563: my $rem = $3;
1.492 raeburn 2564: my $newurl;
2565: my $mapname;
2566: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
2567: my $prefix = $1;
2568: $mapname = $prefix.$2;
2569: if ($tomove->{$mapname}) {
1.533 raeburn 2570: &url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,
2571: $srcdom,$srcnum,$allmaps,$rewrites,
2572: $retitles,$copies,$dbcopies,$zombies,
2573: $params,$mapmoves,$mapchanges,$tomove,
1.597 raeburn 2574: $newsubdir,$newurls,$resdatacopy);
1.492 raeburn 2575: next;
2576: } else {
2577: ($newurl,my $error) =
2578: &get_newmap_url($ressrc,$folder,$prefixchg,$cdom,$cnum,
2579: $srcdom,$srcnum,\$title,$allmaps,$newurls);
2580: if ($newurl =~ /(?:default|supplemental)_(\d+)\.(?:sequence|page)$/) {
2581: $newsubdir->{$ressrc} = $1;
2582: }
2583: if ($error) {
2584: next;
2585: }
2586: }
2587: }
2588: if (($srcdom ne $cdom) || ($srcnum ne $cnum) || ($prefixchg) ||
2589: ($mapchanges->{$oldurl}) || (($newurl ne '') && ($newurl ne $oldurl))) {
2590:
1.488 raeburn 2591: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
1.532 raeburn 2592: $rewrites->{$oldurl}{$id} = $ressrc;
1.491 raeburn 2593: $mapchanges->{$ressrc} = 1;
1.533 raeburn 2594: unless (&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,
2595: $cnum,$srcdom,$srcnum,$allmaps,
2596: $rewrites,$retitles,$copies,$dbcopies,
2597: $zombies,$params,$mapmoves,$mapchanges,
1.597 raeburn 2598: $tomove,$newsubdir,$newurls,$resdatacopy)) {
1.491 raeburn 2599: $mapmoves->{$ressrc} = 1;
2600: }
2601: $changed = 1;
1.488 raeburn 2602: } else {
1.532 raeburn 2603: $rewrites->{$oldurl}{$id} = $ressrc;
1.488 raeburn 2604: $copies->{$oldurl}{$ressrc} = $id;
1.491 raeburn 2605: $changed = 1;
1.488 raeburn 2606: }
2607: }
1.649 raeburn 2608: } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/(.+)$}) {
1.533 raeburn 2609: next if ($skip);
1.492 raeburn 2610: my $srcdom = $1;
2611: my $srcnum = $2;
1.649 raeburn 2612: my $rem = $3;
2613: my ($is_exttool,$exttoolchg);
2614: if ($rem =~ m{\d+/ext\.tool$}) {
1.655 raeburn 2615: $is_exttool = 1;
1.649 raeburn 2616: }
1.492 raeburn 2617: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.532 raeburn 2618: $rewrites->{$oldurl}{$id} = $ressrc;
1.533 raeburn 2619: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2620: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2621: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
2622: $changed = 1;
1.649 raeburn 2623: if ($is_exttool) {
2624: $exttoolchg = 1;
2625: }
2626: } elsif (($rem =~ m{\d+/ext\.tool$}) &&
2627: ($env{'form.docs.markedcopy_options'} ne 'move')) {
2628: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2629: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2630: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
2631: $changed = 1;
2632: $exttoolchg = 1;
2633: }
2634: if (($is_exttool) && ($prefixchg)) {
2635: if ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/default}) {
2636: if ($exttoolchg) {
2637: $dbcopies->{$oldurl}{$id}{'delgradable'} = 1;
2638: }
2639: }
1.533 raeburn 2640: }
2641: } elsif ($ressrc =~ m{^/adm/$match_domain/$match_username/\d+/(smppg|bulletinboard)$}) {
2642: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum) ||
2643: ($env{'form.docs.markedcopy_options'} ne 'move')) {
2644: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2645: $dbcopies->{$oldurl}{$id}{'cdom'} = $fromcdom;
2646: $dbcopies->{$oldurl}{$id}{'cnum'} = $fromcnum;
1.491 raeburn 2647: $changed = 1;
1.488 raeburn 2648: }
1.597 raeburn 2649: } elsif ($ressrc eq '/res/lib/templates/simpleproblem.problem') {
2650: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum)) {
2651: $resdatacopy->{$oldurl}{$id}{'src'} = $ressrc;
2652: $resdatacopy->{$oldurl}{$id}{'cdom'} = $fromcdom;
2653: $resdatacopy->{$oldurl}{$id}{'cnum'} = $fromcnum;
2654: }
1.488 raeburn 2655: } elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) {
1.492 raeburn 2656: next if ($skip);
2657: my $srcdom = $1;
2658: my $srcnum = $2;
2659: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.533 raeburn 2660: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2661: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2662: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
1.491 raeburn 2663: $changed = 1;
1.488 raeburn 2664: }
2665: }
2666: } elsif ($token->[1] eq 'param') {
1.492 raeburn 2667: next if ($skip);
1.488 raeburn 2668: my $to = $token->[2]->{'to'};
2669: if ($to ne '') {
2670: if (ref($params->{$oldurl}{$to}) eq 'ARRAY') {
1.492 raeburn 2671: push(@{$params->{$oldurl}{$to}},$token->[2]->{'name'});
1.488 raeburn 2672: } else {
2673: @{$params->{$oldurl}{$to}} = ($token->[2]->{'name'});
2674: }
2675: }
2676: }
2677: }
1.491 raeburn 2678: return $changed;
1.488 raeburn 2679: }
2680:
2681: sub apply_fixups {
1.529 raeburn 2682: my ($folder,$is_map,$cdom,$cnum,$errors,$updated,$info,$moves,$prefixchg,
2683: $oldurl,$url,$caller) = @_;
2684: my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles,
1.533 raeburn 2685: %params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs,
1.597 raeburn 2686: %resdatacopy,%lockerrors,$lockmsg);
1.529 raeburn 2687: if (ref($updated) eq 'HASH') {
2688: if (ref($updated->{'rewrites'}) eq 'HASH') {
2689: %rewrites = %{$updated->{'rewrites'}};
2690: }
2691: if (ref($updated->{'zombies'}) eq 'HASH') {
2692: %zombies = %{$updated->{'zombies'}};
2693: }
2694: if (ref($updated->{'removefrommap'}) eq 'HASH') {
2695: %removefrommap = %{$updated->{'removefrommap'}};
2696: }
2697: if (ref($updated->{'removeparam'}) eq 'HASH') {
2698: %removeparam = %{$updated->{'removeparam'}};
2699: }
2700: if (ref($updated->{'dbcopies'}) eq 'HASH') {
2701: %dbcopies = %{$updated->{'dbcopies'}};
2702: }
2703: if (ref($updated->{'retitles'}) eq 'HASH') {
2704: %retitles = %{$updated->{'retitles'}};
2705: }
1.597 raeburn 2706: if (ref($updated->{'resdatacopy'}) eq 'HASH') {
2707: %resdatacopy = %{$updated->{'resdatacopy'}};
2708: }
1.529 raeburn 2709: }
2710: if (ref($info) eq 'HASH') {
2711: if (ref($info->{'newsubdir'}) eq 'HASH') {
2712: %newsubdir = %{$info->{'newsubdir'}};
2713: }
2714: if (ref($info->{'params'}) eq 'HASH') {
2715: %params = %{$info->{'params'}};
2716: }
2717: if (ref($info->{'before'}) eq 'HASH') {
2718: %before = %{$info->{'before'}};
2719: }
2720: if (ref($info->{'after'}) eq 'HASH') {
2721: %after = %{$info->{'after'}};
2722: }
2723: }
2724: if (ref($moves) eq 'HASH') {
2725: if (ref($moves->{'copies'}) eq 'HASH') {
2726: %copies = %{$moves->{'copies'}};
2727: }
2728: if (ref($moves->{'docmoves'}) eq 'HASH') {
2729: %docmoves = %{$moves->{'docmoves'}};
2730: }
2731: if (ref($moves->{'mapmoves'}) eq 'HASH') {
2732: %mapmoves = %{$moves->{'mapmoves'}};
2733: }
2734: }
2735: foreach my $key (keys(%copies),keys(%docmoves)) {
1.491 raeburn 2736: my @allcopies;
1.529 raeburn 2737: if (exists($copies{$key})) {
2738: if (ref($copies{$key}) eq 'HASH') {
2739: my %added;
2740: foreach my $innerkey (keys(%{$copies{$key}})) {
2741: if (($innerkey ne '') && (!$added{$innerkey})) {
2742: push(@allcopies,$innerkey);
2743: $added{$innerkey} = 1;
2744: }
1.491 raeburn 2745: }
1.529 raeburn 2746: undef(%added);
1.491 raeburn 2747: }
2748: }
2749: if ($key eq $oldurl) {
1.529 raeburn 2750: if ((exists($docmoves{$key}))) {
1.532 raeburn 2751: unless (grep(/^\Q$oldurl\E$/,@allcopies)) {
1.491 raeburn 2752: push(@allcopies,$oldurl);
2753: }
2754: }
2755: }
2756: if (@allcopies > 0) {
2757: foreach my $item (@allcopies) {
1.492 raeburn 2758: my ($relpath,$oldsubdir,$fname) =
2759: ($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(default|\d+)/.*/)([^/]+)$});
1.491 raeburn 2760: if ($fname ne '') {
2761: my $content = &Apache::lonnet::getfile($item);
2762: unless ($content eq '-1') {
2763: my $storefn;
1.529 raeburn 2764: if (($key eq $oldurl) && (exists($docmoves{$key}))) {
2765: $storefn = $docmoves{$key};
1.491 raeburn 2766: } else {
2767: $storefn = $relpath;
2768: $storefn =~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 2769: if ($prefixchg && $before{'doc'} && $after{'doc'}) {
2770: $storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/;
1.491 raeburn 2771: }
1.529 raeburn 2772: if ($newsubdir{$key}) {
1.532 raeburn 2773: $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}/#;
1.491 raeburn 2774: }
2775: }
2776: ©_dependencies($item,$storefn,$relpath,$errors,\$content);
2777: my $copyurl =
2778: &Apache::lonclonecourse::writefile($env{'request.course.id'},
2779: $storefn.$fname,$content);
2780: if ($copyurl eq '/adm/notfound.html') {
1.529 raeburn 2781: if (exists($docmoves{$oldurl})) {
1.491 raeburn 2782: return &mt('Paste failed: an error occurred copying the file.');
2783: } elsif (ref($errors) eq 'HASH') {
2784: $errors->{$item} = 1;
1.489 raeburn 2785: }
2786: }
1.488 raeburn 2787: }
2788: }
1.491 raeburn 2789: }
2790: }
2791: }
1.529 raeburn 2792: foreach my $key (keys(%mapmoves)) {
1.491 raeburn 2793: my $storefn=$key;
2794: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 2795: if ($prefixchg && $before{'map'} && $after{'map'}) {
2796: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.491 raeburn 2797: }
1.529 raeburn 2798: if ($newsubdir{$key}) {
2799: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.492 raeburn 2800: }
1.491 raeburn 2801: my $mapcontent = &Apache::lonnet::getfile($key);
1.681 raeburn 2802: if (($mapcontent eq '-1') && ($before{'map'} eq 'supplemental') &&
2803: ($after{'map'} eq 'default') &&
2804: ($key =~ m{^/uploaded/$match_domain/$match_courseid/supplemental_\d+\.sequence$})) {
2805: $mapcontent = '<map>'."\n".
2806: '<resource id="1" src="" type="start" />'."\n".
2807: '<link from="1" to="2" index="1" />'."\n".
2808: '<resource id="2" src="" type="finish" />'."\n".
2809: '</map>';
2810: }
1.491 raeburn 2811: if ($mapcontent eq '-1') {
2812: if (ref($errors) eq 'HASH') {
2813: $errors->{$key} = 1;
2814: }
2815: } else {
2816: my $newmap =
2817: &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
2818: $mapcontent);
2819: if ($newmap eq '/adm/notfound.html') {
2820: if (ref($errors) eq 'HASH') {
2821: $errors->{$key} = 1;
1.489 raeburn 2822: }
1.488 raeburn 2823: }
2824: }
2825: }
1.491 raeburn 2826: my %updates;
2827: if ($is_map) {
1.529 raeburn 2828: if (ref($updated) eq 'HASH') {
2829: foreach my $type (keys(%{$updated})) {
2830: if (ref($updated->{$type}) eq 'HASH') {
2831: foreach my $key (keys(%{$updated->{$type}})) {
2832: $updates{$key} = 1;
2833: }
2834: }
2835: }
1.491 raeburn 2836: }
2837: foreach my $key (keys(%updates)) {
1.492 raeburn 2838: my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb);
1.529 raeburn 2839: if (ref($rewrites{$key}) eq 'HASH') {
2840: %torewrite = %{$rewrites{$key}};
1.491 raeburn 2841: }
1.529 raeburn 2842: if (ref($retitles{$key}) eq 'HASH') {
2843: %toretitle = %{$retitles{$key}};
1.491 raeburn 2844: }
1.529 raeburn 2845: if (ref($removefrommap{$key}) eq 'HASH') {
2846: %toremove = %{$removefrommap{$key}};
1.491 raeburn 2847: }
1.529 raeburn 2848: if (ref($removeparam{$key}) eq 'HASH') {
2849: %remparam = %{$removeparam{$key}};
1.492 raeburn 2850: }
1.529 raeburn 2851: if (ref($zombies{$key}) eq 'HASH') {
2852: %zombie = %{$zombies{$key}};
1.491 raeburn 2853: }
1.529 raeburn 2854: if (ref($dbcopies{$key}) eq 'HASH') {
1.533 raeburn 2855: foreach my $idx (keys(%{$dbcopies{$key}})) {
2856: if (ref($dbcopies{$key}{$idx}) eq 'HASH') {
2857: my ($newurl,$result,$errtext) =
2858: &dbcopy($dbcopies{$key}{$idx},$cdom,$cnum,\%lockerrors);
2859: if ($result eq 'ok') {
2860: $newdb{$idx} = $newurl;
2861: } elsif (ref($errors) eq 'HASH') {
2862: $errors->{$key} = 1;
2863: }
2864: push(@msgs,$errtext);
2865: }
1.491 raeburn 2866: }
2867: }
1.597 raeburn 2868: if (ref($resdatacopy{$key}) eq 'HASH') {
1.664 raeburn 2869: my ($gotnewmapname,$newmapname,$srcfolder,$srccontainer);
1.597 raeburn 2870: foreach my $idx (keys(%{$resdatacopy{$key}})) {
2871: if (ref($resdatacopy{$key}{$idx}) eq 'HASH') {
2872: my $srcurl = $resdatacopy{$key}{$idx}{'src'};
2873: if ($srcurl =~ m{^/res/lib/templates/(\w+)\.problem$}) {
2874: my $template = $1;
2875: if (($resdatacopy{$key}{$idx}{'cdom'} =~ /^$match_domain$/) &&
2876: ($resdatacopy{$key}{$idx}{'cnum'} =~ /^$match_courseid$/)) {
2877: my $srcdom = $resdatacopy{$key}{$idx}{'cdom'};
2878: my $srcnum = $resdatacopy{$key}{$idx}{'cnum'};
1.664 raeburn 2879: unless ($gotnewmapname) {
2880: ($newmapname) = ($key =~ m{/([^/]+)$});
2881: ($srcfolder,$srccontainer) = split(/\./,$newmapname);
2882: if ($newsubdir{$key}) {
2883: $newmapname =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
2884: }
2885: $gotnewmapname = 1;
2886: }
1.597 raeburn 2887: my $srcmapinfo = $srcfolder.':'.$idx;
2888: if ($srccontainer eq 'page') {
2889: $srcmapinfo .= ':1';
2890: }
2891: ©_templated_files($srcurl,$srcdom,$srcnum,$srcmapinfo,$cdom,
2892: $cnum,$template,$idx,$newmapname);
2893: }
2894: }
2895: }
2896: }
2897: }
1.529 raeburn 2898: if (ref($params{$key}) eq 'HASH') {
2899: %currparam = %{$params{$key}};
1.492 raeburn 2900: }
2901: my ($errtext,$fatal) = &LONCAPA::map::mapread($key);
2902: if ($fatal) {
1.533 raeburn 2903: return ($errtext);
1.492 raeburn 2904: }
2905: for (my $i=0; $i<@LONCAPA::map::zombies; $i++) {
2906: if (defined($LONCAPA::map::zombies[$i])) {
2907: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::zombies[$i]);
1.532 raeburn 2908: if ($zombie{$i} eq $src) {
1.492 raeburn 2909: undef($LONCAPA::map::zombies[$i]);
2910: }
2911: }
2912: }
1.646 raeburn 2913: my $total = scalar(@LONCAPA::map::order) - 1;
2914: for (my $i=$total; $i>=0; $i--) {
1.529 raeburn 2915: my $idx = $LONCAPA::map::order[$i];
2916: if (defined($LONCAPA::map::resources[$idx])) {
1.492 raeburn 2917: my $changed;
1.529 raeburn 2918: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]);
1.538 raeburn 2919: if ((exists($toremove{$idx})) &&
2920: ($toremove{$idx} eq &LONCAPA::map::qtescape($src))) {
1.492 raeburn 2921: splice(@LONCAPA::map::order,$i,1);
1.529 raeburn 2922: if (ref($currparam{$idx}) eq 'ARRAY') {
2923: foreach my $name (@{$currparam{$idx}}) {
1.647 raeburn 2924: &LONCAPA::map::delparameter($idx,$name);
1.492 raeburn 2925: }
2926: }
2927: next;
2928: }
2929: my $origsrc = $src;
1.532 raeburn 2930: if ((exists($toretitle{$idx})) && ($toretitle{$idx} eq $src)) {
1.492 raeburn 2931: if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
2932: $changed = 1;
1.491 raeburn 2933: }
1.492 raeburn 2934: }
1.532 raeburn 2935: if ((exists($torewrite{$idx})) && ($torewrite{$idx} eq $src)) {
1.492 raeburn 2936: $src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
2937: if ($origsrc =~ m{^/uploaded/}) {
1.529 raeburn 2938: if ($prefixchg && $before{'map'} && $after{'map'}) {
1.492 raeburn 2939: if ($src =~ /\.(page|sequence)$/) {
1.529 raeburn 2940: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'map'}\E#$1$after{'map'}#;
1.492 raeburn 2941: } else {
1.529 raeburn 2942: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
1.488 raeburn 2943: }
1.491 raeburn 2944: }
1.532 raeburn 2945: if ($origsrc =~ /\.(page|sequence)$/) {
2946: if ($newsubdir{$origsrc}) {
1.529 raeburn 2947: $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir{$origsrc}#;
1.491 raeburn 2948: }
1.532 raeburn 2949: } elsif ($newsubdir{$key}) {
2950: $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$key}#;
1.488 raeburn 2951: }
2952: }
1.492 raeburn 2953: $changed = 1;
1.533 raeburn 2954: } elsif ($newdb{$idx} ne '') {
2955: $src = $newdb{$idx};
1.492 raeburn 2956: $changed = 1;
2957: }
2958: if ($changed) {
1.538 raeburn 2959: $LONCAPA::map::resources[$idx] = join(':',($title,&LONCAPA::map::qtunescape($src),$ext,$type));
1.492 raeburn 2960: }
2961: }
2962: }
2963: foreach my $idx (keys(%remparam)) {
2964: if (ref($remparam{$idx}) eq 'ARRAY') {
2965: foreach my $name (@{$remparam{$idx}}) {
1.647 raeburn 2966: &LONCAPA::map::delparameter($idx,$name);
1.491 raeburn 2967: }
2968: }
2969: }
1.533 raeburn 2970: if (values(%lockerrors) > 0) {
2971: $lockmsg = join('<br />',values(%lockerrors));
2972: }
1.491 raeburn 2973: my $storefn;
2974: if ($key eq $oldurl) {
2975: $storefn = $url;
2976: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
2977: } else {
2978: $storefn = $key;
2979: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 2980: if ($prefixchg && $before{'map'} && $after{'map'}) {
2981: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.491 raeburn 2982: }
1.529 raeburn 2983: if ($newsubdir{$key}) {
2984: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.492 raeburn 2985: }
1.491 raeburn 2986: }
1.492 raeburn 2987: my $report;
2988: if ($folder !~ /^supplemental/) {
2989: $report = 1;
2990: }
1.527 raeburn 2991: (my $outtext,$errtext) =
1.492 raeburn 2992: &LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report);
2993: if ($errtext) {
1.529 raeburn 2994: if ($caller eq 'paste') {
1.533 raeburn 2995: return (&mt('Paste failed: an error occurred saving the folder or page.'));
1.529 raeburn 2996: }
1.491 raeburn 2997: }
2998: }
2999: }
1.533 raeburn 3000: return ('ok',\@msgs,$lockmsg);
1.491 raeburn 3001: }
3002:
3003: sub copy_dependencies {
3004: my ($item,$storefn,$relpath,$errors,$contentref) = @_;
3005: my $content;
3006: if (ref($contentref)) {
3007: $content = $$contentref;
3008: } else {
3009: $content = &Apache::lonnet::getfile($item);
3010: }
3011: unless ($content eq '-1') {
3012: my $mm = new File::MMagic;
3013: my $mimetype = $mm->checktype_contents($content);
3014: if ($mimetype eq 'text/html') {
3015: my (%allfiles,%codebase,$state);
3016: my $res = &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,\$content);
3017: if ($res eq 'ok') {
3018: my ($numexisting,$numpathchanges,$existing);
3019: (undef,$numexisting,$numpathchanges,$existing) =
3020: &Apache::loncommon::ask_for_embedded_content(
3021: '/adm/coursedocs',$state,\%allfiles,\%codebase,
3022: {'error_on_invalid_names' => 1,
3023: 'ignore_remote_references' => 1,
3024: 'docs_url' => $item,
3025: 'context' => 'paste'});
3026: if ($numexisting > 0) {
3027: if (ref($existing) eq 'HASH') {
3028: foreach my $dep (keys(%{$existing})) {
3029: my $depfile = $dep;
3030: unless ($depfile =~ m{^\Q$relpath\E}) {
3031: $depfile = $relpath.$dep;
3032: }
3033: my $depcontent = &Apache::lonnet::getfile($depfile);
3034: unless ($depcontent eq '-1') {
3035: my $storedep = $dep;
3036: $storedep =~ s{^\Q$relpath\E}{};
3037: my $dep_url =
3038: &Apache::lonclonecourse::writefile(
3039: $env{'request.course.id'},
3040: $storefn.$storedep,$depcontent);
3041: if ($dep_url eq '/adm/notfound.html') {
3042: if (ref($errors) eq 'HASH') {
3043: $errors->{$depfile} = 1;
3044: }
3045: } else {
3046: ©_dependencies($depfile,$storefn,$relpath,$errors,\$depcontent);
3047: }
3048: }
3049: }
1.488 raeburn 3050: }
3051: }
3052: }
3053: }
3054: }
3055: return;
3056: }
3057:
1.329 droeschl 3058: my %parameter_type = ( 'randompick' => 'int_pos',
3059: 'hiddenresource' => 'string_yesno',
3060: 'encrypturl' => 'string_yesno',
3061: 'randomorder' => 'string_yesno',);
3062: my $valid_parameters_re = join('|',keys(%parameter_type));
3063: # set parameters
3064: sub update_parameter {
1.537 raeburn 3065: if ($env{'form.changeparms'} eq 'all') {
3066: my (@allidx,@allmapidx,%allchecked,%currchecked);
3067: %allchecked = (
3068: 'hiddenresource' => {},
3069: 'encrypturl' => {},
3070: 'randompick' => {},
3071: 'randomorder' => {},
3072: );
3073: foreach my $which (keys(%allchecked)) {
1.630 raeburn 3074: $env{'form.all'.$which} =~ s/,$//;
1.537 raeburn 3075: if ($which eq 'randompick') {
3076: foreach my $item (split(/,/,$env{'form.all'.$which})) {
3077: my ($res,$value) = split(/:/,$item);
3078: if ($value =~ /^\d+$/) {
3079: $allchecked{$which}{$res} = $value;
3080: }
3081: }
3082: } else {
1.539 raeburn 3083: if ($env{'form.all'.$which}) {
3084: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.all'.$which});
3085: }
1.537 raeburn 3086: }
3087: }
3088: my $haschanges = 0;
3089: foreach my $res (@LONCAPA::map::order) {
3090: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3091: $name=&LONCAPA::map::qtescape($name);
3092: $url=&LONCAPA::map::qtescape($url);
3093: next unless ($name && $url);
3094: my $is_map;
3095: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
3096: $is_map = 1;
3097: }
3098: foreach my $which (keys(%allchecked)) {
3099: if (($which eq 'randompick' || $which eq 'randomorder')) {
3100: next if (!$is_map);
3101: }
3102: my $oldvalue = 0;
3103: my $newvalue = 0;
3104: if ($allchecked{$which}{$res}) {
3105: $newvalue = $allchecked{$which}{$res};
3106: }
3107: my $current = (&LONCAPA::map::getparameter($res,'parameter_'.$which))[0];
3108: if ($which eq 'randompick') {
3109: if ($current =~ /^(\d+)$/) {
3110: $oldvalue = $1;
3111: }
3112: } else {
3113: if ($current =~ /^yes$/i) {
3114: $oldvalue = 1;
3115: }
3116: }
3117: if ($oldvalue ne $newvalue) {
3118: $haschanges = 1;
3119: if ($newvalue) {
3120: my $storeval = 'yes';
3121: if ($which eq 'randompick') {
3122: $storeval = $newvalue;
3123: }
3124: &LONCAPA::map::storeparameter($res,'parameter_'.$which,
3125: $storeval,
3126: $parameter_type{$which});
3127: &remember_parms($res,$which,'set',$storeval);
3128: } elsif ($oldvalue) {
3129: &LONCAPA::map::delparameter($res,'parameter_'.$which);
3130: &remember_parms($res,$which,'del');
3131: }
3132: }
3133: }
3134: }
3135: return $haschanges;
3136: } else {
1.588 raeburn 3137: my $haschanges = 0;
3138: return $haschanges if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
1.329 droeschl 3139:
1.537 raeburn 3140: my $which = $env{'form.changeparms'};
3141: my $idx = $env{'form.setparms'};
1.588 raeburn 3142: my $oldvalue = 0;
3143: my $newvalue = 0;
3144: my $current = (&LONCAPA::map::getparameter($idx,'parameter_'.$which))[0];
3145: if ($which eq 'randompick') {
3146: if ($current =~ /^(\d+)$/) {
3147: $oldvalue = $1;
3148: }
3149: } elsif ($current =~ /^yes$/i) {
3150: $oldvalue = 1;
3151: }
1.537 raeburn 3152: if ($env{'form.'.$which.'_'.$idx}) {
1.588 raeburn 3153: $newvalue = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx}
3154: : 1;
3155: }
3156: if ($oldvalue ne $newvalue) {
3157: $haschanges = 1;
3158: if ($newvalue) {
3159: my $storeval = 'yes';
3160: if ($which eq 'randompick') {
3161: $storeval = $newvalue;
3162: }
3163: &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $storeval,
3164: $parameter_type{$which});
3165: &remember_parms($idx,$which,'set',$storeval);
3166: } else {
3167: &LONCAPA::map::delparameter($idx,'parameter_'.$which);
3168: &remember_parms($idx,$which,'del');
3169: }
1.537 raeburn 3170: }
1.588 raeburn 3171: return $haschanges;
1.329 droeschl 3172: }
3173: }
3174:
3175: sub handle_edit_cmd {
3176: my ($coursenum,$coursedom) =@_;
1.633 raeburn 3177: my $haschanges = 0;
1.543 raeburn 3178: if ($env{'form.cmd'} eq '') {
1.633 raeburn 3179: return $haschanges;
1.543 raeburn 3180: }
1.329 droeschl 3181: my ($cmd,$idx)=split('_',$env{'form.cmd'});
3182:
3183: my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
3184: my ($title, $url, @rrest) = split(':', $ratstr);
3185:
1.538 raeburn 3186: if ($cmd eq 'remove') {
1.329 droeschl 3187: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
1.463 www 3188: ($url!~/$LONCAPA::assess_page_seq_re/)) {
1.329 droeschl 3189: &Apache::lonnet::removeuploadedurl($url);
3190: } else {
3191: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
3192: }
3193: splice(@LONCAPA::map::order, $idx, 1);
1.633 raeburn 3194: $haschanges = 1;
1.329 droeschl 3195: } elsif ($cmd eq 'cut') {
3196: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
3197: splice(@LONCAPA::map::order, $idx, 1);
1.633 raeburn 3198: $haschanges = 1;
1.344 bisitz 3199: } elsif ($cmd eq 'up'
1.329 droeschl 3200: && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
3201: @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
1.633 raeburn 3202: $haschanges = 1;
1.329 droeschl 3203: } elsif ($cmd eq 'down'
3204: && defined($LONCAPA::map::order[$idx+1])) {
3205: @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
1.633 raeburn 3206: $haschanges = 1;
1.329 droeschl 3207: } elsif ($cmd eq 'rename') {
3208: my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
3209: if ($comment=~/\S/) {
3210: $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
3211: $comment.':'.join(':', $url, @rrest);
3212: }
3213: # Devalidate title cache
3214: my $renamed_url=&LONCAPA::map::qtescape($url);
3215: &Apache::lonnet::devalidate_title_cache($renamed_url);
1.633 raeburn 3216: $haschanges = 1;
3217: } elsif ($cmd eq 'setalias') {
3218: my $newvalue = $env{'form.alias'};
3219: if ($newvalue ne '') {
3220: unless (Apache::lonnet::get_symb_from_alias($newvalue)) {
3221: &LONCAPA::map::storeparameter($idx,'parameter_0_mapalias',$newvalue,
3222: 'string');
3223: &remember_parms($idx,'mapalias','set',$newvalue);
3224: $haschanges = 1;
3225: }
3226: }
3227: } elsif ($cmd eq 'delalias') {
3228: my $current = (&LONCAPA::map::getparameter($idx,'parameter_0_mapalias'))[0];
3229: if ($current ne '') {
3230: &LONCAPA::map::delparameter($idx,'parameter_0_mapalias');
3231: &remember_parms($idx,'mapalias','del');
3232: $haschanges = 1;
3233: }
1.329 droeschl 3234: }
1.633 raeburn 3235: return $haschanges;
1.329 droeschl 3236: }
3237:
3238: sub editor {
1.458 raeburn 3239: my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
1.615 raeburn 3240: $supplementalflag,$orderhash,$iconpath,$pathitem,$ltitoolsref,
1.622 raeburn 3241: $canedit,$hostname,$navmapref,$hiddentop)=@_;
1.519 raeburn 3242: my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
1.510 raeburn 3243: if ($allowed) {
1.519 raeburn 3244: (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
3245: $is_random_order,$container) =
1.510 raeburn 3246: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
3247: $r->print($breadcrumbtrail);
1.519 raeburn 3248: } elsif ($env{'form.folderpath'} =~ /\:1$/) {
3249: $container = 'page';
3250: } else {
3251: $container = 'sequence';
1.510 raeburn 3252: }
1.484 raeburn 3253:
1.525 raeburn 3254: my $jumpto;
3255:
3256: unless ($supplementalflag) {
1.546 raeburn 3257: $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
1.525 raeburn 3258: }
1.484 raeburn 3259:
3260: unless ($allowed) {
3261: $randompick = -1;
3262: }
3263:
1.615 raeburn 3264: my ($errtext,$fatal);
3265: if (($folder eq '') && (!$supplementalflag)) {
3266: if (@LONCAPA::map::order) {
3267: undef(@LONCAPA::map::order);
3268: undef(@LONCAPA::map::resources);
3269: undef(@LONCAPA::map::resparms);
3270: undef(@LONCAPA::map::zombies);
3271: }
3272: $folder = 'default';
3273: $container = 'sequence';
3274: } else {
3275: ($errtext,$fatal) = &mapread($coursenum,$coursedom,
3276: $folder.'.'.$container);
3277: return $errtext if ($fatal);
3278: }
1.329 droeschl 3279:
1.682 raeburn 3280: my (%supphidden,%suppids,$suppmapid);
3281:
1.329 droeschl 3282: if ($#LONCAPA::map::order<1) {
3283: my $idx=&LONCAPA::map::getresidx();
3284: if ($idx<=0) { $idx=1; }
3285: $LONCAPA::map::order[0]=$idx;
3286: $LONCAPA::map::resources[$idx]='';
1.682 raeburn 3287: } elsif ($supplementalflag && !$allowed) {
3288: my ($supplemental) = &Apache::lonnet::get_supplemental($coursenum,$coursedom);
3289: if (ref($supplemental) eq 'HASH') {
3290: if (ref($supplemental->{'hidden'}) eq 'HASH') {
3291: %supphidden = %{$supplemental->{'hidden'}};
3292: }
3293: if (ref($supplemental->{'ids'}) eq 'HASH') {
3294: %suppids = %{$supplemental->{'ids'}};
3295: }
3296: }
3297: if ($folder eq 'supplemental') {
3298: $suppmapid = 0;
3299: } elsif ($folder =~ /^supplemental_(\d+)$/) {
3300: $suppmapid = $1;
3301: }
1.329 droeschl 3302: }
1.364 bisitz 3303:
1.329 droeschl 3304: # ------------------------------------------------------------ Process commands
3305:
3306: # ---------------- if they are for this folder and user allowed to make changes
1.611 raeburn 3307: if (($allowed && $canedit) && ($env{'form.folder'} eq $folder)) {
1.329 droeschl 3308: # set parameters and change order
3309: &snapshotbefore();
3310:
3311: if (&update_parameter()) {
1.588 raeburn 3312: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1.329 droeschl 3313: return $errtext if ($fatal);
3314: }
3315:
3316: if ($env{'form.newpos'} && $env{'form.currentpos'}) {
3317: # change order
3318: my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
3319: splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
3320:
3321: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
3322: return $errtext if ($fatal);
3323: }
1.364 bisitz 3324:
1.329 droeschl 3325: if ($env{'form.pastemarked'}) {
1.491 raeburn 3326: my %paste_errors;
1.533 raeburn 3327: my ($paste_res,$save_error,$pastemsgarray,$lockerror) =
1.492 raeburn 3328: &do_paste_from_buffer($coursenum,$coursedom,$folder,$container,
3329: \%paste_errors);
1.541 raeburn 3330: if (ref($pastemsgarray) eq 'ARRAY') {
3331: if (@{$pastemsgarray} > 0) {
3332: $r->print('<p class="LC_info">'.
3333: join('<br />',@{$pastemsgarray}).
1.533 raeburn 3334: '</p>');
3335: }
1.541 raeburn 3336: }
3337: if ($lockerror) {
3338: $r->print('<p class="LC_error">'.
3339: $lockerror.
3340: '</p>');
3341: }
3342: if ($save_error ne '') {
3343: return $save_error;
3344: }
3345: if ($paste_res) {
3346: my %errortext = &Apache::lonlocal::texthash (
3347: fail => 'Storage of folder contents failed',
3348: failread => 'Reading folder contents failed',
3349: failstore => 'Storage of folder contents failed',
3350: );
3351: if ($errortext{$paste_res}) {
3352: $r->print('<p class="LC_error">'.$errortext{$paste_res}.'</p>');
1.492 raeburn 3353: }
1.329 droeschl 3354: }
1.491 raeburn 3355: if (keys(%paste_errors) > 0) {
1.538 raeburn 3356: $r->print('<p class="LC_warning">'."\n".
1.491 raeburn 3357: &mt('The following files are either dependencies of a web page or references within a folder and/or composite page which could not be copied during the paste operation:')."\n".
3358: '<ul>'."\n");
3359: foreach my $key (sort(keys(%paste_errors))) {
3360: $r->print('<li>'.$key.'</li>'."\n");
3361: }
3362: $r->print('</ul></p>'."\n");
3363: }
1.538 raeburn 3364: } elsif ($env{'form.clearmarked'}) {
3365: my $output = &do_buffer_empty();
3366: if ($output) {
3367: $r->print('<p class="LC_info">'.$output.'</p>');
3368: }
3369: }
1.329 droeschl 3370:
3371: $r->print($upload_output);
3372:
1.538 raeburn 3373: # Rename, cut, copy or remove a single resource
1.602 raeburn 3374: if (&handle_edit_cmd($coursenum,$coursedom)) {
1.492 raeburn 3375: my $contentchg;
1.633 raeburn 3376: if ($env{'form.cmd'} =~ m{^(remove|cut|setalias|delalias)_}) {
1.492 raeburn 3377: $contentchg = 1;
3378: }
3379: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);
1.329 droeschl 3380: return $errtext if ($fatal);
3381: }
1.538 raeburn 3382:
3383: # Cut, copy and/or remove multiple resources
3384: if ($env{'form.multichange'}) {
3385: my %allchecked = (
3386: cut => {},
3387: remove => {},
3388: );
3389: my $needsupdate;
3390: foreach my $which (keys(%allchecked)) {
3391: $env{'form.multi'.$which} =~ s/,$//;
3392: if ($env{'form.multi'.$which}) {
3393: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.multi'.$which});
3394: if (ref($allchecked{$which}) eq 'HASH') {
3395: $needsupdate += scalar(keys(%{$allchecked{$which}}));
3396: }
3397: }
3398: }
3399: if ($needsupdate) {
3400: my $haschanges = 0;
3401: my %curr_groups = &Apache::longroup::coursegroups();
3402: my $total = scalar(@LONCAPA::map::order) - 1;
3403: for (my $i=$total; $i>=0; $i--) {
3404: my $res = $LONCAPA::map::order[$i];
3405: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3406: $name=&LONCAPA::map::qtescape($name);
3407: $url=&LONCAPA::map::qtescape($url);
1.586 droeschl 3408: next unless $url;
1.538 raeburn 3409: my %denied =
3410: &action_restrictions($coursenum,$coursedom,$url,
3411: $env{'form.folderpath'},\%curr_groups);
3412: foreach my $which (keys(%allchecked)) {
3413: next if ($denied{$which});
3414: next unless ($allchecked{$which}{$res});
3415: if ($which eq 'remove') {
3416: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
3417: ($url!~/$LONCAPA::assess_page_seq_re/)) {
3418: &Apache::lonnet::removeuploadedurl($url);
3419: } else {
3420: &LONCAPA::map::makezombie($res);
3421: }
3422: splice(@LONCAPA::map::order,$i,1);
3423: $haschanges ++;
3424: } elsif ($which eq 'cut') {
3425: &LONCAPA::map::makezombie($res);
3426: splice(@LONCAPA::map::order,$i,1);
3427: $haschanges ++;
3428: }
3429: }
3430: }
3431: if ($haschanges) {
3432: ($errtext,$fatal) =
3433: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
3434: return $errtext if ($fatal);
3435: }
3436: }
3437: }
3438:
1.329 droeschl 3439: # Group import/search
3440: if ($env{'form.importdetail'}) {
3441: my @imports;
3442: foreach my $item (split(/\&/,$env{'form.importdetail'})) {
3443: if (defined($item)) {
3444: my ($name,$url,$residx)=
1.533 raeburn 3445: map { &unescape($_); } split(/\=/,$item);
3446: if ($url =~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
3447: my ($suffix,$errortxt,$locknotfreed) =
3448: &new_timebased_suffix($coursedom,$coursenum,'map',$1,$2);
1.504 raeburn 3449: if ($locknotfreed) {
3450: $r->print($locknotfreed);
3451: }
3452: if ($suffix) {
3453: $url =~ s/_new\./_$suffix./;
3454: } else {
3455: return $errortxt;
3456: }
1.533 raeburn 3457: } elsif ($url =~ m{^/adm/$match_domain/$match_username/new/(smppg|bulletinboard)$}) {
3458: my $type = $1;
3459: my ($suffix,$errortxt,$locknotfreed) =
3460: &new_timebased_suffix($coursedom,$coursenum,$type);
3461: if ($locknotfreed) {
3462: $r->print($locknotfreed);
3463: }
3464: if ($suffix) {
3465: $url =~ s{^(/adm/$match_domain/$match_username)/new}{$1/$suffix};
3466: } else {
3467: return $errortxt;
3468: }
1.626 raeburn 3469: } elsif ($url =~ m{^/adm/$coursedom/$coursenum/new/ext\.tool}) {
1.598 raeburn 3470: my ($suffix,$errortxt,$locknotfreed) =
3471: &new_timebased_suffix($coursedom,$coursenum,'exttool');
3472: if ($locknotfreed) {
3473: $r->print($locknotfreed);
3474: }
3475: if ($suffix) {
3476: $url =~ s{^(/adm/$coursedom/$coursenum)/new}{$1/$suffix};
3477: } else {
3478: return $errortxt;
3479: }
1.534 raeburn 3480: } elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) {
3481: if ($supplementalflag) {
3482: next unless ($1 eq 'supplemental');
3483: if ($folder eq 'supplemental') {
3484: next unless ($2 eq 'default');
3485: } else {
3486: next unless ($folder eq 'supplemental_'.$2);
3487: }
3488: } else {
3489: next unless ($1 eq 'docs');
3490: if ($folder eq 'default') {
3491: next unless ($2 eq 'default');
3492: } else {
3493: next unless ($folder eq 'default_'.$2);
3494: }
3495: }
1.504 raeburn 3496: }
1.329 droeschl 3497: push(@imports, [$name, $url, $residx]);
3498: }
3499: }
1.530 raeburn 3500: ($errtext,$fatal,my $fixuperrors) =
1.529 raeburn 3501: &group_import($coursenum, $coursedom, $folder,$container,
1.598 raeburn 3502: 'londocs',$ltitoolsref,@imports);
1.329 droeschl 3503: return $errtext if ($fatal);
1.529 raeburn 3504: if ($fixuperrors) {
3505: $r->print($fixuperrors);
3506: }
1.329 droeschl 3507: }
3508: # Loading a complete map
3509: if ($env{'form.loadmap'}) {
3510: if ($env{'form.importmap'}=~/\w/) {
3511: foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
3512: my ($title,$url,$ext,$type)=split(/\:/,$res);
3513: my $idx=&LONCAPA::map::getresidx($url);
3514: $LONCAPA::map::resources[$idx]=$res;
3515: $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
3516: }
3517: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.492 raeburn 3518: $folder.'.'.$container,1);
1.329 droeschl 3519: return $errtext if ($fatal);
3520: } else {
3521: $r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
1.364 bisitz 3522:
1.329 droeschl 3523: }
3524: }
3525: &log_differences($plain);
3526: }
3527: # ---------------------------------------------------------------- End commands
3528: # ---------------------------------------------------------------- Print screen
3529: my $idx=0;
3530: my $shown=0;
3531: if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
1.381 bisitz 3532: $r->print('<div class="LC_Box">'.
1.432 raeburn 3533: '<ol class="LC_docs_parameters"><li class="LC_docs_parameters_title">'.&mt('Parameters:').'</li>'.
3534: ($randompick>=0?'<li>'.&mt('randomly pick [quant,_1,resource]',$randompick).'</li>':'').
3535: ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
3536: ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
3537: ($is_random_order?'<li>'.&mt('random order').'</li>':'').
1.431 raeburn 3538: '</ol>');
1.381 bisitz 3539: if ($randompick>=0) {
3540: $r->print('<p class="LC_warning">'
3541: .&mt('Caution: this folder is set to randomly pick a subset'
3542: .' of resources. Adding or removing resources from this'
3543: .' folder will change the set of resources that the'
3544: .' students see, resulting in spurious or missing credit'
3545: .' for completed problems, not limited to ones you'
3546: .' modify. Do not modify the contents of this folder if'
3547: .' it is in active student use.')
3548: .'</p>'
3549: );
3550: }
3551: if ($is_random_order) {
3552: $r->print('<p class="LC_warning">'
3553: .&mt('Caution: this folder is set to randomly order its'
3554: .' contents. Adding or removing resources from this folder'
3555: .' will change the order of resources shown.')
3556: .'</p>'
3557: );
3558: }
3559: $r->print('</div>');
1.364 bisitz 3560: }
1.381 bisitz 3561:
1.538 raeburn 3562: my ($to_show,$output,@allidx,@allmapidx,%filters,%lists,%curr_groups);
3563: %filters = (
1.543 raeburn 3564: canremove => [],
3565: cancut => [],
3566: cancopy => [],
3567: hiddenresource => [],
3568: encrypturl => [],
3569: randomorder => [],
3570: randompick => [],
1.538 raeburn 3571: );
3572: %curr_groups = &Apache::longroup::coursegroups();
1.424 onken 3573: &Apache::loncommon::start_data_table_count(); #setup a row counter
1.381 bisitz 3574: foreach my $res (@LONCAPA::map::order) {
3575: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3576: $name=&LONCAPA::map::qtescape($name);
3577: $url=&LONCAPA::map::qtescape($url);
3578: unless ($name) { $name=(split(/\//,$url))[-1]; }
3579: unless ($name) { $idx++; next; }
1.537 raeburn 3580: push(@allidx,$res);
3581: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
3582: push(@allmapidx,$res);
3583: }
1.617 raeburn 3584:
1.682 raeburn 3585: if (($supplementalflag) && (!$allowed) && (!$env{'request.role.adv'})) {
3586: next if ($supphidden{$suppmapid.':'.$res});
3587: }
1.381 bisitz 3588: $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
1.501 raeburn 3589: $coursenum,$coursedom,$crstype,
1.538 raeburn 3590: $pathitem,$supplementalflag,$container,
1.620 raeburn 3591: \%filters,\%curr_groups,$ltitoolsref,$canedit,
1.682 raeburn 3592: $isencrypted,$navmapref,$hostname,
3593: \%supphidden,\%suppids,$suppmapid);
1.381 bisitz 3594: $idx++;
3595: $shown++;
1.329 droeschl 3596: }
1.424 onken 3597: &Apache::loncommon::end_data_table_count();
1.510 raeburn 3598:
1.538 raeburn 3599: my $need_save;
1.611 raeburn 3600: if ($allowed || ($supplementalflag && $folder eq 'supplemental')) {
1.544 raeburn 3601: my $toolslink;
1.682 raeburn 3602: if ($allowed || $canedit) {
3603: my $helpitem = 'Navigation_Screen';
3604: if (!$allowed) {
3605: $helpitem = 'Supplemental_Navigation';
3606: }
1.544 raeburn 3607: $toolslink = '<table><tr><td>'
1.520 raeburn 3608: .&Apache::loncommon::help_open_menu('Navigation Screen',
1.682 raeburn 3609: $helpitem,undef,'RAT')
1.520 raeburn 3610: .'</td><td class="LC_middle">'.&mt('Tools:').'</td>'
3611: .'<td align="left"><ul id="LC_toolbar">'
1.525 raeburn 3612: .'<li><a href="/adm/coursedocs?forcesupplement=1&command=editsupp" '
1.520 raeburn 3613: .'id="LC_content_toolbar_edittoplevel" '
3614: .'class="LC_toolbarItem" '
3615: .'title="'.&mt('Supplemental Content Editor').'">'
3616: .'</a></li></ul></td></tr></table><br />';
1.544 raeburn 3617: }
1.510 raeburn 3618: if ($shown) {
3619: if ($allowed) {
3620: $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
3621: .&Apache::loncommon::start_data_table(undef,'contentlist')
3622: .&Apache::loncommon::start_data_table_header_row()
3623: .'<th colspan="2">'.&mt('Move').'</th>'
1.633 raeburn 3624: .'<th colspan="3">'.&mt('Actions').'</th>'
1.682 raeburn 3625: .'<th>'.&mt('Document').'</th>'
3626: .'<th colspan="2">'.&mt('Settings').'</th>'
3627: .&Apache::loncommon::end_data_table_header_row();
1.537 raeburn 3628: if ($folder !~ /^supplemental/) {
1.538 raeburn 3629: $lists{'canhide'} = join(',',@allidx);
3630: $lists{'canrandomlyorder'} = join(',',@allmapidx);
1.543 raeburn 3631: my @possfilters = ('canremove','cancut','cancopy','hiddenresource','encrypturl',
3632: 'randomorder','randompick');
3633: foreach my $item (@possfilters) {
1.538 raeburn 3634: if (ref($filters{$item}) eq 'ARRAY') {
1.543 raeburn 3635: if (@{$filters{$item}} > 0) {
3636: $lists{$item} = join(',',@{$filters{$item}});
3637: }
1.538 raeburn 3638: }
3639: }
1.537 raeburn 3640: if (@allidx > 0) {
3641: my $path;
3642: if ($env{'form.folderpath'}) {
1.630 raeburn 3643: $path =
1.537 raeburn 3644: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3645: }
1.538 raeburn 3646: if (@allidx > 1) {
1.630 raeburn 3647: $to_show .=
1.538 raeburn 3648: &Apache::loncommon::continue_data_table_row().
3649: '<td colspan="2"> </td>'.
3650: '<td>'.
1.611 raeburn 3651: &multiple_check_form('actions',\%lists,$canedit).
1.538 raeburn 3652: '</td>'.
1.633 raeburn 3653: '<td colspan="3"> </td>'.
3654: '<td colspan="2">'.
1.611 raeburn 3655: &multiple_check_form('settings',\%lists,$canedit).
1.538 raeburn 3656: '</td>'.
3657: &Apache::loncommon::end_data_table_row();
3658: $need_save = 1;
3659: }
1.537 raeburn 3660: }
3661: }
3662: $to_show .= $output.' '
1.510 raeburn 3663: .&Apache::loncommon::end_data_table()
3664: .'<br style="line-height:2px;" />'
3665: .&Apache::loncommon::end_scrollbox();
3666: } else {
1.520 raeburn 3667: $to_show .= $toolslink
1.510 raeburn 3668: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3669: .$output.' '
3670: .&Apache::loncommon::end_data_table();
1.393 raeburn 3671: }
1.510 raeburn 3672: } else {
1.520 raeburn 3673: if (!$allowed) {
3674: $to_show .= $toolslink;
3675: }
1.615 raeburn 3676: my $noresmsg;
3677: if ($allowed && $hiddentop && !$supplementalflag) {
3678: $noresmsg = &mt('Main Content Hidden');
3679: } else {
3680: $noresmsg = &mt('Currently empty');
3681: }
1.510 raeburn 3682: $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
3683: .'<div class="LC_info" id="contentlist">'
1.615 raeburn 3684: .$noresmsg
1.510 raeburn 3685: .'</div>'
3686: .&Apache::loncommon::end_scrollbox();
1.393 raeburn 3687: }
3688: } else {
1.510 raeburn 3689: if ($shown) {
3690: $to_show = '<div>'
3691: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3692: .$output
3693: .&Apache::loncommon::end_data_table()
3694: .'</div>';
3695: } else {
3696: $to_show = '<div class="LC_info" id="contentlist">'
1.550 raeburn 3697: .&mt('Currently empty')
1.510 raeburn 3698: .'</div>'
3699: }
1.458 raeburn 3700: }
3701: my $tid = 1;
3702: if ($supplementalflag) {
3703: $tid = 2;
1.329 droeschl 3704: }
3705: if ($allowed) {
1.484 raeburn 3706: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
1.538 raeburn 3707: $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,
1.611 raeburn 3708: $jumpto,$readfile,$need_save,"$folder.$container",$canedit));
3709: if ($canedit) {
3710: &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
3711: }
1.460 raeburn 3712: } else {
3713: $r->print($to_show);
1.329 droeschl 3714: }
3715: return;
3716: }
3717:
1.538 raeburn 3718: sub multiple_check_form {
1.611 raeburn 3719: my ($caller,$listsref,$canedit) = @_;
1.538 raeburn 3720: return unless (ref($listsref) eq 'HASH');
1.611 raeburn 3721: my $disabled;
3722: unless ($canedit) {
3723: $disabled = 'disabled="disabled"';
3724: }
1.538 raeburn 3725: my $output =
3726: '<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'.
3727: '<span class="LC_nobreak" style="font-size:x-small;font-weight:bold;">'.
3728: '<label><input type="radio" name="showmultpick" value="0" onclick="javascript:togglePick('."'$caller','0'".');" checked="checked" />'.&mt('one').'</label>'.(' 'x2).'<label><input type="radio" name="showmultpick" value="1" onclick="javascript:togglePick('."'$caller','1'".');" />'.&mt('multiple').'</label></span><span id="more'.$caller.'" class="LC_nobreak LC_docs_ext_edit"></span></form>'.
3729: '<div id="multi'.$caller.'" style="display:none;margin:0;padding:0;border:0">'.
3730: '<form action="/adm/coursedocs" method="post" name="cumulative'.$caller.'">'."\n".
3731: '<fieldset id="allfields'.$caller.'" style="display:none"><legend style="font-size:x-small;">'.&mt('check/uncheck all').'</legend>'."\n";
3732: if ($caller eq 'settings') {
3733: $output .=
3734: '<table><tr>'.
3735: '<td class="LC_docs_entry_parameter">'.
3736: '<span class="LC_nobreak"><label>'.
1.611 raeburn 3737: '<input type="checkbox" name="hiddenresourceall" id="hiddenresourceall" onclick="propagateState(this.form,'."'hiddenresource'".')"'.$disabled.' />'.&mt('Hidden').
1.538 raeburn 3738: '</label></span></td>'.
3739: '<td class="LC_docs_entry_parameter">'.
1.611 raeburn 3740: '<span class="LC_nobreak"><label><input type="checkbox" name="randompickall" id="randompickall" onclick="updatePick(this.form,'."'all','check'".');propagateState(this.form,'."'randompick'".');propagateState(this.form,'."'rpicknum'".');"'.$disabled.' />'.&mt('Randomly Pick').'</label><span id="rpicktextall"></span><input type="hidden" name="rpicknumall" id="rpicknumall" value="" />'.
1.538 raeburn 3741: '</span></td>'.
3742: '</tr>'."\n".
3743: '<tr>'.
3744: '<td class="LC_docs_entry_parameter">'.
1.611 raeburn 3745: '<span class="LC_nobreak"><label><input type="checkbox" name="encrypturlall" id="encrypturlall" onclick="propagateState(this.form,'."'encrypturl'".')"'.$disabled.' />'.&mt('URL hidden').'</label></span></td><td class="LC_docs_entry_parameter"><span class="LC_nobreak"><label><input type="checkbox" name="randomorderall" id="randomorderall" onclick="propagateState(this.form,'."'randomorder'".')"'.$disabled.' />'.&mt('Random Order').
1.538 raeburn 3746: '</label></span>'.
3747: '</td></tr></table>'."\n";
3748: } else {
3749: $output .=
3750: '<table><tr>'.
3751: '<td class="LC_docs_entry_parameter">'.
3752: '<span class="LC_nobreak LC_docs_remove">'.
1.611 raeburn 3753: '<label><input type="checkbox" name="removeall" id="removeall" onclick="propagateState(this.form,'."'remove'".')"'.$disabled.' />'.&mt('Remove').
1.538 raeburn 3754: '</label></span></td>'.
3755: '<td class="LC_docs_entry_parameter">'.
3756: '<span class="LC_nobreak LC_docs_cut">'.
1.611 raeburn 3757: '<label><input type="checkbox" name="cut" id="cutall" onclick="propagateState(this.form,'."'cut'".');"'.$disabled.' />'.&mt('Cut').
1.538 raeburn 3758: '</label></span></td>'."\n".
3759: '<td class="LC_docs_entry_parameter">'.
3760: '<span class="LC_nobreak LC_docs_copy">'.
1.611 raeburn 3761: '<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')"'. $disabled.' />'.&mt('Copy').
1.538 raeburn 3762: '</label></span></td>'.
3763: '</tr></table>'."\n";
3764: }
3765: $output .=
3766: '</fieldset>'.
3767: '<input type="hidden" name="allidx" value="'.$listsref->{'canhide'}.'" />';
3768: if ($caller eq 'settings') {
3769: $output .=
1.543 raeburn 3770: '<input type="hidden" name="allmapidx" value="'.$listsref->{'canrandomlyorder'}.'" />'."\n".
3771: '<input type="hidden" name="currhiddenresource" value="'.$listsref->{'hiddenresource'}.'" />'."\n".
3772: '<input type="hidden" name="currencrypturl" value="'.$listsref->{'encrypturl'}.'" />'."\n".
3773: '<input type="hidden" name="currrandomorder" value="'.$listsref->{'randomorder'}.'" />'."\n".
3774: '<input type="hidden" name="currrandompick" value="'.$listsref->{'randompick'}.'" />'."\n";
1.538 raeburn 3775: } elsif ($caller eq 'actions') {
3776: $output .=
3777: '<input type="hidden" name="allremoveidx" id="allremoveidx" value="'.$listsref->{'canremove'}.'" />'.
3778: '<input type="hidden" name="allcutidx" id="allcutidx" value="'.$listsref->{'cancut'}.'" />'.
3779: '<input type="hidden" name="allcopyidx" id="allcopyidx" value="'.$listsref->{'cancopy'}.'" />';
3780: }
3781: $output .=
3782: '</form>'.
3783: '</div>';
3784: return $output;
3785: }
3786:
1.329 droeschl 3787: sub process_file_upload {
1.552 raeburn 3788: my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd,$crstype) = @_;
1.329 droeschl 3789: # upload a file, if present
1.552 raeburn 3790: my $filesize = length($env{'form.uploaddoc'});
3791: if (!$filesize) {
3792: $$upload_output = '<div class="LC_error">'.
3793: &mt('Unable to upload [_1]. (size = [_2] bytes)',
3794: '<span class="LC_filename">'.$env{'form.uploaddoc.filename'}.'</span>',
3795: $filesize).'<br />'.
3796: &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'<br />'.
3797: '</div>';
3798: return;
3799: }
3800: my $quotatype = 'unofficial';
3801: if ($crstype eq 'Community') {
1.601 raeburn 3802: $quotatype = 'community';
3803: } elsif ($crstype eq 'Placement') {
3804: $quotatype = 'placement';
1.580 raeburn 3805: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
1.552 raeburn 3806: $quotatype = 'official';
1.573 raeburn 3807: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
3808: $quotatype = 'textbook';
1.552 raeburn 3809: }
3810: if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) {
3811: $filesize = int($filesize/1000); #expressed in kb
3812: $$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course',
1.579 raeburn 3813: $env{'form.uploaddoc.filename'},$filesize,
3814: 'upload',$quotatype);
1.552 raeburn 3815: return if ($$upload_output);
3816: }
1.440 raeburn 3817: my ($parseaction,$showupload,$nextphase,$mimetype);
3818: if ($env{'form.parserflag'}) {
1.329 droeschl 3819: $parseaction = 'parse';
3820: }
3821: my $folder=$env{'form.folder'};
3822: if ($folder eq '') {
3823: $folder='default';
3824: }
3825: if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
3826: my $errtext='';
3827: my $fatal=0;
3828: my $container='sequence';
1.519 raeburn 3829: if ($env{'form.folderpath'} =~ /:1$/) {
1.329 droeschl 3830: $container='page';
3831: }
3832: ($errtext,$fatal)=
1.534 raeburn 3833: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1.329 droeschl 3834: if ($#LONCAPA::map::order<1) {
3835: $LONCAPA::map::order[0]=1;
3836: $LONCAPA::map::resources[1]='';
3837: }
3838: my $destination = 'docs/';
3839: if ($folder =~ /^supplemental/) {
3840: $destination = 'supplemental/';
3841: }
3842: if (($folder eq 'default') || ($folder eq 'supplemental')) {
3843: $destination .= 'default/';
3844: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
3845: $destination .= $2.'/';
3846: }
1.534 raeburn 3847: if ($fatal) {
3848: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'</div>';
3849: return;
3850: }
1.440 raeburn 3851: # this is for a course, not a user, so set context to coursedoc.
1.329 droeschl 3852: my $newidx=&LONCAPA::map::getresidx();
3853: $destination .= $newidx;
1.439 raeburn 3854: my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination,
1.329 droeschl 3855: $parseaction,$allfiles,
1.440 raeburn 3856: $codebase,undef,undef,undef,undef,
3857: undef,undef,\$mimetype);
3858: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) {
3859: my $stored = $1;
3860: $showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'.
3861: $stored.'</span>').'</p>';
3862: } else {
3863: my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});
3864:
1.457 raeburn 3865: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>';
1.440 raeburn 3866: return;
3867: }
1.329 droeschl 3868: my $ext='false';
3869: if ($url=~m{^http://}) { $ext='true'; }
3870: $url = &LONCAPA::map::qtunescape($url);
3871: my $comment=$env{'form.comment'};
3872: $comment = &LONCAPA::map::qtunescape($comment);
3873: if ($folder=~/^supplemental/) {
3874: $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
3875: $env{'user.domain'}.'___&&&___'.$comment;
3876: }
3877:
3878: $LONCAPA::map::resources[$newidx]=
3879: $comment.':'.$url.':'.$ext.':normal:res';
3880: $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
3881: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.492 raeburn 3882: $folder.'.'.$container,1);
1.329 droeschl 3883: if ($fatal) {
1.457 raeburn 3884: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>';
1.440 raeburn 3885: return;
1.329 droeschl 3886: } else {
1.440 raeburn 3887: if ($parseaction eq 'parse' && $mimetype eq 'text/html') {
3888: $$upload_output = $showupload;
1.384 raeburn 3889: my $total_embedded = scalar(keys(%{$allfiles}));
1.329 droeschl 3890: if ($total_embedded > 0) {
1.440 raeburn 3891: my $uploadphase = 'upload_embedded';
3892: my $primaryurl = &HTML::Entities::encode($url,'<>&"');
3893: my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx);
1.630 raeburn 3894: my ($embedded,$num) =
1.440 raeburn 3895: &Apache::loncommon::ask_for_embedded_content(
3896: '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url});
3897: if ($embedded) {
3898: if ($num) {
3899: $$upload_output .=
3900: '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
3901: $nextphase = $uploadphase;
3902: } else {
3903: $$upload_output .= $embedded;
3904: }
3905: } else {
3906: $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
3907: }
1.329 droeschl 3908: } else {
1.440 raeburn 3909: $$upload_output .= &mt('No embedded items identified').'<br />';
1.329 droeschl 3910: }
1.457 raeburn 3911: $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
1.578 raeburn 3912: } elsif ((&Apache::loncommon::is_archive_file($mimetype)) &&
3913: ($env{'form.uploaddoc.filename'} =~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i)) {
1.476 raeburn 3914: $nextphase = 'decompress_uploaded';
3915: my $position = scalar(@LONCAPA::map::order)-1;
3916: my $noextract = &return_to_editor();
3917: my $archiveurl = &HTML::Entities::encode($url,'<>&"');
3918: my %archiveitems = (
3919: folderpath => $env{'form.folderpath'},
3920: cmd => $nextphase,
3921: newidx => $newidx,
3922: position => $position,
3923: phase => $nextphase,
1.477 raeburn 3924: comment => $comment,
1.480 raeburn 3925: );
3926: my ($destination,$dir_root) = &embedded_destination($coursenum,$coursedom);
3927: my @current = &get_dir_list($url,$coursenum,$coursedom,$newidx);
1.476 raeburn 3928: $$upload_output = $showupload.
3929: &Apache::loncommon::decompress_form($mimetype,
3930: $archiveurl,'/adm/coursedocs',$noextract,
1.480 raeburn 3931: \%archiveitems,\@current);
1.329 droeschl 3932: }
3933: }
3934: }
1.440 raeburn 3935: return $nextphase;
1.329 droeschl 3936: }
3937:
1.480 raeburn 3938: sub get_dir_list {
3939: my ($url,$coursenum,$coursedom,$newidx) = @_;
3940: my ($destination,$dir_root) = &embedded_destination();
3941: my ($dirlistref,$listerror) =
3942: &Apache::lonnet::dirlist("$dir_root/$destination/$newidx",$coursedom,$coursenum,1);
3943: my @dir_lines;
3944: my $dirptr=16384;
3945: if (ref($dirlistref) eq 'ARRAY') {
3946: foreach my $dir_line (sort
3947: {
3948: my ($afile)=split('&',$a,2);
3949: my ($bfile)=split('&',$b,2);
3950: return (lc($afile) cmp lc($bfile));
3951: } (@{$dirlistref})) {
3952: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
3953: $filename =~ s/\s+$//;
3954: next if ($filename =~ /^\.\.?$/);
3955: my $isdir = 0;
3956: if ($dirptr&$testdir) {
3957: $isdir = 1;
3958: }
3959: push(@dir_lines, [$filename,$dom,$isdir,$size,$mtime,$obs]);
3960: }
3961: }
3962: return @dir_lines;
3963: }
3964:
1.329 droeschl 3965: sub is_supplemental_title {
3966: my ($title) = @_;
3967: return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
3968: }
3969:
3970: # --------------------------------------------------------------- An entry line
3971:
3972: sub entryline {
1.501 raeburn 3973: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
1.598 raeburn 3974: $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups,
1.682 raeburn 3975: $ltitoolsref,$canedit,$isencrypted,$navmapref,$hostname,
3976: $supphidden,$suppids,$suppmapid)=@_;
1.581 raeburn 3977: my ($foldertitle,$renametitle,$oldtitle);
1.329 droeschl 3978: if (&is_supplemental_title($title)) {
1.488 raeburn 3979: ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
1.329 droeschl 3980: } else {
3981: $title=&HTML::Entities::encode($title,'"<>&\'');
3982: $renametitle=$title;
3983: $foldertitle=$title;
3984: }
3985:
1.611 raeburn 3986: my ($disabled,$readonly,$js_lt);
3987: unless ($canedit) {
3988: $disabled = 'disabled="disabled"';
3989: $readonly = 1;
3990: }
3991:
1.329 droeschl 3992: my $orderidx=$LONCAPA::map::order[$index];
1.364 bisitz 3993:
1.329 droeschl 3994: $renametitle=~s/\\/\\\\/g;
3995: $renametitle=~s/\"\;/\\\"/g;
1.585 raeburn 3996: $renametitle=~s/"/%22/g;
1.581 raeburn 3997: $renametitle=~s/ /%20/g;
3998: $oldtitle = $renametitle;
1.576 raeburn 3999: $renametitle=~s/\'/\\\'/g;
1.379 bisitz 4000: my $line=&Apache::loncommon::start_data_table_row();
1.538 raeburn 4001: my ($form_start,$form_end,$form_common,$form_param);
1.329 droeschl 4002: # Edit commands
1.679 raeburn 4003: my ($esc_path, $path, $symb, $shownsymb, $curralias);
1.329 droeschl 4004: if ($env{'form.folderpath'}) {
4005: $esc_path=&escape($env{'form.folderpath'});
4006: $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
4007: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
4008: }
1.505 raeburn 4009: my $isexternal;
1.510 raeburn 4010: if ($residx) {
1.501 raeburn 4011: my $currurl = $url;
4012: $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.505 raeburn 4013: if ($currurl =~ m{^/adm/wrapper/ext/}) {
4014: $isexternal = 1;
4015: }
1.510 raeburn 4016: if (!$supplementalflag) {
4017: my $path = 'uploaded/'.
4018: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
4019: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
4020: $symb = &Apache::lonnet::encode_symb($path.$folder.".$container",
4021: $residx,
4022: &Apache::lonnet::declutter($currurl));
4023: }
1.501 raeburn 4024: }
1.538 raeburn 4025: my ($renamelink,%lt,$ishash);
4026: if (ref($filtersref) eq 'HASH') {
4027: $ishash = 1;
4028: }
4029:
1.329 droeschl 4030: if ($allowed) {
1.538 raeburn 4031: $form_start = '
4032: <form action="/adm/coursedocs" method="post">
4033: ';
4034: $form_common=(<<END);
4035: <input type="hidden" name="folderpath" value="$path" />
4036: <input type="hidden" name="symb" value="$symb" />
4037: END
4038: $form_param=(<<END);
4039: <input type="hidden" name="setparms" value="$orderidx" />
4040: <input type="hidden" name="changeparms" value="0" />
4041: END
4042: $form_end = '</form>';
4043:
1.329 droeschl 4044: my $incindex=$index+1;
4045: my $selectbox='';
1.471 raeburn 4046: if (($#LONCAPA::map::order>0) &&
1.329 droeschl 4047: ((split(/\:/,
1.344 bisitz 4048: $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
4049: ne '') &&
1.329 droeschl 4050: ((split(/\:/,
1.344 bisitz 4051: $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1.329 droeschl 4052: ne '')) {
4053: $selectbox=
4054: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.611 raeburn 4055: '<select name="newpos" onchange="this.form.submit()"'.$disabled.'>';
1.329 droeschl 4056: for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
4057: if ($i==$incindex) {
1.358 bisitz 4058: $selectbox.='<option value="" selected="selected">('.$i.')</option>';
1.329 droeschl 4059: } else {
4060: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
4061: }
4062: }
4063: $selectbox.='</select>';
4064: }
1.501 raeburn 4065: %lt=&Apache::lonlocal::texthash(
1.329 droeschl 4066: 'up' => 'Move Up',
4067: 'dw' => 'Move Down',
4068: 'rm' => 'Remove',
4069: 'ct' => 'Cut',
4070: 'rn' => 'Rename',
1.501 raeburn 4071: 'cp' => 'Copy',
1.633 raeburn 4072: 'da' => 'Unset alias',
4073: 'sa' => 'Set alias',
1.501 raeburn 4074: 'ex' => 'External Resource',
1.598 raeburn 4075: 'et' => 'External Tool',
1.501 raeburn 4076: 'ed' => 'Edit',
4077: 'pr' => 'Preview',
4078: 'sv' => 'Save',
4079: 'ul' => 'URL',
1.611 raeburn 4080: 'ti' => 'Title',
1.618 raeburn 4081: 'er' => 'Editing rights unavailable for your current role.',
1.501 raeburn 4082: );
1.538 raeburn 4083: my %denied = &action_restrictions($coursenum,$coursedom,$url,
4084: $env{'form.folderpath'},
4085: $currgroups);
1.517 raeburn 4086: my ($copylink,$cutlink,$removelink);
1.329 droeschl 4087: my $skip_confirm = 0;
1.603 raeburn 4088: my $confirm_removal = 0;
1.329 droeschl 4089: if ( $folder =~ /^supplemental/
4090: || ($url =~ m{( /smppg$
4091: |/syllabus$
4092: |/aboutme$
4093: |/navmaps$
4094: |/bulletinboard$
1.626 raeburn 4095: |/ext\.tool$
1.505 raeburn 4096: |\.html$)}x)
4097: || $isexternal) {
1.329 droeschl 4098: $skip_confirm = 1;
4099: }
1.603 raeburn 4100: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
4101: ($url!~/$LONCAPA::assess_page_seq_re/)) {
4102: $confirm_removal = 1;
4103: }
1.633 raeburn 4104: if ($url =~ /$LONCAPA::assess_re/) {
4105: $curralias = (&LONCAPA::map::getparameter($orderidx,'parameter_0_mapalias'))[0];
4106: }
1.329 droeschl 4107:
1.538 raeburn 4108: if ($denied{'copy'}) {
1.543 raeburn 4109: $copylink=(<<ENDCOPY)
1.507 raeburn 4110: <span style="visibility: hidden;">$lt{'cp'}</span>
4111: ENDCOPY
4112: } else {
1.538 raeburn 4113: my $formname = 'edit_copy_'.$orderidx;
4114: my $js = "javascript:checkForSubmit(document.forms.renameform,'copy','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.329 droeschl 4115: $copylink=(<<ENDCOPY);
1.538 raeburn 4116: <form name="$formname" method="post" action="/adm/coursedocs">
4117: $form_common
1.611 raeburn 4118: <input type="checkbox" name="copy" id="copy_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','copy');" class="LC_hidden" $disabled /><a href="$js" class="LC_docs_copy">$lt{'cp'}</a>
1.538 raeburn 4119: $form_end
1.329 droeschl 4120: ENDCOPY
1.538 raeburn 4121: if (($ishash) && (ref($filtersref->{'cancopy'}) eq 'ARRAY')) {
4122: push(@{$filtersref->{'cancopy'}},$orderidx);
4123: }
1.329 droeschl 4124: }
1.538 raeburn 4125: if ($denied{'cut'}) {
1.507 raeburn 4126: $cutlink=(<<ENDCUT);
4127: <span style="visibility: hidden;">$lt{'ct'}</span>
4128: ENDCUT
4129: } else {
1.538 raeburn 4130: my $formname = 'edit_cut_'.$orderidx;
4131: my $js = "javascript:checkForSubmit(document.forms.renameform,'cut','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.329 droeschl 4132: $cutlink=(<<ENDCUT);
1.538 raeburn 4133: <form name="$formname" method="post" action="/adm/coursedocs">
4134: $form_common
1.542 raeburn 4135: <input type="hidden" name="skip_$orderidx" id="skip_cut_$orderidx" value="$skip_confirm" />
1.611 raeburn 4136: <input type="checkbox" name="cut" id="cut_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','cut');" class="LC_hidden" $disabled /><a href="$js" class="LC_docs_cut">$lt{'ct'}</a>
1.538 raeburn 4137: $form_end
1.329 droeschl 4138: ENDCUT
1.538 raeburn 4139: if (($ishash) && (ref($filtersref->{'cancut'}) eq 'ARRAY')) {
4140: push(@{$filtersref->{'cancut'}},$orderidx);
4141: }
1.329 droeschl 4142: }
1.538 raeburn 4143: if ($denied{'remove'}) {
1.507 raeburn 4144: $removelink=(<<ENDREM);
4145: <span style="visibility: hidden;">$lt{'rm'}</a>
4146: ENDREM
4147: } else {
1.538 raeburn 4148: my $formname = 'edit_remove_'.$orderidx;
1.603 raeburn 4149: my $js = "javascript:checkForSubmit(document.forms.renameform,'remove','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder',$confirm_removal);";
1.497 raeburn 4150: $removelink=(<<ENDREM);
1.538 raeburn 4151: <form name="$formname" method="post" action="/adm/coursedocs">
4152: $form_common
1.542 raeburn 4153: <input type="hidden" name="skip_$orderidx" id="skip_remove_$orderidx" value="$skip_confirm" />
1.603 raeburn 4154: <input type="hidden" name="confirm_rem_$orderidx" id="confirm_removal_$orderidx" value="$confirm_removal" />
1.611 raeburn 4155: <input type="checkbox" name="remove" id="remove_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','remove');" class="LC_hidden" $disabled /><a href="$js" class="LC_docs_remove">$lt{'rm'}</a>
1.538 raeburn 4156: $form_end
1.497 raeburn 4157: ENDREM
1.538 raeburn 4158: if (($ishash) && (ref($filtersref->{'canremove'}) eq 'ARRAY')) {
4159: push(@{$filtersref->{'canremove'}},$orderidx);
4160: }
1.497 raeburn 4161: }
1.551 raeburn 4162: $renamelink=(<<ENDREN);
1.581 raeburn 4163: <a href='javascript:changename("$esc_path","$index","$oldtitle");' class="LC_docs_rename">$lt{'rn'}</a>
1.507 raeburn 4164: ENDREN
1.611 raeburn 4165: my ($uplink,$downlink);
4166: if ($canedit) {
4167: $uplink = "/adm/coursedocs?cmd=up_$index&folderpath=$esc_path&symb=$symb";
4168: $downlink = "/adm/coursedocs?cmd=down_$index&folderpath=$esc_path&symb=$symb";
4169: } else {
4170: $uplink = "javascript:alert('".&js_escape($lt{'er'})."');";
4171: $downlink = $uplink;
4172: }
1.329 droeschl 4173: $line.=(<<END);
4174: <td>
1.379 bisitz 4175: <div class="LC_docs_entry_move">
1.611 raeburn 4176: <a href="$uplink">
1.501 raeburn 4177: <img src="${iconpath}move_up.gif" alt="$lt{'up'}" class="LC_icon" />
1.379 bisitz 4178: </a>
4179: </div>
4180: <div class="LC_docs_entry_move">
1.611 raeburn 4181: <a href="$downlink">
1.501 raeburn 4182: <img src="${iconpath}move_down.gif" alt="$lt{'dw'}" class="LC_icon" />
1.379 bisitz 4183: </a>
4184: </div>
1.329 droeschl 4185: </td>
4186: <td>
4187: $form_start
1.538 raeburn 4188: $form_param
1.478 raeburn 4189: $form_common
1.329 droeschl 4190: $selectbox
4191: $form_end
4192: </td>
1.540 raeburn 4193: <td class="LC_docs_entry_commands LC_nobreak">
1.497 raeburn 4194: $removelink
1.329 droeschl 4195: $cutlink
4196: $copylink
4197: </td>
4198: END
4199: }
4200: # Figure out what kind of a resource this is
4201: my ($extension)=($url=~/\.(\w+)$/);
4202: my $uploaded=($url=~/^\/*uploaded\//);
4203: my $icon=&Apache::loncommon::icon($url);
1.519 raeburn 4204: my $isfolder;
4205: my $ispage;
4206: my $containerarg;
1.615 raeburn 4207: my $folderurl;
1.329 droeschl 4208: if ($uploaded) {
1.472 raeburn 4209: if (($extension eq 'sequence') || ($extension eq 'page')) {
4210: $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
1.519 raeburn 4211: $containerarg = $1;
1.472 raeburn 4212: if ($extension eq 'sequence') {
4213: $icon=$iconpath.'navmap.folder.closed.gif';
4214: $isfolder=1;
4215: } else {
4216: $icon=$iconpath.'page.gif';
4217: $ispage=1;
4218: }
1.615 raeburn 4219: $folderurl = &Apache::lonnet::declutter($url);
1.472 raeburn 4220: if ($allowed) {
4221: $url='/adm/coursedocs?';
4222: } else {
4223: $url='/adm/supplemental?';
4224: }
1.329 droeschl 4225: } else {
4226: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
4227: }
4228: }
1.364 bisitz 4229:
1.621 raeburn 4230: my ($editlink,$extresform,$anchor,$hiddenres,$nomodal);
1.329 droeschl 4231: my $orig_url = $url;
1.340 raeburn 4232: $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
1.668 raeburn 4233: if ($container eq 'page') {
4234: $url=~s{^http(|s)(:|:)//}{/ext/};
4235: } else {
4236: $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
4237: }
1.501 raeburn 4238: if (!$supplementalflag && $residx && $symb) {
4239: if ((!$isfolder) && (!$ispage)) {
4240: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
1.668 raeburn 4241: if (($url =~ m{^ext/}) && ($container eq 'page')) {
4242: $url=&Apache::lonnet::clutter_with_no_wrapper($url);
4243: } else {
4244: $url=&Apache::lonnet::clutter($url);
4245: }
1.501 raeburn 4246: if ($url=~/^\/*uploaded\//) {
4247: $url=~/\.(\w+)$/;
4248: my $embstyle=&Apache::loncommon::fileembstyle($1);
4249: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
4250: $url='/adm/wrapper'.$url;
4251: } elsif ($embstyle eq 'ssi') {
4252: #do nothing with these
4253: } elsif ($url!~/\.(sequence|page)$/) {
4254: $url='/adm/coursedocs/showdoc'.$url;
4255: }
1.623 raeburn 4256: } elsif ($url=~m{^(|/adm/wrapper)/ext/([^#]+)}) {
4257: my $wrapped = $1;
4258: my $exturl = $2;
1.668 raeburn 4259: if (($wrapped eq '') && ($container ne 'page')) {
1.623 raeburn 4260: $url='/adm/wrapper'.$url;
4261: }
4262: if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) {
4263: $nomodal = 1;
4264: }
1.626 raeburn 4265: } elsif ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
1.598 raeburn 4266: $url='/adm/wrapper'.$url;
1.621 raeburn 4267: } elsif ($url eq "/public/$coursedom/$coursenum/syllabus") {
4268: if (($ENV{'SERVER_PORT'} == 443) &&
4269: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
1.678 raeburn 4270: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.657 raeburn 4271: $url .= '?usehttp=1';
4272: }
1.621 raeburn 4273: $nomodal = 1;
4274: }
1.598 raeburn 4275: }
1.680 raeburn 4276: my ($checkencrypt,$shownurl);
4277: if (!$env{'request.role.adv'}) {
1.615 raeburn 4278: if (((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) ||
1.680 raeburn 4279: ($isencrypted) || (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i)) {
1.615 raeburn 4280: $checkencrypt = 1;
1.620 raeburn 4281: } elsif (ref($navmapref)) {
1.615 raeburn 4282: unless (ref($$navmapref)) {
4283: $$navmapref = Apache::lonnavmaps::navmap->new();
4284: }
4285: if (ref($$navmapref)) {
4286: if (lc($$navmapref->get_mapparam($symb,undef,"0.encrypturl")) eq 'yes') {
1.680 raeburn 4287: $checkencrypt = 1;
1.615 raeburn 4288: }
4289: }
4290: }
1.680 raeburn 4291: }
4292: if ($checkencrypt) {
4293: my $currenc = $env{'request.enc'};
4294: $env{'request.enc'} = 1;
4295: $shownsymb = &Apache::lonenc::encrypted($symb);
4296: $shownurl = &Apache::lonenc::encrypted($url);
4297: if (&Apache::lonnet::symbverify($symb,$url)) {
4298: $url = $shownurl;
4299: } else {
4300: $url = '';
4301: }
4302: $env{'request.enc'} = $currenc;
4303: } elsif (&Apache::lonnet::symbverify($symb,$url)) {
4304: $shownsymb = $symb;
4305: if ($isexternal) {
4306: $url =~ s/\#[^#]+$//;
4307: if ($container eq 'page') {
4308: $url = &Apache::lonnet::clutter($url);
1.613 raeburn 4309: }
1.612 raeburn 4310: }
1.680 raeburn 4311: $shownurl = $url;
4312: }
4313: unless ($env{'request.role.adv'}) {
4314: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4315: $url = '';
4316: }
4317: if (&Apache::lonnet::EXT('resource.0.hiddenresource',$symb) =~ /^yes$/i) {
4318: $url = '';
4319: $hiddenres = 1;
4320: }
4321: }
4322: if ($url ne '') {
4323: $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
1.501 raeburn 4324: }
1.329 droeschl 4325: }
1.621 raeburn 4326: } elsif ($supplementalflag) {
1.610 raeburn 4327: if ($isexternal) {
4328: if ($url =~ /^([^#]+)#([^#]+)$/) {
4329: $url = $1;
4330: $anchor = $2;
1.623 raeburn 4331: if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) {
1.678 raeburn 4332: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.657 raeburn 4333: if ($hostname ne '') {
4334: $url = 'http://'.$hostname.$url;
4335: }
4336: $url .= (($url =~ /\?/) ? '&':'?').'usehttp=1';
1.623 raeburn 4337: }
4338: $nomodal = 1;
4339: }
1.610 raeburn 4340: }
1.621 raeburn 4341: } elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
4342: if (($ENV{'SERVER_PORT'} == 443) &&
4343: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
1.678 raeburn 4344: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.657 raeburn 4345: if ($hostname ne '') {
4346: $url = 'http://'.$hostname.$url;
4347: }
4348: $url .= (($url =~ /\?/) ? '&':'?').'usehttp=1';
1.622 raeburn 4349: }
1.621 raeburn 4350: $nomodal = 1;
4351: }
1.610 raeburn 4352: }
1.329 droeschl 4353: }
1.615 raeburn 4354: my ($rand_pick_text,$rand_order_text,$hiddenfolder);
1.617 raeburn 4355: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.519 raeburn 4356: if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') {
1.329 droeschl 4357: my $foldername=&escape($foldertitle);
4358: my $folderpath=$env{'form.folderpath'};
4359: if ($folderpath) { $folderpath.='&' };
1.510 raeburn 4360: if (!$allowed && $supplementalflag) {
1.519 raeburn 4361: $folderpath.=$containerarg.'&'.$foldername;
1.510 raeburn 4362: $url.='folderpath='.&escape($folderpath);
1.682 raeburn 4363: if (ref($supphidden) eq 'HASH') {
4364: if ($supphidden->{$suppmapid.':'.$residx}) {
4365: $hiddenfolder = 1;
4366: }
4367: }
1.510 raeburn 4368: } else {
1.617 raeburn 4369: my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
4370: 'parameter_randompick'))[0];
4371: my $randorder = ((&LONCAPA::map::getparameter($orderidx,
4372: 'parameter_randomorder'))[0]=~/^yes$/i);
4373: my $hiddenmap = ((&LONCAPA::map::getparameter($orderidx,
4374: 'parameter_hiddenresource'))[0]=~/^yes$/i);
4375: my $encryptmap = ((&LONCAPA::map::getparameter($orderidx,
4376: 'parameter_encrypturl'))[0]=~/^yes$/i);
4377: unless ($hiddenmap) {
1.620 raeburn 4378: if (ref($navmapref)) {
4379: unless (ref($$navmapref)) {
4380: $$navmapref = Apache::lonnavmaps::navmap->new();
4381: }
4382: if (ref($$navmapref)) {
4383: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
4384: my @resources = $$navmapref->retrieveResources($folderurl,$filterFunc,1,1);
4385: unless (@resources) {
4386: $hiddenmap = 1;
4387: unless ($env{'request.role.adv'}) {
4388: $url = '';
4389: $hiddenfolder = 1;
4390: }
1.617 raeburn 4391: }
1.615 raeburn 4392: }
4393: }
4394: }
4395: }
1.617 raeburn 4396: unless ($encryptmap) {
1.620 raeburn 4397: if ((ref($navmapref)) && (ref($$navmapref))) {
4398: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.encrypturl")) eq 'yes') {
4399: $encryptmap = 1;
4400: }
1.617 raeburn 4401: }
4402: }
1.630 raeburn 4403:
1.617 raeburn 4404: # Append randompick number, hidden, and encrypted with ":" to foldername,
4405: # so it gets transferred between levels
4406: $folderpath.=$containerarg.'&'.$foldername.
4407: ':'.$rpicknum.':'.$hiddenmap.':'.$encryptmap.':'.$randorder.':'.$ispage;
1.615 raeburn 4408: unless ($url eq '') {
1.612 raeburn 4409: $url.='folderpath='.&escape($folderpath);
4410: }
1.510 raeburn 4411: my $rpckchk;
4412: if ($rpicknum) {
4413: $rpckchk = ' checked="checked"';
1.543 raeburn 4414: if (($ishash) && (ref($filtersref->{'randompick'}) eq 'ARRAY')) {
4415: push(@{$filtersref->{'randompick'}},$orderidx.':'.$rpicknum);
4416: }
1.510 raeburn 4417: }
1.537 raeburn 4418: my $formname = 'edit_randompick_'.$orderidx;
1.510 raeburn 4419: $rand_pick_text =
1.478 raeburn 4420: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.538 raeburn 4421: $form_param."\n".
1.478 raeburn 4422: $form_common."\n".
1.611 raeburn 4423: '<span class="LC_nobreak"><label><input type="checkbox" name="randompick_'.$orderidx.'" id="randompick_'.$orderidx.'" onclick="'."updatePick(this.form,'$orderidx','check');".'"'.$rpckchk.$disabled.' /> '.&mt('Randomly Pick').'</label><input type="hidden" name="rpicknum_'.$orderidx.'" id="rpicknum_'.$orderidx.'" value="'.$rpicknum.'" /><span id="randompicknum_'.$orderidx.'">';
1.510 raeburn 4424: if ($rpicknum ne '') {
4425: $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
4426: }
1.537 raeburn 4427: $rand_pick_text .= '</span></span>'.
4428: $form_end;
1.543 raeburn 4429: my $ro_set;
1.617 raeburn 4430: if ($randorder) {
1.543 raeburn 4431: $ro_set = 'checked="checked"';
4432: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4433: push(@{$filtersref->{'randomorder'}},$orderidx);
4434: }
4435: }
1.564 raeburn 4436: $formname = 'edit_rorder_'.$orderidx;
1.510 raeburn 4437: $rand_order_text =
1.537 raeburn 4438: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.538 raeburn 4439: $form_param."\n".
1.537 raeburn 4440: $form_common."\n".
1.611 raeburn 4441: '<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.$disabled.' /> '.&mt('Random Order').' </label></span>'.
1.537 raeburn 4442: $form_end;
1.510 raeburn 4443: }
1.509 raeburn 4444: } elsif ($supplementalflag && !$allowed) {
1.598 raeburn 4445: my $isexttool;
1.626 raeburn 4446: if ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
1.598 raeburn 4447: $url='/adm/wrapper'.$url;
4448: $isexttool = 1;
4449: }
1.510 raeburn 4450: $url .= ($url =~ /\?/) ? '&':'?';
1.509 raeburn 4451: $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
1.510 raeburn 4452: if ($title) {
4453: $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"');
4454: }
1.598 raeburn 4455: if ((($isexternal) || ($isexttool)) && $orderidx) {
1.510 raeburn 4456: $url .= '&idx='.$orderidx;
4457: }
1.610 raeburn 4458: if ($anchor ne '') {
4459: $url .= '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4460: }
1.682 raeburn 4461: if (ref($supphidden) eq 'HASH') {
4462: if ($supphidden->{$suppmapid.':'.$residx}) {
4463: $hiddenres = 1;
4464: }
4465: }
1.329 droeschl 4466: }
1.519 raeburn 4467: my ($tdalign,$tdwidth);
1.501 raeburn 4468: if ($allowed) {
1.630 raeburn 4469: my $fileloc =
1.501 raeburn 4470: &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
1.510 raeburn 4471: if ($isexternal) {
1.630 raeburn 4472: ($editlink,$extresform) =
1.611 raeburn 4473: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
4474: undef,undef,undef,undef,undef,undef,
4475: undef,$disabled);
1.626 raeburn 4476: } elsif ($orig_url =~ m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
1.598 raeburn 4477: ($editlink,$extresform) =
4478: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
4479: undef,undef,undef,'tool',$coursedom,
1.611 raeburn 4480: $coursenum,$ltitoolsref,$disabled);
1.511 raeburn 4481: } elsif (!$isfolder && !$ispage) {
1.503 raeburn 4482: my ($cfile,$home,$switchserver,$forceedit,$forceview) =
4483: &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
1.511 raeburn 4484: if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
1.610 raeburn 4485: my $suppanchor;
4486: if ($supplementalflag) {
4487: $suppanchor = $anchor;
4488: }
1.630 raeburn 4489: my $jscall =
1.501 raeburn 4490: &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
4491: $switchserver,
1.503 raeburn 4492: $forceedit,
1.679 raeburn 4493: undef,$symb,$shownsymb,
1.511 raeburn 4494: &escape($env{'form.folderpath'}),
1.622 raeburn 4495: $renametitle,$hostname,
4496: '','',1,$suppanchor);
1.501 raeburn 4497: if ($jscall) {
1.518 raeburn 4498: $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
4499: $jscall.'" >'.&mt('Edit').'</a> '."\n";
1.501 raeburn 4500: }
4501: }
4502: }
1.519 raeburn 4503: $tdalign = ' align="right" valign="top"';
4504: $tdwidth = ' width="80%"';
1.329 droeschl 4505: }
1.408 raeburn 4506: my $reinit;
4507: if ($crstype eq 'Community') {
4508: $reinit = &mt('(re-initialize community to access)');
4509: } else {
4510: $reinit = &mt('(re-initialize course to access)');
1.519 raeburn 4511: }
4512: $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;
1.650 raeburn 4513: if ($orig_url =~ /$LONCAPA::assess_re/) {
1.633 raeburn 4514: $line.= '<br />';
4515: if ($curralias ne '') {
4516: $line.='<span class="LC_nobreak"><a href="javascript:delalias('."'$esc_path','$orderidx'".');" class="LC_docs_alias">'.
4517: $lt{'da'}.'</a></span>';
4518: } else {
4519: $line.='<span class="LC_nobreak"><a href="javascript:setalias('."'$esc_path','$orderidx'".');" class="LC_docs_alias">'.
4520: $lt{'sa'}.'</a></span>';
4521: }
4522: }
4523: $line.='</td><td>';
1.621 raeburn 4524: my $link;
1.472 raeburn 4525: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 4526: $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
4527: } elsif ($url) {
1.610 raeburn 4528: if ($anchor ne '') {
4529: if ($supplementalflag) {
4530: $anchor = '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4531: } else {
4532: $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');
4533: }
4534: }
1.622 raeburn 4535: if ((!$supplementalflag) && ($nomodal) && ($hostname ne '')) {
4536: $link = 'http://'.$hostname.$url;
4537: } else {
4538: $link = $url;
4539: }
1.659 raeburn 4540: $link = &js_escape($link.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.$anchor);
1.621 raeburn 4541: if ($nomodal) {
4542: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4543: '<img src="'.$icon.'" alt="" class="LC_icon" border="0" /></a>';
4544: } else {
4545: $line.=&Apache::loncommon::modal_link($link,
4546: '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
4547: }
1.469 www 4548: } else {
4549: $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
4550: }
1.519 raeburn 4551: $line.='</span></td><td'.$tdwidth.'>';
1.472 raeburn 4552: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 4553: $line.='<a href="'.$url.'">'.$title.'</a>';
1.682 raeburn 4554: if (!$allowed && $supplementalflag && $canedit && $isfolder) {
4555: my $editicon = &Apache::loncommon::lonhttpdurl('/res/adm/pages').'/editmap.png';
4556: my $editurl = $url;
4557: $editurl =~ s{^\Q/adm/supplemental?\E}{/adm/coursedocs?command=direct&forcesupplement=1&};
4558: $line .= ' '.'<a href="'.$editurl.'">'.
4559: '<img src="'.$editicon.'" alt="'.&mt('Edit Content').'" title="'.&mt('Edit Content').'" />'.
4560: '</a>';
4561: }
4562: if ((($hiddenfolder) || ($hiddenres)) && (!$allowed) && ($supplementalflag)) {
4563: $line.= ' <span class="LC_warning">('.&mt('hidden').')</span> ';
4564: }
1.469 www 4565: } elsif ($url) {
1.621 raeburn 4566: if ($nomodal) {
4567: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4568: $title.'</a>';
4569: } else {
4570: $line.=&Apache::loncommon::modal_link($link,$title,600,500);
4571: }
1.617 raeburn 4572: } elsif (($hiddenfolder) || ($hiddenres)) {
1.632 raeburn 4573: $line.=$title.' <span class="LC_warning LC_docs_reinit_warn">('.&mt('Hidden').')</span>';
1.469 www 4574: } else {
4575: $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
4576: }
1.633 raeburn 4577: if (($allowed) && ($curralias ne '')) {
4578: $line .= '<br /><span class="LC_docs_alias_name">('.$curralias.')</span>';
4579: } else {
4580: $line .= $extresform;
4581: }
4582: $line .= '</td>';
1.478 raeburn 4583: $rand_pick_text = ' ' if ($rand_pick_text eq '');
4584: $rand_order_text = ' ' if ($rand_order_text eq '');
1.682 raeburn 4585: if ($allowed) {
4586: my %lt=&Apache::lonlocal::texthash(
4587: 'hd' => 'Hidden',
4588: 'ec' => 'URL hidden');
4589: my ($enctext,$hidtext,$formhidden,$formurlhidden);
1.543 raeburn 4590: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4591: $hidtext = ' checked="checked"';
4592: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4593: push(@{$filtersref->{'hiddenresource'}},$orderidx);
4594: }
4595: }
1.682 raeburn 4596: $formhidden = 'edit_hiddenresource_'.$orderidx;
4597: $line.=(<<ENDPARMS);
1.329 droeschl 4598: <td class="LC_docs_entry_parameter">
1.537 raeburn 4599: <form action="/adm/coursedocs" method="post" name="$formhidden">
1.538 raeburn 4600: $form_param
1.478 raeburn 4601: $form_common
1.611 raeburn 4602: <label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'hiddenresource','settings');" $hidtext $disabled /> $lt{'hd'}</label>
1.329 droeschl 4603: $form_end
1.682 raeburn 4604: ENDPARMS
4605: if ($folder =~/^supplemental/) {
4606: $line.= "\n <td>";
4607: } else {
4608: if ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) {
4609: $enctext = ' checked="checked"';
4610: if (($ishash) && (ref($filtersref->{'encrypturl'}) eq 'ARRAY')) {
4611: push(@{$filtersref->{'encrypturl'}},$orderidx);
4612: }
4613: }
4614: $formurlhidden = 'edit_encrypturl_'.$orderidx;
4615: $line.=(<<ENDPARMS);
1.458 raeburn 4616: <br />
1.537 raeburn 4617: <form action="/adm/coursedocs" method="post" name="$formurlhidden">
1.538 raeburn 4618: $form_param
1.478 raeburn 4619: $form_common
1.611 raeburn 4620: <label><input type="checkbox" name="encrypturl_$orderidx" id="encrypturl_$orderidx" onclick="checkForSubmit(this.form,'encrypturl','settings');" $enctext $disabled /> $lt{'ec'}</label>
1.329 droeschl 4621: $form_end
4622: </td>
1.478 raeburn 4623: <td class="LC_docs_entry_parameter">$rand_pick_text<br />
4624: $rand_order_text</td>
1.329 droeschl 4625: ENDPARMS
1.682 raeburn 4626: }
1.329 droeschl 4627: }
1.379 bisitz 4628: $line.=&Apache::loncommon::end_data_table_row();
1.329 droeschl 4629: return $line;
4630: }
4631:
1.538 raeburn 4632: sub action_restrictions {
4633: my ($cnum,$cdom,$url,$folderpath,$currgroups) = @_;
4634: my %denied = (
4635: cut => 0,
4636: copy => 0,
4637: remove => 0,
4638: );
4639: if ($url=~ m{^/res/.+\.(page|sequence)$}) {
4640: # no copy for published maps
4641: $denied{'copy'} = 1;
1.597 raeburn 4642: } elsif ($url=~m{^/res/lib/templates/([^/]+)\.problem$}) {
4643: unless ($1 eq 'simpleproblem') {
4644: $denied{'copy'} = 1;
4645: }
4646: $denied{'cut'} = 1;
1.538 raeburn 4647: } elsif ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") {
4648: if ($folderpath =~ /^default&[^\&]+$/) {
4649: if ((ref($currgroups) eq 'HASH') && (keys(%{$currgroups}) > 0)) {
4650: $denied{'remove'} = 1;
4651: }
4652: $denied{'cut'} = 1;
4653: $denied{'copy'} = 1;
4654: }
4655: } elsif ($url =~ m{^\Q/uploaded/$cdom/$cnum/group_folder_\E(\w+)\.sequence$}) {
4656: my $group = $1;
4657: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+$/) {
4658: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4659: $denied{'remove'} = 1;
4660: }
4661: }
4662: $denied{'cut'} = 1;
4663: $denied{'copy'} = 1;
4664: } elsif ($url =~ m{^\Q/adm/$cdom/$cnum/\E(\w+)/smppg$}) {
4665: my $group = $1;
4666: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&\Qgroup_folder_$group\E\&[^\&]+$/) {
4667: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4668: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4669: if (keys(%groupsettings) > 0) {
4670: $denied{'remove'} = 1;
4671: }
4672: $denied{'cut'} = 1;
4673: $denied{'copy'} = 1;
4674: }
4675: }
4676: } elsif ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&group_folder_(\w+)\&/) {
4677: my $group = $1;
4678: if ($url =~ /group_boards_\Q$group\E/) {
4679: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4680: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4681: if (keys(%groupsettings) > 0) {
4682: if (ref($groupsettings{'functions'}) eq 'HASH') {
4683: if ($groupsettings{'functions'}{'discussion'} eq 'on') {
4684: $denied{'remove'} = 1;
4685: }
4686: }
4687: }
4688: $denied{'cut'} = 1;
4689: $denied{'copy'} = 1;
4690: }
4691: }
4692: }
4693: return %denied;
4694: }
4695:
1.533 raeburn 4696: sub new_timebased_suffix {
1.538 raeburn 4697: my ($dom,$num,$type,$area,$container) = @_;
1.533 raeburn 4698: my ($prefix,$namespace,$idtype,$errtext,$locknotfreed);
1.538 raeburn 4699: if ($type eq 'paste') {
4700: $prefix = $type;
4701: $namespace = 'courseeditor';
1.587 raeburn 4702: $idtype = 'addcode';
1.538 raeburn 4703: } elsif ($type eq 'map') {
1.533 raeburn 4704: $prefix = 'docs';
4705: if ($area eq 'supplemental') {
4706: $prefix = 'supp';
4707: }
4708: $prefix .= $container;
4709: $namespace = 'uploadedmaps';
4710: } else {
4711: $prefix = $type;
4712: $namespace = 'templated';
1.504 raeburn 4713: }
4714: my ($suffix,$freedlock,$error) =
1.587 raeburn 4715: &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num,$idtype);
1.504 raeburn 4716: if (!$suffix) {
1.538 raeburn 4717: if ($type eq 'paste') {
4718: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.');
4719: } elsif ($type eq 'map') {
1.533 raeburn 4720: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
4721: } elsif ($type eq 'smppg') {
4722: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.');
1.626 raeburn 4723: } elsif ($type eq 'exttool') {
4724: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new external tool.');
1.533 raeburn 4725: } else {
1.565 bisitz 4726: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new discussion board.');
1.533 raeburn 4727: }
1.504 raeburn 4728: if ($error) {
4729: $errtext .= '<br />'.$error;
4730: }
4731: }
4732: if ($freedlock ne 'ok') {
1.630 raeburn 4733: $locknotfreed =
1.533 raeburn 4734: '<div class="LC_error">'.
4735: &mt('There was a problem removing a lockfile.').' ';
1.538 raeburn 4736: if ($type eq 'paste') {
1.591 raeburn 4737: if ($freedlock eq 'nolock') {
4738: $locknotfreed =
4739: '<div class="LC_error">'.
4740: &mt('A lockfile was not released when you added content to the clipboard earlier in this session.').' '.
4741:
1.593 droeschl 4742: &mt('As a result addition of items to the clipboard will be unavailable until your next log-in.');
1.591 raeburn 4743: } else {
4744: $locknotfreed .=
4745: &mt('This will prevent addition of items to the clipboard until your next log-in.');
4746: }
1.538 raeburn 4747: } elsif ($type eq 'map') {
1.591 raeburn 4748: $locknotfreed .=
4749: &mt('This will prevent creation of additional folders or composite pages in this course.');
1.533 raeburn 4750: } elsif ($type eq 'smppg') {
4751: $locknotfreed .=
4752: &mt('This will prevent creation of additional simple pages in this course.');
1.626 raeburn 4753: } elsif ($type eq 'exttool') {
4754: $locknotfreed .=
4755: &mt('This will prevent creation of additional external tools in this course.');
1.533 raeburn 4756: } else {
4757: $locknotfreed .=
1.565 bisitz 4758: &mt('This will prevent creation of additional discussion boards in this course.');
1.533 raeburn 4759: }
1.538 raeburn 4760: unless ($type eq 'paste') {
4761: $locknotfreed .=
1.560 raeburn 4762: ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
4763: '<a href="/adm/helpdesk" target="_helpdesk">','</a>');
1.538 raeburn 4764: }
4765: $locknotfreed .= '</div>';
1.504 raeburn 4766: }
4767: return ($suffix,$errtext,$locknotfreed);
4768: }
4769:
1.329 droeschl 4770: =pod
4771:
4772: =item tiehash()
4773:
4774: tie the hash
4775:
4776: =cut
4777:
4778: sub tiehash {
4779: my ($mode)=@_;
4780: $hashtied=0;
4781: if ($env{'request.course.fn'}) {
4782: if ($mode eq 'write') {
4783: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4784: &GDBM_WRCREAT(),0640)) {
4785: $hashtied=2;
4786: }
4787: } else {
4788: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4789: &GDBM_READER(),0640)) {
4790: $hashtied=1;
4791: }
4792: }
1.364 bisitz 4793: }
1.329 droeschl 4794: }
4795:
4796: sub untiehash {
4797: if ($hashtied) { untie %hash; }
4798: $hashtied=0;
4799: return OK;
4800: }
4801:
4802:
4803:
4804:
4805: sub checkonthis {
1.637 raeburn 4806: my ($r,$url,$level,$title,$checkstale)=@_;
1.329 droeschl 4807: $url=&unescape($url);
4808: $alreadyseen{$url}=1;
4809: $r->rflush();
4810: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
4811: $r->print("\n<br />");
4812: if ($level==0) {
4813: $r->print("<br />");
4814: }
4815: for (my $i=0;$i<=$level*5;$i++) {
4816: $r->print(' ');
4817: }
4818: $r->print('<a href="'.$url.'" target="cat">'.
4819: ($title?$title:$url).'</a> ');
4820: if ($url=~/^\/res\//) {
1.637 raeburn 4821: my $updated;
4822: if (($checkstale) && ($url !~ m{^/res/lib/templates/}) &&
4823: ($url !~ /\.\d+\.\w+$/)) {
4824: $updated = &Apache::lonnet::remove_stale_resfile($url);
4825: }
1.329 droeschl 4826: my $result=&Apache::lonnet::repcopy(
4827: &Apache::lonnet::filelocation('',$url));
4828: if ($result eq 'ok') {
4829: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
1.637 raeburn 4830: if ($updated) {
4831: $r->print('<br />');
4832: for (my $i=0;$i<=$level*5;$i++) {
4833: $r->print(' ');
4834: }
4835: $r->print('- '.&mt('Outdated copy removed'));
4836: }
1.329 droeschl 4837: $r->rflush();
4838: &Apache::lonnet::countacc($url);
4839: $url=~/\.(\w+)$/;
4840: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
4841: $r->print('<br />');
4842: $r->rflush();
4843: for (my $i=0;$i<=$level*5;$i++) {
4844: $r->print(' ');
4845: }
4846: $r->print('- '.&mt('Rendering:').' ');
4847: my ($errorcount,$warningcount)=split(/:/,
4848: &Apache::lonnet::ssi_body($url,
4849: ('grade_target'=>'web',
4850: 'return_only_error_and_warning_counts' => 1)));
4851: if (($errorcount) ||
4852: ($warningcount)) {
4853: if ($errorcount) {
1.369 bisitz 4854: $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1.329 droeschl 4855: &mt('[quant,_1,error]',$errorcount).'</span>');
4856: }
4857: if ($warningcount) {
4858: $r->print('<span class="LC_warning">'.
4859: &mt('[quant,_1,warning]',$warningcount).'</span>');
4860: }
4861: } else {
4862: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
4863: }
4864: $r->rflush();
4865: }
4866: my $dependencies=
4867: &Apache::lonnet::metadata($url,'dependencies');
4868: foreach my $dep (split(/\,/,$dependencies)) {
4869: if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
1.637 raeburn 4870: &checkonthis($r,$dep,$level+1,'',$checkstale);
1.329 droeschl 4871: }
4872: }
4873: } elsif ($result eq 'unavailable') {
4874: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
4875: } elsif ($result eq 'not_found') {
4876: unless ($url=~/\$/) {
1.521 bisitz 4877: $r->print('<span class="LC_error">'.&mt('not found').'</span>');
1.329 droeschl 4878: } else {
1.366 bisitz 4879: $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1.329 droeschl 4880: }
4881: } else {
4882: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
4883: }
1.637 raeburn 4884: if (($updated) && ($result ne 'ok')) {
4885: $r->print('<br />'.&mt('Outdated copy removed'));
4886: }
1.329 droeschl 4887: }
4888: }
4889: }
4890:
4891:
4892:
4893: =pod
4894:
4895: =item list_symbs()
4896:
1.485 raeburn 4897: List Content Identifiers
1.329 droeschl 4898:
4899: =cut
4900:
4901: sub list_symbs {
4902: my ($r) = @_;
4903:
1.408 raeburn 4904: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 4905: $r->print(&Apache::loncommon::start_page('List of Content Identifiers'));
4906: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Identifiers'));
4907: $r->print(&startContentScreen('tools'));
1.329 droeschl 4908: my $navmap = Apache::lonnavmaps::navmap->new();
4909: if (!defined($navmap)) {
4910: $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
4911: '<div class="LC_error">'.
4912: &mt('Unable to retrieve information about course contents').
4913: '</div>');
1.408 raeburn 4914: &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
1.329 droeschl 4915: } else {
1.484 raeburn 4916: $r->print('<h4 class="LC_info">'.&mt("$crstype Content Identifiers").'</h4>'.
4917: &Apache::loncommon::start_data_table().
4918: &Apache::loncommon::start_data_table_header_row().
4919: '<th>'.&mt('Title').'</th><th>'.&mt('Identifier').'</th>'.
4920: &Apache::loncommon::end_data_table_header_row()."\n");
4921: my $count;
1.329 droeschl 4922: foreach my $res ($navmap->retrieveResources()) {
1.484 raeburn 4923: $r->print(&Apache::loncommon::start_data_table_row().
4924: '<td>'.$res->compTitle().'</td>'.
4925: '<td>'.$res->symb().'</td>'.
1.521 bisitz 4926: &Apache::loncommon::end_data_table_row());
1.484 raeburn 4927: $count ++;
4928: }
4929: if (!$count) {
4930: $r->print(&Apache::loncommon::start_data_table_row().
4931: '<td colspan="2">'.&mt("$crstype is empty").'</td>'.
4932: &Apache::loncommon::end_data_table_row());
1.329 droeschl 4933: }
1.484 raeburn 4934: $r->print(&Apache::loncommon::end_data_table());
1.329 droeschl 4935: }
1.521 bisitz 4936: $r->print(&endContentScreen());
1.329 droeschl 4937: }
4938:
1.651 raeburn 4939: sub short_urls {
4940: my ($r,$canedit) = @_;
4941: my $crstype = &Apache::loncommon::course_type();
4942: my $formname = 'shortenurl';
4943: $r->print(&Apache::loncommon::start_page('Display/Set Shortened URLs'));
4944: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Shortened URLs'));
4945: $r->print(&startContentScreen('tools'));
4946: my ($navmap,$errormsg) =
4947: &Apache::loncourserespicker::get_navmap_object($crstype,'shorturls');
4948: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
4949: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4950: my (%maps,%resources,%titles);
4951: if (!ref($navmap)) {
4952: $r->print($errormsg.
4953: &endContentScreen());
4954: return '';
4955: } else {
1.652 raeburn 4956: $r->print('<h4 class="LC_info">'.&mt('Tiny URLs for deep-linking into course').'</h4>'."\n");
1.651 raeburn 4957: $r->rflush();
4958: my $readonly;
4959: if ($canedit) {
1.671 raeburn 4960: my ($numnew,$errors) = &Apache::loncommon::get_requested_shorturls($cdom,$cnum,$navmap);
1.651 raeburn 4961: if ($numnew) {
4962: $r->print('<p class="LC_info">'.&mt('Created [quant,_1,URL]',$numnew).'</p>');
4963: }
4964: if ((ref($errors) eq 'ARRAY') && (@{$errors} > 0)) {
4965: $r->print(&mt('The following errors occurred when processing your request to create shortened URLs:').'<br /><ul>');
4966: foreach my $error (@{$errors}) {
4967: $r->print('<li>'.$error.'</li>');
4968: }
4969: $r->print('</ul><br />');
4970: }
4971: } else {
4972: $readonly = 1;
4973: }
4974: my %currtiny = &Apache::lonnet::dump('tiny',$cdom,$cnum);
4975: $r->print(&Apache::loncourserespicker::create_picker($navmap,'shorturls',$formname,$crstype,undef,
4976: undef,undef,undef,undef,undef,\%currtiny,$readonly));
4977: }
4978: $r->print(&endContentScreen());
4979: }
4980:
1.637 raeburn 4981: sub contentverifyform {
4982: my ($r) = @_;
4983: my $crstype = &Apache::loncommon::course_type();
4984: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
4985: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
4986: $r->print(&startContentScreen('tools'));
4987: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
4988: $r->print('<form method="post" action="/adm/coursedocs"><p>'.
4989: &mt('Include a check if files copied from elsewhere are up to date (will increase verification time)?').
4990: ' <span class="LC_nobreak">'.
4991: '<label><input type="radio" name="checkstale" value="0" checked="checked" />'.
4992: &mt('No').'</label>'.(' 'x2).
4993: '<label><input type="radio" name="checkstale" value="1" />'.
4994: &mt('Yes').'</label></span></p><p>'.
1.674 raeburn 4995: '<input type="submit" value="'.&mt('Verify Content').' "/>'.
1.637 raeburn 4996: '<input type="hidden" value="1" name="tools" />'.
4997: '<input type="hidden" value="1" name="verify" /></p></form>');
4998: $r->print(&endContentScreen());
4999: return;
5000: }
1.329 droeschl 5001:
5002: sub verifycontent {
1.637 raeburn 5003: my ($r,$checkstale) = @_;
1.408 raeburn 5004: my $crstype = &Apache::loncommon::course_type();
1.549 raeburn 5005: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
5006: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
1.484 raeburn 5007: $r->print(&startContentScreen('tools'));
5008: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
1.329 droeschl 5009: $hashtied=0;
5010: undef %alreadyseen;
5011: %alreadyseen=();
5012: &tiehash();
1.484 raeburn 5013:
1.329 droeschl 5014: foreach my $key (keys(%hash)) {
5015: if ($hash{$key}=~/\.(page|sequence)$/) {
5016: if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
5017: $r->print('<hr /><span class="LC_error">'.
1.419 bisitz 5018: &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
1.329 droeschl 5019: &unescape($hash{$key}).'</span><br />'.
1.419 bisitz 5020: &mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />');
1.329 droeschl 5021: }
5022: }
5023: if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
1.637 raeburn 5024: &checkonthis($r,$hash{$key},0,$hash{'title_'.$1},$checkstale);
1.329 droeschl 5025: }
5026: }
5027: &untiehash();
1.442 www 5028: $r->print('<p class="LC_success">'.&mt('Done').'</p>');
1.521 bisitz 5029: $r->print(&endContentScreen());
1.329 droeschl 5030: }
5031:
5032: sub devalidateversioncache {
5033: my $src=shift;
5034: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
5035: &Apache::lonnet::clutter($src));
5036: }
5037:
5038: sub checkversions {
1.611 raeburn 5039: my ($r,$canedit) = @_;
1.408 raeburn 5040: my $crstype = &Apache::loncommon::course_type();
1.571 raeburn 5041: $r->print(&Apache::loncommon::start_page("Check $crstype Resource Versions"));
5042: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Resource Versions"));
1.484 raeburn 5043: $r->print(&startContentScreen('tools'));
1.442 www 5044:
1.329 droeschl 5045: my $header='';
5046: my $startsel='';
5047: my $monthsel='';
5048: my $weeksel='';
5049: my $daysel='';
5050: my $allsel='';
5051: my %changes=();
5052: my $starttime=0;
5053: my $haschanged=0;
5054: my %setversions=&Apache::lonnet::dump('resourceversions',
5055: $env{'course.'.$env{'request.course.id'}.'.domain'},
5056: $env{'course.'.$env{'request.course.id'}.'.num'});
5057:
5058: $hashtied=0;
5059: &tiehash();
1.611 raeburn 5060: if ($canedit) {
5061: my %newsetversions=();
5062: if ($env{'form.setmostrecent'}) {
5063: $haschanged=1;
5064: foreach my $key (keys(%hash)) {
5065: if ($key=~/^ids\_(\/res\/.+)$/) {
5066: $newsetversions{$1}='mostrecent';
5067: &devalidateversioncache($1);
5068: }
5069: }
5070: } elsif ($env{'form.setcurrent'}) {
5071: $haschanged=1;
5072: foreach my $key (keys(%hash)) {
5073: if ($key=~/^ids\_(\/res\/.+)$/) {
5074: my $getvers=&Apache::lonnet::getversion($1);
5075: if ($getvers>0) {
5076: $newsetversions{$1}=$getvers;
5077: &devalidateversioncache($1);
5078: }
5079: }
1.329 droeschl 5080: }
1.611 raeburn 5081: } elsif ($env{'form.setversions'}) {
5082: $haschanged=1;
5083: foreach my $key (keys(%env)) {
5084: if ($key=~/^form\.set_version_(.+)$/) {
5085: my $src=$1;
5086: if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
5087: $newsetversions{$src}=$env{$key};
5088: &devalidateversioncache($src);
5089: }
5090: }
1.329 droeschl 5091: }
1.611 raeburn 5092: }
5093: if ($haschanged) {
5094: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
5095: $env{'course.'.$env{'request.course.id'}.'.domain'},
5096: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
5097: $r->print(&Apache::loncommon::confirmwrapper(
5098: &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
5099: } else {
5100: $r->print(&Apache::loncommon::confirmwrapper(
5101: &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
1.329 droeschl 5102: }
1.611 raeburn 5103: &mark_hash_old();
5104: }
5105: &changewarning($r,'');
1.329 droeschl 5106: }
5107: if ($env{'form.timerange'} eq 'all') {
5108: # show all documents
1.549 raeburn 5109: $header=&mt('All content in '.$crstype);
1.521 bisitz 5110: $allsel=' selected="selected"';
1.329 droeschl 5111: foreach my $key (keys(%hash)) {
5112: if ($key=~/^ids\_(\/res\/.+)$/) {
5113: my $src=$1;
5114: $changes{$src}=1;
5115: }
5116: }
5117: } else {
5118: # show documents which changed
5119: %changes=&Apache::lonnet::dump
5120: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
5121: $env{'course.'.$env{'request.course.id'}.'.num'});
5122: my $firstkey=(keys(%changes))[0];
5123: unless ($firstkey=~/^error\:/) {
5124: unless ($env{'form.timerange'}) {
5125: $env{'form.timerange'}=604800;
5126: }
5127: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
5128: .&mt('seconds');
5129: if ($env{'form.timerange'}==-1) {
5130: $seltext='since start of course';
1.521 bisitz 5131: $startsel=' selected="selected"';
1.329 droeschl 5132: $env{'form.timerange'}=time;
5133: }
5134: $starttime=time-$env{'form.timerange'};
5135: if ($env{'form.timerange'}==2592000) {
5136: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 5137: $monthsel=' selected="selected"';
1.329 droeschl 5138: } elsif ($env{'form.timerange'}==604800) {
5139: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 5140: $weeksel=' selected="selected"';
1.329 droeschl 5141: } elsif ($env{'form.timerange'}==86400) {
5142: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 5143: $daysel=' selected="selected"';
1.329 droeschl 5144: }
5145: $header=&mt('Content changed').' '.$seltext;
5146: } else {
5147: $header=&mt('No content modifications yet.');
5148: }
5149: }
5150: %setversions=&Apache::lonnet::dump('resourceversions',
5151: $env{'course.'.$env{'request.course.id'}.'.domain'},
5152: $env{'course.'.$env{'request.course.id'}.'.num'});
5153: my %lt=&Apache::lonlocal::texthash
1.408 raeburn 5154: ('st' => 'Version changes since start of '.$crstype,
1.329 droeschl 5155: 'lm' => 'Version changes since last Month',
5156: 'lw' => 'Version changes since last Week',
5157: 'sy' => 'Version changes since Yesterday',
5158: 'al' => 'All Resources (possibly large output)',
1.484 raeburn 5159: 'cd' => 'Change display',
1.329 droeschl 5160: 'sd' => 'Display',
5161: 'fi' => 'File',
5162: 'md' => 'Modification Date',
5163: 'mr' => 'Most recently published Version',
1.408 raeburn 5164: 've' => 'Version used in '.$crstype,
5165: 'vu' => 'Set Version to be used in '.$crstype,
5166: 'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
1.329 droeschl 5167: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
5168: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.479 golterma 5169: 'di' => 'Differences',
1.484 raeburn 5170: 'save' => 'Save changes',
5171: 'vers' => 'Version choice(s) for specific resources',
1.479 golterma 5172: 'act' => 'Actions');
1.611 raeburn 5173: my ($disabled,$readonly);
5174: unless ($canedit) {
5175: $disabled = 'disabled="disabled"';
5176: $readonly = 1;
5177: }
1.329 droeschl 5178: $r->print(<<ENDHEADERS);
1.484 raeburn 5179: <h4 class="LC_info">$header</h4>
1.329 droeschl 5180: <form action="/adm/coursedocs" method="post">
5181: <input type="hidden" name="versions" value="1" />
1.484 raeburn 5182: <div class="LC_left_float">
1.479 golterma 5183: <fieldset>
1.484 raeburn 5184: <legend>$lt{'cd'}</legend>
1.329 droeschl 5185: <select name="timerange">
1.521 bisitz 5186: <option value='all'$allsel>$lt{'al'}</option>
5187: <option value="-1"$startsel>$lt{'st'}</option>
5188: <option value="2592000"$monthsel>$lt{'lm'}</option>
5189: <option value="604800"$weeksel>$lt{'lw'}</option>
5190: <option value="86400"$daysel>$lt{'sy'}</option>
1.329 droeschl 5191: </select>
5192: <input type="submit" name="display" value="$lt{'sd'}" />
1.484 raeburn 5193: </fieldset>
5194: </div>
5195: <div class="LC_left_float">
5196: <fieldset>
5197: <legend>$lt{'act'}</legend>
1.611 raeburn 5198: $lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" $disabled /><br />
5199: $lt{'sc'}: <input type="submit" name="setcurrent" value="Go" $disabled />
1.484 raeburn 5200: </fieldset>
5201: </div>
5202: <br clear="all" />
5203: <hr />
5204: <h4>$lt{'vers'}</h4>
1.329 droeschl 5205: ENDHEADERS
1.479 golterma 5206: #number of columns for version history
1.571 raeburn 5207: my %changedbytime;
5208: foreach my $key (keys(%changes)) {
5209: #excludes not versionable problems from resource version history:
5210: next if ($key =~ /^\/res\/lib\/templates/);
5211: my $chg;
5212: if ($env{'form.timerange'} eq 'all') {
5213: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
5214: $chg = &Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate');
5215: } else {
5216: $chg = $changes{$key};
5217: next if ($chg < $starttime);
5218: }
5219: push(@{$changedbytime{$chg}},$key);
5220: }
5221: if (keys(%changedbytime) == 0) {
5222: &untiehash();
5223: $r->print(&mt('No content changes in imported content in specified time frame').
5224: &endContentScreen());
5225: return;
5226: }
1.479 golterma 5227: $r->print(
1.611 raeburn 5228: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.521 bisitz 5229: &Apache::loncommon::start_data_table().
5230: &Apache::loncommon::start_data_table_header_row().
5231: '<th>'.&mt('Resources').'</th>'.
5232: "<th>$lt{'mr'}</th>".
5233: "<th>$lt{'ve'}</th>".
5234: "<th>$lt{'vu'}</th>".
5235: '<th>'.&mt('History').'</th>'.
5236: &Apache::loncommon::end_data_table_header_row()
5237: );
1.571 raeburn 5238: foreach my $chg (sort {$b <=> $a } keys(%changedbytime)) {
5239: foreach my $key (sort(@{$changedbytime{$chg}})) {
5240: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
5241: my $currentversion=&Apache::lonnet::getversion($key);
5242: if ($currentversion<0) {
5243: $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
5244: }
5245: my $linkurl=&Apache::lonnet::clutter($key);
5246: $r->print(
5247: &Apache::loncommon::start_data_table_row().
5248: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br />'.
5249: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
5250: '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br />('.
5251: &Apache::lonlocal::locallocaltime($chg).')</span></td>'.
5252: '<td align="right">'
5253: );
5254: # Used in course
5255: my $usedversion=$hash{'version_'.$linkurl};
5256: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.521 bisitz 5257: if ($usedversion != $currentversion) {
1.479 golterma 5258: $r->print('<span class="LC_warning">'.$usedversion.'</span>');
1.521 bisitz 5259: } else {
1.479 golterma 5260: $r->print($usedversion);
5261: }
1.329 droeschl 5262: } else {
1.521 bisitz 5263: $r->print($currentversion);
1.329 droeschl 5264: }
1.571 raeburn 5265: $r->print('</td><td title="'.$lt{'vu'}.'">');
5266: # Set version
5267: $r->print(&Apache::loncommon::select_form(
5268: $setversions{$linkurl},
5269: 'set_version_'.$linkurl,
5270: {'select_form_order' => ['',1..$currentversion,'mostrecent'],
5271: '' => '',
5272: 'mostrecent' => &mt('most recent'),
1.611 raeburn 5273: map {$_,$_} (1..$currentversion)},'',$readonly));
1.571 raeburn 5274: my $lastold=1;
5275: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
5276: my $url=$root.'.'.$prevvers.'.'.$extension;
5277: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) {
5278: $lastold=$prevvers;
5279: }
5280: }
5281: $r->print('</td>');
5282: # List all available versions
5283: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
5284: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
5285: my $url=$root.'.'.$prevvers.'.'.$extension;
5286: $r->print(
5287: '<span class="LC_nobreak">'
5288: .'<a href="'.&Apache::lonnet::clutter($url).'">'
5289: .&mt('Version [_1]',$prevvers).'</a>'
5290: .' ('.&Apache::lonlocal::locallocaltime(
1.521 bisitz 5291: &Apache::lonnet::metadata($url,'lastrevisiondate'))
1.571 raeburn 5292: .')');
5293: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
5294: $r->print(
5295: ' <a href="/adm/diff?filename='.
5296: &Apache::lonnet::clutter($root.'.'.$extension).
5297: &HTML::Entities::encode('&versionone='.$prevvers,'"<>&').
5298: '" target="diffs">'.&mt('Diffs').'</a>');
5299: }
5300: $r->print('</span><br />');
1.329 droeschl 5301: }
1.571 raeburn 5302: $r->print('</span></td>'.&Apache::loncommon::end_data_table_row());
1.521 bisitz 5303: }
1.329 droeschl 5304: }
1.521 bisitz 5305: $r->print(
5306: &Apache::loncommon::end_data_table().
1.611 raeburn 5307: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.521 bisitz 5308: '</form>'
5309: );
1.329 droeschl 5310:
5311: &untiehash();
1.521 bisitz 5312: $r->print(&endContentScreen());
1.571 raeburn 5313: return;
1.329 droeschl 5314: }
5315:
5316: sub mark_hash_old {
5317: my $retie_hash=0;
5318: if ($hashtied) {
5319: $retie_hash=1;
5320: &untiehash();
5321: }
5322: &tiehash('write');
5323: $hash{'old'}=1;
5324: &untiehash();
5325: if ($retie_hash) { &tiehash(); }
5326: }
5327:
5328: sub is_hash_old {
5329: my $untie_hash=0;
5330: if (!$hashtied) {
5331: $untie_hash=1;
5332: &tiehash();
5333: }
5334: my $return=$hash{'old'};
5335: if ($untie_hash) { &untiehash(); }
5336: return $return;
5337: }
5338:
5339: sub changewarning {
5340: my ($r,$postexec,$message,$url)=@_;
5341: if (!&is_hash_old()) { return; }
5342: my $pathvar='folderpath';
5343: my $path=&escape($env{'form.folderpath'});
5344: if (!defined($url)) {
5345: $url='/adm/coursedocs?'.$pathvar.'='.$path;
5346: }
5347: my $course_type = &Apache::loncommon::course_type();
5348: if (!defined($message)) {
5349: $message='Changes will become active for your current session after [_1], or the next time you log in.';
5350: }
1.653 raeburn 5351: my $windowname = 'loncapaclient';
5352: if ($env{'request.lti.login'}) {
5353: $windowname .= 'lti';
5354: }
1.329 droeschl 5355: $r->print("\n\n".
1.372 bisitz 5356: '<script type="text/javascript">'."\n".
5357: '// <![CDATA['."\n".
5358: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
5359: '// ]]>'."\n".
1.369 bisitz 5360: '</script>'."\n".
1.653 raeburn 5361: '<form name="reinitform" method="post" action="/adm/roles" target="'.$windowname.'">'.
1.329 droeschl 5362: '<input type="hidden" name="orgurl" value="'.$url.
1.372 bisitz 5363: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
1.329 droeschl 5364: &mt($message,' <input type="hidden" name="'.
5365: $env{'request.role'}.'" value="1" /><input type="button" value="'.
1.369 bisitz 5366: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1.372 bisitz 5367: $help{'Caching'}.'</p></form>'."\n\n");
1.329 droeschl 5368: }
5369:
5370:
5371: sub init_breadcrumbs {
1.571 raeburn 5372: my ($form,$text,$help)=@_;
1.329 droeschl 5373: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484 raeburn 5374: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
1.405 bisitz 5375: text=>&Apache::loncommon::course_type().' Editor',
1.329 droeschl 5376: faq=>273,
5377: bug=>'Instructor Interface',
1.571 raeburn 5378: help => $help});
1.329 droeschl 5379: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
5380: text=>$text,
5381: faq=>273,
5382: bug=>'Instructor Interface'});
5383: }
5384:
1.441 www 5385: # subroutine to list form elements
5386: sub create_list_elements {
5387: my @formarr = @_;
5388: my $list = '';
1.501 raeburn 5389: foreach my $button (@formarr){
5390: foreach my $picture (keys(%{$button})) {
5391: $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
1.441 www 5392: }
5393: }
5394: return $list;
5395: }
1.329 droeschl 5396:
1.441 www 5397: # subroutine to create ul from list elements
5398: sub create_form_ul {
5399: my $list = shift;
5400: my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
5401: return $ul;
5402: }
1.329 droeschl 5403:
1.442 www 5404: #
5405: # Start tabs
5406: #
5407:
5408: sub startContentScreen {
1.484 raeburn 5409: my ($mode) = @_;
5410: my $output = '<ul class="LC_TabContentBigger" id="mainnav">';
1.472 raeburn 5411: if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
1.484 raeburn 5412: $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n";
5413: $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n";
5414: $output .= '<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b> '.&mt('Content Index').' </b></a></li>'."\n";
5415: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
5416: } else {
1.549 raeburn 5417: $output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Main Content Editor').' </b></a></li>'."\n";
1.484 raeburn 5418: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
5419: $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>'."\n";
5420: '><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>';
5421: }
5422: $output .= "\n".'</ul>'."\n";
5423: $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
5424: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
5425: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
5426: return $output;
1.442 www 5427: }
5428:
5429: #
5430: # End tabs
5431: #
5432:
5433: sub endContentScreen {
1.484 raeburn 5434: return '</div></div></div>';
1.442 www 5435: }
1.329 droeschl 5436:
1.446 www 5437: sub supplemental_base {
1.548 raeburn 5438: return 'supplemental&'.&escape(&mt('Supplemental Content'));
1.446 www 5439: }
5440:
1.329 droeschl 5441: sub handler {
5442: my $r = shift;
5443: &Apache::loncommon::content_type($r,'text/html');
5444: $r->send_http_header;
5445: return OK if $r->header_only;
1.484 raeburn 5446:
5447: # get course data
1.408 raeburn 5448: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 5449: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
5450: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5451:
1.606 raeburn 5452: # get docroot
5453: my $londocroot = $r->dir_config('lonDocRoot');
5454:
1.484 raeburn 5455: # graphics settings
5456: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329 droeschl 5457:
1.443 www 5458: #
1.329 droeschl 5459: # --------------------------------------------- Initialize help topics for this
5460: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
1.627 raeburn 5461: 'Adding_External_Resource','Adding_External_Tool',
5462: 'Navigate_Content','Adding_Folders','Docs_Overview',
5463: 'Load_Map','Supplemental','Score_Upload_Form',
5464: 'Adding_Pages','Importing_LON-CAPA_Resource',
5465: 'Importing_IMS_Course','Uploading_From_Harddrive',
5466: 'Course_Roster','Web_Page','Dropbox','Simple_Problem') {
1.329 droeschl 5467: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
5468: }
5469: # Composite help files
5470: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
5471: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
5472: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
5473: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
5474: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
5475: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 5476: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 5477: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 5478: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 5479: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1.534 raeburn 5480:
1.611 raeburn 5481: my ($allowed,$canedit,$canview,$noendpage,$disabled);
1.682 raeburn 5482: # does this user have privileges to modify content.
5483: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
1.472 raeburn 5484: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
1.682 raeburn 5485: unless ($r->uri eq '/adm/supplemental') {
1.611 raeburn 5486: $allowed = 1;
1.682 raeburn 5487: }
5488: $canedit = 1;
5489: $canview = 1;
5490: } elsif (&Apache::lonnet::allowed('cev',$env{'request.course.id'})) {
5491: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
5492: unless ($r->uri eq '/adm/supplemental') {
1.611 raeburn 5493: $allowed = 1;
5494: }
1.682 raeburn 5495: $canview = 1;
1.611 raeburn 5496: }
5497: unless ($canedit) {
5498: $disabled = ' disabled="disabled"';
1.472 raeburn 5499: }
1.582 raeburn 5500: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']);
1.635 raeburn 5501: if ($env{'form.inhibitmenu'}) {
5502: unless ($env{'form.inhibitmenu'} eq 'yes') {
5503: delete($env{'form.inhibitmenu'});
5504: }
5505: }
5506:
1.582 raeburn 5507: if ($allowed && $env{'form.verify'}) {
1.571 raeburn 5508: &init_breadcrumbs('verify','Verify Content','Docs_Verify_Content');
1.637 raeburn 5509: if (!$canedit) {
5510: &verifycontent($r);
5511: } elsif (($env{'form.checkstale'} ne '') && ($env{'form.checkstale'} =~ /^\d$/)) {
5512: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1&verify=1&checkstale=$env{'form.checkstale'}",
5513: text=>'Results',
5514: faq=>273,
5515: bug=>'Instructor Interface'});
5516: &verifycontent($r,$env{'form.checkstale'});
5517: } else {
5518: &contentverifyform($r);
5519: }
1.329 droeschl 5520: } elsif ($allowed && $env{'form.listsymbs'}) {
1.484 raeburn 5521: &init_breadcrumbs('listsymbs','List Content IDs');
1.329 droeschl 5522: &list_symbs($r);
1.651 raeburn 5523: } elsif ($allowed && $env{'form.shorturls'}) {
5524: &init_breadcrumbs('shorturls','Set/Display Shortened URLs','Docs_Short_URLs');
5525: &short_urls($r,$canedit);
1.329 droeschl 5526: } elsif ($allowed && $env{'form.docslog'}) {
5527: &init_breadcrumbs('docslog','Show Log');
1.484 raeburn 5528: my $folder = $env{'form.folder'};
5529: if ($folder eq '') {
5530: $folder='default';
5531: }
1.611 raeburn 5532: &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit);
1.329 droeschl 5533: } elsif ($allowed && $env{'form.versions'}) {
1.571 raeburn 5534: &init_breadcrumbs('versions','Check/Set Resource Versions','Docs_Check_Resource_Versions');
1.611 raeburn 5535: &checkversions($r,$canedit);
5536: } elsif ($canedit && $env{'form.dumpcourse'}) {
1.568 raeburn 5537: &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329 droeschl 5538: &dumpcourse($r);
1.611 raeburn 5539: } elsif ($canedit && $env{'form.exportcourse'}) {
1.377 bisitz 5540: &init_breadcrumbs('exportcourse','IMS Export');
1.475 raeburn 5541: &Apache::imsexport::exportcourse($r);
1.329 droeschl 5542: } else {
1.611 raeburn 5543: if ($canedit && $env{'form.authorrole'}) {
1.606 raeburn 5544: $noendpage = 1;
5545: my ($redirect,$error) = &makenewproblem($r,$coursedom,$coursenum);
5546: if ($redirect) {
5547: if (($env{'form.newresourceadd'}) && ($env{'form.folderpath'})) {
5548: my $container = 'sequence';
5549: my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
5550: $is_random_order,$container) =
5551: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
5552: my (@folders)=split('&',$env{'form.folderpath'});
5553: $env{'form.foldername'}=&unescape(pop(@folders));
5554: my $folder=pop(@folders);
5555: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
5556: $folder.'.'.$container);
5557: my $warning;
5558: if ($fatal) {
5559: if ($container eq 'page') {
5560: $warning = &mt('An error occurred retrieving the contents of the current page.');
5561: } else {
5562: $warning = &mt('An error occurred retrieving the contents of the current folder.');
5563: }
5564: } else {
5565: my $url = $redirect;
5566: my $srcfile = $londocroot.$url;
5567: $url =~ s{^/priv/}{/res/};
5568: my $targetfile = $londocroot.$url;
5569: my $nokeyref = &Apache::lonpublisher::getnokey($r->dir_config('lonIncludes'));
5570: my $output = &Apache::lonpublisher::batchpublish($r,$srcfile,$targetfile,$nokeyref,1);
5571: $env{'form.folder'} = $folder;
5572: &snapshotbefore();
5573: my $title = &LONCAPA::map::qtunescape($env{'form.newresourcetitle'});
5574: my $ext = 'false';
5575: my $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
5576: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
5577: ':'.$ext.':normal:res';
5578: push(@LONCAPA::map::order,$newidx);
5579: &LONCAPA::map::storeparameter($newidx,'parameter_hiddenresource','yes',
5580: 'string_yesno');
5581: &remember_parms($newidx,'hiddenresource','set','yes');
5582: ($errtext,$fatal) =
5583: &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
5584: &log_differences($plain);
5585: &mark_hash_old();
5586: $r->internal_redirect($redirect);
5587: return OK;
5588: }
1.654 raeburn 5589: } else {
5590: $r->internal_redirect($redirect);
1.606 raeburn 5591: }
5592: }
5593: }
1.445 www 5594: #
5595: # Done catching special calls
1.484 raeburn 5596: # The whole rest is for course and supplemental documents and utilities menu
1.445 www 5597: # Get the parameters that may be needed
5598: #
5599: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.682 raeburn 5600: ['folderpath','title',
1.519 raeburn 5601: 'forcesupplement','forcestandard',
1.510 raeburn 5602: 'tools','symb','command','supppath']);
1.445 www 5603:
1.635 raeburn 5604: foreach my $item ('forcesupplement','forcestandard','tools') {
5605: next if ($env{'form.'.$item} eq '');
5606: unless ($env{'form.'.$item} eq '1') {
5607: delete($env{'form.'.$item});
5608: }
5609: }
5610:
5611: if ($env{'form.command'}) {
5612: unless ($env{'form.command'} =~ /^(direct|directnav|editdocs|editsupp|contents|home)$/) {
5613: delete($env{'form.command'});
5614: }
5615: }
5616:
5617: if ($env{'form.symb'}) {
5618: my ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.symb'});
5619: unless (($id =~ /^\d+$/) && (&Apache::lonnet::is_on_map($resurl))) {
5620: delete($env{'form.symb'});
5621: }
5622: }
5623:
1.445 www 5624: # standard=1: this is a "new-style" course with an uploaded map as top level
5625: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329 droeschl 5626:
5627: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445 www 5628:
1.484 raeburn 5629: # Decide whether this should display supplemental or main content or utilities
1.445 www 5630: # supplementalflag=1: show supplemental documents
5631: # supplementalflag=0: show standard documents
1.484 raeburn 5632: # toolsflag=1: show utilities
1.445 www 5633:
1.561 raeburn 5634: my $unesc_folderpath = &unescape($env{'form.folderpath'});
5635: my $supplementalflag=($unesc_folderpath=~/^supplemental/);
5636: if (($unesc_folderpath=~/^default/) || ($unesc_folderpath eq "")) {
1.445 www 5637: $supplementalflag=0;
5638: }
5639: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
5640: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
5641: unless ($allowed) { $supplementalflag=1; }
5642: unless ($standard) { $supplementalflag=1; }
1.484 raeburn 5643: my $toolsflag=0;
5644: if ($env{'form.tools'}) { $toolsflag=1; }
1.445 www 5645:
1.635 raeburn 5646: if ($env{'form.folderpath'} ne '') {
1.677 raeburn 5647: &validate_folderpath($supplementalflag);
1.635 raeburn 5648: }
5649:
5650: if ($env{'form.supppath'} ne '') {
1.677 raeburn 5651: &validate_suppath();
1.635 raeburn 5652: }
5653:
1.329 droeschl 5654: my $script='';
5655: my $showdoc=0;
1.457 raeburn 5656: my $addentries = {};
1.475 raeburn 5657: my $container;
1.329 droeschl 5658: my $containertag;
1.508 raeburn 5659: my $pathitem;
1.598 raeburn 5660: my %ltitools;
1.617 raeburn 5661: my $hiddentop;
1.615 raeburn 5662: my $navmap;
1.617 raeburn 5663: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.329 droeschl 5664:
1.464 www 5665: # Do we directly jump somewhere?
1.525 raeburn 5666: if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
1.472 raeburn 5667: if ($env{'form.symb'} ne '') {
1.522 raeburn 5668: $env{'form.folderpath'}=
1.617 raeburn 5669: &Apache::loncommon::symb_to_docspath($env{'form.symb'},\$navmap);
1.530 raeburn 5670: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
1.525 raeburn 5671: $env{'form.command'}.'_'.$env{'form.symb'}});
1.472 raeburn 5672: } elsif ($env{'form.supppath'} ne '') {
5673: $env{'form.folderpath'}=$env{'form.supppath'};
1.530 raeburn 5674: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
1.525 raeburn 5675: $env{'form.command'}.'_'.$env{'form.supppath'}});
1.466 www 5676: }
1.472 raeburn 5677: } elsif ($env{'form.command'} eq 'editdocs') {
1.617 raeburn 5678: $env{'form.folderpath'} = &default_folderpath($coursenum,$coursedom,\$navmap);
1.525 raeburn 5679: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
1.472 raeburn 5680: } elsif ($env{'form.command'} eq 'editsupp') {
1.617 raeburn 5681: $env{'form.folderpath'} = &supplemental_base();
1.525 raeburn 5682: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
5683: } elsif ($env{'form.command'} eq 'contents') {
5684: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
5685: } elsif ($env{'form.command'} eq 'home') {
5686: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
1.464 www 5687: }
5688:
1.525 raeburn 5689:
1.445 www 5690: # Where do we store these for when we come back?
5691: my $stored_folderpath='docs_folderpath';
5692: if ($supplementalflag) {
5693: $stored_folderpath='docs_sup_folderpath';
5694: }
1.464 www 5695:
1.519 raeburn 5696: # No folderpath, and in edit mode, see if we have something stored
5697: if ((!$env{'form.folderpath'}) && $allowed) {
1.445 www 5698: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.510 raeburn 5699: {'folderpath' => 'scalar'});
1.615 raeburn 5700:
5701: if (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
5702: if ($supplementalflag) {
5703: undef($env{'form.folderpath'}) if ($1 eq 'default');
5704: } else {
5705: undef($env{'form.folderpath'}) if ($1 eq 'supplemental');
5706: }
5707: } else {
1.523 raeburn 5708: undef($env{'form.folderpath'});
5709: }
1.677 raeburn 5710: if ($env{'form.folderpath'} ne '') {
5711: &validate_folderpath($supplementalflag);
5712: }
1.329 droeschl 5713: }
1.446 www 5714:
5715: # If we are not allowed to make changes, all we can see are supplemental docs
1.409 raeburn 5716: if (!$allowed) {
1.446 www 5717: unless ($env{'form.folderpath'} =~ /^supplemental/) {
5718: $env{'form.folderpath'} = &supplemental_base();
1.409 raeburn 5719: }
5720: }
1.446 www 5721: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329 droeschl 5722: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446 www 5723: $env{'form.folderpath'} = &supplemental_base()
5724: .'&'.
1.329 droeschl 5725: $env{'form.folderpath'};
5726: }
1.615 raeburn 5727: # If allowed and user's role is not advanced check folderpath is not hidden
5728: if (($allowed) && (!$env{'request.role.adv'}) &&
5729: ($env{'form.folderpath'} ne '') && (!$supplementalflag)) {
5730: my $folderurl;
5731: my @pathitems = split(/\&/,$env{'form.folderpath'});
1.617 raeburn 5732: my $folder = $pathitems[-2];
5733: if ($folder eq '') {
5734: undef($env{'form.folderpath'});
5735: } else {
5736: $folderurl = "uploaded/$coursedom/$coursenum/$folder";
1.666 raeburn 5737: if ((split(/\:/,$pathitems[-1]))[5]) {
1.615 raeburn 5738: $folderurl .= '.page';
5739: } else {
5740: $folderurl .= '.sequence';
5741: }
1.617 raeburn 5742: unless (ref($navmap)) {
5743: $navmap = Apache::lonnavmaps::navmap->new();
5744: }
1.615 raeburn 5745: if (ref($navmap)) {
5746: if (lc($navmap->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
1.617 raeburn 5747: my @resources = $navmap->retrieveResources($folderurl,$filterFunc,1,1);
5748: unless (@resources) {
5749: undef($env{'form.folderpath'});
5750: }
1.615 raeburn 5751: }
5752: }
5753: }
5754: }
5755:
5756:
1.446 www 5757: # If after all of this, we still don't have any paths, make them
1.519 raeburn 5758: unless ($env{'form.folderpath'}) {
1.446 www 5759: if ($supplementalflag) {
5760: $env{'form.folderpath'}=&supplemental_base();
1.617 raeburn 5761: } elsif ($allowed) {
5762: ($env{'form.folderpath'},$hiddentop) = &default_folderpath($coursenum,$coursedom,\$navmap);
1.446 www 5763: }
1.472 raeburn 5764: }
1.446 www 5765:
1.445 www 5766: # Store this
1.484 raeburn 5767: unless ($toolsflag) {
1.615 raeburn 5768: if (($allowed) && ($env{'form.folderpath'} ne '')) {
1.510 raeburn 5769: &Apache::loncommon::store_course_settings($stored_folderpath,
1.519 raeburn 5770: {'folderpath' => 'scalar'});
1.510 raeburn 5771: }
1.519 raeburn 5772: my $folderpath;
1.484 raeburn 5773: if ($env{'form.folderpath'}) {
1.519 raeburn 5774: $folderpath = $env{'form.folderpath'};
5775: my (@folders)=split('&',$env{'form.folderpath'});
5776: $env{'form.foldername'}=&unescape(pop(@folders));
5777: if ($env{'form.foldername'} =~ /\:1$/) {
5778: $container = 'page';
5779: } else {
5780: $container = 'sequence';
5781: }
5782: $env{'form.folder'}=pop(@folders);
1.484 raeburn 5783: } else {
1.519 raeburn 5784: if ($env{'form.folder'} eq '' ||
5785: $env{'form.folder'} eq 'supplemental') {
1.617 raeburn 5786: if ($env{'form.folder'} eq 'supplemental') {
5787: $folderpath=&supplemental_base();
5788: } elsif (!$hiddentop) {
5789: $folderpath='default&'.
5790: &escape(&mt('Main Content').':::::');
5791: }
1.484 raeburn 5792: }
5793: }
1.519 raeburn 5794: $containertag = '<input type="hidden" name="folderpath" value="" />';
5795: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 5796: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
5797: $showdoc='/'.$1;
5798: }
5799: if ($showdoc) { # got called in sequence from course
5800: $allowed=0;
5801: } else {
1.611 raeburn 5802: if ($canedit) {
1.484 raeburn 5803: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
5804: $script=&Apache::lonratedt::editscript('simple');
1.433 raeburn 5805: }
5806: }
1.329 droeschl 5807: }
5808:
1.344 bisitz 5809: # get personal data
1.329 droeschl 5810: my $uname=$env{'user.name'};
5811: my $udom=$env{'user.domain'};
5812: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
5813:
5814: if ($allowed) {
1.484 raeburn 5815: if ($toolsflag) {
5816: $script .= &inject_data_js();
5817: my ($home,$other,%outhash)=&authorhosts();
5818: if (!$home && $other) {
5819: my @hosts;
5820: foreach my $aurole (keys(%outhash)) {
5821: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
5822: push(@hosts,$outhash{$aurole});
5823: }
5824: }
5825: $script .= &dump_switchserver_js(@hosts);
5826: }
1.458 raeburn 5827: } else {
1.570 raeburn 5828: my $tid = 1;
1.484 raeburn 5829: my @tabids;
5830: if ($supplementalflag) {
1.655 raeburn 5831: @tabids = ('002','dd2','ee2','ff2');
1.570 raeburn 5832: $tid = 2;
1.484 raeburn 5833: } else {
5834: @tabids = ('aa1','bb1','cc1','ff1');
1.519 raeburn 5835: unless ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 5836: unshift(@tabids,'001');
5837: push(@tabids,('dd1','ee1'));
5838: }
1.458 raeburn 5839: }
1.484 raeburn 5840: my $tabidstr = join("','",@tabids);
1.644 raeburn 5841: %ltitools = &Apache::lonnet::get_domain_lti($coursedom,'consumer');
1.600 raeburn 5842: my $posslti = keys(%ltitools);
1.622 raeburn 5843: my $hostname = $r->hostname();
1.606 raeburn 5844: $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
1.622 raeburn 5845: $londocroot,$canedit,$hostname,\$navmap).
1.484 raeburn 5846: &history_tab_js().
5847: &inject_data_js().
1.570 raeburn 5848: &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
1.598 raeburn 5849: &Apache::lonextresedit::extedit_javascript(\%ltitools);
1.484 raeburn 5850: $addentries = {
1.485 raeburn 5851: onload => "javascript:resize_scrollbox('contentscroll','1','1');",
1.484 raeburn 5852: };
1.458 raeburn 5853: }
1.538 raeburn 5854: $script .= &paste_popup_js();
1.501 raeburn 5855: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
5856: &mt('Switch server?');
5857:
5858:
1.329 droeschl 5859: }
5860: # -------------------------------------------------------------------- Body tag
1.369 bisitz 5861: $script = '<script type="text/javascript">'."\n"
1.372 bisitz 5862: .'// <![CDATA['."\n"
5863: .$script."\n"
5864: .'// ]]>'."\n"
1.595 musolffc 5865: .'</script>'."\n"
5866: .'<script type="text/javascript"
5867: src="/res/adm/includes/file_upload.js"></script>'."\n";
1.385 bisitz 5868:
5869: # Breadcrumbs
5870: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.510 raeburn 5871:
5872: if ($showdoc) {
1.682 raeburn 5873: my $args;
5874: if ($supplementalflag) {
5875: my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$env{'form.title'},1);
5876: $args = {'bread_crumbs' => $brcrum};
5877: } else {
5878: $args = {'force_register' => $showdoc};
5879: }
5880: $r->print(&Apache::loncommon::start_page("$crstype documents",undef,$args));
1.571 raeburn 5881: } elsif ($toolsflag) {
1.611 raeburn 5882: my ($breadtext,$breadtitle);
1.617 raeburn 5883: $breadtext = "$crstype Editor";
1.611 raeburn 5884: if ($canedit) {
5885: $breadtitle = 'Editing '.$crstype.' Contents';
5886: } else {
5887: $breadtext .= ' (View-only mode)';
5888: $breadtitle = 'Viewing '.$crstype.' Contents';
5889: }
1.571 raeburn 5890: &Apache::lonhtmlcommon::add_breadcrumb({
1.611 raeburn 5891: href=>"/adm/coursedocs",text=>$breadtext});
1.571 raeburn 5892: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script)
5893: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5894: .&Apache::lonhtmlcommon::breadcrumbs(
1.611 raeburn 5895: $breadtitle)
1.571 raeburn 5896: );
1.510 raeburn 5897: } elsif ($r->uri eq '/adm/supplemental') {
1.682 raeburn 5898: unless ($env{'request.role.adv'}) {
5899: unless (&Apache::lonnet::has_unhidden_suppfiles($coursenum,$coursedom)) {
5900: $r->internal_redirect('/adm/navmaps');
5901: return OK;
5902: }
5903: }
1.510 raeburn 5904: my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
5905: $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
5906: {'bread_crumbs' => $brcrum,}));
5907: } else {
1.611 raeburn 5908: my ($breadtext,$breadtitle,$helpitem);
1.617 raeburn 5909: $breadtext = "$crstype Editor";
1.611 raeburn 5910: if ($canedit) {
5911: $breadtitle = 'Editing '.$crstype.' Contents';
5912: $helpitem = 'Docs_Adding_Course_Doc';
5913: } else {
5914: $breadtext .= ' (View-only mode)';
5915: $breadtitle = 'Viewing '.$crstype.' Contents';
5916: $helpitem = 'Docs_Viewing_Course_Doc';
5917: }
1.392 raeburn 5918: &Apache::lonhtmlcommon::add_breadcrumb({
1.611 raeburn 5919: href=>"/adm/coursedocs",text=>$breadtext});
1.446 www 5920: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.510 raeburn 5921: {'add_entries' => $addentries}
5922: )
1.392 raeburn 5923: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5924: .&Apache::lonhtmlcommon::breadcrumbs(
1.611 raeburn 5925: $breadtitle,
5926: $helpitem)
1.392 raeburn 5927: );
5928: }
1.364 bisitz 5929:
1.329 droeschl 5930: my %allfiles = ();
5931: my %codebase = ();
1.440 raeburn 5932: my ($upload_result,$upload_output,$uploadphase);
1.611 raeburn 5933: if ($canedit) {
1.329 droeschl 5934: if (($env{'form.uploaddoc.filename'}) &&
5935: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440 raeburn 5936: my $context = $1;
5937: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 5938: undef($hadchanges);
1.440 raeburn 5939: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
1.552 raeburn 5940: \%allfiles,\%codebase,$context,$crstype);
1.638 raeburn 5941: undef($navmap);
1.329 droeschl 5942: if ($hadchanges) {
5943: &mark_hash_old();
5944: }
1.440 raeburn 5945: $r->print($upload_output);
5946: } elsif ($env{'form.phase'} eq 'upload_embedded') {
5947: # Process file upload - phase two - upload embedded objects
5948: $uploadphase = 'check_embedded';
5949: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
5950: my $state = &embedded_form_elems($uploadphase,$primaryurl,
5951: $env{'form.newidx'});
5952: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5953: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5954: my ($destination,$dir_root) = &embedded_destination();
5955: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
5956: my $actionurl = '/adm/coursedocs';
1.630 raeburn 5957: my ($result,$flag) =
1.440 raeburn 5958: &Apache::loncommon::upload_embedded('coursedoc',$destination,
5959: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
5960: $actionurl);
5961: $r->print($result.&return_to_editor());
5962: } elsif ($env{'form.phase'} eq 'check_embedded') {
5963: # Process file upload - phase three - modify references in HTML file
5964: $uploadphase = 'modified_orightml';
5965: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5966: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5967: my ($destination,$dir_root) = &embedded_destination();
1.630 raeburn 5968: my $result =
1.482 raeburn 5969: &Apache::loncommon::modify_html_refs('coursedoc',$destination,
5970: $docuname,$docudom,undef,
5971: $dir_root);
1.630 raeburn 5972: $r->print($result.&return_to_editor());
1.476 raeburn 5973: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
5974: $uploadphase = 'decompress_phase_one';
5975: $r->print(&decompression_phase_one().
5976: &return_to_editor());
5977: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
5978: $uploadphase = 'decompress_phase_two';
5979: $r->print(&decompression_phase_two().
5980: &return_to_editor());
1.329 droeschl 5981: }
5982: }
5983:
1.484 raeburn 5984: if ($allowed && $toolsflag) {
5985: $r->print(&startContentScreen('tools'));
1.611 raeburn 5986: $r->print(&generate_admin_menu($crstype,$canedit));
1.484 raeburn 5987: $r->print(&endContentScreen());
5988: } elsif ((!$showdoc) && (!$uploadphase)) {
1.329 droeschl 5989: # -----------------------------------------------------------------------------
5990: my %lt=&Apache::lonlocal::texthash(
5991: 'copm' => 'All documents out of a published map into this folder',
1.501 raeburn 5992: 'upfi' => 'Upload File',
1.553 raeburn 5993: 'upld' => 'Upload Content',
1.329 droeschl 5994: 'srch' => 'Search',
5995: 'impo' => 'Import',
1.487 raeburn 5996: 'lnks' => 'Import from Stored Links',
1.502 raeburn 5997: 'impm' => 'Import from Assembled Map',
1.630 raeburn 5998: 'imcr' => 'Import from Course Resources',
1.598 raeburn 5999: 'extr' => 'External Resource',
6000: 'extt' => 'External Tool',
1.329 droeschl 6001: 'selm' => 'Select Map',
6002: 'load' => 'Load Map',
6003: 'newf' => 'New Folder',
6004: 'newp' => 'New Composite Page',
6005: 'syll' => 'Syllabus',
1.425 raeburn 6006: 'navc' => 'Table of Contents',
1.343 biermanm 6007: 'sipa' => 'Simple Course Page',
1.329 droeschl 6008: 'sipr' => 'Simple Problem',
1.630 raeburn 6009: 'webp' => 'Blank Web Page (editable)',
1.606 raeburn 6010: 'stpr' => 'Standard Problem',
6011: 'news' => 'New sub-directory',
6012: 'crpr' => 'Create Problem',
1.329 droeschl 6013: 'drbx' => 'Drop Box',
1.451 www 6014: 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336 schafran 6015: 'bull' => 'Discussion Board',
1.347 weissno 6016: 'mypi' => 'My Personal Information Page',
1.353 weissno 6017: 'grpo' => 'Group Portfolio',
1.329 droeschl 6018: 'rost' => 'Course Roster',
1.528 raeburn 6019: 'abou' => 'Personal Information Page for a User',
1.553 raeburn 6020: 'imsf' => 'IMS Upload',
6021: 'imsl' => 'Upload IMS package',
1.501 raeburn 6022: 'cms' => 'Origin of IMS package',
6023: 'se' => 'Select',
1.329 droeschl 6024: 'file' => 'File',
6025: 'title' => 'Title',
1.606 raeburn 6026: 'addp' => 'Add Placeholder to course?',
6027: 'uste' => 'Use Template?',
6028: 'fnam' => 'File Name:',
6029: 'loca' => 'Location:',
6030: 'dire' => 'Directory:',
6031: 'cate' => 'Category:',
6032: 'tmpl' => 'Template:',
1.329 droeschl 6033: 'comment' => 'Comment',
1.403 raeburn 6034: 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.577 bisitz 6035: 'bb5' => 'Blackboard 5',
6036: 'bb6' => 'Blackboard 6',
6037: 'angel5' => 'ANGEL 5.5',
6038: 'webctce4' => 'WebCT 4 Campus Edition',
1.606 raeburn 6039: 'yes' => 'Yes',
6040: 'no' => 'No',
1.618 raeburn 6041: 'er' => 'Editing rights unavailable for your current role.',
1.577 bisitz 6042: );
1.329 droeschl 6043: # -----------------------------------------------------------------------------
1.595 musolffc 6044:
6045: # Calculate free quota space for a user or course. A javascript function checks
6046: # file size to determine if upload should be allowed.
6047: my $quotatype = 'unofficial';
6048: if ($crstype eq 'Community') {
1.601 raeburn 6049: $quotatype = 'community';
6050: } elsif ($crstype eq 'Placement') {
6051: $quotatype = 'placement';
1.595 musolffc 6052: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
6053: $quotatype = 'official';
6054: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
6055: $quotatype = 'textbook';
6056: }
6057: my $disk_quota = &Apache::loncommon::get_user_quota($coursenum,$coursedom,
6058: 'course',$quotatype); # expressed in MB
6059: my $current_disk_usage = 0;
6060: foreach my $subdir ('docs','supplemental') {
6061: $current_disk_usage += &Apache::lonnet::diskusage($coursedom,$coursenum,
6062: "userfiles/$subdir",1); # expressed in kB
6063: }
6064: my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage);
1.605 raeburn 6065: my $usage = $current_disk_usage/1024; # in MB
6066: my $quota = $disk_quota;
6067: my $percent;
6068: if ($disk_quota == 0) {
6069: $percent = 100.0;
6070: } else {
1.619 raeburn 6071: $percent = 100*($usage/$disk_quota);
1.605 raeburn 6072: }
6073: $usage = sprintf("%.2f",$usage);
6074: $quota = sprintf("%.2f",$quota);
6075: $percent = sprintf("%.0f",$percent);
6076: my $quotainfo = '<p>'.&mt('Currently using [_1] of the [_2] available.',
6077: $percent.'%',$quota.' MB').'</p>';
1.595 musolffc 6078:
1.329 droeschl 6079: my $fileupload=(<<FIUP);
1.605 raeburn 6080: $quotainfo
1.329 droeschl 6081: $lt{'file'}:<br />
1.662 raeburn 6082: <input type="file" name="uploaddoc" class="LC_flUpload" size="40" $disabled />
1.663 raeburn 6083: <input type="hidden" id="LC_free_space" value="$free_space" />
1.329 droeschl 6084: FIUP
6085:
6086: my $checkbox=(<<CHBO);
6087: <!-- <label>$lt{'parse'}?
6088: <input type="checkbox" name="parserflag" />
6089: </label> -->
6090: <label>
1.611 raeburn 6091: <input type="checkbox" name="parserflag" checked="checked" $disabled /> $lt{'parse'}
1.329 droeschl 6092: </label>
6093: CHBO
1.501 raeburn 6094: my $imsfolder = $env{'form.folder'};
6095: if ($imsfolder eq '') {
6096: $imsfolder = 'default';
6097: }
6098: my $imspform=(<<IMSFORM);
6099: <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
6100: $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
6101: <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
1.516 raeburn 6102: <fieldset id="uploadimsform" style="display: none;">
1.501 raeburn 6103: <legend>$lt{'imsf'}</legend>
6104: $fileupload
6105: <br />
6106: <p>
6107: $lt{'cms'}:
1.611 raeburn 6108: <select name="source" $disabled>
1.501 raeburn 6109: <option value="-1" selected="selected">$lt{'se'}</option>
1.577 bisitz 6110: <option value="bb5">$lt{'bb5'}</option>
6111: <option value="bb6">$lt{'bb6'}</option>
6112: <option value="angel5">$lt{'angel5'}</option>
6113: <option value="webctce4">$lt{'webctce4'}</option>
1.501 raeburn 6114: </select>
6115: <input type="hidden" name="folder" value="$imsfolder" />
6116: </p>
6117: <input type="hidden" name="phase" value="one" />
1.611 raeburn 6118: <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" $disabled />
1.501 raeburn 6119: </fieldset>
6120: </form>
6121: IMSFORM
1.329 droeschl 6122:
6123: my $fileuploadform=(<<FUFORM);
1.501 raeburn 6124: <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
6125: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
6126: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.516 raeburn 6127: <fieldset id="uploaddocform" style="display: none;">
1.501 raeburn 6128: <legend>$lt{'upfi'}</legend>
1.371 tempelho 6129: <input type="hidden" name="active" value="aa" />
1.595 musolffc 6130: $fileupload
1.329 droeschl 6131: <br />
6132: $lt{'title'}:<br />
1.611 raeburn 6133: <input type="text" size="60" name="comment" $disabled />
1.508 raeburn 6134: $pathitem
1.329 droeschl 6135: <input type="hidden" name="cmd" value="upload_default" />
6136: <br />
1.458 raeburn 6137: <span class="LC_nobreak" style="float:left">
1.329 droeschl 6138: $checkbox
6139: </span>
1.501 raeburn 6140: <br clear="all" />
1.611 raeburn 6141: <input type="submit" value="$lt{'upld'}" $disabled />
1.501 raeburn 6142: </fieldset>
6143: </form>
1.383 tempelho 6144: FUFORM
1.329 droeschl 6145:
1.611 raeburn 6146: my $mapimportjs;
6147: if ($canedit) {
6148: $mapimportjs = "javascript:openbrowser('mapimportform','importmap','sequence,page','');";
6149: } else {
6150: $mapimportjs = "javascript:alert('".&js_escape($lt{'er'})."');";
6151: }
1.502 raeburn 6152: my $importpubform=(<<SEDFFORM);
1.514 raeburn 6153: <a class="LC_menubuttons_link" href="javascript:toggleMap('map');">
1.502 raeburn 6154: $lt{'impm'}</a>$help{'Load_Map'}
6155: <form action="/adm/coursedocs" method="post" name="mapimportform">
1.516 raeburn 6156: <fieldset id="importmapform" style="display: none;">
1.502 raeburn 6157: <legend>$lt{'impm'}</legend>
1.371 tempelho 6158: <input type="hidden" name="active" value="bb" />
1.502 raeburn 6159: $lt{'copm'}<br />
6160: <span class="LC_nobreak">
6161: <input type="text" name="importmap" size="40" value=""
1.611 raeburn 6162: onfocus="this.blur();$mapimportjs" $disabled />
6163: <a href="$mapimportjs">$lt{'selm'}</a></span><br />
6164: <input type="submit" name="loadmap" value="$lt{'load'}" $disabled />
1.502 raeburn 6165: </fieldset>
6166: </form>
6167:
1.383 tempelho 6168: SEDFFORM
1.606 raeburn 6169: my $importcrsresform;
1.608 raeburn 6170: my ($numdirs,$pickfile) =
6171: &Apache::loncommon::import_crsauthor_form('crsresimportform','coursepath','coursefile',
6172: "resize_scrollbox('contentscroll','1','0');",
6173: undef,'res');
1.606 raeburn 6174: if ($pickfile) {
6175: $importcrsresform=(<<CRSFORM);
6176: <a class="LC_menubuttons_link" href="javascript:toggleImportCrsres('res','$numdirs');">
6177: $lt{'imcr'}</a>$help{'Course_Resources'}
6178: <form action="/adm/coursedocs" method="post" name="crsresimportform" onsubmit="return validImportCrsRes();">
6179: <fieldset id="importcrsresform" style="display: none;">
6180: <legend>$lt{'imcr'}</legend>
6181: <input type="hidden" name="active" value="bb" />
6182: $pickfile
6183: <p>
1.611 raeburn 6184: $lt{'title'}: <input type="textbox" name="crsrestitle" value="" $disabled />
1.606 raeburn 6185: </p>
6186: <input type="hidden" name="importdetail" value="" />
1.611 raeburn 6187: <input type="submit" name="crsres" value="$lt{'impo'}" $disabled />
1.606 raeburn 6188: </fieldset>
6189: </form>
6190: CRSFORM
6191: }
6192:
1.611 raeburn 6193: my $fromstoredjs;
6194: if ($canedit) {
6195: $fromstoredjs = 'open_StoredLinks_Import()';
6196: } else {
6197: $fromstoredjs = "alert('".&js_escape($lt{'er'})."')";
6198: }
6199:
1.502 raeburn 6200: my @importpubforma = (
1.508 raeburn 6201: { '<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 6202: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{impo}.'" onclick="javascript:groupimport();"/>' => "<a class='LC_menubuttons_link' href='javascript:groupimport();'>$lt{'impo'}</a>$help{'Importing_LON-CAPA_Resource'}" },
1.611 raeburn 6203: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{lnks}.'" onclick="javascript:'.$fromstoredjs.';" />' => '<a class="LC_menubuttons_link" href="javascript:'.$fromstoredjs.';">'.$lt{'lnks'}.'</a>' },
1.606 raeburn 6204: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform },
6205: );
6206: if ($pickfile) {
6207: push(@importpubforma,{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{imcr}.'" onclick="javascript:toggleImportCrsres(\'res\','."'$numdirs'".');"/>' => $importcrsresform});
6208: }
1.502 raeburn 6209: $importpubform = &create_form_ul(&create_list_elements(@importpubforma));
1.510 raeburn 6210: my $extresourcesform =
6211: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
1.611 raeburn 6212: $help{'Adding_External_Resource'},
6213: undef,undef,undef,undef,undef,undef,$disabled);
1.598 raeburn 6214: my $exttoolform =
6215: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
6216: $help{'Adding_External_Tool'},undef,
6217: undef,'tool',$coursedom,$coursenum,
1.611 raeburn 6218: \%ltitools,$disabled);
1.329 droeschl 6219: if ($allowed) {
1.492 raeburn 6220: my $folder = $env{'form.folder'};
6221: if ($folder eq '') {
6222: $folder='default';
6223: }
1.615 raeburn 6224: if ($canedit) {
6225: my $output = &update_paste_buffer($coursenum,$coursedom,$folder);
6226: if ($output) {
6227: $r->print($output);
6228: }
1.538 raeburn 6229: }
1.337 ehlerst 6230: $r->print(<<HIDDENFORM);
6231: <form name="renameform" method="post" action="/adm/coursedocs">
6232: <input type="hidden" name="title" />
6233: <input type="hidden" name="cmd" />
6234: <input type="hidden" name="markcopy" />
6235: <input type="hidden" name="copyfolder" />
6236: $containertag
6237: </form>
1.633 raeburn 6238: <form name="aliasform" method="post" action="/adm/coursedocs">
6239: <input type="hidden" name="alias" />
6240: <input type="hidden" name="cmd" />
6241: $containertag
6242: </form>
1.484 raeburn 6243:
1.337 ehlerst 6244: HIDDENFORM
1.508 raeburn 6245: $r->print(&makesimpleeditform($pathitem)."\n".
6246: &makedocslogform($pathitem."\n".
1.484 raeburn 6247: '<input type="hidden" name="folder" value="'.
6248: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 6249: }
1.442 www 6250:
6251: # Generate the tabs
1.510 raeburn 6252: my ($mode,$needs_end);
1.472 raeburn 6253: if (($supplementalflag) && (!$allowed)) {
1.510 raeburn 6254: my @folders = split('&',$env{'form.folderpath'});
6255: unless (@folders > 2) {
6256: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
6257: $needs_end = 1;
6258: }
1.472 raeburn 6259: } else {
1.484 raeburn 6260: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.510 raeburn 6261: $needs_end = 1;
1.472 raeburn 6262: }
1.443 www 6263:
1.442 www 6264: #
1.622 raeburn 6265: my $hostname = $r->hostname();
1.442 www 6266: my $savefolderpath;
6267:
1.395 raeburn 6268: if ($allowed) {
1.329 droeschl 6269: my $folder=$env{'form.folder'};
1.615 raeburn 6270: if ((($folder eq '') && (!$hiddentop)) || ($supplementalflag)) {
1.329 droeschl 6271: $folder='default';
1.356 tempelho 6272: $savefolderpath = $env{'form.folderpath'};
1.548 raeburn 6273: $env{'form.folderpath'}='default&'.&escape(&mt('Main Content'));
1.508 raeburn 6274: $pathitem = '<input type="hidden" name="folderpath" value="'.
1.329 droeschl 6275: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
6276: }
6277: my $postexec='';
6278: if ($folder eq 'default') {
1.653 raeburn 6279: my $windowname = 'loncapaclient';
6280: if ($env{'request.lti.login'}) {
6281: $windowname .= 'lti';
6282: }
1.372 bisitz 6283: $r->print('<script type="text/javascript">'."\n"
6284: .'// <![CDATA['."\n"
1.653 raeburn 6285: .'this.window.name="'.$windowname.'";'."\n"
1.372 bisitz 6286: .'// ]]>'."\n"
6287: .'</script>'."\n"
1.369 bisitz 6288: );
1.329 droeschl 6289: } else {
6290: #$postexec='self.close();';
6291: }
1.504 raeburn 6292: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
6293: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
1.329 droeschl 6294: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
6295:
6296: my $newnavform=(<<NNFORM);
6297: <form action="/adm/coursedocs" method="post" name="newnav">
1.655 raeburn 6298: <input type="hidden" name="active" value="ff" />
1.508 raeburn 6299: $pathitem
1.329 droeschl 6300: <input type="hidden" name="importdetail"
6301: value="$lt{'navc'}=/adm/navmaps" />
1.611 raeburn 6302: <a class="LC_menubuttons_link" href="javascript:makenew(document.newnav);">$lt{'navc'}</a>
1.329 droeschl 6303: $help{'Navigate_Content'}
6304: </form>
6305: NNFORM
6306: my $newsmppageform=(<<NSPFORM);
6307: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.655 raeburn 6308: <input type="hidden" name="active" value="ff" />
1.508 raeburn 6309: $pathitem
1.329 droeschl 6310: <input type="hidden" name="importdetail" value="" />
1.423 onken 6311: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 6312: $help{'Simple Page'}
1.329 droeschl 6313: </form>
6314: NSPFORM
6315:
6316: my $newsmpproblemform=(<<NSPROBFORM);
6317: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.655 raeburn 6318: <input type="hidden" name="active" value="dd" />
1.508 raeburn 6319: $pathitem
1.329 droeschl 6320: <input type="hidden" name="importdetail" value="" />
1.423 onken 6321: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.572 raeburn 6322: $help{'Simple_Problem'}
1.329 droeschl 6323: </form>
6324:
6325: NSPROBFORM
6326:
6327: my $newdropboxform=(<<NDBFORM);
6328: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.655 raeburn 6329: <input type="hidden" name="active" value="dd" />
1.508 raeburn 6330: $pathitem
1.329 droeschl 6331: <input type="hidden" name="importdetail" value="" />
1.423 onken 6332: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.554 raeburn 6333: $help{'Dropbox'}
1.344 bisitz 6334: </form>
1.329 droeschl 6335: NDBFORM
6336:
6337: my $newexuploadform=(<<NEXUFORM);
6338: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.655 raeburn 6339: <input type="hidden" name="active" value="dd" />
1.508 raeburn 6340: $pathitem
1.329 droeschl 6341: <input type="hidden" name="importdetail" value="" />
1.423 onken 6342: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 6343: $help{'Score_Upload_Form'}
6344: </form>
6345: NEXUFORM
6346:
6347: my $newbulform=(<<NBFORM);
6348: <form action="/adm/coursedocs" method="post" name="newbul">
1.655 raeburn 6349: <input type="hidden" name="active" value="ee" />
1.508 raeburn 6350: $pathitem
1.329 droeschl 6351: <input type="hidden" name="importdetail" value="" />
1.423 onken 6352: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 6353: $help{'Bulletin Board'}
6354: </form>
6355: NBFORM
6356:
6357: my $newaboutmeform=(<<NAMFORM);
6358: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.655 raeburn 6359: <input type="hidden" name="active" value="ee" />
1.508 raeburn 6360: $pathitem
1.329 droeschl 6361: <input type="hidden" name="importdetail"
6362: value="$plainname=/adm/$udom/$uname/aboutme" />
1.611 raeburn 6363: <a class="LC_menubuttons_link" href="javascript:makenew(document.newaboutme);">$lt{'mypi'}</a>
1.347 weissno 6364: $help{'My Personal Information Page'}
1.329 droeschl 6365: </form>
6366: NAMFORM
6367:
6368: my $newaboutsomeoneform=(<<NASOFORM);
6369: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.655 raeburn 6370: <input type="hidden" name="active" value="ee" />
1.508 raeburn 6371: $pathitem
1.329 droeschl 6372: <input type="hidden" name="importdetail" value="" />
1.423 onken 6373: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 6374: </form>
6375: NASOFORM
6376:
6377: my $newrosterform=(<<NROSTFORM);
6378: <form action="/adm/coursedocs" method="post" name="newroster">
1.655 raeburn 6379: <input type="hidden" name="active" value="ee" />
1.508 raeburn 6380: $pathitem
1.329 droeschl 6381: <input type="hidden" name="importdetail"
6382: value="$lt{'rost'}=/adm/viewclasslist" />
1.611 raeburn 6383: <a class="LC_menubuttons_link" href="javascript:makenew(document.newroster);">$lt{'rost'}</a>
1.556 raeburn 6384: $help{'Course_Roster'}
1.329 droeschl 6385: </form>
6386: NROSTFORM
6387:
1.534 raeburn 6388: my $newwebpage;
6389: if ($folder =~ /^default_?(\d*)$/) {
6390: $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
6391: if ($1) {
6392: $newwebpage .= $1;
6393: } else {
6394: $newwebpage .= 'default';
6395: }
6396: $newwebpage .= '/new.html';
6397: }
6398: my $newwebpageform =(<<NWEBFORM);
6399: <form action="/adm/coursedocs" method="post" name="newwebpage">
1.655 raeburn 6400: <input type="hidden" name="active" value="ff" />
1.534 raeburn 6401: $pathitem
6402: <input type="hidden" name="importdetail" value="$newwebpage" />
6403: <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
1.556 raeburn 6404: $help{'Web_Page'}
1.534 raeburn 6405: </form>
6406: NWEBFORM
1.604 raeburn 6407:
1.606 raeburn 6408: my @ids=&Apache::lonnet::current_machine_ids();
6409: my %select_menus;
6410: my $numauthor = 0;
6411: my $numcrsdirs = 0;
6412: my $toppath = "/priv/$env{'user.domain'}/$env{'user.name'}";
6413: if ($env{'user.author'}) {
6414: $numauthor ++;
6415: $select_menus{'author'}->{'text'} = &Apache::lonnet::plaintext('au');
6416: if (grep(/^\Q$env{'user.home'}\E$/,@ids)) {
6417: my $is_home = 1;
6418: my %subdirs;
1.608 raeburn 6419: &Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs);
1.606 raeburn 6420: $select_menus{'author'}->{'default'} = '/';
6421: $select_menus{'author'}->{'select2'}->{'/'} = '/';
6422: my @ordered = ('/');
6423: foreach my $relpath (sort { lc($a) cmp lc($b) } (keys(%subdirs))) {
6424: $select_menus{'author'}->{'select2'}->{$relpath} = $relpath;
6425: push(@ordered,$relpath);
6426: }
6427: $select_menus{'author'}->{'order'} = \@ordered;
6428: } else {
6429: $select_menus{'author'}->{'select2'}->{'switch'} = &mt('Switch server required');
6430: $select_menus{'author'}->{'default'} = 'switch';
6431: $select_menus{'author'}->{'order'} = ['switch'];
6432: }
6433: }
6434: my %roleshash = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles',
6435: ['active'],['ca','aa']);
6436: my $crshome = $env{'course.'.$env{'request.course.id'}.'.home'};
6437: my %by_roletype;
6438: if (keys(%roleshash)) {
6439: foreach my $entry (keys(%roleshash)) {
6440: my ($auname,$audom,$roletype) = split(/:/,$entry);
6441: my $key = $entry;
6442: $key =~ s/:/___/g;
6443: $by_roletype{$roletype}{$auname.'___'.$audom} = 1;
6444: $select_menus{$key}->{'text'} = &Apache::lonnet::plaintext($roletype)." ($audom/$auname)";
6445: my $rolehome = &Apache::lonnet::homeserver($auname,$audom);
6446: if (grep(/^\Q$rolehome\E$/,@ids)) {
6447: my $is_home = 1;
6448: my (%subdirs,@ordered);
6449: my $toppath="/priv/$audom/$auname";
1.608 raeburn 6450: &Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs);
1.606 raeburn 6451: $select_menus{$key}->{'default'} = '/';
6452: $select_menus{$key}->{'select2'}->{'/'} = '/';
6453: my @ordered = ('/');
6454: foreach my $relpath (sort { lc($a) cmp lc($b) } (keys(%subdirs))) {
6455: $select_menus{$key}->{'select2'}->{$relpath} = $relpath;
6456: push(@ordered,$relpath);
6457: }
6458: $select_menus{$key}->{'order'} = \@ordered;
6459: } else {
6460: $select_menus{$key}->{'select2'}->{'switch'} = &mt('Switch server required');
6461: $select_menus{$key}->{'default'} = 'switch';
6462: $select_menus{$key}->{'order'} = ['switch'];
6463: }
6464: $numauthor ++;
6465: }
6466: }
1.631 raeburn 6467: my ($pickdir,$showtitle);
1.606 raeburn 6468: if ($numauthor) {
6469: my @order;
6470: my $defrole;
6471: if ($env{'user.author'}) {
6472: push(@order,'author');
6473: $defrole = 'author';
6474: }
6475: if (keys(%by_roletype)) {
6476: foreach my $possrole ('ca','aa') {
6477: if (ref($by_roletype{$possrole}) eq 'HASH') {
6478: foreach my $author (sort { lc($a) cmp lc($b) } (keys(%{$by_roletype{$possrole}}))) {
6479: unless ($defrole) {
6480: $defrole = $author;
6481: }
6482: push(@order,$author.'___'.$possrole);
6483: }
6484: }
6485: }
6486: }
6487: $select_menus{'course'}->{'text'} = &mt('Course Resource');
6488: if (grep(/^\Q$crshome\E$/,@ids)) {
6489: my $is_home = 1;
6490: my %subdirs;
6491: my $toppath="/priv/$coursedom/$coursenum";
1.608 raeburn 6492: &Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs);
1.606 raeburn 6493: $numcrsdirs = keys(%subdirs);
6494: $select_menus{'course'}->{'default'} = '/';
6495: $select_menus{'course'}->{'select2'}->{'/'} = '/';
6496: my @ordered = ('/');
6497: foreach my $relpath (sort { lc($a) cmp lc($b) } (keys(%subdirs))) {
6498: $select_menus{'course'}->{'select2'}->{$relpath} = $relpath;
6499: push(@ordered,$relpath);
6500: }
6501: $select_menus{'course'}->{'order'} = \@ordered;
6502: } else {
6503: $select_menus{'course'}->{'select2'}->{'switch'} = &mt('Switch server required');
6504: $select_menus{'course'}->{'default'} = 'switch';
6505: $select_menus{'course'}->{'order'} = ['switch'];
6506: }
6507: push(@order,'course');
6508: $pickdir = $lt{'loca'}.
6509: &Apache::loncommon::linked_select_forms('courseresform','<br />'.$lt{'dire'},
6510: $defrole,'authorrole','authorpath',
6511: \%select_menus,\@order,'toggleCrsResTitle();',
6512: '','priv').'<br />';
6513: $showtitle = 'none';
6514: } else {
6515: my $is_home;
6516: $showtitle = 'inline';
6517: if (grep(/^\Q$crshome\E$/,@ids)) {
6518: $is_home = 1;
6519: $pickdir .= '<input type="hidden" name="authorrole" value="course" />';
6520: my $toppath="/priv/$coursedom/$coursenum'}";
6521: my %subdirs;
1.608 raeburn 6522: &Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$toppath,'',\%subdirs);
1.606 raeburn 6523: $numcrsdirs = keys(%subdirs);
6524: if ($numcrsdirs) {
6525: $pickdir .= &mt('Directory: ').'<select name="authorpath">'."\n".
6526: '<option value="/">/</option>'."\n";
6527: foreach my $key (sort { lc($a) cmp lc($b) } (keys(%subdirs))) {
1.608 raeburn 6528: $pickdir .= '<option value="'.$key.'">'.$key.'</option>'."\n";
1.606 raeburn 6529: }
6530: $pickdir .= '</select>';
6531: } else {
6532: $pickdir .= '<input type="hidden" name="authorpath" value="/" />'."\n";
6533: }
6534: }
6535: }
6536:
6537: my %seltemplate_menus;
6538: my @files = &Apache::lonhomework::get_template_list('problem');
6539: my @noexamplelink = ('blank.problem','blank.library','script.library');
6540: my $currentcategory = '';
6541: my @ordered = ('');
6542: my %templatehelp;
6543: my $defcategory = '';
6544: my @catorder = ($defcategory);
6545: $seltemplate_menus{$defcategory}->{'order'} = [''];
6546: $seltemplate_menus{$defcategory}->{'text'} = '';
6547: foreach my $file (@files) {
6548: if (ref($file) eq 'ARRAY') {
6549: my ($path,$title,$category,$help) = @{$file};
6550: next if ($title !~ /\S/);
6551: if (&js_escape($category) ne $currentcategory) {
6552: $currentcategory = &js_escape($category);
6553: push(@catorder,&js_escape($currentcategory));
6554: $seltemplate_menus{$currentcategory}->{'text'} = $category;
6555: $seltemplate_menus{$currentcategory}->{'default'} = '';
6556: $seltemplate_menus{$currentcategory}->{'select2'}->{''} = '';
6557: push(@{$seltemplate_menus{$currentcategory}->{'order'}},'');
6558: }
6559: if ($path) {
6560: $seltemplate_menus{$currentcategory}->{'select2'}->{&js_escape($path)} = $title;
6561: push(@{$seltemplate_menus{$currentcategory}->{'order'}},&js_escape($path));
6562: if ($help) {
6563: $templatehelp{$path} = $help;
6564: }
6565: }
6566: }
6567: }
6568:
6569: my $templates = $lt{'cate'}.' '.
6570: &Apache::loncommon::linked_select_forms('courseresform','<br />'.$lt{'tmpl'}.' ',
6571: $defcategory,'tempcategory','template',
6572: \%seltemplate_menus,\@catorder,
6573: "resize_scrollbox('contentscroll','1','0');",
6574: "toggleExampleText();",'template').'<br />';
6575: my $templatepreview = '<a href="#" target="sample" onclick="javascript:getExample(600,420,\'yes\',true); return false;">'.
6576: '<span id="newresexample">'.&mt('Example').'<span></a>';
6577: my $crsresform=(<<RESFORM);
6578: <a class="LC_menubuttons_link" href="javascript:toggleCrsRes('res','$numauthor','$numcrsdirs');">
6579: $lt{'stpr'}</a>$help{'Course_Resource'}
6580: <form action="/adm/coursedocs" method="post" name="courseresform">
6581: <fieldset id="crsresform" style="display:none;">
6582: <legend>$lt{'stpr'}</legend>
1.655 raeburn 6583: <input type="hidden" name="active" value="bb" />
1.606 raeburn 6584: <p>
6585: $pickdir
6586: <span class="LC_nobreak">$lt{'news'}?
1.611 raeburn 6587: <label><input type="radio" name="newsubdir" value="0" onclick="toggleNewsubdir(this.form);" checked="checked" $disabled />No</label>
1.606 raeburn 6588:
1.611 raeburn 6589: <label><input type="radio" name="newsubdir" value="1" onclick="toggleNewsubdir(this.form);" $disabled />Yes</label>
1.606 raeburn 6590: </span><span id="newsubdir"></span>
6591: <input type="hidden" name="newsubdirname" id="newsubdirname" value="" autocomplete="off" />
6592: </p>
6593: $lt{'fnam'}
1.611 raeburn 6594: <input type="text" size="20" name="newresourcename" autocomplete="off" $disabled />
1.606 raeburn 6595: <p>
6596: <div id="newresource" style="display:$showtitle">
6597: $lt{'addp'}
1.611 raeburn 6598: <label><input type="radio" name="newresourceadd" value="0" checked="checked" onclick="toggleNewInCourse(this.form);" $disabled />
1.606 raeburn 6599: $lt{'no'}</label>
1.611 raeburn 6600: <label><input type="radio" name="newresourceadd" value="1" onclick="toggleNewInCourse(this.form);" $disabled />
1.606 raeburn 6601: $lt{'yes'}</label>
6602: <span id="newrestitle"></span>
1.611 raeburn 6603: <input type="hidden" size="20" name="newresourcetitle" id="newresourcetitle" autocomplete="off" $disabled />
1.606 raeburn 6604: </div>
6605: </p>
6606: <p>
6607: $lt{'uste'}
1.611 raeburn 6608: <label><input type="radio" name="newresusetemp" value="0" checked="checked" onclick="toggleWithTemplate(this.form);" $disabled />
1.606 raeburn 6609: $lt{'no'}</label>
1.611 raeburn 6610: <label><input type="radio" name="newresusetemp" value="1" onclick="toggleWithTemplate(this.form);" $disabled />
1.606 raeburn 6611: $lt{'yes'}</label>
6612: <div id="newrestemplate" style="display:none">
6613: $templates
6614: $templatepreview
6615: </div>
6616: </p>
6617: <span class="LC_nobreak">
6618: <input type="hidden" name="folderpath" value="$env{'form.folderpath'}" />
1.611 raeburn 6619: <input type="submit" name="newcrs" value="$lt{'crpr'}" $disabled />
1.606 raeburn 6620: </span>
6621: </fieldset>
6622: </form>
6623:
6624: RESFORM
1.534 raeburn 6625:
1.342 ehlerst 6626: my $specialdocumentsform;
1.383 tempelho 6627: my @specialdocumentsforma;
1.451 www 6628: my $gradingform;
6629: my @gradingforma;
6630: my $communityform;
6631: my @communityforma;
1.351 ehlerst 6632: my $newfolderform;
1.390 tempelho 6633: my $newfolderb;
1.342 ehlerst 6634:
1.451 www 6635: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 6636:
1.329 droeschl 6637: my $newpageform=(<<NPFORM);
6638: <form action="/adm/coursedocs" method="post" name="newpage">
6639: <input type="hidden" name="folderpath" value="$path" />
6640: <input type="hidden" name="importdetail" value="" />
1.570 raeburn 6641: <input type="hidden" name="active" value="ee" />
1.423 onken 6642: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 6643: $help{'Adding_Pages'}
1.329 droeschl 6644: </form>
6645: NPFORM
1.390 tempelho 6646:
6647:
1.351 ehlerst 6648: $newfolderform=(<<NFFORM);
1.329 droeschl 6649: <form action="/adm/coursedocs" method="post" name="newfolder">
1.508 raeburn 6650: $pathitem
1.329 droeschl 6651: <input type="hidden" name="importdetail" value="" />
1.570 raeburn 6652: <input type="hidden" name="active" value="" />
1.422 onken 6653: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 6654: </form>
6655: NFFORM
6656:
6657: my $newsylform=(<<NSYLFORM);
6658: <form action="/adm/coursedocs" method="post" name="newsyl">
1.570 raeburn 6659: <input type="hidden" name="active" value="ee" />
1.508 raeburn 6660: $pathitem
1.329 droeschl 6661: <input type="hidden" name="importdetail"
6662: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.611 raeburn 6663: <a class="LC_menubuttons_link" href="javascript:makenew(document.newsyl);">$lt{'syll'}</a>
1.329 droeschl 6664: $help{'Syllabus'}
1.383 tempelho 6665:
1.329 droeschl 6666: </form>
6667: NSYLFORM
1.364 bisitz 6668:
1.329 droeschl 6669: my $newgroupfileform=(<<NGFFORM);
6670: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.655 raeburn 6671: <input type="hidden" name="active" value="ee" />
1.508 raeburn 6672: $pathitem
1.329 droeschl 6673: <input type="hidden" name="importdetail"
6674: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.611 raeburn 6675: <a class="LC_menubuttons_link" href="javascript:makenew(document.newgroupfiles);">$lt{'grpo'}</a>
1.353 weissno 6676: $help{'Group Portfolio'}
1.329 droeschl 6677: </form>
6678: NGFFORM
1.672 raeburn 6679: if ($container eq 'page') {
6680: @specialdocumentsforma=(
6681: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
6682: );
6683: } else {
6684: @specialdocumentsforma=(
1.421 onken 6685: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/page.png" alt="'.$lt{newp}.'" onclick="javascript:makenewpage(document.newpage,\''.$pageseq.'\');" />'=>$newpageform},
1.618 raeburn 6686: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.newsyl);" />'=>$newsylform},
1.611 raeburn 6687: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="javascript:makenew(document.newnav);" />'=>$newnavform},
1.451 www 6688: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
1.534 raeburn 6689: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
1.672 raeburn 6690: );
6691: }
1.451 www 6692: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
6693:
1.655 raeburn 6694: my @external = (
6695: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleExternal(\'ext\');" />'=>$extresourcesform}
1.519 raeburn 6696: );
1.598 raeburn 6697: if (keys(%ltitools)) {
1.655 raeburn 6698: push(@external,
6699: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="toggleExternal(\'tool\');" />'=>$exttoolform},
6700: );
1.598 raeburn 6701: }
1.655 raeburn 6702: my $externalform = &create_form_ul(&create_list_elements(@external));
6703:
6704: my @importdoc = ();
1.519 raeburn 6705: unless ($container eq 'page') {
6706: push(@importdoc,
6707: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform}
6708: );
6709: }
6710: push(@importdoc,
1.558 raeburn 6711: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'doc\');" />'=>$fileuploadform}
1.519 raeburn 6712: );
1.501 raeburn 6713: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
1.434 raeburn 6714:
1.451 www 6715: @gradingforma=(
6716: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
6717: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
6718: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
1.606 raeburn 6719: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{stpr}.'" onclick="javascript:toggleCrsRes(\'res\','."'$numauthor','$numcrsdirs'".');" />'=>$crsresform},
1.451 www 6720: );
6721: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
6722:
6723: @communityforma=(
6724: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
6725: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
6726: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
1.611 raeburn 6727: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="javascript:makenew(document.newroster);" />'=>$newrosterform},
6728: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="javascript:makenew(document.newgroupfiles);" />'=>$newgroupfileform},
1.451 www 6729: );
6730: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 6731:
1.330 tempelho 6732: my %orderhash = (
1.553 raeburn 6733: 'aa' => ['Upload',$fileuploadform],
6734: 'bb' => ['Import',$importpubform],
1.655 raeburn 6735: 'cc' => ['External',$externalform],
6736: 'dd' => ['Grading',$gradingform],
1.673 raeburn 6737: 'ff' => ['Other',$specialdocumentsform],
1.330 tempelho 6738: );
1.519 raeburn 6739: unless ($container eq 'page') {
1.434 raeburn 6740: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.655 raeburn 6741: $orderhash{'ee'} = ['Collaboration',$communityform];
1.434 raeburn 6742: }
6743:
1.341 ehlerst 6744: $hadchanges=0;
1.484 raeburn 6745: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 6746: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.615 raeburn 6747: $supplementalflag,\%orderhash,$iconpath,$pathitem,
1.622 raeburn 6748: \%ltitools,$canedit,$hostname,\$navmap,$hiddentop);
1.617 raeburn 6749: undef($navmap);
1.443 www 6750: if ($error) {
6751: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
6752: }
1.639 raeburn 6753: if ($hadchanges) {
6754: unless (&is_hash_old()) {
1.638 raeburn 6755: &mark_hash_old();
6756: }
6757: }
1.341 ehlerst 6758:
1.443 www 6759: &changewarning($r,'');
6760: }
1.458 raeburn 6761: }
1.442 www 6762:
1.443 www 6763: # Supplemental documents start here
6764:
1.329 droeschl 6765: my $folder=$env{'form.folder'};
1.443 www 6766: unless ($supplementalflag) {
1.329 droeschl 6767: $folder='supplemental';
6768: }
6769: if ($folder =~ /^supplemental$/ &&
6770: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 6771: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 6772: } elsif ($allowed) {
1.356 tempelho 6773: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 6774: }
1.508 raeburn 6775: $pathitem = '<input type="hidden" name="folderpath" value="'.
6776: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.329 droeschl 6777: if ($allowed) {
6778: my $folderseq=
1.504 raeburn 6779: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
1.329 droeschl 6780:
6781: my $supupdocform=(<<SUPDOCFORM);
1.501 raeburn 6782: <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
6783: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
1.383 tempelho 6784: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.516 raeburn 6785: <fieldset id="uploadsuppdocform" style="display: none;">
1.501 raeburn 6786: <legend>$lt{'upfi'}</legend>
1.630 raeburn 6787: <input type="hidden" name="active" value="ee" />
1.329 droeschl 6788: $fileupload
6789: <br />
6790: <br />
6791: <span class="LC_nobreak">
6792: $checkbox
6793: </span>
6794: <br /><br />
6795: $lt{'comment'}:<br />
1.383 tempelho 6796: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 6797: <br />
1.508 raeburn 6798: $pathitem
1.329 droeschl 6799: <input type="hidden" name="cmd" value="upload_supplemental" />
1.501 raeburn 6800: <input type='submit' value="$lt{'upld'}" />
6801: </form>
1.329 droeschl 6802: SUPDOCFORM
6803:
6804: my $supnewfolderform=(<<SNFFORM);
6805: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.570 raeburn 6806: <input type="hidden" name="active" value="" />
1.508 raeburn 6807: $pathitem
1.329 droeschl 6808: <input type="hidden" name="importdetail" value="" />
1.423 onken 6809: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 6810: $help{'Adding_Folders'}
1.329 droeschl 6811: </form>
6812: SNFFORM
1.383 tempelho 6813:
1.510 raeburn 6814: my $supextform =
6815: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
1.611 raeburn 6816: $help{'Adding_External_Resource'},
6817: undef,undef,undef,undef,undef,undef,
6818: $disabled);
1.329 droeschl 6819:
1.598 raeburn 6820: my $supexttoolform =
6821: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
6822: $help{'Adding_External_Tool'},
6823: undef,undef,'tool',$coursedom,
1.611 raeburn 6824: $coursenum,\%ltitools,$disabled);
1.598 raeburn 6825:
1.329 droeschl 6826: my $supnewsylform=(<<SNSFORM);
6827: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 6828: <input type="hidden" name="active" value="ff" />
1.508 raeburn 6829: $pathitem
1.329 droeschl 6830: <input type="hidden" name="importdetail"
6831: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.611 raeburn 6832: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewsyl);">$lt{'syll'}</a>
1.329 droeschl 6833: $help{'Syllabus'}
6834: </form>
6835: SNSFORM
6836:
6837: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 6838: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 6839: <input type="hidden" name="active" value="ff" />
1.508 raeburn 6840: $pathitem
1.329 droeschl 6841: <input type="hidden" name="importdetail"
6842: value="$plainname=/adm/$udom/$uname/aboutme" />
1.611 raeburn 6843: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewaboutme);">$lt{'mypi'}</a>
1.347 weissno 6844: $help{'My Personal Information Page'}
1.329 droeschl 6845: </form>
6846: SNAMFORM
6847:
1.534 raeburn 6848: my $supwebpage;
6849: if ($folder =~ /^supplemental_?(\d*)$/) {
6850: $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
6851: if ($1) {
6852: $supwebpage .= $1;
6853: } else {
6854: $supwebpage .= 'default';
6855: }
6856: $supwebpage .= '/new.html';
6857: }
6858: my $supwebpageform =(<<SWEBFORM);
6859: <form action="/adm/coursedocs" method="post" name="supwebpage">
6860: <input type="hidden" name="active" value="cc" />
6861: $pathitem
6862: <input type="hidden" name="importdetail" value="$supwebpage" />
6863: <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
1.556 raeburn 6864: $help{'Web_Page'}
1.534 raeburn 6865: </form>
6866: SWEBFORM
6867:
1.333 muellerd 6868:
1.383 tempelho 6869: my @specialdocs = (
1.618 raeburn 6870: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.supnewsyl);" />'
1.417 droeschl 6871: =>$supnewsylform},
1.611 raeburn 6872: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makenew(document.supnewaboutme);" />'
1.417 droeschl 6873: =>$supnewaboutmeform},
1.534 raeburn 6874: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
6875:
1.383 tempelho 6876: );
1.655 raeburn 6877: my @supexternal = (
6878: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleExternal(\'suppext\')" />'
6879: =>$supextform});
1.598 raeburn 6880: if (keys(%ltitools)) {
1.655 raeburn 6881: push(@supexternal,
6882: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="javascript:toggleExternal(\'supptool\')" />'
1.598 raeburn 6883: =>$supexttoolform});
6884: }
1.655 raeburn 6885: my @supimportdoc = (
1.598 raeburn 6886: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
1.501 raeburn 6887: =>$supupdocform},
1.598 raeburn 6888: );
1.501 raeburn 6889:
6890: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
1.333 muellerd 6891: my %suporderhash = (
1.390 tempelho 6892: '00' => ['Supnewfolder', $supnewfolderform],
1.655 raeburn 6893: 'dd' => ['Upload',$supupdocform],
6894: 'ee' => ['External',&create_form_ul(&create_list_elements(@supexternal))],
1.553 raeburn 6895: 'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 6896: );
1.443 www 6897: if ($supplementalflag) {
1.682 raeburn 6898: $suppchanges = 0;
6899: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
6900: $supplementalflag,\%suporderhash,$iconpath,$pathitem,
6901: \%ltitools,$canedit,$hostname);
6902: if ($error) {
6903: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
6904: }
6905: if ($suppchanges) {
6906: my %servers = &Apache::lonnet::internet_dom_servers($coursedom);
6907: my @ids=&Apache::lonnet::current_machine_ids();
6908: foreach my $server (keys(%servers)) {
6909: next if (grep(/^\Q$server\E$/,@ids));
6910: my $hashid=$coursenum.':'.$coursedom;
6911: my $cachekey = &escape('showsupp').':'.&escape($hashid);
6912: &Apache::lonnet::remote_devalidate_cache($server,[$cachekey]);
6913: }
6914: &Apache::lonnet::has_unhidden_suppfiles($coursenum,$coursedom,1);
6915: &Apache::lonnet::count_supptools($coursenum,$coursedom,1);
6916: my $now = time;
6917: if ($env{'request.course.id'} eq $coursedom.'_'.$coursenum) {
6918: &Apache::lonnet::appenv({'request.course.suppupdated' => $now});
6919: }
6920: &Apache::lonnet::put('environment',{'internal.supplementalchange' => $now},
6921: $coursedom,$coursenum);
6922: &Apache::lonnet::appenv(
6923: {'course.'.$coursedom.'_'.$coursenum.'.internal.supplementalchange' => $now});
6924: &Apache::lonnet::do_cache_new('suppchange',$coursedom.'_'.$coursenum,$now,600);
6925: undef($suppchanges);
6926: }
1.393 raeburn 6927: }
1.443 www 6928: } elsif ($supplementalflag) {
1.458 raeburn 6929: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.682 raeburn 6930: $supplementalflag,'',$iconpath,$pathitem,'',$canedit,
6931: $hostname);
1.393 raeburn 6932: if ($error) {
6933: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 6934: }
1.393 raeburn 6935: }
1.389 tempelho 6936:
1.510 raeburn 6937: if ($needs_end) {
6938: $r->print(&endContentScreen());
6939: }
1.383 tempelho 6940:
1.329 droeschl 6941: if ($allowed) {
6942: $r->print('
6943: <form method="post" name="extimport" action="/adm/coursedocs">
6944: <input type="hidden" name="title" />
6945: <input type="hidden" name="url" />
6946: <input type="hidden" name="useform" />
6947: <input type="hidden" name="residx" />
6948: </form>');
6949: }
1.484 raeburn 6950: } elsif ($showdoc) {
1.329 droeschl 6951: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 6952: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.498 bisitz 6953: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 6954: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 6955: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 6956: }
6957: }
1.630 raeburn 6958: unless ($noendpage) {
1.606 raeburn 6959: $r->print(&Apache::loncommon::end_page());
6960: }
1.329 droeschl 6961: return OK;
1.364 bisitz 6962: }
1.329 droeschl 6963:
1.440 raeburn 6964: sub embedded_form_elems {
6965: my ($phase,$primaryurl,$newidx) = @_;
6966: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.634 raeburn 6967: $newidx =~s /\D+//g;
1.440 raeburn 6968: return <<STATE;
6969: <input type="hidden" name="folderpath" value="$folderpath" />
6970: <input type="hidden" name="cmd" value="upload_embedded" />
6971: <input type="hidden" name="newidx" value="$newidx" />
6972: <input type="hidden" name="phase" value="$phase" />
6973: <input type="hidden" name="primaryurl" value="$primaryurl" />
6974: STATE
6975: }
6976:
6977: sub embedded_destination {
6978: my $folder=$env{'form.folder'};
6979: my $destination = 'docs/';
6980: if ($folder =~ /^supplemental/) {
6981: $destination = 'supplemental/';
6982: }
6983: if (($folder eq 'default') || ($folder eq 'supplemental')) {
6984: $destination .= 'default/';
6985: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
6986: $destination .= $2.'/';
6987: }
1.634 raeburn 6988: my $newidx = $env{'form.newidx'};
6989: $newidx =~s /\D+//g;
6990: if ($newidx) {
6991: $destination .= $newidx;
6992: }
1.440 raeburn 6993: my $dir_root = '/userfiles';
6994: return ($destination,$dir_root);
6995: }
6996:
6997: sub return_to_editor {
6998: my $actionurl = '/adm/coursedocs';
6999: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
7000: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
7001: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
7002: '</a></p>';
7003: }
7004:
1.476 raeburn 7005: sub decompression_info {
7006: my ($destination,$dir_root) = &embedded_destination();
7007: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
7008: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
7009: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
7010: my $container='sequence';
1.480 raeburn 7011: my ($pathitem,$hiddenelem);
1.583 raeburn 7012: my @hiddens = ('newidx','comment','position','folderpath','archiveurl');
1.519 raeburn 7013: if ($env{'form.folderpath'} =~ /\:1$/) {
1.476 raeburn 7014: $container='page';
7015: }
1.480 raeburn 7016: unshift(@hiddens,$pathitem);
7017: foreach my $item (@hiddens) {
1.634 raeburn 7018: if ($item eq 'newidx') {
7019: next if ($env{'form.'.$item} =~ /\D/);
7020: }
1.480 raeburn 7021: if ($env{'form.'.$item}) {
7022: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
1.583 raeburn 7023: &HTML::Entities::encode($env{'form.'.$item},'<>&"').'" />'."\n";
1.480 raeburn 7024: }
1.477 raeburn 7025: }
1.476 raeburn 7026: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
7027: $hiddenelem);
7028: }
7029:
7030: sub decompression_phase_one {
7031: my ($dir,$file,$warning,$error,$output);
7032: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
7033: &decompression_info();
1.490 raeburn 7034: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 7035: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
7036: } else {
7037: my $file = $1;
1.630 raeburn 7038: $output =
1.481 raeburn 7039: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
7040: $destination,$dir_root,
7041: $hiddenelem);
7042: if ($env{'form.autoextract_camtasia'}) {
7043: $output .= &remove_archive($docudom,$docuname,$container);
7044: }
1.476 raeburn 7045: }
7046: if ($error) {
7047: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
7048: $error.'</p>'."\n";
7049: }
7050: if ($warning) {
7051: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
7052: }
7053: return $output;
7054: }
7055:
7056: sub decompression_phase_two {
7057: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
7058: &decompression_info();
1.481 raeburn 7059: my $output;
1.480 raeburn 7060: if ($env{'form.archivedelete'}) {
1.481 raeburn 7061: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 7062: }
7063: $output .=
1.481 raeburn 7064: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 7065: $destination,$dir_root,$hiddenelem);
7066: return $output;
7067: }
7068:
1.480 raeburn 7069: sub remove_archive {
7070: my ($docudom,$docuname,$container) = @_;
7071: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 7072: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 7073: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
7074: if ($fatal) {
7075: if ($container eq 'page') {
7076: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
7077: } else {
7078: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
7079: }
1.583 raeburn 7080: $delwarning .= ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 7081: } else {
7082: my $currcmd = $env{'form.cmd'};
7083: my $position = $env{'form.position'};
1.583 raeburn 7084: my $archiveidx = $position;
1.563 raeburn 7085: if ($position > 0) {
1.583 raeburn 7086: if (($env{'form.autoextract_camtasia'}) && (scalar(@LONCAPA::map::order) == 2)) {
7087: $archiveidx = $position-1;
7088: }
7089: $env{'form.cmd'} = 'remove_'.$archiveidx;
1.584 raeburn 7090: my ($title,$url,@rrest) =
1.583 raeburn 7091: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$archiveidx]]);
7092: if ($url eq $env{'form.archiveurl'}) {
7093: if (&handle_edit_cmd($docuname,$docudom)) {
7094: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
7095: if ($fatal) {
7096: if ($container eq 'page') {
7097: $delwarning = &mt('An error occurred updating the contents of the current page.');
7098: } else {
7099: $delwarning = &mt('An error occurred updating the contents of the current folder.');
7100: }
1.480 raeburn 7101: } else {
1.583 raeburn 7102: $delresult = &mt('Archive file removed.');
1.480 raeburn 7103: }
7104: }
1.583 raeburn 7105: } else {
7106: $delwarning .= &mt('Archive file had unexpected item number in folder.').
7107: ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 7108: }
7109: }
7110: $env{'form.cmd'} = $currcmd;
7111: }
7112: if ($delwarning) {
7113: $output = '<p class="LC_warning">'.
7114: $delwarning.
7115: '</p>';
7116: }
7117: if ($delresult) {
7118: $output .= '<p class="LC_info">'.
7119: $delresult.
7120: '</p>';
7121: }
1.481 raeburn 7122: return $output;
1.480 raeburn 7123: }
7124:
1.484 raeburn 7125: sub generate_admin_menu {
1.611 raeburn 7126: my ($crstype,$canedit) = @_;
1.484 raeburn 7127: my $lc_crstype = lc($crstype);
7128: my ($home,$other,%outhash)=&authorhosts();
1.562 bisitz 7129: my %lt= ( # do not translate here
1.484 raeburn 7130: 'vc' => 'Verify Content',
7131: 'cv' => 'Check/Set Resource Versions',
7132: 'ls' => 'List Resource Identifiers',
1.651 raeburn 7133: 'ct' => 'Display/Set Shortened URLs for Deep-linking',
1.484 raeburn 7134: 'imse' => 'Export contents to IMS Archive',
1.568 raeburn 7135: 'dcd' => "Copy $crstype Content to Authoring Space",
1.562 bisitz 7136: );
1.484 raeburn 7137: my ($candump,$dumpurl);
7138: if ($home + $other > 0) {
7139: $candump = 'F';
7140: if ($home) {
7141: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
7142: } else {
7143: my @hosts;
7144: foreach my $aurole (keys(%outhash)) {
7145: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
7146: push(@hosts,$outhash{$aurole});
1.538 raeburn 7147: }
1.484 raeburn 7148: }
7149: if (@hosts == 1) {
7150: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
7151: '&role='.
7152: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
7153: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
7154: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
7155: } else {
7156: $dumpurl = "javascript:choose_switchserver_window()";
7157: }
7158: }
7159: }
7160: my @menu=
7161: ({ categorytitle=>'Administration',
7162: items =>[
7163: { linktext => $lt{'vc'},
7164: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
7165: permission => 'F',
1.571 raeburn 7166: help => 'Docs_Verify_Content',
1.484 raeburn 7167: icon => 'verify.png',
7168: linktitle => 'Verify contents can be retrieved/rendered',
7169: },
7170: { linktext => $lt{'cv'},
7171: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
7172: permission => 'F',
1.571 raeburn 7173: help => 'Docs_Check_Resource_Versions',
1.484 raeburn 7174: icon => 'resversion.png',
7175: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
7176: },
7177: { linktext => $lt{'ls'},
7178: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
7179: permission => 'F',
7180: #help => '',
7181: icon => 'symbs.png',
7182: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
7183: },
1.651 raeburn 7184: { linktext => $lt{'ct'},
7185: url => "javascript:injectData(document.courseverify,'dummy','shorturls','$lt{'ct'}')",
7186: permission => 'F',
7187: help => 'Docs_Short_URLs',
7188: icon => 'shorturls.png',
7189: linktitle => "Set shortened URLs for a resource or folder in your $lc_crstype for use in deep-linking"
7190: },
1.484 raeburn 7191: ]
1.611 raeburn 7192: });
7193: if ($canedit) {
7194: push(@menu,
1.484 raeburn 7195: { categorytitle=>'Export',
7196: items =>[
7197: { linktext => $lt{'imse'},
7198: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
7199: permission => 'F',
7200: help => 'Docs_Export_Course_Docs',
7201: icon => 'imsexport.png',
7202: linktitle => $lt{'imse'},
7203: },
7204: { linktext => $lt{'dcd'},
7205: url => $dumpurl,
7206: permission => $candump,
1.571 raeburn 7207: help => 'Docs_Dump_Course_Docs',
1.484 raeburn 7208: icon => 'dump.png',
7209: linktitle => $lt{'dcd'},
7210: },
7211: ]
7212: });
1.611 raeburn 7213: }
1.484 raeburn 7214: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
7215: '<input type="hidden" id="dummy" />'."\n".
7216: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
7217: '</form>';
1.329 droeschl 7218: }
7219:
7220: sub generate_edit_table {
1.538 raeburn 7221: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile,
1.611 raeburn 7222: $need_save,$copyfolder,$canedit) = @_;
1.406 raeburn 7223: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 7224: my %orderhash = %{$orderhash_ref};
1.611 raeburn 7225: my ($form, $activetab, $active, $disabled);
1.570 raeburn 7226: if (($env{'form.active'} ne '') && ($env{'form.active'} ne '00')) {
1.371 tempelho 7227: $activetab = $env{'form.active'};
7228: }
1.611 raeburn 7229: unless ($canedit) {
7230: $disabled = ' disabled="disabled"';
7231: }
1.472 raeburn 7232: my $backicon = $iconpath.'clickhere.gif';
1.525 raeburn 7233: my $backtext = &mt('Exit Editor');
1.458 raeburn 7234: $form = '<div class="LC_Box" style="margin:0;">'.
1.488 raeburn 7235: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
7236: '<li class="goback">'.
1.546 raeburn 7237: '<a href="javascript:toContents('."'$jumpto'".');">'.
1.488 raeburn 7238: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
7239: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
7240: '<li>'.
7241: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
7242: &mt('Undo Delete').'</a></li>'."\n";
7243: if ($env{'form.docslog'}) {
7244: $form .= '<li class="active">';
7245: } else {
7246: $form .= '<li>';
7247: }
7248: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
7249: &mt('History').'</a></li>'."\n";
7250: if ($env{'form.docslog'}) {
7251: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
7252: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 7253: }
1.458 raeburn 7254: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 7255: if($name ne '00'){
1.371 tempelho 7256: if($activetab eq '' || $activetab ne $name){
7257: $active = '';
7258: }elsif($activetab eq $name){
7259: $active = 'class="active"';
7260: }
1.458 raeburn 7261: $form .= '<li style="float:right" '.$active
1.484 raeburn 7262: .' 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 7263: } else {
1.570 raeburn 7264: $form .= '<li style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 7265:
7266: }
1.329 droeschl 7267: }
1.484 raeburn 7268: $form .= '</ul>'."\n";
7269: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 7270:
7271: if ($to_show ne '') {
1.538 raeburn 7272: my $saveform;
7273: if ($need_save) {
7274: my $button = &mt('Make changes');
7275: my $path;
7276: if ($env{'form.folderpath'}) {
7277: $path =
7278: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
7279: }
7280: $saveform = <<"END";
7281: <div id="multisave" style="display:none; clear:both;" >
7282: <form name="saveactions" method="post" action="/adm/coursedocs" onsubmit="return checkSubmits();">
7283: <input type="hidden" name="folderpath" value="$path" />
7284: <input type="hidden" name="symb" value="$env{'form.symb'}" />
7285: <input type="hidden" name="allhiddenresource" value="" />
7286: <input type="hidden" name="allencrypturl" value="" />
7287: <input type="hidden" name="allrandompick" value="" />
7288: <input type="hidden" name="allrandomorder" value="" />
7289: <input type="hidden" name="changeparms" value="" />
7290: <input type="hidden" name="multiremove" value="" />
7291: <input type="hidden" name="multicut" value="" />
7292: <input type="hidden" name="multicopy" value="" />
7293: <input type="hidden" name="multichange" value="" />
7294: <input type="hidden" name="copyfolder" value="$copyfolder" />
1.611 raeburn 7295: <input type="submit" name="savemultiples" value="$button" $disabled />
1.538 raeburn 7296: </form>
7297: </div>
7298: END
7299: }
7300: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'.$saveform."\n";
1.458 raeburn 7301: }
1.363 ehlerst 7302: foreach my $field (keys(%orderhash)){
1.390 tempelho 7303: if($field ne '00'){
1.422 onken 7304: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 7305: $active = 'style="display: none;float:left"';
1.422 onken 7306: }elsif($activetab eq $field){
1.458 raeburn 7307: $active = 'style="display:block;float:left"';
1.422 onken 7308: }
7309: $form .= '<div id="'.$field.$tid.'"'
7310: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 7311: .'</div>'."\n";
1.363 ehlerst 7312: }
7313: }
1.484 raeburn 7314: unless ($env{'form.docslog'}) {
7315: $form .= '</div></div>'."\n";
7316: }
1.329 droeschl 7317: return $form;
7318: }
7319:
7320: sub editing_js {
1.622 raeburn 7321: my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
7322: $londocroot,$canedit,$hostname,$navmapref) = @_;
1.594 damieng 7323: my %js_lt = &Apache::lonlocal::texthash(
1.329 droeschl 7324: p_mnf => 'Name of New Folder',
7325: t_mnf => 'New Folder',
7326: p_mnp => 'Name of New Page',
7327: t_mnp => 'New Page',
1.451 www 7328: p_mxu => 'Title for the External Score',
1.349 biermanm 7329: p_msp => 'Name of Simple Course Page',
1.329 droeschl 7330: p_msb => 'Title for the Problem',
7331: p_mdb => 'Title for the Drop Box',
1.336 schafran 7332: p_mbb => 'Title for the Discussion Board',
1.604 raeburn 7333: p_mwp => 'Title for Web Page',
1.606 raeburn 7334: p_mnr => 'Title for the Resource',
1.348 weissno 7335: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 7336: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 7337: p_mab_alrt1 => 'Not a valid user:domain',
7338: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
7339: p_chn => 'New Title',
7340: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
1.603 raeburn 7341: p_rmr2a => 'Remove',
7342: p_rmr2b => '?',
7343: p_rmr3a => 'Remove those',
7344: p_rmr3b => 'items?',
7345: p_rmr4 => 'WARNING: Removing a resource uploaded to a course cannot be undone via "Undo Delete".',
7346: p_rmr5 => 'Push "Cancel" and then use "Cut" instead if you might need to undo this change.',
1.329 droeschl 7347: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
7348: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
1.603 raeburn 7349: p_ctr2a => 'Cut',
7350: p_ctr2b => '?',
7351: p_ctr3a => 'Cut those',
7352: p_ctr3b => 'items?',
1.633 raeburn 7353: setal => 'Enter a (unique) alias',
7354: delal => 'Are you sure you want to eliminate the alias?',
1.478 raeburn 7355: rpck => 'Enter number to pick (e.g., 3)',
1.501 raeburn 7356: imsfile => 'You must choose an IMS package for import',
7357: imscms => 'You must select which Course Management System was the source of the IMS package',
7358: invurl => 'Invalid URL',
7359: titbl => 'Title is blank',
1.538 raeburn 7360: more => '(More ...)',
7361: less => '(Less ...)',
1.543 raeburn 7362: noor => 'No actions selected or changes to settings specified.',
7363: noch => 'No changes to settings specified.',
7364: noac => 'No actions selected.',
1.606 raeburn 7365: nofi => 'No file selected',
7366: tinc => 'Title in course',
7367: sunm => 'Sub-directory name',
1.618 raeburn 7368: edri => 'Editing rights unavailable for your current role.',
1.329 droeschl 7369: );
1.594 damieng 7370: &js_escape(\%js_lt);
1.433 raeburn 7371: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 7372: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
7373: my $main_container_page;
1.519 raeburn 7374: if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) {
7375: $main_container_page = 1;
1.434 raeburn 7376: }
1.617 raeburn 7377: my $backtourl;
7378: my $toplevelmain = &escape(&default_folderpath($coursenum,$coursedom,$navmapref));
1.446 www 7379: my $toplevelsupp = &supplemental_base();
1.433 raeburn 7380:
1.530 raeburn 7381: if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
7382: my $caller = $1;
1.525 raeburn 7383: if ($caller =~ /^supplemental/) {
7384: $backtourl = '/adm/supplemental?folderpath='.&escape($caller);
7385: } else {
7386: my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
7387: $res = &Apache::lonnet::clutter($res);
7388: if (&Apache::lonnet::is_on_map($res)) {
1.609 raeburn 7389: my ($url,$anchor);
7390: if ($res =~ /^([^#]+)#([^#]+)$/) {
7391: $url = $1;
7392: $anchor = $2;
7393: if (($caller =~ m{^([^#]+)\Q#$anchor\E$})) {
7394: $caller = $1.&escape('#').$anchor;
7395: }
1.614 raeburn 7396: } else {
7397: $url = $res;
1.609 raeburn 7398: }
1.640 raeburn 7399: $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"');
7400: if ($backtourl =~ m{^\Q/uploaded/$coursedom/$coursenum/\Edefault_\d+\.sequence$}) {
7401: $backtourl .= '?navmap=1';
7402: } else {
7403: $backtourl .= '?symb='.
7404: &HTML::Entities::encode($caller,'<>&"');
7405: }
1.622 raeburn 7406: if ($backtourl =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
7407: if (($ENV{'SERVER_PORT'} == 443) &&
7408: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
1.678 raeburn 7409: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.657 raeburn 7410: if ($hostname ne '') {
7411: $backtourl = 'http://'.$hostname.$backtourl;
7412: }
7413: $backtourl .= (($backtourl =~ /\?/) ? '&':'?').'usehttp=1';
1.622 raeburn 7414: }
7415: }
1.623 raeburn 7416: } elsif ($backtourl =~ m{^/adm/wrapper/ext/(?!https:)}) {
7417: if (($ENV{'SERVER_PORT'} == 443) && ($hostname ne '')) {
1.678 raeburn 7418: unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
1.658 raeburn 7419: if ($hostname ne '') {
7420: $backtourl = 'http://'.$hostname.$backtourl;
7421: }
7422: $backtourl .= (($backtourl =~ /\?/) ? '&':'?').'usehttp=1';
1.657 raeburn 7423: }
1.623 raeburn 7424: }
1.622 raeburn 7425: }
1.609 raeburn 7426: if ($anchor ne '') {
7427: $backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"');
7428: }
1.590 raeburn 7429: $backtourl = &Apache::loncommon::escape_single($backtourl);
1.544 raeburn 7430: } else {
7431: $backtourl = '/adm/navmaps';
1.525 raeburn 7432: }
7433: }
7434: } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
7435: $backtourl = '/adm/menu';
7436: } elsif ($supplementalflag) {
1.682 raeburn 7437: if (($env{'request.role.adv'}) ||
7438: (&Apache::lonnet::has_unhidden_suppfiles($coursenum,$coursedom))) {
7439: $backtourl = '/adm/supplemental';
7440: } else {
7441: $backtourl = '/adm/navmaps';
7442: }
1.525 raeburn 7443: } else {
7444: $backtourl = '/adm/navmaps';
1.472 raeburn 7445: }
7446:
1.655 raeburn 7447: my $fieldsets = "'doc'";
1.519 raeburn 7448: unless ($main_container_page) {
7449: $fieldsets .=",'ims'";
7450: }
1.655 raeburn 7451: my $extfieldsets = "'ext'";
7452: if ($posslti) {
7453: $extfieldsets .= ",'tool'";
7454: }
1.501 raeburn 7455: if ($supplementalflag) {
1.655 raeburn 7456: $fieldsets = "'suppdoc'";
7457: $extfieldsets = "'suppext'";
1.600 raeburn 7458: if ($posslti) {
1.655 raeburn 7459: $extfieldsets .= ",'supptool'";
1.600 raeburn 7460: }
1.501 raeburn 7461: }
1.655 raeburn 7462:
1.611 raeburn 7463: my $jsmakefunctions;
7464: if ($canedit) {
7465: $jsmakefunctions = <<ENDNEWSCRIPT;
1.329 droeschl 7466: function makenewfolder(targetform,folderseq) {
1.594 damieng 7467: var foldername=prompt('$js_lt{"p_mnf"}','$js_lt{"t_mnf"}');
1.329 droeschl 7468: if (foldername) {
1.676 raeburn 7469: targetform.importdetail.value=encodeURIComponent(foldername)+"="+folderseq;
1.329 droeschl 7470: targetform.submit();
7471: }
7472: }
7473:
7474: function makenewpage(targetform,folderseq) {
1.594 damieng 7475: var pagename=prompt('$js_lt{"p_mnp"}','$js_lt{"t_mnp"}');
1.329 droeschl 7476: if (pagename) {
1.676 raeburn 7477: targetform.importdetail.value=encodeURIComponent(pagename)+"="+folderseq;
1.329 droeschl 7478: targetform.submit();
7479: }
7480: }
7481:
7482: function makeexamupload() {
1.594 damieng 7483: var title=prompt('$js_lt{"p_mxu"}');
1.344 bisitz 7484: if (title) {
1.329 droeschl 7485: this.document.forms.newexamupload.importdetail.value=
1.676 raeburn 7486: encodeURIComponent(title)+'=/res/lib/templates/examupload.problem';
1.329 droeschl 7487: this.document.forms.newexamupload.submit();
7488: }
7489: }
7490:
7491: function makesmppage() {
1.594 damieng 7492: var title=prompt('$js_lt{"p_msp"}');
1.344 bisitz 7493: if (title) {
1.329 droeschl 7494: this.document.forms.newsmppg.importdetail.value=
1.676 raeburn 7495: encodeURIComponent(title)+'=/adm/$udom/$uname/new/smppg';
1.329 droeschl 7496: this.document.forms.newsmppg.submit();
7497: }
7498: }
7499:
1.534 raeburn 7500: function makewebpage(type) {
1.594 damieng 7501: var title=prompt('$js_lt{"p_mwp"}');
1.534 raeburn 7502: var formname;
7503: if (type == 'supp') {
7504: formname = this.document.forms.supwebpage;
7505: } else {
7506: formname = this.document.forms.newwebpage;
7507: }
7508: if (title) {
7509: var webpage = formname.importdetail.value;
1.675 raeburn 7510: formname.importdetail.value = encodeURIComponent(title)+'='+webpage;
1.534 raeburn 7511: formname.submit();
7512: }
7513: }
7514:
1.329 droeschl 7515: function makesmpproblem() {
1.594 damieng 7516: var title=prompt('$js_lt{"p_msb"}');
1.344 bisitz 7517: if (title) {
1.329 droeschl 7518: this.document.forms.newsmpproblem.importdetail.value=
1.676 raeburn 7519: encodeURIComponent(title)+'=/res/lib/templates/simpleproblem.problem';
1.329 droeschl 7520: this.document.forms.newsmpproblem.submit();
7521: }
7522: }
7523:
7524: function makedropbox() {
1.594 damieng 7525: var title=prompt('$js_lt{"p_mdb"}');
1.344 bisitz 7526: if (title) {
1.329 droeschl 7527: this.document.forms.newdropbox.importdetail.value=
1.676 raeburn 7528: encodeURIComponent(title)+'=/res/lib/templates/DropBox.problem';
1.329 droeschl 7529: this.document.forms.newdropbox.submit();
7530: }
7531: }
7532:
7533: function makebulboard() {
1.594 damieng 7534: var title=prompt('$js_lt{"p_mbb"}');
1.329 droeschl 7535: if (title) {
7536: this.document.forms.newbul.importdetail.value=
1.676 raeburn 7537: encodeURIComponent(title)+'=/adm/$udom/$uname/new/bulletinboard';
1.329 droeschl 7538: this.document.forms.newbul.submit();
7539: }
7540: }
7541:
7542: function makeabout() {
1.594 damieng 7543: var user=prompt("$js_lt{'p_mab'}");
1.329 droeschl 7544: if (user) {
7545: var comp=new Array();
7546: comp=user.split(':');
7547: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
7548: if ((comp[0]) && (comp[1])) {
7549: this.document.forms.newaboutsomeone.importdetail.value=
1.594 damieng 7550: '$js_lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.611 raeburn 7551: this.document.forms.newaboutsomeone.submit();
7552: } else {
7553: alert("$js_lt{'p_mab_alrt1'}");
7554: }
7555: } else {
7556: alert("$js_lt{'p_mab_alrt2'}");
7557: }
7558: }
7559: }
7560:
7561: function makenew(targetform) {
7562: targetform.submit();
7563: }
7564:
7565: function changename(folderpath,index,oldtitle) {
7566: var title=prompt('$js_lt{"p_chn"}',oldtitle);
7567: if (title) {
7568: this.document.forms.renameform.markcopy.value='';
7569: this.document.forms.renameform.title.value=title;
7570: this.document.forms.renameform.cmd.value='rename_'+index;
7571: this.document.forms.renameform.folderpath.value=folderpath;
7572: this.document.forms.renameform.submit();
7573: }
7574: }
7575:
1.633 raeburn 7576: function setalias(folderpath,index) {
7577: var alias = prompt('$js_lt{"setal"}');
7578: if ((alias != null) && (alias != '')) {
7579: this.document.forms.aliasform.alias.value=alias;
7580: this.document.forms.aliasform.cmd.value='setalias_'+index;
7581: this.document.forms.aliasform.folderpath.value=folderpath;
7582: this.document.forms.aliasform.submit();
7583: }
7584: }
7585:
7586: function delalias(folderpath,index) {
7587: if (confirm('$js_lt{"delal"}')) {
7588: this.document.forms.aliasform.cmd.value='delalias_'+index;
7589: this.document.forms.aliasform.folderpath.value=folderpath;
7590: this.document.forms.aliasform.submit();
7591: }
7592: }
7593:
1.611 raeburn 7594: ENDNEWSCRIPT
7595: } else {
7596: $jsmakefunctions = <<ENDNEWSCRIPT;
7597:
7598: function makenewfolder() {
7599: alert("$js_lt{'edri'}");
7600: }
7601:
7602: function makenewpage() {
7603: alert("$js_lt{'edri'}");
7604: }
7605:
7606: function makeexamupload() {
7607: alert("$js_lt{'edri'}");
7608: }
7609:
7610: function makesmppage() {
7611: alert("$js_lt{'edri'}");
7612: }
7613:
7614: function makewebpage(type) {
7615: alert("$js_lt{'edri'}");
7616: }
7617:
7618: function makesmpproblem() {
7619: alert("$js_lt{'edri'}");
7620: }
7621:
7622: function makedropbox() {
7623: alert("$js_lt{'edri'}");
7624: }
7625:
7626: function makebulboard() {
7627: alert("$js_lt{'edri'}");
7628: }
7629:
7630: function makeabout() {
7631: alert("$js_lt{'edri'}");
7632: }
7633:
7634: function changename() {
7635: alert("$js_lt{'edri'}");
7636: }
7637:
1.633 raeburn 7638: function setalias() {
7639: alert("$js_lt{'edri'}");
7640: }
7641:
7642: function delalias() {
7643: alert("$js_lt{'edri'}");
7644: }
7645:
1.611 raeburn 7646: function makenew() {
7647: alert("$js_lt{'edri'}");
7648: }
7649:
7650: function groupimport() {
7651: alert("$js_lt{'edri'}");
1.335 ehlerst 7652: }
1.611 raeburn 7653:
7654: function groupsearch() {
7655: alert("$js_lt{'edri'}");
1.335 ehlerst 7656: }
1.611 raeburn 7657:
7658: function groupopen(url,recover) {
7659: var options="scrollbars=1,resizable=1,menubar=0";
7660: idxflag=1;
7661: idx=open("/adm/groupsort?inhibitmenu=yes&mode=simple&recover="+recover+"&readfile="+url,"idxout",options);
7662: idx.focus();
1.329 droeschl 7663: }
7664:
1.611 raeburn 7665: ENDNEWSCRIPT
7666:
7667: }
7668: return <<ENDSCRIPT;
7669:
7670: $jsmakefunctions
7671:
1.501 raeburn 7672: function toggleUpload(caller) {
7673: var blocks = Array($fieldsets);
7674: for (var i=0; i<blocks.length; i++) {
7675: var disp = 'none';
7676: if (caller == blocks[i]) {
7677: var curr = document.getElementById('upload'+caller+'form').style.display;
7678: if (curr == 'none') {
7679: disp='block';
7680: }
7681: }
7682: document.getElementById('upload'+blocks[i]+'form').style.display=disp;
1.655 raeburn 7683: }
7684: resize_scrollbox('contentscroll','1','1');
7685: return;
7686: }
7687:
7688: function toggleExternal(caller) {
7689: var blocks = Array($extfieldsets);
7690: for (var i=0; i<blocks.length; i++) {
7691: var disp = 'none';
7692: if (caller == blocks[i]) {
7693: var curr = document.getElementById('external'+caller+'form').style.display;
7694: if (curr == 'none') {
7695: disp='block';
7696: }
7697: }
7698: document.getElementById('external'+blocks[i]+'form').style.display=disp;
1.598 raeburn 7699: if ((caller == 'tool') || (caller == 'supptool')) {
7700: if (disp == 'block') {
1.655 raeburn 7701: if (document.getElementById('LC_exttoolid')) {
7702: var toolselector = document.getElementById('LC_exttoolid');
1.598 raeburn 7703: var suppflag = 0;
7704: if (caller == 'supptool') {
7705: suppflag = 1;
7706: }
7707: currForm = document.getElementById('new'+caller);
1.655 raeburn 7708: updateExttool(toolselector,currForm,suppflag);
1.598 raeburn 7709: }
7710: }
7711: }
1.501 raeburn 7712: }
1.502 raeburn 7713: resize_scrollbox('contentscroll','1','1');
7714: return;
7715: }
7716:
1.514 raeburn 7717: function toggleMap(caller) {
1.502 raeburn 7718: var disp = 'none';
1.510 raeburn 7719: if (document.getElementById('importmapform')) {
1.514 raeburn 7720: if (caller == 'map') {
7721: var curr = document.getElementById('importmapform').style.display;
7722: if (curr == 'none') {
7723: disp='block';
7724: }
1.510 raeburn 7725: }
7726: document.getElementById('importmapform').style.display=disp;
7727: resize_scrollbox('contentscroll','1','1');
1.502 raeburn 7728: }
1.501 raeburn 7729: return;
1.329 droeschl 7730: }
7731:
1.606 raeburn 7732: function toggleCrsRes(caller,numauthorrole,numcrsdirs) {
7733: var disp = 'none';
7734: if (document.getElementById('crsresform')) {
7735: if (caller == 'res') {
7736: var curr = document.getElementById('crsresform').style.display;
7737: if (curr == 'none') {
7738: disp='block';
7739: numauthor = parseInt(numauthorrole);
7740: if (numauthor > 0) {
7741: document.courseresform.authorrole.selectedIndex = 0;
7742: select1priv_changed();
7743: document.courseresform.authorpath.selectedIndex = 0;
7744: document.courseresform.newresourceadd.selectedIndex = 0;
7745: toggleNewInCourse(document.courseresform);
7746: if (document.getElementById('newresource')) {
7747: document.getElementById('newresource').style.display = 'none';
7748: }
7749: } else {
7750: if (numcrsdirs) {
7751: document.courseresform.authorpath.selectedIndex = 0;
7752: }
7753: }
7754: if (document.courseresform.newresusetemp.length) {
7755: document.courseresform.newresusetemp[0].checked = true;
7756: toggleWithTemplate(document.courseresform);
7757: }
7758: document.courseresform.newresourcename.value = '';
7759: }
7760: }
7761: if (document.courseresform.newsubdir.length) {
7762: for (var j=0; j<document.courseresform.newsubdir.length; j++) {
7763: if (document.courseresform.newsubdir[j].value == 0) {
7764: document.courseresform.newsubdir[j].checked = true;
7765: }
7766: break;
7767: }
7768: if (document.getElementById('newsubdirname')) {
7769: document.getElementById('newsubdirname').type = "hidden";
7770: document.getElementById('newsubdirname').value = "";
7771: }
7772: if (document.getElementById('newsubdir')) {
7773: document.getElementById('newsubdir').innerHTML = "";
7774: }
7775: }
7776: document.getElementById('crsresform').style.display=disp;
7777: resize_scrollbox('contentscroll','1','0');
7778: }
7779: return;
7780: }
7781:
7782: function toggleNewsubdir(form) {
7783: if (form.newsubdir.length) {
7784: for (var j=0; j<form.newsubdir.length; j++) {
7785: if (form.newsubdir[j].checked) {
7786: if (document.getElementById('newsubdirname')) {
7787: if (form.newsubdir[j].value == '1') {
7788: document.getElementById('newsubdirname').type = "text";
7789: if (document.getElementById('newsubdir')) {
7790: document.getElementById('newsubdir').innerHTML = '<br />$js_lt{'sunm'}';
7791: }
7792: } else {
7793: document.getElementById('newsubdirname').type = "hidden";
7794: document.getElementById('newsubdirname').value = "";
7795: document.getElementById('newsubdir').innerHTML = "";
7796: }
7797: }
7798: break;
7799: }
7800: }
7801: }
7802: }
7803:
7804: function toggleCrsResTitle() {
7805: if (document.getElementById('newresource')) {
7806: if (document.courseresform.authorrole.options[document.courseresform.authorrole.selectedIndex].value == 'course') {
7807: document.getElementById('newresource').style.display = 'inline';
7808: document.courseresform.newresourceadd[0].checked = true;
7809: toggleNewInCourse(document.courseresform);
7810: } else {
7811: document.getElementById('newresource').style.display = 'none';
7812: }
7813: }
7814: }
7815:
7816: function toggleNewInCourse(form) {
7817: if (form.newresourceadd.length) {
7818: for (var i=0; i<form.newresourceadd.length; i++) {
7819: if (form.newresourceadd[i].checked) {
7820: if (document.getElementById('newresourcetitle')) {
7821: if (form.newresourceadd[i].value == '1') {
7822: document.getElementById('newresourcetitle').type = 'text';
7823: if (document.getElementById('newrestitle')) {
7824: document.getElementById('newrestitle').innerHTML = "<br />$js_lt{'tinc'}";
7825: }
7826: } else {
7827: document.getElementById('newresourcetitle').type = 'hidden';
7828: document.getElementById('newresourcetitle').value = '';
7829: if (document.getElementById('newrestitle')) {
7830: document.getElementById('newrestitle').innerHTML = '';
7831: }
7832: }
7833: }
7834: break;
7835: }
7836: }
7837: }
7838: }
7839:
7840: function toggleWithTemplate(form) {
7841: if (form.newresusetemp.length) {
7842: for (var i=0; i<form.newresusetemp.length; i++) {
7843: if (form.newresusetemp[i].checked) {
7844: if (document.getElementById('newrestemplate')) {
7845: if (form.newresusetemp[i].value == '1') {
7846: document.getElementById('newrestemplate').style.display = 'inline';
7847: toggleExampleText();
7848: } else {
7849: form.tempcategory.selectedIndex = 0;
7850: select1template_changed();
7851: document.getElementById('newrestemplate').style.display = 'none';
7852: }
7853: }
7854: }
7855: }
7856: }
7857: }
7858:
7859: function toggleExampleText() {
7860: if (document.getElementById('newresexample')) {
7861: var url = document.courseresform.template.options[document.courseresform.template.selectedIndex].value;
7862: if (url == '') {
7863: document.getElementById('newresexample').style.fontWeight = 'normal';
7864: } else {
7865: document.getElementById('newresexample').style.fontWeight = 'bold';
7866: }
7867: }
7868: }
7869:
7870: function getExample(width,height,scrolling,transparency) {
7871: var url;
7872: if (document.courseresform.newresusetemp.length) {
7873: for (var i=0; i<document.courseresform.newresusetemp.length; i++) {
7874: if (document.courseresform.newresusetemp[i].checked) {
7875: if (document.courseresform.newresusetemp[i].value == '1') {
7876: var url = document.courseresform.template.options[document.courseresform.template.selectedIndex].value;
7877: if (url == '') {
7878: alert('Pick a category and template');
7879: } else {
7880: url = url.replace("$londocroot","");
7881: url += '?inhibitmenu=yes';
7882: }
7883: }
7884: break;
7885: }
7886: }
7887: }
7888: if (url != '') {
7889: openMyModal(url,width,height,scrolling,transparency,'');
7890: }
7891: }
7892:
7893: function toggleImportCrsres(caller,dircount) {
7894: var disp = 'none';
7895: if (document.getElementById('importcrsresform')) {
7896: if (caller == 'res') {
7897: var numdirs = parseInt(dircount);
7898: var curr = document.getElementById('importcrsresform').style.display;
7899: if (curr == 'none') {
7900: disp='block';
7901: if (numdirs > 1) {
7902: select1res_changed();
7903: }
7904: }
7905: }
7906: document.getElementById('importcrsresform').style.display=disp;
7907: resize_scrollbox('contentscroll','1','0');
7908: }
7909: return;
7910: }
7911:
1.501 raeburn 7912: function makeims(imsform) {
7913: if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
1.594 damieng 7914: alert("$js_lt{'imsfile'}");
1.501 raeburn 7915: return;
7916: }
7917: if (imsform.source.selectedIndex == 0) {
1.594 damieng 7918: alert("$js_lt{'imscms'}");
1.501 raeburn 7919: return;
7920: }
7921: newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
7922: imsform.submit();
7923: }
7924:
1.478 raeburn 7925: function updatePick(targetform,index,caller) {
1.537 raeburn 7926: var pickitem;
7927: var picknumitem;
7928: var picknumtext;
7929: if (index == 'all') {
7930: pickitem = document.getElementById('randompickall');
7931: picknumitem = document.getElementById('rpicknumall');
7932: picknumtext = document.getElementById('rpicktextall');
7933: } else {
7934: pickitem = document.getElementById('randompick_'+index);
7935: picknumitem = document.getElementById('rpicknum_'+index);
7936: picknumtext = document.getElementById('randompicknum_'+index);
7937: }
1.478 raeburn 7938: if (pickitem.checked) {
1.594 damieng 7939: var picknum=prompt('$js_lt{"rpck"}',picknumitem.value);
1.478 raeburn 7940: if (picknum == '' || picknum == null) {
7941: if (caller == 'check') {
7942: pickitem.checked=false;
1.537 raeburn 7943: if (index == 'all') {
7944: picknumtext.innerHTML = '';
7945: if (caller == 'link') {
7946: propagateState(targetform,'rpicknum');
7947: }
7948: } else {
1.538 raeburn 7949: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 7950: }
1.478 raeburn 7951: }
7952: } else {
7953: picknum.toString();
7954: var regexdigit=/^\\d+\$/;
7955: if (regexdigit.test(picknum)) {
7956: picknumitem.value = picknum;
1.537 raeburn 7957: if (index == 'all') {
1.538 raeburn 7958: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.cumulativesettings,\\'all\\',\\'link\\');">'+picknum+'</a>';
1.537 raeburn 7959: if (caller == 'link') {
7960: propagateState(targetform,'rpicknum');
7961: }
7962: } else {
7963: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.edit_randompick_'+index+',\\''+index+'\\',\\'link\\');">'+picknum+'</a>';
1.538 raeburn 7964: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 7965: }
1.478 raeburn 7966: } else {
7967: if (caller == 'check') {
1.537 raeburn 7968: if (index == 'all') {
7969: picknumtext.innerHTML = '';
7970: if (caller == 'link') {
7971: propagateState(targetform,'rpicknum');
7972: }
7973: } else {
7974: pickitem.checked=false;
1.538 raeburn 7975: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 7976: }
1.478 raeburn 7977: }
7978: return;
7979: }
7980: }
7981: } else {
1.537 raeburn 7982: picknumitem.value = '';
7983: picknumtext.innerHTML = '';
7984: if (index == 'all') {
7985: if (caller == 'link') {
7986: propagateState(targetform,'rpicknum');
7987: }
7988: } else {
1.538 raeburn 7989: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 7990: }
7991: }
7992: }
7993:
7994: function propagateState(form,param) {
7995: if (document.getElementById(param+'all')) {
7996: var setcheck = 0;
7997: var rpick = 0;
7998: if (param == 'rpicknum') {
7999: if (document.getElementById('randompickall')) {
8000: if (document.getElementById('randompickall').checked) {
8001: if (document.getElementById('rpicknumall')) {
8002: rpick = document.getElementById('rpicknumall').value;
8003: }
8004: }
8005: }
8006: } else {
8007: if (document.getElementById(param+'all').checked) {
8008: setcheck = 1;
8009: }
8010: }
1.538 raeburn 8011: var allidxlist;
8012: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
8013: if (document.getElementById('all'+param+'idx')) {
8014: allidxlist = document.getElementById('all'+param+'idx').value;
8015: }
8016: var actions = new Array ('remove','cut','copy');
8017: for (var i=0; i<actions.length; i++) {
8018: if (actions[i] != param) {
8019: if (document.getElementById(actions[i]+'all')) {
8020: document.getElementById(actions[i]+'all').checked = false;
8021: }
8022: }
8023: }
8024: }
1.537 raeburn 8025: if ((param == 'encrypturl') || (param == 'hiddenresource')) {
1.538 raeburn 8026: allidxlist = form.allidx.value;
8027: }
8028: if ((param == 'randompick') || (param == 'rpicknum') || (param == 'randomorder')) {
8029: allidxlist = form.allmapidx.value;
8030: }
8031: if ((allidxlist != '') && (allidxlist != null)) {
8032: var allidxs = allidxlist.split(',');
8033: if (allidxs.length > 1) {
8034: for (var i=0; i<allidxs.length; i++) {
8035: if (document.getElementById(param+'_'+allidxs[i])) {
8036: if (param == 'rpicknum') {
8037: if (document.getElementById('randompick_'+allidxs[i])) {
8038: if (document.getElementById('randompick_'+allidxs[i]).checked) {
8039: document.getElementById(param+'_'+allidxs[i]).value = rpick;
8040: if (rpick > 0) {
8041: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = ': <a href="javascript:updatePick(document.edit_randompick_'+allidxs[i]+',\\''+allidxs[i]+'\\',\\'link\\')">'+rpick+'</a>';
8042: } else {
8043: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
8044: }
8045: }
8046: }
8047: } else {
1.537 raeburn 8048: if (setcheck == 1) {
8049: document.getElementById(param+'_'+allidxs[i]).checked = true;
8050: } else {
8051: document.getElementById(param+'_'+allidxs[i]).checked = false;
1.538 raeburn 8052: if (param == 'randompick') {
8053: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
8054: }
1.537 raeburn 8055: }
8056: }
8057: }
8058: }
1.538 raeburn 8059: if (setcheck == 1) {
8060: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
8061: var actions = new Array('copy','cut','remove');
8062: for (var i=0; i<actions.length; i++) {
8063: var otheractions;
8064: var otheridxs;
8065: if (actions[i] === param) {
8066: continue;
8067: } else {
8068: if (document.getElementById('all'+actions[i]+'idx')) {
8069: otheractions = document.getElementById('all'+actions[i]+'idx').value;
8070: otheridxs = otheractions.split(',');
8071: if (otheridxs.length > 1) {
8072: for (var j=0; j<otheridxs.length; j++) {
8073: if (document.getElementById(actions[i]+'_'+otheridxs[j])) {
8074: document.getElementById(actions[i]+'_'+otheridxs[j]).checked = false;
8075: }
1.537 raeburn 8076: }
8077: }
8078: }
1.538 raeburn 8079: }
8080: }
8081: }
8082: }
8083: }
8084: }
8085: }
8086: return;
8087: }
8088:
1.603 raeburn 8089: function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder,confirm_removal) {
1.611 raeburn 8090: var canedit = '$canedit';
8091: if (canedit == '') {
8092: alert("$js_lt{'edri'}");
8093: return;
8094: }
1.539 raeburn 8095: var dosettings;
8096: var doaction;
1.538 raeburn 8097: var control = document.togglemultsettings;
8098: if (context == 'actions') {
8099: control = document.togglemultactions;
1.539 raeburn 8100: doaction = 1;
8101: } else {
8102: dosettings = 1;
1.538 raeburn 8103: }
1.539 raeburn 8104: if (control) {
8105: if (control.showmultpick.length) {
8106: for (var i=0; i<control.showmultpick.length; i++) {
8107: if (control.showmultpick[i].checked) {
8108: if (control.showmultpick[i].value == 1) {
8109: if (context == 'settings') {
8110: dosettings = 0;
8111: } else {
8112: doaction = 0;
1.538 raeburn 8113: }
8114: }
8115: }
1.537 raeburn 8116: }
8117: }
1.539 raeburn 8118: }
8119: if (context == 'settings') {
8120: if (dosettings == 1) {
1.538 raeburn 8121: targetform.changeparms.value=param;
8122: targetform.submit();
8123: }
1.537 raeburn 8124: }
1.539 raeburn 8125: if (context == 'actions') {
8126: if (doaction == 1) {
8127: targetform.cmd.value=param+'_'+index;
8128: targetform.folderpath.value=folderpath;
8129: targetform.markcopy.value=idx+':'+param;
8130: targetform.copyfolder.value=folder+'.'+container;
8131: if (param == 'remove') {
1.603 raeburn 8132: var doremove = 0;
8133: if (skip_confirm) {
8134: if (confirm_removal) {
8135: if (confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'"$js_lt{"p_rmr2b"}')) {
8136: doremove = 1;
8137: }
8138: } else {
8139: doremove = 1;
8140: }
8141: } else {
8142: if (confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'" $js_lt{"p_rmr2b"}')) {
8143: doremove = 1;
8144: }
8145: }
8146: if (doremove) {
1.539 raeburn 8147: targetform.markcopy.value='';
8148: targetform.copyfolder.value='';
8149: targetform.submit();
8150: }
8151: }
8152: if (param == 'cut') {
1.594 damieng 8153: if (skip_confirm || confirm('$js_lt{"p_ctr1a"}\\n$js_lt{"p_ctr1b"}\\n\\n$js_lt{"p_ctr2a"} "'+oldtitle+'" $js_lt{"p_ctr2b"}')) {
1.539 raeburn 8154: targetform.submit();
8155: return;
8156: }
8157: }
8158: if (param == 'copy') {
8159: targetform.submit();
8160: return;
8161: }
8162: targetform.markcopy.value='';
8163: targetform.copyfolder.value='';
8164: targetform.cmd.value='';
8165: targetform.folderpath.value='';
8166: return;
8167: } else {
8168: if (document.getElementById(param+'_'+idx)) {
8169: item = document.getElementById(param+'_'+idx);
8170: if (item.type == 'checkbox') {
8171: if (item.checked) {
8172: item.checked = false;
8173: } else {
8174: item.checked = true;
8175: singleCheck(item,idx,param);
8176: }
8177: }
8178: }
8179: }
8180: }
1.537 raeburn 8181: return;
8182: }
8183:
1.538 raeburn 8184: function singleCheck(caller,idx,action) {
8185: actions = new Array('cut','copy','remove');
8186: if (caller.checked) {
8187: for (var i=0; i<actions.length; i++) {
8188: if (actions[i] != action) {
8189: if (document.getElementById(actions[i]+'_'+idx)) {
8190: if (document.getElementById(actions[i]+'_'+idx).checked) {
8191: document.getElementById(actions[i]+'_'+idx).checked = false;
8192: }
1.537 raeburn 8193: }
8194: }
8195: }
1.478 raeburn 8196: }
1.537 raeburn 8197: return;
1.478 raeburn 8198: }
8199:
1.334 muellerd 8200: function unselectInactive(nav) {
1.335 ehlerst 8201: currentNav = document.getElementById(nav);
8202: currentLis = currentNav.getElementsByTagName('LI');
8203: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 8204: if (currentLis[i].className == 'goback') {
8205: currentLis[i].className = 'goback';
8206: } else {
8207: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 8208: currentLis[i].className = 'right';
1.472 raeburn 8209: } else {
1.374 tempelho 8210: currentLis[i].className = 'i';
1.472 raeburn 8211: }
8212: }
1.335 ehlerst 8213: }
1.332 tempelho 8214: }
8215:
1.334 muellerd 8216: function hideAll(current, nav, data) {
1.335 ehlerst 8217: unselectInactive(nav);
1.570 raeburn 8218: if (current) {
8219: if (current.className == 'right'){
8220: current.className = 'right active'
8221: } else {
8222: current.className = 'active';
8223: }
1.374 tempelho 8224: }
1.335 ehlerst 8225: currentData = document.getElementById(data);
8226: currentDivs = currentData.getElementsByTagName('DIV');
8227: for (i = 0; i < currentDivs.length; i++) {
8228: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 8229: currentDivs[i].style.display = 'none';
1.330 tempelho 8230: }
8231: }
1.335 ehlerst 8232: }
1.330 tempelho 8233:
1.374 tempelho 8234: function openTabs(pageId) {
8235: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 8236: if(tabnav.length > 2 ){
1.389 tempelho 8237: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 8238: currentLis = currentNav.getElementsByTagName('LI');
8239: for(i = 0; i< currentLis.length; i++){
8240: if(currentLis[i].className == 'active') {
1.375 tempelho 8241: funcString = currentLis[i].onclick.toString();
8242: tab = funcString.split('"');
1.420 onken 8243: if(tab.length < 2) {
8244: tab = funcString.split("'");
8245: }
1.375 tempelho 8246: currentData = document.getElementById(tab[1]);
8247: currentData.style.display = 'block';
1.374 tempelho 8248: }
8249: }
8250: }
8251: }
8252:
1.334 muellerd 8253: function showPage(current, pageId, nav, data) {
1.570 raeburn 8254: currstate = current.className;
1.334 muellerd 8255: hideAll(current, nav, data);
1.375 tempelho 8256: openTabs(pageId);
1.334 muellerd 8257: unselectInactive(nav);
1.570 raeburn 8258: if ((currstate == 'active') || (currstate == 'right active')) {
8259: if (currstate == 'active') {
8260: current.className = '';
8261: } else {
8262: current.className = 'right';
8263: }
8264: activeTab = '';
1.656 raeburn 8265: toggleExternal();
1.570 raeburn 8266: toggleUpload();
8267: toggleMap();
1.606 raeburn 8268: toggleCrsRes();
8269: toggleImportCrsres();
1.570 raeburn 8270: resize_scrollbox('contentscroll','1','0');
8271: return;
8272: } else {
8273: current.className = 'active';
8274: }
1.330 tempelho 8275: currentData = document.getElementById(pageId);
8276: currentData.style.display = 'block';
1.458 raeburn 8277: activeTab = pageId;
1.656 raeburn 8278: toggleExternal();
1.501 raeburn 8279: toggleUpload();
1.503 raeburn 8280: toggleMap();
1.606 raeburn 8281: toggleCrsRes();
8282: toggleImportCrsres();
1.433 raeburn 8283: if (nav == 'mainnav') {
8284: var storedpath = "$docs_folderpath";
1.434 raeburn 8285: var storedpage = "$main_container_page";
1.433 raeburn 8286: var reg = new RegExp("^supplemental");
8287: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 8288: if (storedpage == 1) {
8289: document.simpleedit.folderpath.value = '';
8290: document.uploaddocument.folderpath.value = '';
8291: } else {
8292: if (reg.test(storedpath)) {
8293: document.simpleedit.folderpath.value = '$toplevelmain';
8294: document.uploaddocument.folderpath.value = '$toplevelmain';
8295: document.newext.folderpath.value = '$toplevelmain';
8296: } else {
8297: document.simpleedit.folderpath.value = storedpath;
8298: document.uploaddocument.folderpath.value = storedpath;
8299: document.newext.folderpath.value = storedpath;
8300: }
1.433 raeburn 8301: }
8302: } else {
1.434 raeburn 8303: if (reg.test(storedpath)) {
8304: document.simpleedit.folderpath.value = storedpath;
8305: document.supuploaddocument.folderpath.value = storedpath;
8306: document.supnewext.folderpath.value = storedpath;
8307: } else {
1.433 raeburn 8308: document.simpleedit.folderpath.value = '$toplevelsupp';
8309: document.supuploaddocument.folderpath.value = '$toplevelsupp';
8310: document.supnewext.folderpath.value = '$toplevelsupp';
8311: }
8312: }
8313: }
1.485 raeburn 8314: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 8315: return false;
8316: }
1.329 droeschl 8317:
1.472 raeburn 8318: function toContents(jumpto) {
8319: var newurl = '$backtourl';
1.525 raeburn 8320: if ((newurl == '/adm/navmaps') && (jumpto != '')) {
1.472 raeburn 8321: newurl = newurl+'?postdata='+jumpto;
8322: }
8323: location.href=newurl;
8324: }
8325:
1.538 raeburn 8326: function togglePick(caller,value) {
8327: var disp = 'none';
8328: if (document.getElementById('multi'+caller)) {
8329: var curr = document.getElementById('multi'+caller).style.display;
8330: if (value == 1) {
8331: disp='block';
8332: }
8333: if (curr == disp) {
8334: return;
8335: }
8336: document.getElementById('multi'+caller).style.display=disp;
8337: if (value == 1) {
1.594 damieng 8338: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.538 raeburn 8339: } else {
8340: document.getElementById('more'+caller).innerHTML = '';
8341: }
8342: if (caller == 'actions') {
8343: setClass(value);
8344: setBoxes(value);
8345: }
8346: }
8347: var showButton = multiSettings();
8348: if (showButton != 1) {
8349: showButton = multiActions();
8350: }
8351: if (document.getElementById('multisave')) {
8352: if (showButton == 1) {
8353: document.getElementById('multisave').style.display='block';
8354: } else {
8355: document.getElementById('multisave').style.display='none';
8356: }
8357: }
8358: resize_scrollbox('contentscroll','1','1');
8359: return;
8360: }
8361:
8362: function toggleCheckUncheck(caller,more) {
8363: if (more == 1) {
1.594 damieng 8364: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',0);" style="text-decoration:none;">$js_lt{'less'}</a>';
1.538 raeburn 8365: document.getElementById('allfields'+caller).style.display='block';
8366: } else {
1.594 damieng 8367: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.538 raeburn 8368: document.getElementById('allfields'+caller).style.display='none';
8369: }
8370: resize_scrollbox('contentscroll','1','1');
8371: }
8372:
8373: function multiSettings() {
8374: var inuse = 0;
8375: var settingsform = document.togglemultsettings;
8376: if (settingsform.showmultpick.length > 1) {
8377: for (var i=0; i<settingsform.showmultpick.length; i++) {
8378: if (settingsform.showmultpick[i].checked) {
8379: if (settingsform.showmultpick[i].value == 1) {
8380: inuse = 1;
8381: }
8382: }
8383: }
8384: }
8385: return inuse;
8386: }
8387:
8388: function multiActions() {
8389: var inuse = 0;
8390: var actionsform = document.togglemultactions;
8391: if (actionsform.showmultpick.length > 1) {
8392: for (var i=0; i<actionsform.showmultpick.length; i++) {
8393: if (actionsform.showmultpick[i].checked) {
8394: if (actionsform.showmultpick[i].value == 1) {
8395: inuse = 1;
8396: }
8397: }
8398: }
8399: }
8400: return inuse;
8401: }
8402:
8403: function checkSubmits() {
8404: var numchanges = 0;
8405: var form = document.saveactions;
8406: var doactions = multiActions();
1.542 raeburn 8407: var cutwarnings = 0;
8408: var remwarnings = 0;
1.603 raeburn 8409: var removalinfo = 0;
1.538 raeburn 8410: if (doactions == 1) {
8411: var remidxlist = document.cumulativeactions.allremoveidx.value;
8412: if ((remidxlist != '') && (remidxlist != null)) {
8413: var remidxs = remidxlist.split(',');
8414: for (var i=0; i<remidxs.length; i++) {
8415: if (document.getElementById('remove_'+remidxs[i])) {
8416: if (document.getElementById('remove_'+remidxs[i]).checked) {
8417: form.multiremove.value += remidxs[i]+',';
8418: numchanges ++;
1.542 raeburn 8419: if (document.getElementById('skip_remove_'+remidxs[i])) {
8420: if (document.getElementById('skip_remove_'+remidxs[i]).value == 0) {
8421: remwarnings ++;
8422: }
8423: }
1.603 raeburn 8424: if (document.getElementById('confirm_removal_'+remidxs[i])) {
8425: if (document.getElementById('confirm_removal_'+remidxs[i]).value == 1) {
8426: removalinfo ++;
8427: }
8428: }
1.537 raeburn 8429: }
8430: }
1.538 raeburn 8431: }
8432: }
8433: var cutidxlist = document.cumulativeactions.allcutidx.value;
8434: if ((cutidxlist != '') && (cutidxlist != null)) {
8435: var cutidxs = cutidxlist.split(',');
8436: for (var i=0; i<cutidxs.length; i++) {
8437: if (document.getElementById('cut_'+cutidxs[i])) {
8438: if (document.getElementById('cut_'+cutidxs[i]).checked == true) {
8439: form.multicut.value += cutidxs[i]+',';
8440: numchanges ++;
1.542 raeburn 8441: if (document.getElementById('skip_cut_'+cutidxs[i])) {
8442: if (document.getElementById('skip_cut_'+cutidxs[i]).value == 0) {
8443: cutwarnings ++;
8444: }
8445: }
1.537 raeburn 8446: }
8447: }
8448: }
8449: }
1.538 raeburn 8450: var copyidxlist = document.cumulativeactions.allcopyidx.value;
8451: if ((copyidxlist != '') && (copyidxlist != null)) {
8452: var copyidxs = copyidxlist.split(',');
8453: for (var i=0; i<copyidxs.length; i++) {
8454: if (document.getElementById('copy_'+copyidxs[i])) {
8455: if (document.getElementById('copy_'+copyidxs[i]).checked) {
8456: form.multicopy.value += copyidxs[i]+',';
8457: numchanges ++;
8458: }
8459: }
8460: }
8461: }
8462: if (numchanges > 0) {
8463: form.multichange.value = numchanges;
8464: }
1.537 raeburn 8465: }
1.538 raeburn 8466: var dosettings = multiSettings();
1.543 raeburn 8467: var haschanges = 0;
1.538 raeburn 8468: if (dosettings == 1) {
8469: form.allencrypturl.value = '';
8470: form.allhiddenresource.value = '';
1.543 raeburn 8471: form.changeparms.value = 'all';
8472: var patt=new RegExp(",\$");
1.538 raeburn 8473: var allidxlist = document.cumulativesettings.allidx.value;
8474: if ((allidxlist != '') && (allidxlist != null)) {
8475: var allidxs = allidxlist.split(',');
8476: if (allidxs.length > 1) {
8477: for (var i=0; i<allidxs.length; i++) {
8478: if (document.getElementById('hiddenresource_'+allidxs[i])) {
8479: if (document.getElementById('hiddenresource_'+allidxs[i]).checked) {
8480: form.allhiddenresource.value += allidxs[i]+',';
8481: }
8482: }
8483: if (document.getElementById('encrypturl_'+allidxs[i])) {
8484: if (document.getElementById('encrypturl_'+allidxs[i]).checked) {
8485: form.allencrypturl.value += allidxs[i]+',';
8486: }
8487: }
8488: }
1.543 raeburn 8489: form.allhiddenresource.value = form.allhiddenresource.value.replace(patt,"");
8490: form.allencrypturl.value = form.allencrypturl.value.replace(patt,"");
1.537 raeburn 8491: }
1.538 raeburn 8492: }
8493: form.allrandompick.value = '';
8494: form.allrandomorder.value = '';
8495: var allmapidxlist = document.cumulativesettings.allmapidx.value;
8496: if ((allmapidxlist != '') && (allmapidxlist != null)) {
8497: var allmapidxs = allmapidxlist.split(',');
8498: for (var i=0; i<allmapidxs.length; i++) {
8499: var randompick = document.getElementById('randompick_'+allmapidxs[i]);
8500: var rpicknum = document.getElementById('rpicknum_'+allmapidxs[i]);
8501: var randorder = document.getElementById('randomorder_'+allmapidxs[i]);
8502: if ((randompick.checked) && (rpicknum.value != '')) {
8503: form.allrandompick.value += allmapidxs[i]+':'+rpicknum.value+',';
8504: }
8505: if (randorder.checked) {
8506: form.allrandomorder.value += allmapidxs[i]+',';
8507: }
1.537 raeburn 8508: }
1.543 raeburn 8509: form.allrandompick.value = form.allrandompick.value.replace(patt,"");
8510: form.allrandomorder.value = form.allrandomorder.value.replace(patt,"");
8511: }
8512: if (document.cumulativesettings.currhiddenresource.value != form.allhiddenresource.value) {
8513: haschanges = 1;
8514: }
8515: if (document.cumulativesettings.currencrypturl.value != form.allencrypturl.value) {
8516: haschanges = 1;
8517: }
8518: if (document.cumulativesettings.currrandomorder.value != form.allrandomorder.value) {
8519: haschanges = 1;
8520: }
8521: if (document.cumulativesettings.currrandompick.value != form.allrandompick.value) {
8522: haschanges = 1;
1.537 raeburn 8523: }
8524: }
1.543 raeburn 8525: if (doactions == 1) {
1.542 raeburn 8526: if (numchanges > 0) {
1.603 raeburn 8527: if ((cutwarnings > 0) || (remwarnings > 0) || (removalinfo > 0)) {
1.542 raeburn 8528: if (remwarnings > 0) {
1.594 damieng 8529: if (!confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr3a"} '+remwarnings+' $js_lt{"p_rmr3b"}')) {
1.542 raeburn 8530: return false;
8531: }
8532: }
1.603 raeburn 8533: if (removalinfo > 0) {
8534: if (!confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr3a"} '+removalinfo+' $js_lt{"p_rmr3b"}')) {
8535: return false;
8536: }
8537: }
1.542 raeburn 8538: if (cutwarnings > 0) {
1.594 damieng 8539: if (!confirm('$js_lt{"p_ctr1a"}\\n$js_lt{"p_ctr1b"}\\n\\n$js_lt{"p_ctr3a"} '+cutwarnings+' $js_lt{"p_ctr3b"}')) {
1.542 raeburn 8540: return false;
8541: }
8542: }
8543: }
8544: form.submit();
8545: return true;
1.543 raeburn 8546: }
8547: }
8548: if (dosettings == 1) {
8549: if (haschanges == 1) {
1.542 raeburn 8550: form.submit();
8551: return true;
8552: }
1.543 raeburn 8553: }
8554: if ((dosettings == 1) && (doactions == 1)) {
1.594 damieng 8555: alert("$js_lt{'noor'}");
1.543 raeburn 8556: } else {
8557: if (dosettings == 1) {
1.594 damieng 8558: alert("$js_lt{'noch'}");
1.543 raeburn 8559: } else {
1.594 damieng 8560: alert("$js_lt{'noac'}");
1.543 raeburn 8561: }
8562: }
1.538 raeburn 8563: return false;
8564: }
8565:
8566: function setClass(value) {
8567: var cutclass = 'LC_docs_cut';
8568: var copyclass = 'LC_docs_copy';
8569: var removeclass = 'LC_docs_remove';
8570: var cutreg = new RegExp("\\\\b"+cutclass+"\\\\b");
8571: var copyreg = new RegExp("\\\\b"+copyclass+"\\\\b");
8572: var removereg = new RegExp("\\\\"+removeclass+"\\\\b");
8573: var links = document.getElementsByTagName('a');
8574: for (var i=0; i<links.length; i++) {
8575: var classes = links[i].className;
8576: if (cutreg.test(classes)) {
8577: links[i].className = cutclass;
8578: if (value == 1) {
8579: links[i].className += " LC_menubuttons_link";
8580: }
8581: } else {
8582: if (copyreg.test(classes)) {
8583: links[i].className = copyclass;
8584: if (value == 1) {
8585: links[i].className += " LC_menubuttons_link";
8586: }
8587: } else {
8588: if (removereg.test(classes)) {
8589: links[i].className = removeclass;
8590: if (value == 1) {
8591: links[i].className += " LC_menubuttons_link";
8592: }
8593: }
8594: }
8595: }
8596: }
8597: return;
1.537 raeburn 8598: }
8599:
1.538 raeburn 8600: function setBoxes(value) {
8601: var remidxlist = document.cumulativeactions.allremoveidx.value;
8602: if ((remidxlist != '') && (remidxlist != null)) {
8603: var remidxs = remidxlist.split(',');
8604: for (var i=0; i<remidxs.length; i++) {
8605: if (document.getElementById('remove_'+remidxs[i])) {
8606: var item = document.getElementById('remove_'+remidxs[i]);
8607: if (value == 1) {
8608: item.className = 'LC_docs_remove';
8609: } else {
8610: item.className = 'LC_hidden';
8611: }
8612: }
8613: }
8614: }
8615: var cutidxlist = document.cumulativeactions.allcutidx.value;
8616: if ((cutidxlist != '') && (cutidxlist != null)) {
8617: var cutidxs = cutidxlist.split(',');
8618: for (var i=0; i<cutidxs.length; i++) {
8619: if (document.getElementById('cut_'+cutidxs[i])) {
8620: var item = document.getElementById('cut_'+cutidxs[i]);
8621: if (value == 1) {
8622: item.className = 'LC_docs_cut';
8623: } else {
8624: item.className = 'LC_hidden';
8625: }
8626: }
1.537 raeburn 8627: }
8628: }
1.538 raeburn 8629: var copyidxlist = document.cumulativeactions.allcopyidx.value;
8630: if ((copyidxlist != '') && (copyidxlist != null)) {
8631: var copyidxs = copyidxlist.split(',');
8632: for (var i=0; i<copyidxs.length; i++) {
8633: if (document.getElementById('copy_'+copyidxs[i])) {
8634: var item = document.getElementById('copy_'+copyidxs[i]);
8635: if (value == 1) {
8636: item.className = 'LC_docs_copy';
8637: } else {
8638: item.className = 'LC_hidden';
8639: }
8640: }
1.537 raeburn 8641: }
8642: }
8643: return;
8644: }
8645:
1.606 raeburn 8646: function validImportCrsRes() {
8647: var path = document.crsresimportform.coursepath.options[document.crsresimportform.coursepath.selectedIndex].value;
8648: var fname = document.crsresimportform.coursefile.options[document.crsresimportform.coursefile.selectedIndex].value;
8649: if ((fname == '') || (fname == null)) {
8650: alert("$js_lt{'nofi'}");
8651: return false;
8652: }
8653: var url = '/res/$coursedom/$coursenum/';
8654: if (path && path != '/') {
8655: url += path+'/';
8656: }
8657: if (fname != '') {
8658: url += fname;
8659: }
8660: var title = document.crsresimportform.crsrestitle.value;
1.676 raeburn 8661: document.crsresimportform.importdetail.value=encodeURIComponent(title)+'='+encodeURIComponent(url);
1.606 raeburn 8662: return true;
8663: }
8664:
8665: function validateNewRes(caller) {
8666: if (caller == 'single') {
8667: var role = document.courseresform.authorrole.options[document.courseresform.authorrole.selectedIndex].value;
8668: var authorpath = document.courseresform.authorpath.options[document.courseresform.authorpath.selectedIndex].value;
8669: var resname = document.courseresform.newresourcename.value;
8670: }
8671: }
8672:
1.611 raeburn 8673: ENDSCRIPT
1.329 droeschl 8674: }
1.457 raeburn 8675:
1.483 raeburn 8676: sub history_tab_js {
8677: return <<"ENDHIST";
8678: function toggleHistoryDisp(choice) {
8679: document.docslogform.docslog.value = choice;
8680: document.docslogform.submit();
8681: return;
8682: }
8683:
8684: ENDHIST
8685: }
8686:
1.484 raeburn 8687: sub inject_data_js {
8688: return <<ENDINJECT;
8689:
8690: function injectData(current, hiddenField, name, value) {
8691: currentElement = document.getElementById(hiddenField);
8692: currentElement.name = name;
8693: currentElement.value = value;
8694: current.submit();
8695: }
8696:
8697: ENDINJECT
8698: }
8699:
8700: sub dump_switchserver_js {
8701: my @hosts = @_;
1.594 damieng 8702: my %js_lt = &Apache::lonlocal::texthash(
1.574 raeburn 8703: dump => 'Copying content to Authoring Space requires switching server.',
1.484 raeburn 8704: swit => 'Switch server?',
1.594 damieng 8705: );
8706: my %html_js_lt = &Apache::lonlocal::texthash(
8707: swit => 'Switch server?',
1.568 raeburn 8708: duco => 'Copying Content to Authoring Space',
1.484 raeburn 8709: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
8710: chos => 'Choose server',
8711: );
1.594 damieng 8712: &js_escape(\%js_lt);
8713: &html_escape(\%html_js_lt);
8714: &js_escape(\%html_js_lt);
1.484 raeburn 8715: my $role = $env{'request.role'};
8716: my $js = <<"ENDSWJS";
8717: <script type="text/javascript">
8718: function write_switchserver() {
8719: var server;
8720: if (document.setserver.posshosts.length > 0) {
8721: for (var i=0; i<document.setserver.posshosts.length; i++) {
8722: if (document.setserver.posshosts[i].checked) {
8723: server = document.setserver.posshosts[i].value;
8724: }
8725: }
8726: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
8727: }
8728: window.close();
8729: }
8730: </script>
8731:
8732: ENDSWJS
8733:
8734: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
8735: {'only_body' => 1,
8736: 'js_ready' => 1,});
8737: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
8738:
8739: my $hostpicker;
8740: my $count = 0;
8741: foreach my $host (sort(@hosts)) {
8742: my $checked;
8743: if ($count == 0) {
8744: $checked = ' checked="checked"';
8745: }
8746: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
8747: $host.'"'.$checked.' />'.$host.'</label> ';
8748: $count++;
8749: }
8750:
8751: return <<"ENDSWITCHJS";
8752:
8753: function dump_needs_switchserver(url) {
8754: if (url!='' && url!= null) {
1.594 damieng 8755: if (confirm("$js_lt{'dump'}\\n$js_lt{'swit'}")) {
1.484 raeburn 8756: go(url);
8757: }
8758: }
8759: return;
8760: }
8761:
8762: function choose_switchserver_window() {
8763: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
8764: newWindow.document.open();
8765: newWindow.document.writeln('$startpage');
1.594 damieng 8766: newWindow.document.write('<h3>$html_js_lt{'duco'}<\\/h3>\\n'+
8767: '<p>$html_js_lt{'yone'}<\\/p>\\n'+
8768: '<div class="LC_left_float"><fieldset><legend>$html_js_lt{'chos'}<\\/legend>\\n'+
1.484 raeburn 8769: '<form name="setserver" method="post" action="" \\/>\\n'+
8770: '$hostpicker\\n'+
8771: '<br \\/><br \\/>\\n'+
1.594 damieng 8772: '<input type="button" name="makeswitch" value="$html_js_lt{'swit'}" '+
1.484 raeburn 8773: 'onclick="write_switchserver();" \\/>\\n'+
8774: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
8775: newWindow.document.writeln('$endpage');
8776: newWindow.document.close();
8777: newWindow.focus();
8778: }
8779:
8780: ENDSWITCHJS
8781: }
8782:
8783: sub makedocslogform {
8784: my ($formelems,$docslog) = @_;
8785: return <<"LOGSFORM";
8786: <form action="/adm/coursedocs" method="post" name="docslogform">
8787: <input type="hidden" name="docslog" value="$docslog" />
8788: $formelems
8789: </form>
8790: LOGSFORM
8791: }
8792:
8793: sub makesimpleeditform {
8794: my ($formelems) = @_;
8795: return <<"SIMPFORM";
8796: <form name="simpleedit" method="post" action="/adm/coursedocs">
8797: <input type="hidden" name="importdetail" value="" />
8798: $formelems
8799: </form>
8800: SIMPFORM
8801: }
8802:
1.606 raeburn 8803: sub makenewproblem {
8804: my ($r,$coursedom,$coursenum) = @_;
8805: # Creating a new problem
8806: my ($redirect,$error);
8807: if ($env{'form.authorrole'}) {
8808: my ($newsubdir,$filename);
8809: if ($env{'form.newsubdir'}) {
8810: if ($env{'form.newsubdirname'} ne '') {
8811: $newsubdir = $env{'form.newsubdirname'};
1.654 raeburn 8812: }
1.606 raeburn 8813: }
8814: if ($env{'form.newresourcename'}) {
8815: $filename = $env{'form.newresourcename'};
8816: $filename =~ s/\.(\d+)(\.\w+)$/$2/;
8817: $filename =~ s/`//g;
8818: $filename =~ s{/\.\./}{_}g;
8819: $filename =~ s/\.+/./g;
8820: $filename =~ s{/+}{_}g;
8821: if ($filename ne '') {
8822: my ($name,$ext) = ($filename =~ /(.+)\.([^.]+)$/);
8823: if (($ext) && ($ext ne '.problem')) {
8824: $filename = $name.'.problem';
8825: } elsif ($ext eq '') {
8826: $filename .= '.problem';
8827: }
8828: my $docroot = $r->dir_config('lonDocRoot');
8829: my @ids=&Apache::lonnet::current_machine_ids();
8830: if ($env{'form.authorrole'} eq 'author') {
8831: if ($env{'user.author'}) {
8832: if ($env{'user.home'} && grep(/^\Q$env{'user.home'}\E$/,@ids)) {
8833: my $url = "/priv/$env{'user.domain'}/$env{'user.name'}";
8834: my $path = $docroot.$url;
8835: my $subdir = $env{'form.authorpath'};
8836: $redirect = &finishnewprob($url,$path,$subdir,$newsubdir,$filename);
8837: }
8838: }
8839: } elsif ($env{'form.authorrole'} eq 'course') {
8840: my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
8841: if ($chome && grep(/^\Q$chome\E$/,@ids)) {
8842: my $url = "/priv/$coursedom/$coursenum";
8843: my $path=$docroot.$url;
8844: my $subdir = $env{'form.authorpath'};
8845: $redirect = &finishnewprob($url,$path,$subdir,$newsubdir,$filename);
8846: if ($redirect) {
8847: my $rightsfile = 'default.rights';
8848: my $sourcerights = "$path/$rightsfile";
8849: my $targetrights = $docroot."/res/$coursedom/$coursenum/$rightsfile";
8850: my $now = time;
8851: if (!-e $sourcerights) {
8852: my $cid = $coursedom.'_'.$coursenum;
8853: if (open(my $fh,">$sourcerights")) {
8854: print $fh <<END;
8855: <accessrule effect="deny" realm="" type="course" role="" />
8856: <accessrule effect="allow" realm="$cid" type="course" role="" />
8857: END
8858: close($fh);
8859: }
8860: }
8861: if (!-e "$sourcerights.meta") {
8862: if (open(my $fh,">$sourcerights.meta")) {
8863: my $author=$env{'environment.firstname'}.' '.
8864: $env{'environment.middlename'}.' '.
8865: $env{'environment.lastname'}.' '.
8866: $env{'environment.generation'};
8867: $author =~ s/\s+$//;
8868: print $fh <<"END";
8869:
8870: <abstract></abstract>
8871: <author>$author</author>
8872: <authorspace>$coursenum:$coursedom</authorspace>
8873: <copyright>private</copyright>
8874: <creationdate>$now</creationdate>
8875: <customdistributionfile></customdistributionfile>
8876: <dependencies></dependencies>
8877: <domain>$coursedom</domain>
8878: <highestgradelevel>0</highestgradelevel>
8879: <keywords></keywords>
8880: <language>notset </language>
8881: <lastrevisiondate>$now</lastrevisiondate>
8882: <lowestgradelevel>0</lowestgradelevel>
8883: <mime>rights</mime>
8884: <modifyinguser>$env{'user.name'}:$env{'user.domain'}</modifyinguser>
8885: <notes></notes>
8886: <obsolete></obsolete>
8887: <obsoletereplacement></obsoletereplacement>
8888: <owner>$coursenum:$coursedom</owner>
8889: <rule>deny:::course,allow:$cid::course</rule>
8890: <sourceavail></sourceavail>
8891: <standards></standards>
8892: <subject></subject>
8893: <title></title>
8894: END
1.654 raeburn 8895: close($fh);
8896: }
8897: }
8898: if ((-e $sourcerights) && (-e "$sourcerights.meta")) {
8899: if (!-e "$docroot/res/$coursedom") {
8900: mkdir("$docroot/res/$coursedom",0755);
1.606 raeburn 8901: }
1.654 raeburn 8902: if (!-e "$docroot/res/$coursedom/$coursenum") {
8903: mkdir("$docroot/res/$coursedom/$coursenum",0755);
8904: }
8905: if ((-e "$docroot/res/$coursedom/$coursenum") && (!-e $targetrights)) {
8906: my $nokeyref = &Apache::lonpublisher::getnokey($r->dir_config('lonIncludes'));
8907: my $output = &Apache::lonpublisher::batchpublish($r,$sourcerights,$targetrights,$nokeyref,1);
1.606 raeburn 8908: }
8909: }
1.654 raeburn 8910: my $source = $docroot.$redirect;
8911: if (!-e "$source.meta") {
8912: my $cid = $coursedom.'_'.$coursenum;
8913: my $now = time;
8914: if (open(my $fh,">$source.meta")) {
8915: my $author=$env{'environment.firstname'}.' '.
8916: $env{'environment.middlename'}.' '.
8917: $env{'environment.lastname'}.' '.
8918: $env{'environment.generation'};
8919: $author =~ s/\s+$//;
8920: my $title = $env{'form.newresourcetitle'};
8921: $title =~ s/^\s+|\s+$//g;
8922: print $fh <<END;
1.606 raeburn 8923:
8924: <abstract></abstract>
8925: <author>$author</author>
8926: <authorspace>$coursenum:$coursedom</authorspace>
8927: <copyright>custom</copyright>
8928: <creationdate>$now</creationdate>
8929: <customdistributionfile>/res/$coursedom/$coursenum/default.rights</customdistributionfile>
8930: <dependencies></dependencies>
8931: <domain>$coursedom</domain>
8932: <highestgradelevel>0</highestgradelevel>
8933: <keywords></keywords>
8934: <language>notset </language>
8935: <lastrevisiondate>$now</lastrevisiondate>
8936: <lowestgradelevel>0</lowestgradelevel>
8937: <mime>problem</mime>
8938: <modifyinguser>$coursenum:$coursedom</modifyinguser>
8939: <notes></notes>
8940: <obsolete></obsolete>
8941: <obsoletereplacement></obsoletereplacement>
8942: <owner>$coursenum:$coursedom</owner>
8943: <sourceavail></sourceavail>
8944: <standards></standards>
8945: <subject></subject>
8946: <title>$title</title>
8947: END
1.654 raeburn 8948: close($fh);
1.606 raeburn 8949: }
8950: }
8951: }
8952: }
8953: } else {
8954: my ($auname,$audom,$role) = split('___',$env{'form.authorrole'});
8955: my $rolehome = &Apache::lonnet::homeserver($auname,$audom);
8956: if (grep(/^\Q$rolehome\E$/,@ids)) {
8957: my $now = time;
8958: if (exists($env{'user.role.'.$role.'./'.$audom.'/'.$auname})) {
8959: my ($start,$end) = split(/\./,$env{'user.role.'.$role.'./'.$audom.'/'.$auname});
8960: if (($start <= $now) && (($end == 0) || ($end >= $now))) {
8961: my $url = "/priv/$audom/$auname";
8962: my $path = $r->dir_config('lonDocRoot').$url;
8963: my $subdir = $env{'form.authorpath'};
8964: $redirect = &finishnewprob($url,$path,$subdir,$newsubdir,$filename);
8965: }
8966: }
8967: }
8968: }
8969: }
8970: }
8971: }
8972: return ($redirect,$error);
8973: }
8974:
8975: sub finishnewprob {
1.654 raeburn 8976: my ($url,$path,$subdir,$newsubdir,$filename,$context) = @_;
1.607 raeburn 8977: unless (-d $path) {
8978: unless (mkdir($path,02770)) {
8979: return;
8980: }
8981: }
1.606 raeburn 8982: my $redirect;
8983: if ($subdir ne '/') {
8984: $subdir = &cleandir($subdir);
8985: if (($subdir ne '') && (-d "$path/$subdir")) {
8986: $path .= "/$subdir";
8987: $url .= "/$subdir";
8988: }
8989: }
8990: my $dest;
8991: if ($newsubdir ne '') {
8992: $newsubdir = &cleandir($newsubdir);
8993: }
8994: if ($newsubdir ne '') {
8995: if (-d "$path/$newsubdir") {
8996: $dest = "$path/$newsubdir/$filename";
8997: } else {
8998: my $dirok;
8999: unless (-e "$path/$newsubdir") {
9000: if (mkdir("$path/$newsubdir",02770)) {
9001: if (chmod(02770,"$path/$newsubdir")) {
9002: $dirok = 1;
9003: }
9004: }
9005: }
9006: if ($dirok) {
9007: $dest = "$path/$newsubdir/$filename";
9008: }
9009: }
9010: if (($dest ne '') && (!-e $dest)) {
9011: $redirect = "$url/$newsubdir/$filename";
9012: }
9013: } else {
9014: $dest = "$path/$filename";
9015: if (($dest ne '') && (!-e $dest)) {
9016: $redirect = "$url/$filename";
9017: }
9018: }
1.654 raeburn 9019: if ((!-e $dest) && ($context ne 'upload')) {
9020: my $template = $env{'form.template'};
9021: my $copyfrom;
9022: if ($template ne '') {
9023: my %templates;
9024: my @files = &Apache::lonhomework::get_template_list('problem');
9025: foreach my $poss (@files) {
9026: if (ref($poss) eq 'ARRAY') {
9027: if ($template eq $poss->[0]) {
9028: $templates{$template} = 1;
9029: last;
9030: }
9031: }
9032: }
9033: if ($templates{$template}) {
9034: $copyfrom = $template;
9035: }
9036: }
9037: if ($filename =~ /\.problem$/) {
9038: unless ($copyfrom) {
9039: $copyfrom = $Apache::lonnet::perlvar{'lonIncludes'}.'/templates/blank.problem';
9040: }
9041: &File::Copy::copy($copyfrom,$dest);
9042: }
9043: }
1.606 raeburn 9044: return $redirect;
9045: }
9046:
9047: sub cleandir {
9048: my ($dir) = @_;
9049: $dir =~ s/^\s+//;
9050: $dir =~ s/\s+$//;
9051: $dir =~ s/\.+//g;
9052: $dir =~ s/[\#\?&%\":]//g;
9053: return $dir;
9054: }
9055:
1.329 droeschl 9056: 1;
9057: __END__
9058:
9059:
9060: =head1 NAME
9061:
9062: Apache::londocs.pm
9063:
9064: =head1 SYNOPSIS
9065:
9066: This is part of the LearningOnline Network with CAPA project
9067: described at http://www.lon-capa.org.
9068:
9069: =head1 SUBROUTINES
9070:
9071: =over
9072:
9073: =item %help=()
9074:
9075: Available help topics
9076:
9077: =item mapread()
9078:
1.344 bisitz 9079: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 9080: @order and @resources, determines status
9081: sets @order - pointer to resources in right order
9082: sets @resources - array with the resources with correct idx
9083:
9084: =item authorhosts()
9085:
9086: Return hash with valid author names
9087:
9088: =item clean()
9089:
9090: =item dumpcourse()
9091:
9092: Actually dump course
9093:
9094: =item group_import()
9095:
9096: Imports the given (name, url) resources into the course
9097: coursenum, coursedom, and folder must precede the list
9098:
9099: =item breadcrumbs()
9100:
9101: =item log_docs()
9102:
9103: =item docs_change_log()
9104:
9105: =item update_paste_buffer()
9106:
9107: =item print_paste_buffer()
9108:
9109: =item do_paste_from_buffer()
9110:
1.538 raeburn 9111: =item do_buffer_empty()
9112:
9113: =item clear_from_buffer()
9114:
1.492 raeburn 9115: =item get_newmap_url()
9116:
9117: =item dbcopy()
9118:
9119: =item uniqueness_check()
9120:
9121: =item contained_map_check()
9122:
9123: =item url_paste_fixups()
9124:
9125: =item apply_fixups()
9126:
9127: =item copy_dependencies()
9128:
1.329 droeschl 9129: =item update_parameter()
9130:
9131: =item handle_edit_cmd()
9132:
9133: =item editor()
9134:
9135: =item process_file_upload()
9136:
9137: =item process_secondary_uploads()
9138:
9139: =item is_supplemental_title()
9140:
9141: =item entryline()
9142:
9143: =item tiehash()
9144:
9145: =item untiehash()
9146:
9147: =item checkonthis()
9148:
9149: check on this
9150:
9151: =item verifycontent()
9152:
9153: Verify Content
9154:
1.636 raeburn 9155: =item devalidateversioncache()
9156:
9157: =item checkversions()
1.329 droeschl 9158:
9159: Check Versions
9160:
9161: =item mark_hash_old()
9162:
9163: =item is_hash_old()
9164:
9165: =item changewarning()
9166:
9167: =item init_breadcrumbs()
9168:
9169: Breadcrumbs for special functions
9170:
1.484 raeburn 9171: =item create_list_elements()
9172:
9173: =item create_form_ul()
9174:
9175: =item startContentScreen()
9176:
9177: =item endContentScreen()
9178:
9179: =item supplemental_base()
9180:
9181: =item embedded_form_elems()
9182:
9183: =item embedded_destination()
9184:
9185: =item return_to_editor()
9186:
9187: =item decompression_info()
9188:
9189: =item decompression_phase_one()
9190:
9191: =item decompression_phase_two()
9192:
9193: =item remove_archive()
9194:
9195: =item generate_admin_menu()
9196:
9197: =item generate_edit_table()
9198:
9199: =item editing_js()
9200:
9201: =item history_tab_js()
9202:
9203: =item inject_data_js()
9204:
9205: =item dump_switchserver_js()
9206:
1.485 raeburn 9207: =item resize_scrollbox_js()
1.484 raeburn 9208:
9209: =item makedocslogform()
9210:
1.485 raeburn 9211: =item makesimpleeditform()
9212:
1.329 droeschl 9213: =back
9214:
9215: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>