Annotation of loncom/interface/londocs.pm, revision 1.484.2.72.2.8
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.7 2020/01/16 15:21:23 raeburn Exp $
1.329 droeschl 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29: package Apache::londocs;
30:
31: use strict;
32: use Apache::Constants qw(:common :http);
33: use Apache::imsexport;
34: use Apache::lonnet;
35: use Apache::loncommon;
1.383 tempelho 36: use Apache::lonhtmlcommon;
1.329 droeschl 37: use LONCAPA::map();
38: use Apache::lonratedt();
39: use Apache::lonxml;
40: use Apache::lonclonecourse;
41: use Apache::lonnavmaps;
1.472 raeburn 42: use Apache::lonnavdisplay();
1.484.2.19 raeburn 43: use Apache::lonextresedit();
1.484.2.43 raeburn 44: use Apache::lontemplate();
45: use Apache::lonsimplepage();
1.484.2.72.2. (raeburn 46:): use Apache::loncourserespicker();
1.329 droeschl 47: use HTML::Entities;
1.484.2.7 raeburn 48: use HTML::TokeParser;
1.329 droeschl 49: use GDBM_File;
1.484.2.51 raeburn 50: use File::MMagic;
1.329 droeschl 51: use Apache::lonlocal;
52: use Cwd;
53: use LONCAPA qw(:DEFAULT :match);
54:
55: my $iconpath;
56:
57: my %hash;
58:
59: my $hashtied;
60: my %alreadyseen=();
61:
62: my $hadchanges;
1.484.2.37 raeburn 63: my $suppchanges;
1.329 droeschl 64:
65:
66: my %help=();
67:
68:
69: sub mapread {
70: my ($coursenum,$coursedom,$map)=@_;
71: return
72: &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
73: $map);
74: }
75:
76: sub storemap {
1.484.2.7 raeburn 77: my ($coursenum,$coursedom,$map,$contentchg)=@_;
78: my $report;
79: if (($contentchg) && ($map =~ /^default/)) {
80: $report = 1;
81: }
1.329 droeschl 82: my ($outtext,$errtext)=
83: &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.484.2.7 raeburn 84: $map,1,$report);
1.329 droeschl 85: if ($errtext) { return ($errtext,2); }
1.364 bisitz 86:
1.484.2.37 raeburn 87: if ($map =~ /^default/) {
88: $hadchanges=1;
89: } else {
90: $suppchanges=1;
91: }
1.329 droeschl 92: return ($errtext,0);
93: }
94:
95:
96:
97: sub authorhosts {
98: my %outhash=();
99: my $home=0;
100: my $other=0;
101: foreach my $key (keys(%env)) {
102: if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
103: my $role=$1;
104: my $realm=$2;
105: my ($start,$end)=split(/\./,$env{$key});
106: if (($start) && ($start>time)) { next; }
107: if (($end) && (time>$end)) { next; }
108: my ($ca,$cd);
109: if ($1 eq 'au') {
110: $ca=$env{'user.name'};
111: $cd=$env{'user.domain'};
112: } else {
113: ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
114: }
115: my $allowed=0;
116: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
117: my @ids=&Apache::lonnet::current_machine_ids();
1.484 raeburn 118: foreach my $id (@ids) {
119: if ($id eq $myhome) {
120: $allowed=1;
121: last;
122: }
123: }
1.329 droeschl 124: if ($allowed) {
125: $home++;
1.484 raeburn 126: $outhash{'home_'.$ca.':'.$cd}=1;
1.329 droeschl 127: } else {
1.484 raeburn 128: $outhash{'otherhome_'.$ca.':'.$cd}=$myhome;
1.329 droeschl 129: $other++;
130: }
131: }
132: }
133: return ($home,$other,%outhash);
134: }
135:
136:
137: sub clean {
138: my ($title)=@_;
139: $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
1.344 bisitz 140: return $title;
1.329 droeschl 141: }
142:
1.484.2.67 raeburn 143: sub default_folderpath {
144: my ($coursenum,$coursedom,$navmapref) = @_;
145: return unless ($coursenum && $coursedom && ref($navmapref));
146: # Check if entire course is hidden and/or encrypted
147: my ($hiddenmap,$encryptmap,$folderpath,$hiddentop);
148: my $toplevel = "uploaded/$coursedom/$coursenum/default.sequence";
149: unless (ref($$navmapref)) {
150: $$navmapref = Apache::lonnavmaps::navmap->new();
151: }
152: if (ref($$navmapref)) {
153: if (lc($$navmapref->get_mapparam(undef,$toplevel,"0.hiddenresource")) eq 'yes') {
154: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
155: my @resources = $$navmapref->retrieveResources($toplevel,$filterFunc,1,1);
156: unless (@resources) {
157: $hiddenmap = 1;
158: unless ($env{'request.role.adv'}) {
159: $hiddentop = 1;
160: if ($env{'form.folder'}) {
161: undef($env{'form.folder'});
162: }
163: }
164: }
165: }
166: if (lc($$navmapref->get_mapparam(undef,$toplevel,"0.encrypturl")) eq 'yes') {
167: $encryptmap = 1;
168: }
169: }
170: unless ($hiddentop) {
171: $folderpath='default&'.&escape(&mt('Main Content')).
172: '::'.$hiddenmap.':'.$encryptmap.'::';
173: }
174: if (wantarray) {
175: return ($folderpath,$hiddentop);
176: } else {
177: return $folderpath;
178: }
179: }
1.329 droeschl 180:
181: sub dumpcourse {
182: my ($r) = @_;
1.408 raeburn 183: my $crstype = &Apache::loncommon::course_type();
1.484.2.43 raeburn 184: my ($starthash,$js);
185: unless (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
186: $js = <<"ENDJS";
187: <script type="text/javascript">
188: // <![CDATA[
189:
190: function hide_searching() {
191: if (document.getElementById('searching')) {
192: document.getElementById('searching').style.display = 'none';
193: }
194: return;
195: }
196:
197: // ]]>
198: </script>
199: ENDJS
200: $starthash = {
201: add_entries => {'onload' => "hide_searching();"},
202: };
203: }
204: $r->print(&Apache::loncommon::start_page('Copy '.$crstype.' Content to Authoring Space',$js,$starthash)."\n".
205: &Apache::lonhtmlcommon::breadcrumbs('Copy '.$crstype.' Content to Authoring Space')."\n");
1.484 raeburn 206: $r->print(&startContentScreen('tools'));
1.329 droeschl 207: my ($home,$other,%outhash)=&authorhosts();
1.484 raeburn 208: unless ($home) {
209: $r->print(&endContentScreen());
210: return '';
211: }
1.329 droeschl 212: my $origcrsid=$env{'request.course.id'};
213: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
214: if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
215: # Do the dumping
1.484 raeburn 216: unless ($outhash{'home_'.$env{'form.authorspace'}}) {
217: $r->print(&endContentScreen());
218: return '';
219: }
1.484.2.24 raeburn 220: my ($ca,$cd)=split(/\:/,$env{'form.authorspace'});
1.329 droeschl 221: $r->print('<h3>'.&mt('Copying Files').'</h3>');
222: my $title=$env{'form.authorfolder'};
223: $title=&clean($title);
1.484.2.43 raeburn 224: my ($navmap,$errormsg) =
225: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
226: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
227: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
228: my (%maps,%resources,%titles);
229: if (!ref($navmap)) {
230: $r->print($errormsg.
231: &endContentScreen());
232: return '';
233: } else {
234: &Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles,
235: 'dumpdocs',$cdom,$cnum);
236: }
237: my @todump = &Apache::loncommon::get_env_multiple('form.archive');
238: my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages,
239: %newcontent,%has_simpleprobs);
240: foreach my $item (sort {$a <=> $b} (@todump)) {
241: my $name = $env{'form.namefor_'.$item};
242: if ($resources{$item}) {
243: my ($map,$id,$res) = &Apache::lonnet::decode_symb($resources{$item});
244: if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) {
245: $tocopy{$1} = $name;
246: $display{$item} = $1;
247: $lookup{$1} = $item;
248: } elsif ($res eq 'lib/templates/simpleproblem.problem') {
249: $simpleproblems{$item} = {
250: symb => $resources{$item},
251: name => $name,
252: };
253: $display{$item} = 'simpleproblem_'.$name;
254: if ($map =~ m{^\Quploaded/$cdom/$cnum/\E(.+)$}) {
255: $has_simpleprobs{$1}{$id} = $item;
256: }
257: } elsif ($res =~ m{^adm/$match_domain/$match_username/(\d+)/smppg}) {
258: my $marker = $1;
259: my $db_name = &Apache::lonsimplepage::get_db_name($res,$marker,$cdom,$cnum);
260: $simplepages{$item} = {
261: res => $res,
262: title => $titles{$item},
263: db => $db_name,
264: marker => $marker,
265: symb => $resources{$item},
266: name => $name,
267: };
268: $display{$item} = '/'.$res;
269: }
270: } elsif ($maps{$item}) {
271: if ($maps{$item} =~ m{^\Quploaded/$cdom/$cnum/\E((?:default|supplemental)_\d+\.(?:sequence|page))$}) {
272: $tocopy{$1} = $name;
273: $display{$item} = $1;
274: $lookup{$1} = $item;
275: }
276: } else {
277: next;
278: }
279: }
1.329 droeschl 280: my $crs='/uploaded/'.$env{'request.course.id'}.'/';
281: $crs=~s/\_/\//g;
1.484.2.43 raeburn 282: my $mm = new File::MMagic;
283: my $prefix = "/uploaded/$cdom/$cnum/";
284: %replacehash = %tocopy;
285: foreach my $item (sort(keys(%simpleproblems))) {
286: my $content = &Apache::imsexport::simpleproblem($simpleproblems{$item}{'symb'});
287: $newcontent{$display{$item}} = $content;
288: }
289: my $gateway = Apache::lonhtmlgateway->new('web');
290: foreach my $item (sort(keys(%simplepages))) {
291: if (ref($simplepages{$item}) eq 'HASH') {
292: my $pagetitle = $simplepages{$item}{'title'};
293: my %fields = &Apache::lonnet::dump($simplepages{$item}{'db'},$cdom,$cnum);
294: my %contents;
295: foreach my $field (keys(%fields)) {
296: if ($field =~ /^(?:aaa|bbb|ccc)_(\w+)$/) {
297: my $name = $1;
298: my $msg = $fields{$field};
299: if ($name eq 'webreferences') {
300: if ($msg =~ m{^https?://}) {
301: $contents{$name} = '<a href="'.$msg.'"><tt>'.$msg.'</tt></a>';
302: }
303: } else {
304: $msg = &Encode::decode('utf8',$msg);
305: $msg = $gateway->process_outgoing_html($msg,1);
306: $contents{$name} = $msg;
307: }
308: } elsif ($field eq 'uploaded.photourl') {
309: my $marker = $simplepages{$item}{marker};
310: if ($fields{$field} =~ m{^\Q$prefix\E(simplepage/$marker/.+)$}) {
311: my $filepath = $1;
312: my ($relpath,$fname) = ($filepath =~ m{^(.+/)([^/]+)$});
313: if ($fname ne '') {
314: $fname=~s/\.(\w+)$//;
315: my $ext=$1;
316: $fname = &clean($fname);
317: $fname.='.'.$ext;
318: $contents{image} = '<img src="'.$relpath.$fname.'" alt="Image" />';
319: $replacehash{$filepath} = $relpath.$fname;
320: $deps{$item}{$filepath} = 1;
321: }
322: }
323: }
324: }
325: $replacehash{'/'.$simplepages{$item}{'res'}} = $simplepages{$item}{'name'};
326: $lookup{'/'.$simplepages{$item}{'res'}} = $item;
327: my $content = '
328: <html>
329: <head>
330: <title>'.$pagetitle.'</title>
331: </head>
332: <body bgcolor="#ffffff">';
333: if ($contents{title}) {
334: $content .= "\n".'<h2>'.$contents{title}.'</h2>';
335: }
336: if ($contents{image}) {
337: $content .= "\n".$contents{image};
338: }
339: if ($contents{content}) {
340: $content .= '
341: <div class="LC_Box">
1.484.2.50 raeburn 342: <h4 class="LC_hcell">'.&mt('Content').'</h4>'.
1.484.2.43 raeburn 343: $contents{content}.'
344: </div>';
345: }
346: if ($contents{webreferences}) {
347: $content .= '
348: <div class="LC_Box">
1.484.2.50 raeburn 349: <h4 class="LC_hcell">'.&mt('Web References').'</h4>'.
1.484.2.43 raeburn 350: $contents{webreferences}.'
351: </div>';
352: }
353: $content .= '
354: </body>
355: </html>
356: ';
357: $newcontent{'/'.$simplepages{$item}{res}} = $content;
358: }
359: }
360: foreach my $item (keys(%tocopy)) {
361: unless ($item=~/\.(sequence|page)$/) {
362: my $currurlpath = $prefix.$item;
363: my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath);
364: &recurse_html($mm,$prefix,$currdirpath,$currurlpath,$item,$lookup{$item},\%replacehash,\%deps);
365: }
366: }
367: foreach my $num (sort {$a <=> $b} (@todump)) {
368: my $src = $display{$num};
369: next if ($src eq '');
370: my @needcopy = ();
371: if ($replacehash{$src}) {
372: push(@needcopy,$src);
373: if (ref($deps{$num}) eq 'HASH') {
374: foreach my $dep (sort(keys(%{$deps{$num}}))) {
375: if ($replacehash{$dep}) {
376: push(@needcopy,$dep);
377: }
378: }
379: }
380: } elsif ($src =~ /^simpleproblem_/) {
381: push(@needcopy,$src);
382: }
383: next if (@needcopy == 0);
384: my ($result,$depresult);
385: for (my $i=0; $i<@needcopy; $i++) {
386: my $item = $needcopy[$i];
387: my $newfilename;
388: if ($simpleproblems{$num}) {
389: $newfilename=$title.'/'.$simpleproblems{$num}{'name'};
390: } else {
391: $newfilename=$title.'/'.$replacehash{$item};
392: }
393: $newfilename=~s/\.(\w+)$//;
394: my $ext=$1;
395: $newfilename=&clean($newfilename);
396: $newfilename.='.'.$ext;
397: my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$});
398: if ($newrelpath ne $replacehash{$item}) {
399: $replacehash{$item} = $newrelpath;
400: }
401: my @dirs=split(/\//,$newfilename);
402: my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
403: my $makepath=$path;
404: my $fail;
405: my $origin;
406: for (my $i=0;$i<$#dirs;$i++) {
407: $makepath.='/'.$dirs[$i];
408: unless (-e $makepath) {
409: unless(mkdir($makepath,0755)) {
410: $fail = &mt('Directory creation failed.');
411: }
412: }
413: }
414: if ($i == 0) {
415: $result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ';
416: } else {
417: $depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '.
418: '<span class="LC_fontsize_small" style="font-weight: bold;">'.
419: &mt('(dependency)').'</span>: ';
420: }
421: if (-e $path.'/'.$newfilename) {
422: $fail = &mt('Destination already exists -- not overwriting.');
423: } else {
424: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
425: if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) ||
426: ($item =~ /^simpleproblem_/)) {
427: print $fh $newcontent{$item};
428: } else {
429: my $fileloc = &Apache::lonnet::filelocation('',$prefix.$item);
430: if (-e $fileloc) {
431: if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
432: if ((($1 eq 'sequence') || ($1 eq 'page')) &&
433: (ref($has_simpleprobs{$item}) eq 'HASH')) {
434: my %changes = %{$has_simpleprobs{$item}};
435: my $content = &Apache::lonclonecourse::rewritefile(
436: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
437: (%replacehash,$crs => '')
438: );
439: my $updatedcontent = '';
440: my $parser = HTML::TokeParser->new(\$content);
441: $parser->attr_encoded(1);
442: while (my $token = $parser->get_token) {
443: if ($token->[0] eq 'S') {
444: if (($token->[1] eq 'resource') &&
445: ($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') &&
446: ($changes{$token->[2]->{'id'}})) {
447: my $id = $token->[2]->{'id'};
448: $updatedcontent .= '<'.$token->[1];
449: foreach my $attrib (@{$token->[3]}) {
450: next unless ($attrib =~ /^(src|type|title|id)$/);
451: if ($attrib eq 'src') {
452: my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/);
453: if ($file) {
454: $updatedcontent .= ' '.$attrib.'="'.$file.'"';
455: } else {
456: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
457: }
458: } else {
459: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
460: }
461: }
462: $updatedcontent .= ' />'."\n";
463: } else {
464: $updatedcontent .= $token->[4]."\n";
465: }
466: } else {
467: $updatedcontent .= $token->[2];
468: }
469: }
470: print $fh $updatedcontent;
471: } else {
472: print $fh &Apache::lonclonecourse::rewritefile(
473: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
474: (%replacehash,$crs => '')
475: );
476: }
477: } else {
478: print $fh
479: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
480: }
481: } else {
482: $fail = &mt('Source does not exist.');
483: }
484: }
485: $fh->close();
486: } else {
487: $fail = &mt('Could not write to destination.');
488: }
489: }
490: my $text;
491: if ($fail) {
492: $text = '<span class="LC_error">'.&mt('fail').(' 'x3).$fail.'</span>';
493: } else {
494: $text = '<span class="LC_success">'.&mt('ok').'</span>';
495: }
496: if ($i == 0) {
497: $result .= $text;
498: } else {
499: $depresult .= $text.'</li>';
500: }
501: }
502: $r->print($result);
503: if ($depresult) {
504: $r->print('<ul>'.$depresult.'</ul>');
505: }
506: }
1.329 droeschl 507: } else {
1.484.2.43 raeburn 508: my ($navmap,$errormsg) =
509: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
510: if (!ref($navmap)) {
511: $r->print($errormsg);
512: } else {
513: $r->print('<div id="searching">'.&mt('Searching ...').'</div>');
514: $r->rflush();
515: my ($preamble,$formname);
516: $formname = 'dumpdoc';
517: unless ($home==1) {
518: $preamble = '<div class="LC_left_float">'.
519: '<fieldset><legend>'.
520: &mt('Select the Authoring Space').
521: '</legend><select name="authorspace">';
522: }
523: my @orderspaces = ();
524: foreach my $key (sort(keys(%outhash))) {
525: if ($key=~/^home_(.+)$/) {
526: if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) {
527: unshift(@orderspaces,$1);
528: } else {
529: push(@orderspaces,$1);
530: }
531: }
532: }
533: if ($home>1) {
534: $preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>';
535: }
536: foreach my $user (@orderspaces) {
537: if ($home==1) {
538: $preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />';
539: } else {
540: $preamble .= '<option value="'.$user.'">'.$user.' - '.
541: &Apache::loncommon::plainname(split(/\:/,$user)).'</option>';
542: }
543: }
544: unless ($home==1) {
545: $preamble .= '</select></fieldset></div>'."\n";
546: }
547: my $title=$origcrsdata{'description'};
548: $title=~s/[\/\s]+/\_/gs;
549: $title=&clean($title);
550: $preamble .= '<div class="LC_left_float">'.
551: '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.
552: '<input type="text" size="50" name="authorfolder" value="'.
553: $title.'" />'.
554: '</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n";
555: my %uploadedfiles;
556: &tiehash();
557: foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
558: my ($ext)=($file=~/\.(\w+)$/);
559: # FIXME Check supplemental here
560: my $title=$hash{'title_'.$hash{
561: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
562: if (!$title) {
563: $title=$file;
564: } else {
565: $title=~s|/|_|g;
566: }
567: $title=~s/\.(\w+)$//;
568: $title=&clean($title);
569: $title.='.'.$ext;
570: # $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
571: $uploadedfiles{$file} = $title;
572: }
573: &untiehash();
574: $r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef,
575: undef,undef,$preamble,$home,\%uploadedfiles));
576: }
1.329 droeschl 577: }
1.484 raeburn 578: $r->print(&endContentScreen());
1.329 droeschl 579: }
580:
1.484.2.43 raeburn 581: sub recurse_html {
582: my ($mm,$prefix,$currdirpath,$currurlpath,$container,$item,$replacehash,$deps) = @_;
583: return unless ((ref($replacehash) eq 'HASH') && (ref($deps) eq 'HASH'));
584: my (%allfiles,%codebase);
585: if (&Apache::lonnet::extract_embedded_items($currdirpath,\%allfiles,\%codebase) eq 'ok') {
586: if (keys(%allfiles)) {
587: foreach my $dependency (keys(%allfiles)) {
588: next if (($dependency =~ m{^/(res|adm)/}) || ($dependency =~ m{^https?://}));
589: my ($depurl,$relfile,$newcontainer);
590: if ($dependency =~ m{^/}) {
591: if ($dependency =~ m{^\Q$currurlpath/\E(.+)$}) {
592: $relfile = $1;
593: if ($dependency =~ m{^\Q$prefix\E(.+)$}) {
594: $newcontainer = $1;
595: next if ($replacehash->{$newcontainer});
596: }
597: $depurl = $dependency;
598: } else {
599: next;
600: }
601: } else {
602: $relfile = $dependency;
603: $depurl = $currurlpath;
604: $depurl =~ s{[^/]+$}{};
605: $depurl .= $dependency;
606: ($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$});
607: }
608: next if ($relfile eq '');
609: my $newname = $replacehash->{$container};
610: $newname =~ s{[^/]+$}{};
611: $replacehash->{$newcontainer} = $newname.$relfile;
612: $deps->{$item}{$newcontainer} = 1;
613: my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$});
614: my $depfile = &Apache::lonnet::filelocation('',$depurl);
615: my $type = $mm->checktype_filename($depfile);
616: if ($type eq 'text/html') {
617: &recurse_html($mm,$prefix,$depfile,$newurlpath,$newcontainer,$item,$replacehash,$deps);
618: }
619: }
620: }
621: }
622: return;
623: }
624:
1.329 droeschl 625: sub group_import {
1.484.2.72.2. (raeburn 626:): my ($coursenum, $coursedom, $folder, $container, $caller, $ltitoolsref, @files) = @_;
1.484.2.23 raeburn 627: my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap,
628: %removeparam,$importuploaded,$fixuperrors);
629: $allmaps = {};
1.329 droeschl 630: while (@files) {
631: my ($name, $url, $residx) = @{ shift(@files) };
1.344 bisitz 632: if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
1.329 droeschl 633: && ($caller eq 'londocs')
634: && (!&Apache::lonnet::stat_file($url))) {
1.364 bisitz 635:
1.329 droeschl 636: my $errtext = '';
637: my $fatal = 0;
638: my $newmapstr = '<map>'."\n".
639: '<resource id="1" src="" type="start"></resource>'."\n".
640: '<link from="1" to="2" index="1"></link>'."\n".
641: '<resource id="2" src="" type="finish"></resource>'."\n".
642: '</map>';
643: $env{'form.output'}=$newmapstr;
644: my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
645: 'output',$1.$2);
1.484.2.27 raeburn 646: if ($result !~ m{^/uploaded/}) {
1.329 droeschl 647: $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
648: $fatal = 2;
649: }
650: if ($fatal) {
651: return ($errtext,$fatal);
652: }
653: }
654: if ($url) {
1.484.2.72.2. (raeburn 655:): if ($url =~ m{^(/adm/$coursedom/$coursenum/(\d+)/ext\.tool)\:?(.*)$}) {
656:): $url = $1;
657:): my $marker = $2;
658:): my $info = $3;
659:): my ($toolid,%toolhash,%toolsettings);
660:): my @extras = ('linktext','explanation','crslabel','crstitle');
661:): my @toolinfo = split(/:/,$info);
662:): if ($residx) {
663:): %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
664:): $toolid = $toolsettings{'id'};
665:): } else {
666:): $toolid = shift(@toolinfo);
667:): }
668:): $toolid =~ s/\D//g;
669:): ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'},
670:): $toolhash{'linktext'},$toolhash{'explanation'},
671:): $toolhash{'crslabel'},$toolhash{'crstitle'}) = @toolinfo;
672:): foreach my $item (@extras) {
673:): $toolhash{$item} = &unescape($toolhash{$item});
674:): }
675:): if (ref($ltitoolsref) eq 'HASH') {
676:): my @deleted;
677:): if (ref($ltitoolsref->{$toolid}) eq 'HASH') {
678:): $toolhash{'id'} = $toolid;
679:): if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'tab') ||
680:): ($toolhash{'target'} eq 'window')) {
681:): if ($toolhash{'target'} eq 'window') {
682:): foreach my $item ('width','height') {
683:): $toolhash{$item} =~ s/^\s+//;
684:): $toolhash{$item} =~ s/\s+$//;
685:): if ($toolhash{$item} =~ /\D/) {
686:): delete($toolhash{$item});
687:): if ($residx) {
688:): if ($toolsettings{$item}) {
689:): push(@deleted,$item);
690:): }
691:): }
692:): }
693:): }
694:): }
695:): } elsif ($residx) {
696:): $toolhash{'target'} = $toolsettings{'target'};
697:): if ($toolhash{'target'} eq 'window') {
698:): foreach my $item ('width','height') {
699:): $toolhash{$item} = $toolsettings{$item};
700:): }
701:): }
702:): } elsif (ref($ltitoolsref->{$toolid}->{'display'}) eq 'HASH') {
703:): $toolhash{'target'} = $ltitoolsref->{$toolid}->{'display'}->{'target'};
704:): if ($toolhash{'target'} eq 'window') {
705:): $toolhash{'width'} = $ltitoolsref->{$toolid}->{'display'}->{'width'};
706:): $toolhash{'height'} = $ltitoolsref->{$toolid}->{'display'}->{'height'};
707:): }
708:): }
709:): if ($toolhash{'target'} eq 'iframe') {
710:): foreach my $item ('width','height','linktext','explanation') {
711:): delete($toolhash{$item});
712:): if ($residx) {
713:): if ($toolsettings{$item}) {
714:): push(@deleted,$item);
715:): }
716:): }
717:): }
718:): } elsif ($toolhash{'target'} eq 'tab') {
719:): foreach my $item ('width','height') {
720:): delete($toolhash{$item});
721:): if ($residx) {
722:): if ($toolsettings{$item}) {
723:): push(@deleted,$item);
724:): }
725:): }
726:): }
727:): }
728:): if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') {
729:): foreach my $item ('label','title','linktext','explanation') {
730:): my $crsitem;
731:): if (($item eq 'label') || ($item eq 'title')) {
732:): $crsitem = 'crs'.$item;
733:): } else {
734:): $crsitem = $item;
735:): }
736:): if ($ltitoolsref->{$toolid}->{'crsconf'}->{$item}) {
737:): $toolhash{$crsitem} =~ s/^\s+//;
738:): $toolhash{$crsitem} =~ s/\s+$//;
739:): if ($toolhash{$crsitem} eq '') {
740:): delete($toolhash{$crsitem});
741:): }
742:): } else {
743:): delete($toolhash{$crsitem});
744:): }
745:): if (($residx) && (exists($toolsettings{$crsitem}))) {
746:): unless (exists($toolhash{$crsitem})) {
747:): push(@deleted,$crsitem);
748:): }
749:): }
750:): }
751:): }
752:): my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum);
753:): if ($putres eq 'ok') {
754:): if (@deleted) {
755:): &Apache::lonnet::del('exttool_'.$marker,\@deleted,$coursedom,$coursenum);
756:): }
757:): }
758:): }
759:): }
760:): }
1.484.2.23 raeburn 761: if (($caller eq 'londocs') &&
762: ($folder =~ /^default/)) {
1.484.2.27 raeburn 763: if (($url =~ /\.(page|sequence)$/) && (!$donechk)) {
1.484.2.23 raeburn 764: my $chome = &Apache::lonnet::homeserver($coursenum,$coursedom);
765: my $cid = $coursedom.'_'.$coursenum;
766: $allmaps =
767: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
768: $chome,$cid);
769: $donechk = 1;
770: }
771: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) {
1.484.2.72.2. (raeburn 772:): &contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap,
773:): \%removeparam,\%addedmaps,\%hierarchy,\%titles,$allmaps);
1.484.2.23 raeburn 774: $importuploaded = 1;
775: } elsif ($url =~ m{^/res/.+\.(page|sequence)$}) {
776: next if ($allmaps->{$url});
777: }
778: }
1.344 bisitz 779: if (!$residx
1.329 droeschl 780: || defined($LONCAPA::map::zombies[$residx])) {
781: $residx = &LONCAPA::map::getresidx($url,$residx);
782: push(@LONCAPA::map::order, $residx);
783: }
784: my $ext = 'false';
785: if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
786: $name = &LONCAPA::map::qtunescape($name);
1.484.2.27 raeburn 787: if ($name eq '') {
1.484.2.30 raeburn 788: $name = &LONCAPA::map::qtunescape(&mt('Web Page'));
1.484.2.27 raeburn 789: }
790: if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) {
791: my $filepath = $1;
792: my $fname = $name;
793: if ($fname =~ /^\W+$/) {
794: $fname = 'web';
795: } else {
796: $fname =~ s/\W/_/g;
797: }
1.484.2.62 raeburn 798: if (length($fname) > 15) {
1.484.2.27 raeburn 799: $fname = substr($fname,0,14);
800: }
801: my $initialtext = &mt('Replace with your own content.');
802: my $newhtml = <<END;
1.484.2.31 raeburn 803: <html>
1.484.2.27 raeburn 804: <head>
805: <title>$name</title>
806: </head>
807: <body bgcolor="#ffffff">
808: $initialtext
809: </body>
810: </html>
811: END
812: $env{'form.output'}=$newhtml;
813: my $result =
814: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
815: 'output',
816: "$filepath/$residx/$fname.html");
817: if ($result =~ m{^/uploaded/}) {
818: $url = $result;
819: if ($filepath =~ /^supplemental/) {
820: $name = time.'___&&&___'.$env{'user.name'}.'___&&&___'.
821: $env{'user.domain'}.'___&&&___'.$name;
822: }
823: } else {
824: return (&mt('Failed to save new web page.'),1);
825: }
826: }
1.484.2.30 raeburn 827: $url = &LONCAPA::map::qtunescape($url);
1.344 bisitz 828: $LONCAPA::map::resources[$residx] =
1.329 droeschl 829: join(':', ($name, $url, $ext, 'normal', 'res'));
830: }
831: }
1.484.2.23 raeburn 832: if ($importuploaded) {
833: my %import_errors;
834: my %updated = (
835: removefrommap => \%removefrommap,
836: removeparam => \%removeparam,
837: );
1.484.2.26 raeburn 838: my ($result,$msgsarray,$lockerror) =
839: &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
1.484.2.23 raeburn 840: if (keys(%import_errors) > 0) {
841: $fixuperrors =
842: '<p span class="LC_warning">'."\n".
843: &mt('The following files are either dependencies of a web page or references within a folder and/or composite page for which errors occurred during import:')."\n".
844: '<ul>'."\n";
845: foreach my $key (sort(keys(%import_errors))) {
846: $fixuperrors .= '<li>'.$key.'</li>'."\n";
847: }
848: $fixuperrors .= '</ul></p>'."\n";
849: }
1.484.2.26 raeburn 850: if (ref($msgsarray) eq 'ARRAY') {
851: if (@{$msgsarray} > 0) {
852: $fixuperrors .= '<p class="LC_info">'.
853: join('<br />',@{$msgsarray}).
854: '</p>';
855: }
856: }
857: if ($lockerror) {
858: $fixuperrors .= '<p class="LC_error">'.
859: $lockerror.
860: '</p>';
861: }
1.484.2.23 raeburn 862: }
863: my ($errtext,$fatal) =
864: &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
1.484.2.37 raeburn 865: unless ($fatal) {
866: if ($folder =~ /^supplemental/) {
867: &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
1.484.2.39 raeburn 868: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
869: $folder.'.'.$container);
1.484.2.37 raeburn 870: }
871: }
1.484.2.23 raeburn 872: return ($errtext,$fatal,$fixuperrors);
1.329 droeschl 873: }
874:
875: sub log_docs {
1.484.2.8 raeburn 876: return &Apache::lonnet::write_log('course','docslog',@_);
1.329 droeschl 877: }
878:
879: {
880: my @oldresources=();
881: my @oldorder=();
882: my $parmidx;
883: my %parmaction=();
884: my %parmvalue=();
885: my $changedflag;
886:
887: sub snapshotbefore {
888: @oldresources=@LONCAPA::map::resources;
889: @oldorder=@LONCAPA::map::order;
890: $parmidx=undef;
891: %parmaction=();
892: %parmvalue=();
893: $changedflag=0;
894: }
895:
896: sub remember_parms {
897: my ($idx,$parameter,$action,$value)=@_;
898: $parmidx=$idx;
899: $parmaction{$parameter}=$action;
900: $parmvalue{$parameter}=$value;
901: $changedflag=1;
902: }
903:
904: sub log_differences {
905: my ($plain)=@_;
906: my %storehash=('folder' => $plain,
907: 'currentfolder' => $env{'form.folder'});
908: if ($parmidx) {
909: $storehash{'parameter_res'}=$oldresources[$parmidx];
910: foreach my $parm (keys(%parmaction)) {
911: $storehash{'parameter_action_'.$parm}=$parmaction{$parm};
912: $storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
913: }
914: }
915: my $maxidx=$#oldresources;
916: if ($#LONCAPA::map::resources>$#oldresources) {
917: $maxidx=$#LONCAPA::map::resources;
918: }
919: for (my $idx=0; $idx<=$maxidx; $idx++) {
920: if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
921: $storehash{'before_resources_'.$idx}=$oldresources[$idx];
922: $storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
923: $changedflag=1;
924: }
925: if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
926: $storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
927: $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
928: $changedflag=1;
929: }
930: }
931: $storehash{'maxidx'}=$maxidx;
932: if ($changedflag) { &log_docs(\%storehash); }
933: }
934: }
935:
936: sub docs_change_log {
1.484.2.67 raeburn 937: my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit)=@_;
1.484.2.6 raeburn 938: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
1.484.2.67 raeburn 939: my $navmap;
1.483 raeburn 940: my $js = '<script type="text/javascript">'."\n".
941: '// <![CDATA['."\n".
942: &Apache::loncommon::display_filter_js('docslog')."\n".
1.484.2.67 raeburn 943: &editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag,
1.484.2.72.2. (raeburn 944:): $coursedom,$coursenum,'',$canedit,\$navmap)."\n".
1.483 raeburn 945: &history_tab_js()."\n".
1.484 raeburn 946: &Apache::lonratedt::editscript('simple')."\n".
1.483 raeburn 947: '// ]]>'."\n".
948: '</script>'."\n";
1.484 raeburn 949: $r->print(&Apache::loncommon::start_page('Content Change Log',$js));
950: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Change Log'));
1.484.2.7 raeburn 951: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484 raeburn 952: my %orderhash;
953: my $container='sequence';
954: my $pathitem;
1.484.2.19 raeburn 955: if ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 956: $container='page';
957: }
1.484.2.19 raeburn 958: my $folderpath=$env{'form.folderpath'};
959: if ($folderpath eq '') {
1.484.2.67 raeburn 960: $folderpath = &default_folderpath($coursenum,$coursedom,\$navmap);
1.484.2.19 raeburn 961: }
1.484.2.67 raeburn 962: undef($navmap);
1.484.2.19 raeburn 963: $pathitem = '<input type="hidden" name="folderpath" value="'.
964: &HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 965: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
966: my $jumpto = $readfile;
967: $jumpto =~ s{^/}{};
968: my $tid = 1;
1.484.2.7 raeburn 969: if ($supplementalflag) {
970: $tid = 2;
971: }
1.484.2.19 raeburn 972: my ($breadcrumbtrail) =
1.484.2.18 raeburn 973: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
1.484 raeburn 974: $r->print($breadcrumbtrail.
975: &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto,
976: $readfile));
1.329 droeschl 977: my %docslog=&Apache::lonnet::dump('nohist_docslog',
978: $env{'course.'.$env{'request.course.id'}.'.domain'},
979: $env{'course.'.$env{'request.course.id'}.'.num'});
980:
981: if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
982:
983: my %saveable_parameters = ('show' => 'scalar',);
984: &Apache::loncommon::store_course_settings('docs_log',
985: \%saveable_parameters);
986: &Apache::loncommon::restore_course_settings('docs_log',
987: \%saveable_parameters);
988: if (!$env{'form.show'}) { $env{'form.show'}=10; }
1.452 www 989: # FIXME: internationalization seems wrong here
1.329 droeschl 990: my %lt=('hiddenresource' => 'Resources hidden',
991: 'encrypturl' => 'URL hidden',
992: 'randompick' => 'Randomly pick',
993: 'randomorder' => 'Randomly ordered',
994: 'set' => 'set to',
995: 'del' => 'deleted');
1.484 raeburn 996: my $filter = &Apache::loncommon::display_filter('docslog')."\n".
997: $pathitem."\n".
998: '<input type="hidden" name="folder" value="'.$env{'form.folder'}.'" />'.
999: (' 'x2).'<input type="submit" value="'.&mt('Display').'" />';
1000: $r->print('<div class="LC_left_float">'.
1001: '<fieldset><legend>'.&mt('Display of Content Changes').'</legend>'."\n".
1002: &makedocslogform($filter,1).
1003: '</fieldset></div><br clear="all" />');
1.329 droeschl 1004: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
1005: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
1006: &mt('After').'</th>'.
1007: &Apache::loncommon::end_data_table_header_row());
1008: my $shown=0;
1009: foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
1010: if ($env{'form.displayfilter'} eq 'currentfolder') {
1011: if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
1012: }
1013: my @changes=keys(%{$docslog{$id}{'logentry'}});
1014: if ($env{'form.displayfilter'} eq 'containing') {
1015: my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
1016: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
1017: foreach my $key (@changes) {
1018: $wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
1019: }
1.344 bisitz 1020: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
1.329 droeschl 1021: }
1022: my $count = 0;
1023: my $time =
1024: &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
1025: my $plainname =
1026: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
1027: $docslog{$id}{'exe_udom'});
1028: my $about_me_link =
1029: &Apache::loncommon::aboutmewrapper($plainname,
1030: $docslog{$id}{'exe_uname'},
1031: $docslog{$id}{'exe_udom'});
1032: my $send_msg_link='';
1033: if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
1034: || ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
1035: $send_msg_link ='<br />'.
1036: &Apache::loncommon::messagewrapper(&mt('Send message'),
1037: $docslog{$id}{'exe_uname'},
1038: $docslog{$id}{'exe_udom'});
1039: }
1040: $r->print(&Apache::loncommon::start_data_table_row());
1041: $r->print('<td>'.$time.'</td>
1042: <td>'.$about_me_link.
1043: '<br /><tt>'.$docslog{$id}{'exe_uname'}.
1044: ':'.$docslog{$id}{'exe_udom'}.'</tt>'.
1045: $send_msg_link.'</td><td>'.
1046: $docslog{$id}{'logentry'}{'folder'}.'</td><td>');
1.484.2.19 raeburn 1047: my $is_supp = 0;
1.484.2.7 raeburn 1048: if ($docslog{$id}{'logentry'}{'currentfolder'} =~ /^supplemental/) {
1049: $is_supp = 1;
1050: }
1.329 droeschl 1051: # Before
1052: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1053: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
1054: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
1055: if ($oldname ne $newname) {
1.484.2.7 raeburn 1056: my $shown = &LONCAPA::map::qtescape($oldname);
1057: if ($is_supp) {
1058: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1059: }
1060: $r->print($shown);
1.329 droeschl 1061: }
1062: }
1063: $r->print('<ul>');
1064: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1065: if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
1.484.2.7 raeburn 1066: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]);
1067: if ($is_supp) {
1068: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1069: }
1.484.2.19 raeburn 1070: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 1071: }
1072: }
1073: $r->print('</ul>');
1074: # After
1075: $r->print('</td><td>');
1076:
1077: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1078: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
1079: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
1080: if ($oldname ne '' && $oldname ne $newname) {
1.484.2.7 raeburn 1081: my $shown = &LONCAPA::map::qtescape($newname);
1082: if ($is_supp) {
1083: $shown = &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($newname));
1084: }
1085: $r->print($shown);
1.329 droeschl 1086: }
1.364 bisitz 1087: }
1.329 droeschl 1088: $r->print('<ul>');
1089: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1090: if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
1.484.2.7 raeburn 1091: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]);
1092: if ($is_supp) {
1093: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1094: }
1095: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 1096: }
1097: }
1098: $r->print('</ul>');
1099: if ($docslog{$id}{'logentry'}{'parameter_res'}) {
1100: $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
1101: foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
1102: if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
1.452 www 1103: # FIXME: internationalization seems wrong here
1.329 droeschl 1104: $r->print('<li>'.
1105: &mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
1106: $docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
1107: .'</li>');
1108: }
1109: }
1110: $r->print('</ul>');
1111: }
1112: # End
1113: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1114: $shown++;
1115: if (!($env{'form.show'} eq &mt('all')
1116: || $shown<=$env{'form.show'})) { last; }
1117: }
1.484 raeburn 1118: $r->print(&Apache::loncommon::end_data_table()."\n".
1119: &makesimpleeditform($pathitem)."\n".
1120: '</div></div>');
1121: $r->print(&endContentScreen());
1.329 droeschl 1122: }
1123:
1124: sub update_paste_buffer {
1.484.2.7 raeburn 1125: my ($coursenum,$coursedom,$folder) = @_;
1.484.2.57 raeburn 1126: my (@possibles,%removals,%cuts,$output);
1.484.2.30 raeburn 1127: if ($env{'form.multiremove'}) {
1128: $env{'form.multiremove'} =~ s/,$//;
1129: map { $removals{$_} = 1; } split(/,/,$env{'form.multiremove'});
1130: }
1131: if (($env{'form.multicopy'}) || ($env{'form.multicut'})) {
1132: if ($env{'form.multicut'}) {
1133: $env{'form.multicut'} =~ s/,$//;
1134: foreach my $item (split(/,/,$env{'form.multicut'})) {
1135: unless ($removals{$item}) {
1136: $cuts{$item} = 1;
1137: push(@possibles,$item.':cut');
1138: }
1139: }
1140: }
1141: if ($env{'form.multicopy'}) {
1142: $env{'form.multicopy'} =~ s/,$//;
1143: foreach my $item (split(/,/,$env{'form.multicopy'})) {
1144: unless ($removals{$item} || $cuts{$item}) {
1145: push(@possibles,$item.':copy');
1146: }
1147: }
1148: }
1149: } elsif ($env{'form.markcopy'}) {
1150: @possibles = split(/,/,$env{'form.markcopy'});
1151: }
1.329 droeschl 1152:
1.484.2.30 raeburn 1153: return if (@possibles == 0);
1.329 droeschl 1154: return if (!defined($env{'form.copyfolder'}));
1155:
1156: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1157: $env{'form.copyfolder'});
1158: return if ($fatal);
1159:
1.484.2.30 raeburn 1160: my %curr_groups = &Apache::longroup::coursegroups();
1161:
1162: # Retrieve current paste buffer suffixes.
1163: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1164: my (%pasteurls,@newpaste);
1165:
1166: # Construct identifiers for current contents of user's paste buffer
1167: if (@currpaste) {
1168: foreach my $suffix (@currpaste) {
1169: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1170: my $url = $env{'docs.markedcopy_url_'.$suffix};
1171: if (($cid =~ /^$match_domain(?:_)$match_courseid$/) &&
1172: ($url ne '')) {
1.484.2.41 raeburn 1173: $pasteurls{$cid.'_'.$url} = 1;
1.484.2.30 raeburn 1174: }
1175: }
1176: }
1177:
1178: # Mark items for copying (skip any items already in user's paste buffer)
1179: my %addtoenv;
1180:
1181: foreach my $item (@possibles) {
1182: my ($orderidx,$cmd) = split(/:/,$item);
1183: next if ($orderidx =~ /\D/);
1184: next unless (($cmd eq 'cut') || ($cmd eq 'copy') || ($cmd eq 'remove'));
1185: my ($title,$url)=split(':',$LONCAPA::map::resources[$orderidx]);
1186: my %denied = &action_restrictions($coursenum,$coursedom,
1187: &LONCAPA::map::qtescape($url),
1188: $env{'form.folderpath'},\%curr_groups);
1189: next if ($denied{'copy'});
1190: $url=~s{http(:|:)//https(:|:)//}{https$2//};
1191: next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$url}));
1192: my ($suffix,$errortxt,$locknotfreed) =
1193: &new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste');
1.484.2.57 raeburn 1194: if ($suffix ne '') {
1195: push(@newpaste,$suffix);
1196: } else {
1197: if ($locknotfreed) {
1198: return $locknotfreed;
1199: }
1.484.2.30 raeburn 1200: }
1201: if (&is_supplemental_title($title)) {
1202: &Apache::lonnet::appenv({'docs.markedcopy_supplemental_'.$suffix => $title});
1203: ($title) = &Apache::loncommon::parse_supplemental_title($title);
1204: }
1205:
1206: $addtoenv{'docs.markedcopy_title_'.$suffix} = $title,
1207: $addtoenv{'docs.markedcopy_url_'.$suffix} = $url,
1208: $addtoenv{'docs.markedcopy_cmd_'.$suffix} = $cmd,
1209: $addtoenv{'docs.markedcopy_crs_'.$suffix} = $env{'request.course.id'};
1210:
1211: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) {
1212: my $prefix = $1;
1213: my $subdir =$2;
1214: if ($subdir eq '') {
1215: $subdir = $prefix;
1.484.2.7 raeburn 1216: }
1.484.2.30 raeburn 1217: my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps);
1.484.2.72.2. (raeburn 1218:): &contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap,
1219:): \%removeparam,\%addedmaps,\%hierarchy,\%titles,\%allmaps);
1.484.2.30 raeburn 1220: if (ref($hierarchy{$url}) eq 'HASH') {
1221: my ($nested,$nestednames);
1222: &recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames);
1223: $nested =~ s/\&$//;
1224: $nestednames =~ s/\Q___&&&___\E$//;
1225: if ($nested ne '') {
1226: $addtoenv{'docs.markedcopy_nested_'.$suffix} = $nested;
1227: }
1228: if ($nestednames ne '') {
1229: $addtoenv{'docs.markedcopy_nestednames_'.$suffix} = $nestednames;
1230: }
1.484.2.7 raeburn 1231: }
1232: }
1.484.2.57 raeburn 1233: if ($locknotfreed) {
1234: $output = $locknotfreed;
1235: last;
1236: }
1.484.2.7 raeburn 1237: }
1.484.2.30 raeburn 1238: if (@newpaste) {
1239: $addtoenv{'docs.markedcopies'} = join(',',(@currpaste,@newpaste));
1240: }
1.484.2.7 raeburn 1241: &Apache::lonnet::appenv(\%addtoenv);
1.329 droeschl 1242: delete($env{'form.markcopy'});
1.484.2.57 raeburn 1243: return $output;
1.329 droeschl 1244: }
1245:
1.484.2.7 raeburn 1246: sub recurse_uploaded_maps {
1247: my ($url,$dir,$hierarchy,$titlesref,$nestref,$namesref) = @_;
1248: if (ref($hierarchy->{$url}) eq 'HASH') {
1249: my @maps = map { $hierarchy->{$url}{$_}; } sort { $a <=> $b } (keys(%{$hierarchy->{$url}}));
1250: my @titles = map { $titlesref->{$url}{$_}; } sort { $a <=> $b } (keys(%{$titlesref->{$url}}));
1251: my (@uploaded,@names,%shorter);
1252: for (my $i=0; $i<@maps; $i++) {
1253: my ($inner) = ($maps[$i] =~ m{^/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_(\d+)\.(?:page|sequence)$});
1254: if ($inner ne '') {
1255: push(@uploaded,$inner);
1256: push(@names,&escape($titles[$i]));
1257: $shorter{$maps[$i]} = $inner;
1258: }
1259: }
1260: $$nestref .= "$dir:".join(',',@uploaded).'&';
1261: $$namesref .= "$dir:".(join(',',@names)).'___&&&___';
1262: foreach my $map (@maps) {
1263: if ($shorter{$map} ne '') {
1264: &recurse_uploaded_maps($map,$shorter{$map},$hierarchy,$titlesref,$nestref,$namesref);
1265: }
1266: }
1267: }
1268: return;
1269: }
1270:
1.329 droeschl 1271: sub print_paste_buffer {
1.484.2.7 raeburn 1272: my ($r,$container,$folder,$coursedom,$coursenum) = @_;
1.484.2.30 raeburn 1273: return if (!defined($env{'docs.markedcopies'}));
1.329 droeschl 1274:
1.484.2.30 raeburn 1275: unless (($env{'form.pastemarked'}) || ($env{'form.clearmarked'})) {
1276: return if ($env{'docs.markedcopies'} eq '');
1.484.2.7 raeburn 1277: }
1278:
1.484.2.30 raeburn 1279: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1280: my ($pasteitems,@pasteable);
1.484.2.47 raeburn 1281: my $clipboardcount = 0;
1.484.2.7 raeburn 1282:
1.484.2.30 raeburn 1283: # Construct identifiers for current contents of user's paste buffer
1284: foreach my $suffix (@currpaste) {
1285: next if ($suffix =~ /\D/);
1286: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1287: my $url = $env{'docs.markedcopy_url_'.$suffix};
1288: if (($cid =~ /^$match_domain\_$match_courseid$/) &&
1289: ($url ne '')) {
1.484.2.47 raeburn 1290: $clipboardcount ++;
1.484.2.30 raeburn 1291: my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent,
1.484.2.72.2. (raeburn 1292:): $canpaste,$nopaste,$othercrs,$areachange,$is_exttool);
1.484.2.30 raeburn 1293: my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1];
1294: if ($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
1295: $is_external = 1;
1.484.2.72.2. (raeburn 1296:): } elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$}) {
1297:): $is_exttool = 1;
1.484.2.7 raeburn 1298: }
1.484.2.30 raeburn 1299: if ($folder =~ /^supplemental/) {
1300: $canpaste = &supp_pasteable($env{'docs.markedcopy_url_'.$suffix});
1301: unless ($canpaste) {
1302: $nopaste = &mt('Paste into Supplemental Content unavailable.');
1.484.2.7 raeburn 1303: }
1.484.2.30 raeburn 1304: } else {
1305: $canpaste = 1;
1.484.2.7 raeburn 1306: }
1.484.2.30 raeburn 1307: if ($canpaste) {
1308: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1309: my $srcdom = $1;
1310: my $srcnum = $2;
1311: my $rem = $3;
1312: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
1313: $othercourse = 1;
1314: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1.484.2.72.2. (raeburn 1315:): $othercrs = '<br />'.&mt('(from another course)');
1.484.2.30 raeburn 1316: } else {
1317: $canpaste = 0;
1318: $nopaste = &mt('Paste from another course unavailable.');
1.484.2.7 raeburn 1319: }
1320: }
1.484.2.30 raeburn 1321: if ($rem =~ m{^(default|supplemental)_?(\d*)\.(?:page|sequence)$}) {
1322: my $prefix = $1;
1323: $parent = $2;
1324: if ($folder !~ /^\Q$prefix\E/) {
1325: $areachange = 1;
1326: }
1327: $is_uploaded_map = 1;
1328: }
1.484.2.72.2. (raeburn 1329:): } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
1330:): ($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg|ext\.tool)$})) {
1331:): if ($cid ne $env{'request.course.id'}) {
1332:): my ($srcdom,$srcnum) = split(/_/,$cid);
1333:): if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1334:): if (($is_exttool) && ($srcdom ne $coursedom)) {
1335:): $canpaste = 0;
1336:): $nopaste = &mt('Paste from another domain unavailable.');
1337:): } else {
1338:): $othercrs = '<br />'.&mt('(from another course)');
1339:): }
1340:): } else {
1341:): $canpaste = 0;
1342:): $nopaste = &mt('Paste from another course unavailable.');
1343:): }
1344:): }
1.484.2.30 raeburn 1345: }
1346: }
1347: if ($canpaste) {
1348: push(@pasteable,$suffix);
1349: }
1350: my $buffer;
1.484.2.72.2. (raeburn 1351:): if ($is_external) {
1.484.2.30 raeburn 1352: $buffer = &mt('External Resource').': '.
1353: &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('.
1354: &LONCAPA::map::qtescape($url).')';
1.484.2.72.2. (raeburn 1355:): } elsif ($is_exttool) {
1356:): $buffer = &mt('External Tool').': '.
1357:): &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.484.2.30 raeburn 1358: } else {
1359: my $icon = &Apache::loncommon::icon($extension);
1360: if ($extension eq 'sequence' &&
1361: $url =~ m{/default_\d+\.sequence$}x) {
1362: $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
1363: $icon .= '/navmap.folder.closed.gif';
1364: }
1.484.2.57 raeburn 1365: my $title = $env{'docs.markedcopy_title_'.$suffix};
1366: if ($title eq '') {
1367: ($title) = ($url =~ m{/([^/]+)$});
1368: }
1.484.2.30 raeburn 1369: $buffer = '<img src="'.$icon.'" alt="" class="LC_icon" />'.
1370: ': '.
1371: &Apache::loncommon::parse_supplemental_title(
1.484.2.57 raeburn 1372: &LONCAPA::map::qtescape($title));
1.484.2.30 raeburn 1373: }
1374: $pasteitems .= '<div class="LC_left_float">';
1375: my ($options,$onclick);
1376: if (($canpaste) && (!$areachange) && (!$othercourse) &&
1377: ($env{'docs.markedcopy_cmd_'.$suffix} eq 'cut')) {
1378: if (($is_uploaded_map) ||
1379: ($url =~ /(bulletinboard|smppg)$/) ||
1380: ($url =~ m{^/uploaded/$coursedom/$coursenum/(?:docs|supplemental)/(.+)$})) {
1381: $options = &paste_options($suffix,$is_uploaded_map,$parent);
1382: $onclick= 'onclick="showOptions(this,'."'$suffix'".');" ';
1383: }
1384: }
1385: $pasteitems .= '<label><input type="checkbox" name="pasting" id="pasting_'.$suffix.'" value="'.$suffix.'" '.$onclick.'/>'.$buffer.'</label>';
1386: if ($nopaste) {
1387: $pasteitems .= $nopaste;
1388: } else {
1389: if ($othercrs) {
1390: $pasteitems .= $othercrs;
1391: }
1392: if ($options) {
1393: $pasteitems .= $options;
1.484.2.7 raeburn 1394: }
1395: }
1.484.2.30 raeburn 1396: $pasteitems .= '</div>';
1397: }
1398: }
1399: if ($pasteitems eq '') {
1400: &Apache::lonnet::delenv('docs.markedcopies');
1401: }
1402: my ($pasteform,$form_start,$buttons,$form_end);
1403: if ($pasteitems) {
1404: $pasteitems .= '<div style="padding:0;clear:both;margin:0;border:0"></div>';
1405: $form_start = '<form name="pasteform" action="/adm/coursedocs" method="post" onsubmit="return validateClipboard();">';
1406: if (@pasteable) {
1.484.2.47 raeburn 1407: my $value = &mt('Paste to current folder');
1408: if ($container eq 'page') {
1409: $value = &mt('Paste to current page');
1410: }
1411: $buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.(' 'x2);
1412: }
1.484.2.72.2. (raeburn 1413:): $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.(' 'x2);
1.484.2.47 raeburn 1414: if ($clipboardcount > 1) {
1415: $buttons .=
1416: '<span style="text-decoration:line-through">'.(' 'x20).'</span>'.(' 'x2).
1417: '<input type="button" name="checkallclip" value="'.&mt('Check all').'" style="height:20px;" onclick="checkClipboard();" />'.
1418: (' 'x2).
1419: '<input type="button" name="uncheckallclip" value="'.&mt('Uncheck all').'" style="height:20px;" onclick="uncheckClipboard();" />'.
1420: (' 'x2);
1.484.2.7 raeburn 1421: }
1.484.2.48 raeburn 1422: $form_end = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'.
1423: '</form>';
1.484.2.30 raeburn 1424: } else {
1425: $pasteitems = &mt('Clipboard is empty');
1426: }
1427: $r->print($form_start
1428: .'<fieldset>'
1429: .'<legend>'.&mt('Clipboard').(' ' x2).$buttons.'</legend>'
1430: .$pasteitems
1431: .'</fieldset>'
1432: .$form_end);
1433: }
1434:
1435: sub paste_options {
1436: my ($suffix,$is_uploaded_map,$parent) = @_;
1437: my ($copytext,$movetext);
1438: if ($is_uploaded_map) {
1439: $copytext = &mt('Copy to new folder');
1440: $movetext = &mt('Move old');
1441: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /bulletinboard$/) {
1442: $copytext = &mt('Copy to new board');
1443: $movetext = &mt('Move (not posts)');
1444: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /smppg$/) {
1445: $copytext = &mt('Copy to new page');
1446: $movetext = &mt('Move');
1.484.2.7 raeburn 1447: } else {
1.484.2.30 raeburn 1448: $copytext = &mt('Copy to new file');
1449: $movetext = &mt('Move');
1450: }
1451: my $output = '<br />'.
1452: '<span id="pasteoptionstext_'.$suffix.'" class="LC_fontsize_small LC_nobreak"></span>'.
1453: '<div id="pasteoptions_'.$suffix.'" class="LC_dccid" style="display:none;"><span class="LC_nobreak">'.(' 'x 4).
1454: '<label>'.
1455: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="new" checked="checked" />'.
1456: $copytext.'</label></span>'.(' 'x2).' '.
1457: '<span class="LC_nobreak"><label>'.
1458: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="move" />'.
1459: $movetext.'</label></span>';
1460: if (($is_uploaded_map) && ($env{'docs.markedcopy_nested_'.$suffix})) {
1461: $output .= '<br /><fieldset><legend>'.&mt('Folder to paste contains sub-folders').
1462: '</legend><table border="0">';
1463: my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1464: my @titles = split(/\Q___&&&___\E/,$env{'docs.markedcopy_nestednames_'.$suffix});
1465: my $lastdir = $parent;
1466: my %depths = (
1467: $lastdir => 0,
1468: );
1469: my (%display,%deps);
1470: for (my $i=0; $i<@pastemaps; $i++) {
1471: ($lastdir,my $subfolderstr) = split(/\:/,$pastemaps[$i]);
1472: my ($namedir,$esctitlestr) = split(/\:/,$titles[$i]);
1473: my @subfolders = split(/,/,$subfolderstr);
1474: $deps{$lastdir} = \@subfolders;
1475: my @subfoldertitles = map { &unescape($_); } split(/,/,$esctitlestr);
1476: my $depth = $depths{$lastdir} + 1;
1477: my $offset = int($depth * 4);
1478: my $indent = (' ' x $offset);
1479: for (my $j=0; $j<@subfolders; $j++) {
1480: $depths{$subfolders[$j]} = $depth;
1481: $display{$subfolders[$j]} =
1482: '<tr><td>'.$indent.$subfoldertitles[$j].' </td>'.
1483: '<td><label>'.
1484: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="new" checked="checked" />'.&mt('Copy to new').'</label>'.(' ' x2).
1485: '<label>'.
1486: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="move" />'.
1487: &mt('Move old').'</label>'.
1488: '</td></tr>';
1489: }
1490: }
1491: &recurse_print(\$output,$parent,\%deps,\%display);
1492: $output .= '</table></fieldset>';
1.329 droeschl 1493: }
1.484.2.30 raeburn 1494: $output .= '</div>';
1495: return $output;
1.329 droeschl 1496: }
1497:
1.484.2.7 raeburn 1498: sub recurse_print {
1.484.2.30 raeburn 1499: my ($outputref,$dir,$deps,$display) = @_;
1500: $$outputref .= $display->{$dir}."\n";
1.484.2.7 raeburn 1501: if (ref($deps->{$dir}) eq 'ARRAY') {
1502: foreach my $subdir (@{$deps->{$dir}}) {
1.484.2.30 raeburn 1503: &recurse_print($outputref,$subdir,$deps,$display);
1.484.2.7 raeburn 1504: }
1505: }
1506: }
1507:
1508: sub supp_pasteable {
1509: my ($url) = @_;
1510: if (($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//}) ||
1511: (($url =~ /\.sequence$/) && ($url =~ m{^/uploaded/})) ||
1512: ($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) ||
1513: ($url =~ m{^/adm/$match_domain/$match_username/aboutme}) ||
1.484.2.72.2. (raeburn 1514:): ($url =~ m{^/public/$match_domain/$match_courseid/syllabus}) ||
1515:): ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$})) {
1.484.2.7 raeburn 1516: return 1;
1517: }
1518: return;
1519: }
1520:
1521: sub paste_popup_js {
1.484.2.61 raeburn 1522: my %html_js_lt = &Apache::lonlocal::texthash(
1.484.2.30 raeburn 1523: show => 'Show Options',
1524: hide => 'Hide Options',
1.484.2.61 raeburn 1525: );
1526: my %js_lt = &Apache::lonlocal::texthash(
1.484.2.30 raeburn 1527: none => 'No items selected from clipboard.',
1.484.2.7 raeburn 1528: );
1.484.2.61 raeburn 1529: &html_escape(\%html_js_lt);
1530: &js_escape(\%html_js_lt);
1531: &js_escape(\%js_lt);
1.484.2.7 raeburn 1532: return <<"END";
1533:
1.484.2.30 raeburn 1534: function showPasteOptions(suffix) {
1535: document.getElementById('pasteoptions_'+suffix).style.display='block';
1.484.2.61 raeburn 1536: document.getElementById('pasteoptionstext_'+suffix).innerHTML = ' <a href="javascript:hidePasteOptions(\\''+suffix+'\\');" class="LC_menubuttons_link">$html_js_lt{'hide'}</a>';
1.484.2.7 raeburn 1537: return;
1538: }
1539:
1.484.2.30 raeburn 1540: function hidePasteOptions(suffix) {
1541: document.getElementById('pasteoptions_'+suffix).style.display='none';
1.484.2.61 raeburn 1542: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.484.2.7 raeburn 1543: return;
1544: }
1545:
1.484.2.30 raeburn 1546: function showOptions(caller,suffix) {
1547: if (document.getElementById('pasteoptionstext_'+suffix)) {
1548: if (caller.checked) {
1.484.2.61 raeburn 1549: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.484.2.30 raeburn 1550: } else {
1551: document.getElementById('pasteoptionstext_'+suffix).innerHTML ='';
1552: }
1553: if (document.getElementById('pasteoptions_'+suffix)) {
1554: document.getElementById('pasteoptions_'+suffix).style.display='none';
1555: }
1556: }
1557: return;
1558: }
1.484.2.7 raeburn 1559:
1.484.2.30 raeburn 1560: function validateClipboard() {
1561: var numchk = 0;
1562: if (document.pasteform.pasting.length > 1) {
1563: for (var i=0; i<document.pasteform.pasting.length; i++) {
1564: if (document.pasteform.pasting[i].checked) {
1565: numchk ++;
1566: }
1567: }
1568: } else {
1569: if (document.pasteform.pasting.type == 'checkbox') {
1570: if (document.pasteform.pasting.checked) {
1571: numchk ++;
1572: }
1573: }
1574: }
1575: if (numchk > 0) {
1576: return true;
1577: } else {
1.484.2.61 raeburn 1578: alert("$js_lt{'none'}");
1.484.2.30 raeburn 1579: return false;
1580: }
1.484.2.7 raeburn 1581: }
1582:
1.484.2.47 raeburn 1583: function checkClipboard() {
1584: if (document.pasteform.pasting.length > 1) {
1585: for (var i=0; i<document.pasteform.pasting.length; i++) {
1586: document.pasteform.pasting[i].checked = true;
1587: }
1588: }
1589: return;
1590: }
1591:
1592: function uncheckClipboard() {
1593: if (document.pasteform.pasting.length >1) {
1594: for (var i=0; i<document.pasteform.pasting.length; i++) {
1595: document.pasteform.pasting[i].checked = false;
1596: }
1597: }
1598: return;
1599: }
1600:
1.484.2.30 raeburn 1601: END
1602:
1603: }
1.484.2.7 raeburn 1604:
1.329 droeschl 1605: sub do_paste_from_buffer {
1.484.2.7 raeburn 1606: my ($coursenum,$coursedom,$folder,$container,$errors) = @_;
1.329 droeschl 1607:
1.484.2.30 raeburn 1608: # Array of items in paste buffer
1609: my (@currpaste,%pastebuffer,%allerrors);
1610: @currpaste = split(/,/,$env{'docs.markedcopies'});
1611:
1.484.2.7 raeburn 1612: # Early out if paste buffer is empty
1.484.2.30 raeburn 1613: if (@currpaste == 0) {
1.484.2.7 raeburn 1614: return ();
1.484.2.30 raeburn 1615: }
1616: map { $pastebuffer{$_} = 1; } @currpaste;
1617:
1618: # Array of items selected items to paste
1619: my @reqpaste = &Apache::loncommon::get_env_multiple('form.pasting');
1620:
1621: # Early out if nothing selected to paste
1622: if (@reqpaste == 0) {
1623: return();
1624: }
1625: my @topaste;
1626: foreach my $suffix (@reqpaste) {
1627: next if ($suffix =~ /\D/);
1628: next unless (exists($pastebuffer{$suffix}));
1629: push(@topaste,$suffix);
1.484.2.7 raeburn 1630: }
1631:
1.484.2.30 raeburn 1632: # Early out if nothing available to paste
1633: if (@topaste == 0) {
1634: return();
1.329 droeschl 1635: }
1636:
1.484.2.72.2. (raeburn 1637:): my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%notindom,%duplicate,
1.484.2.41 raeburn 1638: %prefixchg,%srcdom,%srcnum,%marktomove,$save_err,$lockerrors,$allresult);
1.484.2.7 raeburn 1639:
1.484.2.30 raeburn 1640: foreach my $suffix (@topaste) {
1641: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1.484.2.72.2. (raeburn 1642:): my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.484.2.30 raeburn 1643: # Supplemental content may only include certain types of content
1644: # Early out if pasted content is not supported in Supplemental area
1645: if ($folder =~ /^supplemental/) {
1646: unless (&supp_pasteable($url)) {
1647: $notinsupp{$suffix} = 1;
1648: next;
1649: }
1650: }
1651: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/}) {
1652: my $srcd = $1;
1653: my $srcn = $2;
1.484.2.7 raeburn 1654: # When paste buffer was populated using an active role in a different course
1.484.2.30 raeburn 1655: # check for mdc privilege in the course from which the resource was pasted
1656: if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1657: unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1658: $notincrs{$suffix} = 1;
1659: next;
1660: }
1.329 droeschl 1661: }
1.484.2.30 raeburn 1662: $srcdom{$suffix} = $srcd;
1663: $srcnum{$suffix} = $srcn;
1.484.2.72.2. (raeburn 1664:): } elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$}) {
1665:): my ($srcd,$srcn) = split(/_/,$cid);
1666:): # When paste buffer was populated using an active role in a different course
1667:): # check for mdc privilege in the course from which the resource was pasted
1668:): if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1669:): unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1670:): $notincrs{$suffix} = 1;
1671:): next;
1672:): }
1673:): }
1674:): # When buffer was populated using an active role in a different course
1675:): # disallow pasting of External Tool if course is in a different domain.
1676:): if ($srcd ne $coursedom) {
1677:): $notindom{$suffix} = 1;
1678:): next;
1679:): }
1680:): $srcdom{$suffix} = $srcd;
1681:): $srcnum{$suffix} = $srcn;
1.484.2.30 raeburn 1682: }
1683: push(@dopaste,$suffix);
1684: if ($url=~/\.(page|sequence)$/) {
1685: $is_map{$suffix} = 1;
1.329 droeschl 1686: }
1.484.2.30 raeburn 1687:
1688: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/([^/]+)}) {
1689: my $oldprefix = $1;
1.484.2.19 raeburn 1690: # When pasting content from Main Content to Supplemental Content and vice versa
1.484.2.7 raeburn 1691: # URLs will contain different paths (which depend on whether pasted item is
1.484.2.72.2. (raeburn 1692:): # a folder/page or a document).
1.484.2.30 raeburn 1693: if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) {
1694: $prefixchg{$suffix} = 'docstosupp';
1695: } elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) {
1696: $prefixchg{$suffix} = 'supptodocs';
1697: }
1.484.2.7 raeburn 1698:
1699: # If pasting an uploaded map, get list of contained uploaded maps.
1.484.2.30 raeburn 1700: if ($env{'docs.markedcopy_nested_'.$suffix}) {
1701: my @nested;
1702: my ($type) = ($oldprefix =~ /^(default|supplemental)/);
1703: my @items = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1704: my @deps = map { /\d+:([\d,]+$)/ } @items;
1705: foreach my $dep (@deps) {
1706: if ($dep =~ /,/) {
1707: push(@nested,split(/,/,$dep));
1708: } else {
1709: push(@nested,$dep);
1710: }
1.484.2.7 raeburn 1711: }
1.484.2.30 raeburn 1712: foreach my $item (@nested) {
1713: if ($env{'form.docs.markedcopy_'.$suffix.'_'.$item} eq 'move') {
1714: push(@{$marktomove{$suffix}},$type.'_'.$item);
1715: }
1.484.2.7 raeburn 1716: }
1717: }
1.329 droeschl 1718: }
1.484.2.7 raeburn 1719: }
1720:
1.484.2.30 raeburn 1721: # Early out if nothing available to paste
1722: if (@dopaste == 0) {
1723: return ();
1724: }
1725:
1726: # Populate message hash and hashes used for main content <=> supplemental content
1727: # changes
1728:
1729: %msgs = &Apache::lonlocal::texthash (
1730: notinsupp => 'Paste failed: content type is not supported within Supplemental Content',
1731: notincrs => 'Paste failed: Item is from a different course which you do not have rights to edit.',
1.484.2.72.2. (raeburn 1732:): notindom => 'Paste failed: Item is an external tool from a course in a different domain.',
1.484.2.30 raeburn 1733: duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.',
1734: );
1735:
1736: %before = (
1737: docstosupp => {
1738: map => 'default',
1739: doc => 'docs',
1740: },
1741: supptodocs => {
1742: map => 'supplemental',
1743: doc => 'supplemental',
1744: },
1745: );
1746:
1747: %after = (
1748: docstosupp => {
1749: map => 'supplemental',
1750: doc => 'supplemental'
1751: },
1752: supptodocs => {
1753: map => 'default',
1754: doc => 'docs',
1755: },
1756: );
1757:
1758: # Retrieve information about all course maps in main content area
1759:
1760: my $allmaps = {};
1761: if ($folder =~ /^default/) {
1762: $allmaps =
1763: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
1764: $env{"course.$env{'request.course.id'}.home"},
1765: $env{'request.course.id'});
1766: }
1767:
1768: my (@toclear,%mapurls,%lockerrs,%msgerrs,%results);
1769:
1770: # Loop over the items to paste
1771: foreach my $suffix (@dopaste) {
1.484.2.7 raeburn 1772: # Maps need to be copied first
1.484.2.30 raeburn 1773: my (%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies,
1774: %dbcopies,%zombies,%params,%docmoves,%mapmoves,%mapchanges,%newsubdir,
1775: %newurls,%tomove);
1776: if (ref($marktomove{$suffix}) eq 'ARRAY') {
1777: map { $tomove{$_} = 1; } @{$marktomove{$suffix}};
1778: }
1779: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1780: my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.484.2.72.2. (raeburn 1781:): my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.484.2.30 raeburn 1782: my $oldurl = $url;
1783: if ($is_map{$suffix}) {
1.484.2.7 raeburn 1784: # If pasting a map, check if map contains other maps
1.484.2.30 raeburn 1785: my (%hierarchy,%titles);
1.484.2.72.2. (raeburn 1786:): &contained_map_check($url,$folder,$coursenum,$coursedom,
1787:): \%removefrommap,\%removeparam,\%addedmaps,
1788:): \%hierarchy,\%titles,$allmaps);
1.484.2.30 raeburn 1789: if ($url=~ m{^/uploaded/}) {
1790: my $newurl;
1791: unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
1792: ($newurl,my $error) =
1793: &get_newmap_url($url,$folder,$prefixchg{$suffix},$coursedom,
1794: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1795: \$title,$allmaps,\%newurls);
1796: if ($error) {
1797: $allerrors{$suffix} = $error;
1798: next;
1799: }
1800: if ($newurl ne '') {
1801: if ($newurl ne $url) {
1802: if ($newurl =~ /(?:default|supplemental)_(\d+).(?:sequence|page)$/) {
1803: $newsubdir{$url} = $1;
1804: }
1805: $mapchanges{$url} = 1;
1.484.2.7 raeburn 1806: }
1807: }
1808: }
1.484.2.30 raeburn 1809: if (($srcdom{$suffix} ne $coursedom) ||
1810: ($srcnum{$suffix} ne $coursenum) ||
1811: ($prefixchg{$suffix}) || (($newurl ne '') && ($newurl ne $url))) {
1812: unless (&url_paste_fixups($url,$folder,$prefixchg{$suffix},
1813: $coursedom,$coursenum,$srcdom{$suffix},
1814: $srcnum{$suffix},$allmaps,\%rewrites,
1815: \%retitles,\%copies,\%dbcopies,
1816: \%zombies,\%params,\%mapmoves,
1817: \%mapchanges,\%tomove,\%newsubdir,
1818: \%newurls)) {
1819: $mapmoves{$url} = 1;
1820: }
1821: $url = $newurl;
1822: } elsif ($env{'docs.markedcopy_nested_'.$suffix}) {
1823: &url_paste_fixups($url,$folder,$prefixchg{$suffix},$coursedom,
1824: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1825: $allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies,
1826: \%zombies,\%params,\%mapmoves,\%mapchanges,
1827: \%tomove,\%newsubdir,\%newurls);
1828: }
1829: } elsif ($url=~m {^/res/}) {
1.484.2.72.2. (raeburn 1830:): # published map can only exist once, so remove from paste buffer when done
1.484.2.30 raeburn 1831: push(@toclear,$suffix);
1832: # if pasting published map (main content area only) check map not already in course
1833: if ($folder =~ /^default/) {
1834: if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) {
1835: $duplicate{$suffix} = 1;
1836: next;
1837: }
1.484.2.7 raeburn 1838: }
1839: }
1840: }
1.484.2.72.2. (raeburn 1841:): if ($url=~ m{/(ext\.tool)$}) {
1.484.2.30 raeburn 1842: my $prefix = $1;
1.484.2.72.2. (raeburn 1843:): my $fromothercrs;
1.484.2.30 raeburn 1844: #need to copy the db contents to a new one, unless this is a move.
1845: my %info = (
1846: src => $url,
1847: cdom => $coursedom,
1848: cnum => $coursenum,
1849: );
1.484.2.72.2. (raeburn 1850:): if (($srcdom{$suffix} =~ /^$match_domain$/) && ($srcnum{$suffix} =~ /^$match_courseid$/)) {
1851:): unless (($srcdom{$suffix} eq $coursedom) && ($srcnum{$suffix} eq $coursenum)) {
1852:): $fromothercrs = 1;
1853:): $info{'cdom'} = $srcdom{$suffix};
1854:): $info{'cnum'} = $srcnum{$suffix};
1855:): }
1856:): }
1857:): unless (($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') && (!$fromothercrs)) {
1.484.2.30 raeburn 1858: my (%lockerr,$msg);
1859: my ($newurl,$result,$errtext) =
1860: &dbcopy(\%info,$coursedom,$coursenum,\%lockerr);
1861: if ($result eq 'ok') {
1862: $url = $newurl;
1863: $title=&mt('Copy of').' '.$title;
1864: } else {
1.484.2.72.2. (raeburn 1865:): if ($prefix eq 'ext.tool') {
1866:): $msg = &mt('Paste failed: An error occurred when copying the external tool.').' '.$errtext;
1.484.2.30 raeburn 1867: }
1868: $results{$suffix} = $result;
1869: $msgerrs{$suffix} = $msg;
1870: $lockerrs{$suffix} = $lockerr{$prefix};
1871: next;
1872: }
1873: if ($lockerr{$prefix}) {
1874: $lockerrs{$suffix} = $lockerr{$prefix};
1.484.2.26 raeburn 1875: }
1.484.2.7 raeburn 1876: }
1.484.2.30 raeburn 1877: }
1878: $title = &LONCAPA::map::qtunescape($title);
1879: my $ext='false';
1880: if ($url=~m{^http(|s)://}) { $ext='true'; }
1881: if ($env{'docs.markedcopy_supplemental_'.$suffix}) {
1882: if ($folder !~ /^supplemental/) {
1883: (undef,undef,$title) =
1884: &Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental_'.$suffix});
1885: }
1886: } else {
1887: if ($folder=~/^supplemental/) {
1888: $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
1889: $env{'user.domain'}.'___&&&___'.$title;
1.484.2.26 raeburn 1890: }
1891: }
1.484.2.7 raeburn 1892:
1893: # For uploaded files (excluding pages/sequences) path in copied file is changed
1894: # if paste is from Main to Supplemental (or vice versa), or if pasting between
1895: # courses.
1896:
1.484.2.30 raeburn 1897: unless ($is_map{$suffix}) {
1898: my $newidx;
1.329 droeschl 1899: # Now insert the URL at the bottom
1.484.2.30 raeburn 1900: $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
1901: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(.+)$}) {
1902: my $relpath = $1;
1903: if ($relpath ne '') {
1904: my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$});
1905: my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/);
1906: my $newprefix = $newloc;
1907: if ($newloc eq 'default') {
1908: $newprefix = 'docs';
1909: }
1910: if ($newdocsdir eq '') {
1911: $newdocsdir = 'default';
1912: }
1913: if (($prefixchg{$suffix}) ||
1914: ($srcdom{$suffix} ne $coursedom) ||
1915: ($srcnum{$suffix} ne $coursenum) ||
1916: ($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) {
1917: my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";
1918: $url =
1919: &Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath,
1920: &Apache::lonnet::getfile($oldurl));
1921: if ($url eq '/adm/notfound.html') {
1922: $msgs{$suffix} = &mt('Paste failed: an error occurred saving the file.');
1923: next;
1924: } else {
1925: my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$});
1926: $newsubpath =~ s{/+$}{/};
1927: $docmoves{$oldurl} = $newsubpath;
1928: }
1.484.2.7 raeburn 1929: }
1930: }
1931: }
1.484.2.30 raeburn 1932: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
1933: ':'.$ext.':normal:res';
1934: push(@LONCAPA::map::order,$newidx);
1935: # Store the result
1936: my ($errtext,$fatal) =
1937: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1938: if ($fatal) {
1939: $save_err .= $errtext;
1940: $allresult = 'fail';
1.484.2.7 raeburn 1941: }
1.329 droeschl 1942: }
1.484.2.30 raeburn 1943:
1944: # Apply any changes to maps, or copy dependencies for uploaded HTML pages
1945: unless ($allresult eq 'fail') {
1946: my %updated = (
1947: rewrites => \%rewrites,
1948: zombies => \%zombies,
1949: removefrommap => \%removefrommap,
1950: removeparam => \%removeparam,
1951: dbcopies => \%dbcopies,
1952: retitles => \%retitles,
1953: );
1954: my %info = (
1955: newsubdir => \%newsubdir,
1956: params => \%params,
1957: );
1958: if ($prefixchg{$suffix}) {
1959: $info{'before'} = $before{$prefixchg{$suffix}};
1960: $info{'after'} = $after{$prefixchg{$suffix}};
1961: }
1962: my %moves = (
1963: copies => \%copies,
1964: docmoves => \%docmoves,
1965: mapmoves => \%mapmoves,
1966: );
1967: (my $result,$msgs{$suffix},my $lockerror) =
1968: &apply_fixups($folder,$is_map{$suffix},$coursedom,$coursenum,$errors,
1969: \%updated,\%info,\%moves,$prefixchg{$suffix},$oldurl,
1970: $url,'paste');
1971: $lockerrors .= $lockerror;
1972: if ($result eq 'ok') {
1973: if ($is_map{$suffix}) {
1974: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1975: $folder.'.'.$container);
1976: if ($fatal) {
1977: $allresult = 'failread';
1978: } else {
1979: if ($#LONCAPA::map::order<1) {
1980: my $idx=&LONCAPA::map::getresidx();
1981: if ($idx<=0) { $idx=1; }
1982: $LONCAPA::map::order[0]=$idx;
1983: $LONCAPA::map::resources[$idx]='';
1984: }
1985: my $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
1986: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
1987: ':'.$ext.':normal:res';
1988: push(@LONCAPA::map::order,$newidx);
1.484.2.7 raeburn 1989:
1990: # Store the result
1.484.2.30 raeburn 1991: my ($errtext,$fatal) =
1992: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1993: if ($fatal) {
1994: $save_err .= $errtext;
1995: $allresult = 'failstore';
1996: }
1997: }
1998: }
1999: if ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
2000: push(@toclear,$suffix);
2001: }
2002: }
1.329 droeschl 2003: }
2004: }
1.484.2.30 raeburn 2005: &clear_from_buffer(\@toclear,\@currpaste);
2006: my $msgsarray;
2007: foreach my $suffix (keys(%msgs)) {
2008: if (ref($msgs{$suffix}) eq 'ARRAY') {
2009: $msgsarray .= join(',',@{$msgs{$suffix}});
2010: }
2011: }
2012: return ($allresult,$save_err,$msgsarray,$lockerrors);
2013: }
2014:
2015: sub do_buffer_empty {
2016: my @currpaste = split(/,/,$env{'docs.markedcopies'});
2017: if (@currpaste == 0) {
2018: return &mt('Clipboard is already empty');
2019: }
2020: my @toclear = &Apache::loncommon::get_env_multiple('form.pasting');
2021: if (@toclear == 0) {
2022: return &mt('Nothing selected to clear from clipboard');
2023: }
2024: my $numdel = &clear_from_buffer(\@toclear,\@currpaste);
2025: if ($numdel) {
2026: return &mt('[quant,_1,item] cleared from clipboard',$numdel);
2027: } else {
2028: return &mt('Clipboard unchanged');
1.484.2.7 raeburn 2029: }
1.484.2.30 raeburn 2030: return;
2031: }
2032:
2033: sub clear_from_buffer {
2034: my ($toclear,$currpaste) = @_;
2035: return unless ((ref($toclear) eq 'ARRAY') && (ref($currpaste) eq 'ARRAY'));
2036: my %pastebuffer;
2037: map { $pastebuffer{$_} = 1; } @{$currpaste};
2038: my $numdel = 0;
2039: foreach my $suffix (@{$toclear}) {
2040: next if ($suffix =~ /\D/);
2041: next unless (exists($pastebuffer{$suffix}));
2042: my $regexp = 'docs.markedcopy_[a-z]+_'.$suffix;
2043: if (&Apache::lonnet::delenv($regexp,1) eq 'ok') {
2044: delete($pastebuffer{$suffix});
2045: $numdel ++;
2046: }
2047: }
2048: my $newbuffer = join(',',sort(keys(%pastebuffer)));
2049: &Apache::lonnet::appenv({'docs.markedcopies' => $newbuffer});
2050: return $numdel;
1.484.2.7 raeburn 2051: }
2052:
2053: sub get_newmap_url {
2054: my ($url,$folder,$prefixchg,$coursedom,$coursenum,$srcdom,$srcnum,
2055: $titleref,$allmaps,$newurls) = @_;
2056: my $newurl;
2057: if ($url=~ m{^/uploaded/}) {
2058: $$titleref=&mt('Copy of').' '.$$titleref;
2059: }
2060: my $now = time;
2061: my $suffix=$$.int(rand(100)).$now;
2062: my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
2063: if ($oldid =~ m{^(/uploaded/$match_domain/$match_courseid/)(\D+)(\d+)$}) {
2064: my $path = $1;
2065: my $prefix = $2;
2066: my $ancestor = $3;
2067: if (length($ancestor) > 10) {
2068: $ancestor = substr($ancestor,-10,10);
2069: }
2070: my $newid;
2071: if ($prefixchg) {
2072: if ($folder =~ /^supplemental/) {
2073: $prefix =~ s/^default/supplemental/;
2074: } else {
2075: $prefix =~ s/^supplemental/default/;
2076: }
2077: }
2078: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
2079: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
2080: } else {
2081: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$now.'.'.$ext;
2082: }
2083: my $counter = 0;
2084: my $is_unique = &uniqueness_check($newurl);
2085: if ($folder =~ /^default/) {
2086: if ($allmaps->{$newurl}) {
2087: $is_unique = 0;
2088: }
2089: }
2090: while ((!$is_unique || $allmaps->{$newurl} || $newurls->{$newurl}) && ($counter < 100)) {
2091: $counter ++;
2092: $suffix ++;
2093: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
2094: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
2095: } else {
2096: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$ancestor.$suffix.'.'.$ext;
2097: }
2098: $is_unique = &uniqueness_check($newurl);
2099: }
2100: if ($is_unique) {
2101: $newurls->{$newurl} = 1;
2102: } else {
2103: if ($url=~/\.page$/) {
2104: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the composite page'));
2105: } else {
2106: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the folder'));
2107: }
2108: }
2109: }
2110: return ($newurl);
2111: }
2112:
2113: sub dbcopy {
1.484.2.26 raeburn 2114: my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_;
2115: my ($url,$result,$errtext);
2116: if (ref($dbref) eq 'HASH') {
1.484.2.71 raeburn 2117: $url = $dbref->{'src'};
1.484.2.72.2. (raeburn 2118:): if ($url =~ m{/(smppg|bulletinboard|ext\.tool)$}) {
1.484.2.26 raeburn 2119: my $prefix = $1;
1.484.2.72.2. (raeburn 2120:): if ($prefix eq 'ext.tool') {
2121:): $prefix = 'exttool';
2122:): }
1.484.2.26 raeburn 2123: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2124: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2125: my $db_name;
2126: my $marker = (split(m{/},$url))[4];
2127: $marker=~s/\D//g;
2128: if ($dbref->{'src'} =~ m{/smppg$}) {
2129: $db_name =
2130: &Apache::lonsimplepage::get_db_name($url,$marker,
2131: $dbref->{'cdom'},
2132: $dbref->{'cnum'});
1.484.2.72.2. (raeburn 2133:): } elsif ($dbref->{'src'} =~ m{/ext\.tool$}) {
2134:): $db_name = 'exttool_'.$marker;
1.484.2.26 raeburn 2135: } else {
2136: $db_name = 'bulletinpage_'.$marker;
2137: }
2138: my ($suffix,$freedlock,$error) =
2139: &Apache::lonnet::get_timebased_id($prefix,'num','templated',
2140: $coursedom,$coursenum,
2141: 'concat');
2142: if (!$suffix) {
2143: if ($prefix eq 'smppg') {
2144: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);
1.484.2.72.2. (raeburn 2145:): } elsif ($prefix eq 'exttool') {
2146:): $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying an external tool [_1].',$url);
1.484.2.26 raeburn 2147: } else {
1.484.2.42 raeburn 2148: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url);
1.484.2.26 raeburn 2149: }
2150: if ($error) {
2151: $errtext .= '<br />'.$error;
2152: }
2153: } else {
2154: #need to copy the db contents to a new one.
2155: my %contents=&Apache::lonnet::dump($db_name,
2156: $dbref->{'cdom'},
2157: $dbref->{'cnum'});
2158: if (exists($contents{'uploaded.photourl'})) {
2159: my $photo = $contents{'uploaded.photourl'};
2160: my ($subdir,$fname) =
2161: ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});
2162: my $newphoto;
2163: if ($fname ne '') {
2164: my $content = &Apache::lonnet::getfile($photo);
2165: unless ($content eq '-1') {
2166: $env{'form.'.$suffix.'.photourl'} = $content;
2167: $newphoto =
2168: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");
2169: delete($env{'form.'.$suffix.'.photourl'});
2170: }
2171: }
2172: if ($newphoto =~ m{^/uploaded/}) {
2173: $contents{'uploaded.photourl'} = $newphoto;
2174: }
2175: }
2176: $db_name =~ s{_\d*$ }{_$suffix}x;
2177: $result=&Apache::lonnet::put($db_name,\%contents,
2178: $coursedom,$coursenum);
2179: if ($result eq 'ok') {
1.484.2.72.2. (raeburn 2180:): $url =~ s{/(\d*)/(smppg|bulletinboard|ext\.tool)$}{/$suffix/$2}x;
1.484.2.26 raeburn 2181: }
2182: }
2183: if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) {
2184: $lockerrorsref->{$prefix} =
2185: '<div class="LC_error">'.
2186: &mt('There was a problem removing a lockfile.');
2187: if ($prefix eq 'smppg') {
2188: $lockerrorsref->{$prefix} .=
1.484.2.38 raeburn 2189: ' '.&mt('This will prevent creation of additional simple pages in this course.');
1.484.2.72.2. (raeburn 2190:): } elsif ($prefix eq 'exttool') {
2191:): $lockerrorsref->{$prefix} .=
2192:): ' '.&mt('This will prevent addition of more external tools to this course.');
1.484.2.26 raeburn 2193: } else {
1.484.2.42 raeburn 2194: $lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional discussion boards in this course.');
1.484.2.26 raeburn 2195: }
1.484.2.38 raeburn 2196: $lockerrorsref->{$prefix} .= ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
2197: '<a href="/adm/helpdesk" target="_helpdesk">','</a>').
2198: '</div>';
1.484.2.26 raeburn 2199: }
2200: }
2201: } elsif ($url =~ m{/syllabus$}) {
2202: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2203: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2204: if (($dbref->{'cdom'} ne $coursedom) ||
2205: ($dbref->{'cnum'} ne $coursenum)) {
2206: my %contents=&Apache::lonnet::dump('syllabus',
2207: $dbref->{'cdom'},
2208: $dbref->{'cnum'});
2209: $result=&Apache::lonnet::put('syllabus',\%contents,
2210: $coursedom,$coursenum);
2211: }
2212: }
1.484.2.7 raeburn 2213: }
2214: }
1.484.2.26 raeburn 2215: return ($url,$result,$errtext);
1.329 droeschl 2216: }
2217:
2218: sub uniqueness_check {
2219: my ($newurl) = @_;
2220: my $unique = 1;
2221: foreach my $res (@LONCAPA::map::order) {
2222: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2223: $url=&LONCAPA::map::qtescape($url);
2224: if ($newurl eq $url) {
2225: $unique = 0;
1.344 bisitz 2226: last;
1.329 droeschl 2227: }
2228: }
2229: return $unique;
2230: }
2231:
1.484.2.7 raeburn 2232: sub contained_map_check {
1.484.2.72.2. (raeburn 2233:): my ($url,$folder,$coursenum,$coursedom,$removefrommap,$removeparam,$addedmaps,
2234:): $hierarchy,$titles,$allmaps) = @_;
1.484.2.7 raeburn 2235: my $content = &Apache::lonnet::getfile($url);
2236: unless ($content eq '-1') {
2237: my $parser = HTML::TokeParser->new(\$content);
2238: $parser->attr_encoded(1);
2239: while (my $token = $parser->get_token) {
2240: next if ($token->[0] ne 'S');
2241: if ($token->[1] eq 'resource') {
2242: next if ($token->[2]->{'type'} eq 'zombie');
2243: my $ressrc = $token->[2]->{'src'};
2244: if ($folder =~ /^supplemental/) {
2245: unless (&supp_pasteable($ressrc)) {
2246: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2247: next;
2248: }
2249: }
2250: if ($ressrc =~ m{^/(res|uploaded)/.+\.(sequence|page)$}) {
2251: if ($1 eq 'uploaded') {
2252: $hierarchy->{$url}{$token->[2]->{'id'}} = $ressrc;
2253: $titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'};
2254: } else {
2255: if ($allmaps->{$ressrc}) {
1.484.2.23 raeburn 2256: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.484.2.7 raeburn 2257: } elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') {
2258: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2259: } else {
2260: $addedmaps->{$ressrc} = [$url];
2261: }
2262: }
1.484.2.72.2. (raeburn 2263:): &contained_map_check($ressrc,$folder,$coursenum,$coursedom,
2264:): $removefrommap,$removeparam,
1.484.2.7 raeburn 2265: $addedmaps,$hierarchy,$titles,$allmaps);
2266: }
2267: } elsif ($token->[1] eq 'param') {
2268: if ($folder =~ /^supplemental/) {
2269: if (ref($removeparam->{$url}{$token->[2]->{'to'}}) eq 'ARRAY') {
2270: push(@{$removeparam->{$url}{$token->[2]->{'to'}}},$token->[2]->{'name'});
2271: } else {
1.484.2.19 raeburn 2272: $removeparam->{$url}{$token->[2]->{'to'}} = [$token->[2]->{'name'}];
1.484.2.7 raeburn 2273: }
2274: }
2275: }
2276: }
2277: }
2278: return;
2279: }
2280:
2281: sub url_paste_fixups {
1.484.2.26 raeburn 2282: my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$fromcdom,$fromcnum,$allmaps,
2283: $rewrites,$retitles,$copies,$dbcopies,$zombies,$params,$mapmoves,
2284: $mapchanges,$tomove,$newsubdir,$newurls) = @_;
1.484.2.7 raeburn 2285: my $checktitle;
2286: if (($prefixchg) &&
2287: ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) {
2288: $checktitle = 1;
2289: }
2290: my $skip;
2291: if ($oldurl =~ m{^\Q/uploaded/$cdom/$cnum/\E(default|supplemental)(_?\d*)\.(?:page|sequence)$}) {
2292: my $mapid = $1.$2;
2293: if ($tomove->{$mapid}) {
2294: $skip = 1;
2295: }
2296: }
2297: my $file = &Apache::lonnet::getfile($oldurl);
2298: return if ($file eq '-1');
2299: my $parser = HTML::TokeParser->new(\$file);
2300: $parser->attr_encoded(1);
2301: my $changed = 0;
2302: while (my $token = $parser->get_token) {
2303: next if ($token->[0] ne 'S');
2304: if ($token->[1] eq 'resource') {
2305: my $ressrc = $token->[2]->{'src'};
2306: next if ($ressrc eq '');
2307: my $id = $token->[2]->{'id'};
2308: my $title = $token->[2]->{'title'};
2309: if ($checktitle) {
2310: if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1.484.2.25 raeburn 2311: $retitles->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2312: }
2313: }
2314: next if ($token->[2]->{'type'} eq 'external');
2315: if ($token->[2]->{'type'} eq 'zombie') {
1.484.2.30 raeburn 2316: next if ($skip);
1.484.2.25 raeburn 2317: $zombies->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2318: $changed = 1;
2319: } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
2320: my $srcdom = $1;
2321: my $srcnum = $2;
2322: my $rem = $3;
2323: my $newurl;
2324: my $mapname;
2325: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
2326: my $prefix = $1;
2327: $mapname = $prefix.$2;
2328: if ($tomove->{$mapname}) {
1.484.2.26 raeburn 2329: &url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,
2330: $srcdom,$srcnum,$allmaps,$rewrites,
2331: $retitles,$copies,$dbcopies,$zombies,
2332: $params,$mapmoves,$mapchanges,$tomove,
2333: $newsubdir,$newurls);
1.484.2.7 raeburn 2334: next;
2335: } else {
2336: ($newurl,my $error) =
2337: &get_newmap_url($ressrc,$folder,$prefixchg,$cdom,$cnum,
2338: $srcdom,$srcnum,\$title,$allmaps,$newurls);
2339: if ($newurl =~ /(?:default|supplemental)_(\d+)\.(?:sequence|page)$/) {
2340: $newsubdir->{$ressrc} = $1;
2341: }
2342: if ($error) {
2343: next;
2344: }
2345: }
2346: }
2347: if (($srcdom ne $cdom) || ($srcnum ne $cnum) || ($prefixchg) ||
2348: ($mapchanges->{$oldurl}) || (($newurl ne '') && ($newurl ne $oldurl))) {
1.484.2.19 raeburn 2349:
1.484.2.7 raeburn 2350: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
1.484.2.25 raeburn 2351: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2352: $mapchanges->{$ressrc} = 1;
1.484.2.26 raeburn 2353: unless (&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,
2354: $cnum,$srcdom,$srcnum,$allmaps,
2355: $rewrites,$retitles,$copies,$dbcopies,
2356: $zombies,$params,$mapmoves,$mapchanges,
2357: $tomove,$newsubdir,$newurls)) {
1.484.2.7 raeburn 2358: $mapmoves->{$ressrc} = 1;
2359: }
2360: $changed = 1;
2361: } else {
1.484.2.25 raeburn 2362: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2363: $copies->{$oldurl}{$ressrc} = $id;
2364: $changed = 1;
2365: }
2366: }
1.484.2.26 raeburn 2367: } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/.+$}) {
1.484.2.30 raeburn 2368: next if ($skip);
1.484.2.7 raeburn 2369: my $srcdom = $1;
2370: my $srcnum = $2;
2371: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.484.2.25 raeburn 2372: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.26 raeburn 2373: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2374: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2375: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
2376: $changed = 1;
2377: }
2378: } elsif ($ressrc =~ m{^/adm/$match_domain/$match_username/\d+/(smppg|bulletinboard)$}) {
2379: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum) ||
2380: ($env{'form.docs.markedcopy_options'} ne 'move')) {
2381: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2382: $dbcopies->{$oldurl}{$id}{'cdom'} = $fromcdom;
2383: $dbcopies->{$oldurl}{$id}{'cnum'} = $fromcnum;
1.484.2.7 raeburn 2384: $changed = 1;
2385: }
2386: } elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) {
2387: next if ($skip);
2388: my $srcdom = $1;
2389: my $srcnum = $2;
2390: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.484.2.26 raeburn 2391: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2392: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2393: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
1.484.2.7 raeburn 2394: $changed = 1;
2395: }
2396: }
2397: } elsif ($token->[1] eq 'param') {
2398: next if ($skip);
1.484.2.19 raeburn 2399: my $to = $token->[2]->{'to'};
1.484.2.7 raeburn 2400: if ($to ne '') {
2401: if (ref($params->{$oldurl}{$to}) eq 'ARRAY') {
2402: push(@{$params->{$oldurl}{$to}},$token->[2]->{'name'});
2403: } else {
2404: @{$params->{$oldurl}{$to}} = ($token->[2]->{'name'});
2405: }
2406: }
2407: }
2408: }
2409: return $changed;
2410: }
2411:
2412: sub apply_fixups {
1.484.2.23 raeburn 2413: my ($folder,$is_map,$cdom,$cnum,$errors,$updated,$info,$moves,$prefixchg,
2414: $oldurl,$url,$caller) = @_;
2415: my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles,
1.484.2.26 raeburn 2416: %params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs,
2417: %lockerrors,$lockmsg);
1.484.2.23 raeburn 2418: if (ref($updated) eq 'HASH') {
2419: if (ref($updated->{'rewrites'}) eq 'HASH') {
2420: %rewrites = %{$updated->{'rewrites'}};
2421: }
2422: if (ref($updated->{'zombies'}) eq 'HASH') {
2423: %zombies = %{$updated->{'zombies'}};
2424: }
2425: if (ref($updated->{'removefrommap'}) eq 'HASH') {
2426: %removefrommap = %{$updated->{'removefrommap'}};
2427: }
2428: if (ref($updated->{'removeparam'}) eq 'HASH') {
2429: %removeparam = %{$updated->{'removeparam'}};
2430: }
2431: if (ref($updated->{'dbcopies'}) eq 'HASH') {
2432: %dbcopies = %{$updated->{'dbcopies'}};
2433: }
2434: if (ref($updated->{'retitles'}) eq 'HASH') {
2435: %retitles = %{$updated->{'retitles'}};
2436: }
2437: }
2438: if (ref($info) eq 'HASH') {
2439: if (ref($info->{'newsubdir'}) eq 'HASH') {
2440: %newsubdir = %{$info->{'newsubdir'}};
2441: }
2442: if (ref($info->{'params'}) eq 'HASH') {
2443: %params = %{$info->{'params'}};
2444: }
2445: if (ref($info->{'before'}) eq 'HASH') {
2446: %before = %{$info->{'before'}};
2447: }
2448: if (ref($info->{'after'}) eq 'HASH') {
2449: %after = %{$info->{'after'}};
2450: }
2451: }
2452: if (ref($moves) eq 'HASH') {
2453: if (ref($moves->{'copies'}) eq 'HASH') {
2454: %copies = %{$moves->{'copies'}};
2455: }
2456: if (ref($moves->{'docmoves'}) eq 'HASH') {
2457: %docmoves = %{$moves->{'docmoves'}};
2458: }
2459: if (ref($moves->{'mapmoves'}) eq 'HASH') {
2460: %mapmoves = %{$moves->{'mapmoves'}};
2461: }
2462: }
2463: foreach my $key (keys(%copies),keys(%docmoves)) {
1.484.2.7 raeburn 2464: my @allcopies;
1.484.2.23 raeburn 2465: if (exists($copies{$key})) {
2466: if (ref($copies{$key}) eq 'HASH') {
2467: my %added;
2468: foreach my $innerkey (keys(%{$copies{$key}})) {
2469: if (($innerkey ne '') && (!$added{$innerkey})) {
2470: push(@allcopies,$innerkey);
2471: $added{$innerkey} = 1;
2472: }
1.484.2.7 raeburn 2473: }
1.484.2.23 raeburn 2474: undef(%added);
1.484.2.7 raeburn 2475: }
2476: }
2477: if ($key eq $oldurl) {
1.484.2.23 raeburn 2478: if ((exists($docmoves{$key}))) {
1.484.2.25 raeburn 2479: unless (grep(/^\Q$oldurl\E$/,@allcopies)) {
1.484.2.7 raeburn 2480: push(@allcopies,$oldurl);
2481: }
2482: }
2483: }
2484: if (@allcopies > 0) {
2485: foreach my $item (@allcopies) {
1.484.2.19 raeburn 2486: my ($relpath,$oldsubdir,$fname) =
1.484.2.7 raeburn 2487: ($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(default|\d+)/.*/)([^/]+)$});
2488: if ($fname ne '') {
2489: my $content = &Apache::lonnet::getfile($item);
2490: unless ($content eq '-1') {
2491: my $storefn;
1.484.2.23 raeburn 2492: if (($key eq $oldurl) && (exists($docmoves{$key}))) {
2493: $storefn = $docmoves{$key};
1.484.2.7 raeburn 2494: } else {
2495: $storefn = $relpath;
2496: $storefn =~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 2497: if ($prefixchg && $before{'doc'} && $after{'doc'}) {
2498: $storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/;
1.484.2.7 raeburn 2499: }
1.484.2.23 raeburn 2500: if ($newsubdir{$key}) {
1.484.2.25 raeburn 2501: $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}/#;
1.484.2.7 raeburn 2502: }
2503: }
2504: ©_dependencies($item,$storefn,$relpath,$errors,\$content);
1.484.2.19 raeburn 2505: my $copyurl =
1.484.2.7 raeburn 2506: &Apache::lonclonecourse::writefile($env{'request.course.id'},
2507: $storefn.$fname,$content);
2508: if ($copyurl eq '/adm/notfound.html') {
1.484.2.23 raeburn 2509: if (exists($docmoves{$oldurl})) {
1.484.2.7 raeburn 2510: return &mt('Paste failed: an error occurred copying the file.');
2511: } elsif (ref($errors) eq 'HASH') {
2512: $errors->{$item} = 1;
2513: }
2514: }
2515: }
2516: }
2517: }
2518: }
2519: }
1.484.2.23 raeburn 2520: foreach my $key (keys(%mapmoves)) {
1.484.2.7 raeburn 2521: my $storefn=$key;
2522: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 2523: if ($prefixchg && $before{'map'} && $after{'map'}) {
2524: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.484.2.7 raeburn 2525: }
1.484.2.23 raeburn 2526: if ($newsubdir{$key}) {
2527: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.484.2.7 raeburn 2528: }
2529: my $mapcontent = &Apache::lonnet::getfile($key);
2530: if ($mapcontent eq '-1') {
2531: if (ref($errors) eq 'HASH') {
2532: $errors->{$key} = 1;
2533: }
2534: } else {
2535: my $newmap =
2536: &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
2537: $mapcontent);
2538: if ($newmap eq '/adm/notfound.html') {
2539: if (ref($errors) eq 'HASH') {
2540: $errors->{$key} = 1;
2541: }
2542: }
2543: }
2544: }
2545: my %updates;
2546: if ($is_map) {
1.484.2.23 raeburn 2547: if (ref($updated) eq 'HASH') {
2548: foreach my $type (keys(%{$updated})) {
2549: if (ref($updated->{$type}) eq 'HASH') {
2550: foreach my $key (keys(%{$updated->{$type}})) {
2551: $updates{$key} = 1;
2552: }
2553: }
2554: }
1.484.2.7 raeburn 2555: }
2556: foreach my $key (keys(%updates)) {
2557: my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb);
1.484.2.23 raeburn 2558: if (ref($rewrites{$key}) eq 'HASH') {
2559: %torewrite = %{$rewrites{$key}};
1.484.2.7 raeburn 2560: }
1.484.2.23 raeburn 2561: if (ref($retitles{$key}) eq 'HASH') {
2562: %toretitle = %{$retitles{$key}};
1.484.2.7 raeburn 2563: }
1.484.2.23 raeburn 2564: if (ref($removefrommap{$key}) eq 'HASH') {
2565: %toremove = %{$removefrommap{$key}};
1.484.2.7 raeburn 2566: }
1.484.2.23 raeburn 2567: if (ref($removeparam{$key}) eq 'HASH') {
2568: %remparam = %{$removeparam{$key}};
1.484.2.7 raeburn 2569: }
1.484.2.23 raeburn 2570: if (ref($zombies{$key}) eq 'HASH') {
2571: %zombie = %{$zombies{$key}};
1.484.2.7 raeburn 2572: }
1.484.2.23 raeburn 2573: if (ref($dbcopies{$key}) eq 'HASH') {
1.484.2.26 raeburn 2574: foreach my $idx (keys(%{$dbcopies{$key}})) {
2575: if (ref($dbcopies{$key}{$idx}) eq 'HASH') {
2576: my ($newurl,$result,$errtext) =
2577: &dbcopy($dbcopies{$key}{$idx},$cdom,$cnum,\%lockerrors);
2578: if ($result eq 'ok') {
2579: $newdb{$idx} = $newurl;
2580: } elsif (ref($errors) eq 'HASH') {
2581: $errors->{$key} = 1;
2582: }
2583: push(@msgs,$errtext);
2584: }
1.484.2.7 raeburn 2585: }
2586: }
1.484.2.23 raeburn 2587: if (ref($params{$key}) eq 'HASH') {
2588: %currparam = %{$params{$key}};
1.484.2.7 raeburn 2589: }
2590: my ($errtext,$fatal) = &LONCAPA::map::mapread($key);
2591: if ($fatal) {
1.484.2.26 raeburn 2592: return ($errtext);
1.484.2.7 raeburn 2593: }
2594: for (my $i=0; $i<@LONCAPA::map::zombies; $i++) {
2595: if (defined($LONCAPA::map::zombies[$i])) {
2596: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::zombies[$i]);
1.484.2.25 raeburn 2597: if ($zombie{$i} eq $src) {
1.484.2.7 raeburn 2598: undef($LONCAPA::map::zombies[$i]);
2599: }
2600: }
2601: }
1.484.2.72.2. (raeburn 2602:): my $total = scalar(@LONCAPA::map::order) - 1;
2603:): for (my $i=$total; $i>=0; $i--) {
1.484.2.23 raeburn 2604: my $idx = $LONCAPA::map::order[$i];
2605: if (defined($LONCAPA::map::resources[$idx])) {
1.484.2.7 raeburn 2606: my $changed;
1.484.2.23 raeburn 2607: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]);
1.484.2.30 raeburn 2608: if ((exists($toremove{$idx})) &&
2609: ($toremove{$idx} eq &LONCAPA::map::qtescape($src))) {
1.484.2.7 raeburn 2610: splice(@LONCAPA::map::order,$i,1);
1.484.2.23 raeburn 2611: if (ref($currparam{$idx}) eq 'ARRAY') {
2612: foreach my $name (@{$currparam{$idx}}) {
1.484.2.72.2. (raeburn 2613:): &LONCAPA::map::delparameter($idx,$name);
1.484.2.7 raeburn 2614: }
2615: }
2616: next;
2617: }
2618: my $origsrc = $src;
1.484.2.25 raeburn 2619: if ((exists($toretitle{$idx})) && ($toretitle{$idx} eq $src)) {
1.484.2.7 raeburn 2620: if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
2621: $changed = 1;
2622: }
2623: }
1.484.2.25 raeburn 2624: if ((exists($torewrite{$idx})) && ($torewrite{$idx} eq $src)) {
1.484.2.7 raeburn 2625: $src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
2626: if ($origsrc =~ m{^/uploaded/}) {
1.484.2.23 raeburn 2627: if ($prefixchg && $before{'map'} && $after{'map'}) {
1.484.2.7 raeburn 2628: if ($src =~ /\.(page|sequence)$/) {
1.484.2.23 raeburn 2629: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'map'}\E#$1$after{'map'}#;
1.484.2.7 raeburn 2630: } else {
1.484.2.23 raeburn 2631: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
1.484.2.7 raeburn 2632: }
2633: }
1.484.2.25 raeburn 2634: if ($origsrc =~ /\.(page|sequence)$/) {
2635: if ($newsubdir{$origsrc}) {
1.484.2.23 raeburn 2636: $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir{$origsrc}#;
1.484.2.7 raeburn 2637: }
1.484.2.25 raeburn 2638: } elsif ($newsubdir{$key}) {
2639: $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$key}#;
1.484.2.7 raeburn 2640: }
2641: }
2642: $changed = 1;
1.484.2.26 raeburn 2643: } elsif ($newdb{$idx} ne '') {
2644: $src = $newdb{$idx};
1.484.2.7 raeburn 2645: $changed = 1;
2646: }
2647: if ($changed) {
1.484.2.30 raeburn 2648: $LONCAPA::map::resources[$idx] = join(':',($title,&LONCAPA::map::qtunescape($src),$ext,$type));
1.484.2.7 raeburn 2649: }
2650: }
2651: }
2652: foreach my $idx (keys(%remparam)) {
2653: if (ref($remparam{$idx}) eq 'ARRAY') {
1.484.2.19 raeburn 2654: foreach my $name (@{$remparam{$idx}}) {
1.484.2.72.2. (raeburn 2655:): &LONCAPA::map::delparameter($idx,$name);
1.484.2.7 raeburn 2656: }
2657: }
2658: }
1.484.2.26 raeburn 2659: if (values(%lockerrors) > 0) {
2660: $lockmsg = join('<br />',values(%lockerrors));
2661: }
1.484.2.7 raeburn 2662: my $storefn;
2663: if ($key eq $oldurl) {
2664: $storefn = $url;
2665: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
2666: } else {
2667: $storefn = $key;
2668: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 2669: if ($prefixchg && $before{'map'} && $after{'map'}) {
2670: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.484.2.7 raeburn 2671: }
1.484.2.23 raeburn 2672: if ($newsubdir{$key}) {
2673: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.484.2.7 raeburn 2674: }
2675: }
2676: my $report;
2677: if ($folder !~ /^supplemental/) {
2678: $report = 1;
2679: }
1.484.2.20 raeburn 2680: (my $outtext,$errtext) =
1.484.2.7 raeburn 2681: &LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report);
2682: if ($errtext) {
1.484.2.23 raeburn 2683: if ($caller eq 'paste') {
1.484.2.26 raeburn 2684: return (&mt('Paste failed: an error occurred saving the folder or page.'));
1.484.2.23 raeburn 2685: }
1.484.2.7 raeburn 2686: }
2687: }
2688: }
1.484.2.26 raeburn 2689: return ('ok',\@msgs,$lockmsg);
1.484.2.7 raeburn 2690: }
2691:
2692: sub copy_dependencies {
2693: my ($item,$storefn,$relpath,$errors,$contentref) = @_;
2694: my $content;
2695: if (ref($contentref)) {
2696: $content = $$contentref;
2697: } else {
2698: $content = &Apache::lonnet::getfile($item);
2699: }
2700: unless ($content eq '-1') {
2701: my $mm = new File::MMagic;
2702: my $mimetype = $mm->checktype_contents($content);
2703: if ($mimetype eq 'text/html') {
2704: my (%allfiles,%codebase,$state);
2705: my $res = &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,\$content);
2706: if ($res eq 'ok') {
2707: my ($numexisting,$numpathchanges,$existing);
2708: (undef,$numexisting,$numpathchanges,$existing) =
2709: &Apache::loncommon::ask_for_embedded_content(
2710: '/adm/coursedocs',$state,\%allfiles,\%codebase,
2711: {'error_on_invalid_names' => 1,
2712: 'ignore_remote_references' => 1,
2713: 'docs_url' => $item,
2714: 'context' => 'paste'});
2715: if ($numexisting > 0) {
2716: if (ref($existing) eq 'HASH') {
2717: foreach my $dep (keys(%{$existing})) {
2718: my $depfile = $dep;
2719: unless ($depfile =~ m{^\Q$relpath\E}) {
2720: $depfile = $relpath.$dep;
2721: }
2722: my $depcontent = &Apache::lonnet::getfile($depfile);
2723: unless ($depcontent eq '-1') {
2724: my $storedep = $dep;
2725: $storedep =~ s{^\Q$relpath\E}{};
2726: my $dep_url =
2727: &Apache::lonclonecourse::writefile(
2728: $env{'request.course.id'},
2729: $storefn.$storedep,$depcontent);
2730: if ($dep_url eq '/adm/notfound.html') {
2731: if (ref($errors) eq 'HASH') {
2732: $errors->{$depfile} = 1;
2733: }
2734: } else {
2735: ©_dependencies($depfile,$storefn,$relpath,$errors,\$depcontent);
2736: }
2737: }
2738: }
2739: }
2740: }
2741: }
2742: }
2743: }
2744: return;
2745: }
2746:
1.329 droeschl 2747: my %parameter_type = ( 'randompick' => 'int_pos',
2748: 'hiddenresource' => 'string_yesno',
2749: 'encrypturl' => 'string_yesno',
2750: 'randomorder' => 'string_yesno',);
2751: my $valid_parameters_re = join('|',keys(%parameter_type));
2752: # set parameters
2753: sub update_parameter {
1.484.2.29 raeburn 2754: if ($env{'form.changeparms'} eq 'all') {
2755: my (@allidx,@allmapidx,%allchecked,%currchecked);
2756: %allchecked = (
2757: 'hiddenresource' => {},
2758: 'encrypturl' => {},
2759: 'randompick' => {},
2760: 'randomorder' => {},
2761: );
2762: foreach my $which (keys(%allchecked)) {
2763: $env{'form.all'.$which} =~ s/,$//;
2764: if ($which eq 'randompick') {
2765: foreach my $item (split(/,/,$env{'form.all'.$which})) {
2766: my ($res,$value) = split(/:/,$item);
2767: if ($value =~ /^\d+$/) {
2768: $allchecked{$which}{$res} = $value;
2769: }
2770: }
2771: } else {
1.484.2.30 raeburn 2772: if ($env{'form.all'.$which}) {
2773: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.all'.$which});
2774: }
1.484.2.29 raeburn 2775: }
2776: }
2777: my $haschanges = 0;
2778: foreach my $res (@LONCAPA::map::order) {
2779: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2780: $name=&LONCAPA::map::qtescape($name);
2781: $url=&LONCAPA::map::qtescape($url);
2782: next unless ($name && $url);
2783: my $is_map;
2784: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
2785: $is_map = 1;
2786: }
2787: foreach my $which (keys(%allchecked)) {
2788: if (($which eq 'randompick' || $which eq 'randomorder')) {
2789: next if (!$is_map);
2790: }
2791: my $oldvalue = 0;
2792: my $newvalue = 0;
2793: if ($allchecked{$which}{$res}) {
2794: $newvalue = $allchecked{$which}{$res};
2795: }
2796: my $current = (&LONCAPA::map::getparameter($res,'parameter_'.$which))[0];
2797: if ($which eq 'randompick') {
2798: if ($current =~ /^(\d+)$/) {
2799: $oldvalue = $1;
2800: }
2801: } else {
2802: if ($current =~ /^yes$/i) {
2803: $oldvalue = 1;
2804: }
2805: }
2806: if ($oldvalue ne $newvalue) {
2807: $haschanges = 1;
2808: if ($newvalue) {
2809: my $storeval = 'yes';
2810: if ($which eq 'randompick') {
2811: $storeval = $newvalue;
2812: }
2813: &LONCAPA::map::storeparameter($res,'parameter_'.$which,
2814: $storeval,
2815: $parameter_type{$which});
2816: &remember_parms($res,$which,'set',$storeval);
2817: } elsif ($oldvalue) {
2818: &LONCAPA::map::delparameter($res,'parameter_'.$which);
2819: &remember_parms($res,$which,'del');
2820: }
2821: }
2822: }
2823: }
2824: return $haschanges;
1.329 droeschl 2825: } else {
1.484.2.59 raeburn 2826: my $haschanges = 0;
2827: return $haschanges if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
1.364 bisitz 2828:
1.484.2.29 raeburn 2829: my $which = $env{'form.changeparms'};
2830: my $idx = $env{'form.setparms'};
1.484.2.59 raeburn 2831: my $oldvalue = 0;
2832: my $newvalue = 0;
2833: my $current = (&LONCAPA::map::getparameter($idx,'parameter_'.$which))[0];
2834: if ($which eq 'randompick') {
2835: if ($current =~ /^(\d+)$/) {
2836: $oldvalue = $1;
2837: }
2838: } elsif ($current =~ /^yes$/i) {
2839: $oldvalue = 1;
2840: }
1.484.2.29 raeburn 2841: if ($env{'form.'.$which.'_'.$idx}) {
1.484.2.59 raeburn 2842: $newvalue = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx}
2843: : 1;
1.484.2.29 raeburn 2844: }
1.484.2.59 raeburn 2845: if ($oldvalue ne $newvalue) {
2846: $haschanges = 1;
2847: if ($newvalue) {
2848: my $storeval = 'yes';
2849: if ($which eq 'randompick') {
2850: $storeval = $newvalue;
2851: }
2852: &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $storeval,
2853: $parameter_type{$which});
2854: &remember_parms($idx,$which,'set',$storeval);
2855: } else {
2856: &LONCAPA::map::delparameter($idx,'parameter_'.$which);
2857: &remember_parms($idx,$which,'del');
2858: }
2859: }
2860: return $haschanges;
1.329 droeschl 2861: }
1.484.2.59 raeburn 2862: return;
1.329 droeschl 2863: }
2864:
2865: sub handle_edit_cmd {
2866: my ($coursenum,$coursedom) =@_;
1.484.2.30 raeburn 2867: if ($env{'form.cmd'} eq '') {
2868: return 0;
2869: }
1.329 droeschl 2870: my ($cmd,$idx)=split('_',$env{'form.cmd'});
2871:
2872: my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
2873: my ($title, $url, @rrest) = split(':', $ratstr);
2874:
1.484.2.30 raeburn 2875: if ($cmd eq 'remove') {
1.329 droeschl 2876: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
1.463 www 2877: ($url!~/$LONCAPA::assess_page_seq_re/)) {
1.329 droeschl 2878: &Apache::lonnet::removeuploadedurl($url);
2879: } else {
2880: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
2881: }
2882: splice(@LONCAPA::map::order, $idx, 1);
2883:
2884: } elsif ($cmd eq 'cut') {
2885: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
2886: splice(@LONCAPA::map::order, $idx, 1);
2887:
1.344 bisitz 2888: } elsif ($cmd eq 'up'
1.329 droeschl 2889: && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
2890: @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
2891:
2892: } elsif ($cmd eq 'down'
2893: && defined($LONCAPA::map::order[$idx+1])) {
2894: @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
2895:
2896: } elsif ($cmd eq 'rename') {
2897: my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
2898: if ($comment=~/\S/) {
2899: $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
2900: $comment.':'.join(':', $url, @rrest);
2901: }
2902: # Devalidate title cache
2903: my $renamed_url=&LONCAPA::map::qtescape($url);
2904: &Apache::lonnet::devalidate_title_cache($renamed_url);
1.484.2.30 raeburn 2905:
1.329 droeschl 2906: } else {
2907: return 0;
2908: }
2909: return 1;
2910: }
2911:
2912: sub editor {
1.458 raeburn 2913: my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
1.484.2.72.2. (raeburn 2914:): $supplementalflag,$orderhash,$iconpath,$pathitem,$ltitoolsref,
2915:): $canedit,$navmapref,$hiddentop)=@_;
1.484.2.19 raeburn 2916: my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
2917: if ($allowed) {
2918: (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
2919: $is_random_order,$container) =
2920: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
2921: $r->print($breadcrumbtrail);
2922: } elsif ($env{'form.folderpath'} =~ /\:1$/) {
2923: $container = 'page';
2924: } else {
2925: $container = 'sequence';
2926: }
1.484 raeburn 2927:
1.484.2.21 raeburn 2928: my $jumpto;
2929:
2930: unless ($supplementalflag) {
1.484.2.32 raeburn 2931: $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
1.484.2.21 raeburn 2932: }
1.484 raeburn 2933:
2934: unless ($allowed) {
2935: $randompick = -1;
2936: }
2937:
1.484.2.67 raeburn 2938: my ($errtext,$fatal);
2939: if (($folder eq '') && (!$supplementalflag)) {
2940: if (@LONCAPA::map::order) {
2941: undef(@LONCAPA::map::order);
2942: undef(@LONCAPA::map::resources);
2943: undef(@LONCAPA::map::resparms);
2944: undef(@LONCAPA::map::zombies);
2945: }
2946: $folder = 'default';
2947: $container = 'sequence';
2948: } else {
2949: ($errtext,$fatal) = &mapread($coursenum,$coursedom,
2950: $folder.'.'.$container);
2951: return $errtext if ($fatal);
2952: }
1.329 droeschl 2953:
2954: if ($#LONCAPA::map::order<1) {
2955: my $idx=&LONCAPA::map::getresidx();
2956: if ($idx<=0) { $idx=1; }
2957: $LONCAPA::map::order[0]=$idx;
2958: $LONCAPA::map::resources[$idx]='';
2959: }
1.364 bisitz 2960:
1.329 droeschl 2961: # ------------------------------------------------------------ Process commands
2962:
2963: # ---------------- if they are for this folder and user allowed to make changes
1.484.2.67 raeburn 2964: if (($allowed && $canedit) && ($env{'form.folder'} eq $folder)) {
1.329 droeschl 2965: # set parameters and change order
2966: &snapshotbefore();
2967:
2968: if (&update_parameter()) {
1.484.2.59 raeburn 2969: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1.329 droeschl 2970: return $errtext if ($fatal);
2971: }
2972:
2973: if ($env{'form.newpos'} && $env{'form.currentpos'}) {
2974: # change order
2975: my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
2976: splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
2977:
2978: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
2979: return $errtext if ($fatal);
2980: }
1.364 bisitz 2981:
1.329 droeschl 2982: if ($env{'form.pastemarked'}) {
1.484.2.7 raeburn 2983: my %paste_errors;
1.484.2.26 raeburn 2984: my ($paste_res,$save_error,$pastemsgarray,$lockerror) =
1.484.2.7 raeburn 2985: &do_paste_from_buffer($coursenum,$coursedom,$folder,$container,
2986: \%paste_errors);
1.484.2.30 raeburn 2987: if (ref($pastemsgarray) eq 'ARRAY') {
2988: if (@{$pastemsgarray} > 0) {
2989: $r->print('<p class="LC_info">'.
2990: join('<br />',@{$pastemsgarray}).
1.484.2.26 raeburn 2991: '</p>');
2992: }
1.484.2.30 raeburn 2993: }
2994: if ($lockerror) {
2995: $r->print('<p class="LC_error">'.
2996: $lockerror.
2997: '</p>');
2998: }
2999: if ($save_error ne '') {
3000: return $save_error;
3001: }
3002: if ($paste_res) {
3003: my %errortext = &Apache::lonlocal::texthash (
3004: fail => 'Storage of folder contents failed',
3005: failread => 'Reading folder contents failed',
3006: failstore => 'Storage of folder contents failed',
3007: );
3008: if ($errortext{$paste_res}) {
3009: $r->print('<p class="LC_error">'.$errortext{$paste_res}.'</p>');
1.484.2.7 raeburn 3010: }
1.329 droeschl 3011: }
1.484.2.7 raeburn 3012: if (keys(%paste_errors) > 0) {
1.484.2.30 raeburn 3013: $r->print('<p class="LC_warning">'."\n".
1.484.2.7 raeburn 3014: &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".
3015: '<ul>'."\n");
3016: foreach my $key (sort(keys(%paste_errors))) {
3017: $r->print('<li>'.$key.'</li>'."\n");
3018: }
3019: $r->print('</ul></p>'."\n");
3020: }
1.484.2.30 raeburn 3021: } elsif ($env{'form.clearmarked'}) {
3022: my $output = &do_buffer_empty();
3023: if ($output) {
3024: $r->print('<p class="LC_info">'.$output.'</p>');
3025: }
3026: }
1.329 droeschl 3027:
3028: $r->print($upload_output);
3029:
1.484.2.30 raeburn 3030: # Rename, cut, copy or remove a single resource
1.484.2.63 raeburn 3031: if (&handle_edit_cmd($coursenum,$coursedom)) {
1.484.2.7 raeburn 3032: my $contentchg;
1.484.2.58 raeburn 3033: if ($env{'form.cmd'} =~ m{^(remove|cut)_}) {
1.484.2.7 raeburn 3034: $contentchg = 1;
3035: }
3036: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);
1.329 droeschl 3037: return $errtext if ($fatal);
3038: }
1.484.2.30 raeburn 3039:
3040: # Cut, copy and/or remove multiple resources
3041: if ($env{'form.multichange'}) {
3042: my %allchecked = (
3043: cut => {},
3044: remove => {},
3045: );
3046: my $needsupdate;
3047: foreach my $which (keys(%allchecked)) {
3048: $env{'form.multi'.$which} =~ s/,$//;
3049: if ($env{'form.multi'.$which}) {
3050: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.multi'.$which});
3051: if (ref($allchecked{$which}) eq 'HASH') {
3052: $needsupdate += scalar(keys(%{$allchecked{$which}}));
3053: }
3054: }
3055: }
3056: if ($needsupdate) {
3057: my $haschanges = 0;
3058: my %curr_groups = &Apache::longroup::coursegroups();
3059: my $total = scalar(@LONCAPA::map::order) - 1;
3060: for (my $i=$total; $i>=0; $i--) {
3061: my $res = $LONCAPA::map::order[$i];
3062: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3063: $name=&LONCAPA::map::qtescape($name);
3064: $url=&LONCAPA::map::qtescape($url);
1.484.2.57 raeburn 3065: next unless $url;
1.484.2.30 raeburn 3066: my %denied =
3067: &action_restrictions($coursenum,$coursedom,$url,
3068: $env{'form.folderpath'},\%curr_groups);
3069: foreach my $which (keys(%allchecked)) {
3070: next if ($denied{$which});
3071: next unless ($allchecked{$which}{$res});
3072: if ($which eq 'remove') {
3073: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
3074: ($url!~/$LONCAPA::assess_page_seq_re/)) {
3075: &Apache::lonnet::removeuploadedurl($url);
3076: } else {
3077: &LONCAPA::map::makezombie($res);
3078: }
3079: splice(@LONCAPA::map::order,$i,1);
3080: $haschanges ++;
3081: } elsif ($which eq 'cut') {
3082: &LONCAPA::map::makezombie($res);
3083: splice(@LONCAPA::map::order,$i,1);
3084: $haschanges ++;
3085: }
3086: }
3087: }
3088: if ($haschanges) {
3089: ($errtext,$fatal) =
3090: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
3091: return $errtext if ($fatal);
3092: }
3093: }
3094: }
3095:
1.329 droeschl 3096: # Group import/search
3097: if ($env{'form.importdetail'}) {
3098: my @imports;
3099: foreach my $item (split(/\&/,$env{'form.importdetail'})) {
3100: if (defined($item)) {
3101: my ($name,$url,$residx)=
1.484.2.26 raeburn 3102: map { &unescape($_); } split(/\=/,$item);
3103: if ($url =~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
1.484.2.30 raeburn 3104: my ($suffix,$errortxt,$locknotfreed) =
1.484.2.26 raeburn 3105: &new_timebased_suffix($coursedom,$coursenum,'map',$1,$2);
1.484.2.15 raeburn 3106: if ($locknotfreed) {
3107: $r->print($locknotfreed);
3108: }
3109: if ($suffix) {
1.484.2.19 raeburn 3110: $url =~ s/_new\./_$suffix./;
1.484.2.15 raeburn 3111: } else {
3112: return $errortxt;
3113: }
1.484.2.26 raeburn 3114: } elsif ($url =~ m{^/adm/$match_domain/$match_username/new/(smppg|bulletinboard)$}) {
3115: my $type = $1;
3116: my ($suffix,$errortxt,$locknotfreed) =
3117: &new_timebased_suffix($coursedom,$coursenum,$type);
3118: if ($locknotfreed) {
3119: $r->print($locknotfreed);
3120: }
3121: if ($suffix) {
3122: $url =~ s{^(/adm/$match_domain/$match_username)/new}{$1/$suffix};
3123: } else {
3124: return $errortxt;
3125: }
1.484.2.72.2. (raeburn 3126:): } elsif ($url =~ m{^/adm/$coursedom/$coursenum/new/ext\.tool}) {
3127:): my ($suffix,$errortxt,$locknotfreed) =
3128:): &new_timebased_suffix($coursedom,$coursenum,'exttool');
3129:): if ($locknotfreed) {
3130:): $r->print($locknotfreed);
3131:): }
3132:): if ($suffix) {
3133:): $url =~ s{^(/adm/$coursedom/$coursenum)/new}{$1/$suffix};
3134:): } else {
3135:): return $errortxt;
3136:): }
1.484.2.27 raeburn 3137: } elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) {
3138: if ($supplementalflag) {
3139: next unless ($1 eq 'supplemental');
3140: if ($folder eq 'supplemental') {
3141: next unless ($2 eq 'default');
3142: } else {
3143: next unless ($folder eq 'supplemental_'.$2);
3144: }
3145: } else {
3146: next unless ($1 eq 'docs');
3147: if ($folder eq 'default') {
3148: next unless ($2 eq 'default');
3149: } else {
3150: next unless ($folder eq 'default_'.$2);
3151: }
3152: }
1.484.2.15 raeburn 3153: }
1.329 droeschl 3154: push(@imports, [$name, $url, $residx]);
3155: }
3156: }
1.484.2.23 raeburn 3157: ($errtext,$fatal,my $fixuperrors) =
3158: &group_import($coursenum, $coursedom, $folder,$container,
1.484.2.72.2. (raeburn 3159:): 'londocs',$ltitoolsref,@imports);
1.329 droeschl 3160: return $errtext if ($fatal);
1.484.2.23 raeburn 3161: if ($fixuperrors) {
3162: $r->print($fixuperrors);
3163: }
1.329 droeschl 3164: }
3165: # Loading a complete map
3166: if ($env{'form.loadmap'}) {
3167: if ($env{'form.importmap'}=~/\w/) {
3168: foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
3169: my ($title,$url,$ext,$type)=split(/\:/,$res);
3170: my $idx=&LONCAPA::map::getresidx($url);
3171: $LONCAPA::map::resources[$idx]=$res;
3172: $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
3173: }
3174: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.484.2.7 raeburn 3175: $folder.'.'.$container,1);
1.329 droeschl 3176: return $errtext if ($fatal);
3177: } else {
3178: $r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
1.364 bisitz 3179:
1.329 droeschl 3180: }
3181: }
3182: &log_differences($plain);
3183: }
3184: # ---------------------------------------------------------------- End commands
3185: # ---------------------------------------------------------------- Print screen
3186: my $idx=0;
3187: my $shown=0;
3188: if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
1.381 bisitz 3189: $r->print('<div class="LC_Box">'.
1.432 raeburn 3190: '<ol class="LC_docs_parameters"><li class="LC_docs_parameters_title">'.&mt('Parameters:').'</li>'.
3191: ($randompick>=0?'<li>'.&mt('randomly pick [quant,_1,resource]',$randompick).'</li>':'').
3192: ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
3193: ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
3194: ($is_random_order?'<li>'.&mt('random order').'</li>':'').
1.431 raeburn 3195: '</ol>');
1.381 bisitz 3196: if ($randompick>=0) {
3197: $r->print('<p class="LC_warning">'
3198: .&mt('Caution: this folder is set to randomly pick a subset'
3199: .' of resources. Adding or removing resources from this'
3200: .' folder will change the set of resources that the'
3201: .' students see, resulting in spurious or missing credit'
3202: .' for completed problems, not limited to ones you'
3203: .' modify. Do not modify the contents of this folder if'
3204: .' it is in active student use.')
3205: .'</p>'
3206: );
3207: }
3208: if ($is_random_order) {
3209: $r->print('<p class="LC_warning">'
3210: .&mt('Caution: this folder is set to randomly order its'
3211: .' contents. Adding or removing resources from this folder'
3212: .' will change the order of resources shown.')
3213: .'</p>'
3214: );
3215: }
3216: $r->print('</div>');
1.364 bisitz 3217: }
1.381 bisitz 3218:
1.484.2.30 raeburn 3219: my ($to_show,$output,@allidx,@allmapidx,%filters,%lists,%curr_groups);
3220: %filters = (
3221: canremove => [],
3222: cancut => [],
3223: cancopy => [],
3224: hiddenresource => [],
3225: encrypturl => [],
3226: randomorder => [],
3227: randompick => [],
3228: );
3229: %curr_groups = &Apache::longroup::coursegroups();
1.424 onken 3230: &Apache::loncommon::start_data_table_count(); #setup a row counter
1.381 bisitz 3231: foreach my $res (@LONCAPA::map::order) {
3232: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3233: $name=&LONCAPA::map::qtescape($name);
3234: $url=&LONCAPA::map::qtescape($url);
3235: unless ($name) { $name=(split(/\//,$url))[-1]; }
3236: unless ($name) { $idx++; next; }
1.484.2.29 raeburn 3237: push(@allidx,$res);
3238: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
3239: push(@allmapidx,$res);
3240: }
1.484.2.67 raeburn 3241:
1.381 bisitz 3242: $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
1.484.2.12 raeburn 3243: $coursenum,$coursedom,$crstype,
1.484.2.30 raeburn 3244: $pathitem,$supplementalflag,$container,
1.484.2.72.2. (raeburn 3245:): \%filters,\%curr_groups,$ltitoolsref,$canedit,
1.484.2.70 raeburn 3246: $isencrypted,$navmapref);
1.381 bisitz 3247: $idx++;
3248: $shown++;
1.329 droeschl 3249: }
1.424 onken 3250: &Apache::loncommon::end_data_table_count();
1.484.2.19 raeburn 3251:
1.484.2.30 raeburn 3252: my $need_save;
1.484.2.67 raeburn 3253: if ($allowed || ($supplementalflag && $folder eq 'supplemental')) {
1.484.2.31 raeburn 3254: my $toolslink;
1.484.2.67 raeburn 3255: if ($allowed) {
1.484.2.31 raeburn 3256: $toolslink = '<table><tr><td>'
1.484.2.19 raeburn 3257: .&Apache::loncommon::help_open_menu('Navigation Screen',
3258: 'Navigation_Screen',undef,'RAT')
3259: .'</td><td class="LC_middle">'.&mt('Tools:').'</td>'
3260: .'<td align="left"><ul id="LC_toolbar">'
1.484.2.21 raeburn 3261: .'<li><a href="/adm/coursedocs?forcesupplement=1&command=editsupp" '
1.484.2.19 raeburn 3262: .'id="LC_content_toolbar_edittoplevel" '
3263: .'class="LC_toolbarItem" '
3264: .'title="'.&mt('Supplemental Content Editor').'">'
3265: .'</a></li></ul></td></tr></table><br />';
1.484.2.31 raeburn 3266: }
1.484.2.19 raeburn 3267: if ($shown) {
3268: if ($allowed) {
3269: $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
3270: .&Apache::loncommon::start_data_table(undef,'contentlist')
3271: .&Apache::loncommon::start_data_table_header_row()
3272: .'<th colspan="2">'.&mt('Move').'</th>'
1.484.2.30 raeburn 3273: .'<th colspan="2">'.&mt('Actions').'</th>'
3274: .'<th>'.&mt('Document').'</th>';
1.484.2.19 raeburn 3275: if ($folder !~ /^supplemental/) {
3276: $to_show .= '<th colspan="4">'.&mt('Settings').'</th>';
3277: }
1.484.2.29 raeburn 3278: $to_show .= &Apache::loncommon::end_data_table_header_row();
3279: if ($folder !~ /^supplemental/) {
1.484.2.30 raeburn 3280: $lists{'canhide'} = join(',',@allidx);
3281: $lists{'canrandomlyorder'} = join(',',@allmapidx);
3282: my @possfilters = ('canremove','cancut','cancopy','hiddenresource','encrypturl',
3283: 'randomorder','randompick');
3284: foreach my $item (@possfilters) {
3285: if (ref($filters{$item}) eq 'ARRAY') {
3286: if (@{$filters{$item}} > 0) {
3287: $lists{$item} = join(',',@{$filters{$item}});
3288: }
3289: }
3290: }
1.484.2.29 raeburn 3291: if (@allidx > 0) {
3292: my $path;
3293: if ($env{'form.folderpath'}) {
3294: $path =
3295: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3296: }
1.484.2.30 raeburn 3297: if (@allidx > 1) {
3298: $to_show .=
3299: &Apache::loncommon::continue_data_table_row().
3300: '<td colspan="2"> </td>'.
3301: '<td>'.
1.484.2.67 raeburn 3302: &multiple_check_form('actions',\%lists,$canedit).
1.484.2.30 raeburn 3303: '</td>'.
3304: '<td> </td>'.
3305: '<td> </td>'.
3306: '<td colspan="4">'.
1.484.2.67 raeburn 3307: &multiple_check_form('settings',\%lists,$canedit).
1.484.2.30 raeburn 3308: '</td>'.
3309: &Apache::loncommon::end_data_table_row();
3310: $need_save = 1;
3311: }
1.484.2.29 raeburn 3312: }
3313: }
3314: $to_show .= $output.' '
1.484.2.19 raeburn 3315: .&Apache::loncommon::end_data_table()
3316: .'<br style="line-height:2px;" />'
3317: .&Apache::loncommon::end_scrollbox();
3318: } else {
3319: $to_show .= $toolslink
3320: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3321: .$output.' '
3322: .&Apache::loncommon::end_data_table();
3323: }
3324: } else {
3325: if (!$allowed) {
3326: $to_show .= $toolslink;
1.393 raeburn 3327: }
1.484.2.67 raeburn 3328: my $noresmsg;
3329: if ($allowed && $hiddentop && !$supplementalflag) {
3330: $noresmsg = &mt('Main Content Hidden');
3331: } else {
3332: $noresmsg = &mt('Currently empty');
3333: }
1.484.2.19 raeburn 3334: $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
3335: .'<div class="LC_info" id="contentlist">'
1.484.2.67 raeburn 3336: .$noresmsg
1.484.2.19 raeburn 3337: .'</div>'
3338: .&Apache::loncommon::end_scrollbox();
1.393 raeburn 3339: }
3340: } else {
1.484.2.19 raeburn 3341: if ($shown) {
3342: $to_show = '<div>'
3343: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3344: .$output
3345: .&Apache::loncommon::end_data_table()
3346: .'</div>';
3347: } else {
3348: $to_show = '<div class="LC_info" id="contentlist">'
1.484.2.34 raeburn 3349: .&mt('Currently empty')
1.484.2.19 raeburn 3350: .'</div>'
3351: }
1.458 raeburn 3352: }
3353: my $tid = 1;
3354: if ($supplementalflag) {
3355: $tid = 2;
1.329 droeschl 3356: }
3357: if ($allowed) {
1.484 raeburn 3358: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
1.484.2.30 raeburn 3359: $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,
1.484.2.67 raeburn 3360: $jumpto,$readfile,$need_save,"$folder.$container",$canedit));
1.484.2.68 raeburn 3361: if ($canedit) {
1.484.2.67 raeburn 3362: &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
3363: }
1.460 raeburn 3364: } else {
3365: $r->print($to_show);
1.329 droeschl 3366: }
3367: return;
3368: }
3369:
1.484.2.30 raeburn 3370: sub multiple_check_form {
1.484.2.67 raeburn 3371: my ($caller,$listsref,$canedit) = @_;
1.484.2.30 raeburn 3372: return unless (ref($listsref) eq 'HASH');
1.484.2.67 raeburn 3373: my $disabled;
3374: unless ($canedit) {
3375: $disabled = 'disabled="disabled"';
3376: }
1.484.2.30 raeburn 3377: my $output =
3378: '<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'.
3379: '<span class="LC_nobreak" style="font-size:x-small;font-weight:bold;">'.
3380: '<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>'.
3381: '<div id="multi'.$caller.'" style="display:none;margin:0;padding:0;border:0">'.
3382: '<form action="/adm/coursedocs" method="post" name="cumulative'.$caller.'">'."\n".
3383: '<fieldset id="allfields'.$caller.'" style="display:none"><legend style="font-size:x-small;">'.&mt('check/uncheck all').'</legend>'."\n";
3384: if ($caller eq 'settings') {
3385: $output .=
3386: '<table><tr>'.
3387: '<td class="LC_docs_entry_parameter">'.
3388: '<span class="LC_nobreak"><label>'.
1.484.2.67 raeburn 3389: '<input type="checkbox" name="hiddenresourceall" id="hiddenresourceall" onclick="propagateState(this.form,'."'hiddenresource'".')"'.$disabled.' />'.&mt('Hidden').
1.484.2.30 raeburn 3390: '</label></span></td>'.
3391: '<td class="LC_docs_entry_parameter">'.
1.484.2.67 raeburn 3392: '<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 3393: '</span></td>'.
3394: '</tr>'."\n".
3395: '<tr>'.
3396: '<td class="LC_docs_entry_parameter">'.
1.484.2.67 raeburn 3397: '<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 3398: '</label></span>'.
3399: '</td></tr></table>'."\n";
3400: } else {
3401: $output .=
3402: '<table><tr>'.
3403: '<td class="LC_docs_entry_parameter">'.
3404: '<span class="LC_nobreak LC_docs_remove">'.
1.484.2.67 raeburn 3405: '<label><input type="checkbox" name="removeall" id="removeall" onclick="propagateState(this.form,'."'remove'".')"'.$disabled.' />'.&mt('Remove').
1.484.2.30 raeburn 3406: '</label></span></td>'.
3407: '<td class="LC_docs_entry_parameter">'.
3408: '<span class="LC_nobreak LC_docs_cut">'.
1.484.2.67 raeburn 3409: '<label><input type="checkbox" name="cut" id="cutall" onclick="propagateState(this.form,'."'cut'".');"'.$disabled.' />'.&mt('Cut').
1.484.2.30 raeburn 3410: '</label></span></td>'."\n".
3411: '<td class="LC_docs_entry_parameter">'.
3412: '<span class="LC_nobreak LC_docs_copy">'.
1.484.2.67 raeburn 3413: '<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')"'.$disabled.' />'.&mt('Copy').
1.484.2.30 raeburn 3414: '</label></span></td>'.
3415: '</tr></table>'."\n";
3416: }
3417: $output .=
3418: '</fieldset>'.
3419: '<input type="hidden" name="allidx" value="'.$listsref->{'canhide'}.'" />';
3420: if ($caller eq 'settings') {
3421: $output .=
3422: '<input type="hidden" name="allmapidx" value="'.$listsref->{'canrandomlyorder'}.'" />'."\n".
3423: '<input type="hidden" name="currhiddenresource" value="'.$listsref->{'hiddenresource'}.'" />'."\n".
3424: '<input type="hidden" name="currencrypturl" value="'.$listsref->{'encrypturl'}.'" />'."\n".
3425: '<input type="hidden" name="currrandomorder" value="'.$listsref->{'randomorder'}.'" />'."\n".
3426: '<input type="hidden" name="currrandompick" value="'.$listsref->{'randompick'}.'" />'."\n";
3427: } elsif ($caller eq 'actions') {
3428: $output .=
3429: '<input type="hidden" name="allremoveidx" id="allremoveidx" value="'.$listsref->{'canremove'}.'" />'.
3430: '<input type="hidden" name="allcutidx" id="allcutidx" value="'.$listsref->{'cancut'}.'" />'.
3431: '<input type="hidden" name="allcopyidx" id="allcopyidx" value="'.$listsref->{'cancopy'}.'" />';
3432: }
3433: $output .=
3434: '</form>'.
3435: '</div>';
3436: return $output;
3437: }
3438:
1.329 droeschl 3439: sub process_file_upload {
1.484.2.36 raeburn 3440: my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd,$crstype) = @_;
1.329 droeschl 3441: # upload a file, if present
1.484.2.36 raeburn 3442: my $filesize = length($env{'form.uploaddoc'});
3443: if (!$filesize) {
3444: $$upload_output = '<div class="LC_error">'.
3445: &mt('Unable to upload [_1]. (size = [_2] bytes)',
3446: '<span class="LC_filename">'.$env{'form.uploaddoc.filename'}.'</span>',
3447: $filesize).'<br />'.
3448: &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'<br />'.
3449: '</div>';
3450: return;
3451: }
3452: my $quotatype = 'unofficial';
3453: if ($crstype eq 'Community') {
3454: $quotatype = 'community';
1.484.2.51 raeburn 3455: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
1.484.2.36 raeburn 3456: $quotatype = 'official';
1.484.2.45 raeburn 3457: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
3458: $quotatype = 'textbook';
1.484.2.36 raeburn 3459: }
3460: if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) {
3461: $filesize = int($filesize/1000); #expressed in kb
3462: $$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course',
1.484.2.51 raeburn 3463: $env{'form.uploaddoc.filename'},$filesize,
3464: 'upload',$quotatype);
1.484.2.36 raeburn 3465: return if ($$upload_output);
3466: }
1.440 raeburn 3467: my ($parseaction,$showupload,$nextphase,$mimetype);
3468: if ($env{'form.parserflag'}) {
1.329 droeschl 3469: $parseaction = 'parse';
3470: }
3471: my $folder=$env{'form.folder'};
3472: if ($folder eq '') {
3473: $folder='default';
3474: }
3475: if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
3476: my $errtext='';
3477: my $fatal=0;
3478: my $container='sequence';
1.484.2.19 raeburn 3479: if ($env{'form.folderpath'} =~ /:1$/) {
1.329 droeschl 3480: $container='page';
3481: }
3482: ($errtext,$fatal)=
1.484.2.27 raeburn 3483: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1.329 droeschl 3484: if ($#LONCAPA::map::order<1) {
3485: $LONCAPA::map::order[0]=1;
3486: $LONCAPA::map::resources[1]='';
3487: }
3488: my $destination = 'docs/';
3489: if ($folder =~ /^supplemental/) {
3490: $destination = 'supplemental/';
3491: }
3492: if (($folder eq 'default') || ($folder eq 'supplemental')) {
3493: $destination .= 'default/';
3494: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
3495: $destination .= $2.'/';
3496: }
1.484.2.27 raeburn 3497: if ($fatal) {
3498: $$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>';
3499: return;
3500: }
1.440 raeburn 3501: # this is for a course, not a user, so set context to coursedoc.
1.329 droeschl 3502: my $newidx=&LONCAPA::map::getresidx();
3503: $destination .= $newidx;
1.439 raeburn 3504: my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination,
1.329 droeschl 3505: $parseaction,$allfiles,
1.440 raeburn 3506: $codebase,undef,undef,undef,undef,
3507: undef,undef,\$mimetype);
3508: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) {
3509: my $stored = $1;
3510: $showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'.
3511: $stored.'</span>').'</p>';
3512: } else {
3513: my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});
3514:
1.457 raeburn 3515: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>';
1.440 raeburn 3516: return;
3517: }
1.329 droeschl 3518: my $ext='false';
3519: if ($url=~m{^http://}) { $ext='true'; }
3520: $url = &LONCAPA::map::qtunescape($url);
3521: my $comment=$env{'form.comment'};
3522: $comment = &LONCAPA::map::qtunescape($comment);
3523: if ($folder=~/^supplemental/) {
3524: $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
3525: $env{'user.domain'}.'___&&&___'.$comment;
3526: }
3527:
3528: $LONCAPA::map::resources[$newidx]=
3529: $comment.':'.$url.':'.$ext.':normal:res';
3530: $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
3531: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.484.2.7 raeburn 3532: $folder.'.'.$container,1);
1.329 droeschl 3533: if ($fatal) {
1.457 raeburn 3534: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>';
1.440 raeburn 3535: return;
1.329 droeschl 3536: } else {
1.440 raeburn 3537: if ($parseaction eq 'parse' && $mimetype eq 'text/html') {
3538: $$upload_output = $showupload;
1.384 raeburn 3539: my $total_embedded = scalar(keys(%{$allfiles}));
1.329 droeschl 3540: if ($total_embedded > 0) {
1.440 raeburn 3541: my $uploadphase = 'upload_embedded';
3542: my $primaryurl = &HTML::Entities::encode($url,'<>&"');
3543: my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx);
3544: my ($embedded,$num) =
3545: &Apache::loncommon::ask_for_embedded_content(
3546: '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url});
3547: if ($embedded) {
3548: if ($num) {
3549: $$upload_output .=
3550: '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
3551: $nextphase = $uploadphase;
3552: } else {
3553: $$upload_output .= $embedded;
3554: }
3555: } else {
3556: $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
3557: }
1.329 droeschl 3558: } else {
1.440 raeburn 3559: $$upload_output .= &mt('No embedded items identified').'<br />';
1.329 droeschl 3560: }
1.457 raeburn 3561: $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
1.484.2.51 raeburn 3562: } elsif ((&Apache::loncommon::is_archive_file($mimetype)) &&
3563: ($env{'form.uploaddoc.filename'} =~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i)) {
1.476 raeburn 3564: $nextphase = 'decompress_uploaded';
3565: my $position = scalar(@LONCAPA::map::order)-1;
3566: my $noextract = &return_to_editor();
3567: my $archiveurl = &HTML::Entities::encode($url,'<>&"');
3568: my %archiveitems = (
3569: folderpath => $env{'form.folderpath'},
3570: cmd => $nextphase,
3571: newidx => $newidx,
3572: position => $position,
3573: phase => $nextphase,
1.477 raeburn 3574: comment => $comment,
1.480 raeburn 3575: );
3576: my ($destination,$dir_root) = &embedded_destination($coursenum,$coursedom);
3577: my @current = &get_dir_list($url,$coursenum,$coursedom,$newidx);
1.476 raeburn 3578: $$upload_output = $showupload.
3579: &Apache::loncommon::decompress_form($mimetype,
3580: $archiveurl,'/adm/coursedocs',$noextract,
1.480 raeburn 3581: \%archiveitems,\@current);
1.329 droeschl 3582: }
3583: }
3584: }
1.440 raeburn 3585: return $nextphase;
1.329 droeschl 3586: }
3587:
1.480 raeburn 3588: sub get_dir_list {
3589: my ($url,$coursenum,$coursedom,$newidx) = @_;
3590: my ($destination,$dir_root) = &embedded_destination();
3591: my ($dirlistref,$listerror) =
3592: &Apache::lonnet::dirlist("$dir_root/$destination/$newidx",$coursedom,$coursenum,1);
3593: my @dir_lines;
3594: my $dirptr=16384;
3595: if (ref($dirlistref) eq 'ARRAY') {
3596: foreach my $dir_line (sort
3597: {
3598: my ($afile)=split('&',$a,2);
3599: my ($bfile)=split('&',$b,2);
3600: return (lc($afile) cmp lc($bfile));
3601: } (@{$dirlistref})) {
3602: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
3603: $filename =~ s/\s+$//;
3604: next if ($filename =~ /^\.\.?$/);
3605: my $isdir = 0;
3606: if ($dirptr&$testdir) {
3607: $isdir = 1;
3608: }
3609: push(@dir_lines, [$filename,$dom,$isdir,$size,$mtime,$obs]);
3610: }
3611: }
3612: return @dir_lines;
3613: }
3614:
1.329 droeschl 3615: sub is_supplemental_title {
3616: my ($title) = @_;
3617: return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
3618: }
3619:
3620: # --------------------------------------------------------------- An entry line
3621:
3622: sub entryline {
1.484.2.12 raeburn 3623: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
1.484.2.67 raeburn 3624: $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups,
1.484.2.72.2. (raeburn 3625:): $ltitoolsref,$canedit,$isencrypted,$navmapref)=@_;
1.484.2.52 raeburn 3626: my ($foldertitle,$renametitle,$oldtitle);
1.329 droeschl 3627: if (&is_supplemental_title($title)) {
1.484.2.7 raeburn 3628: ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
1.329 droeschl 3629: } else {
3630: $title=&HTML::Entities::encode($title,'"<>&\'');
3631: $renametitle=$title;
3632: $foldertitle=$title;
3633: }
3634:
1.484.2.67 raeburn 3635: my ($disabled,$readonly,$js_lt);
3636: unless ($canedit) {
3637: $disabled = 'disabled="disabled"';
3638: $readonly = 1;
3639: }
3640:
1.329 droeschl 3641: my $orderidx=$LONCAPA::map::order[$index];
1.364 bisitz 3642:
1.329 droeschl 3643: $renametitle=~s/\\/\\\\/g;
3644: $renametitle=~s/\"\;/\\\"/g;
1.484.2.55 raeburn 3645: $renametitle=~s/"/%22/g;
1.329 droeschl 3646: $renametitle=~s/ /%20/g;
1.484.2.52 raeburn 3647: $oldtitle = $renametitle;
3648: $renametitle=~s/\'\;/\\\'/g;
1.379 bisitz 3649: my $line=&Apache::loncommon::start_data_table_row();
1.484.2.30 raeburn 3650: my ($form_start,$form_end,$form_common,$form_param);
1.329 droeschl 3651: # Edit commands
1.484.2.28 raeburn 3652: my ($esc_path, $path, $symb);
1.329 droeschl 3653: if ($env{'form.folderpath'}) {
3654: $esc_path=&escape($env{'form.folderpath'});
3655: $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3656: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
3657: }
1.484.2.16 raeburn 3658: my $isexternal;
1.484.2.19 raeburn 3659: if ($residx) {
1.484.2.12 raeburn 3660: my $currurl = $url;
3661: $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.484.2.16 raeburn 3662: if ($currurl =~ m{^/adm/wrapper/ext/}) {
3663: $isexternal = 1;
3664: }
1.484.2.19 raeburn 3665: if (!$supplementalflag) {
3666: my $path = 'uploaded/'.
3667: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
3668: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
3669: $symb = &Apache::lonnet::encode_symb($path.$folder.".$container",
3670: $residx,
3671: &Apache::lonnet::declutter($currurl));
3672: }
1.484.2.12 raeburn 3673: }
1.484.2.30 raeburn 3674: my ($renamelink,%lt,$ishash);
3675: if (ref($filtersref) eq 'HASH') {
3676: $ishash = 1;
3677: }
3678:
1.329 droeschl 3679: if ($allowed) {
1.484.2.30 raeburn 3680: $form_start = '
3681: <form action="/adm/coursedocs" method="post">
3682: ';
3683: $form_common=(<<END);
3684: <input type="hidden" name="folderpath" value="$path" />
3685: <input type="hidden" name="symb" value="$symb" />
3686: END
3687: $form_param=(<<END);
3688: <input type="hidden" name="setparms" value="$orderidx" />
3689: <input type="hidden" name="changeparms" value="0" />
3690: END
3691: $form_end = '</form>';
3692:
1.329 droeschl 3693: my $incindex=$index+1;
3694: my $selectbox='';
1.471 raeburn 3695: if (($#LONCAPA::map::order>0) &&
1.329 droeschl 3696: ((split(/\:/,
1.344 bisitz 3697: $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
3698: ne '') &&
1.329 droeschl 3699: ((split(/\:/,
1.344 bisitz 3700: $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1.329 droeschl 3701: ne '')) {
3702: $selectbox=
3703: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.484.2.67 raeburn 3704: '<select name="newpos" onchange="this.form.submit()"'.$disabled.'>';
1.329 droeschl 3705: for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
3706: if ($i==$incindex) {
1.358 bisitz 3707: $selectbox.='<option value="" selected="selected">('.$i.')</option>';
1.329 droeschl 3708: } else {
3709: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
3710: }
3711: }
3712: $selectbox.='</select>';
3713: }
1.484.2.12 raeburn 3714: %lt=&Apache::lonlocal::texthash(
1.329 droeschl 3715: 'up' => 'Move Up',
3716: 'dw' => 'Move Down',
3717: 'rm' => 'Remove',
3718: 'ct' => 'Cut',
3719: 'rn' => 'Rename',
1.484.2.12 raeburn 3720: 'cp' => 'Copy',
3721: 'ex' => 'External Resource',
1.484.2.72.2. (raeburn 3722:): 'et' => 'External Tool',
1.484.2.12 raeburn 3723: 'ed' => 'Edit',
3724: 'pr' => 'Preview',
3725: 'sv' => 'Save',
3726: 'ul' => 'URL',
1.484.2.67 raeburn 3727: 'ti' => 'Title',
3728: 'er' => 'Editing rights unavailable for your current role.',
1.484.2.12 raeburn 3729: );
1.484.2.30 raeburn 3730: my %denied = &action_restrictions($coursenum,$coursedom,$url,
3731: $env{'form.folderpath'},
3732: $currgroups);
1.484.2.19 raeburn 3733: my ($copylink,$cutlink,$removelink);
1.329 droeschl 3734: my $skip_confirm = 0;
1.484.2.63 raeburn 3735: my $confirm_removal = 0;
1.329 droeschl 3736: if ( $folder =~ /^supplemental/
3737: || ($url =~ m{( /smppg$
3738: |/syllabus$
3739: |/aboutme$
3740: |/navmaps$
3741: |/bulletinboard$
1.484.2.72.2. (raeburn 3742:): |/ext\.tool$
1.484.2.16 raeburn 3743: |\.html$)}x)
1.484.2.19 raeburn 3744: || $isexternal) {
1.329 droeschl 3745: $skip_confirm = 1;
3746: }
1.484.2.63 raeburn 3747: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
3748: ($url!~/$LONCAPA::assess_page_seq_re/)) {
3749: $confirm_removal = 1;
3750: }
1.484.2.19 raeburn 3751:
1.484.2.30 raeburn 3752: if ($denied{'copy'}) {
3753: $copylink=(<<ENDCOPY)
1.484.2.16 raeburn 3754: <span style="visibility: hidden;">$lt{'cp'}</span>
3755: ENDCOPY
3756: } else {
1.484.2.30 raeburn 3757: my $formname = 'edit_copy_'.$orderidx;
3758: my $js = "javascript:checkForSubmit(document.forms.renameform,'copy','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.484.2.19 raeburn 3759: $copylink=(<<ENDCOPY);
1.484.2.30 raeburn 3760: <form name="$formname" method="post" action="/adm/coursedocs">
3761: $form_common
1.484.2.67 raeburn 3762: <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 3763: $form_end
1.329 droeschl 3764: ENDCOPY
1.484.2.30 raeburn 3765: if (($ishash) && (ref($filtersref->{'cancopy'}) eq 'ARRAY')) {
3766: push(@{$filtersref->{'cancopy'}},$orderidx);
3767: }
1.329 droeschl 3768: }
1.484.2.30 raeburn 3769: if ($denied{'cut'}) {
1.484.2.16 raeburn 3770: $cutlink=(<<ENDCUT);
3771: <span style="visibility: hidden;">$lt{'ct'}</span>
3772: ENDCUT
3773: } else {
1.484.2.30 raeburn 3774: my $formname = 'edit_cut_'.$orderidx;
3775: my $js = "javascript:checkForSubmit(document.forms.renameform,'cut','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.484.2.19 raeburn 3776: $cutlink=(<<ENDCUT);
1.484.2.30 raeburn 3777: <form name="$formname" method="post" action="/adm/coursedocs">
3778: $form_common
3779: <input type="hidden" name="skip_$orderidx" id="skip_cut_$orderidx" value="$skip_confirm" />
1.484.2.67 raeburn 3780: <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 3781: $form_end
1.329 droeschl 3782: ENDCUT
1.484.2.30 raeburn 3783: if (($ishash) && (ref($filtersref->{'cancut'}) eq 'ARRAY')) {
3784: push(@{$filtersref->{'cancut'}},$orderidx);
3785: }
1.329 droeschl 3786: }
1.484.2.30 raeburn 3787: if ($denied{'remove'}) {
1.484.2.16 raeburn 3788: $removelink=(<<ENDREM);
3789: <span style="visibility: hidden;">$lt{'rm'}</a>
3790: ENDREM
3791: } else {
1.484.2.30 raeburn 3792: my $formname = 'edit_remove_'.$orderidx;
1.484.2.63 raeburn 3793: 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 3794: $removelink=(<<ENDREM);
1.484.2.30 raeburn 3795: <form name="$formname" method="post" action="/adm/coursedocs">
3796: $form_common
3797: <input type="hidden" name="skip_$orderidx" id="skip_remove_$orderidx" value="$skip_confirm" />
1.484.2.63 raeburn 3798: <input type="hidden" name="confirm_rem_$orderidx" id="confirm_removal_$orderidx" value="$confirm_removal" />
1.484.2.67 raeburn 3799: <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 3800: $form_end
1.484.2.9 raeburn 3801: ENDREM
1.484.2.30 raeburn 3802: if (($ishash) && (ref($filtersref->{'canremove'}) eq 'ARRAY')) {
3803: push(@{$filtersref->{'canremove'}},$orderidx);
3804: }
1.484.2.9 raeburn 3805: }
1.484.2.35 raeburn 3806: $renamelink=(<<ENDREN);
1.484.2.52 raeburn 3807: <a href='javascript:changename("$esc_path","$index","$oldtitle");' class="LC_docs_rename">$lt{'rn'}</a>
1.484.2.16 raeburn 3808: ENDREN
1.484.2.67 raeburn 3809: my ($uplink,$downlink);
3810: if ($canedit) {
3811: $uplink = "/adm/coursedocs?cmd=up_$index&folderpath=$esc_path&symb=$symb";
3812: $downlink = "/adm/coursedocs?cmd=down_$index&folderpath=$esc_path&symb=$symb";
3813: } else {
3814: $uplink = "javascript:alert('".&js_escape($lt{'er'})."');";
3815: $downlink = $uplink;
3816: }
1.329 droeschl 3817: $line.=(<<END);
3818: <td>
1.379 bisitz 3819: <div class="LC_docs_entry_move">
1.484.2.67 raeburn 3820: <a href="$uplink">
1.484.2.12 raeburn 3821: <img src="${iconpath}move_up.gif" alt="$lt{'up'}" class="LC_icon" />
1.379 bisitz 3822: </a>
3823: </div>
3824: <div class="LC_docs_entry_move">
1.484.2.67 raeburn 3825: <a href="$downlink">
1.484.2.12 raeburn 3826: <img src="${iconpath}move_down.gif" alt="$lt{'dw'}" class="LC_icon" />
1.379 bisitz 3827: </a>
3828: </div>
1.329 droeschl 3829: </td>
3830: <td>
3831: $form_start
1.484.2.30 raeburn 3832: $form_param
1.478 raeburn 3833: $form_common
1.329 droeschl 3834: $selectbox
3835: $form_end
3836: </td>
1.484.2.30 raeburn 3837: <td class="LC_docs_entry_commands LC_nobreak">
1.484.2.9 raeburn 3838: $removelink
1.329 droeschl 3839: $cutlink
3840: $copylink
3841: </td>
3842: END
3843: }
3844: # Figure out what kind of a resource this is
3845: my ($extension)=($url=~/\.(\w+)$/);
3846: my $uploaded=($url=~/^\/*uploaded\//);
3847: my $icon=&Apache::loncommon::icon($url);
1.484.2.19 raeburn 3848: my $isfolder;
3849: my $ispage;
3850: my $containerarg;
1.484.2.67 raeburn 3851: my $folderurl;
1.329 droeschl 3852: if ($uploaded) {
1.472 raeburn 3853: if (($extension eq 'sequence') || ($extension eq 'page')) {
3854: $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
1.484.2.19 raeburn 3855: $containerarg = $1;
1.472 raeburn 3856: if ($extension eq 'sequence') {
3857: $icon=$iconpath.'navmap.folder.closed.gif';
3858: $isfolder=1;
3859: } else {
3860: $icon=$iconpath.'page.gif';
3861: $ispage=1;
3862: }
1.484.2.67 raeburn 3863: $folderurl = &Apache::lonnet::declutter($url);
1.472 raeburn 3864: if ($allowed) {
3865: $url='/adm/coursedocs?';
3866: } else {
3867: $url='/adm/supplemental?';
3868: }
1.329 droeschl 3869: } else {
3870: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
3871: }
3872: }
1.364 bisitz 3873:
1.484.2.70 raeburn 3874: my ($editlink,$extresform,$anchor,$hiddenres,$nomodal);
1.329 droeschl 3875: my $orig_url = $url;
1.340 raeburn 3876: $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
1.484.2.19 raeburn 3877: $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.484.2.12 raeburn 3878: if (!$supplementalflag && $residx && $symb) {
3879: if ((!$isfolder) && (!$ispage)) {
3880: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
3881: $url=&Apache::lonnet::clutter($url);
3882: if ($url=~/^\/*uploaded\//) {
3883: $url=~/\.(\w+)$/;
3884: my $embstyle=&Apache::loncommon::fileembstyle($1);
3885: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
3886: $url='/adm/wrapper'.$url;
3887: } elsif ($embstyle eq 'ssi') {
3888: #do nothing with these
3889: } elsif ($url!~/\.(sequence|page)$/) {
3890: $url='/adm/coursedocs/showdoc'.$url;
3891: }
1.484.2.70 raeburn 3892: } elsif ($url=~m{^(|/adm/wrapper)/ext/([^#]+)}) {
3893: my $wrapped = $1;
3894: my $exturl = $2;
3895: if ($wrapped eq '') {
3896: $url='/adm/wrapper'.$url;
3897: }
3898: if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) {
3899: $nomodal = 1;
3900: }
1.484.2.72.2. (raeburn 3901:): } elsif ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
3902:): $url='/adm/wrapper'.$url;
1.484.2.70 raeburn 3903: } elsif ($url eq "/public/$coursedom/$coursenum/syllabus") {
3904: if (($ENV{'SERVER_PORT'} == 443) &&
3905: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
3906: $nomodal = 1;
3907: }
1.484.2.19 raeburn 3908: }
1.484.2.12 raeburn 3909: if (&Apache::lonnet::symbverify($symb,$url)) {
1.484.2.66 raeburn 3910: my $shownsymb = $symb;
3911: if ($isexternal) {
3912: if ($url =~ /^([^#]+)#([^#]+)$/) {
3913: $url = $1;
3914: $anchor = $2;
3915: if ($symb =~ m{^([^#]+)\Q#$anchor\E$}) {
3916: $shownsymb = $1.&escape('#').$anchor;
3917: }
3918: }
3919: }
1.484.2.67 raeburn 3920: unless ($env{'request.role.adv'}) {
3921: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
3922: $url = '';
3923: }
3924: if (&Apache::lonnet::EXT('resource.0.hiddenresource',$symb) =~ /^yes$/i) {
3925: $url = '';
3926: $hiddenres = 1;
3927: }
3928: }
3929: if ($url ne '') {
1.484.2.72.2. (raeburn 3930:): $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
1.484.2.67 raeburn 3931: }
3932: } elsif (!$env{'request.role.adv'}) {
3933: my $checkencrypt;
3934: if (((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) ||
3935: $isencrypted || (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i)) {
3936: $checkencrypt = 1;
1.484.2.70 raeburn 3937: } elsif (ref($navmapref)) {
1.484.2.67 raeburn 3938: unless (ref($$navmapref)) {
3939: $$navmapref = Apache::lonnavmaps::navmap->new();
3940: }
3941: if (ref($$navmapref)) {
3942: if (lc($$navmapref->get_mapparam($symb,undef,"0.encrypturl")) eq 'yes') {
3943: $checkencrypt = 1;
3944: }
3945: }
3946: }
3947: if ($checkencrypt) {
3948: my $shownsymb = &Apache::lonenc::encrypted($symb);
3949: my $shownurl = &Apache::lonenc::encrypted($url);
3950: if (&Apache::lonnet::symbverify($shownsymb,$shownurl)) {
1.484.2.72.2. (raeburn 3951:): $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
1.484.2.67 raeburn 3952: if ($env{'request.enc'} ne '') {
3953: delete($env{'request.enc'});
3954: }
3955: } else {
3956: $url='';
3957: }
3958: } else {
3959: $url='';
3960: }
1.484.2.12 raeburn 3961: } else {
3962: $url='';
3963: }
1.484.2.19 raeburn 3964: }
1.484.2.66 raeburn 3965: } elsif ($supplementalflag) {
3966: if ($isexternal) {
3967: if ($url =~ /^([^#]+)#([^#]+)$/) {
3968: $url = $1;
3969: $anchor = $2;
1.484.2.70 raeburn 3970: if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) {
3971: $nomodal = 1;
3972: }
3973: }
3974: } elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
3975: if (($ENV{'SERVER_PORT'} == 443) &&
3976: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
3977: $nomodal = 1;
1.484.2.66 raeburn 3978: }
3979: }
1.329 droeschl 3980: }
1.484.2.67 raeburn 3981: my ($rand_pick_text,$rand_order_text,$hiddenfolder);
3982: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.484.2.19 raeburn 3983: if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') {
1.329 droeschl 3984: my $foldername=&escape($foldertitle);
3985: my $folderpath=$env{'form.folderpath'};
3986: if ($folderpath) { $folderpath.='&' };
1.484.2.19 raeburn 3987: if (!$allowed && $supplementalflag) {
3988: $folderpath.=$containerarg.'&'.$foldername;
3989: $url.='folderpath='.&escape($folderpath);
3990: } else {
3991: my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
3992: 'parameter_randompick'))[0];
1.484.2.67 raeburn 3993: my $randorder = ((&LONCAPA::map::getparameter($orderidx,
3994: 'parameter_randomorder'))[0]=~/^yes$/i);
3995: my $hiddenmap = ((&LONCAPA::map::getparameter($orderidx,
3996: 'parameter_hiddenresource'))[0]=~/^yes$/i);
3997: my $encryptmap = ((&LONCAPA::map::getparameter($orderidx,
3998: 'parameter_encrypturl'))[0]=~/^yes$/i);
3999: unless ($hiddenmap) {
1.484.2.70 raeburn 4000: if (ref($navmapref)) {
4001: unless (ref($$navmapref)) {
4002: $$navmapref = Apache::lonnavmaps::navmap->new();
4003: }
4004: if (ref($$navmapref)) {
4005: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
4006: my @resources = $$navmapref->retrieveResources($folderurl,$filterFunc,1,1);
4007: unless (@resources) {
4008: $hiddenmap = 1;
4009: unless ($env{'request.role.adv'}) {
4010: $url = '';
4011: $hiddenfolder = 1;
4012: }
1.484.2.67 raeburn 4013: }
4014: }
4015: }
4016: }
4017: }
4018: unless ($encryptmap) {
1.484.2.70 raeburn 4019: if ((ref($navmapref)) && (ref($$navmapref))) {
4020: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.encrypturl")) eq 'yes') {
4021: $encryptmap = 1;
4022: }
1.484.2.67 raeburn 4023: }
4024: }
4025:
4026: # Append randompick number, hidden, and encrypted with ":" to foldername,
4027: # so it gets transferred between levels
4028: $folderpath.=$containerarg.'&'.$foldername.
4029: ':'.$rpicknum.':'.$hiddenmap.':'.$encryptmap.':'.$randorder.':'.$ispage;
4030: unless ($url eq '') {
4031: $url.='folderpath='.&escape($folderpath);
4032: }
1.484.2.19 raeburn 4033: my $rpckchk;
4034: if ($rpicknum) {
4035: $rpckchk = ' checked="checked"';
1.484.2.30 raeburn 4036: if (($ishash) && (ref($filtersref->{'randompick'}) eq 'ARRAY')) {
4037: push(@{$filtersref->{'randompick'}},$orderidx.':'.$rpicknum);
4038: }
1.484.2.19 raeburn 4039: }
1.484.2.29 raeburn 4040: my $formname = 'edit_randompick_'.$orderidx;
1.484.2.19 raeburn 4041: $rand_pick_text =
1.478 raeburn 4042: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.484.2.30 raeburn 4043: $form_param."\n".
1.478 raeburn 4044: $form_common."\n".
1.484.2.67 raeburn 4045: '<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 4046: if ($rpicknum ne '') {
4047: $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
4048: }
1.484.2.29 raeburn 4049: $rand_pick_text .= '</span></span>'.
4050: $form_end;
1.484.2.30 raeburn 4051: my $ro_set;
1.484.2.67 raeburn 4052: if ($randorder) {
1.484.2.30 raeburn 4053: $ro_set = 'checked="checked"';
4054: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4055: push(@{$filtersref->{'randomorder'}},$orderidx);
4056: }
4057: }
1.484.2.41 raeburn 4058: $formname = 'edit_rorder_'.$orderidx;
1.484.2.19 raeburn 4059: $rand_order_text =
1.484.2.29 raeburn 4060: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.484.2.30 raeburn 4061: $form_param."\n".
1.484.2.29 raeburn 4062: $form_common."\n".
1.484.2.67 raeburn 4063: '<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 4064: $form_end;
1.484.2.19 raeburn 4065: }
1.484.2.18 raeburn 4066: } elsif ($supplementalflag && !$allowed) {
1.484.2.72.2. (raeburn 4067:): my $isexttool;
4068:): if ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4069:): $url='/adm/wrapper'.$url;
4070:): $isexttool = 1;
4071:): }
1.484.2.19 raeburn 4072: $url .= ($url =~ /\?/) ? '&':'?';
1.484.2.18 raeburn 4073: $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
1.484.2.19 raeburn 4074: if ($title) {
4075: $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"');
4076: }
1.484.2.72.2. (raeburn 4077:): if ((($isexternal) || ($isexttool)) && $orderidx) {
1.484.2.19 raeburn 4078: $url .= '&idx='.$orderidx;
4079: }
1.484.2.66 raeburn 4080: if ($anchor ne '') {
4081: $url .= '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4082: }
1.329 droeschl 4083: }
1.484.2.19 raeburn 4084: my ($tdalign,$tdwidth);
1.484.2.12 raeburn 4085: if ($allowed) {
1.484.2.19 raeburn 4086: my $fileloc =
1.484.2.12 raeburn 4087: &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
1.484.2.19 raeburn 4088: if ($isexternal) {
4089: ($editlink,$extresform) =
1.484.2.67 raeburn 4090: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
1.484.2.72.2. (raeburn 4091:): undef,undef,undef,undef,undef,undef,
4092:): undef,$disabled);
4093:): } elsif ($orig_url =~ m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4094:): ($editlink,$extresform) =
4095:): &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
4096:): undef,undef,undef,'tool',$coursedom,
4097:): $coursenum,$ltitoolsref,$disabled);
1.484.2.19 raeburn 4098: } elsif (!$isfolder && !$ispage) {
4099: my ($cfile,$home,$switchserver,$forceedit,$forceview) =
1.484.2.14 raeburn 4100: &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
1.484.2.19 raeburn 4101: if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
1.484.2.66 raeburn 4102: my $suppanchor;
4103: if ($supplementalflag) {
4104: $suppanchor = $anchor;
4105: }
1.484.2.19 raeburn 4106: my $jscall =
1.484.2.12 raeburn 4107: &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
4108: $switchserver,
1.484.2.14 raeburn 4109: $forceedit,
1.484.2.19 raeburn 4110: undef,$symb,
4111: &escape($env{'form.folderpath'}),
1.484.2.66 raeburn 4112: $renametitle,'','',1,$suppanchor);
1.484.2.12 raeburn 4113: if ($jscall) {
1.484.2.19 raeburn 4114: $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
4115: $jscall.'" >'.&mt('Edit').'</a> '."\n";
1.484.2.12 raeburn 4116: }
4117: }
4118: }
1.484.2.19 raeburn 4119: $tdalign = ' align="right" valign="top"';
4120: $tdwidth = ' width="80%"';
1.329 droeschl 4121: }
1.408 raeburn 4122: my $reinit;
4123: if ($crstype eq 'Community') {
4124: $reinit = &mt('(re-initialize community to access)');
4125: } else {
4126: $reinit = &mt('(re-initialize course to access)');
1.484.2.19 raeburn 4127: }
4128: $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;
1.484.2.70 raeburn 4129: my $link;
1.472 raeburn 4130: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 4131: $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
4132: } elsif ($url) {
1.484.2.66 raeburn 4133: if ($anchor ne '') {
4134: if ($supplementalflag) {
4135: $anchor = '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4136: } else {
4137: $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');
4138: }
4139: }
1.484.2.70 raeburn 4140: $link = &js_escape($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.
4141: (($anchor ne '')?$anchor:''));
4142: if ($nomodal) {
4143: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4144: '<img src="'.$icon.'" alt="" class="LC_icon" border="0" /></a>';
4145: } else {
4146: $line.=&Apache::loncommon::modal_link($link,
4147: '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
4148: }
1.469 www 4149: } else {
4150: $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
4151: }
1.484.2.19 raeburn 4152: $line.='</span></td><td'.$tdwidth.'>';
1.472 raeburn 4153: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 4154: $line.='<a href="'.$url.'">'.$title.'</a>';
4155: } elsif ($url) {
1.484.2.70 raeburn 4156: if ($nomodal) {
4157: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4158: $title.'</a>';
4159: } else {
4160: $line.=&Apache::loncommon::modal_link($link,$title,600,500);
4161: }
1.484.2.67 raeburn 4162: } elsif (($hiddenfolder) || ($hiddenres)) {
1.484.2.72 raeburn 4163: $line.=$title.' <span class="LC_warning LC_docs_reinit_warn">('.&mt('Hidden').')</span>';
1.469 www 4164: } else {
4165: $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
4166: }
1.484.2.19 raeburn 4167: $line.="$extresform</td>";
1.478 raeburn 4168: $rand_pick_text = ' ' if ($rand_pick_text eq '');
4169: $rand_order_text = ' ' if ($rand_order_text eq '');
1.329 droeschl 4170: if (($allowed) && ($folder!~/^supplemental/)) {
4171: my %lt=&Apache::lonlocal::texthash(
4172: 'hd' => 'Hidden',
4173: 'ec' => 'URL hidden');
1.484.2.30 raeburn 4174: my ($enctext,$hidtext);
4175: if ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) {
4176: $enctext = ' checked="checked"';
4177: if (($ishash) && (ref($filtersref->{'encrypturl'}) eq 'ARRAY')) {
4178: push(@{$filtersref->{'encrypturl'}},$orderidx);
4179: }
4180: }
4181: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4182: $hidtext = ' checked="checked"';
4183: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4184: push(@{$filtersref->{'hiddenresource'}},$orderidx);
4185: }
4186: }
1.484.2.29 raeburn 4187: my $formhidden = 'edit_hiddenresource_'.$orderidx;
4188: my $formurlhidden = 'edit_encrypturl_'.$orderidx;
1.329 droeschl 4189: $line.=(<<ENDPARMS);
4190: <td class="LC_docs_entry_parameter">
1.484.2.30 raeburn 4191: <form action="/adm/coursedocs" method="post" name="$formhidden">
4192: $form_param
1.478 raeburn 4193: $form_common
1.484.2.67 raeburn 4194: <label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'hiddenresource','settings');" $hidtext $disabled /> $lt{'hd'}</label>
1.329 droeschl 4195: $form_end
1.458 raeburn 4196: <br />
1.484.2.29 raeburn 4197: <form action="/adm/coursedocs" method="post" name="$formurlhidden">
1.484.2.30 raeburn 4198: $form_param
1.478 raeburn 4199: $form_common
1.484.2.67 raeburn 4200: <label><input type="checkbox" name="encrypturl_$orderidx" id="encrypturl_$orderidx" onclick="checkForSubmit(this.form,'encrypturl','settings');" $enctext $disabled /> $lt{'ec'}</label>
1.329 droeschl 4201: $form_end
4202: </td>
1.478 raeburn 4203: <td class="LC_docs_entry_parameter">$rand_pick_text<br />
4204: $rand_order_text</td>
1.329 droeschl 4205: ENDPARMS
4206: }
1.379 bisitz 4207: $line.=&Apache::loncommon::end_data_table_row();
1.329 droeschl 4208: return $line;
4209: }
4210:
1.484.2.30 raeburn 4211: sub action_restrictions {
4212: my ($cnum,$cdom,$url,$folderpath,$currgroups) = @_;
4213: my %denied = (
4214: cut => 0,
4215: copy => 0,
4216: remove => 0,
4217: );
4218: if ($url=~ m{^/res/.+\.(page|sequence)$}) {
4219: # no copy for published maps
4220: $denied{'copy'} = 1;
4221: } elsif ($url=~m{^/res/lib/templates/}) {
4222: $denied{'copy'} = 1;
4223: $denied{'cut'} = 1;
4224: } elsif ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") {
4225: if ($folderpath =~ /^default&[^\&]+$/) {
4226: if ((ref($currgroups) eq 'HASH') && (keys(%{$currgroups}) > 0)) {
4227: $denied{'remove'} = 1;
4228: }
4229: $denied{'cut'} = 1;
4230: $denied{'copy'} = 1;
4231: }
4232: } elsif ($url =~ m{^\Q/uploaded/$cdom/$cnum/group_folder_\E(\w+)\.sequence$}) {
4233: my $group = $1;
4234: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+$/) {
4235: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4236: $denied{'remove'} = 1;
4237: }
4238: }
4239: $denied{'cut'} = 1;
4240: $denied{'copy'} = 1;
4241: } elsif ($url =~ m{^\Q/adm/$cdom/$cnum/\E(\w+)/smppg$}) {
4242: my $group = $1;
4243: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&\Qgroup_folder_$group\E\&[^\&]+$/) {
4244: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4245: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4246: if (keys(%groupsettings) > 0) {
4247: $denied{'remove'} = 1;
4248: }
4249: $denied{'cut'} = 1;
4250: $denied{'copy'} = 1;
4251: }
4252: }
4253: } elsif ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&group_folder_(\w+)\&/) {
4254: my $group = $1;
4255: if ($url =~ /group_boards_\Q$group\E/) {
4256: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4257: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4258: if (keys(%groupsettings) > 0) {
4259: if (ref($groupsettings{'functions'}) eq 'HASH') {
4260: if ($groupsettings{'functions'}{'discussion'} eq 'on') {
4261: $denied{'remove'} = 1;
4262: }
4263: }
4264: }
4265: $denied{'cut'} = 1;
4266: $denied{'copy'} = 1;
4267: }
4268: }
4269: }
4270: return %denied;
4271: }
4272:
1.484.2.26 raeburn 4273: sub new_timebased_suffix {
1.484.2.30 raeburn 4274: my ($dom,$num,$type,$area,$container) = @_;
1.484.2.26 raeburn 4275: my ($prefix,$namespace,$idtype,$errtext,$locknotfreed);
1.484.2.30 raeburn 4276: if ($type eq 'paste') {
4277: $prefix = $type;
4278: $namespace = 'courseeditor';
1.484.2.56 raeburn 4279: $idtype = 'addcode';
1.484.2.30 raeburn 4280: } elsif ($type eq 'map') {
1.484.2.26 raeburn 4281: $prefix = 'docs';
4282: if ($area eq 'supplemental') {
4283: $prefix = 'supp';
4284: }
4285: $prefix .= $container;
4286: $namespace = 'uploadedmaps';
4287: } else {
4288: $prefix = $type;
4289: $namespace = 'templated';
1.484.2.15 raeburn 4290: }
4291: my ($suffix,$freedlock,$error) =
1.484.2.56 raeburn 4292: &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num,$idtype);
1.484.2.15 raeburn 4293: if (!$suffix) {
1.484.2.30 raeburn 4294: if ($type eq 'paste') {
4295: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.');
4296: } elsif ($type eq 'map') {
1.484.2.26 raeburn 4297: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
4298: } elsif ($type eq 'smppg') {
4299: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.');
1.484.2.72.2. (raeburn 4300:): } elsif ($type eq 'exttool') {
4301:): $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new external tool.');
1.484.2.26 raeburn 4302: } else {
1.484.2.42 raeburn 4303: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new discussion board.');
1.484.2.26 raeburn 4304: }
1.484.2.15 raeburn 4305: if ($error) {
4306: $errtext .= '<br />'.$error;
4307: }
4308: }
4309: if ($freedlock ne 'ok') {
1.484.2.26 raeburn 4310: $locknotfreed =
4311: '<div class="LC_error">'.
4312: &mt('There was a problem removing a lockfile.').' ';
1.484.2.30 raeburn 4313: if ($type eq 'paste') {
1.484.2.57 raeburn 4314: if ($freedlock eq 'nolock') {
4315: $locknotfreed =
4316: '<div class="LC_error">'.
4317: &mt('A lockfile was not released when you added content to the clipboard earlier in this session.').' '.
4318:
1.484.2.60 raeburn 4319: &mt('As a result addition of items to the clipboard will be unavailable until your next log-in.');
1.484.2.57 raeburn 4320: } else {
4321: $locknotfreed .=
4322: &mt('This will prevent addition of items to the clipboard until your next log-in.');
4323: }
1.484.2.30 raeburn 4324: } elsif ($type eq 'map') {
1.484.2.57 raeburn 4325: $locknotfreed .=
4326: &mt('This will prevent creation of additional folders or composite pages in this course.');
1.484.2.26 raeburn 4327: } elsif ($type eq 'smppg') {
4328: $locknotfreed .=
4329: &mt('This will prevent creation of additional simple pages in this course.');
1.484.2.72.2. (raeburn 4330:): } elsif ($type eq 'exttool') {
4331:): $locknotfreed .=
4332:): &mt('This will prevent creation of additional external tools in this course.');
1.484.2.26 raeburn 4333: } else {
4334: $locknotfreed .=
1.484.2.42 raeburn 4335: &mt('This will prevent creation of additional discussion boards in this course.');
1.484.2.26 raeburn 4336: }
1.484.2.30 raeburn 4337: unless ($type eq 'paste') {
4338: $locknotfreed .=
1.484.2.38 raeburn 4339: ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
4340: '<a href="/adm/helpdesk" target="_helpdesk">','</a>');
1.484.2.30 raeburn 4341: }
4342: $locknotfreed .= '</div>';
1.484.2.15 raeburn 4343: }
4344: return ($suffix,$errtext,$locknotfreed);
4345: }
4346:
1.329 droeschl 4347: =pod
4348:
4349: =item tiehash()
4350:
4351: tie the hash
4352:
4353: =cut
4354:
4355: sub tiehash {
4356: my ($mode)=@_;
4357: $hashtied=0;
4358: if ($env{'request.course.fn'}) {
4359: if ($mode eq 'write') {
4360: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4361: &GDBM_WRCREAT(),0640)) {
4362: $hashtied=2;
4363: }
4364: } else {
4365: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4366: &GDBM_READER(),0640)) {
4367: $hashtied=1;
4368: }
4369: }
1.364 bisitz 4370: }
1.329 droeschl 4371: }
4372:
4373: sub untiehash {
4374: if ($hashtied) { untie %hash; }
4375: $hashtied=0;
4376: return OK;
4377: }
4378:
4379:
4380:
4381:
4382: sub checkonthis {
4383: my ($r,$url,$level,$title)=@_;
4384: $url=&unescape($url);
4385: $alreadyseen{$url}=1;
4386: $r->rflush();
4387: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
4388: $r->print("\n<br />");
4389: if ($level==0) {
4390: $r->print("<br />");
4391: }
4392: for (my $i=0;$i<=$level*5;$i++) {
4393: $r->print(' ');
4394: }
4395: $r->print('<a href="'.$url.'" target="cat">'.
4396: ($title?$title:$url).'</a> ');
4397: if ($url=~/^\/res\//) {
4398: my $result=&Apache::lonnet::repcopy(
4399: &Apache::lonnet::filelocation('',$url));
4400: if ($result eq 'ok') {
4401: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
4402: $r->rflush();
4403: &Apache::lonnet::countacc($url);
4404: $url=~/\.(\w+)$/;
4405: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
4406: $r->print('<br />');
4407: $r->rflush();
4408: for (my $i=0;$i<=$level*5;$i++) {
4409: $r->print(' ');
4410: }
4411: $r->print('- '.&mt('Rendering:').' ');
4412: my ($errorcount,$warningcount)=split(/:/,
4413: &Apache::lonnet::ssi_body($url,
4414: ('grade_target'=>'web',
4415: 'return_only_error_and_warning_counts' => 1)));
4416: if (($errorcount) ||
4417: ($warningcount)) {
4418: if ($errorcount) {
1.369 bisitz 4419: $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1.329 droeschl 4420: &mt('[quant,_1,error]',$errorcount).'</span>');
4421: }
4422: if ($warningcount) {
4423: $r->print('<span class="LC_warning">'.
4424: &mt('[quant,_1,warning]',$warningcount).'</span>');
4425: }
4426: } else {
4427: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
4428: }
4429: $r->rflush();
4430: }
4431: my $dependencies=
4432: &Apache::lonnet::metadata($url,'dependencies');
4433: foreach my $dep (split(/\,/,$dependencies)) {
4434: if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
4435: &checkonthis($r,$dep,$level+1);
4436: }
4437: }
4438: } elsif ($result eq 'unavailable') {
4439: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
4440: } elsif ($result eq 'not_found') {
4441: unless ($url=~/\$/) {
1.484.2.19 raeburn 4442: $r->print('<span class="LC_error">'.&mt('not found').'</span>');
1.329 droeschl 4443: } else {
1.366 bisitz 4444: $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1.329 droeschl 4445: }
4446: } else {
4447: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
4448: }
4449: }
4450: }
4451: }
4452:
4453:
4454:
4455: =pod
4456:
4457: =item list_symbs()
4458:
1.484.2.3 raeburn 4459: List Content Identifiers
1.329 droeschl 4460:
4461: =cut
4462:
4463: sub list_symbs {
4464: my ($r) = @_;
4465:
1.408 raeburn 4466: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 4467: $r->print(&Apache::loncommon::start_page('List of Content Identifiers'));
4468: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Identifiers'));
4469: $r->print(&startContentScreen('tools'));
1.329 droeschl 4470: my $navmap = Apache::lonnavmaps::navmap->new();
4471: if (!defined($navmap)) {
4472: $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
4473: '<div class="LC_error">'.
4474: &mt('Unable to retrieve information about course contents').
4475: '</div>');
1.408 raeburn 4476: &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
1.329 droeschl 4477: } else {
1.484 raeburn 4478: $r->print('<h4 class="LC_info">'.&mt("$crstype Content Identifiers").'</h4>'.
4479: &Apache::loncommon::start_data_table().
4480: &Apache::loncommon::start_data_table_header_row().
4481: '<th>'.&mt('Title').'</th><th>'.&mt('Identifier').'</th>'.
4482: &Apache::loncommon::end_data_table_header_row()."\n");
4483: my $count;
1.329 droeschl 4484: foreach my $res ($navmap->retrieveResources()) {
1.484 raeburn 4485: $r->print(&Apache::loncommon::start_data_table_row().
4486: '<td>'.$res->compTitle().'</td>'.
4487: '<td>'.$res->symb().'</td>'.
1.484.2.19 raeburn 4488: &Apache::loncommon::end_data_table_row());
1.484 raeburn 4489: $count ++;
4490: }
4491: if (!$count) {
4492: $r->print(&Apache::loncommon::start_data_table_row().
4493: '<td colspan="2">'.&mt("$crstype is empty").'</td>'.
4494: &Apache::loncommon::end_data_table_row());
1.329 droeschl 4495: }
1.484 raeburn 4496: $r->print(&Apache::loncommon::end_data_table());
1.329 droeschl 4497: }
1.484.2.19 raeburn 4498: $r->print(&endContentScreen());
1.329 droeschl 4499: }
4500:
1.484.2.72.2. (raeburn 4501:): sub short_urls {
4502:): my ($r,$canedit) = @_;
4503:): my $crstype = &Apache::loncommon::course_type();
4504:): my $formname = 'shortenurl';
4505:): $r->print(&Apache::loncommon::start_page('Display/Set Shortened URLs'));
4506:): $r->print(&Apache::lonhtmlcommon::breadcrumbs('Shortened URLs'));
4507:): $r->print(&startContentScreen('tools'));
4508:): my ($navmap,$errormsg) =
4509:): &Apache::loncourserespicker::get_navmap_object($crstype,'shorturls');
4510:): my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
4511:): my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4512:): my (%maps,%resources,%titles);
4513:): if (!ref($navmap)) {
4514:): $r->print($errormsg.
4515:): &endContentScreen());
4516:): return '';
4517:): } else {
4518:): $r->print('<h4 class="LC_info">'.&mt('Tiny URLs for deep-linking into course').'</h4>'."\n");
4519:): $r->rflush();
4520:): my $readonly;
4521:): if ($canedit) {
4522:): my ($numnew,$errors) = &Apache::loncommon::get_requested_shorturls($cdom,$cnum,$navmap);
4523:): if ($numnew) {
4524:): $r->print('<p class="LC_info">'.&mt('Created [quant,_1,URL]',$numnew).'</p>');
4525:): }
4526:): if ((ref($errors) eq 'ARRAY') && (@{$errors} > 0)) {
4527:): $r->print(&mt('The following errors occurred when processing your request to create shortened URLs:').'<br /><ul>');
4528:): foreach my $error (@{$errors}) {
4529:): $r->print('<li>'.$error.'</li>');
4530:): }
4531:): $r->print('</ul><br />');
4532:): }
4533:): } else {
4534:): $readonly = 1;
4535:): }
4536:): my %currtiny = &Apache::lonnet::dump('tiny',$cdom,$cnum);
4537:): $r->print(&Apache::loncourserespicker::create_picker($navmap,'shorturls',$formname,$crstype,undef,
4538:): undef,undef,undef,undef,undef,\%currtiny,$readonly));
4539:): }
4540:): $r->print(&endContentScreen());
4541:): }
1.329 droeschl 4542:
4543: sub verifycontent {
4544: my ($r) = @_;
1.408 raeburn 4545: my $crstype = &Apache::loncommon::course_type();
1.484.2.34 raeburn 4546: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
4547: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
1.484 raeburn 4548: $r->print(&startContentScreen('tools'));
4549: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
1.329 droeschl 4550: $hashtied=0;
4551: undef %alreadyseen;
4552: %alreadyseen=();
4553: &tiehash();
1.484 raeburn 4554:
1.329 droeschl 4555: foreach my $key (keys(%hash)) {
4556: if ($hash{$key}=~/\.(page|sequence)$/) {
4557: if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
4558: $r->print('<hr /><span class="LC_error">'.
1.419 bisitz 4559: &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
1.329 droeschl 4560: &unescape($hash{$key}).'</span><br />'.
1.419 bisitz 4561: &mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />');
1.329 droeschl 4562: }
4563: }
4564: if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
4565: &checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
4566: }
4567: }
4568: &untiehash();
1.442 www 4569: $r->print('<p class="LC_success">'.&mt('Done').'</p>');
1.484.2.19 raeburn 4570: $r->print(&endContentScreen());
1.329 droeschl 4571: }
4572:
4573:
4574: sub devalidateversioncache {
4575: my $src=shift;
4576: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
4577: &Apache::lonnet::clutter($src));
4578: }
4579:
4580: sub checkversions {
1.484.2.67 raeburn 4581: my ($r,$canedit) = @_;
1.408 raeburn 4582: my $crstype = &Apache::loncommon::course_type();
1.484.2.44 raeburn 4583: $r->print(&Apache::loncommon::start_page("Check $crstype Resource Versions"));
4584: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Resource Versions"));
1.484 raeburn 4585: $r->print(&startContentScreen('tools'));
1.442 www 4586:
1.329 droeschl 4587: my $header='';
4588: my $startsel='';
4589: my $monthsel='';
4590: my $weeksel='';
4591: my $daysel='';
4592: my $allsel='';
4593: my %changes=();
4594: my $starttime=0;
4595: my $haschanged=0;
4596: my %setversions=&Apache::lonnet::dump('resourceversions',
4597: $env{'course.'.$env{'request.course.id'}.'.domain'},
4598: $env{'course.'.$env{'request.course.id'}.'.num'});
4599:
4600: $hashtied=0;
4601: &tiehash();
1.484.2.67 raeburn 4602: if ($canedit) {
4603: my %newsetversions=();
4604: if ($env{'form.setmostrecent'}) {
4605: $haschanged=1;
4606: foreach my $key (keys(%hash)) {
4607: if ($key=~/^ids\_(\/res\/.+)$/) {
4608: $newsetversions{$1}='mostrecent';
4609: &devalidateversioncache($1);
4610: }
1.329 droeschl 4611: }
1.484.2.67 raeburn 4612: } elsif ($env{'form.setcurrent'}) {
4613: $haschanged=1;
4614: foreach my $key (keys(%hash)) {
4615: if ($key=~/^ids\_(\/res\/.+)$/) {
4616: my $getvers=&Apache::lonnet::getversion($1);
4617: if ($getvers>0) {
4618: $newsetversions{$1}=$getvers;
4619: &devalidateversioncache($1);
4620: }
4621: }
1.329 droeschl 4622: }
1.484.2.67 raeburn 4623: } elsif ($env{'form.setversions'}) {
4624: $haschanged=1;
4625: foreach my $key (keys(%env)) {
4626: if ($key=~/^form\.set_version_(.+)$/) {
4627: my $src=$1;
4628: if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
4629: $newsetversions{$src}=$env{$key};
4630: &devalidateversioncache($src);
4631: }
4632: }
1.329 droeschl 4633: }
1.484.2.67 raeburn 4634: }
4635: if ($haschanged) {
4636: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
4637: $env{'course.'.$env{'request.course.id'}.'.domain'},
4638: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
4639: $r->print(&Apache::loncommon::confirmwrapper(
4640: &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
4641: } else {
4642: $r->print(&Apache::loncommon::confirmwrapper(
4643: &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
4644: }
4645: &mark_hash_old();
4646: }
4647: &changewarning($r,'');
1.329 droeschl 4648: }
4649: if ($env{'form.timerange'} eq 'all') {
4650: # show all documents
1.484.2.34 raeburn 4651: $header=&mt('All content in '.$crstype);
1.484.2.19 raeburn 4652: $allsel=' selected="selected"';
1.329 droeschl 4653: foreach my $key (keys(%hash)) {
4654: if ($key=~/^ids\_(\/res\/.+)$/) {
4655: my $src=$1;
4656: $changes{$src}=1;
4657: }
4658: }
4659: } else {
4660: # show documents which changed
4661: %changes=&Apache::lonnet::dump
4662: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
4663: $env{'course.'.$env{'request.course.id'}.'.num'});
4664: my $firstkey=(keys(%changes))[0];
4665: unless ($firstkey=~/^error\:/) {
4666: unless ($env{'form.timerange'}) {
4667: $env{'form.timerange'}=604800;
4668: }
4669: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
4670: .&mt('seconds');
4671: if ($env{'form.timerange'}==-1) {
4672: $seltext='since start of course';
1.484.2.19 raeburn 4673: $startsel=' selected="selected"';
1.329 droeschl 4674: $env{'form.timerange'}=time;
4675: }
4676: $starttime=time-$env{'form.timerange'};
4677: if ($env{'form.timerange'}==2592000) {
4678: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 4679: $monthsel=' selected="selected"';
1.329 droeschl 4680: } elsif ($env{'form.timerange'}==604800) {
4681: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 4682: $weeksel=' selected="selected"';
1.329 droeschl 4683: } elsif ($env{'form.timerange'}==86400) {
4684: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 4685: $daysel=' selected="selected"';
1.329 droeschl 4686: }
4687: $header=&mt('Content changed').' '.$seltext;
4688: } else {
4689: $header=&mt('No content modifications yet.');
4690: }
4691: }
4692: %setversions=&Apache::lonnet::dump('resourceversions',
4693: $env{'course.'.$env{'request.course.id'}.'.domain'},
4694: $env{'course.'.$env{'request.course.id'}.'.num'});
4695: my %lt=&Apache::lonlocal::texthash
1.408 raeburn 4696: ('st' => 'Version changes since start of '.$crstype,
1.329 droeschl 4697: 'lm' => 'Version changes since last Month',
4698: 'lw' => 'Version changes since last Week',
4699: 'sy' => 'Version changes since Yesterday',
4700: 'al' => 'All Resources (possibly large output)',
1.484 raeburn 4701: 'cd' => 'Change display',
1.329 droeschl 4702: 'sd' => 'Display',
4703: 'fi' => 'File',
4704: 'md' => 'Modification Date',
4705: 'mr' => 'Most recently published Version',
1.408 raeburn 4706: 've' => 'Version used in '.$crstype,
4707: 'vu' => 'Set Version to be used in '.$crstype,
4708: 'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
1.329 droeschl 4709: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
4710: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.479 golterma 4711: 'di' => 'Differences',
1.484 raeburn 4712: 'save' => 'Save changes',
4713: 'vers' => 'Version choice(s) for specific resources',
1.479 golterma 4714: 'act' => 'Actions');
1.484.2.67 raeburn 4715: my ($disabled,$readonly);
4716: unless ($canedit) {
4717: $disabled = 'disabled="disabled"';
4718: $readonly = 1;
4719: }
1.329 droeschl 4720: $r->print(<<ENDHEADERS);
1.484 raeburn 4721: <h4 class="LC_info">$header</h4>
1.329 droeschl 4722: <form action="/adm/coursedocs" method="post">
4723: <input type="hidden" name="versions" value="1" />
1.484 raeburn 4724: <div class="LC_left_float">
1.479 golterma 4725: <fieldset>
1.484 raeburn 4726: <legend>$lt{'cd'}</legend>
1.329 droeschl 4727: <select name="timerange">
1.484.2.19 raeburn 4728: <option value='all'$allsel>$lt{'al'}</option>
4729: <option value="-1"$startsel>$lt{'st'}</option>
4730: <option value="2592000"$monthsel>$lt{'lm'}</option>
4731: <option value="604800"$weeksel>$lt{'lw'}</option>
4732: <option value="86400"$daysel>$lt{'sy'}</option>
1.329 droeschl 4733: </select>
4734: <input type="submit" name="display" value="$lt{'sd'}" />
1.484 raeburn 4735: </fieldset>
4736: </div>
4737: <div class="LC_left_float">
4738: <fieldset>
4739: <legend>$lt{'act'}</legend>
1.484.2.67 raeburn 4740: $lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" $disabled /><br />
4741: $lt{'sc'}: <input type="submit" name="setcurrent" value="Go" $disabled />
1.484 raeburn 4742: </fieldset>
4743: </div>
4744: <br clear="all" />
4745: <hr />
4746: <h4>$lt{'vers'}</h4>
1.329 droeschl 4747: ENDHEADERS
1.479 golterma 4748: #number of columns for version history
1.484.2.44 raeburn 4749: my %changedbytime;
4750: foreach my $key (keys(%changes)) {
4751: #excludes not versionable problems from resource version history:
4752: next if ($key =~ /^\/res\/lib\/templates/);
4753: my $chg;
4754: if ($env{'form.timerange'} eq 'all') {
4755: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
4756: $chg = &Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate');
4757: } else {
4758: $chg = $changes{$key};
4759: next if ($chg < $starttime);
4760: }
4761: push(@{$changedbytime{$chg}},$key);
4762: }
4763: if (keys(%changedbytime) == 0) {
4764: &untiehash();
4765: $r->print(&mt('No content changes in imported content in specified time frame').
4766: &endContentScreen());
4767: return;
4768: }
1.479 golterma 4769: $r->print(
1.484.2.67 raeburn 4770: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.484.2.19 raeburn 4771: &Apache::loncommon::start_data_table().
4772: &Apache::loncommon::start_data_table_header_row().
4773: '<th>'.&mt('Resources').'</th>'.
4774: "<th>$lt{'mr'}</th>".
4775: "<th>$lt{'ve'}</th>".
4776: "<th>$lt{'vu'}</th>".
4777: '<th>'.&mt('History').'</th>'.
4778: &Apache::loncommon::end_data_table_header_row()
4779: );
1.484.2.44 raeburn 4780: foreach my $chg (sort {$b <=> $a } keys(%changedbytime)) {
4781: foreach my $key (sort(@{$changedbytime{$chg}})) {
4782: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
4783: my $currentversion=&Apache::lonnet::getversion($key);
4784: if ($currentversion<0) {
4785: $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
4786: }
4787: my $linkurl=&Apache::lonnet::clutter($key);
4788: $r->print(
4789: &Apache::loncommon::start_data_table_row().
4790: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br />'.
4791: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
4792: '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br />('.
4793: &Apache::lonlocal::locallocaltime($chg).')</span></td>'.
4794: '<td align="right">'
4795: );
4796: # Used in course
4797: my $usedversion=$hash{'version_'.$linkurl};
4798: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.484.2.19 raeburn 4799: if ($usedversion != $currentversion) {
1.479 golterma 4800: $r->print('<span class="LC_warning">'.$usedversion.'</span>');
1.484.2.19 raeburn 4801: } else {
1.479 golterma 4802: $r->print($usedversion);
4803: }
1.329 droeschl 4804: } else {
1.484.2.19 raeburn 4805: $r->print($currentversion);
1.329 droeschl 4806: }
1.484.2.44 raeburn 4807: $r->print('</td><td title="'.$lt{'vu'}.'">');
4808: # Set version
4809: $r->print(&Apache::loncommon::select_form(
4810: $setversions{$linkurl},
4811: 'set_version_'.$linkurl,
4812: {'select_form_order' => ['',1..$currentversion,'mostrecent'],
4813: '' => '',
4814: 'mostrecent' => &mt('most recent'),
1.484.2.67 raeburn 4815: map {$_,$_} (1..$currentversion)},'',$readonly));
1.484.2.44 raeburn 4816: my $lastold=1;
4817: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
4818: my $url=$root.'.'.$prevvers.'.'.$extension;
4819: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) {
4820: $lastold=$prevvers;
4821: }
4822: }
4823: $r->print('</td>');
4824: # List all available versions
4825: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
4826: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
4827: my $url=$root.'.'.$prevvers.'.'.$extension;
1.484.2.19 raeburn 4828: $r->print(
1.484.2.44 raeburn 4829: '<span class="LC_nobreak">'
4830: .'<a href="'.&Apache::lonnet::clutter($url).'">'
4831: .&mt('Version [_1]',$prevvers).'</a>'
4832: .' ('.&Apache::lonlocal::locallocaltime(
4833: &Apache::lonnet::metadata($url,'lastrevisiondate'))
4834: .')');
4835: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
4836: $r->print(
4837: ' <a href="/adm/diff?filename='.
4838: &Apache::lonnet::clutter($root.'.'.$extension).
4839: &HTML::Entities::encode('&versionone='.$prevvers,'"<>&').
4840: '" target="diffs">'.&mt('Diffs').'</a>');
4841: }
4842: $r->print('</span><br />');
1.329 droeschl 4843: }
1.484.2.44 raeburn 4844: $r->print('</span></td>'.&Apache::loncommon::end_data_table_row());
1.484.2.19 raeburn 4845: }
1.329 droeschl 4846: }
1.484.2.19 raeburn 4847: $r->print(
4848: &Apache::loncommon::end_data_table().
1.484.2.67 raeburn 4849: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.484.2.19 raeburn 4850: '</form>'
4851: );
1.329 droeschl 4852:
4853: &untiehash();
1.484.2.19 raeburn 4854: $r->print(&endContentScreen());
1.484.2.44 raeburn 4855: return;
1.329 droeschl 4856: }
4857:
4858: sub mark_hash_old {
4859: my $retie_hash=0;
4860: if ($hashtied) {
4861: $retie_hash=1;
4862: &untiehash();
4863: }
4864: &tiehash('write');
4865: $hash{'old'}=1;
4866: &untiehash();
4867: if ($retie_hash) { &tiehash(); }
4868: }
4869:
4870: sub is_hash_old {
4871: my $untie_hash=0;
4872: if (!$hashtied) {
4873: $untie_hash=1;
4874: &tiehash();
4875: }
4876: my $return=$hash{'old'};
4877: if ($untie_hash) { &untiehash(); }
4878: return $return;
4879: }
4880:
4881: sub changewarning {
4882: my ($r,$postexec,$message,$url)=@_;
4883: if (!&is_hash_old()) { return; }
4884: my $pathvar='folderpath';
4885: my $path=&escape($env{'form.folderpath'});
4886: if (!defined($url)) {
4887: $url='/adm/coursedocs?'.$pathvar.'='.$path;
4888: }
4889: my $course_type = &Apache::loncommon::course_type();
4890: if (!defined($message)) {
4891: $message='Changes will become active for your current session after [_1], or the next time you log in.';
4892: }
4893: $r->print("\n\n".
1.372 bisitz 4894: '<script type="text/javascript">'."\n".
4895: '// <![CDATA['."\n".
4896: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
4897: '// ]]>'."\n".
1.369 bisitz 4898: '</script>'."\n".
1.375 tempelho 4899: '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
1.329 droeschl 4900: '<input type="hidden" name="orgurl" value="'.$url.
1.372 bisitz 4901: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
1.329 droeschl 4902: &mt($message,' <input type="hidden" name="'.
4903: $env{'request.role'}.'" value="1" /><input type="button" value="'.
1.369 bisitz 4904: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1.372 bisitz 4905: $help{'Caching'}.'</p></form>'."\n\n");
1.329 droeschl 4906: }
4907:
4908:
4909: sub init_breadcrumbs {
1.484.2.44 raeburn 4910: my ($form,$text,$help)=@_;
1.329 droeschl 4911: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484 raeburn 4912: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
1.405 bisitz 4913: text=>&Apache::loncommon::course_type().' Editor',
1.329 droeschl 4914: faq=>273,
4915: bug=>'Instructor Interface',
1.484.2.44 raeburn 4916: help => $help});
1.329 droeschl 4917: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
4918: text=>$text,
4919: faq=>273,
4920: bug=>'Instructor Interface'});
4921: }
4922:
1.441 www 4923: # subroutine to list form elements
4924: sub create_list_elements {
4925: my @formarr = @_;
4926: my $list = '';
1.484.2.12 raeburn 4927: foreach my $button (@formarr){
4928: foreach my $picture (keys(%{$button})) {
4929: $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
1.441 www 4930: }
4931: }
4932: return $list;
4933: }
1.329 droeschl 4934:
1.441 www 4935: # subroutine to create ul from list elements
4936: sub create_form_ul {
4937: my $list = shift;
4938: my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
4939: return $ul;
4940: }
1.329 droeschl 4941:
1.442 www 4942: #
4943: # Start tabs
4944: #
4945:
4946: sub startContentScreen {
1.484 raeburn 4947: my ($mode) = @_;
4948: my $output = '<ul class="LC_TabContentBigger" id="mainnav">';
1.472 raeburn 4949: if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
1.484 raeburn 4950: $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n";
4951: $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n";
4952: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
4953: } else {
1.484.2.34 raeburn 4954: $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 4955: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
4956: $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>'."\n";
4957: '><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>';
4958: }
4959: $output .= "\n".'</ul>'."\n";
4960: $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
4961: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
4962: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
4963: return $output;
1.442 www 4964: }
4965:
4966: #
4967: # End tabs
4968: #
4969:
4970: sub endContentScreen {
1.484 raeburn 4971: return '</div></div></div>';
1.442 www 4972: }
1.329 droeschl 4973:
1.446 www 4974: sub supplemental_base {
1.484.2.33 raeburn 4975: return 'supplemental&'.&escape(&mt('Supplemental Content'));
1.446 www 4976: }
4977:
1.329 droeschl 4978: sub handler {
4979: my $r = shift;
4980: &Apache::loncommon::content_type($r,'text/html');
4981: $r->send_http_header;
4982: return OK if $r->header_only;
1.484 raeburn 4983:
4984: # get course data
1.408 raeburn 4985: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 4986: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
4987: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
4988:
4989: # graphics settings
4990: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329 droeschl 4991:
1.443 www 4992: #
1.329 droeschl 4993: # --------------------------------------------- Initialize help topics for this
4994: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
1.484.2.72.2. (raeburn 4995:): 'Adding_External_Resource','Adding_External_Tool',
4996:): 'Navigate_Content','Adding_Folders','Docs_Overview',
4997:): 'Load_Map','Supplemental','Score_Upload_Form',
4998:): 'Adding_Pages','Importing_LON-CAPA_Resource',
4999:): 'Importing_IMS_Course','Uploading_From_Harddrive',
5000:): 'Course_Roster','Web_Page','Dropbox','Simple_Problem') {
1.329 droeschl 5001: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
5002: }
5003: # Composite help files
5004: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
5005: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
5006: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
5007: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
5008: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
5009: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 5010: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 5011: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 5012: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 5013: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1.484.2.30 raeburn 5014:
1.484.2.67 raeburn 5015: my ($allowed,$canedit,$canview,$disabled);
1.472 raeburn 5016: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
5017: unless ($r->uri eq '/adm/supplemental') {
5018: # does this user have privileges to modify content.
1.484.2.67 raeburn 5019: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
5020: $allowed = 1;
5021: $canedit = 1;
5022: $canview = 1;
5023: } elsif (&Apache::lonnet::allowed('cev',$env{'request.course.id'})) {
5024: $allowed = 1;
5025: $canview = 1;
5026: }
5027: }
5028: unless ($canedit) {
5029: $disabled = ' disabled="disabled"';
1.472 raeburn 5030: }
1.484.2.53 raeburn 5031: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']);
1.484.2.72.2. (raeburn 5032:): if ($env{'form.inhibitmenu'}) {
5033:): unless ($env{'form.inhibitmenu'} eq 'yes') {
5034:): delete($env{'form.inhibitmenu'});
5035:): }
5036:): }
1.484.2.53 raeburn 5037: if ($allowed && $env{'form.verify'}) {
1.484.2.44 raeburn 5038: &init_breadcrumbs('verify','Verify Content','Docs_Verify_Content');
1.329 droeschl 5039: &verifycontent($r);
5040: } elsif ($allowed && $env{'form.listsymbs'}) {
1.484 raeburn 5041: &init_breadcrumbs('listsymbs','List Content IDs');
1.329 droeschl 5042: &list_symbs($r);
1.484.2.72.2. (raeburn 5043:): } elsif ($allowed && $env{'form.shorturls'}) {
5044:): &init_breadcrumbs('shorturls','Set/Display Shortened URLs','Docs_Short_URLs');
5045:): &short_urls($r,$canedit);
1.329 droeschl 5046: } elsif ($allowed && $env{'form.docslog'}) {
5047: &init_breadcrumbs('docslog','Show Log');
1.484 raeburn 5048: my $folder = $env{'form.folder'};
5049: if ($folder eq '') {
5050: $folder='default';
5051: }
1.484.2.67 raeburn 5052: &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit);
1.329 droeschl 5053: } elsif ($allowed && $env{'form.versions'}) {
1.484.2.44 raeburn 5054: &init_breadcrumbs('versions','Check/Set Resource Versions','Docs_Check_Resource_Versions');
1.484.2.67 raeburn 5055: &checkversions($r,$canedit);
5056: } elsif ($canedit && $env{'form.dumpcourse'}) {
1.484.2.43 raeburn 5057: &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329 droeschl 5058: &dumpcourse($r);
5059: } elsif ($allowed && $env{'form.exportcourse'}) {
1.377 bisitz 5060: &init_breadcrumbs('exportcourse','IMS Export');
1.475 raeburn 5061: &Apache::imsexport::exportcourse($r);
1.329 droeschl 5062: } else {
1.445 www 5063: #
5064: # Done catching special calls
1.484 raeburn 5065: # The whole rest is for course and supplemental documents and utilities menu
1.445 www 5066: # Get the parameters that may be needed
5067: #
5068: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.484.2.19 raeburn 5069: ['folderpath',
5070: 'forcesupplement','forcestandard',
5071: 'tools','symb','command','supppath']);
1.445 www 5072:
1.484.2.72.2. (raeburn 5073:): foreach my $item ('forcesupplement','forcestandard','tools') {
5074:): next if ($env{'form.'.$item} eq '');
5075:): unless ($env{'form.'.$item} eq '1') {
5076:): delete($env{'form.'.$item});
5077:): }
5078:): }
5079:):
5080:): if ($env{'form.command'}) {
5081:): unless ($env{'form.command'} =~ /^(direct|directnav|editdocs|editsupp|contents|home)$/) {
5082:): delete($env{'form.command'});
5083:): }
5084:): }
5085:):
5086:): if ($env{'form.symb'}) {
5087:): my ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.symb'});
5088:): unless (($id =~ /^\d+$/) && (&Apache::lonnet::is_on_map($resurl))) {
5089:): delete($env{'form.symb'});
5090:): }
5091:): }
1.445 www 5092: # standard=1: this is a "new-style" course with an uploaded map as top level
5093: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329 droeschl 5094:
5095: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445 www 5096:
1.484 raeburn 5097: # Decide whether this should display supplemental or main content or utilities
1.445 www 5098: # supplementalflag=1: show supplemental documents
5099: # supplementalflag=0: show standard documents
1.484 raeburn 5100: # toolsflag=1: show utilities
1.445 www 5101:
1.484.2.39 raeburn 5102: my $unesc_folderpath = &unescape($env{'form.folderpath'});
5103: my $supplementalflag=($unesc_folderpath=~/^supplemental/);
5104: if (($unesc_folderpath=~/^default/) || ($unesc_folderpath eq "")) {
1.445 www 5105: $supplementalflag=0;
5106: }
5107: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
5108: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
5109: unless ($allowed) { $supplementalflag=1; }
5110: unless ($standard) { $supplementalflag=1; }
1.484 raeburn 5111: my $toolsflag=0;
5112: if ($env{'form.tools'}) { $toolsflag=1; }
1.445 www 5113:
1.484.2.72.2. (raeburn 5114:): if ($env{'form.folderpath'} ne '') {
5115:): my @items = split(/\&/,$env{'form.folderpath'});
5116:): my $badpath;
5117:): for (my $i=0; $i<@items; $i++) {
5118:): my $odd = $i%2;
5119:): if (($odd) && (!$supplementalflag) && ($items[$i] !~ /^[^:]*:(|\d+):(|1):(|1):(|1):(|1)$/)) {
5120:): $badpath = 1;
5121:): } elsif ((!$odd) && ($items[$i] !~ /^(default|supplemental)(|_\d+)$/)) {
5122:): $badpath = 1;
5123:): }
5124:): last if ($badpath);
5125:): }
5126:): if ($badpath) {
5127:): delete($env{'form.folderpath'});
5128:): }
5129:): }
5130:):
5131:): if ($env{'form.supppath'} ne '') {
5132:): my @items = split(/\&/,$env{'form.supppath'});
5133:): my $badpath;
5134:): for (my $i=0; $i<@items; $i++) {
5135:): my $odd = $i%2;
5136:): if ((!$odd) && ($items[$i] !~ /^supplemental(|_\d+)$/)) {
5137:): $badpath = 1;
5138:): }
5139:): last if ($badpath);
5140:): }
5141:): if ($badpath) {
5142:): delete($env{'form.supppath'});
5143:): }
5144:): }
5145:):
1.329 droeschl 5146: my $script='';
5147: my $showdoc=0;
1.457 raeburn 5148: my $addentries = {};
1.475 raeburn 5149: my $container;
1.329 droeschl 5150: my $containertag;
1.484.2.17 raeburn 5151: my $pathitem;
1.484.2.72.2. (raeburn 5152:): my %ltitools;
1.484.2.67 raeburn 5153: my $hiddentop;
5154: my $navmap;
5155: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.329 droeschl 5156:
1.464 www 5157: # Do we directly jump somewhere?
1.484.2.21 raeburn 5158: if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
1.472 raeburn 5159: if ($env{'form.symb'} ne '') {
1.484.2.19 raeburn 5160: $env{'form.folderpath'}=
1.484.2.67 raeburn 5161: &Apache::loncommon::symb_to_docspath($env{'form.symb'},\$navmap);
1.484.2.21 raeburn 5162: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
5163: $env{'form.command'}.'_'.$env{'form.symb'}});
1.472 raeburn 5164: } elsif ($env{'form.supppath'} ne '') {
5165: $env{'form.folderpath'}=$env{'form.supppath'};
1.484.2.21 raeburn 5166: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
5167: $env{'form.command'}.'_'.$env{'form.supppath'}});
1.466 www 5168: }
1.472 raeburn 5169: } elsif ($env{'form.command'} eq 'editdocs') {
1.484.2.67 raeburn 5170: $env{'form.folderpath'} = &default_folderpath($coursenum,$coursedom,\$navmap);
1.484.2.21 raeburn 5171: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
1.472 raeburn 5172: } elsif ($env{'form.command'} eq 'editsupp') {
1.484.2.67 raeburn 5173: $env{'form.folderpath'} = &supplemental_base();
1.484.2.21 raeburn 5174: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
5175: } elsif ($env{'form.command'} eq 'contents') {
5176: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
5177: } elsif ($env{'form.command'} eq 'home') {
5178: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
1.464 www 5179: }
5180:
1.484.2.23 raeburn 5181:
1.445 www 5182: # Where do we store these for when we come back?
5183: my $stored_folderpath='docs_folderpath';
5184: if ($supplementalflag) {
5185: $stored_folderpath='docs_sup_folderpath';
5186: }
1.464 www 5187:
1.484.2.19 raeburn 5188: # No folderpath, and in edit mode, see if we have something stored
5189: if ((!$env{'form.folderpath'}) && $allowed) {
1.445 www 5190: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.484.2.19 raeburn 5191: {'folderpath' => 'scalar'});
1.484.2.67 raeburn 5192:
5193: if (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
5194: if ($supplementalflag) {
5195: undef($env{'form.folderpath'}) if ($1 eq 'default');
5196: } else {
5197: undef($env{'form.folderpath'}) if ($1 eq 'supplemental');
5198: }
5199: } else {
1.484.2.19 raeburn 5200: undef($env{'form.folderpath'});
5201: }
1.329 droeschl 5202: }
1.446 www 5203:
5204: # If we are not allowed to make changes, all we can see are supplemental docs
1.409 raeburn 5205: if (!$allowed) {
1.446 www 5206: unless ($env{'form.folderpath'} =~ /^supplemental/) {
5207: $env{'form.folderpath'} = &supplemental_base();
1.409 raeburn 5208: }
5209: }
1.446 www 5210: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329 droeschl 5211: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446 www 5212: $env{'form.folderpath'} = &supplemental_base()
5213: .'&'.
1.329 droeschl 5214: $env{'form.folderpath'};
5215: }
1.484.2.67 raeburn 5216: # If allowed and user's role is not advanced check folderpath is not hidden
5217: if (($allowed) && (!$env{'request.role.adv'}) &&
5218: ($env{'form.folderpath'} ne '') && (!$supplementalflag)) {
5219: my $folderurl;
5220: my @pathitems = split(/\&/,$env{'form.folderpath'});
5221: my $folder = $pathitems[-2];
5222: if ($folder eq '') {
5223: undef($env{'form.folderpath'});
5224: } else {
5225: $folderurl = "uploaded/$coursedom/$coursenum/$folder";
5226: if ((split(/\:/,$pathitems[-1]))[4]) {
5227: $folderurl .= '.page';
5228: } else {
5229: $folderurl .= '.sequence';
5230: }
5231: unless (ref($navmap)) {
5232: $navmap = Apache::lonnavmaps::navmap->new();
5233: }
5234: if (ref($navmap)) {
5235: if (lc($navmap->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
5236: my @resources = $navmap->retrieveResources($folderurl,$filterFunc,1,1);
5237: unless (@resources) {
5238: undef($env{'form.folderpath'});
5239: }
5240: }
5241: }
5242: }
5243: }
5244:
5245:
1.446 www 5246: # If after all of this, we still don't have any paths, make them
1.484.2.19 raeburn 5247: unless ($env{'form.folderpath'}) {
1.446 www 5248: if ($supplementalflag) {
5249: $env{'form.folderpath'}=&supplemental_base();
1.484.2.67 raeburn 5250: } elsif ($allowed) {
5251: ($env{'form.folderpath'},$hiddentop) = &default_folderpath($coursenum,$coursedom,\$navmap);
1.446 www 5252: }
1.472 raeburn 5253: }
1.446 www 5254:
1.445 www 5255: # Store this
1.484 raeburn 5256: unless ($toolsflag) {
1.484.2.67 raeburn 5257: if (($allowed) && ($env{'form.folderpath'} ne '')) {
1.484.2.19 raeburn 5258: &Apache::loncommon::store_course_settings($stored_folderpath,
5259: {'folderpath' => 'scalar'});
5260: }
5261: my $folderpath;
1.484 raeburn 5262: if ($env{'form.folderpath'}) {
1.484.2.19 raeburn 5263: $folderpath = $env{'form.folderpath'};
5264: my (@folders)=split('&',$env{'form.folderpath'});
5265: $env{'form.foldername'}=&unescape(pop(@folders));
5266: if ($env{'form.foldername'} =~ /\:1$/) {
5267: $container = 'page';
5268: } else {
5269: $container = 'sequence';
5270: }
5271: $env{'form.folder'}=pop(@folders);
1.484 raeburn 5272: } else {
1.484.2.19 raeburn 5273: if ($env{'form.folder'} eq '' ||
5274: $env{'form.folder'} eq 'supplemental') {
1.484.2.67 raeburn 5275: if ($env{'form.folder'} eq 'supplemental') {
5276: $folderpath=&supplemental_base();
5277: } elsif (!$hiddentop) {
5278: $folderpath='default&'.
5279: &escape(&mt('Main Content').':::::');
5280: }
1.484 raeburn 5281: }
5282: }
1.484.2.19 raeburn 5283: $containertag = '<input type="hidden" name="folderpath" value="" />';
5284: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 5285: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
5286: $showdoc='/'.$1;
5287: }
5288: if ($showdoc) { # got called in sequence from course
5289: $allowed=0;
5290: } else {
1.484.2.67 raeburn 5291: if ($canedit) {
1.484 raeburn 5292: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
5293: $script=&Apache::lonratedt::editscript('simple');
1.433 raeburn 5294: }
5295: }
1.329 droeschl 5296: }
5297:
1.344 bisitz 5298: # get personal data
1.329 droeschl 5299: my $uname=$env{'user.name'};
5300: my $udom=$env{'user.domain'};
5301: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
5302:
5303: if ($allowed) {
1.484 raeburn 5304: if ($toolsflag) {
5305: $script .= &inject_data_js();
5306: my ($home,$other,%outhash)=&authorhosts();
5307: if (!$home && $other) {
5308: my @hosts;
5309: foreach my $aurole (keys(%outhash)) {
5310: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
5311: push(@hosts,$outhash{$aurole});
5312: }
5313: }
5314: $script .= &dump_switchserver_js(@hosts);
5315: }
1.458 raeburn 5316: } else {
1.484.2.43 raeburn 5317: my $tid = 1;
1.484 raeburn 5318: my @tabids;
5319: if ($supplementalflag) {
5320: @tabids = ('002','ee2','ff2');
1.484.2.43 raeburn 5321: $tid = 2;
1.484 raeburn 5322: } else {
5323: @tabids = ('aa1','bb1','cc1','ff1');
1.484.2.19 raeburn 5324: unless ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 5325: unshift(@tabids,'001');
5326: push(@tabids,('dd1','ee1'));
5327: }
1.458 raeburn 5328: }
1.484 raeburn 5329: my $tabidstr = join("','",@tabids);
1.484.2.72.2. (raeburn 5330:): %ltitools = &Apache::lonnet::get_domain_ltitools($coursedom);
5331:): my $posslti = keys(%ltitools);
5332:): $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
1.484.2.67 raeburn 5333: $canedit,\$navmap).
1.484 raeburn 5334: &history_tab_js().
5335: &inject_data_js().
1.484.2.43 raeburn 5336: &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
1.484.2.72.2. (raeburn 5337:): &Apache::lonextresedit::extedit_javascript(\%ltitools);
1.484 raeburn 5338: $addentries = {
1.484.2.3 raeburn 5339: onload => "javascript:resize_scrollbox('contentscroll','1','1');",
1.484 raeburn 5340: };
1.458 raeburn 5341: }
1.484.2.30 raeburn 5342: $script .= &paste_popup_js();
1.484.2.12 raeburn 5343: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
5344: &mt('Switch server?');
1.484.2.19 raeburn 5345:
5346:
1.329 droeschl 5347: }
5348: # -------------------------------------------------------------------- Body tag
1.369 bisitz 5349: $script = '<script type="text/javascript">'."\n"
1.372 bisitz 5350: .'// <![CDATA['."\n"
5351: .$script."\n"
5352: .'// ]]>'."\n"
5353: .'</script>'."\n";
1.385 bisitz 5354:
5355: # Breadcrumbs
5356: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484.2.19 raeburn 5357:
5358: if ($showdoc) {
5359: $r->print(&Apache::loncommon::start_page("$crstype documents",undef,
5360: {'force_register' => $showdoc,}));
1.484.2.44 raeburn 5361: } elsif ($toolsflag) {
1.484.2.67 raeburn 5362: my ($breadtext,$breadtitle);
5363: $breadtext = "$crstype Editor";
5364: if ($canedit) {
5365: $breadtitle = 'Editing '.$crstype.' Contents';
5366: } else {
5367: $breadtext .= ' (View-only mode)';
5368: $breadtitle = 'Viewing '.$crstype.' Contents';
5369: }
1.484.2.44 raeburn 5370: &Apache::lonhtmlcommon::add_breadcrumb({
1.484.2.67 raeburn 5371: href=>"/adm/coursedocs",text=>$breadtext});
1.484.2.44 raeburn 5372: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script)
5373: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5374: .&Apache::lonhtmlcommon::breadcrumbs(
1.484.2.67 raeburn 5375: $breadtitle)
1.484.2.44 raeburn 5376: );
1.484.2.19 raeburn 5377: } elsif ($r->uri eq '/adm/supplemental') {
5378: my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
5379: $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
5380: {'bread_crumbs' => $brcrum,}));
5381: } else {
1.484.2.67 raeburn 5382: my ($breadtext,$breadtitle,$helpitem);
5383: $breadtext = "$crstype Editor";
5384: if ($canedit) {
5385: $breadtitle = 'Editing '.$crstype.' Contents';
5386: $helpitem = 'Docs_Adding_Course_Doc';
5387: } else {
5388: $breadtext .= ' (View-only mode)';
5389: $breadtitle = 'Viewing '.$crstype.' Contents';
5390: $helpitem = 'Docs_Viewing_Course_Doc';
5391: }
1.392 raeburn 5392: &Apache::lonhtmlcommon::add_breadcrumb({
1.484.2.67 raeburn 5393: href=>"/adm/coursedocs",text=>$breadtext});
1.446 www 5394: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.484.2.19 raeburn 5395: {'add_entries' => $addentries}
5396: )
1.392 raeburn 5397: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5398: .&Apache::lonhtmlcommon::breadcrumbs(
1.484.2.67 raeburn 5399: $breadtitle,
5400: $helpitem)
1.392 raeburn 5401: );
5402: }
1.364 bisitz 5403:
1.329 droeschl 5404: my %allfiles = ();
5405: my %codebase = ();
1.440 raeburn 5406: my ($upload_result,$upload_output,$uploadphase);
1.484.2.67 raeburn 5407: if ($canedit) {
1.329 droeschl 5408: if (($env{'form.uploaddoc.filename'}) &&
5409: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440 raeburn 5410: my $context = $1;
5411: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 5412: undef($hadchanges);
1.440 raeburn 5413: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
1.484.2.36 raeburn 5414: \%allfiles,\%codebase,$context,$crstype);
1.484.2.72.2. (raeburn 5415:): undef($navmap);
1.329 droeschl 5416: if ($hadchanges) {
5417: &mark_hash_old();
5418: }
1.440 raeburn 5419: $r->print($upload_output);
5420: } elsif ($env{'form.phase'} eq 'upload_embedded') {
5421: # Process file upload - phase two - upload embedded objects
5422: $uploadphase = 'check_embedded';
5423: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
5424: my $state = &embedded_form_elems($uploadphase,$primaryurl,
5425: $env{'form.newidx'});
5426: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5427: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5428: my ($destination,$dir_root) = &embedded_destination();
5429: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
5430: my $actionurl = '/adm/coursedocs';
5431: my ($result,$flag) =
5432: &Apache::loncommon::upload_embedded('coursedoc',$destination,
5433: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
5434: $actionurl);
5435: $r->print($result.&return_to_editor());
5436: } elsif ($env{'form.phase'} eq 'check_embedded') {
5437: # Process file upload - phase three - modify references in HTML file
5438: $uploadphase = 'modified_orightml';
5439: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5440: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5441: my ($destination,$dir_root) = &embedded_destination();
1.482 raeburn 5442: my $result =
5443: &Apache::loncommon::modify_html_refs('coursedoc',$destination,
5444: $docuname,$docudom,undef,
5445: $dir_root);
5446: $r->print($result.&return_to_editor());
1.476 raeburn 5447: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
5448: $uploadphase = 'decompress_phase_one';
5449: $r->print(&decompression_phase_one().
5450: &return_to_editor());
5451: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
5452: $uploadphase = 'decompress_phase_two';
5453: $r->print(&decompression_phase_two().
5454: &return_to_editor());
1.329 droeschl 5455: }
5456: }
5457:
1.484 raeburn 5458: if ($allowed && $toolsflag) {
5459: $r->print(&startContentScreen('tools'));
1.484.2.67 raeburn 5460: $r->print(&generate_admin_menu($crstype,$canedit));
1.484 raeburn 5461: $r->print(&endContentScreen());
5462: } elsif ((!$showdoc) && (!$uploadphase)) {
1.329 droeschl 5463: # -----------------------------------------------------------------------------
5464: my %lt=&Apache::lonlocal::texthash(
5465: 'copm' => 'All documents out of a published map into this folder',
1.484.2.12 raeburn 5466: 'upfi' => 'Upload File',
1.484.2.36 raeburn 5467: 'upld' => 'Upload Content',
1.329 droeschl 5468: 'srch' => 'Search',
5469: 'impo' => 'Import',
1.484.2.19 raeburn 5470: 'lnks' => 'Import from Stored Links',
1.484.2.13 raeburn 5471: 'impm' => 'Import from Assembled Map',
1.484.2.72.2. (raeburn 5472:): 'extr' => 'External Resource',
5473:): 'extt' => 'External Tool',
1.329 droeschl 5474: 'selm' => 'Select Map',
5475: 'load' => 'Load Map',
5476: 'newf' => 'New Folder',
5477: 'newp' => 'New Composite Page',
5478: 'syll' => 'Syllabus',
1.425 raeburn 5479: 'navc' => 'Table of Contents',
1.343 biermanm 5480: 'sipa' => 'Simple Course Page',
1.329 droeschl 5481: 'sipr' => 'Simple Problem',
1.484.2.27 raeburn 5482: 'webp' => 'Blank Web Page (editable)',
1.329 droeschl 5483: 'drbx' => 'Drop Box',
1.451 www 5484: 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336 schafran 5485: 'bull' => 'Discussion Board',
1.347 weissno 5486: 'mypi' => 'My Personal Information Page',
1.353 weissno 5487: 'grpo' => 'Group Portfolio',
1.329 droeschl 5488: 'rost' => 'Course Roster',
1.484.2.22 raeburn 5489: 'abou' => 'Personal Information Page for a User',
1.484.2.36 raeburn 5490: 'imsf' => 'IMS Upload',
5491: 'imsl' => 'Upload IMS package',
1.484.2.12 raeburn 5492: 'cms' => 'Origin of IMS package',
5493: 'se' => 'Select',
1.484.2.19 raeburn 5494: 'file' => 'File',
1.329 droeschl 5495: 'title' => 'Title',
5496: 'comment' => 'Comment',
1.403 raeburn 5497: 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.484.2.50 raeburn 5498: 'bb5' => 'Blackboard 5',
5499: 'bb6' => 'Blackboard 6',
5500: 'angel5' => 'ANGEL 5.5',
5501: 'webctce4' => 'WebCT 4 Campus Edition',
1.484.2.67 raeburn 5502: 'er' => 'Editing rights unavailable for your current role.',
1.484.2.50 raeburn 5503: );
1.329 droeschl 5504: # -----------------------------------------------------------------------------
1.484.2.64 raeburn 5505: # Calculate free quota space for a user or course.
5506: my $quotatype = 'unofficial';
5507: if ($crstype eq 'Community') {
5508: $quotatype = 'community';
5509: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
5510: $quotatype = 'official';
5511: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
5512: $quotatype = 'textbook';
5513: }
5514: my $disk_quota = &Apache::loncommon::get_user_quota($coursenum,$coursedom,
5515: 'course',$quotatype); # expressed in MB
5516: my $current_disk_usage = 0;
5517: foreach my $subdir ('docs','supplemental') {
5518: $current_disk_usage += &Apache::lonnet::diskusage($coursedom,$coursenum,
5519: "userfiles/$subdir",1); # expressed in kB
5520: }
5521: my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage);
5522: my $usage = $current_disk_usage/1024; # in MB
5523: my $quota = $disk_quota;
5524: my $percent;
5525: if ($disk_quota == 0) {
5526: $percent = 100.0;
5527: } else {
1.484.2.69 raeburn 5528: $percent = 100*($usage/$disk_quota);
1.484.2.64 raeburn 5529: }
5530: $usage = sprintf("%.2f",$usage);
5531: $quota = sprintf("%.2f",$quota);
5532: $percent = sprintf("%.0f",$percent);
5533: my $quotainfo = '<p>'.&mt('Currently using [_1] of the [_2] available.',
5534: $percent.'%',$quota.' MB').'</p>';
5535:
1.329 droeschl 5536: my $fileupload=(<<FIUP);
1.484.2.64 raeburn 5537: $quotainfo
1.329 droeschl 5538: $lt{'file'}:<br />
1.484.2.67 raeburn 5539: <input type="file" name="uploaddoc" size="40" $disabled />
1.329 droeschl 5540: FIUP
5541:
5542: my $checkbox=(<<CHBO);
5543: <!-- <label>$lt{'parse'}?
5544: <input type="checkbox" name="parserflag" />
5545: </label> -->
5546: <label>
1.484.2.67 raeburn 5547: <input type="checkbox" name="parserflag" checked="checked" $disabled /> $lt{'parse'}
1.329 droeschl 5548: </label>
5549: CHBO
1.484.2.12 raeburn 5550: my $imsfolder = $env{'form.folder'};
5551: if ($imsfolder eq '') {
1.484.2.19 raeburn 5552: $imsfolder = 'default';
1.484.2.12 raeburn 5553: }
5554: my $imspform=(<<IMSFORM);
5555: <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
5556: $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
5557: <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
1.484.2.19 raeburn 5558: <fieldset id="uploadimsform" style="display: none;">
1.484.2.12 raeburn 5559: <legend>$lt{'imsf'}</legend>
5560: $fileupload
5561: <br />
5562: <p>
1.484.2.19 raeburn 5563: $lt{'cms'}:
1.484.2.67 raeburn 5564: <select name="source" $disabled>
1.484.2.12 raeburn 5565: <option value="-1" selected="selected">$lt{'se'}</option>
1.484.2.50 raeburn 5566: <option value="bb5">$lt{'bb5'}</option>
5567: <option value="bb6">$lt{'bb6'}</option>
5568: <option value="angel5">$lt{'angel5'}</option>
5569: <option value="webctce4">$lt{'webctce4'}</option>
1.484.2.12 raeburn 5570: </select>
5571: <input type="hidden" name="folder" value="$imsfolder" />
5572: </p>
5573: <input type="hidden" name="phase" value="one" />
1.484.2.67 raeburn 5574: <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" $disabled />
1.484.2.12 raeburn 5575: </fieldset>
5576: </form>
5577: IMSFORM
5578:
1.484.2.19 raeburn 5579: my $fileuploadform=(<<FUFORM);
1.484.2.12 raeburn 5580: <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
5581: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
5582: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.484.2.19 raeburn 5583: <fieldset id="uploaddocform" style="display: none;">
1.484.2.12 raeburn 5584: <legend>$lt{'upfi'}</legend>
1.371 tempelho 5585: <input type="hidden" name="active" value="aa" />
1.329 droeschl 5586: $fileupload
5587: <br />
5588: $lt{'title'}:<br />
1.484.2.67 raeburn 5589: <input type="text" size="60" name="comment" $disabled />
1.484.2.17 raeburn 5590: $pathitem
1.329 droeschl 5591: <input type="hidden" name="cmd" value="upload_default" />
5592: <br />
1.458 raeburn 5593: <span class="LC_nobreak" style="float:left">
1.329 droeschl 5594: $checkbox
5595: </span>
1.484.2.12 raeburn 5596: <br clear="all" />
1.484.2.67 raeburn 5597: <input type="submit" value="$lt{'upld'}" $disabled />
1.484.2.12 raeburn 5598: </fieldset>
5599: </form>
1.383 tempelho 5600: FUFORM
1.329 droeschl 5601:
1.484.2.67 raeburn 5602: my $mapimportjs;
5603: if ($canedit) {
5604: $mapimportjs = "javascript:openbrowser('mapimportform','importmap','sequence,page','');";
5605: } else {
5606: $mapimportjs = "javascript:alert('".&js_escape($lt{'er'})."');";
5607: }
1.484.2.19 raeburn 5608: my $importpubform=(<<SEDFFORM);
5609: <a class="LC_menubuttons_link" href="javascript:toggleMap('map');">
1.484.2.13 raeburn 5610: $lt{'impm'}</a>$help{'Load_Map'}
1.484.2.19 raeburn 5611: <form action="/adm/coursedocs" method="post" name="mapimportform">
5612: <fieldset id="importmapform" style="display: none;">
1.484.2.13 raeburn 5613: <legend>$lt{'impm'}</legend>
1.484.2.19 raeburn 5614: <input type="hidden" name="active" value="bb" />
1.484.2.13 raeburn 5615: $lt{'copm'}<br />
5616: <span class="LC_nobreak">
1.484.2.19 raeburn 5617: <input type="text" name="importmap" size="40" value=""
1.484.2.67 raeburn 5618: onfocus="this.blur();$mapimportjs" $disabled />
5619: <a href="$mapimportjs">$lt{'selm'}</a></span><br />
5620: <input type="submit" name="loadmap" value="$lt{'load'}" $disabled />
1.484.2.13 raeburn 5621: </fieldset>
5622: </form>
5623:
1.383 tempelho 5624: SEDFFORM
1.484.2.67 raeburn 5625:
5626: my $fromstoredjs;
5627: if ($canedit) {
5628: $fromstoredjs = 'open_StoredLinks_Import()';
5629: } else {
5630: $fromstoredjs = "alert('".&js_escape($lt{'er'})."')";
5631: }
5632:
1.484.2.19 raeburn 5633: my @importpubforma = (
5634: { '<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 5635: { '<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 5636: { '<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 5637: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform }
5638: );
5639: $importpubform = &create_form_ul(&create_list_elements(@importpubforma));
5640: my $extresourcesform =
5641: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
1.484.2.67 raeburn 5642: $help{'Adding_External_Resource'},
1.484.2.72.2. (raeburn 5643:): undef,undef,undef,undef,undef,undef,$disabled);
5644:): my $exttoolform =
5645:): &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
5646:): $help{'Adding_External_Tool'},undef,
5647:): undef,'tool',$coursedom,$coursenum,
5648:): \%ltitools,$disabled);
1.329 droeschl 5649: if ($allowed) {
1.484.2.7 raeburn 5650: my $folder = $env{'form.folder'};
5651: if ($folder eq '') {
5652: $folder='default';
5653: }
1.484.2.67 raeburn 5654: if ($canedit) {
5655: my $output = &update_paste_buffer($coursenum,$coursedom,$folder);
5656: if ($output) {
5657: $r->print($output);
5658: }
1.484.2.30 raeburn 5659: }
1.337 ehlerst 5660: $r->print(<<HIDDENFORM);
5661: <form name="renameform" method="post" action="/adm/coursedocs">
5662: <input type="hidden" name="title" />
5663: <input type="hidden" name="cmd" />
5664: <input type="hidden" name="markcopy" />
5665: <input type="hidden" name="copyfolder" />
5666: $containertag
5667: </form>
1.484 raeburn 5668:
1.337 ehlerst 5669: HIDDENFORM
1.484.2.17 raeburn 5670: $r->print(&makesimpleeditform($pathitem)."\n".
5671: &makedocslogform($pathitem."\n".
1.484 raeburn 5672: '<input type="hidden" name="folder" value="'.
5673: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 5674: }
1.442 www 5675:
5676: # Generate the tabs
1.484.2.19 raeburn 5677: my ($mode,$needs_end);
1.472 raeburn 5678: if (($supplementalflag) && (!$allowed)) {
1.484.2.19 raeburn 5679: my @folders = split('&',$env{'form.folderpath'});
5680: unless (@folders > 2) {
5681: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
5682: $needs_end = 1;
5683: }
1.472 raeburn 5684: } else {
1.484 raeburn 5685: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484.2.19 raeburn 5686: $needs_end = 1;
1.472 raeburn 5687: }
1.443 www 5688:
1.442 www 5689: #
5690:
5691: my $savefolderpath;
5692:
1.395 raeburn 5693: if ($allowed) {
1.329 droeschl 5694: my $folder=$env{'form.folder'};
1.484.2.67 raeburn 5695: if ((($folder eq '') && (!$hiddentop)) || ($supplementalflag)) {
1.329 droeschl 5696: $folder='default';
1.356 tempelho 5697: $savefolderpath = $env{'form.folderpath'};
1.484.2.33 raeburn 5698: $env{'form.folderpath'}='default&'.&escape(&mt('Main Content'));
1.484.2.17 raeburn 5699: $pathitem = '<input type="hidden" name="folderpath" value="'.
1.329 droeschl 5700: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
5701: }
5702: my $postexec='';
5703: if ($folder eq 'default') {
1.372 bisitz 5704: $r->print('<script type="text/javascript">'."\n"
5705: .'// <![CDATA['."\n"
5706: .'this.window.name="loncapaclient";'."\n"
5707: .'// ]]>'."\n"
5708: .'</script>'."\n"
1.369 bisitz 5709: );
1.329 droeschl 5710: } else {
5711: #$postexec='self.close();';
5712: }
1.484.2.15 raeburn 5713: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
5714: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
1.329 droeschl 5715: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
5716:
5717: my $newnavform=(<<NNFORM);
5718: <form action="/adm/coursedocs" method="post" name="newnav">
1.484.2.43 raeburn 5719: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 5720: $pathitem
1.329 droeschl 5721: <input type="hidden" name="importdetail"
5722: value="$lt{'navc'}=/adm/navmaps" />
1.484.2.67 raeburn 5723: <a class="LC_menubuttons_link" href="javascript:makenew(document.newnav);">$lt{'navc'}</a>
1.329 droeschl 5724: $help{'Navigate_Content'}
5725: </form>
5726: NNFORM
5727: my $newsmppageform=(<<NSPFORM);
5728: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.484.2.43 raeburn 5729: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 5730: $pathitem
1.329 droeschl 5731: <input type="hidden" name="importdetail" value="" />
1.423 onken 5732: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 5733: $help{'Simple Page'}
1.329 droeschl 5734: </form>
5735: NSPFORM
5736:
5737: my $newsmpproblemform=(<<NSPROBFORM);
5738: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371 tempelho 5739: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 5740: $pathitem
1.329 droeschl 5741: <input type="hidden" name="importdetail" value="" />
1.423 onken 5742: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.484.2.44 raeburn 5743: $help{'Simple_Problem'}
1.329 droeschl 5744: </form>
5745:
5746: NSPROBFORM
5747:
5748: my $newdropboxform=(<<NDBFORM);
5749: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.371 tempelho 5750: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 5751: $pathitem
1.329 droeschl 5752: <input type="hidden" name="importdetail" value="" />
1.423 onken 5753: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.484.2.36 raeburn 5754: $help{'Dropbox'}
1.344 bisitz 5755: </form>
1.329 droeschl 5756: NDBFORM
5757:
5758: my $newexuploadform=(<<NEXUFORM);
5759: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.371 tempelho 5760: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 5761: $pathitem
1.329 droeschl 5762: <input type="hidden" name="importdetail" value="" />
1.423 onken 5763: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 5764: $help{'Score_Upload_Form'}
5765: </form>
5766: NEXUFORM
5767:
5768: my $newbulform=(<<NBFORM);
5769: <form action="/adm/coursedocs" method="post" name="newbul">
1.484.2.43 raeburn 5770: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5771: $pathitem
1.329 droeschl 5772: <input type="hidden" name="importdetail" value="" />
1.423 onken 5773: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 5774: $help{'Bulletin Board'}
5775: </form>
5776: NBFORM
5777:
5778: my $newaboutmeform=(<<NAMFORM);
5779: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.484.2.43 raeburn 5780: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5781: $pathitem
1.329 droeschl 5782: <input type="hidden" name="importdetail"
5783: value="$plainname=/adm/$udom/$uname/aboutme" />
1.484.2.67 raeburn 5784: <a class="LC_menubuttons_link" href="javascript:makenew(document.newaboutme);">$lt{'mypi'}</a>
1.347 weissno 5785: $help{'My Personal Information Page'}
1.329 droeschl 5786: </form>
5787: NAMFORM
5788:
5789: my $newaboutsomeoneform=(<<NASOFORM);
5790: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.484.2.43 raeburn 5791: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5792: $pathitem
1.329 droeschl 5793: <input type="hidden" name="importdetail" value="" />
1.423 onken 5794: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 5795: </form>
5796: NASOFORM
5797:
5798: my $newrosterform=(<<NROSTFORM);
5799: <form action="/adm/coursedocs" method="post" name="newroster">
1.484.2.43 raeburn 5800: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5801: $pathitem
1.329 droeschl 5802: <input type="hidden" name="importdetail"
5803: value="$lt{'rost'}=/adm/viewclasslist" />
1.484.2.67 raeburn 5804: <a class="LC_menubuttons_link" href="javascript:makenew(document.newroster);">$lt{'rost'}</a>
1.484.2.37 raeburn 5805: $help{'Course_Roster'}
1.329 droeschl 5806: </form>
5807: NROSTFORM
5808:
1.484.2.27 raeburn 5809: my $newwebpage;
5810: if ($folder =~ /^default_?(\d*)$/) {
5811: $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
5812: if ($1) {
5813: $newwebpage .= $1;
5814: } else {
5815: $newwebpage .= 'default';
5816: }
5817: $newwebpage .= '/new.html';
5818: }
5819: my $newwebpageform =(<<NWEBFORM);
5820: <form action="/adm/coursedocs" method="post" name="newwebpage">
1.484.2.43 raeburn 5821: <input type="hidden" name="active" value="ee" />
1.484.2.27 raeburn 5822: $pathitem
5823: <input type="hidden" name="importdetail" value="$newwebpage" />
5824: <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
1.484.2.36 raeburn 5825: $help{'Web_Page'}
1.484.2.27 raeburn 5826: </form>
5827: NWEBFORM
1.484.2.30 raeburn 5828:
1.484.2.27 raeburn 5829:
1.342 ehlerst 5830: my $specialdocumentsform;
1.383 tempelho 5831: my @specialdocumentsforma;
1.451 www 5832: my $gradingform;
5833: my @gradingforma;
5834: my $communityform;
5835: my @communityforma;
1.351 ehlerst 5836: my $newfolderform;
1.390 tempelho 5837: my $newfolderb;
1.342 ehlerst 5838:
1.451 www 5839: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 5840:
1.329 droeschl 5841: my $newpageform=(<<NPFORM);
5842: <form action="/adm/coursedocs" method="post" name="newpage">
5843: <input type="hidden" name="folderpath" value="$path" />
5844: <input type="hidden" name="importdetail" value="" />
1.484.2.43 raeburn 5845: <input type="hidden" name="active" value="ee" />
1.423 onken 5846: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 5847: $help{'Adding_Pages'}
1.329 droeschl 5848: </form>
5849: NPFORM
1.390 tempelho 5850:
5851:
1.351 ehlerst 5852: $newfolderform=(<<NFFORM);
1.329 droeschl 5853: <form action="/adm/coursedocs" method="post" name="newfolder">
1.484.2.19 raeburn 5854: $pathitem
1.329 droeschl 5855: <input type="hidden" name="importdetail" value="" />
1.484.2.43 raeburn 5856: <input type="hidden" name="active" value="" />
1.422 onken 5857: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 5858: </form>
5859: NFFORM
5860:
5861: my $newsylform=(<<NSYLFORM);
5862: <form action="/adm/coursedocs" method="post" name="newsyl">
1.484.2.43 raeburn 5863: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 5864: $pathitem
1.329 droeschl 5865: <input type="hidden" name="importdetail"
5866: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.484.2.67 raeburn 5867: <a class="LC_menubuttons_link" href="javascript:makenew(document.newsyl);">$lt{'syll'}</a>
1.329 droeschl 5868: $help{'Syllabus'}
1.383 tempelho 5869:
1.329 droeschl 5870: </form>
5871: NSYLFORM
1.364 bisitz 5872:
1.329 droeschl 5873: my $newgroupfileform=(<<NGFFORM);
5874: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.484.2.43 raeburn 5875: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5876: $pathitem
1.329 droeschl 5877: <input type="hidden" name="importdetail"
5878: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.484.2.67 raeburn 5879: <a class="LC_menubuttons_link" href="javascript:makenew(document.newgroupfiles);">$lt{'grpo'}</a>
1.353 weissno 5880: $help{'Group Portfolio'}
1.329 droeschl 5881: </form>
5882: NGFFORM
1.383 tempelho 5883: @specialdocumentsforma=(
1.421 onken 5884: {'<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 5885: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.newsyl);" />'=>$newsylform},
5886: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="javascript:makenew(document.newnav);" />'=>$newnavform},
1.451 www 5887: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
1.484.2.27 raeburn 5888: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
1.451 www 5889: );
5890: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
5891:
1.434 raeburn 5892:
5893: my @importdoc = (
1.484.2.19 raeburn 5894: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform}
5895: );
1.484.2.72.2. (raeburn 5896:): if (keys(%ltitools)) {
5897:): push(@importdoc,
5898:): {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="toggleUpload(\'tool\');" />'=>$exttoolform},
5899:): );
5900:): }
1.484.2.19 raeburn 5901: unless ($container eq 'page') {
5902: push(@importdoc,
5903: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform}
5904: );
5905: }
5906: push(@importdoc,
1.484.2.38 raeburn 5907: {'<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 5908: );
1.484.2.12 raeburn 5909: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
1.434 raeburn 5910:
1.451 www 5911: @gradingforma=(
5912: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
5913: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
5914: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
5915:
5916: );
5917: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
5918:
5919: @communityforma=(
5920: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
5921: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
5922: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
1.484.2.67 raeburn 5923: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="javascript:makenew(document.newroster);" />'=>$newrosterform},
5924: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="javascript:makenew(document.newgroupfiles);" />'=>$newgroupfileform},
1.451 www 5925: );
5926: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 5927:
1.330 tempelho 5928: my %orderhash = (
1.484.2.36 raeburn 5929: 'aa' => ['Upload',$fileuploadform],
5930: 'bb' => ['Import',$importpubform],
5931: 'cc' => ['Grading',$gradingform],
1.330 tempelho 5932: );
1.484.2.19 raeburn 5933: unless ($container eq 'page') {
1.434 raeburn 5934: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.484 raeburn 5935: $orderhash{'dd'} = ['Collaboration',$communityform];
1.484.2.36 raeburn 5936: $orderhash{'ee'} = ['Other',$specialdocumentsform];
1.434 raeburn 5937: }
5938:
1.341 ehlerst 5939: $hadchanges=0;
1.484 raeburn 5940: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 5941: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.67 raeburn 5942: $supplementalflag,\%orderhash,$iconpath,$pathitem,
1.484.2.72.2. (raeburn 5943:): \%ltitools,$canedit,\$navmap,$hiddentop);
1.484.2.67 raeburn 5944: undef($navmap);
1.443 www 5945: if ($error) {
5946: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
5947: }
5948: if ($hadchanges) {
1.484.2.72.2. (raeburn 5949:): unless (&is_hash_old()) {
5950:): &mark_hash_old();
5951:): }
1.443 www 5952: }
5953: &changewarning($r,'');
5954: }
1.458 raeburn 5955: }
1.442 www 5956:
1.443 www 5957: # Supplemental documents start here
5958:
1.329 droeschl 5959: my $folder=$env{'form.folder'};
1.443 www 5960: unless ($supplementalflag) {
1.329 droeschl 5961: $folder='supplemental';
5962: }
5963: if ($folder =~ /^supplemental$/ &&
5964: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 5965: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 5966: } elsif ($allowed) {
1.356 tempelho 5967: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 5968: }
1.484.2.17 raeburn 5969: $pathitem = '<input type="hidden" name="folderpath" value="'.
5970: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.329 droeschl 5971: if ($allowed) {
5972: my $folderseq=
1.484.2.15 raeburn 5973: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
1.329 droeschl 5974:
5975: my $supupdocform=(<<SUPDOCFORM);
1.484.2.12 raeburn 5976: <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
5977: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
1.383 tempelho 5978: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.484.2.19 raeburn 5979: <fieldset id="uploadsuppdocform" style="display: none;">
1.484.2.12 raeburn 5980: <legend>$lt{'upfi'}</legend>
1.371 tempelho 5981: <input type="hidden" name="active" value="ee" />
1.329 droeschl 5982: $fileupload
5983: <br />
5984: <br />
5985: <span class="LC_nobreak">
5986: $checkbox
5987: </span>
5988: <br /><br />
5989: $lt{'comment'}:<br />
1.383 tempelho 5990: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 5991: <br />
1.484.2.19 raeburn 5992: $pathitem
1.329 droeschl 5993: <input type="hidden" name="cmd" value="upload_supplemental" />
1.484.2.12 raeburn 5994: <input type='submit' value="$lt{'upld'}" />
5995: </form>
1.484.2.19 raeburn 5996: SUPDOCFORM
1.329 droeschl 5997:
5998: my $supnewfolderform=(<<SNFFORM);
5999: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.484.2.43 raeburn 6000: <input type="hidden" name="active" value="" />
1.484.2.17 raeburn 6001: $pathitem
1.329 droeschl 6002: <input type="hidden" name="importdetail" value="" />
1.423 onken 6003: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 6004: $help{'Adding_Folders'}
1.329 droeschl 6005: </form>
6006: SNFFORM
1.383 tempelho 6007:
1.484.2.19 raeburn 6008: my $supextform =
6009: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
1.484.2.67 raeburn 6010: $help{'Adding_External_Resource'},
1.484.2.72.2. (raeburn 6011:): undef,undef,undef,undef,undef,undef,
6012:): $disabled);
6013:): my $supexttoolform =
6014:): &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
6015:): $help{'Adding_External_Tool'},
6016:): undef,undef,'tool',$coursedom,
6017:): $coursenum,\%ltitools,$disabled);
1.329 droeschl 6018: my $supnewsylform=(<<SNSFORM);
6019: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 6020: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 6021: $pathitem
1.329 droeschl 6022: <input type="hidden" name="importdetail"
6023: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.484.2.67 raeburn 6024: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewsyl);">$lt{'syll'}</a>
1.329 droeschl 6025: $help{'Syllabus'}
6026: </form>
6027: SNSFORM
6028:
6029: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 6030: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 6031: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 6032: $pathitem
1.329 droeschl 6033: <input type="hidden" name="importdetail"
6034: value="$plainname=/adm/$udom/$uname/aboutme" />
1.484.2.67 raeburn 6035: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewaboutme);">$lt{'mypi'}</a>
1.347 weissno 6036: $help{'My Personal Information Page'}
1.329 droeschl 6037: </form>
6038: SNAMFORM
6039:
1.484.2.27 raeburn 6040: my $supwebpage;
6041: if ($folder =~ /^supplemental_?(\d*)$/) {
6042: $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
6043: if ($1) {
6044: $supwebpage .= $1;
6045: } else {
6046: $supwebpage .= 'default';
6047: }
6048: $supwebpage .= '/new.html';
6049: }
6050: my $supwebpageform =(<<SWEBFORM);
6051: <form action="/adm/coursedocs" method="post" name="supwebpage">
6052: <input type="hidden" name="active" value="cc" />
6053: $pathitem
6054: <input type="hidden" name="importdetail" value="$supwebpage" />
6055: <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
1.484.2.36 raeburn 6056: $help{'Web_Page'}
1.484.2.27 raeburn 6057: </form>
6058: SWEBFORM
6059:
1.333 muellerd 6060:
1.383 tempelho 6061: my @specialdocs = (
1.484.2.67 raeburn 6062: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.supnewsyl);" />'
1.417 droeschl 6063: =>$supnewsylform},
1.484.2.67 raeburn 6064: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makenew(document.supnewaboutme);" />'
1.417 droeschl 6065: =>$supnewaboutmeform},
1.484.2.27 raeburn 6066: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
6067:
1.383 tempelho 6068: );
1.417 droeschl 6069: my @supimportdoc = (
1.484.2.19 raeburn 6070: {'<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 6071:): =>$supextform});
6072:): if (keys(%ltitools)) {
6073:): push(@supimportdoc,
6074:): {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="javascript:toggleUpload(\'supptool\')" />'
6075:): =>$supexttoolform});
6076:): }
6077:): push(@supimportdoc,
1.484.2.12 raeburn 6078: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
6079: =>$supupdocform},
1.484.2.72.2. (raeburn 6080:): );
1.484.2.19 raeburn 6081:
1.484.2.12 raeburn 6082: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
1.333 muellerd 6083: my %suporderhash = (
1.390 tempelho 6084: '00' => ['Supnewfolder', $supnewfolderform],
1.484.2.36 raeburn 6085: 'ee' => ['Upload',$supupdocform],
6086: 'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 6087: );
1.443 www 6088: if ($supplementalflag) {
1.458 raeburn 6089: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.67 raeburn 6090: $supplementalflag,\%suporderhash,$iconpath,$pathitem,
1.484.2.72.2. (raeburn 6091:): \%ltitools,$canedit);
1.443 www 6092: if ($error) {
6093: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.484.2.37 raeburn 6094: } else {
6095: if ($suppchanges) {
6096: my %servers = &Apache::lonnet::internet_dom_servers($coursedom);
6097: my @ids=&Apache::lonnet::current_machine_ids();
6098: foreach my $server (keys(%servers)) {
6099: next if (grep(/^\Q$server\E$/,@ids));
6100: my $hashid=$coursenum.':'.$coursedom;
1.484.2.42 raeburn 6101: my $cachekey = &escape('suppcount').':'.&escape($hashid);
6102: &Apache::lonnet::remote_devalidate_cache($server,[$cachekey]);
1.484.2.37 raeburn 6103: }
6104: &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
6105: undef($suppchanges);
6106: }
1.443 www 6107: }
1.393 raeburn 6108: }
1.443 www 6109: } elsif ($supplementalflag) {
1.458 raeburn 6110: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.17 raeburn 6111: $supplementalflag,'',$iconpath,$pathitem);
1.393 raeburn 6112: if ($error) {
6113: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 6114: }
1.393 raeburn 6115: }
1.389 tempelho 6116:
1.484.2.19 raeburn 6117: if ($needs_end) {
6118: $r->print(&endContentScreen());
6119: }
1.383 tempelho 6120:
1.329 droeschl 6121: if ($allowed) {
6122: $r->print('
6123: <form method="post" name="extimport" action="/adm/coursedocs">
6124: <input type="hidden" name="title" />
6125: <input type="hidden" name="url" />
6126: <input type="hidden" name="useform" />
6127: <input type="hidden" name="residx" />
6128: </form>');
6129: }
1.484 raeburn 6130: } elsif ($showdoc) {
1.329 droeschl 6131: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 6132: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.484.2.10 raeburn 6133: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 6134: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 6135: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 6136: }
6137: }
6138: $r->print(&Apache::loncommon::end_page());
6139: return OK;
1.364 bisitz 6140: }
1.329 droeschl 6141:
1.440 raeburn 6142: sub embedded_form_elems {
6143: my ($phase,$primaryurl,$newidx) = @_;
6144: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.484.2.72.2. (raeburn 6145:): $newidx =~s /\D+//g;
1.440 raeburn 6146: return <<STATE;
6147: <input type="hidden" name="folderpath" value="$folderpath" />
6148: <input type="hidden" name="cmd" value="upload_embedded" />
6149: <input type="hidden" name="newidx" value="$newidx" />
6150: <input type="hidden" name="phase" value="$phase" />
6151: <input type="hidden" name="primaryurl" value="$primaryurl" />
6152: STATE
6153: }
6154:
6155: sub embedded_destination {
6156: my $folder=$env{'form.folder'};
6157: my $destination = 'docs/';
6158: if ($folder =~ /^supplemental/) {
6159: $destination = 'supplemental/';
6160: }
6161: if (($folder eq 'default') || ($folder eq 'supplemental')) {
6162: $destination .= 'default/';
6163: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
6164: $destination .= $2.'/';
6165: }
1.484.2.72.2. (raeburn 6166:): my $newidx = $env{'form.newidx'};
6167:): $newidx =~s /\D+//g;
6168:): if ($newidx) {
6169:): $destination .= $newidx;
6170:): }
1.440 raeburn 6171: my $dir_root = '/userfiles';
6172: return ($destination,$dir_root);
6173: }
6174:
6175: sub return_to_editor {
6176: my $actionurl = '/adm/coursedocs';
6177: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
6178: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
6179: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
6180: '</a></p>';
6181: }
6182:
1.476 raeburn 6183: sub decompression_info {
6184: my ($destination,$dir_root) = &embedded_destination();
6185: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
6186: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
6187: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
6188: my $container='sequence';
1.480 raeburn 6189: my ($pathitem,$hiddenelem);
1.484.2.54 raeburn 6190: my @hiddens = ('newidx','comment','position','folderpath','archiveurl');
1.484.2.19 raeburn 6191: if ($env{'form.folderpath'} =~ /\:1$/) {
1.476 raeburn 6192: $container='page';
6193: }
1.480 raeburn 6194: unshift(@hiddens,$pathitem);
6195: foreach my $item (@hiddens) {
1.484.2.72.2. (raeburn 6196:): if ($item eq 'newidx') {
6197:): next if ($env{'form.'.$item} =~ /\D/);
6198:): }
1.480 raeburn 6199: if ($env{'form.'.$item}) {
6200: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
1.484.2.54 raeburn 6201: &HTML::Entities::encode($env{'form.'.$item},'<>&"').'" />'."\n";
1.480 raeburn 6202: }
1.477 raeburn 6203: }
1.476 raeburn 6204: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
6205: $hiddenelem);
6206: }
6207:
6208: sub decompression_phase_one {
6209: my ($dir,$file,$warning,$error,$output);
6210: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
6211: &decompression_info();
1.484.2.7 raeburn 6212: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 6213: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
6214: } else {
6215: my $file = $1;
1.481 raeburn 6216: $output =
6217: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
6218: $destination,$dir_root,
6219: $hiddenelem);
6220: if ($env{'form.autoextract_camtasia'}) {
6221: $output .= &remove_archive($docudom,$docuname,$container);
6222: }
1.476 raeburn 6223: }
6224: if ($error) {
6225: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
6226: $error.'</p>'."\n";
6227: }
6228: if ($warning) {
6229: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
6230: }
6231: return $output;
6232: }
6233:
6234: sub decompression_phase_two {
6235: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
6236: &decompression_info();
1.481 raeburn 6237: my $output;
1.480 raeburn 6238: if ($env{'form.archivedelete'}) {
1.481 raeburn 6239: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 6240: }
6241: $output .=
1.481 raeburn 6242: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 6243: $destination,$dir_root,$hiddenelem);
6244: return $output;
6245: }
6246:
1.480 raeburn 6247: sub remove_archive {
6248: my ($docudom,$docuname,$container) = @_;
6249: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 6250: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 6251: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
6252: if ($fatal) {
6253: if ($container eq 'page') {
6254: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
6255: } else {
6256: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
6257: }
1.484.2.54 raeburn 6258: $delwarning .= ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 6259: } else {
6260: my $currcmd = $env{'form.cmd'};
6261: my $position = $env{'form.position'};
1.484.2.54 raeburn 6262: my $archiveidx = $position;
6263: if ($position > 0) {
6264: if (($env{'form.autoextract_camtasia'}) && (scalar(@LONCAPA::map::order) == 2)) {
6265: $archiveidx = $position-1;
6266: }
6267: $env{'form.cmd'} = 'remove_'.$archiveidx;
6268: my ($title,$url,@rrest) =
6269: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$archiveidx]]);
6270: if ($url eq $env{'form.archiveurl'}) {
6271: if (&handle_edit_cmd($docuname,$docudom)) {
6272: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
6273: if ($fatal) {
6274: if ($container eq 'page') {
6275: $delwarning = &mt('An error occurred updating the contents of the current page.');
6276: } else {
6277: $delwarning = &mt('An error occurred updating the contents of the current folder.');
6278: }
1.480 raeburn 6279: } else {
1.484.2.54 raeburn 6280: $delresult = &mt('Archive file removed.');
1.480 raeburn 6281: }
6282: }
1.484.2.54 raeburn 6283: } else {
6284: $delwarning .= &mt('Archive file had unexpected item number in folder.').
6285: ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 6286: }
6287: }
6288: $env{'form.cmd'} = $currcmd;
6289: }
6290: if ($delwarning) {
6291: $output = '<p class="LC_warning">'.
6292: $delwarning.
6293: '</p>';
6294: }
6295: if ($delresult) {
6296: $output .= '<p class="LC_info">'.
6297: $delresult.
6298: '</p>';
6299: }
1.481 raeburn 6300: return $output;
1.480 raeburn 6301: }
6302:
1.484 raeburn 6303: sub generate_admin_menu {
1.484.2.67 raeburn 6304: my ($crstype,$canedit) = @_;
1.484 raeburn 6305: my $lc_crstype = lc($crstype);
6306: my ($home,$other,%outhash)=&authorhosts();
1.484.2.43 raeburn 6307: my %lt= ( # do not translate here
1.484 raeburn 6308: 'vc' => 'Verify Content',
6309: 'cv' => 'Check/Set Resource Versions',
6310: 'ls' => 'List Resource Identifiers',
1.484.2.72.2. (raeburn 6311:): 'ct' => 'Display/Set Shortened URLs for Deep-linking',
1.484 raeburn 6312: 'imse' => 'Export contents to IMS Archive',
1.484.2.43 raeburn 6313: 'dcd' => "Copy $crstype Content to Authoring Space",
6314: );
1.484 raeburn 6315: my ($candump,$dumpurl);
6316: if ($home + $other > 0) {
6317: $candump = 'F';
6318: if ($home) {
6319: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
6320: } else {
6321: my @hosts;
6322: foreach my $aurole (keys(%outhash)) {
6323: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
6324: push(@hosts,$outhash{$aurole});
1.484.2.30 raeburn 6325: }
1.484 raeburn 6326: }
6327: if (@hosts == 1) {
6328: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
6329: '&role='.
6330: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
6331: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
6332: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
6333: } else {
6334: $dumpurl = "javascript:choose_switchserver_window()";
6335: }
6336: }
6337: }
6338: my @menu=
6339: ({ categorytitle=>'Administration',
6340: items =>[
6341: { linktext => $lt{'vc'},
6342: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
6343: permission => 'F',
1.484.2.44 raeburn 6344: help => 'Docs_Verify_Content',
1.484 raeburn 6345: icon => 'verify.png',
6346: linktitle => 'Verify contents can be retrieved/rendered',
6347: },
6348: { linktext => $lt{'cv'},
6349: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
6350: permission => 'F',
1.484.2.44 raeburn 6351: help => 'Docs_Check_Resource_Versions',
1.484 raeburn 6352: icon => 'resversion.png',
6353: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
6354: },
6355: { linktext => $lt{'ls'},
6356: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
6357: permission => 'F',
6358: #help => '',
6359: icon => 'symbs.png',
6360: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
6361: },
1.484.2.72.2. (raeburn 6362:): { linktext => $lt{'ct'},
6363:): url => "javascript:injectData(document.courseverify,'dummy','shorturls','$lt{'ct'}')",
6364:): permission => 'F',
6365:): help => 'Docs_Short_URLs',
6366:): icon => 'shorturls.png',
6367:): linktitle => "Set shortened URLs for a resource or folder in your $lc_crstype for use in deep-linking"
6368:): },
1.484 raeburn 6369: ]
1.484.2.67 raeburn 6370: });
6371: if ($canedit) {
6372: push(@menu,
1.484 raeburn 6373: { categorytitle=>'Export',
6374: items =>[
6375: { linktext => $lt{'imse'},
6376: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
6377: permission => 'F',
6378: help => 'Docs_Export_Course_Docs',
6379: icon => 'imsexport.png',
6380: linktitle => $lt{'imse'},
6381: },
6382: { linktext => $lt{'dcd'},
6383: url => $dumpurl,
6384: permission => $candump,
1.484.2.44 raeburn 6385: help => 'Docs_Dump_Course_Docs',
1.484 raeburn 6386: icon => 'dump.png',
6387: linktitle => $lt{'dcd'},
6388: },
6389: ]
6390: });
1.484.2.67 raeburn 6391: }
1.484 raeburn 6392: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
6393: '<input type="hidden" id="dummy" />'."\n".
6394: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
6395: '</form>';
1.329 droeschl 6396: }
6397:
6398: sub generate_edit_table {
1.484.2.30 raeburn 6399: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile,
1.484.2.67 raeburn 6400: $need_save,$copyfolder,$canedit) = @_;
1.406 raeburn 6401: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 6402: my %orderhash = %{$orderhash_ref};
1.484.2.67 raeburn 6403: my ($form, $activetab, $active, $disabled);
1.484.2.43 raeburn 6404: if (($env{'form.active'} ne '') && ($env{'form.active'} ne '00')) {
1.371 tempelho 6405: $activetab = $env{'form.active'};
6406: }
1.484.2.67 raeburn 6407: unless ($canedit) {
6408: $disabled = ' disabled="disabled"';
6409: }
1.472 raeburn 6410: my $backicon = $iconpath.'clickhere.gif';
1.484.2.21 raeburn 6411: my $backtext = &mt('Exit Editor');
1.458 raeburn 6412: $form = '<div class="LC_Box" style="margin:0;">'.
1.484.2.19 raeburn 6413: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
6414: '<li class="goback">'.
1.484.2.32 raeburn 6415: '<a href="javascript:toContents('."'$jumpto'".');">'.
1.484.2.19 raeburn 6416: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
6417: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
6418: '<li>'.
6419: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
6420: &mt('Undo Delete').'</a></li>'."\n";
1.484.2.7 raeburn 6421: if ($env{'form.docslog'}) {
6422: $form .= '<li class="active">';
6423: } else {
6424: $form .= '<li>';
6425: }
6426: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
6427: &mt('History').'</a></li>'."\n";
6428: if ($env{'form.docslog'}) {
6429: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
6430: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 6431: }
1.458 raeburn 6432: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 6433: if($name ne '00'){
1.371 tempelho 6434: if($activetab eq '' || $activetab ne $name){
6435: $active = '';
6436: }elsif($activetab eq $name){
6437: $active = 'class="active"';
6438: }
1.458 raeburn 6439: $form .= '<li style="float:right" '.$active
1.484 raeburn 6440: .' 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 6441: } else {
1.484.2.43 raeburn 6442: $form .= '<li style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 6443:
6444: }
1.329 droeschl 6445: }
1.484 raeburn 6446: $form .= '</ul>'."\n";
6447: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 6448:
6449: if ($to_show ne '') {
1.484.2.30 raeburn 6450: my $saveform;
6451: if ($need_save) {
6452: my $button = &mt('Make changes');
6453: my $path;
6454: if ($env{'form.folderpath'}) {
6455: $path =
6456: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
6457: }
6458: $saveform = <<"END";
6459: <div id="multisave" style="display:none; clear:both;" >
6460: <form name="saveactions" method="post" action="/adm/coursedocs" onsubmit="return checkSubmits();">
6461: <input type="hidden" name="folderpath" value="$path" />
6462: <input type="hidden" name="symb" value="$env{'form.symb'}" />
6463: <input type="hidden" name="allhiddenresource" value="" />
6464: <input type="hidden" name="allencrypturl" value="" />
6465: <input type="hidden" name="allrandompick" value="" />
6466: <input type="hidden" name="allrandomorder" value="" />
6467: <input type="hidden" name="changeparms" value="" />
6468: <input type="hidden" name="multiremove" value="" />
6469: <input type="hidden" name="multicut" value="" />
6470: <input type="hidden" name="multicopy" value="" />
6471: <input type="hidden" name="multichange" value="" />
6472: <input type="hidden" name="copyfolder" value="$copyfolder" />
1.484.2.67 raeburn 6473: <input type="submit" name="savemultiples" value="$button" $disabled />
1.484.2.30 raeburn 6474: </form>
6475: </div>
6476: END
6477: }
6478: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'.$saveform."\n";
1.458 raeburn 6479: }
1.363 ehlerst 6480: foreach my $field (keys(%orderhash)){
1.390 tempelho 6481: if($field ne '00'){
1.422 onken 6482: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 6483: $active = 'style="display: none;float:left"';
1.422 onken 6484: }elsif($activetab eq $field){
1.458 raeburn 6485: $active = 'style="display:block;float:left"';
1.422 onken 6486: }
6487: $form .= '<div id="'.$field.$tid.'"'
6488: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 6489: .'</div>'."\n";
1.363 ehlerst 6490: }
6491: }
1.484 raeburn 6492: unless ($env{'form.docslog'}) {
6493: $form .= '</div></div>'."\n";
6494: }
1.329 droeschl 6495: return $form;
6496: }
6497:
6498: sub editing_js {
1.484.2.72.2. (raeburn 6499:): my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,$canedit,$navmapref) = @_;
1.484.2.61 raeburn 6500: my %js_lt = &Apache::lonlocal::texthash(
1.329 droeschl 6501: p_mnf => 'Name of New Folder',
6502: t_mnf => 'New Folder',
6503: p_mnp => 'Name of New Page',
6504: t_mnp => 'New Page',
1.451 www 6505: p_mxu => 'Title for the External Score',
1.349 biermanm 6506: p_msp => 'Name of Simple Course Page',
1.329 droeschl 6507: p_msb => 'Title for the Problem',
6508: p_mdb => 'Title for the Drop Box',
1.336 schafran 6509: p_mbb => 'Title for the Discussion Board',
1.484.2.27 raeburn 6510: p_mwp => 'Title for Web Page',
1.348 weissno 6511: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 6512: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 6513: p_mab_alrt1 => 'Not a valid user:domain',
6514: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
6515: p_chn => 'New Title',
6516: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
1.484.2.63 raeburn 6517: p_rmr2a => 'Remove',
6518: p_rmr2b => '?',
6519: p_rmr3a => 'Remove those',
6520: p_rmr3b => 'items?',
6521: p_rmr4 => 'WARNING: Removing a resource uploaded to a course cannot be undone via "Undo Delete".',
6522: p_rmr5 => 'Push "Cancel" and then use "Cut" instead if you might need to undo this change.',
1.329 droeschl 6523: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
6524: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
1.484.2.63 raeburn 6525: p_ctr2a => 'Cut',
6526: p_ctr2b => '?',
6527: p_ctr3a => 'Cut those',
6528: p_ctr3b => 'items?',
1.478 raeburn 6529: rpck => 'Enter number to pick (e.g., 3)',
1.484.2.12 raeburn 6530: imsfile => 'You must choose an IMS package for import',
6531: imscms => 'You must select which Course Management System was the source of the IMS package',
6532: invurl => 'Invalid URL',
6533: titbl => 'Title is blank',
1.484.2.30 raeburn 6534: more => '(More ...)',
6535: less => '(Less ...)',
6536: noor => 'No actions selected or changes to settings specified.',
6537: noch => 'No changes to settings specified.',
6538: noac => 'No actions selected.',
1.484.2.67 raeburn 6539: edri => 'Editing rights unavailable for your current role.',
1.329 droeschl 6540: );
6541:
1.484.2.61 raeburn 6542: &js_escape(\%js_lt);
1.433 raeburn 6543: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 6544: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
6545: my $main_container_page;
1.484.2.19 raeburn 6546: if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) {
6547: $main_container_page = 1;
1.434 raeburn 6548: }
1.484.2.67 raeburn 6549: my $backtourl;
6550: my $toplevelmain = &escape(&default_folderpath($coursenum,$coursedom,$navmapref));
1.446 www 6551: my $toplevelsupp = &supplemental_base();
1.433 raeburn 6552:
1.484.2.21 raeburn 6553: if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
6554: my $caller = $1;
6555: if ($caller =~ /^supplemental/) {
6556: $backtourl = '/adm/supplemental?folderpath='.&escape($caller);
6557: } else {
6558: my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
6559: $res = &Apache::lonnet::clutter($res);
6560: if (&Apache::lonnet::is_on_map($res)) {
1.484.2.66 raeburn 6561: my ($url,$anchor);
6562: if ($res =~ /^([^#]+)#([^#]+)$/) {
6563: $url = $1;
6564: $anchor = $2;
6565: if (($caller =~ m{^([^#]+)\Q#$anchor\E$})) {
6566: $caller = $1.&escape('#').$anchor;
6567: }
1.484.2.67 raeburn 6568: } else {
6569: $url = $res;
1.484.2.66 raeburn 6570: }
1.484.2.72.2. (raeburn 6571:): $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"');
6572:): if ($backtourl =~ m{^\Q/uploaded/$coursedom/$coursenum/\Edefault_\d+\.sequence$}) {
6573:): $backtourl .= '?navmap=1';
6574:): } else {
6575:): $backtourl .= '?symb='.
6576:): &HTML::Entities::encode($caller,'<>&"');
6577:): }
1.484.2.66 raeburn 6578: if ($anchor ne '') {
6579: $backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"');
6580: }
1.484.2.57 raeburn 6581: $backtourl = &Apache::loncommon::escape_single($backtourl);
1.484.2.31 raeburn 6582: } else {
6583: $backtourl = '/adm/navmaps';
1.484.2.21 raeburn 6584: }
6585: }
6586: } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
6587: $backtourl = '/adm/menu';
6588: } elsif ($supplementalflag) {
1.472 raeburn 6589: $backtourl = '/adm/supplemental';
1.484.2.21 raeburn 6590: } else {
6591: $backtourl = '/adm/navmaps';
1.472 raeburn 6592: }
6593:
1.484.2.19 raeburn 6594: my $fieldsets = "'ext','doc'";
1.484.2.72.2. (raeburn 6595:): if ($posslti) {
6596:): $fieldsets .= ",'tool'";
6597:): }
1.484.2.19 raeburn 6598: unless ($main_container_page) {
6599: $fieldsets .=",'ims'";
6600: }
1.484.2.12 raeburn 6601: if ($supplementalflag) {
6602: $fieldsets = "'suppext','suppdoc'";
1.484.2.72.2. (raeburn 6603:): if ($posslti) {
6604:): $fieldsets .= ",'supptool'";
6605:): }
1.484.2.12 raeburn 6606: }
6607:
1.484.2.67 raeburn 6608: my $jsmakefunctions;
6609: if ($canedit) {
6610: $jsmakefunctions = <<ENDNEWSCRIPT;
1.329 droeschl 6611: function makenewfolder(targetform,folderseq) {
1.484.2.65 raeburn 6612: var foldername=prompt('$js_lt{"p_mnf"}','$js_lt{"t_mnf"}');
1.329 droeschl 6613: if (foldername) {
6614: targetform.importdetail.value=escape(foldername)+"="+folderseq;
6615: targetform.submit();
6616: }
6617: }
6618:
6619: function makenewpage(targetform,folderseq) {
1.484.2.61 raeburn 6620: var pagename=prompt('$js_lt{"p_mnp"}','$js_lt{"t_mnp"}');
1.329 droeschl 6621: if (pagename) {
6622: targetform.importdetail.value=escape(pagename)+"="+folderseq;
6623: targetform.submit();
6624: }
6625: }
6626:
6627: function makeexamupload() {
1.484.2.61 raeburn 6628: var title=prompt('$js_lt{"p_mxu"}');
1.344 bisitz 6629: if (title) {
1.329 droeschl 6630: this.document.forms.newexamupload.importdetail.value=
6631: escape(title)+'=/res/lib/templates/examupload.problem';
6632: this.document.forms.newexamupload.submit();
6633: }
6634: }
6635:
6636: function makesmppage() {
1.484.2.61 raeburn 6637: var title=prompt('$js_lt{"p_msp"}');
1.344 bisitz 6638: if (title) {
1.329 droeschl 6639: this.document.forms.newsmppg.importdetail.value=
1.484.2.26 raeburn 6640: escape(title)+'=/adm/$udom/$uname/new/smppg';
1.329 droeschl 6641: this.document.forms.newsmppg.submit();
6642: }
6643: }
6644:
1.484.2.27 raeburn 6645: function makewebpage(type) {
1.484.2.61 raeburn 6646: var title=prompt('$js_lt{"p_mwp"}');
1.484.2.27 raeburn 6647: var formname;
6648: if (type == 'supp') {
6649: formname = this.document.forms.supwebpage;
6650: } else {
6651: formname = this.document.forms.newwebpage;
6652: }
6653: if (title) {
6654: var webpage = formname.importdetail.value;
6655: formname.importdetail.value = escape(title)+'='+webpage;
6656: formname.submit();
6657: }
6658: }
6659:
1.329 droeschl 6660: function makesmpproblem() {
1.484.2.61 raeburn 6661: var title=prompt('$js_lt{"p_msb"}');
1.344 bisitz 6662: if (title) {
1.329 droeschl 6663: this.document.forms.newsmpproblem.importdetail.value=
6664: escape(title)+'=/res/lib/templates/simpleproblem.problem';
6665: this.document.forms.newsmpproblem.submit();
6666: }
6667: }
6668:
6669: function makedropbox() {
1.484.2.61 raeburn 6670: var title=prompt('$js_lt{"p_mdb"}');
1.344 bisitz 6671: if (title) {
1.329 droeschl 6672: this.document.forms.newdropbox.importdetail.value=
6673: escape(title)+'=/res/lib/templates/DropBox.problem';
6674: this.document.forms.newdropbox.submit();
6675: }
6676: }
6677:
6678: function makebulboard() {
1.484.2.61 raeburn 6679: var title=prompt('$js_lt{"p_mbb"}');
1.329 droeschl 6680: if (title) {
6681: this.document.forms.newbul.importdetail.value=
1.484.2.26 raeburn 6682: escape(title)+'=/adm/$udom/$uname/new/bulletinboard';
1.329 droeschl 6683: this.document.forms.newbul.submit();
6684: }
6685: }
6686:
6687: function makeabout() {
1.484.2.61 raeburn 6688: var user=prompt("$js_lt{'p_mab'}");
1.329 droeschl 6689: if (user) {
6690: var comp=new Array();
6691: comp=user.split(':');
6692: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
6693: if ((comp[0]) && (comp[1])) {
6694: this.document.forms.newaboutsomeone.importdetail.value=
1.484.2.61 raeburn 6695: '$js_lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.484.2.67 raeburn 6696: this.document.forms.newaboutsomeone.submit();
6697: } else {
6698: alert("$js_lt{'p_mab_alrt1'}");
6699: }
6700: } else {
6701: alert("$js_lt{'p_mab_alrt2'}");
6702: }
6703: }
1.335 ehlerst 6704: }
1.484.2.67 raeburn 6705:
6706: function makenew(targetform) {
6707: targetform.submit();
1.335 ehlerst 6708: }
1.484.2.67 raeburn 6709:
6710: function changename(folderpath,index,oldtitle) {
6711: var title=prompt('$js_lt{"p_chn"}',oldtitle);
6712: if (title) {
6713: this.document.forms.renameform.markcopy.value='';
6714: this.document.forms.renameform.title.value=title;
6715: this.document.forms.renameform.cmd.value='rename_'+index;
6716: this.document.forms.renameform.folderpath.value=folderpath;
6717: this.document.forms.renameform.submit();
6718: }
1.329 droeschl 6719: }
6720:
1.484.2.67 raeburn 6721: ENDNEWSCRIPT
6722: } else {
6723: $jsmakefunctions = <<ENDNEWSCRIPT;
6724:
6725: function makenewfolder() {
6726: alert("$js_lt{'edri'}");
6727: }
6728:
6729: function makenewpage() {
6730: alert("$js_lt{'edri'}");
6731: }
6732:
6733: function makeexamupload() {
6734: alert("$js_lt{'edri'}");
6735: }
6736:
6737: function makesmppage() {
6738: alert("$js_lt{'edri'}");
6739: }
6740:
6741: function makewebpage(type) {
6742: alert("$js_lt{'edri'}");
6743: }
6744:
6745: function makesmpproblem() {
6746: alert("$js_lt{'edri'}");
6747: }
6748:
6749: function makedropbox() {
6750: alert("$js_lt{'edri'}");
6751: }
6752:
6753: function makebulboard() {
6754: alert("$js_lt{'edri'}");
6755: }
6756:
6757: function makeabout() {
6758: alert("$js_lt{'edri'}");
6759: }
6760:
6761: function changename() {
6762: alert("$js_lt{'edri'}");
6763: }
6764:
6765: function makenew() {
6766: alert("$js_lt{'edri'}");
6767: }
6768:
6769: function groupimport() {
6770: alert("$js_lt{'edri'}");
6771: }
6772:
6773: function groupsearch() {
6774: alert("$js_lt{'edri'}");
6775: }
6776:
6777: function groupopen(url,recover) {
6778: var options="scrollbars=1,resizable=1,menubar=0";
6779: idxflag=1;
6780: idx=open("/adm/groupsort?inhibitmenu=yes&mode=simple&recover="+recover+"&readfile="+url,"idxout",options);
6781: idx.focus();
6782: }
6783:
6784: ENDNEWSCRIPT
6785:
6786: }
6787: return <<ENDSCRIPT;
6788:
6789: $jsmakefunctions
6790:
1.484.2.13 raeburn 6791: function toggleUpload(caller) {
6792: var blocks = Array($fieldsets);
6793: for (var i=0; i<blocks.length; i++) {
6794: var disp = 'none';
6795: if (caller == blocks[i]) {
6796: var curr = document.getElementById('upload'+caller+'form').style.display;
6797: if (curr == 'none') {
6798: disp='block';
6799: }
6800: }
6801: document.getElementById('upload'+blocks[i]+'form').style.display=disp;
1.484.2.72.2. (raeburn 6802:): if ((caller == 'tool') || (caller == 'supptool')) {
6803:): if (disp == 'block') {
6804:): if (document.getElementById('LC_exttoolid')) {
6805:): var toolselector = document.getElementById('LC_exttoolid');
6806:): var suppflag = 0;
6807:): if (caller == 'supptool') {
6808:): suppflag = 1;
6809:): }
6810:): currForm = document.getElementById('new'+caller);
6811:): updateExttool(toolselector,currForm,suppflag);
6812:): }
6813:): }
6814:): }
1.484.2.13 raeburn 6815: }
6816: resize_scrollbox('contentscroll','1','1');
6817: return;
6818: }
6819:
1.484.2.19 raeburn 6820: function toggleMap(caller) {
1.484.2.13 raeburn 6821: var disp = 'none';
1.484.2.19 raeburn 6822: if (document.getElementById('importmapform')) {
6823: if (caller == 'map') {
6824: var curr = document.getElementById('importmapform').style.display;
6825: if (curr == 'none') {
6826: disp='block';
6827: }
1.484.2.12 raeburn 6828: }
1.484.2.19 raeburn 6829: document.getElementById('importmapform').style.display=disp;
6830: resize_scrollbox('contentscroll','1','1');
1.484.2.12 raeburn 6831: }
1.484.2.19 raeburn 6832: return;
1.329 droeschl 6833: }
6834:
1.484.2.12 raeburn 6835: function makeims(imsform) {
6836: if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
1.484.2.61 raeburn 6837: alert("$js_lt{'imsfile'}");
1.484.2.12 raeburn 6838: return;
6839: }
6840: if (imsform.source.selectedIndex == 0) {
1.484.2.61 raeburn 6841: alert("$js_lt{'imscms'}");
1.484.2.12 raeburn 6842: return;
6843: }
6844: newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
6845: imsform.submit();
6846: }
6847:
1.478 raeburn 6848: function updatePick(targetform,index,caller) {
1.484.2.29 raeburn 6849: var pickitem;
6850: var picknumitem;
6851: var picknumtext;
6852: if (index == 'all') {
6853: pickitem = document.getElementById('randompickall');
6854: picknumitem = document.getElementById('rpicknumall');
6855: picknumtext = document.getElementById('rpicktextall');
6856: } else {
6857: pickitem = document.getElementById('randompick_'+index);
6858: picknumitem = document.getElementById('rpicknum_'+index);
6859: picknumtext = document.getElementById('randompicknum_'+index);
6860: }
1.478 raeburn 6861: if (pickitem.checked) {
1.484.2.61 raeburn 6862: var picknum=prompt('$js_lt{"rpck"}',picknumitem.value);
1.478 raeburn 6863: if (picknum == '' || picknum == null) {
6864: if (caller == 'check') {
6865: pickitem.checked=false;
1.484.2.29 raeburn 6866: if (index == 'all') {
6867: picknumtext.innerHTML = '';
6868: if (caller == 'link') {
6869: propagateState(targetform,'rpicknum');
6870: }
6871: } else {
1.484.2.30 raeburn 6872: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 6873: }
1.478 raeburn 6874: }
6875: } else {
6876: picknum.toString();
6877: var regexdigit=/^\\d+\$/;
6878: if (regexdigit.test(picknum)) {
6879: picknumitem.value = picknum;
1.484.2.29 raeburn 6880: if (index == 'all') {
1.484.2.30 raeburn 6881: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.cumulativesettings,\\'all\\',\\'link\\');">'+picknum+'</a>';
1.484.2.29 raeburn 6882: if (caller == 'link') {
6883: propagateState(targetform,'rpicknum');
6884: }
6885: } else {
6886: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.edit_randompick_'+index+',\\''+index+'\\',\\'link\\');">'+picknum+'</a>';
1.484.2.30 raeburn 6887: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 6888: }
1.478 raeburn 6889: } else {
6890: if (caller == 'check') {
1.484.2.29 raeburn 6891: if (index == 'all') {
6892: picknumtext.innerHTML = '';
6893: if (caller == 'link') {
6894: propagateState(targetform,'rpicknum');
6895: }
6896: } else {
6897: pickitem.checked=false;
1.484.2.30 raeburn 6898: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 6899: }
1.478 raeburn 6900: }
6901: return;
6902: }
6903: }
6904: } else {
1.484.2.29 raeburn 6905: picknumitem.value = '';
6906: picknumtext.innerHTML = '';
6907: if (index == 'all') {
6908: if (caller == 'link') {
6909: propagateState(targetform,'rpicknum');
6910: }
6911: } else {
1.484.2.30 raeburn 6912: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 6913: }
6914: }
6915: }
6916:
6917: function propagateState(form,param) {
6918: if (document.getElementById(param+'all')) {
6919: var setcheck = 0;
6920: var rpick = 0;
6921: if (param == 'rpicknum') {
6922: if (document.getElementById('randompickall')) {
6923: if (document.getElementById('randompickall').checked) {
6924: if (document.getElementById('rpicknumall')) {
6925: rpick = document.getElementById('rpicknumall').value;
6926: }
6927: }
6928: }
6929: } else {
6930: if (document.getElementById(param+'all').checked) {
6931: setcheck = 1;
6932: }
6933: }
1.484.2.30 raeburn 6934: var allidxlist;
6935: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
6936: if (document.getElementById('all'+param+'idx')) {
6937: allidxlist = document.getElementById('all'+param+'idx').value;
6938: }
6939: var actions = new Array ('remove','cut','copy');
6940: for (var i=0; i<actions.length; i++) {
6941: if (actions[i] != param) {
6942: if (document.getElementById(actions[i]+'all')) {
6943: document.getElementById(actions[i]+'all').checked = false;
6944: }
6945: }
6946: }
6947: }
1.484.2.29 raeburn 6948: if ((param == 'encrypturl') || (param == 'hiddenresource')) {
1.484.2.30 raeburn 6949: allidxlist = form.allidx.value;
6950: }
6951: if ((param == 'randompick') || (param == 'rpicknum') || (param == 'randomorder')) {
6952: allidxlist = form.allmapidx.value;
6953: }
6954: if ((allidxlist != '') && (allidxlist != null)) {
6955: var allidxs = allidxlist.split(',');
6956: if (allidxs.length > 1) {
6957: for (var i=0; i<allidxs.length; i++) {
6958: if (document.getElementById(param+'_'+allidxs[i])) {
6959: if (param == 'rpicknum') {
6960: if (document.getElementById('randompick_'+allidxs[i])) {
6961: if (document.getElementById('randompick_'+allidxs[i]).checked) {
6962: document.getElementById(param+'_'+allidxs[i]).value = rpick;
6963: if (rpick > 0) {
6964: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = ': <a href="javascript:updatePick(document.edit_randompick_'+allidxs[i]+',\\''+allidxs[i]+'\\',\\'link\\')">'+rpick+'</a>';
6965: } else {
6966: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
6967: }
6968: }
6969: }
6970: } else {
1.484.2.29 raeburn 6971: if (setcheck == 1) {
6972: document.getElementById(param+'_'+allidxs[i]).checked = true;
6973: } else {
6974: document.getElementById(param+'_'+allidxs[i]).checked = false;
1.484.2.30 raeburn 6975: if (param == 'randompick') {
6976: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
6977: }
1.484.2.29 raeburn 6978: }
6979: }
6980: }
6981: }
1.484.2.30 raeburn 6982: if (setcheck == 1) {
6983: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
6984: var actions = new Array('copy','cut','remove');
6985: for (var i=0; i<actions.length; i++) {
6986: var otheractions;
6987: var otheridxs;
6988: if (actions[i] === param) {
6989: continue;
6990: } else {
6991: if (document.getElementById('all'+actions[i]+'idx')) {
6992: otheractions = document.getElementById('all'+actions[i]+'idx').value;
6993: otheridxs = otheractions.split(',');
6994: if (otheridxs.length > 1) {
6995: for (var j=0; j<otheridxs.length; j++) {
6996: if (document.getElementById(actions[i]+'_'+otheridxs[j])) {
6997: document.getElementById(actions[i]+'_'+otheridxs[j]).checked = false;
6998: }
1.484.2.29 raeburn 6999: }
7000: }
7001: }
7002: }
1.484.2.30 raeburn 7003: }
1.484.2.29 raeburn 7004: }
7005: }
7006: }
7007: }
1.478 raeburn 7008: }
1.484.2.29 raeburn 7009: return;
7010: }
7011:
1.484.2.63 raeburn 7012: function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder,confirm_removal) {
1.484.2.67 raeburn 7013: var canedit = '$canedit';
7014: if (canedit == '') {
7015: alert("$js_lt{'edri'}");
7016: return;
7017: }
1.484.2.30 raeburn 7018: var dosettings;
7019: var doaction;
7020: var control = document.togglemultsettings;
7021: if (context == 'actions') {
7022: control = document.togglemultactions;
7023: doaction = 1;
7024: } else {
7025: dosettings = 1;
7026: }
7027: if (control) {
7028: if (control.showmultpick.length) {
7029: for (var i=0; i<control.showmultpick.length; i++) {
7030: if (control.showmultpick[i].checked) {
7031: if (control.showmultpick[i].value == 1) {
7032: if (context == 'settings') {
7033: dosettings = 0;
7034: } else {
7035: doaction = 0;
7036: }
7037: }
7038: }
7039: }
7040: }
7041: }
7042: if (context == 'settings') {
7043: if (dosettings == 1) {
7044: targetform.changeparms.value=param;
7045: targetform.submit();
7046: }
7047: }
7048: if (context == 'actions') {
7049: if (doaction == 1) {
7050: targetform.cmd.value=param+'_'+index;
7051: targetform.folderpath.value=folderpath;
7052: targetform.markcopy.value=idx+':'+param;
7053: targetform.copyfolder.value=folder+'.'+container;
7054: if (param == 'remove') {
1.484.2.63 raeburn 7055: var doremove = 0;
7056: if (skip_confirm) {
7057: if (confirm_removal) {
7058: if (confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'"$js_lt{"p_rmr2b"}')) {
7059: doremove = 1;
7060: }
7061: } else {
7062: doremove = 1;
7063: }
7064: } else {
7065: if (confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'" $js_lt{"p_rmr2b"}')) {
7066: doremove = 1;
7067: }
7068: }
7069: if (doremove) {
1.484.2.30 raeburn 7070: targetform.markcopy.value='';
7071: targetform.copyfolder.value='';
1.484.2.29 raeburn 7072: targetform.submit();
7073: }
7074: }
1.484.2.30 raeburn 7075: if (param == 'cut') {
1.484.2.61 raeburn 7076: 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 7077: targetform.submit();
7078: return;
7079: }
7080: }
7081: if (param == 'copy') {
7082: targetform.submit();
7083: return;
7084: }
7085: targetform.markcopy.value='';
7086: targetform.copyfolder.value='';
7087: targetform.cmd.value='';
7088: targetform.folderpath.value='';
7089: return;
7090: } else {
7091: if (document.getElementById(param+'_'+idx)) {
7092: item = document.getElementById(param+'_'+idx);
7093: if (item.type == 'checkbox') {
7094: if (item.checked) {
7095: item.checked = false;
7096: } else {
7097: item.checked = true;
7098: singleCheck(item,idx,param);
7099: }
7100: }
7101: }
7102: }
7103: }
7104: return;
7105: }
7106:
7107: function singleCheck(caller,idx,action) {
7108: actions = new Array('cut','copy','remove');
7109: if (caller.checked) {
7110: for (var i=0; i<actions.length; i++) {
7111: if (actions[i] != action) {
7112: if (document.getElementById(actions[i]+'_'+idx)) {
7113: if (document.getElementById(actions[i]+'_'+idx).checked) {
7114: document.getElementById(actions[i]+'_'+idx).checked = false;
7115: }
7116: }
7117: }
1.484.2.29 raeburn 7118: }
7119: }
7120: return;
1.478 raeburn 7121: }
7122:
1.334 muellerd 7123: function unselectInactive(nav) {
1.335 ehlerst 7124: currentNav = document.getElementById(nav);
7125: currentLis = currentNav.getElementsByTagName('LI');
7126: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 7127: if (currentLis[i].className == 'goback') {
7128: currentLis[i].className = 'goback';
7129: } else {
7130: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 7131: currentLis[i].className = 'right';
1.472 raeburn 7132: } else {
1.374 tempelho 7133: currentLis[i].className = 'i';
1.472 raeburn 7134: }
7135: }
1.335 ehlerst 7136: }
1.332 tempelho 7137: }
7138:
1.334 muellerd 7139: function hideAll(current, nav, data) {
1.335 ehlerst 7140: unselectInactive(nav);
1.484.2.43 raeburn 7141: if (current) {
7142: if (current.className == 'right'){
1.374 tempelho 7143: current.className = 'right active'
1.484.2.43 raeburn 7144: } else {
1.374 tempelho 7145: current.className = 'active';
1.484.2.43 raeburn 7146: }
1.374 tempelho 7147: }
1.335 ehlerst 7148: currentData = document.getElementById(data);
7149: currentDivs = currentData.getElementsByTagName('DIV');
7150: for (i = 0; i < currentDivs.length; i++) {
7151: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 7152: currentDivs[i].style.display = 'none';
1.330 tempelho 7153: }
7154: }
1.335 ehlerst 7155: }
1.330 tempelho 7156:
1.374 tempelho 7157: function openTabs(pageId) {
7158: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 7159: if(tabnav.length > 2 ){
1.389 tempelho 7160: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 7161: currentLis = currentNav.getElementsByTagName('LI');
7162: for(i = 0; i< currentLis.length; i++){
7163: if(currentLis[i].className == 'active') {
1.375 tempelho 7164: funcString = currentLis[i].onclick.toString();
7165: tab = funcString.split('"');
1.420 onken 7166: if(tab.length < 2) {
7167: tab = funcString.split("'");
7168: }
1.375 tempelho 7169: currentData = document.getElementById(tab[1]);
7170: currentData.style.display = 'block';
1.374 tempelho 7171: }
7172: }
7173: }
7174: }
7175:
1.334 muellerd 7176: function showPage(current, pageId, nav, data) {
1.484.2.43 raeburn 7177: currstate = current.className;
1.334 muellerd 7178: hideAll(current, nav, data);
1.375 tempelho 7179: openTabs(pageId);
1.334 muellerd 7180: unselectInactive(nav);
1.484.2.43 raeburn 7181: if ((currstate == 'active') || (currstate == 'right active')) {
7182: if (currstate == 'active') {
7183: current.className = '';
7184: } else {
7185: current.className = 'right';
7186: }
7187: activeTab = '';
7188: toggleUpload();
7189: toggleMap();
7190: resize_scrollbox('contentscroll','1','0');
7191: return;
7192: } else {
7193: current.className = 'active';
7194: }
1.330 tempelho 7195: currentData = document.getElementById(pageId);
7196: currentData.style.display = 'block';
1.458 raeburn 7197: activeTab = pageId;
1.484.2.12 raeburn 7198: toggleUpload();
1.484.2.14 raeburn 7199: toggleMap();
1.433 raeburn 7200: if (nav == 'mainnav') {
7201: var storedpath = "$docs_folderpath";
1.434 raeburn 7202: var storedpage = "$main_container_page";
1.433 raeburn 7203: var reg = new RegExp("^supplemental");
7204: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 7205: if (storedpage == 1) {
7206: document.simpleedit.folderpath.value = '';
7207: document.uploaddocument.folderpath.value = '';
7208: } else {
7209: if (reg.test(storedpath)) {
7210: document.simpleedit.folderpath.value = '$toplevelmain';
7211: document.uploaddocument.folderpath.value = '$toplevelmain';
7212: document.newext.folderpath.value = '$toplevelmain';
7213: } else {
7214: document.simpleedit.folderpath.value = storedpath;
7215: document.uploaddocument.folderpath.value = storedpath;
7216: document.newext.folderpath.value = storedpath;
7217: }
1.433 raeburn 7218: }
7219: } else {
1.434 raeburn 7220: if (reg.test(storedpath)) {
7221: document.simpleedit.folderpath.value = storedpath;
7222: document.supuploaddocument.folderpath.value = storedpath;
7223: document.supnewext.folderpath.value = storedpath;
7224: } else {
1.433 raeburn 7225: document.simpleedit.folderpath.value = '$toplevelsupp';
7226: document.supuploaddocument.folderpath.value = '$toplevelsupp';
7227: document.supnewext.folderpath.value = '$toplevelsupp';
7228: }
7229: }
7230: }
1.484.2.3 raeburn 7231: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 7232: return false;
7233: }
1.329 droeschl 7234:
1.472 raeburn 7235: function toContents(jumpto) {
7236: var newurl = '$backtourl';
1.484.2.21 raeburn 7237: if ((newurl == '/adm/navmaps') && (jumpto != '')) {
1.472 raeburn 7238: newurl = newurl+'?postdata='+jumpto;
7239: }
7240: location.href=newurl;
7241: }
7242:
1.484.2.30 raeburn 7243: function togglePick(caller,value) {
7244: var disp = 'none';
7245: if (document.getElementById('multi'+caller)) {
7246: var curr = document.getElementById('multi'+caller).style.display;
7247: if (value == 1) {
7248: disp='block';
7249: }
7250: if (curr == disp) {
7251: return;
7252: }
7253: document.getElementById('multi'+caller).style.display=disp;
7254: if (value == 1) {
1.484.2.61 raeburn 7255: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.484.2.30 raeburn 7256: } else {
7257: document.getElementById('more'+caller).innerHTML = '';
7258: }
7259: if (caller == 'actions') {
7260: setClass(value);
7261: setBoxes(value);
7262: }
7263: }
7264: var showButton = multiSettings();
7265: if (showButton != 1) {
7266: showButton = multiActions();
7267: }
7268: if (document.getElementById('multisave')) {
7269: if (showButton == 1) {
7270: document.getElementById('multisave').style.display='block';
7271: } else {
7272: document.getElementById('multisave').style.display='none';
7273: }
7274: }
7275: resize_scrollbox('contentscroll','1','1');
7276: return;
7277: }
7278:
7279: function toggleCheckUncheck(caller,more) {
7280: if (more == 1) {
1.484.2.61 raeburn 7281: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',0);" style="text-decoration:none;">$js_lt{'less'}</a>';
1.484.2.30 raeburn 7282: document.getElementById('allfields'+caller).style.display='block';
7283: } else {
1.484.2.61 raeburn 7284: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.484.2.30 raeburn 7285: document.getElementById('allfields'+caller).style.display='none';
7286: }
7287: resize_scrollbox('contentscroll','1','1');
7288: }
7289:
7290: function multiSettings() {
7291: var inuse = 0;
7292: var settingsform = document.togglemultsettings;
7293: if (settingsform.showmultpick.length > 1) {
7294: for (var i=0; i<settingsform.showmultpick.length; i++) {
7295: if (settingsform.showmultpick[i].checked) {
7296: if (settingsform.showmultpick[i].value == 1) {
7297: inuse = 1;
7298: }
7299: }
7300: }
7301: }
7302: return inuse;
7303: }
7304:
7305: function multiActions() {
7306: var inuse = 0;
7307: var actionsform = document.togglemultactions;
7308: if (actionsform.showmultpick.length > 1) {
7309: for (var i=0; i<actionsform.showmultpick.length; i++) {
7310: if (actionsform.showmultpick[i].checked) {
7311: if (actionsform.showmultpick[i].value == 1) {
7312: inuse = 1;
7313: }
7314: }
7315: }
7316: }
7317: return inuse;
7318: }
7319:
7320: function checkSubmits() {
7321: var numchanges = 0;
7322: var form = document.saveactions;
7323: var doactions = multiActions();
7324: var cutwarnings = 0;
7325: var remwarnings = 0;
1.484.2.63 raeburn 7326: var removalinfo = 0;
1.484.2.30 raeburn 7327: if (doactions == 1) {
7328: var remidxlist = document.cumulativeactions.allremoveidx.value;
7329: if ((remidxlist != '') && (remidxlist != null)) {
7330: var remidxs = remidxlist.split(',');
7331: for (var i=0; i<remidxs.length; i++) {
7332: if (document.getElementById('remove_'+remidxs[i])) {
7333: if (document.getElementById('remove_'+remidxs[i]).checked) {
7334: form.multiremove.value += remidxs[i]+',';
7335: numchanges ++;
7336: if (document.getElementById('skip_remove_'+remidxs[i])) {
7337: if (document.getElementById('skip_remove_'+remidxs[i]).value == 0) {
7338: remwarnings ++;
7339: }
7340: }
1.484.2.63 raeburn 7341: if (document.getElementById('confirm_removal_'+remidxs[i])) {
7342: if (document.getElementById('confirm_removal_'+remidxs[i]).value == 1) {
7343: removalinfo ++;
7344: }
7345: }
1.484.2.30 raeburn 7346: }
7347: }
7348: }
7349: }
7350: var cutidxlist = document.cumulativeactions.allcutidx.value;
7351: if ((cutidxlist != '') && (cutidxlist != null)) {
7352: var cutidxs = cutidxlist.split(',');
7353: for (var i=0; i<cutidxs.length; i++) {
7354: if (document.getElementById('cut_'+cutidxs[i])) {
7355: if (document.getElementById('cut_'+cutidxs[i]).checked == true) {
7356: form.multicut.value += cutidxs[i]+',';
7357: numchanges ++;
7358: if (document.getElementById('skip_cut_'+cutidxs[i])) {
7359: if (document.getElementById('skip_cut_'+cutidxs[i]).value == 0) {
7360: cutwarnings ++;
7361: }
7362: }
7363: }
7364: }
7365: }
7366: }
7367: var copyidxlist = document.cumulativeactions.allcopyidx.value;
7368: if ((copyidxlist != '') && (copyidxlist != null)) {
7369: var copyidxs = copyidxlist.split(',');
7370: for (var i=0; i<copyidxs.length; i++) {
7371: if (document.getElementById('copy_'+copyidxs[i])) {
7372: if (document.getElementById('copy_'+copyidxs[i]).checked) {
7373: form.multicopy.value += copyidxs[i]+',';
7374: numchanges ++;
7375: }
7376: }
7377: }
7378: }
7379: if (numchanges > 0) {
7380: form.multichange.value = numchanges;
7381: }
7382: }
7383: var dosettings = multiSettings();
7384: var haschanges = 0;
7385: if (dosettings == 1) {
7386: form.allencrypturl.value = '';
7387: form.allhiddenresource.value = '';
7388: form.changeparms.value = 'all';
7389: var patt=new RegExp(",\$");
7390: var allidxlist = document.cumulativesettings.allidx.value;
7391: if ((allidxlist != '') && (allidxlist != null)) {
7392: var allidxs = allidxlist.split(',');
7393: if (allidxs.length > 1) {
7394: for (var i=0; i<allidxs.length; i++) {
7395: if (document.getElementById('hiddenresource_'+allidxs[i])) {
7396: if (document.getElementById('hiddenresource_'+allidxs[i]).checked) {
7397: form.allhiddenresource.value += allidxs[i]+',';
7398: }
7399: }
7400: if (document.getElementById('encrypturl_'+allidxs[i])) {
7401: if (document.getElementById('encrypturl_'+allidxs[i]).checked) {
7402: form.allencrypturl.value += allidxs[i]+',';
7403: }
1.484.2.29 raeburn 7404: }
7405: }
1.484.2.30 raeburn 7406: form.allhiddenresource.value = form.allhiddenresource.value.replace(patt,"");
7407: form.allencrypturl.value = form.allencrypturl.value.replace(patt,"");
7408: }
7409: }
7410: form.allrandompick.value = '';
7411: form.allrandomorder.value = '';
7412: var allmapidxlist = document.cumulativesettings.allmapidx.value;
7413: if ((allmapidxlist != '') && (allmapidxlist != null)) {
7414: var allmapidxs = allmapidxlist.split(',');
7415: for (var i=0; i<allmapidxs.length; i++) {
7416: var randompick = document.getElementById('randompick_'+allmapidxs[i]);
7417: var rpicknum = document.getElementById('rpicknum_'+allmapidxs[i]);
7418: var randorder = document.getElementById('randomorder_'+allmapidxs[i]);
7419: if ((randompick.checked) && (rpicknum.value != '')) {
7420: form.allrandompick.value += allmapidxs[i]+':'+rpicknum.value+',';
7421: }
7422: if (randorder.checked) {
7423: form.allrandomorder.value += allmapidxs[i]+',';
7424: }
7425: }
7426: form.allrandompick.value = form.allrandompick.value.replace(patt,"");
7427: form.allrandomorder.value = form.allrandomorder.value.replace(patt,"");
7428: }
7429: if (document.cumulativesettings.currhiddenresource.value != form.allhiddenresource.value) {
7430: haschanges = 1;
7431: }
7432: if (document.cumulativesettings.currencrypturl.value != form.allencrypturl.value) {
7433: haschanges = 1;
7434: }
7435: if (document.cumulativesettings.currrandomorder.value != form.allrandomorder.value) {
7436: haschanges = 1;
7437: }
7438: if (document.cumulativesettings.currrandompick.value != form.allrandompick.value) {
7439: haschanges = 1;
7440: }
7441: }
7442: if (doactions == 1) {
7443: if (numchanges > 0) {
1.484.2.63 raeburn 7444: if ((cutwarnings > 0) || (remwarnings > 0) || (removalinfo > 0)) {
1.484.2.30 raeburn 7445: if (remwarnings > 0) {
1.484.2.61 raeburn 7446: if (!confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr3a"} '+remwarnings+' $js_lt{"p_rmr3b"}')) {
1.484.2.30 raeburn 7447: return false;
7448: }
7449: }
1.484.2.63 raeburn 7450: if (removalinfo > 0) {
7451: if (!confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr3a"} '+removalinfo+' $js_lt{"p_rmr3b"}')) {
7452: return false;
7453: }
7454: }
1.484.2.30 raeburn 7455: if (cutwarnings > 0) {
1.484.2.61 raeburn 7456: 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 7457: return false;
1.484.2.29 raeburn 7458: }
7459: }
7460: }
1.484.2.30 raeburn 7461: form.submit();
7462: return true;
7463: }
7464: }
7465: if (dosettings == 1) {
7466: if (haschanges == 1) {
7467: form.submit();
7468: return true;
1.484.2.29 raeburn 7469: }
7470: }
1.484.2.30 raeburn 7471: if ((dosettings == 1) && (doactions == 1)) {
1.484.2.61 raeburn 7472: alert("$js_lt{'noor'}");
1.484.2.30 raeburn 7473: } else {
7474: if (dosettings == 1) {
1.484.2.61 raeburn 7475: alert("$js_lt{'noch'}");
1.484.2.30 raeburn 7476: } else {
1.484.2.61 raeburn 7477: alert("$js_lt{'noac'}");
1.484.2.30 raeburn 7478: }
7479: }
7480: return false;
7481: }
7482:
7483: function setClass(value) {
7484: var cutclass = 'LC_docs_cut';
7485: var copyclass = 'LC_docs_copy';
7486: var removeclass = 'LC_docs_remove';
7487: var cutreg = new RegExp("\\\\b"+cutclass+"\\\\b");
7488: var copyreg = new RegExp("\\\\b"+copyclass+"\\\\b");
7489: var removereg = new RegExp("\\\\"+removeclass+"\\\\b");
7490: var links = document.getElementsByTagName('a');
7491: for (var i=0; i<links.length; i++) {
7492: var classes = links[i].className;
7493: if (cutreg.test(classes)) {
7494: links[i].className = cutclass;
7495: if (value == 1) {
7496: links[i].className += " LC_menubuttons_link";
1.484.2.29 raeburn 7497: }
1.484.2.30 raeburn 7498: } else {
7499: if (copyreg.test(classes)) {
7500: links[i].className = copyclass;
7501: if (value == 1) {
7502: links[i].className += " LC_menubuttons_link";
7503: }
7504: } else {
7505: if (removereg.test(classes)) {
7506: links[i].className = removeclass;
7507: if (value == 1) {
7508: links[i].className += " LC_menubuttons_link";
7509: }
7510: }
1.484.2.29 raeburn 7511: }
7512: }
7513: }
1.484.2.30 raeburn 7514: return;
1.484.2.29 raeburn 7515: }
7516:
1.484.2.30 raeburn 7517: function setBoxes(value) {
7518: var remidxlist = document.cumulativeactions.allremoveidx.value;
7519: if ((remidxlist != '') && (remidxlist != null)) {
7520: var remidxs = remidxlist.split(',');
7521: for (var i=0; i<remidxs.length; i++) {
7522: if (document.getElementById('remove_'+remidxs[i])) {
7523: var item = document.getElementById('remove_'+remidxs[i]);
7524: if (value == 1) {
7525: item.className = 'LC_docs_remove';
7526: } else {
7527: item.className = 'LC_hidden';
7528: }
7529: }
1.484.2.29 raeburn 7530: }
7531: }
1.484.2.30 raeburn 7532: var cutidxlist = document.cumulativeactions.allcutidx.value;
7533: if ((cutidxlist != '') && (cutidxlist != null)) {
7534: var cutidxs = cutidxlist.split(',');
7535: for (var i=0; i<cutidxs.length; i++) {
7536: if (document.getElementById('cut_'+cutidxs[i])) {
7537: var item = document.getElementById('cut_'+cutidxs[i]);
7538: if (value == 1) {
7539: item.className = 'LC_docs_cut';
7540: } else {
7541: item.className = 'LC_hidden';
7542: }
7543: }
7544: }
7545: }
7546: var copyidxlist = document.cumulativeactions.allcopyidx.value;
7547: if ((copyidxlist != '') && (copyidxlist != null)) {
7548: var copyidxs = copyidxlist.split(',');
7549: for (var i=0; i<copyidxs.length; i++) {
7550: if (document.getElementById('copy_'+copyidxs[i])) {
7551: var item = document.getElementById('copy_'+copyidxs[i]);
7552: if (value == 1) {
7553: item.className = 'LC_docs_copy';
7554: } else {
7555: item.className = 'LC_hidden';
7556: }
7557: }
1.484.2.29 raeburn 7558: }
7559: }
7560: return;
7561: }
7562:
1.484.2.67 raeburn 7563: ENDSCRIPT
1.329 droeschl 7564: }
1.457 raeburn 7565:
1.483 raeburn 7566: sub history_tab_js {
7567: return <<"ENDHIST";
7568: function toggleHistoryDisp(choice) {
7569: document.docslogform.docslog.value = choice;
7570: document.docslogform.submit();
7571: return;
7572: }
7573:
7574: ENDHIST
7575: }
7576:
1.484 raeburn 7577: sub inject_data_js {
7578: return <<ENDINJECT;
7579:
7580: function injectData(current, hiddenField, name, value) {
7581: currentElement = document.getElementById(hiddenField);
7582: currentElement.name = name;
7583: currentElement.value = value;
7584: current.submit();
7585: }
7586:
7587: ENDINJECT
7588: }
7589:
7590: sub dump_switchserver_js {
7591: my @hosts = @_;
1.484.2.61 raeburn 7592: my %js_lt = &Apache::lonlocal::texthash(
1.484.2.46 raeburn 7593: dump => 'Copying content to Authoring Space requires switching server.',
1.484 raeburn 7594: swit => 'Switch server?',
1.484.2.61 raeburn 7595: );
7596: my %html_js_lt = &Apache::lonlocal::texthash(
7597: swit => 'Switch server?',
1.484.2.43 raeburn 7598: duco => 'Copying Content to Authoring Space',
1.484 raeburn 7599: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
7600: chos => 'Choose server',
7601: );
1.484.2.61 raeburn 7602: &js_escape(\%js_lt);
7603: &html_escape(\%html_js_lt);
7604: &js_escape(\%html_js_lt);
1.484 raeburn 7605: my $role = $env{'request.role'};
7606: my $js = <<"ENDSWJS";
7607: <script type="text/javascript">
7608: function write_switchserver() {
7609: var server;
7610: if (document.setserver.posshosts.length > 0) {
7611: for (var i=0; i<document.setserver.posshosts.length; i++) {
7612: if (document.setserver.posshosts[i].checked) {
7613: server = document.setserver.posshosts[i].value;
7614: }
7615: }
7616: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
7617: }
7618: window.close();
7619: }
7620: </script>
7621:
7622: ENDSWJS
7623:
7624: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
7625: {'only_body' => 1,
7626: 'js_ready' => 1,});
7627: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
7628:
7629: my $hostpicker;
7630: my $count = 0;
7631: foreach my $host (sort(@hosts)) {
7632: my $checked;
7633: if ($count == 0) {
7634: $checked = ' checked="checked"';
7635: }
7636: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
7637: $host.'"'.$checked.' />'.$host.'</label> ';
7638: $count++;
7639: }
7640:
7641: return <<"ENDSWITCHJS";
7642:
7643: function dump_needs_switchserver(url) {
7644: if (url!='' && url!= null) {
1.484.2.61 raeburn 7645: if (confirm("$js_lt{'dump'}\\n$js_lt{'swit'}")) {
1.484 raeburn 7646: go(url);
7647: }
7648: }
7649: return;
7650: }
7651:
7652: function choose_switchserver_window() {
7653: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
7654: newWindow.document.open();
7655: newWindow.document.writeln('$startpage');
1.484.2.61 raeburn 7656: newWindow.document.write('<h3>$html_js_lt{'duco'}<\\/h3>\\n'+
7657: '<p>$html_js_lt{'yone'}<\\/p>\\n'+
7658: '<div class="LC_left_float"><fieldset><legend>$html_js_lt{'chos'}<\\/legend>\\n'+
1.484 raeburn 7659: '<form name="setserver" method="post" action="" \\/>\\n'+
7660: '$hostpicker\\n'+
7661: '<br \\/><br \\/>\\n'+
1.484.2.61 raeburn 7662: '<input type="button" name="makeswitch" value="$html_js_lt{'swit'}" '+
1.484 raeburn 7663: 'onclick="write_switchserver();" \\/>\\n'+
7664: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
7665: newWindow.document.writeln('$endpage');
7666: newWindow.document.close();
7667: newWindow.focus();
7668: }
7669:
7670: ENDSWITCHJS
7671: }
7672:
7673: sub makedocslogform {
7674: my ($formelems,$docslog) = @_;
7675: return <<"LOGSFORM";
7676: <form action="/adm/coursedocs" method="post" name="docslogform">
7677: <input type="hidden" name="docslog" value="$docslog" />
7678: $formelems
7679: </form>
7680: LOGSFORM
7681: }
7682:
7683: sub makesimpleeditform {
7684: my ($formelems) = @_;
7685: return <<"SIMPFORM";
7686: <form name="simpleedit" method="post" action="/adm/coursedocs">
7687: <input type="hidden" name="importdetail" value="" />
7688: $formelems
7689: </form>
7690: SIMPFORM
7691: }
7692:
1.329 droeschl 7693: 1;
7694: __END__
7695:
7696:
7697: =head1 NAME
7698:
7699: Apache::londocs.pm
7700:
7701: =head1 SYNOPSIS
7702:
7703: This is part of the LearningOnline Network with CAPA project
7704: described at http://www.lon-capa.org.
7705:
7706: =head1 SUBROUTINES
7707:
7708: =over
7709:
7710: =item %help=()
7711:
7712: Available help topics
7713:
7714: =item mapread()
7715:
1.344 bisitz 7716: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 7717: @order and @resources, determines status
7718: sets @order - pointer to resources in right order
7719: sets @resources - array with the resources with correct idx
7720:
7721: =item authorhosts()
7722:
7723: Return hash with valid author names
7724:
7725: =item clean()
7726:
7727: =item dumpcourse()
7728:
7729: Actually dump course
7730:
7731: =item group_import()
7732:
7733: Imports the given (name, url) resources into the course
7734: coursenum, coursedom, and folder must precede the list
7735:
7736: =item breadcrumbs()
7737:
7738: =item log_docs()
7739:
7740: =item docs_change_log()
7741:
7742: =item update_paste_buffer()
7743:
7744: =item print_paste_buffer()
7745:
7746: =item do_paste_from_buffer()
7747:
1.484.2.30 raeburn 7748: =item do_buffer_empty()
7749:
7750: =item clear_from_buffer()
7751:
1.484.2.7 raeburn 7752: =item get_newmap_url()
7753:
7754: =item dbcopy()
7755:
7756: =item uniqueness_check()
7757:
7758: =item contained_map_check()
7759:
7760: =item url_paste_fixups()
7761:
7762: =item apply_fixups()
7763:
7764: =item copy_dependencies()
7765:
1.329 droeschl 7766: =item update_parameter()
7767:
7768: =item handle_edit_cmd()
7769:
7770: =item editor()
7771:
7772: =item process_file_upload()
7773:
7774: =item process_secondary_uploads()
7775:
7776: =item is_supplemental_title()
7777:
7778: =item entryline()
7779:
7780: =item tiehash()
7781:
7782: =item untiehash()
7783:
7784: =item checkonthis()
7785:
7786: check on this
7787:
7788: =item verifycontent()
7789:
7790: Verify Content
7791:
1.484.2.72.2. (raeburn 7792:): =item devalidateversioncache()
7793:):
7794:): =item checkversions()
1.329 droeschl 7795:
7796: Check Versions
7797:
7798: =item mark_hash_old()
7799:
7800: =item is_hash_old()
7801:
7802: =item changewarning()
7803:
7804: =item init_breadcrumbs()
7805:
7806: Breadcrumbs for special functions
7807:
1.484 raeburn 7808: =item create_list_elements()
7809:
7810: =item create_form_ul()
7811:
7812: =item startContentScreen()
7813:
7814: =item endContentScreen()
7815:
7816: =item supplemental_base()
7817:
7818: =item embedded_form_elems()
7819:
7820: =item embedded_destination()
7821:
7822: =item return_to_editor()
7823:
7824: =item decompression_info()
7825:
7826: =item decompression_phase_one()
7827:
7828: =item decompression_phase_two()
7829:
7830: =item remove_archive()
7831:
7832: =item generate_admin_menu()
7833:
7834: =item generate_edit_table()
7835:
7836: =item editing_js()
7837:
7838: =item history_tab_js()
7839:
7840: =item inject_data_js()
7841:
7842: =item dump_switchserver_js()
7843:
1.484.2.3 raeburn 7844: =item resize_scrollbox_js()
1.484 raeburn 7845:
7846: =item makedocslogform()
7847:
1.484.2.3 raeburn 7848: =item makesimpleeditform()
7849:
1.329 droeschl 7850: =back
7851:
7852: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>