Annotation of loncom/interface/londocs.pm, revision 1.484.2.85.2.1
1.329 droeschl 1: # The LearningOnline Network
2: # Documents
3: #
1.484.2.85.2. (raeburn 4:): # $Id: londocs.pm,v 1.484.2.85 2020/01/16 18:14:29 raeburn Exp $
1.329 droeschl 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29: package Apache::londocs;
30:
31: use strict;
32: use Apache::Constants qw(:common :http);
33: use Apache::imsexport;
34: use Apache::lonnet;
35: use Apache::loncommon;
1.383 tempelho 36: use Apache::lonhtmlcommon;
1.329 droeschl 37: use LONCAPA::map();
38: use Apache::lonratedt();
39: use Apache::lonxml;
40: use Apache::lonclonecourse;
41: use Apache::lonnavmaps;
1.472 raeburn 42: use Apache::lonnavdisplay();
1.484.2.19 raeburn 43: use Apache::lonextresedit();
1.484.2.43 raeburn 44: use Apache::lontemplate();
45: use Apache::lonsimplepage();
1.484.2.85.2. (raeburn 46:): use Apache::loncourserespicker();
1.329 droeschl 47: use HTML::Entities;
1.484.2.7 raeburn 48: use HTML::TokeParser;
1.329 droeschl 49: use GDBM_File;
1.484.2.51 raeburn 50: use File::MMagic;
1.329 droeschl 51: use Apache::lonlocal;
52: use Cwd;
53: use LONCAPA qw(:DEFAULT :match);
54:
55: my $iconpath;
56:
57: my %hash;
58:
59: my $hashtied;
60: my %alreadyseen=();
61:
62: my $hadchanges;
1.484.2.37 raeburn 63: my $suppchanges;
1.329 droeschl 64:
65:
66: my %help=();
67:
68:
69: sub mapread {
70: my ($coursenum,$coursedom,$map)=@_;
71: return
72: &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
73: $map);
74: }
75:
76: sub storemap {
1.484.2.7 raeburn 77: my ($coursenum,$coursedom,$map,$contentchg)=@_;
78: my $report;
79: if (($contentchg) && ($map =~ /^default/)) {
80: $report = 1;
81: }
1.329 droeschl 82: my ($outtext,$errtext)=
83: &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.484.2.7 raeburn 84: $map,1,$report);
1.329 droeschl 85: if ($errtext) { return ($errtext,2); }
1.364 bisitz 86:
1.484.2.37 raeburn 87: if ($map =~ /^default/) {
88: $hadchanges=1;
89: } else {
90: $suppchanges=1;
91: }
1.329 droeschl 92: return ($errtext,0);
93: }
94:
95:
96:
97: sub authorhosts {
98: my %outhash=();
99: my $home=0;
100: my $other=0;
101: foreach my $key (keys(%env)) {
102: if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
103: my $role=$1;
104: my $realm=$2;
105: my ($start,$end)=split(/\./,$env{$key});
106: if (($start) && ($start>time)) { next; }
107: if (($end) && (time>$end)) { next; }
108: my ($ca,$cd);
109: if ($1 eq 'au') {
110: $ca=$env{'user.name'};
111: $cd=$env{'user.domain'};
112: } else {
113: ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
114: }
115: my $allowed=0;
116: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
117: my @ids=&Apache::lonnet::current_machine_ids();
1.484 raeburn 118: foreach my $id (@ids) {
119: if ($id eq $myhome) {
120: $allowed=1;
121: last;
122: }
123: }
1.329 droeschl 124: if ($allowed) {
125: $home++;
1.484 raeburn 126: $outhash{'home_'.$ca.':'.$cd}=1;
1.329 droeschl 127: } else {
1.484 raeburn 128: $outhash{'otherhome_'.$ca.':'.$cd}=$myhome;
1.329 droeschl 129: $other++;
130: }
131: }
132: }
133: return ($home,$other,%outhash);
134: }
135:
136:
137: sub clean {
138: my ($title)=@_;
139: $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
1.344 bisitz 140: return $title;
1.329 droeschl 141: }
142:
1.484.2.67 raeburn 143: sub default_folderpath {
144: my ($coursenum,$coursedom,$navmapref) = @_;
145: return unless ($coursenum && $coursedom && ref($navmapref));
146: # Check if entire course is hidden and/or encrypted
147: my ($hiddenmap,$encryptmap,$folderpath,$hiddentop);
148: my $toplevel = "uploaded/$coursedom/$coursenum/default.sequence";
149: unless (ref($$navmapref)) {
150: $$navmapref = Apache::lonnavmaps::navmap->new();
151: }
152: if (ref($$navmapref)) {
153: if (lc($$navmapref->get_mapparam(undef,$toplevel,"0.hiddenresource")) eq 'yes') {
154: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
155: my @resources = $$navmapref->retrieveResources($toplevel,$filterFunc,1,1);
156: unless (@resources) {
157: $hiddenmap = 1;
158: unless ($env{'request.role.adv'}) {
159: $hiddentop = 1;
160: if ($env{'form.folder'}) {
161: undef($env{'form.folder'});
162: }
163: }
164: }
165: }
166: if (lc($$navmapref->get_mapparam(undef,$toplevel,"0.encrypturl")) eq 'yes') {
167: $encryptmap = 1;
168: }
169: }
170: unless ($hiddentop) {
171: $folderpath='default&'.&escape(&mt('Main Content')).
172: '::'.$hiddenmap.':'.$encryptmap.'::';
173: }
174: if (wantarray) {
175: return ($folderpath,$hiddentop);
176: } else {
177: return $folderpath;
178: }
179: }
1.329 droeschl 180:
181: sub dumpcourse {
182: my ($r) = @_;
1.408 raeburn 183: my $crstype = &Apache::loncommon::course_type();
1.484.2.43 raeburn 184: my ($starthash,$js);
185: unless (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
186: $js = <<"ENDJS";
187: <script type="text/javascript">
188: // <![CDATA[
189:
190: function hide_searching() {
191: if (document.getElementById('searching')) {
192: document.getElementById('searching').style.display = 'none';
193: }
194: return;
195: }
196:
197: // ]]>
198: </script>
199: ENDJS
200: $starthash = {
201: add_entries => {'onload' => "hide_searching();"},
202: };
203: }
204: $r->print(&Apache::loncommon::start_page('Copy '.$crstype.' Content to Authoring Space',$js,$starthash)."\n".
205: &Apache::lonhtmlcommon::breadcrumbs('Copy '.$crstype.' Content to Authoring Space')."\n");
1.484 raeburn 206: $r->print(&startContentScreen('tools'));
1.329 droeschl 207: my ($home,$other,%outhash)=&authorhosts();
1.484 raeburn 208: unless ($home) {
209: $r->print(&endContentScreen());
210: return '';
211: }
1.329 droeschl 212: my $origcrsid=$env{'request.course.id'};
213: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
214: if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
215: # Do the dumping
1.484 raeburn 216: unless ($outhash{'home_'.$env{'form.authorspace'}}) {
217: $r->print(&endContentScreen());
218: return '';
219: }
1.484.2.24 raeburn 220: my ($ca,$cd)=split(/\:/,$env{'form.authorspace'});
1.329 droeschl 221: $r->print('<h3>'.&mt('Copying Files').'</h3>');
222: my $title=$env{'form.authorfolder'};
223: $title=&clean($title);
1.484.2.43 raeburn 224: my ($navmap,$errormsg) =
225: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
226: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
227: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
228: my (%maps,%resources,%titles);
229: if (!ref($navmap)) {
230: $r->print($errormsg.
231: &endContentScreen());
232: return '';
233: } else {
234: &Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles,
235: 'dumpdocs',$cdom,$cnum);
236: }
237: my @todump = &Apache::loncommon::get_env_multiple('form.archive');
238: my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages,
239: %newcontent,%has_simpleprobs);
240: foreach my $item (sort {$a <=> $b} (@todump)) {
241: my $name = $env{'form.namefor_'.$item};
242: if ($resources{$item}) {
243: my ($map,$id,$res) = &Apache::lonnet::decode_symb($resources{$item});
244: if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) {
245: $tocopy{$1} = $name;
246: $display{$item} = $1;
247: $lookup{$1} = $item;
248: } elsif ($res eq 'lib/templates/simpleproblem.problem') {
249: $simpleproblems{$item} = {
250: symb => $resources{$item},
251: name => $name,
252: };
253: $display{$item} = 'simpleproblem_'.$name;
254: if ($map =~ m{^\Quploaded/$cdom/$cnum/\E(.+)$}) {
255: $has_simpleprobs{$1}{$id} = $item;
256: }
257: } elsif ($res =~ m{^adm/$match_domain/$match_username/(\d+)/smppg}) {
258: my $marker = $1;
259: my $db_name = &Apache::lonsimplepage::get_db_name($res,$marker,$cdom,$cnum);
260: $simplepages{$item} = {
261: res => $res,
262: title => $titles{$item},
263: db => $db_name,
264: marker => $marker,
265: symb => $resources{$item},
266: name => $name,
267: };
268: $display{$item} = '/'.$res;
269: }
270: } elsif ($maps{$item}) {
271: if ($maps{$item} =~ m{^\Quploaded/$cdom/$cnum/\E((?:default|supplemental)_\d+\.(?:sequence|page))$}) {
272: $tocopy{$1} = $name;
273: $display{$item} = $1;
274: $lookup{$1} = $item;
275: }
276: } else {
277: next;
278: }
279: }
1.329 droeschl 280: my $crs='/uploaded/'.$env{'request.course.id'}.'/';
281: $crs=~s/\_/\//g;
1.484.2.43 raeburn 282: my $mm = new File::MMagic;
283: my $prefix = "/uploaded/$cdom/$cnum/";
284: %replacehash = %tocopy;
285: foreach my $item (sort(keys(%simpleproblems))) {
286: my $content = &Apache::imsexport::simpleproblem($simpleproblems{$item}{'symb'});
287: $newcontent{$display{$item}} = $content;
288: }
289: my $gateway = Apache::lonhtmlgateway->new('web');
290: foreach my $item (sort(keys(%simplepages))) {
291: if (ref($simplepages{$item}) eq 'HASH') {
292: my $pagetitle = $simplepages{$item}{'title'};
293: my %fields = &Apache::lonnet::dump($simplepages{$item}{'db'},$cdom,$cnum);
294: my %contents;
295: foreach my $field (keys(%fields)) {
296: if ($field =~ /^(?:aaa|bbb|ccc)_(\w+)$/) {
297: my $name = $1;
298: my $msg = $fields{$field};
299: if ($name eq 'webreferences') {
300: if ($msg =~ m{^https?://}) {
301: $contents{$name} = '<a href="'.$msg.'"><tt>'.$msg.'</tt></a>';
302: }
303: } else {
304: $msg = &Encode::decode('utf8',$msg);
305: $msg = $gateway->process_outgoing_html($msg,1);
306: $contents{$name} = $msg;
307: }
308: } elsif ($field eq 'uploaded.photourl') {
309: my $marker = $simplepages{$item}{marker};
310: if ($fields{$field} =~ m{^\Q$prefix\E(simplepage/$marker/.+)$}) {
311: my $filepath = $1;
312: my ($relpath,$fname) = ($filepath =~ m{^(.+/)([^/]+)$});
313: if ($fname ne '') {
314: $fname=~s/\.(\w+)$//;
315: my $ext=$1;
316: $fname = &clean($fname);
317: $fname.='.'.$ext;
318: $contents{image} = '<img src="'.$relpath.$fname.'" alt="Image" />';
319: $replacehash{$filepath} = $relpath.$fname;
320: $deps{$item}{$filepath} = 1;
321: }
322: }
323: }
324: }
325: $replacehash{'/'.$simplepages{$item}{'res'}} = $simplepages{$item}{'name'};
326: $lookup{'/'.$simplepages{$item}{'res'}} = $item;
327: my $content = '
328: <html>
329: <head>
330: <title>'.$pagetitle.'</title>
331: </head>
332: <body bgcolor="#ffffff">';
333: if ($contents{title}) {
334: $content .= "\n".'<h2>'.$contents{title}.'</h2>';
335: }
336: if ($contents{image}) {
337: $content .= "\n".$contents{image};
338: }
339: if ($contents{content}) {
340: $content .= '
341: <div class="LC_Box">
1.484.2.50 raeburn 342: <h4 class="LC_hcell">'.&mt('Content').'</h4>'.
1.484.2.43 raeburn 343: $contents{content}.'
344: </div>';
345: }
346: if ($contents{webreferences}) {
347: $content .= '
348: <div class="LC_Box">
1.484.2.50 raeburn 349: <h4 class="LC_hcell">'.&mt('Web References').'</h4>'.
1.484.2.43 raeburn 350: $contents{webreferences}.'
351: </div>';
352: }
353: $content .= '
354: </body>
355: </html>
356: ';
357: $newcontent{'/'.$simplepages{$item}{res}} = $content;
358: }
359: }
360: foreach my $item (keys(%tocopy)) {
361: unless ($item=~/\.(sequence|page)$/) {
362: my $currurlpath = $prefix.$item;
363: my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath);
364: &recurse_html($mm,$prefix,$currdirpath,$currurlpath,$item,$lookup{$item},\%replacehash,\%deps);
365: }
366: }
367: foreach my $num (sort {$a <=> $b} (@todump)) {
368: my $src = $display{$num};
369: next if ($src eq '');
370: my @needcopy = ();
371: if ($replacehash{$src}) {
372: push(@needcopy,$src);
373: if (ref($deps{$num}) eq 'HASH') {
374: foreach my $dep (sort(keys(%{$deps{$num}}))) {
375: if ($replacehash{$dep}) {
376: push(@needcopy,$dep);
377: }
378: }
379: }
380: } elsif ($src =~ /^simpleproblem_/) {
381: push(@needcopy,$src);
382: }
383: next if (@needcopy == 0);
384: my ($result,$depresult);
385: for (my $i=0; $i<@needcopy; $i++) {
386: my $item = $needcopy[$i];
387: my $newfilename;
388: if ($simpleproblems{$num}) {
389: $newfilename=$title.'/'.$simpleproblems{$num}{'name'};
390: } else {
391: $newfilename=$title.'/'.$replacehash{$item};
392: }
393: $newfilename=~s/\.(\w+)$//;
394: my $ext=$1;
395: $newfilename=&clean($newfilename);
396: $newfilename.='.'.$ext;
397: my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$});
398: if ($newrelpath ne $replacehash{$item}) {
399: $replacehash{$item} = $newrelpath;
400: }
401: my @dirs=split(/\//,$newfilename);
402: my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
403: my $makepath=$path;
404: my $fail;
405: my $origin;
406: for (my $i=0;$i<$#dirs;$i++) {
407: $makepath.='/'.$dirs[$i];
408: unless (-e $makepath) {
409: unless(mkdir($makepath,0755)) {
410: $fail = &mt('Directory creation failed.');
411: }
412: }
413: }
414: if ($i == 0) {
415: $result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ';
416: } else {
417: $depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '.
418: '<span class="LC_fontsize_small" style="font-weight: bold;">'.
419: &mt('(dependency)').'</span>: ';
420: }
421: if (-e $path.'/'.$newfilename) {
422: $fail = &mt('Destination already exists -- not overwriting.');
423: } else {
424: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
425: if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) ||
426: ($item =~ /^simpleproblem_/)) {
427: print $fh $newcontent{$item};
428: } else {
429: my $fileloc = &Apache::lonnet::filelocation('',$prefix.$item);
430: if (-e $fileloc) {
431: if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
432: if ((($1 eq 'sequence') || ($1 eq 'page')) &&
433: (ref($has_simpleprobs{$item}) eq 'HASH')) {
434: my %changes = %{$has_simpleprobs{$item}};
435: my $content = &Apache::lonclonecourse::rewritefile(
436: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
437: (%replacehash,$crs => '')
438: );
439: my $updatedcontent = '';
440: my $parser = HTML::TokeParser->new(\$content);
441: $parser->attr_encoded(1);
442: while (my $token = $parser->get_token) {
443: if ($token->[0] eq 'S') {
444: if (($token->[1] eq 'resource') &&
445: ($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') &&
446: ($changes{$token->[2]->{'id'}})) {
447: my $id = $token->[2]->{'id'};
448: $updatedcontent .= '<'.$token->[1];
449: foreach my $attrib (@{$token->[3]}) {
450: next unless ($attrib =~ /^(src|type|title|id)$/);
451: if ($attrib eq 'src') {
452: my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/);
453: if ($file) {
454: $updatedcontent .= ' '.$attrib.'="'.$file.'"';
455: } else {
456: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
457: }
458: } else {
459: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
460: }
461: }
462: $updatedcontent .= ' />'."\n";
463: } else {
464: $updatedcontent .= $token->[4]."\n";
465: }
466: } else {
467: $updatedcontent .= $token->[2];
468: }
469: }
470: print $fh $updatedcontent;
471: } else {
472: print $fh &Apache::lonclonecourse::rewritefile(
473: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
474: (%replacehash,$crs => '')
475: );
476: }
477: } else {
478: print $fh
479: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
480: }
481: } else {
482: $fail = &mt('Source does not exist.');
483: }
484: }
485: $fh->close();
486: } else {
487: $fail = &mt('Could not write to destination.');
488: }
489: }
490: my $text;
491: if ($fail) {
492: $text = '<span class="LC_error">'.&mt('fail').(' 'x3).$fail.'</span>';
493: } else {
494: $text = '<span class="LC_success">'.&mt('ok').'</span>';
495: }
496: if ($i == 0) {
497: $result .= $text;
498: } else {
499: $depresult .= $text.'</li>';
500: }
501: }
502: $r->print($result);
503: if ($depresult) {
504: $r->print('<ul>'.$depresult.'</ul>');
505: }
506: }
1.329 droeschl 507: } else {
1.484.2.43 raeburn 508: my ($navmap,$errormsg) =
509: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
510: if (!ref($navmap)) {
511: $r->print($errormsg);
512: } else {
513: $r->print('<div id="searching">'.&mt('Searching ...').'</div>');
514: $r->rflush();
515: my ($preamble,$formname);
516: $formname = 'dumpdoc';
517: unless ($home==1) {
518: $preamble = '<div class="LC_left_float">'.
519: '<fieldset><legend>'.
520: &mt('Select the Authoring Space').
521: '</legend><select name="authorspace">';
522: }
523: my @orderspaces = ();
524: foreach my $key (sort(keys(%outhash))) {
525: if ($key=~/^home_(.+)$/) {
526: if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) {
527: unshift(@orderspaces,$1);
528: } else {
529: push(@orderspaces,$1);
530: }
531: }
532: }
533: if ($home>1) {
534: $preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>';
535: }
536: foreach my $user (@orderspaces) {
537: if ($home==1) {
538: $preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />';
539: } else {
540: $preamble .= '<option value="'.$user.'">'.$user.' - '.
541: &Apache::loncommon::plainname(split(/\:/,$user)).'</option>';
542: }
543: }
544: unless ($home==1) {
545: $preamble .= '</select></fieldset></div>'."\n";
546: }
547: my $title=$origcrsdata{'description'};
548: $title=~s/[\/\s]+/\_/gs;
549: $title=&clean($title);
550: $preamble .= '<div class="LC_left_float">'.
551: '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.
552: '<input type="text" size="50" name="authorfolder" value="'.
553: $title.'" />'.
554: '</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n";
555: my %uploadedfiles;
556: &tiehash();
557: foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
558: my ($ext)=($file=~/\.(\w+)$/);
559: # FIXME Check supplemental here
560: my $title=$hash{'title_'.$hash{
561: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
562: if (!$title) {
563: $title=$file;
564: } else {
565: $title=~s|/|_|g;
566: }
567: $title=~s/\.(\w+)$//;
568: $title=&clean($title);
569: $title.='.'.$ext;
570: # $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
571: $uploadedfiles{$file} = $title;
572: }
573: &untiehash();
574: $r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef,
575: undef,undef,$preamble,$home,\%uploadedfiles));
576: }
1.329 droeschl 577: }
1.484 raeburn 578: $r->print(&endContentScreen());
1.329 droeschl 579: }
580:
1.484.2.43 raeburn 581: sub recurse_html {
582: my ($mm,$prefix,$currdirpath,$currurlpath,$container,$item,$replacehash,$deps) = @_;
583: return unless ((ref($replacehash) eq 'HASH') && (ref($deps) eq 'HASH'));
584: my (%allfiles,%codebase);
585: if (&Apache::lonnet::extract_embedded_items($currdirpath,\%allfiles,\%codebase) eq 'ok') {
586: if (keys(%allfiles)) {
587: foreach my $dependency (keys(%allfiles)) {
588: next if (($dependency =~ m{^/(res|adm)/}) || ($dependency =~ m{^https?://}));
589: my ($depurl,$relfile,$newcontainer);
590: if ($dependency =~ m{^/}) {
591: if ($dependency =~ m{^\Q$currurlpath/\E(.+)$}) {
592: $relfile = $1;
593: if ($dependency =~ m{^\Q$prefix\E(.+)$}) {
594: $newcontainer = $1;
595: next if ($replacehash->{$newcontainer});
596: }
597: $depurl = $dependency;
598: } else {
599: next;
600: }
601: } else {
602: $relfile = $dependency;
603: $depurl = $currurlpath;
604: $depurl =~ s{[^/]+$}{};
605: $depurl .= $dependency;
606: ($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$});
607: }
608: next if ($relfile eq '');
609: my $newname = $replacehash->{$container};
610: $newname =~ s{[^/]+$}{};
611: $replacehash->{$newcontainer} = $newname.$relfile;
612: $deps->{$item}{$newcontainer} = 1;
613: my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$});
614: my $depfile = &Apache::lonnet::filelocation('',$depurl);
615: my $type = $mm->checktype_filename($depfile);
616: if ($type eq 'text/html') {
617: &recurse_html($mm,$prefix,$depfile,$newurlpath,$newcontainer,$item,$replacehash,$deps);
618: }
619: }
620: }
621: }
622: return;
623: }
624:
1.329 droeschl 625: sub group_import {
1.484.2.85.2. (raeburn 626:): my ($coursenum, $coursedom, $folder, $container, $caller, $ltitoolsref, @files) = @_;
1.484.2.23 raeburn 627: my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap,
628: %removeparam,$importuploaded,$fixuperrors);
629: $allmaps = {};
1.329 droeschl 630: while (@files) {
631: my ($name, $url, $residx) = @{ shift(@files) };
1.344 bisitz 632: if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
1.329 droeschl 633: && ($caller eq 'londocs')
634: && (!&Apache::lonnet::stat_file($url))) {
1.364 bisitz 635:
1.329 droeschl 636: my $errtext = '';
637: my $fatal = 0;
638: my $newmapstr = '<map>'."\n".
639: '<resource id="1" src="" type="start"></resource>'."\n".
640: '<link from="1" to="2" index="1"></link>'."\n".
641: '<resource id="2" src="" type="finish"></resource>'."\n".
642: '</map>';
643: $env{'form.output'}=$newmapstr;
644: my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
645: 'output',$1.$2);
1.484.2.27 raeburn 646: if ($result !~ m{^/uploaded/}) {
1.329 droeschl 647: $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
648: $fatal = 2;
649: }
650: if ($fatal) {
651: return ($errtext,$fatal);
652: }
653: }
654: if ($url) {
1.484.2.85.2. (raeburn 655:): if ($url =~ m{^(/adm/$coursedom/$coursenum/(\d+)/ext\.tool)\:?(.*)$}) {
656:): $url = $1;
657:): my $marker = $2;
658:): my $info = $3;
659:): my ($toolid,%toolhash,%toolsettings);
660:): my @extras = ('linktext','explanation','crslabel','crstitle');
661:): my @toolinfo = split(/:/,$info);
662:): if ($residx) {
663:): %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
664:): $toolid = $toolsettings{'id'};
665:): } else {
666:): $toolid = shift(@toolinfo);
667:): }
668:): $toolid =~ s/\D//g;
669:): ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'},
670:): $toolhash{'linktext'},$toolhash{'explanation'},
671:): $toolhash{'crslabel'},$toolhash{'crstitle'}) = @toolinfo;
672:): foreach my $item (@extras) {
673:): $toolhash{$item} = &unescape($toolhash{$item});
674:): }
675:): if (ref($ltitoolsref) eq 'HASH') {
676:): my @deleted;
677:): if (ref($ltitoolsref->{$toolid}) eq 'HASH') {
678:): $toolhash{'id'} = $toolid;
679:): if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'tab') ||
680:): ($toolhash{'target'} eq 'window')) {
681:): if ($toolhash{'target'} eq 'window') {
682:): foreach my $item ('width','height') {
683:): $toolhash{$item} =~ s/^\s+//;
684:): $toolhash{$item} =~ s/\s+$//;
685:): if ($toolhash{$item} =~ /\D/) {
686:): delete($toolhash{$item});
687:): if ($residx) {
688:): if ($toolsettings{$item}) {
689:): push(@deleted,$item);
690:): }
691:): }
692:): }
693:): }
694:): }
695:): } elsif ($residx) {
696:): $toolhash{'target'} = $toolsettings{'target'};
697:): if ($toolhash{'target'} eq 'window') {
698:): foreach my $item ('width','height') {
699:): $toolhash{$item} = $toolsettings{$item};
700:): }
701:): }
702:): } elsif (ref($ltitoolsref->{$toolid}->{'display'}) eq 'HASH') {
703:): $toolhash{'target'} = $ltitoolsref->{$toolid}->{'display'}->{'target'};
704:): if ($toolhash{'target'} eq 'window') {
705:): $toolhash{'width'} = $ltitoolsref->{$toolid}->{'display'}->{'width'};
706:): $toolhash{'height'} = $ltitoolsref->{$toolid}->{'display'}->{'height'};
707:): }
708:): }
709:): if ($toolhash{'target'} eq 'iframe') {
710:): foreach my $item ('width','height','linktext','explanation') {
711:): delete($toolhash{$item});
712:): if ($residx) {
713:): if ($toolsettings{$item}) {
714:): push(@deleted,$item);
715:): }
716:): }
717:): }
718:): } elsif ($toolhash{'target'} eq 'tab') {
719:): foreach my $item ('width','height') {
720:): delete($toolhash{$item});
721:): if ($residx) {
722:): if ($toolsettings{$item}) {
723:): push(@deleted,$item);
724:): }
725:): }
726:): }
727:): }
728:): if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') {
729:): foreach my $item ('label','title','linktext','explanation') {
730:): my $crsitem;
731:): if (($item eq 'label') || ($item eq 'title')) {
732:): $crsitem = 'crs'.$item;
733:): } else {
734:): $crsitem = $item;
735:): }
736:): if ($ltitoolsref->{$toolid}->{'crsconf'}->{$item}) {
737:): $toolhash{$crsitem} =~ s/^\s+//;
738:): $toolhash{$crsitem} =~ s/\s+$//;
739:): if ($toolhash{$crsitem} eq '') {
740:): delete($toolhash{$crsitem});
741:): }
742:): } else {
743:): delete($toolhash{$crsitem});
744:): }
745:): if (($residx) && (exists($toolsettings{$crsitem}))) {
746:): unless (exists($toolhash{$crsitem})) {
747:): push(@deleted,$crsitem);
748:): }
749:): }
750:): }
751:): }
752:): my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum);
753:): if ($putres eq 'ok') {
754:): if (@deleted) {
755:): &Apache::lonnet::del('exttool_'.$marker,\@deleted,$coursedom,$coursenum);
756:): }
757:): }
758:): }
759:): }
760:): }
1.484.2.23 raeburn 761: if (($caller eq 'londocs') &&
762: ($folder =~ /^default/)) {
1.484.2.27 raeburn 763: if (($url =~ /\.(page|sequence)$/) && (!$donechk)) {
1.484.2.23 raeburn 764: my $chome = &Apache::lonnet::homeserver($coursenum,$coursedom);
765: my $cid = $coursedom.'_'.$coursenum;
766: $allmaps =
767: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
768: $chome,$cid);
769: $donechk = 1;
770: }
771: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) {
1.484.2.85.2. (raeburn 772:): &contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap,
773:): \%removeparam,\%addedmaps,\%hierarchy,\%titles,$allmaps);
1.484.2.23 raeburn 774: $importuploaded = 1;
775: } elsif ($url =~ m{^/res/.+\.(page|sequence)$}) {
776: next if ($allmaps->{$url});
777: }
778: }
1.344 bisitz 779: if (!$residx
1.329 droeschl 780: || defined($LONCAPA::map::zombies[$residx])) {
781: $residx = &LONCAPA::map::getresidx($url,$residx);
782: push(@LONCAPA::map::order, $residx);
783: }
784: my $ext = 'false';
785: if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
786: $name = &LONCAPA::map::qtunescape($name);
1.484.2.27 raeburn 787: if ($name eq '') {
1.484.2.30 raeburn 788: $name = &LONCAPA::map::qtunescape(&mt('Web Page'));
1.484.2.27 raeburn 789: }
790: if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) {
791: my $filepath = $1;
792: my $fname = $name;
793: if ($fname =~ /^\W+$/) {
794: $fname = 'web';
795: } else {
796: $fname =~ s/\W/_/g;
797: }
1.484.2.62 raeburn 798: if (length($fname) > 15) {
1.484.2.27 raeburn 799: $fname = substr($fname,0,14);
800: }
801: my $initialtext = &mt('Replace with your own content.');
802: my $newhtml = <<END;
1.484.2.31 raeburn 803: <html>
1.484.2.27 raeburn 804: <head>
805: <title>$name</title>
806: </head>
807: <body bgcolor="#ffffff">
808: $initialtext
809: </body>
810: </html>
811: END
812: $env{'form.output'}=$newhtml;
813: my $result =
814: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
815: 'output',
816: "$filepath/$residx/$fname.html");
817: if ($result =~ m{^/uploaded/}) {
818: $url = $result;
819: if ($filepath =~ /^supplemental/) {
820: $name = time.'___&&&___'.$env{'user.name'}.'___&&&___'.
821: $env{'user.domain'}.'___&&&___'.$name;
822: }
823: } else {
824: return (&mt('Failed to save new web page.'),1);
825: }
826: }
1.484.2.30 raeburn 827: $url = &LONCAPA::map::qtunescape($url);
1.344 bisitz 828: $LONCAPA::map::resources[$residx] =
1.329 droeschl 829: join(':', ($name, $url, $ext, 'normal', 'res'));
830: }
831: }
1.484.2.23 raeburn 832: if ($importuploaded) {
833: my %import_errors;
834: my %updated = (
835: removefrommap => \%removefrommap,
836: removeparam => \%removeparam,
837: );
1.484.2.26 raeburn 838: my ($result,$msgsarray,$lockerror) =
839: &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
1.484.2.23 raeburn 840: if (keys(%import_errors) > 0) {
841: $fixuperrors =
842: '<p span class="LC_warning">'."\n".
843: &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".
844: '<ul>'."\n";
845: foreach my $key (sort(keys(%import_errors))) {
846: $fixuperrors .= '<li>'.$key.'</li>'."\n";
847: }
848: $fixuperrors .= '</ul></p>'."\n";
849: }
1.484.2.26 raeburn 850: if (ref($msgsarray) eq 'ARRAY') {
851: if (@{$msgsarray} > 0) {
852: $fixuperrors .= '<p class="LC_info">'.
853: join('<br />',@{$msgsarray}).
854: '</p>';
855: }
856: }
857: if ($lockerror) {
858: $fixuperrors .= '<p class="LC_error">'.
859: $lockerror.
860: '</p>';
861: }
1.484.2.23 raeburn 862: }
863: my ($errtext,$fatal) =
864: &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
1.484.2.37 raeburn 865: unless ($fatal) {
866: if ($folder =~ /^supplemental/) {
867: &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
1.484.2.39 raeburn 868: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
869: $folder.'.'.$container);
1.484.2.37 raeburn 870: }
871: }
1.484.2.23 raeburn 872: return ($errtext,$fatal,$fixuperrors);
1.329 droeschl 873: }
874:
875: sub log_docs {
1.484.2.8 raeburn 876: return &Apache::lonnet::write_log('course','docslog',@_);
1.329 droeschl 877: }
878:
879: {
880: my @oldresources=();
881: my @oldorder=();
882: my $parmidx;
883: my %parmaction=();
884: my %parmvalue=();
885: my $changedflag;
886:
887: sub snapshotbefore {
888: @oldresources=@LONCAPA::map::resources;
889: @oldorder=@LONCAPA::map::order;
890: $parmidx=undef;
891: %parmaction=();
892: %parmvalue=();
893: $changedflag=0;
894: }
895:
896: sub remember_parms {
897: my ($idx,$parameter,$action,$value)=@_;
898: $parmidx=$idx;
899: $parmaction{$parameter}=$action;
900: $parmvalue{$parameter}=$value;
901: $changedflag=1;
902: }
903:
904: sub log_differences {
905: my ($plain)=@_;
906: my %storehash=('folder' => $plain,
907: 'currentfolder' => $env{'form.folder'});
908: if ($parmidx) {
909: $storehash{'parameter_res'}=$oldresources[$parmidx];
910: foreach my $parm (keys(%parmaction)) {
911: $storehash{'parameter_action_'.$parm}=$parmaction{$parm};
912: $storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
913: }
914: }
915: my $maxidx=$#oldresources;
916: if ($#LONCAPA::map::resources>$#oldresources) {
917: $maxidx=$#LONCAPA::map::resources;
918: }
919: for (my $idx=0; $idx<=$maxidx; $idx++) {
920: if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
921: $storehash{'before_resources_'.$idx}=$oldresources[$idx];
922: $storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
923: $changedflag=1;
924: }
925: if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
926: $storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
927: $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
928: $changedflag=1;
929: }
930: }
931: $storehash{'maxidx'}=$maxidx;
932: if ($changedflag) { &log_docs(\%storehash); }
933: }
934: }
935:
936: sub docs_change_log {
1.484.2.67 raeburn 937: my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit)=@_;
1.484.2.6 raeburn 938: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
1.484.2.67 raeburn 939: my $navmap;
1.483 raeburn 940: my $js = '<script type="text/javascript">'."\n".
941: '// <![CDATA['."\n".
942: &Apache::loncommon::display_filter_js('docslog')."\n".
1.484.2.67 raeburn 943: &editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag,
1.484.2.85.2. (raeburn 944:): $coursedom,$coursenum,'',$canedit,'',\$navmap)."\n".
1.483 raeburn 945: &history_tab_js()."\n".
1.484 raeburn 946: &Apache::lonratedt::editscript('simple')."\n".
1.483 raeburn 947: '// ]]>'."\n".
948: '</script>'."\n";
1.484 raeburn 949: $r->print(&Apache::loncommon::start_page('Content Change Log',$js));
950: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Change Log'));
1.484.2.7 raeburn 951: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484 raeburn 952: my %orderhash;
953: my $container='sequence';
954: my $pathitem;
1.484.2.19 raeburn 955: if ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 956: $container='page';
957: }
1.484.2.19 raeburn 958: my $folderpath=$env{'form.folderpath'};
959: if ($folderpath eq '') {
1.484.2.67 raeburn 960: $folderpath = &default_folderpath($coursenum,$coursedom,\$navmap);
1.484.2.19 raeburn 961: }
1.484.2.67 raeburn 962: undef($navmap);
1.484.2.19 raeburn 963: $pathitem = '<input type="hidden" name="folderpath" value="'.
964: &HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 965: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
966: my $jumpto = $readfile;
967: $jumpto =~ s{^/}{};
968: my $tid = 1;
1.484.2.7 raeburn 969: if ($supplementalflag) {
970: $tid = 2;
971: }
1.484.2.19 raeburn 972: my ($breadcrumbtrail) =
1.484.2.18 raeburn 973: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
1.484 raeburn 974: $r->print($breadcrumbtrail.
975: &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto,
976: $readfile));
1.329 droeschl 977: my %docslog=&Apache::lonnet::dump('nohist_docslog',
978: $env{'course.'.$env{'request.course.id'}.'.domain'},
979: $env{'course.'.$env{'request.course.id'}.'.num'});
980:
981: if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
982:
983: my %saveable_parameters = ('show' => 'scalar',);
984: &Apache::loncommon::store_course_settings('docs_log',
985: \%saveable_parameters);
986: &Apache::loncommon::restore_course_settings('docs_log',
987: \%saveable_parameters);
988: if (!$env{'form.show'}) { $env{'form.show'}=10; }
1.452 www 989: # FIXME: internationalization seems wrong here
1.329 droeschl 990: my %lt=('hiddenresource' => 'Resources hidden',
991: 'encrypturl' => 'URL hidden',
992: 'randompick' => 'Randomly pick',
993: 'randomorder' => 'Randomly ordered',
994: 'set' => 'set to',
995: 'del' => 'deleted');
1.484 raeburn 996: my $filter = &Apache::loncommon::display_filter('docslog')."\n".
997: $pathitem."\n".
998: '<input type="hidden" name="folder" value="'.$env{'form.folder'}.'" />'.
999: (' 'x2).'<input type="submit" value="'.&mt('Display').'" />';
1000: $r->print('<div class="LC_left_float">'.
1001: '<fieldset><legend>'.&mt('Display of Content Changes').'</legend>'."\n".
1002: &makedocslogform($filter,1).
1003: '</fieldset></div><br clear="all" />');
1.329 droeschl 1004: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
1005: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
1006: &mt('After').'</th>'.
1007: &Apache::loncommon::end_data_table_header_row());
1008: my $shown=0;
1009: foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
1010: if ($env{'form.displayfilter'} eq 'currentfolder') {
1011: if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
1012: }
1013: my @changes=keys(%{$docslog{$id}{'logentry'}});
1014: if ($env{'form.displayfilter'} eq 'containing') {
1015: my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
1016: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
1017: foreach my $key (@changes) {
1018: $wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
1019: }
1.344 bisitz 1020: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
1.329 droeschl 1021: }
1022: my $count = 0;
1023: my $time =
1024: &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
1025: my $plainname =
1026: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
1027: $docslog{$id}{'exe_udom'});
1028: my $about_me_link =
1029: &Apache::loncommon::aboutmewrapper($plainname,
1030: $docslog{$id}{'exe_uname'},
1031: $docslog{$id}{'exe_udom'});
1032: my $send_msg_link='';
1033: if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
1034: || ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
1035: $send_msg_link ='<br />'.
1036: &Apache::loncommon::messagewrapper(&mt('Send message'),
1037: $docslog{$id}{'exe_uname'},
1038: $docslog{$id}{'exe_udom'});
1039: }
1040: $r->print(&Apache::loncommon::start_data_table_row());
1041: $r->print('<td>'.$time.'</td>
1042: <td>'.$about_me_link.
1043: '<br /><tt>'.$docslog{$id}{'exe_uname'}.
1044: ':'.$docslog{$id}{'exe_udom'}.'</tt>'.
1045: $send_msg_link.'</td><td>'.
1046: $docslog{$id}{'logentry'}{'folder'}.'</td><td>');
1.484.2.19 raeburn 1047: my $is_supp = 0;
1.484.2.7 raeburn 1048: if ($docslog{$id}{'logentry'}{'currentfolder'} =~ /^supplemental/) {
1049: $is_supp = 1;
1050: }
1.329 droeschl 1051: # Before
1052: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1053: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
1054: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
1055: if ($oldname ne $newname) {
1.484.2.7 raeburn 1056: my $shown = &LONCAPA::map::qtescape($oldname);
1057: if ($is_supp) {
1058: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1059: }
1060: $r->print($shown);
1.329 droeschl 1061: }
1062: }
1063: $r->print('<ul>');
1064: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1065: if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
1.484.2.7 raeburn 1066: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]);
1067: if ($is_supp) {
1068: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1069: }
1.484.2.19 raeburn 1070: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 1071: }
1072: }
1073: $r->print('</ul>');
1074: # After
1075: $r->print('</td><td>');
1076:
1077: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1078: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
1079: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
1080: if ($oldname ne '' && $oldname ne $newname) {
1.484.2.7 raeburn 1081: my $shown = &LONCAPA::map::qtescape($newname);
1082: if ($is_supp) {
1083: $shown = &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($newname));
1084: }
1085: $r->print($shown);
1.329 droeschl 1086: }
1.364 bisitz 1087: }
1.329 droeschl 1088: $r->print('<ul>');
1089: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1090: if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
1.484.2.7 raeburn 1091: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]);
1092: if ($is_supp) {
1093: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1094: }
1095: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 1096: }
1097: }
1098: $r->print('</ul>');
1099: if ($docslog{$id}{'logentry'}{'parameter_res'}) {
1100: $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
1101: foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
1102: if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
1.452 www 1103: # FIXME: internationalization seems wrong here
1.329 droeschl 1104: $r->print('<li>'.
1105: &mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
1106: $docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
1107: .'</li>');
1108: }
1109: }
1110: $r->print('</ul>');
1111: }
1112: # End
1113: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1114: $shown++;
1115: if (!($env{'form.show'} eq &mt('all')
1116: || $shown<=$env{'form.show'})) { last; }
1117: }
1.484 raeburn 1118: $r->print(&Apache::loncommon::end_data_table()."\n".
1119: &makesimpleeditform($pathitem)."\n".
1120: '</div></div>');
1121: $r->print(&endContentScreen());
1.329 droeschl 1122: }
1123:
1124: sub update_paste_buffer {
1.484.2.7 raeburn 1125: my ($coursenum,$coursedom,$folder) = @_;
1.484.2.57 raeburn 1126: my (@possibles,%removals,%cuts,$output);
1.484.2.30 raeburn 1127: if ($env{'form.multiremove'}) {
1128: $env{'form.multiremove'} =~ s/,$//;
1129: map { $removals{$_} = 1; } split(/,/,$env{'form.multiremove'});
1130: }
1131: if (($env{'form.multicopy'}) || ($env{'form.multicut'})) {
1132: if ($env{'form.multicut'}) {
1133: $env{'form.multicut'} =~ s/,$//;
1134: foreach my $item (split(/,/,$env{'form.multicut'})) {
1135: unless ($removals{$item}) {
1136: $cuts{$item} = 1;
1137: push(@possibles,$item.':cut');
1138: }
1139: }
1140: }
1141: if ($env{'form.multicopy'}) {
1142: $env{'form.multicopy'} =~ s/,$//;
1143: foreach my $item (split(/,/,$env{'form.multicopy'})) {
1144: unless ($removals{$item} || $cuts{$item}) {
1145: push(@possibles,$item.':copy');
1146: }
1147: }
1148: }
1149: } elsif ($env{'form.markcopy'}) {
1150: @possibles = split(/,/,$env{'form.markcopy'});
1151: }
1.329 droeschl 1152:
1.484.2.30 raeburn 1153: return if (@possibles == 0);
1.329 droeschl 1154: return if (!defined($env{'form.copyfolder'}));
1155:
1156: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1157: $env{'form.copyfolder'});
1158: return if ($fatal);
1159:
1.484.2.30 raeburn 1160: my %curr_groups = &Apache::longroup::coursegroups();
1161:
1162: # Retrieve current paste buffer suffixes.
1163: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1164: my (%pasteurls,@newpaste);
1165:
1166: # Construct identifiers for current contents of user's paste buffer
1167: if (@currpaste) {
1168: foreach my $suffix (@currpaste) {
1169: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1170: my $url = $env{'docs.markedcopy_url_'.$suffix};
1.484.2.82 raeburn 1171: my $mapidx = $env{'docs.markedcopy_map_'.$suffix};
1.484.2.30 raeburn 1172: if (($cid =~ /^$match_domain(?:_)$match_courseid$/) &&
1173: ($url ne '')) {
1.484.2.82 raeburn 1174: $pasteurls{$cid.'_'.$url.'_'.$mapidx} = 1;
1.484.2.30 raeburn 1175: }
1176: }
1177: }
1178:
1179: # Mark items for copying (skip any items already in user's paste buffer)
1180: my %addtoenv;
1.484.2.82 raeburn 1181:
1182: my @pathitems = split(/\&/,$env{'form.folderpath'});
1183: my @folderconf = split(/\:/,$pathitems[-1]);
1184: my $ispage = $folderconf[4];
1185:
1.484.2.30 raeburn 1186: foreach my $item (@possibles) {
1187: my ($orderidx,$cmd) = split(/:/,$item);
1188: next if ($orderidx =~ /\D/);
1189: next unless (($cmd eq 'cut') || ($cmd eq 'copy') || ($cmd eq 'remove'));
1.484.2.82 raeburn 1190: my $mapidx = $folder.':'.$orderidx.':'.$ispage;
1.484.2.30 raeburn 1191: my ($title,$url)=split(':',$LONCAPA::map::resources[$orderidx]);
1192: my %denied = &action_restrictions($coursenum,$coursedom,
1193: &LONCAPA::map::qtescape($url),
1194: $env{'form.folderpath'},\%curr_groups);
1195: next if ($denied{'copy'});
1196: $url=~s{http(:|:)//https(:|:)//}{https$2//};
1.484.2.82 raeburn 1197: next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$mapidx}));
1.484.2.30 raeburn 1198: my ($suffix,$errortxt,$locknotfreed) =
1199: &new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste');
1.484.2.57 raeburn 1200: if ($suffix ne '') {
1201: push(@newpaste,$suffix);
1202: } else {
1203: if ($locknotfreed) {
1204: return $locknotfreed;
1205: }
1.484.2.30 raeburn 1206: }
1207: if (&is_supplemental_title($title)) {
1208: &Apache::lonnet::appenv({'docs.markedcopy_supplemental_'.$suffix => $title});
1209: ($title) = &Apache::loncommon::parse_supplemental_title($title);
1210: }
1211:
1212: $addtoenv{'docs.markedcopy_title_'.$suffix} = $title,
1213: $addtoenv{'docs.markedcopy_url_'.$suffix} = $url,
1214: $addtoenv{'docs.markedcopy_cmd_'.$suffix} = $cmd,
1215: $addtoenv{'docs.markedcopy_crs_'.$suffix} = $env{'request.course.id'};
1.484.2.82 raeburn 1216: $addtoenv{'docs.markedcopy_map_'.$suffix} = $mapidx;
1.484.2.30 raeburn 1217: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) {
1218: my $prefix = $1;
1219: my $subdir =$2;
1220: if ($subdir eq '') {
1221: $subdir = $prefix;
1.484.2.7 raeburn 1222: }
1.484.2.30 raeburn 1223: my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps);
1.484.2.85.2. (raeburn 1224:): &contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap,
1225:): \%removeparam,\%addedmaps,\%hierarchy,\%titles,\%allmaps);
1.484.2.30 raeburn 1226: if (ref($hierarchy{$url}) eq 'HASH') {
1227: my ($nested,$nestednames);
1228: &recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames);
1229: $nested =~ s/\&$//;
1230: $nestednames =~ s/\Q___&&&___\E$//;
1231: if ($nested ne '') {
1232: $addtoenv{'docs.markedcopy_nested_'.$suffix} = $nested;
1233: }
1234: if ($nestednames ne '') {
1235: $addtoenv{'docs.markedcopy_nestednames_'.$suffix} = $nestednames;
1236: }
1.484.2.7 raeburn 1237: }
1238: }
1.484.2.57 raeburn 1239: if ($locknotfreed) {
1240: $output = $locknotfreed;
1241: last;
1242: }
1.484.2.7 raeburn 1243: }
1.484.2.30 raeburn 1244: if (@newpaste) {
1245: $addtoenv{'docs.markedcopies'} = join(',',(@currpaste,@newpaste));
1246: }
1.484.2.7 raeburn 1247: &Apache::lonnet::appenv(\%addtoenv);
1.329 droeschl 1248: delete($env{'form.markcopy'});
1.484.2.57 raeburn 1249: return $output;
1.329 droeschl 1250: }
1251:
1.484.2.7 raeburn 1252: sub recurse_uploaded_maps {
1253: my ($url,$dir,$hierarchy,$titlesref,$nestref,$namesref) = @_;
1254: if (ref($hierarchy->{$url}) eq 'HASH') {
1255: my @maps = map { $hierarchy->{$url}{$_}; } sort { $a <=> $b } (keys(%{$hierarchy->{$url}}));
1256: my @titles = map { $titlesref->{$url}{$_}; } sort { $a <=> $b } (keys(%{$titlesref->{$url}}));
1257: my (@uploaded,@names,%shorter);
1258: for (my $i=0; $i<@maps; $i++) {
1259: my ($inner) = ($maps[$i] =~ m{^/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_(\d+)\.(?:page|sequence)$});
1260: if ($inner ne '') {
1261: push(@uploaded,$inner);
1262: push(@names,&escape($titles[$i]));
1263: $shorter{$maps[$i]} = $inner;
1264: }
1265: }
1266: $$nestref .= "$dir:".join(',',@uploaded).'&';
1267: $$namesref .= "$dir:".(join(',',@names)).'___&&&___';
1268: foreach my $map (@maps) {
1269: if ($shorter{$map} ne '') {
1270: &recurse_uploaded_maps($map,$shorter{$map},$hierarchy,$titlesref,$nestref,$namesref);
1271: }
1272: }
1273: }
1274: return;
1275: }
1276:
1.329 droeschl 1277: sub print_paste_buffer {
1.484.2.7 raeburn 1278: my ($r,$container,$folder,$coursedom,$coursenum) = @_;
1.484.2.30 raeburn 1279: return if (!defined($env{'docs.markedcopies'}));
1.329 droeschl 1280:
1.484.2.30 raeburn 1281: unless (($env{'form.pastemarked'}) || ($env{'form.clearmarked'})) {
1282: return if ($env{'docs.markedcopies'} eq '');
1.484.2.7 raeburn 1283: }
1284:
1.484.2.30 raeburn 1285: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1286: my ($pasteitems,@pasteable);
1.484.2.47 raeburn 1287: my $clipboardcount = 0;
1.484.2.7 raeburn 1288:
1.484.2.30 raeburn 1289: # Construct identifiers for current contents of user's paste buffer
1290: foreach my $suffix (@currpaste) {
1291: next if ($suffix =~ /\D/);
1292: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1293: my $url = $env{'docs.markedcopy_url_'.$suffix};
1.484.2.82 raeburn 1294: my $mapidx = $env{'docs.markedcopy_map_'.$suffix};
1.484.2.30 raeburn 1295: if (($cid =~ /^$match_domain\_$match_courseid$/) &&
1296: ($url ne '')) {
1.484.2.47 raeburn 1297: $clipboardcount ++;
1.484.2.30 raeburn 1298: my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent,
1.484.2.85.2. (raeburn 1299:): $canpaste,$nopaste,$othercrs,$areachange,$is_exttool);
1.484.2.30 raeburn 1300: my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1];
1301: if ($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
1302: $is_external = 1;
1.484.2.85.2. (raeburn 1303:): } elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$}) {
1304:): $is_exttool = 1;
1.484.2.7 raeburn 1305: }
1.484.2.30 raeburn 1306: if ($folder =~ /^supplemental/) {
1307: $canpaste = &supp_pasteable($env{'docs.markedcopy_url_'.$suffix});
1308: unless ($canpaste) {
1309: $nopaste = &mt('Paste into Supplemental Content unavailable.');
1.484.2.7 raeburn 1310: }
1.484.2.30 raeburn 1311: } else {
1312: $canpaste = 1;
1.484.2.7 raeburn 1313: }
1.484.2.30 raeburn 1314: if ($canpaste) {
1315: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1316: my $srcdom = $1;
1317: my $srcnum = $2;
1318: my $rem = $3;
1319: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
1320: $othercourse = 1;
1321: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1.484.2.76 raeburn 1322: $othercrs = '<br />'.&mt('(from another course)');
1.484.2.30 raeburn 1323: } else {
1324: $canpaste = 0;
1325: $nopaste = &mt('Paste from another course unavailable.');
1.484.2.7 raeburn 1326: }
1327: }
1.484.2.30 raeburn 1328: if ($rem =~ m{^(default|supplemental)_?(\d*)\.(?:page|sequence)$}) {
1329: my $prefix = $1;
1330: $parent = $2;
1331: if ($folder !~ /^\Q$prefix\E/) {
1332: $areachange = 1;
1333: }
1334: $is_uploaded_map = 1;
1335: }
1.484.2.82 raeburn 1336: } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
1.484.2.85.2. (raeburn 1337:): ($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg|ext\.tool)$})) {
1.484.2.76 raeburn 1338: if ($cid ne $env{'request.course.id'}) {
1339: my ($srcdom,$srcnum) = split(/_/,$cid);
1340: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1.484.2.85.2. (raeburn 1341:): if (($is_exttool) && ($srcdom ne $coursedom)) {
1342:): $canpaste = 0;
1343:): $nopaste = &mt('Paste from another domain unavailable.');
1344:): } else {
1345:): $othercrs = '<br />'.&mt('(from another course)');
1346:): }
1.484.2.76 raeburn 1347: } else {
1348: $canpaste = 0;
1349: $nopaste = &mt('Paste from another course unavailable.');
1350: }
1351: }
1352: }
1353: if ($canpaste) {
1354: push(@pasteable,$suffix);
1.484.2.30 raeburn 1355: }
1356: }
1357: my $buffer;
1358: if ($is_external) {
1359: $buffer = &mt('External Resource').': '.
1360: &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('.
1361: &LONCAPA::map::qtescape($url).')';
1.484.2.85.2. (raeburn 1362:): } elsif ($is_exttool) {
1363:): $buffer = &mt('External Tool').': '.
1364:): &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.484.2.30 raeburn 1365: } else {
1366: my $icon = &Apache::loncommon::icon($extension);
1367: if ($extension eq 'sequence' &&
1368: $url =~ m{/default_\d+\.sequence$}x) {
1369: $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
1370: $icon .= '/navmap.folder.closed.gif';
1371: }
1.484.2.57 raeburn 1372: my $title = $env{'docs.markedcopy_title_'.$suffix};
1373: if ($title eq '') {
1374: ($title) = ($url =~ m{/([^/]+)$});
1375: }
1.484.2.30 raeburn 1376: $buffer = '<img src="'.$icon.'" alt="" class="LC_icon" />'.
1377: ': '.
1378: &Apache::loncommon::parse_supplemental_title(
1.484.2.57 raeburn 1379: &LONCAPA::map::qtescape($title));
1.484.2.30 raeburn 1380: }
1381: $pasteitems .= '<div class="LC_left_float">';
1382: my ($options,$onclick);
1383: if (($canpaste) && (!$areachange) && (!$othercourse) &&
1384: ($env{'docs.markedcopy_cmd_'.$suffix} eq 'cut')) {
1385: if (($is_uploaded_map) ||
1386: ($url =~ /(bulletinboard|smppg)$/) ||
1387: ($url =~ m{^/uploaded/$coursedom/$coursenum/(?:docs|supplemental)/(.+)$})) {
1388: $options = &paste_options($suffix,$is_uploaded_map,$parent);
1389: $onclick= 'onclick="showOptions(this,'."'$suffix'".');" ';
1390: }
1391: }
1392: $pasteitems .= '<label><input type="checkbox" name="pasting" id="pasting_'.$suffix.'" value="'.$suffix.'" '.$onclick.'/>'.$buffer.'</label>';
1393: if ($nopaste) {
1394: $pasteitems .= $nopaste;
1395: } else {
1396: if ($othercrs) {
1397: $pasteitems .= $othercrs;
1398: }
1399: if ($options) {
1400: $pasteitems .= $options;
1.484.2.7 raeburn 1401: }
1402: }
1.484.2.30 raeburn 1403: $pasteitems .= '</div>';
1404: }
1405: }
1406: if ($pasteitems eq '') {
1407: &Apache::lonnet::delenv('docs.markedcopies');
1408: }
1409: my ($pasteform,$form_start,$buttons,$form_end);
1410: if ($pasteitems) {
1411: $pasteitems .= '<div style="padding:0;clear:both;margin:0;border:0"></div>';
1412: $form_start = '<form name="pasteform" action="/adm/coursedocs" method="post" onsubmit="return validateClipboard();">';
1413: if (@pasteable) {
1.484.2.47 raeburn 1414: my $value = &mt('Paste to current folder');
1415: if ($container eq 'page') {
1416: $value = &mt('Paste to current page');
1417: }
1418: $buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.(' 'x2);
1419: }
1.484.2.85.2. (raeburn 1420:): $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.(' 'x2);
1.484.2.47 raeburn 1421: if ($clipboardcount > 1) {
1422: $buttons .=
1423: '<span style="text-decoration:line-through">'.(' 'x20).'</span>'.(' 'x2).
1424: '<input type="button" name="checkallclip" value="'.&mt('Check all').'" style="height:20px;" onclick="checkClipboard();" />'.
1425: (' 'x2).
1426: '<input type="button" name="uncheckallclip" value="'.&mt('Uncheck all').'" style="height:20px;" onclick="uncheckClipboard();" />'.
1427: (' 'x2);
1.484.2.7 raeburn 1428: }
1.484.2.48 raeburn 1429: $form_end = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'.
1430: '</form>';
1.484.2.30 raeburn 1431: } else {
1432: $pasteitems = &mt('Clipboard is empty');
1433: }
1434: $r->print($form_start
1435: .'<fieldset>'
1436: .'<legend>'.&mt('Clipboard').(' ' x2).$buttons.'</legend>'
1437: .$pasteitems
1438: .'</fieldset>'
1439: .$form_end);
1440: }
1441:
1442: sub paste_options {
1443: my ($suffix,$is_uploaded_map,$parent) = @_;
1444: my ($copytext,$movetext);
1445: if ($is_uploaded_map) {
1446: $copytext = &mt('Copy to new folder');
1447: $movetext = &mt('Move old');
1448: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /bulletinboard$/) {
1449: $copytext = &mt('Copy to new board');
1450: $movetext = &mt('Move (not posts)');
1451: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /smppg$/) {
1452: $copytext = &mt('Copy to new page');
1453: $movetext = &mt('Move');
1.484.2.7 raeburn 1454: } else {
1.484.2.30 raeburn 1455: $copytext = &mt('Copy to new file');
1456: $movetext = &mt('Move');
1457: }
1458: my $output = '<br />'.
1459: '<span id="pasteoptionstext_'.$suffix.'" class="LC_fontsize_small LC_nobreak"></span>'.
1460: '<div id="pasteoptions_'.$suffix.'" class="LC_dccid" style="display:none;"><span class="LC_nobreak">'.(' 'x 4).
1461: '<label>'.
1462: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="new" checked="checked" />'.
1463: $copytext.'</label></span>'.(' 'x2).' '.
1464: '<span class="LC_nobreak"><label>'.
1465: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="move" />'.
1466: $movetext.'</label></span>';
1467: if (($is_uploaded_map) && ($env{'docs.markedcopy_nested_'.$suffix})) {
1468: $output .= '<br /><fieldset><legend>'.&mt('Folder to paste contains sub-folders').
1469: '</legend><table border="0">';
1470: my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1471: my @titles = split(/\Q___&&&___\E/,$env{'docs.markedcopy_nestednames_'.$suffix});
1472: my $lastdir = $parent;
1473: my %depths = (
1474: $lastdir => 0,
1475: );
1476: my (%display,%deps);
1477: for (my $i=0; $i<@pastemaps; $i++) {
1478: ($lastdir,my $subfolderstr) = split(/\:/,$pastemaps[$i]);
1479: my ($namedir,$esctitlestr) = split(/\:/,$titles[$i]);
1480: my @subfolders = split(/,/,$subfolderstr);
1481: $deps{$lastdir} = \@subfolders;
1482: my @subfoldertitles = map { &unescape($_); } split(/,/,$esctitlestr);
1483: my $depth = $depths{$lastdir} + 1;
1484: my $offset = int($depth * 4);
1485: my $indent = (' ' x $offset);
1486: for (my $j=0; $j<@subfolders; $j++) {
1487: $depths{$subfolders[$j]} = $depth;
1488: $display{$subfolders[$j]} =
1489: '<tr><td>'.$indent.$subfoldertitles[$j].' </td>'.
1490: '<td><label>'.
1491: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="new" checked="checked" />'.&mt('Copy to new').'</label>'.(' ' x2).
1492: '<label>'.
1493: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="move" />'.
1494: &mt('Move old').'</label>'.
1495: '</td></tr>';
1496: }
1497: }
1498: &recurse_print(\$output,$parent,\%deps,\%display);
1499: $output .= '</table></fieldset>';
1.329 droeschl 1500: }
1.484.2.30 raeburn 1501: $output .= '</div>';
1502: return $output;
1.329 droeschl 1503: }
1504:
1.484.2.7 raeburn 1505: sub recurse_print {
1.484.2.30 raeburn 1506: my ($outputref,$dir,$deps,$display) = @_;
1507: $$outputref .= $display->{$dir}."\n";
1.484.2.7 raeburn 1508: if (ref($deps->{$dir}) eq 'ARRAY') {
1509: foreach my $subdir (@{$deps->{$dir}}) {
1.484.2.30 raeburn 1510: &recurse_print($outputref,$subdir,$deps,$display);
1.484.2.7 raeburn 1511: }
1512: }
1513: }
1514:
1515: sub supp_pasteable {
1516: my ($url) = @_;
1517: if (($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//}) ||
1518: (($url =~ /\.sequence$/) && ($url =~ m{^/uploaded/})) ||
1519: ($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) ||
1520: ($url =~ m{^/adm/$match_domain/$match_username/aboutme}) ||
1.484.2.85.2. (raeburn 1521:): ($url =~ m{^/public/$match_domain/$match_courseid/syllabus}) ||
1522:): ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$})) {
1.484.2.7 raeburn 1523: return 1;
1524: }
1525: return;
1526: }
1527:
1528: sub paste_popup_js {
1.484.2.61 raeburn 1529: my %html_js_lt = &Apache::lonlocal::texthash(
1.484.2.30 raeburn 1530: show => 'Show Options',
1531: hide => 'Hide Options',
1.484.2.61 raeburn 1532: );
1533: my %js_lt = &Apache::lonlocal::texthash(
1.484.2.30 raeburn 1534: none => 'No items selected from clipboard.',
1.484.2.7 raeburn 1535: );
1.484.2.61 raeburn 1536: &html_escape(\%html_js_lt);
1537: &js_escape(\%html_js_lt);
1538: &js_escape(\%js_lt);
1.484.2.7 raeburn 1539: return <<"END";
1540:
1.484.2.30 raeburn 1541: function showPasteOptions(suffix) {
1542: document.getElementById('pasteoptions_'+suffix).style.display='block';
1.484.2.61 raeburn 1543: document.getElementById('pasteoptionstext_'+suffix).innerHTML = ' <a href="javascript:hidePasteOptions(\\''+suffix+'\\');" class="LC_menubuttons_link">$html_js_lt{'hide'}</a>';
1.484.2.7 raeburn 1544: return;
1545: }
1546:
1.484.2.30 raeburn 1547: function hidePasteOptions(suffix) {
1548: document.getElementById('pasteoptions_'+suffix).style.display='none';
1.484.2.61 raeburn 1549: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.484.2.7 raeburn 1550: return;
1551: }
1552:
1.484.2.30 raeburn 1553: function showOptions(caller,suffix) {
1554: if (document.getElementById('pasteoptionstext_'+suffix)) {
1555: if (caller.checked) {
1.484.2.61 raeburn 1556: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.484.2.30 raeburn 1557: } else {
1558: document.getElementById('pasteoptionstext_'+suffix).innerHTML ='';
1559: }
1560: if (document.getElementById('pasteoptions_'+suffix)) {
1561: document.getElementById('pasteoptions_'+suffix).style.display='none';
1562: }
1563: }
1564: return;
1565: }
1.484.2.7 raeburn 1566:
1.484.2.30 raeburn 1567: function validateClipboard() {
1568: var numchk = 0;
1569: if (document.pasteform.pasting.length > 1) {
1570: for (var i=0; i<document.pasteform.pasting.length; i++) {
1571: if (document.pasteform.pasting[i].checked) {
1572: numchk ++;
1573: }
1574: }
1575: } else {
1576: if (document.pasteform.pasting.type == 'checkbox') {
1577: if (document.pasteform.pasting.checked) {
1578: numchk ++;
1579: }
1580: }
1581: }
1582: if (numchk > 0) {
1583: return true;
1584: } else {
1.484.2.61 raeburn 1585: alert("$js_lt{'none'}");
1.484.2.30 raeburn 1586: return false;
1587: }
1.484.2.7 raeburn 1588: }
1589:
1.484.2.47 raeburn 1590: function checkClipboard() {
1591: if (document.pasteform.pasting.length > 1) {
1592: for (var i=0; i<document.pasteform.pasting.length; i++) {
1593: document.pasteform.pasting[i].checked = true;
1594: }
1595: }
1596: return;
1597: }
1598:
1599: function uncheckClipboard() {
1600: if (document.pasteform.pasting.length >1) {
1601: for (var i=0; i<document.pasteform.pasting.length; i++) {
1602: document.pasteform.pasting[i].checked = false;
1603: }
1604: }
1605: return;
1606: }
1607:
1.484.2.30 raeburn 1608: END
1609:
1610: }
1.484.2.7 raeburn 1611:
1.329 droeschl 1612: sub do_paste_from_buffer {
1.484.2.7 raeburn 1613: my ($coursenum,$coursedom,$folder,$container,$errors) = @_;
1.329 droeschl 1614:
1.484.2.30 raeburn 1615: # Array of items in paste buffer
1616: my (@currpaste,%pastebuffer,%allerrors);
1617: @currpaste = split(/,/,$env{'docs.markedcopies'});
1618:
1.484.2.7 raeburn 1619: # Early out if paste buffer is empty
1.484.2.30 raeburn 1620: if (@currpaste == 0) {
1.484.2.7 raeburn 1621: return ();
1.484.2.30 raeburn 1622: }
1623: map { $pastebuffer{$_} = 1; } @currpaste;
1624:
1625: # Array of items selected items to paste
1626: my @reqpaste = &Apache::loncommon::get_env_multiple('form.pasting');
1627:
1628: # Early out if nothing selected to paste
1629: if (@reqpaste == 0) {
1630: return();
1631: }
1632: my @topaste;
1633: foreach my $suffix (@reqpaste) {
1634: next if ($suffix =~ /\D/);
1635: next unless (exists($pastebuffer{$suffix}));
1636: push(@topaste,$suffix);
1.484.2.7 raeburn 1637: }
1638:
1.484.2.30 raeburn 1639: # Early out if nothing available to paste
1640: if (@topaste == 0) {
1641: return();
1.329 droeschl 1642: }
1643:
1.484.2.85.2. (raeburn 1644:): my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%notindom,%duplicate,
1.484.2.82 raeburn 1645: %prefixchg,%srcdom,%srcnum,%srcmapidx,%marktomove,$save_err,$lockerrors,$allresult);
1.484.2.7 raeburn 1646:
1.484.2.30 raeburn 1647: foreach my $suffix (@topaste) {
1648: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1.484.2.76 raeburn 1649: my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.484.2.82 raeburn 1650: my $mapidx=&LONCAPA::map::qtescape($env{'docs.markedcopy_map_'.$suffix});
1.484.2.30 raeburn 1651: # Supplemental content may only include certain types of content
1652: # Early out if pasted content is not supported in Supplemental area
1653: if ($folder =~ /^supplemental/) {
1654: unless (&supp_pasteable($url)) {
1655: $notinsupp{$suffix} = 1;
1656: next;
1657: }
1658: }
1659: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/}) {
1660: my $srcd = $1;
1661: my $srcn = $2;
1.484.2.7 raeburn 1662: # When paste buffer was populated using an active role in a different course
1.484.2.30 raeburn 1663: # check for mdc privilege in the course from which the resource was pasted
1664: if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1665: unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1666: $notincrs{$suffix} = 1;
1667: next;
1668: }
1.329 droeschl 1669: }
1.484.2.30 raeburn 1670: $srcdom{$suffix} = $srcd;
1671: $srcnum{$suffix} = $srcn;
1.484.2.85.2. (raeburn 1672:): } elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$}) {
1673:): my ($srcd,$srcn) = split(/_/,$cid);
1674:): # When paste buffer was populated using an active role in a different course
1675:): # check for mdc privilege in the course from which the resource was pasted
1676:): if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1677:): unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1678:): $notincrs{$suffix} = 1;
1679:): next;
1680:): }
1681:): }
1682:): # When buffer was populated using an active role in a different course
1683:): # disallow pasting of External Tool if course is in a different domain.
1684:): if ($srcd ne $coursedom) {
1685:): $notindom{$suffix} = 1;
1686:): next;
1687:): }
1688:): $srcdom{$suffix} = $srcd;
1689:): $srcnum{$suffix} = $srcn;
1.484.2.82 raeburn 1690: } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
1691: ($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg)$})) {
1.484.2.76 raeburn 1692: my ($srcd,$srcn) = split(/_/,$cid);
1693: # When paste buffer was populated using an active role in a different course
1694: # check for mdc privilege in the course from which the resource was pasted
1695: if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1696: unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1697: $notincrs{$suffix} = 1;
1698: next;
1699: }
1700: }
1701: $srcdom{$suffix} = $srcd;
1702: $srcnum{$suffix} = $srcn;
1.484.2.30 raeburn 1703: }
1.484.2.82 raeburn 1704: $srcmapidx{$suffix} = $mapidx;
1.484.2.30 raeburn 1705: push(@dopaste,$suffix);
1706: if ($url=~/\.(page|sequence)$/) {
1707: $is_map{$suffix} = 1;
1.329 droeschl 1708: }
1.484.2.30 raeburn 1709:
1710: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/([^/]+)}) {
1711: my $oldprefix = $1;
1.484.2.19 raeburn 1712: # When pasting content from Main Content to Supplemental Content and vice versa
1.484.2.7 raeburn 1713: # URLs will contain different paths (which depend on whether pasted item is
1.484.2.82 raeburn 1714: # a folder/page or a document).
1.484.2.30 raeburn 1715: if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) {
1716: $prefixchg{$suffix} = 'docstosupp';
1717: } elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) {
1718: $prefixchg{$suffix} = 'supptodocs';
1719: }
1.484.2.7 raeburn 1720:
1721: # If pasting an uploaded map, get list of contained uploaded maps.
1.484.2.30 raeburn 1722: if ($env{'docs.markedcopy_nested_'.$suffix}) {
1723: my @nested;
1724: my ($type) = ($oldprefix =~ /^(default|supplemental)/);
1725: my @items = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1726: my @deps = map { /\d+:([\d,]+$)/ } @items;
1727: foreach my $dep (@deps) {
1728: if ($dep =~ /,/) {
1729: push(@nested,split(/,/,$dep));
1730: } else {
1731: push(@nested,$dep);
1732: }
1.484.2.7 raeburn 1733: }
1.484.2.30 raeburn 1734: foreach my $item (@nested) {
1735: if ($env{'form.docs.markedcopy_'.$suffix.'_'.$item} eq 'move') {
1736: push(@{$marktomove{$suffix}},$type.'_'.$item);
1737: }
1.484.2.7 raeburn 1738: }
1739: }
1.329 droeschl 1740: }
1.484.2.7 raeburn 1741: }
1742:
1.484.2.30 raeburn 1743: # Early out if nothing available to paste
1744: if (@dopaste == 0) {
1745: return ();
1746: }
1747:
1748: # Populate message hash and hashes used for main content <=> supplemental content
1749: # changes
1750:
1751: %msgs = &Apache::lonlocal::texthash (
1752: notinsupp => 'Paste failed: content type is not supported within Supplemental Content',
1753: notincrs => 'Paste failed: Item is from a different course which you do not have rights to edit.',
1.484.2.85.2. (raeburn 1754:): notindom => 'Paste failed: Item is an external tool from a course in a different donain.',
1.484.2.30 raeburn 1755: duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.',
1756: );
1757:
1758: %before = (
1759: docstosupp => {
1760: map => 'default',
1761: doc => 'docs',
1762: },
1763: supptodocs => {
1764: map => 'supplemental',
1765: doc => 'supplemental',
1766: },
1767: );
1768:
1769: %after = (
1770: docstosupp => {
1771: map => 'supplemental',
1772: doc => 'supplemental'
1773: },
1774: supptodocs => {
1775: map => 'default',
1776: doc => 'docs',
1777: },
1778: );
1779:
1780: # Retrieve information about all course maps in main content area
1781:
1782: my $allmaps = {};
1.484.2.79 raeburn 1783: my (@toclear,%mapurls,%lockerrs,%msgerrs,%results,$donechk);
1.484.2.30 raeburn 1784:
1785: # Loop over the items to paste
1786: foreach my $suffix (@dopaste) {
1.484.2.7 raeburn 1787: # Maps need to be copied first
1.484.2.30 raeburn 1788: my (%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies,
1789: %dbcopies,%zombies,%params,%docmoves,%mapmoves,%mapchanges,%newsubdir,
1.484.2.82 raeburn 1790: %newurls,%tomove,%resdatacopy);
1.484.2.30 raeburn 1791: if (ref($marktomove{$suffix}) eq 'ARRAY') {
1792: map { $tomove{$_} = 1; } @{$marktomove{$suffix}};
1793: }
1794: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1795: my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.484.2.76 raeburn 1796: my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.484.2.30 raeburn 1797: my $oldurl = $url;
1798: if ($is_map{$suffix}) {
1.484.2.7 raeburn 1799: # If pasting a map, check if map contains other maps
1.484.2.30 raeburn 1800: my (%hierarchy,%titles);
1.484.2.79 raeburn 1801: if (($folder =~ /^default/) && (!$donechk)) {
1802: $allmaps =
1803: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
1804: $env{"course.$env{'request.course.id'}.home"},
1805: $env{'request.course.id'});
1806: $donechk = 1;
1807: }
1.484.2.85.2. (raeburn 1808:): &contained_map_check($url,$folder,$coursenum,$coursedom,
1809:): \%removefrommap,\%removeparam,\%addedmaps,
1810:): \%hierarchy,\%titles,$allmaps);
1.484.2.30 raeburn 1811: if ($url=~ m{^/uploaded/}) {
1812: my $newurl;
1813: unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
1814: ($newurl,my $error) =
1815: &get_newmap_url($url,$folder,$prefixchg{$suffix},$coursedom,
1816: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1817: \$title,$allmaps,\%newurls);
1818: if ($error) {
1819: $allerrors{$suffix} = $error;
1820: next;
1821: }
1822: if ($newurl ne '') {
1823: if ($newurl ne $url) {
1824: if ($newurl =~ /(?:default|supplemental)_(\d+).(?:sequence|page)$/) {
1825: $newsubdir{$url} = $1;
1826: }
1827: $mapchanges{$url} = 1;
1.484.2.7 raeburn 1828: }
1829: }
1830: }
1.484.2.30 raeburn 1831: if (($srcdom{$suffix} ne $coursedom) ||
1832: ($srcnum{$suffix} ne $coursenum) ||
1833: ($prefixchg{$suffix}) || (($newurl ne '') && ($newurl ne $url))) {
1834: unless (&url_paste_fixups($url,$folder,$prefixchg{$suffix},
1835: $coursedom,$coursenum,$srcdom{$suffix},
1836: $srcnum{$suffix},$allmaps,\%rewrites,
1837: \%retitles,\%copies,\%dbcopies,
1838: \%zombies,\%params,\%mapmoves,
1839: \%mapchanges,\%tomove,\%newsubdir,
1.484.2.82 raeburn 1840: \%newurls,\%resdatacopy)) {
1.484.2.30 raeburn 1841: $mapmoves{$url} = 1;
1842: }
1843: $url = $newurl;
1844: } elsif ($env{'docs.markedcopy_nested_'.$suffix}) {
1845: &url_paste_fixups($url,$folder,$prefixchg{$suffix},$coursedom,
1846: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1847: $allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies,
1848: \%zombies,\%params,\%mapmoves,\%mapchanges,
1.484.2.82 raeburn 1849: \%tomove,\%newsubdir,\%newurls,\%resdatacopy);
1.484.2.30 raeburn 1850: }
1851: } elsif ($url=~m {^/res/}) {
1.484.2.82 raeburn 1852: # published map can only exist once, so remove from paste buffer when done
1.484.2.30 raeburn 1853: push(@toclear,$suffix);
1854: # if pasting published map (main content area only) check map not already in course
1855: if ($folder =~ /^default/) {
1856: if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) {
1857: $duplicate{$suffix} = 1;
1858: next;
1859: }
1.484.2.7 raeburn 1860: }
1861: }
1862: }
1.484.2.85.2. (raeburn 1863:): if ($url=~ m{/(bulletinboard|smppg|ext\.tool)$}) {
1.484.2.30 raeburn 1864: my $prefix = $1;
1.484.2.76 raeburn 1865: my $fromothercrs;
1.484.2.30 raeburn 1866: #need to copy the db contents to a new one, unless this is a move.
1867: my %info = (
1868: src => $url,
1869: cdom => $coursedom,
1870: cnum => $coursenum,
1.484.2.76 raeburn 1871: );
1872: if (($srcdom{$suffix} =~ /^$match_domain$/) && ($srcnum{$suffix} =~ /^$match_courseid$/)) {
1873: unless (($srcdom{$suffix} eq $coursedom) && ($srcnum{$suffix} eq $coursenum)) {
1874: $fromothercrs = 1;
1875: $info{'cdom'} = $srcdom{$suffix};
1876: $info{'cnum'} = $srcnum{$suffix};
1877: }
1878: }
1879: unless (($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') && (!$fromothercrs)) {
1.484.2.30 raeburn 1880: my (%lockerr,$msg);
1881: my ($newurl,$result,$errtext) =
1882: &dbcopy(\%info,$coursedom,$coursenum,\%lockerr);
1883: if ($result eq 'ok') {
1884: $url = $newurl;
1885: $title=&mt('Copy of').' '.$title;
1886: } else {
1887: if ($prefix eq 'smppg') {
1888: $msg = &mt('Paste failed: An error occurred when copying the simple page.').' '.$errtext;
1889: } elsif ($prefix eq 'bulletinboard') {
1.484.2.42 raeburn 1890: $msg = &mt('Paste failed: An error occurred when copying the discussion board.').' '.$errtext;
1.484.2.85.2. (raeburn 1891:): } elsif ($prefix eq 'ext.tool') {
1892:): $msg = &mt('Paste failed: An error occurred when copying the external tool.').' '.$errtext;
1.484.2.30 raeburn 1893: }
1894: $results{$suffix} = $result;
1895: $msgerrs{$suffix} = $msg;
1896: $lockerrs{$suffix} = $lockerr{$prefix};
1897: next;
1898: }
1899: if ($lockerr{$prefix}) {
1900: $lockerrs{$suffix} = $lockerr{$prefix};
1.484.2.26 raeburn 1901: }
1.484.2.7 raeburn 1902: }
1.484.2.30 raeburn 1903: }
1904: $title = &LONCAPA::map::qtunescape($title);
1905: my $ext='false';
1906: if ($url=~m{^http(|s)://}) { $ext='true'; }
1907: if ($env{'docs.markedcopy_supplemental_'.$suffix}) {
1908: if ($folder !~ /^supplemental/) {
1909: (undef,undef,$title) =
1910: &Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental_'.$suffix});
1911: }
1912: } else {
1913: if ($folder=~/^supplemental/) {
1914: $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
1915: $env{'user.domain'}.'___&&&___'.$title;
1.484.2.26 raeburn 1916: }
1917: }
1.484.2.7 raeburn 1918:
1919: # For uploaded files (excluding pages/sequences) path in copied file is changed
1920: # if paste is from Main to Supplemental (or vice versa), or if pasting between
1921: # courses.
1922:
1.484.2.30 raeburn 1923: unless ($is_map{$suffix}) {
1924: my $newidx;
1.329 droeschl 1925: # Now insert the URL at the bottom
1.484.2.30 raeburn 1926: $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
1927: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(.+)$}) {
1928: my $relpath = $1;
1929: if ($relpath ne '') {
1930: my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$});
1931: my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/);
1932: my $newprefix = $newloc;
1933: if ($newloc eq 'default') {
1934: $newprefix = 'docs';
1935: }
1936: if ($newdocsdir eq '') {
1937: $newdocsdir = 'default';
1938: }
1939: if (($prefixchg{$suffix}) ||
1940: ($srcdom{$suffix} ne $coursedom) ||
1941: ($srcnum{$suffix} ne $coursenum) ||
1942: ($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) {
1943: my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";
1944: $url =
1945: &Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath,
1946: &Apache::lonnet::getfile($oldurl));
1947: if ($url eq '/adm/notfound.html') {
1948: $msgs{$suffix} = &mt('Paste failed: an error occurred saving the file.');
1949: next;
1950: } else {
1951: my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$});
1952: $newsubpath =~ s{/+$}{/};
1953: $docmoves{$oldurl} = $newsubpath;
1954: }
1.484.2.7 raeburn 1955: }
1956: }
1.484.2.82 raeburn 1957: } elsif ($url =~ m{^/res/lib/templates/(\w+)\.problem$}) {
1958: my $template = $1;
1959: if ($newidx) {
1960: ©_templated_files($url,$srcdom{$suffix},$srcnum{$suffix},$srcmapidx{$suffix},
1961: $coursedom,$coursenum,$template,$newidx,"$folder.$container");
1962: }
1.484.2.7 raeburn 1963: }
1.484.2.30 raeburn 1964: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
1965: ':'.$ext.':normal:res';
1966: push(@LONCAPA::map::order,$newidx);
1967: # Store the result
1968: my ($errtext,$fatal) =
1969: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1970: if ($fatal) {
1971: $save_err .= $errtext;
1972: $allresult = 'fail';
1.484.2.7 raeburn 1973: }
1.329 droeschl 1974: }
1.484.2.30 raeburn 1975:
1.484.2.82 raeburn 1976: # Apply any changes to maps, or copy dependencies for uploaded HTML pages, or update
1977: # resourcedata for simpleproblems copied from another course
1.484.2.30 raeburn 1978: unless ($allresult eq 'fail') {
1979: my %updated = (
1980: rewrites => \%rewrites,
1981: zombies => \%zombies,
1982: removefrommap => \%removefrommap,
1983: removeparam => \%removeparam,
1984: dbcopies => \%dbcopies,
1.484.2.82 raeburn 1985: resdatacopy => \%resdatacopy,
1.484.2.30 raeburn 1986: retitles => \%retitles,
1987: );
1988: my %info = (
1989: newsubdir => \%newsubdir,
1990: params => \%params,
1991: );
1992: if ($prefixchg{$suffix}) {
1993: $info{'before'} = $before{$prefixchg{$suffix}};
1994: $info{'after'} = $after{$prefixchg{$suffix}};
1995: }
1996: my %moves = (
1997: copies => \%copies,
1998: docmoves => \%docmoves,
1999: mapmoves => \%mapmoves,
2000: );
2001: (my $result,$msgs{$suffix},my $lockerror) =
2002: &apply_fixups($folder,$is_map{$suffix},$coursedom,$coursenum,$errors,
2003: \%updated,\%info,\%moves,$prefixchg{$suffix},$oldurl,
2004: $url,'paste');
2005: $lockerrors .= $lockerror;
2006: if ($result eq 'ok') {
2007: if ($is_map{$suffix}) {
2008: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
2009: $folder.'.'.$container);
2010: if ($fatal) {
2011: $allresult = 'failread';
2012: } else {
2013: if ($#LONCAPA::map::order<1) {
2014: my $idx=&LONCAPA::map::getresidx();
2015: if ($idx<=0) { $idx=1; }
2016: $LONCAPA::map::order[0]=$idx;
2017: $LONCAPA::map::resources[$idx]='';
2018: }
2019: my $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
2020: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
2021: ':'.$ext.':normal:res';
2022: push(@LONCAPA::map::order,$newidx);
1.484.2.7 raeburn 2023:
2024: # Store the result
1.484.2.30 raeburn 2025: my ($errtext,$fatal) =
2026: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
2027: if ($fatal) {
2028: $save_err .= $errtext;
2029: $allresult = 'failstore';
2030: }
2031: }
2032: }
2033: if ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
2034: push(@toclear,$suffix);
2035: }
2036: }
1.329 droeschl 2037: }
2038: }
1.484.2.30 raeburn 2039: &clear_from_buffer(\@toclear,\@currpaste);
2040: my $msgsarray;
2041: foreach my $suffix (keys(%msgs)) {
2042: if (ref($msgs{$suffix}) eq 'ARRAY') {
2043: $msgsarray .= join(',',@{$msgs{$suffix}});
2044: }
2045: }
2046: return ($allresult,$save_err,$msgsarray,$lockerrors);
2047: }
2048:
2049: sub do_buffer_empty {
2050: my @currpaste = split(/,/,$env{'docs.markedcopies'});
2051: if (@currpaste == 0) {
2052: return &mt('Clipboard is already empty');
2053: }
2054: my @toclear = &Apache::loncommon::get_env_multiple('form.pasting');
2055: if (@toclear == 0) {
2056: return &mt('Nothing selected to clear from clipboard');
2057: }
2058: my $numdel = &clear_from_buffer(\@toclear,\@currpaste);
2059: if ($numdel) {
2060: return &mt('[quant,_1,item] cleared from clipboard',$numdel);
2061: } else {
2062: return &mt('Clipboard unchanged');
1.484.2.7 raeburn 2063: }
1.484.2.30 raeburn 2064: return;
2065: }
2066:
2067: sub clear_from_buffer {
2068: my ($toclear,$currpaste) = @_;
2069: return unless ((ref($toclear) eq 'ARRAY') && (ref($currpaste) eq 'ARRAY'));
2070: my %pastebuffer;
2071: map { $pastebuffer{$_} = 1; } @{$currpaste};
2072: my $numdel = 0;
2073: foreach my $suffix (@{$toclear}) {
2074: next if ($suffix =~ /\D/);
2075: next unless (exists($pastebuffer{$suffix}));
2076: my $regexp = 'docs.markedcopy_[a-z]+_'.$suffix;
2077: if (&Apache::lonnet::delenv($regexp,1) eq 'ok') {
2078: delete($pastebuffer{$suffix});
2079: $numdel ++;
2080: }
2081: }
2082: my $newbuffer = join(',',sort(keys(%pastebuffer)));
2083: &Apache::lonnet::appenv({'docs.markedcopies' => $newbuffer});
2084: return $numdel;
1.484.2.7 raeburn 2085: }
2086:
2087: sub get_newmap_url {
2088: my ($url,$folder,$prefixchg,$coursedom,$coursenum,$srcdom,$srcnum,
2089: $titleref,$allmaps,$newurls) = @_;
2090: my $newurl;
2091: if ($url=~ m{^/uploaded/}) {
2092: $$titleref=&mt('Copy of').' '.$$titleref;
2093: }
2094: my $now = time;
2095: my $suffix=$$.int(rand(100)).$now;
2096: my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
2097: if ($oldid =~ m{^(/uploaded/$match_domain/$match_courseid/)(\D+)(\d+)$}) {
2098: my $path = $1;
2099: my $prefix = $2;
2100: my $ancestor = $3;
2101: if (length($ancestor) > 10) {
2102: $ancestor = substr($ancestor,-10,10);
2103: }
2104: my $newid;
2105: if ($prefixchg) {
2106: if ($folder =~ /^supplemental/) {
2107: $prefix =~ s/^default/supplemental/;
2108: } else {
2109: $prefix =~ s/^supplemental/default/;
2110: }
2111: }
2112: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
2113: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
2114: } else {
2115: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$now.'.'.$ext;
2116: }
2117: my $counter = 0;
2118: my $is_unique = &uniqueness_check($newurl);
2119: if ($folder =~ /^default/) {
2120: if ($allmaps->{$newurl}) {
2121: $is_unique = 0;
2122: }
2123: }
2124: while ((!$is_unique || $allmaps->{$newurl} || $newurls->{$newurl}) && ($counter < 100)) {
2125: $counter ++;
2126: $suffix ++;
2127: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
2128: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
2129: } else {
2130: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$ancestor.$suffix.'.'.$ext;
2131: }
2132: $is_unique = &uniqueness_check($newurl);
2133: }
2134: if ($is_unique) {
2135: $newurls->{$newurl} = 1;
2136: } else {
2137: if ($url=~/\.page$/) {
2138: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the composite page'));
2139: } else {
2140: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the folder'));
2141: }
2142: }
2143: }
2144: return ($newurl);
2145: }
2146:
2147: sub dbcopy {
1.484.2.26 raeburn 2148: my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_;
2149: my ($url,$result,$errtext);
2150: if (ref($dbref) eq 'HASH') {
1.484.2.71 raeburn 2151: $url = $dbref->{'src'};
1.484.2.85.2. (raeburn 2152:): if ($url =~ m{/(smppg|bulletinboard|ext\.tool)$}) {
1.484.2.26 raeburn 2153: my $prefix = $1;
1.484.2.85.2. (raeburn 2154:): if ($prefix eq 'ext.tool') {
2155:): $prefix = 'exttool';
2156:): }
1.484.2.26 raeburn 2157: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2158: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2159: my $db_name;
2160: my $marker = (split(m{/},$url))[4];
2161: $marker=~s/\D//g;
2162: if ($dbref->{'src'} =~ m{/smppg$}) {
2163: $db_name =
2164: &Apache::lonsimplepage::get_db_name($url,$marker,
2165: $dbref->{'cdom'},
2166: $dbref->{'cnum'});
1.484.2.85.2. (raeburn 2167:): } elsif ($dbref->{'src'} =~ m{/ext\.tool$}) {
2168:): $db_name = 'exttool_'.$marker;
1.484.2.26 raeburn 2169: } else {
2170: $db_name = 'bulletinpage_'.$marker;
2171: }
2172: my ($suffix,$freedlock,$error) =
2173: &Apache::lonnet::get_timebased_id($prefix,'num','templated',
2174: $coursedom,$coursenum,
2175: 'concat');
2176: if (!$suffix) {
2177: if ($prefix eq 'smppg') {
2178: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);
1.484.2.85.2. (raeburn 2179:): } elsif ($prefix eq 'exttool') {
2180:): $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying an external tool [_1].',$url);
1.484.2.26 raeburn 2181: } else {
1.484.2.42 raeburn 2182: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url);
1.484.2.26 raeburn 2183: }
2184: if ($error) {
2185: $errtext .= '<br />'.$error;
2186: }
2187: } else {
2188: #need to copy the db contents to a new one.
2189: my %contents=&Apache::lonnet::dump($db_name,
2190: $dbref->{'cdom'},
2191: $dbref->{'cnum'});
2192: if (exists($contents{'uploaded.photourl'})) {
2193: my $photo = $contents{'uploaded.photourl'};
2194: my ($subdir,$fname) =
2195: ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});
2196: my $newphoto;
2197: if ($fname ne '') {
2198: my $content = &Apache::lonnet::getfile($photo);
2199: unless ($content eq '-1') {
2200: $env{'form.'.$suffix.'.photourl'} = $content;
2201: $newphoto =
2202: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");
2203: delete($env{'form.'.$suffix.'.photourl'});
2204: }
2205: }
2206: if ($newphoto =~ m{^/uploaded/}) {
2207: $contents{'uploaded.photourl'} = $newphoto;
2208: }
2209: }
2210: $db_name =~ s{_\d*$ }{_$suffix}x;
2211: $result=&Apache::lonnet::put($db_name,\%contents,
2212: $coursedom,$coursenum);
2213: if ($result eq 'ok') {
1.484.2.85.2. (raeburn 2214:): $url =~ s{/(\d*)/(smppg|bulletinboard|ext\.tool)$}{/$suffix/$2}x;
1.484.2.26 raeburn 2215: }
2216: }
2217: if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) {
2218: $lockerrorsref->{$prefix} =
2219: '<div class="LC_error">'.
2220: &mt('There was a problem removing a lockfile.');
2221: if ($prefix eq 'smppg') {
2222: $lockerrorsref->{$prefix} .=
1.484.2.38 raeburn 2223: ' '.&mt('This will prevent creation of additional simple pages in this course.');
1.484.2.85.2. (raeburn 2224:): } elsif ($prefix eq 'exttool') {
2225:): $lockerrorsref->{$prefix} .=
2226:): ' '.&mt('This will prevent addition of more external tools to this course.');
1.484.2.26 raeburn 2227: } else {
1.484.2.42 raeburn 2228: $lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional discussion boards in this course.');
1.484.2.26 raeburn 2229: }
1.484.2.38 raeburn 2230: $lockerrorsref->{$prefix} .= ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
2231: '<a href="/adm/helpdesk" target="_helpdesk">','</a>').
2232: '</div>';
1.484.2.26 raeburn 2233: }
2234: }
2235: } elsif ($url =~ m{/syllabus$}) {
2236: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2237: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2238: if (($dbref->{'cdom'} ne $coursedom) ||
2239: ($dbref->{'cnum'} ne $coursenum)) {
2240: my %contents=&Apache::lonnet::dump('syllabus',
2241: $dbref->{'cdom'},
2242: $dbref->{'cnum'});
2243: $result=&Apache::lonnet::put('syllabus',\%contents,
2244: $coursedom,$coursenum);
2245: }
2246: }
1.484.2.7 raeburn 2247: }
2248: }
1.484.2.26 raeburn 2249: return ($url,$result,$errtext);
1.329 droeschl 2250: }
2251:
1.484.2.82 raeburn 2252: sub copy_templated_files {
2253: my ($srcurl,$srcdom,$srcnum,$srcmapinfo,$coursedom,$coursenum,$template,$newidx,$newmapname) = @_;
2254: my ($srcfolder,$srcid,$srcwaspage) = split(/:/,$srcmapinfo);
2255: my $srccontainer = 'sequence';
2256: if ($srcwaspage) {
2257: $srccontainer = 'page';
2258: }
2259: my $srcsymb = "uploaded/$srcdom/$srcnum/$srcfolder.$srccontainer".
2260: '___'.$srcid.'___'.&Apache::lonnet::declutter($srcurl);
2261: my $srcprefix = $srcdom.'_'.$srcnum.'.'.$srcsymb;
2262: my %srcparms=&Apache::lonnet::dump('resourcedata',$srcdom,$srcnum,$srcprefix);
2263: my $newsymb = "uploaded/$coursedom/$coursenum/$newmapname".'___'.$newidx.'___lib/templates/'.
2264: $template.'.problem';
2265: my $newprefix = $coursedom.'_'.$coursenum.'.'.$newsymb;
2266: if ($template eq 'simpleproblem') {
2267: $srcprefix .= '.0.';
2268: my $weightprefix = $newprefix;
2269: $newprefix .= '.0.';
2270: my @simpleprobqtypes = qw(radio option string essay numerical);
2271: my $qtype=$srcparms{$srcprefix.'questiontype'};
2272: if (grep(/^\Q$qtype\E$/,@simpleprobqtypes)) {
2273: my %newdata = (
2274: $newprefix.'questiontype' => $qtype,
1.484.2.84 raeburn 2275: );
1.484.2.82 raeburn 2276: foreach my $type (@simpleprobqtypes) {
2277: if ($type eq $qtype) {
2278: $newdata{"$weightprefix.$type.weight"}=1;
2279: } else {
2280: $newdata{"$weightprefix.$type.weight"}=0;
2281: }
2282: }
2283: $newdata{$newprefix.'hiddenparts'} = '!'.$qtype;
2284: $newdata{$newprefix.'questiontext'} = $srcparms{$srcprefix.'questiontext'};
2285: $newdata{$newprefix.'hinttext'} = $srcparms{$srcprefix.'hinttext'};
2286: if ($qtype eq 'numerical') {
2287: $newdata{$newprefix.'numericalscript'} = $srcparms{$srcprefix.'numericalscript'};
2288: $newdata{$newprefix.'numericalanswer'} = $srcparms{$srcprefix.'numericalanswer'};
2289: $newdata{$newprefix.'numericaltolerance'} = $srcparms{$srcprefix.'numericaltolerance'};
2290: $newdata{$newprefix.'numericalsigfigs'} = $srcparms{$srcprefix.'numericalsigfigs'};
2291: } elsif (($qtype eq 'option') || ($qtype eq 'radio')) {
2292: my $maxfoils=$srcparms{$srcprefix.'maxfoils'};
2293: unless (defined($maxfoils)) { $maxfoils=10; }
2294: unless ($maxfoils=~/^\d+$/) { $maxfoils=10; }
2295: if ($maxfoils<=0) { $maxfoils=10; }
2296: my $randomize=$srcparms{$srcprefix.'randomize'};
2297: unless (defined($randomize)) { $randomize='yes'; }
2298: unless ($randomize eq 'no') { $randomize='yes'; }
2299: $newdata{$newprefix.'maxfoils'} = $maxfoils;
2300: $newdata{$newprefix.'randomize'} = $randomize;
2301: if ($qtype eq 'option') {
2302: $newdata{$newprefix.'options'} = $srcparms{$srcprefix.'options'};
2303: }
2304: for (my $i=1; $i<=10; $i++) {
2305: $newdata{$newprefix.'value'.$i} = $srcparms{$srcprefix.'value'.$i};
2306: $newdata{$newprefix.'position'.$i} = $srcparms{$srcprefix.'position'.$i};
2307: $newdata{$newprefix.'text'.$i} = $srcparms{$srcprefix.'text'.$i};
2308: }
2309:
2310: } elsif (($qtype eq 'option') || ($qtype eq 'radio')) {
2311: my $maxfoils=$srcparms{$srcprefix.'maxfoils'};
2312: unless (defined($maxfoils)) { $maxfoils=10; }
2313: unless ($maxfoils=~/^\d+$/) { $maxfoils=10; }
2314: if ($maxfoils<=0) { $maxfoils=10; }
2315: my $randomize=$srcparms{$srcprefix.'randomize'};
2316: unless (defined($randomize)) { $randomize='yes'; }
2317: unless ($randomize eq 'no') { $randomize='yes'; }
2318: $newdata{$newprefix.'maxfoils'} = $maxfoils;
2319: $newdata{$newprefix.'randomize'} = $randomize;
2320: if ($qtype eq 'option') {
2321: $newdata{$newprefix.'options'} = $srcparms{$srcprefix.'options'};
2322: }
2323: for (my $i=1; $i<=10; $i++) {
2324: $newdata{$newprefix.'value'.$i} = $srcparms{$srcprefix.'value'.$i};
2325: $newdata{$newprefix.'position'.$i} = $srcparms{$srcprefix.'position'.$i};
2326: $newdata{$newprefix.'text'.$i} = $srcparms{$srcprefix.'text'.$i};
2327: }
2328: } elsif ($qtype eq 'string') {
2329: $newdata{$newprefix.'stringanswer'} = $srcparms{$srcprefix.'stringanswer'};
2330: $newdata{$newprefix.'stringtype'} = $srcparms{$srcprefix.'stringtype'};
2331: }
2332: if (keys(%newdata)) {
2333: my $putres = &Apache::lonnet::cput('resourcedata',\%newdata,$coursedom,
2334: $coursenum);
2335: if ($putres eq 'ok') {
2336: &Apache::lonnet::devalidatecourseresdata($coursenum,$coursedom);
2337: }
2338: }
2339: }
2340: }
2341: }
2342:
1.329 droeschl 2343: sub uniqueness_check {
2344: my ($newurl) = @_;
2345: my $unique = 1;
2346: foreach my $res (@LONCAPA::map::order) {
2347: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2348: $url=&LONCAPA::map::qtescape($url);
2349: if ($newurl eq $url) {
2350: $unique = 0;
1.344 bisitz 2351: last;
1.329 droeschl 2352: }
2353: }
2354: return $unique;
2355: }
2356:
1.484.2.7 raeburn 2357: sub contained_map_check {
1.484.2.85.2. (raeburn 2358:): my ($url,$folder,$coursenum,$coursedom,$removefrommap,$removeparam,$addedmaps,
2359:): $hierarchy,$titles,$allmaps) = @_;
1.484.2.7 raeburn 2360: my $content = &Apache::lonnet::getfile($url);
2361: unless ($content eq '-1') {
2362: my $parser = HTML::TokeParser->new(\$content);
2363: $parser->attr_encoded(1);
2364: while (my $token = $parser->get_token) {
2365: next if ($token->[0] ne 'S');
2366: if ($token->[1] eq 'resource') {
2367: next if ($token->[2]->{'type'} eq 'zombie');
2368: my $ressrc = $token->[2]->{'src'};
2369: if ($folder =~ /^supplemental/) {
2370: unless (&supp_pasteable($ressrc)) {
2371: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2372: next;
2373: }
2374: }
2375: if ($ressrc =~ m{^/(res|uploaded)/.+\.(sequence|page)$}) {
2376: if ($1 eq 'uploaded') {
2377: $hierarchy->{$url}{$token->[2]->{'id'}} = $ressrc;
2378: $titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'};
2379: } else {
2380: if ($allmaps->{$ressrc}) {
1.484.2.23 raeburn 2381: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.484.2.7 raeburn 2382: } elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') {
2383: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2384: } else {
2385: $addedmaps->{$ressrc} = [$url];
2386: }
2387: }
1.484.2.85.2. (raeburn 2388:): &contained_map_check($ressrc,$folder,$coursenum,$coursedom,
2389:): $removefrommap,$removeparam,
1.484.2.7 raeburn 2390: $addedmaps,$hierarchy,$titles,$allmaps);
2391: }
2392: } elsif ($token->[1] eq 'param') {
2393: if ($folder =~ /^supplemental/) {
2394: if (ref($removeparam->{$url}{$token->[2]->{'to'}}) eq 'ARRAY') {
2395: push(@{$removeparam->{$url}{$token->[2]->{'to'}}},$token->[2]->{'name'});
2396: } else {
1.484.2.19 raeburn 2397: $removeparam->{$url}{$token->[2]->{'to'}} = [$token->[2]->{'name'}];
1.484.2.7 raeburn 2398: }
2399: }
2400: }
2401: }
2402: }
2403: return;
2404: }
2405:
2406: sub url_paste_fixups {
1.484.2.26 raeburn 2407: my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$fromcdom,$fromcnum,$allmaps,
2408: $rewrites,$retitles,$copies,$dbcopies,$zombies,$params,$mapmoves,
1.484.2.82 raeburn 2409: $mapchanges,$tomove,$newsubdir,$newurls,$resdatacopy) = @_;
1.484.2.7 raeburn 2410: my $checktitle;
2411: if (($prefixchg) &&
2412: ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) {
2413: $checktitle = 1;
2414: }
2415: my $skip;
2416: if ($oldurl =~ m{^\Q/uploaded/$cdom/$cnum/\E(default|supplemental)(_?\d*)\.(?:page|sequence)$}) {
2417: my $mapid = $1.$2;
2418: if ($tomove->{$mapid}) {
2419: $skip = 1;
2420: }
2421: }
2422: my $file = &Apache::lonnet::getfile($oldurl);
2423: return if ($file eq '-1');
2424: my $parser = HTML::TokeParser->new(\$file);
2425: $parser->attr_encoded(1);
2426: my $changed = 0;
2427: while (my $token = $parser->get_token) {
2428: next if ($token->[0] ne 'S');
2429: if ($token->[1] eq 'resource') {
2430: my $ressrc = $token->[2]->{'src'};
2431: next if ($ressrc eq '');
2432: my $id = $token->[2]->{'id'};
2433: my $title = $token->[2]->{'title'};
2434: if ($checktitle) {
2435: if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1.484.2.25 raeburn 2436: $retitles->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2437: }
2438: }
2439: next if ($token->[2]->{'type'} eq 'external');
2440: if ($token->[2]->{'type'} eq 'zombie') {
1.484.2.30 raeburn 2441: next if ($skip);
1.484.2.25 raeburn 2442: $zombies->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2443: $changed = 1;
2444: } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
2445: my $srcdom = $1;
2446: my $srcnum = $2;
2447: my $rem = $3;
2448: my $newurl;
2449: my $mapname;
2450: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
2451: my $prefix = $1;
2452: $mapname = $prefix.$2;
2453: if ($tomove->{$mapname}) {
1.484.2.26 raeburn 2454: &url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,
2455: $srcdom,$srcnum,$allmaps,$rewrites,
2456: $retitles,$copies,$dbcopies,$zombies,
2457: $params,$mapmoves,$mapchanges,$tomove,
1.484.2.82 raeburn 2458: $newsubdir,$newurls,$resdatacopy);
1.484.2.7 raeburn 2459: next;
2460: } else {
2461: ($newurl,my $error) =
2462: &get_newmap_url($ressrc,$folder,$prefixchg,$cdom,$cnum,
2463: $srcdom,$srcnum,\$title,$allmaps,$newurls);
2464: if ($newurl =~ /(?:default|supplemental)_(\d+)\.(?:sequence|page)$/) {
2465: $newsubdir->{$ressrc} = $1;
2466: }
2467: if ($error) {
2468: next;
2469: }
2470: }
2471: }
2472: if (($srcdom ne $cdom) || ($srcnum ne $cnum) || ($prefixchg) ||
2473: ($mapchanges->{$oldurl}) || (($newurl ne '') && ($newurl ne $oldurl))) {
1.484.2.19 raeburn 2474:
1.484.2.7 raeburn 2475: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
1.484.2.25 raeburn 2476: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2477: $mapchanges->{$ressrc} = 1;
1.484.2.26 raeburn 2478: unless (&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,
2479: $cnum,$srcdom,$srcnum,$allmaps,
2480: $rewrites,$retitles,$copies,$dbcopies,
2481: $zombies,$params,$mapmoves,$mapchanges,
1.484.2.82 raeburn 2482: $tomove,$newsubdir,$newurls,$resdatacopy)) {
1.484.2.7 raeburn 2483: $mapmoves->{$ressrc} = 1;
2484: }
2485: $changed = 1;
2486: } else {
1.484.2.25 raeburn 2487: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2488: $copies->{$oldurl}{$ressrc} = $id;
2489: $changed = 1;
2490: }
2491: }
1.484.2.26 raeburn 2492: } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/.+$}) {
1.484.2.30 raeburn 2493: next if ($skip);
1.484.2.7 raeburn 2494: my $srcdom = $1;
2495: my $srcnum = $2;
2496: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.484.2.25 raeburn 2497: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.26 raeburn 2498: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2499: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2500: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
2501: $changed = 1;
2502: }
2503: } elsif ($ressrc =~ m{^/adm/$match_domain/$match_username/\d+/(smppg|bulletinboard)$}) {
2504: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum) ||
2505: ($env{'form.docs.markedcopy_options'} ne 'move')) {
2506: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2507: $dbcopies->{$oldurl}{$id}{'cdom'} = $fromcdom;
2508: $dbcopies->{$oldurl}{$id}{'cnum'} = $fromcnum;
1.484.2.7 raeburn 2509: $changed = 1;
2510: }
1.484.2.82 raeburn 2511: } elsif ($ressrc eq '/res/lib/templates/simpleproblem.problem') {
2512: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum)) {
2513: $resdatacopy->{$oldurl}{$id}{'src'} = $ressrc;
2514: $resdatacopy->{$oldurl}{$id}{'cdom'} = $fromcdom;
2515: $resdatacopy->{$oldurl}{$id}{'cnum'} = $fromcnum;
2516: }
1.484.2.7 raeburn 2517: } elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) {
2518: next if ($skip);
2519: my $srcdom = $1;
2520: my $srcnum = $2;
2521: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.484.2.26 raeburn 2522: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2523: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2524: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
1.484.2.7 raeburn 2525: $changed = 1;
2526: }
2527: }
2528: } elsif ($token->[1] eq 'param') {
2529: next if ($skip);
1.484.2.19 raeburn 2530: my $to = $token->[2]->{'to'};
1.484.2.7 raeburn 2531: if ($to ne '') {
2532: if (ref($params->{$oldurl}{$to}) eq 'ARRAY') {
2533: push(@{$params->{$oldurl}{$to}},$token->[2]->{'name'});
2534: } else {
2535: @{$params->{$oldurl}{$to}} = ($token->[2]->{'name'});
2536: }
2537: }
2538: }
2539: }
2540: return $changed;
2541: }
2542:
2543: sub apply_fixups {
1.484.2.23 raeburn 2544: my ($folder,$is_map,$cdom,$cnum,$errors,$updated,$info,$moves,$prefixchg,
2545: $oldurl,$url,$caller) = @_;
2546: my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles,
1.484.2.26 raeburn 2547: %params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs,
1.484.2.82 raeburn 2548: %resdatacopy,%lockerrors,$lockmsg);
1.484.2.23 raeburn 2549: if (ref($updated) eq 'HASH') {
2550: if (ref($updated->{'rewrites'}) eq 'HASH') {
2551: %rewrites = %{$updated->{'rewrites'}};
2552: }
2553: if (ref($updated->{'zombies'}) eq 'HASH') {
2554: %zombies = %{$updated->{'zombies'}};
2555: }
2556: if (ref($updated->{'removefrommap'}) eq 'HASH') {
2557: %removefrommap = %{$updated->{'removefrommap'}};
2558: }
2559: if (ref($updated->{'removeparam'}) eq 'HASH') {
2560: %removeparam = %{$updated->{'removeparam'}};
2561: }
2562: if (ref($updated->{'dbcopies'}) eq 'HASH') {
2563: %dbcopies = %{$updated->{'dbcopies'}};
2564: }
2565: if (ref($updated->{'retitles'}) eq 'HASH') {
2566: %retitles = %{$updated->{'retitles'}};
2567: }
1.484.2.82 raeburn 2568: if (ref($updated->{'resdatacopy'}) eq 'HASH') {
2569: %resdatacopy = %{$updated->{'resdatacopy'}};
2570: }
1.484.2.23 raeburn 2571: }
2572: if (ref($info) eq 'HASH') {
2573: if (ref($info->{'newsubdir'}) eq 'HASH') {
2574: %newsubdir = %{$info->{'newsubdir'}};
2575: }
2576: if (ref($info->{'params'}) eq 'HASH') {
2577: %params = %{$info->{'params'}};
2578: }
2579: if (ref($info->{'before'}) eq 'HASH') {
2580: %before = %{$info->{'before'}};
2581: }
2582: if (ref($info->{'after'}) eq 'HASH') {
2583: %after = %{$info->{'after'}};
2584: }
2585: }
2586: if (ref($moves) eq 'HASH') {
2587: if (ref($moves->{'copies'}) eq 'HASH') {
2588: %copies = %{$moves->{'copies'}};
2589: }
2590: if (ref($moves->{'docmoves'}) eq 'HASH') {
2591: %docmoves = %{$moves->{'docmoves'}};
2592: }
2593: if (ref($moves->{'mapmoves'}) eq 'HASH') {
2594: %mapmoves = %{$moves->{'mapmoves'}};
2595: }
2596: }
2597: foreach my $key (keys(%copies),keys(%docmoves)) {
1.484.2.7 raeburn 2598: my @allcopies;
1.484.2.23 raeburn 2599: if (exists($copies{$key})) {
2600: if (ref($copies{$key}) eq 'HASH') {
2601: my %added;
2602: foreach my $innerkey (keys(%{$copies{$key}})) {
2603: if (($innerkey ne '') && (!$added{$innerkey})) {
2604: push(@allcopies,$innerkey);
2605: $added{$innerkey} = 1;
2606: }
1.484.2.7 raeburn 2607: }
1.484.2.23 raeburn 2608: undef(%added);
1.484.2.7 raeburn 2609: }
2610: }
2611: if ($key eq $oldurl) {
1.484.2.23 raeburn 2612: if ((exists($docmoves{$key}))) {
1.484.2.25 raeburn 2613: unless (grep(/^\Q$oldurl\E$/,@allcopies)) {
1.484.2.7 raeburn 2614: push(@allcopies,$oldurl);
2615: }
2616: }
2617: }
2618: if (@allcopies > 0) {
2619: foreach my $item (@allcopies) {
1.484.2.19 raeburn 2620: my ($relpath,$oldsubdir,$fname) =
1.484.2.7 raeburn 2621: ($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(default|\d+)/.*/)([^/]+)$});
2622: if ($fname ne '') {
2623: my $content = &Apache::lonnet::getfile($item);
2624: unless ($content eq '-1') {
2625: my $storefn;
1.484.2.23 raeburn 2626: if (($key eq $oldurl) && (exists($docmoves{$key}))) {
2627: $storefn = $docmoves{$key};
1.484.2.7 raeburn 2628: } else {
2629: $storefn = $relpath;
2630: $storefn =~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 2631: if ($prefixchg && $before{'doc'} && $after{'doc'}) {
2632: $storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/;
1.484.2.7 raeburn 2633: }
1.484.2.23 raeburn 2634: if ($newsubdir{$key}) {
1.484.2.25 raeburn 2635: $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}/#;
1.484.2.7 raeburn 2636: }
2637: }
2638: ©_dependencies($item,$storefn,$relpath,$errors,\$content);
1.484.2.19 raeburn 2639: my $copyurl =
1.484.2.7 raeburn 2640: &Apache::lonclonecourse::writefile($env{'request.course.id'},
2641: $storefn.$fname,$content);
2642: if ($copyurl eq '/adm/notfound.html') {
1.484.2.23 raeburn 2643: if (exists($docmoves{$oldurl})) {
1.484.2.7 raeburn 2644: return &mt('Paste failed: an error occurred copying the file.');
2645: } elsif (ref($errors) eq 'HASH') {
2646: $errors->{$item} = 1;
2647: }
2648: }
2649: }
2650: }
2651: }
2652: }
2653: }
1.484.2.23 raeburn 2654: foreach my $key (keys(%mapmoves)) {
1.484.2.7 raeburn 2655: my $storefn=$key;
2656: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 2657: if ($prefixchg && $before{'map'} && $after{'map'}) {
2658: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.484.2.7 raeburn 2659: }
1.484.2.23 raeburn 2660: if ($newsubdir{$key}) {
2661: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.484.2.7 raeburn 2662: }
2663: my $mapcontent = &Apache::lonnet::getfile($key);
2664: if ($mapcontent eq '-1') {
2665: if (ref($errors) eq 'HASH') {
2666: $errors->{$key} = 1;
2667: }
2668: } else {
2669: my $newmap =
2670: &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
2671: $mapcontent);
2672: if ($newmap eq '/adm/notfound.html') {
2673: if (ref($errors) eq 'HASH') {
2674: $errors->{$key} = 1;
2675: }
2676: }
2677: }
2678: }
2679: my %updates;
2680: if ($is_map) {
1.484.2.23 raeburn 2681: if (ref($updated) eq 'HASH') {
2682: foreach my $type (keys(%{$updated})) {
2683: if (ref($updated->{$type}) eq 'HASH') {
2684: foreach my $key (keys(%{$updated->{$type}})) {
2685: $updates{$key} = 1;
2686: }
2687: }
2688: }
1.484.2.7 raeburn 2689: }
2690: foreach my $key (keys(%updates)) {
2691: my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb);
1.484.2.23 raeburn 2692: if (ref($rewrites{$key}) eq 'HASH') {
2693: %torewrite = %{$rewrites{$key}};
1.484.2.7 raeburn 2694: }
1.484.2.23 raeburn 2695: if (ref($retitles{$key}) eq 'HASH') {
2696: %toretitle = %{$retitles{$key}};
1.484.2.7 raeburn 2697: }
1.484.2.23 raeburn 2698: if (ref($removefrommap{$key}) eq 'HASH') {
2699: %toremove = %{$removefrommap{$key}};
1.484.2.7 raeburn 2700: }
1.484.2.23 raeburn 2701: if (ref($removeparam{$key}) eq 'HASH') {
2702: %remparam = %{$removeparam{$key}};
1.484.2.7 raeburn 2703: }
1.484.2.23 raeburn 2704: if (ref($zombies{$key}) eq 'HASH') {
2705: %zombie = %{$zombies{$key}};
1.484.2.7 raeburn 2706: }
1.484.2.23 raeburn 2707: if (ref($dbcopies{$key}) eq 'HASH') {
1.484.2.26 raeburn 2708: foreach my $idx (keys(%{$dbcopies{$key}})) {
2709: if (ref($dbcopies{$key}{$idx}) eq 'HASH') {
2710: my ($newurl,$result,$errtext) =
2711: &dbcopy($dbcopies{$key}{$idx},$cdom,$cnum,\%lockerrors);
2712: if ($result eq 'ok') {
2713: $newdb{$idx} = $newurl;
2714: } elsif (ref($errors) eq 'HASH') {
2715: $errors->{$key} = 1;
2716: }
2717: push(@msgs,$errtext);
2718: }
1.484.2.7 raeburn 2719: }
2720: }
1.484.2.82 raeburn 2721: if (ref($resdatacopy{$key}) eq 'HASH') {
2722: my ($gotnewmapname,$newmapname,$srcfolder,$srccontainer);
2723: foreach my $idx (keys(%{$resdatacopy{$key}})) {
2724: if (ref($resdatacopy{$key}{$idx}) eq 'HASH') {
2725: my $srcurl = $resdatacopy{$key}{$idx}{'src'};
2726: if ($srcurl =~ m{^/res/lib/templates/(\w+)\.problem$}) {
2727: my $template = $1;
2728: if (($resdatacopy{$key}{$idx}{'cdom'} =~ /^$match_domain$/) &&
2729: ($resdatacopy{$key}{$idx}{'cnum'} =~ /^$match_courseid$/)) {
2730: my $srcdom = $resdatacopy{$key}{$idx}{'cdom'};
2731: my $srcnum = $resdatacopy{$key}{$idx}{'cnum'};
2732: unless ($gotnewmapname) {
2733: ($newmapname) = ($key =~ m{/([^/]+)$});
2734: ($srcfolder,$srccontainer) = split(/\./,$newmapname);
2735: if ($newsubdir{$key}) {
2736: $newmapname =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
2737: }
2738: $gotnewmapname = 1;
2739: }
2740: my $srcmapinfo = $srcfolder.':'.$idx;
2741: if ($srccontainer eq 'page') {
2742: $srcmapinfo .= ':1';
2743: }
2744: ©_templated_files($srcurl,$srcdom,$srcnum,$srcmapinfo,$cdom,
2745: $cnum,$template,$idx,$newmapname);
2746: }
2747: }
2748: }
2749: }
2750: }
1.484.2.23 raeburn 2751: if (ref($params{$key}) eq 'HASH') {
2752: %currparam = %{$params{$key}};
1.484.2.7 raeburn 2753: }
2754: my ($errtext,$fatal) = &LONCAPA::map::mapread($key);
2755: if ($fatal) {
1.484.2.26 raeburn 2756: return ($errtext);
1.484.2.7 raeburn 2757: }
2758: for (my $i=0; $i<@LONCAPA::map::zombies; $i++) {
2759: if (defined($LONCAPA::map::zombies[$i])) {
2760: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::zombies[$i]);
1.484.2.25 raeburn 2761: if ($zombie{$i} eq $src) {
1.484.2.7 raeburn 2762: undef($LONCAPA::map::zombies[$i]);
2763: }
2764: }
2765: }
1.484.2.77 raeburn 2766: my $total = scalar(@LONCAPA::map::order) - 1;
2767: for (my $i=$total; $i>=0; $i--) {
1.484.2.23 raeburn 2768: my $idx = $LONCAPA::map::order[$i];
2769: if (defined($LONCAPA::map::resources[$idx])) {
1.484.2.7 raeburn 2770: my $changed;
1.484.2.23 raeburn 2771: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]);
1.484.2.30 raeburn 2772: if ((exists($toremove{$idx})) &&
2773: ($toremove{$idx} eq &LONCAPA::map::qtescape($src))) {
1.484.2.7 raeburn 2774: splice(@LONCAPA::map::order,$i,1);
1.484.2.23 raeburn 2775: if (ref($currparam{$idx}) eq 'ARRAY') {
2776: foreach my $name (@{$currparam{$idx}}) {
1.484.2.77 raeburn 2777: &LONCAPA::map::delparameter($idx,$name);
1.484.2.7 raeburn 2778: }
2779: }
2780: next;
2781: }
2782: my $origsrc = $src;
1.484.2.25 raeburn 2783: if ((exists($toretitle{$idx})) && ($toretitle{$idx} eq $src)) {
1.484.2.7 raeburn 2784: if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
2785: $changed = 1;
2786: }
2787: }
1.484.2.25 raeburn 2788: if ((exists($torewrite{$idx})) && ($torewrite{$idx} eq $src)) {
1.484.2.7 raeburn 2789: $src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
2790: if ($origsrc =~ m{^/uploaded/}) {
1.484.2.23 raeburn 2791: if ($prefixchg && $before{'map'} && $after{'map'}) {
1.484.2.7 raeburn 2792: if ($src =~ /\.(page|sequence)$/) {
1.484.2.23 raeburn 2793: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'map'}\E#$1$after{'map'}#;
1.484.2.7 raeburn 2794: } else {
1.484.2.23 raeburn 2795: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
1.484.2.7 raeburn 2796: }
2797: }
1.484.2.25 raeburn 2798: if ($origsrc =~ /\.(page|sequence)$/) {
2799: if ($newsubdir{$origsrc}) {
1.484.2.23 raeburn 2800: $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir{$origsrc}#;
1.484.2.7 raeburn 2801: }
1.484.2.25 raeburn 2802: } elsif ($newsubdir{$key}) {
2803: $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$key}#;
1.484.2.7 raeburn 2804: }
2805: }
2806: $changed = 1;
1.484.2.26 raeburn 2807: } elsif ($newdb{$idx} ne '') {
2808: $src = $newdb{$idx};
1.484.2.7 raeburn 2809: $changed = 1;
2810: }
2811: if ($changed) {
1.484.2.30 raeburn 2812: $LONCAPA::map::resources[$idx] = join(':',($title,&LONCAPA::map::qtunescape($src),$ext,$type));
1.484.2.7 raeburn 2813: }
2814: }
2815: }
2816: foreach my $idx (keys(%remparam)) {
2817: if (ref($remparam{$idx}) eq 'ARRAY') {
1.484.2.19 raeburn 2818: foreach my $name (@{$remparam{$idx}}) {
1.484.2.77 raeburn 2819: &LONCAPA::map::delparameter($idx,$name);
1.484.2.7 raeburn 2820: }
2821: }
2822: }
1.484.2.26 raeburn 2823: if (values(%lockerrors) > 0) {
2824: $lockmsg = join('<br />',values(%lockerrors));
2825: }
1.484.2.7 raeburn 2826: my $storefn;
2827: if ($key eq $oldurl) {
2828: $storefn = $url;
2829: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
2830: } else {
2831: $storefn = $key;
2832: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 2833: if ($prefixchg && $before{'map'} && $after{'map'}) {
2834: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.484.2.7 raeburn 2835: }
1.484.2.23 raeburn 2836: if ($newsubdir{$key}) {
2837: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.484.2.7 raeburn 2838: }
2839: }
2840: my $report;
2841: if ($folder !~ /^supplemental/) {
2842: $report = 1;
2843: }
1.484.2.20 raeburn 2844: (my $outtext,$errtext) =
1.484.2.7 raeburn 2845: &LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report);
2846: if ($errtext) {
1.484.2.23 raeburn 2847: if ($caller eq 'paste') {
1.484.2.26 raeburn 2848: return (&mt('Paste failed: an error occurred saving the folder or page.'));
1.484.2.23 raeburn 2849: }
1.484.2.7 raeburn 2850: }
2851: }
2852: }
1.484.2.26 raeburn 2853: return ('ok',\@msgs,$lockmsg);
1.484.2.7 raeburn 2854: }
2855:
2856: sub copy_dependencies {
2857: my ($item,$storefn,$relpath,$errors,$contentref) = @_;
2858: my $content;
2859: if (ref($contentref)) {
2860: $content = $$contentref;
2861: } else {
2862: $content = &Apache::lonnet::getfile($item);
2863: }
2864: unless ($content eq '-1') {
2865: my $mm = new File::MMagic;
2866: my $mimetype = $mm->checktype_contents($content);
2867: if ($mimetype eq 'text/html') {
2868: my (%allfiles,%codebase,$state);
2869: my $res = &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,\$content);
2870: if ($res eq 'ok') {
2871: my ($numexisting,$numpathchanges,$existing);
2872: (undef,$numexisting,$numpathchanges,$existing) =
2873: &Apache::loncommon::ask_for_embedded_content(
2874: '/adm/coursedocs',$state,\%allfiles,\%codebase,
2875: {'error_on_invalid_names' => 1,
2876: 'ignore_remote_references' => 1,
2877: 'docs_url' => $item,
2878: 'context' => 'paste'});
2879: if ($numexisting > 0) {
2880: if (ref($existing) eq 'HASH') {
2881: foreach my $dep (keys(%{$existing})) {
2882: my $depfile = $dep;
2883: unless ($depfile =~ m{^\Q$relpath\E}) {
2884: $depfile = $relpath.$dep;
2885: }
2886: my $depcontent = &Apache::lonnet::getfile($depfile);
2887: unless ($depcontent eq '-1') {
2888: my $storedep = $dep;
2889: $storedep =~ s{^\Q$relpath\E}{};
2890: my $dep_url =
2891: &Apache::lonclonecourse::writefile(
2892: $env{'request.course.id'},
2893: $storefn.$storedep,$depcontent);
2894: if ($dep_url eq '/adm/notfound.html') {
2895: if (ref($errors) eq 'HASH') {
2896: $errors->{$depfile} = 1;
2897: }
2898: } else {
2899: ©_dependencies($depfile,$storefn,$relpath,$errors,\$depcontent);
2900: }
2901: }
2902: }
2903: }
2904: }
2905: }
2906: }
2907: }
2908: return;
2909: }
2910:
1.329 droeschl 2911: my %parameter_type = ( 'randompick' => 'int_pos',
2912: 'hiddenresource' => 'string_yesno',
2913: 'encrypturl' => 'string_yesno',
2914: 'randomorder' => 'string_yesno',);
2915: my $valid_parameters_re = join('|',keys(%parameter_type));
2916: # set parameters
2917: sub update_parameter {
1.484.2.29 raeburn 2918: if ($env{'form.changeparms'} eq 'all') {
2919: my (@allidx,@allmapidx,%allchecked,%currchecked);
2920: %allchecked = (
2921: 'hiddenresource' => {},
2922: 'encrypturl' => {},
2923: 'randompick' => {},
2924: 'randomorder' => {},
2925: );
2926: foreach my $which (keys(%allchecked)) {
2927: $env{'form.all'.$which} =~ s/,$//;
2928: if ($which eq 'randompick') {
2929: foreach my $item (split(/,/,$env{'form.all'.$which})) {
2930: my ($res,$value) = split(/:/,$item);
2931: if ($value =~ /^\d+$/) {
2932: $allchecked{$which}{$res} = $value;
2933: }
2934: }
2935: } else {
1.484.2.30 raeburn 2936: if ($env{'form.all'.$which}) {
2937: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.all'.$which});
2938: }
1.484.2.29 raeburn 2939: }
2940: }
2941: my $haschanges = 0;
2942: foreach my $res (@LONCAPA::map::order) {
2943: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2944: $name=&LONCAPA::map::qtescape($name);
2945: $url=&LONCAPA::map::qtescape($url);
2946: next unless ($name && $url);
2947: my $is_map;
2948: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
2949: $is_map = 1;
2950: }
2951: foreach my $which (keys(%allchecked)) {
2952: if (($which eq 'randompick' || $which eq 'randomorder')) {
2953: next if (!$is_map);
2954: }
2955: my $oldvalue = 0;
2956: my $newvalue = 0;
2957: if ($allchecked{$which}{$res}) {
2958: $newvalue = $allchecked{$which}{$res};
2959: }
2960: my $current = (&LONCAPA::map::getparameter($res,'parameter_'.$which))[0];
2961: if ($which eq 'randompick') {
2962: if ($current =~ /^(\d+)$/) {
2963: $oldvalue = $1;
2964: }
2965: } else {
2966: if ($current =~ /^yes$/i) {
2967: $oldvalue = 1;
2968: }
2969: }
2970: if ($oldvalue ne $newvalue) {
2971: $haschanges = 1;
2972: if ($newvalue) {
2973: my $storeval = 'yes';
2974: if ($which eq 'randompick') {
2975: $storeval = $newvalue;
2976: }
2977: &LONCAPA::map::storeparameter($res,'parameter_'.$which,
2978: $storeval,
2979: $parameter_type{$which});
2980: &remember_parms($res,$which,'set',$storeval);
2981: } elsif ($oldvalue) {
2982: &LONCAPA::map::delparameter($res,'parameter_'.$which);
2983: &remember_parms($res,$which,'del');
2984: }
2985: }
2986: }
2987: }
2988: return $haschanges;
1.329 droeschl 2989: } else {
1.484.2.59 raeburn 2990: my $haschanges = 0;
2991: return $haschanges if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
1.364 bisitz 2992:
1.484.2.29 raeburn 2993: my $which = $env{'form.changeparms'};
2994: my $idx = $env{'form.setparms'};
1.484.2.59 raeburn 2995: my $oldvalue = 0;
2996: my $newvalue = 0;
2997: my $current = (&LONCAPA::map::getparameter($idx,'parameter_'.$which))[0];
2998: if ($which eq 'randompick') {
2999: if ($current =~ /^(\d+)$/) {
3000: $oldvalue = $1;
3001: }
3002: } elsif ($current =~ /^yes$/i) {
3003: $oldvalue = 1;
3004: }
1.484.2.29 raeburn 3005: if ($env{'form.'.$which.'_'.$idx}) {
1.484.2.59 raeburn 3006: $newvalue = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx}
3007: : 1;
1.484.2.29 raeburn 3008: }
1.484.2.59 raeburn 3009: if ($oldvalue ne $newvalue) {
3010: $haschanges = 1;
3011: if ($newvalue) {
3012: my $storeval = 'yes';
3013: if ($which eq 'randompick') {
3014: $storeval = $newvalue;
3015: }
3016: &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $storeval,
3017: $parameter_type{$which});
3018: &remember_parms($idx,$which,'set',$storeval);
3019: } else {
3020: &LONCAPA::map::delparameter($idx,'parameter_'.$which);
3021: &remember_parms($idx,$which,'del');
3022: }
3023: }
3024: return $haschanges;
1.329 droeschl 3025: }
1.484.2.59 raeburn 3026: return;
1.329 droeschl 3027: }
3028:
3029: sub handle_edit_cmd {
3030: my ($coursenum,$coursedom) =@_;
1.484.2.30 raeburn 3031: if ($env{'form.cmd'} eq '') {
3032: return 0;
3033: }
1.329 droeschl 3034: my ($cmd,$idx)=split('_',$env{'form.cmd'});
3035:
3036: my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
3037: my ($title, $url, @rrest) = split(':', $ratstr);
3038:
1.484.2.30 raeburn 3039: if ($cmd eq 'remove') {
1.329 droeschl 3040: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
1.463 www 3041: ($url!~/$LONCAPA::assess_page_seq_re/)) {
1.329 droeschl 3042: &Apache::lonnet::removeuploadedurl($url);
3043: } else {
3044: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
3045: }
3046: splice(@LONCAPA::map::order, $idx, 1);
3047:
3048: } elsif ($cmd eq 'cut') {
3049: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
3050: splice(@LONCAPA::map::order, $idx, 1);
3051:
1.344 bisitz 3052: } elsif ($cmd eq 'up'
1.329 droeschl 3053: && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
3054: @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
3055:
3056: } elsif ($cmd eq 'down'
3057: && defined($LONCAPA::map::order[$idx+1])) {
3058: @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
3059:
3060: } elsif ($cmd eq 'rename') {
3061: my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
3062: if ($comment=~/\S/) {
3063: $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
3064: $comment.':'.join(':', $url, @rrest);
3065: }
3066: # Devalidate title cache
3067: my $renamed_url=&LONCAPA::map::qtescape($url);
3068: &Apache::lonnet::devalidate_title_cache($renamed_url);
1.484.2.30 raeburn 3069:
1.329 droeschl 3070: } else {
3071: return 0;
3072: }
3073: return 1;
3074: }
3075:
3076: sub editor {
1.458 raeburn 3077: my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
1.484.2.85.2. (raeburn 3078:): $supplementalflag,$orderhash,$iconpath,$pathitem,$ltitoolsref,
3079:): $canedit,$hostname,$navmapref,$hiddentop)=@_;
1.484.2.19 raeburn 3080: my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
3081: if ($allowed) {
3082: (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
3083: $is_random_order,$container) =
3084: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
3085: $r->print($breadcrumbtrail);
3086: } elsif ($env{'form.folderpath'} =~ /\:1$/) {
3087: $container = 'page';
3088: } else {
3089: $container = 'sequence';
3090: }
1.484 raeburn 3091:
1.484.2.21 raeburn 3092: my $jumpto;
3093:
3094: unless ($supplementalflag) {
1.484.2.32 raeburn 3095: $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
1.484.2.21 raeburn 3096: }
1.484 raeburn 3097:
3098: unless ($allowed) {
3099: $randompick = -1;
3100: }
3101:
1.484.2.67 raeburn 3102: my ($errtext,$fatal);
3103: if (($folder eq '') && (!$supplementalflag)) {
3104: if (@LONCAPA::map::order) {
3105: undef(@LONCAPA::map::order);
3106: undef(@LONCAPA::map::resources);
3107: undef(@LONCAPA::map::resparms);
3108: undef(@LONCAPA::map::zombies);
3109: }
3110: $folder = 'default';
3111: $container = 'sequence';
3112: } else {
3113: ($errtext,$fatal) = &mapread($coursenum,$coursedom,
3114: $folder.'.'.$container);
3115: return $errtext if ($fatal);
3116: }
1.329 droeschl 3117:
3118: if ($#LONCAPA::map::order<1) {
3119: my $idx=&LONCAPA::map::getresidx();
3120: if ($idx<=0) { $idx=1; }
3121: $LONCAPA::map::order[0]=$idx;
3122: $LONCAPA::map::resources[$idx]='';
3123: }
1.364 bisitz 3124:
1.329 droeschl 3125: # ------------------------------------------------------------ Process commands
3126:
3127: # ---------------- if they are for this folder and user allowed to make changes
1.484.2.67 raeburn 3128: if (($allowed && $canedit) && ($env{'form.folder'} eq $folder)) {
1.329 droeschl 3129: # set parameters and change order
3130: &snapshotbefore();
3131:
3132: if (&update_parameter()) {
1.484.2.59 raeburn 3133: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1.329 droeschl 3134: return $errtext if ($fatal);
3135: }
3136:
3137: if ($env{'form.newpos'} && $env{'form.currentpos'}) {
3138: # change order
3139: my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
3140: splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
3141:
3142: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
3143: return $errtext if ($fatal);
3144: }
1.364 bisitz 3145:
1.329 droeschl 3146: if ($env{'form.pastemarked'}) {
1.484.2.7 raeburn 3147: my %paste_errors;
1.484.2.26 raeburn 3148: my ($paste_res,$save_error,$pastemsgarray,$lockerror) =
1.484.2.7 raeburn 3149: &do_paste_from_buffer($coursenum,$coursedom,$folder,$container,
3150: \%paste_errors);
1.484.2.30 raeburn 3151: if (ref($pastemsgarray) eq 'ARRAY') {
3152: if (@{$pastemsgarray} > 0) {
3153: $r->print('<p class="LC_info">'.
3154: join('<br />',@{$pastemsgarray}).
1.484.2.26 raeburn 3155: '</p>');
3156: }
1.484.2.30 raeburn 3157: }
3158: if ($lockerror) {
3159: $r->print('<p class="LC_error">'.
3160: $lockerror.
3161: '</p>');
3162: }
3163: if ($save_error ne '') {
3164: return $save_error;
3165: }
3166: if ($paste_res) {
3167: my %errortext = &Apache::lonlocal::texthash (
3168: fail => 'Storage of folder contents failed',
3169: failread => 'Reading folder contents failed',
3170: failstore => 'Storage of folder contents failed',
3171: );
3172: if ($errortext{$paste_res}) {
3173: $r->print('<p class="LC_error">'.$errortext{$paste_res}.'</p>');
1.484.2.7 raeburn 3174: }
1.329 droeschl 3175: }
1.484.2.7 raeburn 3176: if (keys(%paste_errors) > 0) {
1.484.2.30 raeburn 3177: $r->print('<p class="LC_warning">'."\n".
1.484.2.7 raeburn 3178: &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".
3179: '<ul>'."\n");
3180: foreach my $key (sort(keys(%paste_errors))) {
3181: $r->print('<li>'.$key.'</li>'."\n");
3182: }
3183: $r->print('</ul></p>'."\n");
3184: }
1.484.2.30 raeburn 3185: } elsif ($env{'form.clearmarked'}) {
3186: my $output = &do_buffer_empty();
3187: if ($output) {
3188: $r->print('<p class="LC_info">'.$output.'</p>');
3189: }
3190: }
1.329 droeschl 3191:
3192: $r->print($upload_output);
3193:
1.484.2.30 raeburn 3194: # Rename, cut, copy or remove a single resource
1.484.2.63 raeburn 3195: if (&handle_edit_cmd($coursenum,$coursedom)) {
1.484.2.7 raeburn 3196: my $contentchg;
1.484.2.58 raeburn 3197: if ($env{'form.cmd'} =~ m{^(remove|cut)_}) {
1.484.2.7 raeburn 3198: $contentchg = 1;
3199: }
3200: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);
1.329 droeschl 3201: return $errtext if ($fatal);
3202: }
1.484.2.30 raeburn 3203:
3204: # Cut, copy and/or remove multiple resources
3205: if ($env{'form.multichange'}) {
3206: my %allchecked = (
3207: cut => {},
3208: remove => {},
3209: );
3210: my $needsupdate;
3211: foreach my $which (keys(%allchecked)) {
3212: $env{'form.multi'.$which} =~ s/,$//;
3213: if ($env{'form.multi'.$which}) {
3214: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.multi'.$which});
3215: if (ref($allchecked{$which}) eq 'HASH') {
3216: $needsupdate += scalar(keys(%{$allchecked{$which}}));
3217: }
3218: }
3219: }
3220: if ($needsupdate) {
3221: my $haschanges = 0;
3222: my %curr_groups = &Apache::longroup::coursegroups();
3223: my $total = scalar(@LONCAPA::map::order) - 1;
3224: for (my $i=$total; $i>=0; $i--) {
3225: my $res = $LONCAPA::map::order[$i];
3226: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3227: $name=&LONCAPA::map::qtescape($name);
3228: $url=&LONCAPA::map::qtescape($url);
1.484.2.57 raeburn 3229: next unless $url;
1.484.2.30 raeburn 3230: my %denied =
3231: &action_restrictions($coursenum,$coursedom,$url,
3232: $env{'form.folderpath'},\%curr_groups);
3233: foreach my $which (keys(%allchecked)) {
3234: next if ($denied{$which});
3235: next unless ($allchecked{$which}{$res});
3236: if ($which eq 'remove') {
3237: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
3238: ($url!~/$LONCAPA::assess_page_seq_re/)) {
3239: &Apache::lonnet::removeuploadedurl($url);
3240: } else {
3241: &LONCAPA::map::makezombie($res);
3242: }
3243: splice(@LONCAPA::map::order,$i,1);
3244: $haschanges ++;
3245: } elsif ($which eq 'cut') {
3246: &LONCAPA::map::makezombie($res);
3247: splice(@LONCAPA::map::order,$i,1);
3248: $haschanges ++;
3249: }
3250: }
3251: }
3252: if ($haschanges) {
3253: ($errtext,$fatal) =
3254: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
3255: return $errtext if ($fatal);
3256: }
3257: }
3258: }
3259:
1.329 droeschl 3260: # Group import/search
3261: if ($env{'form.importdetail'}) {
3262: my @imports;
3263: foreach my $item (split(/\&/,$env{'form.importdetail'})) {
3264: if (defined($item)) {
3265: my ($name,$url,$residx)=
1.484.2.26 raeburn 3266: map { &unescape($_); } split(/\=/,$item);
3267: if ($url =~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
1.484.2.30 raeburn 3268: my ($suffix,$errortxt,$locknotfreed) =
1.484.2.26 raeburn 3269: &new_timebased_suffix($coursedom,$coursenum,'map',$1,$2);
1.484.2.15 raeburn 3270: if ($locknotfreed) {
3271: $r->print($locknotfreed);
3272: }
3273: if ($suffix) {
1.484.2.19 raeburn 3274: $url =~ s/_new\./_$suffix./;
1.484.2.15 raeburn 3275: } else {
3276: return $errortxt;
3277: }
1.484.2.26 raeburn 3278: } elsif ($url =~ m{^/adm/$match_domain/$match_username/new/(smppg|bulletinboard)$}) {
3279: my $type = $1;
3280: my ($suffix,$errortxt,$locknotfreed) =
3281: &new_timebased_suffix($coursedom,$coursenum,$type);
3282: if ($locknotfreed) {
3283: $r->print($locknotfreed);
3284: }
3285: if ($suffix) {
3286: $url =~ s{^(/adm/$match_domain/$match_username)/new}{$1/$suffix};
3287: } else {
3288: return $errortxt;
3289: }
1.484.2.85.2. (raeburn 3290:): } elsif ($url =~ m{^/adm/$coursedom/$coursenum/new/ext\.tool}) {
3291:): my ($suffix,$errortxt,$locknotfreed) =
3292:): &new_timebased_suffix($coursedom,$coursenum,'exttool');
3293:): if ($locknotfreed) {
3294:): $r->print($locknotfreed);
3295:): }
3296:): if ($suffix) {
3297:): $url =~ s{^(/adm/$coursedom/$coursenum)/new}{$1/$suffix};
3298:): } else {
3299:): return $errortxt;
3300:): }
1.484.2.27 raeburn 3301: } elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) {
3302: if ($supplementalflag) {
3303: next unless ($1 eq 'supplemental');
3304: if ($folder eq 'supplemental') {
3305: next unless ($2 eq 'default');
3306: } else {
3307: next unless ($folder eq 'supplemental_'.$2);
3308: }
3309: } else {
3310: next unless ($1 eq 'docs');
3311: if ($folder eq 'default') {
3312: next unless ($2 eq 'default');
3313: } else {
3314: next unless ($folder eq 'default_'.$2);
3315: }
3316: }
1.484.2.15 raeburn 3317: }
1.329 droeschl 3318: push(@imports, [$name, $url, $residx]);
3319: }
3320: }
1.484.2.23 raeburn 3321: ($errtext,$fatal,my $fixuperrors) =
3322: &group_import($coursenum, $coursedom, $folder,$container,
1.484.2.85.2. (raeburn 3323:): 'londocs',$ltitoolsref,@imports);
1.329 droeschl 3324: return $errtext if ($fatal);
1.484.2.23 raeburn 3325: if ($fixuperrors) {
3326: $r->print($fixuperrors);
3327: }
1.329 droeschl 3328: }
3329: # Loading a complete map
3330: if ($env{'form.loadmap'}) {
3331: if ($env{'form.importmap'}=~/\w/) {
3332: foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
3333: my ($title,$url,$ext,$type)=split(/\:/,$res);
3334: my $idx=&LONCAPA::map::getresidx($url);
3335: $LONCAPA::map::resources[$idx]=$res;
3336: $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
3337: }
3338: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.484.2.7 raeburn 3339: $folder.'.'.$container,1);
1.329 droeschl 3340: return $errtext if ($fatal);
3341: } else {
3342: $r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
1.364 bisitz 3343:
1.329 droeschl 3344: }
3345: }
3346: &log_differences($plain);
3347: }
3348: # ---------------------------------------------------------------- End commands
3349: # ---------------------------------------------------------------- Print screen
3350: my $idx=0;
3351: my $shown=0;
3352: if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
1.381 bisitz 3353: $r->print('<div class="LC_Box">'.
1.432 raeburn 3354: '<ol class="LC_docs_parameters"><li class="LC_docs_parameters_title">'.&mt('Parameters:').'</li>'.
3355: ($randompick>=0?'<li>'.&mt('randomly pick [quant,_1,resource]',$randompick).'</li>':'').
3356: ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
3357: ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
3358: ($is_random_order?'<li>'.&mt('random order').'</li>':'').
1.431 raeburn 3359: '</ol>');
1.381 bisitz 3360: if ($randompick>=0) {
3361: $r->print('<p class="LC_warning">'
3362: .&mt('Caution: this folder is set to randomly pick a subset'
3363: .' of resources. Adding or removing resources from this'
3364: .' folder will change the set of resources that the'
3365: .' students see, resulting in spurious or missing credit'
3366: .' for completed problems, not limited to ones you'
3367: .' modify. Do not modify the contents of this folder if'
3368: .' it is in active student use.')
3369: .'</p>'
3370: );
3371: }
3372: if ($is_random_order) {
3373: $r->print('<p class="LC_warning">'
3374: .&mt('Caution: this folder is set to randomly order its'
3375: .' contents. Adding or removing resources from this folder'
3376: .' will change the order of resources shown.')
3377: .'</p>'
3378: );
3379: }
3380: $r->print('</div>');
1.364 bisitz 3381: }
1.381 bisitz 3382:
1.484.2.30 raeburn 3383: my ($to_show,$output,@allidx,@allmapidx,%filters,%lists,%curr_groups);
3384: %filters = (
3385: canremove => [],
3386: cancut => [],
3387: cancopy => [],
3388: hiddenresource => [],
3389: encrypturl => [],
3390: randomorder => [],
3391: randompick => [],
3392: );
3393: %curr_groups = &Apache::longroup::coursegroups();
1.424 onken 3394: &Apache::loncommon::start_data_table_count(); #setup a row counter
1.381 bisitz 3395: foreach my $res (@LONCAPA::map::order) {
3396: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3397: $name=&LONCAPA::map::qtescape($name);
3398: $url=&LONCAPA::map::qtescape($url);
3399: unless ($name) { $name=(split(/\//,$url))[-1]; }
3400: unless ($name) { $idx++; next; }
1.484.2.29 raeburn 3401: push(@allidx,$res);
3402: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
3403: push(@allmapidx,$res);
3404: }
1.484.2.67 raeburn 3405:
1.381 bisitz 3406: $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
1.484.2.12 raeburn 3407: $coursenum,$coursedom,$crstype,
1.484.2.30 raeburn 3408: $pathitem,$supplementalflag,$container,
1.484.2.85.2. (raeburn 3409:): \%filters,\%curr_groups,$ltitoolsref,$canedit,
1.484.2.80 raeburn 3410: $isencrypted,$navmapref,$hostname);
1.381 bisitz 3411: $idx++;
3412: $shown++;
1.329 droeschl 3413: }
1.424 onken 3414: &Apache::loncommon::end_data_table_count();
1.484.2.19 raeburn 3415:
1.484.2.30 raeburn 3416: my $need_save;
1.484.2.67 raeburn 3417: if ($allowed || ($supplementalflag && $folder eq 'supplemental')) {
1.484.2.31 raeburn 3418: my $toolslink;
1.484.2.67 raeburn 3419: if ($allowed) {
1.484.2.31 raeburn 3420: $toolslink = '<table><tr><td>'
1.484.2.19 raeburn 3421: .&Apache::loncommon::help_open_menu('Navigation Screen',
3422: 'Navigation_Screen',undef,'RAT')
3423: .'</td><td class="LC_middle">'.&mt('Tools:').'</td>'
3424: .'<td align="left"><ul id="LC_toolbar">'
1.484.2.21 raeburn 3425: .'<li><a href="/adm/coursedocs?forcesupplement=1&command=editsupp" '
1.484.2.19 raeburn 3426: .'id="LC_content_toolbar_edittoplevel" '
3427: .'class="LC_toolbarItem" '
3428: .'title="'.&mt('Supplemental Content Editor').'">'
3429: .'</a></li></ul></td></tr></table><br />';
1.484.2.31 raeburn 3430: }
1.484.2.19 raeburn 3431: if ($shown) {
3432: if ($allowed) {
3433: $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
3434: .&Apache::loncommon::start_data_table(undef,'contentlist')
3435: .&Apache::loncommon::start_data_table_header_row()
3436: .'<th colspan="2">'.&mt('Move').'</th>'
1.484.2.30 raeburn 3437: .'<th colspan="2">'.&mt('Actions').'</th>'
3438: .'<th>'.&mt('Document').'</th>';
1.484.2.19 raeburn 3439: if ($folder !~ /^supplemental/) {
3440: $to_show .= '<th colspan="4">'.&mt('Settings').'</th>';
3441: }
1.484.2.29 raeburn 3442: $to_show .= &Apache::loncommon::end_data_table_header_row();
3443: if ($folder !~ /^supplemental/) {
1.484.2.30 raeburn 3444: $lists{'canhide'} = join(',',@allidx);
3445: $lists{'canrandomlyorder'} = join(',',@allmapidx);
3446: my @possfilters = ('canremove','cancut','cancopy','hiddenresource','encrypturl',
3447: 'randomorder','randompick');
3448: foreach my $item (@possfilters) {
3449: if (ref($filters{$item}) eq 'ARRAY') {
3450: if (@{$filters{$item}} > 0) {
3451: $lists{$item} = join(',',@{$filters{$item}});
3452: }
3453: }
3454: }
1.484.2.29 raeburn 3455: if (@allidx > 0) {
3456: my $path;
3457: if ($env{'form.folderpath'}) {
3458: $path =
3459: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3460: }
1.484.2.30 raeburn 3461: if (@allidx > 1) {
3462: $to_show .=
3463: &Apache::loncommon::continue_data_table_row().
3464: '<td colspan="2"> </td>'.
3465: '<td>'.
1.484.2.67 raeburn 3466: &multiple_check_form('actions',\%lists,$canedit).
1.484.2.30 raeburn 3467: '</td>'.
3468: '<td> </td>'.
3469: '<td> </td>'.
3470: '<td colspan="4">'.
1.484.2.67 raeburn 3471: &multiple_check_form('settings',\%lists,$canedit).
1.484.2.30 raeburn 3472: '</td>'.
3473: &Apache::loncommon::end_data_table_row();
3474: $need_save = 1;
3475: }
1.484.2.29 raeburn 3476: }
3477: }
3478: $to_show .= $output.' '
1.484.2.19 raeburn 3479: .&Apache::loncommon::end_data_table()
3480: .'<br style="line-height:2px;" />'
3481: .&Apache::loncommon::end_scrollbox();
3482: } else {
3483: $to_show .= $toolslink
3484: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3485: .$output.' '
3486: .&Apache::loncommon::end_data_table();
3487: }
3488: } else {
3489: if (!$allowed) {
3490: $to_show .= $toolslink;
1.393 raeburn 3491: }
1.484.2.67 raeburn 3492: my $noresmsg;
3493: if ($allowed && $hiddentop && !$supplementalflag) {
3494: $noresmsg = &mt('Main Content Hidden');
3495: } else {
3496: $noresmsg = &mt('Currently empty');
3497: }
1.484.2.19 raeburn 3498: $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
3499: .'<div class="LC_info" id="contentlist">'
1.484.2.67 raeburn 3500: .$noresmsg
1.484.2.19 raeburn 3501: .'</div>'
3502: .&Apache::loncommon::end_scrollbox();
1.393 raeburn 3503: }
3504: } else {
1.484.2.19 raeburn 3505: if ($shown) {
3506: $to_show = '<div>'
3507: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3508: .$output
3509: .&Apache::loncommon::end_data_table()
3510: .'</div>';
3511: } else {
3512: $to_show = '<div class="LC_info" id="contentlist">'
1.484.2.34 raeburn 3513: .&mt('Currently empty')
1.484.2.19 raeburn 3514: .'</div>'
3515: }
1.458 raeburn 3516: }
3517: my $tid = 1;
3518: if ($supplementalflag) {
3519: $tid = 2;
1.329 droeschl 3520: }
3521: if ($allowed) {
1.484 raeburn 3522: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
1.484.2.30 raeburn 3523: $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,
1.484.2.67 raeburn 3524: $jumpto,$readfile,$need_save,"$folder.$container",$canedit));
1.484.2.68 raeburn 3525: if ($canedit) {
1.484.2.67 raeburn 3526: &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
3527: }
1.460 raeburn 3528: } else {
3529: $r->print($to_show);
1.329 droeschl 3530: }
3531: return;
3532: }
3533:
1.484.2.30 raeburn 3534: sub multiple_check_form {
1.484.2.67 raeburn 3535: my ($caller,$listsref,$canedit) = @_;
1.484.2.30 raeburn 3536: return unless (ref($listsref) eq 'HASH');
1.484.2.67 raeburn 3537: my $disabled;
3538: unless ($canedit) {
3539: $disabled = 'disabled="disabled"';
3540: }
1.484.2.30 raeburn 3541: my $output =
3542: '<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'.
3543: '<span class="LC_nobreak" style="font-size:x-small;font-weight:bold;">'.
3544: '<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>'.
3545: '<div id="multi'.$caller.'" style="display:none;margin:0;padding:0;border:0">'.
3546: '<form action="/adm/coursedocs" method="post" name="cumulative'.$caller.'">'."\n".
3547: '<fieldset id="allfields'.$caller.'" style="display:none"><legend style="font-size:x-small;">'.&mt('check/uncheck all').'</legend>'."\n";
3548: if ($caller eq 'settings') {
3549: $output .=
3550: '<table><tr>'.
3551: '<td class="LC_docs_entry_parameter">'.
3552: '<span class="LC_nobreak"><label>'.
1.484.2.67 raeburn 3553: '<input type="checkbox" name="hiddenresourceall" id="hiddenresourceall" onclick="propagateState(this.form,'."'hiddenresource'".')"'.$disabled.' />'.&mt('Hidden').
1.484.2.30 raeburn 3554: '</label></span></td>'.
3555: '<td class="LC_docs_entry_parameter">'.
1.484.2.67 raeburn 3556: '<span class="LC_nobreak"><label><input type="checkbox" name="randompickall" id="randompickall" onclick="updatePick(this.form,'."'all','check'".');propagateState(this.form,'."'randompick'".');propagateState(this.form,'."'rpicknum'".');"'.$disabled.' />'.&mt('Randomly Pick').'</label><span id="rpicktextall"></span><input type="hidden" name="rpicknumall" id="rpicknumall" value="" />'.
1.484.2.30 raeburn 3557: '</span></td>'.
3558: '</tr>'."\n".
3559: '<tr>'.
3560: '<td class="LC_docs_entry_parameter">'.
1.484.2.67 raeburn 3561: '<span class="LC_nobreak"><label><input type="checkbox" name="encrypturlall" id="encrypturlall" onclick="propagateState(this.form,'."'encrypturl'".')"'.$disabled.' />'.&mt('URL hidden').'</label></span></td><td class="LC_docs_entry_parameter"><span class="LC_nobreak"><label><input type="checkbox" name="randomorderall" id="randomorderall" onclick="propagateState(this.form,'."'randomorder'".')"'.$disabled.' />'.&mt('Random Order').
1.484.2.30 raeburn 3562: '</label></span>'.
3563: '</td></tr></table>'."\n";
3564: } else {
3565: $output .=
3566: '<table><tr>'.
3567: '<td class="LC_docs_entry_parameter">'.
3568: '<span class="LC_nobreak LC_docs_remove">'.
1.484.2.67 raeburn 3569: '<label><input type="checkbox" name="removeall" id="removeall" onclick="propagateState(this.form,'."'remove'".')"'.$disabled.' />'.&mt('Remove').
1.484.2.30 raeburn 3570: '</label></span></td>'.
3571: '<td class="LC_docs_entry_parameter">'.
3572: '<span class="LC_nobreak LC_docs_cut">'.
1.484.2.67 raeburn 3573: '<label><input type="checkbox" name="cut" id="cutall" onclick="propagateState(this.form,'."'cut'".');"'.$disabled.' />'.&mt('Cut').
1.484.2.30 raeburn 3574: '</label></span></td>'."\n".
3575: '<td class="LC_docs_entry_parameter">'.
3576: '<span class="LC_nobreak LC_docs_copy">'.
1.484.2.67 raeburn 3577: '<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')"'.$disabled.' />'.&mt('Copy').
1.484.2.30 raeburn 3578: '</label></span></td>'.
3579: '</tr></table>'."\n";
3580: }
3581: $output .=
3582: '</fieldset>'.
3583: '<input type="hidden" name="allidx" value="'.$listsref->{'canhide'}.'" />';
3584: if ($caller eq 'settings') {
3585: $output .=
3586: '<input type="hidden" name="allmapidx" value="'.$listsref->{'canrandomlyorder'}.'" />'."\n".
3587: '<input type="hidden" name="currhiddenresource" value="'.$listsref->{'hiddenresource'}.'" />'."\n".
3588: '<input type="hidden" name="currencrypturl" value="'.$listsref->{'encrypturl'}.'" />'."\n".
3589: '<input type="hidden" name="currrandomorder" value="'.$listsref->{'randomorder'}.'" />'."\n".
3590: '<input type="hidden" name="currrandompick" value="'.$listsref->{'randompick'}.'" />'."\n";
3591: } elsif ($caller eq 'actions') {
3592: $output .=
3593: '<input type="hidden" name="allremoveidx" id="allremoveidx" value="'.$listsref->{'canremove'}.'" />'.
3594: '<input type="hidden" name="allcutidx" id="allcutidx" value="'.$listsref->{'cancut'}.'" />'.
3595: '<input type="hidden" name="allcopyidx" id="allcopyidx" value="'.$listsref->{'cancopy'}.'" />';
3596: }
3597: $output .=
3598: '</form>'.
3599: '</div>';
3600: return $output;
3601: }
3602:
1.329 droeschl 3603: sub process_file_upload {
1.484.2.36 raeburn 3604: my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd,$crstype) = @_;
1.329 droeschl 3605: # upload a file, if present
1.484.2.36 raeburn 3606: my $filesize = length($env{'form.uploaddoc'});
3607: if (!$filesize) {
3608: $$upload_output = '<div class="LC_error">'.
3609: &mt('Unable to upload [_1]. (size = [_2] bytes)',
3610: '<span class="LC_filename">'.$env{'form.uploaddoc.filename'}.'</span>',
3611: $filesize).'<br />'.
3612: &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'<br />'.
3613: '</div>';
3614: return;
3615: }
3616: my $quotatype = 'unofficial';
3617: if ($crstype eq 'Community') {
3618: $quotatype = 'community';
1.484.2.51 raeburn 3619: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
1.484.2.36 raeburn 3620: $quotatype = 'official';
1.484.2.45 raeburn 3621: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
3622: $quotatype = 'textbook';
1.484.2.36 raeburn 3623: }
3624: if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) {
3625: $filesize = int($filesize/1000); #expressed in kb
3626: $$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course',
1.484.2.51 raeburn 3627: $env{'form.uploaddoc.filename'},$filesize,
3628: 'upload',$quotatype);
1.484.2.36 raeburn 3629: return if ($$upload_output);
3630: }
1.440 raeburn 3631: my ($parseaction,$showupload,$nextphase,$mimetype);
3632: if ($env{'form.parserflag'}) {
1.329 droeschl 3633: $parseaction = 'parse';
3634: }
3635: my $folder=$env{'form.folder'};
3636: if ($folder eq '') {
3637: $folder='default';
3638: }
3639: if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
3640: my $errtext='';
3641: my $fatal=0;
3642: my $container='sequence';
1.484.2.19 raeburn 3643: if ($env{'form.folderpath'} =~ /:1$/) {
1.329 droeschl 3644: $container='page';
3645: }
3646: ($errtext,$fatal)=
1.484.2.27 raeburn 3647: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1.329 droeschl 3648: if ($#LONCAPA::map::order<1) {
3649: $LONCAPA::map::order[0]=1;
3650: $LONCAPA::map::resources[1]='';
3651: }
3652: my $destination = 'docs/';
3653: if ($folder =~ /^supplemental/) {
3654: $destination = 'supplemental/';
3655: }
3656: if (($folder eq 'default') || ($folder eq 'supplemental')) {
3657: $destination .= 'default/';
3658: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
3659: $destination .= $2.'/';
3660: }
1.484.2.27 raeburn 3661: if ($fatal) {
3662: $$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>';
3663: return;
3664: }
1.440 raeburn 3665: # this is for a course, not a user, so set context to coursedoc.
1.329 droeschl 3666: my $newidx=&LONCAPA::map::getresidx();
3667: $destination .= $newidx;
1.439 raeburn 3668: my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination,
1.329 droeschl 3669: $parseaction,$allfiles,
1.440 raeburn 3670: $codebase,undef,undef,undef,undef,
3671: undef,undef,\$mimetype);
3672: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) {
3673: my $stored = $1;
3674: $showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'.
3675: $stored.'</span>').'</p>';
3676: } else {
3677: my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});
3678:
1.457 raeburn 3679: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>';
1.440 raeburn 3680: return;
3681: }
1.329 droeschl 3682: my $ext='false';
3683: if ($url=~m{^http://}) { $ext='true'; }
3684: $url = &LONCAPA::map::qtunescape($url);
3685: my $comment=$env{'form.comment'};
3686: $comment = &LONCAPA::map::qtunescape($comment);
3687: if ($folder=~/^supplemental/) {
3688: $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
3689: $env{'user.domain'}.'___&&&___'.$comment;
3690: }
3691:
3692: $LONCAPA::map::resources[$newidx]=
3693: $comment.':'.$url.':'.$ext.':normal:res';
3694: $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
3695: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.484.2.7 raeburn 3696: $folder.'.'.$container,1);
1.329 droeschl 3697: if ($fatal) {
1.457 raeburn 3698: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>';
1.440 raeburn 3699: return;
1.329 droeschl 3700: } else {
1.440 raeburn 3701: if ($parseaction eq 'parse' && $mimetype eq 'text/html') {
3702: $$upload_output = $showupload;
1.384 raeburn 3703: my $total_embedded = scalar(keys(%{$allfiles}));
1.329 droeschl 3704: if ($total_embedded > 0) {
1.440 raeburn 3705: my $uploadphase = 'upload_embedded';
3706: my $primaryurl = &HTML::Entities::encode($url,'<>&"');
3707: my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx);
3708: my ($embedded,$num) =
3709: &Apache::loncommon::ask_for_embedded_content(
3710: '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url});
3711: if ($embedded) {
3712: if ($num) {
3713: $$upload_output .=
3714: '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
3715: $nextphase = $uploadphase;
3716: } else {
3717: $$upload_output .= $embedded;
3718: }
3719: } else {
3720: $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
3721: }
1.329 droeschl 3722: } else {
1.440 raeburn 3723: $$upload_output .= &mt('No embedded items identified').'<br />';
1.329 droeschl 3724: }
1.457 raeburn 3725: $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
1.484.2.51 raeburn 3726: } elsif ((&Apache::loncommon::is_archive_file($mimetype)) &&
3727: ($env{'form.uploaddoc.filename'} =~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i)) {
1.476 raeburn 3728: $nextphase = 'decompress_uploaded';
3729: my $position = scalar(@LONCAPA::map::order)-1;
3730: my $noextract = &return_to_editor();
3731: my $archiveurl = &HTML::Entities::encode($url,'<>&"');
3732: my %archiveitems = (
3733: folderpath => $env{'form.folderpath'},
3734: cmd => $nextphase,
3735: newidx => $newidx,
3736: position => $position,
3737: phase => $nextphase,
1.477 raeburn 3738: comment => $comment,
1.480 raeburn 3739: );
3740: my ($destination,$dir_root) = &embedded_destination($coursenum,$coursedom);
3741: my @current = &get_dir_list($url,$coursenum,$coursedom,$newidx);
1.476 raeburn 3742: $$upload_output = $showupload.
3743: &Apache::loncommon::decompress_form($mimetype,
3744: $archiveurl,'/adm/coursedocs',$noextract,
1.480 raeburn 3745: \%archiveitems,\@current);
1.329 droeschl 3746: }
3747: }
3748: }
1.440 raeburn 3749: return $nextphase;
1.329 droeschl 3750: }
3751:
1.480 raeburn 3752: sub get_dir_list {
3753: my ($url,$coursenum,$coursedom,$newidx) = @_;
3754: my ($destination,$dir_root) = &embedded_destination();
3755: my ($dirlistref,$listerror) =
3756: &Apache::lonnet::dirlist("$dir_root/$destination/$newidx",$coursedom,$coursenum,1);
3757: my @dir_lines;
3758: my $dirptr=16384;
3759: if (ref($dirlistref) eq 'ARRAY') {
3760: foreach my $dir_line (sort
3761: {
3762: my ($afile)=split('&',$a,2);
3763: my ($bfile)=split('&',$b,2);
3764: return (lc($afile) cmp lc($bfile));
3765: } (@{$dirlistref})) {
3766: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
3767: $filename =~ s/\s+$//;
3768: next if ($filename =~ /^\.\.?$/);
3769: my $isdir = 0;
3770: if ($dirptr&$testdir) {
3771: $isdir = 1;
3772: }
3773: push(@dir_lines, [$filename,$dom,$isdir,$size,$mtime,$obs]);
3774: }
3775: }
3776: return @dir_lines;
3777: }
3778:
1.329 droeschl 3779: sub is_supplemental_title {
3780: my ($title) = @_;
3781: return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
3782: }
3783:
3784: # --------------------------------------------------------------- An entry line
3785:
3786: sub entryline {
1.484.2.12 raeburn 3787: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
1.484.2.67 raeburn 3788: $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups,
1.484.2.85.2. (raeburn 3789:): $ltitoolsref,$canedit,$isencrypted,$navmapref,$hostname)=@_;
1.484.2.52 raeburn 3790: my ($foldertitle,$renametitle,$oldtitle);
1.329 droeschl 3791: if (&is_supplemental_title($title)) {
1.484.2.7 raeburn 3792: ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
1.329 droeschl 3793: } else {
3794: $title=&HTML::Entities::encode($title,'"<>&\'');
3795: $renametitle=$title;
3796: $foldertitle=$title;
3797: }
3798:
1.484.2.67 raeburn 3799: my ($disabled,$readonly,$js_lt);
3800: unless ($canedit) {
3801: $disabled = 'disabled="disabled"';
3802: $readonly = 1;
3803: }
3804:
1.329 droeschl 3805: my $orderidx=$LONCAPA::map::order[$index];
1.364 bisitz 3806:
1.329 droeschl 3807: $renametitle=~s/\\/\\\\/g;
3808: $renametitle=~s/\"\;/\\\"/g;
1.484.2.55 raeburn 3809: $renametitle=~s/"/%22/g;
1.329 droeschl 3810: $renametitle=~s/ /%20/g;
1.484.2.52 raeburn 3811: $oldtitle = $renametitle;
3812: $renametitle=~s/\'\;/\\\'/g;
1.379 bisitz 3813: my $line=&Apache::loncommon::start_data_table_row();
1.484.2.30 raeburn 3814: my ($form_start,$form_end,$form_common,$form_param);
1.329 droeschl 3815: # Edit commands
1.484.2.28 raeburn 3816: my ($esc_path, $path, $symb);
1.329 droeschl 3817: if ($env{'form.folderpath'}) {
3818: $esc_path=&escape($env{'form.folderpath'});
3819: $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3820: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
3821: }
1.484.2.16 raeburn 3822: my $isexternal;
1.484.2.19 raeburn 3823: if ($residx) {
1.484.2.12 raeburn 3824: my $currurl = $url;
3825: $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.484.2.16 raeburn 3826: if ($currurl =~ m{^/adm/wrapper/ext/}) {
3827: $isexternal = 1;
3828: }
1.484.2.19 raeburn 3829: if (!$supplementalflag) {
3830: my $path = 'uploaded/'.
3831: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
3832: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
3833: $symb = &Apache::lonnet::encode_symb($path.$folder.".$container",
3834: $residx,
3835: &Apache::lonnet::declutter($currurl));
3836: }
1.484.2.12 raeburn 3837: }
1.484.2.30 raeburn 3838: my ($renamelink,%lt,$ishash);
3839: if (ref($filtersref) eq 'HASH') {
3840: $ishash = 1;
3841: }
3842:
1.329 droeschl 3843: if ($allowed) {
1.484.2.30 raeburn 3844: $form_start = '
3845: <form action="/adm/coursedocs" method="post">
3846: ';
3847: $form_common=(<<END);
3848: <input type="hidden" name="folderpath" value="$path" />
3849: <input type="hidden" name="symb" value="$symb" />
3850: END
3851: $form_param=(<<END);
3852: <input type="hidden" name="setparms" value="$orderidx" />
3853: <input type="hidden" name="changeparms" value="0" />
3854: END
3855: $form_end = '</form>';
3856:
1.329 droeschl 3857: my $incindex=$index+1;
3858: my $selectbox='';
1.471 raeburn 3859: if (($#LONCAPA::map::order>0) &&
1.329 droeschl 3860: ((split(/\:/,
1.344 bisitz 3861: $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
3862: ne '') &&
1.329 droeschl 3863: ((split(/\:/,
1.344 bisitz 3864: $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1.329 droeschl 3865: ne '')) {
3866: $selectbox=
3867: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.484.2.67 raeburn 3868: '<select name="newpos" onchange="this.form.submit()"'.$disabled.'>';
1.329 droeschl 3869: for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
3870: if ($i==$incindex) {
1.358 bisitz 3871: $selectbox.='<option value="" selected="selected">('.$i.')</option>';
1.329 droeschl 3872: } else {
3873: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
3874: }
3875: }
3876: $selectbox.='</select>';
3877: }
1.484.2.12 raeburn 3878: %lt=&Apache::lonlocal::texthash(
1.329 droeschl 3879: 'up' => 'Move Up',
3880: 'dw' => 'Move Down',
3881: 'rm' => 'Remove',
3882: 'ct' => 'Cut',
3883: 'rn' => 'Rename',
1.484.2.12 raeburn 3884: 'cp' => 'Copy',
3885: 'ex' => 'External Resource',
1.484.2.85.2. (raeburn 3886:): 'et' => 'External Tool',
1.484.2.12 raeburn 3887: 'ed' => 'Edit',
3888: 'pr' => 'Preview',
3889: 'sv' => 'Save',
3890: 'ul' => 'URL',
1.484.2.67 raeburn 3891: 'ti' => 'Title',
3892: 'er' => 'Editing rights unavailable for your current role.',
1.484.2.12 raeburn 3893: );
1.484.2.30 raeburn 3894: my %denied = &action_restrictions($coursenum,$coursedom,$url,
3895: $env{'form.folderpath'},
3896: $currgroups);
1.484.2.19 raeburn 3897: my ($copylink,$cutlink,$removelink);
1.329 droeschl 3898: my $skip_confirm = 0;
1.484.2.63 raeburn 3899: my $confirm_removal = 0;
1.329 droeschl 3900: if ( $folder =~ /^supplemental/
3901: || ($url =~ m{( /smppg$
3902: |/syllabus$
3903: |/aboutme$
3904: |/navmaps$
3905: |/bulletinboard$
1.484.2.85.2. (raeburn 3906:): |/ext\.tool$
1.484.2.16 raeburn 3907: |\.html$)}x)
1.484.2.19 raeburn 3908: || $isexternal) {
1.329 droeschl 3909: $skip_confirm = 1;
3910: }
1.484.2.63 raeburn 3911: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
3912: ($url!~/$LONCAPA::assess_page_seq_re/)) {
3913: $confirm_removal = 1;
3914: }
1.484.2.19 raeburn 3915:
1.484.2.30 raeburn 3916: if ($denied{'copy'}) {
3917: $copylink=(<<ENDCOPY)
1.484.2.16 raeburn 3918: <span style="visibility: hidden;">$lt{'cp'}</span>
3919: ENDCOPY
3920: } else {
1.484.2.30 raeburn 3921: my $formname = 'edit_copy_'.$orderidx;
3922: my $js = "javascript:checkForSubmit(document.forms.renameform,'copy','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.484.2.19 raeburn 3923: $copylink=(<<ENDCOPY);
1.484.2.30 raeburn 3924: <form name="$formname" method="post" action="/adm/coursedocs">
3925: $form_common
1.484.2.67 raeburn 3926: <input type="checkbox" name="copy" id="copy_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','copy');" class="LC_hidden" $disabled /><a href="$js" class="LC_docs_copy">$lt{'cp'}</a>
1.484.2.30 raeburn 3927: $form_end
1.329 droeschl 3928: ENDCOPY
1.484.2.30 raeburn 3929: if (($ishash) && (ref($filtersref->{'cancopy'}) eq 'ARRAY')) {
3930: push(@{$filtersref->{'cancopy'}},$orderidx);
3931: }
1.329 droeschl 3932: }
1.484.2.30 raeburn 3933: if ($denied{'cut'}) {
1.484.2.16 raeburn 3934: $cutlink=(<<ENDCUT);
3935: <span style="visibility: hidden;">$lt{'ct'}</span>
3936: ENDCUT
3937: } else {
1.484.2.30 raeburn 3938: my $formname = 'edit_cut_'.$orderidx;
3939: my $js = "javascript:checkForSubmit(document.forms.renameform,'cut','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.484.2.19 raeburn 3940: $cutlink=(<<ENDCUT);
1.484.2.30 raeburn 3941: <form name="$formname" method="post" action="/adm/coursedocs">
3942: $form_common
3943: <input type="hidden" name="skip_$orderidx" id="skip_cut_$orderidx" value="$skip_confirm" />
1.484.2.67 raeburn 3944: <input type="checkbox" name="cut" id="cut_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','cut');" class="LC_hidden" $disabled /><a href="$js" class="LC_docs_cut">$lt{'ct'}</a>
1.484.2.30 raeburn 3945: $form_end
1.329 droeschl 3946: ENDCUT
1.484.2.30 raeburn 3947: if (($ishash) && (ref($filtersref->{'cancut'}) eq 'ARRAY')) {
3948: push(@{$filtersref->{'cancut'}},$orderidx);
3949: }
1.329 droeschl 3950: }
1.484.2.30 raeburn 3951: if ($denied{'remove'}) {
1.484.2.16 raeburn 3952: $removelink=(<<ENDREM);
3953: <span style="visibility: hidden;">$lt{'rm'}</a>
3954: ENDREM
3955: } else {
1.484.2.30 raeburn 3956: my $formname = 'edit_remove_'.$orderidx;
1.484.2.63 raeburn 3957: my $js = "javascript:checkForSubmit(document.forms.renameform,'remove','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder',$confirm_removal);";
1.484.2.9 raeburn 3958: $removelink=(<<ENDREM);
1.484.2.30 raeburn 3959: <form name="$formname" method="post" action="/adm/coursedocs">
3960: $form_common
3961: <input type="hidden" name="skip_$orderidx" id="skip_remove_$orderidx" value="$skip_confirm" />
1.484.2.63 raeburn 3962: <input type="hidden" name="confirm_rem_$orderidx" id="confirm_removal_$orderidx" value="$confirm_removal" />
1.484.2.67 raeburn 3963: <input type="checkbox" name="remove" id="remove_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','remove');" class="LC_hidden" $disabled /><a href="$js" class="LC_docs_remove">$lt{'rm'}</a>
1.484.2.30 raeburn 3964: $form_end
1.484.2.9 raeburn 3965: ENDREM
1.484.2.30 raeburn 3966: if (($ishash) && (ref($filtersref->{'canremove'}) eq 'ARRAY')) {
3967: push(@{$filtersref->{'canremove'}},$orderidx);
3968: }
1.484.2.9 raeburn 3969: }
1.484.2.35 raeburn 3970: $renamelink=(<<ENDREN);
1.484.2.52 raeburn 3971: <a href='javascript:changename("$esc_path","$index","$oldtitle");' class="LC_docs_rename">$lt{'rn'}</a>
1.484.2.16 raeburn 3972: ENDREN
1.484.2.67 raeburn 3973: my ($uplink,$downlink);
3974: if ($canedit) {
3975: $uplink = "/adm/coursedocs?cmd=up_$index&folderpath=$esc_path&symb=$symb";
3976: $downlink = "/adm/coursedocs?cmd=down_$index&folderpath=$esc_path&symb=$symb";
3977: } else {
3978: $uplink = "javascript:alert('".&js_escape($lt{'er'})."');";
3979: $downlink = $uplink;
3980: }
1.329 droeschl 3981: $line.=(<<END);
3982: <td>
1.379 bisitz 3983: <div class="LC_docs_entry_move">
1.484.2.67 raeburn 3984: <a href="$uplink">
1.484.2.12 raeburn 3985: <img src="${iconpath}move_up.gif" alt="$lt{'up'}" class="LC_icon" />
1.379 bisitz 3986: </a>
3987: </div>
3988: <div class="LC_docs_entry_move">
1.484.2.67 raeburn 3989: <a href="$downlink">
1.484.2.12 raeburn 3990: <img src="${iconpath}move_down.gif" alt="$lt{'dw'}" class="LC_icon" />
1.379 bisitz 3991: </a>
3992: </div>
1.329 droeschl 3993: </td>
3994: <td>
3995: $form_start
1.484.2.30 raeburn 3996: $form_param
1.478 raeburn 3997: $form_common
1.329 droeschl 3998: $selectbox
3999: $form_end
4000: </td>
1.484.2.30 raeburn 4001: <td class="LC_docs_entry_commands LC_nobreak">
1.484.2.9 raeburn 4002: $removelink
1.329 droeschl 4003: $cutlink
4004: $copylink
4005: </td>
4006: END
4007: }
4008: # Figure out what kind of a resource this is
4009: my ($extension)=($url=~/\.(\w+)$/);
4010: my $uploaded=($url=~/^\/*uploaded\//);
4011: my $icon=&Apache::loncommon::icon($url);
1.484.2.19 raeburn 4012: my $isfolder;
4013: my $ispage;
4014: my $containerarg;
1.484.2.67 raeburn 4015: my $folderurl;
1.329 droeschl 4016: if ($uploaded) {
1.472 raeburn 4017: if (($extension eq 'sequence') || ($extension eq 'page')) {
4018: $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
1.484.2.19 raeburn 4019: $containerarg = $1;
1.472 raeburn 4020: if ($extension eq 'sequence') {
4021: $icon=$iconpath.'navmap.folder.closed.gif';
4022: $isfolder=1;
4023: } else {
4024: $icon=$iconpath.'page.gif';
4025: $ispage=1;
4026: }
1.484.2.67 raeburn 4027: $folderurl = &Apache::lonnet::declutter($url);
1.472 raeburn 4028: if ($allowed) {
4029: $url='/adm/coursedocs?';
4030: } else {
4031: $url='/adm/supplemental?';
4032: }
1.329 droeschl 4033: } else {
4034: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
4035: }
4036: }
1.364 bisitz 4037:
1.484.2.70 raeburn 4038: my ($editlink,$extresform,$anchor,$hiddenres,$nomodal);
1.329 droeschl 4039: my $orig_url = $url;
1.340 raeburn 4040: $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
1.484.2.19 raeburn 4041: $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.484.2.12 raeburn 4042: if (!$supplementalflag && $residx && $symb) {
4043: if ((!$isfolder) && (!$ispage)) {
4044: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
4045: $url=&Apache::lonnet::clutter($url);
4046: if ($url=~/^\/*uploaded\//) {
4047: $url=~/\.(\w+)$/;
4048: my $embstyle=&Apache::loncommon::fileembstyle($1);
4049: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
4050: $url='/adm/wrapper'.$url;
4051: } elsif ($embstyle eq 'ssi') {
4052: #do nothing with these
4053: } elsif ($url!~/\.(sequence|page)$/) {
4054: $url='/adm/coursedocs/showdoc'.$url;
4055: }
1.484.2.70 raeburn 4056: } elsif ($url=~m{^(|/adm/wrapper)/ext/([^#]+)}) {
4057: my $wrapped = $1;
4058: my $exturl = $2;
4059: if ($wrapped eq '') {
4060: $url='/adm/wrapper'.$url;
4061: }
4062: if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) {
4063: $nomodal = 1;
4064: }
1.484.2.85.2. (raeburn 4065:): } elsif ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4066:): $url='/adm/wrapper'.$url;
1.484.2.70 raeburn 4067: } elsif ($url eq "/public/$coursedom/$coursenum/syllabus") {
4068: if (($ENV{'SERVER_PORT'} == 443) &&
4069: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
1.484.2.80 raeburn 4070: unless (&Apache::lonnet::uses_sts()) {
4071: $url .= '?usehttp=1';
4072: }
1.484.2.70 raeburn 4073: $nomodal = 1;
4074: }
1.484.2.19 raeburn 4075: }
1.484.2.12 raeburn 4076: if (&Apache::lonnet::symbverify($symb,$url)) {
1.484.2.66 raeburn 4077: my $shownsymb = $symb;
4078: if ($isexternal) {
4079: if ($url =~ /^([^#]+)#([^#]+)$/) {
4080: $url = $1;
4081: $anchor = $2;
1.484.2.80 raeburn 4082: my $escan = &escape('#');
4083: $shownsymb =~ s/^([^\#]+)#([^\#]+)$/$1$escan$2/;
1.484.2.66 raeburn 4084: }
4085: }
1.484.2.67 raeburn 4086: unless ($env{'request.role.adv'}) {
4087: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4088: $url = '';
4089: }
4090: if (&Apache::lonnet::EXT('resource.0.hiddenresource',$symb) =~ /^yes$/i) {
4091: $url = '';
4092: $hiddenres = 1;
4093: }
4094: }
4095: if ($url ne '') {
1.484.2.75 raeburn 4096: $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
1.484.2.67 raeburn 4097: }
4098: } elsif (!$env{'request.role.adv'}) {
4099: my $checkencrypt;
4100: if (((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) ||
4101: $isencrypted || (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i)) {
4102: $checkencrypt = 1;
1.484.2.70 raeburn 4103: } elsif (ref($navmapref)) {
1.484.2.67 raeburn 4104: unless (ref($$navmapref)) {
4105: $$navmapref = Apache::lonnavmaps::navmap->new();
4106: }
4107: if (ref($$navmapref)) {
4108: if (lc($$navmapref->get_mapparam($symb,undef,"0.encrypturl")) eq 'yes') {
4109: $checkencrypt = 1;
4110: }
4111: }
4112: }
4113: if ($checkencrypt) {
4114: my $shownsymb = &Apache::lonenc::encrypted($symb);
4115: my $shownurl = &Apache::lonenc::encrypted($url);
4116: if (&Apache::lonnet::symbverify($shownsymb,$shownurl)) {
1.484.2.80 raeburn 4117: $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
1.484.2.67 raeburn 4118: if ($env{'request.enc'} ne '') {
4119: delete($env{'request.enc'});
4120: }
4121: } else {
4122: $url='';
4123: }
4124: } else {
4125: $url='';
4126: }
1.484.2.12 raeburn 4127: } else {
4128: $url='';
4129: }
1.484.2.19 raeburn 4130: }
1.484.2.66 raeburn 4131: } elsif ($supplementalflag) {
4132: if ($isexternal) {
4133: if ($url =~ /^([^#]+)#([^#]+)$/) {
4134: $url = $1;
4135: $anchor = $2;
1.484.2.70 raeburn 4136: if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) {
1.484.2.80 raeburn 4137: unless (&Apache::lonnet::uses_sts()) {
4138: if ($hostname ne '') {
4139: $url = 'http://'.$hostname.$url;
4140: }
4141: $url .= (($url =~ /\?/) ? '&':'?').'usehttp=1';
4142: }
1.484.2.70 raeburn 4143: $nomodal = 1;
4144: }
4145: }
4146: } elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
4147: if (($ENV{'SERVER_PORT'} == 443) &&
4148: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
1.484.2.80 raeburn 4149: unless (&Apache::lonnet::uses_sts()) {
4150: if ($hostname ne '') {
4151: $url = 'http://'.$hostname.$url;
4152: }
4153: $url .= (($url =~ /\?/) ? '&':'?').'usehttp=1';
4154: }
1.484.2.70 raeburn 4155: $nomodal = 1;
1.484.2.66 raeburn 4156: }
4157: }
1.329 droeschl 4158: }
1.484.2.67 raeburn 4159: my ($rand_pick_text,$rand_order_text,$hiddenfolder);
4160: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.484.2.19 raeburn 4161: if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') {
1.329 droeschl 4162: my $foldername=&escape($foldertitle);
4163: my $folderpath=$env{'form.folderpath'};
4164: if ($folderpath) { $folderpath.='&' };
1.484.2.19 raeburn 4165: if (!$allowed && $supplementalflag) {
4166: $folderpath.=$containerarg.'&'.$foldername;
4167: $url.='folderpath='.&escape($folderpath);
4168: } else {
4169: my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
4170: 'parameter_randompick'))[0];
1.484.2.67 raeburn 4171: my $randorder = ((&LONCAPA::map::getparameter($orderidx,
4172: 'parameter_randomorder'))[0]=~/^yes$/i);
4173: my $hiddenmap = ((&LONCAPA::map::getparameter($orderidx,
4174: 'parameter_hiddenresource'))[0]=~/^yes$/i);
4175: my $encryptmap = ((&LONCAPA::map::getparameter($orderidx,
4176: 'parameter_encrypturl'))[0]=~/^yes$/i);
4177: unless ($hiddenmap) {
1.484.2.70 raeburn 4178: if (ref($navmapref)) {
4179: unless (ref($$navmapref)) {
4180: $$navmapref = Apache::lonnavmaps::navmap->new();
4181: }
4182: if (ref($$navmapref)) {
4183: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
4184: my @resources = $$navmapref->retrieveResources($folderurl,$filterFunc,1,1);
4185: unless (@resources) {
4186: $hiddenmap = 1;
4187: unless ($env{'request.role.adv'}) {
4188: $url = '';
4189: $hiddenfolder = 1;
4190: }
1.484.2.67 raeburn 4191: }
4192: }
4193: }
4194: }
4195: }
4196: unless ($encryptmap) {
1.484.2.70 raeburn 4197: if ((ref($navmapref)) && (ref($$navmapref))) {
4198: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.encrypturl")) eq 'yes') {
4199: $encryptmap = 1;
4200: }
1.484.2.67 raeburn 4201: }
4202: }
4203:
4204: # Append randompick number, hidden, and encrypted with ":" to foldername,
4205: # so it gets transferred between levels
4206: $folderpath.=$containerarg.'&'.$foldername.
4207: ':'.$rpicknum.':'.$hiddenmap.':'.$encryptmap.':'.$randorder.':'.$ispage;
4208: unless ($url eq '') {
4209: $url.='folderpath='.&escape($folderpath);
4210: }
1.484.2.19 raeburn 4211: my $rpckchk;
4212: if ($rpicknum) {
4213: $rpckchk = ' checked="checked"';
1.484.2.30 raeburn 4214: if (($ishash) && (ref($filtersref->{'randompick'}) eq 'ARRAY')) {
4215: push(@{$filtersref->{'randompick'}},$orderidx.':'.$rpicknum);
4216: }
1.484.2.19 raeburn 4217: }
1.484.2.29 raeburn 4218: my $formname = 'edit_randompick_'.$orderidx;
1.484.2.19 raeburn 4219: $rand_pick_text =
1.478 raeburn 4220: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.484.2.30 raeburn 4221: $form_param."\n".
1.478 raeburn 4222: $form_common."\n".
1.484.2.67 raeburn 4223: '<span class="LC_nobreak"><label><input type="checkbox" name="randompick_'.$orderidx.'" id="randompick_'.$orderidx.'" onclick="'."updatePick(this.form,'$orderidx','check');".'"'.$rpckchk.$disabled.' /> '.&mt('Randomly Pick').'</label><input type="hidden" name="rpicknum_'.$orderidx.'" id="rpicknum_'.$orderidx.'" value="'.$rpicknum.'" /><span id="randompicknum_'.$orderidx.'">';
1.484.2.19 raeburn 4224: if ($rpicknum ne '') {
4225: $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
4226: }
1.484.2.29 raeburn 4227: $rand_pick_text .= '</span></span>'.
4228: $form_end;
1.484.2.30 raeburn 4229: my $ro_set;
1.484.2.67 raeburn 4230: if ($randorder) {
1.484.2.30 raeburn 4231: $ro_set = 'checked="checked"';
4232: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4233: push(@{$filtersref->{'randomorder'}},$orderidx);
4234: }
4235: }
1.484.2.41 raeburn 4236: $formname = 'edit_rorder_'.$orderidx;
1.484.2.19 raeburn 4237: $rand_order_text =
1.484.2.29 raeburn 4238: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.484.2.30 raeburn 4239: $form_param."\n".
1.484.2.29 raeburn 4240: $form_common."\n".
1.484.2.67 raeburn 4241: '<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.$disabled.' /> '.&mt('Random Order').' </label></span>'.
1.484.2.29 raeburn 4242: $form_end;
1.484.2.19 raeburn 4243: }
1.484.2.18 raeburn 4244: } elsif ($supplementalflag && !$allowed) {
1.484.2.85.2. (raeburn 4245:): my $isexttool;
4246:): if ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4247:): $url='/adm/wrapper'.$url;
4248:): $isexttool = 1;
4249:): }
1.484.2.19 raeburn 4250: $url .= ($url =~ /\?/) ? '&':'?';
1.484.2.18 raeburn 4251: $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
1.484.2.19 raeburn 4252: if ($title) {
4253: $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"');
4254: }
1.484.2.85.2. (raeburn 4255:): if ((($isexternal) || ($isexttool)) && $orderidx) {
1.484.2.19 raeburn 4256: $url .= '&idx='.$orderidx;
4257: }
1.484.2.66 raeburn 4258: if ($anchor ne '') {
4259: $url .= '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4260: }
1.329 droeschl 4261: }
1.484.2.19 raeburn 4262: my ($tdalign,$tdwidth);
1.484.2.12 raeburn 4263: if ($allowed) {
1.484.2.19 raeburn 4264: my $fileloc =
1.484.2.12 raeburn 4265: &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
1.484.2.19 raeburn 4266: if ($isexternal) {
4267: ($editlink,$extresform) =
1.484.2.67 raeburn 4268: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
1.484.2.85.2. (raeburn 4269:): undef,undef,undef,undef,undef,undef,
4270:): undef,$disabled);
4271:): } elsif ($orig_url =~ m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4272:): ($editlink,$extresform) =
4273:): &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
4274:): undef,undef,undef,'tool',$coursedom,
4275:): $coursenum,$ltitoolsref,$disabled);
1.484.2.19 raeburn 4276: } elsif (!$isfolder && !$ispage) {
4277: my ($cfile,$home,$switchserver,$forceedit,$forceview) =
1.484.2.14 raeburn 4278: &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
1.484.2.19 raeburn 4279: if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
1.484.2.66 raeburn 4280: my $suppanchor;
4281: if ($supplementalflag) {
4282: $suppanchor = $anchor;
4283: }
1.484.2.19 raeburn 4284: my $jscall =
1.484.2.12 raeburn 4285: &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
4286: $switchserver,
1.484.2.14 raeburn 4287: $forceedit,
1.484.2.19 raeburn 4288: undef,$symb,
4289: &escape($env{'form.folderpath'}),
1.484.2.80 raeburn 4290: $renametitle,$hostname,
4291: '','',1,$suppanchor);
1.484.2.12 raeburn 4292: if ($jscall) {
1.484.2.19 raeburn 4293: $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
4294: $jscall.'" >'.&mt('Edit').'</a> '."\n";
1.484.2.12 raeburn 4295: }
4296: }
4297: }
1.484.2.19 raeburn 4298: $tdalign = ' align="right" valign="top"';
4299: $tdwidth = ' width="80%"';
1.329 droeschl 4300: }
1.408 raeburn 4301: my $reinit;
4302: if ($crstype eq 'Community') {
4303: $reinit = &mt('(re-initialize community to access)');
4304: } else {
4305: $reinit = &mt('(re-initialize course to access)');
1.484.2.19 raeburn 4306: }
4307: $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;
1.484.2.70 raeburn 4308: my $link;
1.472 raeburn 4309: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 4310: $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
4311: } elsif ($url) {
1.484.2.66 raeburn 4312: if ($anchor ne '') {
4313: if ($supplementalflag) {
4314: $anchor = '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4315: } else {
4316: $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');
4317: }
4318: }
1.484.2.80 raeburn 4319:
4320: if ((!$supplementalflag) && ($nomodal) && ($hostname ne '')) {
4321: $link = 'http://'.$hostname.$url;
4322: } else {
4323: $link = $url;
4324: }
4325: $link = &js_escape($link.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.$anchor);
1.484.2.70 raeburn 4326: if ($nomodal) {
4327: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4328: '<img src="'.$icon.'" alt="" class="LC_icon" border="0" /></a>';
4329: } else {
4330: $line.=&Apache::loncommon::modal_link($link,
4331: '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
4332: }
1.469 www 4333: } else {
4334: $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
4335: }
1.484.2.19 raeburn 4336: $line.='</span></td><td'.$tdwidth.'>';
1.472 raeburn 4337: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 4338: $line.='<a href="'.$url.'">'.$title.'</a>';
4339: } elsif ($url) {
1.484.2.70 raeburn 4340: if ($nomodal) {
4341: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4342: $title.'</a>';
4343: } else {
4344: $line.=&Apache::loncommon::modal_link($link,$title,600,500);
4345: }
1.484.2.67 raeburn 4346: } elsif (($hiddenfolder) || ($hiddenres)) {
1.484.2.72 raeburn 4347: $line.=$title.' <span class="LC_warning LC_docs_reinit_warn">('.&mt('Hidden').')</span>';
1.469 www 4348: } else {
4349: $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
4350: }
1.484.2.19 raeburn 4351: $line.="$extresform</td>";
1.478 raeburn 4352: $rand_pick_text = ' ' if ($rand_pick_text eq '');
4353: $rand_order_text = ' ' if ($rand_order_text eq '');
1.329 droeschl 4354: if (($allowed) && ($folder!~/^supplemental/)) {
4355: my %lt=&Apache::lonlocal::texthash(
4356: 'hd' => 'Hidden',
4357: 'ec' => 'URL hidden');
1.484.2.30 raeburn 4358: my ($enctext,$hidtext);
4359: if ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) {
4360: $enctext = ' checked="checked"';
4361: if (($ishash) && (ref($filtersref->{'encrypturl'}) eq 'ARRAY')) {
4362: push(@{$filtersref->{'encrypturl'}},$orderidx);
4363: }
4364: }
4365: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4366: $hidtext = ' checked="checked"';
4367: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4368: push(@{$filtersref->{'hiddenresource'}},$orderidx);
4369: }
4370: }
1.484.2.29 raeburn 4371: my $formhidden = 'edit_hiddenresource_'.$orderidx;
4372: my $formurlhidden = 'edit_encrypturl_'.$orderidx;
1.329 droeschl 4373: $line.=(<<ENDPARMS);
4374: <td class="LC_docs_entry_parameter">
1.484.2.30 raeburn 4375: <form action="/adm/coursedocs" method="post" name="$formhidden">
4376: $form_param
1.478 raeburn 4377: $form_common
1.484.2.67 raeburn 4378: <label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'hiddenresource','settings');" $hidtext $disabled /> $lt{'hd'}</label>
1.329 droeschl 4379: $form_end
1.458 raeburn 4380: <br />
1.484.2.29 raeburn 4381: <form action="/adm/coursedocs" method="post" name="$formurlhidden">
1.484.2.30 raeburn 4382: $form_param
1.478 raeburn 4383: $form_common
1.484.2.67 raeburn 4384: <label><input type="checkbox" name="encrypturl_$orderidx" id="encrypturl_$orderidx" onclick="checkForSubmit(this.form,'encrypturl','settings');" $enctext $disabled /> $lt{'ec'}</label>
1.329 droeschl 4385: $form_end
4386: </td>
1.478 raeburn 4387: <td class="LC_docs_entry_parameter">$rand_pick_text<br />
4388: $rand_order_text</td>
1.329 droeschl 4389: ENDPARMS
4390: }
1.379 bisitz 4391: $line.=&Apache::loncommon::end_data_table_row();
1.329 droeschl 4392: return $line;
4393: }
4394:
1.484.2.30 raeburn 4395: sub action_restrictions {
4396: my ($cnum,$cdom,$url,$folderpath,$currgroups) = @_;
4397: my %denied = (
4398: cut => 0,
4399: copy => 0,
4400: remove => 0,
4401: );
4402: if ($url=~ m{^/res/.+\.(page|sequence)$}) {
4403: # no copy for published maps
4404: $denied{'copy'} = 1;
1.484.2.82 raeburn 4405: } elsif ($url=~m{^/res/lib/templates/([^/]+)\.problem$}) {
4406: unless ($1 eq 'simpleproblem') {
4407: $denied{'copy'} = 1;
4408: }
4409: $denied{'cut'} = 1;
1.484.2.30 raeburn 4410: } elsif ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") {
4411: if ($folderpath =~ /^default&[^\&]+$/) {
4412: if ((ref($currgroups) eq 'HASH') && (keys(%{$currgroups}) > 0)) {
4413: $denied{'remove'} = 1;
4414: }
4415: $denied{'cut'} = 1;
4416: $denied{'copy'} = 1;
4417: }
4418: } elsif ($url =~ m{^\Q/uploaded/$cdom/$cnum/group_folder_\E(\w+)\.sequence$}) {
4419: my $group = $1;
4420: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+$/) {
4421: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4422: $denied{'remove'} = 1;
4423: }
4424: }
4425: $denied{'cut'} = 1;
4426: $denied{'copy'} = 1;
4427: } elsif ($url =~ m{^\Q/adm/$cdom/$cnum/\E(\w+)/smppg$}) {
4428: my $group = $1;
4429: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&\Qgroup_folder_$group\E\&[^\&]+$/) {
4430: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4431: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4432: if (keys(%groupsettings) > 0) {
4433: $denied{'remove'} = 1;
4434: }
4435: $denied{'cut'} = 1;
4436: $denied{'copy'} = 1;
4437: }
4438: }
4439: } elsif ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&group_folder_(\w+)\&/) {
4440: my $group = $1;
4441: if ($url =~ /group_boards_\Q$group\E/) {
4442: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4443: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4444: if (keys(%groupsettings) > 0) {
4445: if (ref($groupsettings{'functions'}) eq 'HASH') {
4446: if ($groupsettings{'functions'}{'discussion'} eq 'on') {
4447: $denied{'remove'} = 1;
4448: }
4449: }
4450: }
4451: $denied{'cut'} = 1;
4452: $denied{'copy'} = 1;
4453: }
4454: }
4455: }
4456: return %denied;
4457: }
4458:
1.484.2.26 raeburn 4459: sub new_timebased_suffix {
1.484.2.30 raeburn 4460: my ($dom,$num,$type,$area,$container) = @_;
1.484.2.26 raeburn 4461: my ($prefix,$namespace,$idtype,$errtext,$locknotfreed);
1.484.2.30 raeburn 4462: if ($type eq 'paste') {
4463: $prefix = $type;
4464: $namespace = 'courseeditor';
1.484.2.56 raeburn 4465: $idtype = 'addcode';
1.484.2.30 raeburn 4466: } elsif ($type eq 'map') {
1.484.2.26 raeburn 4467: $prefix = 'docs';
4468: if ($area eq 'supplemental') {
4469: $prefix = 'supp';
4470: }
4471: $prefix .= $container;
4472: $namespace = 'uploadedmaps';
4473: } else {
4474: $prefix = $type;
4475: $namespace = 'templated';
1.484.2.15 raeburn 4476: }
4477: my ($suffix,$freedlock,$error) =
1.484.2.56 raeburn 4478: &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num,$idtype);
1.484.2.15 raeburn 4479: if (!$suffix) {
1.484.2.30 raeburn 4480: if ($type eq 'paste') {
4481: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.');
4482: } elsif ($type eq 'map') {
1.484.2.26 raeburn 4483: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
4484: } elsif ($type eq 'smppg') {
4485: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.');
1.484.2.85.2. (raeburn 4486:): } elsif ($type eq 'exttool') {
4487:): $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new external tool.');
1.484.2.26 raeburn 4488: } else {
1.484.2.42 raeburn 4489: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new discussion board.');
1.484.2.26 raeburn 4490: }
1.484.2.15 raeburn 4491: if ($error) {
4492: $errtext .= '<br />'.$error;
4493: }
4494: }
4495: if ($freedlock ne 'ok') {
1.484.2.26 raeburn 4496: $locknotfreed =
4497: '<div class="LC_error">'.
4498: &mt('There was a problem removing a lockfile.').' ';
1.484.2.30 raeburn 4499: if ($type eq 'paste') {
1.484.2.57 raeburn 4500: if ($freedlock eq 'nolock') {
4501: $locknotfreed =
4502: '<div class="LC_error">'.
4503: &mt('A lockfile was not released when you added content to the clipboard earlier in this session.').' '.
4504:
1.484.2.60 raeburn 4505: &mt('As a result addition of items to the clipboard will be unavailable until your next log-in.');
1.484.2.57 raeburn 4506: } else {
4507: $locknotfreed .=
4508: &mt('This will prevent addition of items to the clipboard until your next log-in.');
4509: }
1.484.2.30 raeburn 4510: } elsif ($type eq 'map') {
1.484.2.57 raeburn 4511: $locknotfreed .=
4512: &mt('This will prevent creation of additional folders or composite pages in this course.');
1.484.2.26 raeburn 4513: } elsif ($type eq 'smppg') {
4514: $locknotfreed .=
4515: &mt('This will prevent creation of additional simple pages in this course.');
1.484.2.85.2. (raeburn 4516:): } elsif ($type eq 'exttool') {
4517:): $locknotfreed .=
4518:): &mt('This will prevent creation of additional external tools in this course.');
1.484.2.26 raeburn 4519: } else {
4520: $locknotfreed .=
1.484.2.42 raeburn 4521: &mt('This will prevent creation of additional discussion boards in this course.');
1.484.2.26 raeburn 4522: }
1.484.2.30 raeburn 4523: unless ($type eq 'paste') {
4524: $locknotfreed .=
1.484.2.38 raeburn 4525: ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
4526: '<a href="/adm/helpdesk" target="_helpdesk">','</a>');
1.484.2.30 raeburn 4527: }
4528: $locknotfreed .= '</div>';
1.484.2.15 raeburn 4529: }
4530: return ($suffix,$errtext,$locknotfreed);
4531: }
4532:
1.329 droeschl 4533: =pod
4534:
4535: =item tiehash()
4536:
4537: tie the hash
4538:
4539: =cut
4540:
4541: sub tiehash {
4542: my ($mode)=@_;
4543: $hashtied=0;
4544: if ($env{'request.course.fn'}) {
4545: if ($mode eq 'write') {
4546: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4547: &GDBM_WRCREAT(),0640)) {
4548: $hashtied=2;
4549: }
4550: } else {
4551: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4552: &GDBM_READER(),0640)) {
4553: $hashtied=1;
4554: }
4555: }
1.364 bisitz 4556: }
1.329 droeschl 4557: }
4558:
4559: sub untiehash {
4560: if ($hashtied) { untie %hash; }
4561: $hashtied=0;
4562: return OK;
4563: }
4564:
4565:
4566:
4567:
4568: sub checkonthis {
1.484.2.78 raeburn 4569: my ($r,$url,$level,$title,$checkstale)=@_;
1.329 droeschl 4570: $url=&unescape($url);
4571: $alreadyseen{$url}=1;
4572: $r->rflush();
4573: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
4574: $r->print("\n<br />");
4575: if ($level==0) {
4576: $r->print("<br />");
4577: }
4578: for (my $i=0;$i<=$level*5;$i++) {
4579: $r->print(' ');
4580: }
4581: $r->print('<a href="'.$url.'" target="cat">'.
4582: ($title?$title:$url).'</a> ');
4583: if ($url=~/^\/res\//) {
1.484.2.78 raeburn 4584: my $updated;
4585: if (($checkstale) && ($url !~ m{^/res/lib/templates/}) &&
4586: ($url !~ /\.\d+\.\w+$/)) {
4587: $updated = &Apache::lonnet::remove_stale_resfile($url);
4588: }
1.329 droeschl 4589: my $result=&Apache::lonnet::repcopy(
4590: &Apache::lonnet::filelocation('',$url));
4591: if ($result eq 'ok') {
4592: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
1.484.2.78 raeburn 4593: if ($updated) {
4594: $r->print('<br />');
4595: for (my $i=0;$i<=$level*5;$i++) {
4596: $r->print(' ');
4597: }
4598: $r->print('- '.&mt('Outdated copy removed'));
4599: }
1.329 droeschl 4600: $r->rflush();
4601: &Apache::lonnet::countacc($url);
4602: $url=~/\.(\w+)$/;
4603: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
4604: $r->print('<br />');
4605: $r->rflush();
4606: for (my $i=0;$i<=$level*5;$i++) {
4607: $r->print(' ');
4608: }
4609: $r->print('- '.&mt('Rendering:').' ');
4610: my ($errorcount,$warningcount)=split(/:/,
4611: &Apache::lonnet::ssi_body($url,
4612: ('grade_target'=>'web',
4613: 'return_only_error_and_warning_counts' => 1)));
4614: if (($errorcount) ||
4615: ($warningcount)) {
4616: if ($errorcount) {
1.369 bisitz 4617: $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1.329 droeschl 4618: &mt('[quant,_1,error]',$errorcount).'</span>');
4619: }
4620: if ($warningcount) {
4621: $r->print('<span class="LC_warning">'.
4622: &mt('[quant,_1,warning]',$warningcount).'</span>');
4623: }
4624: } else {
4625: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
4626: }
4627: $r->rflush();
4628: }
4629: my $dependencies=
4630: &Apache::lonnet::metadata($url,'dependencies');
4631: foreach my $dep (split(/\,/,$dependencies)) {
4632: if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
1.484.2.78 raeburn 4633: &checkonthis($r,$dep,$level+1,'',$checkstale);
1.329 droeschl 4634: }
4635: }
4636: } elsif ($result eq 'unavailable') {
4637: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
4638: } elsif ($result eq 'not_found') {
4639: unless ($url=~/\$/) {
1.484.2.19 raeburn 4640: $r->print('<span class="LC_error">'.&mt('not found').'</span>');
1.329 droeschl 4641: } else {
1.366 bisitz 4642: $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1.329 droeschl 4643: }
4644: } else {
4645: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
4646: }
1.484.2.78 raeburn 4647: if (($updated) && ($result ne 'ok')) {
4648: $r->print('<br />'.&mt('Outdated copy removed'));
4649: }
1.329 droeschl 4650: }
4651: }
4652: }
4653:
4654:
4655:
4656: =pod
4657:
4658: =item list_symbs()
4659:
1.484.2.3 raeburn 4660: List Content Identifiers
1.329 droeschl 4661:
4662: =cut
4663:
4664: sub list_symbs {
4665: my ($r) = @_;
4666:
1.408 raeburn 4667: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 4668: $r->print(&Apache::loncommon::start_page('List of Content Identifiers'));
4669: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Identifiers'));
4670: $r->print(&startContentScreen('tools'));
1.329 droeschl 4671: my $navmap = Apache::lonnavmaps::navmap->new();
4672: if (!defined($navmap)) {
4673: $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
4674: '<div class="LC_error">'.
4675: &mt('Unable to retrieve information about course contents').
4676: '</div>');
1.408 raeburn 4677: &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
1.329 droeschl 4678: } else {
1.484 raeburn 4679: $r->print('<h4 class="LC_info">'.&mt("$crstype Content Identifiers").'</h4>'.
4680: &Apache::loncommon::start_data_table().
4681: &Apache::loncommon::start_data_table_header_row().
4682: '<th>'.&mt('Title').'</th><th>'.&mt('Identifier').'</th>'.
4683: &Apache::loncommon::end_data_table_header_row()."\n");
4684: my $count;
1.329 droeschl 4685: foreach my $res ($navmap->retrieveResources()) {
1.484 raeburn 4686: $r->print(&Apache::loncommon::start_data_table_row().
4687: '<td>'.$res->compTitle().'</td>'.
4688: '<td>'.$res->symb().'</td>'.
1.484.2.19 raeburn 4689: &Apache::loncommon::end_data_table_row());
1.484 raeburn 4690: $count ++;
4691: }
4692: if (!$count) {
4693: $r->print(&Apache::loncommon::start_data_table_row().
4694: '<td colspan="2">'.&mt("$crstype is empty").'</td>'.
4695: &Apache::loncommon::end_data_table_row());
1.329 droeschl 4696: }
1.484 raeburn 4697: $r->print(&Apache::loncommon::end_data_table());
1.329 droeschl 4698: }
1.484.2.19 raeburn 4699: $r->print(&endContentScreen());
1.329 droeschl 4700: }
4701:
1.484.2.85.2. (raeburn 4702:): sub short_urls {
4703:): my ($r,$canedit) = @_;
4704:): my $crstype = &Apache::loncommon::course_type();
4705:): my $formname = 'shortenurl';
4706:): $r->print(&Apache::loncommon::start_page('Display/Set Shortened URLs'));
4707:): $r->print(&Apache::lonhtmlcommon::breadcrumbs('Shortened URLs'));
4708:): $r->print(&startContentScreen('tools'));
4709:): my ($navmap,$errormsg) =
4710:): &Apache::loncourserespicker::get_navmap_object($crstype,'shorturls');
4711:): my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
4712:): my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4713:): my (%maps,%resources,%titles);
4714:): if (!ref($navmap)) {
4715:): $r->print($errormsg.
4716:): &endContentScreen());
4717:): return '';
4718:): } else {
4719:): $r->print('<h4 class="LC_info">'.&mt('Tiny URLs for deep-linking into course').'</h4>'."\n");
4720:): $r->rflush();
4721:): my $readonly;
4722:): if ($canedit) {
4723:): my ($numnew,$errors) = &Apache::loncommon::make_short_symbs($cdom,$cnum,$navmap);
4724:): if ($numnew) {
4725:): $r->print('<p class="LC_info">'.&mt('Created [quant,_1,URL]',$numnew).'</p>');
4726:): }
4727:): if ((ref($errors) eq 'ARRAY') && (@{$errors} > 0)) {
4728:): $r->print(&mt('The following errors occurred when processing your request to create shortened URLs:').'<br /><ul>');
4729:): foreach my $error (@{$errors}) {
4730:): $r->print('<li>'.$error.'</li>');
4731:): }
4732:): $r->print('</ul><br />');
4733:): }
4734:): } else {
4735:): $readonly = 1;
4736:): }
4737:): my %currtiny = &Apache::lonnet::dump('tiny',$cdom,$cnum);
4738:): $r->print(&Apache::loncourserespicker::create_picker($navmap,'shorturls',$formname,$crstype,undef,
4739:): undef,undef,undef,undef,undef,\%currtiny,$readonly));
4740:): }
4741:): $r->print(&endContentScreen());
4742:): }
4743:):
1.484.2.78 raeburn 4744: sub contentverifyform {
4745: my ($r) = @_;
4746: my $crstype = &Apache::loncommon::course_type();
4747: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
4748: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
4749: $r->print(&startContentScreen('tools'));
4750: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
4751: $r->print('<form method="post" action="/adm/coursedocs"><p>'.
4752: &mt('Include a check if files copied from elsewhere are up to date (will increase verification time)?').
4753: ' <span class="LC_nobreak">'.
4754: '<label><input type="radio" name="checkstale" value="0" checked="checked" />'.
4755: &mt('No').'</label>'.(' 'x2).
4756: '<label><input type="radio" name="checkstale" value="1" />'.
4757: &mt('Yes').'</label></span></p><p>'.
4758: '<input type="submit" value="'.&mt('Verify content').' "/>'.
4759: '<input type="hidden" value="1" name="tools" />'.
4760: '<input type="hidden" value="1" name="verify" /></p></form>');
4761: $r->print(&endContentScreen());
4762: return;
4763: }
1.329 droeschl 4764:
4765: sub verifycontent {
1.484.2.78 raeburn 4766: my ($r,$checkstale) = @_;
1.408 raeburn 4767: my $crstype = &Apache::loncommon::course_type();
1.484.2.34 raeburn 4768: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
4769: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
1.484 raeburn 4770: $r->print(&startContentScreen('tools'));
4771: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
1.329 droeschl 4772: $hashtied=0;
4773: undef %alreadyseen;
4774: %alreadyseen=();
4775: &tiehash();
1.484 raeburn 4776:
1.329 droeschl 4777: foreach my $key (keys(%hash)) {
4778: if ($hash{$key}=~/\.(page|sequence)$/) {
4779: if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
4780: $r->print('<hr /><span class="LC_error">'.
1.419 bisitz 4781: &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
1.329 droeschl 4782: &unescape($hash{$key}).'</span><br />'.
1.419 bisitz 4783: &mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />');
1.329 droeschl 4784: }
4785: }
4786: if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
1.484.2.78 raeburn 4787: &checkonthis($r,$hash{$key},0,$hash{'title_'.$1},$checkstale);
1.329 droeschl 4788: }
4789: }
4790: &untiehash();
1.442 www 4791: $r->print('<p class="LC_success">'.&mt('Done').'</p>');
1.484.2.19 raeburn 4792: $r->print(&endContentScreen());
1.329 droeschl 4793: }
4794:
4795:
4796: sub devalidateversioncache {
4797: my $src=shift;
4798: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
4799: &Apache::lonnet::clutter($src));
4800: }
4801:
4802: sub checkversions {
1.484.2.67 raeburn 4803: my ($r,$canedit) = @_;
1.408 raeburn 4804: my $crstype = &Apache::loncommon::course_type();
1.484.2.44 raeburn 4805: $r->print(&Apache::loncommon::start_page("Check $crstype Resource Versions"));
4806: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Resource Versions"));
1.484 raeburn 4807: $r->print(&startContentScreen('tools'));
1.442 www 4808:
1.329 droeschl 4809: my $header='';
4810: my $startsel='';
4811: my $monthsel='';
4812: my $weeksel='';
4813: my $daysel='';
4814: my $allsel='';
4815: my %changes=();
4816: my $starttime=0;
4817: my $haschanged=0;
4818: my %setversions=&Apache::lonnet::dump('resourceversions',
4819: $env{'course.'.$env{'request.course.id'}.'.domain'},
4820: $env{'course.'.$env{'request.course.id'}.'.num'});
4821:
4822: $hashtied=0;
4823: &tiehash();
1.484.2.67 raeburn 4824: if ($canedit) {
4825: my %newsetversions=();
4826: if ($env{'form.setmostrecent'}) {
4827: $haschanged=1;
4828: foreach my $key (keys(%hash)) {
4829: if ($key=~/^ids\_(\/res\/.+)$/) {
4830: $newsetversions{$1}='mostrecent';
4831: &devalidateversioncache($1);
4832: }
1.329 droeschl 4833: }
1.484.2.67 raeburn 4834: } elsif ($env{'form.setcurrent'}) {
4835: $haschanged=1;
4836: foreach my $key (keys(%hash)) {
4837: if ($key=~/^ids\_(\/res\/.+)$/) {
4838: my $getvers=&Apache::lonnet::getversion($1);
4839: if ($getvers>0) {
4840: $newsetversions{$1}=$getvers;
4841: &devalidateversioncache($1);
4842: }
4843: }
1.329 droeschl 4844: }
1.484.2.67 raeburn 4845: } elsif ($env{'form.setversions'}) {
4846: $haschanged=1;
4847: foreach my $key (keys(%env)) {
4848: if ($key=~/^form\.set_version_(.+)$/) {
4849: my $src=$1;
4850: if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
4851: $newsetversions{$src}=$env{$key};
4852: &devalidateversioncache($src);
4853: }
4854: }
1.329 droeschl 4855: }
1.484.2.67 raeburn 4856: }
4857: if ($haschanged) {
4858: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
4859: $env{'course.'.$env{'request.course.id'}.'.domain'},
4860: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
4861: $r->print(&Apache::loncommon::confirmwrapper(
4862: &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
4863: } else {
4864: $r->print(&Apache::loncommon::confirmwrapper(
4865: &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
4866: }
4867: &mark_hash_old();
4868: }
4869: &changewarning($r,'');
1.329 droeschl 4870: }
4871: if ($env{'form.timerange'} eq 'all') {
4872: # show all documents
1.484.2.34 raeburn 4873: $header=&mt('All content in '.$crstype);
1.484.2.19 raeburn 4874: $allsel=' selected="selected"';
1.329 droeschl 4875: foreach my $key (keys(%hash)) {
4876: if ($key=~/^ids\_(\/res\/.+)$/) {
4877: my $src=$1;
4878: $changes{$src}=1;
4879: }
4880: }
4881: } else {
4882: # show documents which changed
4883: %changes=&Apache::lonnet::dump
4884: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
4885: $env{'course.'.$env{'request.course.id'}.'.num'});
4886: my $firstkey=(keys(%changes))[0];
4887: unless ($firstkey=~/^error\:/) {
4888: unless ($env{'form.timerange'}) {
4889: $env{'form.timerange'}=604800;
4890: }
4891: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
4892: .&mt('seconds');
4893: if ($env{'form.timerange'}==-1) {
4894: $seltext='since start of course';
1.484.2.19 raeburn 4895: $startsel=' selected="selected"';
1.329 droeschl 4896: $env{'form.timerange'}=time;
4897: }
4898: $starttime=time-$env{'form.timerange'};
4899: if ($env{'form.timerange'}==2592000) {
4900: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 4901: $monthsel=' selected="selected"';
1.329 droeschl 4902: } elsif ($env{'form.timerange'}==604800) {
4903: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 4904: $weeksel=' selected="selected"';
1.329 droeschl 4905: } elsif ($env{'form.timerange'}==86400) {
4906: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 4907: $daysel=' selected="selected"';
1.329 droeschl 4908: }
4909: $header=&mt('Content changed').' '.$seltext;
4910: } else {
4911: $header=&mt('No content modifications yet.');
4912: }
4913: }
4914: %setversions=&Apache::lonnet::dump('resourceversions',
4915: $env{'course.'.$env{'request.course.id'}.'.domain'},
4916: $env{'course.'.$env{'request.course.id'}.'.num'});
4917: my %lt=&Apache::lonlocal::texthash
1.408 raeburn 4918: ('st' => 'Version changes since start of '.$crstype,
1.329 droeschl 4919: 'lm' => 'Version changes since last Month',
4920: 'lw' => 'Version changes since last Week',
4921: 'sy' => 'Version changes since Yesterday',
4922: 'al' => 'All Resources (possibly large output)',
1.484 raeburn 4923: 'cd' => 'Change display',
1.329 droeschl 4924: 'sd' => 'Display',
4925: 'fi' => 'File',
4926: 'md' => 'Modification Date',
4927: 'mr' => 'Most recently published Version',
1.408 raeburn 4928: 've' => 'Version used in '.$crstype,
4929: 'vu' => 'Set Version to be used in '.$crstype,
4930: 'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
1.329 droeschl 4931: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
4932: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.479 golterma 4933: 'di' => 'Differences',
1.484 raeburn 4934: 'save' => 'Save changes',
4935: 'vers' => 'Version choice(s) for specific resources',
1.479 golterma 4936: 'act' => 'Actions');
1.484.2.67 raeburn 4937: my ($disabled,$readonly);
4938: unless ($canedit) {
4939: $disabled = 'disabled="disabled"';
4940: $readonly = 1;
4941: }
1.329 droeschl 4942: $r->print(<<ENDHEADERS);
1.484 raeburn 4943: <h4 class="LC_info">$header</h4>
1.329 droeschl 4944: <form action="/adm/coursedocs" method="post">
4945: <input type="hidden" name="versions" value="1" />
1.484 raeburn 4946: <div class="LC_left_float">
1.479 golterma 4947: <fieldset>
1.484 raeburn 4948: <legend>$lt{'cd'}</legend>
1.329 droeschl 4949: <select name="timerange">
1.484.2.19 raeburn 4950: <option value='all'$allsel>$lt{'al'}</option>
4951: <option value="-1"$startsel>$lt{'st'}</option>
4952: <option value="2592000"$monthsel>$lt{'lm'}</option>
4953: <option value="604800"$weeksel>$lt{'lw'}</option>
4954: <option value="86400"$daysel>$lt{'sy'}</option>
1.329 droeschl 4955: </select>
4956: <input type="submit" name="display" value="$lt{'sd'}" />
1.484 raeburn 4957: </fieldset>
4958: </div>
4959: <div class="LC_left_float">
4960: <fieldset>
4961: <legend>$lt{'act'}</legend>
1.484.2.67 raeburn 4962: $lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" $disabled /><br />
4963: $lt{'sc'}: <input type="submit" name="setcurrent" value="Go" $disabled />
1.484 raeburn 4964: </fieldset>
4965: </div>
4966: <br clear="all" />
4967: <hr />
4968: <h4>$lt{'vers'}</h4>
1.329 droeschl 4969: ENDHEADERS
1.479 golterma 4970: #number of columns for version history
1.484.2.44 raeburn 4971: my %changedbytime;
4972: foreach my $key (keys(%changes)) {
4973: #excludes not versionable problems from resource version history:
4974: next if ($key =~ /^\/res\/lib\/templates/);
4975: my $chg;
4976: if ($env{'form.timerange'} eq 'all') {
4977: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
4978: $chg = &Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate');
4979: } else {
4980: $chg = $changes{$key};
4981: next if ($chg < $starttime);
4982: }
4983: push(@{$changedbytime{$chg}},$key);
4984: }
4985: if (keys(%changedbytime) == 0) {
4986: &untiehash();
4987: $r->print(&mt('No content changes in imported content in specified time frame').
4988: &endContentScreen());
4989: return;
4990: }
1.479 golterma 4991: $r->print(
1.484.2.67 raeburn 4992: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.484.2.19 raeburn 4993: &Apache::loncommon::start_data_table().
4994: &Apache::loncommon::start_data_table_header_row().
4995: '<th>'.&mt('Resources').'</th>'.
4996: "<th>$lt{'mr'}</th>".
4997: "<th>$lt{'ve'}</th>".
4998: "<th>$lt{'vu'}</th>".
4999: '<th>'.&mt('History').'</th>'.
5000: &Apache::loncommon::end_data_table_header_row()
5001: );
1.484.2.44 raeburn 5002: foreach my $chg (sort {$b <=> $a } keys(%changedbytime)) {
5003: foreach my $key (sort(@{$changedbytime{$chg}})) {
5004: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
5005: my $currentversion=&Apache::lonnet::getversion($key);
5006: if ($currentversion<0) {
5007: $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
5008: }
5009: my $linkurl=&Apache::lonnet::clutter($key);
5010: $r->print(
5011: &Apache::loncommon::start_data_table_row().
5012: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br />'.
5013: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
5014: '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br />('.
5015: &Apache::lonlocal::locallocaltime($chg).')</span></td>'.
5016: '<td align="right">'
5017: );
5018: # Used in course
5019: my $usedversion=$hash{'version_'.$linkurl};
5020: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.484.2.19 raeburn 5021: if ($usedversion != $currentversion) {
1.479 golterma 5022: $r->print('<span class="LC_warning">'.$usedversion.'</span>');
1.484.2.19 raeburn 5023: } else {
1.479 golterma 5024: $r->print($usedversion);
5025: }
1.329 droeschl 5026: } else {
1.484.2.19 raeburn 5027: $r->print($currentversion);
1.329 droeschl 5028: }
1.484.2.44 raeburn 5029: $r->print('</td><td title="'.$lt{'vu'}.'">');
5030: # Set version
5031: $r->print(&Apache::loncommon::select_form(
5032: $setversions{$linkurl},
5033: 'set_version_'.$linkurl,
5034: {'select_form_order' => ['',1..$currentversion,'mostrecent'],
5035: '' => '',
5036: 'mostrecent' => &mt('most recent'),
1.484.2.67 raeburn 5037: map {$_,$_} (1..$currentversion)},'',$readonly));
1.484.2.44 raeburn 5038: my $lastold=1;
5039: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
5040: my $url=$root.'.'.$prevvers.'.'.$extension;
5041: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) {
5042: $lastold=$prevvers;
5043: }
5044: }
5045: $r->print('</td>');
5046: # List all available versions
5047: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
5048: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
5049: my $url=$root.'.'.$prevvers.'.'.$extension;
1.484.2.19 raeburn 5050: $r->print(
1.484.2.44 raeburn 5051: '<span class="LC_nobreak">'
5052: .'<a href="'.&Apache::lonnet::clutter($url).'">'
5053: .&mt('Version [_1]',$prevvers).'</a>'
5054: .' ('.&Apache::lonlocal::locallocaltime(
5055: &Apache::lonnet::metadata($url,'lastrevisiondate'))
5056: .')');
5057: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
5058: $r->print(
5059: ' <a href="/adm/diff?filename='.
5060: &Apache::lonnet::clutter($root.'.'.$extension).
5061: &HTML::Entities::encode('&versionone='.$prevvers,'"<>&').
5062: '" target="diffs">'.&mt('Diffs').'</a>');
5063: }
5064: $r->print('</span><br />');
1.329 droeschl 5065: }
1.484.2.44 raeburn 5066: $r->print('</span></td>'.&Apache::loncommon::end_data_table_row());
1.484.2.19 raeburn 5067: }
1.329 droeschl 5068: }
1.484.2.19 raeburn 5069: $r->print(
5070: &Apache::loncommon::end_data_table().
1.484.2.67 raeburn 5071: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.484.2.19 raeburn 5072: '</form>'
5073: );
1.329 droeschl 5074:
5075: &untiehash();
1.484.2.19 raeburn 5076: $r->print(&endContentScreen());
1.484.2.44 raeburn 5077: return;
1.329 droeschl 5078: }
5079:
5080: sub mark_hash_old {
5081: my $retie_hash=0;
5082: if ($hashtied) {
5083: $retie_hash=1;
5084: &untiehash();
5085: }
5086: &tiehash('write');
5087: $hash{'old'}=1;
5088: &untiehash();
5089: if ($retie_hash) { &tiehash(); }
5090: }
5091:
5092: sub is_hash_old {
5093: my $untie_hash=0;
5094: if (!$hashtied) {
5095: $untie_hash=1;
5096: &tiehash();
5097: }
5098: my $return=$hash{'old'};
5099: if ($untie_hash) { &untiehash(); }
5100: return $return;
5101: }
5102:
5103: sub changewarning {
5104: my ($r,$postexec,$message,$url)=@_;
5105: if (!&is_hash_old()) { return; }
5106: my $pathvar='folderpath';
5107: my $path=&escape($env{'form.folderpath'});
5108: if (!defined($url)) {
5109: $url='/adm/coursedocs?'.$pathvar.'='.$path;
5110: }
5111: my $course_type = &Apache::loncommon::course_type();
5112: if (!defined($message)) {
5113: $message='Changes will become active for your current session after [_1], or the next time you log in.';
5114: }
5115: $r->print("\n\n".
1.372 bisitz 5116: '<script type="text/javascript">'."\n".
5117: '// <![CDATA['."\n".
5118: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
5119: '// ]]>'."\n".
1.369 bisitz 5120: '</script>'."\n".
1.375 tempelho 5121: '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
1.329 droeschl 5122: '<input type="hidden" name="orgurl" value="'.$url.
1.372 bisitz 5123: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
1.329 droeschl 5124: &mt($message,' <input type="hidden" name="'.
5125: $env{'request.role'}.'" value="1" /><input type="button" value="'.
1.369 bisitz 5126: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1.372 bisitz 5127: $help{'Caching'}.'</p></form>'."\n\n");
1.329 droeschl 5128: }
5129:
5130:
5131: sub init_breadcrumbs {
1.484.2.44 raeburn 5132: my ($form,$text,$help)=@_;
1.329 droeschl 5133: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484 raeburn 5134: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
1.405 bisitz 5135: text=>&Apache::loncommon::course_type().' Editor',
1.329 droeschl 5136: faq=>273,
5137: bug=>'Instructor Interface',
1.484.2.44 raeburn 5138: help => $help});
1.329 droeschl 5139: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
5140: text=>$text,
5141: faq=>273,
5142: bug=>'Instructor Interface'});
5143: }
5144:
1.441 www 5145: # subroutine to list form elements
5146: sub create_list_elements {
5147: my @formarr = @_;
5148: my $list = '';
1.484.2.12 raeburn 5149: foreach my $button (@formarr){
5150: foreach my $picture (keys(%{$button})) {
5151: $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
1.441 www 5152: }
5153: }
5154: return $list;
5155: }
1.329 droeschl 5156:
1.441 www 5157: # subroutine to create ul from list elements
5158: sub create_form_ul {
5159: my $list = shift;
5160: my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
5161: return $ul;
5162: }
1.329 droeschl 5163:
1.442 www 5164: #
5165: # Start tabs
5166: #
5167:
5168: sub startContentScreen {
1.484 raeburn 5169: my ($mode) = @_;
5170: my $output = '<ul class="LC_TabContentBigger" id="mainnav">';
1.472 raeburn 5171: if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
1.484 raeburn 5172: $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n";
5173: $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n";
5174: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
5175: } else {
1.484.2.34 raeburn 5176: $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 5177: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
5178: $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>'."\n";
5179: '><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>';
5180: }
5181: $output .= "\n".'</ul>'."\n";
5182: $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
5183: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
5184: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
5185: return $output;
1.442 www 5186: }
5187:
5188: #
5189: # End tabs
5190: #
5191:
5192: sub endContentScreen {
1.484 raeburn 5193: return '</div></div></div>';
1.442 www 5194: }
1.329 droeschl 5195:
1.446 www 5196: sub supplemental_base {
1.484.2.33 raeburn 5197: return 'supplemental&'.&escape(&mt('Supplemental Content'));
1.446 www 5198: }
5199:
1.329 droeschl 5200: sub handler {
5201: my $r = shift;
5202: &Apache::loncommon::content_type($r,'text/html');
5203: $r->send_http_header;
5204: return OK if $r->header_only;
1.484 raeburn 5205:
5206: # get course data
1.408 raeburn 5207: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 5208: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
5209: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5210:
5211: # graphics settings
5212: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329 droeschl 5213:
1.443 www 5214: #
1.329 droeschl 5215: # --------------------------------------------- Initialize help topics for this
5216: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
1.484.2.85.2. (raeburn 5217:): 'Adding_External_Resource','Adding_External_Tool',
5218:): 'Navigate_Content','Adding_Folders','Docs_Overview',
5219:): 'Load_Map','Supplemental','Score_Upload_Form',
5220:): 'Adding_Pages','Importing_LON-CAPA_Resource',
5221:): 'Importing_IMS_Course','Uploading_From_Harddrive',
5222:): 'Course_Roster','Web_Page','Dropbox','Simple_Problem') {
1.329 droeschl 5223: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
5224: }
5225: # Composite help files
5226: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
5227: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
5228: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
5229: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
5230: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
5231: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 5232: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 5233: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 5234: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 5235: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1.484.2.30 raeburn 5236:
1.484.2.67 raeburn 5237: my ($allowed,$canedit,$canview,$disabled);
1.472 raeburn 5238: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
5239: unless ($r->uri eq '/adm/supplemental') {
5240: # does this user have privileges to modify content.
1.484.2.67 raeburn 5241: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
5242: $allowed = 1;
5243: $canedit = 1;
5244: $canview = 1;
5245: } elsif (&Apache::lonnet::allowed('cev',$env{'request.course.id'})) {
5246: $allowed = 1;
5247: $canview = 1;
5248: }
5249: }
5250: unless ($canedit) {
5251: $disabled = ' disabled="disabled"';
1.472 raeburn 5252: }
1.484.2.53 raeburn 5253: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']);
1.484.2.78 raeburn 5254: if ($env{'form.inhibitmenu'}) {
5255: unless ($env{'form.inhibitmenu'} eq 'yes') {
5256: delete($env{'form.inhibitmenu'});
5257: }
5258: }
5259:
1.484.2.53 raeburn 5260: if ($allowed && $env{'form.verify'}) {
1.484.2.44 raeburn 5261: &init_breadcrumbs('verify','Verify Content','Docs_Verify_Content');
1.484.2.78 raeburn 5262: if (!$canedit) {
5263: &verifycontent($r);
5264: } elsif (($env{'form.checkstale'} ne '') && ($env{'form.checkstale'} =~ /^\d$/)) {
5265: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1&verify=1&checkstale=$env{'form.checkstale'}",
5266: text=>'Results',
5267: faq=>273,
5268: bug=>'Instructor Interface'});
5269: &verifycontent($r,$env{'form.checkstale'});
5270: } else {
5271: &contentverifyform($r);
5272: }
1.329 droeschl 5273: } elsif ($allowed && $env{'form.listsymbs'}) {
1.484 raeburn 5274: &init_breadcrumbs('listsymbs','List Content IDs');
1.329 droeschl 5275: &list_symbs($r);
1.484.2.85.2. (raeburn 5276:): } elsif ($allowed && $env{'form.shorturls'}) {
5277:): &init_breadcrumbs('shorturls','Set/Display Shortened URLs','Docs_Short_URLs');
5278:): &short_urls($r,$canedit);
1.329 droeschl 5279: } elsif ($allowed && $env{'form.docslog'}) {
5280: &init_breadcrumbs('docslog','Show Log');
1.484 raeburn 5281: my $folder = $env{'form.folder'};
5282: if ($folder eq '') {
5283: $folder='default';
5284: }
1.484.2.67 raeburn 5285: &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit);
1.329 droeschl 5286: } elsif ($allowed && $env{'form.versions'}) {
1.484.2.44 raeburn 5287: &init_breadcrumbs('versions','Check/Set Resource Versions','Docs_Check_Resource_Versions');
1.484.2.67 raeburn 5288: &checkversions($r,$canedit);
5289: } elsif ($canedit && $env{'form.dumpcourse'}) {
1.484.2.43 raeburn 5290: &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329 droeschl 5291: &dumpcourse($r);
5292: } elsif ($allowed && $env{'form.exportcourse'}) {
1.377 bisitz 5293: &init_breadcrumbs('exportcourse','IMS Export');
1.475 raeburn 5294: &Apache::imsexport::exportcourse($r);
1.329 droeschl 5295: } else {
1.445 www 5296: #
5297: # Done catching special calls
1.484 raeburn 5298: # The whole rest is for course and supplemental documents and utilities menu
1.445 www 5299: # Get the parameters that may be needed
5300: #
5301: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.484.2.19 raeburn 5302: ['folderpath',
5303: 'forcesupplement','forcestandard',
5304: 'tools','symb','command','supppath']);
1.445 www 5305:
1.484.2.78 raeburn 5306: foreach my $item ('forcesupplement','forcestandard','tools') {
5307: next if ($env{'form.'.$item} eq '');
5308: unless ($env{'form.'.$item} eq '1') {
5309: delete($env{'form.'.$item});
5310: }
5311: }
5312:
5313: if ($env{'form.command'}) {
5314: unless ($env{'form.command'} =~ /^(direct|directnav|editdocs|editsupp|contents|home)$/) {
5315: delete($env{'form.command'});
5316: }
5317: }
5318:
5319: if ($env{'form.symb'}) {
5320: my ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.symb'});
5321: unless (($id =~ /^\d+$/) && (&Apache::lonnet::is_on_map($resurl))) {
5322: delete($env{'form.symb'});
5323: }
5324: }
5325:
1.445 www 5326: # standard=1: this is a "new-style" course with an uploaded map as top level
5327: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329 droeschl 5328:
5329: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445 www 5330:
1.484 raeburn 5331: # Decide whether this should display supplemental or main content or utilities
1.445 www 5332: # supplementalflag=1: show supplemental documents
5333: # supplementalflag=0: show standard documents
1.484 raeburn 5334: # toolsflag=1: show utilities
1.445 www 5335:
1.484.2.39 raeburn 5336: my $unesc_folderpath = &unescape($env{'form.folderpath'});
5337: my $supplementalflag=($unesc_folderpath=~/^supplemental/);
5338: if (($unesc_folderpath=~/^default/) || ($unesc_folderpath eq "")) {
1.445 www 5339: $supplementalflag=0;
5340: }
5341: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
5342: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
5343: unless ($allowed) { $supplementalflag=1; }
5344: unless ($standard) { $supplementalflag=1; }
1.484 raeburn 5345: my $toolsflag=0;
5346: if ($env{'form.tools'}) { $toolsflag=1; }
1.445 www 5347:
1.484.2.78 raeburn 5348: if ($env{'form.folderpath'} ne '') {
5349: my @items = split(/\&/,$env{'form.folderpath'});
5350: my $badpath;
5351: for (my $i=0; $i<@items; $i++) {
5352: my $odd = $i%2;
5353: if (($odd) && (!$supplementalflag) && ($items[$i] !~ /^[^:]*:(|\d+):(|1):(|1):(|1):(|1)$/)) {
5354: $badpath = 1;
5355: } elsif ((!$odd) && ($items[$i] !~ /^(default|supplemental)(|_\d+)$/)) {
5356: $badpath = 1;
5357: }
5358: last if ($badpath);
5359: }
5360: if ($badpath) {
5361: delete($env{'form.folderpath'});
5362: }
5363: }
5364:
5365: if ($env{'form.supppath'} ne '') {
5366: my @items = split(/\&/,$env{'form.supppath'});
5367: my $badpath;
5368: for (my $i=0; $i<@items; $i++) {
5369: my $odd = $i%2;
5370: if ((!$odd) && ($items[$i] !~ /^supplemental(|_\d+)$/)) {
5371: $badpath = 1;
5372: }
5373: last if ($badpath);
5374: }
5375: if ($badpath) {
5376: delete($env{'form.supppath'});
5377: }
5378: }
5379:
1.329 droeschl 5380: my $script='';
5381: my $showdoc=0;
1.457 raeburn 5382: my $addentries = {};
1.475 raeburn 5383: my $container;
1.329 droeschl 5384: my $containertag;
1.484.2.17 raeburn 5385: my $pathitem;
1.484.2.85.2. (raeburn 5386:): my %ltitools;
1.484.2.67 raeburn 5387: my $hiddentop;
5388: my $navmap;
5389: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.329 droeschl 5390:
1.464 www 5391: # Do we directly jump somewhere?
1.484.2.21 raeburn 5392: if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
1.472 raeburn 5393: if ($env{'form.symb'} ne '') {
1.484.2.19 raeburn 5394: $env{'form.folderpath'}=
1.484.2.67 raeburn 5395: &Apache::loncommon::symb_to_docspath($env{'form.symb'},\$navmap);
1.484.2.21 raeburn 5396: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
5397: $env{'form.command'}.'_'.$env{'form.symb'}});
1.472 raeburn 5398: } elsif ($env{'form.supppath'} ne '') {
5399: $env{'form.folderpath'}=$env{'form.supppath'};
1.484.2.21 raeburn 5400: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
5401: $env{'form.command'}.'_'.$env{'form.supppath'}});
1.466 www 5402: }
1.472 raeburn 5403: } elsif ($env{'form.command'} eq 'editdocs') {
1.484.2.67 raeburn 5404: $env{'form.folderpath'} = &default_folderpath($coursenum,$coursedom,\$navmap);
1.484.2.21 raeburn 5405: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
1.472 raeburn 5406: } elsif ($env{'form.command'} eq 'editsupp') {
1.484.2.67 raeburn 5407: $env{'form.folderpath'} = &supplemental_base();
1.484.2.21 raeburn 5408: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
5409: } elsif ($env{'form.command'} eq 'contents') {
5410: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
5411: } elsif ($env{'form.command'} eq 'home') {
5412: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
1.464 www 5413: }
5414:
1.484.2.23 raeburn 5415:
1.445 www 5416: # Where do we store these for when we come back?
5417: my $stored_folderpath='docs_folderpath';
5418: if ($supplementalflag) {
5419: $stored_folderpath='docs_sup_folderpath';
5420: }
1.464 www 5421:
1.484.2.19 raeburn 5422: # No folderpath, and in edit mode, see if we have something stored
5423: if ((!$env{'form.folderpath'}) && $allowed) {
1.445 www 5424: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.484.2.19 raeburn 5425: {'folderpath' => 'scalar'});
1.484.2.67 raeburn 5426:
5427: if (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
5428: if ($supplementalflag) {
5429: undef($env{'form.folderpath'}) if ($1 eq 'default');
5430: } else {
5431: undef($env{'form.folderpath'}) if ($1 eq 'supplemental');
5432: }
5433: } else {
1.484.2.19 raeburn 5434: undef($env{'form.folderpath'});
5435: }
1.329 droeschl 5436: }
1.446 www 5437:
5438: # If we are not allowed to make changes, all we can see are supplemental docs
1.409 raeburn 5439: if (!$allowed) {
1.446 www 5440: unless ($env{'form.folderpath'} =~ /^supplemental/) {
5441: $env{'form.folderpath'} = &supplemental_base();
1.409 raeburn 5442: }
5443: }
1.446 www 5444: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329 droeschl 5445: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446 www 5446: $env{'form.folderpath'} = &supplemental_base()
5447: .'&'.
1.329 droeschl 5448: $env{'form.folderpath'};
5449: }
1.484.2.67 raeburn 5450: # If allowed and user's role is not advanced check folderpath is not hidden
5451: if (($allowed) && (!$env{'request.role.adv'}) &&
5452: ($env{'form.folderpath'} ne '') && (!$supplementalflag)) {
5453: my $folderurl;
5454: my @pathitems = split(/\&/,$env{'form.folderpath'});
5455: my $folder = $pathitems[-2];
5456: if ($folder eq '') {
5457: undef($env{'form.folderpath'});
5458: } else {
5459: $folderurl = "uploaded/$coursedom/$coursenum/$folder";
5460: if ((split(/\:/,$pathitems[-1]))[4]) {
5461: $folderurl .= '.page';
5462: } else {
5463: $folderurl .= '.sequence';
5464: }
5465: unless (ref($navmap)) {
5466: $navmap = Apache::lonnavmaps::navmap->new();
5467: }
5468: if (ref($navmap)) {
5469: if (lc($navmap->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
5470: my @resources = $navmap->retrieveResources($folderurl,$filterFunc,1,1);
5471: unless (@resources) {
5472: undef($env{'form.folderpath'});
5473: }
5474: }
5475: }
5476: }
5477: }
5478:
5479:
1.446 www 5480: # If after all of this, we still don't have any paths, make them
1.484.2.19 raeburn 5481: unless ($env{'form.folderpath'}) {
1.446 www 5482: if ($supplementalflag) {
5483: $env{'form.folderpath'}=&supplemental_base();
1.484.2.67 raeburn 5484: } elsif ($allowed) {
5485: ($env{'form.folderpath'},$hiddentop) = &default_folderpath($coursenum,$coursedom,\$navmap);
1.446 www 5486: }
1.472 raeburn 5487: }
1.446 www 5488:
1.445 www 5489: # Store this
1.484 raeburn 5490: unless ($toolsflag) {
1.484.2.67 raeburn 5491: if (($allowed) && ($env{'form.folderpath'} ne '')) {
1.484.2.19 raeburn 5492: &Apache::loncommon::store_course_settings($stored_folderpath,
5493: {'folderpath' => 'scalar'});
5494: }
5495: my $folderpath;
1.484 raeburn 5496: if ($env{'form.folderpath'}) {
1.484.2.19 raeburn 5497: $folderpath = $env{'form.folderpath'};
5498: my (@folders)=split('&',$env{'form.folderpath'});
5499: $env{'form.foldername'}=&unescape(pop(@folders));
5500: if ($env{'form.foldername'} =~ /\:1$/) {
5501: $container = 'page';
5502: } else {
5503: $container = 'sequence';
5504: }
5505: $env{'form.folder'}=pop(@folders);
1.484 raeburn 5506: } else {
1.484.2.19 raeburn 5507: if ($env{'form.folder'} eq '' ||
5508: $env{'form.folder'} eq 'supplemental') {
1.484.2.67 raeburn 5509: if ($env{'form.folder'} eq 'supplemental') {
5510: $folderpath=&supplemental_base();
5511: } elsif (!$hiddentop) {
5512: $folderpath='default&'.
5513: &escape(&mt('Main Content').':::::');
5514: }
1.484 raeburn 5515: }
5516: }
1.484.2.19 raeburn 5517: $containertag = '<input type="hidden" name="folderpath" value="" />';
5518: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 5519: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
5520: $showdoc='/'.$1;
5521: }
5522: if ($showdoc) { # got called in sequence from course
5523: $allowed=0;
5524: } else {
1.484.2.67 raeburn 5525: if ($canedit) {
1.484 raeburn 5526: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
5527: $script=&Apache::lonratedt::editscript('simple');
1.433 raeburn 5528: }
5529: }
1.329 droeschl 5530: }
5531:
1.344 bisitz 5532: # get personal data
1.329 droeschl 5533: my $uname=$env{'user.name'};
5534: my $udom=$env{'user.domain'};
5535: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
5536:
5537: if ($allowed) {
1.484 raeburn 5538: if ($toolsflag) {
5539: $script .= &inject_data_js();
5540: my ($home,$other,%outhash)=&authorhosts();
5541: if (!$home && $other) {
5542: my @hosts;
5543: foreach my $aurole (keys(%outhash)) {
5544: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
5545: push(@hosts,$outhash{$aurole});
5546: }
5547: }
5548: $script .= &dump_switchserver_js(@hosts);
5549: }
1.458 raeburn 5550: } else {
1.484.2.43 raeburn 5551: my $tid = 1;
1.484 raeburn 5552: my @tabids;
5553: if ($supplementalflag) {
5554: @tabids = ('002','ee2','ff2');
1.484.2.43 raeburn 5555: $tid = 2;
1.484 raeburn 5556: } else {
5557: @tabids = ('aa1','bb1','cc1','ff1');
1.484.2.19 raeburn 5558: unless ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 5559: unshift(@tabids,'001');
5560: push(@tabids,('dd1','ee1'));
5561: }
1.458 raeburn 5562: }
1.484 raeburn 5563: my $tabidstr = join("','",@tabids);
1.484.2.85.2. (raeburn 5564:): %ltitools = &Apache::lonnet::get_domain_ltitools($coursedom);
5565:): my $posslti = keys(%ltitools);
1.484.2.80 raeburn 5566: my $hostname = $r->hostname();
1.484.2.85.2. (raeburn 5567:): $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
1.484.2.80 raeburn 5568: $canedit,$hostname,\$navmap).
1.484 raeburn 5569: &history_tab_js().
5570: &inject_data_js().
1.484.2.43 raeburn 5571: &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
1.484.2.85.2. (raeburn 5572:): &Apache::lonextresedit::extedit_javascript(\%ltitools);
1.484 raeburn 5573: $addentries = {
1.484.2.3 raeburn 5574: onload => "javascript:resize_scrollbox('contentscroll','1','1');",
1.484 raeburn 5575: };
1.458 raeburn 5576: }
1.484.2.30 raeburn 5577: $script .= &paste_popup_js();
1.484.2.12 raeburn 5578: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
5579: &mt('Switch server?');
1.484.2.19 raeburn 5580:
5581:
1.329 droeschl 5582: }
5583: # -------------------------------------------------------------------- Body tag
1.369 bisitz 5584: $script = '<script type="text/javascript">'."\n"
1.372 bisitz 5585: .'// <![CDATA['."\n"
5586: .$script."\n"
5587: .'// ]]>'."\n"
1.484.2.81 raeburn 5588: .'</script>'."\n"
5589: .'<script type="text/javascript" src="/res/adm/includes/file_upload.js"></script>'."\n";
1.385 bisitz 5590:
5591: # Breadcrumbs
5592: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484.2.19 raeburn 5593:
5594: if ($showdoc) {
5595: $r->print(&Apache::loncommon::start_page("$crstype documents",undef,
5596: {'force_register' => $showdoc,}));
1.484.2.44 raeburn 5597: } elsif ($toolsflag) {
1.484.2.67 raeburn 5598: my ($breadtext,$breadtitle);
5599: $breadtext = "$crstype Editor";
5600: if ($canedit) {
5601: $breadtitle = 'Editing '.$crstype.' Contents';
5602: } else {
5603: $breadtext .= ' (View-only mode)';
5604: $breadtitle = 'Viewing '.$crstype.' Contents';
5605: }
1.484.2.44 raeburn 5606: &Apache::lonhtmlcommon::add_breadcrumb({
1.484.2.67 raeburn 5607: href=>"/adm/coursedocs",text=>$breadtext});
1.484.2.44 raeburn 5608: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script)
5609: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5610: .&Apache::lonhtmlcommon::breadcrumbs(
1.484.2.67 raeburn 5611: $breadtitle)
1.484.2.44 raeburn 5612: );
1.484.2.19 raeburn 5613: } elsif ($r->uri eq '/adm/supplemental') {
5614: my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
5615: $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
5616: {'bread_crumbs' => $brcrum,}));
5617: } else {
1.484.2.67 raeburn 5618: my ($breadtext,$breadtitle,$helpitem);
5619: $breadtext = "$crstype Editor";
5620: if ($canedit) {
5621: $breadtitle = 'Editing '.$crstype.' Contents';
5622: $helpitem = 'Docs_Adding_Course_Doc';
5623: } else {
5624: $breadtext .= ' (View-only mode)';
5625: $breadtitle = 'Viewing '.$crstype.' Contents';
5626: $helpitem = 'Docs_Viewing_Course_Doc';
5627: }
1.392 raeburn 5628: &Apache::lonhtmlcommon::add_breadcrumb({
1.484.2.67 raeburn 5629: href=>"/adm/coursedocs",text=>$breadtext});
1.446 www 5630: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.484.2.19 raeburn 5631: {'add_entries' => $addentries}
5632: )
1.392 raeburn 5633: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5634: .&Apache::lonhtmlcommon::breadcrumbs(
1.484.2.67 raeburn 5635: $breadtitle,
5636: $helpitem)
1.392 raeburn 5637: );
5638: }
1.364 bisitz 5639:
1.329 droeschl 5640: my %allfiles = ();
5641: my %codebase = ();
1.440 raeburn 5642: my ($upload_result,$upload_output,$uploadphase);
1.484.2.67 raeburn 5643: if ($canedit) {
1.329 droeschl 5644: if (($env{'form.uploaddoc.filename'}) &&
5645: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440 raeburn 5646: my $context = $1;
5647: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 5648: undef($hadchanges);
1.440 raeburn 5649: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
1.484.2.36 raeburn 5650: \%allfiles,\%codebase,$context,$crstype);
1.484.2.73 raeburn 5651: undef($navmap);
1.329 droeschl 5652: if ($hadchanges) {
5653: &mark_hash_old();
5654: }
1.440 raeburn 5655: $r->print($upload_output);
5656: } elsif ($env{'form.phase'} eq 'upload_embedded') {
5657: # Process file upload - phase two - upload embedded objects
5658: $uploadphase = 'check_embedded';
5659: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
5660: my $state = &embedded_form_elems($uploadphase,$primaryurl,
5661: $env{'form.newidx'});
5662: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5663: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5664: my ($destination,$dir_root) = &embedded_destination();
5665: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
5666: my $actionurl = '/adm/coursedocs';
5667: my ($result,$flag) =
5668: &Apache::loncommon::upload_embedded('coursedoc',$destination,
5669: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
5670: $actionurl);
5671: $r->print($result.&return_to_editor());
5672: } elsif ($env{'form.phase'} eq 'check_embedded') {
5673: # Process file upload - phase three - modify references in HTML file
5674: $uploadphase = 'modified_orightml';
5675: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5676: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5677: my ($destination,$dir_root) = &embedded_destination();
1.482 raeburn 5678: my $result =
5679: &Apache::loncommon::modify_html_refs('coursedoc',$destination,
5680: $docuname,$docudom,undef,
5681: $dir_root);
5682: $r->print($result.&return_to_editor());
1.476 raeburn 5683: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
5684: $uploadphase = 'decompress_phase_one';
5685: $r->print(&decompression_phase_one().
5686: &return_to_editor());
5687: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
5688: $uploadphase = 'decompress_phase_two';
5689: $r->print(&decompression_phase_two().
5690: &return_to_editor());
1.329 droeschl 5691: }
5692: }
5693:
1.484 raeburn 5694: if ($allowed && $toolsflag) {
5695: $r->print(&startContentScreen('tools'));
1.484.2.67 raeburn 5696: $r->print(&generate_admin_menu($crstype,$canedit));
1.484 raeburn 5697: $r->print(&endContentScreen());
5698: } elsif ((!$showdoc) && (!$uploadphase)) {
1.329 droeschl 5699: # -----------------------------------------------------------------------------
5700: my %lt=&Apache::lonlocal::texthash(
5701: 'copm' => 'All documents out of a published map into this folder',
1.484.2.12 raeburn 5702: 'upfi' => 'Upload File',
1.484.2.36 raeburn 5703: 'upld' => 'Upload Content',
1.329 droeschl 5704: 'srch' => 'Search',
5705: 'impo' => 'Import',
1.484.2.19 raeburn 5706: 'lnks' => 'Import from Stored Links',
1.484.2.13 raeburn 5707: 'impm' => 'Import from Assembled Map',
1.484.2.85.2. (raeburn 5708:): 'extr' => 'External Resource',
5709:): 'extt' => 'External Tool',
1.329 droeschl 5710: 'selm' => 'Select Map',
5711: 'load' => 'Load Map',
5712: 'newf' => 'New Folder',
5713: 'newp' => 'New Composite Page',
5714: 'syll' => 'Syllabus',
1.425 raeburn 5715: 'navc' => 'Table of Contents',
1.343 biermanm 5716: 'sipa' => 'Simple Course Page',
1.329 droeschl 5717: 'sipr' => 'Simple Problem',
1.484.2.27 raeburn 5718: 'webp' => 'Blank Web Page (editable)',
1.329 droeschl 5719: 'drbx' => 'Drop Box',
1.451 www 5720: 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336 schafran 5721: 'bull' => 'Discussion Board',
1.347 weissno 5722: 'mypi' => 'My Personal Information Page',
1.353 weissno 5723: 'grpo' => 'Group Portfolio',
1.329 droeschl 5724: 'rost' => 'Course Roster',
1.484.2.22 raeburn 5725: 'abou' => 'Personal Information Page for a User',
1.484.2.36 raeburn 5726: 'imsf' => 'IMS Upload',
5727: 'imsl' => 'Upload IMS package',
1.484.2.12 raeburn 5728: 'cms' => 'Origin of IMS package',
5729: 'se' => 'Select',
1.484.2.19 raeburn 5730: 'file' => 'File',
1.329 droeschl 5731: 'title' => 'Title',
5732: 'comment' => 'Comment',
1.403 raeburn 5733: 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.484.2.50 raeburn 5734: 'bb5' => 'Blackboard 5',
5735: 'bb6' => 'Blackboard 6',
5736: 'angel5' => 'ANGEL 5.5',
5737: 'webctce4' => 'WebCT 4 Campus Edition',
1.484.2.67 raeburn 5738: 'er' => 'Editing rights unavailable for your current role.',
1.484.2.50 raeburn 5739: );
1.329 droeschl 5740: # -----------------------------------------------------------------------------
1.484.2.82 raeburn 5741: # Calculate free quota space for a user or course. A javascript function checks
5742: # file size to determine if upload should be allowed.
1.484.2.64 raeburn 5743: my $quotatype = 'unofficial';
5744: if ($crstype eq 'Community') {
5745: $quotatype = 'community';
5746: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
5747: $quotatype = 'official';
5748: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
5749: $quotatype = 'textbook';
5750: }
5751: my $disk_quota = &Apache::loncommon::get_user_quota($coursenum,$coursedom,
5752: 'course',$quotatype); # expressed in MB
5753: my $current_disk_usage = 0;
5754: foreach my $subdir ('docs','supplemental') {
5755: $current_disk_usage += &Apache::lonnet::diskusage($coursedom,$coursenum,
5756: "userfiles/$subdir",1); # expressed in kB
5757: }
5758: my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage);
5759: my $usage = $current_disk_usage/1024; # in MB
5760: my $quota = $disk_quota;
5761: my $percent;
5762: if ($disk_quota == 0) {
5763: $percent = 100.0;
5764: } else {
1.484.2.69 raeburn 5765: $percent = 100*($usage/$disk_quota);
1.484.2.64 raeburn 5766: }
5767: $usage = sprintf("%.2f",$usage);
5768: $quota = sprintf("%.2f",$quota);
5769: $percent = sprintf("%.0f",$percent);
5770: my $quotainfo = '<p>'.&mt('Currently using [_1] of the [_2] available.',
5771: $percent.'%',$quota.' MB').'</p>';
5772:
1.329 droeschl 5773: my $fileupload=(<<FIUP);
1.484.2.64 raeburn 5774: $quotainfo
1.329 droeschl 5775: $lt{'file'}:<br />
1.484.2.81 raeburn 5776: <input type="file" name="uploaddoc" class="LC_flUpload" size="40" $disabled />
5777: <input type="hidden" id="LC_free_space" value="$free_space" />
1.329 droeschl 5778: FIUP
5779:
5780: my $checkbox=(<<CHBO);
5781: <!-- <label>$lt{'parse'}?
5782: <input type="checkbox" name="parserflag" />
5783: </label> -->
5784: <label>
1.484.2.67 raeburn 5785: <input type="checkbox" name="parserflag" checked="checked" $disabled /> $lt{'parse'}
1.329 droeschl 5786: </label>
5787: CHBO
1.484.2.12 raeburn 5788: my $imsfolder = $env{'form.folder'};
5789: if ($imsfolder eq '') {
1.484.2.19 raeburn 5790: $imsfolder = 'default';
1.484.2.12 raeburn 5791: }
5792: my $imspform=(<<IMSFORM);
5793: <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
5794: $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
5795: <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
1.484.2.19 raeburn 5796: <fieldset id="uploadimsform" style="display: none;">
1.484.2.12 raeburn 5797: <legend>$lt{'imsf'}</legend>
5798: $fileupload
5799: <br />
5800: <p>
1.484.2.19 raeburn 5801: $lt{'cms'}:
1.484.2.67 raeburn 5802: <select name="source" $disabled>
1.484.2.12 raeburn 5803: <option value="-1" selected="selected">$lt{'se'}</option>
1.484.2.50 raeburn 5804: <option value="bb5">$lt{'bb5'}</option>
5805: <option value="bb6">$lt{'bb6'}</option>
5806: <option value="angel5">$lt{'angel5'}</option>
5807: <option value="webctce4">$lt{'webctce4'}</option>
1.484.2.12 raeburn 5808: </select>
5809: <input type="hidden" name="folder" value="$imsfolder" />
5810: </p>
5811: <input type="hidden" name="phase" value="one" />
1.484.2.67 raeburn 5812: <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" $disabled />
1.484.2.12 raeburn 5813: </fieldset>
5814: </form>
5815: IMSFORM
5816:
1.484.2.19 raeburn 5817: my $fileuploadform=(<<FUFORM);
1.484.2.12 raeburn 5818: <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
5819: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
5820: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.484.2.19 raeburn 5821: <fieldset id="uploaddocform" style="display: none;">
1.484.2.12 raeburn 5822: <legend>$lt{'upfi'}</legend>
1.371 tempelho 5823: <input type="hidden" name="active" value="aa" />
1.329 droeschl 5824: $fileupload
5825: <br />
5826: $lt{'title'}:<br />
1.484.2.67 raeburn 5827: <input type="text" size="60" name="comment" $disabled />
1.484.2.17 raeburn 5828: $pathitem
1.329 droeschl 5829: <input type="hidden" name="cmd" value="upload_default" />
5830: <br />
1.458 raeburn 5831: <span class="LC_nobreak" style="float:left">
1.329 droeschl 5832: $checkbox
5833: </span>
1.484.2.12 raeburn 5834: <br clear="all" />
1.484.2.67 raeburn 5835: <input type="submit" value="$lt{'upld'}" $disabled />
1.484.2.12 raeburn 5836: </fieldset>
5837: </form>
1.383 tempelho 5838: FUFORM
1.329 droeschl 5839:
1.484.2.67 raeburn 5840: my $mapimportjs;
5841: if ($canedit) {
5842: $mapimportjs = "javascript:openbrowser('mapimportform','importmap','sequence,page','');";
5843: } else {
5844: $mapimportjs = "javascript:alert('".&js_escape($lt{'er'})."');";
5845: }
1.484.2.19 raeburn 5846: my $importpubform=(<<SEDFFORM);
5847: <a class="LC_menubuttons_link" href="javascript:toggleMap('map');">
1.484.2.13 raeburn 5848: $lt{'impm'}</a>$help{'Load_Map'}
1.484.2.19 raeburn 5849: <form action="/adm/coursedocs" method="post" name="mapimportform">
5850: <fieldset id="importmapform" style="display: none;">
1.484.2.13 raeburn 5851: <legend>$lt{'impm'}</legend>
1.484.2.19 raeburn 5852: <input type="hidden" name="active" value="bb" />
1.484.2.13 raeburn 5853: $lt{'copm'}<br />
5854: <span class="LC_nobreak">
1.484.2.19 raeburn 5855: <input type="text" name="importmap" size="40" value=""
1.484.2.67 raeburn 5856: onfocus="this.blur();$mapimportjs" $disabled />
5857: <a href="$mapimportjs">$lt{'selm'}</a></span><br />
5858: <input type="submit" name="loadmap" value="$lt{'load'}" $disabled />
1.484.2.13 raeburn 5859: </fieldset>
5860: </form>
5861:
1.383 tempelho 5862: SEDFFORM
1.484.2.67 raeburn 5863:
5864: my $fromstoredjs;
5865: if ($canedit) {
5866: $fromstoredjs = 'open_StoredLinks_Import()';
5867: } else {
5868: $fromstoredjs = "alert('".&js_escape($lt{'er'})."')";
5869: }
5870:
1.484.2.19 raeburn 5871: my @importpubforma = (
5872: { '<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 5873: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{impo}.'" onclick="javascript:groupimport();"/>' => "<a class='LC_menubuttons_link' href='javascript:groupimport();'>$lt{'impo'}</a>$help{'Importing_LON-CAPA_Resource'}" },
1.484.2.67 raeburn 5874: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{lnks}.'" onclick="javascript:'.$fromstoredjs.';" />' => '<a class="LC_menubuttons_link" href="javascript:'.$fromstoredjs.';">'.$lt{'lnks'}.'</a>' },
1.484.2.19 raeburn 5875: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform }
5876: );
5877: $importpubform = &create_form_ul(&create_list_elements(@importpubforma));
5878: my $extresourcesform =
5879: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
1.484.2.67 raeburn 5880: $help{'Adding_External_Resource'},
1.484.2.85.2. (raeburn 5881:): undef,undef,undef,undef,undef,undef,$disabled);
5882:): my $exttoolform =
5883:): &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
5884:): $help{'Adding_External_Tool'},undef,
5885:): undef,'tool',$coursedom,$coursenum,
5886:): \%ltitools,$disabled);
1.329 droeschl 5887: if ($allowed) {
1.484.2.7 raeburn 5888: my $folder = $env{'form.folder'};
5889: if ($folder eq '') {
5890: $folder='default';
5891: }
1.484.2.67 raeburn 5892: if ($canedit) {
5893: my $output = &update_paste_buffer($coursenum,$coursedom,$folder);
5894: if ($output) {
5895: $r->print($output);
5896: }
1.484.2.30 raeburn 5897: }
1.337 ehlerst 5898: $r->print(<<HIDDENFORM);
5899: <form name="renameform" method="post" action="/adm/coursedocs">
5900: <input type="hidden" name="title" />
5901: <input type="hidden" name="cmd" />
5902: <input type="hidden" name="markcopy" />
5903: <input type="hidden" name="copyfolder" />
5904: $containertag
5905: </form>
1.484 raeburn 5906:
1.337 ehlerst 5907: HIDDENFORM
1.484.2.17 raeburn 5908: $r->print(&makesimpleeditform($pathitem)."\n".
5909: &makedocslogform($pathitem."\n".
1.484 raeburn 5910: '<input type="hidden" name="folder" value="'.
5911: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 5912: }
1.442 www 5913:
5914: # Generate the tabs
1.484.2.19 raeburn 5915: my ($mode,$needs_end);
1.472 raeburn 5916: if (($supplementalflag) && (!$allowed)) {
1.484.2.19 raeburn 5917: my @folders = split('&',$env{'form.folderpath'});
5918: unless (@folders > 2) {
5919: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
5920: $needs_end = 1;
5921: }
1.472 raeburn 5922: } else {
1.484 raeburn 5923: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484.2.19 raeburn 5924: $needs_end = 1;
1.472 raeburn 5925: }
1.443 www 5926:
1.442 www 5927: #
5928:
5929: my $savefolderpath;
5930:
1.395 raeburn 5931: if ($allowed) {
1.329 droeschl 5932: my $folder=$env{'form.folder'};
1.484.2.67 raeburn 5933: if ((($folder eq '') && (!$hiddentop)) || ($supplementalflag)) {
1.329 droeschl 5934: $folder='default';
1.356 tempelho 5935: $savefolderpath = $env{'form.folderpath'};
1.484.2.33 raeburn 5936: $env{'form.folderpath'}='default&'.&escape(&mt('Main Content'));
1.484.2.17 raeburn 5937: $pathitem = '<input type="hidden" name="folderpath" value="'.
1.329 droeschl 5938: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
5939: }
5940: my $postexec='';
5941: if ($folder eq 'default') {
1.372 bisitz 5942: $r->print('<script type="text/javascript">'."\n"
5943: .'// <![CDATA['."\n"
5944: .'this.window.name="loncapaclient";'."\n"
5945: .'// ]]>'."\n"
5946: .'</script>'."\n"
1.369 bisitz 5947: );
1.329 droeschl 5948: } else {
5949: #$postexec='self.close();';
5950: }
1.484.2.15 raeburn 5951: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
5952: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
1.329 droeschl 5953: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
5954:
5955: my $newnavform=(<<NNFORM);
5956: <form action="/adm/coursedocs" method="post" name="newnav">
1.484.2.43 raeburn 5957: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 5958: $pathitem
1.329 droeschl 5959: <input type="hidden" name="importdetail"
5960: value="$lt{'navc'}=/adm/navmaps" />
1.484.2.67 raeburn 5961: <a class="LC_menubuttons_link" href="javascript:makenew(document.newnav);">$lt{'navc'}</a>
1.329 droeschl 5962: $help{'Navigate_Content'}
5963: </form>
5964: NNFORM
5965: my $newsmppageform=(<<NSPFORM);
5966: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.484.2.43 raeburn 5967: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 5968: $pathitem
1.329 droeschl 5969: <input type="hidden" name="importdetail" value="" />
1.423 onken 5970: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 5971: $help{'Simple Page'}
1.329 droeschl 5972: </form>
5973: NSPFORM
5974:
5975: my $newsmpproblemform=(<<NSPROBFORM);
5976: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371 tempelho 5977: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 5978: $pathitem
1.329 droeschl 5979: <input type="hidden" name="importdetail" value="" />
1.423 onken 5980: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.484.2.44 raeburn 5981: $help{'Simple_Problem'}
1.329 droeschl 5982: </form>
5983:
5984: NSPROBFORM
5985:
5986: my $newdropboxform=(<<NDBFORM);
5987: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.371 tempelho 5988: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 5989: $pathitem
1.329 droeschl 5990: <input type="hidden" name="importdetail" value="" />
1.423 onken 5991: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.484.2.36 raeburn 5992: $help{'Dropbox'}
1.344 bisitz 5993: </form>
1.329 droeschl 5994: NDBFORM
5995:
5996: my $newexuploadform=(<<NEXUFORM);
5997: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.371 tempelho 5998: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 5999: $pathitem
1.329 droeschl 6000: <input type="hidden" name="importdetail" value="" />
1.423 onken 6001: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 6002: $help{'Score_Upload_Form'}
6003: </form>
6004: NEXUFORM
6005:
6006: my $newbulform=(<<NBFORM);
6007: <form action="/adm/coursedocs" method="post" name="newbul">
1.484.2.43 raeburn 6008: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 6009: $pathitem
1.329 droeschl 6010: <input type="hidden" name="importdetail" value="" />
1.423 onken 6011: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 6012: $help{'Bulletin Board'}
6013: </form>
6014: NBFORM
6015:
6016: my $newaboutmeform=(<<NAMFORM);
6017: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.484.2.43 raeburn 6018: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 6019: $pathitem
1.329 droeschl 6020: <input type="hidden" name="importdetail"
6021: value="$plainname=/adm/$udom/$uname/aboutme" />
1.484.2.67 raeburn 6022: <a class="LC_menubuttons_link" href="javascript:makenew(document.newaboutme);">$lt{'mypi'}</a>
1.347 weissno 6023: $help{'My Personal Information Page'}
1.329 droeschl 6024: </form>
6025: NAMFORM
6026:
6027: my $newaboutsomeoneform=(<<NASOFORM);
6028: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.484.2.43 raeburn 6029: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 6030: $pathitem
1.329 droeschl 6031: <input type="hidden" name="importdetail" value="" />
1.423 onken 6032: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 6033: </form>
6034: NASOFORM
6035:
6036: my $newrosterform=(<<NROSTFORM);
6037: <form action="/adm/coursedocs" method="post" name="newroster">
1.484.2.43 raeburn 6038: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 6039: $pathitem
1.329 droeschl 6040: <input type="hidden" name="importdetail"
6041: value="$lt{'rost'}=/adm/viewclasslist" />
1.484.2.67 raeburn 6042: <a class="LC_menubuttons_link" href="javascript:makenew(document.newroster);">$lt{'rost'}</a>
1.484.2.37 raeburn 6043: $help{'Course_Roster'}
1.329 droeschl 6044: </form>
6045: NROSTFORM
6046:
1.484.2.27 raeburn 6047: my $newwebpage;
6048: if ($folder =~ /^default_?(\d*)$/) {
6049: $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
6050: if ($1) {
6051: $newwebpage .= $1;
6052: } else {
6053: $newwebpage .= 'default';
6054: }
6055: $newwebpage .= '/new.html';
6056: }
6057: my $newwebpageform =(<<NWEBFORM);
6058: <form action="/adm/coursedocs" method="post" name="newwebpage">
1.484.2.43 raeburn 6059: <input type="hidden" name="active" value="ee" />
1.484.2.27 raeburn 6060: $pathitem
6061: <input type="hidden" name="importdetail" value="$newwebpage" />
6062: <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
1.484.2.36 raeburn 6063: $help{'Web_Page'}
1.484.2.27 raeburn 6064: </form>
6065: NWEBFORM
1.484.2.30 raeburn 6066:
1.484.2.27 raeburn 6067:
1.342 ehlerst 6068: my $specialdocumentsform;
1.383 tempelho 6069: my @specialdocumentsforma;
1.451 www 6070: my $gradingform;
6071: my @gradingforma;
6072: my $communityform;
6073: my @communityforma;
1.351 ehlerst 6074: my $newfolderform;
1.390 tempelho 6075: my $newfolderb;
1.342 ehlerst 6076:
1.451 www 6077: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 6078:
1.329 droeschl 6079: my $newpageform=(<<NPFORM);
6080: <form action="/adm/coursedocs" method="post" name="newpage">
6081: <input type="hidden" name="folderpath" value="$path" />
6082: <input type="hidden" name="importdetail" value="" />
1.484.2.43 raeburn 6083: <input type="hidden" name="active" value="ee" />
1.423 onken 6084: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 6085: $help{'Adding_Pages'}
1.329 droeschl 6086: </form>
6087: NPFORM
1.390 tempelho 6088:
6089:
1.351 ehlerst 6090: $newfolderform=(<<NFFORM);
1.329 droeschl 6091: <form action="/adm/coursedocs" method="post" name="newfolder">
1.484.2.19 raeburn 6092: $pathitem
1.329 droeschl 6093: <input type="hidden" name="importdetail" value="" />
1.484.2.43 raeburn 6094: <input type="hidden" name="active" value="" />
1.422 onken 6095: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 6096: </form>
6097: NFFORM
6098:
6099: my $newsylform=(<<NSYLFORM);
6100: <form action="/adm/coursedocs" method="post" name="newsyl">
1.484.2.43 raeburn 6101: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 6102: $pathitem
1.329 droeschl 6103: <input type="hidden" name="importdetail"
6104: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.484.2.67 raeburn 6105: <a class="LC_menubuttons_link" href="javascript:makenew(document.newsyl);">$lt{'syll'}</a>
1.329 droeschl 6106: $help{'Syllabus'}
1.383 tempelho 6107:
1.329 droeschl 6108: </form>
6109: NSYLFORM
1.364 bisitz 6110:
1.329 droeschl 6111: my $newgroupfileform=(<<NGFFORM);
6112: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.484.2.43 raeburn 6113: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 6114: $pathitem
1.329 droeschl 6115: <input type="hidden" name="importdetail"
6116: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.484.2.67 raeburn 6117: <a class="LC_menubuttons_link" href="javascript:makenew(document.newgroupfiles);">$lt{'grpo'}</a>
1.353 weissno 6118: $help{'Group Portfolio'}
1.329 droeschl 6119: </form>
6120: NGFFORM
1.383 tempelho 6121: @specialdocumentsforma=(
1.421 onken 6122: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/page.png" alt="'.$lt{newp}.'" onclick="javascript:makenewpage(document.newpage,\''.$pageseq.'\');" />'=>$newpageform},
1.484.2.67 raeburn 6123: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.newsyl);" />'=>$newsylform},
6124: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="javascript:makenew(document.newnav);" />'=>$newnavform},
1.451 www 6125: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
1.484.2.27 raeburn 6126: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
1.451 www 6127: );
6128: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
6129:
1.434 raeburn 6130:
6131: my @importdoc = (
1.484.2.19 raeburn 6132: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform}
6133: );
1.484.2.85.2. (raeburn 6134:): if (keys(%ltitools)) {
6135:): push(@importdoc,
6136:): {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="toggleUpload(\'tool\');" />'=>$exttoolform},
6137:): );
6138:): }
1.484.2.19 raeburn 6139: unless ($container eq 'page') {
6140: push(@importdoc,
6141: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform}
6142: );
6143: }
6144: push(@importdoc,
1.484.2.38 raeburn 6145: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'doc\');" />'=>$fileuploadform}
1.484.2.19 raeburn 6146: );
1.484.2.12 raeburn 6147: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
1.434 raeburn 6148:
1.451 www 6149: @gradingforma=(
6150: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
6151: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
6152: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
6153:
6154: );
6155: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
6156:
6157: @communityforma=(
6158: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
6159: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
6160: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
1.484.2.67 raeburn 6161: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="javascript:makenew(document.newroster);" />'=>$newrosterform},
6162: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="javascript:makenew(document.newgroupfiles);" />'=>$newgroupfileform},
1.451 www 6163: );
6164: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 6165:
1.330 tempelho 6166: my %orderhash = (
1.484.2.36 raeburn 6167: 'aa' => ['Upload',$fileuploadform],
6168: 'bb' => ['Import',$importpubform],
6169: 'cc' => ['Grading',$gradingform],
1.330 tempelho 6170: );
1.484.2.19 raeburn 6171: unless ($container eq 'page') {
1.434 raeburn 6172: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.484 raeburn 6173: $orderhash{'dd'} = ['Collaboration',$communityform];
1.484.2.36 raeburn 6174: $orderhash{'ee'} = ['Other',$specialdocumentsform];
1.434 raeburn 6175: }
6176:
1.341 ehlerst 6177: $hadchanges=0;
1.484 raeburn 6178: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 6179: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.67 raeburn 6180: $supplementalflag,\%orderhash,$iconpath,$pathitem,
1.484.2.85.2. (raeburn 6181:): \%ltitools,$canedit,$hostname,\$navmap,$hiddentop);
1.484.2.67 raeburn 6182: undef($navmap);
1.443 www 6183: if ($error) {
6184: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
6185: }
6186: if ($hadchanges) {
1.484.2.73 raeburn 6187: unless (&is_hash_old()) {
6188: &mark_hash_old();
6189: }
1.443 www 6190: }
1.341 ehlerst 6191:
1.443 www 6192: &changewarning($r,'');
6193: }
1.458 raeburn 6194: }
1.442 www 6195:
1.443 www 6196: # Supplemental documents start here
6197:
1.329 droeschl 6198: my $folder=$env{'form.folder'};
1.443 www 6199: unless ($supplementalflag) {
1.329 droeschl 6200: $folder='supplemental';
6201: }
6202: if ($folder =~ /^supplemental$/ &&
6203: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 6204: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 6205: } elsif ($allowed) {
1.356 tempelho 6206: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 6207: }
1.484.2.17 raeburn 6208: $pathitem = '<input type="hidden" name="folderpath" value="'.
6209: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.329 droeschl 6210: if ($allowed) {
6211: my $folderseq=
1.484.2.15 raeburn 6212: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
1.329 droeschl 6213:
6214: my $supupdocform=(<<SUPDOCFORM);
1.484.2.12 raeburn 6215: <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
6216: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
1.383 tempelho 6217: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.484.2.19 raeburn 6218: <fieldset id="uploadsuppdocform" style="display: none;">
1.484.2.12 raeburn 6219: <legend>$lt{'upfi'}</legend>
1.371 tempelho 6220: <input type="hidden" name="active" value="ee" />
1.329 droeschl 6221: $fileupload
6222: <br />
6223: <br />
6224: <span class="LC_nobreak">
6225: $checkbox
6226: </span>
6227: <br /><br />
6228: $lt{'comment'}:<br />
1.383 tempelho 6229: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 6230: <br />
1.484.2.19 raeburn 6231: $pathitem
1.329 droeschl 6232: <input type="hidden" name="cmd" value="upload_supplemental" />
1.484.2.12 raeburn 6233: <input type='submit' value="$lt{'upld'}" />
6234: </form>
1.484.2.19 raeburn 6235: SUPDOCFORM
1.329 droeschl 6236:
6237: my $supnewfolderform=(<<SNFFORM);
6238: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.484.2.43 raeburn 6239: <input type="hidden" name="active" value="" />
1.484.2.17 raeburn 6240: $pathitem
1.329 droeschl 6241: <input type="hidden" name="importdetail" value="" />
1.423 onken 6242: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 6243: $help{'Adding_Folders'}
1.329 droeschl 6244: </form>
6245: SNFFORM
1.383 tempelho 6246:
1.484.2.19 raeburn 6247: my $supextform =
6248: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
1.484.2.67 raeburn 6249: $help{'Adding_External_Resource'},
6250: undef,undef,$disabled);
1.484.2.85.2. (raeburn 6251:): my $supexttoolform =
6252:): &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
6253:): $help{'Adding_External_Tool'},
6254:): undef,undef,'tool',$coursedom,
6255:): $coursenum,\%ltitools,$disabled);
1.329 droeschl 6256:
6257: my $supnewsylform=(<<SNSFORM);
6258: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 6259: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 6260: $pathitem
1.329 droeschl 6261: <input type="hidden" name="importdetail"
6262: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.484.2.67 raeburn 6263: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewsyl);">$lt{'syll'}</a>
1.329 droeschl 6264: $help{'Syllabus'}
6265: </form>
6266: SNSFORM
6267:
6268: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 6269: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 6270: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 6271: $pathitem
1.329 droeschl 6272: <input type="hidden" name="importdetail"
6273: value="$plainname=/adm/$udom/$uname/aboutme" />
1.484.2.67 raeburn 6274: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewaboutme);">$lt{'mypi'}</a>
1.347 weissno 6275: $help{'My Personal Information Page'}
1.329 droeschl 6276: </form>
6277: SNAMFORM
6278:
1.484.2.27 raeburn 6279: my $supwebpage;
6280: if ($folder =~ /^supplemental_?(\d*)$/) {
6281: $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
6282: if ($1) {
6283: $supwebpage .= $1;
6284: } else {
6285: $supwebpage .= 'default';
6286: }
6287: $supwebpage .= '/new.html';
6288: }
6289: my $supwebpageform =(<<SWEBFORM);
6290: <form action="/adm/coursedocs" method="post" name="supwebpage">
6291: <input type="hidden" name="active" value="cc" />
6292: $pathitem
6293: <input type="hidden" name="importdetail" value="$supwebpage" />
6294: <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
1.484.2.36 raeburn 6295: $help{'Web_Page'}
1.484.2.27 raeburn 6296: </form>
6297: SWEBFORM
6298:
1.333 muellerd 6299:
1.383 tempelho 6300: my @specialdocs = (
1.484.2.67 raeburn 6301: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.supnewsyl);" />'
1.417 droeschl 6302: =>$supnewsylform},
1.484.2.67 raeburn 6303: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makenew(document.supnewaboutme);" />'
1.417 droeschl 6304: =>$supnewaboutmeform},
1.484.2.27 raeburn 6305: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
6306:
1.383 tempelho 6307: );
1.417 droeschl 6308: my @supimportdoc = (
1.484.2.19 raeburn 6309: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleUpload(\'suppext\')" />'
1.484.2.85.2. (raeburn 6310:): =>$supextform});
6311:): if (keys(%ltitools)) {
6312:): push(@supimportdoc,
6313:): {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="javascript:toggleUpload(\'supptool\')" />'
6314:): =>$supexttoolform});
6315:): }
6316:): push(@supimportdoc,
1.484.2.12 raeburn 6317: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
6318: =>$supupdocform},
1.484.2.85.2. (raeburn 6319:): );
1.484.2.19 raeburn 6320:
1.484.2.12 raeburn 6321: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
1.333 muellerd 6322: my %suporderhash = (
1.390 tempelho 6323: '00' => ['Supnewfolder', $supnewfolderform],
1.484.2.36 raeburn 6324: 'ee' => ['Upload',$supupdocform],
6325: 'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 6326: );
1.443 www 6327: if ($supplementalflag) {
1.458 raeburn 6328: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.67 raeburn 6329: $supplementalflag,\%suporderhash,$iconpath,$pathitem,
1.484.2.85.2. (raeburn 6330:): \%ltitools,$canedit,$hostname);
1.443 www 6331: if ($error) {
6332: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.484.2.37 raeburn 6333: } else {
6334: if ($suppchanges) {
6335: my %servers = &Apache::lonnet::internet_dom_servers($coursedom);
6336: my @ids=&Apache::lonnet::current_machine_ids();
6337: foreach my $server (keys(%servers)) {
6338: next if (grep(/^\Q$server\E$/,@ids));
6339: my $hashid=$coursenum.':'.$coursedom;
1.484.2.42 raeburn 6340: my $cachekey = &escape('suppcount').':'.&escape($hashid);
6341: &Apache::lonnet::remote_devalidate_cache($server,[$cachekey]);
1.484.2.37 raeburn 6342: }
6343: &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
6344: undef($suppchanges);
6345: }
1.443 www 6346: }
1.393 raeburn 6347: }
1.443 www 6348: } elsif ($supplementalflag) {
1.458 raeburn 6349: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.85 raeburn 6350: $supplementalflag,'',$iconpath,$pathitem,'',$hostname);
1.393 raeburn 6351: if ($error) {
6352: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 6353: }
1.393 raeburn 6354: }
1.389 tempelho 6355:
1.484.2.19 raeburn 6356: if ($needs_end) {
6357: $r->print(&endContentScreen());
6358: }
1.383 tempelho 6359:
1.329 droeschl 6360: if ($allowed) {
6361: $r->print('
6362: <form method="post" name="extimport" action="/adm/coursedocs">
6363: <input type="hidden" name="title" />
6364: <input type="hidden" name="url" />
6365: <input type="hidden" name="useform" />
6366: <input type="hidden" name="residx" />
6367: </form>');
6368: }
1.484 raeburn 6369: } elsif ($showdoc) {
1.329 droeschl 6370: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 6371: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.484.2.10 raeburn 6372: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 6373: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 6374: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 6375: }
6376: }
6377: $r->print(&Apache::loncommon::end_page());
6378: return OK;
1.364 bisitz 6379: }
1.329 droeschl 6380:
1.440 raeburn 6381: sub embedded_form_elems {
6382: my ($phase,$primaryurl,$newidx) = @_;
6383: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.484.2.78 raeburn 6384: $newidx =~s /\D+//g;
1.440 raeburn 6385: return <<STATE;
6386: <input type="hidden" name="folderpath" value="$folderpath" />
6387: <input type="hidden" name="cmd" value="upload_embedded" />
6388: <input type="hidden" name="newidx" value="$newidx" />
6389: <input type="hidden" name="phase" value="$phase" />
6390: <input type="hidden" name="primaryurl" value="$primaryurl" />
6391: STATE
6392: }
6393:
6394: sub embedded_destination {
6395: my $folder=$env{'form.folder'};
6396: my $destination = 'docs/';
6397: if ($folder =~ /^supplemental/) {
6398: $destination = 'supplemental/';
6399: }
6400: if (($folder eq 'default') || ($folder eq 'supplemental')) {
6401: $destination .= 'default/';
6402: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
6403: $destination .= $2.'/';
6404: }
1.484.2.78 raeburn 6405: my $newidx = $env{'form.newidx'};
6406: $newidx =~s /\D+//g;
6407: if ($newidx) {
6408: $destination .= $newidx;
6409: }
1.440 raeburn 6410: my $dir_root = '/userfiles';
6411: return ($destination,$dir_root);
6412: }
6413:
6414: sub return_to_editor {
6415: my $actionurl = '/adm/coursedocs';
6416: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
6417: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
6418: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
6419: '</a></p>';
6420: }
6421:
1.476 raeburn 6422: sub decompression_info {
6423: my ($destination,$dir_root) = &embedded_destination();
6424: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
6425: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
6426: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
6427: my $container='sequence';
1.480 raeburn 6428: my ($pathitem,$hiddenelem);
1.484.2.54 raeburn 6429: my @hiddens = ('newidx','comment','position','folderpath','archiveurl');
1.484.2.19 raeburn 6430: if ($env{'form.folderpath'} =~ /\:1$/) {
1.476 raeburn 6431: $container='page';
6432: }
1.480 raeburn 6433: unshift(@hiddens,$pathitem);
6434: foreach my $item (@hiddens) {
1.484.2.78 raeburn 6435: if ($item eq 'newidx') {
6436: next if ($env{'form.'.$item} =~ /\D/);
6437: }
1.480 raeburn 6438: if ($env{'form.'.$item}) {
6439: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
1.484.2.54 raeburn 6440: &HTML::Entities::encode($env{'form.'.$item},'<>&"').'" />'."\n";
1.480 raeburn 6441: }
1.477 raeburn 6442: }
1.476 raeburn 6443: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
6444: $hiddenelem);
6445: }
6446:
6447: sub decompression_phase_one {
6448: my ($dir,$file,$warning,$error,$output);
6449: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
6450: &decompression_info();
1.484.2.7 raeburn 6451: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 6452: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
6453: } else {
6454: my $file = $1;
1.481 raeburn 6455: $output =
6456: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
6457: $destination,$dir_root,
6458: $hiddenelem);
6459: if ($env{'form.autoextract_camtasia'}) {
6460: $output .= &remove_archive($docudom,$docuname,$container);
6461: }
1.476 raeburn 6462: }
6463: if ($error) {
6464: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
6465: $error.'</p>'."\n";
6466: }
6467: if ($warning) {
6468: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
6469: }
6470: return $output;
6471: }
6472:
6473: sub decompression_phase_two {
6474: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
6475: &decompression_info();
1.481 raeburn 6476: my $output;
1.480 raeburn 6477: if ($env{'form.archivedelete'}) {
1.481 raeburn 6478: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 6479: }
6480: $output .=
1.481 raeburn 6481: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 6482: $destination,$dir_root,$hiddenelem);
6483: return $output;
6484: }
6485:
1.480 raeburn 6486: sub remove_archive {
6487: my ($docudom,$docuname,$container) = @_;
6488: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 6489: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 6490: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
6491: if ($fatal) {
6492: if ($container eq 'page') {
6493: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
6494: } else {
6495: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
6496: }
1.484.2.54 raeburn 6497: $delwarning .= ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 6498: } else {
6499: my $currcmd = $env{'form.cmd'};
6500: my $position = $env{'form.position'};
1.484.2.54 raeburn 6501: my $archiveidx = $position;
6502: if ($position > 0) {
6503: if (($env{'form.autoextract_camtasia'}) && (scalar(@LONCAPA::map::order) == 2)) {
6504: $archiveidx = $position-1;
6505: }
6506: $env{'form.cmd'} = 'remove_'.$archiveidx;
6507: my ($title,$url,@rrest) =
6508: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$archiveidx]]);
6509: if ($url eq $env{'form.archiveurl'}) {
6510: if (&handle_edit_cmd($docuname,$docudom)) {
6511: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
6512: if ($fatal) {
6513: if ($container eq 'page') {
6514: $delwarning = &mt('An error occurred updating the contents of the current page.');
6515: } else {
6516: $delwarning = &mt('An error occurred updating the contents of the current folder.');
6517: }
1.480 raeburn 6518: } else {
1.484.2.54 raeburn 6519: $delresult = &mt('Archive file removed.');
1.480 raeburn 6520: }
6521: }
1.484.2.54 raeburn 6522: } else {
6523: $delwarning .= &mt('Archive file had unexpected item number in folder.').
6524: ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 6525: }
6526: }
6527: $env{'form.cmd'} = $currcmd;
6528: }
6529: if ($delwarning) {
6530: $output = '<p class="LC_warning">'.
6531: $delwarning.
6532: '</p>';
6533: }
6534: if ($delresult) {
6535: $output .= '<p class="LC_info">'.
6536: $delresult.
6537: '</p>';
6538: }
1.481 raeburn 6539: return $output;
1.480 raeburn 6540: }
6541:
1.484 raeburn 6542: sub generate_admin_menu {
1.484.2.67 raeburn 6543: my ($crstype,$canedit) = @_;
1.484 raeburn 6544: my $lc_crstype = lc($crstype);
6545: my ($home,$other,%outhash)=&authorhosts();
1.484.2.43 raeburn 6546: my %lt= ( # do not translate here
1.484 raeburn 6547: 'vc' => 'Verify Content',
6548: 'cv' => 'Check/Set Resource Versions',
6549: 'ls' => 'List Resource Identifiers',
1.484.2.85.2. (raeburn 6550:): 'ct' => 'Display/Set Shortened URLs for Deep-linking',
1.484 raeburn 6551: 'imse' => 'Export contents to IMS Archive',
1.484.2.43 raeburn 6552: 'dcd' => "Copy $crstype Content to Authoring Space",
6553: );
1.484 raeburn 6554: my ($candump,$dumpurl);
6555: if ($home + $other > 0) {
6556: $candump = 'F';
6557: if ($home) {
6558: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
6559: } else {
6560: my @hosts;
6561: foreach my $aurole (keys(%outhash)) {
6562: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
6563: push(@hosts,$outhash{$aurole});
1.484.2.30 raeburn 6564: }
1.484 raeburn 6565: }
6566: if (@hosts == 1) {
6567: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
6568: '&role='.
6569: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
6570: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
6571: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
6572: } else {
6573: $dumpurl = "javascript:choose_switchserver_window()";
6574: }
6575: }
6576: }
6577: my @menu=
6578: ({ categorytitle=>'Administration',
6579: items =>[
6580: { linktext => $lt{'vc'},
6581: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
6582: permission => 'F',
1.484.2.44 raeburn 6583: help => 'Docs_Verify_Content',
1.484 raeburn 6584: icon => 'verify.png',
6585: linktitle => 'Verify contents can be retrieved/rendered',
6586: },
6587: { linktext => $lt{'cv'},
6588: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
6589: permission => 'F',
1.484.2.44 raeburn 6590: help => 'Docs_Check_Resource_Versions',
1.484 raeburn 6591: icon => 'resversion.png',
6592: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
6593: },
6594: { linktext => $lt{'ls'},
6595: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
6596: permission => 'F',
6597: #help => '',
6598: icon => 'symbs.png',
6599: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
6600: },
1.484.2.85.2. (raeburn 6601:): { linktext => $lt{'ct'},
6602:): url => "javascript:injectData(document.courseverify,'dummy','shorturls','$lt{'ct'}')",
6603:): permission => 'F',
6604:): help => 'Docs_Short_URLs',
6605:): icon => 'shorturls.png',
6606:): linktitle => "Set shortened URLs for a resource or folder in your $lc_crstype for use in deep-linking"
6607:): },
1.484 raeburn 6608: ]
1.484.2.67 raeburn 6609: });
6610: if ($canedit) {
6611: push(@menu,
1.484 raeburn 6612: { categorytitle=>'Export',
6613: items =>[
6614: { linktext => $lt{'imse'},
6615: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
6616: permission => 'F',
6617: help => 'Docs_Export_Course_Docs',
6618: icon => 'imsexport.png',
6619: linktitle => $lt{'imse'},
6620: },
6621: { linktext => $lt{'dcd'},
6622: url => $dumpurl,
6623: permission => $candump,
1.484.2.44 raeburn 6624: help => 'Docs_Dump_Course_Docs',
1.484 raeburn 6625: icon => 'dump.png',
6626: linktitle => $lt{'dcd'},
6627: },
6628: ]
6629: });
1.484.2.67 raeburn 6630: }
1.484 raeburn 6631: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
6632: '<input type="hidden" id="dummy" />'."\n".
6633: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
6634: '</form>';
1.329 droeschl 6635: }
6636:
6637: sub generate_edit_table {
1.484.2.30 raeburn 6638: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile,
1.484.2.67 raeburn 6639: $need_save,$copyfolder,$canedit) = @_;
1.406 raeburn 6640: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 6641: my %orderhash = %{$orderhash_ref};
1.484.2.67 raeburn 6642: my ($form, $activetab, $active, $disabled);
1.484.2.43 raeburn 6643: if (($env{'form.active'} ne '') && ($env{'form.active'} ne '00')) {
1.371 tempelho 6644: $activetab = $env{'form.active'};
6645: }
1.484.2.67 raeburn 6646: unless ($canedit) {
6647: $disabled = ' disabled="disabled"';
6648: }
1.472 raeburn 6649: my $backicon = $iconpath.'clickhere.gif';
1.484.2.21 raeburn 6650: my $backtext = &mt('Exit Editor');
1.458 raeburn 6651: $form = '<div class="LC_Box" style="margin:0;">'.
1.484.2.19 raeburn 6652: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
6653: '<li class="goback">'.
1.484.2.32 raeburn 6654: '<a href="javascript:toContents('."'$jumpto'".');">'.
1.484.2.19 raeburn 6655: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
6656: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
6657: '<li>'.
6658: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
6659: &mt('Undo Delete').'</a></li>'."\n";
1.484.2.7 raeburn 6660: if ($env{'form.docslog'}) {
6661: $form .= '<li class="active">';
6662: } else {
6663: $form .= '<li>';
6664: }
6665: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
6666: &mt('History').'</a></li>'."\n";
6667: if ($env{'form.docslog'}) {
6668: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
6669: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 6670: }
1.458 raeburn 6671: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 6672: if($name ne '00'){
1.371 tempelho 6673: if($activetab eq '' || $activetab ne $name){
6674: $active = '';
6675: }elsif($activetab eq $name){
6676: $active = 'class="active"';
6677: }
1.458 raeburn 6678: $form .= '<li style="float:right" '.$active
1.484 raeburn 6679: .' 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 6680: } else {
1.484.2.43 raeburn 6681: $form .= '<li style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 6682:
6683: }
1.329 droeschl 6684: }
1.484 raeburn 6685: $form .= '</ul>'."\n";
6686: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 6687:
6688: if ($to_show ne '') {
1.484.2.30 raeburn 6689: my $saveform;
6690: if ($need_save) {
6691: my $button = &mt('Make changes');
6692: my $path;
6693: if ($env{'form.folderpath'}) {
6694: $path =
6695: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
6696: }
6697: $saveform = <<"END";
6698: <div id="multisave" style="display:none; clear:both;" >
6699: <form name="saveactions" method="post" action="/adm/coursedocs" onsubmit="return checkSubmits();">
6700: <input type="hidden" name="folderpath" value="$path" />
6701: <input type="hidden" name="symb" value="$env{'form.symb'}" />
6702: <input type="hidden" name="allhiddenresource" value="" />
6703: <input type="hidden" name="allencrypturl" value="" />
6704: <input type="hidden" name="allrandompick" value="" />
6705: <input type="hidden" name="allrandomorder" value="" />
6706: <input type="hidden" name="changeparms" value="" />
6707: <input type="hidden" name="multiremove" value="" />
6708: <input type="hidden" name="multicut" value="" />
6709: <input type="hidden" name="multicopy" value="" />
6710: <input type="hidden" name="multichange" value="" />
6711: <input type="hidden" name="copyfolder" value="$copyfolder" />
1.484.2.67 raeburn 6712: <input type="submit" name="savemultiples" value="$button" $disabled />
1.484.2.30 raeburn 6713: </form>
6714: </div>
6715: END
6716: }
6717: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'.$saveform."\n";
1.458 raeburn 6718: }
1.363 ehlerst 6719: foreach my $field (keys(%orderhash)){
1.390 tempelho 6720: if($field ne '00'){
1.422 onken 6721: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 6722: $active = 'style="display: none;float:left"';
1.422 onken 6723: }elsif($activetab eq $field){
1.458 raeburn 6724: $active = 'style="display:block;float:left"';
1.422 onken 6725: }
6726: $form .= '<div id="'.$field.$tid.'"'
6727: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 6728: .'</div>'."\n";
1.363 ehlerst 6729: }
6730: }
1.484 raeburn 6731: unless ($env{'form.docslog'}) {
6732: $form .= '</div></div>'."\n";
6733: }
1.329 droeschl 6734: return $form;
6735: }
6736:
6737: sub editing_js {
1.484.2.85.2. (raeburn 6738:): my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
1.484.2.80 raeburn 6739: $canedit,$hostname,$navmapref) = @_;
1.484.2.61 raeburn 6740: my %js_lt = &Apache::lonlocal::texthash(
1.329 droeschl 6741: p_mnf => 'Name of New Folder',
6742: t_mnf => 'New Folder',
6743: p_mnp => 'Name of New Page',
6744: t_mnp => 'New Page',
1.451 www 6745: p_mxu => 'Title for the External Score',
1.349 biermanm 6746: p_msp => 'Name of Simple Course Page',
1.329 droeschl 6747: p_msb => 'Title for the Problem',
6748: p_mdb => 'Title for the Drop Box',
1.336 schafran 6749: p_mbb => 'Title for the Discussion Board',
1.484.2.27 raeburn 6750: p_mwp => 'Title for Web Page',
1.348 weissno 6751: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 6752: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 6753: p_mab_alrt1 => 'Not a valid user:domain',
6754: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
6755: p_chn => 'New Title',
6756: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
1.484.2.63 raeburn 6757: p_rmr2a => 'Remove',
6758: p_rmr2b => '?',
6759: p_rmr3a => 'Remove those',
6760: p_rmr3b => 'items?',
6761: p_rmr4 => 'WARNING: Removing a resource uploaded to a course cannot be undone via "Undo Delete".',
6762: p_rmr5 => 'Push "Cancel" and then use "Cut" instead if you might need to undo this change.',
1.329 droeschl 6763: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
6764: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
1.484.2.63 raeburn 6765: p_ctr2a => 'Cut',
6766: p_ctr2b => '?',
6767: p_ctr3a => 'Cut those',
6768: p_ctr3b => 'items?',
1.478 raeburn 6769: rpck => 'Enter number to pick (e.g., 3)',
1.484.2.12 raeburn 6770: imsfile => 'You must choose an IMS package for import',
6771: imscms => 'You must select which Course Management System was the source of the IMS package',
6772: invurl => 'Invalid URL',
6773: titbl => 'Title is blank',
1.484.2.30 raeburn 6774: more => '(More ...)',
6775: less => '(Less ...)',
6776: noor => 'No actions selected or changes to settings specified.',
6777: noch => 'No changes to settings specified.',
6778: noac => 'No actions selected.',
1.484.2.67 raeburn 6779: edri => 'Editing rights unavailable for your current role.',
1.329 droeschl 6780: );
6781:
1.484.2.61 raeburn 6782: &js_escape(\%js_lt);
1.433 raeburn 6783: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 6784: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
6785: my $main_container_page;
1.484.2.19 raeburn 6786: if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) {
6787: $main_container_page = 1;
1.434 raeburn 6788: }
1.484.2.67 raeburn 6789: my $backtourl;
6790: my $toplevelmain = &escape(&default_folderpath($coursenum,$coursedom,$navmapref));
1.446 www 6791: my $toplevelsupp = &supplemental_base();
1.433 raeburn 6792:
1.484.2.21 raeburn 6793: if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
6794: my $caller = $1;
6795: if ($caller =~ /^supplemental/) {
6796: $backtourl = '/adm/supplemental?folderpath='.&escape($caller);
6797: } else {
6798: my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
6799: $res = &Apache::lonnet::clutter($res);
6800: if (&Apache::lonnet::is_on_map($res)) {
1.484.2.66 raeburn 6801: my ($url,$anchor);
6802: if ($res =~ /^([^#]+)#([^#]+)$/) {
6803: $url = $1;
6804: $anchor = $2;
6805: if (($caller =~ m{^([^#]+)\Q#$anchor\E$})) {
6806: $caller = $1.&escape('#').$anchor;
6807: }
1.484.2.67 raeburn 6808: } else {
6809: $url = $res;
1.484.2.66 raeburn 6810: }
1.484.2.83 raeburn 6811: $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"');
6812: if ($backtourl =~ m{^\Q/uploaded/$coursedom/$coursenum/\Edefault_\d+\.sequence$}) {
6813: $backtourl .= '?navmap=1';
6814: } else {
6815: $backtourl .= '?symb='.
6816: &HTML::Entities::encode($caller,'<>&"');
6817: }
1.484.2.80 raeburn 6818: if ($backtourl =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
6819: if (($ENV{'SERVER_PORT'} == 443) &&
6820: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
6821: unless (&Apache::lonnet::uses_sts()) {
6822: if ($hostname ne '') {
6823: $backtourl = 'http://'.$hostname.$backtourl;
6824: }
6825: $backtourl .= (($backtourl =~ /\?/) ? '&':'?').'usehttp=1';
6826: }
6827: }
6828: } elsif ($backtourl =~ m{^/adm/wrapper/ext/(?!https:)}) {
6829: if (($ENV{'SERVER_PORT'} == 443) && ($hostname ne '')) {
6830: unless (&Apache::lonnet::uses_sts()) {
6831: if ($hostname ne '') {
6832: $backtourl = 'http://'.$hostname.$backtourl;
6833: }
6834: $backtourl .= (($backtourl =~ /\?/) ? '&':'?').'usehttp=1';
6835: }
6836: }
6837: }
1.484.2.66 raeburn 6838: if ($anchor ne '') {
6839: $backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"');
6840: }
1.484.2.57 raeburn 6841: $backtourl = &Apache::loncommon::escape_single($backtourl);
1.484.2.31 raeburn 6842: } else {
6843: $backtourl = '/adm/navmaps';
1.484.2.21 raeburn 6844: }
6845: }
6846: } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
6847: $backtourl = '/adm/menu';
6848: } elsif ($supplementalflag) {
1.472 raeburn 6849: $backtourl = '/adm/supplemental';
1.484.2.21 raeburn 6850: } else {
6851: $backtourl = '/adm/navmaps';
1.472 raeburn 6852: }
6853:
1.484.2.19 raeburn 6854: my $fieldsets = "'ext','doc'";
1.484.2.85.2. (raeburn 6855:): if ($posslti) {
6856:): $fieldsets .= ",'tool'";
6857:): }
1.484.2.19 raeburn 6858: unless ($main_container_page) {
6859: $fieldsets .=",'ims'";
6860: }
1.484.2.12 raeburn 6861: if ($supplementalflag) {
6862: $fieldsets = "'suppext','suppdoc'";
1.484.2.85.2. (raeburn 6863:): if ($posslti) {
6864:): $fieldsets .= ",'supptool'";
6865:): }
1.484.2.12 raeburn 6866: }
6867:
1.484.2.67 raeburn 6868: my $jsmakefunctions;
6869: if ($canedit) {
6870: $jsmakefunctions = <<ENDNEWSCRIPT;
1.329 droeschl 6871: function makenewfolder(targetform,folderseq) {
1.484.2.65 raeburn 6872: var foldername=prompt('$js_lt{"p_mnf"}','$js_lt{"t_mnf"}');
1.329 droeschl 6873: if (foldername) {
6874: targetform.importdetail.value=escape(foldername)+"="+folderseq;
6875: targetform.submit();
6876: }
6877: }
6878:
6879: function makenewpage(targetform,folderseq) {
1.484.2.61 raeburn 6880: var pagename=prompt('$js_lt{"p_mnp"}','$js_lt{"t_mnp"}');
1.329 droeschl 6881: if (pagename) {
6882: targetform.importdetail.value=escape(pagename)+"="+folderseq;
6883: targetform.submit();
6884: }
6885: }
6886:
6887: function makeexamupload() {
1.484.2.61 raeburn 6888: var title=prompt('$js_lt{"p_mxu"}');
1.344 bisitz 6889: if (title) {
1.329 droeschl 6890: this.document.forms.newexamupload.importdetail.value=
6891: escape(title)+'=/res/lib/templates/examupload.problem';
6892: this.document.forms.newexamupload.submit();
6893: }
6894: }
6895:
6896: function makesmppage() {
1.484.2.61 raeburn 6897: var title=prompt('$js_lt{"p_msp"}');
1.344 bisitz 6898: if (title) {
1.329 droeschl 6899: this.document.forms.newsmppg.importdetail.value=
1.484.2.26 raeburn 6900: escape(title)+'=/adm/$udom/$uname/new/smppg';
1.329 droeschl 6901: this.document.forms.newsmppg.submit();
6902: }
6903: }
6904:
1.484.2.27 raeburn 6905: function makewebpage(type) {
1.484.2.61 raeburn 6906: var title=prompt('$js_lt{"p_mwp"}');
1.484.2.27 raeburn 6907: var formname;
6908: if (type == 'supp') {
6909: formname = this.document.forms.supwebpage;
6910: } else {
6911: formname = this.document.forms.newwebpage;
6912: }
6913: if (title) {
6914: var webpage = formname.importdetail.value;
6915: formname.importdetail.value = escape(title)+'='+webpage;
6916: formname.submit();
6917: }
6918: }
6919:
1.329 droeschl 6920: function makesmpproblem() {
1.484.2.61 raeburn 6921: var title=prompt('$js_lt{"p_msb"}');
1.344 bisitz 6922: if (title) {
1.329 droeschl 6923: this.document.forms.newsmpproblem.importdetail.value=
6924: escape(title)+'=/res/lib/templates/simpleproblem.problem';
6925: this.document.forms.newsmpproblem.submit();
6926: }
6927: }
6928:
6929: function makedropbox() {
1.484.2.61 raeburn 6930: var title=prompt('$js_lt{"p_mdb"}');
1.344 bisitz 6931: if (title) {
1.329 droeschl 6932: this.document.forms.newdropbox.importdetail.value=
6933: escape(title)+'=/res/lib/templates/DropBox.problem';
6934: this.document.forms.newdropbox.submit();
6935: }
6936: }
6937:
6938: function makebulboard() {
1.484.2.61 raeburn 6939: var title=prompt('$js_lt{"p_mbb"}');
1.329 droeschl 6940: if (title) {
6941: this.document.forms.newbul.importdetail.value=
1.484.2.26 raeburn 6942: escape(title)+'=/adm/$udom/$uname/new/bulletinboard';
1.329 droeschl 6943: this.document.forms.newbul.submit();
6944: }
6945: }
6946:
6947: function makeabout() {
1.484.2.61 raeburn 6948: var user=prompt("$js_lt{'p_mab'}");
1.329 droeschl 6949: if (user) {
6950: var comp=new Array();
6951: comp=user.split(':');
6952: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
6953: if ((comp[0]) && (comp[1])) {
6954: this.document.forms.newaboutsomeone.importdetail.value=
1.484.2.61 raeburn 6955: '$js_lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.484.2.67 raeburn 6956: this.document.forms.newaboutsomeone.submit();
6957: } else {
6958: alert("$js_lt{'p_mab_alrt1'}");
6959: }
6960: } else {
6961: alert("$js_lt{'p_mab_alrt2'}");
6962: }
6963: }
1.335 ehlerst 6964: }
1.484.2.67 raeburn 6965:
6966: function makenew(targetform) {
6967: targetform.submit();
1.335 ehlerst 6968: }
1.484.2.67 raeburn 6969:
6970: function changename(folderpath,index,oldtitle) {
6971: var title=prompt('$js_lt{"p_chn"}',oldtitle);
6972: if (title) {
6973: this.document.forms.renameform.markcopy.value='';
6974: this.document.forms.renameform.title.value=title;
6975: this.document.forms.renameform.cmd.value='rename_'+index;
6976: this.document.forms.renameform.folderpath.value=folderpath;
6977: this.document.forms.renameform.submit();
6978: }
1.329 droeschl 6979: }
6980:
1.484.2.67 raeburn 6981: ENDNEWSCRIPT
6982: } else {
6983: $jsmakefunctions = <<ENDNEWSCRIPT;
6984:
6985: function makenewfolder() {
6986: alert("$js_lt{'edri'}");
6987: }
6988:
6989: function makenewpage() {
6990: alert("$js_lt{'edri'}");
6991: }
6992:
6993: function makeexamupload() {
6994: alert("$js_lt{'edri'}");
6995: }
6996:
6997: function makesmppage() {
6998: alert("$js_lt{'edri'}");
6999: }
7000:
7001: function makewebpage(type) {
7002: alert("$js_lt{'edri'}");
7003: }
7004:
7005: function makesmpproblem() {
7006: alert("$js_lt{'edri'}");
7007: }
7008:
7009: function makedropbox() {
7010: alert("$js_lt{'edri'}");
7011: }
7012:
7013: function makebulboard() {
7014: alert("$js_lt{'edri'}");
7015: }
7016:
7017: function makeabout() {
7018: alert("$js_lt{'edri'}");
7019: }
7020:
7021: function changename() {
7022: alert("$js_lt{'edri'}");
7023: }
7024:
7025: function makenew() {
7026: alert("$js_lt{'edri'}");
7027: }
7028:
7029: function groupimport() {
7030: alert("$js_lt{'edri'}");
7031: }
7032:
7033: function groupsearch() {
7034: alert("$js_lt{'edri'}");
7035: }
7036:
7037: function groupopen(url,recover) {
7038: var options="scrollbars=1,resizable=1,menubar=0";
7039: idxflag=1;
7040: idx=open("/adm/groupsort?inhibitmenu=yes&mode=simple&recover="+recover+"&readfile="+url,"idxout",options);
7041: idx.focus();
7042: }
7043:
7044: ENDNEWSCRIPT
7045:
7046: }
7047: return <<ENDSCRIPT;
7048:
7049: $jsmakefunctions
7050:
1.484.2.13 raeburn 7051: function toggleUpload(caller) {
7052: var blocks = Array($fieldsets);
7053: for (var i=0; i<blocks.length; i++) {
7054: var disp = 'none';
7055: if (caller == blocks[i]) {
7056: var curr = document.getElementById('upload'+caller+'form').style.display;
7057: if (curr == 'none') {
7058: disp='block';
7059: }
7060: }
7061: document.getElementById('upload'+blocks[i]+'form').style.display=disp;
1.484.2.85.2. (raeburn 7062:): if ((caller == 'tool') || (caller == 'supptool')) {
7063:): if (disp == 'block') {
7064:): if (document.getElementById('LC_exttoolid')) {
7065:): var toolselector = document.getElementById('LC_exttoolid');
7066:): var suppflag = 0;
7067:): if (caller == 'supptool') {
7068:): suppflag = 1;
7069:): }
7070:): currForm = document.getElementById('new'+caller);
7071:): updateExttool(toolselector,currForm,suppflag);
7072:): }
7073:): }
7074:): }
1.484.2.13 raeburn 7075: }
7076: resize_scrollbox('contentscroll','1','1');
7077: return;
7078: }
7079:
1.484.2.19 raeburn 7080: function toggleMap(caller) {
1.484.2.13 raeburn 7081: var disp = 'none';
1.484.2.19 raeburn 7082: if (document.getElementById('importmapform')) {
7083: if (caller == 'map') {
7084: var curr = document.getElementById('importmapform').style.display;
7085: if (curr == 'none') {
7086: disp='block';
7087: }
1.484.2.12 raeburn 7088: }
1.484.2.19 raeburn 7089: document.getElementById('importmapform').style.display=disp;
7090: resize_scrollbox('contentscroll','1','1');
1.484.2.12 raeburn 7091: }
1.484.2.19 raeburn 7092: return;
1.329 droeschl 7093: }
7094:
1.484.2.12 raeburn 7095: function makeims(imsform) {
7096: if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
1.484.2.61 raeburn 7097: alert("$js_lt{'imsfile'}");
1.484.2.12 raeburn 7098: return;
7099: }
7100: if (imsform.source.selectedIndex == 0) {
1.484.2.61 raeburn 7101: alert("$js_lt{'imscms'}");
1.484.2.12 raeburn 7102: return;
7103: }
7104: newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
7105: imsform.submit();
7106: }
7107:
1.478 raeburn 7108: function updatePick(targetform,index,caller) {
1.484.2.29 raeburn 7109: var pickitem;
7110: var picknumitem;
7111: var picknumtext;
7112: if (index == 'all') {
7113: pickitem = document.getElementById('randompickall');
7114: picknumitem = document.getElementById('rpicknumall');
7115: picknumtext = document.getElementById('rpicktextall');
7116: } else {
7117: pickitem = document.getElementById('randompick_'+index);
7118: picknumitem = document.getElementById('rpicknum_'+index);
7119: picknumtext = document.getElementById('randompicknum_'+index);
7120: }
1.478 raeburn 7121: if (pickitem.checked) {
1.484.2.61 raeburn 7122: var picknum=prompt('$js_lt{"rpck"}',picknumitem.value);
1.478 raeburn 7123: if (picknum == '' || picknum == null) {
7124: if (caller == 'check') {
7125: pickitem.checked=false;
1.484.2.29 raeburn 7126: if (index == 'all') {
7127: picknumtext.innerHTML = '';
7128: if (caller == 'link') {
7129: propagateState(targetform,'rpicknum');
7130: }
7131: } else {
1.484.2.30 raeburn 7132: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 7133: }
1.478 raeburn 7134: }
7135: } else {
7136: picknum.toString();
7137: var regexdigit=/^\\d+\$/;
7138: if (regexdigit.test(picknum)) {
7139: picknumitem.value = picknum;
1.484.2.29 raeburn 7140: if (index == 'all') {
1.484.2.30 raeburn 7141: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.cumulativesettings,\\'all\\',\\'link\\');">'+picknum+'</a>';
1.484.2.29 raeburn 7142: if (caller == 'link') {
7143: propagateState(targetform,'rpicknum');
7144: }
7145: } else {
7146: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.edit_randompick_'+index+',\\''+index+'\\',\\'link\\');">'+picknum+'</a>';
1.484.2.30 raeburn 7147: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 7148: }
1.478 raeburn 7149: } else {
7150: if (caller == 'check') {
1.484.2.29 raeburn 7151: if (index == 'all') {
7152: picknumtext.innerHTML = '';
7153: if (caller == 'link') {
7154: propagateState(targetform,'rpicknum');
7155: }
7156: } else {
7157: pickitem.checked=false;
1.484.2.30 raeburn 7158: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 7159: }
1.478 raeburn 7160: }
7161: return;
7162: }
7163: }
7164: } else {
1.484.2.29 raeburn 7165: picknumitem.value = '';
7166: picknumtext.innerHTML = '';
7167: if (index == 'all') {
7168: if (caller == 'link') {
7169: propagateState(targetform,'rpicknum');
7170: }
7171: } else {
1.484.2.30 raeburn 7172: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 7173: }
7174: }
7175: }
7176:
7177: function propagateState(form,param) {
7178: if (document.getElementById(param+'all')) {
7179: var setcheck = 0;
7180: var rpick = 0;
7181: if (param == 'rpicknum') {
7182: if (document.getElementById('randompickall')) {
7183: if (document.getElementById('randompickall').checked) {
7184: if (document.getElementById('rpicknumall')) {
7185: rpick = document.getElementById('rpicknumall').value;
7186: }
7187: }
7188: }
7189: } else {
7190: if (document.getElementById(param+'all').checked) {
7191: setcheck = 1;
7192: }
7193: }
1.484.2.30 raeburn 7194: var allidxlist;
7195: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
7196: if (document.getElementById('all'+param+'idx')) {
7197: allidxlist = document.getElementById('all'+param+'idx').value;
7198: }
7199: var actions = new Array ('remove','cut','copy');
7200: for (var i=0; i<actions.length; i++) {
7201: if (actions[i] != param) {
7202: if (document.getElementById(actions[i]+'all')) {
7203: document.getElementById(actions[i]+'all').checked = false;
7204: }
7205: }
7206: }
7207: }
1.484.2.29 raeburn 7208: if ((param == 'encrypturl') || (param == 'hiddenresource')) {
1.484.2.30 raeburn 7209: allidxlist = form.allidx.value;
7210: }
7211: if ((param == 'randompick') || (param == 'rpicknum') || (param == 'randomorder')) {
7212: allidxlist = form.allmapidx.value;
7213: }
7214: if ((allidxlist != '') && (allidxlist != null)) {
7215: var allidxs = allidxlist.split(',');
7216: if (allidxs.length > 1) {
7217: for (var i=0; i<allidxs.length; i++) {
7218: if (document.getElementById(param+'_'+allidxs[i])) {
7219: if (param == 'rpicknum') {
7220: if (document.getElementById('randompick_'+allidxs[i])) {
7221: if (document.getElementById('randompick_'+allidxs[i]).checked) {
7222: document.getElementById(param+'_'+allidxs[i]).value = rpick;
7223: if (rpick > 0) {
7224: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = ': <a href="javascript:updatePick(document.edit_randompick_'+allidxs[i]+',\\''+allidxs[i]+'\\',\\'link\\')">'+rpick+'</a>';
7225: } else {
7226: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
7227: }
7228: }
7229: }
7230: } else {
1.484.2.29 raeburn 7231: if (setcheck == 1) {
7232: document.getElementById(param+'_'+allidxs[i]).checked = true;
7233: } else {
7234: document.getElementById(param+'_'+allidxs[i]).checked = false;
1.484.2.30 raeburn 7235: if (param == 'randompick') {
7236: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
7237: }
1.484.2.29 raeburn 7238: }
7239: }
7240: }
7241: }
1.484.2.30 raeburn 7242: if (setcheck == 1) {
7243: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
7244: var actions = new Array('copy','cut','remove');
7245: for (var i=0; i<actions.length; i++) {
7246: var otheractions;
7247: var otheridxs;
7248: if (actions[i] === param) {
7249: continue;
7250: } else {
7251: if (document.getElementById('all'+actions[i]+'idx')) {
7252: otheractions = document.getElementById('all'+actions[i]+'idx').value;
7253: otheridxs = otheractions.split(',');
7254: if (otheridxs.length > 1) {
7255: for (var j=0; j<otheridxs.length; j++) {
7256: if (document.getElementById(actions[i]+'_'+otheridxs[j])) {
7257: document.getElementById(actions[i]+'_'+otheridxs[j]).checked = false;
7258: }
1.484.2.29 raeburn 7259: }
7260: }
7261: }
7262: }
1.484.2.30 raeburn 7263: }
1.484.2.29 raeburn 7264: }
7265: }
7266: }
7267: }
1.478 raeburn 7268: }
1.484.2.29 raeburn 7269: return;
7270: }
7271:
1.484.2.63 raeburn 7272: function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder,confirm_removal) {
1.484.2.67 raeburn 7273: var canedit = '$canedit';
7274: if (canedit == '') {
7275: alert("$js_lt{'edri'}");
7276: return;
7277: }
1.484.2.30 raeburn 7278: var dosettings;
7279: var doaction;
7280: var control = document.togglemultsettings;
7281: if (context == 'actions') {
7282: control = document.togglemultactions;
7283: doaction = 1;
7284: } else {
7285: dosettings = 1;
7286: }
7287: if (control) {
7288: if (control.showmultpick.length) {
7289: for (var i=0; i<control.showmultpick.length; i++) {
7290: if (control.showmultpick[i].checked) {
7291: if (control.showmultpick[i].value == 1) {
7292: if (context == 'settings') {
7293: dosettings = 0;
7294: } else {
7295: doaction = 0;
7296: }
7297: }
7298: }
7299: }
7300: }
7301: }
7302: if (context == 'settings') {
7303: if (dosettings == 1) {
7304: targetform.changeparms.value=param;
7305: targetform.submit();
7306: }
7307: }
7308: if (context == 'actions') {
7309: if (doaction == 1) {
7310: targetform.cmd.value=param+'_'+index;
7311: targetform.folderpath.value=folderpath;
7312: targetform.markcopy.value=idx+':'+param;
7313: targetform.copyfolder.value=folder+'.'+container;
7314: if (param == 'remove') {
1.484.2.63 raeburn 7315: var doremove = 0;
7316: if (skip_confirm) {
7317: if (confirm_removal) {
7318: if (confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'"$js_lt{"p_rmr2b"}')) {
7319: doremove = 1;
7320: }
7321: } else {
7322: doremove = 1;
7323: }
7324: } else {
7325: if (confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'" $js_lt{"p_rmr2b"}')) {
7326: doremove = 1;
7327: }
7328: }
7329: if (doremove) {
1.484.2.30 raeburn 7330: targetform.markcopy.value='';
7331: targetform.copyfolder.value='';
1.484.2.29 raeburn 7332: targetform.submit();
7333: }
7334: }
1.484.2.30 raeburn 7335: if (param == 'cut') {
1.484.2.61 raeburn 7336: if (skip_confirm || confirm('$js_lt{"p_ctr1a"}\\n$js_lt{"p_ctr1b"}\\n\\n$js_lt{"p_ctr2a"} "'+oldtitle+'" $js_lt{"p_ctr2b"}')) {
1.484.2.30 raeburn 7337: targetform.submit();
7338: return;
7339: }
7340: }
7341: if (param == 'copy') {
7342: targetform.submit();
7343: return;
7344: }
7345: targetform.markcopy.value='';
7346: targetform.copyfolder.value='';
7347: targetform.cmd.value='';
7348: targetform.folderpath.value='';
7349: return;
7350: } else {
7351: if (document.getElementById(param+'_'+idx)) {
7352: item = document.getElementById(param+'_'+idx);
7353: if (item.type == 'checkbox') {
7354: if (item.checked) {
7355: item.checked = false;
7356: } else {
7357: item.checked = true;
7358: singleCheck(item,idx,param);
7359: }
7360: }
7361: }
7362: }
7363: }
7364: return;
7365: }
7366:
7367: function singleCheck(caller,idx,action) {
7368: actions = new Array('cut','copy','remove');
7369: if (caller.checked) {
7370: for (var i=0; i<actions.length; i++) {
7371: if (actions[i] != action) {
7372: if (document.getElementById(actions[i]+'_'+idx)) {
7373: if (document.getElementById(actions[i]+'_'+idx).checked) {
7374: document.getElementById(actions[i]+'_'+idx).checked = false;
7375: }
7376: }
7377: }
1.484.2.29 raeburn 7378: }
7379: }
7380: return;
1.478 raeburn 7381: }
7382:
1.334 muellerd 7383: function unselectInactive(nav) {
1.335 ehlerst 7384: currentNav = document.getElementById(nav);
7385: currentLis = currentNav.getElementsByTagName('LI');
7386: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 7387: if (currentLis[i].className == 'goback') {
7388: currentLis[i].className = 'goback';
7389: } else {
7390: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 7391: currentLis[i].className = 'right';
1.472 raeburn 7392: } else {
1.374 tempelho 7393: currentLis[i].className = 'i';
1.472 raeburn 7394: }
7395: }
1.335 ehlerst 7396: }
1.332 tempelho 7397: }
7398:
1.334 muellerd 7399: function hideAll(current, nav, data) {
1.335 ehlerst 7400: unselectInactive(nav);
1.484.2.43 raeburn 7401: if (current) {
7402: if (current.className == 'right'){
1.374 tempelho 7403: current.className = 'right active'
1.484.2.43 raeburn 7404: } else {
1.374 tempelho 7405: current.className = 'active';
1.484.2.43 raeburn 7406: }
1.374 tempelho 7407: }
1.335 ehlerst 7408: currentData = document.getElementById(data);
7409: currentDivs = currentData.getElementsByTagName('DIV');
7410: for (i = 0; i < currentDivs.length; i++) {
7411: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 7412: currentDivs[i].style.display = 'none';
1.330 tempelho 7413: }
7414: }
1.335 ehlerst 7415: }
1.330 tempelho 7416:
1.374 tempelho 7417: function openTabs(pageId) {
7418: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 7419: if(tabnav.length > 2 ){
1.389 tempelho 7420: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 7421: currentLis = currentNav.getElementsByTagName('LI');
7422: for(i = 0; i< currentLis.length; i++){
7423: if(currentLis[i].className == 'active') {
1.375 tempelho 7424: funcString = currentLis[i].onclick.toString();
7425: tab = funcString.split('"');
1.420 onken 7426: if(tab.length < 2) {
7427: tab = funcString.split("'");
7428: }
1.375 tempelho 7429: currentData = document.getElementById(tab[1]);
7430: currentData.style.display = 'block';
1.374 tempelho 7431: }
7432: }
7433: }
7434: }
7435:
1.334 muellerd 7436: function showPage(current, pageId, nav, data) {
1.484.2.43 raeburn 7437: currstate = current.className;
1.334 muellerd 7438: hideAll(current, nav, data);
1.375 tempelho 7439: openTabs(pageId);
1.334 muellerd 7440: unselectInactive(nav);
1.484.2.43 raeburn 7441: if ((currstate == 'active') || (currstate == 'right active')) {
7442: if (currstate == 'active') {
7443: current.className = '';
7444: } else {
7445: current.className = 'right';
7446: }
7447: activeTab = '';
7448: toggleUpload();
7449: toggleMap();
7450: resize_scrollbox('contentscroll','1','0');
7451: return;
7452: } else {
7453: current.className = 'active';
7454: }
1.330 tempelho 7455: currentData = document.getElementById(pageId);
7456: currentData.style.display = 'block';
1.458 raeburn 7457: activeTab = pageId;
1.484.2.12 raeburn 7458: toggleUpload();
1.484.2.14 raeburn 7459: toggleMap();
1.433 raeburn 7460: if (nav == 'mainnav') {
7461: var storedpath = "$docs_folderpath";
1.434 raeburn 7462: var storedpage = "$main_container_page";
1.433 raeburn 7463: var reg = new RegExp("^supplemental");
7464: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 7465: if (storedpage == 1) {
7466: document.simpleedit.folderpath.value = '';
7467: document.uploaddocument.folderpath.value = '';
7468: } else {
7469: if (reg.test(storedpath)) {
7470: document.simpleedit.folderpath.value = '$toplevelmain';
7471: document.uploaddocument.folderpath.value = '$toplevelmain';
7472: document.newext.folderpath.value = '$toplevelmain';
7473: } else {
7474: document.simpleedit.folderpath.value = storedpath;
7475: document.uploaddocument.folderpath.value = storedpath;
7476: document.newext.folderpath.value = storedpath;
7477: }
1.433 raeburn 7478: }
7479: } else {
1.434 raeburn 7480: if (reg.test(storedpath)) {
7481: document.simpleedit.folderpath.value = storedpath;
7482: document.supuploaddocument.folderpath.value = storedpath;
7483: document.supnewext.folderpath.value = storedpath;
7484: } else {
1.433 raeburn 7485: document.simpleedit.folderpath.value = '$toplevelsupp';
7486: document.supuploaddocument.folderpath.value = '$toplevelsupp';
7487: document.supnewext.folderpath.value = '$toplevelsupp';
7488: }
7489: }
7490: }
1.484.2.3 raeburn 7491: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 7492: return false;
7493: }
1.329 droeschl 7494:
1.472 raeburn 7495: function toContents(jumpto) {
7496: var newurl = '$backtourl';
1.484.2.21 raeburn 7497: if ((newurl == '/adm/navmaps') && (jumpto != '')) {
1.472 raeburn 7498: newurl = newurl+'?postdata='+jumpto;
7499: }
7500: location.href=newurl;
7501: }
7502:
1.484.2.30 raeburn 7503: function togglePick(caller,value) {
7504: var disp = 'none';
7505: if (document.getElementById('multi'+caller)) {
7506: var curr = document.getElementById('multi'+caller).style.display;
7507: if (value == 1) {
7508: disp='block';
7509: }
7510: if (curr == disp) {
7511: return;
7512: }
7513: document.getElementById('multi'+caller).style.display=disp;
7514: if (value == 1) {
1.484.2.61 raeburn 7515: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.484.2.30 raeburn 7516: } else {
7517: document.getElementById('more'+caller).innerHTML = '';
7518: }
7519: if (caller == 'actions') {
7520: setClass(value);
7521: setBoxes(value);
7522: }
7523: }
7524: var showButton = multiSettings();
7525: if (showButton != 1) {
7526: showButton = multiActions();
7527: }
7528: if (document.getElementById('multisave')) {
7529: if (showButton == 1) {
7530: document.getElementById('multisave').style.display='block';
7531: } else {
7532: document.getElementById('multisave').style.display='none';
7533: }
7534: }
7535: resize_scrollbox('contentscroll','1','1');
7536: return;
7537: }
7538:
7539: function toggleCheckUncheck(caller,more) {
7540: if (more == 1) {
1.484.2.61 raeburn 7541: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',0);" style="text-decoration:none;">$js_lt{'less'}</a>';
1.484.2.30 raeburn 7542: document.getElementById('allfields'+caller).style.display='block';
7543: } else {
1.484.2.61 raeburn 7544: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.484.2.30 raeburn 7545: document.getElementById('allfields'+caller).style.display='none';
7546: }
7547: resize_scrollbox('contentscroll','1','1');
7548: }
7549:
7550: function multiSettings() {
7551: var inuse = 0;
7552: var settingsform = document.togglemultsettings;
7553: if (settingsform.showmultpick.length > 1) {
7554: for (var i=0; i<settingsform.showmultpick.length; i++) {
7555: if (settingsform.showmultpick[i].checked) {
7556: if (settingsform.showmultpick[i].value == 1) {
7557: inuse = 1;
7558: }
7559: }
7560: }
7561: }
7562: return inuse;
7563: }
7564:
7565: function multiActions() {
7566: var inuse = 0;
7567: var actionsform = document.togglemultactions;
7568: if (actionsform.showmultpick.length > 1) {
7569: for (var i=0; i<actionsform.showmultpick.length; i++) {
7570: if (actionsform.showmultpick[i].checked) {
7571: if (actionsform.showmultpick[i].value == 1) {
7572: inuse = 1;
7573: }
7574: }
7575: }
7576: }
7577: return inuse;
7578: }
7579:
7580: function checkSubmits() {
7581: var numchanges = 0;
7582: var form = document.saveactions;
7583: var doactions = multiActions();
7584: var cutwarnings = 0;
7585: var remwarnings = 0;
1.484.2.63 raeburn 7586: var removalinfo = 0;
1.484.2.30 raeburn 7587: if (doactions == 1) {
7588: var remidxlist = document.cumulativeactions.allremoveidx.value;
7589: if ((remidxlist != '') && (remidxlist != null)) {
7590: var remidxs = remidxlist.split(',');
7591: for (var i=0; i<remidxs.length; i++) {
7592: if (document.getElementById('remove_'+remidxs[i])) {
7593: if (document.getElementById('remove_'+remidxs[i]).checked) {
7594: form.multiremove.value += remidxs[i]+',';
7595: numchanges ++;
7596: if (document.getElementById('skip_remove_'+remidxs[i])) {
7597: if (document.getElementById('skip_remove_'+remidxs[i]).value == 0) {
7598: remwarnings ++;
7599: }
7600: }
1.484.2.63 raeburn 7601: if (document.getElementById('confirm_removal_'+remidxs[i])) {
7602: if (document.getElementById('confirm_removal_'+remidxs[i]).value == 1) {
7603: removalinfo ++;
7604: }
7605: }
1.484.2.30 raeburn 7606: }
7607: }
7608: }
7609: }
7610: var cutidxlist = document.cumulativeactions.allcutidx.value;
7611: if ((cutidxlist != '') && (cutidxlist != null)) {
7612: var cutidxs = cutidxlist.split(',');
7613: for (var i=0; i<cutidxs.length; i++) {
7614: if (document.getElementById('cut_'+cutidxs[i])) {
7615: if (document.getElementById('cut_'+cutidxs[i]).checked == true) {
7616: form.multicut.value += cutidxs[i]+',';
7617: numchanges ++;
7618: if (document.getElementById('skip_cut_'+cutidxs[i])) {
7619: if (document.getElementById('skip_cut_'+cutidxs[i]).value == 0) {
7620: cutwarnings ++;
7621: }
7622: }
7623: }
7624: }
7625: }
7626: }
7627: var copyidxlist = document.cumulativeactions.allcopyidx.value;
7628: if ((copyidxlist != '') && (copyidxlist != null)) {
7629: var copyidxs = copyidxlist.split(',');
7630: for (var i=0; i<copyidxs.length; i++) {
7631: if (document.getElementById('copy_'+copyidxs[i])) {
7632: if (document.getElementById('copy_'+copyidxs[i]).checked) {
7633: form.multicopy.value += copyidxs[i]+',';
7634: numchanges ++;
7635: }
7636: }
7637: }
7638: }
7639: if (numchanges > 0) {
7640: form.multichange.value = numchanges;
7641: }
7642: }
7643: var dosettings = multiSettings();
7644: var haschanges = 0;
7645: if (dosettings == 1) {
7646: form.allencrypturl.value = '';
7647: form.allhiddenresource.value = '';
7648: form.changeparms.value = 'all';
7649: var patt=new RegExp(",\$");
7650: var allidxlist = document.cumulativesettings.allidx.value;
7651: if ((allidxlist != '') && (allidxlist != null)) {
7652: var allidxs = allidxlist.split(',');
7653: if (allidxs.length > 1) {
7654: for (var i=0; i<allidxs.length; i++) {
7655: if (document.getElementById('hiddenresource_'+allidxs[i])) {
7656: if (document.getElementById('hiddenresource_'+allidxs[i]).checked) {
7657: form.allhiddenresource.value += allidxs[i]+',';
7658: }
7659: }
7660: if (document.getElementById('encrypturl_'+allidxs[i])) {
7661: if (document.getElementById('encrypturl_'+allidxs[i]).checked) {
7662: form.allencrypturl.value += allidxs[i]+',';
7663: }
1.484.2.29 raeburn 7664: }
7665: }
1.484.2.30 raeburn 7666: form.allhiddenresource.value = form.allhiddenresource.value.replace(patt,"");
7667: form.allencrypturl.value = form.allencrypturl.value.replace(patt,"");
7668: }
7669: }
7670: form.allrandompick.value = '';
7671: form.allrandomorder.value = '';
7672: var allmapidxlist = document.cumulativesettings.allmapidx.value;
7673: if ((allmapidxlist != '') && (allmapidxlist != null)) {
7674: var allmapidxs = allmapidxlist.split(',');
7675: for (var i=0; i<allmapidxs.length; i++) {
7676: var randompick = document.getElementById('randompick_'+allmapidxs[i]);
7677: var rpicknum = document.getElementById('rpicknum_'+allmapidxs[i]);
7678: var randorder = document.getElementById('randomorder_'+allmapidxs[i]);
7679: if ((randompick.checked) && (rpicknum.value != '')) {
7680: form.allrandompick.value += allmapidxs[i]+':'+rpicknum.value+',';
7681: }
7682: if (randorder.checked) {
7683: form.allrandomorder.value += allmapidxs[i]+',';
7684: }
7685: }
7686: form.allrandompick.value = form.allrandompick.value.replace(patt,"");
7687: form.allrandomorder.value = form.allrandomorder.value.replace(patt,"");
7688: }
7689: if (document.cumulativesettings.currhiddenresource.value != form.allhiddenresource.value) {
7690: haschanges = 1;
7691: }
7692: if (document.cumulativesettings.currencrypturl.value != form.allencrypturl.value) {
7693: haschanges = 1;
7694: }
7695: if (document.cumulativesettings.currrandomorder.value != form.allrandomorder.value) {
7696: haschanges = 1;
7697: }
7698: if (document.cumulativesettings.currrandompick.value != form.allrandompick.value) {
7699: haschanges = 1;
7700: }
7701: }
7702: if (doactions == 1) {
7703: if (numchanges > 0) {
1.484.2.63 raeburn 7704: if ((cutwarnings > 0) || (remwarnings > 0) || (removalinfo > 0)) {
1.484.2.30 raeburn 7705: if (remwarnings > 0) {
1.484.2.61 raeburn 7706: if (!confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr3a"} '+remwarnings+' $js_lt{"p_rmr3b"}')) {
1.484.2.30 raeburn 7707: return false;
7708: }
7709: }
1.484.2.63 raeburn 7710: if (removalinfo > 0) {
7711: if (!confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr3a"} '+removalinfo+' $js_lt{"p_rmr3b"}')) {
7712: return false;
7713: }
7714: }
1.484.2.30 raeburn 7715: if (cutwarnings > 0) {
1.484.2.61 raeburn 7716: if (!confirm('$js_lt{"p_ctr1a"}\\n$js_lt{"p_ctr1b"}\\n\\n$js_lt{"p_ctr3a"} '+cutwarnings+' $js_lt{"p_ctr3b"}')) {
1.484.2.30 raeburn 7717: return false;
1.484.2.29 raeburn 7718: }
7719: }
7720: }
1.484.2.30 raeburn 7721: form.submit();
7722: return true;
7723: }
7724: }
7725: if (dosettings == 1) {
7726: if (haschanges == 1) {
7727: form.submit();
7728: return true;
1.484.2.29 raeburn 7729: }
7730: }
1.484.2.30 raeburn 7731: if ((dosettings == 1) && (doactions == 1)) {
1.484.2.61 raeburn 7732: alert("$js_lt{'noor'}");
1.484.2.30 raeburn 7733: } else {
7734: if (dosettings == 1) {
1.484.2.61 raeburn 7735: alert("$js_lt{'noch'}");
1.484.2.30 raeburn 7736: } else {
1.484.2.61 raeburn 7737: alert("$js_lt{'noac'}");
1.484.2.30 raeburn 7738: }
7739: }
7740: return false;
7741: }
7742:
7743: function setClass(value) {
7744: var cutclass = 'LC_docs_cut';
7745: var copyclass = 'LC_docs_copy';
7746: var removeclass = 'LC_docs_remove';
7747: var cutreg = new RegExp("\\\\b"+cutclass+"\\\\b");
7748: var copyreg = new RegExp("\\\\b"+copyclass+"\\\\b");
7749: var removereg = new RegExp("\\\\"+removeclass+"\\\\b");
7750: var links = document.getElementsByTagName('a');
7751: for (var i=0; i<links.length; i++) {
7752: var classes = links[i].className;
7753: if (cutreg.test(classes)) {
7754: links[i].className = cutclass;
7755: if (value == 1) {
7756: links[i].className += " LC_menubuttons_link";
1.484.2.29 raeburn 7757: }
1.484.2.30 raeburn 7758: } else {
7759: if (copyreg.test(classes)) {
7760: links[i].className = copyclass;
7761: if (value == 1) {
7762: links[i].className += " LC_menubuttons_link";
7763: }
7764: } else {
7765: if (removereg.test(classes)) {
7766: links[i].className = removeclass;
7767: if (value == 1) {
7768: links[i].className += " LC_menubuttons_link";
7769: }
7770: }
1.484.2.29 raeburn 7771: }
7772: }
7773: }
1.484.2.30 raeburn 7774: return;
1.484.2.29 raeburn 7775: }
7776:
1.484.2.30 raeburn 7777: function setBoxes(value) {
7778: var remidxlist = document.cumulativeactions.allremoveidx.value;
7779: if ((remidxlist != '') && (remidxlist != null)) {
7780: var remidxs = remidxlist.split(',');
7781: for (var i=0; i<remidxs.length; i++) {
7782: if (document.getElementById('remove_'+remidxs[i])) {
7783: var item = document.getElementById('remove_'+remidxs[i]);
7784: if (value == 1) {
7785: item.className = 'LC_docs_remove';
7786: } else {
7787: item.className = 'LC_hidden';
7788: }
7789: }
1.484.2.29 raeburn 7790: }
7791: }
1.484.2.30 raeburn 7792: var cutidxlist = document.cumulativeactions.allcutidx.value;
7793: if ((cutidxlist != '') && (cutidxlist != null)) {
7794: var cutidxs = cutidxlist.split(',');
7795: for (var i=0; i<cutidxs.length; i++) {
7796: if (document.getElementById('cut_'+cutidxs[i])) {
7797: var item = document.getElementById('cut_'+cutidxs[i]);
7798: if (value == 1) {
7799: item.className = 'LC_docs_cut';
7800: } else {
7801: item.className = 'LC_hidden';
7802: }
7803: }
7804: }
7805: }
7806: var copyidxlist = document.cumulativeactions.allcopyidx.value;
7807: if ((copyidxlist != '') && (copyidxlist != null)) {
7808: var copyidxs = copyidxlist.split(',');
7809: for (var i=0; i<copyidxs.length; i++) {
7810: if (document.getElementById('copy_'+copyidxs[i])) {
7811: var item = document.getElementById('copy_'+copyidxs[i]);
7812: if (value == 1) {
7813: item.className = 'LC_docs_copy';
7814: } else {
7815: item.className = 'LC_hidden';
7816: }
7817: }
1.484.2.29 raeburn 7818: }
7819: }
7820: return;
7821: }
7822:
1.484.2.67 raeburn 7823: ENDSCRIPT
1.329 droeschl 7824: }
1.457 raeburn 7825:
1.483 raeburn 7826: sub history_tab_js {
7827: return <<"ENDHIST";
7828: function toggleHistoryDisp(choice) {
7829: document.docslogform.docslog.value = choice;
7830: document.docslogform.submit();
7831: return;
7832: }
7833:
7834: ENDHIST
7835: }
7836:
1.484 raeburn 7837: sub inject_data_js {
7838: return <<ENDINJECT;
7839:
7840: function injectData(current, hiddenField, name, value) {
7841: currentElement = document.getElementById(hiddenField);
7842: currentElement.name = name;
7843: currentElement.value = value;
7844: current.submit();
7845: }
7846:
7847: ENDINJECT
7848: }
7849:
7850: sub dump_switchserver_js {
7851: my @hosts = @_;
1.484.2.61 raeburn 7852: my %js_lt = &Apache::lonlocal::texthash(
1.484.2.46 raeburn 7853: dump => 'Copying content to Authoring Space requires switching server.',
1.484 raeburn 7854: swit => 'Switch server?',
1.484.2.61 raeburn 7855: );
7856: my %html_js_lt = &Apache::lonlocal::texthash(
7857: swit => 'Switch server?',
1.484.2.43 raeburn 7858: duco => 'Copying Content to Authoring Space',
1.484 raeburn 7859: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
7860: chos => 'Choose server',
7861: );
1.484.2.61 raeburn 7862: &js_escape(\%js_lt);
7863: &html_escape(\%html_js_lt);
7864: &js_escape(\%html_js_lt);
1.484 raeburn 7865: my $role = $env{'request.role'};
7866: my $js = <<"ENDSWJS";
7867: <script type="text/javascript">
7868: function write_switchserver() {
7869: var server;
7870: if (document.setserver.posshosts.length > 0) {
7871: for (var i=0; i<document.setserver.posshosts.length; i++) {
7872: if (document.setserver.posshosts[i].checked) {
7873: server = document.setserver.posshosts[i].value;
7874: }
7875: }
7876: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
7877: }
7878: window.close();
7879: }
7880: </script>
7881:
7882: ENDSWJS
7883:
7884: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
7885: {'only_body' => 1,
7886: 'js_ready' => 1,});
7887: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
7888:
7889: my $hostpicker;
7890: my $count = 0;
7891: foreach my $host (sort(@hosts)) {
7892: my $checked;
7893: if ($count == 0) {
7894: $checked = ' checked="checked"';
7895: }
7896: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
7897: $host.'"'.$checked.' />'.$host.'</label> ';
7898: $count++;
7899: }
7900:
7901: return <<"ENDSWITCHJS";
7902:
7903: function dump_needs_switchserver(url) {
7904: if (url!='' && url!= null) {
1.484.2.61 raeburn 7905: if (confirm("$js_lt{'dump'}\\n$js_lt{'swit'}")) {
1.484 raeburn 7906: go(url);
7907: }
7908: }
7909: return;
7910: }
7911:
7912: function choose_switchserver_window() {
7913: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
7914: newWindow.document.open();
7915: newWindow.document.writeln('$startpage');
1.484.2.61 raeburn 7916: newWindow.document.write('<h3>$html_js_lt{'duco'}<\\/h3>\\n'+
7917: '<p>$html_js_lt{'yone'}<\\/p>\\n'+
7918: '<div class="LC_left_float"><fieldset><legend>$html_js_lt{'chos'}<\\/legend>\\n'+
1.484 raeburn 7919: '<form name="setserver" method="post" action="" \\/>\\n'+
7920: '$hostpicker\\n'+
7921: '<br \\/><br \\/>\\n'+
1.484.2.61 raeburn 7922: '<input type="button" name="makeswitch" value="$html_js_lt{'swit'}" '+
1.484 raeburn 7923: 'onclick="write_switchserver();" \\/>\\n'+
7924: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
7925: newWindow.document.writeln('$endpage');
7926: newWindow.document.close();
7927: newWindow.focus();
7928: }
7929:
7930: ENDSWITCHJS
7931: }
7932:
7933: sub makedocslogform {
7934: my ($formelems,$docslog) = @_;
7935: return <<"LOGSFORM";
7936: <form action="/adm/coursedocs" method="post" name="docslogform">
7937: <input type="hidden" name="docslog" value="$docslog" />
7938: $formelems
7939: </form>
7940: LOGSFORM
7941: }
7942:
7943: sub makesimpleeditform {
7944: my ($formelems) = @_;
7945: return <<"SIMPFORM";
7946: <form name="simpleedit" method="post" action="/adm/coursedocs">
7947: <input type="hidden" name="importdetail" value="" />
7948: $formelems
7949: </form>
7950: SIMPFORM
7951: }
7952:
1.329 droeschl 7953: 1;
7954: __END__
7955:
7956:
7957: =head1 NAME
7958:
7959: Apache::londocs.pm
7960:
7961: =head1 SYNOPSIS
7962:
7963: This is part of the LearningOnline Network with CAPA project
7964: described at http://www.lon-capa.org.
7965:
7966: =head1 SUBROUTINES
7967:
7968: =over
7969:
7970: =item %help=()
7971:
7972: Available help topics
7973:
7974: =item mapread()
7975:
1.344 bisitz 7976: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 7977: @order and @resources, determines status
7978: sets @order - pointer to resources in right order
7979: sets @resources - array with the resources with correct idx
7980:
7981: =item authorhosts()
7982:
7983: Return hash with valid author names
7984:
7985: =item clean()
7986:
7987: =item dumpcourse()
7988:
7989: Actually dump course
7990:
7991: =item group_import()
7992:
7993: Imports the given (name, url) resources into the course
7994: coursenum, coursedom, and folder must precede the list
7995:
7996: =item breadcrumbs()
7997:
7998: =item log_docs()
7999:
8000: =item docs_change_log()
8001:
8002: =item update_paste_buffer()
8003:
8004: =item print_paste_buffer()
8005:
8006: =item do_paste_from_buffer()
8007:
1.484.2.30 raeburn 8008: =item do_buffer_empty()
8009:
8010: =item clear_from_buffer()
8011:
1.484.2.7 raeburn 8012: =item get_newmap_url()
8013:
8014: =item dbcopy()
8015:
8016: =item uniqueness_check()
8017:
8018: =item contained_map_check()
8019:
8020: =item url_paste_fixups()
8021:
8022: =item apply_fixups()
8023:
8024: =item copy_dependencies()
8025:
1.329 droeschl 8026: =item update_parameter()
8027:
8028: =item handle_edit_cmd()
8029:
8030: =item editor()
8031:
8032: =item process_file_upload()
8033:
8034: =item process_secondary_uploads()
8035:
8036: =item is_supplemental_title()
8037:
8038: =item entryline()
8039:
8040: =item tiehash()
8041:
8042: =item untiehash()
8043:
8044: =item checkonthis()
8045:
8046: check on this
8047:
8048: =item verifycontent()
8049:
8050: Verify Content
8051:
1.484.2.78 raeburn 8052: =item devalidateversioncache()
8053:
8054: =item checkversions()
1.329 droeschl 8055:
8056: Check Versions
8057:
8058: =item mark_hash_old()
8059:
8060: =item is_hash_old()
8061:
8062: =item changewarning()
8063:
8064: =item init_breadcrumbs()
8065:
8066: Breadcrumbs for special functions
8067:
1.484 raeburn 8068: =item create_list_elements()
8069:
8070: =item create_form_ul()
8071:
8072: =item startContentScreen()
8073:
8074: =item endContentScreen()
8075:
8076: =item supplemental_base()
8077:
8078: =item embedded_form_elems()
8079:
8080: =item embedded_destination()
8081:
8082: =item return_to_editor()
8083:
8084: =item decompression_info()
8085:
8086: =item decompression_phase_one()
8087:
8088: =item decompression_phase_two()
8089:
8090: =item remove_archive()
8091:
8092: =item generate_admin_menu()
8093:
8094: =item generate_edit_table()
8095:
8096: =item editing_js()
8097:
8098: =item history_tab_js()
8099:
8100: =item inject_data_js()
8101:
8102: =item dump_switchserver_js()
8103:
1.484.2.3 raeburn 8104: =item resize_scrollbox_js()
1.484 raeburn 8105:
8106: =item makedocslogform()
8107:
1.484.2.3 raeburn 8108: =item makesimpleeditform()
8109:
1.329 droeschl 8110: =back
8111:
8112: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>