Annotation of loncom/interface/londocs.pm, revision 1.484.2.72.2.3
1.329 droeschl 1: # The LearningOnline Network
2: # Documents
3: #
1.484.2.72.2. (raeburn 4:): # $Id: londocs.pm,v 1.484.2.72.2.2 2017/09/15 23:15:55 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.329 droeschl 46: use HTML::Entities;
1.484.2.7 raeburn 47: use HTML::TokeParser;
1.329 droeschl 48: use GDBM_File;
1.484.2.51 raeburn 49: use File::MMagic;
1.329 droeschl 50: use Apache::lonlocal;
51: use Cwd;
52: use LONCAPA qw(:DEFAULT :match);
53:
54: my $iconpath;
55:
56: my %hash;
57:
58: my $hashtied;
59: my %alreadyseen=();
60:
61: my $hadchanges;
1.484.2.37 raeburn 62: my $suppchanges;
1.329 droeschl 63:
64:
65: my %help=();
66:
67:
68: sub mapread {
69: my ($coursenum,$coursedom,$map)=@_;
70: return
71: &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
72: $map);
73: }
74:
75: sub storemap {
1.484.2.7 raeburn 76: my ($coursenum,$coursedom,$map,$contentchg)=@_;
77: my $report;
78: if (($contentchg) && ($map =~ /^default/)) {
79: $report = 1;
80: }
1.329 droeschl 81: my ($outtext,$errtext)=
82: &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.484.2.7 raeburn 83: $map,1,$report);
1.329 droeschl 84: if ($errtext) { return ($errtext,2); }
1.364 bisitz 85:
1.484.2.37 raeburn 86: if ($map =~ /^default/) {
87: $hadchanges=1;
88: } else {
89: $suppchanges=1;
90: }
1.329 droeschl 91: return ($errtext,0);
92: }
93:
94:
95:
96: sub authorhosts {
97: my %outhash=();
98: my $home=0;
99: my $other=0;
100: foreach my $key (keys(%env)) {
101: if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
102: my $role=$1;
103: my $realm=$2;
104: my ($start,$end)=split(/\./,$env{$key});
105: if (($start) && ($start>time)) { next; }
106: if (($end) && (time>$end)) { next; }
107: my ($ca,$cd);
108: if ($1 eq 'au') {
109: $ca=$env{'user.name'};
110: $cd=$env{'user.domain'};
111: } else {
112: ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
113: }
114: my $allowed=0;
115: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
116: my @ids=&Apache::lonnet::current_machine_ids();
1.484 raeburn 117: foreach my $id (@ids) {
118: if ($id eq $myhome) {
119: $allowed=1;
120: last;
121: }
122: }
1.329 droeschl 123: if ($allowed) {
124: $home++;
1.484 raeburn 125: $outhash{'home_'.$ca.':'.$cd}=1;
1.329 droeschl 126: } else {
1.484 raeburn 127: $outhash{'otherhome_'.$ca.':'.$cd}=$myhome;
1.329 droeschl 128: $other++;
129: }
130: }
131: }
132: return ($home,$other,%outhash);
133: }
134:
135:
136: sub clean {
137: my ($title)=@_;
138: $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
1.344 bisitz 139: return $title;
1.329 droeschl 140: }
141:
1.484.2.67 raeburn 142: sub default_folderpath {
143: my ($coursenum,$coursedom,$navmapref) = @_;
144: return unless ($coursenum && $coursedom && ref($navmapref));
145: # Check if entire course is hidden and/or encrypted
146: my ($hiddenmap,$encryptmap,$folderpath,$hiddentop);
147: my $toplevel = "uploaded/$coursedom/$coursenum/default.sequence";
148: unless (ref($$navmapref)) {
149: $$navmapref = Apache::lonnavmaps::navmap->new();
150: }
151: if (ref($$navmapref)) {
152: if (lc($$navmapref->get_mapparam(undef,$toplevel,"0.hiddenresource")) eq 'yes') {
153: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
154: my @resources = $$navmapref->retrieveResources($toplevel,$filterFunc,1,1);
155: unless (@resources) {
156: $hiddenmap = 1;
157: unless ($env{'request.role.adv'}) {
158: $hiddentop = 1;
159: if ($env{'form.folder'}) {
160: undef($env{'form.folder'});
161: }
162: }
163: }
164: }
165: if (lc($$navmapref->get_mapparam(undef,$toplevel,"0.encrypturl")) eq 'yes') {
166: $encryptmap = 1;
167: }
168: }
169: unless ($hiddentop) {
170: $folderpath='default&'.&escape(&mt('Main Content')).
171: '::'.$hiddenmap.':'.$encryptmap.'::';
172: }
173: if (wantarray) {
174: return ($folderpath,$hiddentop);
175: } else {
176: return $folderpath;
177: }
178: }
1.329 droeschl 179:
180: sub dumpcourse {
181: my ($r) = @_;
1.408 raeburn 182: my $crstype = &Apache::loncommon::course_type();
1.484.2.43 raeburn 183: my ($starthash,$js);
184: unless (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
185: $js = <<"ENDJS";
186: <script type="text/javascript">
187: // <![CDATA[
188:
189: function hide_searching() {
190: if (document.getElementById('searching')) {
191: document.getElementById('searching').style.display = 'none';
192: }
193: return;
194: }
195:
196: // ]]>
197: </script>
198: ENDJS
199: $starthash = {
200: add_entries => {'onload' => "hide_searching();"},
201: };
202: }
203: $r->print(&Apache::loncommon::start_page('Copy '.$crstype.' Content to Authoring Space',$js,$starthash)."\n".
204: &Apache::lonhtmlcommon::breadcrumbs('Copy '.$crstype.' Content to Authoring Space')."\n");
1.484 raeburn 205: $r->print(&startContentScreen('tools'));
1.329 droeschl 206: my ($home,$other,%outhash)=&authorhosts();
1.484 raeburn 207: unless ($home) {
208: $r->print(&endContentScreen());
209: return '';
210: }
1.329 droeschl 211: my $origcrsid=$env{'request.course.id'};
212: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
213: if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
214: # Do the dumping
1.484 raeburn 215: unless ($outhash{'home_'.$env{'form.authorspace'}}) {
216: $r->print(&endContentScreen());
217: return '';
218: }
1.484.2.24 raeburn 219: my ($ca,$cd)=split(/\:/,$env{'form.authorspace'});
1.329 droeschl 220: $r->print('<h3>'.&mt('Copying Files').'</h3>');
221: my $title=$env{'form.authorfolder'};
222: $title=&clean($title);
1.484.2.43 raeburn 223: my ($navmap,$errormsg) =
224: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
225: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
226: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
227: my (%maps,%resources,%titles);
228: if (!ref($navmap)) {
229: $r->print($errormsg.
230: &endContentScreen());
231: return '';
232: } else {
233: &Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles,
234: 'dumpdocs',$cdom,$cnum);
235: }
236: my @todump = &Apache::loncommon::get_env_multiple('form.archive');
237: my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages,
238: %newcontent,%has_simpleprobs);
239: foreach my $item (sort {$a <=> $b} (@todump)) {
240: my $name = $env{'form.namefor_'.$item};
241: if ($resources{$item}) {
242: my ($map,$id,$res) = &Apache::lonnet::decode_symb($resources{$item});
243: if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) {
244: $tocopy{$1} = $name;
245: $display{$item} = $1;
246: $lookup{$1} = $item;
247: } elsif ($res eq 'lib/templates/simpleproblem.problem') {
248: $simpleproblems{$item} = {
249: symb => $resources{$item},
250: name => $name,
251: };
252: $display{$item} = 'simpleproblem_'.$name;
253: if ($map =~ m{^\Quploaded/$cdom/$cnum/\E(.+)$}) {
254: $has_simpleprobs{$1}{$id} = $item;
255: }
256: } elsif ($res =~ m{^adm/$match_domain/$match_username/(\d+)/smppg}) {
257: my $marker = $1;
258: my $db_name = &Apache::lonsimplepage::get_db_name($res,$marker,$cdom,$cnum);
259: $simplepages{$item} = {
260: res => $res,
261: title => $titles{$item},
262: db => $db_name,
263: marker => $marker,
264: symb => $resources{$item},
265: name => $name,
266: };
267: $display{$item} = '/'.$res;
268: }
269: } elsif ($maps{$item}) {
270: if ($maps{$item} =~ m{^\Quploaded/$cdom/$cnum/\E((?:default|supplemental)_\d+\.(?:sequence|page))$}) {
271: $tocopy{$1} = $name;
272: $display{$item} = $1;
273: $lookup{$1} = $item;
274: }
275: } else {
276: next;
277: }
278: }
1.329 droeschl 279: my $crs='/uploaded/'.$env{'request.course.id'}.'/';
280: $crs=~s/\_/\//g;
1.484.2.43 raeburn 281: my $mm = new File::MMagic;
282: my $prefix = "/uploaded/$cdom/$cnum/";
283: %replacehash = %tocopy;
284: foreach my $item (sort(keys(%simpleproblems))) {
285: my $content = &Apache::imsexport::simpleproblem($simpleproblems{$item}{'symb'});
286: $newcontent{$display{$item}} = $content;
287: }
288: my $gateway = Apache::lonhtmlgateway->new('web');
289: foreach my $item (sort(keys(%simplepages))) {
290: if (ref($simplepages{$item}) eq 'HASH') {
291: my $pagetitle = $simplepages{$item}{'title'};
292: my %fields = &Apache::lonnet::dump($simplepages{$item}{'db'},$cdom,$cnum);
293: my %contents;
294: foreach my $field (keys(%fields)) {
295: if ($field =~ /^(?:aaa|bbb|ccc)_(\w+)$/) {
296: my $name = $1;
297: my $msg = $fields{$field};
298: if ($name eq 'webreferences') {
299: if ($msg =~ m{^https?://}) {
300: $contents{$name} = '<a href="'.$msg.'"><tt>'.$msg.'</tt></a>';
301: }
302: } else {
303: $msg = &Encode::decode('utf8',$msg);
304: $msg = $gateway->process_outgoing_html($msg,1);
305: $contents{$name} = $msg;
306: }
307: } elsif ($field eq 'uploaded.photourl') {
308: my $marker = $simplepages{$item}{marker};
309: if ($fields{$field} =~ m{^\Q$prefix\E(simplepage/$marker/.+)$}) {
310: my $filepath = $1;
311: my ($relpath,$fname) = ($filepath =~ m{^(.+/)([^/]+)$});
312: if ($fname ne '') {
313: $fname=~s/\.(\w+)$//;
314: my $ext=$1;
315: $fname = &clean($fname);
316: $fname.='.'.$ext;
317: $contents{image} = '<img src="'.$relpath.$fname.'" alt="Image" />';
318: $replacehash{$filepath} = $relpath.$fname;
319: $deps{$item}{$filepath} = 1;
320: }
321: }
322: }
323: }
324: $replacehash{'/'.$simplepages{$item}{'res'}} = $simplepages{$item}{'name'};
325: $lookup{'/'.$simplepages{$item}{'res'}} = $item;
326: my $content = '
327: <html>
328: <head>
329: <title>'.$pagetitle.'</title>
330: </head>
331: <body bgcolor="#ffffff">';
332: if ($contents{title}) {
333: $content .= "\n".'<h2>'.$contents{title}.'</h2>';
334: }
335: if ($contents{image}) {
336: $content .= "\n".$contents{image};
337: }
338: if ($contents{content}) {
339: $content .= '
340: <div class="LC_Box">
1.484.2.50 raeburn 341: <h4 class="LC_hcell">'.&mt('Content').'</h4>'.
1.484.2.43 raeburn 342: $contents{content}.'
343: </div>';
344: }
345: if ($contents{webreferences}) {
346: $content .= '
347: <div class="LC_Box">
1.484.2.50 raeburn 348: <h4 class="LC_hcell">'.&mt('Web References').'</h4>'.
1.484.2.43 raeburn 349: $contents{webreferences}.'
350: </div>';
351: }
352: $content .= '
353: </body>
354: </html>
355: ';
356: $newcontent{'/'.$simplepages{$item}{res}} = $content;
357: }
358: }
359: foreach my $item (keys(%tocopy)) {
360: unless ($item=~/\.(sequence|page)$/) {
361: my $currurlpath = $prefix.$item;
362: my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath);
363: &recurse_html($mm,$prefix,$currdirpath,$currurlpath,$item,$lookup{$item},\%replacehash,\%deps);
364: }
365: }
366: foreach my $num (sort {$a <=> $b} (@todump)) {
367: my $src = $display{$num};
368: next if ($src eq '');
369: my @needcopy = ();
370: if ($replacehash{$src}) {
371: push(@needcopy,$src);
372: if (ref($deps{$num}) eq 'HASH') {
373: foreach my $dep (sort(keys(%{$deps{$num}}))) {
374: if ($replacehash{$dep}) {
375: push(@needcopy,$dep);
376: }
377: }
378: }
379: } elsif ($src =~ /^simpleproblem_/) {
380: push(@needcopy,$src);
381: }
382: next if (@needcopy == 0);
383: my ($result,$depresult);
384: for (my $i=0; $i<@needcopy; $i++) {
385: my $item = $needcopy[$i];
386: my $newfilename;
387: if ($simpleproblems{$num}) {
388: $newfilename=$title.'/'.$simpleproblems{$num}{'name'};
389: } else {
390: $newfilename=$title.'/'.$replacehash{$item};
391: }
392: $newfilename=~s/\.(\w+)$//;
393: my $ext=$1;
394: $newfilename=&clean($newfilename);
395: $newfilename.='.'.$ext;
396: my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$});
397: if ($newrelpath ne $replacehash{$item}) {
398: $replacehash{$item} = $newrelpath;
399: }
400: my @dirs=split(/\//,$newfilename);
401: my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
402: my $makepath=$path;
403: my $fail;
404: my $origin;
405: for (my $i=0;$i<$#dirs;$i++) {
406: $makepath.='/'.$dirs[$i];
407: unless (-e $makepath) {
408: unless(mkdir($makepath,0755)) {
409: $fail = &mt('Directory creation failed.');
410: }
411: }
412: }
413: if ($i == 0) {
414: $result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ';
415: } else {
416: $depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '.
417: '<span class="LC_fontsize_small" style="font-weight: bold;">'.
418: &mt('(dependency)').'</span>: ';
419: }
420: if (-e $path.'/'.$newfilename) {
421: $fail = &mt('Destination already exists -- not overwriting.');
422: } else {
423: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
424: if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) ||
425: ($item =~ /^simpleproblem_/)) {
426: print $fh $newcontent{$item};
427: } else {
428: my $fileloc = &Apache::lonnet::filelocation('',$prefix.$item);
429: if (-e $fileloc) {
430: if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
431: if ((($1 eq 'sequence') || ($1 eq 'page')) &&
432: (ref($has_simpleprobs{$item}) eq 'HASH')) {
433: my %changes = %{$has_simpleprobs{$item}};
434: my $content = &Apache::lonclonecourse::rewritefile(
435: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
436: (%replacehash,$crs => '')
437: );
438: my $updatedcontent = '';
439: my $parser = HTML::TokeParser->new(\$content);
440: $parser->attr_encoded(1);
441: while (my $token = $parser->get_token) {
442: if ($token->[0] eq 'S') {
443: if (($token->[1] eq 'resource') &&
444: ($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') &&
445: ($changes{$token->[2]->{'id'}})) {
446: my $id = $token->[2]->{'id'};
447: $updatedcontent .= '<'.$token->[1];
448: foreach my $attrib (@{$token->[3]}) {
449: next unless ($attrib =~ /^(src|type|title|id)$/);
450: if ($attrib eq 'src') {
451: my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/);
452: if ($file) {
453: $updatedcontent .= ' '.$attrib.'="'.$file.'"';
454: } else {
455: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
456: }
457: } else {
458: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
459: }
460: }
461: $updatedcontent .= ' />'."\n";
462: } else {
463: $updatedcontent .= $token->[4]."\n";
464: }
465: } else {
466: $updatedcontent .= $token->[2];
467: }
468: }
469: print $fh $updatedcontent;
470: } else {
471: print $fh &Apache::lonclonecourse::rewritefile(
472: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
473: (%replacehash,$crs => '')
474: );
475: }
476: } else {
477: print $fh
478: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
479: }
480: } else {
481: $fail = &mt('Source does not exist.');
482: }
483: }
484: $fh->close();
485: } else {
486: $fail = &mt('Could not write to destination.');
487: }
488: }
489: my $text;
490: if ($fail) {
491: $text = '<span class="LC_error">'.&mt('fail').(' 'x3).$fail.'</span>';
492: } else {
493: $text = '<span class="LC_success">'.&mt('ok').'</span>';
494: }
495: if ($i == 0) {
496: $result .= $text;
497: } else {
498: $depresult .= $text.'</li>';
499: }
500: }
501: $r->print($result);
502: if ($depresult) {
503: $r->print('<ul>'.$depresult.'</ul>');
504: }
505: }
1.329 droeschl 506: } else {
1.484.2.43 raeburn 507: my ($navmap,$errormsg) =
508: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
509: if (!ref($navmap)) {
510: $r->print($errormsg);
511: } else {
512: $r->print('<div id="searching">'.&mt('Searching ...').'</div>');
513: $r->rflush();
514: my ($preamble,$formname);
515: $formname = 'dumpdoc';
516: unless ($home==1) {
517: $preamble = '<div class="LC_left_float">'.
518: '<fieldset><legend>'.
519: &mt('Select the Authoring Space').
520: '</legend><select name="authorspace">';
521: }
522: my @orderspaces = ();
523: foreach my $key (sort(keys(%outhash))) {
524: if ($key=~/^home_(.+)$/) {
525: if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) {
526: unshift(@orderspaces,$1);
527: } else {
528: push(@orderspaces,$1);
529: }
530: }
531: }
532: if ($home>1) {
533: $preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>';
534: }
535: foreach my $user (@orderspaces) {
536: if ($home==1) {
537: $preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />';
538: } else {
539: $preamble .= '<option value="'.$user.'">'.$user.' - '.
540: &Apache::loncommon::plainname(split(/\:/,$user)).'</option>';
541: }
542: }
543: unless ($home==1) {
544: $preamble .= '</select></fieldset></div>'."\n";
545: }
546: my $title=$origcrsdata{'description'};
547: $title=~s/[\/\s]+/\_/gs;
548: $title=&clean($title);
549: $preamble .= '<div class="LC_left_float">'.
550: '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.
551: '<input type="text" size="50" name="authorfolder" value="'.
552: $title.'" />'.
553: '</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n";
554: my %uploadedfiles;
555: &tiehash();
556: foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
557: my ($ext)=($file=~/\.(\w+)$/);
558: # FIXME Check supplemental here
559: my $title=$hash{'title_'.$hash{
560: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
561: if (!$title) {
562: $title=$file;
563: } else {
564: $title=~s|/|_|g;
565: }
566: $title=~s/\.(\w+)$//;
567: $title=&clean($title);
568: $title.='.'.$ext;
569: # $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
570: $uploadedfiles{$file} = $title;
571: }
572: &untiehash();
573: $r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef,
574: undef,undef,$preamble,$home,\%uploadedfiles));
575: }
1.329 droeschl 576: }
1.484 raeburn 577: $r->print(&endContentScreen());
1.329 droeschl 578: }
579:
1.484.2.43 raeburn 580: sub recurse_html {
581: my ($mm,$prefix,$currdirpath,$currurlpath,$container,$item,$replacehash,$deps) = @_;
582: return unless ((ref($replacehash) eq 'HASH') && (ref($deps) eq 'HASH'));
583: my (%allfiles,%codebase);
584: if (&Apache::lonnet::extract_embedded_items($currdirpath,\%allfiles,\%codebase) eq 'ok') {
585: if (keys(%allfiles)) {
586: foreach my $dependency (keys(%allfiles)) {
587: next if (($dependency =~ m{^/(res|adm)/}) || ($dependency =~ m{^https?://}));
588: my ($depurl,$relfile,$newcontainer);
589: if ($dependency =~ m{^/}) {
590: if ($dependency =~ m{^\Q$currurlpath/\E(.+)$}) {
591: $relfile = $1;
592: if ($dependency =~ m{^\Q$prefix\E(.+)$}) {
593: $newcontainer = $1;
594: next if ($replacehash->{$newcontainer});
595: }
596: $depurl = $dependency;
597: } else {
598: next;
599: }
600: } else {
601: $relfile = $dependency;
602: $depurl = $currurlpath;
603: $depurl =~ s{[^/]+$}{};
604: $depurl .= $dependency;
605: ($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$});
606: }
607: next if ($relfile eq '');
608: my $newname = $replacehash->{$container};
609: $newname =~ s{[^/]+$}{};
610: $replacehash->{$newcontainer} = $newname.$relfile;
611: $deps->{$item}{$newcontainer} = 1;
612: my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$});
613: my $depfile = &Apache::lonnet::filelocation('',$depurl);
614: my $type = $mm->checktype_filename($depfile);
615: if ($type eq 'text/html') {
616: &recurse_html($mm,$prefix,$depfile,$newurlpath,$newcontainer,$item,$replacehash,$deps);
617: }
618: }
619: }
620: }
621: return;
622: }
623:
1.329 droeschl 624: sub group_import {
1.484.2.72.2. (raeburn 625:): my ($coursenum, $coursedom, $folder, $container, $caller, $ltitoolsref, @files) = @_;
1.484.2.23 raeburn 626: my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap,
627: %removeparam,$importuploaded,$fixuperrors);
628: $allmaps = {};
1.329 droeschl 629: while (@files) {
630: my ($name, $url, $residx) = @{ shift(@files) };
1.344 bisitz 631: if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
1.329 droeschl 632: && ($caller eq 'londocs')
633: && (!&Apache::lonnet::stat_file($url))) {
1.364 bisitz 634:
1.329 droeschl 635: my $errtext = '';
636: my $fatal = 0;
637: my $newmapstr = '<map>'."\n".
638: '<resource id="1" src="" type="start"></resource>'."\n".
639: '<link from="1" to="2" index="1"></link>'."\n".
640: '<resource id="2" src="" type="finish"></resource>'."\n".
641: '</map>';
642: $env{'form.output'}=$newmapstr;
643: my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
644: 'output',$1.$2);
1.484.2.27 raeburn 645: if ($result !~ m{^/uploaded/}) {
1.329 droeschl 646: $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
647: $fatal = 2;
648: }
649: if ($fatal) {
650: return ($errtext,$fatal);
651: }
652: }
653: if ($url) {
1.484.2.72.2. (raeburn 654:): if ($url =~ m{^(/adm/$coursedom/$coursenum/(\d+)/ext\.tool)\:?(.*)$}) {
655:): $url = $1;
656:): my $marker = $2;
657:): my $info = $3;
658:): my ($toolid,%toolhash,%toolsettings);
659:): my @extras = ('linktext','explanation','crslabel','crstitle');
660:): my @toolinfo = split(/:/,$info);
661:): if ($residx) {
662:): %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
663:): $toolid = $toolsettings{'id'};
664:): } else {
665:): $toolid = shift(@toolinfo);
666:): }
667:): $toolid =~ s/\D//g;
668:): ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'},
669:): $toolhash{'linktext'},$toolhash{'explanation'},
670:): $toolhash{'crslabel'},$toolhash{'crstitle'}) = @toolinfo;
671:): foreach my $item (@extras) {
672:): $toolhash{$item} = &unescape($toolhash{$item});
673:): }
674:): if (ref($ltitoolsref) eq 'HASH') {
675:): my @deleted;
676:): if (ref($ltitoolsref->{$toolid}) eq 'HASH') {
677:): $toolhash{'id'} = $toolid;
678:): if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'tab') ||
679:): ($toolhash{'target'} eq 'window')) {
680:): if ($toolhash{'target'} eq 'window') {
681:): foreach my $item ('width','height') {
682:): $toolhash{$item} =~ s/^\s+//;
683:): $toolhash{$item} =~ s/\s+$//;
684:): if ($toolhash{$item} =~ /\D/) {
685:): delete($toolhash{$item});
686:): if ($residx) {
687:): if ($toolsettings{$item}) {
688:): push(@deleted,$item);
689:): }
690:): }
691:): }
692:): }
693:): }
694:): } elsif ($residx) {
695:): $toolhash{'target'} = $toolsettings{'target'};
696:): if ($toolhash{'target'} eq 'window') {
697:): foreach my $item ('width','height') {
698:): $toolhash{$item} = $toolsettings{$item};
699:): }
700:): }
701:): } elsif (ref($ltitoolsref->{$toolid}->{'display'}) eq 'HASH') {
702:): $toolhash{'target'} = $ltitoolsref->{$toolid}->{'display'}->{'target'};
703:): if ($toolhash{'target'} eq 'window') {
704:): $toolhash{'width'} = $ltitoolsref->{$toolid}->{'display'}->{'width'};
705:): $toolhash{'height'} = $ltitoolsref->{$toolid}->{'display'}->{'height'};
706:): }
707:): }
708:): if ($toolhash{'target'} eq 'iframe') {
709:): foreach my $item ('width','height','linktext','explanation') {
710:): delete($toolhash{$item});
711:): if ($residx) {
712:): if ($toolsettings{$item}) {
713:): push(@deleted,$item);
714:): }
715:): }
716:): }
717:): } elsif ($toolhash{'target'} eq 'tab') {
718:): foreach my $item ('width','height') {
719:): delete($toolhash{$item});
720:): if ($residx) {
721:): if ($toolsettings{$item}) {
722:): push(@deleted,$item);
723:): }
724:): }
725:): }
726:): }
727:): if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') {
728:): foreach my $item ('label','title','linktext','explanation') {
729:): my $crsitem;
730:): if (($item eq 'label') || ($item eq 'title')) {
731:): $crsitem = 'crs'.$item;
732:): } else {
733:): $crsitem = $item;
734:): }
735:): if ($ltitoolsref->{$toolid}->{'crsconf'}->{$item}) {
736:): $toolhash{$crsitem} =~ s/^\s+//;
737:): $toolhash{$crsitem} =~ s/\s+$//;
738:): if ($toolhash{$crsitem} eq '') {
739:): delete($toolhash{$crsitem});
740:): }
741:): } else {
742:): delete($toolhash{$crsitem});
743:): }
744:): if (($residx) && (exists($toolsettings{$crsitem}))) {
745:): unless (exists($toolhash{$crsitem})) {
746:): push(@deleted,$crsitem);
747:): }
748:): }
749:): }
750:): }
751:): my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum);
752:): if ($putres eq 'ok') {
753:): if (@deleted) {
754:): &Apache::lonnet::del('exttool_'.$marker,\@deleted,$coursedom,$coursenum);
755:): }
756:): }
757:): }
758:): }
759:): }
1.484.2.23 raeburn 760: if (($caller eq 'londocs') &&
761: ($folder =~ /^default/)) {
1.484.2.27 raeburn 762: if (($url =~ /\.(page|sequence)$/) && (!$donechk)) {
1.484.2.23 raeburn 763: my $chome = &Apache::lonnet::homeserver($coursenum,$coursedom);
764: my $cid = $coursedom.'_'.$coursenum;
765: $allmaps =
766: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
767: $chome,$cid);
768: $donechk = 1;
769: }
770: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) {
1.484.2.72.2. (raeburn 771:): &contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap,
772:): \%removeparam,\%addedmaps,\%hierarchy,\%titles,$allmaps);
1.484.2.23 raeburn 773: $importuploaded = 1;
774: } elsif ($url =~ m{^/res/.+\.(page|sequence)$}) {
775: next if ($allmaps->{$url});
776: }
777: }
1.344 bisitz 778: if (!$residx
1.329 droeschl 779: || defined($LONCAPA::map::zombies[$residx])) {
780: $residx = &LONCAPA::map::getresidx($url,$residx);
781: push(@LONCAPA::map::order, $residx);
782: }
783: my $ext = 'false';
784: if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
785: $name = &LONCAPA::map::qtunescape($name);
1.484.2.27 raeburn 786: if ($name eq '') {
1.484.2.30 raeburn 787: $name = &LONCAPA::map::qtunescape(&mt('Web Page'));
1.484.2.27 raeburn 788: }
789: if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) {
790: my $filepath = $1;
791: my $fname = $name;
792: if ($fname =~ /^\W+$/) {
793: $fname = 'web';
794: } else {
795: $fname =~ s/\W/_/g;
796: }
1.484.2.62 raeburn 797: if (length($fname) > 15) {
1.484.2.27 raeburn 798: $fname = substr($fname,0,14);
799: }
800: my $initialtext = &mt('Replace with your own content.');
801: my $newhtml = <<END;
1.484.2.31 raeburn 802: <html>
1.484.2.27 raeburn 803: <head>
804: <title>$name</title>
805: </head>
806: <body bgcolor="#ffffff">
807: $initialtext
808: </body>
809: </html>
810: END
811: $env{'form.output'}=$newhtml;
812: my $result =
813: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
814: 'output',
815: "$filepath/$residx/$fname.html");
816: if ($result =~ m{^/uploaded/}) {
817: $url = $result;
818: if ($filepath =~ /^supplemental/) {
819: $name = time.'___&&&___'.$env{'user.name'}.'___&&&___'.
820: $env{'user.domain'}.'___&&&___'.$name;
821: }
822: } else {
823: return (&mt('Failed to save new web page.'),1);
824: }
825: }
1.484.2.30 raeburn 826: $url = &LONCAPA::map::qtunescape($url);
1.344 bisitz 827: $LONCAPA::map::resources[$residx] =
1.329 droeschl 828: join(':', ($name, $url, $ext, 'normal', 'res'));
829: }
830: }
1.484.2.23 raeburn 831: if ($importuploaded) {
832: my %import_errors;
833: my %updated = (
834: removefrommap => \%removefrommap,
835: removeparam => \%removeparam,
836: );
1.484.2.26 raeburn 837: my ($result,$msgsarray,$lockerror) =
838: &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
1.484.2.23 raeburn 839: if (keys(%import_errors) > 0) {
840: $fixuperrors =
841: '<p span class="LC_warning">'."\n".
842: &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".
843: '<ul>'."\n";
844: foreach my $key (sort(keys(%import_errors))) {
845: $fixuperrors .= '<li>'.$key.'</li>'."\n";
846: }
847: $fixuperrors .= '</ul></p>'."\n";
848: }
1.484.2.26 raeburn 849: if (ref($msgsarray) eq 'ARRAY') {
850: if (@{$msgsarray} > 0) {
851: $fixuperrors .= '<p class="LC_info">'.
852: join('<br />',@{$msgsarray}).
853: '</p>';
854: }
855: }
856: if ($lockerror) {
857: $fixuperrors .= '<p class="LC_error">'.
858: $lockerror.
859: '</p>';
860: }
1.484.2.23 raeburn 861: }
862: my ($errtext,$fatal) =
863: &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
1.484.2.37 raeburn 864: unless ($fatal) {
865: if ($folder =~ /^supplemental/) {
866: &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
1.484.2.39 raeburn 867: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
868: $folder.'.'.$container);
1.484.2.37 raeburn 869: }
870: }
1.484.2.23 raeburn 871: return ($errtext,$fatal,$fixuperrors);
1.329 droeschl 872: }
873:
874: sub log_docs {
1.484.2.8 raeburn 875: return &Apache::lonnet::write_log('course','docslog',@_);
1.329 droeschl 876: }
877:
878: {
879: my @oldresources=();
880: my @oldorder=();
881: my $parmidx;
882: my %parmaction=();
883: my %parmvalue=();
884: my $changedflag;
885:
886: sub snapshotbefore {
887: @oldresources=@LONCAPA::map::resources;
888: @oldorder=@LONCAPA::map::order;
889: $parmidx=undef;
890: %parmaction=();
891: %parmvalue=();
892: $changedflag=0;
893: }
894:
895: sub remember_parms {
896: my ($idx,$parameter,$action,$value)=@_;
897: $parmidx=$idx;
898: $parmaction{$parameter}=$action;
899: $parmvalue{$parameter}=$value;
900: $changedflag=1;
901: }
902:
903: sub log_differences {
904: my ($plain)=@_;
905: my %storehash=('folder' => $plain,
906: 'currentfolder' => $env{'form.folder'});
907: if ($parmidx) {
908: $storehash{'parameter_res'}=$oldresources[$parmidx];
909: foreach my $parm (keys(%parmaction)) {
910: $storehash{'parameter_action_'.$parm}=$parmaction{$parm};
911: $storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
912: }
913: }
914: my $maxidx=$#oldresources;
915: if ($#LONCAPA::map::resources>$#oldresources) {
916: $maxidx=$#LONCAPA::map::resources;
917: }
918: for (my $idx=0; $idx<=$maxidx; $idx++) {
919: if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
920: $storehash{'before_resources_'.$idx}=$oldresources[$idx];
921: $storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
922: $changedflag=1;
923: }
924: if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
925: $storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
926: $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
927: $changedflag=1;
928: }
929: }
930: $storehash{'maxidx'}=$maxidx;
931: if ($changedflag) { &log_docs(\%storehash); }
932: }
933: }
934:
935: sub docs_change_log {
1.484.2.67 raeburn 936: my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit)=@_;
1.484.2.6 raeburn 937: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
1.484.2.67 raeburn 938: my $navmap;
1.483 raeburn 939: my $js = '<script type="text/javascript">'."\n".
940: '// <![CDATA['."\n".
941: &Apache::loncommon::display_filter_js('docslog')."\n".
1.484.2.67 raeburn 942: &editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag,
1.484.2.72.2. (raeburn 943:): $coursedom,$coursenum,'',$canedit,\$navmap)."\n".
1.483 raeburn 944: &history_tab_js()."\n".
1.484 raeburn 945: &Apache::lonratedt::editscript('simple')."\n".
1.483 raeburn 946: '// ]]>'."\n".
947: '</script>'."\n";
1.484 raeburn 948: $r->print(&Apache::loncommon::start_page('Content Change Log',$js));
949: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Change Log'));
1.484.2.7 raeburn 950: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484 raeburn 951: my %orderhash;
952: my $container='sequence';
953: my $pathitem;
1.484.2.19 raeburn 954: if ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 955: $container='page';
956: }
1.484.2.19 raeburn 957: my $folderpath=$env{'form.folderpath'};
958: if ($folderpath eq '') {
1.484.2.67 raeburn 959: $folderpath = &default_folderpath($coursenum,$coursedom,\$navmap);
1.484.2.19 raeburn 960: }
1.484.2.67 raeburn 961: undef($navmap);
1.484.2.19 raeburn 962: $pathitem = '<input type="hidden" name="folderpath" value="'.
963: &HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 964: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
965: my $jumpto = $readfile;
966: $jumpto =~ s{^/}{};
967: my $tid = 1;
1.484.2.7 raeburn 968: if ($supplementalflag) {
969: $tid = 2;
970: }
1.484.2.19 raeburn 971: my ($breadcrumbtrail) =
1.484.2.18 raeburn 972: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
1.484 raeburn 973: $r->print($breadcrumbtrail.
974: &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto,
975: $readfile));
1.329 droeschl 976: my %docslog=&Apache::lonnet::dump('nohist_docslog',
977: $env{'course.'.$env{'request.course.id'}.'.domain'},
978: $env{'course.'.$env{'request.course.id'}.'.num'});
979:
980: if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
981:
982: my %saveable_parameters = ('show' => 'scalar',);
983: &Apache::loncommon::store_course_settings('docs_log',
984: \%saveable_parameters);
985: &Apache::loncommon::restore_course_settings('docs_log',
986: \%saveable_parameters);
987: if (!$env{'form.show'}) { $env{'form.show'}=10; }
1.452 www 988: # FIXME: internationalization seems wrong here
1.329 droeschl 989: my %lt=('hiddenresource' => 'Resources hidden',
990: 'encrypturl' => 'URL hidden',
991: 'randompick' => 'Randomly pick',
992: 'randomorder' => 'Randomly ordered',
993: 'set' => 'set to',
994: 'del' => 'deleted');
1.484 raeburn 995: my $filter = &Apache::loncommon::display_filter('docslog')."\n".
996: $pathitem."\n".
997: '<input type="hidden" name="folder" value="'.$env{'form.folder'}.'" />'.
998: (' 'x2).'<input type="submit" value="'.&mt('Display').'" />';
999: $r->print('<div class="LC_left_float">'.
1000: '<fieldset><legend>'.&mt('Display of Content Changes').'</legend>'."\n".
1001: &makedocslogform($filter,1).
1002: '</fieldset></div><br clear="all" />');
1.329 droeschl 1003: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
1004: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
1005: &mt('After').'</th>'.
1006: &Apache::loncommon::end_data_table_header_row());
1007: my $shown=0;
1008: foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
1009: if ($env{'form.displayfilter'} eq 'currentfolder') {
1010: if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
1011: }
1012: my @changes=keys(%{$docslog{$id}{'logentry'}});
1013: if ($env{'form.displayfilter'} eq 'containing') {
1014: my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
1015: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
1016: foreach my $key (@changes) {
1017: $wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
1018: }
1.344 bisitz 1019: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
1.329 droeschl 1020: }
1021: my $count = 0;
1022: my $time =
1023: &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
1024: my $plainname =
1025: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
1026: $docslog{$id}{'exe_udom'});
1027: my $about_me_link =
1028: &Apache::loncommon::aboutmewrapper($plainname,
1029: $docslog{$id}{'exe_uname'},
1030: $docslog{$id}{'exe_udom'});
1031: my $send_msg_link='';
1032: if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
1033: || ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
1034: $send_msg_link ='<br />'.
1035: &Apache::loncommon::messagewrapper(&mt('Send message'),
1036: $docslog{$id}{'exe_uname'},
1037: $docslog{$id}{'exe_udom'});
1038: }
1039: $r->print(&Apache::loncommon::start_data_table_row());
1040: $r->print('<td>'.$time.'</td>
1041: <td>'.$about_me_link.
1042: '<br /><tt>'.$docslog{$id}{'exe_uname'}.
1043: ':'.$docslog{$id}{'exe_udom'}.'</tt>'.
1044: $send_msg_link.'</td><td>'.
1045: $docslog{$id}{'logentry'}{'folder'}.'</td><td>');
1.484.2.19 raeburn 1046: my $is_supp = 0;
1.484.2.7 raeburn 1047: if ($docslog{$id}{'logentry'}{'currentfolder'} =~ /^supplemental/) {
1048: $is_supp = 1;
1049: }
1.329 droeschl 1050: # Before
1051: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1052: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
1053: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
1054: if ($oldname ne $newname) {
1.484.2.7 raeburn 1055: my $shown = &LONCAPA::map::qtescape($oldname);
1056: if ($is_supp) {
1057: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1058: }
1059: $r->print($shown);
1.329 droeschl 1060: }
1061: }
1062: $r->print('<ul>');
1063: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1064: if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
1.484.2.7 raeburn 1065: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]);
1066: if ($is_supp) {
1067: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1068: }
1.484.2.19 raeburn 1069: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 1070: }
1071: }
1072: $r->print('</ul>');
1073: # After
1074: $r->print('</td><td>');
1075:
1076: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1077: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
1078: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
1079: if ($oldname ne '' && $oldname ne $newname) {
1.484.2.7 raeburn 1080: my $shown = &LONCAPA::map::qtescape($newname);
1081: if ($is_supp) {
1082: $shown = &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($newname));
1083: }
1084: $r->print($shown);
1.329 droeschl 1085: }
1.364 bisitz 1086: }
1.329 droeschl 1087: $r->print('<ul>');
1088: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1089: if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
1.484.2.7 raeburn 1090: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]);
1091: if ($is_supp) {
1092: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1093: }
1094: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 1095: }
1096: }
1097: $r->print('</ul>');
1098: if ($docslog{$id}{'logentry'}{'parameter_res'}) {
1099: $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
1100: foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
1101: if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
1.452 www 1102: # FIXME: internationalization seems wrong here
1.329 droeschl 1103: $r->print('<li>'.
1104: &mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
1105: $docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
1106: .'</li>');
1107: }
1108: }
1109: $r->print('</ul>');
1110: }
1111: # End
1112: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1113: $shown++;
1114: if (!($env{'form.show'} eq &mt('all')
1115: || $shown<=$env{'form.show'})) { last; }
1116: }
1.484 raeburn 1117: $r->print(&Apache::loncommon::end_data_table()."\n".
1118: &makesimpleeditform($pathitem)."\n".
1119: '</div></div>');
1120: $r->print(&endContentScreen());
1.329 droeschl 1121: }
1122:
1123: sub update_paste_buffer {
1.484.2.7 raeburn 1124: my ($coursenum,$coursedom,$folder) = @_;
1.484.2.57 raeburn 1125: my (@possibles,%removals,%cuts,$output);
1.484.2.30 raeburn 1126: if ($env{'form.multiremove'}) {
1127: $env{'form.multiremove'} =~ s/,$//;
1128: map { $removals{$_} = 1; } split(/,/,$env{'form.multiremove'});
1129: }
1130: if (($env{'form.multicopy'}) || ($env{'form.multicut'})) {
1131: if ($env{'form.multicut'}) {
1132: $env{'form.multicut'} =~ s/,$//;
1133: foreach my $item (split(/,/,$env{'form.multicut'})) {
1134: unless ($removals{$item}) {
1135: $cuts{$item} = 1;
1136: push(@possibles,$item.':cut');
1137: }
1138: }
1139: }
1140: if ($env{'form.multicopy'}) {
1141: $env{'form.multicopy'} =~ s/,$//;
1142: foreach my $item (split(/,/,$env{'form.multicopy'})) {
1143: unless ($removals{$item} || $cuts{$item}) {
1144: push(@possibles,$item.':copy');
1145: }
1146: }
1147: }
1148: } elsif ($env{'form.markcopy'}) {
1149: @possibles = split(/,/,$env{'form.markcopy'});
1150: }
1.329 droeschl 1151:
1.484.2.30 raeburn 1152: return if (@possibles == 0);
1.329 droeschl 1153: return if (!defined($env{'form.copyfolder'}));
1154:
1155: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1156: $env{'form.copyfolder'});
1157: return if ($fatal);
1158:
1.484.2.30 raeburn 1159: my %curr_groups = &Apache::longroup::coursegroups();
1160:
1161: # Retrieve current paste buffer suffixes.
1162: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1163: my (%pasteurls,@newpaste);
1164:
1165: # Construct identifiers for current contents of user's paste buffer
1166: if (@currpaste) {
1167: foreach my $suffix (@currpaste) {
1168: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1169: my $url = $env{'docs.markedcopy_url_'.$suffix};
1170: if (($cid =~ /^$match_domain(?:_)$match_courseid$/) &&
1171: ($url ne '')) {
1.484.2.41 raeburn 1172: $pasteurls{$cid.'_'.$url} = 1;
1.484.2.30 raeburn 1173: }
1174: }
1175: }
1176:
1177: # Mark items for copying (skip any items already in user's paste buffer)
1178: my %addtoenv;
1179:
1180: foreach my $item (@possibles) {
1181: my ($orderidx,$cmd) = split(/:/,$item);
1182: next if ($orderidx =~ /\D/);
1183: next unless (($cmd eq 'cut') || ($cmd eq 'copy') || ($cmd eq 'remove'));
1184: my ($title,$url)=split(':',$LONCAPA::map::resources[$orderidx]);
1185: my %denied = &action_restrictions($coursenum,$coursedom,
1186: &LONCAPA::map::qtescape($url),
1187: $env{'form.folderpath'},\%curr_groups);
1188: next if ($denied{'copy'});
1189: $url=~s{http(:|:)//https(:|:)//}{https$2//};
1190: next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$url}));
1191: my ($suffix,$errortxt,$locknotfreed) =
1192: &new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste');
1.484.2.57 raeburn 1193: if ($suffix ne '') {
1194: push(@newpaste,$suffix);
1195: } else {
1196: if ($locknotfreed) {
1197: return $locknotfreed;
1198: }
1.484.2.30 raeburn 1199: }
1200: if (&is_supplemental_title($title)) {
1201: &Apache::lonnet::appenv({'docs.markedcopy_supplemental_'.$suffix => $title});
1202: ($title) = &Apache::loncommon::parse_supplemental_title($title);
1203: }
1204:
1205: $addtoenv{'docs.markedcopy_title_'.$suffix} = $title,
1206: $addtoenv{'docs.markedcopy_url_'.$suffix} = $url,
1207: $addtoenv{'docs.markedcopy_cmd_'.$suffix} = $cmd,
1208: $addtoenv{'docs.markedcopy_crs_'.$suffix} = $env{'request.course.id'};
1209:
1210: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) {
1211: my $prefix = $1;
1212: my $subdir =$2;
1213: if ($subdir eq '') {
1214: $subdir = $prefix;
1.484.2.7 raeburn 1215: }
1.484.2.30 raeburn 1216: my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps);
1.484.2.72.2. (raeburn 1217:): &contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap,
1218:): \%removeparam,\%addedmaps,\%hierarchy,\%titles,\%allmaps);
1.484.2.30 raeburn 1219: if (ref($hierarchy{$url}) eq 'HASH') {
1220: my ($nested,$nestednames);
1221: &recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames);
1222: $nested =~ s/\&$//;
1223: $nestednames =~ s/\Q___&&&___\E$//;
1224: if ($nested ne '') {
1225: $addtoenv{'docs.markedcopy_nested_'.$suffix} = $nested;
1226: }
1227: if ($nestednames ne '') {
1228: $addtoenv{'docs.markedcopy_nestednames_'.$suffix} = $nestednames;
1229: }
1.484.2.7 raeburn 1230: }
1231: }
1.484.2.57 raeburn 1232: if ($locknotfreed) {
1233: $output = $locknotfreed;
1234: last;
1235: }
1.484.2.7 raeburn 1236: }
1.484.2.30 raeburn 1237: if (@newpaste) {
1238: $addtoenv{'docs.markedcopies'} = join(',',(@currpaste,@newpaste));
1239: }
1.484.2.7 raeburn 1240: &Apache::lonnet::appenv(\%addtoenv);
1.329 droeschl 1241: delete($env{'form.markcopy'});
1.484.2.57 raeburn 1242: return $output;
1.329 droeschl 1243: }
1244:
1.484.2.7 raeburn 1245: sub recurse_uploaded_maps {
1246: my ($url,$dir,$hierarchy,$titlesref,$nestref,$namesref) = @_;
1247: if (ref($hierarchy->{$url}) eq 'HASH') {
1248: my @maps = map { $hierarchy->{$url}{$_}; } sort { $a <=> $b } (keys(%{$hierarchy->{$url}}));
1249: my @titles = map { $titlesref->{$url}{$_}; } sort { $a <=> $b } (keys(%{$titlesref->{$url}}));
1250: my (@uploaded,@names,%shorter);
1251: for (my $i=0; $i<@maps; $i++) {
1252: my ($inner) = ($maps[$i] =~ m{^/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_(\d+)\.(?:page|sequence)$});
1253: if ($inner ne '') {
1254: push(@uploaded,$inner);
1255: push(@names,&escape($titles[$i]));
1256: $shorter{$maps[$i]} = $inner;
1257: }
1258: }
1259: $$nestref .= "$dir:".join(',',@uploaded).'&';
1260: $$namesref .= "$dir:".(join(',',@names)).'___&&&___';
1261: foreach my $map (@maps) {
1262: if ($shorter{$map} ne '') {
1263: &recurse_uploaded_maps($map,$shorter{$map},$hierarchy,$titlesref,$nestref,$namesref);
1264: }
1265: }
1266: }
1267: return;
1268: }
1269:
1.329 droeschl 1270: sub print_paste_buffer {
1.484.2.7 raeburn 1271: my ($r,$container,$folder,$coursedom,$coursenum) = @_;
1.484.2.30 raeburn 1272: return if (!defined($env{'docs.markedcopies'}));
1.329 droeschl 1273:
1.484.2.30 raeburn 1274: unless (($env{'form.pastemarked'}) || ($env{'form.clearmarked'})) {
1275: return if ($env{'docs.markedcopies'} eq '');
1.484.2.7 raeburn 1276: }
1277:
1.484.2.30 raeburn 1278: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1279: my ($pasteitems,@pasteable);
1.484.2.47 raeburn 1280: my $clipboardcount = 0;
1.484.2.7 raeburn 1281:
1.484.2.30 raeburn 1282: # Construct identifiers for current contents of user's paste buffer
1283: foreach my $suffix (@currpaste) {
1284: next if ($suffix =~ /\D/);
1285: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1286: my $url = $env{'docs.markedcopy_url_'.$suffix};
1287: if (($cid =~ /^$match_domain\_$match_courseid$/) &&
1288: ($url ne '')) {
1.484.2.47 raeburn 1289: $clipboardcount ++;
1.484.2.30 raeburn 1290: my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent,
1.484.2.72.2. (raeburn 1291:): $canpaste,$nopaste,$othercrs,$areachange,$is_exttool);
1.484.2.30 raeburn 1292: my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1];
1293: if ($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
1294: $is_external = 1;
1.484.2.72.2. (raeburn 1295:): } elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$}) {
1296:): $is_exttool = 1;
1.484.2.7 raeburn 1297: }
1.484.2.30 raeburn 1298: if ($folder =~ /^supplemental/) {
1299: $canpaste = &supp_pasteable($env{'docs.markedcopy_url_'.$suffix});
1300: unless ($canpaste) {
1301: $nopaste = &mt('Paste into Supplemental Content unavailable.');
1.484.2.7 raeburn 1302: }
1.484.2.30 raeburn 1303: } else {
1304: $canpaste = 1;
1.484.2.7 raeburn 1305: }
1.484.2.30 raeburn 1306: if ($canpaste) {
1307: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1308: my $srcdom = $1;
1309: my $srcnum = $2;
1310: my $rem = $3;
1311: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
1312: $othercourse = 1;
1313: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1.484.2.72.2. (raeburn 1314:): $othercrs = '<br />'.&mt('(from another course)');
1.484.2.30 raeburn 1315: } else {
1316: $canpaste = 0;
1317: $nopaste = &mt('Paste from another course unavailable.');
1.484.2.7 raeburn 1318: }
1319: }
1.484.2.30 raeburn 1320: if ($rem =~ m{^(default|supplemental)_?(\d*)\.(?:page|sequence)$}) {
1321: my $prefix = $1;
1322: $parent = $2;
1323: if ($folder !~ /^\Q$prefix\E/) {
1324: $areachange = 1;
1325: }
1326: $is_uploaded_map = 1;
1327: }
1.484.2.72.2. (raeburn 1328:): } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
1329:): ($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg|ext\.tool)$})) {
1330:): if ($cid ne $env{'request.course.id'}) {
1331:): my ($srcdom,$srcnum) = split(/_/,$cid);
1332:): if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1333:): if (($is_exttool) && ($srcdom ne $coursedom)) {
1334:): $canpaste = 0;
1335:): $nopaste = &mt('Paste from another domain unavailable.');
1336:): } else {
1337:): $othercrs = '<br />'.&mt('(from another course)');
1338:): }
1339:): } else {
1340:): $canpaste = 0;
1341:): $nopaste = &mt('Paste from another course unavailable.');
1342:): }
1343:): }
1.484.2.30 raeburn 1344: }
1345: }
1346: if ($canpaste) {
1347: push(@pasteable,$suffix);
1348: }
1349: my $buffer;
1.484.2.72.2. (raeburn 1350:): if ($is_external) {
1.484.2.30 raeburn 1351: $buffer = &mt('External Resource').': '.
1352: &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('.
1353: &LONCAPA::map::qtescape($url).')';
1.484.2.72.2. (raeburn 1354:): } elsif ($is_exttool) {
1355:): $buffer = &mt('External Tool').': '.
1356:): &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.484.2.30 raeburn 1357: } else {
1358: my $icon = &Apache::loncommon::icon($extension);
1359: if ($extension eq 'sequence' &&
1360: $url =~ m{/default_\d+\.sequence$}x) {
1361: $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
1362: $icon .= '/navmap.folder.closed.gif';
1363: }
1.484.2.57 raeburn 1364: my $title = $env{'docs.markedcopy_title_'.$suffix};
1365: if ($title eq '') {
1366: ($title) = ($url =~ m{/([^/]+)$});
1367: }
1.484.2.30 raeburn 1368: $buffer = '<img src="'.$icon.'" alt="" class="LC_icon" />'.
1369: ': '.
1370: &Apache::loncommon::parse_supplemental_title(
1.484.2.57 raeburn 1371: &LONCAPA::map::qtescape($title));
1.484.2.30 raeburn 1372: }
1373: $pasteitems .= '<div class="LC_left_float">';
1374: my ($options,$onclick);
1375: if (($canpaste) && (!$areachange) && (!$othercourse) &&
1376: ($env{'docs.markedcopy_cmd_'.$suffix} eq 'cut')) {
1377: if (($is_uploaded_map) ||
1378: ($url =~ /(bulletinboard|smppg)$/) ||
1379: ($url =~ m{^/uploaded/$coursedom/$coursenum/(?:docs|supplemental)/(.+)$})) {
1380: $options = &paste_options($suffix,$is_uploaded_map,$parent);
1381: $onclick= 'onclick="showOptions(this,'."'$suffix'".');" ';
1382: }
1383: }
1384: $pasteitems .= '<label><input type="checkbox" name="pasting" id="pasting_'.$suffix.'" value="'.$suffix.'" '.$onclick.'/>'.$buffer.'</label>';
1385: if ($nopaste) {
1386: $pasteitems .= $nopaste;
1387: } else {
1388: if ($othercrs) {
1389: $pasteitems .= $othercrs;
1390: }
1391: if ($options) {
1392: $pasteitems .= $options;
1.484.2.7 raeburn 1393: }
1394: }
1.484.2.30 raeburn 1395: $pasteitems .= '</div>';
1396: }
1397: }
1398: if ($pasteitems eq '') {
1399: &Apache::lonnet::delenv('docs.markedcopies');
1400: }
1401: my ($pasteform,$form_start,$buttons,$form_end);
1402: if ($pasteitems) {
1403: $pasteitems .= '<div style="padding:0;clear:both;margin:0;border:0"></div>';
1404: $form_start = '<form name="pasteform" action="/adm/coursedocs" method="post" onsubmit="return validateClipboard();">';
1405: if (@pasteable) {
1.484.2.47 raeburn 1406: my $value = &mt('Paste to current folder');
1407: if ($container eq 'page') {
1408: $value = &mt('Paste to current page');
1409: }
1410: $buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.(' 'x2);
1411: }
1.484.2.72.2. (raeburn 1412:): $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.(' 'x2);
1.484.2.47 raeburn 1413: if ($clipboardcount > 1) {
1414: $buttons .=
1415: '<span style="text-decoration:line-through">'.(' 'x20).'</span>'.(' 'x2).
1416: '<input type="button" name="checkallclip" value="'.&mt('Check all').'" style="height:20px;" onclick="checkClipboard();" />'.
1417: (' 'x2).
1418: '<input type="button" name="uncheckallclip" value="'.&mt('Uncheck all').'" style="height:20px;" onclick="uncheckClipboard();" />'.
1419: (' 'x2);
1.484.2.7 raeburn 1420: }
1.484.2.48 raeburn 1421: $form_end = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'.
1422: '</form>';
1.484.2.30 raeburn 1423: } else {
1424: $pasteitems = &mt('Clipboard is empty');
1425: }
1426: $r->print($form_start
1427: .'<fieldset>'
1428: .'<legend>'.&mt('Clipboard').(' ' x2).$buttons.'</legend>'
1429: .$pasteitems
1430: .'</fieldset>'
1431: .$form_end);
1432: }
1433:
1434: sub paste_options {
1435: my ($suffix,$is_uploaded_map,$parent) = @_;
1436: my ($copytext,$movetext);
1437: if ($is_uploaded_map) {
1438: $copytext = &mt('Copy to new folder');
1439: $movetext = &mt('Move old');
1440: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /bulletinboard$/) {
1441: $copytext = &mt('Copy to new board');
1442: $movetext = &mt('Move (not posts)');
1443: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /smppg$/) {
1444: $copytext = &mt('Copy to new page');
1445: $movetext = &mt('Move');
1.484.2.7 raeburn 1446: } else {
1.484.2.30 raeburn 1447: $copytext = &mt('Copy to new file');
1448: $movetext = &mt('Move');
1449: }
1450: my $output = '<br />'.
1451: '<span id="pasteoptionstext_'.$suffix.'" class="LC_fontsize_small LC_nobreak"></span>'.
1452: '<div id="pasteoptions_'.$suffix.'" class="LC_dccid" style="display:none;"><span class="LC_nobreak">'.(' 'x 4).
1453: '<label>'.
1454: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="new" checked="checked" />'.
1455: $copytext.'</label></span>'.(' 'x2).' '.
1456: '<span class="LC_nobreak"><label>'.
1457: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="move" />'.
1458: $movetext.'</label></span>';
1459: if (($is_uploaded_map) && ($env{'docs.markedcopy_nested_'.$suffix})) {
1460: $output .= '<br /><fieldset><legend>'.&mt('Folder to paste contains sub-folders').
1461: '</legend><table border="0">';
1462: my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1463: my @titles = split(/\Q___&&&___\E/,$env{'docs.markedcopy_nestednames_'.$suffix});
1464: my $lastdir = $parent;
1465: my %depths = (
1466: $lastdir => 0,
1467: );
1468: my (%display,%deps);
1469: for (my $i=0; $i<@pastemaps; $i++) {
1470: ($lastdir,my $subfolderstr) = split(/\:/,$pastemaps[$i]);
1471: my ($namedir,$esctitlestr) = split(/\:/,$titles[$i]);
1472: my @subfolders = split(/,/,$subfolderstr);
1473: $deps{$lastdir} = \@subfolders;
1474: my @subfoldertitles = map { &unescape($_); } split(/,/,$esctitlestr);
1475: my $depth = $depths{$lastdir} + 1;
1476: my $offset = int($depth * 4);
1477: my $indent = (' ' x $offset);
1478: for (my $j=0; $j<@subfolders; $j++) {
1479: $depths{$subfolders[$j]} = $depth;
1480: $display{$subfolders[$j]} =
1481: '<tr><td>'.$indent.$subfoldertitles[$j].' </td>'.
1482: '<td><label>'.
1483: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="new" checked="checked" />'.&mt('Copy to new').'</label>'.(' ' x2).
1484: '<label>'.
1485: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="move" />'.
1486: &mt('Move old').'</label>'.
1487: '</td></tr>';
1488: }
1489: }
1490: &recurse_print(\$output,$parent,\%deps,\%display);
1491: $output .= '</table></fieldset>';
1.329 droeschl 1492: }
1.484.2.30 raeburn 1493: $output .= '</div>';
1494: return $output;
1.329 droeschl 1495: }
1496:
1.484.2.7 raeburn 1497: sub recurse_print {
1.484.2.30 raeburn 1498: my ($outputref,$dir,$deps,$display) = @_;
1499: $$outputref .= $display->{$dir}."\n";
1.484.2.7 raeburn 1500: if (ref($deps->{$dir}) eq 'ARRAY') {
1501: foreach my $subdir (@{$deps->{$dir}}) {
1.484.2.30 raeburn 1502: &recurse_print($outputref,$subdir,$deps,$display);
1.484.2.7 raeburn 1503: }
1504: }
1505: }
1506:
1507: sub supp_pasteable {
1508: my ($url) = @_;
1509: if (($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//}) ||
1510: (($url =~ /\.sequence$/) && ($url =~ m{^/uploaded/})) ||
1511: ($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) ||
1512: ($url =~ m{^/adm/$match_domain/$match_username/aboutme}) ||
1.484.2.72.2. (raeburn 1513:): ($url =~ m{^/public/$match_domain/$match_courseid/syllabus}) ||
1514:): ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$})) {
1.484.2.7 raeburn 1515: return 1;
1516: }
1517: return;
1518: }
1519:
1520: sub paste_popup_js {
1.484.2.61 raeburn 1521: my %html_js_lt = &Apache::lonlocal::texthash(
1.484.2.30 raeburn 1522: show => 'Show Options',
1523: hide => 'Hide Options',
1.484.2.61 raeburn 1524: );
1525: my %js_lt = &Apache::lonlocal::texthash(
1.484.2.30 raeburn 1526: none => 'No items selected from clipboard.',
1.484.2.7 raeburn 1527: );
1.484.2.61 raeburn 1528: &html_escape(\%html_js_lt);
1529: &js_escape(\%html_js_lt);
1530: &js_escape(\%js_lt);
1.484.2.7 raeburn 1531: return <<"END";
1532:
1.484.2.30 raeburn 1533: function showPasteOptions(suffix) {
1534: document.getElementById('pasteoptions_'+suffix).style.display='block';
1.484.2.61 raeburn 1535: document.getElementById('pasteoptionstext_'+suffix).innerHTML = ' <a href="javascript:hidePasteOptions(\\''+suffix+'\\');" class="LC_menubuttons_link">$html_js_lt{'hide'}</a>';
1.484.2.7 raeburn 1536: return;
1537: }
1538:
1.484.2.30 raeburn 1539: function hidePasteOptions(suffix) {
1540: document.getElementById('pasteoptions_'+suffix).style.display='none';
1.484.2.61 raeburn 1541: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.484.2.7 raeburn 1542: return;
1543: }
1544:
1.484.2.30 raeburn 1545: function showOptions(caller,suffix) {
1546: if (document.getElementById('pasteoptionstext_'+suffix)) {
1547: if (caller.checked) {
1.484.2.61 raeburn 1548: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.484.2.30 raeburn 1549: } else {
1550: document.getElementById('pasteoptionstext_'+suffix).innerHTML ='';
1551: }
1552: if (document.getElementById('pasteoptions_'+suffix)) {
1553: document.getElementById('pasteoptions_'+suffix).style.display='none';
1554: }
1555: }
1556: return;
1557: }
1.484.2.7 raeburn 1558:
1.484.2.30 raeburn 1559: function validateClipboard() {
1560: var numchk = 0;
1561: if (document.pasteform.pasting.length > 1) {
1562: for (var i=0; i<document.pasteform.pasting.length; i++) {
1563: if (document.pasteform.pasting[i].checked) {
1564: numchk ++;
1565: }
1566: }
1567: } else {
1568: if (document.pasteform.pasting.type == 'checkbox') {
1569: if (document.pasteform.pasting.checked) {
1570: numchk ++;
1571: }
1572: }
1573: }
1574: if (numchk > 0) {
1575: return true;
1576: } else {
1.484.2.61 raeburn 1577: alert("$js_lt{'none'}");
1.484.2.30 raeburn 1578: return false;
1579: }
1.484.2.7 raeburn 1580: }
1581:
1.484.2.47 raeburn 1582: function checkClipboard() {
1583: if (document.pasteform.pasting.length > 1) {
1584: for (var i=0; i<document.pasteform.pasting.length; i++) {
1585: document.pasteform.pasting[i].checked = true;
1586: }
1587: }
1588: return;
1589: }
1590:
1591: function uncheckClipboard() {
1592: if (document.pasteform.pasting.length >1) {
1593: for (var i=0; i<document.pasteform.pasting.length; i++) {
1594: document.pasteform.pasting[i].checked = false;
1595: }
1596: }
1597: return;
1598: }
1599:
1.484.2.30 raeburn 1600: END
1601:
1602: }
1.484.2.7 raeburn 1603:
1.329 droeschl 1604: sub do_paste_from_buffer {
1.484.2.7 raeburn 1605: my ($coursenum,$coursedom,$folder,$container,$errors) = @_;
1.329 droeschl 1606:
1.484.2.30 raeburn 1607: # Array of items in paste buffer
1608: my (@currpaste,%pastebuffer,%allerrors);
1609: @currpaste = split(/,/,$env{'docs.markedcopies'});
1610:
1.484.2.7 raeburn 1611: # Early out if paste buffer is empty
1.484.2.30 raeburn 1612: if (@currpaste == 0) {
1.484.2.7 raeburn 1613: return ();
1.484.2.30 raeburn 1614: }
1615: map { $pastebuffer{$_} = 1; } @currpaste;
1616:
1617: # Array of items selected items to paste
1618: my @reqpaste = &Apache::loncommon::get_env_multiple('form.pasting');
1619:
1620: # Early out if nothing selected to paste
1621: if (@reqpaste == 0) {
1622: return();
1623: }
1624: my @topaste;
1625: foreach my $suffix (@reqpaste) {
1626: next if ($suffix =~ /\D/);
1627: next unless (exists($pastebuffer{$suffix}));
1628: push(@topaste,$suffix);
1.484.2.7 raeburn 1629: }
1630:
1.484.2.30 raeburn 1631: # Early out if nothing available to paste
1632: if (@topaste == 0) {
1633: return();
1.329 droeschl 1634: }
1635:
1.484.2.72.2. (raeburn 1636:): my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%notindom,%duplicate,
1.484.2.41 raeburn 1637: %prefixchg,%srcdom,%srcnum,%marktomove,$save_err,$lockerrors,$allresult);
1.484.2.7 raeburn 1638:
1.484.2.30 raeburn 1639: foreach my $suffix (@topaste) {
1640: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1.484.2.72.2. (raeburn 1641:): my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.484.2.30 raeburn 1642: # Supplemental content may only include certain types of content
1643: # Early out if pasted content is not supported in Supplemental area
1644: if ($folder =~ /^supplemental/) {
1645: unless (&supp_pasteable($url)) {
1646: $notinsupp{$suffix} = 1;
1647: next;
1648: }
1649: }
1650: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/}) {
1651: my $srcd = $1;
1652: my $srcn = $2;
1.484.2.7 raeburn 1653: # When paste buffer was populated using an active role in a different course
1.484.2.30 raeburn 1654: # check for mdc privilege in the course from which the resource was pasted
1655: if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1656: unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1657: $notincrs{$suffix} = 1;
1658: next;
1659: }
1.329 droeschl 1660: }
1.484.2.30 raeburn 1661: $srcdom{$suffix} = $srcd;
1662: $srcnum{$suffix} = $srcn;
1.484.2.72.2. (raeburn 1663:): } elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$}) {
1664:): my ($srcd,$srcn) = split(/_/,$cid);
1665:): # When paste buffer was populated using an active role in a different course
1666:): # check for mdc privilege in the course from which the resource was pasted
1667:): if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1668:): unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1669:): $notincrs{$suffix} = 1;
1670:): next;
1671:): }
1672:): }
1673:): # When buffer was populated using an active role in a different course
1674:): # disallow pasting of External Tool if course is in a different domain.
1675:): if ($srcd ne $coursedom) {
1676:): $notindom{$suffix} = 1;
1677:): next;
1678:): }
1679:): $srcdom{$suffix} = $srcd;
1680:): $srcnum{$suffix} = $srcn;
1.484.2.30 raeburn 1681: }
1682: push(@dopaste,$suffix);
1683: if ($url=~/\.(page|sequence)$/) {
1684: $is_map{$suffix} = 1;
1.329 droeschl 1685: }
1.484.2.30 raeburn 1686:
1687: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/([^/]+)}) {
1688: my $oldprefix = $1;
1.484.2.19 raeburn 1689: # When pasting content from Main Content to Supplemental Content and vice versa
1.484.2.7 raeburn 1690: # URLs will contain different paths (which depend on whether pasted item is
1.484.2.72.2. (raeburn 1691:): # a folder/page or a document).
1.484.2.30 raeburn 1692: if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) {
1693: $prefixchg{$suffix} = 'docstosupp';
1694: } elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) {
1695: $prefixchg{$suffix} = 'supptodocs';
1696: }
1.484.2.7 raeburn 1697:
1698: # If pasting an uploaded map, get list of contained uploaded maps.
1.484.2.30 raeburn 1699: if ($env{'docs.markedcopy_nested_'.$suffix}) {
1700: my @nested;
1701: my ($type) = ($oldprefix =~ /^(default|supplemental)/);
1702: my @items = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1703: my @deps = map { /\d+:([\d,]+$)/ } @items;
1704: foreach my $dep (@deps) {
1705: if ($dep =~ /,/) {
1706: push(@nested,split(/,/,$dep));
1707: } else {
1708: push(@nested,$dep);
1709: }
1.484.2.7 raeburn 1710: }
1.484.2.30 raeburn 1711: foreach my $item (@nested) {
1712: if ($env{'form.docs.markedcopy_'.$suffix.'_'.$item} eq 'move') {
1713: push(@{$marktomove{$suffix}},$type.'_'.$item);
1714: }
1.484.2.7 raeburn 1715: }
1716: }
1.329 droeschl 1717: }
1.484.2.7 raeburn 1718: }
1719:
1.484.2.30 raeburn 1720: # Early out if nothing available to paste
1721: if (@dopaste == 0) {
1722: return ();
1723: }
1724:
1725: # Populate message hash and hashes used for main content <=> supplemental content
1726: # changes
1727:
1728: %msgs = &Apache::lonlocal::texthash (
1729: notinsupp => 'Paste failed: content type is not supported within Supplemental Content',
1730: notincrs => 'Paste failed: Item is from a different course which you do not have rights to edit.',
1.484.2.72.2. (raeburn 1731:): notindom => 'Paste failed: Item is an external tool from a course in a different donain.',
1.484.2.30 raeburn 1732: duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.',
1733: );
1734:
1735: %before = (
1736: docstosupp => {
1737: map => 'default',
1738: doc => 'docs',
1739: },
1740: supptodocs => {
1741: map => 'supplemental',
1742: doc => 'supplemental',
1743: },
1744: );
1745:
1746: %after = (
1747: docstosupp => {
1748: map => 'supplemental',
1749: doc => 'supplemental'
1750: },
1751: supptodocs => {
1752: map => 'default',
1753: doc => 'docs',
1754: },
1755: );
1756:
1757: # Retrieve information about all course maps in main content area
1758:
1759: my $allmaps = {};
1760: if ($folder =~ /^default/) {
1761: $allmaps =
1762: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
1763: $env{"course.$env{'request.course.id'}.home"},
1764: $env{'request.course.id'});
1765: }
1766:
1767: my (@toclear,%mapurls,%lockerrs,%msgerrs,%results);
1768:
1769: # Loop over the items to paste
1770: foreach my $suffix (@dopaste) {
1.484.2.7 raeburn 1771: # Maps need to be copied first
1.484.2.30 raeburn 1772: my (%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies,
1773: %dbcopies,%zombies,%params,%docmoves,%mapmoves,%mapchanges,%newsubdir,
1774: %newurls,%tomove);
1775: if (ref($marktomove{$suffix}) eq 'ARRAY') {
1776: map { $tomove{$_} = 1; } @{$marktomove{$suffix}};
1777: }
1778: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1779: my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.484.2.72.2. (raeburn 1780:): my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.484.2.30 raeburn 1781: my $oldurl = $url;
1782: if ($is_map{$suffix}) {
1.484.2.7 raeburn 1783: # If pasting a map, check if map contains other maps
1.484.2.30 raeburn 1784: my (%hierarchy,%titles);
1.484.2.72.2. (raeburn 1785:): &contained_map_check($url,$folder,$coursenum,$coursedom,
1786:): \%removefrommap,\%removeparam,\%addedmaps,
1787:): \%hierarchy,\%titles,$allmaps);
1.484.2.30 raeburn 1788: if ($url=~ m{^/uploaded/}) {
1789: my $newurl;
1790: unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
1791: ($newurl,my $error) =
1792: &get_newmap_url($url,$folder,$prefixchg{$suffix},$coursedom,
1793: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1794: \$title,$allmaps,\%newurls);
1795: if ($error) {
1796: $allerrors{$suffix} = $error;
1797: next;
1798: }
1799: if ($newurl ne '') {
1800: if ($newurl ne $url) {
1801: if ($newurl =~ /(?:default|supplemental)_(\d+).(?:sequence|page)$/) {
1802: $newsubdir{$url} = $1;
1803: }
1804: $mapchanges{$url} = 1;
1.484.2.7 raeburn 1805: }
1806: }
1807: }
1.484.2.30 raeburn 1808: if (($srcdom{$suffix} ne $coursedom) ||
1809: ($srcnum{$suffix} ne $coursenum) ||
1810: ($prefixchg{$suffix}) || (($newurl ne '') && ($newurl ne $url))) {
1811: unless (&url_paste_fixups($url,$folder,$prefixchg{$suffix},
1812: $coursedom,$coursenum,$srcdom{$suffix},
1813: $srcnum{$suffix},$allmaps,\%rewrites,
1814: \%retitles,\%copies,\%dbcopies,
1815: \%zombies,\%params,\%mapmoves,
1816: \%mapchanges,\%tomove,\%newsubdir,
1817: \%newurls)) {
1818: $mapmoves{$url} = 1;
1819: }
1820: $url = $newurl;
1821: } elsif ($env{'docs.markedcopy_nested_'.$suffix}) {
1822: &url_paste_fixups($url,$folder,$prefixchg{$suffix},$coursedom,
1823: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1824: $allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies,
1825: \%zombies,\%params,\%mapmoves,\%mapchanges,
1826: \%tomove,\%newsubdir,\%newurls);
1827: }
1828: } elsif ($url=~m {^/res/}) {
1.484.2.72.2. (raeburn 1829:): # published map can only exist once, so remove from paste buffer when done
1.484.2.30 raeburn 1830: push(@toclear,$suffix);
1831: # if pasting published map (main content area only) check map not already in course
1832: if ($folder =~ /^default/) {
1833: if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) {
1834: $duplicate{$suffix} = 1;
1835: next;
1836: }
1.484.2.7 raeburn 1837: }
1838: }
1839: }
1.484.2.72.2. (raeburn 1840:): if ($url=~ m{/(ext\.tool)$}) {
1.484.2.30 raeburn 1841: my $prefix = $1;
1.484.2.72.2. (raeburn 1842:): my $fromothercrs;
1.484.2.30 raeburn 1843: #need to copy the db contents to a new one, unless this is a move.
1844: my %info = (
1845: src => $url,
1846: cdom => $coursedom,
1847: cnum => $coursenum,
1848: );
1.484.2.72.2. (raeburn 1849:): if (($srcdom{$suffix} =~ /^$match_domain$/) && ($srcnum{$suffix} =~ /^$match_courseid$/)) {
1850:): unless (($srcdom{$suffix} eq $coursedom) && ($srcnum{$suffix} eq $coursenum)) {
1851:): $fromothercrs = 1;
1852:): $info{'cdom'} = $srcdom{$suffix};
1853:): $info{'cnum'} = $srcnum{$suffix};
1854:): }
1855:): }
1856:): unless (($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') && (!$fromothercrs)) {
1.484.2.30 raeburn 1857: my (%lockerr,$msg);
1858: my ($newurl,$result,$errtext) =
1859: &dbcopy(\%info,$coursedom,$coursenum,\%lockerr);
1860: if ($result eq 'ok') {
1861: $url = $newurl;
1862: $title=&mt('Copy of').' '.$title;
1863: } else {
1.484.2.72.2. (raeburn 1864:): if ($prefix eq 'ext.tool') {
1865:): $msg = &mt('Paste failed: An error occurred when copying the external tool.').' '.$errtext;
1.484.2.30 raeburn 1866: }
1867: $results{$suffix} = $result;
1868: $msgerrs{$suffix} = $msg;
1869: $lockerrs{$suffix} = $lockerr{$prefix};
1870: next;
1871: }
1872: if ($lockerr{$prefix}) {
1873: $lockerrs{$suffix} = $lockerr{$prefix};
1.484.2.26 raeburn 1874: }
1.484.2.7 raeburn 1875: }
1.484.2.30 raeburn 1876: }
1877: $title = &LONCAPA::map::qtunescape($title);
1878: my $ext='false';
1879: if ($url=~m{^http(|s)://}) { $ext='true'; }
1880: if ($env{'docs.markedcopy_supplemental_'.$suffix}) {
1881: if ($folder !~ /^supplemental/) {
1882: (undef,undef,$title) =
1883: &Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental_'.$suffix});
1884: }
1885: } else {
1886: if ($folder=~/^supplemental/) {
1887: $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
1888: $env{'user.domain'}.'___&&&___'.$title;
1.484.2.26 raeburn 1889: }
1890: }
1.484.2.7 raeburn 1891:
1892: # For uploaded files (excluding pages/sequences) path in copied file is changed
1893: # if paste is from Main to Supplemental (or vice versa), or if pasting between
1894: # courses.
1895:
1.484.2.30 raeburn 1896: unless ($is_map{$suffix}) {
1897: my $newidx;
1.329 droeschl 1898: # Now insert the URL at the bottom
1.484.2.30 raeburn 1899: $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
1900: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(.+)$}) {
1901: my $relpath = $1;
1902: if ($relpath ne '') {
1903: my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$});
1904: my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/);
1905: my $newprefix = $newloc;
1906: if ($newloc eq 'default') {
1907: $newprefix = 'docs';
1908: }
1909: if ($newdocsdir eq '') {
1910: $newdocsdir = 'default';
1911: }
1912: if (($prefixchg{$suffix}) ||
1913: ($srcdom{$suffix} ne $coursedom) ||
1914: ($srcnum{$suffix} ne $coursenum) ||
1915: ($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) {
1916: my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";
1917: $url =
1918: &Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath,
1919: &Apache::lonnet::getfile($oldurl));
1920: if ($url eq '/adm/notfound.html') {
1921: $msgs{$suffix} = &mt('Paste failed: an error occurred saving the file.');
1922: next;
1923: } else {
1924: my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$});
1925: $newsubpath =~ s{/+$}{/};
1926: $docmoves{$oldurl} = $newsubpath;
1927: }
1.484.2.7 raeburn 1928: }
1929: }
1930: }
1.484.2.30 raeburn 1931: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
1932: ':'.$ext.':normal:res';
1933: push(@LONCAPA::map::order,$newidx);
1934: # Store the result
1935: my ($errtext,$fatal) =
1936: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1937: if ($fatal) {
1938: $save_err .= $errtext;
1939: $allresult = 'fail';
1.484.2.7 raeburn 1940: }
1.329 droeschl 1941: }
1.484.2.30 raeburn 1942:
1943: # Apply any changes to maps, or copy dependencies for uploaded HTML pages
1944: unless ($allresult eq 'fail') {
1945: my %updated = (
1946: rewrites => \%rewrites,
1947: zombies => \%zombies,
1948: removefrommap => \%removefrommap,
1949: removeparam => \%removeparam,
1950: dbcopies => \%dbcopies,
1951: retitles => \%retitles,
1952: );
1953: my %info = (
1954: newsubdir => \%newsubdir,
1955: params => \%params,
1956: );
1957: if ($prefixchg{$suffix}) {
1958: $info{'before'} = $before{$prefixchg{$suffix}};
1959: $info{'after'} = $after{$prefixchg{$suffix}};
1960: }
1961: my %moves = (
1962: copies => \%copies,
1963: docmoves => \%docmoves,
1964: mapmoves => \%mapmoves,
1965: );
1966: (my $result,$msgs{$suffix},my $lockerror) =
1967: &apply_fixups($folder,$is_map{$suffix},$coursedom,$coursenum,$errors,
1968: \%updated,\%info,\%moves,$prefixchg{$suffix},$oldurl,
1969: $url,'paste');
1970: $lockerrors .= $lockerror;
1971: if ($result eq 'ok') {
1972: if ($is_map{$suffix}) {
1973: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1974: $folder.'.'.$container);
1975: if ($fatal) {
1976: $allresult = 'failread';
1977: } else {
1978: if ($#LONCAPA::map::order<1) {
1979: my $idx=&LONCAPA::map::getresidx();
1980: if ($idx<=0) { $idx=1; }
1981: $LONCAPA::map::order[0]=$idx;
1982: $LONCAPA::map::resources[$idx]='';
1983: }
1984: my $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
1985: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
1986: ':'.$ext.':normal:res';
1987: push(@LONCAPA::map::order,$newidx);
1.484.2.7 raeburn 1988:
1989: # Store the result
1.484.2.30 raeburn 1990: my ($errtext,$fatal) =
1991: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1992: if ($fatal) {
1993: $save_err .= $errtext;
1994: $allresult = 'failstore';
1995: }
1996: }
1997: }
1998: if ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
1999: push(@toclear,$suffix);
2000: }
2001: }
1.329 droeschl 2002: }
2003: }
1.484.2.30 raeburn 2004: &clear_from_buffer(\@toclear,\@currpaste);
2005: my $msgsarray;
2006: foreach my $suffix (keys(%msgs)) {
2007: if (ref($msgs{$suffix}) eq 'ARRAY') {
2008: $msgsarray .= join(',',@{$msgs{$suffix}});
2009: }
2010: }
2011: return ($allresult,$save_err,$msgsarray,$lockerrors);
2012: }
2013:
2014: sub do_buffer_empty {
2015: my @currpaste = split(/,/,$env{'docs.markedcopies'});
2016: if (@currpaste == 0) {
2017: return &mt('Clipboard is already empty');
2018: }
2019: my @toclear = &Apache::loncommon::get_env_multiple('form.pasting');
2020: if (@toclear == 0) {
2021: return &mt('Nothing selected to clear from clipboard');
2022: }
2023: my $numdel = &clear_from_buffer(\@toclear,\@currpaste);
2024: if ($numdel) {
2025: return &mt('[quant,_1,item] cleared from clipboard',$numdel);
2026: } else {
2027: return &mt('Clipboard unchanged');
1.484.2.7 raeburn 2028: }
1.484.2.30 raeburn 2029: return;
2030: }
2031:
2032: sub clear_from_buffer {
2033: my ($toclear,$currpaste) = @_;
2034: return unless ((ref($toclear) eq 'ARRAY') && (ref($currpaste) eq 'ARRAY'));
2035: my %pastebuffer;
2036: map { $pastebuffer{$_} = 1; } @{$currpaste};
2037: my $numdel = 0;
2038: foreach my $suffix (@{$toclear}) {
2039: next if ($suffix =~ /\D/);
2040: next unless (exists($pastebuffer{$suffix}));
2041: my $regexp = 'docs.markedcopy_[a-z]+_'.$suffix;
2042: if (&Apache::lonnet::delenv($regexp,1) eq 'ok') {
2043: delete($pastebuffer{$suffix});
2044: $numdel ++;
2045: }
2046: }
2047: my $newbuffer = join(',',sort(keys(%pastebuffer)));
2048: &Apache::lonnet::appenv({'docs.markedcopies' => $newbuffer});
2049: return $numdel;
1.484.2.7 raeburn 2050: }
2051:
2052: sub get_newmap_url {
2053: my ($url,$folder,$prefixchg,$coursedom,$coursenum,$srcdom,$srcnum,
2054: $titleref,$allmaps,$newurls) = @_;
2055: my $newurl;
2056: if ($url=~ m{^/uploaded/}) {
2057: $$titleref=&mt('Copy of').' '.$$titleref;
2058: }
2059: my $now = time;
2060: my $suffix=$$.int(rand(100)).$now;
2061: my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
2062: if ($oldid =~ m{^(/uploaded/$match_domain/$match_courseid/)(\D+)(\d+)$}) {
2063: my $path = $1;
2064: my $prefix = $2;
2065: my $ancestor = $3;
2066: if (length($ancestor) > 10) {
2067: $ancestor = substr($ancestor,-10,10);
2068: }
2069: my $newid;
2070: if ($prefixchg) {
2071: if ($folder =~ /^supplemental/) {
2072: $prefix =~ s/^default/supplemental/;
2073: } else {
2074: $prefix =~ s/^supplemental/default/;
2075: }
2076: }
2077: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
2078: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
2079: } else {
2080: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$now.'.'.$ext;
2081: }
2082: my $counter = 0;
2083: my $is_unique = &uniqueness_check($newurl);
2084: if ($folder =~ /^default/) {
2085: if ($allmaps->{$newurl}) {
2086: $is_unique = 0;
2087: }
2088: }
2089: while ((!$is_unique || $allmaps->{$newurl} || $newurls->{$newurl}) && ($counter < 100)) {
2090: $counter ++;
2091: $suffix ++;
2092: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
2093: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
2094: } else {
2095: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$ancestor.$suffix.'.'.$ext;
2096: }
2097: $is_unique = &uniqueness_check($newurl);
2098: }
2099: if ($is_unique) {
2100: $newurls->{$newurl} = 1;
2101: } else {
2102: if ($url=~/\.page$/) {
2103: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the composite page'));
2104: } else {
2105: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the folder'));
2106: }
2107: }
2108: }
2109: return ($newurl);
2110: }
2111:
2112: sub dbcopy {
1.484.2.26 raeburn 2113: my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_;
2114: my ($url,$result,$errtext);
2115: if (ref($dbref) eq 'HASH') {
1.484.2.71 raeburn 2116: $url = $dbref->{'src'};
1.484.2.72.2. (raeburn 2117:): if ($url =~ m{/(smppg|bulletinboard|ext\.tool)$}) {
1.484.2.26 raeburn 2118: my $prefix = $1;
1.484.2.72.2. (raeburn 2119:): if ($prefix eq 'ext.tool') {
2120:): $prefix = 'exttool';
2121:): }
1.484.2.26 raeburn 2122: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2123: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2124: my $db_name;
2125: my $marker = (split(m{/},$url))[4];
2126: $marker=~s/\D//g;
2127: if ($dbref->{'src'} =~ m{/smppg$}) {
2128: $db_name =
2129: &Apache::lonsimplepage::get_db_name($url,$marker,
2130: $dbref->{'cdom'},
2131: $dbref->{'cnum'});
1.484.2.72.2. (raeburn 2132:): } elsif ($dbref->{'src'} =~ m{/ext\.tool$}) {
2133:): $db_name = 'exttool_'.$marker;
1.484.2.26 raeburn 2134: } else {
2135: $db_name = 'bulletinpage_'.$marker;
2136: }
2137: my ($suffix,$freedlock,$error) =
2138: &Apache::lonnet::get_timebased_id($prefix,'num','templated',
2139: $coursedom,$coursenum,
2140: 'concat');
2141: if (!$suffix) {
2142: if ($prefix eq 'smppg') {
2143: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);
1.484.2.72.2. (raeburn 2144:): } elsif ($prefix eq 'exttool') {
2145:): $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying an external tool [_1].',$url);
1.484.2.26 raeburn 2146: } else {
1.484.2.42 raeburn 2147: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url);
1.484.2.26 raeburn 2148: }
2149: if ($error) {
2150: $errtext .= '<br />'.$error;
2151: }
2152: } else {
2153: #need to copy the db contents to a new one.
2154: my %contents=&Apache::lonnet::dump($db_name,
2155: $dbref->{'cdom'},
2156: $dbref->{'cnum'});
2157: if (exists($contents{'uploaded.photourl'})) {
2158: my $photo = $contents{'uploaded.photourl'};
2159: my ($subdir,$fname) =
2160: ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});
2161: my $newphoto;
2162: if ($fname ne '') {
2163: my $content = &Apache::lonnet::getfile($photo);
2164: unless ($content eq '-1') {
2165: $env{'form.'.$suffix.'.photourl'} = $content;
2166: $newphoto =
2167: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");
2168: delete($env{'form.'.$suffix.'.photourl'});
2169: }
2170: }
2171: if ($newphoto =~ m{^/uploaded/}) {
2172: $contents{'uploaded.photourl'} = $newphoto;
2173: }
2174: }
2175: $db_name =~ s{_\d*$ }{_$suffix}x;
2176: $result=&Apache::lonnet::put($db_name,\%contents,
2177: $coursedom,$coursenum);
2178: if ($result eq 'ok') {
1.484.2.72.2. (raeburn 2179:): $url =~ s{/(\d*)/(smppg|bulletinboard|ext\.tool)$}{/$suffix/$2}x;
1.484.2.26 raeburn 2180: }
2181: }
2182: if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) {
2183: $lockerrorsref->{$prefix} =
2184: '<div class="LC_error">'.
2185: &mt('There was a problem removing a lockfile.');
2186: if ($prefix eq 'smppg') {
2187: $lockerrorsref->{$prefix} .=
1.484.2.38 raeburn 2188: ' '.&mt('This will prevent creation of additional simple pages in this course.');
1.484.2.72.2. (raeburn 2189:): } elsif ($prefix eq 'exttool') {
2190:): $lockerrorsref->{$prefix} .=
2191:): ' '.&mt('This will prevent addition of more external tools to this course.');
1.484.2.26 raeburn 2192: } else {
1.484.2.42 raeburn 2193: $lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional discussion boards in this course.');
1.484.2.26 raeburn 2194: }
1.484.2.38 raeburn 2195: $lockerrorsref->{$prefix} .= ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
2196: '<a href="/adm/helpdesk" target="_helpdesk">','</a>').
2197: '</div>';
1.484.2.26 raeburn 2198: }
2199: }
2200: } elsif ($url =~ m{/syllabus$}) {
2201: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2202: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2203: if (($dbref->{'cdom'} ne $coursedom) ||
2204: ($dbref->{'cnum'} ne $coursenum)) {
2205: my %contents=&Apache::lonnet::dump('syllabus',
2206: $dbref->{'cdom'},
2207: $dbref->{'cnum'});
2208: $result=&Apache::lonnet::put('syllabus',\%contents,
2209: $coursedom,$coursenum);
2210: }
2211: }
1.484.2.7 raeburn 2212: }
2213: }
1.484.2.26 raeburn 2214: return ($url,$result,$errtext);
1.329 droeschl 2215: }
2216:
2217: sub uniqueness_check {
2218: my ($newurl) = @_;
2219: my $unique = 1;
2220: foreach my $res (@LONCAPA::map::order) {
2221: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2222: $url=&LONCAPA::map::qtescape($url);
2223: if ($newurl eq $url) {
2224: $unique = 0;
1.344 bisitz 2225: last;
1.329 droeschl 2226: }
2227: }
2228: return $unique;
2229: }
2230:
1.484.2.7 raeburn 2231: sub contained_map_check {
1.484.2.72.2. (raeburn 2232:): my ($url,$folder,$coursenum,$coursedom,$removefrommap,$removeparam,$addedmaps,
2233:): $hierarchy,$titles,$allmaps) = @_;
1.484.2.7 raeburn 2234: my $content = &Apache::lonnet::getfile($url);
2235: unless ($content eq '-1') {
2236: my $parser = HTML::TokeParser->new(\$content);
2237: $parser->attr_encoded(1);
2238: while (my $token = $parser->get_token) {
2239: next if ($token->[0] ne 'S');
2240: if ($token->[1] eq 'resource') {
2241: next if ($token->[2]->{'type'} eq 'zombie');
2242: my $ressrc = $token->[2]->{'src'};
2243: if ($folder =~ /^supplemental/) {
2244: unless (&supp_pasteable($ressrc)) {
2245: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2246: next;
2247: }
2248: }
2249: if ($ressrc =~ m{^/(res|uploaded)/.+\.(sequence|page)$}) {
2250: if ($1 eq 'uploaded') {
2251: $hierarchy->{$url}{$token->[2]->{'id'}} = $ressrc;
2252: $titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'};
2253: } else {
2254: if ($allmaps->{$ressrc}) {
1.484.2.23 raeburn 2255: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.484.2.7 raeburn 2256: } elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') {
2257: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2258: } else {
2259: $addedmaps->{$ressrc} = [$url];
2260: }
2261: }
1.484.2.72.2. (raeburn 2262:): &contained_map_check($ressrc,$folder,$coursenum,$coursedom,
2263:): $removefrommap,$removeparam,
1.484.2.7 raeburn 2264: $addedmaps,$hierarchy,$titles,$allmaps);
2265: }
2266: } elsif ($token->[1] eq 'param') {
2267: if ($folder =~ /^supplemental/) {
2268: if (ref($removeparam->{$url}{$token->[2]->{'to'}}) eq 'ARRAY') {
2269: push(@{$removeparam->{$url}{$token->[2]->{'to'}}},$token->[2]->{'name'});
2270: } else {
1.484.2.19 raeburn 2271: $removeparam->{$url}{$token->[2]->{'to'}} = [$token->[2]->{'name'}];
1.484.2.7 raeburn 2272: }
2273: }
2274: }
2275: }
2276: }
2277: return;
2278: }
2279:
2280: sub url_paste_fixups {
1.484.2.26 raeburn 2281: my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$fromcdom,$fromcnum,$allmaps,
2282: $rewrites,$retitles,$copies,$dbcopies,$zombies,$params,$mapmoves,
2283: $mapchanges,$tomove,$newsubdir,$newurls) = @_;
1.484.2.7 raeburn 2284: my $checktitle;
2285: if (($prefixchg) &&
2286: ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) {
2287: $checktitle = 1;
2288: }
2289: my $skip;
2290: if ($oldurl =~ m{^\Q/uploaded/$cdom/$cnum/\E(default|supplemental)(_?\d*)\.(?:page|sequence)$}) {
2291: my $mapid = $1.$2;
2292: if ($tomove->{$mapid}) {
2293: $skip = 1;
2294: }
2295: }
2296: my $file = &Apache::lonnet::getfile($oldurl);
2297: return if ($file eq '-1');
2298: my $parser = HTML::TokeParser->new(\$file);
2299: $parser->attr_encoded(1);
2300: my $changed = 0;
2301: while (my $token = $parser->get_token) {
2302: next if ($token->[0] ne 'S');
2303: if ($token->[1] eq 'resource') {
2304: my $ressrc = $token->[2]->{'src'};
2305: next if ($ressrc eq '');
2306: my $id = $token->[2]->{'id'};
2307: my $title = $token->[2]->{'title'};
2308: if ($checktitle) {
2309: if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1.484.2.25 raeburn 2310: $retitles->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2311: }
2312: }
2313: next if ($token->[2]->{'type'} eq 'external');
2314: if ($token->[2]->{'type'} eq 'zombie') {
1.484.2.30 raeburn 2315: next if ($skip);
1.484.2.25 raeburn 2316: $zombies->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2317: $changed = 1;
2318: } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
2319: my $srcdom = $1;
2320: my $srcnum = $2;
2321: my $rem = $3;
2322: my $newurl;
2323: my $mapname;
2324: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
2325: my $prefix = $1;
2326: $mapname = $prefix.$2;
2327: if ($tomove->{$mapname}) {
1.484.2.26 raeburn 2328: &url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,
2329: $srcdom,$srcnum,$allmaps,$rewrites,
2330: $retitles,$copies,$dbcopies,$zombies,
2331: $params,$mapmoves,$mapchanges,$tomove,
2332: $newsubdir,$newurls);
1.484.2.7 raeburn 2333: next;
2334: } else {
2335: ($newurl,my $error) =
2336: &get_newmap_url($ressrc,$folder,$prefixchg,$cdom,$cnum,
2337: $srcdom,$srcnum,\$title,$allmaps,$newurls);
2338: if ($newurl =~ /(?:default|supplemental)_(\d+)\.(?:sequence|page)$/) {
2339: $newsubdir->{$ressrc} = $1;
2340: }
2341: if ($error) {
2342: next;
2343: }
2344: }
2345: }
2346: if (($srcdom ne $cdom) || ($srcnum ne $cnum) || ($prefixchg) ||
2347: ($mapchanges->{$oldurl}) || (($newurl ne '') && ($newurl ne $oldurl))) {
1.484.2.19 raeburn 2348:
1.484.2.7 raeburn 2349: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
1.484.2.25 raeburn 2350: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2351: $mapchanges->{$ressrc} = 1;
1.484.2.26 raeburn 2352: unless (&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,
2353: $cnum,$srcdom,$srcnum,$allmaps,
2354: $rewrites,$retitles,$copies,$dbcopies,
2355: $zombies,$params,$mapmoves,$mapchanges,
2356: $tomove,$newsubdir,$newurls)) {
1.484.2.7 raeburn 2357: $mapmoves->{$ressrc} = 1;
2358: }
2359: $changed = 1;
2360: } else {
1.484.2.25 raeburn 2361: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2362: $copies->{$oldurl}{$ressrc} = $id;
2363: $changed = 1;
2364: }
2365: }
1.484.2.26 raeburn 2366: } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/.+$}) {
1.484.2.30 raeburn 2367: next if ($skip);
1.484.2.7 raeburn 2368: my $srcdom = $1;
2369: my $srcnum = $2;
2370: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.484.2.25 raeburn 2371: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.26 raeburn 2372: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2373: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2374: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
2375: $changed = 1;
2376: }
2377: } elsif ($ressrc =~ m{^/adm/$match_domain/$match_username/\d+/(smppg|bulletinboard)$}) {
2378: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum) ||
2379: ($env{'form.docs.markedcopy_options'} ne 'move')) {
2380: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2381: $dbcopies->{$oldurl}{$id}{'cdom'} = $fromcdom;
2382: $dbcopies->{$oldurl}{$id}{'cnum'} = $fromcnum;
1.484.2.7 raeburn 2383: $changed = 1;
2384: }
2385: } elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) {
2386: next if ($skip);
2387: my $srcdom = $1;
2388: my $srcnum = $2;
2389: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.484.2.26 raeburn 2390: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2391: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2392: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
1.484.2.7 raeburn 2393: $changed = 1;
2394: }
2395: }
2396: } elsif ($token->[1] eq 'param') {
2397: next if ($skip);
1.484.2.19 raeburn 2398: my $to = $token->[2]->{'to'};
1.484.2.7 raeburn 2399: if ($to ne '') {
2400: if (ref($params->{$oldurl}{$to}) eq 'ARRAY') {
2401: push(@{$params->{$oldurl}{$to}},$token->[2]->{'name'});
2402: } else {
2403: @{$params->{$oldurl}{$to}} = ($token->[2]->{'name'});
2404: }
2405: }
2406: }
2407: }
2408: return $changed;
2409: }
2410:
2411: sub apply_fixups {
1.484.2.23 raeburn 2412: my ($folder,$is_map,$cdom,$cnum,$errors,$updated,$info,$moves,$prefixchg,
2413: $oldurl,$url,$caller) = @_;
2414: my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles,
1.484.2.26 raeburn 2415: %params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs,
2416: %lockerrors,$lockmsg);
1.484.2.23 raeburn 2417: if (ref($updated) eq 'HASH') {
2418: if (ref($updated->{'rewrites'}) eq 'HASH') {
2419: %rewrites = %{$updated->{'rewrites'}};
2420: }
2421: if (ref($updated->{'zombies'}) eq 'HASH') {
2422: %zombies = %{$updated->{'zombies'}};
2423: }
2424: if (ref($updated->{'removefrommap'}) eq 'HASH') {
2425: %removefrommap = %{$updated->{'removefrommap'}};
2426: }
2427: if (ref($updated->{'removeparam'}) eq 'HASH') {
2428: %removeparam = %{$updated->{'removeparam'}};
2429: }
2430: if (ref($updated->{'dbcopies'}) eq 'HASH') {
2431: %dbcopies = %{$updated->{'dbcopies'}};
2432: }
2433: if (ref($updated->{'retitles'}) eq 'HASH') {
2434: %retitles = %{$updated->{'retitles'}};
2435: }
2436: }
2437: if (ref($info) eq 'HASH') {
2438: if (ref($info->{'newsubdir'}) eq 'HASH') {
2439: %newsubdir = %{$info->{'newsubdir'}};
2440: }
2441: if (ref($info->{'params'}) eq 'HASH') {
2442: %params = %{$info->{'params'}};
2443: }
2444: if (ref($info->{'before'}) eq 'HASH') {
2445: %before = %{$info->{'before'}};
2446: }
2447: if (ref($info->{'after'}) eq 'HASH') {
2448: %after = %{$info->{'after'}};
2449: }
2450: }
2451: if (ref($moves) eq 'HASH') {
2452: if (ref($moves->{'copies'}) eq 'HASH') {
2453: %copies = %{$moves->{'copies'}};
2454: }
2455: if (ref($moves->{'docmoves'}) eq 'HASH') {
2456: %docmoves = %{$moves->{'docmoves'}};
2457: }
2458: if (ref($moves->{'mapmoves'}) eq 'HASH') {
2459: %mapmoves = %{$moves->{'mapmoves'}};
2460: }
2461: }
2462: foreach my $key (keys(%copies),keys(%docmoves)) {
1.484.2.7 raeburn 2463: my @allcopies;
1.484.2.23 raeburn 2464: if (exists($copies{$key})) {
2465: if (ref($copies{$key}) eq 'HASH') {
2466: my %added;
2467: foreach my $innerkey (keys(%{$copies{$key}})) {
2468: if (($innerkey ne '') && (!$added{$innerkey})) {
2469: push(@allcopies,$innerkey);
2470: $added{$innerkey} = 1;
2471: }
1.484.2.7 raeburn 2472: }
1.484.2.23 raeburn 2473: undef(%added);
1.484.2.7 raeburn 2474: }
2475: }
2476: if ($key eq $oldurl) {
1.484.2.23 raeburn 2477: if ((exists($docmoves{$key}))) {
1.484.2.25 raeburn 2478: unless (grep(/^\Q$oldurl\E$/,@allcopies)) {
1.484.2.7 raeburn 2479: push(@allcopies,$oldurl);
2480: }
2481: }
2482: }
2483: if (@allcopies > 0) {
2484: foreach my $item (@allcopies) {
1.484.2.19 raeburn 2485: my ($relpath,$oldsubdir,$fname) =
1.484.2.7 raeburn 2486: ($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(default|\d+)/.*/)([^/]+)$});
2487: if ($fname ne '') {
2488: my $content = &Apache::lonnet::getfile($item);
2489: unless ($content eq '-1') {
2490: my $storefn;
1.484.2.23 raeburn 2491: if (($key eq $oldurl) && (exists($docmoves{$key}))) {
2492: $storefn = $docmoves{$key};
1.484.2.7 raeburn 2493: } else {
2494: $storefn = $relpath;
2495: $storefn =~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 2496: if ($prefixchg && $before{'doc'} && $after{'doc'}) {
2497: $storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/;
1.484.2.7 raeburn 2498: }
1.484.2.23 raeburn 2499: if ($newsubdir{$key}) {
1.484.2.25 raeburn 2500: $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}/#;
1.484.2.7 raeburn 2501: }
2502: }
2503: ©_dependencies($item,$storefn,$relpath,$errors,\$content);
1.484.2.19 raeburn 2504: my $copyurl =
1.484.2.7 raeburn 2505: &Apache::lonclonecourse::writefile($env{'request.course.id'},
2506: $storefn.$fname,$content);
2507: if ($copyurl eq '/adm/notfound.html') {
1.484.2.23 raeburn 2508: if (exists($docmoves{$oldurl})) {
1.484.2.7 raeburn 2509: return &mt('Paste failed: an error occurred copying the file.');
2510: } elsif (ref($errors) eq 'HASH') {
2511: $errors->{$item} = 1;
2512: }
2513: }
2514: }
2515: }
2516: }
2517: }
2518: }
1.484.2.23 raeburn 2519: foreach my $key (keys(%mapmoves)) {
1.484.2.7 raeburn 2520: my $storefn=$key;
2521: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 2522: if ($prefixchg && $before{'map'} && $after{'map'}) {
2523: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.484.2.7 raeburn 2524: }
1.484.2.23 raeburn 2525: if ($newsubdir{$key}) {
2526: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.484.2.7 raeburn 2527: }
2528: my $mapcontent = &Apache::lonnet::getfile($key);
2529: if ($mapcontent eq '-1') {
2530: if (ref($errors) eq 'HASH') {
2531: $errors->{$key} = 1;
2532: }
2533: } else {
2534: my $newmap =
2535: &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
2536: $mapcontent);
2537: if ($newmap eq '/adm/notfound.html') {
2538: if (ref($errors) eq 'HASH') {
2539: $errors->{$key} = 1;
2540: }
2541: }
2542: }
2543: }
2544: my %updates;
2545: if ($is_map) {
1.484.2.23 raeburn 2546: if (ref($updated) eq 'HASH') {
2547: foreach my $type (keys(%{$updated})) {
2548: if (ref($updated->{$type}) eq 'HASH') {
2549: foreach my $key (keys(%{$updated->{$type}})) {
2550: $updates{$key} = 1;
2551: }
2552: }
2553: }
1.484.2.7 raeburn 2554: }
2555: foreach my $key (keys(%updates)) {
2556: my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb);
1.484.2.23 raeburn 2557: if (ref($rewrites{$key}) eq 'HASH') {
2558: %torewrite = %{$rewrites{$key}};
1.484.2.7 raeburn 2559: }
1.484.2.23 raeburn 2560: if (ref($retitles{$key}) eq 'HASH') {
2561: %toretitle = %{$retitles{$key}};
1.484.2.7 raeburn 2562: }
1.484.2.23 raeburn 2563: if (ref($removefrommap{$key}) eq 'HASH') {
2564: %toremove = %{$removefrommap{$key}};
1.484.2.7 raeburn 2565: }
1.484.2.23 raeburn 2566: if (ref($removeparam{$key}) eq 'HASH') {
2567: %remparam = %{$removeparam{$key}};
1.484.2.7 raeburn 2568: }
1.484.2.23 raeburn 2569: if (ref($zombies{$key}) eq 'HASH') {
2570: %zombie = %{$zombies{$key}};
1.484.2.7 raeburn 2571: }
1.484.2.23 raeburn 2572: if (ref($dbcopies{$key}) eq 'HASH') {
1.484.2.26 raeburn 2573: foreach my $idx (keys(%{$dbcopies{$key}})) {
2574: if (ref($dbcopies{$key}{$idx}) eq 'HASH') {
2575: my ($newurl,$result,$errtext) =
2576: &dbcopy($dbcopies{$key}{$idx},$cdom,$cnum,\%lockerrors);
2577: if ($result eq 'ok') {
2578: $newdb{$idx} = $newurl;
2579: } elsif (ref($errors) eq 'HASH') {
2580: $errors->{$key} = 1;
2581: }
2582: push(@msgs,$errtext);
2583: }
1.484.2.7 raeburn 2584: }
2585: }
1.484.2.23 raeburn 2586: if (ref($params{$key}) eq 'HASH') {
2587: %currparam = %{$params{$key}};
1.484.2.7 raeburn 2588: }
2589: my ($errtext,$fatal) = &LONCAPA::map::mapread($key);
2590: if ($fatal) {
1.484.2.26 raeburn 2591: return ($errtext);
1.484.2.7 raeburn 2592: }
2593: for (my $i=0; $i<@LONCAPA::map::zombies; $i++) {
2594: if (defined($LONCAPA::map::zombies[$i])) {
2595: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::zombies[$i]);
1.484.2.25 raeburn 2596: if ($zombie{$i} eq $src) {
1.484.2.7 raeburn 2597: undef($LONCAPA::map::zombies[$i]);
2598: }
2599: }
2600: }
1.484.2.23 raeburn 2601: for (my $i=0; $i<@LONCAPA::map::order; $i++) {
2602: my $idx = $LONCAPA::map::order[$i];
2603: if (defined($LONCAPA::map::resources[$idx])) {
1.484.2.7 raeburn 2604: my $changed;
1.484.2.23 raeburn 2605: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]);
1.484.2.30 raeburn 2606: if ((exists($toremove{$idx})) &&
2607: ($toremove{$idx} eq &LONCAPA::map::qtescape($src))) {
1.484.2.7 raeburn 2608: splice(@LONCAPA::map::order,$i,1);
1.484.2.23 raeburn 2609: if (ref($currparam{$idx}) eq 'ARRAY') {
2610: foreach my $name (@{$currparam{$idx}}) {
2611: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
1.484.2.7 raeburn 2612: }
2613: }
2614: next;
2615: }
2616: my $origsrc = $src;
1.484.2.25 raeburn 2617: if ((exists($toretitle{$idx})) && ($toretitle{$idx} eq $src)) {
1.484.2.7 raeburn 2618: if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
2619: $changed = 1;
2620: }
2621: }
1.484.2.25 raeburn 2622: if ((exists($torewrite{$idx})) && ($torewrite{$idx} eq $src)) {
1.484.2.7 raeburn 2623: $src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
2624: if ($origsrc =~ m{^/uploaded/}) {
1.484.2.23 raeburn 2625: if ($prefixchg && $before{'map'} && $after{'map'}) {
1.484.2.7 raeburn 2626: if ($src =~ /\.(page|sequence)$/) {
1.484.2.23 raeburn 2627: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'map'}\E#$1$after{'map'}#;
1.484.2.7 raeburn 2628: } else {
1.484.2.23 raeburn 2629: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
1.484.2.7 raeburn 2630: }
2631: }
1.484.2.25 raeburn 2632: if ($origsrc =~ /\.(page|sequence)$/) {
2633: if ($newsubdir{$origsrc}) {
1.484.2.23 raeburn 2634: $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir{$origsrc}#;
1.484.2.7 raeburn 2635: }
1.484.2.25 raeburn 2636: } elsif ($newsubdir{$key}) {
2637: $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$key}#;
1.484.2.7 raeburn 2638: }
2639: }
2640: $changed = 1;
1.484.2.26 raeburn 2641: } elsif ($newdb{$idx} ne '') {
2642: $src = $newdb{$idx};
1.484.2.7 raeburn 2643: $changed = 1;
2644: }
2645: if ($changed) {
1.484.2.30 raeburn 2646: $LONCAPA::map::resources[$idx] = join(':',($title,&LONCAPA::map::qtunescape($src),$ext,$type));
1.484.2.7 raeburn 2647: }
2648: }
2649: }
2650: foreach my $idx (keys(%remparam)) {
2651: if (ref($remparam{$idx}) eq 'ARRAY') {
1.484.2.19 raeburn 2652: foreach my $name (@{$remparam{$idx}}) {
1.484.2.7 raeburn 2653: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
2654: }
2655: }
2656: }
1.484.2.26 raeburn 2657: if (values(%lockerrors) > 0) {
2658: $lockmsg = join('<br />',values(%lockerrors));
2659: }
1.484.2.7 raeburn 2660: my $storefn;
2661: if ($key eq $oldurl) {
2662: $storefn = $url;
2663: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
2664: } else {
2665: $storefn = $key;
2666: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 2667: if ($prefixchg && $before{'map'} && $after{'map'}) {
2668: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.484.2.7 raeburn 2669: }
1.484.2.23 raeburn 2670: if ($newsubdir{$key}) {
2671: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.484.2.7 raeburn 2672: }
2673: }
2674: my $report;
2675: if ($folder !~ /^supplemental/) {
2676: $report = 1;
2677: }
1.484.2.20 raeburn 2678: (my $outtext,$errtext) =
1.484.2.7 raeburn 2679: &LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report);
2680: if ($errtext) {
1.484.2.23 raeburn 2681: if ($caller eq 'paste') {
1.484.2.26 raeburn 2682: return (&mt('Paste failed: an error occurred saving the folder or page.'));
1.484.2.23 raeburn 2683: }
1.484.2.7 raeburn 2684: }
2685: }
2686: }
1.484.2.26 raeburn 2687: return ('ok',\@msgs,$lockmsg);
1.484.2.7 raeburn 2688: }
2689:
2690: sub copy_dependencies {
2691: my ($item,$storefn,$relpath,$errors,$contentref) = @_;
2692: my $content;
2693: if (ref($contentref)) {
2694: $content = $$contentref;
2695: } else {
2696: $content = &Apache::lonnet::getfile($item);
2697: }
2698: unless ($content eq '-1') {
2699: my $mm = new File::MMagic;
2700: my $mimetype = $mm->checktype_contents($content);
2701: if ($mimetype eq 'text/html') {
2702: my (%allfiles,%codebase,$state);
2703: my $res = &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,\$content);
2704: if ($res eq 'ok') {
2705: my ($numexisting,$numpathchanges,$existing);
2706: (undef,$numexisting,$numpathchanges,$existing) =
2707: &Apache::loncommon::ask_for_embedded_content(
2708: '/adm/coursedocs',$state,\%allfiles,\%codebase,
2709: {'error_on_invalid_names' => 1,
2710: 'ignore_remote_references' => 1,
2711: 'docs_url' => $item,
2712: 'context' => 'paste'});
2713: if ($numexisting > 0) {
2714: if (ref($existing) eq 'HASH') {
2715: foreach my $dep (keys(%{$existing})) {
2716: my $depfile = $dep;
2717: unless ($depfile =~ m{^\Q$relpath\E}) {
2718: $depfile = $relpath.$dep;
2719: }
2720: my $depcontent = &Apache::lonnet::getfile($depfile);
2721: unless ($depcontent eq '-1') {
2722: my $storedep = $dep;
2723: $storedep =~ s{^\Q$relpath\E}{};
2724: my $dep_url =
2725: &Apache::lonclonecourse::writefile(
2726: $env{'request.course.id'},
2727: $storefn.$storedep,$depcontent);
2728: if ($dep_url eq '/adm/notfound.html') {
2729: if (ref($errors) eq 'HASH') {
2730: $errors->{$depfile} = 1;
2731: }
2732: } else {
2733: ©_dependencies($depfile,$storefn,$relpath,$errors,\$depcontent);
2734: }
2735: }
2736: }
2737: }
2738: }
2739: }
2740: }
2741: }
2742: return;
2743: }
2744:
1.329 droeschl 2745: my %parameter_type = ( 'randompick' => 'int_pos',
2746: 'hiddenresource' => 'string_yesno',
2747: 'encrypturl' => 'string_yesno',
2748: 'randomorder' => 'string_yesno',);
2749: my $valid_parameters_re = join('|',keys(%parameter_type));
2750: # set parameters
2751: sub update_parameter {
1.484.2.29 raeburn 2752: if ($env{'form.changeparms'} eq 'all') {
2753: my (@allidx,@allmapidx,%allchecked,%currchecked);
2754: %allchecked = (
2755: 'hiddenresource' => {},
2756: 'encrypturl' => {},
2757: 'randompick' => {},
2758: 'randomorder' => {},
2759: );
2760: foreach my $which (keys(%allchecked)) {
2761: $env{'form.all'.$which} =~ s/,$//;
2762: if ($which eq 'randompick') {
2763: foreach my $item (split(/,/,$env{'form.all'.$which})) {
2764: my ($res,$value) = split(/:/,$item);
2765: if ($value =~ /^\d+$/) {
2766: $allchecked{$which}{$res} = $value;
2767: }
2768: }
2769: } else {
1.484.2.30 raeburn 2770: if ($env{'form.all'.$which}) {
2771: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.all'.$which});
2772: }
1.484.2.29 raeburn 2773: }
2774: }
2775: my $haschanges = 0;
2776: foreach my $res (@LONCAPA::map::order) {
2777: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2778: $name=&LONCAPA::map::qtescape($name);
2779: $url=&LONCAPA::map::qtescape($url);
2780: next unless ($name && $url);
2781: my $is_map;
2782: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
2783: $is_map = 1;
2784: }
2785: foreach my $which (keys(%allchecked)) {
2786: if (($which eq 'randompick' || $which eq 'randomorder')) {
2787: next if (!$is_map);
2788: }
2789: my $oldvalue = 0;
2790: my $newvalue = 0;
2791: if ($allchecked{$which}{$res}) {
2792: $newvalue = $allchecked{$which}{$res};
2793: }
2794: my $current = (&LONCAPA::map::getparameter($res,'parameter_'.$which))[0];
2795: if ($which eq 'randompick') {
2796: if ($current =~ /^(\d+)$/) {
2797: $oldvalue = $1;
2798: }
2799: } else {
2800: if ($current =~ /^yes$/i) {
2801: $oldvalue = 1;
2802: }
2803: }
2804: if ($oldvalue ne $newvalue) {
2805: $haschanges = 1;
2806: if ($newvalue) {
2807: my $storeval = 'yes';
2808: if ($which eq 'randompick') {
2809: $storeval = $newvalue;
2810: }
2811: &LONCAPA::map::storeparameter($res,'parameter_'.$which,
2812: $storeval,
2813: $parameter_type{$which});
2814: &remember_parms($res,$which,'set',$storeval);
2815: } elsif ($oldvalue) {
2816: &LONCAPA::map::delparameter($res,'parameter_'.$which);
2817: &remember_parms($res,$which,'del');
2818: }
2819: }
2820: }
2821: }
2822: return $haschanges;
1.329 droeschl 2823: } else {
1.484.2.59 raeburn 2824: my $haschanges = 0;
2825: return $haschanges if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
1.364 bisitz 2826:
1.484.2.29 raeburn 2827: my $which = $env{'form.changeparms'};
2828: my $idx = $env{'form.setparms'};
1.484.2.59 raeburn 2829: my $oldvalue = 0;
2830: my $newvalue = 0;
2831: my $current = (&LONCAPA::map::getparameter($idx,'parameter_'.$which))[0];
2832: if ($which eq 'randompick') {
2833: if ($current =~ /^(\d+)$/) {
2834: $oldvalue = $1;
2835: }
2836: } elsif ($current =~ /^yes$/i) {
2837: $oldvalue = 1;
2838: }
1.484.2.29 raeburn 2839: if ($env{'form.'.$which.'_'.$idx}) {
1.484.2.59 raeburn 2840: $newvalue = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx}
2841: : 1;
1.484.2.29 raeburn 2842: }
1.484.2.59 raeburn 2843: if ($oldvalue ne $newvalue) {
2844: $haschanges = 1;
2845: if ($newvalue) {
2846: my $storeval = 'yes';
2847: if ($which eq 'randompick') {
2848: $storeval = $newvalue;
2849: }
2850: &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $storeval,
2851: $parameter_type{$which});
2852: &remember_parms($idx,$which,'set',$storeval);
2853: } else {
2854: &LONCAPA::map::delparameter($idx,'parameter_'.$which);
2855: &remember_parms($idx,$which,'del');
2856: }
2857: }
2858: return $haschanges;
1.329 droeschl 2859: }
1.484.2.59 raeburn 2860: return;
1.329 droeschl 2861: }
2862:
2863: sub handle_edit_cmd {
2864: my ($coursenum,$coursedom) =@_;
1.484.2.30 raeburn 2865: if ($env{'form.cmd'} eq '') {
2866: return 0;
2867: }
1.329 droeschl 2868: my ($cmd,$idx)=split('_',$env{'form.cmd'});
2869:
2870: my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
2871: my ($title, $url, @rrest) = split(':', $ratstr);
2872:
1.484.2.30 raeburn 2873: if ($cmd eq 'remove') {
1.329 droeschl 2874: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
1.463 www 2875: ($url!~/$LONCAPA::assess_page_seq_re/)) {
1.329 droeschl 2876: &Apache::lonnet::removeuploadedurl($url);
2877: } else {
2878: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
2879: }
2880: splice(@LONCAPA::map::order, $idx, 1);
2881:
2882: } elsif ($cmd eq 'cut') {
2883: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
2884: splice(@LONCAPA::map::order, $idx, 1);
2885:
1.344 bisitz 2886: } elsif ($cmd eq 'up'
1.329 droeschl 2887: && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
2888: @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
2889:
2890: } elsif ($cmd eq 'down'
2891: && defined($LONCAPA::map::order[$idx+1])) {
2892: @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
2893:
2894: } elsif ($cmd eq 'rename') {
2895: my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
2896: if ($comment=~/\S/) {
2897: $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
2898: $comment.':'.join(':', $url, @rrest);
2899: }
2900: # Devalidate title cache
2901: my $renamed_url=&LONCAPA::map::qtescape($url);
2902: &Apache::lonnet::devalidate_title_cache($renamed_url);
1.484.2.30 raeburn 2903:
1.329 droeschl 2904: } else {
2905: return 0;
2906: }
2907: return 1;
2908: }
2909:
2910: sub editor {
1.458 raeburn 2911: my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
1.484.2.72.2. (raeburn 2912:): $supplementalflag,$orderhash,$iconpath,$pathitem,$ltitoolsref,
2913:): $canedit,$navmapref,$hiddentop)=@_;
1.484.2.19 raeburn 2914: my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
2915: if ($allowed) {
2916: (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
2917: $is_random_order,$container) =
2918: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
2919: $r->print($breadcrumbtrail);
2920: } elsif ($env{'form.folderpath'} =~ /\:1$/) {
2921: $container = 'page';
2922: } else {
2923: $container = 'sequence';
2924: }
1.484 raeburn 2925:
1.484.2.21 raeburn 2926: my $jumpto;
2927:
2928: unless ($supplementalflag) {
1.484.2.32 raeburn 2929: $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
1.484.2.21 raeburn 2930: }
1.484 raeburn 2931:
2932: unless ($allowed) {
2933: $randompick = -1;
2934: }
2935:
1.484.2.67 raeburn 2936: my ($errtext,$fatal);
2937: if (($folder eq '') && (!$supplementalflag)) {
2938: if (@LONCAPA::map::order) {
2939: undef(@LONCAPA::map::order);
2940: undef(@LONCAPA::map::resources);
2941: undef(@LONCAPA::map::resparms);
2942: undef(@LONCAPA::map::zombies);
2943: }
2944: $folder = 'default';
2945: $container = 'sequence';
2946: } else {
2947: ($errtext,$fatal) = &mapread($coursenum,$coursedom,
2948: $folder.'.'.$container);
2949: return $errtext if ($fatal);
2950: }
1.329 droeschl 2951:
2952: if ($#LONCAPA::map::order<1) {
2953: my $idx=&LONCAPA::map::getresidx();
2954: if ($idx<=0) { $idx=1; }
2955: $LONCAPA::map::order[0]=$idx;
2956: $LONCAPA::map::resources[$idx]='';
2957: }
1.364 bisitz 2958:
1.329 droeschl 2959: # ------------------------------------------------------------ Process commands
2960:
2961: # ---------------- if they are for this folder and user allowed to make changes
1.484.2.67 raeburn 2962: if (($allowed && $canedit) && ($env{'form.folder'} eq $folder)) {
1.329 droeschl 2963: # set parameters and change order
2964: &snapshotbefore();
2965:
2966: if (&update_parameter()) {
1.484.2.59 raeburn 2967: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1.329 droeschl 2968: return $errtext if ($fatal);
2969: }
2970:
2971: if ($env{'form.newpos'} && $env{'form.currentpos'}) {
2972: # change order
2973: my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
2974: splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
2975:
2976: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
2977: return $errtext if ($fatal);
2978: }
1.364 bisitz 2979:
1.329 droeschl 2980: if ($env{'form.pastemarked'}) {
1.484.2.7 raeburn 2981: my %paste_errors;
1.484.2.26 raeburn 2982: my ($paste_res,$save_error,$pastemsgarray,$lockerror) =
1.484.2.7 raeburn 2983: &do_paste_from_buffer($coursenum,$coursedom,$folder,$container,
2984: \%paste_errors);
1.484.2.30 raeburn 2985: if (ref($pastemsgarray) eq 'ARRAY') {
2986: if (@{$pastemsgarray} > 0) {
2987: $r->print('<p class="LC_info">'.
2988: join('<br />',@{$pastemsgarray}).
1.484.2.26 raeburn 2989: '</p>');
2990: }
1.484.2.30 raeburn 2991: }
2992: if ($lockerror) {
2993: $r->print('<p class="LC_error">'.
2994: $lockerror.
2995: '</p>');
2996: }
2997: if ($save_error ne '') {
2998: return $save_error;
2999: }
3000: if ($paste_res) {
3001: my %errortext = &Apache::lonlocal::texthash (
3002: fail => 'Storage of folder contents failed',
3003: failread => 'Reading folder contents failed',
3004: failstore => 'Storage of folder contents failed',
3005: );
3006: if ($errortext{$paste_res}) {
3007: $r->print('<p class="LC_error">'.$errortext{$paste_res}.'</p>');
1.484.2.7 raeburn 3008: }
1.329 droeschl 3009: }
1.484.2.7 raeburn 3010: if (keys(%paste_errors) > 0) {
1.484.2.30 raeburn 3011: $r->print('<p class="LC_warning">'."\n".
1.484.2.7 raeburn 3012: &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".
3013: '<ul>'."\n");
3014: foreach my $key (sort(keys(%paste_errors))) {
3015: $r->print('<li>'.$key.'</li>'."\n");
3016: }
3017: $r->print('</ul></p>'."\n");
3018: }
1.484.2.30 raeburn 3019: } elsif ($env{'form.clearmarked'}) {
3020: my $output = &do_buffer_empty();
3021: if ($output) {
3022: $r->print('<p class="LC_info">'.$output.'</p>');
3023: }
3024: }
1.329 droeschl 3025:
3026: $r->print($upload_output);
3027:
1.484.2.30 raeburn 3028: # Rename, cut, copy or remove a single resource
1.484.2.63 raeburn 3029: if (&handle_edit_cmd($coursenum,$coursedom)) {
1.484.2.7 raeburn 3030: my $contentchg;
1.484.2.58 raeburn 3031: if ($env{'form.cmd'} =~ m{^(remove|cut)_}) {
1.484.2.7 raeburn 3032: $contentchg = 1;
3033: }
3034: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);
1.329 droeschl 3035: return $errtext if ($fatal);
3036: }
1.484.2.30 raeburn 3037:
3038: # Cut, copy and/or remove multiple resources
3039: if ($env{'form.multichange'}) {
3040: my %allchecked = (
3041: cut => {},
3042: remove => {},
3043: );
3044: my $needsupdate;
3045: foreach my $which (keys(%allchecked)) {
3046: $env{'form.multi'.$which} =~ s/,$//;
3047: if ($env{'form.multi'.$which}) {
3048: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.multi'.$which});
3049: if (ref($allchecked{$which}) eq 'HASH') {
3050: $needsupdate += scalar(keys(%{$allchecked{$which}}));
3051: }
3052: }
3053: }
3054: if ($needsupdate) {
3055: my $haschanges = 0;
3056: my %curr_groups = &Apache::longroup::coursegroups();
3057: my $total = scalar(@LONCAPA::map::order) - 1;
3058: for (my $i=$total; $i>=0; $i--) {
3059: my $res = $LONCAPA::map::order[$i];
3060: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3061: $name=&LONCAPA::map::qtescape($name);
3062: $url=&LONCAPA::map::qtescape($url);
1.484.2.57 raeburn 3063: next unless $url;
1.484.2.30 raeburn 3064: my %denied =
3065: &action_restrictions($coursenum,$coursedom,$url,
3066: $env{'form.folderpath'},\%curr_groups);
3067: foreach my $which (keys(%allchecked)) {
3068: next if ($denied{$which});
3069: next unless ($allchecked{$which}{$res});
3070: if ($which eq 'remove') {
3071: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
3072: ($url!~/$LONCAPA::assess_page_seq_re/)) {
3073: &Apache::lonnet::removeuploadedurl($url);
3074: } else {
3075: &LONCAPA::map::makezombie($res);
3076: }
3077: splice(@LONCAPA::map::order,$i,1);
3078: $haschanges ++;
3079: } elsif ($which eq 'cut') {
3080: &LONCAPA::map::makezombie($res);
3081: splice(@LONCAPA::map::order,$i,1);
3082: $haschanges ++;
3083: }
3084: }
3085: }
3086: if ($haschanges) {
3087: ($errtext,$fatal) =
3088: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
3089: return $errtext if ($fatal);
3090: }
3091: }
3092: }
3093:
1.329 droeschl 3094: # Group import/search
3095: if ($env{'form.importdetail'}) {
3096: my @imports;
3097: foreach my $item (split(/\&/,$env{'form.importdetail'})) {
3098: if (defined($item)) {
3099: my ($name,$url,$residx)=
1.484.2.26 raeburn 3100: map { &unescape($_); } split(/\=/,$item);
3101: if ($url =~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
1.484.2.30 raeburn 3102: my ($suffix,$errortxt,$locknotfreed) =
1.484.2.26 raeburn 3103: &new_timebased_suffix($coursedom,$coursenum,'map',$1,$2);
1.484.2.15 raeburn 3104: if ($locknotfreed) {
3105: $r->print($locknotfreed);
3106: }
3107: if ($suffix) {
1.484.2.19 raeburn 3108: $url =~ s/_new\./_$suffix./;
1.484.2.15 raeburn 3109: } else {
3110: return $errortxt;
3111: }
1.484.2.26 raeburn 3112: } elsif ($url =~ m{^/adm/$match_domain/$match_username/new/(smppg|bulletinboard)$}) {
3113: my $type = $1;
3114: my ($suffix,$errortxt,$locknotfreed) =
3115: &new_timebased_suffix($coursedom,$coursenum,$type);
3116: if ($locknotfreed) {
3117: $r->print($locknotfreed);
3118: }
3119: if ($suffix) {
3120: $url =~ s{^(/adm/$match_domain/$match_username)/new}{$1/$suffix};
3121: } else {
3122: return $errortxt;
3123: }
1.484.2.72.2. (raeburn 3124:): } elsif ($url =~ m{^/adm/$coursedom/$coursenum/new/ext\.tool}) {
3125:): my ($suffix,$errortxt,$locknotfreed) =
3126:): &new_timebased_suffix($coursedom,$coursenum,'exttool');
3127:): if ($locknotfreed) {
3128:): $r->print($locknotfreed);
3129:): }
3130:): if ($suffix) {
3131:): $url =~ s{^(/adm/$coursedom/$coursenum)/new}{$1/$suffix};
3132:): } else {
3133:): return $errortxt;
3134:): }
1.484.2.27 raeburn 3135: } elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) {
3136: if ($supplementalflag) {
3137: next unless ($1 eq 'supplemental');
3138: if ($folder eq 'supplemental') {
3139: next unless ($2 eq 'default');
3140: } else {
3141: next unless ($folder eq 'supplemental_'.$2);
3142: }
3143: } else {
3144: next unless ($1 eq 'docs');
3145: if ($folder eq 'default') {
3146: next unless ($2 eq 'default');
3147: } else {
3148: next unless ($folder eq 'default_'.$2);
3149: }
3150: }
1.484.2.15 raeburn 3151: }
1.329 droeschl 3152: push(@imports, [$name, $url, $residx]);
3153: }
3154: }
1.484.2.23 raeburn 3155: ($errtext,$fatal,my $fixuperrors) =
3156: &group_import($coursenum, $coursedom, $folder,$container,
1.484.2.72.2. (raeburn 3157:): 'londocs',$ltitoolsref,@imports);
1.329 droeschl 3158: return $errtext if ($fatal);
1.484.2.23 raeburn 3159: if ($fixuperrors) {
3160: $r->print($fixuperrors);
3161: }
1.329 droeschl 3162: }
3163: # Loading a complete map
3164: if ($env{'form.loadmap'}) {
3165: if ($env{'form.importmap'}=~/\w/) {
3166: foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
3167: my ($title,$url,$ext,$type)=split(/\:/,$res);
3168: my $idx=&LONCAPA::map::getresidx($url);
3169: $LONCAPA::map::resources[$idx]=$res;
3170: $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
3171: }
3172: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.484.2.7 raeburn 3173: $folder.'.'.$container,1);
1.329 droeschl 3174: return $errtext if ($fatal);
3175: } else {
3176: $r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
1.364 bisitz 3177:
1.329 droeschl 3178: }
3179: }
3180: &log_differences($plain);
3181: }
3182: # ---------------------------------------------------------------- End commands
3183: # ---------------------------------------------------------------- Print screen
3184: my $idx=0;
3185: my $shown=0;
3186: if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
1.381 bisitz 3187: $r->print('<div class="LC_Box">'.
1.432 raeburn 3188: '<ol class="LC_docs_parameters"><li class="LC_docs_parameters_title">'.&mt('Parameters:').'</li>'.
3189: ($randompick>=0?'<li>'.&mt('randomly pick [quant,_1,resource]',$randompick).'</li>':'').
3190: ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
3191: ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
3192: ($is_random_order?'<li>'.&mt('random order').'</li>':'').
1.431 raeburn 3193: '</ol>');
1.381 bisitz 3194: if ($randompick>=0) {
3195: $r->print('<p class="LC_warning">'
3196: .&mt('Caution: this folder is set to randomly pick a subset'
3197: .' of resources. Adding or removing resources from this'
3198: .' folder will change the set of resources that the'
3199: .' students see, resulting in spurious or missing credit'
3200: .' for completed problems, not limited to ones you'
3201: .' modify. Do not modify the contents of this folder if'
3202: .' it is in active student use.')
3203: .'</p>'
3204: );
3205: }
3206: if ($is_random_order) {
3207: $r->print('<p class="LC_warning">'
3208: .&mt('Caution: this folder is set to randomly order its'
3209: .' contents. Adding or removing resources from this folder'
3210: .' will change the order of resources shown.')
3211: .'</p>'
3212: );
3213: }
3214: $r->print('</div>');
1.364 bisitz 3215: }
1.381 bisitz 3216:
1.484.2.30 raeburn 3217: my ($to_show,$output,@allidx,@allmapidx,%filters,%lists,%curr_groups);
3218: %filters = (
3219: canremove => [],
3220: cancut => [],
3221: cancopy => [],
3222: hiddenresource => [],
3223: encrypturl => [],
3224: randomorder => [],
3225: randompick => [],
3226: );
3227: %curr_groups = &Apache::longroup::coursegroups();
1.424 onken 3228: &Apache::loncommon::start_data_table_count(); #setup a row counter
1.381 bisitz 3229: foreach my $res (@LONCAPA::map::order) {
3230: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3231: $name=&LONCAPA::map::qtescape($name);
3232: $url=&LONCAPA::map::qtescape($url);
3233: unless ($name) { $name=(split(/\//,$url))[-1]; }
3234: unless ($name) { $idx++; next; }
1.484.2.29 raeburn 3235: push(@allidx,$res);
3236: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
3237: push(@allmapidx,$res);
3238: }
1.484.2.67 raeburn 3239:
1.381 bisitz 3240: $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
1.484.2.12 raeburn 3241: $coursenum,$coursedom,$crstype,
1.484.2.30 raeburn 3242: $pathitem,$supplementalflag,$container,
1.484.2.72.2. (raeburn 3243:): \%filters,\%curr_groups,$ltitoolsref,$canedit,
1.484.2.70 raeburn 3244: $isencrypted,$navmapref);
1.381 bisitz 3245: $idx++;
3246: $shown++;
1.329 droeschl 3247: }
1.424 onken 3248: &Apache::loncommon::end_data_table_count();
1.484.2.19 raeburn 3249:
1.484.2.30 raeburn 3250: my $need_save;
1.484.2.67 raeburn 3251: if ($allowed || ($supplementalflag && $folder eq 'supplemental')) {
1.484.2.31 raeburn 3252: my $toolslink;
1.484.2.67 raeburn 3253: if ($allowed) {
1.484.2.31 raeburn 3254: $toolslink = '<table><tr><td>'
1.484.2.19 raeburn 3255: .&Apache::loncommon::help_open_menu('Navigation Screen',
3256: 'Navigation_Screen',undef,'RAT')
3257: .'</td><td class="LC_middle">'.&mt('Tools:').'</td>'
3258: .'<td align="left"><ul id="LC_toolbar">'
1.484.2.21 raeburn 3259: .'<li><a href="/adm/coursedocs?forcesupplement=1&command=editsupp" '
1.484.2.19 raeburn 3260: .'id="LC_content_toolbar_edittoplevel" '
3261: .'class="LC_toolbarItem" '
3262: .'title="'.&mt('Supplemental Content Editor').'">'
3263: .'</a></li></ul></td></tr></table><br />';
1.484.2.31 raeburn 3264: }
1.484.2.19 raeburn 3265: if ($shown) {
3266: if ($allowed) {
3267: $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
3268: .&Apache::loncommon::start_data_table(undef,'contentlist')
3269: .&Apache::loncommon::start_data_table_header_row()
3270: .'<th colspan="2">'.&mt('Move').'</th>'
1.484.2.30 raeburn 3271: .'<th colspan="2">'.&mt('Actions').'</th>'
3272: .'<th>'.&mt('Document').'</th>';
1.484.2.19 raeburn 3273: if ($folder !~ /^supplemental/) {
3274: $to_show .= '<th colspan="4">'.&mt('Settings').'</th>';
3275: }
1.484.2.29 raeburn 3276: $to_show .= &Apache::loncommon::end_data_table_header_row();
3277: if ($folder !~ /^supplemental/) {
1.484.2.30 raeburn 3278: $lists{'canhide'} = join(',',@allidx);
3279: $lists{'canrandomlyorder'} = join(',',@allmapidx);
3280: my @possfilters = ('canremove','cancut','cancopy','hiddenresource','encrypturl',
3281: 'randomorder','randompick');
3282: foreach my $item (@possfilters) {
3283: if (ref($filters{$item}) eq 'ARRAY') {
3284: if (@{$filters{$item}} > 0) {
3285: $lists{$item} = join(',',@{$filters{$item}});
3286: }
3287: }
3288: }
1.484.2.29 raeburn 3289: if (@allidx > 0) {
3290: my $path;
3291: if ($env{'form.folderpath'}) {
3292: $path =
3293: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3294: }
1.484.2.30 raeburn 3295: if (@allidx > 1) {
3296: $to_show .=
3297: &Apache::loncommon::continue_data_table_row().
3298: '<td colspan="2"> </td>'.
3299: '<td>'.
1.484.2.67 raeburn 3300: &multiple_check_form('actions',\%lists,$canedit).
1.484.2.30 raeburn 3301: '</td>'.
3302: '<td> </td>'.
3303: '<td> </td>'.
3304: '<td colspan="4">'.
1.484.2.67 raeburn 3305: &multiple_check_form('settings',\%lists,$canedit).
1.484.2.30 raeburn 3306: '</td>'.
3307: &Apache::loncommon::end_data_table_row();
3308: $need_save = 1;
3309: }
1.484.2.29 raeburn 3310: }
3311: }
3312: $to_show .= $output.' '
1.484.2.19 raeburn 3313: .&Apache::loncommon::end_data_table()
3314: .'<br style="line-height:2px;" />'
3315: .&Apache::loncommon::end_scrollbox();
3316: } else {
3317: $to_show .= $toolslink
3318: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3319: .$output.' '
3320: .&Apache::loncommon::end_data_table();
3321: }
3322: } else {
3323: if (!$allowed) {
3324: $to_show .= $toolslink;
1.393 raeburn 3325: }
1.484.2.67 raeburn 3326: my $noresmsg;
3327: if ($allowed && $hiddentop && !$supplementalflag) {
3328: $noresmsg = &mt('Main Content Hidden');
3329: } else {
3330: $noresmsg = &mt('Currently empty');
3331: }
1.484.2.19 raeburn 3332: $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
3333: .'<div class="LC_info" id="contentlist">'
1.484.2.67 raeburn 3334: .$noresmsg
1.484.2.19 raeburn 3335: .'</div>'
3336: .&Apache::loncommon::end_scrollbox();
1.393 raeburn 3337: }
3338: } else {
1.484.2.19 raeburn 3339: if ($shown) {
3340: $to_show = '<div>'
3341: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3342: .$output
3343: .&Apache::loncommon::end_data_table()
3344: .'</div>';
3345: } else {
3346: $to_show = '<div class="LC_info" id="contentlist">'
1.484.2.34 raeburn 3347: .&mt('Currently empty')
1.484.2.19 raeburn 3348: .'</div>'
3349: }
1.458 raeburn 3350: }
3351: my $tid = 1;
3352: if ($supplementalflag) {
3353: $tid = 2;
1.329 droeschl 3354: }
3355: if ($allowed) {
1.484 raeburn 3356: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
1.484.2.30 raeburn 3357: $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,
1.484.2.67 raeburn 3358: $jumpto,$readfile,$need_save,"$folder.$container",$canedit));
1.484.2.68 raeburn 3359: if ($canedit) {
1.484.2.67 raeburn 3360: &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
3361: }
1.460 raeburn 3362: } else {
3363: $r->print($to_show);
1.329 droeschl 3364: }
3365: return;
3366: }
3367:
1.484.2.30 raeburn 3368: sub multiple_check_form {
1.484.2.67 raeburn 3369: my ($caller,$listsref,$canedit) = @_;
1.484.2.30 raeburn 3370: return unless (ref($listsref) eq 'HASH');
1.484.2.67 raeburn 3371: my $disabled;
3372: unless ($canedit) {
3373: $disabled = 'disabled="disabled"';
3374: }
1.484.2.30 raeburn 3375: my $output =
3376: '<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'.
3377: '<span class="LC_nobreak" style="font-size:x-small;font-weight:bold;">'.
3378: '<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>'.
3379: '<div id="multi'.$caller.'" style="display:none;margin:0;padding:0;border:0">'.
3380: '<form action="/adm/coursedocs" method="post" name="cumulative'.$caller.'">'."\n".
3381: '<fieldset id="allfields'.$caller.'" style="display:none"><legend style="font-size:x-small;">'.&mt('check/uncheck all').'</legend>'."\n";
3382: if ($caller eq 'settings') {
3383: $output .=
3384: '<table><tr>'.
3385: '<td class="LC_docs_entry_parameter">'.
3386: '<span class="LC_nobreak"><label>'.
1.484.2.67 raeburn 3387: '<input type="checkbox" name="hiddenresourceall" id="hiddenresourceall" onclick="propagateState(this.form,'."'hiddenresource'".')"'.$disabled.' />'.&mt('Hidden').
1.484.2.30 raeburn 3388: '</label></span></td>'.
3389: '<td class="LC_docs_entry_parameter">'.
1.484.2.67 raeburn 3390: '<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 3391: '</span></td>'.
3392: '</tr>'."\n".
3393: '<tr>'.
3394: '<td class="LC_docs_entry_parameter">'.
1.484.2.67 raeburn 3395: '<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 3396: '</label></span>'.
3397: '</td></tr></table>'."\n";
3398: } else {
3399: $output .=
3400: '<table><tr>'.
3401: '<td class="LC_docs_entry_parameter">'.
3402: '<span class="LC_nobreak LC_docs_remove">'.
1.484.2.67 raeburn 3403: '<label><input type="checkbox" name="removeall" id="removeall" onclick="propagateState(this.form,'."'remove'".')"'.$disabled.' />'.&mt('Remove').
1.484.2.30 raeburn 3404: '</label></span></td>'.
3405: '<td class="LC_docs_entry_parameter">'.
3406: '<span class="LC_nobreak LC_docs_cut">'.
1.484.2.67 raeburn 3407: '<label><input type="checkbox" name="cut" id="cutall" onclick="propagateState(this.form,'."'cut'".');"'.$disabled.' />'.&mt('Cut').
1.484.2.30 raeburn 3408: '</label></span></td>'."\n".
3409: '<td class="LC_docs_entry_parameter">'.
3410: '<span class="LC_nobreak LC_docs_copy">'.
1.484.2.67 raeburn 3411: '<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')"'.$disabled.' />'.&mt('Copy').
1.484.2.30 raeburn 3412: '</label></span></td>'.
3413: '</tr></table>'."\n";
3414: }
3415: $output .=
3416: '</fieldset>'.
3417: '<input type="hidden" name="allidx" value="'.$listsref->{'canhide'}.'" />';
3418: if ($caller eq 'settings') {
3419: $output .=
3420: '<input type="hidden" name="allmapidx" value="'.$listsref->{'canrandomlyorder'}.'" />'."\n".
3421: '<input type="hidden" name="currhiddenresource" value="'.$listsref->{'hiddenresource'}.'" />'."\n".
3422: '<input type="hidden" name="currencrypturl" value="'.$listsref->{'encrypturl'}.'" />'."\n".
3423: '<input type="hidden" name="currrandomorder" value="'.$listsref->{'randomorder'}.'" />'."\n".
3424: '<input type="hidden" name="currrandompick" value="'.$listsref->{'randompick'}.'" />'."\n";
3425: } elsif ($caller eq 'actions') {
3426: $output .=
3427: '<input type="hidden" name="allremoveidx" id="allremoveidx" value="'.$listsref->{'canremove'}.'" />'.
3428: '<input type="hidden" name="allcutidx" id="allcutidx" value="'.$listsref->{'cancut'}.'" />'.
3429: '<input type="hidden" name="allcopyidx" id="allcopyidx" value="'.$listsref->{'cancopy'}.'" />';
3430: }
3431: $output .=
3432: '</form>'.
3433: '</div>';
3434: return $output;
3435: }
3436:
1.329 droeschl 3437: sub process_file_upload {
1.484.2.36 raeburn 3438: my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd,$crstype) = @_;
1.329 droeschl 3439: # upload a file, if present
1.484.2.36 raeburn 3440: my $filesize = length($env{'form.uploaddoc'});
3441: if (!$filesize) {
3442: $$upload_output = '<div class="LC_error">'.
3443: &mt('Unable to upload [_1]. (size = [_2] bytes)',
3444: '<span class="LC_filename">'.$env{'form.uploaddoc.filename'}.'</span>',
3445: $filesize).'<br />'.
3446: &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'<br />'.
3447: '</div>';
3448: return;
3449: }
3450: my $quotatype = 'unofficial';
3451: if ($crstype eq 'Community') {
3452: $quotatype = 'community';
1.484.2.51 raeburn 3453: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
1.484.2.36 raeburn 3454: $quotatype = 'official';
1.484.2.45 raeburn 3455: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
3456: $quotatype = 'textbook';
1.484.2.36 raeburn 3457: }
3458: if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) {
3459: $filesize = int($filesize/1000); #expressed in kb
3460: $$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course',
1.484.2.51 raeburn 3461: $env{'form.uploaddoc.filename'},$filesize,
3462: 'upload',$quotatype);
1.484.2.36 raeburn 3463: return if ($$upload_output);
3464: }
1.440 raeburn 3465: my ($parseaction,$showupload,$nextphase,$mimetype);
3466: if ($env{'form.parserflag'}) {
1.329 droeschl 3467: $parseaction = 'parse';
3468: }
3469: my $folder=$env{'form.folder'};
3470: if ($folder eq '') {
3471: $folder='default';
3472: }
3473: if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
3474: my $errtext='';
3475: my $fatal=0;
3476: my $container='sequence';
1.484.2.19 raeburn 3477: if ($env{'form.folderpath'} =~ /:1$/) {
1.329 droeschl 3478: $container='page';
3479: }
3480: ($errtext,$fatal)=
1.484.2.27 raeburn 3481: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1.329 droeschl 3482: if ($#LONCAPA::map::order<1) {
3483: $LONCAPA::map::order[0]=1;
3484: $LONCAPA::map::resources[1]='';
3485: }
3486: my $destination = 'docs/';
3487: if ($folder =~ /^supplemental/) {
3488: $destination = 'supplemental/';
3489: }
3490: if (($folder eq 'default') || ($folder eq 'supplemental')) {
3491: $destination .= 'default/';
3492: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
3493: $destination .= $2.'/';
3494: }
1.484.2.27 raeburn 3495: if ($fatal) {
3496: $$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>';
3497: return;
3498: }
1.440 raeburn 3499: # this is for a course, not a user, so set context to coursedoc.
1.329 droeschl 3500: my $newidx=&LONCAPA::map::getresidx();
3501: $destination .= $newidx;
1.439 raeburn 3502: my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination,
1.329 droeschl 3503: $parseaction,$allfiles,
1.440 raeburn 3504: $codebase,undef,undef,undef,undef,
3505: undef,undef,\$mimetype);
3506: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) {
3507: my $stored = $1;
3508: $showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'.
3509: $stored.'</span>').'</p>';
3510: } else {
3511: my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});
3512:
1.457 raeburn 3513: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>';
1.440 raeburn 3514: return;
3515: }
1.329 droeschl 3516: my $ext='false';
3517: if ($url=~m{^http://}) { $ext='true'; }
3518: $url = &LONCAPA::map::qtunescape($url);
3519: my $comment=$env{'form.comment'};
3520: $comment = &LONCAPA::map::qtunescape($comment);
3521: if ($folder=~/^supplemental/) {
3522: $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
3523: $env{'user.domain'}.'___&&&___'.$comment;
3524: }
3525:
3526: $LONCAPA::map::resources[$newidx]=
3527: $comment.':'.$url.':'.$ext.':normal:res';
3528: $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
3529: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.484.2.7 raeburn 3530: $folder.'.'.$container,1);
1.329 droeschl 3531: if ($fatal) {
1.457 raeburn 3532: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>';
1.440 raeburn 3533: return;
1.329 droeschl 3534: } else {
1.440 raeburn 3535: if ($parseaction eq 'parse' && $mimetype eq 'text/html') {
3536: $$upload_output = $showupload;
1.384 raeburn 3537: my $total_embedded = scalar(keys(%{$allfiles}));
1.329 droeschl 3538: if ($total_embedded > 0) {
1.440 raeburn 3539: my $uploadphase = 'upload_embedded';
3540: my $primaryurl = &HTML::Entities::encode($url,'<>&"');
3541: my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx);
3542: my ($embedded,$num) =
3543: &Apache::loncommon::ask_for_embedded_content(
3544: '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url});
3545: if ($embedded) {
3546: if ($num) {
3547: $$upload_output .=
3548: '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
3549: $nextphase = $uploadphase;
3550: } else {
3551: $$upload_output .= $embedded;
3552: }
3553: } else {
3554: $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
3555: }
1.329 droeschl 3556: } else {
1.440 raeburn 3557: $$upload_output .= &mt('No embedded items identified').'<br />';
1.329 droeschl 3558: }
1.457 raeburn 3559: $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
1.484.2.51 raeburn 3560: } elsif ((&Apache::loncommon::is_archive_file($mimetype)) &&
3561: ($env{'form.uploaddoc.filename'} =~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i)) {
1.476 raeburn 3562: $nextphase = 'decompress_uploaded';
3563: my $position = scalar(@LONCAPA::map::order)-1;
3564: my $noextract = &return_to_editor();
3565: my $archiveurl = &HTML::Entities::encode($url,'<>&"');
3566: my %archiveitems = (
3567: folderpath => $env{'form.folderpath'},
3568: cmd => $nextphase,
3569: newidx => $newidx,
3570: position => $position,
3571: phase => $nextphase,
1.477 raeburn 3572: comment => $comment,
1.480 raeburn 3573: );
3574: my ($destination,$dir_root) = &embedded_destination($coursenum,$coursedom);
3575: my @current = &get_dir_list($url,$coursenum,$coursedom,$newidx);
1.476 raeburn 3576: $$upload_output = $showupload.
3577: &Apache::loncommon::decompress_form($mimetype,
3578: $archiveurl,'/adm/coursedocs',$noextract,
1.480 raeburn 3579: \%archiveitems,\@current);
1.329 droeschl 3580: }
3581: }
3582: }
1.440 raeburn 3583: return $nextphase;
1.329 droeschl 3584: }
3585:
1.480 raeburn 3586: sub get_dir_list {
3587: my ($url,$coursenum,$coursedom,$newidx) = @_;
3588: my ($destination,$dir_root) = &embedded_destination();
3589: my ($dirlistref,$listerror) =
3590: &Apache::lonnet::dirlist("$dir_root/$destination/$newidx",$coursedom,$coursenum,1);
3591: my @dir_lines;
3592: my $dirptr=16384;
3593: if (ref($dirlistref) eq 'ARRAY') {
3594: foreach my $dir_line (sort
3595: {
3596: my ($afile)=split('&',$a,2);
3597: my ($bfile)=split('&',$b,2);
3598: return (lc($afile) cmp lc($bfile));
3599: } (@{$dirlistref})) {
3600: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
3601: $filename =~ s/\s+$//;
3602: next if ($filename =~ /^\.\.?$/);
3603: my $isdir = 0;
3604: if ($dirptr&$testdir) {
3605: $isdir = 1;
3606: }
3607: push(@dir_lines, [$filename,$dom,$isdir,$size,$mtime,$obs]);
3608: }
3609: }
3610: return @dir_lines;
3611: }
3612:
1.329 droeschl 3613: sub is_supplemental_title {
3614: my ($title) = @_;
3615: return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
3616: }
3617:
3618: # --------------------------------------------------------------- An entry line
3619:
3620: sub entryline {
1.484.2.12 raeburn 3621: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
1.484.2.67 raeburn 3622: $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups,
1.484.2.72.2. (raeburn 3623:): $ltitoolsref,$canedit,$isencrypted,$navmapref)=@_;
1.484.2.52 raeburn 3624: my ($foldertitle,$renametitle,$oldtitle);
1.329 droeschl 3625: if (&is_supplemental_title($title)) {
1.484.2.7 raeburn 3626: ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
1.329 droeschl 3627: } else {
3628: $title=&HTML::Entities::encode($title,'"<>&\'');
3629: $renametitle=$title;
3630: $foldertitle=$title;
3631: }
3632:
1.484.2.67 raeburn 3633: my ($disabled,$readonly,$js_lt);
3634: unless ($canedit) {
3635: $disabled = 'disabled="disabled"';
3636: $readonly = 1;
3637: }
3638:
1.329 droeschl 3639: my $orderidx=$LONCAPA::map::order[$index];
1.364 bisitz 3640:
1.329 droeschl 3641: $renametitle=~s/\\/\\\\/g;
3642: $renametitle=~s/\"\;/\\\"/g;
1.484.2.55 raeburn 3643: $renametitle=~s/"/%22/g;
1.329 droeschl 3644: $renametitle=~s/ /%20/g;
1.484.2.52 raeburn 3645: $oldtitle = $renametitle;
3646: $renametitle=~s/\'\;/\\\'/g;
1.379 bisitz 3647: my $line=&Apache::loncommon::start_data_table_row();
1.484.2.30 raeburn 3648: my ($form_start,$form_end,$form_common,$form_param);
1.329 droeschl 3649: # Edit commands
1.484.2.28 raeburn 3650: my ($esc_path, $path, $symb);
1.329 droeschl 3651: if ($env{'form.folderpath'}) {
3652: $esc_path=&escape($env{'form.folderpath'});
3653: $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3654: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
3655: }
1.484.2.16 raeburn 3656: my $isexternal;
1.484.2.19 raeburn 3657: if ($residx) {
1.484.2.12 raeburn 3658: my $currurl = $url;
3659: $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.484.2.16 raeburn 3660: if ($currurl =~ m{^/adm/wrapper/ext/}) {
3661: $isexternal = 1;
3662: }
1.484.2.19 raeburn 3663: if (!$supplementalflag) {
3664: my $path = 'uploaded/'.
3665: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
3666: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
3667: $symb = &Apache::lonnet::encode_symb($path.$folder.".$container",
3668: $residx,
3669: &Apache::lonnet::declutter($currurl));
3670: }
1.484.2.12 raeburn 3671: }
1.484.2.30 raeburn 3672: my ($renamelink,%lt,$ishash);
3673: if (ref($filtersref) eq 'HASH') {
3674: $ishash = 1;
3675: }
3676:
1.329 droeschl 3677: if ($allowed) {
1.484.2.30 raeburn 3678: $form_start = '
3679: <form action="/adm/coursedocs" method="post">
3680: ';
3681: $form_common=(<<END);
3682: <input type="hidden" name="folderpath" value="$path" />
3683: <input type="hidden" name="symb" value="$symb" />
3684: END
3685: $form_param=(<<END);
3686: <input type="hidden" name="setparms" value="$orderidx" />
3687: <input type="hidden" name="changeparms" value="0" />
3688: END
3689: $form_end = '</form>';
3690:
1.329 droeschl 3691: my $incindex=$index+1;
3692: my $selectbox='';
1.471 raeburn 3693: if (($#LONCAPA::map::order>0) &&
1.329 droeschl 3694: ((split(/\:/,
1.344 bisitz 3695: $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
3696: ne '') &&
1.329 droeschl 3697: ((split(/\:/,
1.344 bisitz 3698: $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1.329 droeschl 3699: ne '')) {
3700: $selectbox=
3701: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.484.2.67 raeburn 3702: '<select name="newpos" onchange="this.form.submit()"'.$disabled.'>';
1.329 droeschl 3703: for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
3704: if ($i==$incindex) {
1.358 bisitz 3705: $selectbox.='<option value="" selected="selected">('.$i.')</option>';
1.329 droeschl 3706: } else {
3707: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
3708: }
3709: }
3710: $selectbox.='</select>';
3711: }
1.484.2.12 raeburn 3712: %lt=&Apache::lonlocal::texthash(
1.329 droeschl 3713: 'up' => 'Move Up',
3714: 'dw' => 'Move Down',
3715: 'rm' => 'Remove',
3716: 'ct' => 'Cut',
3717: 'rn' => 'Rename',
1.484.2.12 raeburn 3718: 'cp' => 'Copy',
3719: 'ex' => 'External Resource',
1.484.2.72.2. (raeburn 3720:): 'et' => 'External Tool',
1.484.2.12 raeburn 3721: 'ed' => 'Edit',
3722: 'pr' => 'Preview',
3723: 'sv' => 'Save',
3724: 'ul' => 'URL',
1.484.2.67 raeburn 3725: 'ti' => 'Title',
3726: 'er' => 'Editing rights unavailable for your current role.',
1.484.2.12 raeburn 3727: );
1.484.2.30 raeburn 3728: my %denied = &action_restrictions($coursenum,$coursedom,$url,
3729: $env{'form.folderpath'},
3730: $currgroups);
1.484.2.19 raeburn 3731: my ($copylink,$cutlink,$removelink);
1.329 droeschl 3732: my $skip_confirm = 0;
1.484.2.63 raeburn 3733: my $confirm_removal = 0;
1.329 droeschl 3734: if ( $folder =~ /^supplemental/
3735: || ($url =~ m{( /smppg$
3736: |/syllabus$
3737: |/aboutme$
3738: |/navmaps$
3739: |/bulletinboard$
1.484.2.72.2. (raeburn 3740:): |/ext\.tool$
1.484.2.16 raeburn 3741: |\.html$)}x)
1.484.2.19 raeburn 3742: || $isexternal) {
1.329 droeschl 3743: $skip_confirm = 1;
3744: }
1.484.2.63 raeburn 3745: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
3746: ($url!~/$LONCAPA::assess_page_seq_re/)) {
3747: $confirm_removal = 1;
3748: }
1.484.2.19 raeburn 3749:
1.484.2.30 raeburn 3750: if ($denied{'copy'}) {
3751: $copylink=(<<ENDCOPY)
1.484.2.16 raeburn 3752: <span style="visibility: hidden;">$lt{'cp'}</span>
3753: ENDCOPY
3754: } else {
1.484.2.30 raeburn 3755: my $formname = 'edit_copy_'.$orderidx;
3756: my $js = "javascript:checkForSubmit(document.forms.renameform,'copy','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.484.2.19 raeburn 3757: $copylink=(<<ENDCOPY);
1.484.2.30 raeburn 3758: <form name="$formname" method="post" action="/adm/coursedocs">
3759: $form_common
1.484.2.67 raeburn 3760: <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 3761: $form_end
1.329 droeschl 3762: ENDCOPY
1.484.2.30 raeburn 3763: if (($ishash) && (ref($filtersref->{'cancopy'}) eq 'ARRAY')) {
3764: push(@{$filtersref->{'cancopy'}},$orderidx);
3765: }
1.329 droeschl 3766: }
1.484.2.30 raeburn 3767: if ($denied{'cut'}) {
1.484.2.16 raeburn 3768: $cutlink=(<<ENDCUT);
3769: <span style="visibility: hidden;">$lt{'ct'}</span>
3770: ENDCUT
3771: } else {
1.484.2.30 raeburn 3772: my $formname = 'edit_cut_'.$orderidx;
3773: my $js = "javascript:checkForSubmit(document.forms.renameform,'cut','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.484.2.19 raeburn 3774: $cutlink=(<<ENDCUT);
1.484.2.30 raeburn 3775: <form name="$formname" method="post" action="/adm/coursedocs">
3776: $form_common
3777: <input type="hidden" name="skip_$orderidx" id="skip_cut_$orderidx" value="$skip_confirm" />
1.484.2.67 raeburn 3778: <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 3779: $form_end
1.329 droeschl 3780: ENDCUT
1.484.2.30 raeburn 3781: if (($ishash) && (ref($filtersref->{'cancut'}) eq 'ARRAY')) {
3782: push(@{$filtersref->{'cancut'}},$orderidx);
3783: }
1.329 droeschl 3784: }
1.484.2.30 raeburn 3785: if ($denied{'remove'}) {
1.484.2.16 raeburn 3786: $removelink=(<<ENDREM);
3787: <span style="visibility: hidden;">$lt{'rm'}</a>
3788: ENDREM
3789: } else {
1.484.2.30 raeburn 3790: my $formname = 'edit_remove_'.$orderidx;
1.484.2.63 raeburn 3791: 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 3792: $removelink=(<<ENDREM);
1.484.2.30 raeburn 3793: <form name="$formname" method="post" action="/adm/coursedocs">
3794: $form_common
3795: <input type="hidden" name="skip_$orderidx" id="skip_remove_$orderidx" value="$skip_confirm" />
1.484.2.63 raeburn 3796: <input type="hidden" name="confirm_rem_$orderidx" id="confirm_removal_$orderidx" value="$confirm_removal" />
1.484.2.67 raeburn 3797: <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 3798: $form_end
1.484.2.9 raeburn 3799: ENDREM
1.484.2.30 raeburn 3800: if (($ishash) && (ref($filtersref->{'canremove'}) eq 'ARRAY')) {
3801: push(@{$filtersref->{'canremove'}},$orderidx);
3802: }
1.484.2.9 raeburn 3803: }
1.484.2.35 raeburn 3804: $renamelink=(<<ENDREN);
1.484.2.52 raeburn 3805: <a href='javascript:changename("$esc_path","$index","$oldtitle");' class="LC_docs_rename">$lt{'rn'}</a>
1.484.2.16 raeburn 3806: ENDREN
1.484.2.67 raeburn 3807: my ($uplink,$downlink);
3808: if ($canedit) {
3809: $uplink = "/adm/coursedocs?cmd=up_$index&folderpath=$esc_path&symb=$symb";
3810: $downlink = "/adm/coursedocs?cmd=down_$index&folderpath=$esc_path&symb=$symb";
3811: } else {
3812: $uplink = "javascript:alert('".&js_escape($lt{'er'})."');";
3813: $downlink = $uplink;
3814: }
1.329 droeschl 3815: $line.=(<<END);
3816: <td>
1.379 bisitz 3817: <div class="LC_docs_entry_move">
1.484.2.67 raeburn 3818: <a href="$uplink">
1.484.2.12 raeburn 3819: <img src="${iconpath}move_up.gif" alt="$lt{'up'}" class="LC_icon" />
1.379 bisitz 3820: </a>
3821: </div>
3822: <div class="LC_docs_entry_move">
1.484.2.67 raeburn 3823: <a href="$downlink">
1.484.2.12 raeburn 3824: <img src="${iconpath}move_down.gif" alt="$lt{'dw'}" class="LC_icon" />
1.379 bisitz 3825: </a>
3826: </div>
1.329 droeschl 3827: </td>
3828: <td>
3829: $form_start
1.484.2.30 raeburn 3830: $form_param
1.478 raeburn 3831: $form_common
1.329 droeschl 3832: $selectbox
3833: $form_end
3834: </td>
1.484.2.30 raeburn 3835: <td class="LC_docs_entry_commands LC_nobreak">
1.484.2.9 raeburn 3836: $removelink
1.329 droeschl 3837: $cutlink
3838: $copylink
3839: </td>
3840: END
3841: }
3842: # Figure out what kind of a resource this is
3843: my ($extension)=($url=~/\.(\w+)$/);
3844: my $uploaded=($url=~/^\/*uploaded\//);
3845: my $icon=&Apache::loncommon::icon($url);
1.484.2.19 raeburn 3846: my $isfolder;
3847: my $ispage;
3848: my $containerarg;
1.484.2.67 raeburn 3849: my $folderurl;
1.329 droeschl 3850: if ($uploaded) {
1.472 raeburn 3851: if (($extension eq 'sequence') || ($extension eq 'page')) {
3852: $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
1.484.2.19 raeburn 3853: $containerarg = $1;
1.472 raeburn 3854: if ($extension eq 'sequence') {
3855: $icon=$iconpath.'navmap.folder.closed.gif';
3856: $isfolder=1;
3857: } else {
3858: $icon=$iconpath.'page.gif';
3859: $ispage=1;
3860: }
1.484.2.67 raeburn 3861: $folderurl = &Apache::lonnet::declutter($url);
1.472 raeburn 3862: if ($allowed) {
3863: $url='/adm/coursedocs?';
3864: } else {
3865: $url='/adm/supplemental?';
3866: }
1.329 droeschl 3867: } else {
3868: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
3869: }
3870: }
1.364 bisitz 3871:
1.484.2.70 raeburn 3872: my ($editlink,$extresform,$anchor,$hiddenres,$nomodal);
1.329 droeschl 3873: my $orig_url = $url;
1.340 raeburn 3874: $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
1.484.2.19 raeburn 3875: $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.484.2.12 raeburn 3876: if (!$supplementalflag && $residx && $symb) {
3877: if ((!$isfolder) && (!$ispage)) {
3878: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
3879: $url=&Apache::lonnet::clutter($url);
3880: if ($url=~/^\/*uploaded\//) {
3881: $url=~/\.(\w+)$/;
3882: my $embstyle=&Apache::loncommon::fileembstyle($1);
3883: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
3884: $url='/adm/wrapper'.$url;
3885: } elsif ($embstyle eq 'ssi') {
3886: #do nothing with these
3887: } elsif ($url!~/\.(sequence|page)$/) {
3888: $url='/adm/coursedocs/showdoc'.$url;
3889: }
1.484.2.70 raeburn 3890: } elsif ($url=~m{^(|/adm/wrapper)/ext/([^#]+)}) {
3891: my $wrapped = $1;
3892: my $exturl = $2;
3893: if ($wrapped eq '') {
3894: $url='/adm/wrapper'.$url;
3895: }
3896: if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) {
3897: $nomodal = 1;
3898: }
1.484.2.72.2. (raeburn 3899:): } elsif ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
3900:): $url='/adm/wrapper'.$url;
1.484.2.70 raeburn 3901: } elsif ($url eq "/public/$coursedom/$coursenum/syllabus") {
3902: if (($ENV{'SERVER_PORT'} == 443) &&
3903: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
3904: $nomodal = 1;
3905: }
1.484.2.19 raeburn 3906: }
1.484.2.12 raeburn 3907: if (&Apache::lonnet::symbverify($symb,$url)) {
1.484.2.66 raeburn 3908: my $shownsymb = $symb;
3909: if ($isexternal) {
3910: if ($url =~ /^([^#]+)#([^#]+)$/) {
3911: $url = $1;
3912: $anchor = $2;
3913: if ($symb =~ m{^([^#]+)\Q#$anchor\E$}) {
3914: $shownsymb = $1.&escape('#').$anchor;
3915: }
3916: }
3917: }
1.484.2.67 raeburn 3918: unless ($env{'request.role.adv'}) {
3919: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
3920: $url = '';
3921: }
3922: if (&Apache::lonnet::EXT('resource.0.hiddenresource',$symb) =~ /^yes$/i) {
3923: $url = '';
3924: $hiddenres = 1;
3925: }
3926: }
3927: if ($url ne '') {
3928: $url.=(($url=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&');
3929: }
3930: } elsif (!$env{'request.role.adv'}) {
3931: my $checkencrypt;
3932: if (((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) ||
3933: $isencrypted || (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i)) {
3934: $checkencrypt = 1;
1.484.2.70 raeburn 3935: } elsif (ref($navmapref)) {
1.484.2.67 raeburn 3936: unless (ref($$navmapref)) {
3937: $$navmapref = Apache::lonnavmaps::navmap->new();
3938: }
3939: if (ref($$navmapref)) {
3940: if (lc($$navmapref->get_mapparam($symb,undef,"0.encrypturl")) eq 'yes') {
3941: $checkencrypt = 1;
3942: }
3943: }
3944: }
3945: if ($checkencrypt) {
3946: my $shownsymb = &Apache::lonenc::encrypted($symb);
3947: my $shownurl = &Apache::lonenc::encrypted($url);
3948: if (&Apache::lonnet::symbverify($shownsymb,$shownurl)) {
3949: $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&');
3950: if ($env{'request.enc'} ne '') {
3951: delete($env{'request.enc'});
3952: }
3953: } else {
3954: $url='';
3955: }
3956: } else {
3957: $url='';
3958: }
1.484.2.12 raeburn 3959: } else {
3960: $url='';
3961: }
1.484.2.19 raeburn 3962: }
1.484.2.66 raeburn 3963: } elsif ($supplementalflag) {
3964: if ($isexternal) {
3965: if ($url =~ /^([^#]+)#([^#]+)$/) {
3966: $url = $1;
3967: $anchor = $2;
1.484.2.70 raeburn 3968: if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) {
3969: $nomodal = 1;
3970: }
3971: }
3972: } elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
3973: if (($ENV{'SERVER_PORT'} == 443) &&
3974: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
3975: $nomodal = 1;
1.484.2.66 raeburn 3976: }
3977: }
1.329 droeschl 3978: }
1.484.2.67 raeburn 3979: my ($rand_pick_text,$rand_order_text,$hiddenfolder);
3980: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.484.2.19 raeburn 3981: if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') {
1.329 droeschl 3982: my $foldername=&escape($foldertitle);
3983: my $folderpath=$env{'form.folderpath'};
3984: if ($folderpath) { $folderpath.='&' };
1.484.2.19 raeburn 3985: if (!$allowed && $supplementalflag) {
3986: $folderpath.=$containerarg.'&'.$foldername;
3987: $url.='folderpath='.&escape($folderpath);
3988: } else {
3989: my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
3990: 'parameter_randompick'))[0];
1.484.2.67 raeburn 3991: my $randorder = ((&LONCAPA::map::getparameter($orderidx,
3992: 'parameter_randomorder'))[0]=~/^yes$/i);
3993: my $hiddenmap = ((&LONCAPA::map::getparameter($orderidx,
3994: 'parameter_hiddenresource'))[0]=~/^yes$/i);
3995: my $encryptmap = ((&LONCAPA::map::getparameter($orderidx,
3996: 'parameter_encrypturl'))[0]=~/^yes$/i);
3997: unless ($hiddenmap) {
1.484.2.70 raeburn 3998: if (ref($navmapref)) {
3999: unless (ref($$navmapref)) {
4000: $$navmapref = Apache::lonnavmaps::navmap->new();
4001: }
4002: if (ref($$navmapref)) {
4003: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
4004: my @resources = $$navmapref->retrieveResources($folderurl,$filterFunc,1,1);
4005: unless (@resources) {
4006: $hiddenmap = 1;
4007: unless ($env{'request.role.adv'}) {
4008: $url = '';
4009: $hiddenfolder = 1;
4010: }
1.484.2.67 raeburn 4011: }
4012: }
4013: }
4014: }
4015: }
4016: unless ($encryptmap) {
1.484.2.70 raeburn 4017: if ((ref($navmapref)) && (ref($$navmapref))) {
4018: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.encrypturl")) eq 'yes') {
4019: $encryptmap = 1;
4020: }
1.484.2.67 raeburn 4021: }
4022: }
4023:
4024: # Append randompick number, hidden, and encrypted with ":" to foldername,
4025: # so it gets transferred between levels
4026: $folderpath.=$containerarg.'&'.$foldername.
4027: ':'.$rpicknum.':'.$hiddenmap.':'.$encryptmap.':'.$randorder.':'.$ispage;
4028: unless ($url eq '') {
4029: $url.='folderpath='.&escape($folderpath);
4030: }
1.484.2.19 raeburn 4031: my $rpckchk;
4032: if ($rpicknum) {
4033: $rpckchk = ' checked="checked"';
1.484.2.30 raeburn 4034: if (($ishash) && (ref($filtersref->{'randompick'}) eq 'ARRAY')) {
4035: push(@{$filtersref->{'randompick'}},$orderidx.':'.$rpicknum);
4036: }
1.484.2.19 raeburn 4037: }
1.484.2.29 raeburn 4038: my $formname = 'edit_randompick_'.$orderidx;
1.484.2.19 raeburn 4039: $rand_pick_text =
1.478 raeburn 4040: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.484.2.30 raeburn 4041: $form_param."\n".
1.478 raeburn 4042: $form_common."\n".
1.484.2.67 raeburn 4043: '<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 4044: if ($rpicknum ne '') {
4045: $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
4046: }
1.484.2.29 raeburn 4047: $rand_pick_text .= '</span></span>'.
4048: $form_end;
1.484.2.30 raeburn 4049: my $ro_set;
1.484.2.67 raeburn 4050: if ($randorder) {
1.484.2.30 raeburn 4051: $ro_set = 'checked="checked"';
4052: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4053: push(@{$filtersref->{'randomorder'}},$orderidx);
4054: }
4055: }
1.484.2.41 raeburn 4056: $formname = 'edit_rorder_'.$orderidx;
1.484.2.19 raeburn 4057: $rand_order_text =
1.484.2.29 raeburn 4058: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.484.2.30 raeburn 4059: $form_param."\n".
1.484.2.29 raeburn 4060: $form_common."\n".
1.484.2.67 raeburn 4061: '<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 4062: $form_end;
1.484.2.19 raeburn 4063: }
1.484.2.18 raeburn 4064: } elsif ($supplementalflag && !$allowed) {
1.484.2.72.2. (raeburn 4065:): my $isexttool;
4066:): if ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4067:): $url='/adm/wrapper'.$url;
4068:): $isexttool = 1;
4069:): }
1.484.2.19 raeburn 4070: $url .= ($url =~ /\?/) ? '&':'?';
1.484.2.18 raeburn 4071: $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
1.484.2.19 raeburn 4072: if ($title) {
4073: $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"');
4074: }
1.484.2.72.2. (raeburn 4075:): if ((($isexternal) || ($isexttool)) && $orderidx) {
1.484.2.19 raeburn 4076: $url .= '&idx='.$orderidx;
4077: }
1.484.2.66 raeburn 4078: if ($anchor ne '') {
4079: $url .= '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4080: }
1.329 droeschl 4081: }
1.484.2.19 raeburn 4082: my ($tdalign,$tdwidth);
1.484.2.12 raeburn 4083: if ($allowed) {
1.484.2.19 raeburn 4084: my $fileloc =
1.484.2.12 raeburn 4085: &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
1.484.2.19 raeburn 4086: if ($isexternal) {
4087: ($editlink,$extresform) =
1.484.2.67 raeburn 4088: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
4089: undef,undef,undef,$disabled);
1.484.2.72.2. (raeburn 4090:): } elsif ($orig_url =~ m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4091:): ($editlink,$extresform) =
4092:): &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
4093:): undef,undef,undef,'tool',$coursedom,
4094:): $coursenum,$ltitoolsref,$disabled);
1.484.2.19 raeburn 4095: } elsif (!$isfolder && !$ispage) {
4096: my ($cfile,$home,$switchserver,$forceedit,$forceview) =
1.484.2.14 raeburn 4097: &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
1.484.2.19 raeburn 4098: if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
1.484.2.66 raeburn 4099: my $suppanchor;
4100: if ($supplementalflag) {
4101: $suppanchor = $anchor;
4102: }
1.484.2.19 raeburn 4103: my $jscall =
1.484.2.12 raeburn 4104: &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
4105: $switchserver,
1.484.2.14 raeburn 4106: $forceedit,
1.484.2.19 raeburn 4107: undef,$symb,
4108: &escape($env{'form.folderpath'}),
1.484.2.66 raeburn 4109: $renametitle,'','',1,$suppanchor);
1.484.2.12 raeburn 4110: if ($jscall) {
1.484.2.19 raeburn 4111: $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
4112: $jscall.'" >'.&mt('Edit').'</a> '."\n";
1.484.2.12 raeburn 4113: }
4114: }
4115: }
1.484.2.19 raeburn 4116: $tdalign = ' align="right" valign="top"';
4117: $tdwidth = ' width="80%"';
1.329 droeschl 4118: }
1.408 raeburn 4119: my $reinit;
4120: if ($crstype eq 'Community') {
4121: $reinit = &mt('(re-initialize community to access)');
4122: } else {
4123: $reinit = &mt('(re-initialize course to access)');
1.484.2.19 raeburn 4124: }
4125: $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;
1.484.2.70 raeburn 4126: my $link;
1.472 raeburn 4127: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 4128: $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
4129: } elsif ($url) {
1.484.2.66 raeburn 4130: if ($anchor ne '') {
4131: if ($supplementalflag) {
4132: $anchor = '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4133: } else {
4134: $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');
4135: }
4136: }
1.484.2.70 raeburn 4137: $link = &js_escape($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.
4138: (($anchor ne '')?$anchor:''));
4139: if ($nomodal) {
4140: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4141: '<img src="'.$icon.'" alt="" class="LC_icon" border="0" /></a>';
4142: } else {
4143: $line.=&Apache::loncommon::modal_link($link,
4144: '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
4145: }
1.469 www 4146: } else {
4147: $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
4148: }
1.484.2.19 raeburn 4149: $line.='</span></td><td'.$tdwidth.'>';
1.472 raeburn 4150: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 4151: $line.='<a href="'.$url.'">'.$title.'</a>';
4152: } elsif ($url) {
1.484.2.70 raeburn 4153: if ($nomodal) {
4154: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4155: $title.'</a>';
4156: } else {
4157: $line.=&Apache::loncommon::modal_link($link,$title,600,500);
4158: }
1.484.2.67 raeburn 4159: } elsif (($hiddenfolder) || ($hiddenres)) {
1.484.2.72 raeburn 4160: $line.=$title.' <span class="LC_warning LC_docs_reinit_warn">('.&mt('Hidden').')</span>';
1.469 www 4161: } else {
4162: $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
4163: }
1.484.2.19 raeburn 4164: $line.="$extresform</td>";
1.478 raeburn 4165: $rand_pick_text = ' ' if ($rand_pick_text eq '');
4166: $rand_order_text = ' ' if ($rand_order_text eq '');
1.329 droeschl 4167: if (($allowed) && ($folder!~/^supplemental/)) {
4168: my %lt=&Apache::lonlocal::texthash(
4169: 'hd' => 'Hidden',
4170: 'ec' => 'URL hidden');
1.484.2.30 raeburn 4171: my ($enctext,$hidtext);
4172: if ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) {
4173: $enctext = ' checked="checked"';
4174: if (($ishash) && (ref($filtersref->{'encrypturl'}) eq 'ARRAY')) {
4175: push(@{$filtersref->{'encrypturl'}},$orderidx);
4176: }
4177: }
4178: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4179: $hidtext = ' checked="checked"';
4180: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4181: push(@{$filtersref->{'hiddenresource'}},$orderidx);
4182: }
4183: }
1.484.2.29 raeburn 4184: my $formhidden = 'edit_hiddenresource_'.$orderidx;
4185: my $formurlhidden = 'edit_encrypturl_'.$orderidx;
1.329 droeschl 4186: $line.=(<<ENDPARMS);
4187: <td class="LC_docs_entry_parameter">
1.484.2.30 raeburn 4188: <form action="/adm/coursedocs" method="post" name="$formhidden">
4189: $form_param
1.478 raeburn 4190: $form_common
1.484.2.67 raeburn 4191: <label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'hiddenresource','settings');" $hidtext $disabled /> $lt{'hd'}</label>
1.329 droeschl 4192: $form_end
1.458 raeburn 4193: <br />
1.484.2.29 raeburn 4194: <form action="/adm/coursedocs" method="post" name="$formurlhidden">
1.484.2.30 raeburn 4195: $form_param
1.478 raeburn 4196: $form_common
1.484.2.67 raeburn 4197: <label><input type="checkbox" name="encrypturl_$orderidx" id="encrypturl_$orderidx" onclick="checkForSubmit(this.form,'encrypturl','settings');" $enctext $disabled /> $lt{'ec'}</label>
1.329 droeschl 4198: $form_end
4199: </td>
1.478 raeburn 4200: <td class="LC_docs_entry_parameter">$rand_pick_text<br />
4201: $rand_order_text</td>
1.329 droeschl 4202: ENDPARMS
4203: }
1.379 bisitz 4204: $line.=&Apache::loncommon::end_data_table_row();
1.329 droeschl 4205: return $line;
4206: }
4207:
1.484.2.30 raeburn 4208: sub action_restrictions {
4209: my ($cnum,$cdom,$url,$folderpath,$currgroups) = @_;
4210: my %denied = (
4211: cut => 0,
4212: copy => 0,
4213: remove => 0,
4214: );
4215: if ($url=~ m{^/res/.+\.(page|sequence)$}) {
4216: # no copy for published maps
4217: $denied{'copy'} = 1;
4218: } elsif ($url=~m{^/res/lib/templates/}) {
4219: $denied{'copy'} = 1;
4220: $denied{'cut'} = 1;
4221: } elsif ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") {
4222: if ($folderpath =~ /^default&[^\&]+$/) {
4223: if ((ref($currgroups) eq 'HASH') && (keys(%{$currgroups}) > 0)) {
4224: $denied{'remove'} = 1;
4225: }
4226: $denied{'cut'} = 1;
4227: $denied{'copy'} = 1;
4228: }
4229: } elsif ($url =~ m{^\Q/uploaded/$cdom/$cnum/group_folder_\E(\w+)\.sequence$}) {
4230: my $group = $1;
4231: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+$/) {
4232: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4233: $denied{'remove'} = 1;
4234: }
4235: }
4236: $denied{'cut'} = 1;
4237: $denied{'copy'} = 1;
4238: } elsif ($url =~ m{^\Q/adm/$cdom/$cnum/\E(\w+)/smppg$}) {
4239: my $group = $1;
4240: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&\Qgroup_folder_$group\E\&[^\&]+$/) {
4241: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4242: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4243: if (keys(%groupsettings) > 0) {
4244: $denied{'remove'} = 1;
4245: }
4246: $denied{'cut'} = 1;
4247: $denied{'copy'} = 1;
4248: }
4249: }
4250: } elsif ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&group_folder_(\w+)\&/) {
4251: my $group = $1;
4252: if ($url =~ /group_boards_\Q$group\E/) {
4253: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4254: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4255: if (keys(%groupsettings) > 0) {
4256: if (ref($groupsettings{'functions'}) eq 'HASH') {
4257: if ($groupsettings{'functions'}{'discussion'} eq 'on') {
4258: $denied{'remove'} = 1;
4259: }
4260: }
4261: }
4262: $denied{'cut'} = 1;
4263: $denied{'copy'} = 1;
4264: }
4265: }
4266: }
4267: return %denied;
4268: }
4269:
1.484.2.26 raeburn 4270: sub new_timebased_suffix {
1.484.2.30 raeburn 4271: my ($dom,$num,$type,$area,$container) = @_;
1.484.2.26 raeburn 4272: my ($prefix,$namespace,$idtype,$errtext,$locknotfreed);
1.484.2.30 raeburn 4273: if ($type eq 'paste') {
4274: $prefix = $type;
4275: $namespace = 'courseeditor';
1.484.2.56 raeburn 4276: $idtype = 'addcode';
1.484.2.30 raeburn 4277: } elsif ($type eq 'map') {
1.484.2.26 raeburn 4278: $prefix = 'docs';
4279: if ($area eq 'supplemental') {
4280: $prefix = 'supp';
4281: }
4282: $prefix .= $container;
4283: $namespace = 'uploadedmaps';
4284: } else {
4285: $prefix = $type;
4286: $namespace = 'templated';
1.484.2.15 raeburn 4287: }
4288: my ($suffix,$freedlock,$error) =
1.484.2.56 raeburn 4289: &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num,$idtype);
1.484.2.15 raeburn 4290: if (!$suffix) {
1.484.2.30 raeburn 4291: if ($type eq 'paste') {
4292: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.');
4293: } elsif ($type eq 'map') {
1.484.2.26 raeburn 4294: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
4295: } elsif ($type eq 'smppg') {
4296: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.');
1.484.2.72.2. (raeburn 4297:): } elsif ($type eq 'exttool') {
4298:): $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new external tool.');
1.484.2.26 raeburn 4299: } else {
1.484.2.42 raeburn 4300: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new discussion board.');
1.484.2.26 raeburn 4301: }
1.484.2.15 raeburn 4302: if ($error) {
4303: $errtext .= '<br />'.$error;
4304: }
4305: }
4306: if ($freedlock ne 'ok') {
1.484.2.26 raeburn 4307: $locknotfreed =
4308: '<div class="LC_error">'.
4309: &mt('There was a problem removing a lockfile.').' ';
1.484.2.30 raeburn 4310: if ($type eq 'paste') {
1.484.2.57 raeburn 4311: if ($freedlock eq 'nolock') {
4312: $locknotfreed =
4313: '<div class="LC_error">'.
4314: &mt('A lockfile was not released when you added content to the clipboard earlier in this session.').' '.
4315:
1.484.2.60 raeburn 4316: &mt('As a result addition of items to the clipboard will be unavailable until your next log-in.');
1.484.2.57 raeburn 4317: } else {
4318: $locknotfreed .=
4319: &mt('This will prevent addition of items to the clipboard until your next log-in.');
4320: }
1.484.2.30 raeburn 4321: } elsif ($type eq 'map') {
1.484.2.57 raeburn 4322: $locknotfreed .=
4323: &mt('This will prevent creation of additional folders or composite pages in this course.');
1.484.2.26 raeburn 4324: } elsif ($type eq 'smppg') {
4325: $locknotfreed .=
4326: &mt('This will prevent creation of additional simple pages in this course.');
1.484.2.72.2. (raeburn 4327:): } elsif ($type eq 'exttool') {
4328:): $locknotfreed .=
4329:): &mt('This will prevent creation of additional external tools in this course.');
1.484.2.26 raeburn 4330: } else {
4331: $locknotfreed .=
1.484.2.42 raeburn 4332: &mt('This will prevent creation of additional discussion boards in this course.');
1.484.2.26 raeburn 4333: }
1.484.2.30 raeburn 4334: unless ($type eq 'paste') {
4335: $locknotfreed .=
1.484.2.38 raeburn 4336: ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
4337: '<a href="/adm/helpdesk" target="_helpdesk">','</a>');
1.484.2.30 raeburn 4338: }
4339: $locknotfreed .= '</div>';
1.484.2.15 raeburn 4340: }
4341: return ($suffix,$errtext,$locknotfreed);
4342: }
4343:
1.329 droeschl 4344: =pod
4345:
4346: =item tiehash()
4347:
4348: tie the hash
4349:
4350: =cut
4351:
4352: sub tiehash {
4353: my ($mode)=@_;
4354: $hashtied=0;
4355: if ($env{'request.course.fn'}) {
4356: if ($mode eq 'write') {
4357: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4358: &GDBM_WRCREAT(),0640)) {
4359: $hashtied=2;
4360: }
4361: } else {
4362: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4363: &GDBM_READER(),0640)) {
4364: $hashtied=1;
4365: }
4366: }
1.364 bisitz 4367: }
1.329 droeschl 4368: }
4369:
4370: sub untiehash {
4371: if ($hashtied) { untie %hash; }
4372: $hashtied=0;
4373: return OK;
4374: }
4375:
4376:
4377:
4378:
4379: sub checkonthis {
4380: my ($r,$url,$level,$title)=@_;
4381: $url=&unescape($url);
4382: $alreadyseen{$url}=1;
4383: $r->rflush();
4384: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
4385: $r->print("\n<br />");
4386: if ($level==0) {
4387: $r->print("<br />");
4388: }
4389: for (my $i=0;$i<=$level*5;$i++) {
4390: $r->print(' ');
4391: }
4392: $r->print('<a href="'.$url.'" target="cat">'.
4393: ($title?$title:$url).'</a> ');
4394: if ($url=~/^\/res\//) {
4395: my $result=&Apache::lonnet::repcopy(
4396: &Apache::lonnet::filelocation('',$url));
4397: if ($result eq 'ok') {
4398: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
4399: $r->rflush();
4400: &Apache::lonnet::countacc($url);
4401: $url=~/\.(\w+)$/;
4402: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
4403: $r->print('<br />');
4404: $r->rflush();
4405: for (my $i=0;$i<=$level*5;$i++) {
4406: $r->print(' ');
4407: }
4408: $r->print('- '.&mt('Rendering:').' ');
4409: my ($errorcount,$warningcount)=split(/:/,
4410: &Apache::lonnet::ssi_body($url,
4411: ('grade_target'=>'web',
4412: 'return_only_error_and_warning_counts' => 1)));
4413: if (($errorcount) ||
4414: ($warningcount)) {
4415: if ($errorcount) {
1.369 bisitz 4416: $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1.329 droeschl 4417: &mt('[quant,_1,error]',$errorcount).'</span>');
4418: }
4419: if ($warningcount) {
4420: $r->print('<span class="LC_warning">'.
4421: &mt('[quant,_1,warning]',$warningcount).'</span>');
4422: }
4423: } else {
4424: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
4425: }
4426: $r->rflush();
4427: }
4428: my $dependencies=
4429: &Apache::lonnet::metadata($url,'dependencies');
4430: foreach my $dep (split(/\,/,$dependencies)) {
4431: if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
4432: &checkonthis($r,$dep,$level+1);
4433: }
4434: }
4435: } elsif ($result eq 'unavailable') {
4436: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
4437: } elsif ($result eq 'not_found') {
4438: unless ($url=~/\$/) {
1.484.2.19 raeburn 4439: $r->print('<span class="LC_error">'.&mt('not found').'</span>');
1.329 droeschl 4440: } else {
1.366 bisitz 4441: $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1.329 droeschl 4442: }
4443: } else {
4444: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
4445: }
4446: }
4447: }
4448: }
4449:
4450:
4451:
4452: =pod
4453:
4454: =item list_symbs()
4455:
1.484.2.3 raeburn 4456: List Content Identifiers
1.329 droeschl 4457:
4458: =cut
4459:
4460: sub list_symbs {
4461: my ($r) = @_;
4462:
1.408 raeburn 4463: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 4464: $r->print(&Apache::loncommon::start_page('List of Content Identifiers'));
4465: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Identifiers'));
4466: $r->print(&startContentScreen('tools'));
1.329 droeschl 4467: my $navmap = Apache::lonnavmaps::navmap->new();
4468: if (!defined($navmap)) {
4469: $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
4470: '<div class="LC_error">'.
4471: &mt('Unable to retrieve information about course contents').
4472: '</div>');
1.408 raeburn 4473: &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
1.329 droeschl 4474: } else {
1.484 raeburn 4475: $r->print('<h4 class="LC_info">'.&mt("$crstype Content Identifiers").'</h4>'.
4476: &Apache::loncommon::start_data_table().
4477: &Apache::loncommon::start_data_table_header_row().
4478: '<th>'.&mt('Title').'</th><th>'.&mt('Identifier').'</th>'.
4479: &Apache::loncommon::end_data_table_header_row()."\n");
4480: my $count;
1.329 droeschl 4481: foreach my $res ($navmap->retrieveResources()) {
1.484 raeburn 4482: $r->print(&Apache::loncommon::start_data_table_row().
4483: '<td>'.$res->compTitle().'</td>'.
4484: '<td>'.$res->symb().'</td>'.
1.484.2.19 raeburn 4485: &Apache::loncommon::end_data_table_row());
1.484 raeburn 4486: $count ++;
4487: }
4488: if (!$count) {
4489: $r->print(&Apache::loncommon::start_data_table_row().
4490: '<td colspan="2">'.&mt("$crstype is empty").'</td>'.
4491: &Apache::loncommon::end_data_table_row());
1.329 droeschl 4492: }
1.484 raeburn 4493: $r->print(&Apache::loncommon::end_data_table());
1.329 droeschl 4494: }
1.484.2.19 raeburn 4495: $r->print(&endContentScreen());
1.329 droeschl 4496: }
4497:
4498:
4499: sub verifycontent {
4500: my ($r) = @_;
1.408 raeburn 4501: my $crstype = &Apache::loncommon::course_type();
1.484.2.34 raeburn 4502: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
4503: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
1.484 raeburn 4504: $r->print(&startContentScreen('tools'));
4505: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
1.329 droeschl 4506: $hashtied=0;
4507: undef %alreadyseen;
4508: %alreadyseen=();
4509: &tiehash();
1.484 raeburn 4510:
1.329 droeschl 4511: foreach my $key (keys(%hash)) {
4512: if ($hash{$key}=~/\.(page|sequence)$/) {
4513: if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
4514: $r->print('<hr /><span class="LC_error">'.
1.419 bisitz 4515: &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
1.329 droeschl 4516: &unescape($hash{$key}).'</span><br />'.
1.419 bisitz 4517: &mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />');
1.329 droeschl 4518: }
4519: }
4520: if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
4521: &checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
4522: }
4523: }
4524: &untiehash();
1.442 www 4525: $r->print('<p class="LC_success">'.&mt('Done').'</p>');
1.484.2.19 raeburn 4526: $r->print(&endContentScreen());
1.329 droeschl 4527: }
4528:
4529:
4530: sub devalidateversioncache {
4531: my $src=shift;
4532: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
4533: &Apache::lonnet::clutter($src));
4534: }
4535:
4536: sub checkversions {
1.484.2.67 raeburn 4537: my ($r,$canedit) = @_;
1.408 raeburn 4538: my $crstype = &Apache::loncommon::course_type();
1.484.2.44 raeburn 4539: $r->print(&Apache::loncommon::start_page("Check $crstype Resource Versions"));
4540: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Resource Versions"));
1.484 raeburn 4541: $r->print(&startContentScreen('tools'));
1.442 www 4542:
1.329 droeschl 4543: my $header='';
4544: my $startsel='';
4545: my $monthsel='';
4546: my $weeksel='';
4547: my $daysel='';
4548: my $allsel='';
4549: my %changes=();
4550: my $starttime=0;
4551: my $haschanged=0;
4552: my %setversions=&Apache::lonnet::dump('resourceversions',
4553: $env{'course.'.$env{'request.course.id'}.'.domain'},
4554: $env{'course.'.$env{'request.course.id'}.'.num'});
4555:
4556: $hashtied=0;
4557: &tiehash();
1.484.2.67 raeburn 4558: if ($canedit) {
4559: my %newsetversions=();
4560: if ($env{'form.setmostrecent'}) {
4561: $haschanged=1;
4562: foreach my $key (keys(%hash)) {
4563: if ($key=~/^ids\_(\/res\/.+)$/) {
4564: $newsetversions{$1}='mostrecent';
4565: &devalidateversioncache($1);
4566: }
1.329 droeschl 4567: }
1.484.2.67 raeburn 4568: } elsif ($env{'form.setcurrent'}) {
4569: $haschanged=1;
4570: foreach my $key (keys(%hash)) {
4571: if ($key=~/^ids\_(\/res\/.+)$/) {
4572: my $getvers=&Apache::lonnet::getversion($1);
4573: if ($getvers>0) {
4574: $newsetversions{$1}=$getvers;
4575: &devalidateversioncache($1);
4576: }
4577: }
1.329 droeschl 4578: }
1.484.2.67 raeburn 4579: } elsif ($env{'form.setversions'}) {
4580: $haschanged=1;
4581: foreach my $key (keys(%env)) {
4582: if ($key=~/^form\.set_version_(.+)$/) {
4583: my $src=$1;
4584: if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
4585: $newsetversions{$src}=$env{$key};
4586: &devalidateversioncache($src);
4587: }
4588: }
1.329 droeschl 4589: }
1.484.2.67 raeburn 4590: }
4591: if ($haschanged) {
4592: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
4593: $env{'course.'.$env{'request.course.id'}.'.domain'},
4594: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
4595: $r->print(&Apache::loncommon::confirmwrapper(
4596: &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
4597: } else {
4598: $r->print(&Apache::loncommon::confirmwrapper(
4599: &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
4600: }
4601: &mark_hash_old();
4602: }
4603: &changewarning($r,'');
1.329 droeschl 4604: }
4605: if ($env{'form.timerange'} eq 'all') {
4606: # show all documents
1.484.2.34 raeburn 4607: $header=&mt('All content in '.$crstype);
1.484.2.19 raeburn 4608: $allsel=' selected="selected"';
1.329 droeschl 4609: foreach my $key (keys(%hash)) {
4610: if ($key=~/^ids\_(\/res\/.+)$/) {
4611: my $src=$1;
4612: $changes{$src}=1;
4613: }
4614: }
4615: } else {
4616: # show documents which changed
4617: %changes=&Apache::lonnet::dump
4618: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
4619: $env{'course.'.$env{'request.course.id'}.'.num'});
4620: my $firstkey=(keys(%changes))[0];
4621: unless ($firstkey=~/^error\:/) {
4622: unless ($env{'form.timerange'}) {
4623: $env{'form.timerange'}=604800;
4624: }
4625: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
4626: .&mt('seconds');
4627: if ($env{'form.timerange'}==-1) {
4628: $seltext='since start of course';
1.484.2.19 raeburn 4629: $startsel=' selected="selected"';
1.329 droeschl 4630: $env{'form.timerange'}=time;
4631: }
4632: $starttime=time-$env{'form.timerange'};
4633: if ($env{'form.timerange'}==2592000) {
4634: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 4635: $monthsel=' selected="selected"';
1.329 droeschl 4636: } elsif ($env{'form.timerange'}==604800) {
4637: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 4638: $weeksel=' selected="selected"';
1.329 droeschl 4639: } elsif ($env{'form.timerange'}==86400) {
4640: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 4641: $daysel=' selected="selected"';
1.329 droeschl 4642: }
4643: $header=&mt('Content changed').' '.$seltext;
4644: } else {
4645: $header=&mt('No content modifications yet.');
4646: }
4647: }
4648: %setversions=&Apache::lonnet::dump('resourceversions',
4649: $env{'course.'.$env{'request.course.id'}.'.domain'},
4650: $env{'course.'.$env{'request.course.id'}.'.num'});
4651: my %lt=&Apache::lonlocal::texthash
1.408 raeburn 4652: ('st' => 'Version changes since start of '.$crstype,
1.329 droeschl 4653: 'lm' => 'Version changes since last Month',
4654: 'lw' => 'Version changes since last Week',
4655: 'sy' => 'Version changes since Yesterday',
4656: 'al' => 'All Resources (possibly large output)',
1.484 raeburn 4657: 'cd' => 'Change display',
1.329 droeschl 4658: 'sd' => 'Display',
4659: 'fi' => 'File',
4660: 'md' => 'Modification Date',
4661: 'mr' => 'Most recently published Version',
1.408 raeburn 4662: 've' => 'Version used in '.$crstype,
4663: 'vu' => 'Set Version to be used in '.$crstype,
4664: 'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
1.329 droeschl 4665: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
4666: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.479 golterma 4667: 'di' => 'Differences',
1.484 raeburn 4668: 'save' => 'Save changes',
4669: 'vers' => 'Version choice(s) for specific resources',
1.479 golterma 4670: 'act' => 'Actions');
1.484.2.67 raeburn 4671: my ($disabled,$readonly);
4672: unless ($canedit) {
4673: $disabled = 'disabled="disabled"';
4674: $readonly = 1;
4675: }
1.329 droeschl 4676: $r->print(<<ENDHEADERS);
1.484 raeburn 4677: <h4 class="LC_info">$header</h4>
1.329 droeschl 4678: <form action="/adm/coursedocs" method="post">
4679: <input type="hidden" name="versions" value="1" />
1.484 raeburn 4680: <div class="LC_left_float">
1.479 golterma 4681: <fieldset>
1.484 raeburn 4682: <legend>$lt{'cd'}</legend>
1.329 droeschl 4683: <select name="timerange">
1.484.2.19 raeburn 4684: <option value='all'$allsel>$lt{'al'}</option>
4685: <option value="-1"$startsel>$lt{'st'}</option>
4686: <option value="2592000"$monthsel>$lt{'lm'}</option>
4687: <option value="604800"$weeksel>$lt{'lw'}</option>
4688: <option value="86400"$daysel>$lt{'sy'}</option>
1.329 droeschl 4689: </select>
4690: <input type="submit" name="display" value="$lt{'sd'}" />
1.484 raeburn 4691: </fieldset>
4692: </div>
4693: <div class="LC_left_float">
4694: <fieldset>
4695: <legend>$lt{'act'}</legend>
1.484.2.67 raeburn 4696: $lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" $disabled /><br />
4697: $lt{'sc'}: <input type="submit" name="setcurrent" value="Go" $disabled />
1.484 raeburn 4698: </fieldset>
4699: </div>
4700: <br clear="all" />
4701: <hr />
4702: <h4>$lt{'vers'}</h4>
1.329 droeschl 4703: ENDHEADERS
1.479 golterma 4704: #number of columns for version history
1.484.2.44 raeburn 4705: my %changedbytime;
4706: foreach my $key (keys(%changes)) {
4707: #excludes not versionable problems from resource version history:
4708: next if ($key =~ /^\/res\/lib\/templates/);
4709: my $chg;
4710: if ($env{'form.timerange'} eq 'all') {
4711: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
4712: $chg = &Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate');
4713: } else {
4714: $chg = $changes{$key};
4715: next if ($chg < $starttime);
4716: }
4717: push(@{$changedbytime{$chg}},$key);
4718: }
4719: if (keys(%changedbytime) == 0) {
4720: &untiehash();
4721: $r->print(&mt('No content changes in imported content in specified time frame').
4722: &endContentScreen());
4723: return;
4724: }
1.479 golterma 4725: $r->print(
1.484.2.67 raeburn 4726: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.484.2.19 raeburn 4727: &Apache::loncommon::start_data_table().
4728: &Apache::loncommon::start_data_table_header_row().
4729: '<th>'.&mt('Resources').'</th>'.
4730: "<th>$lt{'mr'}</th>".
4731: "<th>$lt{'ve'}</th>".
4732: "<th>$lt{'vu'}</th>".
4733: '<th>'.&mt('History').'</th>'.
4734: &Apache::loncommon::end_data_table_header_row()
4735: );
1.484.2.44 raeburn 4736: foreach my $chg (sort {$b <=> $a } keys(%changedbytime)) {
4737: foreach my $key (sort(@{$changedbytime{$chg}})) {
4738: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
4739: my $currentversion=&Apache::lonnet::getversion($key);
4740: if ($currentversion<0) {
4741: $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
4742: }
4743: my $linkurl=&Apache::lonnet::clutter($key);
4744: $r->print(
4745: &Apache::loncommon::start_data_table_row().
4746: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br />'.
4747: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
4748: '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br />('.
4749: &Apache::lonlocal::locallocaltime($chg).')</span></td>'.
4750: '<td align="right">'
4751: );
4752: # Used in course
4753: my $usedversion=$hash{'version_'.$linkurl};
4754: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.484.2.19 raeburn 4755: if ($usedversion != $currentversion) {
1.479 golterma 4756: $r->print('<span class="LC_warning">'.$usedversion.'</span>');
1.484.2.19 raeburn 4757: } else {
1.479 golterma 4758: $r->print($usedversion);
4759: }
1.329 droeschl 4760: } else {
1.484.2.19 raeburn 4761: $r->print($currentversion);
1.329 droeschl 4762: }
1.484.2.44 raeburn 4763: $r->print('</td><td title="'.$lt{'vu'}.'">');
4764: # Set version
4765: $r->print(&Apache::loncommon::select_form(
4766: $setversions{$linkurl},
4767: 'set_version_'.$linkurl,
4768: {'select_form_order' => ['',1..$currentversion,'mostrecent'],
4769: '' => '',
4770: 'mostrecent' => &mt('most recent'),
1.484.2.67 raeburn 4771: map {$_,$_} (1..$currentversion)},'',$readonly));
1.484.2.44 raeburn 4772: my $lastold=1;
4773: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
4774: my $url=$root.'.'.$prevvers.'.'.$extension;
4775: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) {
4776: $lastold=$prevvers;
4777: }
4778: }
4779: $r->print('</td>');
4780: # List all available versions
4781: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
4782: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
4783: my $url=$root.'.'.$prevvers.'.'.$extension;
1.484.2.19 raeburn 4784: $r->print(
1.484.2.44 raeburn 4785: '<span class="LC_nobreak">'
4786: .'<a href="'.&Apache::lonnet::clutter($url).'">'
4787: .&mt('Version [_1]',$prevvers).'</a>'
4788: .' ('.&Apache::lonlocal::locallocaltime(
4789: &Apache::lonnet::metadata($url,'lastrevisiondate'))
4790: .')');
4791: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
4792: $r->print(
4793: ' <a href="/adm/diff?filename='.
4794: &Apache::lonnet::clutter($root.'.'.$extension).
4795: &HTML::Entities::encode('&versionone='.$prevvers,'"<>&').
4796: '" target="diffs">'.&mt('Diffs').'</a>');
4797: }
4798: $r->print('</span><br />');
1.329 droeschl 4799: }
1.484.2.44 raeburn 4800: $r->print('</span></td>'.&Apache::loncommon::end_data_table_row());
1.484.2.19 raeburn 4801: }
1.329 droeschl 4802: }
1.484.2.19 raeburn 4803: $r->print(
4804: &Apache::loncommon::end_data_table().
1.484.2.67 raeburn 4805: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.484.2.19 raeburn 4806: '</form>'
4807: );
1.329 droeschl 4808:
4809: &untiehash();
1.484.2.19 raeburn 4810: $r->print(&endContentScreen());
1.484.2.44 raeburn 4811: return;
1.329 droeschl 4812: }
4813:
4814: sub mark_hash_old {
4815: my $retie_hash=0;
4816: if ($hashtied) {
4817: $retie_hash=1;
4818: &untiehash();
4819: }
4820: &tiehash('write');
4821: $hash{'old'}=1;
4822: &untiehash();
4823: if ($retie_hash) { &tiehash(); }
4824: }
4825:
4826: sub is_hash_old {
4827: my $untie_hash=0;
4828: if (!$hashtied) {
4829: $untie_hash=1;
4830: &tiehash();
4831: }
4832: my $return=$hash{'old'};
4833: if ($untie_hash) { &untiehash(); }
4834: return $return;
4835: }
4836:
4837: sub changewarning {
4838: my ($r,$postexec,$message,$url)=@_;
4839: if (!&is_hash_old()) { return; }
4840: my $pathvar='folderpath';
4841: my $path=&escape($env{'form.folderpath'});
4842: if (!defined($url)) {
4843: $url='/adm/coursedocs?'.$pathvar.'='.$path;
4844: }
4845: my $course_type = &Apache::loncommon::course_type();
4846: if (!defined($message)) {
4847: $message='Changes will become active for your current session after [_1], or the next time you log in.';
4848: }
4849: $r->print("\n\n".
1.372 bisitz 4850: '<script type="text/javascript">'."\n".
4851: '// <![CDATA['."\n".
4852: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
4853: '// ]]>'."\n".
1.369 bisitz 4854: '</script>'."\n".
1.375 tempelho 4855: '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
1.329 droeschl 4856: '<input type="hidden" name="orgurl" value="'.$url.
1.372 bisitz 4857: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
1.329 droeschl 4858: &mt($message,' <input type="hidden" name="'.
4859: $env{'request.role'}.'" value="1" /><input type="button" value="'.
1.369 bisitz 4860: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1.372 bisitz 4861: $help{'Caching'}.'</p></form>'."\n\n");
1.329 droeschl 4862: }
4863:
4864:
4865: sub init_breadcrumbs {
1.484.2.44 raeburn 4866: my ($form,$text,$help)=@_;
1.329 droeschl 4867: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484 raeburn 4868: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
1.405 bisitz 4869: text=>&Apache::loncommon::course_type().' Editor',
1.329 droeschl 4870: faq=>273,
4871: bug=>'Instructor Interface',
1.484.2.44 raeburn 4872: help => $help});
1.329 droeschl 4873: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
4874: text=>$text,
4875: faq=>273,
4876: bug=>'Instructor Interface'});
4877: }
4878:
1.441 www 4879: # subroutine to list form elements
4880: sub create_list_elements {
4881: my @formarr = @_;
4882: my $list = '';
1.484.2.12 raeburn 4883: foreach my $button (@formarr){
4884: foreach my $picture (keys(%{$button})) {
4885: $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
1.441 www 4886: }
4887: }
4888: return $list;
4889: }
1.329 droeschl 4890:
1.441 www 4891: # subroutine to create ul from list elements
4892: sub create_form_ul {
4893: my $list = shift;
4894: my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
4895: return $ul;
4896: }
1.329 droeschl 4897:
1.442 www 4898: #
4899: # Start tabs
4900: #
4901:
4902: sub startContentScreen {
1.484 raeburn 4903: my ($mode) = @_;
4904: my $output = '<ul class="LC_TabContentBigger" id="mainnav">';
1.472 raeburn 4905: if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
1.484 raeburn 4906: $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n";
4907: $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n";
4908: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
4909: } else {
1.484.2.34 raeburn 4910: $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 4911: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
4912: $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>'."\n";
4913: '><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>';
4914: }
4915: $output .= "\n".'</ul>'."\n";
4916: $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
4917: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
4918: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
4919: return $output;
1.442 www 4920: }
4921:
4922: #
4923: # End tabs
4924: #
4925:
4926: sub endContentScreen {
1.484 raeburn 4927: return '</div></div></div>';
1.442 www 4928: }
1.329 droeschl 4929:
1.446 www 4930: sub supplemental_base {
1.484.2.33 raeburn 4931: return 'supplemental&'.&escape(&mt('Supplemental Content'));
1.446 www 4932: }
4933:
1.329 droeschl 4934: sub handler {
4935: my $r = shift;
4936: &Apache::loncommon::content_type($r,'text/html');
4937: $r->send_http_header;
4938: return OK if $r->header_only;
1.484 raeburn 4939:
4940: # get course data
1.408 raeburn 4941: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 4942: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
4943: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
4944:
4945: # graphics settings
4946: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329 droeschl 4947:
1.443 www 4948: #
1.329 droeschl 4949: # --------------------------------------------- Initialize help topics for this
4950: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
1.484.2.72.2. (raeburn 4951:): 'Adding_External_Resource','Adding_External_Tool',
4952:): 'Navigate_Content','Adding_Folders','Docs_Overview',
4953:): 'Load_Map','Supplemental','Score_Upload_Form',
4954:): 'Adding_Pages','Importing_LON-CAPA_Resource',
4955:): 'Importing_IMS_Course','Uploading_From_Harddrive',
4956:): 'Course_Roster','Web_Page','Dropbox','Simple_Problem') {
1.329 droeschl 4957: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
4958: }
4959: # Composite help files
4960: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
4961: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
4962: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
4963: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
4964: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
4965: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 4966: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 4967: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 4968: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 4969: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1.484.2.30 raeburn 4970:
1.484.2.67 raeburn 4971: my ($allowed,$canedit,$canview,$disabled);
1.472 raeburn 4972: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
4973: unless ($r->uri eq '/adm/supplemental') {
4974: # does this user have privileges to modify content.
1.484.2.67 raeburn 4975: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
4976: $allowed = 1;
4977: $canedit = 1;
4978: $canview = 1;
4979: } elsif (&Apache::lonnet::allowed('cev',$env{'request.course.id'})) {
4980: $allowed = 1;
4981: $canview = 1;
4982: }
4983: }
4984: unless ($canedit) {
4985: $disabled = ' disabled="disabled"';
1.472 raeburn 4986: }
1.484.2.53 raeburn 4987: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']);
1.484.2.72.2. (raeburn 4988:): if ($env{'form.inhibitmenu'}) {
4989:): unless ($env{'form.inhibitmenu'} eq 'yes') {
4990:): delete($env{'form.inhibitmenu'});
4991:): }
4992:): }
1.484.2.53 raeburn 4993: if ($allowed && $env{'form.verify'}) {
1.484.2.44 raeburn 4994: &init_breadcrumbs('verify','Verify Content','Docs_Verify_Content');
1.329 droeschl 4995: &verifycontent($r);
4996: } elsif ($allowed && $env{'form.listsymbs'}) {
1.484 raeburn 4997: &init_breadcrumbs('listsymbs','List Content IDs');
1.329 droeschl 4998: &list_symbs($r);
4999: } elsif ($allowed && $env{'form.docslog'}) {
5000: &init_breadcrumbs('docslog','Show Log');
1.484 raeburn 5001: my $folder = $env{'form.folder'};
5002: if ($folder eq '') {
5003: $folder='default';
5004: }
1.484.2.67 raeburn 5005: &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit);
1.329 droeschl 5006: } elsif ($allowed && $env{'form.versions'}) {
1.484.2.44 raeburn 5007: &init_breadcrumbs('versions','Check/Set Resource Versions','Docs_Check_Resource_Versions');
1.484.2.67 raeburn 5008: &checkversions($r,$canedit);
5009: } elsif ($canedit && $env{'form.dumpcourse'}) {
1.484.2.43 raeburn 5010: &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329 droeschl 5011: &dumpcourse($r);
5012: } elsif ($allowed && $env{'form.exportcourse'}) {
1.377 bisitz 5013: &init_breadcrumbs('exportcourse','IMS Export');
1.475 raeburn 5014: &Apache::imsexport::exportcourse($r);
1.329 droeschl 5015: } else {
1.445 www 5016: #
5017: # Done catching special calls
1.484 raeburn 5018: # The whole rest is for course and supplemental documents and utilities menu
1.445 www 5019: # Get the parameters that may be needed
5020: #
5021: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.484.2.19 raeburn 5022: ['folderpath',
5023: 'forcesupplement','forcestandard',
5024: 'tools','symb','command','supppath']);
1.445 www 5025:
1.484.2.72.2. (raeburn 5026:): foreach my $item ('forcesupplement','forcestandard','tools') {
5027:): next if ($env{'form.'.$item} eq '');
5028:): unless ($env{'form.'.$item} eq '1') {
5029:): delete($env{'form.'.$item});
5030:): }
5031:): }
5032:):
5033:): if ($env{'form.command'}) {
5034:): unless ($env{'form.command'} =~ /^(direct|directnav|editdocs|editsupp|contents|home)$/) {
5035:): delete($env{'form.command'});
5036:): }
5037:): }
5038:):
5039:): if ($env{'form.symb'}) {
5040:): my ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.symb'});
5041:): unless (($id =~ /^\d+$/) && (&Apache::lonnet::is_on_map($resurl))) {
5042:): delete($env{'form.symb'});
5043:): }
5044:): }
1.445 www 5045: # standard=1: this is a "new-style" course with an uploaded map as top level
5046: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329 droeschl 5047:
5048: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445 www 5049:
1.484 raeburn 5050: # Decide whether this should display supplemental or main content or utilities
1.445 www 5051: # supplementalflag=1: show supplemental documents
5052: # supplementalflag=0: show standard documents
1.484 raeburn 5053: # toolsflag=1: show utilities
1.445 www 5054:
1.484.2.39 raeburn 5055: my $unesc_folderpath = &unescape($env{'form.folderpath'});
5056: my $supplementalflag=($unesc_folderpath=~/^supplemental/);
5057: if (($unesc_folderpath=~/^default/) || ($unesc_folderpath eq "")) {
1.445 www 5058: $supplementalflag=0;
5059: }
5060: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
5061: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
5062: unless ($allowed) { $supplementalflag=1; }
5063: unless ($standard) { $supplementalflag=1; }
1.484 raeburn 5064: my $toolsflag=0;
5065: if ($env{'form.tools'}) { $toolsflag=1; }
1.445 www 5066:
1.484.2.72.2. (raeburn 5067:): if ($env{'form.folderpath'} ne '') {
5068:): my @items = split(/\&/,$env{'form.folderpath'});
5069:): my $badpath;
5070:): for (my $i=0; $i<@items; $i++) {
5071:): my $odd = $i%2;
5072:): if (($odd) && (!$supplementalflag) && ($items[$i] !~ /^[^:]*:(|\d+):(|1):(|1):(|1):(|1)$/)) {
5073:): $badpath = 1;
5074:): } elsif ((!$odd) && ($items[$i] !~ /^(default|supplemental)(|_\d+)$/)) {
5075:): $badpath = 1;
5076:): }
5077:): last if ($badpath);
5078:): }
5079:): if ($badpath) {
5080:): delete($env{'form.folderpath'});
5081:): }
5082:): }
5083:):
5084:): if ($env{'form.supppath'} ne '') {
5085:): my @items = split(/\&/,$env{'form.supppath'});
5086:): my $badpath;
5087:): for (my $i=0; $i<@items; $i++) {
5088:): my $odd = $i%2;
5089:): if ((!$odd) && ($items[$i] !~ /^supplemental(|_\d+)$/)) {
5090:): $badpath = 1;
5091:): }
5092:): last if ($badpath);
5093:): }
5094:): if ($badpath) {
5095:): delete($env{'form.supppath'});
5096:): }
5097:): }
5098:):
1.329 droeschl 5099: my $script='';
5100: my $showdoc=0;
1.457 raeburn 5101: my $addentries = {};
1.475 raeburn 5102: my $container;
1.329 droeschl 5103: my $containertag;
1.484.2.17 raeburn 5104: my $pathitem;
1.484.2.72.2. (raeburn 5105:): my %ltitools;
1.484.2.67 raeburn 5106: my $hiddentop;
5107: my $navmap;
5108: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.329 droeschl 5109:
1.464 www 5110: # Do we directly jump somewhere?
1.484.2.21 raeburn 5111: if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
1.472 raeburn 5112: if ($env{'form.symb'} ne '') {
1.484.2.19 raeburn 5113: $env{'form.folderpath'}=
1.484.2.67 raeburn 5114: &Apache::loncommon::symb_to_docspath($env{'form.symb'},\$navmap);
1.484.2.21 raeburn 5115: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
5116: $env{'form.command'}.'_'.$env{'form.symb'}});
1.472 raeburn 5117: } elsif ($env{'form.supppath'} ne '') {
5118: $env{'form.folderpath'}=$env{'form.supppath'};
1.484.2.21 raeburn 5119: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
5120: $env{'form.command'}.'_'.$env{'form.supppath'}});
1.466 www 5121: }
1.472 raeburn 5122: } elsif ($env{'form.command'} eq 'editdocs') {
1.484.2.67 raeburn 5123: $env{'form.folderpath'} = &default_folderpath($coursenum,$coursedom,\$navmap);
1.484.2.21 raeburn 5124: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
1.472 raeburn 5125: } elsif ($env{'form.command'} eq 'editsupp') {
1.484.2.67 raeburn 5126: $env{'form.folderpath'} = &supplemental_base();
1.484.2.21 raeburn 5127: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
5128: } elsif ($env{'form.command'} eq 'contents') {
5129: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
5130: } elsif ($env{'form.command'} eq 'home') {
5131: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
1.464 www 5132: }
5133:
1.484.2.23 raeburn 5134:
1.445 www 5135: # Where do we store these for when we come back?
5136: my $stored_folderpath='docs_folderpath';
5137: if ($supplementalflag) {
5138: $stored_folderpath='docs_sup_folderpath';
5139: }
1.464 www 5140:
1.484.2.19 raeburn 5141: # No folderpath, and in edit mode, see if we have something stored
5142: if ((!$env{'form.folderpath'}) && $allowed) {
1.445 www 5143: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.484.2.19 raeburn 5144: {'folderpath' => 'scalar'});
1.484.2.67 raeburn 5145:
5146: if (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
5147: if ($supplementalflag) {
5148: undef($env{'form.folderpath'}) if ($1 eq 'default');
5149: } else {
5150: undef($env{'form.folderpath'}) if ($1 eq 'supplemental');
5151: }
5152: } else {
1.484.2.19 raeburn 5153: undef($env{'form.folderpath'});
5154: }
1.329 droeschl 5155: }
1.446 www 5156:
5157: # If we are not allowed to make changes, all we can see are supplemental docs
1.409 raeburn 5158: if (!$allowed) {
1.446 www 5159: unless ($env{'form.folderpath'} =~ /^supplemental/) {
5160: $env{'form.folderpath'} = &supplemental_base();
1.409 raeburn 5161: }
5162: }
1.446 www 5163: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329 droeschl 5164: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446 www 5165: $env{'form.folderpath'} = &supplemental_base()
5166: .'&'.
1.329 droeschl 5167: $env{'form.folderpath'};
5168: }
1.484.2.67 raeburn 5169: # If allowed and user's role is not advanced check folderpath is not hidden
5170: if (($allowed) && (!$env{'request.role.adv'}) &&
5171: ($env{'form.folderpath'} ne '') && (!$supplementalflag)) {
5172: my $folderurl;
5173: my @pathitems = split(/\&/,$env{'form.folderpath'});
5174: my $folder = $pathitems[-2];
5175: if ($folder eq '') {
5176: undef($env{'form.folderpath'});
5177: } else {
5178: $folderurl = "uploaded/$coursedom/$coursenum/$folder";
5179: if ((split(/\:/,$pathitems[-1]))[4]) {
5180: $folderurl .= '.page';
5181: } else {
5182: $folderurl .= '.sequence';
5183: }
5184: unless (ref($navmap)) {
5185: $navmap = Apache::lonnavmaps::navmap->new();
5186: }
5187: if (ref($navmap)) {
5188: if (lc($navmap->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
5189: my @resources = $navmap->retrieveResources($folderurl,$filterFunc,1,1);
5190: unless (@resources) {
5191: undef($env{'form.folderpath'});
5192: }
5193: }
5194: }
5195: }
5196: }
5197:
5198:
1.446 www 5199: # If after all of this, we still don't have any paths, make them
1.484.2.19 raeburn 5200: unless ($env{'form.folderpath'}) {
1.446 www 5201: if ($supplementalflag) {
5202: $env{'form.folderpath'}=&supplemental_base();
1.484.2.67 raeburn 5203: } elsif ($allowed) {
5204: ($env{'form.folderpath'},$hiddentop) = &default_folderpath($coursenum,$coursedom,\$navmap);
1.446 www 5205: }
1.472 raeburn 5206: }
1.446 www 5207:
1.445 www 5208: # Store this
1.484 raeburn 5209: unless ($toolsflag) {
1.484.2.67 raeburn 5210: if (($allowed) && ($env{'form.folderpath'} ne '')) {
1.484.2.19 raeburn 5211: &Apache::loncommon::store_course_settings($stored_folderpath,
5212: {'folderpath' => 'scalar'});
5213: }
5214: my $folderpath;
1.484 raeburn 5215: if ($env{'form.folderpath'}) {
1.484.2.19 raeburn 5216: $folderpath = $env{'form.folderpath'};
5217: my (@folders)=split('&',$env{'form.folderpath'});
5218: $env{'form.foldername'}=&unescape(pop(@folders));
5219: if ($env{'form.foldername'} =~ /\:1$/) {
5220: $container = 'page';
5221: } else {
5222: $container = 'sequence';
5223: }
5224: $env{'form.folder'}=pop(@folders);
1.484 raeburn 5225: } else {
1.484.2.19 raeburn 5226: if ($env{'form.folder'} eq '' ||
5227: $env{'form.folder'} eq 'supplemental') {
1.484.2.67 raeburn 5228: if ($env{'form.folder'} eq 'supplemental') {
5229: $folderpath=&supplemental_base();
5230: } elsif (!$hiddentop) {
5231: $folderpath='default&'.
5232: &escape(&mt('Main Content').':::::');
5233: }
1.484 raeburn 5234: }
5235: }
1.484.2.19 raeburn 5236: $containertag = '<input type="hidden" name="folderpath" value="" />';
5237: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 5238: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
5239: $showdoc='/'.$1;
5240: }
5241: if ($showdoc) { # got called in sequence from course
5242: $allowed=0;
5243: } else {
1.484.2.67 raeburn 5244: if ($canedit) {
1.484 raeburn 5245: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
5246: $script=&Apache::lonratedt::editscript('simple');
1.433 raeburn 5247: }
5248: }
1.329 droeschl 5249: }
5250:
1.344 bisitz 5251: # get personal data
1.329 droeschl 5252: my $uname=$env{'user.name'};
5253: my $udom=$env{'user.domain'};
5254: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
5255:
5256: if ($allowed) {
1.484 raeburn 5257: if ($toolsflag) {
5258: $script .= &inject_data_js();
5259: my ($home,$other,%outhash)=&authorhosts();
5260: if (!$home && $other) {
5261: my @hosts;
5262: foreach my $aurole (keys(%outhash)) {
5263: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
5264: push(@hosts,$outhash{$aurole});
5265: }
5266: }
5267: $script .= &dump_switchserver_js(@hosts);
5268: }
1.458 raeburn 5269: } else {
1.484.2.43 raeburn 5270: my $tid = 1;
1.484 raeburn 5271: my @tabids;
5272: if ($supplementalflag) {
5273: @tabids = ('002','ee2','ff2');
1.484.2.43 raeburn 5274: $tid = 2;
1.484 raeburn 5275: } else {
5276: @tabids = ('aa1','bb1','cc1','ff1');
1.484.2.19 raeburn 5277: unless ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 5278: unshift(@tabids,'001');
5279: push(@tabids,('dd1','ee1'));
5280: }
1.458 raeburn 5281: }
1.484 raeburn 5282: my $tabidstr = join("','",@tabids);
1.484.2.72.2. (raeburn 5283:): %ltitools = &Apache::lonnet::get_domain_ltitools($coursedom);
5284:): my $posslti = keys(%ltitools);
5285:): $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
1.484.2.67 raeburn 5286: $canedit,\$navmap).
1.484 raeburn 5287: &history_tab_js().
5288: &inject_data_js().
1.484.2.43 raeburn 5289: &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
1.484.2.72.2. (raeburn 5290:): &Apache::lonextresedit::extedit_javascript(\%ltitools);
1.484 raeburn 5291: $addentries = {
1.484.2.3 raeburn 5292: onload => "javascript:resize_scrollbox('contentscroll','1','1');",
1.484 raeburn 5293: };
1.458 raeburn 5294: }
1.484.2.30 raeburn 5295: $script .= &paste_popup_js();
1.484.2.12 raeburn 5296: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
5297: &mt('Switch server?');
1.484.2.19 raeburn 5298:
5299:
1.329 droeschl 5300: }
5301: # -------------------------------------------------------------------- Body tag
1.369 bisitz 5302: $script = '<script type="text/javascript">'."\n"
1.372 bisitz 5303: .'// <![CDATA['."\n"
5304: .$script."\n"
5305: .'// ]]>'."\n"
5306: .'</script>'."\n";
1.385 bisitz 5307:
5308: # Breadcrumbs
5309: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484.2.19 raeburn 5310:
5311: if ($showdoc) {
5312: $r->print(&Apache::loncommon::start_page("$crstype documents",undef,
5313: {'force_register' => $showdoc,}));
1.484.2.44 raeburn 5314: } elsif ($toolsflag) {
1.484.2.67 raeburn 5315: my ($breadtext,$breadtitle);
5316: $breadtext = "$crstype Editor";
5317: if ($canedit) {
5318: $breadtitle = 'Editing '.$crstype.' Contents';
5319: } else {
5320: $breadtext .= ' (View-only mode)';
5321: $breadtitle = 'Viewing '.$crstype.' Contents';
5322: }
1.484.2.44 raeburn 5323: &Apache::lonhtmlcommon::add_breadcrumb({
1.484.2.67 raeburn 5324: href=>"/adm/coursedocs",text=>$breadtext});
1.484.2.44 raeburn 5325: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script)
5326: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5327: .&Apache::lonhtmlcommon::breadcrumbs(
1.484.2.67 raeburn 5328: $breadtitle)
1.484.2.44 raeburn 5329: );
1.484.2.19 raeburn 5330: } elsif ($r->uri eq '/adm/supplemental') {
5331: my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
5332: $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
5333: {'bread_crumbs' => $brcrum,}));
5334: } else {
1.484.2.67 raeburn 5335: my ($breadtext,$breadtitle,$helpitem);
5336: $breadtext = "$crstype Editor";
5337: if ($canedit) {
5338: $breadtitle = 'Editing '.$crstype.' Contents';
5339: $helpitem = 'Docs_Adding_Course_Doc';
5340: } else {
5341: $breadtext .= ' (View-only mode)';
5342: $breadtitle = 'Viewing '.$crstype.' Contents';
5343: $helpitem = 'Docs_Viewing_Course_Doc';
5344: }
1.392 raeburn 5345: &Apache::lonhtmlcommon::add_breadcrumb({
1.484.2.67 raeburn 5346: href=>"/adm/coursedocs",text=>$breadtext});
1.446 www 5347: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.484.2.19 raeburn 5348: {'add_entries' => $addentries}
5349: )
1.392 raeburn 5350: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5351: .&Apache::lonhtmlcommon::breadcrumbs(
1.484.2.67 raeburn 5352: $breadtitle,
5353: $helpitem)
1.392 raeburn 5354: );
5355: }
1.364 bisitz 5356:
1.329 droeschl 5357: my %allfiles = ();
5358: my %codebase = ();
1.440 raeburn 5359: my ($upload_result,$upload_output,$uploadphase);
1.484.2.67 raeburn 5360: if ($canedit) {
1.329 droeschl 5361: if (($env{'form.uploaddoc.filename'}) &&
5362: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440 raeburn 5363: my $context = $1;
5364: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 5365: undef($hadchanges);
1.440 raeburn 5366: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
1.484.2.36 raeburn 5367: \%allfiles,\%codebase,$context,$crstype);
1.484.2.72.2. (raeburn 5368:): undef($navmap);
1.329 droeschl 5369: if ($hadchanges) {
5370: &mark_hash_old();
5371: }
1.440 raeburn 5372: $r->print($upload_output);
5373: } elsif ($env{'form.phase'} eq 'upload_embedded') {
5374: # Process file upload - phase two - upload embedded objects
5375: $uploadphase = 'check_embedded';
5376: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
5377: my $state = &embedded_form_elems($uploadphase,$primaryurl,
5378: $env{'form.newidx'});
5379: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5380: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5381: my ($destination,$dir_root) = &embedded_destination();
5382: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
5383: my $actionurl = '/adm/coursedocs';
5384: my ($result,$flag) =
5385: &Apache::loncommon::upload_embedded('coursedoc',$destination,
5386: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
5387: $actionurl);
5388: $r->print($result.&return_to_editor());
5389: } elsif ($env{'form.phase'} eq 'check_embedded') {
5390: # Process file upload - phase three - modify references in HTML file
5391: $uploadphase = 'modified_orightml';
5392: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5393: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5394: my ($destination,$dir_root) = &embedded_destination();
1.482 raeburn 5395: my $result =
5396: &Apache::loncommon::modify_html_refs('coursedoc',$destination,
5397: $docuname,$docudom,undef,
5398: $dir_root);
5399: $r->print($result.&return_to_editor());
1.476 raeburn 5400: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
5401: $uploadphase = 'decompress_phase_one';
5402: $r->print(&decompression_phase_one().
5403: &return_to_editor());
5404: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
5405: $uploadphase = 'decompress_phase_two';
5406: $r->print(&decompression_phase_two().
5407: &return_to_editor());
1.329 droeschl 5408: }
5409: }
5410:
1.484 raeburn 5411: if ($allowed && $toolsflag) {
5412: $r->print(&startContentScreen('tools'));
1.484.2.67 raeburn 5413: $r->print(&generate_admin_menu($crstype,$canedit));
1.484 raeburn 5414: $r->print(&endContentScreen());
5415: } elsif ((!$showdoc) && (!$uploadphase)) {
1.329 droeschl 5416: # -----------------------------------------------------------------------------
5417: my %lt=&Apache::lonlocal::texthash(
5418: 'copm' => 'All documents out of a published map into this folder',
1.484.2.12 raeburn 5419: 'upfi' => 'Upload File',
1.484.2.36 raeburn 5420: 'upld' => 'Upload Content',
1.329 droeschl 5421: 'srch' => 'Search',
5422: 'impo' => 'Import',
1.484.2.19 raeburn 5423: 'lnks' => 'Import from Stored Links',
1.484.2.13 raeburn 5424: 'impm' => 'Import from Assembled Map',
1.484.2.72.2. (raeburn 5425:): 'extr' => 'External Resource',
5426:): 'extt' => 'External Tool',
1.329 droeschl 5427: 'selm' => 'Select Map',
5428: 'load' => 'Load Map',
5429: 'newf' => 'New Folder',
5430: 'newp' => 'New Composite Page',
5431: 'syll' => 'Syllabus',
1.425 raeburn 5432: 'navc' => 'Table of Contents',
1.343 biermanm 5433: 'sipa' => 'Simple Course Page',
1.329 droeschl 5434: 'sipr' => 'Simple Problem',
1.484.2.27 raeburn 5435: 'webp' => 'Blank Web Page (editable)',
1.329 droeschl 5436: 'drbx' => 'Drop Box',
1.451 www 5437: 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336 schafran 5438: 'bull' => 'Discussion Board',
1.347 weissno 5439: 'mypi' => 'My Personal Information Page',
1.353 weissno 5440: 'grpo' => 'Group Portfolio',
1.329 droeschl 5441: 'rost' => 'Course Roster',
1.484.2.22 raeburn 5442: 'abou' => 'Personal Information Page for a User',
1.484.2.36 raeburn 5443: 'imsf' => 'IMS Upload',
5444: 'imsl' => 'Upload IMS package',
1.484.2.12 raeburn 5445: 'cms' => 'Origin of IMS package',
5446: 'se' => 'Select',
1.484.2.19 raeburn 5447: 'file' => 'File',
1.329 droeschl 5448: 'title' => 'Title',
5449: 'comment' => 'Comment',
1.403 raeburn 5450: 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.484.2.50 raeburn 5451: 'bb5' => 'Blackboard 5',
5452: 'bb6' => 'Blackboard 6',
5453: 'angel5' => 'ANGEL 5.5',
5454: 'webctce4' => 'WebCT 4 Campus Edition',
1.484.2.67 raeburn 5455: 'er' => 'Editing rights unavailable for your current role.',
1.484.2.50 raeburn 5456: );
1.329 droeschl 5457: # -----------------------------------------------------------------------------
1.484.2.64 raeburn 5458: # Calculate free quota space for a user or course.
5459: my $quotatype = 'unofficial';
5460: if ($crstype eq 'Community') {
5461: $quotatype = 'community';
5462: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
5463: $quotatype = 'official';
5464: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
5465: $quotatype = 'textbook';
5466: }
5467: my $disk_quota = &Apache::loncommon::get_user_quota($coursenum,$coursedom,
5468: 'course',$quotatype); # expressed in MB
5469: my $current_disk_usage = 0;
5470: foreach my $subdir ('docs','supplemental') {
5471: $current_disk_usage += &Apache::lonnet::diskusage($coursedom,$coursenum,
5472: "userfiles/$subdir",1); # expressed in kB
5473: }
5474: my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage);
5475: my $usage = $current_disk_usage/1024; # in MB
5476: my $quota = $disk_quota;
5477: my $percent;
5478: if ($disk_quota == 0) {
5479: $percent = 100.0;
5480: } else {
1.484.2.69 raeburn 5481: $percent = 100*($usage/$disk_quota);
1.484.2.64 raeburn 5482: }
5483: $usage = sprintf("%.2f",$usage);
5484: $quota = sprintf("%.2f",$quota);
5485: $percent = sprintf("%.0f",$percent);
5486: my $quotainfo = '<p>'.&mt('Currently using [_1] of the [_2] available.',
5487: $percent.'%',$quota.' MB').'</p>';
5488:
1.329 droeschl 5489: my $fileupload=(<<FIUP);
1.484.2.64 raeburn 5490: $quotainfo
1.329 droeschl 5491: $lt{'file'}:<br />
1.484.2.67 raeburn 5492: <input type="file" name="uploaddoc" size="40" $disabled />
1.329 droeschl 5493: FIUP
5494:
5495: my $checkbox=(<<CHBO);
5496: <!-- <label>$lt{'parse'}?
5497: <input type="checkbox" name="parserflag" />
5498: </label> -->
5499: <label>
1.484.2.67 raeburn 5500: <input type="checkbox" name="parserflag" checked="checked" $disabled /> $lt{'parse'}
1.329 droeschl 5501: </label>
5502: CHBO
1.484.2.12 raeburn 5503: my $imsfolder = $env{'form.folder'};
5504: if ($imsfolder eq '') {
1.484.2.19 raeburn 5505: $imsfolder = 'default';
1.484.2.12 raeburn 5506: }
5507: my $imspform=(<<IMSFORM);
5508: <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
5509: $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
5510: <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
1.484.2.19 raeburn 5511: <fieldset id="uploadimsform" style="display: none;">
1.484.2.12 raeburn 5512: <legend>$lt{'imsf'}</legend>
5513: $fileupload
5514: <br />
5515: <p>
1.484.2.19 raeburn 5516: $lt{'cms'}:
1.484.2.67 raeburn 5517: <select name="source" $disabled>
1.484.2.12 raeburn 5518: <option value="-1" selected="selected">$lt{'se'}</option>
1.484.2.50 raeburn 5519: <option value="bb5">$lt{'bb5'}</option>
5520: <option value="bb6">$lt{'bb6'}</option>
5521: <option value="angel5">$lt{'angel5'}</option>
5522: <option value="webctce4">$lt{'webctce4'}</option>
1.484.2.12 raeburn 5523: </select>
5524: <input type="hidden" name="folder" value="$imsfolder" />
5525: </p>
5526: <input type="hidden" name="phase" value="one" />
1.484.2.67 raeburn 5527: <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" $disabled />
1.484.2.12 raeburn 5528: </fieldset>
5529: </form>
5530: IMSFORM
5531:
1.484.2.19 raeburn 5532: my $fileuploadform=(<<FUFORM);
1.484.2.12 raeburn 5533: <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
5534: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
5535: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.484.2.19 raeburn 5536: <fieldset id="uploaddocform" style="display: none;">
1.484.2.12 raeburn 5537: <legend>$lt{'upfi'}</legend>
1.371 tempelho 5538: <input type="hidden" name="active" value="aa" />
1.329 droeschl 5539: $fileupload
5540: <br />
5541: $lt{'title'}:<br />
1.484.2.67 raeburn 5542: <input type="text" size="60" name="comment" $disabled />
1.484.2.17 raeburn 5543: $pathitem
1.329 droeschl 5544: <input type="hidden" name="cmd" value="upload_default" />
5545: <br />
1.458 raeburn 5546: <span class="LC_nobreak" style="float:left">
1.329 droeschl 5547: $checkbox
5548: </span>
1.484.2.12 raeburn 5549: <br clear="all" />
1.484.2.67 raeburn 5550: <input type="submit" value="$lt{'upld'}" $disabled />
1.484.2.12 raeburn 5551: </fieldset>
5552: </form>
1.383 tempelho 5553: FUFORM
1.329 droeschl 5554:
1.484.2.67 raeburn 5555: my $mapimportjs;
5556: if ($canedit) {
5557: $mapimportjs = "javascript:openbrowser('mapimportform','importmap','sequence,page','');";
5558: } else {
5559: $mapimportjs = "javascript:alert('".&js_escape($lt{'er'})."');";
5560: }
1.484.2.19 raeburn 5561: my $importpubform=(<<SEDFFORM);
5562: <a class="LC_menubuttons_link" href="javascript:toggleMap('map');">
1.484.2.13 raeburn 5563: $lt{'impm'}</a>$help{'Load_Map'}
1.484.2.19 raeburn 5564: <form action="/adm/coursedocs" method="post" name="mapimportform">
5565: <fieldset id="importmapform" style="display: none;">
1.484.2.13 raeburn 5566: <legend>$lt{'impm'}</legend>
1.484.2.19 raeburn 5567: <input type="hidden" name="active" value="bb" />
1.484.2.13 raeburn 5568: $lt{'copm'}<br />
5569: <span class="LC_nobreak">
1.484.2.19 raeburn 5570: <input type="text" name="importmap" size="40" value=""
1.484.2.67 raeburn 5571: onfocus="this.blur();$mapimportjs" $disabled />
5572: <a href="$mapimportjs">$lt{'selm'}</a></span><br />
5573: <input type="submit" name="loadmap" value="$lt{'load'}" $disabled />
1.484.2.13 raeburn 5574: </fieldset>
5575: </form>
5576:
1.383 tempelho 5577: SEDFFORM
1.484.2.67 raeburn 5578:
5579: my $fromstoredjs;
5580: if ($canedit) {
5581: $fromstoredjs = 'open_StoredLinks_Import()';
5582: } else {
5583: $fromstoredjs = "alert('".&js_escape($lt{'er'})."')";
5584: }
5585:
1.484.2.19 raeburn 5586: my @importpubforma = (
5587: { '<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 5588: { '<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 5589: { '<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 5590: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform }
5591: );
5592: $importpubform = &create_form_ul(&create_list_elements(@importpubforma));
5593: my $extresourcesform =
5594: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
1.484.2.67 raeburn 5595: $help{'Adding_External_Resource'},
5596: undef,undef,$disabled);
1.484.2.72.2. (raeburn 5597:): my $exttoolform =
5598:): &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
5599:): $help{'Adding_External_Tool'},undef,
5600:): undef,'tool',$coursedom,$coursenum,
5601:): \%ltitools,$disabled);
1.329 droeschl 5602: if ($allowed) {
1.484.2.7 raeburn 5603: my $folder = $env{'form.folder'};
5604: if ($folder eq '') {
5605: $folder='default';
5606: }
1.484.2.67 raeburn 5607: if ($canedit) {
5608: my $output = &update_paste_buffer($coursenum,$coursedom,$folder);
5609: if ($output) {
5610: $r->print($output);
5611: }
1.484.2.30 raeburn 5612: }
1.337 ehlerst 5613: $r->print(<<HIDDENFORM);
5614: <form name="renameform" method="post" action="/adm/coursedocs">
5615: <input type="hidden" name="title" />
5616: <input type="hidden" name="cmd" />
5617: <input type="hidden" name="markcopy" />
5618: <input type="hidden" name="copyfolder" />
5619: $containertag
5620: </form>
1.484 raeburn 5621:
1.337 ehlerst 5622: HIDDENFORM
1.484.2.17 raeburn 5623: $r->print(&makesimpleeditform($pathitem)."\n".
5624: &makedocslogform($pathitem."\n".
1.484 raeburn 5625: '<input type="hidden" name="folder" value="'.
5626: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 5627: }
1.442 www 5628:
5629: # Generate the tabs
1.484.2.19 raeburn 5630: my ($mode,$needs_end);
1.472 raeburn 5631: if (($supplementalflag) && (!$allowed)) {
1.484.2.19 raeburn 5632: my @folders = split('&',$env{'form.folderpath'});
5633: unless (@folders > 2) {
5634: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
5635: $needs_end = 1;
5636: }
1.472 raeburn 5637: } else {
1.484 raeburn 5638: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484.2.19 raeburn 5639: $needs_end = 1;
1.472 raeburn 5640: }
1.443 www 5641:
1.442 www 5642: #
5643:
5644: my $savefolderpath;
5645:
1.395 raeburn 5646: if ($allowed) {
1.329 droeschl 5647: my $folder=$env{'form.folder'};
1.484.2.67 raeburn 5648: if ((($folder eq '') && (!$hiddentop)) || ($supplementalflag)) {
1.329 droeschl 5649: $folder='default';
1.356 tempelho 5650: $savefolderpath = $env{'form.folderpath'};
1.484.2.33 raeburn 5651: $env{'form.folderpath'}='default&'.&escape(&mt('Main Content'));
1.484.2.17 raeburn 5652: $pathitem = '<input type="hidden" name="folderpath" value="'.
1.329 droeschl 5653: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
5654: }
5655: my $postexec='';
5656: if ($folder eq 'default') {
1.372 bisitz 5657: $r->print('<script type="text/javascript">'."\n"
5658: .'// <![CDATA['."\n"
5659: .'this.window.name="loncapaclient";'."\n"
5660: .'// ]]>'."\n"
5661: .'</script>'."\n"
1.369 bisitz 5662: );
1.329 droeschl 5663: } else {
5664: #$postexec='self.close();';
5665: }
1.484.2.15 raeburn 5666: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
5667: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
1.329 droeschl 5668: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
5669:
5670: my $newnavform=(<<NNFORM);
5671: <form action="/adm/coursedocs" method="post" name="newnav">
1.484.2.43 raeburn 5672: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 5673: $pathitem
1.329 droeschl 5674: <input type="hidden" name="importdetail"
5675: value="$lt{'navc'}=/adm/navmaps" />
1.484.2.67 raeburn 5676: <a class="LC_menubuttons_link" href="javascript:makenew(document.newnav);">$lt{'navc'}</a>
1.329 droeschl 5677: $help{'Navigate_Content'}
5678: </form>
5679: NNFORM
5680: my $newsmppageform=(<<NSPFORM);
5681: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.484.2.43 raeburn 5682: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 5683: $pathitem
1.329 droeschl 5684: <input type="hidden" name="importdetail" value="" />
1.423 onken 5685: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 5686: $help{'Simple Page'}
1.329 droeschl 5687: </form>
5688: NSPFORM
5689:
5690: my $newsmpproblemform=(<<NSPROBFORM);
5691: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371 tempelho 5692: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 5693: $pathitem
1.329 droeschl 5694: <input type="hidden" name="importdetail" value="" />
1.423 onken 5695: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.484.2.44 raeburn 5696: $help{'Simple_Problem'}
1.329 droeschl 5697: </form>
5698:
5699: NSPROBFORM
5700:
5701: my $newdropboxform=(<<NDBFORM);
5702: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.371 tempelho 5703: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 5704: $pathitem
1.329 droeschl 5705: <input type="hidden" name="importdetail" value="" />
1.423 onken 5706: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.484.2.36 raeburn 5707: $help{'Dropbox'}
1.344 bisitz 5708: </form>
1.329 droeschl 5709: NDBFORM
5710:
5711: my $newexuploadform=(<<NEXUFORM);
5712: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.371 tempelho 5713: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 5714: $pathitem
1.329 droeschl 5715: <input type="hidden" name="importdetail" value="" />
1.423 onken 5716: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 5717: $help{'Score_Upload_Form'}
5718: </form>
5719: NEXUFORM
5720:
5721: my $newbulform=(<<NBFORM);
5722: <form action="/adm/coursedocs" method="post" name="newbul">
1.484.2.43 raeburn 5723: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5724: $pathitem
1.329 droeschl 5725: <input type="hidden" name="importdetail" value="" />
1.423 onken 5726: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 5727: $help{'Bulletin Board'}
5728: </form>
5729: NBFORM
5730:
5731: my $newaboutmeform=(<<NAMFORM);
5732: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.484.2.43 raeburn 5733: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5734: $pathitem
1.329 droeschl 5735: <input type="hidden" name="importdetail"
5736: value="$plainname=/adm/$udom/$uname/aboutme" />
1.484.2.67 raeburn 5737: <a class="LC_menubuttons_link" href="javascript:makenew(document.newaboutme);">$lt{'mypi'}</a>
1.347 weissno 5738: $help{'My Personal Information Page'}
1.329 droeschl 5739: </form>
5740: NAMFORM
5741:
5742: my $newaboutsomeoneform=(<<NASOFORM);
5743: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.484.2.43 raeburn 5744: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5745: $pathitem
1.329 droeschl 5746: <input type="hidden" name="importdetail" value="" />
1.423 onken 5747: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 5748: </form>
5749: NASOFORM
5750:
5751: my $newrosterform=(<<NROSTFORM);
5752: <form action="/adm/coursedocs" method="post" name="newroster">
1.484.2.43 raeburn 5753: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5754: $pathitem
1.329 droeschl 5755: <input type="hidden" name="importdetail"
5756: value="$lt{'rost'}=/adm/viewclasslist" />
1.484.2.67 raeburn 5757: <a class="LC_menubuttons_link" href="javascript:makenew(document.newroster);">$lt{'rost'}</a>
1.484.2.37 raeburn 5758: $help{'Course_Roster'}
1.329 droeschl 5759: </form>
5760: NROSTFORM
5761:
1.484.2.27 raeburn 5762: my $newwebpage;
5763: if ($folder =~ /^default_?(\d*)$/) {
5764: $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
5765: if ($1) {
5766: $newwebpage .= $1;
5767: } else {
5768: $newwebpage .= 'default';
5769: }
5770: $newwebpage .= '/new.html';
5771: }
5772: my $newwebpageform =(<<NWEBFORM);
5773: <form action="/adm/coursedocs" method="post" name="newwebpage">
1.484.2.43 raeburn 5774: <input type="hidden" name="active" value="ee" />
1.484.2.27 raeburn 5775: $pathitem
5776: <input type="hidden" name="importdetail" value="$newwebpage" />
5777: <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
1.484.2.36 raeburn 5778: $help{'Web_Page'}
1.484.2.27 raeburn 5779: </form>
5780: NWEBFORM
1.484.2.30 raeburn 5781:
1.484.2.27 raeburn 5782:
1.342 ehlerst 5783: my $specialdocumentsform;
1.383 tempelho 5784: my @specialdocumentsforma;
1.451 www 5785: my $gradingform;
5786: my @gradingforma;
5787: my $communityform;
5788: my @communityforma;
1.351 ehlerst 5789: my $newfolderform;
1.390 tempelho 5790: my $newfolderb;
1.342 ehlerst 5791:
1.451 www 5792: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 5793:
1.329 droeschl 5794: my $newpageform=(<<NPFORM);
5795: <form action="/adm/coursedocs" method="post" name="newpage">
5796: <input type="hidden" name="folderpath" value="$path" />
5797: <input type="hidden" name="importdetail" value="" />
1.484.2.43 raeburn 5798: <input type="hidden" name="active" value="ee" />
1.423 onken 5799: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 5800: $help{'Adding_Pages'}
1.329 droeschl 5801: </form>
5802: NPFORM
1.390 tempelho 5803:
5804:
1.351 ehlerst 5805: $newfolderform=(<<NFFORM);
1.329 droeschl 5806: <form action="/adm/coursedocs" method="post" name="newfolder">
1.484.2.19 raeburn 5807: $pathitem
1.329 droeschl 5808: <input type="hidden" name="importdetail" value="" />
1.484.2.43 raeburn 5809: <input type="hidden" name="active" value="" />
1.422 onken 5810: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 5811: </form>
5812: NFFORM
5813:
5814: my $newsylform=(<<NSYLFORM);
5815: <form action="/adm/coursedocs" method="post" name="newsyl">
1.484.2.43 raeburn 5816: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 5817: $pathitem
1.329 droeschl 5818: <input type="hidden" name="importdetail"
5819: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.484.2.67 raeburn 5820: <a class="LC_menubuttons_link" href="javascript:makenew(document.newsyl);">$lt{'syll'}</a>
1.329 droeschl 5821: $help{'Syllabus'}
1.383 tempelho 5822:
1.329 droeschl 5823: </form>
5824: NSYLFORM
1.364 bisitz 5825:
1.329 droeschl 5826: my $newgroupfileform=(<<NGFFORM);
5827: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.484.2.43 raeburn 5828: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5829: $pathitem
1.329 droeschl 5830: <input type="hidden" name="importdetail"
5831: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.484.2.67 raeburn 5832: <a class="LC_menubuttons_link" href="javascript:makenew(document.newgroupfiles);">$lt{'grpo'}</a>
1.353 weissno 5833: $help{'Group Portfolio'}
1.329 droeschl 5834: </form>
5835: NGFFORM
1.383 tempelho 5836: @specialdocumentsforma=(
1.421 onken 5837: {'<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 5838: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.newsyl);" />'=>$newsylform},
5839: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="javascript:makenew(document.newnav);" />'=>$newnavform},
1.451 www 5840: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
1.484.2.27 raeburn 5841: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
1.451 www 5842: );
5843: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
5844:
1.434 raeburn 5845:
5846: my @importdoc = (
1.484.2.19 raeburn 5847: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform}
5848: );
1.484.2.72.2. (raeburn 5849:): if (keys(%ltitools)) {
5850:): push(@importdoc,
5851:): {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="toggleUpload(\'tool\');" />'=>$exttoolform},
5852:): );
5853:): }
1.484.2.19 raeburn 5854: unless ($container eq 'page') {
5855: push(@importdoc,
5856: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform}
5857: );
5858: }
5859: push(@importdoc,
1.484.2.38 raeburn 5860: {'<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 5861: );
1.484.2.12 raeburn 5862: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
1.434 raeburn 5863:
1.451 www 5864: @gradingforma=(
5865: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
5866: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
5867: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
5868:
5869: );
5870: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
5871:
5872: @communityforma=(
5873: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
5874: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
5875: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
1.484.2.67 raeburn 5876: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="javascript:makenew(document.newroster);" />'=>$newrosterform},
5877: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="javascript:makenew(document.newgroupfiles);" />'=>$newgroupfileform},
1.451 www 5878: );
5879: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 5880:
1.330 tempelho 5881: my %orderhash = (
1.484.2.36 raeburn 5882: 'aa' => ['Upload',$fileuploadform],
5883: 'bb' => ['Import',$importpubform],
5884: 'cc' => ['Grading',$gradingform],
1.330 tempelho 5885: );
1.484.2.19 raeburn 5886: unless ($container eq 'page') {
1.434 raeburn 5887: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.484 raeburn 5888: $orderhash{'dd'} = ['Collaboration',$communityform];
1.484.2.36 raeburn 5889: $orderhash{'ee'} = ['Other',$specialdocumentsform];
1.434 raeburn 5890: }
5891:
1.341 ehlerst 5892: $hadchanges=0;
1.484 raeburn 5893: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 5894: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.67 raeburn 5895: $supplementalflag,\%orderhash,$iconpath,$pathitem,
1.484.2.72.2. (raeburn 5896:): \%ltitools,$canedit,\$navmap,$hiddentop);
1.484.2.67 raeburn 5897: undef($navmap);
1.443 www 5898: if ($error) {
5899: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
5900: }
5901: if ($hadchanges) {
1.484.2.72.2. (raeburn 5902:): unless (&is_hash_old()) {
5903:): &mark_hash_old();
5904:): }
1.443 www 5905: }
5906: &changewarning($r,'');
5907: }
1.458 raeburn 5908: }
1.442 www 5909:
1.443 www 5910: # Supplemental documents start here
5911:
1.329 droeschl 5912: my $folder=$env{'form.folder'};
1.443 www 5913: unless ($supplementalflag) {
1.329 droeschl 5914: $folder='supplemental';
5915: }
5916: if ($folder =~ /^supplemental$/ &&
5917: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 5918: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 5919: } elsif ($allowed) {
1.356 tempelho 5920: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 5921: }
1.484.2.17 raeburn 5922: $pathitem = '<input type="hidden" name="folderpath" value="'.
5923: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.329 droeschl 5924: if ($allowed) {
5925: my $folderseq=
1.484.2.15 raeburn 5926: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
1.329 droeschl 5927:
5928: my $supupdocform=(<<SUPDOCFORM);
1.484.2.12 raeburn 5929: <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
5930: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
1.383 tempelho 5931: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.484.2.19 raeburn 5932: <fieldset id="uploadsuppdocform" style="display: none;">
1.484.2.12 raeburn 5933: <legend>$lt{'upfi'}</legend>
1.371 tempelho 5934: <input type="hidden" name="active" value="ee" />
1.329 droeschl 5935: $fileupload
5936: <br />
5937: <br />
5938: <span class="LC_nobreak">
5939: $checkbox
5940: </span>
5941: <br /><br />
5942: $lt{'comment'}:<br />
1.383 tempelho 5943: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 5944: <br />
1.484.2.19 raeburn 5945: $pathitem
1.329 droeschl 5946: <input type="hidden" name="cmd" value="upload_supplemental" />
1.484.2.12 raeburn 5947: <input type='submit' value="$lt{'upld'}" />
5948: </form>
1.484.2.19 raeburn 5949: SUPDOCFORM
1.329 droeschl 5950:
5951: my $supnewfolderform=(<<SNFFORM);
5952: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.484.2.43 raeburn 5953: <input type="hidden" name="active" value="" />
1.484.2.17 raeburn 5954: $pathitem
1.329 droeschl 5955: <input type="hidden" name="importdetail" value="" />
1.423 onken 5956: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 5957: $help{'Adding_Folders'}
1.329 droeschl 5958: </form>
5959: SNFFORM
1.383 tempelho 5960:
1.484.2.19 raeburn 5961: my $supextform =
5962: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
1.484.2.67 raeburn 5963: $help{'Adding_External_Resource'},
5964: undef,undef,$disabled);
1.329 droeschl 5965:
1.484.2.72.2. (raeburn 5966:): my $supexttoolform =
5967:): &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
5968:): $help{'Adding_External_Tool'},
5969:): undef,undef,'tool',$coursedom,
5970:): $coursenum,\%ltitools,$disabled);
1.329 droeschl 5971: my $supnewsylform=(<<SNSFORM);
5972: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 5973: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 5974: $pathitem
1.329 droeschl 5975: <input type="hidden" name="importdetail"
5976: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.484.2.67 raeburn 5977: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewsyl);">$lt{'syll'}</a>
1.329 droeschl 5978: $help{'Syllabus'}
5979: </form>
5980: SNSFORM
5981:
5982: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 5983: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 5984: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 5985: $pathitem
1.329 droeschl 5986: <input type="hidden" name="importdetail"
5987: value="$plainname=/adm/$udom/$uname/aboutme" />
1.484.2.67 raeburn 5988: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewaboutme);">$lt{'mypi'}</a>
1.347 weissno 5989: $help{'My Personal Information Page'}
1.329 droeschl 5990: </form>
5991: SNAMFORM
5992:
1.484.2.27 raeburn 5993: my $supwebpage;
5994: if ($folder =~ /^supplemental_?(\d*)$/) {
5995: $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
5996: if ($1) {
5997: $supwebpage .= $1;
5998: } else {
5999: $supwebpage .= 'default';
6000: }
6001: $supwebpage .= '/new.html';
6002: }
6003: my $supwebpageform =(<<SWEBFORM);
6004: <form action="/adm/coursedocs" method="post" name="supwebpage">
6005: <input type="hidden" name="active" value="cc" />
6006: $pathitem
6007: <input type="hidden" name="importdetail" value="$supwebpage" />
6008: <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
1.484.2.36 raeburn 6009: $help{'Web_Page'}
1.484.2.27 raeburn 6010: </form>
6011: SWEBFORM
6012:
1.333 muellerd 6013:
1.383 tempelho 6014: my @specialdocs = (
1.484.2.67 raeburn 6015: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.supnewsyl);" />'
1.417 droeschl 6016: =>$supnewsylform},
1.484.2.67 raeburn 6017: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makenew(document.supnewaboutme);" />'
1.417 droeschl 6018: =>$supnewaboutmeform},
1.484.2.27 raeburn 6019: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
6020:
1.383 tempelho 6021: );
1.417 droeschl 6022: my @supimportdoc = (
1.484.2.19 raeburn 6023: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleUpload(\'suppext\')" />'
1.484.2.72.2. (raeburn 6024:): =>$supextform});
6025:): if (keys(%ltitools)) {
6026:): push(@supimportdoc,
6027:): {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="javascript:toggleUpload(\'supptool\')" />'
6028:): =>$supexttoolform});
6029:): }
6030:): push(@supimportdoc,
1.484.2.12 raeburn 6031: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
6032: =>$supupdocform},
1.484.2.72.2. (raeburn 6033:): );
1.484.2.19 raeburn 6034:
1.484.2.12 raeburn 6035: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
1.333 muellerd 6036: my %suporderhash = (
1.390 tempelho 6037: '00' => ['Supnewfolder', $supnewfolderform],
1.484.2.36 raeburn 6038: 'ee' => ['Upload',$supupdocform],
6039: 'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 6040: );
1.443 www 6041: if ($supplementalflag) {
1.458 raeburn 6042: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.67 raeburn 6043: $supplementalflag,\%suporderhash,$iconpath,$pathitem,
1.484.2.72.2. (raeburn 6044:): \%ltitools,$canedit);
1.443 www 6045: if ($error) {
6046: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.484.2.37 raeburn 6047: } else {
6048: if ($suppchanges) {
6049: my %servers = &Apache::lonnet::internet_dom_servers($coursedom);
6050: my @ids=&Apache::lonnet::current_machine_ids();
6051: foreach my $server (keys(%servers)) {
6052: next if (grep(/^\Q$server\E$/,@ids));
6053: my $hashid=$coursenum.':'.$coursedom;
1.484.2.42 raeburn 6054: my $cachekey = &escape('suppcount').':'.&escape($hashid);
6055: &Apache::lonnet::remote_devalidate_cache($server,[$cachekey]);
1.484.2.37 raeburn 6056: }
6057: &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
6058: undef($suppchanges);
6059: }
1.443 www 6060: }
1.393 raeburn 6061: }
1.443 www 6062: } elsif ($supplementalflag) {
1.458 raeburn 6063: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.17 raeburn 6064: $supplementalflag,'',$iconpath,$pathitem);
1.393 raeburn 6065: if ($error) {
6066: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 6067: }
1.393 raeburn 6068: }
1.389 tempelho 6069:
1.484.2.19 raeburn 6070: if ($needs_end) {
6071: $r->print(&endContentScreen());
6072: }
1.383 tempelho 6073:
1.329 droeschl 6074: if ($allowed) {
6075: $r->print('
6076: <form method="post" name="extimport" action="/adm/coursedocs">
6077: <input type="hidden" name="title" />
6078: <input type="hidden" name="url" />
6079: <input type="hidden" name="useform" />
6080: <input type="hidden" name="residx" />
6081: </form>');
6082: }
1.484 raeburn 6083: } elsif ($showdoc) {
1.329 droeschl 6084: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 6085: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.484.2.10 raeburn 6086: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 6087: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 6088: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 6089: }
6090: }
6091: $r->print(&Apache::loncommon::end_page());
6092: return OK;
1.364 bisitz 6093: }
1.329 droeschl 6094:
1.440 raeburn 6095: sub embedded_form_elems {
6096: my ($phase,$primaryurl,$newidx) = @_;
6097: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.484.2.72.2. (raeburn 6098:): $newidx =~s /\D+//g;
1.440 raeburn 6099: return <<STATE;
6100: <input type="hidden" name="folderpath" value="$folderpath" />
6101: <input type="hidden" name="cmd" value="upload_embedded" />
6102: <input type="hidden" name="newidx" value="$newidx" />
6103: <input type="hidden" name="phase" value="$phase" />
6104: <input type="hidden" name="primaryurl" value="$primaryurl" />
6105: STATE
6106: }
6107:
6108: sub embedded_destination {
6109: my $folder=$env{'form.folder'};
6110: my $destination = 'docs/';
6111: if ($folder =~ /^supplemental/) {
6112: $destination = 'supplemental/';
6113: }
6114: if (($folder eq 'default') || ($folder eq 'supplemental')) {
6115: $destination .= 'default/';
6116: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
6117: $destination .= $2.'/';
6118: }
1.484.2.72.2. (raeburn 6119:): my $newidx = $env{'form.newidx'};
6120:): $newidx =~s /\D+//g;
6121:): if ($newidx) {
6122:): $destination .= $newidx;
6123:): }
1.440 raeburn 6124: my $dir_root = '/userfiles';
6125: return ($destination,$dir_root);
6126: }
6127:
6128: sub return_to_editor {
6129: my $actionurl = '/adm/coursedocs';
6130: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
6131: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
6132: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
6133: '</a></p>';
6134: }
6135:
1.476 raeburn 6136: sub decompression_info {
6137: my ($destination,$dir_root) = &embedded_destination();
6138: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
6139: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
6140: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
6141: my $container='sequence';
1.480 raeburn 6142: my ($pathitem,$hiddenelem);
1.484.2.54 raeburn 6143: my @hiddens = ('newidx','comment','position','folderpath','archiveurl');
1.484.2.19 raeburn 6144: if ($env{'form.folderpath'} =~ /\:1$/) {
1.476 raeburn 6145: $container='page';
6146: }
1.480 raeburn 6147: unshift(@hiddens,$pathitem);
6148: foreach my $item (@hiddens) {
1.484.2.72.2. (raeburn 6149:): if ($item eq 'newidx') {
6150:): next if ($env{'form.'.$item} =~ /\D/);
6151:): }
1.480 raeburn 6152: if ($env{'form.'.$item}) {
6153: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
1.484.2.54 raeburn 6154: &HTML::Entities::encode($env{'form.'.$item},'<>&"').'" />'."\n";
1.480 raeburn 6155: }
1.477 raeburn 6156: }
1.476 raeburn 6157: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
6158: $hiddenelem);
6159: }
6160:
6161: sub decompression_phase_one {
6162: my ($dir,$file,$warning,$error,$output);
6163: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
6164: &decompression_info();
1.484.2.7 raeburn 6165: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 6166: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
6167: } else {
6168: my $file = $1;
1.481 raeburn 6169: $output =
6170: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
6171: $destination,$dir_root,
6172: $hiddenelem);
6173: if ($env{'form.autoextract_camtasia'}) {
6174: $output .= &remove_archive($docudom,$docuname,$container);
6175: }
1.476 raeburn 6176: }
6177: if ($error) {
6178: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
6179: $error.'</p>'."\n";
6180: }
6181: if ($warning) {
6182: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
6183: }
6184: return $output;
6185: }
6186:
6187: sub decompression_phase_two {
6188: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
6189: &decompression_info();
1.481 raeburn 6190: my $output;
1.480 raeburn 6191: if ($env{'form.archivedelete'}) {
1.481 raeburn 6192: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 6193: }
6194: $output .=
1.481 raeburn 6195: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 6196: $destination,$dir_root,$hiddenelem);
6197: return $output;
6198: }
6199:
1.480 raeburn 6200: sub remove_archive {
6201: my ($docudom,$docuname,$container) = @_;
6202: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 6203: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 6204: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
6205: if ($fatal) {
6206: if ($container eq 'page') {
6207: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
6208: } else {
6209: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
6210: }
1.484.2.54 raeburn 6211: $delwarning .= ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 6212: } else {
6213: my $currcmd = $env{'form.cmd'};
6214: my $position = $env{'form.position'};
1.484.2.54 raeburn 6215: my $archiveidx = $position;
6216: if ($position > 0) {
6217: if (($env{'form.autoextract_camtasia'}) && (scalar(@LONCAPA::map::order) == 2)) {
6218: $archiveidx = $position-1;
6219: }
6220: $env{'form.cmd'} = 'remove_'.$archiveidx;
6221: my ($title,$url,@rrest) =
6222: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$archiveidx]]);
6223: if ($url eq $env{'form.archiveurl'}) {
6224: if (&handle_edit_cmd($docuname,$docudom)) {
6225: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
6226: if ($fatal) {
6227: if ($container eq 'page') {
6228: $delwarning = &mt('An error occurred updating the contents of the current page.');
6229: } else {
6230: $delwarning = &mt('An error occurred updating the contents of the current folder.');
6231: }
1.480 raeburn 6232: } else {
1.484.2.54 raeburn 6233: $delresult = &mt('Archive file removed.');
1.480 raeburn 6234: }
6235: }
1.484.2.54 raeburn 6236: } else {
6237: $delwarning .= &mt('Archive file had unexpected item number in folder.').
6238: ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 6239: }
6240: }
6241: $env{'form.cmd'} = $currcmd;
6242: }
6243: if ($delwarning) {
6244: $output = '<p class="LC_warning">'.
6245: $delwarning.
6246: '</p>';
6247: }
6248: if ($delresult) {
6249: $output .= '<p class="LC_info">'.
6250: $delresult.
6251: '</p>';
6252: }
1.481 raeburn 6253: return $output;
1.480 raeburn 6254: }
6255:
1.484 raeburn 6256: sub generate_admin_menu {
1.484.2.67 raeburn 6257: my ($crstype,$canedit) = @_;
1.484 raeburn 6258: my $lc_crstype = lc($crstype);
6259: my ($home,$other,%outhash)=&authorhosts();
1.484.2.43 raeburn 6260: my %lt= ( # do not translate here
1.484 raeburn 6261: 'vc' => 'Verify Content',
6262: 'cv' => 'Check/Set Resource Versions',
6263: 'ls' => 'List Resource Identifiers',
6264: 'imse' => 'Export contents to IMS Archive',
1.484.2.43 raeburn 6265: 'dcd' => "Copy $crstype Content to Authoring Space",
6266: );
1.484 raeburn 6267: my ($candump,$dumpurl);
6268: if ($home + $other > 0) {
6269: $candump = 'F';
6270: if ($home) {
6271: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
6272: } else {
6273: my @hosts;
6274: foreach my $aurole (keys(%outhash)) {
6275: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
6276: push(@hosts,$outhash{$aurole});
1.484.2.30 raeburn 6277: }
1.484 raeburn 6278: }
6279: if (@hosts == 1) {
6280: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
6281: '&role='.
6282: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
6283: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
6284: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
6285: } else {
6286: $dumpurl = "javascript:choose_switchserver_window()";
6287: }
6288: }
6289: }
6290: my @menu=
6291: ({ categorytitle=>'Administration',
6292: items =>[
6293: { linktext => $lt{'vc'},
6294: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
6295: permission => 'F',
1.484.2.44 raeburn 6296: help => 'Docs_Verify_Content',
1.484 raeburn 6297: icon => 'verify.png',
6298: linktitle => 'Verify contents can be retrieved/rendered',
6299: },
6300: { linktext => $lt{'cv'},
6301: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
6302: permission => 'F',
1.484.2.44 raeburn 6303: help => 'Docs_Check_Resource_Versions',
1.484 raeburn 6304: icon => 'resversion.png',
6305: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
6306: },
6307: { linktext => $lt{'ls'},
6308: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
6309: permission => 'F',
6310: #help => '',
6311: icon => 'symbs.png',
6312: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
6313: },
6314: ]
1.484.2.67 raeburn 6315: });
6316: if ($canedit) {
6317: push(@menu,
1.484 raeburn 6318: { categorytitle=>'Export',
6319: items =>[
6320: { linktext => $lt{'imse'},
6321: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
6322: permission => 'F',
6323: help => 'Docs_Export_Course_Docs',
6324: icon => 'imsexport.png',
6325: linktitle => $lt{'imse'},
6326: },
6327: { linktext => $lt{'dcd'},
6328: url => $dumpurl,
6329: permission => $candump,
1.484.2.44 raeburn 6330: help => 'Docs_Dump_Course_Docs',
1.484 raeburn 6331: icon => 'dump.png',
6332: linktitle => $lt{'dcd'},
6333: },
6334: ]
6335: });
1.484.2.67 raeburn 6336: }
1.484 raeburn 6337: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
6338: '<input type="hidden" id="dummy" />'."\n".
6339: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
6340: '</form>';
1.329 droeschl 6341: }
6342:
6343: sub generate_edit_table {
1.484.2.30 raeburn 6344: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile,
1.484.2.67 raeburn 6345: $need_save,$copyfolder,$canedit) = @_;
1.406 raeburn 6346: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 6347: my %orderhash = %{$orderhash_ref};
1.484.2.67 raeburn 6348: my ($form, $activetab, $active, $disabled);
1.484.2.43 raeburn 6349: if (($env{'form.active'} ne '') && ($env{'form.active'} ne '00')) {
1.371 tempelho 6350: $activetab = $env{'form.active'};
6351: }
1.484.2.67 raeburn 6352: unless ($canedit) {
6353: $disabled = ' disabled="disabled"';
6354: }
1.472 raeburn 6355: my $backicon = $iconpath.'clickhere.gif';
1.484.2.21 raeburn 6356: my $backtext = &mt('Exit Editor');
1.458 raeburn 6357: $form = '<div class="LC_Box" style="margin:0;">'.
1.484.2.19 raeburn 6358: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
6359: '<li class="goback">'.
1.484.2.32 raeburn 6360: '<a href="javascript:toContents('."'$jumpto'".');">'.
1.484.2.19 raeburn 6361: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
6362: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
6363: '<li>'.
6364: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
6365: &mt('Undo Delete').'</a></li>'."\n";
1.484.2.7 raeburn 6366: if ($env{'form.docslog'}) {
6367: $form .= '<li class="active">';
6368: } else {
6369: $form .= '<li>';
6370: }
6371: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
6372: &mt('History').'</a></li>'."\n";
6373: if ($env{'form.docslog'}) {
6374: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
6375: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 6376: }
1.458 raeburn 6377: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 6378: if($name ne '00'){
1.371 tempelho 6379: if($activetab eq '' || $activetab ne $name){
6380: $active = '';
6381: }elsif($activetab eq $name){
6382: $active = 'class="active"';
6383: }
1.458 raeburn 6384: $form .= '<li style="float:right" '.$active
1.484 raeburn 6385: .' 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 6386: } else {
1.484.2.43 raeburn 6387: $form .= '<li style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 6388:
6389: }
1.329 droeschl 6390: }
1.484 raeburn 6391: $form .= '</ul>'."\n";
6392: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 6393:
6394: if ($to_show ne '') {
1.484.2.30 raeburn 6395: my $saveform;
6396: if ($need_save) {
6397: my $button = &mt('Make changes');
6398: my $path;
6399: if ($env{'form.folderpath'}) {
6400: $path =
6401: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
6402: }
6403: $saveform = <<"END";
6404: <div id="multisave" style="display:none; clear:both;" >
6405: <form name="saveactions" method="post" action="/adm/coursedocs" onsubmit="return checkSubmits();">
6406: <input type="hidden" name="folderpath" value="$path" />
6407: <input type="hidden" name="symb" value="$env{'form.symb'}" />
6408: <input type="hidden" name="allhiddenresource" value="" />
6409: <input type="hidden" name="allencrypturl" value="" />
6410: <input type="hidden" name="allrandompick" value="" />
6411: <input type="hidden" name="allrandomorder" value="" />
6412: <input type="hidden" name="changeparms" value="" />
6413: <input type="hidden" name="multiremove" value="" />
6414: <input type="hidden" name="multicut" value="" />
6415: <input type="hidden" name="multicopy" value="" />
6416: <input type="hidden" name="multichange" value="" />
6417: <input type="hidden" name="copyfolder" value="$copyfolder" />
1.484.2.67 raeburn 6418: <input type="submit" name="savemultiples" value="$button" $disabled />
1.484.2.30 raeburn 6419: </form>
6420: </div>
6421: END
6422: }
6423: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'.$saveform."\n";
1.458 raeburn 6424: }
1.363 ehlerst 6425: foreach my $field (keys(%orderhash)){
1.390 tempelho 6426: if($field ne '00'){
1.422 onken 6427: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 6428: $active = 'style="display: none;float:left"';
1.422 onken 6429: }elsif($activetab eq $field){
1.458 raeburn 6430: $active = 'style="display:block;float:left"';
1.422 onken 6431: }
6432: $form .= '<div id="'.$field.$tid.'"'
6433: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 6434: .'</div>'."\n";
1.363 ehlerst 6435: }
6436: }
1.484 raeburn 6437: unless ($env{'form.docslog'}) {
6438: $form .= '</div></div>'."\n";
6439: }
1.329 droeschl 6440: return $form;
6441: }
6442:
6443: sub editing_js {
1.484.2.72.2. (raeburn 6444:): my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,$canedit,$navmapref) = @_;
1.484.2.61 raeburn 6445: my %js_lt = &Apache::lonlocal::texthash(
1.329 droeschl 6446: p_mnf => 'Name of New Folder',
6447: t_mnf => 'New Folder',
6448: p_mnp => 'Name of New Page',
6449: t_mnp => 'New Page',
1.451 www 6450: p_mxu => 'Title for the External Score',
1.349 biermanm 6451: p_msp => 'Name of Simple Course Page',
1.329 droeschl 6452: p_msb => 'Title for the Problem',
6453: p_mdb => 'Title for the Drop Box',
1.336 schafran 6454: p_mbb => 'Title for the Discussion Board',
1.484.2.27 raeburn 6455: p_mwp => 'Title for Web Page',
1.348 weissno 6456: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 6457: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 6458: p_mab_alrt1 => 'Not a valid user:domain',
6459: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
6460: p_chn => 'New Title',
6461: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
1.484.2.63 raeburn 6462: p_rmr2a => 'Remove',
6463: p_rmr2b => '?',
6464: p_rmr3a => 'Remove those',
6465: p_rmr3b => 'items?',
6466: p_rmr4 => 'WARNING: Removing a resource uploaded to a course cannot be undone via "Undo Delete".',
6467: p_rmr5 => 'Push "Cancel" and then use "Cut" instead if you might need to undo this change.',
1.329 droeschl 6468: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
6469: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
1.484.2.63 raeburn 6470: p_ctr2a => 'Cut',
6471: p_ctr2b => '?',
6472: p_ctr3a => 'Cut those',
6473: p_ctr3b => 'items?',
1.478 raeburn 6474: rpck => 'Enter number to pick (e.g., 3)',
1.484.2.12 raeburn 6475: imsfile => 'You must choose an IMS package for import',
6476: imscms => 'You must select which Course Management System was the source of the IMS package',
6477: invurl => 'Invalid URL',
6478: titbl => 'Title is blank',
1.484.2.30 raeburn 6479: more => '(More ...)',
6480: less => '(Less ...)',
6481: noor => 'No actions selected or changes to settings specified.',
6482: noch => 'No changes to settings specified.',
6483: noac => 'No actions selected.',
1.484.2.67 raeburn 6484: edri => 'Editing rights unavailable for your current role.',
1.329 droeschl 6485: );
6486:
1.484.2.61 raeburn 6487: &js_escape(\%js_lt);
1.433 raeburn 6488: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 6489: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
6490: my $main_container_page;
1.484.2.19 raeburn 6491: if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) {
6492: $main_container_page = 1;
1.434 raeburn 6493: }
1.484.2.67 raeburn 6494: my $backtourl;
6495: my $toplevelmain = &escape(&default_folderpath($coursenum,$coursedom,$navmapref));
1.446 www 6496: my $toplevelsupp = &supplemental_base();
1.433 raeburn 6497:
1.484.2.21 raeburn 6498: if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
6499: my $caller = $1;
6500: if ($caller =~ /^supplemental/) {
6501: $backtourl = '/adm/supplemental?folderpath='.&escape($caller);
6502: } else {
6503: my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
6504: $res = &Apache::lonnet::clutter($res);
6505: if (&Apache::lonnet::is_on_map($res)) {
1.484.2.66 raeburn 6506: my ($url,$anchor);
6507: if ($res =~ /^([^#]+)#([^#]+)$/) {
6508: $url = $1;
6509: $anchor = $2;
6510: if (($caller =~ m{^([^#]+)\Q#$anchor\E$})) {
6511: $caller = $1.&escape('#').$anchor;
6512: }
1.484.2.67 raeburn 6513: } else {
6514: $url = $res;
1.484.2.66 raeburn 6515: }
1.484.2.72.2. (raeburn 6516:): $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"');
6517:): if ($backtourl =~ m{^\Q/uploaded/$coursedom/$coursenum/\Edefault_\d+\.sequence$}) {
6518:): $backtourl .= '?navmap=1';
6519:): } else {
6520:): $backtourl .= '?symb='.
6521:): &HTML::Entities::encode($caller,'<>&"');
6522:): }
1.484.2.66 raeburn 6523: if ($anchor ne '') {
6524: $backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"');
6525: }
1.484.2.57 raeburn 6526: $backtourl = &Apache::loncommon::escape_single($backtourl);
1.484.2.31 raeburn 6527: } else {
6528: $backtourl = '/adm/navmaps';
1.484.2.21 raeburn 6529: }
6530: }
6531: } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
6532: $backtourl = '/adm/menu';
6533: } elsif ($supplementalflag) {
1.472 raeburn 6534: $backtourl = '/adm/supplemental';
1.484.2.21 raeburn 6535: } else {
6536: $backtourl = '/adm/navmaps';
1.472 raeburn 6537: }
6538:
1.484.2.19 raeburn 6539: my $fieldsets = "'ext','doc'";
1.484.2.72.2. (raeburn 6540:): if ($posslti) {
6541:): $fieldsets .= ",'tool'";
6542:): }
1.484.2.19 raeburn 6543: unless ($main_container_page) {
6544: $fieldsets .=",'ims'";
6545: }
1.484.2.12 raeburn 6546: if ($supplementalflag) {
6547: $fieldsets = "'suppext','suppdoc'";
1.484.2.72.2. (raeburn 6548:): if ($posslti) {
6549:): $fieldsets .= ",'supptool'";
6550:): }
1.484.2.12 raeburn 6551: }
6552:
1.484.2.67 raeburn 6553: my $jsmakefunctions;
6554: if ($canedit) {
6555: $jsmakefunctions = <<ENDNEWSCRIPT;
1.329 droeschl 6556: function makenewfolder(targetform,folderseq) {
1.484.2.65 raeburn 6557: var foldername=prompt('$js_lt{"p_mnf"}','$js_lt{"t_mnf"}');
1.329 droeschl 6558: if (foldername) {
6559: targetform.importdetail.value=escape(foldername)+"="+folderseq;
6560: targetform.submit();
6561: }
6562: }
6563:
6564: function makenewpage(targetform,folderseq) {
1.484.2.61 raeburn 6565: var pagename=prompt('$js_lt{"p_mnp"}','$js_lt{"t_mnp"}');
1.329 droeschl 6566: if (pagename) {
6567: targetform.importdetail.value=escape(pagename)+"="+folderseq;
6568: targetform.submit();
6569: }
6570: }
6571:
6572: function makeexamupload() {
1.484.2.61 raeburn 6573: var title=prompt('$js_lt{"p_mxu"}');
1.344 bisitz 6574: if (title) {
1.329 droeschl 6575: this.document.forms.newexamupload.importdetail.value=
6576: escape(title)+'=/res/lib/templates/examupload.problem';
6577: this.document.forms.newexamupload.submit();
6578: }
6579: }
6580:
6581: function makesmppage() {
1.484.2.61 raeburn 6582: var title=prompt('$js_lt{"p_msp"}');
1.344 bisitz 6583: if (title) {
1.329 droeschl 6584: this.document.forms.newsmppg.importdetail.value=
1.484.2.26 raeburn 6585: escape(title)+'=/adm/$udom/$uname/new/smppg';
1.329 droeschl 6586: this.document.forms.newsmppg.submit();
6587: }
6588: }
6589:
1.484.2.27 raeburn 6590: function makewebpage(type) {
1.484.2.61 raeburn 6591: var title=prompt('$js_lt{"p_mwp"}');
1.484.2.27 raeburn 6592: var formname;
6593: if (type == 'supp') {
6594: formname = this.document.forms.supwebpage;
6595: } else {
6596: formname = this.document.forms.newwebpage;
6597: }
6598: if (title) {
6599: var webpage = formname.importdetail.value;
6600: formname.importdetail.value = escape(title)+'='+webpage;
6601: formname.submit();
6602: }
6603: }
6604:
1.329 droeschl 6605: function makesmpproblem() {
1.484.2.61 raeburn 6606: var title=prompt('$js_lt{"p_msb"}');
1.344 bisitz 6607: if (title) {
1.329 droeschl 6608: this.document.forms.newsmpproblem.importdetail.value=
6609: escape(title)+'=/res/lib/templates/simpleproblem.problem';
6610: this.document.forms.newsmpproblem.submit();
6611: }
6612: }
6613:
6614: function makedropbox() {
1.484.2.61 raeburn 6615: var title=prompt('$js_lt{"p_mdb"}');
1.344 bisitz 6616: if (title) {
1.329 droeschl 6617: this.document.forms.newdropbox.importdetail.value=
6618: escape(title)+'=/res/lib/templates/DropBox.problem';
6619: this.document.forms.newdropbox.submit();
6620: }
6621: }
6622:
6623: function makebulboard() {
1.484.2.61 raeburn 6624: var title=prompt('$js_lt{"p_mbb"}');
1.329 droeschl 6625: if (title) {
6626: this.document.forms.newbul.importdetail.value=
1.484.2.26 raeburn 6627: escape(title)+'=/adm/$udom/$uname/new/bulletinboard';
1.329 droeschl 6628: this.document.forms.newbul.submit();
6629: }
6630: }
6631:
6632: function makeabout() {
1.484.2.61 raeburn 6633: var user=prompt("$js_lt{'p_mab'}");
1.329 droeschl 6634: if (user) {
6635: var comp=new Array();
6636: comp=user.split(':');
6637: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
6638: if ((comp[0]) && (comp[1])) {
6639: this.document.forms.newaboutsomeone.importdetail.value=
1.484.2.61 raeburn 6640: '$js_lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.484.2.67 raeburn 6641: this.document.forms.newaboutsomeone.submit();
6642: } else {
6643: alert("$js_lt{'p_mab_alrt1'}");
6644: }
6645: } else {
6646: alert("$js_lt{'p_mab_alrt2'}");
6647: }
6648: }
1.335 ehlerst 6649: }
1.484.2.67 raeburn 6650:
6651: function makenew(targetform) {
6652: targetform.submit();
1.335 ehlerst 6653: }
1.484.2.67 raeburn 6654:
6655: function changename(folderpath,index,oldtitle) {
6656: var title=prompt('$js_lt{"p_chn"}',oldtitle);
6657: if (title) {
6658: this.document.forms.renameform.markcopy.value='';
6659: this.document.forms.renameform.title.value=title;
6660: this.document.forms.renameform.cmd.value='rename_'+index;
6661: this.document.forms.renameform.folderpath.value=folderpath;
6662: this.document.forms.renameform.submit();
6663: }
1.329 droeschl 6664: }
6665:
1.484.2.67 raeburn 6666: ENDNEWSCRIPT
6667: } else {
6668: $jsmakefunctions = <<ENDNEWSCRIPT;
6669:
6670: function makenewfolder() {
6671: alert("$js_lt{'edri'}");
6672: }
6673:
6674: function makenewpage() {
6675: alert("$js_lt{'edri'}");
6676: }
6677:
6678: function makeexamupload() {
6679: alert("$js_lt{'edri'}");
6680: }
6681:
6682: function makesmppage() {
6683: alert("$js_lt{'edri'}");
6684: }
6685:
6686: function makewebpage(type) {
6687: alert("$js_lt{'edri'}");
6688: }
6689:
6690: function makesmpproblem() {
6691: alert("$js_lt{'edri'}");
6692: }
6693:
6694: function makedropbox() {
6695: alert("$js_lt{'edri'}");
6696: }
6697:
6698: function makebulboard() {
6699: alert("$js_lt{'edri'}");
6700: }
6701:
6702: function makeabout() {
6703: alert("$js_lt{'edri'}");
6704: }
6705:
6706: function changename() {
6707: alert("$js_lt{'edri'}");
6708: }
6709:
6710: function makenew() {
6711: alert("$js_lt{'edri'}");
6712: }
6713:
6714: function groupimport() {
6715: alert("$js_lt{'edri'}");
6716: }
6717:
6718: function groupsearch() {
6719: alert("$js_lt{'edri'}");
6720: }
6721:
6722: function groupopen(url,recover) {
6723: var options="scrollbars=1,resizable=1,menubar=0";
6724: idxflag=1;
6725: idx=open("/adm/groupsort?inhibitmenu=yes&mode=simple&recover="+recover+"&readfile="+url,"idxout",options);
6726: idx.focus();
6727: }
6728:
6729: ENDNEWSCRIPT
6730:
6731: }
6732: return <<ENDSCRIPT;
6733:
6734: $jsmakefunctions
6735:
1.484.2.13 raeburn 6736: function toggleUpload(caller) {
6737: var blocks = Array($fieldsets);
6738: for (var i=0; i<blocks.length; i++) {
6739: var disp = 'none';
6740: if (caller == blocks[i]) {
6741: var curr = document.getElementById('upload'+caller+'form').style.display;
6742: if (curr == 'none') {
6743: disp='block';
6744: }
6745: }
6746: document.getElementById('upload'+blocks[i]+'form').style.display=disp;
1.484.2.72.2. (raeburn 6747:): if ((caller == 'tool') || (caller == 'supptool')) {
6748:): if (disp == 'block') {
6749:): if (document.getElementById('LC_exttoolid')) {
6750:): var toolselector = document.getElementById('LC_exttoolid');
6751:): var suppflag = 0;
6752:): if (caller == 'supptool') {
6753:): suppflag = 1;
6754:): }
6755:): currForm = document.getElementById('new'+caller);
6756:): updateExttool(toolselector,currForm,suppflag);
6757:): }
6758:): }
6759:): }
1.484.2.13 raeburn 6760: }
6761: resize_scrollbox('contentscroll','1','1');
6762: return;
6763: }
6764:
1.484.2.19 raeburn 6765: function toggleMap(caller) {
1.484.2.13 raeburn 6766: var disp = 'none';
1.484.2.19 raeburn 6767: if (document.getElementById('importmapform')) {
6768: if (caller == 'map') {
6769: var curr = document.getElementById('importmapform').style.display;
6770: if (curr == 'none') {
6771: disp='block';
6772: }
1.484.2.12 raeburn 6773: }
1.484.2.19 raeburn 6774: document.getElementById('importmapform').style.display=disp;
6775: resize_scrollbox('contentscroll','1','1');
1.484.2.12 raeburn 6776: }
1.484.2.19 raeburn 6777: return;
1.329 droeschl 6778: }
6779:
1.484.2.12 raeburn 6780: function makeims(imsform) {
6781: if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
1.484.2.61 raeburn 6782: alert("$js_lt{'imsfile'}");
1.484.2.12 raeburn 6783: return;
6784: }
6785: if (imsform.source.selectedIndex == 0) {
1.484.2.61 raeburn 6786: alert("$js_lt{'imscms'}");
1.484.2.12 raeburn 6787: return;
6788: }
6789: newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
6790: imsform.submit();
6791: }
6792:
1.478 raeburn 6793: function updatePick(targetform,index,caller) {
1.484.2.29 raeburn 6794: var pickitem;
6795: var picknumitem;
6796: var picknumtext;
6797: if (index == 'all') {
6798: pickitem = document.getElementById('randompickall');
6799: picknumitem = document.getElementById('rpicknumall');
6800: picknumtext = document.getElementById('rpicktextall');
6801: } else {
6802: pickitem = document.getElementById('randompick_'+index);
6803: picknumitem = document.getElementById('rpicknum_'+index);
6804: picknumtext = document.getElementById('randompicknum_'+index);
6805: }
1.478 raeburn 6806: if (pickitem.checked) {
1.484.2.61 raeburn 6807: var picknum=prompt('$js_lt{"rpck"}',picknumitem.value);
1.478 raeburn 6808: if (picknum == '' || picknum == null) {
6809: if (caller == 'check') {
6810: pickitem.checked=false;
1.484.2.29 raeburn 6811: if (index == 'all') {
6812: picknumtext.innerHTML = '';
6813: if (caller == 'link') {
6814: propagateState(targetform,'rpicknum');
6815: }
6816: } else {
1.484.2.30 raeburn 6817: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 6818: }
1.478 raeburn 6819: }
6820: } else {
6821: picknum.toString();
6822: var regexdigit=/^\\d+\$/;
6823: if (regexdigit.test(picknum)) {
6824: picknumitem.value = picknum;
1.484.2.29 raeburn 6825: if (index == 'all') {
1.484.2.30 raeburn 6826: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.cumulativesettings,\\'all\\',\\'link\\');">'+picknum+'</a>';
1.484.2.29 raeburn 6827: if (caller == 'link') {
6828: propagateState(targetform,'rpicknum');
6829: }
6830: } else {
6831: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.edit_randompick_'+index+',\\''+index+'\\',\\'link\\');">'+picknum+'</a>';
1.484.2.30 raeburn 6832: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 6833: }
1.478 raeburn 6834: } else {
6835: if (caller == 'check') {
1.484.2.29 raeburn 6836: if (index == 'all') {
6837: picknumtext.innerHTML = '';
6838: if (caller == 'link') {
6839: propagateState(targetform,'rpicknum');
6840: }
6841: } else {
6842: pickitem.checked=false;
1.484.2.30 raeburn 6843: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 6844: }
1.478 raeburn 6845: }
6846: return;
6847: }
6848: }
6849: } else {
1.484.2.29 raeburn 6850: picknumitem.value = '';
6851: picknumtext.innerHTML = '';
6852: if (index == 'all') {
6853: if (caller == 'link') {
6854: propagateState(targetform,'rpicknum');
6855: }
6856: } else {
1.484.2.30 raeburn 6857: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 6858: }
6859: }
6860: }
6861:
6862: function propagateState(form,param) {
6863: if (document.getElementById(param+'all')) {
6864: var setcheck = 0;
6865: var rpick = 0;
6866: if (param == 'rpicknum') {
6867: if (document.getElementById('randompickall')) {
6868: if (document.getElementById('randompickall').checked) {
6869: if (document.getElementById('rpicknumall')) {
6870: rpick = document.getElementById('rpicknumall').value;
6871: }
6872: }
6873: }
6874: } else {
6875: if (document.getElementById(param+'all').checked) {
6876: setcheck = 1;
6877: }
6878: }
1.484.2.30 raeburn 6879: var allidxlist;
6880: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
6881: if (document.getElementById('all'+param+'idx')) {
6882: allidxlist = document.getElementById('all'+param+'idx').value;
6883: }
6884: var actions = new Array ('remove','cut','copy');
6885: for (var i=0; i<actions.length; i++) {
6886: if (actions[i] != param) {
6887: if (document.getElementById(actions[i]+'all')) {
6888: document.getElementById(actions[i]+'all').checked = false;
6889: }
6890: }
6891: }
6892: }
1.484.2.29 raeburn 6893: if ((param == 'encrypturl') || (param == 'hiddenresource')) {
1.484.2.30 raeburn 6894: allidxlist = form.allidx.value;
6895: }
6896: if ((param == 'randompick') || (param == 'rpicknum') || (param == 'randomorder')) {
6897: allidxlist = form.allmapidx.value;
6898: }
6899: if ((allidxlist != '') && (allidxlist != null)) {
6900: var allidxs = allidxlist.split(',');
6901: if (allidxs.length > 1) {
6902: for (var i=0; i<allidxs.length; i++) {
6903: if (document.getElementById(param+'_'+allidxs[i])) {
6904: if (param == 'rpicknum') {
6905: if (document.getElementById('randompick_'+allidxs[i])) {
6906: if (document.getElementById('randompick_'+allidxs[i]).checked) {
6907: document.getElementById(param+'_'+allidxs[i]).value = rpick;
6908: if (rpick > 0) {
6909: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = ': <a href="javascript:updatePick(document.edit_randompick_'+allidxs[i]+',\\''+allidxs[i]+'\\',\\'link\\')">'+rpick+'</a>';
6910: } else {
6911: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
6912: }
6913: }
6914: }
6915: } else {
1.484.2.29 raeburn 6916: if (setcheck == 1) {
6917: document.getElementById(param+'_'+allidxs[i]).checked = true;
6918: } else {
6919: document.getElementById(param+'_'+allidxs[i]).checked = false;
1.484.2.30 raeburn 6920: if (param == 'randompick') {
6921: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
6922: }
1.484.2.29 raeburn 6923: }
6924: }
6925: }
6926: }
1.484.2.30 raeburn 6927: if (setcheck == 1) {
6928: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
6929: var actions = new Array('copy','cut','remove');
6930: for (var i=0; i<actions.length; i++) {
6931: var otheractions;
6932: var otheridxs;
6933: if (actions[i] === param) {
6934: continue;
6935: } else {
6936: if (document.getElementById('all'+actions[i]+'idx')) {
6937: otheractions = document.getElementById('all'+actions[i]+'idx').value;
6938: otheridxs = otheractions.split(',');
6939: if (otheridxs.length > 1) {
6940: for (var j=0; j<otheridxs.length; j++) {
6941: if (document.getElementById(actions[i]+'_'+otheridxs[j])) {
6942: document.getElementById(actions[i]+'_'+otheridxs[j]).checked = false;
6943: }
1.484.2.29 raeburn 6944: }
6945: }
6946: }
6947: }
1.484.2.30 raeburn 6948: }
1.484.2.29 raeburn 6949: }
6950: }
6951: }
6952: }
1.478 raeburn 6953: }
1.484.2.29 raeburn 6954: return;
6955: }
6956:
1.484.2.63 raeburn 6957: function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder,confirm_removal) {
1.484.2.67 raeburn 6958: var canedit = '$canedit';
6959: if (canedit == '') {
6960: alert("$js_lt{'edri'}");
6961: return;
6962: }
1.484.2.30 raeburn 6963: var dosettings;
6964: var doaction;
6965: var control = document.togglemultsettings;
6966: if (context == 'actions') {
6967: control = document.togglemultactions;
6968: doaction = 1;
6969: } else {
6970: dosettings = 1;
6971: }
6972: if (control) {
6973: if (control.showmultpick.length) {
6974: for (var i=0; i<control.showmultpick.length; i++) {
6975: if (control.showmultpick[i].checked) {
6976: if (control.showmultpick[i].value == 1) {
6977: if (context == 'settings') {
6978: dosettings = 0;
6979: } else {
6980: doaction = 0;
6981: }
6982: }
6983: }
6984: }
6985: }
6986: }
6987: if (context == 'settings') {
6988: if (dosettings == 1) {
6989: targetform.changeparms.value=param;
6990: targetform.submit();
6991: }
6992: }
6993: if (context == 'actions') {
6994: if (doaction == 1) {
6995: targetform.cmd.value=param+'_'+index;
6996: targetform.folderpath.value=folderpath;
6997: targetform.markcopy.value=idx+':'+param;
6998: targetform.copyfolder.value=folder+'.'+container;
6999: if (param == 'remove') {
1.484.2.63 raeburn 7000: var doremove = 0;
7001: if (skip_confirm) {
7002: if (confirm_removal) {
7003: if (confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'"$js_lt{"p_rmr2b"}')) {
7004: doremove = 1;
7005: }
7006: } else {
7007: doremove = 1;
7008: }
7009: } else {
7010: if (confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'" $js_lt{"p_rmr2b"}')) {
7011: doremove = 1;
7012: }
7013: }
7014: if (doremove) {
1.484.2.30 raeburn 7015: targetform.markcopy.value='';
7016: targetform.copyfolder.value='';
1.484.2.29 raeburn 7017: targetform.submit();
7018: }
7019: }
1.484.2.30 raeburn 7020: if (param == 'cut') {
1.484.2.61 raeburn 7021: 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 7022: targetform.submit();
7023: return;
7024: }
7025: }
7026: if (param == 'copy') {
7027: targetform.submit();
7028: return;
7029: }
7030: targetform.markcopy.value='';
7031: targetform.copyfolder.value='';
7032: targetform.cmd.value='';
7033: targetform.folderpath.value='';
7034: return;
7035: } else {
7036: if (document.getElementById(param+'_'+idx)) {
7037: item = document.getElementById(param+'_'+idx);
7038: if (item.type == 'checkbox') {
7039: if (item.checked) {
7040: item.checked = false;
7041: } else {
7042: item.checked = true;
7043: singleCheck(item,idx,param);
7044: }
7045: }
7046: }
7047: }
7048: }
7049: return;
7050: }
7051:
7052: function singleCheck(caller,idx,action) {
7053: actions = new Array('cut','copy','remove');
7054: if (caller.checked) {
7055: for (var i=0; i<actions.length; i++) {
7056: if (actions[i] != action) {
7057: if (document.getElementById(actions[i]+'_'+idx)) {
7058: if (document.getElementById(actions[i]+'_'+idx).checked) {
7059: document.getElementById(actions[i]+'_'+idx).checked = false;
7060: }
7061: }
7062: }
1.484.2.29 raeburn 7063: }
7064: }
7065: return;
1.478 raeburn 7066: }
7067:
1.334 muellerd 7068: function unselectInactive(nav) {
1.335 ehlerst 7069: currentNav = document.getElementById(nav);
7070: currentLis = currentNav.getElementsByTagName('LI');
7071: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 7072: if (currentLis[i].className == 'goback') {
7073: currentLis[i].className = 'goback';
7074: } else {
7075: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 7076: currentLis[i].className = 'right';
1.472 raeburn 7077: } else {
1.374 tempelho 7078: currentLis[i].className = 'i';
1.472 raeburn 7079: }
7080: }
1.335 ehlerst 7081: }
1.332 tempelho 7082: }
7083:
1.334 muellerd 7084: function hideAll(current, nav, data) {
1.335 ehlerst 7085: unselectInactive(nav);
1.484.2.43 raeburn 7086: if (current) {
7087: if (current.className == 'right'){
1.374 tempelho 7088: current.className = 'right active'
1.484.2.43 raeburn 7089: } else {
1.374 tempelho 7090: current.className = 'active';
1.484.2.43 raeburn 7091: }
1.374 tempelho 7092: }
1.335 ehlerst 7093: currentData = document.getElementById(data);
7094: currentDivs = currentData.getElementsByTagName('DIV');
7095: for (i = 0; i < currentDivs.length; i++) {
7096: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 7097: currentDivs[i].style.display = 'none';
1.330 tempelho 7098: }
7099: }
1.335 ehlerst 7100: }
1.330 tempelho 7101:
1.374 tempelho 7102: function openTabs(pageId) {
7103: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 7104: if(tabnav.length > 2 ){
1.389 tempelho 7105: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 7106: currentLis = currentNav.getElementsByTagName('LI');
7107: for(i = 0; i< currentLis.length; i++){
7108: if(currentLis[i].className == 'active') {
1.375 tempelho 7109: funcString = currentLis[i].onclick.toString();
7110: tab = funcString.split('"');
1.420 onken 7111: if(tab.length < 2) {
7112: tab = funcString.split("'");
7113: }
1.375 tempelho 7114: currentData = document.getElementById(tab[1]);
7115: currentData.style.display = 'block';
1.374 tempelho 7116: }
7117: }
7118: }
7119: }
7120:
1.334 muellerd 7121: function showPage(current, pageId, nav, data) {
1.484.2.43 raeburn 7122: currstate = current.className;
1.334 muellerd 7123: hideAll(current, nav, data);
1.375 tempelho 7124: openTabs(pageId);
1.334 muellerd 7125: unselectInactive(nav);
1.484.2.43 raeburn 7126: if ((currstate == 'active') || (currstate == 'right active')) {
7127: if (currstate == 'active') {
7128: current.className = '';
7129: } else {
7130: current.className = 'right';
7131: }
7132: activeTab = '';
7133: toggleUpload();
7134: toggleMap();
7135: resize_scrollbox('contentscroll','1','0');
7136: return;
7137: } else {
7138: current.className = 'active';
7139: }
1.330 tempelho 7140: currentData = document.getElementById(pageId);
7141: currentData.style.display = 'block';
1.458 raeburn 7142: activeTab = pageId;
1.484.2.12 raeburn 7143: toggleUpload();
1.484.2.14 raeburn 7144: toggleMap();
1.433 raeburn 7145: if (nav == 'mainnav') {
7146: var storedpath = "$docs_folderpath";
1.434 raeburn 7147: var storedpage = "$main_container_page";
1.433 raeburn 7148: var reg = new RegExp("^supplemental");
7149: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 7150: if (storedpage == 1) {
7151: document.simpleedit.folderpath.value = '';
7152: document.uploaddocument.folderpath.value = '';
7153: } else {
7154: if (reg.test(storedpath)) {
7155: document.simpleedit.folderpath.value = '$toplevelmain';
7156: document.uploaddocument.folderpath.value = '$toplevelmain';
7157: document.newext.folderpath.value = '$toplevelmain';
7158: } else {
7159: document.simpleedit.folderpath.value = storedpath;
7160: document.uploaddocument.folderpath.value = storedpath;
7161: document.newext.folderpath.value = storedpath;
7162: }
1.433 raeburn 7163: }
7164: } else {
1.434 raeburn 7165: if (reg.test(storedpath)) {
7166: document.simpleedit.folderpath.value = storedpath;
7167: document.supuploaddocument.folderpath.value = storedpath;
7168: document.supnewext.folderpath.value = storedpath;
7169: } else {
1.433 raeburn 7170: document.simpleedit.folderpath.value = '$toplevelsupp';
7171: document.supuploaddocument.folderpath.value = '$toplevelsupp';
7172: document.supnewext.folderpath.value = '$toplevelsupp';
7173: }
7174: }
7175: }
1.484.2.3 raeburn 7176: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 7177: return false;
7178: }
1.329 droeschl 7179:
1.472 raeburn 7180: function toContents(jumpto) {
7181: var newurl = '$backtourl';
1.484.2.21 raeburn 7182: if ((newurl == '/adm/navmaps') && (jumpto != '')) {
1.472 raeburn 7183: newurl = newurl+'?postdata='+jumpto;
7184: }
7185: location.href=newurl;
7186: }
7187:
1.484.2.30 raeburn 7188: function togglePick(caller,value) {
7189: var disp = 'none';
7190: if (document.getElementById('multi'+caller)) {
7191: var curr = document.getElementById('multi'+caller).style.display;
7192: if (value == 1) {
7193: disp='block';
7194: }
7195: if (curr == disp) {
7196: return;
7197: }
7198: document.getElementById('multi'+caller).style.display=disp;
7199: if (value == 1) {
1.484.2.61 raeburn 7200: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.484.2.30 raeburn 7201: } else {
7202: document.getElementById('more'+caller).innerHTML = '';
7203: }
7204: if (caller == 'actions') {
7205: setClass(value);
7206: setBoxes(value);
7207: }
7208: }
7209: var showButton = multiSettings();
7210: if (showButton != 1) {
7211: showButton = multiActions();
7212: }
7213: if (document.getElementById('multisave')) {
7214: if (showButton == 1) {
7215: document.getElementById('multisave').style.display='block';
7216: } else {
7217: document.getElementById('multisave').style.display='none';
7218: }
7219: }
7220: resize_scrollbox('contentscroll','1','1');
7221: return;
7222: }
7223:
7224: function toggleCheckUncheck(caller,more) {
7225: if (more == 1) {
1.484.2.61 raeburn 7226: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',0);" style="text-decoration:none;">$js_lt{'less'}</a>';
1.484.2.30 raeburn 7227: document.getElementById('allfields'+caller).style.display='block';
7228: } else {
1.484.2.61 raeburn 7229: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.484.2.30 raeburn 7230: document.getElementById('allfields'+caller).style.display='none';
7231: }
7232: resize_scrollbox('contentscroll','1','1');
7233: }
7234:
7235: function multiSettings() {
7236: var inuse = 0;
7237: var settingsform = document.togglemultsettings;
7238: if (settingsform.showmultpick.length > 1) {
7239: for (var i=0; i<settingsform.showmultpick.length; i++) {
7240: if (settingsform.showmultpick[i].checked) {
7241: if (settingsform.showmultpick[i].value == 1) {
7242: inuse = 1;
7243: }
7244: }
7245: }
7246: }
7247: return inuse;
7248: }
7249:
7250: function multiActions() {
7251: var inuse = 0;
7252: var actionsform = document.togglemultactions;
7253: if (actionsform.showmultpick.length > 1) {
7254: for (var i=0; i<actionsform.showmultpick.length; i++) {
7255: if (actionsform.showmultpick[i].checked) {
7256: if (actionsform.showmultpick[i].value == 1) {
7257: inuse = 1;
7258: }
7259: }
7260: }
7261: }
7262: return inuse;
7263: }
7264:
7265: function checkSubmits() {
7266: var numchanges = 0;
7267: var form = document.saveactions;
7268: var doactions = multiActions();
7269: var cutwarnings = 0;
7270: var remwarnings = 0;
1.484.2.63 raeburn 7271: var removalinfo = 0;
1.484.2.30 raeburn 7272: if (doactions == 1) {
7273: var remidxlist = document.cumulativeactions.allremoveidx.value;
7274: if ((remidxlist != '') && (remidxlist != null)) {
7275: var remidxs = remidxlist.split(',');
7276: for (var i=0; i<remidxs.length; i++) {
7277: if (document.getElementById('remove_'+remidxs[i])) {
7278: if (document.getElementById('remove_'+remidxs[i]).checked) {
7279: form.multiremove.value += remidxs[i]+',';
7280: numchanges ++;
7281: if (document.getElementById('skip_remove_'+remidxs[i])) {
7282: if (document.getElementById('skip_remove_'+remidxs[i]).value == 0) {
7283: remwarnings ++;
7284: }
7285: }
1.484.2.63 raeburn 7286: if (document.getElementById('confirm_removal_'+remidxs[i])) {
7287: if (document.getElementById('confirm_removal_'+remidxs[i]).value == 1) {
7288: removalinfo ++;
7289: }
7290: }
1.484.2.30 raeburn 7291: }
7292: }
7293: }
7294: }
7295: var cutidxlist = document.cumulativeactions.allcutidx.value;
7296: if ((cutidxlist != '') && (cutidxlist != null)) {
7297: var cutidxs = cutidxlist.split(',');
7298: for (var i=0; i<cutidxs.length; i++) {
7299: if (document.getElementById('cut_'+cutidxs[i])) {
7300: if (document.getElementById('cut_'+cutidxs[i]).checked == true) {
7301: form.multicut.value += cutidxs[i]+',';
7302: numchanges ++;
7303: if (document.getElementById('skip_cut_'+cutidxs[i])) {
7304: if (document.getElementById('skip_cut_'+cutidxs[i]).value == 0) {
7305: cutwarnings ++;
7306: }
7307: }
7308: }
7309: }
7310: }
7311: }
7312: var copyidxlist = document.cumulativeactions.allcopyidx.value;
7313: if ((copyidxlist != '') && (copyidxlist != null)) {
7314: var copyidxs = copyidxlist.split(',');
7315: for (var i=0; i<copyidxs.length; i++) {
7316: if (document.getElementById('copy_'+copyidxs[i])) {
7317: if (document.getElementById('copy_'+copyidxs[i]).checked) {
7318: form.multicopy.value += copyidxs[i]+',';
7319: numchanges ++;
7320: }
7321: }
7322: }
7323: }
7324: if (numchanges > 0) {
7325: form.multichange.value = numchanges;
7326: }
7327: }
7328: var dosettings = multiSettings();
7329: var haschanges = 0;
7330: if (dosettings == 1) {
7331: form.allencrypturl.value = '';
7332: form.allhiddenresource.value = '';
7333: form.changeparms.value = 'all';
7334: var patt=new RegExp(",\$");
7335: var allidxlist = document.cumulativesettings.allidx.value;
7336: if ((allidxlist != '') && (allidxlist != null)) {
7337: var allidxs = allidxlist.split(',');
7338: if (allidxs.length > 1) {
7339: for (var i=0; i<allidxs.length; i++) {
7340: if (document.getElementById('hiddenresource_'+allidxs[i])) {
7341: if (document.getElementById('hiddenresource_'+allidxs[i]).checked) {
7342: form.allhiddenresource.value += allidxs[i]+',';
7343: }
7344: }
7345: if (document.getElementById('encrypturl_'+allidxs[i])) {
7346: if (document.getElementById('encrypturl_'+allidxs[i]).checked) {
7347: form.allencrypturl.value += allidxs[i]+',';
7348: }
1.484.2.29 raeburn 7349: }
7350: }
1.484.2.30 raeburn 7351: form.allhiddenresource.value = form.allhiddenresource.value.replace(patt,"");
7352: form.allencrypturl.value = form.allencrypturl.value.replace(patt,"");
7353: }
7354: }
7355: form.allrandompick.value = '';
7356: form.allrandomorder.value = '';
7357: var allmapidxlist = document.cumulativesettings.allmapidx.value;
7358: if ((allmapidxlist != '') && (allmapidxlist != null)) {
7359: var allmapidxs = allmapidxlist.split(',');
7360: for (var i=0; i<allmapidxs.length; i++) {
7361: var randompick = document.getElementById('randompick_'+allmapidxs[i]);
7362: var rpicknum = document.getElementById('rpicknum_'+allmapidxs[i]);
7363: var randorder = document.getElementById('randomorder_'+allmapidxs[i]);
7364: if ((randompick.checked) && (rpicknum.value != '')) {
7365: form.allrandompick.value += allmapidxs[i]+':'+rpicknum.value+',';
7366: }
7367: if (randorder.checked) {
7368: form.allrandomorder.value += allmapidxs[i]+',';
7369: }
7370: }
7371: form.allrandompick.value = form.allrandompick.value.replace(patt,"");
7372: form.allrandomorder.value = form.allrandomorder.value.replace(patt,"");
7373: }
7374: if (document.cumulativesettings.currhiddenresource.value != form.allhiddenresource.value) {
7375: haschanges = 1;
7376: }
7377: if (document.cumulativesettings.currencrypturl.value != form.allencrypturl.value) {
7378: haschanges = 1;
7379: }
7380: if (document.cumulativesettings.currrandomorder.value != form.allrandomorder.value) {
7381: haschanges = 1;
7382: }
7383: if (document.cumulativesettings.currrandompick.value != form.allrandompick.value) {
7384: haschanges = 1;
7385: }
7386: }
7387: if (doactions == 1) {
7388: if (numchanges > 0) {
1.484.2.63 raeburn 7389: if ((cutwarnings > 0) || (remwarnings > 0) || (removalinfo > 0)) {
1.484.2.30 raeburn 7390: if (remwarnings > 0) {
1.484.2.61 raeburn 7391: if (!confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr3a"} '+remwarnings+' $js_lt{"p_rmr3b"}')) {
1.484.2.30 raeburn 7392: return false;
7393: }
7394: }
1.484.2.63 raeburn 7395: if (removalinfo > 0) {
7396: if (!confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr3a"} '+removalinfo+' $js_lt{"p_rmr3b"}')) {
7397: return false;
7398: }
7399: }
1.484.2.30 raeburn 7400: if (cutwarnings > 0) {
1.484.2.61 raeburn 7401: 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 7402: return false;
1.484.2.29 raeburn 7403: }
7404: }
7405: }
1.484.2.30 raeburn 7406: form.submit();
7407: return true;
7408: }
7409: }
7410: if (dosettings == 1) {
7411: if (haschanges == 1) {
7412: form.submit();
7413: return true;
1.484.2.29 raeburn 7414: }
7415: }
1.484.2.30 raeburn 7416: if ((dosettings == 1) && (doactions == 1)) {
1.484.2.61 raeburn 7417: alert("$js_lt{'noor'}");
1.484.2.30 raeburn 7418: } else {
7419: if (dosettings == 1) {
1.484.2.61 raeburn 7420: alert("$js_lt{'noch'}");
1.484.2.30 raeburn 7421: } else {
1.484.2.61 raeburn 7422: alert("$js_lt{'noac'}");
1.484.2.30 raeburn 7423: }
7424: }
7425: return false;
7426: }
7427:
7428: function setClass(value) {
7429: var cutclass = 'LC_docs_cut';
7430: var copyclass = 'LC_docs_copy';
7431: var removeclass = 'LC_docs_remove';
7432: var cutreg = new RegExp("\\\\b"+cutclass+"\\\\b");
7433: var copyreg = new RegExp("\\\\b"+copyclass+"\\\\b");
7434: var removereg = new RegExp("\\\\"+removeclass+"\\\\b");
7435: var links = document.getElementsByTagName('a');
7436: for (var i=0; i<links.length; i++) {
7437: var classes = links[i].className;
7438: if (cutreg.test(classes)) {
7439: links[i].className = cutclass;
7440: if (value == 1) {
7441: links[i].className += " LC_menubuttons_link";
1.484.2.29 raeburn 7442: }
1.484.2.30 raeburn 7443: } else {
7444: if (copyreg.test(classes)) {
7445: links[i].className = copyclass;
7446: if (value == 1) {
7447: links[i].className += " LC_menubuttons_link";
7448: }
7449: } else {
7450: if (removereg.test(classes)) {
7451: links[i].className = removeclass;
7452: if (value == 1) {
7453: links[i].className += " LC_menubuttons_link";
7454: }
7455: }
1.484.2.29 raeburn 7456: }
7457: }
7458: }
1.484.2.30 raeburn 7459: return;
1.484.2.29 raeburn 7460: }
7461:
1.484.2.30 raeburn 7462: function setBoxes(value) {
7463: var remidxlist = document.cumulativeactions.allremoveidx.value;
7464: if ((remidxlist != '') && (remidxlist != null)) {
7465: var remidxs = remidxlist.split(',');
7466: for (var i=0; i<remidxs.length; i++) {
7467: if (document.getElementById('remove_'+remidxs[i])) {
7468: var item = document.getElementById('remove_'+remidxs[i]);
7469: if (value == 1) {
7470: item.className = 'LC_docs_remove';
7471: } else {
7472: item.className = 'LC_hidden';
7473: }
7474: }
1.484.2.29 raeburn 7475: }
7476: }
1.484.2.30 raeburn 7477: var cutidxlist = document.cumulativeactions.allcutidx.value;
7478: if ((cutidxlist != '') && (cutidxlist != null)) {
7479: var cutidxs = cutidxlist.split(',');
7480: for (var i=0; i<cutidxs.length; i++) {
7481: if (document.getElementById('cut_'+cutidxs[i])) {
7482: var item = document.getElementById('cut_'+cutidxs[i]);
7483: if (value == 1) {
7484: item.className = 'LC_docs_cut';
7485: } else {
7486: item.className = 'LC_hidden';
7487: }
7488: }
7489: }
7490: }
7491: var copyidxlist = document.cumulativeactions.allcopyidx.value;
7492: if ((copyidxlist != '') && (copyidxlist != null)) {
7493: var copyidxs = copyidxlist.split(',');
7494: for (var i=0; i<copyidxs.length; i++) {
7495: if (document.getElementById('copy_'+copyidxs[i])) {
7496: var item = document.getElementById('copy_'+copyidxs[i]);
7497: if (value == 1) {
7498: item.className = 'LC_docs_copy';
7499: } else {
7500: item.className = 'LC_hidden';
7501: }
7502: }
1.484.2.29 raeburn 7503: }
7504: }
7505: return;
7506: }
7507:
1.484.2.67 raeburn 7508: ENDSCRIPT
1.329 droeschl 7509: }
1.457 raeburn 7510:
1.483 raeburn 7511: sub history_tab_js {
7512: return <<"ENDHIST";
7513: function toggleHistoryDisp(choice) {
7514: document.docslogform.docslog.value = choice;
7515: document.docslogform.submit();
7516: return;
7517: }
7518:
7519: ENDHIST
7520: }
7521:
1.484 raeburn 7522: sub inject_data_js {
7523: return <<ENDINJECT;
7524:
7525: function injectData(current, hiddenField, name, value) {
7526: currentElement = document.getElementById(hiddenField);
7527: currentElement.name = name;
7528: currentElement.value = value;
7529: current.submit();
7530: }
7531:
7532: ENDINJECT
7533: }
7534:
7535: sub dump_switchserver_js {
7536: my @hosts = @_;
1.484.2.61 raeburn 7537: my %js_lt = &Apache::lonlocal::texthash(
1.484.2.46 raeburn 7538: dump => 'Copying content to Authoring Space requires switching server.',
1.484 raeburn 7539: swit => 'Switch server?',
1.484.2.61 raeburn 7540: );
7541: my %html_js_lt = &Apache::lonlocal::texthash(
7542: swit => 'Switch server?',
1.484.2.43 raeburn 7543: duco => 'Copying Content to Authoring Space',
1.484 raeburn 7544: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
7545: chos => 'Choose server',
7546: );
1.484.2.61 raeburn 7547: &js_escape(\%js_lt);
7548: &html_escape(\%html_js_lt);
7549: &js_escape(\%html_js_lt);
1.484 raeburn 7550: my $role = $env{'request.role'};
7551: my $js = <<"ENDSWJS";
7552: <script type="text/javascript">
7553: function write_switchserver() {
7554: var server;
7555: if (document.setserver.posshosts.length > 0) {
7556: for (var i=0; i<document.setserver.posshosts.length; i++) {
7557: if (document.setserver.posshosts[i].checked) {
7558: server = document.setserver.posshosts[i].value;
7559: }
7560: }
7561: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
7562: }
7563: window.close();
7564: }
7565: </script>
7566:
7567: ENDSWJS
7568:
7569: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
7570: {'only_body' => 1,
7571: 'js_ready' => 1,});
7572: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
7573:
7574: my $hostpicker;
7575: my $count = 0;
7576: foreach my $host (sort(@hosts)) {
7577: my $checked;
7578: if ($count == 0) {
7579: $checked = ' checked="checked"';
7580: }
7581: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
7582: $host.'"'.$checked.' />'.$host.'</label> ';
7583: $count++;
7584: }
7585:
7586: return <<"ENDSWITCHJS";
7587:
7588: function dump_needs_switchserver(url) {
7589: if (url!='' && url!= null) {
1.484.2.61 raeburn 7590: if (confirm("$js_lt{'dump'}\\n$js_lt{'swit'}")) {
1.484 raeburn 7591: go(url);
7592: }
7593: }
7594: return;
7595: }
7596:
7597: function choose_switchserver_window() {
7598: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
7599: newWindow.document.open();
7600: newWindow.document.writeln('$startpage');
1.484.2.61 raeburn 7601: newWindow.document.write('<h3>$html_js_lt{'duco'}<\\/h3>\\n'+
7602: '<p>$html_js_lt{'yone'}<\\/p>\\n'+
7603: '<div class="LC_left_float"><fieldset><legend>$html_js_lt{'chos'}<\\/legend>\\n'+
1.484 raeburn 7604: '<form name="setserver" method="post" action="" \\/>\\n'+
7605: '$hostpicker\\n'+
7606: '<br \\/><br \\/>\\n'+
1.484.2.61 raeburn 7607: '<input type="button" name="makeswitch" value="$html_js_lt{'swit'}" '+
1.484 raeburn 7608: 'onclick="write_switchserver();" \\/>\\n'+
7609: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
7610: newWindow.document.writeln('$endpage');
7611: newWindow.document.close();
7612: newWindow.focus();
7613: }
7614:
7615: ENDSWITCHJS
7616: }
7617:
7618: sub makedocslogform {
7619: my ($formelems,$docslog) = @_;
7620: return <<"LOGSFORM";
7621: <form action="/adm/coursedocs" method="post" name="docslogform">
7622: <input type="hidden" name="docslog" value="$docslog" />
7623: $formelems
7624: </form>
7625: LOGSFORM
7626: }
7627:
7628: sub makesimpleeditform {
7629: my ($formelems) = @_;
7630: return <<"SIMPFORM";
7631: <form name="simpleedit" method="post" action="/adm/coursedocs">
7632: <input type="hidden" name="importdetail" value="" />
7633: $formelems
7634: </form>
7635: SIMPFORM
7636: }
7637:
1.329 droeschl 7638: 1;
7639: __END__
7640:
7641:
7642: =head1 NAME
7643:
7644: Apache::londocs.pm
7645:
7646: =head1 SYNOPSIS
7647:
7648: This is part of the LearningOnline Network with CAPA project
7649: described at http://www.lon-capa.org.
7650:
7651: =head1 SUBROUTINES
7652:
7653: =over
7654:
7655: =item %help=()
7656:
7657: Available help topics
7658:
7659: =item mapread()
7660:
1.344 bisitz 7661: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 7662: @order and @resources, determines status
7663: sets @order - pointer to resources in right order
7664: sets @resources - array with the resources with correct idx
7665:
7666: =item authorhosts()
7667:
7668: Return hash with valid author names
7669:
7670: =item clean()
7671:
7672: =item dumpcourse()
7673:
7674: Actually dump course
7675:
7676: =item group_import()
7677:
7678: Imports the given (name, url) resources into the course
7679: coursenum, coursedom, and folder must precede the list
7680:
7681: =item breadcrumbs()
7682:
7683: =item log_docs()
7684:
7685: =item docs_change_log()
7686:
7687: =item update_paste_buffer()
7688:
7689: =item print_paste_buffer()
7690:
7691: =item do_paste_from_buffer()
7692:
1.484.2.30 raeburn 7693: =item do_buffer_empty()
7694:
7695: =item clear_from_buffer()
7696:
1.484.2.7 raeburn 7697: =item get_newmap_url()
7698:
7699: =item dbcopy()
7700:
7701: =item uniqueness_check()
7702:
7703: =item contained_map_check()
7704:
7705: =item url_paste_fixups()
7706:
7707: =item apply_fixups()
7708:
7709: =item copy_dependencies()
7710:
1.329 droeschl 7711: =item update_parameter()
7712:
7713: =item handle_edit_cmd()
7714:
7715: =item editor()
7716:
7717: =item process_file_upload()
7718:
7719: =item process_secondary_uploads()
7720:
7721: =item is_supplemental_title()
7722:
7723: =item entryline()
7724:
7725: =item tiehash()
7726:
7727: =item untiehash()
7728:
7729: =item checkonthis()
7730:
7731: check on this
7732:
7733: =item verifycontent()
7734:
7735: Verify Content
7736:
1.484.2.72.2. (raeburn 7737:): =item devalidateversioncache()
7738:):
7739:): =item checkversions()
1.329 droeschl 7740:
7741: Check Versions
7742:
7743: =item mark_hash_old()
7744:
7745: =item is_hash_old()
7746:
7747: =item changewarning()
7748:
7749: =item init_breadcrumbs()
7750:
7751: Breadcrumbs for special functions
7752:
1.484 raeburn 7753: =item create_list_elements()
7754:
7755: =item create_form_ul()
7756:
7757: =item startContentScreen()
7758:
7759: =item endContentScreen()
7760:
7761: =item supplemental_base()
7762:
7763: =item embedded_form_elems()
7764:
7765: =item embedded_destination()
7766:
7767: =item return_to_editor()
7768:
7769: =item decompression_info()
7770:
7771: =item decompression_phase_one()
7772:
7773: =item decompression_phase_two()
7774:
7775: =item remove_archive()
7776:
7777: =item generate_admin_menu()
7778:
7779: =item generate_edit_table()
7780:
7781: =item editing_js()
7782:
7783: =item history_tab_js()
7784:
7785: =item inject_data_js()
7786:
7787: =item dump_switchserver_js()
7788:
1.484.2.3 raeburn 7789: =item resize_scrollbox_js()
1.484 raeburn 7790:
7791: =item makedocslogform()
7792:
1.484.2.3 raeburn 7793: =item makesimpleeditform()
7794:
1.329 droeschl 7795: =back
7796:
7797: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>