Annotation of loncom/interface/londocs.pm, revision 1.484.2.72.2.2
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.1 2017/06/22 02:11:26 raeburn Exp $
1.329 droeschl 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29: package Apache::londocs;
30:
31: use strict;
32: use Apache::Constants qw(:common :http);
33: use Apache::imsexport;
34: use Apache::lonnet;
35: use Apache::loncommon;
1.383 tempelho 36: use Apache::lonhtmlcommon;
1.329 droeschl 37: use LONCAPA::map();
38: use Apache::lonratedt();
39: use Apache::lonxml;
40: use Apache::lonclonecourse;
41: use Apache::lonnavmaps;
1.472 raeburn 42: use Apache::lonnavdisplay();
1.484.2.19 raeburn 43: use Apache::lonextresedit();
1.484.2.43 raeburn 44: use Apache::lontemplate();
45: use Apache::lonsimplepage();
1.329 droeschl 46: use HTML::Entities;
1.484.2.7 raeburn 47: use HTML::TokeParser;
1.329 droeschl 48: use GDBM_File;
1.484.2.51 raeburn 49: use File::MMagic;
1.329 droeschl 50: use Apache::lonlocal;
51: use Cwd;
52: use LONCAPA qw(:DEFAULT :match);
53:
54: my $iconpath;
55:
56: my %hash;
57:
58: my $hashtied;
59: my %alreadyseen=();
60:
61: my $hadchanges;
1.484.2.37 raeburn 62: my $suppchanges;
1.329 droeschl 63:
64:
65: my %help=();
66:
67:
68: sub mapread {
69: my ($coursenum,$coursedom,$map)=@_;
70: return
71: &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
72: $map);
73: }
74:
75: sub storemap {
1.484.2.7 raeburn 76: my ($coursenum,$coursedom,$map,$contentchg)=@_;
77: my $report;
78: if (($contentchg) && ($map =~ /^default/)) {
79: $report = 1;
80: }
1.329 droeschl 81: my ($outtext,$errtext)=
82: &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.484.2.7 raeburn 83: $map,1,$report);
1.329 droeschl 84: if ($errtext) { return ($errtext,2); }
1.364 bisitz 85:
1.484.2.37 raeburn 86: if ($map =~ /^default/) {
87: $hadchanges=1;
88: } else {
89: $suppchanges=1;
90: }
1.329 droeschl 91: return ($errtext,0);
92: }
93:
94:
95:
96: sub authorhosts {
97: my %outhash=();
98: my $home=0;
99: my $other=0;
100: foreach my $key (keys(%env)) {
101: if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
102: my $role=$1;
103: my $realm=$2;
104: my ($start,$end)=split(/\./,$env{$key});
105: if (($start) && ($start>time)) { next; }
106: if (($end) && (time>$end)) { next; }
107: my ($ca,$cd);
108: if ($1 eq 'au') {
109: $ca=$env{'user.name'};
110: $cd=$env{'user.domain'};
111: } else {
112: ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
113: }
114: my $allowed=0;
115: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
116: my @ids=&Apache::lonnet::current_machine_ids();
1.484 raeburn 117: foreach my $id (@ids) {
118: if ($id eq $myhome) {
119: $allowed=1;
120: last;
121: }
122: }
1.329 droeschl 123: if ($allowed) {
124: $home++;
1.484 raeburn 125: $outhash{'home_'.$ca.':'.$cd}=1;
1.329 droeschl 126: } else {
1.484 raeburn 127: $outhash{'otherhome_'.$ca.':'.$cd}=$myhome;
1.329 droeschl 128: $other++;
129: }
130: }
131: }
132: return ($home,$other,%outhash);
133: }
134:
135:
136: sub clean {
137: my ($title)=@_;
138: $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
1.344 bisitz 139: return $title;
1.329 droeschl 140: }
141:
1.484.2.67 raeburn 142: sub default_folderpath {
143: my ($coursenum,$coursedom,$navmapref) = @_;
144: return unless ($coursenum && $coursedom && ref($navmapref));
145: # Check if entire course is hidden and/or encrypted
146: my ($hiddenmap,$encryptmap,$folderpath,$hiddentop);
147: my $toplevel = "uploaded/$coursedom/$coursenum/default.sequence";
148: unless (ref($$navmapref)) {
149: $$navmapref = Apache::lonnavmaps::navmap->new();
150: }
151: if (ref($$navmapref)) {
152: if (lc($$navmapref->get_mapparam(undef,$toplevel,"0.hiddenresource")) eq 'yes') {
153: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
154: my @resources = $$navmapref->retrieveResources($toplevel,$filterFunc,1,1);
155: unless (@resources) {
156: $hiddenmap = 1;
157: unless ($env{'request.role.adv'}) {
158: $hiddentop = 1;
159: if ($env{'form.folder'}) {
160: undef($env{'form.folder'});
161: }
162: }
163: }
164: }
165: if (lc($$navmapref->get_mapparam(undef,$toplevel,"0.encrypturl")) eq 'yes') {
166: $encryptmap = 1;
167: }
168: }
169: unless ($hiddentop) {
170: $folderpath='default&'.&escape(&mt('Main Content')).
171: '::'.$hiddenmap.':'.$encryptmap.'::';
172: }
173: if (wantarray) {
174: return ($folderpath,$hiddentop);
175: } else {
176: return $folderpath;
177: }
178: }
1.329 droeschl 179:
180: sub dumpcourse {
181: my ($r) = @_;
1.408 raeburn 182: my $crstype = &Apache::loncommon::course_type();
1.484.2.43 raeburn 183: my ($starthash,$js);
184: unless (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
185: $js = <<"ENDJS";
186: <script type="text/javascript">
187: // <![CDATA[
188:
189: function hide_searching() {
190: if (document.getElementById('searching')) {
191: document.getElementById('searching').style.display = 'none';
192: }
193: return;
194: }
195:
196: // ]]>
197: </script>
198: ENDJS
199: $starthash = {
200: add_entries => {'onload' => "hide_searching();"},
201: };
202: }
203: $r->print(&Apache::loncommon::start_page('Copy '.$crstype.' Content to Authoring Space',$js,$starthash)."\n".
204: &Apache::lonhtmlcommon::breadcrumbs('Copy '.$crstype.' Content to Authoring Space')."\n");
1.484 raeburn 205: $r->print(&startContentScreen('tools'));
1.329 droeschl 206: my ($home,$other,%outhash)=&authorhosts();
1.484 raeburn 207: unless ($home) {
208: $r->print(&endContentScreen());
209: return '';
210: }
1.329 droeschl 211: my $origcrsid=$env{'request.course.id'};
212: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
213: if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
214: # Do the dumping
1.484 raeburn 215: unless ($outhash{'home_'.$env{'form.authorspace'}}) {
216: $r->print(&endContentScreen());
217: return '';
218: }
1.484.2.24 raeburn 219: my ($ca,$cd)=split(/\:/,$env{'form.authorspace'});
1.329 droeschl 220: $r->print('<h3>'.&mt('Copying Files').'</h3>');
221: my $title=$env{'form.authorfolder'};
222: $title=&clean($title);
1.484.2.43 raeburn 223: my ($navmap,$errormsg) =
224: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
225: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
226: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
227: my (%maps,%resources,%titles);
228: if (!ref($navmap)) {
229: $r->print($errormsg.
230: &endContentScreen());
231: return '';
232: } else {
233: &Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles,
234: 'dumpdocs',$cdom,$cnum);
235: }
236: my @todump = &Apache::loncommon::get_env_multiple('form.archive');
237: my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages,
238: %newcontent,%has_simpleprobs);
239: foreach my $item (sort {$a <=> $b} (@todump)) {
240: my $name = $env{'form.namefor_'.$item};
241: if ($resources{$item}) {
242: my ($map,$id,$res) = &Apache::lonnet::decode_symb($resources{$item});
243: if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) {
244: $tocopy{$1} = $name;
245: $display{$item} = $1;
246: $lookup{$1} = $item;
247: } elsif ($res eq 'lib/templates/simpleproblem.problem') {
248: $simpleproblems{$item} = {
249: symb => $resources{$item},
250: name => $name,
251: };
252: $display{$item} = 'simpleproblem_'.$name;
253: if ($map =~ m{^\Quploaded/$cdom/$cnum/\E(.+)$}) {
254: $has_simpleprobs{$1}{$id} = $item;
255: }
256: } elsif ($res =~ m{^adm/$match_domain/$match_username/(\d+)/smppg}) {
257: my $marker = $1;
258: my $db_name = &Apache::lonsimplepage::get_db_name($res,$marker,$cdom,$cnum);
259: $simplepages{$item} = {
260: res => $res,
261: title => $titles{$item},
262: db => $db_name,
263: marker => $marker,
264: symb => $resources{$item},
265: name => $name,
266: };
267: $display{$item} = '/'.$res;
268: }
269: } elsif ($maps{$item}) {
270: if ($maps{$item} =~ m{^\Quploaded/$cdom/$cnum/\E((?:default|supplemental)_\d+\.(?:sequence|page))$}) {
271: $tocopy{$1} = $name;
272: $display{$item} = $1;
273: $lookup{$1} = $item;
274: }
275: } else {
276: next;
277: }
278: }
1.329 droeschl 279: my $crs='/uploaded/'.$env{'request.course.id'}.'/';
280: $crs=~s/\_/\//g;
1.484.2.43 raeburn 281: my $mm = new File::MMagic;
282: my $prefix = "/uploaded/$cdom/$cnum/";
283: %replacehash = %tocopy;
284: foreach my $item (sort(keys(%simpleproblems))) {
285: my $content = &Apache::imsexport::simpleproblem($simpleproblems{$item}{'symb'});
286: $newcontent{$display{$item}} = $content;
287: }
288: my $gateway = Apache::lonhtmlgateway->new('web');
289: foreach my $item (sort(keys(%simplepages))) {
290: if (ref($simplepages{$item}) eq 'HASH') {
291: my $pagetitle = $simplepages{$item}{'title'};
292: my %fields = &Apache::lonnet::dump($simplepages{$item}{'db'},$cdom,$cnum);
293: my %contents;
294: foreach my $field (keys(%fields)) {
295: if ($field =~ /^(?:aaa|bbb|ccc)_(\w+)$/) {
296: my $name = $1;
297: my $msg = $fields{$field};
298: if ($name eq 'webreferences') {
299: if ($msg =~ m{^https?://}) {
300: $contents{$name} = '<a href="'.$msg.'"><tt>'.$msg.'</tt></a>';
301: }
302: } else {
303: $msg = &Encode::decode('utf8',$msg);
304: $msg = $gateway->process_outgoing_html($msg,1);
305: $contents{$name} = $msg;
306: }
307: } elsif ($field eq 'uploaded.photourl') {
308: my $marker = $simplepages{$item}{marker};
309: if ($fields{$field} =~ m{^\Q$prefix\E(simplepage/$marker/.+)$}) {
310: my $filepath = $1;
311: my ($relpath,$fname) = ($filepath =~ m{^(.+/)([^/]+)$});
312: if ($fname ne '') {
313: $fname=~s/\.(\w+)$//;
314: my $ext=$1;
315: $fname = &clean($fname);
316: $fname.='.'.$ext;
317: $contents{image} = '<img src="'.$relpath.$fname.'" alt="Image" />';
318: $replacehash{$filepath} = $relpath.$fname;
319: $deps{$item}{$filepath} = 1;
320: }
321: }
322: }
323: }
324: $replacehash{'/'.$simplepages{$item}{'res'}} = $simplepages{$item}{'name'};
325: $lookup{'/'.$simplepages{$item}{'res'}} = $item;
326: my $content = '
327: <html>
328: <head>
329: <title>'.$pagetitle.'</title>
330: </head>
331: <body bgcolor="#ffffff">';
332: if ($contents{title}) {
333: $content .= "\n".'<h2>'.$contents{title}.'</h2>';
334: }
335: if ($contents{image}) {
336: $content .= "\n".$contents{image};
337: }
338: if ($contents{content}) {
339: $content .= '
340: <div class="LC_Box">
1.484.2.50 raeburn 341: <h4 class="LC_hcell">'.&mt('Content').'</h4>'.
1.484.2.43 raeburn 342: $contents{content}.'
343: </div>';
344: }
345: if ($contents{webreferences}) {
346: $content .= '
347: <div class="LC_Box">
1.484.2.50 raeburn 348: <h4 class="LC_hcell">'.&mt('Web References').'</h4>'.
1.484.2.43 raeburn 349: $contents{webreferences}.'
350: </div>';
351: }
352: $content .= '
353: </body>
354: </html>
355: ';
356: $newcontent{'/'.$simplepages{$item}{res}} = $content;
357: }
358: }
359: foreach my $item (keys(%tocopy)) {
360: unless ($item=~/\.(sequence|page)$/) {
361: my $currurlpath = $prefix.$item;
362: my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath);
363: &recurse_html($mm,$prefix,$currdirpath,$currurlpath,$item,$lookup{$item},\%replacehash,\%deps);
364: }
365: }
366: foreach my $num (sort {$a <=> $b} (@todump)) {
367: my $src = $display{$num};
368: next if ($src eq '');
369: my @needcopy = ();
370: if ($replacehash{$src}) {
371: push(@needcopy,$src);
372: if (ref($deps{$num}) eq 'HASH') {
373: foreach my $dep (sort(keys(%{$deps{$num}}))) {
374: if ($replacehash{$dep}) {
375: push(@needcopy,$dep);
376: }
377: }
378: }
379: } elsif ($src =~ /^simpleproblem_/) {
380: push(@needcopy,$src);
381: }
382: next if (@needcopy == 0);
383: my ($result,$depresult);
384: for (my $i=0; $i<@needcopy; $i++) {
385: my $item = $needcopy[$i];
386: my $newfilename;
387: if ($simpleproblems{$num}) {
388: $newfilename=$title.'/'.$simpleproblems{$num}{'name'};
389: } else {
390: $newfilename=$title.'/'.$replacehash{$item};
391: }
392: $newfilename=~s/\.(\w+)$//;
393: my $ext=$1;
394: $newfilename=&clean($newfilename);
395: $newfilename.='.'.$ext;
396: my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$});
397: if ($newrelpath ne $replacehash{$item}) {
398: $replacehash{$item} = $newrelpath;
399: }
400: my @dirs=split(/\//,$newfilename);
401: my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
402: my $makepath=$path;
403: my $fail;
404: my $origin;
405: for (my $i=0;$i<$#dirs;$i++) {
406: $makepath.='/'.$dirs[$i];
407: unless (-e $makepath) {
408: unless(mkdir($makepath,0755)) {
409: $fail = &mt('Directory creation failed.');
410: }
411: }
412: }
413: if ($i == 0) {
414: $result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ';
415: } else {
416: $depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '.
417: '<span class="LC_fontsize_small" style="font-weight: bold;">'.
418: &mt('(dependency)').'</span>: ';
419: }
420: if (-e $path.'/'.$newfilename) {
421: $fail = &mt('Destination already exists -- not overwriting.');
422: } else {
423: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
424: if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) ||
425: ($item =~ /^simpleproblem_/)) {
426: print $fh $newcontent{$item};
427: } else {
428: my $fileloc = &Apache::lonnet::filelocation('',$prefix.$item);
429: if (-e $fileloc) {
430: if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
431: if ((($1 eq 'sequence') || ($1 eq 'page')) &&
432: (ref($has_simpleprobs{$item}) eq 'HASH')) {
433: my %changes = %{$has_simpleprobs{$item}};
434: my $content = &Apache::lonclonecourse::rewritefile(
435: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
436: (%replacehash,$crs => '')
437: );
438: my $updatedcontent = '';
439: my $parser = HTML::TokeParser->new(\$content);
440: $parser->attr_encoded(1);
441: while (my $token = $parser->get_token) {
442: if ($token->[0] eq 'S') {
443: if (($token->[1] eq 'resource') &&
444: ($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') &&
445: ($changes{$token->[2]->{'id'}})) {
446: my $id = $token->[2]->{'id'};
447: $updatedcontent .= '<'.$token->[1];
448: foreach my $attrib (@{$token->[3]}) {
449: next unless ($attrib =~ /^(src|type|title|id)$/);
450: if ($attrib eq 'src') {
451: my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/);
452: if ($file) {
453: $updatedcontent .= ' '.$attrib.'="'.$file.'"';
454: } else {
455: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
456: }
457: } else {
458: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
459: }
460: }
461: $updatedcontent .= ' />'."\n";
462: } else {
463: $updatedcontent .= $token->[4]."\n";
464: }
465: } else {
466: $updatedcontent .= $token->[2];
467: }
468: }
469: print $fh $updatedcontent;
470: } else {
471: print $fh &Apache::lonclonecourse::rewritefile(
472: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
473: (%replacehash,$crs => '')
474: );
475: }
476: } else {
477: print $fh
478: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
479: }
480: } else {
481: $fail = &mt('Source does not exist.');
482: }
483: }
484: $fh->close();
485: } else {
486: $fail = &mt('Could not write to destination.');
487: }
488: }
489: my $text;
490: if ($fail) {
491: $text = '<span class="LC_error">'.&mt('fail').(' 'x3).$fail.'</span>';
492: } else {
493: $text = '<span class="LC_success">'.&mt('ok').'</span>';
494: }
495: if ($i == 0) {
496: $result .= $text;
497: } else {
498: $depresult .= $text.'</li>';
499: }
500: }
501: $r->print($result);
502: if ($depresult) {
503: $r->print('<ul>'.$depresult.'</ul>');
504: }
505: }
1.329 droeschl 506: } else {
1.484.2.43 raeburn 507: my ($navmap,$errormsg) =
508: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
509: if (!ref($navmap)) {
510: $r->print($errormsg);
511: } else {
512: $r->print('<div id="searching">'.&mt('Searching ...').'</div>');
513: $r->rflush();
514: my ($preamble,$formname);
515: $formname = 'dumpdoc';
516: unless ($home==1) {
517: $preamble = '<div class="LC_left_float">'.
518: '<fieldset><legend>'.
519: &mt('Select the Authoring Space').
520: '</legend><select name="authorspace">';
521: }
522: my @orderspaces = ();
523: foreach my $key (sort(keys(%outhash))) {
524: if ($key=~/^home_(.+)$/) {
525: if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) {
526: unshift(@orderspaces,$1);
527: } else {
528: push(@orderspaces,$1);
529: }
530: }
531: }
532: if ($home>1) {
533: $preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>';
534: }
535: foreach my $user (@orderspaces) {
536: if ($home==1) {
537: $preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />';
538: } else {
539: $preamble .= '<option value="'.$user.'">'.$user.' - '.
540: &Apache::loncommon::plainname(split(/\:/,$user)).'</option>';
541: }
542: }
543: unless ($home==1) {
544: $preamble .= '</select></fieldset></div>'."\n";
545: }
546: my $title=$origcrsdata{'description'};
547: $title=~s/[\/\s]+/\_/gs;
548: $title=&clean($title);
549: $preamble .= '<div class="LC_left_float">'.
550: '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.
551: '<input type="text" size="50" name="authorfolder" value="'.
552: $title.'" />'.
553: '</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n";
554: my %uploadedfiles;
555: &tiehash();
556: foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
557: my ($ext)=($file=~/\.(\w+)$/);
558: # FIXME Check supplemental here
559: my $title=$hash{'title_'.$hash{
560: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
561: if (!$title) {
562: $title=$file;
563: } else {
564: $title=~s|/|_|g;
565: }
566: $title=~s/\.(\w+)$//;
567: $title=&clean($title);
568: $title.='.'.$ext;
569: # $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
570: $uploadedfiles{$file} = $title;
571: }
572: &untiehash();
573: $r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef,
574: undef,undef,$preamble,$home,\%uploadedfiles));
575: }
1.329 droeschl 576: }
1.484 raeburn 577: $r->print(&endContentScreen());
1.329 droeschl 578: }
579:
1.484.2.43 raeburn 580: sub recurse_html {
581: my ($mm,$prefix,$currdirpath,$currurlpath,$container,$item,$replacehash,$deps) = @_;
582: return unless ((ref($replacehash) eq 'HASH') && (ref($deps) eq 'HASH'));
583: my (%allfiles,%codebase);
584: if (&Apache::lonnet::extract_embedded_items($currdirpath,\%allfiles,\%codebase) eq 'ok') {
585: if (keys(%allfiles)) {
586: foreach my $dependency (keys(%allfiles)) {
587: next if (($dependency =~ m{^/(res|adm)/}) || ($dependency =~ m{^https?://}));
588: my ($depurl,$relfile,$newcontainer);
589: if ($dependency =~ m{^/}) {
590: if ($dependency =~ m{^\Q$currurlpath/\E(.+)$}) {
591: $relfile = $1;
592: if ($dependency =~ m{^\Q$prefix\E(.+)$}) {
593: $newcontainer = $1;
594: next if ($replacehash->{$newcontainer});
595: }
596: $depurl = $dependency;
597: } else {
598: next;
599: }
600: } else {
601: $relfile = $dependency;
602: $depurl = $currurlpath;
603: $depurl =~ s{[^/]+$}{};
604: $depurl .= $dependency;
605: ($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$});
606: }
607: next if ($relfile eq '');
608: my $newname = $replacehash->{$container};
609: $newname =~ s{[^/]+$}{};
610: $replacehash->{$newcontainer} = $newname.$relfile;
611: $deps->{$item}{$newcontainer} = 1;
612: my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$});
613: my $depfile = &Apache::lonnet::filelocation('',$depurl);
614: my $type = $mm->checktype_filename($depfile);
615: if ($type eq 'text/html') {
616: &recurse_html($mm,$prefix,$depfile,$newurlpath,$newcontainer,$item,$replacehash,$deps);
617: }
618: }
619: }
620: }
621: return;
622: }
623:
1.329 droeschl 624: sub group_import {
1.484.2.72.2. (raeburn 625:): my ($coursenum, $coursedom, $folder, $container, $caller, $ltitoolsref, @files) = @_;
1.484.2.23 raeburn 626: my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap,
627: %removeparam,$importuploaded,$fixuperrors);
628: $allmaps = {};
1.329 droeschl 629: while (@files) {
630: my ($name, $url, $residx) = @{ shift(@files) };
1.344 bisitz 631: if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
1.329 droeschl 632: && ($caller eq 'londocs')
633: && (!&Apache::lonnet::stat_file($url))) {
1.364 bisitz 634:
1.329 droeschl 635: my $errtext = '';
636: my $fatal = 0;
637: my $newmapstr = '<map>'."\n".
638: '<resource id="1" src="" type="start"></resource>'."\n".
639: '<link from="1" to="2" index="1"></link>'."\n".
640: '<resource id="2" src="" type="finish"></resource>'."\n".
641: '</map>';
642: $env{'form.output'}=$newmapstr;
643: my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
644: 'output',$1.$2);
1.484.2.27 raeburn 645: if ($result !~ m{^/uploaded/}) {
1.329 droeschl 646: $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
647: $fatal = 2;
648: }
649: if ($fatal) {
650: return ($errtext,$fatal);
651: }
652: }
653: if ($url) {
1.484.2.72.2. (raeburn 654:): if ($url =~ m{^(/adm/$coursedom/$coursenum/(\d+)/ext\.tool)\:?(.*)$}) {
655:): $url = $1;
656:): my $marker = $2;
657:): my $info = $3;
658:): my ($toolid,%toolhash,%toolsettings);
659:): my @extras = ('linktext','explanation','crslabel','crstitle');
660:): my @toolinfo = split(/:/,$info);
661:): if ($residx) {
662:): %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
663:): $toolid = $toolsettings{'id'};
664:): } else {
665:): $toolid = shift(@toolinfo);
666:): }
667:): $toolid =~ s/\D//g;
668:): ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'},
669:): $toolhash{'linktext'},$toolhash{'explanation'},
670:): $toolhash{'crslabel'},$toolhash{'crstitle'}) = @toolinfo;
671:): foreach my $item (@extras) {
672:): $toolhash{$item} = &unescape($toolhash{$item});
673:): }
674:): if (ref($ltitoolsref) eq 'HASH') {
675:): my @deleted;
676:): if (ref($ltitoolsref->{$toolid}) eq 'HASH') {
677:): $toolhash{'id'} = $toolid;
678:): if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'tab') ||
679:): ($toolhash{'target'} eq 'window')) {
680:): if ($toolhash{'target'} eq 'window') {
681:): foreach my $item ('width','height') {
682:): $toolhash{$item} =~ s/^\s+//;
683:): $toolhash{$item} =~ s/\s+$//;
684:): if ($toolhash{$item} =~ /\D/) {
685:): delete($toolhash{$item});
686:): if ($residx) {
687:): if ($toolsettings{$item}) {
688:): push(@deleted,$item);
689:): }
690:): }
691:): }
692:): }
693:): }
694:): } elsif ($residx) {
695:): $toolhash{'target'} = $toolsettings{'target'};
696:): if ($toolhash{'target'} eq 'window') {
697:): foreach my $item ('width','height') {
698:): $toolhash{$item} = $toolsettings{$item};
699:): }
700:): }
701:): } elsif (ref($ltitoolsref->{$toolid}->{'display'}) eq 'HASH') {
702:): $toolhash{'target'} = $ltitoolsref->{$toolid}->{'display'}->{'target'};
703:): if ($toolhash{'target'} eq 'window') {
704:): $toolhash{'width'} = $ltitoolsref->{$toolid}->{'display'}->{'width'};
705:): $toolhash{'height'} = $ltitoolsref->{$toolid}->{'display'}->{'height'};
706:): }
707:): }
708:): if ($toolhash{'target'} eq 'iframe') {
709:): foreach my $item ('width','height','linktext','explanation') {
710:): delete($toolhash{$item});
711:): if ($residx) {
712:): if ($toolsettings{$item}) {
713:): push(@deleted,$item);
714:): }
715:): }
716:): }
717:): } elsif ($toolhash{'target'} eq 'tab') {
718:): foreach my $item ('width','height') {
719:): delete($toolhash{$item});
720:): if ($residx) {
721:): if ($toolsettings{$item}) {
722:): push(@deleted,$item);
723:): }
724:): }
725:): }
726:): }
727:): if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') {
728:): foreach my $item ('label','title','linktext','explanation') {
729:): my $crsitem;
730:): if (($item eq 'label') || ($item eq 'title')) {
731:): $crsitem = 'crs'.$item;
732:): } else {
733:): $crsitem = $item;
734:): }
735:): if ($ltitoolsref->{$toolid}->{'crsconf'}->{$item}) {
736:): $toolhash{$crsitem} =~ s/^\s+//;
737:): $toolhash{$crsitem} =~ s/\s+$//;
738:): if ($toolhash{$crsitem} eq '') {
739:): delete($toolhash{$crsitem});
740:): }
741:): } else {
742:): delete($toolhash{$crsitem});
743:): }
744:): if (($residx) && (exists($toolsettings{$crsitem}))) {
745:): unless (exists($toolhash{$crsitem})) {
746:): push(@deleted,$crsitem);
747:): }
748:): }
749:): }
750:): }
751:): my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum);
752:): if ($putres eq 'ok') {
753:): if (@deleted) {
754:): &Apache::lonnet::del('exttool_'.$marker,\@deleted,$coursedom,$coursenum);
755:): }
756:): }
757:): }
758:): }
759:): }
1.484.2.23 raeburn 760: if (($caller eq 'londocs') &&
761: ($folder =~ /^default/)) {
1.484.2.27 raeburn 762: if (($url =~ /\.(page|sequence)$/) && (!$donechk)) {
1.484.2.23 raeburn 763: my $chome = &Apache::lonnet::homeserver($coursenum,$coursedom);
764: my $cid = $coursedom.'_'.$coursenum;
765: $allmaps =
766: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
767: $chome,$cid);
768: $donechk = 1;
769: }
770: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) {
1.484.2.72.2. (raeburn 771:): &contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap,
772:): \%removeparam,\%addedmaps,\%hierarchy,\%titles,$allmaps);
1.484.2.23 raeburn 773: $importuploaded = 1;
774: } elsif ($url =~ m{^/res/.+\.(page|sequence)$}) {
775: next if ($allmaps->{$url});
776: }
777: }
1.344 bisitz 778: if (!$residx
1.329 droeschl 779: || defined($LONCAPA::map::zombies[$residx])) {
780: $residx = &LONCAPA::map::getresidx($url,$residx);
781: push(@LONCAPA::map::order, $residx);
782: }
783: my $ext = 'false';
784: if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
785: $name = &LONCAPA::map::qtunescape($name);
1.484.2.27 raeburn 786: if ($name eq '') {
1.484.2.30 raeburn 787: $name = &LONCAPA::map::qtunescape(&mt('Web Page'));
1.484.2.27 raeburn 788: }
789: if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) {
790: my $filepath = $1;
791: my $fname = $name;
792: if ($fname =~ /^\W+$/) {
793: $fname = 'web';
794: } else {
795: $fname =~ s/\W/_/g;
796: }
1.484.2.62 raeburn 797: if (length($fname) > 15) {
1.484.2.27 raeburn 798: $fname = substr($fname,0,14);
799: }
800: my $initialtext = &mt('Replace with your own content.');
801: my $newhtml = <<END;
1.484.2.31 raeburn 802: <html>
1.484.2.27 raeburn 803: <head>
804: <title>$name</title>
805: </head>
806: <body bgcolor="#ffffff">
807: $initialtext
808: </body>
809: </html>
810: END
811: $env{'form.output'}=$newhtml;
812: my $result =
813: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
814: 'output',
815: "$filepath/$residx/$fname.html");
816: if ($result =~ m{^/uploaded/}) {
817: $url = $result;
818: if ($filepath =~ /^supplemental/) {
819: $name = time.'___&&&___'.$env{'user.name'}.'___&&&___'.
820: $env{'user.domain'}.'___&&&___'.$name;
821: }
822: } else {
823: return (&mt('Failed to save new web page.'),1);
824: }
825: }
1.484.2.30 raeburn 826: $url = &LONCAPA::map::qtunescape($url);
1.344 bisitz 827: $LONCAPA::map::resources[$residx] =
1.329 droeschl 828: join(':', ($name, $url, $ext, 'normal', 'res'));
829: }
830: }
1.484.2.23 raeburn 831: if ($importuploaded) {
832: my %import_errors;
833: my %updated = (
834: removefrommap => \%removefrommap,
835: removeparam => \%removeparam,
836: );
1.484.2.26 raeburn 837: my ($result,$msgsarray,$lockerror) =
838: &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
1.484.2.23 raeburn 839: if (keys(%import_errors) > 0) {
840: $fixuperrors =
841: '<p span class="LC_warning">'."\n".
842: &mt('The following files are either dependencies of a web page or references within a folder and/or composite page for which errors occurred during import:')."\n".
843: '<ul>'."\n";
844: foreach my $key (sort(keys(%import_errors))) {
845: $fixuperrors .= '<li>'.$key.'</li>'."\n";
846: }
847: $fixuperrors .= '</ul></p>'."\n";
848: }
1.484.2.26 raeburn 849: if (ref($msgsarray) eq 'ARRAY') {
850: if (@{$msgsarray} > 0) {
851: $fixuperrors .= '<p class="LC_info">'.
852: join('<br />',@{$msgsarray}).
853: '</p>';
854: }
855: }
856: if ($lockerror) {
857: $fixuperrors .= '<p class="LC_error">'.
858: $lockerror.
859: '</p>';
860: }
1.484.2.23 raeburn 861: }
862: my ($errtext,$fatal) =
863: &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
1.484.2.37 raeburn 864: unless ($fatal) {
865: if ($folder =~ /^supplemental/) {
866: &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
1.484.2.39 raeburn 867: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
868: $folder.'.'.$container);
1.484.2.37 raeburn 869: }
870: }
1.484.2.23 raeburn 871: return ($errtext,$fatal,$fixuperrors);
1.329 droeschl 872: }
873:
874: sub log_docs {
1.484.2.8 raeburn 875: return &Apache::lonnet::write_log('course','docslog',@_);
1.329 droeschl 876: }
877:
878: {
879: my @oldresources=();
880: my @oldorder=();
881: my $parmidx;
882: my %parmaction=();
883: my %parmvalue=();
884: my $changedflag;
885:
886: sub snapshotbefore {
887: @oldresources=@LONCAPA::map::resources;
888: @oldorder=@LONCAPA::map::order;
889: $parmidx=undef;
890: %parmaction=();
891: %parmvalue=();
892: $changedflag=0;
893: }
894:
895: sub remember_parms {
896: my ($idx,$parameter,$action,$value)=@_;
897: $parmidx=$idx;
898: $parmaction{$parameter}=$action;
899: $parmvalue{$parameter}=$value;
900: $changedflag=1;
901: }
902:
903: sub log_differences {
904: my ($plain)=@_;
905: my %storehash=('folder' => $plain,
906: 'currentfolder' => $env{'form.folder'});
907: if ($parmidx) {
908: $storehash{'parameter_res'}=$oldresources[$parmidx];
909: foreach my $parm (keys(%parmaction)) {
910: $storehash{'parameter_action_'.$parm}=$parmaction{$parm};
911: $storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
912: }
913: }
914: my $maxidx=$#oldresources;
915: if ($#LONCAPA::map::resources>$#oldresources) {
916: $maxidx=$#LONCAPA::map::resources;
917: }
918: for (my $idx=0; $idx<=$maxidx; $idx++) {
919: if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
920: $storehash{'before_resources_'.$idx}=$oldresources[$idx];
921: $storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
922: $changedflag=1;
923: }
924: if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
925: $storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
926: $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
927: $changedflag=1;
928: }
929: }
930: $storehash{'maxidx'}=$maxidx;
931: if ($changedflag) { &log_docs(\%storehash); }
932: }
933: }
934:
935: sub docs_change_log {
1.484.2.67 raeburn 936: my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit)=@_;
1.484.2.6 raeburn 937: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
1.484.2.67 raeburn 938: my $navmap;
1.483 raeburn 939: my $js = '<script type="text/javascript">'."\n".
940: '// <![CDATA['."\n".
941: &Apache::loncommon::display_filter_js('docslog')."\n".
1.484.2.67 raeburn 942: &editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag,
1.484.2.72.2. (raeburn 943:): $coursedom,$coursenum,'',$canedit,\$navmap)."\n".
1.483 raeburn 944: &history_tab_js()."\n".
1.484 raeburn 945: &Apache::lonratedt::editscript('simple')."\n".
1.483 raeburn 946: '// ]]>'."\n".
947: '</script>'."\n";
1.484 raeburn 948: $r->print(&Apache::loncommon::start_page('Content Change Log',$js));
949: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Change Log'));
1.484.2.7 raeburn 950: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484 raeburn 951: my %orderhash;
952: my $container='sequence';
953: my $pathitem;
1.484.2.19 raeburn 954: if ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 955: $container='page';
956: }
1.484.2.19 raeburn 957: my $folderpath=$env{'form.folderpath'};
958: if ($folderpath eq '') {
1.484.2.67 raeburn 959: $folderpath = &default_folderpath($coursenum,$coursedom,\$navmap);
1.484.2.19 raeburn 960: }
1.484.2.67 raeburn 961: undef($navmap);
1.484.2.19 raeburn 962: $pathitem = '<input type="hidden" name="folderpath" value="'.
963: &HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 964: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
965: my $jumpto = $readfile;
966: $jumpto =~ s{^/}{};
967: my $tid = 1;
1.484.2.7 raeburn 968: if ($supplementalflag) {
969: $tid = 2;
970: }
1.484.2.19 raeburn 971: my ($breadcrumbtrail) =
1.484.2.18 raeburn 972: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
1.484 raeburn 973: $r->print($breadcrumbtrail.
974: &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto,
975: $readfile));
1.329 droeschl 976: my %docslog=&Apache::lonnet::dump('nohist_docslog',
977: $env{'course.'.$env{'request.course.id'}.'.domain'},
978: $env{'course.'.$env{'request.course.id'}.'.num'});
979:
980: if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
981:
982: my %saveable_parameters = ('show' => 'scalar',);
983: &Apache::loncommon::store_course_settings('docs_log',
984: \%saveable_parameters);
985: &Apache::loncommon::restore_course_settings('docs_log',
986: \%saveable_parameters);
987: if (!$env{'form.show'}) { $env{'form.show'}=10; }
1.452 www 988: # FIXME: internationalization seems wrong here
1.329 droeschl 989: my %lt=('hiddenresource' => 'Resources hidden',
990: 'encrypturl' => 'URL hidden',
991: 'randompick' => 'Randomly pick',
992: 'randomorder' => 'Randomly ordered',
993: 'set' => 'set to',
994: 'del' => 'deleted');
1.484 raeburn 995: my $filter = &Apache::loncommon::display_filter('docslog')."\n".
996: $pathitem."\n".
997: '<input type="hidden" name="folder" value="'.$env{'form.folder'}.'" />'.
998: (' 'x2).'<input type="submit" value="'.&mt('Display').'" />';
999: $r->print('<div class="LC_left_float">'.
1000: '<fieldset><legend>'.&mt('Display of Content Changes').'</legend>'."\n".
1001: &makedocslogform($filter,1).
1002: '</fieldset></div><br clear="all" />');
1.329 droeschl 1003: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
1004: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
1005: &mt('After').'</th>'.
1006: &Apache::loncommon::end_data_table_header_row());
1007: my $shown=0;
1008: foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
1009: if ($env{'form.displayfilter'} eq 'currentfolder') {
1010: if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
1011: }
1012: my @changes=keys(%{$docslog{$id}{'logentry'}});
1013: if ($env{'form.displayfilter'} eq 'containing') {
1014: my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
1015: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
1016: foreach my $key (@changes) {
1017: $wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
1018: }
1.344 bisitz 1019: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
1.329 droeschl 1020: }
1021: my $count = 0;
1022: my $time =
1023: &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
1024: my $plainname =
1025: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
1026: $docslog{$id}{'exe_udom'});
1027: my $about_me_link =
1028: &Apache::loncommon::aboutmewrapper($plainname,
1029: $docslog{$id}{'exe_uname'},
1030: $docslog{$id}{'exe_udom'});
1031: my $send_msg_link='';
1032: if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
1033: || ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
1034: $send_msg_link ='<br />'.
1035: &Apache::loncommon::messagewrapper(&mt('Send message'),
1036: $docslog{$id}{'exe_uname'},
1037: $docslog{$id}{'exe_udom'});
1038: }
1039: $r->print(&Apache::loncommon::start_data_table_row());
1040: $r->print('<td>'.$time.'</td>
1041: <td>'.$about_me_link.
1042: '<br /><tt>'.$docslog{$id}{'exe_uname'}.
1043: ':'.$docslog{$id}{'exe_udom'}.'</tt>'.
1044: $send_msg_link.'</td><td>'.
1045: $docslog{$id}{'logentry'}{'folder'}.'</td><td>');
1.484.2.19 raeburn 1046: my $is_supp = 0;
1.484.2.7 raeburn 1047: if ($docslog{$id}{'logentry'}{'currentfolder'} =~ /^supplemental/) {
1048: $is_supp = 1;
1049: }
1.329 droeschl 1050: # Before
1051: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1052: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
1053: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
1054: if ($oldname ne $newname) {
1.484.2.7 raeburn 1055: my $shown = &LONCAPA::map::qtescape($oldname);
1056: if ($is_supp) {
1057: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1058: }
1059: $r->print($shown);
1.329 droeschl 1060: }
1061: }
1062: $r->print('<ul>');
1063: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1064: if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
1.484.2.7 raeburn 1065: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]);
1066: if ($is_supp) {
1067: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1068: }
1.484.2.19 raeburn 1069: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 1070: }
1071: }
1072: $r->print('</ul>');
1073: # After
1074: $r->print('</td><td>');
1075:
1076: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1077: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
1078: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
1079: if ($oldname ne '' && $oldname ne $newname) {
1.484.2.7 raeburn 1080: my $shown = &LONCAPA::map::qtescape($newname);
1081: if ($is_supp) {
1082: $shown = &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($newname));
1083: }
1084: $r->print($shown);
1.329 droeschl 1085: }
1.364 bisitz 1086: }
1.329 droeschl 1087: $r->print('<ul>');
1088: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1089: if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
1.484.2.7 raeburn 1090: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]);
1091: if ($is_supp) {
1092: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1093: }
1094: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 1095: }
1096: }
1097: $r->print('</ul>');
1098: if ($docslog{$id}{'logentry'}{'parameter_res'}) {
1099: $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
1100: foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
1101: if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
1.452 www 1102: # FIXME: internationalization seems wrong here
1.329 droeschl 1103: $r->print('<li>'.
1104: &mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
1105: $docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
1106: .'</li>');
1107: }
1108: }
1109: $r->print('</ul>');
1110: }
1111: # End
1112: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1113: $shown++;
1114: if (!($env{'form.show'} eq &mt('all')
1115: || $shown<=$env{'form.show'})) { last; }
1116: }
1.484 raeburn 1117: $r->print(&Apache::loncommon::end_data_table()."\n".
1118: &makesimpleeditform($pathitem)."\n".
1119: '</div></div>');
1120: $r->print(&endContentScreen());
1.329 droeschl 1121: }
1122:
1123: sub update_paste_buffer {
1.484.2.7 raeburn 1124: my ($coursenum,$coursedom,$folder) = @_;
1.484.2.57 raeburn 1125: my (@possibles,%removals,%cuts,$output);
1.484.2.30 raeburn 1126: if ($env{'form.multiremove'}) {
1127: $env{'form.multiremove'} =~ s/,$//;
1128: map { $removals{$_} = 1; } split(/,/,$env{'form.multiremove'});
1129: }
1130: if (($env{'form.multicopy'}) || ($env{'form.multicut'})) {
1131: if ($env{'form.multicut'}) {
1132: $env{'form.multicut'} =~ s/,$//;
1133: foreach my $item (split(/,/,$env{'form.multicut'})) {
1134: unless ($removals{$item}) {
1135: $cuts{$item} = 1;
1136: push(@possibles,$item.':cut');
1137: }
1138: }
1139: }
1140: if ($env{'form.multicopy'}) {
1141: $env{'form.multicopy'} =~ s/,$//;
1142: foreach my $item (split(/,/,$env{'form.multicopy'})) {
1143: unless ($removals{$item} || $cuts{$item}) {
1144: push(@possibles,$item.':copy');
1145: }
1146: }
1147: }
1148: } elsif ($env{'form.markcopy'}) {
1149: @possibles = split(/,/,$env{'form.markcopy'});
1150: }
1.329 droeschl 1151:
1.484.2.30 raeburn 1152: return if (@possibles == 0);
1.329 droeschl 1153: return if (!defined($env{'form.copyfolder'}));
1154:
1155: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1156: $env{'form.copyfolder'});
1157: return if ($fatal);
1158:
1.484.2.30 raeburn 1159: my %curr_groups = &Apache::longroup::coursegroups();
1160:
1161: # Retrieve current paste buffer suffixes.
1162: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1163: my (%pasteurls,@newpaste);
1164:
1165: # Construct identifiers for current contents of user's paste buffer
1166: if (@currpaste) {
1167: foreach my $suffix (@currpaste) {
1168: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1169: my $url = $env{'docs.markedcopy_url_'.$suffix};
1170: if (($cid =~ /^$match_domain(?:_)$match_courseid$/) &&
1171: ($url ne '')) {
1.484.2.41 raeburn 1172: $pasteurls{$cid.'_'.$url} = 1;
1.484.2.30 raeburn 1173: }
1174: }
1175: }
1176:
1177: # Mark items for copying (skip any items already in user's paste buffer)
1178: my %addtoenv;
1179:
1180: foreach my $item (@possibles) {
1181: my ($orderidx,$cmd) = split(/:/,$item);
1182: next if ($orderidx =~ /\D/);
1183: next unless (($cmd eq 'cut') || ($cmd eq 'copy') || ($cmd eq 'remove'));
1184: my ($title,$url)=split(':',$LONCAPA::map::resources[$orderidx]);
1185: my %denied = &action_restrictions($coursenum,$coursedom,
1186: &LONCAPA::map::qtescape($url),
1187: $env{'form.folderpath'},\%curr_groups);
1188: next if ($denied{'copy'});
1189: $url=~s{http(:|:)//https(:|:)//}{https$2//};
1190: next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$url}));
1191: my ($suffix,$errortxt,$locknotfreed) =
1192: &new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste');
1.484.2.57 raeburn 1193: if ($suffix ne '') {
1194: push(@newpaste,$suffix);
1195: } else {
1196: if ($locknotfreed) {
1197: return $locknotfreed;
1198: }
1.484.2.30 raeburn 1199: }
1200: if (&is_supplemental_title($title)) {
1201: &Apache::lonnet::appenv({'docs.markedcopy_supplemental_'.$suffix => $title});
1202: ($title) = &Apache::loncommon::parse_supplemental_title($title);
1203: }
1204:
1205: $addtoenv{'docs.markedcopy_title_'.$suffix} = $title,
1206: $addtoenv{'docs.markedcopy_url_'.$suffix} = $url,
1207: $addtoenv{'docs.markedcopy_cmd_'.$suffix} = $cmd,
1208: $addtoenv{'docs.markedcopy_crs_'.$suffix} = $env{'request.course.id'};
1209:
1210: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) {
1211: my $prefix = $1;
1212: my $subdir =$2;
1213: if ($subdir eq '') {
1214: $subdir = $prefix;
1.484.2.7 raeburn 1215: }
1.484.2.30 raeburn 1216: my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps);
1.484.2.72.2. (raeburn 1217:): &contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap,
1218:): \%removeparam,\%addedmaps,\%hierarchy,\%titles,\%allmaps);
1.484.2.30 raeburn 1219: if (ref($hierarchy{$url}) eq 'HASH') {
1220: my ($nested,$nestednames);
1221: &recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames);
1222: $nested =~ s/\&$//;
1223: $nestednames =~ s/\Q___&&&___\E$//;
1224: if ($nested ne '') {
1225: $addtoenv{'docs.markedcopy_nested_'.$suffix} = $nested;
1226: }
1227: if ($nestednames ne '') {
1228: $addtoenv{'docs.markedcopy_nestednames_'.$suffix} = $nestednames;
1229: }
1.484.2.7 raeburn 1230: }
1231: }
1.484.2.57 raeburn 1232: if ($locknotfreed) {
1233: $output = $locknotfreed;
1234: last;
1235: }
1.484.2.7 raeburn 1236: }
1.484.2.30 raeburn 1237: if (@newpaste) {
1238: $addtoenv{'docs.markedcopies'} = join(',',(@currpaste,@newpaste));
1239: }
1.484.2.7 raeburn 1240: &Apache::lonnet::appenv(\%addtoenv);
1.329 droeschl 1241: delete($env{'form.markcopy'});
1.484.2.57 raeburn 1242: return $output;
1.329 droeschl 1243: }
1244:
1.484.2.7 raeburn 1245: sub recurse_uploaded_maps {
1246: my ($url,$dir,$hierarchy,$titlesref,$nestref,$namesref) = @_;
1247: if (ref($hierarchy->{$url}) eq 'HASH') {
1248: my @maps = map { $hierarchy->{$url}{$_}; } sort { $a <=> $b } (keys(%{$hierarchy->{$url}}));
1249: my @titles = map { $titlesref->{$url}{$_}; } sort { $a <=> $b } (keys(%{$titlesref->{$url}}));
1250: my (@uploaded,@names,%shorter);
1251: for (my $i=0; $i<@maps; $i++) {
1252: my ($inner) = ($maps[$i] =~ m{^/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_(\d+)\.(?:page|sequence)$});
1253: if ($inner ne '') {
1254: push(@uploaded,$inner);
1255: push(@names,&escape($titles[$i]));
1256: $shorter{$maps[$i]} = $inner;
1257: }
1258: }
1259: $$nestref .= "$dir:".join(',',@uploaded).'&';
1260: $$namesref .= "$dir:".(join(',',@names)).'___&&&___';
1261: foreach my $map (@maps) {
1262: if ($shorter{$map} ne '') {
1263: &recurse_uploaded_maps($map,$shorter{$map},$hierarchy,$titlesref,$nestref,$namesref);
1264: }
1265: }
1266: }
1267: return;
1268: }
1269:
1.329 droeschl 1270: sub print_paste_buffer {
1.484.2.7 raeburn 1271: my ($r,$container,$folder,$coursedom,$coursenum) = @_;
1.484.2.30 raeburn 1272: return if (!defined($env{'docs.markedcopies'}));
1.329 droeschl 1273:
1.484.2.30 raeburn 1274: unless (($env{'form.pastemarked'}) || ($env{'form.clearmarked'})) {
1275: return if ($env{'docs.markedcopies'} eq '');
1.484.2.7 raeburn 1276: }
1277:
1.484.2.30 raeburn 1278: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1279: my ($pasteitems,@pasteable);
1.484.2.47 raeburn 1280: my $clipboardcount = 0;
1.484.2.7 raeburn 1281:
1.484.2.30 raeburn 1282: # Construct identifiers for current contents of user's paste buffer
1283: foreach my $suffix (@currpaste) {
1284: next if ($suffix =~ /\D/);
1285: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1286: my $url = $env{'docs.markedcopy_url_'.$suffix};
1287: if (($cid =~ /^$match_domain\_$match_courseid$/) &&
1288: ($url ne '')) {
1.484.2.47 raeburn 1289: $clipboardcount ++;
1.484.2.30 raeburn 1290: my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent,
1.484.2.72.2. (raeburn 1291:): $canpaste,$nopaste,$othercrs,$areachange,$is_exttool);
1.484.2.30 raeburn 1292: my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1];
1293: if ($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
1294: $is_external = 1;
1.484.2.72.2. (raeburn 1295:): } elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$}) {
1296:): $is_exttool = 1;
1.484.2.7 raeburn 1297: }
1.484.2.30 raeburn 1298: if ($folder =~ /^supplemental/) {
1299: $canpaste = &supp_pasteable($env{'docs.markedcopy_url_'.$suffix});
1300: unless ($canpaste) {
1301: $nopaste = &mt('Paste into Supplemental Content unavailable.');
1.484.2.7 raeburn 1302: }
1.484.2.30 raeburn 1303: } else {
1304: $canpaste = 1;
1.484.2.7 raeburn 1305: }
1.484.2.30 raeburn 1306: if ($canpaste) {
1307: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1308: my $srcdom = $1;
1309: my $srcnum = $2;
1310: my $rem = $3;
1311: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
1312: $othercourse = 1;
1313: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1.484.2.72.2. (raeburn 1314:): $othercrs = '<br />'.&mt('(from another course)');
1.484.2.30 raeburn 1315: } else {
1316: $canpaste = 0;
1317: $nopaste = &mt('Paste from another course unavailable.');
1.484.2.7 raeburn 1318: }
1319: }
1.484.2.30 raeburn 1320: if ($rem =~ m{^(default|supplemental)_?(\d*)\.(?:page|sequence)$}) {
1321: my $prefix = $1;
1322: $parent = $2;
1323: if ($folder !~ /^\Q$prefix\E/) {
1324: $areachange = 1;
1325: }
1326: $is_uploaded_map = 1;
1327: }
1.484.2.72.2. (raeburn 1328:): } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
1329:): ($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg|ext\.tool)$})) {
1330:): if ($cid ne $env{'request.course.id'}) {
1331:): my ($srcdom,$srcnum) = split(/_/,$cid);
1332:): if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1333:): if (($is_exttool) && ($srcdom ne $coursedom)) {
1334:): $canpaste = 0;
1335:): $nopaste = &mt('Paste from another domain unavailable.');
1336:): } else {
1337:): $othercrs = '<br />'.&mt('(from another course)');
1338:): }
1339:): } else {
1340:): $canpaste = 0;
1341:): $nopaste = &mt('Paste from another course unavailable.');
1342:): }
1343:): }
1.484.2.30 raeburn 1344: }
1345: }
1346: if ($canpaste) {
1347: push(@pasteable,$suffix);
1348: }
1349: my $buffer;
1.484.2.72.2. (raeburn 1350:): if ($is_external) {
1.484.2.30 raeburn 1351: $buffer = &mt('External Resource').': '.
1352: &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('.
1353: &LONCAPA::map::qtescape($url).')';
1.484.2.72.2. (raeburn 1354:): } elsif ($is_exttool) {
1355:): $buffer = &mt('External Tool').': '.
1356:): &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.484.2.30 raeburn 1357: } else {
1358: my $icon = &Apache::loncommon::icon($extension);
1359: if ($extension eq 'sequence' &&
1360: $url =~ m{/default_\d+\.sequence$}x) {
1361: $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
1362: $icon .= '/navmap.folder.closed.gif';
1363: }
1.484.2.57 raeburn 1364: my $title = $env{'docs.markedcopy_title_'.$suffix};
1365: if ($title eq '') {
1366: ($title) = ($url =~ m{/([^/]+)$});
1367: }
1.484.2.30 raeburn 1368: $buffer = '<img src="'.$icon.'" alt="" class="LC_icon" />'.
1369: ': '.
1370: &Apache::loncommon::parse_supplemental_title(
1.484.2.57 raeburn 1371: &LONCAPA::map::qtescape($title));
1.484.2.30 raeburn 1372: }
1373: $pasteitems .= '<div class="LC_left_float">';
1374: my ($options,$onclick);
1375: if (($canpaste) && (!$areachange) && (!$othercourse) &&
1376: ($env{'docs.markedcopy_cmd_'.$suffix} eq 'cut')) {
1377: if (($is_uploaded_map) ||
1378: ($url =~ /(bulletinboard|smppg)$/) ||
1379: ($url =~ m{^/uploaded/$coursedom/$coursenum/(?:docs|supplemental)/(.+)$})) {
1380: $options = &paste_options($suffix,$is_uploaded_map,$parent);
1381: $onclick= 'onclick="showOptions(this,'."'$suffix'".');" ';
1382: }
1383: }
1384: $pasteitems .= '<label><input type="checkbox" name="pasting" id="pasting_'.$suffix.'" value="'.$suffix.'" '.$onclick.'/>'.$buffer.'</label>';
1385: if ($nopaste) {
1386: $pasteitems .= $nopaste;
1387: } else {
1388: if ($othercrs) {
1389: $pasteitems .= $othercrs;
1390: }
1391: if ($options) {
1392: $pasteitems .= $options;
1.484.2.7 raeburn 1393: }
1394: }
1.484.2.30 raeburn 1395: $pasteitems .= '</div>';
1396: }
1397: }
1398: if ($pasteitems eq '') {
1399: &Apache::lonnet::delenv('docs.markedcopies');
1400: }
1401: my ($pasteform,$form_start,$buttons,$form_end);
1402: if ($pasteitems) {
1403: $pasteitems .= '<div style="padding:0;clear:both;margin:0;border:0"></div>';
1404: $form_start = '<form name="pasteform" action="/adm/coursedocs" method="post" onsubmit="return validateClipboard();">';
1405: if (@pasteable) {
1.484.2.47 raeburn 1406: my $value = &mt('Paste to current folder');
1407: if ($container eq 'page') {
1408: $value = &mt('Paste to current page');
1409: }
1410: $buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.(' 'x2);
1411: }
1.484.2.72.2. (raeburn 1412:): $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.(' 'x2);
1.484.2.47 raeburn 1413: if ($clipboardcount > 1) {
1414: $buttons .=
1415: '<span style="text-decoration:line-through">'.(' 'x20).'</span>'.(' 'x2).
1416: '<input type="button" name="checkallclip" value="'.&mt('Check all').'" style="height:20px;" onclick="checkClipboard();" />'.
1417: (' 'x2).
1418: '<input type="button" name="uncheckallclip" value="'.&mt('Uncheck all').'" style="height:20px;" onclick="uncheckClipboard();" />'.
1419: (' 'x2);
1.484.2.7 raeburn 1420: }
1.484.2.48 raeburn 1421: $form_end = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'.
1422: '</form>';
1.484.2.30 raeburn 1423: } else {
1424: $pasteitems = &mt('Clipboard is empty');
1425: }
1426: $r->print($form_start
1427: .'<fieldset>'
1428: .'<legend>'.&mt('Clipboard').(' ' x2).$buttons.'</legend>'
1429: .$pasteitems
1430: .'</fieldset>'
1431: .$form_end);
1432: }
1433:
1434: sub paste_options {
1435: my ($suffix,$is_uploaded_map,$parent) = @_;
1436: my ($copytext,$movetext);
1437: if ($is_uploaded_map) {
1438: $copytext = &mt('Copy to new folder');
1439: $movetext = &mt('Move old');
1440: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /bulletinboard$/) {
1441: $copytext = &mt('Copy to new board');
1442: $movetext = &mt('Move (not posts)');
1443: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /smppg$/) {
1444: $copytext = &mt('Copy to new page');
1445: $movetext = &mt('Move');
1.484.2.7 raeburn 1446: } else {
1.484.2.30 raeburn 1447: $copytext = &mt('Copy to new file');
1448: $movetext = &mt('Move');
1449: }
1450: my $output = '<br />'.
1451: '<span id="pasteoptionstext_'.$suffix.'" class="LC_fontsize_small LC_nobreak"></span>'.
1452: '<div id="pasteoptions_'.$suffix.'" class="LC_dccid" style="display:none;"><span class="LC_nobreak">'.(' 'x 4).
1453: '<label>'.
1454: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="new" checked="checked" />'.
1455: $copytext.'</label></span>'.(' 'x2).' '.
1456: '<span class="LC_nobreak"><label>'.
1457: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="move" />'.
1458: $movetext.'</label></span>';
1459: if (($is_uploaded_map) && ($env{'docs.markedcopy_nested_'.$suffix})) {
1460: $output .= '<br /><fieldset><legend>'.&mt('Folder to paste contains sub-folders').
1461: '</legend><table border="0">';
1462: my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1463: my @titles = split(/\Q___&&&___\E/,$env{'docs.markedcopy_nestednames_'.$suffix});
1464: my $lastdir = $parent;
1465: my %depths = (
1466: $lastdir => 0,
1467: );
1468: my (%display,%deps);
1469: for (my $i=0; $i<@pastemaps; $i++) {
1470: ($lastdir,my $subfolderstr) = split(/\:/,$pastemaps[$i]);
1471: my ($namedir,$esctitlestr) = split(/\:/,$titles[$i]);
1472: my @subfolders = split(/,/,$subfolderstr);
1473: $deps{$lastdir} = \@subfolders;
1474: my @subfoldertitles = map { &unescape($_); } split(/,/,$esctitlestr);
1475: my $depth = $depths{$lastdir} + 1;
1476: my $offset = int($depth * 4);
1477: my $indent = (' ' x $offset);
1478: for (my $j=0; $j<@subfolders; $j++) {
1479: $depths{$subfolders[$j]} = $depth;
1480: $display{$subfolders[$j]} =
1481: '<tr><td>'.$indent.$subfoldertitles[$j].' </td>'.
1482: '<td><label>'.
1483: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="new" checked="checked" />'.&mt('Copy to new').'</label>'.(' ' x2).
1484: '<label>'.
1485: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="move" />'.
1486: &mt('Move old').'</label>'.
1487: '</td></tr>';
1488: }
1489: }
1490: &recurse_print(\$output,$parent,\%deps,\%display);
1491: $output .= '</table></fieldset>';
1.329 droeschl 1492: }
1.484.2.30 raeburn 1493: $output .= '</div>';
1494: return $output;
1.329 droeschl 1495: }
1496:
1.484.2.7 raeburn 1497: sub recurse_print {
1.484.2.30 raeburn 1498: my ($outputref,$dir,$deps,$display) = @_;
1499: $$outputref .= $display->{$dir}."\n";
1.484.2.7 raeburn 1500: if (ref($deps->{$dir}) eq 'ARRAY') {
1501: foreach my $subdir (@{$deps->{$dir}}) {
1.484.2.30 raeburn 1502: &recurse_print($outputref,$subdir,$deps,$display);
1.484.2.7 raeburn 1503: }
1504: }
1505: }
1506:
1507: sub supp_pasteable {
1508: my ($url) = @_;
1509: if (($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//}) ||
1510: (($url =~ /\.sequence$/) && ($url =~ m{^/uploaded/})) ||
1511: ($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) ||
1512: ($url =~ m{^/adm/$match_domain/$match_username/aboutme}) ||
1.484.2.72.2. (raeburn 1513:): ($url =~ m{^/public/$match_domain/$match_courseid/syllabus}) ||
1514:): ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$})) {
1.484.2.7 raeburn 1515: return 1;
1516: }
1517: return;
1518: }
1519:
1520: sub paste_popup_js {
1.484.2.61 raeburn 1521: my %html_js_lt = &Apache::lonlocal::texthash(
1.484.2.30 raeburn 1522: show => 'Show Options',
1523: hide => 'Hide Options',
1.484.2.61 raeburn 1524: );
1525: my %js_lt = &Apache::lonlocal::texthash(
1.484.2.30 raeburn 1526: none => 'No items selected from clipboard.',
1.484.2.7 raeburn 1527: );
1.484.2.61 raeburn 1528: &html_escape(\%html_js_lt);
1529: &js_escape(\%html_js_lt);
1530: &js_escape(\%js_lt);
1.484.2.7 raeburn 1531: return <<"END";
1532:
1.484.2.30 raeburn 1533: function showPasteOptions(suffix) {
1534: document.getElementById('pasteoptions_'+suffix).style.display='block';
1.484.2.61 raeburn 1535: document.getElementById('pasteoptionstext_'+suffix).innerHTML = ' <a href="javascript:hidePasteOptions(\\''+suffix+'\\');" class="LC_menubuttons_link">$html_js_lt{'hide'}</a>';
1.484.2.7 raeburn 1536: return;
1537: }
1538:
1.484.2.30 raeburn 1539: function hidePasteOptions(suffix) {
1540: document.getElementById('pasteoptions_'+suffix).style.display='none';
1.484.2.61 raeburn 1541: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.484.2.7 raeburn 1542: return;
1543: }
1544:
1.484.2.30 raeburn 1545: function showOptions(caller,suffix) {
1546: if (document.getElementById('pasteoptionstext_'+suffix)) {
1547: if (caller.checked) {
1.484.2.61 raeburn 1548: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.484.2.30 raeburn 1549: } else {
1550: document.getElementById('pasteoptionstext_'+suffix).innerHTML ='';
1551: }
1552: if (document.getElementById('pasteoptions_'+suffix)) {
1553: document.getElementById('pasteoptions_'+suffix).style.display='none';
1554: }
1555: }
1556: return;
1557: }
1.484.2.7 raeburn 1558:
1.484.2.30 raeburn 1559: function validateClipboard() {
1560: var numchk = 0;
1561: if (document.pasteform.pasting.length > 1) {
1562: for (var i=0; i<document.pasteform.pasting.length; i++) {
1563: if (document.pasteform.pasting[i].checked) {
1564: numchk ++;
1565: }
1566: }
1567: } else {
1568: if (document.pasteform.pasting.type == 'checkbox') {
1569: if (document.pasteform.pasting.checked) {
1570: numchk ++;
1571: }
1572: }
1573: }
1574: if (numchk > 0) {
1575: return true;
1576: } else {
1.484.2.61 raeburn 1577: alert("$js_lt{'none'}");
1.484.2.30 raeburn 1578: return false;
1579: }
1.484.2.7 raeburn 1580: }
1581:
1.484.2.47 raeburn 1582: function checkClipboard() {
1583: if (document.pasteform.pasting.length > 1) {
1584: for (var i=0; i<document.pasteform.pasting.length; i++) {
1585: document.pasteform.pasting[i].checked = true;
1586: }
1587: }
1588: return;
1589: }
1590:
1591: function uncheckClipboard() {
1592: if (document.pasteform.pasting.length >1) {
1593: for (var i=0; i<document.pasteform.pasting.length; i++) {
1594: document.pasteform.pasting[i].checked = false;
1595: }
1596: }
1597: return;
1598: }
1599:
1.484.2.30 raeburn 1600: END
1601:
1602: }
1.484.2.7 raeburn 1603:
1.329 droeschl 1604: sub do_paste_from_buffer {
1.484.2.7 raeburn 1605: my ($coursenum,$coursedom,$folder,$container,$errors) = @_;
1.329 droeschl 1606:
1.484.2.30 raeburn 1607: # Array of items in paste buffer
1608: my (@currpaste,%pastebuffer,%allerrors);
1609: @currpaste = split(/,/,$env{'docs.markedcopies'});
1610:
1.484.2.7 raeburn 1611: # Early out if paste buffer is empty
1.484.2.30 raeburn 1612: if (@currpaste == 0) {
1.484.2.7 raeburn 1613: return ();
1.484.2.30 raeburn 1614: }
1615: map { $pastebuffer{$_} = 1; } @currpaste;
1616:
1617: # Array of items selected items to paste
1618: my @reqpaste = &Apache::loncommon::get_env_multiple('form.pasting');
1619:
1620: # Early out if nothing selected to paste
1621: if (@reqpaste == 0) {
1622: return();
1623: }
1624: my @topaste;
1625: foreach my $suffix (@reqpaste) {
1626: next if ($suffix =~ /\D/);
1627: next unless (exists($pastebuffer{$suffix}));
1628: push(@topaste,$suffix);
1.484.2.7 raeburn 1629: }
1630:
1.484.2.30 raeburn 1631: # Early out if nothing available to paste
1632: if (@topaste == 0) {
1633: return();
1.329 droeschl 1634: }
1635:
1.484.2.72.2. (raeburn 1636:): my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%notindom,%duplicate,
1.484.2.41 raeburn 1637: %prefixchg,%srcdom,%srcnum,%marktomove,$save_err,$lockerrors,$allresult);
1.484.2.7 raeburn 1638:
1.484.2.30 raeburn 1639: foreach my $suffix (@topaste) {
1640: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1.484.2.72.2. (raeburn 1641:): my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.484.2.30 raeburn 1642: # Supplemental content may only include certain types of content
1643: # Early out if pasted content is not supported in Supplemental area
1644: if ($folder =~ /^supplemental/) {
1645: unless (&supp_pasteable($url)) {
1646: $notinsupp{$suffix} = 1;
1647: next;
1648: }
1649: }
1650: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/}) {
1651: my $srcd = $1;
1652: my $srcn = $2;
1.484.2.7 raeburn 1653: # When paste buffer was populated using an active role in a different course
1.484.2.30 raeburn 1654: # check for mdc privilege in the course from which the resource was pasted
1655: if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1656: unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1657: $notincrs{$suffix} = 1;
1658: next;
1659: }
1.329 droeschl 1660: }
1.484.2.30 raeburn 1661: $srcdom{$suffix} = $srcd;
1662: $srcnum{$suffix} = $srcn;
1.484.2.72.2. (raeburn 1663:): } elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$}) {
1664:): my ($srcd,$srcn) = split(/_/,$cid);
1665:): # When paste buffer was populated using an active role in a different course
1666:): # check for mdc privilege in the course from which the resource was pasted
1667:): if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1668:): unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1669:): $notincrs{$suffix} = 1;
1670:): next;
1671:): }
1672:): }
1673:): # When buffer was populated using an active role in a different course
1674:): # disallow pasting of External Tool if course is in a different domain.
1675:): if ($srcd ne $coursedom) {
1676:): $notindom{$suffix} = 1;
1677:): next;
1678:): }
1679:): $srcdom{$suffix} = $srcd;
1680:): $srcnum{$suffix} = $srcn;
1.484.2.30 raeburn 1681: }
1682: push(@dopaste,$suffix);
1683: if ($url=~/\.(page|sequence)$/) {
1684: $is_map{$suffix} = 1;
1.329 droeschl 1685: }
1.484.2.30 raeburn 1686:
1687: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/([^/]+)}) {
1688: my $oldprefix = $1;
1.484.2.19 raeburn 1689: # When pasting content from Main Content to Supplemental Content and vice versa
1.484.2.7 raeburn 1690: # URLs will contain different paths (which depend on whether pasted item is
1.484.2.72.2. (raeburn 1691:): # a folder/page or a document).
1.484.2.30 raeburn 1692: if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) {
1693: $prefixchg{$suffix} = 'docstosupp';
1694: } elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) {
1695: $prefixchg{$suffix} = 'supptodocs';
1696: }
1.484.2.7 raeburn 1697:
1698: # If pasting an uploaded map, get list of contained uploaded maps.
1.484.2.30 raeburn 1699: if ($env{'docs.markedcopy_nested_'.$suffix}) {
1700: my @nested;
1701: my ($type) = ($oldprefix =~ /^(default|supplemental)/);
1702: my @items = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1703: my @deps = map { /\d+:([\d,]+$)/ } @items;
1704: foreach my $dep (@deps) {
1705: if ($dep =~ /,/) {
1706: push(@nested,split(/,/,$dep));
1707: } else {
1708: push(@nested,$dep);
1709: }
1.484.2.7 raeburn 1710: }
1.484.2.30 raeburn 1711: foreach my $item (@nested) {
1712: if ($env{'form.docs.markedcopy_'.$suffix.'_'.$item} eq 'move') {
1713: push(@{$marktomove{$suffix}},$type.'_'.$item);
1714: }
1.484.2.7 raeburn 1715: }
1716: }
1.329 droeschl 1717: }
1.484.2.7 raeburn 1718: }
1719:
1.484.2.30 raeburn 1720: # Early out if nothing available to paste
1721: if (@dopaste == 0) {
1722: return ();
1723: }
1724:
1725: # Populate message hash and hashes used for main content <=> supplemental content
1726: # changes
1727:
1728: %msgs = &Apache::lonlocal::texthash (
1729: notinsupp => 'Paste failed: content type is not supported within Supplemental Content',
1730: notincrs => 'Paste failed: Item is from a different course which you do not have rights to edit.',
1.484.2.72.2. (raeburn 1731:): notindom => 'Paste failed: Item is an external tool from a course in a different donain.',
1.484.2.30 raeburn 1732: duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.',
1733: );
1734:
1735: %before = (
1736: docstosupp => {
1737: map => 'default',
1738: doc => 'docs',
1739: },
1740: supptodocs => {
1741: map => 'supplemental',
1742: doc => 'supplemental',
1743: },
1744: );
1745:
1746: %after = (
1747: docstosupp => {
1748: map => 'supplemental',
1749: doc => 'supplemental'
1750: },
1751: supptodocs => {
1752: map => 'default',
1753: doc => 'docs',
1754: },
1755: );
1756:
1757: # Retrieve information about all course maps in main content area
1758:
1759: my $allmaps = {};
1760: if ($folder =~ /^default/) {
1761: $allmaps =
1762: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
1763: $env{"course.$env{'request.course.id'}.home"},
1764: $env{'request.course.id'});
1765: }
1766:
1767: my (@toclear,%mapurls,%lockerrs,%msgerrs,%results);
1768:
1769: # Loop over the items to paste
1770: foreach my $suffix (@dopaste) {
1.484.2.7 raeburn 1771: # Maps need to be copied first
1.484.2.30 raeburn 1772: my (%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies,
1773: %dbcopies,%zombies,%params,%docmoves,%mapmoves,%mapchanges,%newsubdir,
1774: %newurls,%tomove);
1775: if (ref($marktomove{$suffix}) eq 'ARRAY') {
1776: map { $tomove{$_} = 1; } @{$marktomove{$suffix}};
1777: }
1778: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1779: my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.484.2.72.2. (raeburn 1780:): my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.484.2.30 raeburn 1781: my $oldurl = $url;
1782: if ($is_map{$suffix}) {
1.484.2.7 raeburn 1783: # If pasting a map, check if map contains other maps
1.484.2.30 raeburn 1784: my (%hierarchy,%titles);
1.484.2.72.2. (raeburn 1785:): &contained_map_check($url,$folder,$coursenum,$coursedom,
1786:): \%removefrommap,\%removeparam,\%addedmaps,
1787:): \%hierarchy,\%titles,$allmaps);
1.484.2.30 raeburn 1788: if ($url=~ m{^/uploaded/}) {
1789: my $newurl;
1790: unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
1791: ($newurl,my $error) =
1792: &get_newmap_url($url,$folder,$prefixchg{$suffix},$coursedom,
1793: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1794: \$title,$allmaps,\%newurls);
1795: if ($error) {
1796: $allerrors{$suffix} = $error;
1797: next;
1798: }
1799: if ($newurl ne '') {
1800: if ($newurl ne $url) {
1801: if ($newurl =~ /(?:default|supplemental)_(\d+).(?:sequence|page)$/) {
1802: $newsubdir{$url} = $1;
1803: }
1804: $mapchanges{$url} = 1;
1.484.2.7 raeburn 1805: }
1806: }
1807: }
1.484.2.30 raeburn 1808: if (($srcdom{$suffix} ne $coursedom) ||
1809: ($srcnum{$suffix} ne $coursenum) ||
1810: ($prefixchg{$suffix}) || (($newurl ne '') && ($newurl ne $url))) {
1811: unless (&url_paste_fixups($url,$folder,$prefixchg{$suffix},
1812: $coursedom,$coursenum,$srcdom{$suffix},
1813: $srcnum{$suffix},$allmaps,\%rewrites,
1814: \%retitles,\%copies,\%dbcopies,
1815: \%zombies,\%params,\%mapmoves,
1816: \%mapchanges,\%tomove,\%newsubdir,
1817: \%newurls)) {
1818: $mapmoves{$url} = 1;
1819: }
1820: $url = $newurl;
1821: } elsif ($env{'docs.markedcopy_nested_'.$suffix}) {
1822: &url_paste_fixups($url,$folder,$prefixchg{$suffix},$coursedom,
1823: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1824: $allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies,
1825: \%zombies,\%params,\%mapmoves,\%mapchanges,
1826: \%tomove,\%newsubdir,\%newurls);
1827: }
1828: } elsif ($url=~m {^/res/}) {
1.484.2.72.2. (raeburn 1829:): # published map can only exist once, so remove from paste buffer when done
1.484.2.30 raeburn 1830: push(@toclear,$suffix);
1831: # if pasting published map (main content area only) check map not already in course
1832: if ($folder =~ /^default/) {
1833: if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) {
1834: $duplicate{$suffix} = 1;
1835: next;
1836: }
1.484.2.7 raeburn 1837: }
1838: }
1839: }
1.484.2.72.2. (raeburn 1840:): if ($url=~ m{/(ext\.tool)$}) {
1.484.2.30 raeburn 1841: my $prefix = $1;
1.484.2.72.2. (raeburn 1842:): my $fromothercrs;
1.484.2.30 raeburn 1843: #need to copy the db contents to a new one, unless this is a move.
1844: my %info = (
1845: src => $url,
1846: cdom => $coursedom,
1847: cnum => $coursenum,
1848: );
1.484.2.72.2. (raeburn 1849:): if (($srcdom{$suffix} =~ /^$match_domain$/) && ($srcnum{$suffix} =~ /^$match_courseid$/)) {
1850:): unless (($srcdom{$suffix} eq $coursedom) && ($srcnum{$suffix} eq $coursenum)) {
1851:): $fromothercrs = 1;
1852:): $info{'cdom'} = $srcdom{$suffix};
1853:): $info{'cnum'} = $srcnum{$suffix};
1854:): }
1855:): }
1856:): unless (($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') && (!$fromothercrs)) {
1.484.2.30 raeburn 1857: my (%lockerr,$msg);
1858: my ($newurl,$result,$errtext) =
1859: &dbcopy(\%info,$coursedom,$coursenum,\%lockerr);
1860: if ($result eq 'ok') {
1861: $url = $newurl;
1862: $title=&mt('Copy of').' '.$title;
1863: } else {
1.484.2.72.2. (raeburn 1864:): if ($prefix eq 'ext.tool') {
1865:): $msg = &mt('Paste failed: An error occurred when copying the external tool.').' '.$errtext;
1.484.2.30 raeburn 1866: }
1867: $results{$suffix} = $result;
1868: $msgerrs{$suffix} = $msg;
1869: $lockerrs{$suffix} = $lockerr{$prefix};
1870: next;
1871: }
1872: if ($lockerr{$prefix}) {
1873: $lockerrs{$suffix} = $lockerr{$prefix};
1.484.2.26 raeburn 1874: }
1.484.2.7 raeburn 1875: }
1.484.2.30 raeburn 1876: }
1877: $title = &LONCAPA::map::qtunescape($title);
1878: my $ext='false';
1879: if ($url=~m{^http(|s)://}) { $ext='true'; }
1880: if ($env{'docs.markedcopy_supplemental_'.$suffix}) {
1881: if ($folder !~ /^supplemental/) {
1882: (undef,undef,$title) =
1883: &Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental_'.$suffix});
1884: }
1885: } else {
1886: if ($folder=~/^supplemental/) {
1887: $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
1888: $env{'user.domain'}.'___&&&___'.$title;
1.484.2.26 raeburn 1889: }
1890: }
1.484.2.7 raeburn 1891:
1892: # For uploaded files (excluding pages/sequences) path in copied file is changed
1893: # if paste is from Main to Supplemental (or vice versa), or if pasting between
1894: # courses.
1895:
1.484.2.30 raeburn 1896: unless ($is_map{$suffix}) {
1897: my $newidx;
1.329 droeschl 1898: # Now insert the URL at the bottom
1.484.2.30 raeburn 1899: $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
1900: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(.+)$}) {
1901: my $relpath = $1;
1902: if ($relpath ne '') {
1903: my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$});
1904: my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/);
1905: my $newprefix = $newloc;
1906: if ($newloc eq 'default') {
1907: $newprefix = 'docs';
1908: }
1909: if ($newdocsdir eq '') {
1910: $newdocsdir = 'default';
1911: }
1912: if (($prefixchg{$suffix}) ||
1913: ($srcdom{$suffix} ne $coursedom) ||
1914: ($srcnum{$suffix} ne $coursenum) ||
1915: ($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) {
1916: my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";
1917: $url =
1918: &Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath,
1919: &Apache::lonnet::getfile($oldurl));
1920: if ($url eq '/adm/notfound.html') {
1921: $msgs{$suffix} = &mt('Paste failed: an error occurred saving the file.');
1922: next;
1923: } else {
1924: my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$});
1925: $newsubpath =~ s{/+$}{/};
1926: $docmoves{$oldurl} = $newsubpath;
1927: }
1.484.2.7 raeburn 1928: }
1929: }
1930: }
1.484.2.30 raeburn 1931: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
1932: ':'.$ext.':normal:res';
1933: push(@LONCAPA::map::order,$newidx);
1934: # Store the result
1935: my ($errtext,$fatal) =
1936: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1937: if ($fatal) {
1938: $save_err .= $errtext;
1939: $allresult = 'fail';
1.484.2.7 raeburn 1940: }
1.329 droeschl 1941: }
1.484.2.30 raeburn 1942:
1943: # Apply any changes to maps, or copy dependencies for uploaded HTML pages
1944: unless ($allresult eq 'fail') {
1945: my %updated = (
1946: rewrites => \%rewrites,
1947: zombies => \%zombies,
1948: removefrommap => \%removefrommap,
1949: removeparam => \%removeparam,
1950: dbcopies => \%dbcopies,
1951: retitles => \%retitles,
1952: );
1953: my %info = (
1954: newsubdir => \%newsubdir,
1955: params => \%params,
1956: );
1957: if ($prefixchg{$suffix}) {
1958: $info{'before'} = $before{$prefixchg{$suffix}};
1959: $info{'after'} = $after{$prefixchg{$suffix}};
1960: }
1961: my %moves = (
1962: copies => \%copies,
1963: docmoves => \%docmoves,
1964: mapmoves => \%mapmoves,
1965: );
1966: (my $result,$msgs{$suffix},my $lockerror) =
1967: &apply_fixups($folder,$is_map{$suffix},$coursedom,$coursenum,$errors,
1968: \%updated,\%info,\%moves,$prefixchg{$suffix},$oldurl,
1969: $url,'paste');
1970: $lockerrors .= $lockerror;
1971: if ($result eq 'ok') {
1972: if ($is_map{$suffix}) {
1973: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1974: $folder.'.'.$container);
1975: if ($fatal) {
1976: $allresult = 'failread';
1977: } else {
1978: if ($#LONCAPA::map::order<1) {
1979: my $idx=&LONCAPA::map::getresidx();
1980: if ($idx<=0) { $idx=1; }
1981: $LONCAPA::map::order[0]=$idx;
1982: $LONCAPA::map::resources[$idx]='';
1983: }
1984: my $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
1985: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
1986: ':'.$ext.':normal:res';
1987: push(@LONCAPA::map::order,$newidx);
1.484.2.7 raeburn 1988:
1989: # Store the result
1.484.2.30 raeburn 1990: my ($errtext,$fatal) =
1991: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1992: if ($fatal) {
1993: $save_err .= $errtext;
1994: $allresult = 'failstore';
1995: }
1996: }
1997: }
1998: if ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
1999: push(@toclear,$suffix);
2000: }
2001: }
1.329 droeschl 2002: }
2003: }
1.484.2.30 raeburn 2004: &clear_from_buffer(\@toclear,\@currpaste);
2005: my $msgsarray;
2006: foreach my $suffix (keys(%msgs)) {
2007: if (ref($msgs{$suffix}) eq 'ARRAY') {
2008: $msgsarray .= join(',',@{$msgs{$suffix}});
2009: }
2010: }
2011: return ($allresult,$save_err,$msgsarray,$lockerrors);
2012: }
2013:
2014: sub do_buffer_empty {
2015: my @currpaste = split(/,/,$env{'docs.markedcopies'});
2016: if (@currpaste == 0) {
2017: return &mt('Clipboard is already empty');
2018: }
2019: my @toclear = &Apache::loncommon::get_env_multiple('form.pasting');
2020: if (@toclear == 0) {
2021: return &mt('Nothing selected to clear from clipboard');
2022: }
2023: my $numdel = &clear_from_buffer(\@toclear,\@currpaste);
2024: if ($numdel) {
2025: return &mt('[quant,_1,item] cleared from clipboard',$numdel);
2026: } else {
2027: return &mt('Clipboard unchanged');
1.484.2.7 raeburn 2028: }
1.484.2.30 raeburn 2029: return;
2030: }
2031:
2032: sub clear_from_buffer {
2033: my ($toclear,$currpaste) = @_;
2034: return unless ((ref($toclear) eq 'ARRAY') && (ref($currpaste) eq 'ARRAY'));
2035: my %pastebuffer;
2036: map { $pastebuffer{$_} = 1; } @{$currpaste};
2037: my $numdel = 0;
2038: foreach my $suffix (@{$toclear}) {
2039: next if ($suffix =~ /\D/);
2040: next unless (exists($pastebuffer{$suffix}));
2041: my $regexp = 'docs.markedcopy_[a-z]+_'.$suffix;
2042: if (&Apache::lonnet::delenv($regexp,1) eq 'ok') {
2043: delete($pastebuffer{$suffix});
2044: $numdel ++;
2045: }
2046: }
2047: my $newbuffer = join(',',sort(keys(%pastebuffer)));
2048: &Apache::lonnet::appenv({'docs.markedcopies' => $newbuffer});
2049: return $numdel;
1.484.2.7 raeburn 2050: }
2051:
2052: sub get_newmap_url {
2053: my ($url,$folder,$prefixchg,$coursedom,$coursenum,$srcdom,$srcnum,
2054: $titleref,$allmaps,$newurls) = @_;
2055: my $newurl;
2056: if ($url=~ m{^/uploaded/}) {
2057: $$titleref=&mt('Copy of').' '.$$titleref;
2058: }
2059: my $now = time;
2060: my $suffix=$$.int(rand(100)).$now;
2061: my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
2062: if ($oldid =~ m{^(/uploaded/$match_domain/$match_courseid/)(\D+)(\d+)$}) {
2063: my $path = $1;
2064: my $prefix = $2;
2065: my $ancestor = $3;
2066: if (length($ancestor) > 10) {
2067: $ancestor = substr($ancestor,-10,10);
2068: }
2069: my $newid;
2070: if ($prefixchg) {
2071: if ($folder =~ /^supplemental/) {
2072: $prefix =~ s/^default/supplemental/;
2073: } else {
2074: $prefix =~ s/^supplemental/default/;
2075: }
2076: }
2077: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
2078: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
2079: } else {
2080: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$now.'.'.$ext;
2081: }
2082: my $counter = 0;
2083: my $is_unique = &uniqueness_check($newurl);
2084: if ($folder =~ /^default/) {
2085: if ($allmaps->{$newurl}) {
2086: $is_unique = 0;
2087: }
2088: }
2089: while ((!$is_unique || $allmaps->{$newurl} || $newurls->{$newurl}) && ($counter < 100)) {
2090: $counter ++;
2091: $suffix ++;
2092: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
2093: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
2094: } else {
2095: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$ancestor.$suffix.'.'.$ext;
2096: }
2097: $is_unique = &uniqueness_check($newurl);
2098: }
2099: if ($is_unique) {
2100: $newurls->{$newurl} = 1;
2101: } else {
2102: if ($url=~/\.page$/) {
2103: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the composite page'));
2104: } else {
2105: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the folder'));
2106: }
2107: }
2108: }
2109: return ($newurl);
2110: }
2111:
2112: sub dbcopy {
1.484.2.26 raeburn 2113: my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_;
2114: my ($url,$result,$errtext);
2115: if (ref($dbref) eq 'HASH') {
1.484.2.71 raeburn 2116: $url = $dbref->{'src'};
1.484.2.72.2. (raeburn 2117:): if ($url =~ m{/(smppg|bulletinboard|ext\.tool)$}) {
1.484.2.26 raeburn 2118: my $prefix = $1;
1.484.2.72.2. (raeburn 2119:): if ($prefix eq 'ext.tool') {
2120:): $prefix = 'exttool';
2121:): }
1.484.2.26 raeburn 2122: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2123: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2124: my $db_name;
2125: my $marker = (split(m{/},$url))[4];
2126: $marker=~s/\D//g;
2127: if ($dbref->{'src'} =~ m{/smppg$}) {
2128: $db_name =
2129: &Apache::lonsimplepage::get_db_name($url,$marker,
2130: $dbref->{'cdom'},
2131: $dbref->{'cnum'});
1.484.2.72.2. (raeburn 2132:): } elsif ($dbref->{'src'} =~ m{/ext\.tool$}) {
2133:): $db_name = 'exttool_'.$marker;
1.484.2.26 raeburn 2134: } else {
2135: $db_name = 'bulletinpage_'.$marker;
2136: }
2137: my ($suffix,$freedlock,$error) =
2138: &Apache::lonnet::get_timebased_id($prefix,'num','templated',
2139: $coursedom,$coursenum,
2140: 'concat');
2141: if (!$suffix) {
2142: if ($prefix eq 'smppg') {
2143: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);
1.484.2.72.2. (raeburn 2144:): } elsif ($prefix eq 'exttool') {
2145:): $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying an external tool [_1].',$url);
1.484.2.26 raeburn 2146: } else {
1.484.2.42 raeburn 2147: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url);
1.484.2.26 raeburn 2148: }
2149: if ($error) {
2150: $errtext .= '<br />'.$error;
2151: }
2152: } else {
2153: #need to copy the db contents to a new one.
2154: my %contents=&Apache::lonnet::dump($db_name,
2155: $dbref->{'cdom'},
2156: $dbref->{'cnum'});
2157: if (exists($contents{'uploaded.photourl'})) {
2158: my $photo = $contents{'uploaded.photourl'};
2159: my ($subdir,$fname) =
2160: ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});
2161: my $newphoto;
2162: if ($fname ne '') {
2163: my $content = &Apache::lonnet::getfile($photo);
2164: unless ($content eq '-1') {
2165: $env{'form.'.$suffix.'.photourl'} = $content;
2166: $newphoto =
2167: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");
2168: delete($env{'form.'.$suffix.'.photourl'});
2169: }
2170: }
2171: if ($newphoto =~ m{^/uploaded/}) {
2172: $contents{'uploaded.photourl'} = $newphoto;
2173: }
2174: }
2175: $db_name =~ s{_\d*$ }{_$suffix}x;
2176: $result=&Apache::lonnet::put($db_name,\%contents,
2177: $coursedom,$coursenum);
2178: if ($result eq 'ok') {
1.484.2.72.2. (raeburn 2179:): $url =~ s{/(\d*)/(smppg|bulletinboard|ext\.tool)$}{/$suffix/$2}x;
1.484.2.26 raeburn 2180: }
2181: }
2182: if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) {
2183: $lockerrorsref->{$prefix} =
2184: '<div class="LC_error">'.
2185: &mt('There was a problem removing a lockfile.');
2186: if ($prefix eq 'smppg') {
2187: $lockerrorsref->{$prefix} .=
1.484.2.38 raeburn 2188: ' '.&mt('This will prevent creation of additional simple pages in this course.');
1.484.2.72.2. (raeburn 2189:): } elsif ($prefix eq 'exttool') {
2190:): $lockerrorsref->{$prefix} .=
2191:): ' '.&mt('This will prevent addition of more external tools to this course.');
1.484.2.26 raeburn 2192: } else {
1.484.2.42 raeburn 2193: $lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional discussion boards in this course.');
1.484.2.26 raeburn 2194: }
1.484.2.38 raeburn 2195: $lockerrorsref->{$prefix} .= ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
2196: '<a href="/adm/helpdesk" target="_helpdesk">','</a>').
2197: '</div>';
1.484.2.26 raeburn 2198: }
2199: }
2200: } elsif ($url =~ m{/syllabus$}) {
2201: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2202: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2203: if (($dbref->{'cdom'} ne $coursedom) ||
2204: ($dbref->{'cnum'} ne $coursenum)) {
2205: my %contents=&Apache::lonnet::dump('syllabus',
2206: $dbref->{'cdom'},
2207: $dbref->{'cnum'});
2208: $result=&Apache::lonnet::put('syllabus',\%contents,
2209: $coursedom,$coursenum);
2210: }
2211: }
1.484.2.7 raeburn 2212: }
2213: }
1.484.2.26 raeburn 2214: return ($url,$result,$errtext);
1.329 droeschl 2215: }
2216:
2217: sub uniqueness_check {
2218: my ($newurl) = @_;
2219: my $unique = 1;
2220: foreach my $res (@LONCAPA::map::order) {
2221: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2222: $url=&LONCAPA::map::qtescape($url);
2223: if ($newurl eq $url) {
2224: $unique = 0;
1.344 bisitz 2225: last;
1.329 droeschl 2226: }
2227: }
2228: return $unique;
2229: }
2230:
1.484.2.7 raeburn 2231: sub contained_map_check {
1.484.2.72.2. (raeburn 2232:): my ($url,$folder,$coursenum,$coursedom,$removefrommap,$removeparam,$addedmaps,
2233:): $hierarchy,$titles,$allmaps) = @_;
1.484.2.7 raeburn 2234: my $content = &Apache::lonnet::getfile($url);
2235: unless ($content eq '-1') {
2236: my $parser = HTML::TokeParser->new(\$content);
2237: $parser->attr_encoded(1);
2238: while (my $token = $parser->get_token) {
2239: next if ($token->[0] ne 'S');
2240: if ($token->[1] eq 'resource') {
2241: next if ($token->[2]->{'type'} eq 'zombie');
2242: my $ressrc = $token->[2]->{'src'};
2243: if ($folder =~ /^supplemental/) {
2244: unless (&supp_pasteable($ressrc)) {
2245: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2246: next;
2247: }
2248: }
2249: if ($ressrc =~ m{^/(res|uploaded)/.+\.(sequence|page)$}) {
2250: if ($1 eq 'uploaded') {
2251: $hierarchy->{$url}{$token->[2]->{'id'}} = $ressrc;
2252: $titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'};
2253: } else {
2254: if ($allmaps->{$ressrc}) {
1.484.2.23 raeburn 2255: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.484.2.7 raeburn 2256: } elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') {
2257: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2258: } else {
2259: $addedmaps->{$ressrc} = [$url];
2260: }
2261: }
1.484.2.72.2. (raeburn 2262:): &contained_map_check($ressrc,$folder,$coursenum,$coursedom,
2263:): $removefrommap,$removeparam,
1.484.2.7 raeburn 2264: $addedmaps,$hierarchy,$titles,$allmaps);
2265: }
2266: } elsif ($token->[1] eq 'param') {
2267: if ($folder =~ /^supplemental/) {
2268: if (ref($removeparam->{$url}{$token->[2]->{'to'}}) eq 'ARRAY') {
2269: push(@{$removeparam->{$url}{$token->[2]->{'to'}}},$token->[2]->{'name'});
2270: } else {
1.484.2.19 raeburn 2271: $removeparam->{$url}{$token->[2]->{'to'}} = [$token->[2]->{'name'}];
1.484.2.7 raeburn 2272: }
2273: }
2274: }
2275: }
2276: }
2277: return;
2278: }
2279:
2280: sub url_paste_fixups {
1.484.2.26 raeburn 2281: my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$fromcdom,$fromcnum,$allmaps,
2282: $rewrites,$retitles,$copies,$dbcopies,$zombies,$params,$mapmoves,
2283: $mapchanges,$tomove,$newsubdir,$newurls) = @_;
1.484.2.7 raeburn 2284: my $checktitle;
2285: if (($prefixchg) &&
2286: ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) {
2287: $checktitle = 1;
2288: }
2289: my $skip;
2290: if ($oldurl =~ m{^\Q/uploaded/$cdom/$cnum/\E(default|supplemental)(_?\d*)\.(?:page|sequence)$}) {
2291: my $mapid = $1.$2;
2292: if ($tomove->{$mapid}) {
2293: $skip = 1;
2294: }
2295: }
2296: my $file = &Apache::lonnet::getfile($oldurl);
2297: return if ($file eq '-1');
2298: my $parser = HTML::TokeParser->new(\$file);
2299: $parser->attr_encoded(1);
2300: my $changed = 0;
2301: while (my $token = $parser->get_token) {
2302: next if ($token->[0] ne 'S');
2303: if ($token->[1] eq 'resource') {
2304: my $ressrc = $token->[2]->{'src'};
2305: next if ($ressrc eq '');
2306: my $id = $token->[2]->{'id'};
2307: my $title = $token->[2]->{'title'};
2308: if ($checktitle) {
2309: if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1.484.2.25 raeburn 2310: $retitles->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2311: }
2312: }
2313: next if ($token->[2]->{'type'} eq 'external');
2314: if ($token->[2]->{'type'} eq 'zombie') {
1.484.2.30 raeburn 2315: next if ($skip);
1.484.2.25 raeburn 2316: $zombies->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2317: $changed = 1;
2318: } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
2319: my $srcdom = $1;
2320: my $srcnum = $2;
2321: my $rem = $3;
2322: my $newurl;
2323: my $mapname;
2324: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
2325: my $prefix = $1;
2326: $mapname = $prefix.$2;
2327: if ($tomove->{$mapname}) {
1.484.2.26 raeburn 2328: &url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,
2329: $srcdom,$srcnum,$allmaps,$rewrites,
2330: $retitles,$copies,$dbcopies,$zombies,
2331: $params,$mapmoves,$mapchanges,$tomove,
2332: $newsubdir,$newurls);
1.484.2.7 raeburn 2333: next;
2334: } else {
2335: ($newurl,my $error) =
2336: &get_newmap_url($ressrc,$folder,$prefixchg,$cdom,$cnum,
2337: $srcdom,$srcnum,\$title,$allmaps,$newurls);
2338: if ($newurl =~ /(?:default|supplemental)_(\d+)\.(?:sequence|page)$/) {
2339: $newsubdir->{$ressrc} = $1;
2340: }
2341: if ($error) {
2342: next;
2343: }
2344: }
2345: }
2346: if (($srcdom ne $cdom) || ($srcnum ne $cnum) || ($prefixchg) ||
2347: ($mapchanges->{$oldurl}) || (($newurl ne '') && ($newurl ne $oldurl))) {
1.484.2.19 raeburn 2348:
1.484.2.7 raeburn 2349: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
1.484.2.25 raeburn 2350: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2351: $mapchanges->{$ressrc} = 1;
1.484.2.26 raeburn 2352: unless (&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,
2353: $cnum,$srcdom,$srcnum,$allmaps,
2354: $rewrites,$retitles,$copies,$dbcopies,
2355: $zombies,$params,$mapmoves,$mapchanges,
2356: $tomove,$newsubdir,$newurls)) {
1.484.2.7 raeburn 2357: $mapmoves->{$ressrc} = 1;
2358: }
2359: $changed = 1;
2360: } else {
1.484.2.25 raeburn 2361: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2362: $copies->{$oldurl}{$ressrc} = $id;
2363: $changed = 1;
2364: }
2365: }
1.484.2.26 raeburn 2366: } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/.+$}) {
1.484.2.30 raeburn 2367: next if ($skip);
1.484.2.7 raeburn 2368: my $srcdom = $1;
2369: my $srcnum = $2;
2370: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.484.2.25 raeburn 2371: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.26 raeburn 2372: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2373: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2374: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
2375: $changed = 1;
2376: }
2377: } elsif ($ressrc =~ m{^/adm/$match_domain/$match_username/\d+/(smppg|bulletinboard)$}) {
2378: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum) ||
2379: ($env{'form.docs.markedcopy_options'} ne 'move')) {
2380: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2381: $dbcopies->{$oldurl}{$id}{'cdom'} = $fromcdom;
2382: $dbcopies->{$oldurl}{$id}{'cnum'} = $fromcnum;
1.484.2.7 raeburn 2383: $changed = 1;
2384: }
2385: } elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) {
2386: next if ($skip);
2387: my $srcdom = $1;
2388: my $srcnum = $2;
2389: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.484.2.26 raeburn 2390: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2391: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2392: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
1.484.2.7 raeburn 2393: $changed = 1;
2394: }
2395: }
2396: } elsif ($token->[1] eq 'param') {
2397: next if ($skip);
1.484.2.19 raeburn 2398: my $to = $token->[2]->{'to'};
1.484.2.7 raeburn 2399: if ($to ne '') {
2400: if (ref($params->{$oldurl}{$to}) eq 'ARRAY') {
2401: push(@{$params->{$oldurl}{$to}},$token->[2]->{'name'});
2402: } else {
2403: @{$params->{$oldurl}{$to}} = ($token->[2]->{'name'});
2404: }
2405: }
2406: }
2407: }
2408: return $changed;
2409: }
2410:
2411: sub apply_fixups {
1.484.2.23 raeburn 2412: my ($folder,$is_map,$cdom,$cnum,$errors,$updated,$info,$moves,$prefixchg,
2413: $oldurl,$url,$caller) = @_;
2414: my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles,
1.484.2.26 raeburn 2415: %params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs,
2416: %lockerrors,$lockmsg);
1.484.2.23 raeburn 2417: if (ref($updated) eq 'HASH') {
2418: if (ref($updated->{'rewrites'}) eq 'HASH') {
2419: %rewrites = %{$updated->{'rewrites'}};
2420: }
2421: if (ref($updated->{'zombies'}) eq 'HASH') {
2422: %zombies = %{$updated->{'zombies'}};
2423: }
2424: if (ref($updated->{'removefrommap'}) eq 'HASH') {
2425: %removefrommap = %{$updated->{'removefrommap'}};
2426: }
2427: if (ref($updated->{'removeparam'}) eq 'HASH') {
2428: %removeparam = %{$updated->{'removeparam'}};
2429: }
2430: if (ref($updated->{'dbcopies'}) eq 'HASH') {
2431: %dbcopies = %{$updated->{'dbcopies'}};
2432: }
2433: if (ref($updated->{'retitles'}) eq 'HASH') {
2434: %retitles = %{$updated->{'retitles'}};
2435: }
2436: }
2437: if (ref($info) eq 'HASH') {
2438: if (ref($info->{'newsubdir'}) eq 'HASH') {
2439: %newsubdir = %{$info->{'newsubdir'}};
2440: }
2441: if (ref($info->{'params'}) eq 'HASH') {
2442: %params = %{$info->{'params'}};
2443: }
2444: if (ref($info->{'before'}) eq 'HASH') {
2445: %before = %{$info->{'before'}};
2446: }
2447: if (ref($info->{'after'}) eq 'HASH') {
2448: %after = %{$info->{'after'}};
2449: }
2450: }
2451: if (ref($moves) eq 'HASH') {
2452: if (ref($moves->{'copies'}) eq 'HASH') {
2453: %copies = %{$moves->{'copies'}};
2454: }
2455: if (ref($moves->{'docmoves'}) eq 'HASH') {
2456: %docmoves = %{$moves->{'docmoves'}};
2457: }
2458: if (ref($moves->{'mapmoves'}) eq 'HASH') {
2459: %mapmoves = %{$moves->{'mapmoves'}};
2460: }
2461: }
2462: foreach my $key (keys(%copies),keys(%docmoves)) {
1.484.2.7 raeburn 2463: my @allcopies;
1.484.2.23 raeburn 2464: if (exists($copies{$key})) {
2465: if (ref($copies{$key}) eq 'HASH') {
2466: my %added;
2467: foreach my $innerkey (keys(%{$copies{$key}})) {
2468: if (($innerkey ne '') && (!$added{$innerkey})) {
2469: push(@allcopies,$innerkey);
2470: $added{$innerkey} = 1;
2471: }
1.484.2.7 raeburn 2472: }
1.484.2.23 raeburn 2473: undef(%added);
1.484.2.7 raeburn 2474: }
2475: }
2476: if ($key eq $oldurl) {
1.484.2.23 raeburn 2477: if ((exists($docmoves{$key}))) {
1.484.2.25 raeburn 2478: unless (grep(/^\Q$oldurl\E$/,@allcopies)) {
1.484.2.7 raeburn 2479: push(@allcopies,$oldurl);
2480: }
2481: }
2482: }
2483: if (@allcopies > 0) {
2484: foreach my $item (@allcopies) {
1.484.2.19 raeburn 2485: my ($relpath,$oldsubdir,$fname) =
1.484.2.7 raeburn 2486: ($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(default|\d+)/.*/)([^/]+)$});
2487: if ($fname ne '') {
2488: my $content = &Apache::lonnet::getfile($item);
2489: unless ($content eq '-1') {
2490: my $storefn;
1.484.2.23 raeburn 2491: if (($key eq $oldurl) && (exists($docmoves{$key}))) {
2492: $storefn = $docmoves{$key};
1.484.2.7 raeburn 2493: } else {
2494: $storefn = $relpath;
2495: $storefn =~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 2496: if ($prefixchg && $before{'doc'} && $after{'doc'}) {
2497: $storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/;
1.484.2.7 raeburn 2498: }
1.484.2.23 raeburn 2499: if ($newsubdir{$key}) {
1.484.2.25 raeburn 2500: $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}/#;
1.484.2.7 raeburn 2501: }
2502: }
2503: ©_dependencies($item,$storefn,$relpath,$errors,\$content);
1.484.2.19 raeburn 2504: my $copyurl =
1.484.2.7 raeburn 2505: &Apache::lonclonecourse::writefile($env{'request.course.id'},
2506: $storefn.$fname,$content);
2507: if ($copyurl eq '/adm/notfound.html') {
1.484.2.23 raeburn 2508: if (exists($docmoves{$oldurl})) {
1.484.2.7 raeburn 2509: return &mt('Paste failed: an error occurred copying the file.');
2510: } elsif (ref($errors) eq 'HASH') {
2511: $errors->{$item} = 1;
2512: }
2513: }
2514: }
2515: }
2516: }
2517: }
2518: }
1.484.2.23 raeburn 2519: foreach my $key (keys(%mapmoves)) {
1.484.2.7 raeburn 2520: my $storefn=$key;
2521: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 2522: if ($prefixchg && $before{'map'} && $after{'map'}) {
2523: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.484.2.7 raeburn 2524: }
1.484.2.23 raeburn 2525: if ($newsubdir{$key}) {
2526: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.484.2.7 raeburn 2527: }
2528: my $mapcontent = &Apache::lonnet::getfile($key);
2529: if ($mapcontent eq '-1') {
2530: if (ref($errors) eq 'HASH') {
2531: $errors->{$key} = 1;
2532: }
2533: } else {
2534: my $newmap =
2535: &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
2536: $mapcontent);
2537: if ($newmap eq '/adm/notfound.html') {
2538: if (ref($errors) eq 'HASH') {
2539: $errors->{$key} = 1;
2540: }
2541: }
2542: }
2543: }
2544: my %updates;
2545: if ($is_map) {
1.484.2.23 raeburn 2546: if (ref($updated) eq 'HASH') {
2547: foreach my $type (keys(%{$updated})) {
2548: if (ref($updated->{$type}) eq 'HASH') {
2549: foreach my $key (keys(%{$updated->{$type}})) {
2550: $updates{$key} = 1;
2551: }
2552: }
2553: }
1.484.2.7 raeburn 2554: }
2555: foreach my $key (keys(%updates)) {
2556: my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb);
1.484.2.23 raeburn 2557: if (ref($rewrites{$key}) eq 'HASH') {
2558: %torewrite = %{$rewrites{$key}};
1.484.2.7 raeburn 2559: }
1.484.2.23 raeburn 2560: if (ref($retitles{$key}) eq 'HASH') {
2561: %toretitle = %{$retitles{$key}};
1.484.2.7 raeburn 2562: }
1.484.2.23 raeburn 2563: if (ref($removefrommap{$key}) eq 'HASH') {
2564: %toremove = %{$removefrommap{$key}};
1.484.2.7 raeburn 2565: }
1.484.2.23 raeburn 2566: if (ref($removeparam{$key}) eq 'HASH') {
2567: %remparam = %{$removeparam{$key}};
1.484.2.7 raeburn 2568: }
1.484.2.23 raeburn 2569: if (ref($zombies{$key}) eq 'HASH') {
2570: %zombie = %{$zombies{$key}};
1.484.2.7 raeburn 2571: }
1.484.2.23 raeburn 2572: if (ref($dbcopies{$key}) eq 'HASH') {
1.484.2.26 raeburn 2573: foreach my $idx (keys(%{$dbcopies{$key}})) {
2574: if (ref($dbcopies{$key}{$idx}) eq 'HASH') {
2575: my ($newurl,$result,$errtext) =
2576: &dbcopy($dbcopies{$key}{$idx},$cdom,$cnum,\%lockerrors);
2577: if ($result eq 'ok') {
2578: $newdb{$idx} = $newurl;
2579: } elsif (ref($errors) eq 'HASH') {
2580: $errors->{$key} = 1;
2581: }
2582: push(@msgs,$errtext);
2583: }
1.484.2.7 raeburn 2584: }
2585: }
1.484.2.23 raeburn 2586: if (ref($params{$key}) eq 'HASH') {
2587: %currparam = %{$params{$key}};
1.484.2.7 raeburn 2588: }
2589: my ($errtext,$fatal) = &LONCAPA::map::mapread($key);
2590: if ($fatal) {
1.484.2.26 raeburn 2591: return ($errtext);
1.484.2.7 raeburn 2592: }
2593: for (my $i=0; $i<@LONCAPA::map::zombies; $i++) {
2594: if (defined($LONCAPA::map::zombies[$i])) {
2595: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::zombies[$i]);
1.484.2.25 raeburn 2596: if ($zombie{$i} eq $src) {
1.484.2.7 raeburn 2597: undef($LONCAPA::map::zombies[$i]);
2598: }
2599: }
2600: }
1.484.2.23 raeburn 2601: for (my $i=0; $i<@LONCAPA::map::order; $i++) {
2602: my $idx = $LONCAPA::map::order[$i];
2603: if (defined($LONCAPA::map::resources[$idx])) {
1.484.2.7 raeburn 2604: my $changed;
1.484.2.23 raeburn 2605: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]);
1.484.2.30 raeburn 2606: if ((exists($toremove{$idx})) &&
2607: ($toremove{$idx} eq &LONCAPA::map::qtescape($src))) {
1.484.2.7 raeburn 2608: splice(@LONCAPA::map::order,$i,1);
1.484.2.23 raeburn 2609: if (ref($currparam{$idx}) eq 'ARRAY') {
2610: foreach my $name (@{$currparam{$idx}}) {
2611: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
1.484.2.7 raeburn 2612: }
2613: }
2614: next;
2615: }
2616: my $origsrc = $src;
1.484.2.25 raeburn 2617: if ((exists($toretitle{$idx})) && ($toretitle{$idx} eq $src)) {
1.484.2.7 raeburn 2618: if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
2619: $changed = 1;
2620: }
2621: }
1.484.2.25 raeburn 2622: if ((exists($torewrite{$idx})) && ($torewrite{$idx} eq $src)) {
1.484.2.7 raeburn 2623: $src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
2624: if ($origsrc =~ m{^/uploaded/}) {
1.484.2.23 raeburn 2625: if ($prefixchg && $before{'map'} && $after{'map'}) {
1.484.2.7 raeburn 2626: if ($src =~ /\.(page|sequence)$/) {
1.484.2.23 raeburn 2627: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'map'}\E#$1$after{'map'}#;
1.484.2.7 raeburn 2628: } else {
1.484.2.23 raeburn 2629: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
1.484.2.7 raeburn 2630: }
2631: }
1.484.2.25 raeburn 2632: if ($origsrc =~ /\.(page|sequence)$/) {
2633: if ($newsubdir{$origsrc}) {
1.484.2.23 raeburn 2634: $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir{$origsrc}#;
1.484.2.7 raeburn 2635: }
1.484.2.25 raeburn 2636: } elsif ($newsubdir{$key}) {
2637: $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$key}#;
1.484.2.7 raeburn 2638: }
2639: }
2640: $changed = 1;
1.484.2.26 raeburn 2641: } elsif ($newdb{$idx} ne '') {
2642: $src = $newdb{$idx};
1.484.2.7 raeburn 2643: $changed = 1;
2644: }
2645: if ($changed) {
1.484.2.30 raeburn 2646: $LONCAPA::map::resources[$idx] = join(':',($title,&LONCAPA::map::qtunescape($src),$ext,$type));
1.484.2.7 raeburn 2647: }
2648: }
2649: }
2650: foreach my $idx (keys(%remparam)) {
2651: if (ref($remparam{$idx}) eq 'ARRAY') {
1.484.2.19 raeburn 2652: foreach my $name (@{$remparam{$idx}}) {
1.484.2.7 raeburn 2653: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
2654: }
2655: }
2656: }
1.484.2.26 raeburn 2657: if (values(%lockerrors) > 0) {
2658: $lockmsg = join('<br />',values(%lockerrors));
2659: }
1.484.2.7 raeburn 2660: my $storefn;
2661: if ($key eq $oldurl) {
2662: $storefn = $url;
2663: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
2664: } else {
2665: $storefn = $key;
2666: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 2667: if ($prefixchg && $before{'map'} && $after{'map'}) {
2668: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.484.2.7 raeburn 2669: }
1.484.2.23 raeburn 2670: if ($newsubdir{$key}) {
2671: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.484.2.7 raeburn 2672: }
2673: }
2674: my $report;
2675: if ($folder !~ /^supplemental/) {
2676: $report = 1;
2677: }
1.484.2.20 raeburn 2678: (my $outtext,$errtext) =
1.484.2.7 raeburn 2679: &LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report);
2680: if ($errtext) {
1.484.2.23 raeburn 2681: if ($caller eq 'paste') {
1.484.2.26 raeburn 2682: return (&mt('Paste failed: an error occurred saving the folder or page.'));
1.484.2.23 raeburn 2683: }
1.484.2.7 raeburn 2684: }
2685: }
2686: }
1.484.2.26 raeburn 2687: return ('ok',\@msgs,$lockmsg);
1.484.2.7 raeburn 2688: }
2689:
2690: sub copy_dependencies {
2691: my ($item,$storefn,$relpath,$errors,$contentref) = @_;
2692: my $content;
2693: if (ref($contentref)) {
2694: $content = $$contentref;
2695: } else {
2696: $content = &Apache::lonnet::getfile($item);
2697: }
2698: unless ($content eq '-1') {
2699: my $mm = new File::MMagic;
2700: my $mimetype = $mm->checktype_contents($content);
2701: if ($mimetype eq 'text/html') {
2702: my (%allfiles,%codebase,$state);
2703: my $res = &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,\$content);
2704: if ($res eq 'ok') {
2705: my ($numexisting,$numpathchanges,$existing);
2706: (undef,$numexisting,$numpathchanges,$existing) =
2707: &Apache::loncommon::ask_for_embedded_content(
2708: '/adm/coursedocs',$state,\%allfiles,\%codebase,
2709: {'error_on_invalid_names' => 1,
2710: 'ignore_remote_references' => 1,
2711: 'docs_url' => $item,
2712: 'context' => 'paste'});
2713: if ($numexisting > 0) {
2714: if (ref($existing) eq 'HASH') {
2715: foreach my $dep (keys(%{$existing})) {
2716: my $depfile = $dep;
2717: unless ($depfile =~ m{^\Q$relpath\E}) {
2718: $depfile = $relpath.$dep;
2719: }
2720: my $depcontent = &Apache::lonnet::getfile($depfile);
2721: unless ($depcontent eq '-1') {
2722: my $storedep = $dep;
2723: $storedep =~ s{^\Q$relpath\E}{};
2724: my $dep_url =
2725: &Apache::lonclonecourse::writefile(
2726: $env{'request.course.id'},
2727: $storefn.$storedep,$depcontent);
2728: if ($dep_url eq '/adm/notfound.html') {
2729: if (ref($errors) eq 'HASH') {
2730: $errors->{$depfile} = 1;
2731: }
2732: } else {
2733: ©_dependencies($depfile,$storefn,$relpath,$errors,\$depcontent);
2734: }
2735: }
2736: }
2737: }
2738: }
2739: }
2740: }
2741: }
2742: return;
2743: }
2744:
1.329 droeschl 2745: my %parameter_type = ( 'randompick' => 'int_pos',
2746: 'hiddenresource' => 'string_yesno',
2747: 'encrypturl' => 'string_yesno',
2748: 'randomorder' => 'string_yesno',);
2749: my $valid_parameters_re = join('|',keys(%parameter_type));
2750: # set parameters
2751: sub update_parameter {
1.484.2.29 raeburn 2752: if ($env{'form.changeparms'} eq 'all') {
2753: my (@allidx,@allmapidx,%allchecked,%currchecked);
2754: %allchecked = (
2755: 'hiddenresource' => {},
2756: 'encrypturl' => {},
2757: 'randompick' => {},
2758: 'randomorder' => {},
2759: );
2760: foreach my $which (keys(%allchecked)) {
2761: $env{'form.all'.$which} =~ s/,$//;
2762: if ($which eq 'randompick') {
2763: foreach my $item (split(/,/,$env{'form.all'.$which})) {
2764: my ($res,$value) = split(/:/,$item);
2765: if ($value =~ /^\d+$/) {
2766: $allchecked{$which}{$res} = $value;
2767: }
2768: }
2769: } else {
1.484.2.30 raeburn 2770: if ($env{'form.all'.$which}) {
2771: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.all'.$which});
2772: }
1.484.2.29 raeburn 2773: }
2774: }
2775: my $haschanges = 0;
2776: foreach my $res (@LONCAPA::map::order) {
2777: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2778: $name=&LONCAPA::map::qtescape($name);
2779: $url=&LONCAPA::map::qtescape($url);
2780: next unless ($name && $url);
2781: my $is_map;
2782: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
2783: $is_map = 1;
2784: }
2785: foreach my $which (keys(%allchecked)) {
2786: if (($which eq 'randompick' || $which eq 'randomorder')) {
2787: next if (!$is_map);
2788: }
2789: my $oldvalue = 0;
2790: my $newvalue = 0;
2791: if ($allchecked{$which}{$res}) {
2792: $newvalue = $allchecked{$which}{$res};
2793: }
2794: my $current = (&LONCAPA::map::getparameter($res,'parameter_'.$which))[0];
2795: if ($which eq 'randompick') {
2796: if ($current =~ /^(\d+)$/) {
2797: $oldvalue = $1;
2798: }
2799: } else {
2800: if ($current =~ /^yes$/i) {
2801: $oldvalue = 1;
2802: }
2803: }
2804: if ($oldvalue ne $newvalue) {
2805: $haschanges = 1;
2806: if ($newvalue) {
2807: my $storeval = 'yes';
2808: if ($which eq 'randompick') {
2809: $storeval = $newvalue;
2810: }
2811: &LONCAPA::map::storeparameter($res,'parameter_'.$which,
2812: $storeval,
2813: $parameter_type{$which});
2814: &remember_parms($res,$which,'set',$storeval);
2815: } elsif ($oldvalue) {
2816: &LONCAPA::map::delparameter($res,'parameter_'.$which);
2817: &remember_parms($res,$which,'del');
2818: }
2819: }
2820: }
2821: }
2822: return $haschanges;
1.329 droeschl 2823: } else {
1.484.2.59 raeburn 2824: my $haschanges = 0;
2825: return $haschanges if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
1.364 bisitz 2826:
1.484.2.29 raeburn 2827: my $which = $env{'form.changeparms'};
2828: my $idx = $env{'form.setparms'};
1.484.2.59 raeburn 2829: my $oldvalue = 0;
2830: my $newvalue = 0;
2831: my $current = (&LONCAPA::map::getparameter($idx,'parameter_'.$which))[0];
2832: if ($which eq 'randompick') {
2833: if ($current =~ /^(\d+)$/) {
2834: $oldvalue = $1;
2835: }
2836: } elsif ($current =~ /^yes$/i) {
2837: $oldvalue = 1;
2838: }
1.484.2.29 raeburn 2839: if ($env{'form.'.$which.'_'.$idx}) {
1.484.2.59 raeburn 2840: $newvalue = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx}
2841: : 1;
1.484.2.29 raeburn 2842: }
1.484.2.59 raeburn 2843: if ($oldvalue ne $newvalue) {
2844: $haschanges = 1;
2845: if ($newvalue) {
2846: my $storeval = 'yes';
2847: if ($which eq 'randompick') {
2848: $storeval = $newvalue;
2849: }
2850: &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $storeval,
2851: $parameter_type{$which});
2852: &remember_parms($idx,$which,'set',$storeval);
2853: } else {
2854: &LONCAPA::map::delparameter($idx,'parameter_'.$which);
2855: &remember_parms($idx,$which,'del');
2856: }
2857: }
2858: return $haschanges;
1.329 droeschl 2859: }
1.484.2.59 raeburn 2860: return;
1.329 droeschl 2861: }
2862:
2863: sub handle_edit_cmd {
2864: my ($coursenum,$coursedom) =@_;
1.484.2.30 raeburn 2865: if ($env{'form.cmd'} eq '') {
2866: return 0;
2867: }
1.329 droeschl 2868: my ($cmd,$idx)=split('_',$env{'form.cmd'});
2869:
2870: my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
2871: my ($title, $url, @rrest) = split(':', $ratstr);
2872:
1.484.2.30 raeburn 2873: if ($cmd eq 'remove') {
1.329 droeschl 2874: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
1.463 www 2875: ($url!~/$LONCAPA::assess_page_seq_re/)) {
1.329 droeschl 2876: &Apache::lonnet::removeuploadedurl($url);
2877: } else {
2878: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
2879: }
2880: splice(@LONCAPA::map::order, $idx, 1);
2881:
2882: } elsif ($cmd eq 'cut') {
2883: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
2884: splice(@LONCAPA::map::order, $idx, 1);
2885:
1.344 bisitz 2886: } elsif ($cmd eq 'up'
1.329 droeschl 2887: && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
2888: @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
2889:
2890: } elsif ($cmd eq 'down'
2891: && defined($LONCAPA::map::order[$idx+1])) {
2892: @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
2893:
2894: } elsif ($cmd eq 'rename') {
2895: my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
2896: if ($comment=~/\S/) {
2897: $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
2898: $comment.':'.join(':', $url, @rrest);
2899: }
2900: # Devalidate title cache
2901: my $renamed_url=&LONCAPA::map::qtescape($url);
2902: &Apache::lonnet::devalidate_title_cache($renamed_url);
1.484.2.30 raeburn 2903:
1.329 droeschl 2904: } else {
2905: return 0;
2906: }
2907: return 1;
2908: }
2909:
2910: sub editor {
1.458 raeburn 2911: my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
1.484.2.72.2. (raeburn 2912:): $supplementalflag,$orderhash,$iconpath,$pathitem,$ltitoolsref,
2913:): $canedit,$navmapref,$hiddentop)=@_;
1.484.2.19 raeburn 2914: my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
2915: if ($allowed) {
2916: (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
2917: $is_random_order,$container) =
2918: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
2919: $r->print($breadcrumbtrail);
2920: } elsif ($env{'form.folderpath'} =~ /\:1$/) {
2921: $container = 'page';
2922: } else {
2923: $container = 'sequence';
2924: }
1.484 raeburn 2925:
1.484.2.21 raeburn 2926: my $jumpto;
2927:
2928: unless ($supplementalflag) {
1.484.2.32 raeburn 2929: $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
1.484.2.21 raeburn 2930: }
1.484 raeburn 2931:
2932: unless ($allowed) {
2933: $randompick = -1;
2934: }
2935:
1.484.2.67 raeburn 2936: my ($errtext,$fatal);
2937: if (($folder eq '') && (!$supplementalflag)) {
2938: if (@LONCAPA::map::order) {
2939: undef(@LONCAPA::map::order);
2940: undef(@LONCAPA::map::resources);
2941: undef(@LONCAPA::map::resparms);
2942: undef(@LONCAPA::map::zombies);
2943: }
2944: $folder = 'default';
2945: $container = 'sequence';
2946: } else {
2947: ($errtext,$fatal) = &mapread($coursenum,$coursedom,
2948: $folder.'.'.$container);
2949: return $errtext if ($fatal);
2950: }
1.329 droeschl 2951:
2952: if ($#LONCAPA::map::order<1) {
2953: my $idx=&LONCAPA::map::getresidx();
2954: if ($idx<=0) { $idx=1; }
2955: $LONCAPA::map::order[0]=$idx;
2956: $LONCAPA::map::resources[$idx]='';
2957: }
1.364 bisitz 2958:
1.329 droeschl 2959: # ------------------------------------------------------------ Process commands
2960:
2961: # ---------------- if they are for this folder and user allowed to make changes
1.484.2.67 raeburn 2962: if (($allowed && $canedit) && ($env{'form.folder'} eq $folder)) {
1.329 droeschl 2963: # set parameters and change order
2964: &snapshotbefore();
2965:
2966: if (&update_parameter()) {
1.484.2.59 raeburn 2967: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1.329 droeschl 2968: return $errtext if ($fatal);
2969: }
2970:
2971: if ($env{'form.newpos'} && $env{'form.currentpos'}) {
2972: # change order
2973: my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
2974: splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
2975:
2976: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
2977: return $errtext if ($fatal);
2978: }
1.364 bisitz 2979:
1.329 droeschl 2980: if ($env{'form.pastemarked'}) {
1.484.2.7 raeburn 2981: my %paste_errors;
1.484.2.26 raeburn 2982: my ($paste_res,$save_error,$pastemsgarray,$lockerror) =
1.484.2.7 raeburn 2983: &do_paste_from_buffer($coursenum,$coursedom,$folder,$container,
2984: \%paste_errors);
1.484.2.30 raeburn 2985: if (ref($pastemsgarray) eq 'ARRAY') {
2986: if (@{$pastemsgarray} > 0) {
2987: $r->print('<p class="LC_info">'.
2988: join('<br />',@{$pastemsgarray}).
1.484.2.26 raeburn 2989: '</p>');
2990: }
1.484.2.30 raeburn 2991: }
2992: if ($lockerror) {
2993: $r->print('<p class="LC_error">'.
2994: $lockerror.
2995: '</p>');
2996: }
2997: if ($save_error ne '') {
2998: return $save_error;
2999: }
3000: if ($paste_res) {
3001: my %errortext = &Apache::lonlocal::texthash (
3002: fail => 'Storage of folder contents failed',
3003: failread => 'Reading folder contents failed',
3004: failstore => 'Storage of folder contents failed',
3005: );
3006: if ($errortext{$paste_res}) {
3007: $r->print('<p class="LC_error">'.$errortext{$paste_res}.'</p>');
1.484.2.7 raeburn 3008: }
1.329 droeschl 3009: }
1.484.2.7 raeburn 3010: if (keys(%paste_errors) > 0) {
1.484.2.30 raeburn 3011: $r->print('<p class="LC_warning">'."\n".
1.484.2.7 raeburn 3012: &mt('The following files are either dependencies of a web page or references within a folder and/or composite page which could not be copied during the paste operation:')."\n".
3013: '<ul>'."\n");
3014: foreach my $key (sort(keys(%paste_errors))) {
3015: $r->print('<li>'.$key.'</li>'."\n");
3016: }
3017: $r->print('</ul></p>'."\n");
3018: }
1.484.2.30 raeburn 3019: } elsif ($env{'form.clearmarked'}) {
3020: my $output = &do_buffer_empty();
3021: if ($output) {
3022: $r->print('<p class="LC_info">'.$output.'</p>');
3023: }
3024: }
1.329 droeschl 3025:
3026: $r->print($upload_output);
3027:
1.484.2.30 raeburn 3028: # Rename, cut, copy or remove a single resource
1.484.2.63 raeburn 3029: if (&handle_edit_cmd($coursenum,$coursedom)) {
1.484.2.7 raeburn 3030: my $contentchg;
1.484.2.58 raeburn 3031: if ($env{'form.cmd'} =~ m{^(remove|cut)_}) {
1.484.2.7 raeburn 3032: $contentchg = 1;
3033: }
3034: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);
1.329 droeschl 3035: return $errtext if ($fatal);
3036: }
1.484.2.30 raeburn 3037:
3038: # Cut, copy and/or remove multiple resources
3039: if ($env{'form.multichange'}) {
3040: my %allchecked = (
3041: cut => {},
3042: remove => {},
3043: );
3044: my $needsupdate;
3045: foreach my $which (keys(%allchecked)) {
3046: $env{'form.multi'.$which} =~ s/,$//;
3047: if ($env{'form.multi'.$which}) {
3048: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.multi'.$which});
3049: if (ref($allchecked{$which}) eq 'HASH') {
3050: $needsupdate += scalar(keys(%{$allchecked{$which}}));
3051: }
3052: }
3053: }
3054: if ($needsupdate) {
3055: my $haschanges = 0;
3056: my %curr_groups = &Apache::longroup::coursegroups();
3057: my $total = scalar(@LONCAPA::map::order) - 1;
3058: for (my $i=$total; $i>=0; $i--) {
3059: my $res = $LONCAPA::map::order[$i];
3060: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3061: $name=&LONCAPA::map::qtescape($name);
3062: $url=&LONCAPA::map::qtescape($url);
1.484.2.57 raeburn 3063: next unless $url;
1.484.2.30 raeburn 3064: my %denied =
3065: &action_restrictions($coursenum,$coursedom,$url,
3066: $env{'form.folderpath'},\%curr_groups);
3067: foreach my $which (keys(%allchecked)) {
3068: next if ($denied{$which});
3069: next unless ($allchecked{$which}{$res});
3070: if ($which eq 'remove') {
3071: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
3072: ($url!~/$LONCAPA::assess_page_seq_re/)) {
3073: &Apache::lonnet::removeuploadedurl($url);
3074: } else {
3075: &LONCAPA::map::makezombie($res);
3076: }
3077: splice(@LONCAPA::map::order,$i,1);
3078: $haschanges ++;
3079: } elsif ($which eq 'cut') {
3080: &LONCAPA::map::makezombie($res);
3081: splice(@LONCAPA::map::order,$i,1);
3082: $haschanges ++;
3083: }
3084: }
3085: }
3086: if ($haschanges) {
3087: ($errtext,$fatal) =
3088: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
3089: return $errtext if ($fatal);
3090: }
3091: }
3092: }
3093:
1.329 droeschl 3094: # Group import/search
3095: if ($env{'form.importdetail'}) {
3096: my @imports;
3097: foreach my $item (split(/\&/,$env{'form.importdetail'})) {
3098: if (defined($item)) {
3099: my ($name,$url,$residx)=
1.484.2.26 raeburn 3100: map { &unescape($_); } split(/\=/,$item);
3101: if ($url =~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
1.484.2.30 raeburn 3102: my ($suffix,$errortxt,$locknotfreed) =
1.484.2.26 raeburn 3103: &new_timebased_suffix($coursedom,$coursenum,'map',$1,$2);
1.484.2.15 raeburn 3104: if ($locknotfreed) {
3105: $r->print($locknotfreed);
3106: }
3107: if ($suffix) {
1.484.2.19 raeburn 3108: $url =~ s/_new\./_$suffix./;
1.484.2.15 raeburn 3109: } else {
3110: return $errortxt;
3111: }
1.484.2.26 raeburn 3112: } elsif ($url =~ m{^/adm/$match_domain/$match_username/new/(smppg|bulletinboard)$}) {
3113: my $type = $1;
3114: my ($suffix,$errortxt,$locknotfreed) =
3115: &new_timebased_suffix($coursedom,$coursenum,$type);
3116: if ($locknotfreed) {
3117: $r->print($locknotfreed);
3118: }
3119: if ($suffix) {
3120: $url =~ s{^(/adm/$match_domain/$match_username)/new}{$1/$suffix};
3121: } else {
3122: return $errortxt;
3123: }
1.484.2.72.2. (raeburn 3124:): } elsif ($url =~ m{^/adm/$coursedom/$coursenum/new/ext\.tool}) {
3125:): my ($suffix,$errortxt,$locknotfreed) =
3126:): &new_timebased_suffix($coursedom,$coursenum,'exttool');
3127:): if ($locknotfreed) {
3128:): $r->print($locknotfreed);
3129:): }
3130:): if ($suffix) {
3131:): $url =~ s{^(/adm/$coursedom/$coursenum)/new}{$1/$suffix};
3132:): } else {
3133:): return $errortxt;
3134:): }
1.484.2.27 raeburn 3135: } elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) {
3136: if ($supplementalflag) {
3137: next unless ($1 eq 'supplemental');
3138: if ($folder eq 'supplemental') {
3139: next unless ($2 eq 'default');
3140: } else {
3141: next unless ($folder eq 'supplemental_'.$2);
3142: }
3143: } else {
3144: next unless ($1 eq 'docs');
3145: if ($folder eq 'default') {
3146: next unless ($2 eq 'default');
3147: } else {
3148: next unless ($folder eq 'default_'.$2);
3149: }
3150: }
1.484.2.15 raeburn 3151: }
1.329 droeschl 3152: push(@imports, [$name, $url, $residx]);
3153: }
3154: }
1.484.2.23 raeburn 3155: ($errtext,$fatal,my $fixuperrors) =
3156: &group_import($coursenum, $coursedom, $folder,$container,
1.484.2.72.2. (raeburn 3157:): 'londocs',$ltitoolsref,@imports);
1.329 droeschl 3158: return $errtext if ($fatal);
1.484.2.23 raeburn 3159: if ($fixuperrors) {
3160: $r->print($fixuperrors);
3161: }
1.329 droeschl 3162: }
3163: # Loading a complete map
3164: if ($env{'form.loadmap'}) {
3165: if ($env{'form.importmap'}=~/\w/) {
3166: foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
3167: my ($title,$url,$ext,$type)=split(/\:/,$res);
3168: my $idx=&LONCAPA::map::getresidx($url);
3169: $LONCAPA::map::resources[$idx]=$res;
3170: $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
3171: }
3172: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.484.2.7 raeburn 3173: $folder.'.'.$container,1);
1.329 droeschl 3174: return $errtext if ($fatal);
3175: } else {
3176: $r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
1.364 bisitz 3177:
1.329 droeschl 3178: }
3179: }
3180: &log_differences($plain);
3181: }
3182: # ---------------------------------------------------------------- End commands
3183: # ---------------------------------------------------------------- Print screen
3184: my $idx=0;
3185: my $shown=0;
3186: if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
1.381 bisitz 3187: $r->print('<div class="LC_Box">'.
1.432 raeburn 3188: '<ol class="LC_docs_parameters"><li class="LC_docs_parameters_title">'.&mt('Parameters:').'</li>'.
3189: ($randompick>=0?'<li>'.&mt('randomly pick [quant,_1,resource]',$randompick).'</li>':'').
3190: ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
3191: ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
3192: ($is_random_order?'<li>'.&mt('random order').'</li>':'').
1.431 raeburn 3193: '</ol>');
1.381 bisitz 3194: if ($randompick>=0) {
3195: $r->print('<p class="LC_warning">'
3196: .&mt('Caution: this folder is set to randomly pick a subset'
3197: .' of resources. Adding or removing resources from this'
3198: .' folder will change the set of resources that the'
3199: .' students see, resulting in spurious or missing credit'
3200: .' for completed problems, not limited to ones you'
3201: .' modify. Do not modify the contents of this folder if'
3202: .' it is in active student use.')
3203: .'</p>'
3204: );
3205: }
3206: if ($is_random_order) {
3207: $r->print('<p class="LC_warning">'
3208: .&mt('Caution: this folder is set to randomly order its'
3209: .' contents. Adding or removing resources from this folder'
3210: .' will change the order of resources shown.')
3211: .'</p>'
3212: );
3213: }
3214: $r->print('</div>');
1.364 bisitz 3215: }
1.381 bisitz 3216:
1.484.2.30 raeburn 3217: my ($to_show,$output,@allidx,@allmapidx,%filters,%lists,%curr_groups);
3218: %filters = (
3219: canremove => [],
3220: cancut => [],
3221: cancopy => [],
3222: hiddenresource => [],
3223: encrypturl => [],
3224: randomorder => [],
3225: randompick => [],
3226: );
3227: %curr_groups = &Apache::longroup::coursegroups();
1.424 onken 3228: &Apache::loncommon::start_data_table_count(); #setup a row counter
1.381 bisitz 3229: foreach my $res (@LONCAPA::map::order) {
3230: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3231: $name=&LONCAPA::map::qtescape($name);
3232: $url=&LONCAPA::map::qtescape($url);
3233: unless ($name) { $name=(split(/\//,$url))[-1]; }
3234: unless ($name) { $idx++; next; }
1.484.2.29 raeburn 3235: push(@allidx,$res);
3236: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
3237: push(@allmapidx,$res);
3238: }
1.484.2.67 raeburn 3239:
1.381 bisitz 3240: $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
1.484.2.12 raeburn 3241: $coursenum,$coursedom,$crstype,
1.484.2.30 raeburn 3242: $pathitem,$supplementalflag,$container,
1.484.2.72.2. (raeburn 3243:): \%filters,\%curr_groups,$ltitoolsref,$canedit,
1.484.2.70 raeburn 3244: $isencrypted,$navmapref);
1.381 bisitz 3245: $idx++;
3246: $shown++;
1.329 droeschl 3247: }
1.424 onken 3248: &Apache::loncommon::end_data_table_count();
1.484.2.19 raeburn 3249:
1.484.2.30 raeburn 3250: my $need_save;
1.484.2.67 raeburn 3251: if ($allowed || ($supplementalflag && $folder eq 'supplemental')) {
1.484.2.31 raeburn 3252: my $toolslink;
1.484.2.67 raeburn 3253: if ($allowed) {
1.484.2.31 raeburn 3254: $toolslink = '<table><tr><td>'
1.484.2.19 raeburn 3255: .&Apache::loncommon::help_open_menu('Navigation Screen',
3256: 'Navigation_Screen',undef,'RAT')
3257: .'</td><td class="LC_middle">'.&mt('Tools:').'</td>'
3258: .'<td align="left"><ul id="LC_toolbar">'
1.484.2.21 raeburn 3259: .'<li><a href="/adm/coursedocs?forcesupplement=1&command=editsupp" '
1.484.2.19 raeburn 3260: .'id="LC_content_toolbar_edittoplevel" '
3261: .'class="LC_toolbarItem" '
3262: .'title="'.&mt('Supplemental Content Editor').'">'
3263: .'</a></li></ul></td></tr></table><br />';
1.484.2.31 raeburn 3264: }
1.484.2.19 raeburn 3265: if ($shown) {
3266: if ($allowed) {
3267: $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
3268: .&Apache::loncommon::start_data_table(undef,'contentlist')
3269: .&Apache::loncommon::start_data_table_header_row()
3270: .'<th colspan="2">'.&mt('Move').'</th>'
1.484.2.30 raeburn 3271: .'<th colspan="2">'.&mt('Actions').'</th>'
3272: .'<th>'.&mt('Document').'</th>';
1.484.2.19 raeburn 3273: if ($folder !~ /^supplemental/) {
3274: $to_show .= '<th colspan="4">'.&mt('Settings').'</th>';
3275: }
1.484.2.29 raeburn 3276: $to_show .= &Apache::loncommon::end_data_table_header_row();
3277: if ($folder !~ /^supplemental/) {
1.484.2.30 raeburn 3278: $lists{'canhide'} = join(',',@allidx);
3279: $lists{'canrandomlyorder'} = join(',',@allmapidx);
3280: my @possfilters = ('canremove','cancut','cancopy','hiddenresource','encrypturl',
3281: 'randomorder','randompick');
3282: foreach my $item (@possfilters) {
3283: if (ref($filters{$item}) eq 'ARRAY') {
3284: if (@{$filters{$item}} > 0) {
3285: $lists{$item} = join(',',@{$filters{$item}});
3286: }
3287: }
3288: }
1.484.2.29 raeburn 3289: if (@allidx > 0) {
3290: my $path;
3291: if ($env{'form.folderpath'}) {
3292: $path =
3293: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3294: }
1.484.2.30 raeburn 3295: if (@allidx > 1) {
3296: $to_show .=
3297: &Apache::loncommon::continue_data_table_row().
3298: '<td colspan="2"> </td>'.
3299: '<td>'.
1.484.2.67 raeburn 3300: &multiple_check_form('actions',\%lists,$canedit).
1.484.2.30 raeburn 3301: '</td>'.
3302: '<td> </td>'.
3303: '<td> </td>'.
3304: '<td colspan="4">'.
1.484.2.67 raeburn 3305: &multiple_check_form('settings',\%lists,$canedit).
1.484.2.30 raeburn 3306: '</td>'.
3307: &Apache::loncommon::end_data_table_row();
3308: $need_save = 1;
3309: }
1.484.2.29 raeburn 3310: }
3311: }
3312: $to_show .= $output.' '
1.484.2.19 raeburn 3313: .&Apache::loncommon::end_data_table()
3314: .'<br style="line-height:2px;" />'
3315: .&Apache::loncommon::end_scrollbox();
3316: } else {
3317: $to_show .= $toolslink
3318: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3319: .$output.' '
3320: .&Apache::loncommon::end_data_table();
3321: }
3322: } else {
3323: if (!$allowed) {
3324: $to_show .= $toolslink;
1.393 raeburn 3325: }
1.484.2.67 raeburn 3326: my $noresmsg;
3327: if ($allowed && $hiddentop && !$supplementalflag) {
3328: $noresmsg = &mt('Main Content Hidden');
3329: } else {
3330: $noresmsg = &mt('Currently empty');
3331: }
1.484.2.19 raeburn 3332: $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
3333: .'<div class="LC_info" id="contentlist">'
1.484.2.67 raeburn 3334: .$noresmsg
1.484.2.19 raeburn 3335: .'</div>'
3336: .&Apache::loncommon::end_scrollbox();
1.393 raeburn 3337: }
3338: } else {
1.484.2.19 raeburn 3339: if ($shown) {
3340: $to_show = '<div>'
3341: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3342: .$output
3343: .&Apache::loncommon::end_data_table()
3344: .'</div>';
3345: } else {
3346: $to_show = '<div class="LC_info" id="contentlist">'
1.484.2.34 raeburn 3347: .&mt('Currently empty')
1.484.2.19 raeburn 3348: .'</div>'
3349: }
1.458 raeburn 3350: }
3351: my $tid = 1;
3352: if ($supplementalflag) {
3353: $tid = 2;
1.329 droeschl 3354: }
3355: if ($allowed) {
1.484 raeburn 3356: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
1.484.2.30 raeburn 3357: $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,
1.484.2.67 raeburn 3358: $jumpto,$readfile,$need_save,"$folder.$container",$canedit));
1.484.2.68 raeburn 3359: if ($canedit) {
1.484.2.67 raeburn 3360: &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
3361: }
1.460 raeburn 3362: } else {
3363: $r->print($to_show);
1.329 droeschl 3364: }
3365: return;
3366: }
3367:
1.484.2.30 raeburn 3368: sub multiple_check_form {
1.484.2.67 raeburn 3369: my ($caller,$listsref,$canedit) = @_;
1.484.2.30 raeburn 3370: return unless (ref($listsref) eq 'HASH');
1.484.2.67 raeburn 3371: my $disabled;
3372: unless ($canedit) {
3373: $disabled = 'disabled="disabled"';
3374: }
1.484.2.30 raeburn 3375: my $output =
3376: '<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'.
3377: '<span class="LC_nobreak" style="font-size:x-small;font-weight:bold;">'.
3378: '<label><input type="radio" name="showmultpick" value="0" onclick="javascript:togglePick('."'$caller','0'".');" checked="checked" />'.&mt('one').'</label>'.(' 'x2).'<label><input type="radio" name="showmultpick" value="1" onclick="javascript:togglePick('."'$caller','1'".');" />'.&mt('multiple').'</label></span><span id="more'.$caller.'" class="LC_nobreak LC_docs_ext_edit"></span></form>'.
3379: '<div id="multi'.$caller.'" style="display:none;margin:0;padding:0;border:0">'.
3380: '<form action="/adm/coursedocs" method="post" name="cumulative'.$caller.'">'."\n".
3381: '<fieldset id="allfields'.$caller.'" style="display:none"><legend style="font-size:x-small;">'.&mt('check/uncheck all').'</legend>'."\n";
3382: if ($caller eq 'settings') {
3383: $output .=
3384: '<table><tr>'.
3385: '<td class="LC_docs_entry_parameter">'.
3386: '<span class="LC_nobreak"><label>'.
1.484.2.67 raeburn 3387: '<input type="checkbox" name="hiddenresourceall" id="hiddenresourceall" onclick="propagateState(this.form,'."'hiddenresource'".')"'.$disabled.' />'.&mt('Hidden').
1.484.2.30 raeburn 3388: '</label></span></td>'.
3389: '<td class="LC_docs_entry_parameter">'.
1.484.2.67 raeburn 3390: '<span class="LC_nobreak"><label><input type="checkbox" name="randompickall" id="randompickall" onclick="updatePick(this.form,'."'all','check'".');propagateState(this.form,'."'randompick'".');propagateState(this.form,'."'rpicknum'".');"'.$disabled.' />'.&mt('Randomly Pick').'</label><span id="rpicktextall"></span><input type="hidden" name="rpicknumall" id="rpicknumall" value="" />'.
1.484.2.30 raeburn 3391: '</span></td>'.
3392: '</tr>'."\n".
3393: '<tr>'.
3394: '<td class="LC_docs_entry_parameter">'.
1.484.2.67 raeburn 3395: '<span class="LC_nobreak"><label><input type="checkbox" name="encrypturlall" id="encrypturlall" onclick="propagateState(this.form,'."'encrypturl'".')"'.$disabled.' />'.&mt('URL hidden').'</label></span></td><td class="LC_docs_entry_parameter"><span class="LC_nobreak"><label><input type="checkbox" name="randomorderall" id="randomorderall" onclick="propagateState(this.form,'."'randomorder'".')"'.$disabled.' />'.&mt('Random Order').
1.484.2.30 raeburn 3396: '</label></span>'.
3397: '</td></tr></table>'."\n";
3398: } else {
3399: $output .=
3400: '<table><tr>'.
3401: '<td class="LC_docs_entry_parameter">'.
3402: '<span class="LC_nobreak LC_docs_remove">'.
1.484.2.67 raeburn 3403: '<label><input type="checkbox" name="removeall" id="removeall" onclick="propagateState(this.form,'."'remove'".')"'.$disabled.' />'.&mt('Remove').
1.484.2.30 raeburn 3404: '</label></span></td>'.
3405: '<td class="LC_docs_entry_parameter">'.
3406: '<span class="LC_nobreak LC_docs_cut">'.
1.484.2.67 raeburn 3407: '<label><input type="checkbox" name="cut" id="cutall" onclick="propagateState(this.form,'."'cut'".');"'.$disabled.' />'.&mt('Cut').
1.484.2.30 raeburn 3408: '</label></span></td>'."\n".
3409: '<td class="LC_docs_entry_parameter">'.
3410: '<span class="LC_nobreak LC_docs_copy">'.
1.484.2.67 raeburn 3411: '<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')"'.$disabled.' />'.&mt('Copy').
1.484.2.30 raeburn 3412: '</label></span></td>'.
3413: '</tr></table>'."\n";
3414: }
3415: $output .=
3416: '</fieldset>'.
3417: '<input type="hidden" name="allidx" value="'.$listsref->{'canhide'}.'" />';
3418: if ($caller eq 'settings') {
3419: $output .=
3420: '<input type="hidden" name="allmapidx" value="'.$listsref->{'canrandomlyorder'}.'" />'."\n".
3421: '<input type="hidden" name="currhiddenresource" value="'.$listsref->{'hiddenresource'}.'" />'."\n".
3422: '<input type="hidden" name="currencrypturl" value="'.$listsref->{'encrypturl'}.'" />'."\n".
3423: '<input type="hidden" name="currrandomorder" value="'.$listsref->{'randomorder'}.'" />'."\n".
3424: '<input type="hidden" name="currrandompick" value="'.$listsref->{'randompick'}.'" />'."\n";
3425: } elsif ($caller eq 'actions') {
3426: $output .=
3427: '<input type="hidden" name="allremoveidx" id="allremoveidx" value="'.$listsref->{'canremove'}.'" />'.
3428: '<input type="hidden" name="allcutidx" id="allcutidx" value="'.$listsref->{'cancut'}.'" />'.
3429: '<input type="hidden" name="allcopyidx" id="allcopyidx" value="'.$listsref->{'cancopy'}.'" />';
3430: }
3431: $output .=
3432: '</form>'.
3433: '</div>';
3434: return $output;
3435: }
3436:
1.329 droeschl 3437: sub process_file_upload {
1.484.2.36 raeburn 3438: my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd,$crstype) = @_;
1.329 droeschl 3439: # upload a file, if present
1.484.2.36 raeburn 3440: my $filesize = length($env{'form.uploaddoc'});
3441: if (!$filesize) {
3442: $$upload_output = '<div class="LC_error">'.
3443: &mt('Unable to upload [_1]. (size = [_2] bytes)',
3444: '<span class="LC_filename">'.$env{'form.uploaddoc.filename'}.'</span>',
3445: $filesize).'<br />'.
3446: &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'<br />'.
3447: '</div>';
3448: return;
3449: }
3450: my $quotatype = 'unofficial';
3451: if ($crstype eq 'Community') {
3452: $quotatype = 'community';
1.484.2.51 raeburn 3453: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
1.484.2.36 raeburn 3454: $quotatype = 'official';
1.484.2.45 raeburn 3455: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
3456: $quotatype = 'textbook';
1.484.2.36 raeburn 3457: }
3458: if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) {
3459: $filesize = int($filesize/1000); #expressed in kb
3460: $$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course',
1.484.2.51 raeburn 3461: $env{'form.uploaddoc.filename'},$filesize,
3462: 'upload',$quotatype);
1.484.2.36 raeburn 3463: return if ($$upload_output);
3464: }
1.440 raeburn 3465: my ($parseaction,$showupload,$nextphase,$mimetype);
3466: if ($env{'form.parserflag'}) {
1.329 droeschl 3467: $parseaction = 'parse';
3468: }
3469: my $folder=$env{'form.folder'};
3470: if ($folder eq '') {
3471: $folder='default';
3472: }
3473: if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
3474: my $errtext='';
3475: my $fatal=0;
3476: my $container='sequence';
1.484.2.19 raeburn 3477: if ($env{'form.folderpath'} =~ /:1$/) {
1.329 droeschl 3478: $container='page';
3479: }
3480: ($errtext,$fatal)=
1.484.2.27 raeburn 3481: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1.329 droeschl 3482: if ($#LONCAPA::map::order<1) {
3483: $LONCAPA::map::order[0]=1;
3484: $LONCAPA::map::resources[1]='';
3485: }
3486: my $destination = 'docs/';
3487: if ($folder =~ /^supplemental/) {
3488: $destination = 'supplemental/';
3489: }
3490: if (($folder eq 'default') || ($folder eq 'supplemental')) {
3491: $destination .= 'default/';
3492: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
3493: $destination .= $2.'/';
3494: }
1.484.2.27 raeburn 3495: if ($fatal) {
3496: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'</div>';
3497: return;
3498: }
1.440 raeburn 3499: # this is for a course, not a user, so set context to coursedoc.
1.329 droeschl 3500: my $newidx=&LONCAPA::map::getresidx();
3501: $destination .= $newidx;
1.439 raeburn 3502: my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination,
1.329 droeschl 3503: $parseaction,$allfiles,
1.440 raeburn 3504: $codebase,undef,undef,undef,undef,
3505: undef,undef,\$mimetype);
3506: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) {
3507: my $stored = $1;
3508: $showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'.
3509: $stored.'</span>').'</p>';
3510: } else {
3511: my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});
3512:
1.457 raeburn 3513: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>';
1.440 raeburn 3514: return;
3515: }
1.329 droeschl 3516: my $ext='false';
3517: if ($url=~m{^http://}) { $ext='true'; }
3518: $url = &LONCAPA::map::qtunescape($url);
3519: my $comment=$env{'form.comment'};
3520: $comment = &LONCAPA::map::qtunescape($comment);
3521: if ($folder=~/^supplemental/) {
3522: $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
3523: $env{'user.domain'}.'___&&&___'.$comment;
3524: }
3525:
3526: $LONCAPA::map::resources[$newidx]=
3527: $comment.':'.$url.':'.$ext.':normal:res';
3528: $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
3529: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.484.2.7 raeburn 3530: $folder.'.'.$container,1);
1.329 droeschl 3531: if ($fatal) {
1.457 raeburn 3532: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>';
1.440 raeburn 3533: return;
1.329 droeschl 3534: } else {
1.440 raeburn 3535: if ($parseaction eq 'parse' && $mimetype eq 'text/html') {
3536: $$upload_output = $showupload;
1.384 raeburn 3537: my $total_embedded = scalar(keys(%{$allfiles}));
1.329 droeschl 3538: if ($total_embedded > 0) {
1.440 raeburn 3539: my $uploadphase = 'upload_embedded';
3540: my $primaryurl = &HTML::Entities::encode($url,'<>&"');
3541: my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx);
3542: my ($embedded,$num) =
3543: &Apache::loncommon::ask_for_embedded_content(
3544: '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url});
3545: if ($embedded) {
3546: if ($num) {
3547: $$upload_output .=
3548: '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
3549: $nextphase = $uploadphase;
3550: } else {
3551: $$upload_output .= $embedded;
3552: }
3553: } else {
3554: $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
3555: }
1.329 droeschl 3556: } else {
1.440 raeburn 3557: $$upload_output .= &mt('No embedded items identified').'<br />';
1.329 droeschl 3558: }
1.457 raeburn 3559: $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
1.484.2.51 raeburn 3560: } elsif ((&Apache::loncommon::is_archive_file($mimetype)) &&
3561: ($env{'form.uploaddoc.filename'} =~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i)) {
1.476 raeburn 3562: $nextphase = 'decompress_uploaded';
3563: my $position = scalar(@LONCAPA::map::order)-1;
3564: my $noextract = &return_to_editor();
3565: my $archiveurl = &HTML::Entities::encode($url,'<>&"');
3566: my %archiveitems = (
3567: folderpath => $env{'form.folderpath'},
3568: cmd => $nextphase,
3569: newidx => $newidx,
3570: position => $position,
3571: phase => $nextphase,
1.477 raeburn 3572: comment => $comment,
1.480 raeburn 3573: );
3574: my ($destination,$dir_root) = &embedded_destination($coursenum,$coursedom);
3575: my @current = &get_dir_list($url,$coursenum,$coursedom,$newidx);
1.476 raeburn 3576: $$upload_output = $showupload.
3577: &Apache::loncommon::decompress_form($mimetype,
3578: $archiveurl,'/adm/coursedocs',$noextract,
1.480 raeburn 3579: \%archiveitems,\@current);
1.329 droeschl 3580: }
3581: }
3582: }
1.440 raeburn 3583: return $nextphase;
1.329 droeschl 3584: }
3585:
1.480 raeburn 3586: sub get_dir_list {
3587: my ($url,$coursenum,$coursedom,$newidx) = @_;
3588: my ($destination,$dir_root) = &embedded_destination();
3589: my ($dirlistref,$listerror) =
3590: &Apache::lonnet::dirlist("$dir_root/$destination/$newidx",$coursedom,$coursenum,1);
3591: my @dir_lines;
3592: my $dirptr=16384;
3593: if (ref($dirlistref) eq 'ARRAY') {
3594: foreach my $dir_line (sort
3595: {
3596: my ($afile)=split('&',$a,2);
3597: my ($bfile)=split('&',$b,2);
3598: return (lc($afile) cmp lc($bfile));
3599: } (@{$dirlistref})) {
3600: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
3601: $filename =~ s/\s+$//;
3602: next if ($filename =~ /^\.\.?$/);
3603: my $isdir = 0;
3604: if ($dirptr&$testdir) {
3605: $isdir = 1;
3606: }
3607: push(@dir_lines, [$filename,$dom,$isdir,$size,$mtime,$obs]);
3608: }
3609: }
3610: return @dir_lines;
3611: }
3612:
1.329 droeschl 3613: sub is_supplemental_title {
3614: my ($title) = @_;
3615: return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
3616: }
3617:
3618: # --------------------------------------------------------------- An entry line
3619:
3620: sub entryline {
1.484.2.12 raeburn 3621: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
1.484.2.67 raeburn 3622: $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups,
1.484.2.72.2. (raeburn 3623:): $ltitoolsref,$canedit,$isencrypted,$navmapref)=@_;
1.484.2.52 raeburn 3624: my ($foldertitle,$renametitle,$oldtitle);
1.329 droeschl 3625: if (&is_supplemental_title($title)) {
1.484.2.7 raeburn 3626: ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
1.329 droeschl 3627: } else {
3628: $title=&HTML::Entities::encode($title,'"<>&\'');
3629: $renametitle=$title;
3630: $foldertitle=$title;
3631: }
3632:
1.484.2.67 raeburn 3633: my ($disabled,$readonly,$js_lt);
3634: unless ($canedit) {
3635: $disabled = 'disabled="disabled"';
3636: $readonly = 1;
3637: }
3638:
1.329 droeschl 3639: my $orderidx=$LONCAPA::map::order[$index];
1.364 bisitz 3640:
1.329 droeschl 3641: $renametitle=~s/\\/\\\\/g;
3642: $renametitle=~s/\"\;/\\\"/g;
1.484.2.55 raeburn 3643: $renametitle=~s/"/%22/g;
1.329 droeschl 3644: $renametitle=~s/ /%20/g;
1.484.2.52 raeburn 3645: $oldtitle = $renametitle;
3646: $renametitle=~s/\'\;/\\\'/g;
1.379 bisitz 3647: my $line=&Apache::loncommon::start_data_table_row();
1.484.2.30 raeburn 3648: my ($form_start,$form_end,$form_common,$form_param);
1.329 droeschl 3649: # Edit commands
1.484.2.28 raeburn 3650: my ($esc_path, $path, $symb);
1.329 droeschl 3651: if ($env{'form.folderpath'}) {
3652: $esc_path=&escape($env{'form.folderpath'});
3653: $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3654: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
3655: }
1.484.2.16 raeburn 3656: my $isexternal;
1.484.2.19 raeburn 3657: if ($residx) {
1.484.2.12 raeburn 3658: my $currurl = $url;
3659: $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.484.2.16 raeburn 3660: if ($currurl =~ m{^/adm/wrapper/ext/}) {
3661: $isexternal = 1;
3662: }
1.484.2.19 raeburn 3663: if (!$supplementalflag) {
3664: my $path = 'uploaded/'.
3665: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
3666: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
3667: $symb = &Apache::lonnet::encode_symb($path.$folder.".$container",
3668: $residx,
3669: &Apache::lonnet::declutter($currurl));
3670: }
1.484.2.12 raeburn 3671: }
1.484.2.30 raeburn 3672: my ($renamelink,%lt,$ishash);
3673: if (ref($filtersref) eq 'HASH') {
3674: $ishash = 1;
3675: }
3676:
1.329 droeschl 3677: if ($allowed) {
1.484.2.30 raeburn 3678: $form_start = '
3679: <form action="/adm/coursedocs" method="post">
3680: ';
3681: $form_common=(<<END);
3682: <input type="hidden" name="folderpath" value="$path" />
3683: <input type="hidden" name="symb" value="$symb" />
3684: END
3685: $form_param=(<<END);
3686: <input type="hidden" name="setparms" value="$orderidx" />
3687: <input type="hidden" name="changeparms" value="0" />
3688: END
3689: $form_end = '</form>';
3690:
1.329 droeschl 3691: my $incindex=$index+1;
3692: my $selectbox='';
1.471 raeburn 3693: if (($#LONCAPA::map::order>0) &&
1.329 droeschl 3694: ((split(/\:/,
1.344 bisitz 3695: $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
3696: ne '') &&
1.329 droeschl 3697: ((split(/\:/,
1.344 bisitz 3698: $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1.329 droeschl 3699: ne '')) {
3700: $selectbox=
3701: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.484.2.67 raeburn 3702: '<select name="newpos" onchange="this.form.submit()"'.$disabled.'>';
1.329 droeschl 3703: for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
3704: if ($i==$incindex) {
1.358 bisitz 3705: $selectbox.='<option value="" selected="selected">('.$i.')</option>';
1.329 droeschl 3706: } else {
3707: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
3708: }
3709: }
3710: $selectbox.='</select>';
3711: }
1.484.2.12 raeburn 3712: %lt=&Apache::lonlocal::texthash(
1.329 droeschl 3713: 'up' => 'Move Up',
3714: 'dw' => 'Move Down',
3715: 'rm' => 'Remove',
3716: 'ct' => 'Cut',
3717: 'rn' => 'Rename',
1.484.2.12 raeburn 3718: 'cp' => 'Copy',
3719: 'ex' => 'External Resource',
1.484.2.72.2. (raeburn 3720:): 'et' => 'External Tool',
1.484.2.12 raeburn 3721: 'ed' => 'Edit',
3722: 'pr' => 'Preview',
3723: 'sv' => 'Save',
3724: 'ul' => 'URL',
1.484.2.67 raeburn 3725: 'ti' => 'Title',
3726: 'er' => 'Editing rights unavailable for your current role.',
1.484.2.12 raeburn 3727: );
1.484.2.30 raeburn 3728: my %denied = &action_restrictions($coursenum,$coursedom,$url,
3729: $env{'form.folderpath'},
3730: $currgroups);
1.484.2.19 raeburn 3731: my ($copylink,$cutlink,$removelink);
1.329 droeschl 3732: my $skip_confirm = 0;
1.484.2.63 raeburn 3733: my $confirm_removal = 0;
1.329 droeschl 3734: if ( $folder =~ /^supplemental/
3735: || ($url =~ m{( /smppg$
3736: |/syllabus$
3737: |/aboutme$
3738: |/navmaps$
3739: |/bulletinboard$
1.484.2.72.2. (raeburn 3740:): |/ext\.tool$
1.484.2.16 raeburn 3741: |\.html$)}x)
1.484.2.19 raeburn 3742: || $isexternal) {
1.329 droeschl 3743: $skip_confirm = 1;
3744: }
1.484.2.63 raeburn 3745: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
3746: ($url!~/$LONCAPA::assess_page_seq_re/)) {
3747: $confirm_removal = 1;
3748: }
1.484.2.19 raeburn 3749:
1.484.2.30 raeburn 3750: if ($denied{'copy'}) {
3751: $copylink=(<<ENDCOPY)
1.484.2.16 raeburn 3752: <span style="visibility: hidden;">$lt{'cp'}</span>
3753: ENDCOPY
3754: } else {
1.484.2.30 raeburn 3755: my $formname = 'edit_copy_'.$orderidx;
3756: my $js = "javascript:checkForSubmit(document.forms.renameform,'copy','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.484.2.19 raeburn 3757: $copylink=(<<ENDCOPY);
1.484.2.30 raeburn 3758: <form name="$formname" method="post" action="/adm/coursedocs">
3759: $form_common
1.484.2.67 raeburn 3760: <input type="checkbox" name="copy" id="copy_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','copy');" class="LC_hidden" $disabled /><a href="$js" class="LC_docs_copy">$lt{'cp'}</a>
1.484.2.30 raeburn 3761: $form_end
1.329 droeschl 3762: ENDCOPY
1.484.2.30 raeburn 3763: if (($ishash) && (ref($filtersref->{'cancopy'}) eq 'ARRAY')) {
3764: push(@{$filtersref->{'cancopy'}},$orderidx);
3765: }
1.329 droeschl 3766: }
1.484.2.30 raeburn 3767: if ($denied{'cut'}) {
1.484.2.16 raeburn 3768: $cutlink=(<<ENDCUT);
3769: <span style="visibility: hidden;">$lt{'ct'}</span>
3770: ENDCUT
3771: } else {
1.484.2.30 raeburn 3772: my $formname = 'edit_cut_'.$orderidx;
3773: my $js = "javascript:checkForSubmit(document.forms.renameform,'cut','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.484.2.19 raeburn 3774: $cutlink=(<<ENDCUT);
1.484.2.30 raeburn 3775: <form name="$formname" method="post" action="/adm/coursedocs">
3776: $form_common
3777: <input type="hidden" name="skip_$orderidx" id="skip_cut_$orderidx" value="$skip_confirm" />
1.484.2.67 raeburn 3778: <input type="checkbox" name="cut" id="cut_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','cut');" class="LC_hidden" $disabled /><a href="$js" class="LC_docs_cut">$lt{'ct'}</a>
1.484.2.30 raeburn 3779: $form_end
1.329 droeschl 3780: ENDCUT
1.484.2.30 raeburn 3781: if (($ishash) && (ref($filtersref->{'cancut'}) eq 'ARRAY')) {
3782: push(@{$filtersref->{'cancut'}},$orderidx);
3783: }
1.329 droeschl 3784: }
1.484.2.30 raeburn 3785: if ($denied{'remove'}) {
1.484.2.16 raeburn 3786: $removelink=(<<ENDREM);
3787: <span style="visibility: hidden;">$lt{'rm'}</a>
3788: ENDREM
3789: } else {
1.484.2.30 raeburn 3790: my $formname = 'edit_remove_'.$orderidx;
1.484.2.63 raeburn 3791: my $js = "javascript:checkForSubmit(document.forms.renameform,'remove','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder',$confirm_removal);";
1.484.2.9 raeburn 3792: $removelink=(<<ENDREM);
1.484.2.30 raeburn 3793: <form name="$formname" method="post" action="/adm/coursedocs">
3794: $form_common
3795: <input type="hidden" name="skip_$orderidx" id="skip_remove_$orderidx" value="$skip_confirm" />
1.484.2.63 raeburn 3796: <input type="hidden" name="confirm_rem_$orderidx" id="confirm_removal_$orderidx" value="$confirm_removal" />
1.484.2.67 raeburn 3797: <input type="checkbox" name="remove" id="remove_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','remove');" class="LC_hidden" $disabled /><a href="$js" class="LC_docs_remove">$lt{'rm'}</a>
1.484.2.30 raeburn 3798: $form_end
1.484.2.9 raeburn 3799: ENDREM
1.484.2.30 raeburn 3800: if (($ishash) && (ref($filtersref->{'canremove'}) eq 'ARRAY')) {
3801: push(@{$filtersref->{'canremove'}},$orderidx);
3802: }
1.484.2.9 raeburn 3803: }
1.484.2.35 raeburn 3804: $renamelink=(<<ENDREN);
1.484.2.52 raeburn 3805: <a href='javascript:changename("$esc_path","$index","$oldtitle");' class="LC_docs_rename">$lt{'rn'}</a>
1.484.2.16 raeburn 3806: ENDREN
1.484.2.67 raeburn 3807: my ($uplink,$downlink);
3808: if ($canedit) {
3809: $uplink = "/adm/coursedocs?cmd=up_$index&folderpath=$esc_path&symb=$symb";
3810: $downlink = "/adm/coursedocs?cmd=down_$index&folderpath=$esc_path&symb=$symb";
3811: } else {
3812: $uplink = "javascript:alert('".&js_escape($lt{'er'})."');";
3813: $downlink = $uplink;
3814: }
1.329 droeschl 3815: $line.=(<<END);
3816: <td>
1.379 bisitz 3817: <div class="LC_docs_entry_move">
1.484.2.67 raeburn 3818: <a href="$uplink">
1.484.2.12 raeburn 3819: <img src="${iconpath}move_up.gif" alt="$lt{'up'}" class="LC_icon" />
1.379 bisitz 3820: </a>
3821: </div>
3822: <div class="LC_docs_entry_move">
1.484.2.67 raeburn 3823: <a href="$downlink">
1.484.2.12 raeburn 3824: <img src="${iconpath}move_down.gif" alt="$lt{'dw'}" class="LC_icon" />
1.379 bisitz 3825: </a>
3826: </div>
1.329 droeschl 3827: </td>
3828: <td>
3829: $form_start
1.484.2.30 raeburn 3830: $form_param
1.478 raeburn 3831: $form_common
1.329 droeschl 3832: $selectbox
3833: $form_end
3834: </td>
1.484.2.30 raeburn 3835: <td class="LC_docs_entry_commands LC_nobreak">
1.484.2.9 raeburn 3836: $removelink
1.329 droeschl 3837: $cutlink
3838: $copylink
3839: </td>
3840: END
3841: }
3842: # Figure out what kind of a resource this is
3843: my ($extension)=($url=~/\.(\w+)$/);
3844: my $uploaded=($url=~/^\/*uploaded\//);
3845: my $icon=&Apache::loncommon::icon($url);
1.484.2.19 raeburn 3846: my $isfolder;
3847: my $ispage;
3848: my $containerarg;
1.484.2.67 raeburn 3849: my $folderurl;
1.329 droeschl 3850: if ($uploaded) {
1.472 raeburn 3851: if (($extension eq 'sequence') || ($extension eq 'page')) {
3852: $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
1.484.2.19 raeburn 3853: $containerarg = $1;
1.472 raeburn 3854: if ($extension eq 'sequence') {
3855: $icon=$iconpath.'navmap.folder.closed.gif';
3856: $isfolder=1;
3857: } else {
3858: $icon=$iconpath.'page.gif';
3859: $ispage=1;
3860: }
1.484.2.67 raeburn 3861: $folderurl = &Apache::lonnet::declutter($url);
1.472 raeburn 3862: if ($allowed) {
3863: $url='/adm/coursedocs?';
3864: } else {
3865: $url='/adm/supplemental?';
3866: }
1.329 droeschl 3867: } else {
3868: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
3869: }
3870: }
1.364 bisitz 3871:
1.484.2.70 raeburn 3872: my ($editlink,$extresform,$anchor,$hiddenres,$nomodal);
1.329 droeschl 3873: my $orig_url = $url;
1.340 raeburn 3874: $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
1.484.2.19 raeburn 3875: $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.484.2.12 raeburn 3876: if (!$supplementalflag && $residx && $symb) {
3877: if ((!$isfolder) && (!$ispage)) {
3878: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
3879: $url=&Apache::lonnet::clutter($url);
3880: if ($url=~/^\/*uploaded\//) {
3881: $url=~/\.(\w+)$/;
3882: my $embstyle=&Apache::loncommon::fileembstyle($1);
3883: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
3884: $url='/adm/wrapper'.$url;
3885: } elsif ($embstyle eq 'ssi') {
3886: #do nothing with these
3887: } elsif ($url!~/\.(sequence|page)$/) {
3888: $url='/adm/coursedocs/showdoc'.$url;
3889: }
1.484.2.70 raeburn 3890: } elsif ($url=~m{^(|/adm/wrapper)/ext/([^#]+)}) {
3891: my $wrapped = $1;
3892: my $exturl = $2;
3893: if ($wrapped eq '') {
3894: $url='/adm/wrapper'.$url;
3895: }
3896: if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) {
3897: $nomodal = 1;
3898: }
1.484.2.72.2. (raeburn 3899:): } elsif ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
3900:): $url='/adm/wrapper'.$url;
1.484.2.70 raeburn 3901: } elsif ($url eq "/public/$coursedom/$coursenum/syllabus") {
3902: if (($ENV{'SERVER_PORT'} == 443) &&
3903: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
3904: $nomodal = 1;
3905: }
1.484.2.19 raeburn 3906: }
1.484.2.12 raeburn 3907: if (&Apache::lonnet::symbverify($symb,$url)) {
1.484.2.66 raeburn 3908: my $shownsymb = $symb;
3909: if ($isexternal) {
3910: if ($url =~ /^([^#]+)#([^#]+)$/) {
3911: $url = $1;
3912: $anchor = $2;
3913: if ($symb =~ m{^([^#]+)\Q#$anchor\E$}) {
3914: $shownsymb = $1.&escape('#').$anchor;
3915: }
3916: }
3917: }
1.484.2.67 raeburn 3918: unless ($env{'request.role.adv'}) {
3919: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
3920: $url = '';
3921: }
3922: if (&Apache::lonnet::EXT('resource.0.hiddenresource',$symb) =~ /^yes$/i) {
3923: $url = '';
3924: $hiddenres = 1;
3925: }
3926: }
3927: if ($url ne '') {
3928: $url.=(($url=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&');
3929: }
3930: } elsif (!$env{'request.role.adv'}) {
3931: my $checkencrypt;
3932: if (((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) ||
3933: $isencrypted || (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i)) {
3934: $checkencrypt = 1;
1.484.2.70 raeburn 3935: } elsif (ref($navmapref)) {
1.484.2.67 raeburn 3936: unless (ref($$navmapref)) {
3937: $$navmapref = Apache::lonnavmaps::navmap->new();
3938: }
3939: if (ref($$navmapref)) {
3940: if (lc($$navmapref->get_mapparam($symb,undef,"0.encrypturl")) eq 'yes') {
3941: $checkencrypt = 1;
3942: }
3943: }
3944: }
3945: if ($checkencrypt) {
3946: my $shownsymb = &Apache::lonenc::encrypted($symb);
3947: my $shownurl = &Apache::lonenc::encrypted($url);
3948: if (&Apache::lonnet::symbverify($shownsymb,$shownurl)) {
3949: $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&');
3950: if ($env{'request.enc'} ne '') {
3951: delete($env{'request.enc'});
3952: }
3953: } else {
3954: $url='';
3955: }
3956: } else {
3957: $url='';
3958: }
1.484.2.12 raeburn 3959: } else {
3960: $url='';
3961: }
1.484.2.19 raeburn 3962: }
1.484.2.66 raeburn 3963: } elsif ($supplementalflag) {
3964: if ($isexternal) {
3965: if ($url =~ /^([^#]+)#([^#]+)$/) {
3966: $url = $1;
3967: $anchor = $2;
1.484.2.70 raeburn 3968: if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) {
3969: $nomodal = 1;
3970: }
3971: }
3972: } elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
3973: if (($ENV{'SERVER_PORT'} == 443) &&
3974: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
3975: $nomodal = 1;
1.484.2.66 raeburn 3976: }
3977: }
1.329 droeschl 3978: }
1.484.2.67 raeburn 3979: my ($rand_pick_text,$rand_order_text,$hiddenfolder);
3980: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.484.2.19 raeburn 3981: if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') {
1.329 droeschl 3982: my $foldername=&escape($foldertitle);
3983: my $folderpath=$env{'form.folderpath'};
3984: if ($folderpath) { $folderpath.='&' };
1.484.2.19 raeburn 3985: if (!$allowed && $supplementalflag) {
3986: $folderpath.=$containerarg.'&'.$foldername;
3987: $url.='folderpath='.&escape($folderpath);
3988: } else {
3989: my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
3990: 'parameter_randompick'))[0];
1.484.2.67 raeburn 3991: my $randorder = ((&LONCAPA::map::getparameter($orderidx,
3992: 'parameter_randomorder'))[0]=~/^yes$/i);
3993: my $hiddenmap = ((&LONCAPA::map::getparameter($orderidx,
3994: 'parameter_hiddenresource'))[0]=~/^yes$/i);
3995: my $encryptmap = ((&LONCAPA::map::getparameter($orderidx,
3996: 'parameter_encrypturl'))[0]=~/^yes$/i);
3997: unless ($hiddenmap) {
1.484.2.70 raeburn 3998: if (ref($navmapref)) {
3999: unless (ref($$navmapref)) {
4000: $$navmapref = Apache::lonnavmaps::navmap->new();
4001: }
4002: if (ref($$navmapref)) {
4003: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
4004: my @resources = $$navmapref->retrieveResources($folderurl,$filterFunc,1,1);
4005: unless (@resources) {
4006: $hiddenmap = 1;
4007: unless ($env{'request.role.adv'}) {
4008: $url = '';
4009: $hiddenfolder = 1;
4010: }
1.484.2.67 raeburn 4011: }
4012: }
4013: }
4014: }
4015: }
4016: unless ($encryptmap) {
1.484.2.70 raeburn 4017: if ((ref($navmapref)) && (ref($$navmapref))) {
4018: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.encrypturl")) eq 'yes') {
4019: $encryptmap = 1;
4020: }
1.484.2.67 raeburn 4021: }
4022: }
4023:
4024: # Append randompick number, hidden, and encrypted with ":" to foldername,
4025: # so it gets transferred between levels
4026: $folderpath.=$containerarg.'&'.$foldername.
4027: ':'.$rpicknum.':'.$hiddenmap.':'.$encryptmap.':'.$randorder.':'.$ispage;
4028: unless ($url eq '') {
4029: $url.='folderpath='.&escape($folderpath);
4030: }
1.484.2.19 raeburn 4031: my $rpckchk;
4032: if ($rpicknum) {
4033: $rpckchk = ' checked="checked"';
1.484.2.30 raeburn 4034: if (($ishash) && (ref($filtersref->{'randompick'}) eq 'ARRAY')) {
4035: push(@{$filtersref->{'randompick'}},$orderidx.':'.$rpicknum);
4036: }
1.484.2.19 raeburn 4037: }
1.484.2.29 raeburn 4038: my $formname = 'edit_randompick_'.$orderidx;
1.484.2.19 raeburn 4039: $rand_pick_text =
1.478 raeburn 4040: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.484.2.30 raeburn 4041: $form_param."\n".
1.478 raeburn 4042: $form_common."\n".
1.484.2.67 raeburn 4043: '<span class="LC_nobreak"><label><input type="checkbox" name="randompick_'.$orderidx.'" id="randompick_'.$orderidx.'" onclick="'."updatePick(this.form,'$orderidx','check');".'"'.$rpckchk.$disabled.' /> '.&mt('Randomly Pick').'</label><input type="hidden" name="rpicknum_'.$orderidx.'" id="rpicknum_'.$orderidx.'" value="'.$rpicknum.'" /><span id="randompicknum_'.$orderidx.'">';
1.484.2.19 raeburn 4044: if ($rpicknum ne '') {
4045: $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
4046: }
1.484.2.29 raeburn 4047: $rand_pick_text .= '</span></span>'.
4048: $form_end;
1.484.2.30 raeburn 4049: my $ro_set;
1.484.2.67 raeburn 4050: if ($randorder) {
1.484.2.30 raeburn 4051: $ro_set = 'checked="checked"';
4052: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4053: push(@{$filtersref->{'randomorder'}},$orderidx);
4054: }
4055: }
1.484.2.41 raeburn 4056: $formname = 'edit_rorder_'.$orderidx;
1.484.2.19 raeburn 4057: $rand_order_text =
1.484.2.29 raeburn 4058: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.484.2.30 raeburn 4059: $form_param."\n".
1.484.2.29 raeburn 4060: $form_common."\n".
1.484.2.67 raeburn 4061: '<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.$disabled.' /> '.&mt('Random Order').' </label></span>'.
1.484.2.29 raeburn 4062: $form_end;
1.484.2.19 raeburn 4063: }
1.484.2.18 raeburn 4064: } elsif ($supplementalflag && !$allowed) {
1.484.2.72.2. (raeburn 4065:): my $isexttool;
4066:): if ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4067:): $url='/adm/wrapper'.$url;
4068:): $isexttool = 1;
4069:): }
1.484.2.19 raeburn 4070: $url .= ($url =~ /\?/) ? '&':'?';
1.484.2.18 raeburn 4071: $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
1.484.2.19 raeburn 4072: if ($title) {
4073: $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"');
4074: }
1.484.2.72.2. (raeburn 4075:): if ((($isexternal) || ($isexttool)) && $orderidx) {
1.484.2.19 raeburn 4076: $url .= '&idx='.$orderidx;
4077: }
1.484.2.66 raeburn 4078: if ($anchor ne '') {
4079: $url .= '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4080: }
1.329 droeschl 4081: }
1.484.2.19 raeburn 4082: my ($tdalign,$tdwidth);
1.484.2.12 raeburn 4083: if ($allowed) {
1.484.2.19 raeburn 4084: my $fileloc =
1.484.2.12 raeburn 4085: &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
1.484.2.19 raeburn 4086: if ($isexternal) {
4087: ($editlink,$extresform) =
1.484.2.67 raeburn 4088: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
4089: undef,undef,undef,$disabled);
1.484.2.72.2. (raeburn 4090:): } elsif ($orig_url =~ m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4091:): ($editlink,$extresform) =
4092:): &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
4093:): undef,undef,undef,'tool',$coursedom,
4094:): $coursenum,$ltitoolsref,$disabled);
1.484.2.19 raeburn 4095: } elsif (!$isfolder && !$ispage) {
4096: my ($cfile,$home,$switchserver,$forceedit,$forceview) =
1.484.2.14 raeburn 4097: &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
1.484.2.19 raeburn 4098: if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
1.484.2.66 raeburn 4099: my $suppanchor;
4100: if ($supplementalflag) {
4101: $suppanchor = $anchor;
4102: }
1.484.2.19 raeburn 4103: my $jscall =
1.484.2.12 raeburn 4104: &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
4105: $switchserver,
1.484.2.14 raeburn 4106: $forceedit,
1.484.2.19 raeburn 4107: undef,$symb,
4108: &escape($env{'form.folderpath'}),
1.484.2.66 raeburn 4109: $renametitle,'','',1,$suppanchor);
1.484.2.12 raeburn 4110: if ($jscall) {
1.484.2.19 raeburn 4111: $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
4112: $jscall.'" >'.&mt('Edit').'</a> '."\n";
1.484.2.12 raeburn 4113: }
4114: }
4115: }
1.484.2.19 raeburn 4116: $tdalign = ' align="right" valign="top"';
4117: $tdwidth = ' width="80%"';
1.329 droeschl 4118: }
1.408 raeburn 4119: my $reinit;
4120: if ($crstype eq 'Community') {
4121: $reinit = &mt('(re-initialize community to access)');
4122: } else {
4123: $reinit = &mt('(re-initialize course to access)');
1.484.2.19 raeburn 4124: }
4125: $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;
1.484.2.70 raeburn 4126: my $link;
1.472 raeburn 4127: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 4128: $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
4129: } elsif ($url) {
1.484.2.66 raeburn 4130: if ($anchor ne '') {
4131: if ($supplementalflag) {
4132: $anchor = '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4133: } else {
4134: $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');
4135: }
4136: }
1.484.2.70 raeburn 4137: $link = &js_escape($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.
4138: (($anchor ne '')?$anchor:''));
4139: if ($nomodal) {
4140: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4141: '<img src="'.$icon.'" alt="" class="LC_icon" border="0" /></a>';
4142: } else {
4143: $line.=&Apache::loncommon::modal_link($link,
4144: '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
4145: }
1.469 www 4146: } else {
4147: $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
4148: }
1.484.2.19 raeburn 4149: $line.='</span></td><td'.$tdwidth.'>';
1.472 raeburn 4150: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 4151: $line.='<a href="'.$url.'">'.$title.'</a>';
4152: } elsif ($url) {
1.484.2.70 raeburn 4153: if ($nomodal) {
4154: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4155: $title.'</a>';
4156: } else {
4157: $line.=&Apache::loncommon::modal_link($link,$title,600,500);
4158: }
1.484.2.67 raeburn 4159: } elsif (($hiddenfolder) || ($hiddenres)) {
1.484.2.72 raeburn 4160: $line.=$title.' <span class="LC_warning LC_docs_reinit_warn">('.&mt('Hidden').')</span>';
1.469 www 4161: } else {
4162: $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
4163: }
1.484.2.19 raeburn 4164: $line.="$extresform</td>";
1.478 raeburn 4165: $rand_pick_text = ' ' if ($rand_pick_text eq '');
4166: $rand_order_text = ' ' if ($rand_order_text eq '');
1.329 droeschl 4167: if (($allowed) && ($folder!~/^supplemental/)) {
4168: my %lt=&Apache::lonlocal::texthash(
4169: 'hd' => 'Hidden',
4170: 'ec' => 'URL hidden');
1.484.2.30 raeburn 4171: my ($enctext,$hidtext);
4172: if ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) {
4173: $enctext = ' checked="checked"';
4174: if (($ishash) && (ref($filtersref->{'encrypturl'}) eq 'ARRAY')) {
4175: push(@{$filtersref->{'encrypturl'}},$orderidx);
4176: }
4177: }
4178: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4179: $hidtext = ' checked="checked"';
4180: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4181: push(@{$filtersref->{'hiddenresource'}},$orderidx);
4182: }
4183: }
1.484.2.29 raeburn 4184: my $formhidden = 'edit_hiddenresource_'.$orderidx;
4185: my $formurlhidden = 'edit_encrypturl_'.$orderidx;
1.329 droeschl 4186: $line.=(<<ENDPARMS);
4187: <td class="LC_docs_entry_parameter">
1.484.2.30 raeburn 4188: <form action="/adm/coursedocs" method="post" name="$formhidden">
4189: $form_param
1.478 raeburn 4190: $form_common
1.484.2.67 raeburn 4191: <label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'hiddenresource','settings');" $hidtext $disabled /> $lt{'hd'}</label>
1.329 droeschl 4192: $form_end
1.458 raeburn 4193: <br />
1.484.2.29 raeburn 4194: <form action="/adm/coursedocs" method="post" name="$formurlhidden">
1.484.2.30 raeburn 4195: $form_param
1.478 raeburn 4196: $form_common
1.484.2.67 raeburn 4197: <label><input type="checkbox" name="encrypturl_$orderidx" id="encrypturl_$orderidx" onclick="checkForSubmit(this.form,'encrypturl','settings');" $enctext $disabled /> $lt{'ec'}</label>
1.329 droeschl 4198: $form_end
4199: </td>
1.478 raeburn 4200: <td class="LC_docs_entry_parameter">$rand_pick_text<br />
4201: $rand_order_text</td>
1.329 droeschl 4202: ENDPARMS
4203: }
1.379 bisitz 4204: $line.=&Apache::loncommon::end_data_table_row();
1.329 droeschl 4205: return $line;
4206: }
4207:
1.484.2.30 raeburn 4208: sub action_restrictions {
4209: my ($cnum,$cdom,$url,$folderpath,$currgroups) = @_;
4210: my %denied = (
4211: cut => 0,
4212: copy => 0,
4213: remove => 0,
4214: );
4215: if ($url=~ m{^/res/.+\.(page|sequence)$}) {
4216: # no copy for published maps
4217: $denied{'copy'} = 1;
4218: } elsif ($url=~m{^/res/lib/templates/}) {
4219: $denied{'copy'} = 1;
4220: $denied{'cut'} = 1;
4221: } elsif ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") {
4222: if ($folderpath =~ /^default&[^\&]+$/) {
4223: if ((ref($currgroups) eq 'HASH') && (keys(%{$currgroups}) > 0)) {
4224: $denied{'remove'} = 1;
4225: }
4226: $denied{'cut'} = 1;
4227: $denied{'copy'} = 1;
4228: }
4229: } elsif ($url =~ m{^\Q/uploaded/$cdom/$cnum/group_folder_\E(\w+)\.sequence$}) {
4230: my $group = $1;
4231: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+$/) {
4232: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4233: $denied{'remove'} = 1;
4234: }
4235: }
4236: $denied{'cut'} = 1;
4237: $denied{'copy'} = 1;
4238: } elsif ($url =~ m{^\Q/adm/$cdom/$cnum/\E(\w+)/smppg$}) {
4239: my $group = $1;
4240: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&\Qgroup_folder_$group\E\&[^\&]+$/) {
4241: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4242: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4243: if (keys(%groupsettings) > 0) {
4244: $denied{'remove'} = 1;
4245: }
4246: $denied{'cut'} = 1;
4247: $denied{'copy'} = 1;
4248: }
4249: }
4250: } elsif ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&group_folder_(\w+)\&/) {
4251: my $group = $1;
4252: if ($url =~ /group_boards_\Q$group\E/) {
4253: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4254: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4255: if (keys(%groupsettings) > 0) {
4256: if (ref($groupsettings{'functions'}) eq 'HASH') {
4257: if ($groupsettings{'functions'}{'discussion'} eq 'on') {
4258: $denied{'remove'} = 1;
4259: }
4260: }
4261: }
4262: $denied{'cut'} = 1;
4263: $denied{'copy'} = 1;
4264: }
4265: }
4266: }
4267: return %denied;
4268: }
4269:
1.484.2.26 raeburn 4270: sub new_timebased_suffix {
1.484.2.30 raeburn 4271: my ($dom,$num,$type,$area,$container) = @_;
1.484.2.26 raeburn 4272: my ($prefix,$namespace,$idtype,$errtext,$locknotfreed);
1.484.2.30 raeburn 4273: if ($type eq 'paste') {
4274: $prefix = $type;
4275: $namespace = 'courseeditor';
1.484.2.56 raeburn 4276: $idtype = 'addcode';
1.484.2.30 raeburn 4277: } elsif ($type eq 'map') {
1.484.2.26 raeburn 4278: $prefix = 'docs';
4279: if ($area eq 'supplemental') {
4280: $prefix = 'supp';
4281: }
4282: $prefix .= $container;
4283: $namespace = 'uploadedmaps';
4284: } else {
4285: $prefix = $type;
4286: $namespace = 'templated';
1.484.2.15 raeburn 4287: }
4288: my ($suffix,$freedlock,$error) =
1.484.2.56 raeburn 4289: &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num,$idtype);
1.484.2.15 raeburn 4290: if (!$suffix) {
1.484.2.30 raeburn 4291: if ($type eq 'paste') {
4292: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.');
4293: } elsif ($type eq 'map') {
1.484.2.26 raeburn 4294: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
4295: } elsif ($type eq 'smppg') {
4296: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.');
1.484.2.72.2. (raeburn 4297:): } elsif ($type eq 'exttool') {
4298:): $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new external tool.');
1.484.2.26 raeburn 4299: } else {
1.484.2.42 raeburn 4300: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new discussion board.');
1.484.2.26 raeburn 4301: }
1.484.2.15 raeburn 4302: if ($error) {
4303: $errtext .= '<br />'.$error;
4304: }
4305: }
4306: if ($freedlock ne 'ok') {
1.484.2.26 raeburn 4307: $locknotfreed =
4308: '<div class="LC_error">'.
4309: &mt('There was a problem removing a lockfile.').' ';
1.484.2.30 raeburn 4310: if ($type eq 'paste') {
1.484.2.57 raeburn 4311: if ($freedlock eq 'nolock') {
4312: $locknotfreed =
4313: '<div class="LC_error">'.
4314: &mt('A lockfile was not released when you added content to the clipboard earlier in this session.').' '.
4315:
1.484.2.60 raeburn 4316: &mt('As a result addition of items to the clipboard will be unavailable until your next log-in.');
1.484.2.57 raeburn 4317: } else {
4318: $locknotfreed .=
4319: &mt('This will prevent addition of items to the clipboard until your next log-in.');
4320: }
1.484.2.30 raeburn 4321: } elsif ($type eq 'map') {
1.484.2.57 raeburn 4322: $locknotfreed .=
4323: &mt('This will prevent creation of additional folders or composite pages in this course.');
1.484.2.26 raeburn 4324: } elsif ($type eq 'smppg') {
4325: $locknotfreed .=
4326: &mt('This will prevent creation of additional simple pages in this course.');
1.484.2.72.2. (raeburn 4327:): } elsif ($type eq 'exttool') {
4328:): $locknotfreed .=
4329:): &mt('This will prevent creation of additional external tools in this course.');
1.484.2.26 raeburn 4330: } else {
4331: $locknotfreed .=
1.484.2.42 raeburn 4332: &mt('This will prevent creation of additional discussion boards in this course.');
1.484.2.26 raeburn 4333: }
1.484.2.30 raeburn 4334: unless ($type eq 'paste') {
4335: $locknotfreed .=
1.484.2.38 raeburn 4336: ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
4337: '<a href="/adm/helpdesk" target="_helpdesk">','</a>');
1.484.2.30 raeburn 4338: }
4339: $locknotfreed .= '</div>';
1.484.2.15 raeburn 4340: }
4341: return ($suffix,$errtext,$locknotfreed);
4342: }
4343:
1.329 droeschl 4344: =pod
4345:
4346: =item tiehash()
4347:
4348: tie the hash
4349:
4350: =cut
4351:
4352: sub tiehash {
4353: my ($mode)=@_;
4354: $hashtied=0;
4355: if ($env{'request.course.fn'}) {
4356: if ($mode eq 'write') {
4357: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4358: &GDBM_WRCREAT(),0640)) {
4359: $hashtied=2;
4360: }
4361: } else {
4362: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4363: &GDBM_READER(),0640)) {
4364: $hashtied=1;
4365: }
4366: }
1.364 bisitz 4367: }
1.329 droeschl 4368: }
4369:
4370: sub untiehash {
4371: if ($hashtied) { untie %hash; }
4372: $hashtied=0;
4373: return OK;
4374: }
4375:
4376:
4377:
4378:
4379: sub checkonthis {
4380: my ($r,$url,$level,$title)=@_;
4381: $url=&unescape($url);
4382: $alreadyseen{$url}=1;
4383: $r->rflush();
4384: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
4385: $r->print("\n<br />");
4386: if ($level==0) {
4387: $r->print("<br />");
4388: }
4389: for (my $i=0;$i<=$level*5;$i++) {
4390: $r->print(' ');
4391: }
4392: $r->print('<a href="'.$url.'" target="cat">'.
4393: ($title?$title:$url).'</a> ');
4394: if ($url=~/^\/res\//) {
4395: my $result=&Apache::lonnet::repcopy(
4396: &Apache::lonnet::filelocation('',$url));
4397: if ($result eq 'ok') {
4398: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
4399: $r->rflush();
4400: &Apache::lonnet::countacc($url);
4401: $url=~/\.(\w+)$/;
4402: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
4403: $r->print('<br />');
4404: $r->rflush();
4405: for (my $i=0;$i<=$level*5;$i++) {
4406: $r->print(' ');
4407: }
4408: $r->print('- '.&mt('Rendering:').' ');
4409: my ($errorcount,$warningcount)=split(/:/,
4410: &Apache::lonnet::ssi_body($url,
4411: ('grade_target'=>'web',
4412: 'return_only_error_and_warning_counts' => 1)));
4413: if (($errorcount) ||
4414: ($warningcount)) {
4415: if ($errorcount) {
1.369 bisitz 4416: $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1.329 droeschl 4417: &mt('[quant,_1,error]',$errorcount).'</span>');
4418: }
4419: if ($warningcount) {
4420: $r->print('<span class="LC_warning">'.
4421: &mt('[quant,_1,warning]',$warningcount).'</span>');
4422: }
4423: } else {
4424: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
4425: }
4426: $r->rflush();
4427: }
4428: my $dependencies=
4429: &Apache::lonnet::metadata($url,'dependencies');
4430: foreach my $dep (split(/\,/,$dependencies)) {
4431: if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
4432: &checkonthis($r,$dep,$level+1);
4433: }
4434: }
4435: } elsif ($result eq 'unavailable') {
4436: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
4437: } elsif ($result eq 'not_found') {
4438: unless ($url=~/\$/) {
1.484.2.19 raeburn 4439: $r->print('<span class="LC_error">'.&mt('not found').'</span>');
1.329 droeschl 4440: } else {
1.366 bisitz 4441: $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1.329 droeschl 4442: }
4443: } else {
4444: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
4445: }
4446: }
4447: }
4448: }
4449:
4450:
4451:
4452: =pod
4453:
4454: =item list_symbs()
4455:
1.484.2.3 raeburn 4456: List Content Identifiers
1.329 droeschl 4457:
4458: =cut
4459:
4460: sub list_symbs {
4461: my ($r) = @_;
4462:
1.408 raeburn 4463: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 4464: $r->print(&Apache::loncommon::start_page('List of Content Identifiers'));
4465: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Identifiers'));
4466: $r->print(&startContentScreen('tools'));
1.329 droeschl 4467: my $navmap = Apache::lonnavmaps::navmap->new();
4468: if (!defined($navmap)) {
4469: $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
4470: '<div class="LC_error">'.
4471: &mt('Unable to retrieve information about course contents').
4472: '</div>');
1.408 raeburn 4473: &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
1.329 droeschl 4474: } else {
1.484 raeburn 4475: $r->print('<h4 class="LC_info">'.&mt("$crstype Content Identifiers").'</h4>'.
4476: &Apache::loncommon::start_data_table().
4477: &Apache::loncommon::start_data_table_header_row().
4478: '<th>'.&mt('Title').'</th><th>'.&mt('Identifier').'</th>'.
4479: &Apache::loncommon::end_data_table_header_row()."\n");
4480: my $count;
1.329 droeschl 4481: foreach my $res ($navmap->retrieveResources()) {
1.484 raeburn 4482: $r->print(&Apache::loncommon::start_data_table_row().
4483: '<td>'.$res->compTitle().'</td>'.
4484: '<td>'.$res->symb().'</td>'.
1.484.2.19 raeburn 4485: &Apache::loncommon::end_data_table_row());
1.484 raeburn 4486: $count ++;
4487: }
4488: if (!$count) {
4489: $r->print(&Apache::loncommon::start_data_table_row().
4490: '<td colspan="2">'.&mt("$crstype is empty").'</td>'.
4491: &Apache::loncommon::end_data_table_row());
1.329 droeschl 4492: }
1.484 raeburn 4493: $r->print(&Apache::loncommon::end_data_table());
1.329 droeschl 4494: }
1.484.2.19 raeburn 4495: $r->print(&endContentScreen());
1.329 droeschl 4496: }
4497:
4498:
4499: sub verifycontent {
4500: my ($r) = @_;
1.408 raeburn 4501: my $crstype = &Apache::loncommon::course_type();
1.484.2.34 raeburn 4502: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
4503: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
1.484 raeburn 4504: $r->print(&startContentScreen('tools'));
4505: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
1.329 droeschl 4506: $hashtied=0;
4507: undef %alreadyseen;
4508: %alreadyseen=();
4509: &tiehash();
1.484 raeburn 4510:
1.329 droeschl 4511: foreach my $key (keys(%hash)) {
4512: if ($hash{$key}=~/\.(page|sequence)$/) {
4513: if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
4514: $r->print('<hr /><span class="LC_error">'.
1.419 bisitz 4515: &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
1.329 droeschl 4516: &unescape($hash{$key}).'</span><br />'.
1.419 bisitz 4517: &mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />');
1.329 droeschl 4518: }
4519: }
4520: if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
4521: &checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
4522: }
4523: }
4524: &untiehash();
1.442 www 4525: $r->print('<p class="LC_success">'.&mt('Done').'</p>');
1.484.2.19 raeburn 4526: $r->print(&endContentScreen());
1.329 droeschl 4527: }
4528:
4529:
4530: sub devalidateversioncache {
4531: my $src=shift;
4532: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
4533: &Apache::lonnet::clutter($src));
4534: }
4535:
4536: sub checkversions {
1.484.2.67 raeburn 4537: my ($r,$canedit) = @_;
1.408 raeburn 4538: my $crstype = &Apache::loncommon::course_type();
1.484.2.44 raeburn 4539: $r->print(&Apache::loncommon::start_page("Check $crstype Resource Versions"));
4540: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Resource Versions"));
1.484 raeburn 4541: $r->print(&startContentScreen('tools'));
1.442 www 4542:
1.329 droeschl 4543: my $header='';
4544: my $startsel='';
4545: my $monthsel='';
4546: my $weeksel='';
4547: my $daysel='';
4548: my $allsel='';
4549: my %changes=();
4550: my $starttime=0;
4551: my $haschanged=0;
4552: my %setversions=&Apache::lonnet::dump('resourceversions',
4553: $env{'course.'.$env{'request.course.id'}.'.domain'},
4554: $env{'course.'.$env{'request.course.id'}.'.num'});
4555:
4556: $hashtied=0;
4557: &tiehash();
1.484.2.67 raeburn 4558: if ($canedit) {
4559: my %newsetversions=();
4560: if ($env{'form.setmostrecent'}) {
4561: $haschanged=1;
4562: foreach my $key (keys(%hash)) {
4563: if ($key=~/^ids\_(\/res\/.+)$/) {
4564: $newsetversions{$1}='mostrecent';
4565: &devalidateversioncache($1);
4566: }
1.329 droeschl 4567: }
1.484.2.67 raeburn 4568: } elsif ($env{'form.setcurrent'}) {
4569: $haschanged=1;
4570: foreach my $key (keys(%hash)) {
4571: if ($key=~/^ids\_(\/res\/.+)$/) {
4572: my $getvers=&Apache::lonnet::getversion($1);
4573: if ($getvers>0) {
4574: $newsetversions{$1}=$getvers;
4575: &devalidateversioncache($1);
4576: }
4577: }
1.329 droeschl 4578: }
1.484.2.67 raeburn 4579: } elsif ($env{'form.setversions'}) {
4580: $haschanged=1;
4581: foreach my $key (keys(%env)) {
4582: if ($key=~/^form\.set_version_(.+)$/) {
4583: my $src=$1;
4584: if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
4585: $newsetversions{$src}=$env{$key};
4586: &devalidateversioncache($src);
4587: }
4588: }
1.329 droeschl 4589: }
1.484.2.67 raeburn 4590: }
4591: if ($haschanged) {
4592: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
4593: $env{'course.'.$env{'request.course.id'}.'.domain'},
4594: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
4595: $r->print(&Apache::loncommon::confirmwrapper(
4596: &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
4597: } else {
4598: $r->print(&Apache::loncommon::confirmwrapper(
4599: &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
4600: }
4601: &mark_hash_old();
4602: }
4603: &changewarning($r,'');
1.329 droeschl 4604: }
4605: if ($env{'form.timerange'} eq 'all') {
4606: # show all documents
1.484.2.34 raeburn 4607: $header=&mt('All content in '.$crstype);
1.484.2.19 raeburn 4608: $allsel=' selected="selected"';
1.329 droeschl 4609: foreach my $key (keys(%hash)) {
4610: if ($key=~/^ids\_(\/res\/.+)$/) {
4611: my $src=$1;
4612: $changes{$src}=1;
4613: }
4614: }
4615: } else {
4616: # show documents which changed
4617: %changes=&Apache::lonnet::dump
4618: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
4619: $env{'course.'.$env{'request.course.id'}.'.num'});
4620: my $firstkey=(keys(%changes))[0];
4621: unless ($firstkey=~/^error\:/) {
4622: unless ($env{'form.timerange'}) {
4623: $env{'form.timerange'}=604800;
4624: }
4625: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
4626: .&mt('seconds');
4627: if ($env{'form.timerange'}==-1) {
4628: $seltext='since start of course';
1.484.2.19 raeburn 4629: $startsel=' selected="selected"';
1.329 droeschl 4630: $env{'form.timerange'}=time;
4631: }
4632: $starttime=time-$env{'form.timerange'};
4633: if ($env{'form.timerange'}==2592000) {
4634: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 4635: $monthsel=' selected="selected"';
1.329 droeschl 4636: } elsif ($env{'form.timerange'}==604800) {
4637: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 4638: $weeksel=' selected="selected"';
1.329 droeschl 4639: } elsif ($env{'form.timerange'}==86400) {
4640: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 4641: $daysel=' selected="selected"';
1.329 droeschl 4642: }
4643: $header=&mt('Content changed').' '.$seltext;
4644: } else {
4645: $header=&mt('No content modifications yet.');
4646: }
4647: }
4648: %setversions=&Apache::lonnet::dump('resourceversions',
4649: $env{'course.'.$env{'request.course.id'}.'.domain'},
4650: $env{'course.'.$env{'request.course.id'}.'.num'});
4651: my %lt=&Apache::lonlocal::texthash
1.408 raeburn 4652: ('st' => 'Version changes since start of '.$crstype,
1.329 droeschl 4653: 'lm' => 'Version changes since last Month',
4654: 'lw' => 'Version changes since last Week',
4655: 'sy' => 'Version changes since Yesterday',
4656: 'al' => 'All Resources (possibly large output)',
1.484 raeburn 4657: 'cd' => 'Change display',
1.329 droeschl 4658: 'sd' => 'Display',
4659: 'fi' => 'File',
4660: 'md' => 'Modification Date',
4661: 'mr' => 'Most recently published Version',
1.408 raeburn 4662: 've' => 'Version used in '.$crstype,
4663: 'vu' => 'Set Version to be used in '.$crstype,
4664: 'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
1.329 droeschl 4665: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
4666: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.479 golterma 4667: 'di' => 'Differences',
1.484 raeburn 4668: 'save' => 'Save changes',
4669: 'vers' => 'Version choice(s) for specific resources',
1.479 golterma 4670: 'act' => 'Actions');
1.484.2.67 raeburn 4671: my ($disabled,$readonly);
4672: unless ($canedit) {
4673: $disabled = 'disabled="disabled"';
4674: $readonly = 1;
4675: }
1.329 droeschl 4676: $r->print(<<ENDHEADERS);
1.484 raeburn 4677: <h4 class="LC_info">$header</h4>
1.329 droeschl 4678: <form action="/adm/coursedocs" method="post">
4679: <input type="hidden" name="versions" value="1" />
1.484 raeburn 4680: <div class="LC_left_float">
1.479 golterma 4681: <fieldset>
1.484 raeburn 4682: <legend>$lt{'cd'}</legend>
1.329 droeschl 4683: <select name="timerange">
1.484.2.19 raeburn 4684: <option value='all'$allsel>$lt{'al'}</option>
4685: <option value="-1"$startsel>$lt{'st'}</option>
4686: <option value="2592000"$monthsel>$lt{'lm'}</option>
4687: <option value="604800"$weeksel>$lt{'lw'}</option>
4688: <option value="86400"$daysel>$lt{'sy'}</option>
1.329 droeschl 4689: </select>
4690: <input type="submit" name="display" value="$lt{'sd'}" />
1.484 raeburn 4691: </fieldset>
4692: </div>
4693: <div class="LC_left_float">
4694: <fieldset>
4695: <legend>$lt{'act'}</legend>
1.484.2.67 raeburn 4696: $lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" $disabled /><br />
4697: $lt{'sc'}: <input type="submit" name="setcurrent" value="Go" $disabled />
1.484 raeburn 4698: </fieldset>
4699: </div>
4700: <br clear="all" />
4701: <hr />
4702: <h4>$lt{'vers'}</h4>
1.329 droeschl 4703: ENDHEADERS
1.479 golterma 4704: #number of columns for version history
1.484.2.44 raeburn 4705: my %changedbytime;
4706: foreach my $key (keys(%changes)) {
4707: #excludes not versionable problems from resource version history:
4708: next if ($key =~ /^\/res\/lib\/templates/);
4709: my $chg;
4710: if ($env{'form.timerange'} eq 'all') {
4711: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
4712: $chg = &Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate');
4713: } else {
4714: $chg = $changes{$key};
4715: next if ($chg < $starttime);
4716: }
4717: push(@{$changedbytime{$chg}},$key);
4718: }
4719: if (keys(%changedbytime) == 0) {
4720: &untiehash();
4721: $r->print(&mt('No content changes in imported content in specified time frame').
4722: &endContentScreen());
4723: return;
4724: }
1.479 golterma 4725: $r->print(
1.484.2.67 raeburn 4726: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.484.2.19 raeburn 4727: &Apache::loncommon::start_data_table().
4728: &Apache::loncommon::start_data_table_header_row().
4729: '<th>'.&mt('Resources').'</th>'.
4730: "<th>$lt{'mr'}</th>".
4731: "<th>$lt{'ve'}</th>".
4732: "<th>$lt{'vu'}</th>".
4733: '<th>'.&mt('History').'</th>'.
4734: &Apache::loncommon::end_data_table_header_row()
4735: );
1.484.2.44 raeburn 4736: foreach my $chg (sort {$b <=> $a } keys(%changedbytime)) {
4737: foreach my $key (sort(@{$changedbytime{$chg}})) {
4738: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
4739: my $currentversion=&Apache::lonnet::getversion($key);
4740: if ($currentversion<0) {
4741: $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
4742: }
4743: my $linkurl=&Apache::lonnet::clutter($key);
4744: $r->print(
4745: &Apache::loncommon::start_data_table_row().
4746: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br />'.
4747: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
4748: '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br />('.
4749: &Apache::lonlocal::locallocaltime($chg).')</span></td>'.
4750: '<td align="right">'
4751: );
4752: # Used in course
4753: my $usedversion=$hash{'version_'.$linkurl};
4754: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.484.2.19 raeburn 4755: if ($usedversion != $currentversion) {
1.479 golterma 4756: $r->print('<span class="LC_warning">'.$usedversion.'</span>');
1.484.2.19 raeburn 4757: } else {
1.479 golterma 4758: $r->print($usedversion);
4759: }
1.329 droeschl 4760: } else {
1.484.2.19 raeburn 4761: $r->print($currentversion);
1.329 droeschl 4762: }
1.484.2.44 raeburn 4763: $r->print('</td><td title="'.$lt{'vu'}.'">');
4764: # Set version
4765: $r->print(&Apache::loncommon::select_form(
4766: $setversions{$linkurl},
4767: 'set_version_'.$linkurl,
4768: {'select_form_order' => ['',1..$currentversion,'mostrecent'],
4769: '' => '',
4770: 'mostrecent' => &mt('most recent'),
1.484.2.67 raeburn 4771: map {$_,$_} (1..$currentversion)},'',$readonly));
1.484.2.44 raeburn 4772: my $lastold=1;
4773: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
4774: my $url=$root.'.'.$prevvers.'.'.$extension;
4775: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) {
4776: $lastold=$prevvers;
4777: }
4778: }
4779: $r->print('</td>');
4780: # List all available versions
4781: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
4782: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
4783: my $url=$root.'.'.$prevvers.'.'.$extension;
1.484.2.19 raeburn 4784: $r->print(
1.484.2.44 raeburn 4785: '<span class="LC_nobreak">'
4786: .'<a href="'.&Apache::lonnet::clutter($url).'">'
4787: .&mt('Version [_1]',$prevvers).'</a>'
4788: .' ('.&Apache::lonlocal::locallocaltime(
4789: &Apache::lonnet::metadata($url,'lastrevisiondate'))
4790: .')');
4791: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
4792: $r->print(
4793: ' <a href="/adm/diff?filename='.
4794: &Apache::lonnet::clutter($root.'.'.$extension).
4795: &HTML::Entities::encode('&versionone='.$prevvers,'"<>&').
4796: '" target="diffs">'.&mt('Diffs').'</a>');
4797: }
4798: $r->print('</span><br />');
1.329 droeschl 4799: }
1.484.2.44 raeburn 4800: $r->print('</span></td>'.&Apache::loncommon::end_data_table_row());
1.484.2.19 raeburn 4801: }
1.329 droeschl 4802: }
1.484.2.19 raeburn 4803: $r->print(
4804: &Apache::loncommon::end_data_table().
1.484.2.67 raeburn 4805: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.484.2.19 raeburn 4806: '</form>'
4807: );
1.329 droeschl 4808:
4809: &untiehash();
1.484.2.19 raeburn 4810: $r->print(&endContentScreen());
1.484.2.44 raeburn 4811: return;
1.329 droeschl 4812: }
4813:
4814: sub mark_hash_old {
4815: my $retie_hash=0;
4816: if ($hashtied) {
4817: $retie_hash=1;
4818: &untiehash();
4819: }
4820: &tiehash('write');
4821: $hash{'old'}=1;
4822: &untiehash();
4823: if ($retie_hash) { &tiehash(); }
4824: }
4825:
4826: sub is_hash_old {
4827: my $untie_hash=0;
4828: if (!$hashtied) {
4829: $untie_hash=1;
4830: &tiehash();
4831: }
4832: my $return=$hash{'old'};
4833: if ($untie_hash) { &untiehash(); }
4834: return $return;
4835: }
4836:
4837: sub changewarning {
4838: my ($r,$postexec,$message,$url)=@_;
4839: if (!&is_hash_old()) { return; }
4840: my $pathvar='folderpath';
4841: my $path=&escape($env{'form.folderpath'});
4842: if (!defined($url)) {
4843: $url='/adm/coursedocs?'.$pathvar.'='.$path;
4844: }
4845: my $course_type = &Apache::loncommon::course_type();
4846: if (!defined($message)) {
4847: $message='Changes will become active for your current session after [_1], or the next time you log in.';
4848: }
4849: $r->print("\n\n".
1.372 bisitz 4850: '<script type="text/javascript">'."\n".
4851: '// <![CDATA['."\n".
4852: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
4853: '// ]]>'."\n".
1.369 bisitz 4854: '</script>'."\n".
1.375 tempelho 4855: '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
1.329 droeschl 4856: '<input type="hidden" name="orgurl" value="'.$url.
1.372 bisitz 4857: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
1.329 droeschl 4858: &mt($message,' <input type="hidden" name="'.
4859: $env{'request.role'}.'" value="1" /><input type="button" value="'.
1.369 bisitz 4860: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1.372 bisitz 4861: $help{'Caching'}.'</p></form>'."\n\n");
1.329 droeschl 4862: }
4863:
4864:
4865: sub init_breadcrumbs {
1.484.2.44 raeburn 4866: my ($form,$text,$help)=@_;
1.329 droeschl 4867: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484 raeburn 4868: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
1.405 bisitz 4869: text=>&Apache::loncommon::course_type().' Editor',
1.329 droeschl 4870: faq=>273,
4871: bug=>'Instructor Interface',
1.484.2.44 raeburn 4872: help => $help});
1.329 droeschl 4873: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
4874: text=>$text,
4875: faq=>273,
4876: bug=>'Instructor Interface'});
4877: }
4878:
1.441 www 4879: # subroutine to list form elements
4880: sub create_list_elements {
4881: my @formarr = @_;
4882: my $list = '';
1.484.2.12 raeburn 4883: foreach my $button (@formarr){
4884: foreach my $picture (keys(%{$button})) {
4885: $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
1.441 www 4886: }
4887: }
4888: return $list;
4889: }
1.329 droeschl 4890:
1.441 www 4891: # subroutine to create ul from list elements
4892: sub create_form_ul {
4893: my $list = shift;
4894: my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
4895: return $ul;
4896: }
1.329 droeschl 4897:
1.442 www 4898: #
4899: # Start tabs
4900: #
4901:
4902: sub startContentScreen {
1.484 raeburn 4903: my ($mode) = @_;
4904: my $output = '<ul class="LC_TabContentBigger" id="mainnav">';
1.472 raeburn 4905: if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
1.484 raeburn 4906: $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n";
4907: $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n";
4908: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
4909: } else {
1.484.2.34 raeburn 4910: $output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Main Content Editor').' </b></a></li>'."\n";
1.484 raeburn 4911: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
4912: $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>'."\n";
4913: '><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>';
4914: }
4915: $output .= "\n".'</ul>'."\n";
4916: $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
4917: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
4918: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
4919: return $output;
1.442 www 4920: }
4921:
4922: #
4923: # End tabs
4924: #
4925:
4926: sub endContentScreen {
1.484 raeburn 4927: return '</div></div></div>';
1.442 www 4928: }
1.329 droeschl 4929:
1.446 www 4930: sub supplemental_base {
1.484.2.33 raeburn 4931: return 'supplemental&'.&escape(&mt('Supplemental Content'));
1.446 www 4932: }
4933:
1.329 droeschl 4934: sub handler {
4935: my $r = shift;
4936: &Apache::loncommon::content_type($r,'text/html');
4937: $r->send_http_header;
4938: return OK if $r->header_only;
1.484 raeburn 4939:
4940: # get course data
1.408 raeburn 4941: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 4942: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
4943: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
4944:
4945: # graphics settings
4946: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329 droeschl 4947:
1.443 www 4948: #
1.329 droeschl 4949: # --------------------------------------------- Initialize help topics for this
4950: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
1.484.2.72.2. (raeburn 4951:): 'Adding_External_Resource','Adding_External_Tool',
4952:): 'Navigate_Content','Adding_Folders','Docs_Overview',
4953:): 'Load_Map','Supplemental','Score_Upload_Form',
4954:): 'Adding_Pages','Importing_LON-CAPA_Resource',
4955:): 'Importing_IMS_Course','Uploading_From_Harddrive',
4956:): 'Course_Roster','Web_Page','Dropbox','Simple_Problem') {
1.329 droeschl 4957: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
4958: }
4959: # Composite help files
4960: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
4961: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
4962: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
4963: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
4964: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
4965: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 4966: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 4967: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 4968: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 4969: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1.484.2.30 raeburn 4970:
1.484.2.67 raeburn 4971: my ($allowed,$canedit,$canview,$disabled);
1.472 raeburn 4972: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
4973: unless ($r->uri eq '/adm/supplemental') {
4974: # does this user have privileges to modify content.
1.484.2.67 raeburn 4975: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
4976: $allowed = 1;
4977: $canedit = 1;
4978: $canview = 1;
4979: } elsif (&Apache::lonnet::allowed('cev',$env{'request.course.id'})) {
4980: $allowed = 1;
4981: $canview = 1;
4982: }
4983: }
4984: unless ($canedit) {
4985: $disabled = ' disabled="disabled"';
1.472 raeburn 4986: }
1.484.2.53 raeburn 4987: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']);
4988: if ($allowed && $env{'form.verify'}) {
1.484.2.44 raeburn 4989: &init_breadcrumbs('verify','Verify Content','Docs_Verify_Content');
1.329 droeschl 4990: &verifycontent($r);
4991: } elsif ($allowed && $env{'form.listsymbs'}) {
1.484 raeburn 4992: &init_breadcrumbs('listsymbs','List Content IDs');
1.329 droeschl 4993: &list_symbs($r);
4994: } elsif ($allowed && $env{'form.docslog'}) {
4995: &init_breadcrumbs('docslog','Show Log');
1.484 raeburn 4996: my $folder = $env{'form.folder'};
4997: if ($folder eq '') {
4998: $folder='default';
4999: }
1.484.2.67 raeburn 5000: &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit);
1.329 droeschl 5001: } elsif ($allowed && $env{'form.versions'}) {
1.484.2.44 raeburn 5002: &init_breadcrumbs('versions','Check/Set Resource Versions','Docs_Check_Resource_Versions');
1.484.2.67 raeburn 5003: &checkversions($r,$canedit);
5004: } elsif ($canedit && $env{'form.dumpcourse'}) {
1.484.2.43 raeburn 5005: &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329 droeschl 5006: &dumpcourse($r);
5007: } elsif ($allowed && $env{'form.exportcourse'}) {
1.377 bisitz 5008: &init_breadcrumbs('exportcourse','IMS Export');
1.475 raeburn 5009: &Apache::imsexport::exportcourse($r);
1.329 droeschl 5010: } else {
1.445 www 5011: #
5012: # Done catching special calls
1.484 raeburn 5013: # The whole rest is for course and supplemental documents and utilities menu
1.445 www 5014: # Get the parameters that may be needed
5015: #
5016: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.484.2.19 raeburn 5017: ['folderpath',
5018: 'forcesupplement','forcestandard',
5019: 'tools','symb','command','supppath']);
1.445 www 5020:
5021: # standard=1: this is a "new-style" course with an uploaded map as top level
5022: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329 droeschl 5023:
5024: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445 www 5025:
1.484 raeburn 5026: # Decide whether this should display supplemental or main content or utilities
1.445 www 5027: # supplementalflag=1: show supplemental documents
5028: # supplementalflag=0: show standard documents
1.484 raeburn 5029: # toolsflag=1: show utilities
1.445 www 5030:
1.484.2.39 raeburn 5031: my $unesc_folderpath = &unescape($env{'form.folderpath'});
5032: my $supplementalflag=($unesc_folderpath=~/^supplemental/);
5033: if (($unesc_folderpath=~/^default/) || ($unesc_folderpath eq "")) {
1.445 www 5034: $supplementalflag=0;
5035: }
5036: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
5037: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
5038: unless ($allowed) { $supplementalflag=1; }
5039: unless ($standard) { $supplementalflag=1; }
1.484 raeburn 5040: my $toolsflag=0;
5041: if ($env{'form.tools'}) { $toolsflag=1; }
1.445 www 5042:
1.329 droeschl 5043: my $script='';
5044: my $showdoc=0;
1.457 raeburn 5045: my $addentries = {};
1.475 raeburn 5046: my $container;
1.329 droeschl 5047: my $containertag;
1.484.2.17 raeburn 5048: my $pathitem;
1.484.2.72.2. (raeburn 5049:): my %ltitools;
1.484.2.67 raeburn 5050: my $hiddentop;
5051: my $navmap;
5052: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.329 droeschl 5053:
1.464 www 5054: # Do we directly jump somewhere?
1.484.2.21 raeburn 5055: if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
1.472 raeburn 5056: if ($env{'form.symb'} ne '') {
1.484.2.19 raeburn 5057: $env{'form.folderpath'}=
1.484.2.67 raeburn 5058: &Apache::loncommon::symb_to_docspath($env{'form.symb'},\$navmap);
1.484.2.21 raeburn 5059: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
5060: $env{'form.command'}.'_'.$env{'form.symb'}});
1.472 raeburn 5061: } elsif ($env{'form.supppath'} ne '') {
5062: $env{'form.folderpath'}=$env{'form.supppath'};
1.484.2.21 raeburn 5063: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
5064: $env{'form.command'}.'_'.$env{'form.supppath'}});
1.466 www 5065: }
1.472 raeburn 5066: } elsif ($env{'form.command'} eq 'editdocs') {
1.484.2.67 raeburn 5067: $env{'form.folderpath'} = &default_folderpath($coursenum,$coursedom,\$navmap);
1.484.2.21 raeburn 5068: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
1.472 raeburn 5069: } elsif ($env{'form.command'} eq 'editsupp') {
1.484.2.67 raeburn 5070: $env{'form.folderpath'} = &supplemental_base();
1.484.2.21 raeburn 5071: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
5072: } elsif ($env{'form.command'} eq 'contents') {
5073: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
5074: } elsif ($env{'form.command'} eq 'home') {
5075: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
1.464 www 5076: }
5077:
1.484.2.23 raeburn 5078:
1.445 www 5079: # Where do we store these for when we come back?
5080: my $stored_folderpath='docs_folderpath';
5081: if ($supplementalflag) {
5082: $stored_folderpath='docs_sup_folderpath';
5083: }
1.464 www 5084:
1.484.2.19 raeburn 5085: # No folderpath, and in edit mode, see if we have something stored
5086: if ((!$env{'form.folderpath'}) && $allowed) {
1.445 www 5087: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.484.2.19 raeburn 5088: {'folderpath' => 'scalar'});
1.484.2.67 raeburn 5089:
5090: if (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
5091: if ($supplementalflag) {
5092: undef($env{'form.folderpath'}) if ($1 eq 'default');
5093: } else {
5094: undef($env{'form.folderpath'}) if ($1 eq 'supplemental');
5095: }
5096: } else {
1.484.2.19 raeburn 5097: undef($env{'form.folderpath'});
5098: }
1.329 droeschl 5099: }
1.446 www 5100:
5101: # If we are not allowed to make changes, all we can see are supplemental docs
1.409 raeburn 5102: if (!$allowed) {
1.446 www 5103: unless ($env{'form.folderpath'} =~ /^supplemental/) {
5104: $env{'form.folderpath'} = &supplemental_base();
1.409 raeburn 5105: }
5106: }
1.446 www 5107: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329 droeschl 5108: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446 www 5109: $env{'form.folderpath'} = &supplemental_base()
5110: .'&'.
1.329 droeschl 5111: $env{'form.folderpath'};
5112: }
1.484.2.67 raeburn 5113: # If allowed and user's role is not advanced check folderpath is not hidden
5114: if (($allowed) && (!$env{'request.role.adv'}) &&
5115: ($env{'form.folderpath'} ne '') && (!$supplementalflag)) {
5116: my $folderurl;
5117: my @pathitems = split(/\&/,$env{'form.folderpath'});
5118: my $folder = $pathitems[-2];
5119: if ($folder eq '') {
5120: undef($env{'form.folderpath'});
5121: } else {
5122: $folderurl = "uploaded/$coursedom/$coursenum/$folder";
5123: if ((split(/\:/,$pathitems[-1]))[4]) {
5124: $folderurl .= '.page';
5125: } else {
5126: $folderurl .= '.sequence';
5127: }
5128: unless (ref($navmap)) {
5129: $navmap = Apache::lonnavmaps::navmap->new();
5130: }
5131: if (ref($navmap)) {
5132: if (lc($navmap->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
5133: my @resources = $navmap->retrieveResources($folderurl,$filterFunc,1,1);
5134: unless (@resources) {
5135: undef($env{'form.folderpath'});
5136: }
5137: }
5138: }
5139: }
5140: }
5141:
5142:
1.446 www 5143: # If after all of this, we still don't have any paths, make them
1.484.2.19 raeburn 5144: unless ($env{'form.folderpath'}) {
1.446 www 5145: if ($supplementalflag) {
5146: $env{'form.folderpath'}=&supplemental_base();
1.484.2.67 raeburn 5147: } elsif ($allowed) {
5148: ($env{'form.folderpath'},$hiddentop) = &default_folderpath($coursenum,$coursedom,\$navmap);
1.446 www 5149: }
1.472 raeburn 5150: }
1.446 www 5151:
1.445 www 5152: # Store this
1.484 raeburn 5153: unless ($toolsflag) {
1.484.2.67 raeburn 5154: if (($allowed) && ($env{'form.folderpath'} ne '')) {
1.484.2.19 raeburn 5155: &Apache::loncommon::store_course_settings($stored_folderpath,
5156: {'folderpath' => 'scalar'});
5157: }
5158: my $folderpath;
1.484 raeburn 5159: if ($env{'form.folderpath'}) {
1.484.2.19 raeburn 5160: $folderpath = $env{'form.folderpath'};
5161: my (@folders)=split('&',$env{'form.folderpath'});
5162: $env{'form.foldername'}=&unescape(pop(@folders));
5163: if ($env{'form.foldername'} =~ /\:1$/) {
5164: $container = 'page';
5165: } else {
5166: $container = 'sequence';
5167: }
5168: $env{'form.folder'}=pop(@folders);
1.484 raeburn 5169: } else {
1.484.2.19 raeburn 5170: if ($env{'form.folder'} eq '' ||
5171: $env{'form.folder'} eq 'supplemental') {
1.484.2.67 raeburn 5172: if ($env{'form.folder'} eq 'supplemental') {
5173: $folderpath=&supplemental_base();
5174: } elsif (!$hiddentop) {
5175: $folderpath='default&'.
5176: &escape(&mt('Main Content').':::::');
5177: }
1.484 raeburn 5178: }
5179: }
1.484.2.19 raeburn 5180: $containertag = '<input type="hidden" name="folderpath" value="" />';
5181: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 5182: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
5183: $showdoc='/'.$1;
5184: }
5185: if ($showdoc) { # got called in sequence from course
5186: $allowed=0;
5187: } else {
1.484.2.67 raeburn 5188: if ($canedit) {
1.484 raeburn 5189: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
5190: $script=&Apache::lonratedt::editscript('simple');
1.433 raeburn 5191: }
5192: }
1.329 droeschl 5193: }
5194:
1.344 bisitz 5195: # get personal data
1.329 droeschl 5196: my $uname=$env{'user.name'};
5197: my $udom=$env{'user.domain'};
5198: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
5199:
5200: if ($allowed) {
1.484 raeburn 5201: if ($toolsflag) {
5202: $script .= &inject_data_js();
5203: my ($home,$other,%outhash)=&authorhosts();
5204: if (!$home && $other) {
5205: my @hosts;
5206: foreach my $aurole (keys(%outhash)) {
5207: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
5208: push(@hosts,$outhash{$aurole});
5209: }
5210: }
5211: $script .= &dump_switchserver_js(@hosts);
5212: }
1.458 raeburn 5213: } else {
1.484.2.43 raeburn 5214: my $tid = 1;
1.484 raeburn 5215: my @tabids;
5216: if ($supplementalflag) {
5217: @tabids = ('002','ee2','ff2');
1.484.2.43 raeburn 5218: $tid = 2;
1.484 raeburn 5219: } else {
5220: @tabids = ('aa1','bb1','cc1','ff1');
1.484.2.19 raeburn 5221: unless ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 5222: unshift(@tabids,'001');
5223: push(@tabids,('dd1','ee1'));
5224: }
1.458 raeburn 5225: }
1.484 raeburn 5226: my $tabidstr = join("','",@tabids);
1.484.2.72.2. (raeburn 5227:): %ltitools = &Apache::lonnet::get_domain_ltitools($coursedom);
5228:): my $posslti = keys(%ltitools);
5229:): $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
1.484.2.67 raeburn 5230: $canedit,\$navmap).
1.484 raeburn 5231: &history_tab_js().
5232: &inject_data_js().
1.484.2.43 raeburn 5233: &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
1.484.2.72.2. (raeburn 5234:): &Apache::lonextresedit::extedit_javascript(\%ltitools);
1.484 raeburn 5235: $addentries = {
1.484.2.3 raeburn 5236: onload => "javascript:resize_scrollbox('contentscroll','1','1');",
1.484 raeburn 5237: };
1.458 raeburn 5238: }
1.484.2.30 raeburn 5239: $script .= &paste_popup_js();
1.484.2.12 raeburn 5240: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
5241: &mt('Switch server?');
1.484.2.19 raeburn 5242:
5243:
1.329 droeschl 5244: }
5245: # -------------------------------------------------------------------- Body tag
1.369 bisitz 5246: $script = '<script type="text/javascript">'."\n"
1.372 bisitz 5247: .'// <![CDATA['."\n"
5248: .$script."\n"
5249: .'// ]]>'."\n"
5250: .'</script>'."\n";
1.385 bisitz 5251:
5252: # Breadcrumbs
5253: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484.2.19 raeburn 5254:
5255: if ($showdoc) {
5256: $r->print(&Apache::loncommon::start_page("$crstype documents",undef,
5257: {'force_register' => $showdoc,}));
1.484.2.44 raeburn 5258: } elsif ($toolsflag) {
1.484.2.67 raeburn 5259: my ($breadtext,$breadtitle);
5260: $breadtext = "$crstype Editor";
5261: if ($canedit) {
5262: $breadtitle = 'Editing '.$crstype.' Contents';
5263: } else {
5264: $breadtext .= ' (View-only mode)';
5265: $breadtitle = 'Viewing '.$crstype.' Contents';
5266: }
1.484.2.44 raeburn 5267: &Apache::lonhtmlcommon::add_breadcrumb({
1.484.2.67 raeburn 5268: href=>"/adm/coursedocs",text=>$breadtext});
1.484.2.44 raeburn 5269: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script)
5270: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5271: .&Apache::lonhtmlcommon::breadcrumbs(
1.484.2.67 raeburn 5272: $breadtitle)
1.484.2.44 raeburn 5273: );
1.484.2.19 raeburn 5274: } elsif ($r->uri eq '/adm/supplemental') {
5275: my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
5276: $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
5277: {'bread_crumbs' => $brcrum,}));
5278: } else {
1.484.2.67 raeburn 5279: my ($breadtext,$breadtitle,$helpitem);
5280: $breadtext = "$crstype Editor";
5281: if ($canedit) {
5282: $breadtitle = 'Editing '.$crstype.' Contents';
5283: $helpitem = 'Docs_Adding_Course_Doc';
5284: } else {
5285: $breadtext .= ' (View-only mode)';
5286: $breadtitle = 'Viewing '.$crstype.' Contents';
5287: $helpitem = 'Docs_Viewing_Course_Doc';
5288: }
1.392 raeburn 5289: &Apache::lonhtmlcommon::add_breadcrumb({
1.484.2.67 raeburn 5290: href=>"/adm/coursedocs",text=>$breadtext});
1.446 www 5291: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.484.2.19 raeburn 5292: {'add_entries' => $addentries}
5293: )
1.392 raeburn 5294: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5295: .&Apache::lonhtmlcommon::breadcrumbs(
1.484.2.67 raeburn 5296: $breadtitle,
5297: $helpitem)
1.392 raeburn 5298: );
5299: }
1.364 bisitz 5300:
1.329 droeschl 5301: my %allfiles = ();
5302: my %codebase = ();
1.440 raeburn 5303: my ($upload_result,$upload_output,$uploadphase);
1.484.2.67 raeburn 5304: if ($canedit) {
1.329 droeschl 5305: if (($env{'form.uploaddoc.filename'}) &&
5306: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440 raeburn 5307: my $context = $1;
5308: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 5309: undef($hadchanges);
1.440 raeburn 5310: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
1.484.2.36 raeburn 5311: \%allfiles,\%codebase,$context,$crstype);
1.484.2.72.2. (raeburn 5312:): undef($navmap);
1.329 droeschl 5313: if ($hadchanges) {
5314: &mark_hash_old();
5315: }
1.440 raeburn 5316: $r->print($upload_output);
5317: } elsif ($env{'form.phase'} eq 'upload_embedded') {
5318: # Process file upload - phase two - upload embedded objects
5319: $uploadphase = 'check_embedded';
5320: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
5321: my $state = &embedded_form_elems($uploadphase,$primaryurl,
5322: $env{'form.newidx'});
5323: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5324: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5325: my ($destination,$dir_root) = &embedded_destination();
5326: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
5327: my $actionurl = '/adm/coursedocs';
5328: my ($result,$flag) =
5329: &Apache::loncommon::upload_embedded('coursedoc',$destination,
5330: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
5331: $actionurl);
5332: $r->print($result.&return_to_editor());
5333: } elsif ($env{'form.phase'} eq 'check_embedded') {
5334: # Process file upload - phase three - modify references in HTML file
5335: $uploadphase = 'modified_orightml';
5336: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5337: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5338: my ($destination,$dir_root) = &embedded_destination();
1.482 raeburn 5339: my $result =
5340: &Apache::loncommon::modify_html_refs('coursedoc',$destination,
5341: $docuname,$docudom,undef,
5342: $dir_root);
5343: $r->print($result.&return_to_editor());
1.476 raeburn 5344: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
5345: $uploadphase = 'decompress_phase_one';
5346: $r->print(&decompression_phase_one().
5347: &return_to_editor());
5348: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
5349: $uploadphase = 'decompress_phase_two';
5350: $r->print(&decompression_phase_two().
5351: &return_to_editor());
1.329 droeschl 5352: }
5353: }
5354:
1.484 raeburn 5355: if ($allowed && $toolsflag) {
5356: $r->print(&startContentScreen('tools'));
1.484.2.67 raeburn 5357: $r->print(&generate_admin_menu($crstype,$canedit));
1.484 raeburn 5358: $r->print(&endContentScreen());
5359: } elsif ((!$showdoc) && (!$uploadphase)) {
1.329 droeschl 5360: # -----------------------------------------------------------------------------
5361: my %lt=&Apache::lonlocal::texthash(
5362: 'copm' => 'All documents out of a published map into this folder',
1.484.2.12 raeburn 5363: 'upfi' => 'Upload File',
1.484.2.36 raeburn 5364: 'upld' => 'Upload Content',
1.329 droeschl 5365: 'srch' => 'Search',
5366: 'impo' => 'Import',
1.484.2.19 raeburn 5367: 'lnks' => 'Import from Stored Links',
1.484.2.13 raeburn 5368: 'impm' => 'Import from Assembled Map',
1.484.2.72.2. (raeburn 5369:): 'extr' => 'External Resource',
5370:): 'extt' => 'External Tool',
1.329 droeschl 5371: 'selm' => 'Select Map',
5372: 'load' => 'Load Map',
5373: 'newf' => 'New Folder',
5374: 'newp' => 'New Composite Page',
5375: 'syll' => 'Syllabus',
1.425 raeburn 5376: 'navc' => 'Table of Contents',
1.343 biermanm 5377: 'sipa' => 'Simple Course Page',
1.329 droeschl 5378: 'sipr' => 'Simple Problem',
1.484.2.27 raeburn 5379: 'webp' => 'Blank Web Page (editable)',
1.329 droeschl 5380: 'drbx' => 'Drop Box',
1.451 www 5381: 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336 schafran 5382: 'bull' => 'Discussion Board',
1.347 weissno 5383: 'mypi' => 'My Personal Information Page',
1.353 weissno 5384: 'grpo' => 'Group Portfolio',
1.329 droeschl 5385: 'rost' => 'Course Roster',
1.484.2.22 raeburn 5386: 'abou' => 'Personal Information Page for a User',
1.484.2.36 raeburn 5387: 'imsf' => 'IMS Upload',
5388: 'imsl' => 'Upload IMS package',
1.484.2.12 raeburn 5389: 'cms' => 'Origin of IMS package',
5390: 'se' => 'Select',
1.484.2.19 raeburn 5391: 'file' => 'File',
1.329 droeschl 5392: 'title' => 'Title',
5393: 'comment' => 'Comment',
1.403 raeburn 5394: 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.484.2.50 raeburn 5395: 'bb5' => 'Blackboard 5',
5396: 'bb6' => 'Blackboard 6',
5397: 'angel5' => 'ANGEL 5.5',
5398: 'webctce4' => 'WebCT 4 Campus Edition',
1.484.2.67 raeburn 5399: 'er' => 'Editing rights unavailable for your current role.',
1.484.2.50 raeburn 5400: );
1.329 droeschl 5401: # -----------------------------------------------------------------------------
1.484.2.64 raeburn 5402: # Calculate free quota space for a user or course.
5403: my $quotatype = 'unofficial';
5404: if ($crstype eq 'Community') {
5405: $quotatype = 'community';
5406: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
5407: $quotatype = 'official';
5408: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
5409: $quotatype = 'textbook';
5410: }
5411: my $disk_quota = &Apache::loncommon::get_user_quota($coursenum,$coursedom,
5412: 'course',$quotatype); # expressed in MB
5413: my $current_disk_usage = 0;
5414: foreach my $subdir ('docs','supplemental') {
5415: $current_disk_usage += &Apache::lonnet::diskusage($coursedom,$coursenum,
5416: "userfiles/$subdir",1); # expressed in kB
5417: }
5418: my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage);
5419: my $usage = $current_disk_usage/1024; # in MB
5420: my $quota = $disk_quota;
5421: my $percent;
5422: if ($disk_quota == 0) {
5423: $percent = 100.0;
5424: } else {
1.484.2.69 raeburn 5425: $percent = 100*($usage/$disk_quota);
1.484.2.64 raeburn 5426: }
5427: $usage = sprintf("%.2f",$usage);
5428: $quota = sprintf("%.2f",$quota);
5429: $percent = sprintf("%.0f",$percent);
5430: my $quotainfo = '<p>'.&mt('Currently using [_1] of the [_2] available.',
5431: $percent.'%',$quota.' MB').'</p>';
5432:
1.329 droeschl 5433: my $fileupload=(<<FIUP);
1.484.2.64 raeburn 5434: $quotainfo
1.329 droeschl 5435: $lt{'file'}:<br />
1.484.2.67 raeburn 5436: <input type="file" name="uploaddoc" size="40" $disabled />
1.329 droeschl 5437: FIUP
5438:
5439: my $checkbox=(<<CHBO);
5440: <!-- <label>$lt{'parse'}?
5441: <input type="checkbox" name="parserflag" />
5442: </label> -->
5443: <label>
1.484.2.67 raeburn 5444: <input type="checkbox" name="parserflag" checked="checked" $disabled /> $lt{'parse'}
1.329 droeschl 5445: </label>
5446: CHBO
1.484.2.12 raeburn 5447: my $imsfolder = $env{'form.folder'};
5448: if ($imsfolder eq '') {
1.484.2.19 raeburn 5449: $imsfolder = 'default';
1.484.2.12 raeburn 5450: }
5451: my $imspform=(<<IMSFORM);
5452: <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
5453: $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
5454: <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
1.484.2.19 raeburn 5455: <fieldset id="uploadimsform" style="display: none;">
1.484.2.12 raeburn 5456: <legend>$lt{'imsf'}</legend>
5457: $fileupload
5458: <br />
5459: <p>
1.484.2.19 raeburn 5460: $lt{'cms'}:
1.484.2.67 raeburn 5461: <select name="source" $disabled>
1.484.2.12 raeburn 5462: <option value="-1" selected="selected">$lt{'se'}</option>
1.484.2.50 raeburn 5463: <option value="bb5">$lt{'bb5'}</option>
5464: <option value="bb6">$lt{'bb6'}</option>
5465: <option value="angel5">$lt{'angel5'}</option>
5466: <option value="webctce4">$lt{'webctce4'}</option>
1.484.2.12 raeburn 5467: </select>
5468: <input type="hidden" name="folder" value="$imsfolder" />
5469: </p>
5470: <input type="hidden" name="phase" value="one" />
1.484.2.67 raeburn 5471: <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" $disabled />
1.484.2.12 raeburn 5472: </fieldset>
5473: </form>
5474: IMSFORM
5475:
1.484.2.19 raeburn 5476: my $fileuploadform=(<<FUFORM);
1.484.2.12 raeburn 5477: <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
5478: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
5479: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.484.2.19 raeburn 5480: <fieldset id="uploaddocform" style="display: none;">
1.484.2.12 raeburn 5481: <legend>$lt{'upfi'}</legend>
1.371 tempelho 5482: <input type="hidden" name="active" value="aa" />
1.329 droeschl 5483: $fileupload
5484: <br />
5485: $lt{'title'}:<br />
1.484.2.67 raeburn 5486: <input type="text" size="60" name="comment" $disabled />
1.484.2.17 raeburn 5487: $pathitem
1.329 droeschl 5488: <input type="hidden" name="cmd" value="upload_default" />
5489: <br />
1.458 raeburn 5490: <span class="LC_nobreak" style="float:left">
1.329 droeschl 5491: $checkbox
5492: </span>
1.484.2.12 raeburn 5493: <br clear="all" />
1.484.2.67 raeburn 5494: <input type="submit" value="$lt{'upld'}" $disabled />
1.484.2.12 raeburn 5495: </fieldset>
5496: </form>
1.383 tempelho 5497: FUFORM
1.329 droeschl 5498:
1.484.2.67 raeburn 5499: my $mapimportjs;
5500: if ($canedit) {
5501: $mapimportjs = "javascript:openbrowser('mapimportform','importmap','sequence,page','');";
5502: } else {
5503: $mapimportjs = "javascript:alert('".&js_escape($lt{'er'})."');";
5504: }
1.484.2.19 raeburn 5505: my $importpubform=(<<SEDFFORM);
5506: <a class="LC_menubuttons_link" href="javascript:toggleMap('map');">
1.484.2.13 raeburn 5507: $lt{'impm'}</a>$help{'Load_Map'}
1.484.2.19 raeburn 5508: <form action="/adm/coursedocs" method="post" name="mapimportform">
5509: <fieldset id="importmapform" style="display: none;">
1.484.2.13 raeburn 5510: <legend>$lt{'impm'}</legend>
1.484.2.19 raeburn 5511: <input type="hidden" name="active" value="bb" />
1.484.2.13 raeburn 5512: $lt{'copm'}<br />
5513: <span class="LC_nobreak">
1.484.2.19 raeburn 5514: <input type="text" name="importmap" size="40" value=""
1.484.2.67 raeburn 5515: onfocus="this.blur();$mapimportjs" $disabled />
5516: <a href="$mapimportjs">$lt{'selm'}</a></span><br />
5517: <input type="submit" name="loadmap" value="$lt{'load'}" $disabled />
1.484.2.13 raeburn 5518: </fieldset>
5519: </form>
5520:
1.383 tempelho 5521: SEDFFORM
1.484.2.67 raeburn 5522:
5523: my $fromstoredjs;
5524: if ($canedit) {
5525: $fromstoredjs = 'open_StoredLinks_Import()';
5526: } else {
5527: $fromstoredjs = "alert('".&js_escape($lt{'er'})."')";
5528: }
5529:
1.484.2.19 raeburn 5530: my @importpubforma = (
5531: { '<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 5532: { '<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 5533: { '<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 5534: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform }
5535: );
5536: $importpubform = &create_form_ul(&create_list_elements(@importpubforma));
5537: my $extresourcesform =
5538: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
1.484.2.67 raeburn 5539: $help{'Adding_External_Resource'},
5540: undef,undef,$disabled);
1.484.2.72.2. (raeburn 5541:): my $exttoolform =
5542:): &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
5543:): $help{'Adding_External_Tool'},undef,
5544:): undef,'tool',$coursedom,$coursenum,
5545:): \%ltitools,$disabled);
1.329 droeschl 5546: if ($allowed) {
1.484.2.7 raeburn 5547: my $folder = $env{'form.folder'};
5548: if ($folder eq '') {
5549: $folder='default';
5550: }
1.484.2.67 raeburn 5551: if ($canedit) {
5552: my $output = &update_paste_buffer($coursenum,$coursedom,$folder);
5553: if ($output) {
5554: $r->print($output);
5555: }
1.484.2.30 raeburn 5556: }
1.337 ehlerst 5557: $r->print(<<HIDDENFORM);
5558: <form name="renameform" method="post" action="/adm/coursedocs">
5559: <input type="hidden" name="title" />
5560: <input type="hidden" name="cmd" />
5561: <input type="hidden" name="markcopy" />
5562: <input type="hidden" name="copyfolder" />
5563: $containertag
5564: </form>
1.484 raeburn 5565:
1.337 ehlerst 5566: HIDDENFORM
1.484.2.17 raeburn 5567: $r->print(&makesimpleeditform($pathitem)."\n".
5568: &makedocslogform($pathitem."\n".
1.484 raeburn 5569: '<input type="hidden" name="folder" value="'.
5570: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 5571: }
1.442 www 5572:
5573: # Generate the tabs
1.484.2.19 raeburn 5574: my ($mode,$needs_end);
1.472 raeburn 5575: if (($supplementalflag) && (!$allowed)) {
1.484.2.19 raeburn 5576: my @folders = split('&',$env{'form.folderpath'});
5577: unless (@folders > 2) {
5578: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
5579: $needs_end = 1;
5580: }
1.472 raeburn 5581: } else {
1.484 raeburn 5582: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484.2.19 raeburn 5583: $needs_end = 1;
1.472 raeburn 5584: }
1.443 www 5585:
1.442 www 5586: #
5587:
5588: my $savefolderpath;
5589:
1.395 raeburn 5590: if ($allowed) {
1.329 droeschl 5591: my $folder=$env{'form.folder'};
1.484.2.67 raeburn 5592: if ((($folder eq '') && (!$hiddentop)) || ($supplementalflag)) {
1.329 droeschl 5593: $folder='default';
1.356 tempelho 5594: $savefolderpath = $env{'form.folderpath'};
1.484.2.33 raeburn 5595: $env{'form.folderpath'}='default&'.&escape(&mt('Main Content'));
1.484.2.17 raeburn 5596: $pathitem = '<input type="hidden" name="folderpath" value="'.
1.329 droeschl 5597: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
5598: }
5599: my $postexec='';
5600: if ($folder eq 'default') {
1.372 bisitz 5601: $r->print('<script type="text/javascript">'."\n"
5602: .'// <![CDATA['."\n"
5603: .'this.window.name="loncapaclient";'."\n"
5604: .'// ]]>'."\n"
5605: .'</script>'."\n"
1.369 bisitz 5606: );
1.329 droeschl 5607: } else {
5608: #$postexec='self.close();';
5609: }
1.484.2.15 raeburn 5610: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
5611: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
1.329 droeschl 5612: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
5613:
5614: my $newnavform=(<<NNFORM);
5615: <form action="/adm/coursedocs" method="post" name="newnav">
1.484.2.43 raeburn 5616: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 5617: $pathitem
1.329 droeschl 5618: <input type="hidden" name="importdetail"
5619: value="$lt{'navc'}=/adm/navmaps" />
1.484.2.67 raeburn 5620: <a class="LC_menubuttons_link" href="javascript:makenew(document.newnav);">$lt{'navc'}</a>
1.329 droeschl 5621: $help{'Navigate_Content'}
5622: </form>
5623: NNFORM
5624: my $newsmppageform=(<<NSPFORM);
5625: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.484.2.43 raeburn 5626: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 5627: $pathitem
1.329 droeschl 5628: <input type="hidden" name="importdetail" value="" />
1.423 onken 5629: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 5630: $help{'Simple Page'}
1.329 droeschl 5631: </form>
5632: NSPFORM
5633:
5634: my $newsmpproblemform=(<<NSPROBFORM);
5635: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371 tempelho 5636: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 5637: $pathitem
1.329 droeschl 5638: <input type="hidden" name="importdetail" value="" />
1.423 onken 5639: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.484.2.44 raeburn 5640: $help{'Simple_Problem'}
1.329 droeschl 5641: </form>
5642:
5643: NSPROBFORM
5644:
5645: my $newdropboxform=(<<NDBFORM);
5646: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.371 tempelho 5647: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 5648: $pathitem
1.329 droeschl 5649: <input type="hidden" name="importdetail" value="" />
1.423 onken 5650: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.484.2.36 raeburn 5651: $help{'Dropbox'}
1.344 bisitz 5652: </form>
1.329 droeschl 5653: NDBFORM
5654:
5655: my $newexuploadform=(<<NEXUFORM);
5656: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.371 tempelho 5657: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 5658: $pathitem
1.329 droeschl 5659: <input type="hidden" name="importdetail" value="" />
1.423 onken 5660: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 5661: $help{'Score_Upload_Form'}
5662: </form>
5663: NEXUFORM
5664:
5665: my $newbulform=(<<NBFORM);
5666: <form action="/adm/coursedocs" method="post" name="newbul">
1.484.2.43 raeburn 5667: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5668: $pathitem
1.329 droeschl 5669: <input type="hidden" name="importdetail" value="" />
1.423 onken 5670: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 5671: $help{'Bulletin Board'}
5672: </form>
5673: NBFORM
5674:
5675: my $newaboutmeform=(<<NAMFORM);
5676: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.484.2.43 raeburn 5677: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5678: $pathitem
1.329 droeschl 5679: <input type="hidden" name="importdetail"
5680: value="$plainname=/adm/$udom/$uname/aboutme" />
1.484.2.67 raeburn 5681: <a class="LC_menubuttons_link" href="javascript:makenew(document.newaboutme);">$lt{'mypi'}</a>
1.347 weissno 5682: $help{'My Personal Information Page'}
1.329 droeschl 5683: </form>
5684: NAMFORM
5685:
5686: my $newaboutsomeoneform=(<<NASOFORM);
5687: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.484.2.43 raeburn 5688: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5689: $pathitem
1.329 droeschl 5690: <input type="hidden" name="importdetail" value="" />
1.423 onken 5691: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 5692: </form>
5693: NASOFORM
5694:
5695: my $newrosterform=(<<NROSTFORM);
5696: <form action="/adm/coursedocs" method="post" name="newroster">
1.484.2.43 raeburn 5697: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5698: $pathitem
1.329 droeschl 5699: <input type="hidden" name="importdetail"
5700: value="$lt{'rost'}=/adm/viewclasslist" />
1.484.2.67 raeburn 5701: <a class="LC_menubuttons_link" href="javascript:makenew(document.newroster);">$lt{'rost'}</a>
1.484.2.37 raeburn 5702: $help{'Course_Roster'}
1.329 droeschl 5703: </form>
5704: NROSTFORM
5705:
1.484.2.27 raeburn 5706: my $newwebpage;
5707: if ($folder =~ /^default_?(\d*)$/) {
5708: $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
5709: if ($1) {
5710: $newwebpage .= $1;
5711: } else {
5712: $newwebpage .= 'default';
5713: }
5714: $newwebpage .= '/new.html';
5715: }
5716: my $newwebpageform =(<<NWEBFORM);
5717: <form action="/adm/coursedocs" method="post" name="newwebpage">
1.484.2.43 raeburn 5718: <input type="hidden" name="active" value="ee" />
1.484.2.27 raeburn 5719: $pathitem
5720: <input type="hidden" name="importdetail" value="$newwebpage" />
5721: <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
1.484.2.36 raeburn 5722: $help{'Web_Page'}
1.484.2.27 raeburn 5723: </form>
5724: NWEBFORM
1.484.2.30 raeburn 5725:
1.484.2.27 raeburn 5726:
1.342 ehlerst 5727: my $specialdocumentsform;
1.383 tempelho 5728: my @specialdocumentsforma;
1.451 www 5729: my $gradingform;
5730: my @gradingforma;
5731: my $communityform;
5732: my @communityforma;
1.351 ehlerst 5733: my $newfolderform;
1.390 tempelho 5734: my $newfolderb;
1.342 ehlerst 5735:
1.451 www 5736: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 5737:
1.329 droeschl 5738: my $newpageform=(<<NPFORM);
5739: <form action="/adm/coursedocs" method="post" name="newpage">
5740: <input type="hidden" name="folderpath" value="$path" />
5741: <input type="hidden" name="importdetail" value="" />
1.484.2.43 raeburn 5742: <input type="hidden" name="active" value="ee" />
1.423 onken 5743: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 5744: $help{'Adding_Pages'}
1.329 droeschl 5745: </form>
5746: NPFORM
1.390 tempelho 5747:
5748:
1.351 ehlerst 5749: $newfolderform=(<<NFFORM);
1.329 droeschl 5750: <form action="/adm/coursedocs" method="post" name="newfolder">
1.484.2.19 raeburn 5751: $pathitem
1.329 droeschl 5752: <input type="hidden" name="importdetail" value="" />
1.484.2.43 raeburn 5753: <input type="hidden" name="active" value="" />
1.422 onken 5754: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 5755: </form>
5756: NFFORM
5757:
5758: my $newsylform=(<<NSYLFORM);
5759: <form action="/adm/coursedocs" method="post" name="newsyl">
1.484.2.43 raeburn 5760: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 5761: $pathitem
1.329 droeschl 5762: <input type="hidden" name="importdetail"
5763: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.484.2.67 raeburn 5764: <a class="LC_menubuttons_link" href="javascript:makenew(document.newsyl);">$lt{'syll'}</a>
1.329 droeschl 5765: $help{'Syllabus'}
1.383 tempelho 5766:
1.329 droeschl 5767: </form>
5768: NSYLFORM
1.364 bisitz 5769:
1.329 droeschl 5770: my $newgroupfileform=(<<NGFFORM);
5771: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.484.2.43 raeburn 5772: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5773: $pathitem
1.329 droeschl 5774: <input type="hidden" name="importdetail"
5775: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.484.2.67 raeburn 5776: <a class="LC_menubuttons_link" href="javascript:makenew(document.newgroupfiles);">$lt{'grpo'}</a>
1.353 weissno 5777: $help{'Group Portfolio'}
1.329 droeschl 5778: </form>
5779: NGFFORM
1.383 tempelho 5780: @specialdocumentsforma=(
1.421 onken 5781: {'<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 5782: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.newsyl);" />'=>$newsylform},
5783: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="javascript:makenew(document.newnav);" />'=>$newnavform},
1.451 www 5784: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
1.484.2.27 raeburn 5785: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
1.451 www 5786: );
5787: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
5788:
1.434 raeburn 5789:
5790: my @importdoc = (
1.484.2.19 raeburn 5791: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform}
5792: );
1.484.2.72.2. (raeburn 5793:): if (keys(%ltitools)) {
5794:): push(@importdoc,
5795:): {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="toggleUpload(\'tool\');" />'=>$exttoolform},
5796:): );
5797:): }
1.484.2.19 raeburn 5798: unless ($container eq 'page') {
5799: push(@importdoc,
5800: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform}
5801: );
5802: }
5803: push(@importdoc,
1.484.2.38 raeburn 5804: {'<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 5805: );
1.484.2.12 raeburn 5806: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
1.434 raeburn 5807:
1.451 www 5808: @gradingforma=(
5809: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
5810: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
5811: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
5812:
5813: );
5814: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
5815:
5816: @communityforma=(
5817: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
5818: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
5819: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
1.484.2.67 raeburn 5820: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="javascript:makenew(document.newroster);" />'=>$newrosterform},
5821: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="javascript:makenew(document.newgroupfiles);" />'=>$newgroupfileform},
1.451 www 5822: );
5823: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 5824:
1.330 tempelho 5825: my %orderhash = (
1.484.2.36 raeburn 5826: 'aa' => ['Upload',$fileuploadform],
5827: 'bb' => ['Import',$importpubform],
5828: 'cc' => ['Grading',$gradingform],
1.330 tempelho 5829: );
1.484.2.19 raeburn 5830: unless ($container eq 'page') {
1.434 raeburn 5831: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.484 raeburn 5832: $orderhash{'dd'} = ['Collaboration',$communityform];
1.484.2.36 raeburn 5833: $orderhash{'ee'} = ['Other',$specialdocumentsform];
1.434 raeburn 5834: }
5835:
1.341 ehlerst 5836: $hadchanges=0;
1.484 raeburn 5837: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 5838: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.67 raeburn 5839: $supplementalflag,\%orderhash,$iconpath,$pathitem,
1.484.2.72.2. (raeburn 5840:): \%ltitools,$canedit,\$navmap,$hiddentop);
1.484.2.67 raeburn 5841: undef($navmap);
1.443 www 5842: if ($error) {
5843: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
5844: }
5845: if ($hadchanges) {
1.484.2.72.2. (raeburn 5846:): unless (&is_hash_old()) {
5847:): &mark_hash_old();
5848:): }
1.443 www 5849: }
5850: &changewarning($r,'');
5851: }
1.458 raeburn 5852: }
1.442 www 5853:
1.443 www 5854: # Supplemental documents start here
5855:
1.329 droeschl 5856: my $folder=$env{'form.folder'};
1.443 www 5857: unless ($supplementalflag) {
1.329 droeschl 5858: $folder='supplemental';
5859: }
5860: if ($folder =~ /^supplemental$/ &&
5861: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 5862: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 5863: } elsif ($allowed) {
1.356 tempelho 5864: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 5865: }
1.484.2.17 raeburn 5866: $pathitem = '<input type="hidden" name="folderpath" value="'.
5867: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.329 droeschl 5868: if ($allowed) {
5869: my $folderseq=
1.484.2.15 raeburn 5870: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
1.329 droeschl 5871:
5872: my $supupdocform=(<<SUPDOCFORM);
1.484.2.12 raeburn 5873: <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
5874: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
1.383 tempelho 5875: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.484.2.19 raeburn 5876: <fieldset id="uploadsuppdocform" style="display: none;">
1.484.2.12 raeburn 5877: <legend>$lt{'upfi'}</legend>
1.371 tempelho 5878: <input type="hidden" name="active" value="ee" />
1.329 droeschl 5879: $fileupload
5880: <br />
5881: <br />
5882: <span class="LC_nobreak">
5883: $checkbox
5884: </span>
5885: <br /><br />
5886: $lt{'comment'}:<br />
1.383 tempelho 5887: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 5888: <br />
1.484.2.19 raeburn 5889: $pathitem
1.329 droeschl 5890: <input type="hidden" name="cmd" value="upload_supplemental" />
1.484.2.12 raeburn 5891: <input type='submit' value="$lt{'upld'}" />
5892: </form>
1.484.2.19 raeburn 5893: SUPDOCFORM
1.329 droeschl 5894:
5895: my $supnewfolderform=(<<SNFFORM);
5896: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.484.2.43 raeburn 5897: <input type="hidden" name="active" value="" />
1.484.2.17 raeburn 5898: $pathitem
1.329 droeschl 5899: <input type="hidden" name="importdetail" value="" />
1.423 onken 5900: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 5901: $help{'Adding_Folders'}
1.329 droeschl 5902: </form>
5903: SNFFORM
1.383 tempelho 5904:
1.484.2.19 raeburn 5905: my $supextform =
5906: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
1.484.2.67 raeburn 5907: $help{'Adding_External_Resource'},
5908: undef,undef,$disabled);
1.329 droeschl 5909:
1.484.2.72.2. (raeburn 5910:): my $supexttoolform =
5911:): &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
5912:): $help{'Adding_External_Tool'},
5913:): undef,undef,'tool',$coursedom,
5914:): $coursenum,\%ltitools,$disabled);
1.329 droeschl 5915: my $supnewsylform=(<<SNSFORM);
5916: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 5917: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 5918: $pathitem
1.329 droeschl 5919: <input type="hidden" name="importdetail"
5920: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.484.2.67 raeburn 5921: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewsyl);">$lt{'syll'}</a>
1.329 droeschl 5922: $help{'Syllabus'}
5923: </form>
5924: SNSFORM
5925:
5926: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 5927: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 5928: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 5929: $pathitem
1.329 droeschl 5930: <input type="hidden" name="importdetail"
5931: value="$plainname=/adm/$udom/$uname/aboutme" />
1.484.2.67 raeburn 5932: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewaboutme);">$lt{'mypi'}</a>
1.347 weissno 5933: $help{'My Personal Information Page'}
1.329 droeschl 5934: </form>
5935: SNAMFORM
5936:
1.484.2.27 raeburn 5937: my $supwebpage;
5938: if ($folder =~ /^supplemental_?(\d*)$/) {
5939: $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
5940: if ($1) {
5941: $supwebpage .= $1;
5942: } else {
5943: $supwebpage .= 'default';
5944: }
5945: $supwebpage .= '/new.html';
5946: }
5947: my $supwebpageform =(<<SWEBFORM);
5948: <form action="/adm/coursedocs" method="post" name="supwebpage">
5949: <input type="hidden" name="active" value="cc" />
5950: $pathitem
5951: <input type="hidden" name="importdetail" value="$supwebpage" />
5952: <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
1.484.2.36 raeburn 5953: $help{'Web_Page'}
1.484.2.27 raeburn 5954: </form>
5955: SWEBFORM
5956:
1.333 muellerd 5957:
1.383 tempelho 5958: my @specialdocs = (
1.484.2.67 raeburn 5959: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.supnewsyl);" />'
1.417 droeschl 5960: =>$supnewsylform},
1.484.2.67 raeburn 5961: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makenew(document.supnewaboutme);" />'
1.417 droeschl 5962: =>$supnewaboutmeform},
1.484.2.27 raeburn 5963: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
5964:
1.383 tempelho 5965: );
1.417 droeschl 5966: my @supimportdoc = (
1.484.2.19 raeburn 5967: {'<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 5968:): =>$supextform});
5969:): if (keys(%ltitools)) {
5970:): push(@supimportdoc,
5971:): {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="javascript:toggleUpload(\'supptool\')" />'
5972:): =>$supexttoolform});
5973:): }
5974:): push(@supimportdoc,
1.484.2.12 raeburn 5975: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
5976: =>$supupdocform},
1.484.2.72.2. (raeburn 5977:): );
1.484.2.19 raeburn 5978:
1.484.2.12 raeburn 5979: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
1.333 muellerd 5980: my %suporderhash = (
1.390 tempelho 5981: '00' => ['Supnewfolder', $supnewfolderform],
1.484.2.36 raeburn 5982: 'ee' => ['Upload',$supupdocform],
5983: 'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 5984: );
1.443 www 5985: if ($supplementalflag) {
1.458 raeburn 5986: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.67 raeburn 5987: $supplementalflag,\%suporderhash,$iconpath,$pathitem,
1.484.2.72.2. (raeburn 5988:): \%ltitools,$canedit);
1.443 www 5989: if ($error) {
5990: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.484.2.37 raeburn 5991: } else {
5992: if ($suppchanges) {
5993: my %servers = &Apache::lonnet::internet_dom_servers($coursedom);
5994: my @ids=&Apache::lonnet::current_machine_ids();
5995: foreach my $server (keys(%servers)) {
5996: next if (grep(/^\Q$server\E$/,@ids));
5997: my $hashid=$coursenum.':'.$coursedom;
1.484.2.42 raeburn 5998: my $cachekey = &escape('suppcount').':'.&escape($hashid);
5999: &Apache::lonnet::remote_devalidate_cache($server,[$cachekey]);
1.484.2.37 raeburn 6000: }
6001: &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
6002: undef($suppchanges);
6003: }
1.443 www 6004: }
1.393 raeburn 6005: }
1.443 www 6006: } elsif ($supplementalflag) {
1.458 raeburn 6007: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.17 raeburn 6008: $supplementalflag,'',$iconpath,$pathitem);
1.393 raeburn 6009: if ($error) {
6010: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 6011: }
1.393 raeburn 6012: }
1.389 tempelho 6013:
1.484.2.19 raeburn 6014: if ($needs_end) {
6015: $r->print(&endContentScreen());
6016: }
1.383 tempelho 6017:
1.329 droeschl 6018: if ($allowed) {
6019: $r->print('
6020: <form method="post" name="extimport" action="/adm/coursedocs">
6021: <input type="hidden" name="title" />
6022: <input type="hidden" name="url" />
6023: <input type="hidden" name="useform" />
6024: <input type="hidden" name="residx" />
6025: </form>');
6026: }
1.484 raeburn 6027: } elsif ($showdoc) {
1.329 droeschl 6028: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 6029: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.484.2.10 raeburn 6030: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 6031: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 6032: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 6033: }
6034: }
6035: $r->print(&Apache::loncommon::end_page());
6036: return OK;
1.364 bisitz 6037: }
1.329 droeschl 6038:
1.440 raeburn 6039: sub embedded_form_elems {
6040: my ($phase,$primaryurl,$newidx) = @_;
6041: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
6042: return <<STATE;
6043: <input type="hidden" name="folderpath" value="$folderpath" />
6044: <input type="hidden" name="cmd" value="upload_embedded" />
6045: <input type="hidden" name="newidx" value="$newidx" />
6046: <input type="hidden" name="phase" value="$phase" />
6047: <input type="hidden" name="primaryurl" value="$primaryurl" />
6048: STATE
6049: }
6050:
6051: sub embedded_destination {
6052: my $folder=$env{'form.folder'};
6053: my $destination = 'docs/';
6054: if ($folder =~ /^supplemental/) {
6055: $destination = 'supplemental/';
6056: }
6057: if (($folder eq 'default') || ($folder eq 'supplemental')) {
6058: $destination .= 'default/';
6059: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
6060: $destination .= $2.'/';
6061: }
6062: $destination .= $env{'form.newidx'};
6063: my $dir_root = '/userfiles';
6064: return ($destination,$dir_root);
6065: }
6066:
6067: sub return_to_editor {
6068: my $actionurl = '/adm/coursedocs';
6069: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
6070: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
6071: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
6072: '</a></p>';
6073: }
6074:
1.476 raeburn 6075: sub decompression_info {
6076: my ($destination,$dir_root) = &embedded_destination();
6077: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
6078: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
6079: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
6080: my $container='sequence';
1.480 raeburn 6081: my ($pathitem,$hiddenelem);
1.484.2.54 raeburn 6082: my @hiddens = ('newidx','comment','position','folderpath','archiveurl');
1.484.2.19 raeburn 6083: if ($env{'form.folderpath'} =~ /\:1$/) {
1.476 raeburn 6084: $container='page';
6085: }
1.480 raeburn 6086: unshift(@hiddens,$pathitem);
6087: foreach my $item (@hiddens) {
6088: if ($env{'form.'.$item}) {
6089: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
1.484.2.54 raeburn 6090: &HTML::Entities::encode($env{'form.'.$item},'<>&"').'" />'."\n";
1.480 raeburn 6091: }
1.477 raeburn 6092: }
1.476 raeburn 6093: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
6094: $hiddenelem);
6095: }
6096:
6097: sub decompression_phase_one {
6098: my ($dir,$file,$warning,$error,$output);
6099: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
6100: &decompression_info();
1.484.2.7 raeburn 6101: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 6102: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
6103: } else {
6104: my $file = $1;
1.481 raeburn 6105: $output =
6106: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
6107: $destination,$dir_root,
6108: $hiddenelem);
6109: if ($env{'form.autoextract_camtasia'}) {
6110: $output .= &remove_archive($docudom,$docuname,$container);
6111: }
1.476 raeburn 6112: }
6113: if ($error) {
6114: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
6115: $error.'</p>'."\n";
6116: }
6117: if ($warning) {
6118: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
6119: }
6120: return $output;
6121: }
6122:
6123: sub decompression_phase_two {
6124: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
6125: &decompression_info();
1.481 raeburn 6126: my $output;
1.480 raeburn 6127: if ($env{'form.archivedelete'}) {
1.481 raeburn 6128: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 6129: }
6130: $output .=
1.481 raeburn 6131: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 6132: $destination,$dir_root,$hiddenelem);
6133: return $output;
6134: }
6135:
1.480 raeburn 6136: sub remove_archive {
6137: my ($docudom,$docuname,$container) = @_;
6138: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 6139: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 6140: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
6141: if ($fatal) {
6142: if ($container eq 'page') {
6143: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
6144: } else {
6145: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
6146: }
1.484.2.54 raeburn 6147: $delwarning .= ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 6148: } else {
6149: my $currcmd = $env{'form.cmd'};
6150: my $position = $env{'form.position'};
1.484.2.54 raeburn 6151: my $archiveidx = $position;
6152: if ($position > 0) {
6153: if (($env{'form.autoextract_camtasia'}) && (scalar(@LONCAPA::map::order) == 2)) {
6154: $archiveidx = $position-1;
6155: }
6156: $env{'form.cmd'} = 'remove_'.$archiveidx;
6157: my ($title,$url,@rrest) =
6158: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$archiveidx]]);
6159: if ($url eq $env{'form.archiveurl'}) {
6160: if (&handle_edit_cmd($docuname,$docudom)) {
6161: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
6162: if ($fatal) {
6163: if ($container eq 'page') {
6164: $delwarning = &mt('An error occurred updating the contents of the current page.');
6165: } else {
6166: $delwarning = &mt('An error occurred updating the contents of the current folder.');
6167: }
1.480 raeburn 6168: } else {
1.484.2.54 raeburn 6169: $delresult = &mt('Archive file removed.');
1.480 raeburn 6170: }
6171: }
1.484.2.54 raeburn 6172: } else {
6173: $delwarning .= &mt('Archive file had unexpected item number in folder.').
6174: ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 6175: }
6176: }
6177: $env{'form.cmd'} = $currcmd;
6178: }
6179: if ($delwarning) {
6180: $output = '<p class="LC_warning">'.
6181: $delwarning.
6182: '</p>';
6183: }
6184: if ($delresult) {
6185: $output .= '<p class="LC_info">'.
6186: $delresult.
6187: '</p>';
6188: }
1.481 raeburn 6189: return $output;
1.480 raeburn 6190: }
6191:
1.484 raeburn 6192: sub generate_admin_menu {
1.484.2.67 raeburn 6193: my ($crstype,$canedit) = @_;
1.484 raeburn 6194: my $lc_crstype = lc($crstype);
6195: my ($home,$other,%outhash)=&authorhosts();
1.484.2.43 raeburn 6196: my %lt= ( # do not translate here
1.484 raeburn 6197: 'vc' => 'Verify Content',
6198: 'cv' => 'Check/Set Resource Versions',
6199: 'ls' => 'List Resource Identifiers',
6200: 'imse' => 'Export contents to IMS Archive',
1.484.2.43 raeburn 6201: 'dcd' => "Copy $crstype Content to Authoring Space",
6202: );
1.484 raeburn 6203: my ($candump,$dumpurl);
6204: if ($home + $other > 0) {
6205: $candump = 'F';
6206: if ($home) {
6207: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
6208: } else {
6209: my @hosts;
6210: foreach my $aurole (keys(%outhash)) {
6211: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
6212: push(@hosts,$outhash{$aurole});
1.484.2.30 raeburn 6213: }
1.484 raeburn 6214: }
6215: if (@hosts == 1) {
6216: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
6217: '&role='.
6218: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
6219: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
6220: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
6221: } else {
6222: $dumpurl = "javascript:choose_switchserver_window()";
6223: }
6224: }
6225: }
6226: my @menu=
6227: ({ categorytitle=>'Administration',
6228: items =>[
6229: { linktext => $lt{'vc'},
6230: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
6231: permission => 'F',
1.484.2.44 raeburn 6232: help => 'Docs_Verify_Content',
1.484 raeburn 6233: icon => 'verify.png',
6234: linktitle => 'Verify contents can be retrieved/rendered',
6235: },
6236: { linktext => $lt{'cv'},
6237: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
6238: permission => 'F',
1.484.2.44 raeburn 6239: help => 'Docs_Check_Resource_Versions',
1.484 raeburn 6240: icon => 'resversion.png',
6241: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
6242: },
6243: { linktext => $lt{'ls'},
6244: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
6245: permission => 'F',
6246: #help => '',
6247: icon => 'symbs.png',
6248: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
6249: },
6250: ]
1.484.2.67 raeburn 6251: });
6252: if ($canedit) {
6253: push(@menu,
1.484 raeburn 6254: { categorytitle=>'Export',
6255: items =>[
6256: { linktext => $lt{'imse'},
6257: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
6258: permission => 'F',
6259: help => 'Docs_Export_Course_Docs',
6260: icon => 'imsexport.png',
6261: linktitle => $lt{'imse'},
6262: },
6263: { linktext => $lt{'dcd'},
6264: url => $dumpurl,
6265: permission => $candump,
1.484.2.44 raeburn 6266: help => 'Docs_Dump_Course_Docs',
1.484 raeburn 6267: icon => 'dump.png',
6268: linktitle => $lt{'dcd'},
6269: },
6270: ]
6271: });
1.484.2.67 raeburn 6272: }
1.484 raeburn 6273: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
6274: '<input type="hidden" id="dummy" />'."\n".
6275: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
6276: '</form>';
1.329 droeschl 6277: }
6278:
6279: sub generate_edit_table {
1.484.2.30 raeburn 6280: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile,
1.484.2.67 raeburn 6281: $need_save,$copyfolder,$canedit) = @_;
1.406 raeburn 6282: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 6283: my %orderhash = %{$orderhash_ref};
1.484.2.67 raeburn 6284: my ($form, $activetab, $active, $disabled);
1.484.2.43 raeburn 6285: if (($env{'form.active'} ne '') && ($env{'form.active'} ne '00')) {
1.371 tempelho 6286: $activetab = $env{'form.active'};
6287: }
1.484.2.67 raeburn 6288: unless ($canedit) {
6289: $disabled = ' disabled="disabled"';
6290: }
1.472 raeburn 6291: my $backicon = $iconpath.'clickhere.gif';
1.484.2.21 raeburn 6292: my $backtext = &mt('Exit Editor');
1.458 raeburn 6293: $form = '<div class="LC_Box" style="margin:0;">'.
1.484.2.19 raeburn 6294: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
6295: '<li class="goback">'.
1.484.2.32 raeburn 6296: '<a href="javascript:toContents('."'$jumpto'".');">'.
1.484.2.19 raeburn 6297: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
6298: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
6299: '<li>'.
6300: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
6301: &mt('Undo Delete').'</a></li>'."\n";
1.484.2.7 raeburn 6302: if ($env{'form.docslog'}) {
6303: $form .= '<li class="active">';
6304: } else {
6305: $form .= '<li>';
6306: }
6307: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
6308: &mt('History').'</a></li>'."\n";
6309: if ($env{'form.docslog'}) {
6310: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
6311: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 6312: }
1.458 raeburn 6313: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 6314: if($name ne '00'){
1.371 tempelho 6315: if($activetab eq '' || $activetab ne $name){
6316: $active = '';
6317: }elsif($activetab eq $name){
6318: $active = 'class="active"';
6319: }
1.458 raeburn 6320: $form .= '<li style="float:right" '.$active
1.484 raeburn 6321: .' 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 6322: } else {
1.484.2.43 raeburn 6323: $form .= '<li style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 6324:
6325: }
1.329 droeschl 6326: }
1.484 raeburn 6327: $form .= '</ul>'."\n";
6328: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 6329:
6330: if ($to_show ne '') {
1.484.2.30 raeburn 6331: my $saveform;
6332: if ($need_save) {
6333: my $button = &mt('Make changes');
6334: my $path;
6335: if ($env{'form.folderpath'}) {
6336: $path =
6337: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
6338: }
6339: $saveform = <<"END";
6340: <div id="multisave" style="display:none; clear:both;" >
6341: <form name="saveactions" method="post" action="/adm/coursedocs" onsubmit="return checkSubmits();">
6342: <input type="hidden" name="folderpath" value="$path" />
6343: <input type="hidden" name="symb" value="$env{'form.symb'}" />
6344: <input type="hidden" name="allhiddenresource" value="" />
6345: <input type="hidden" name="allencrypturl" value="" />
6346: <input type="hidden" name="allrandompick" value="" />
6347: <input type="hidden" name="allrandomorder" value="" />
6348: <input type="hidden" name="changeparms" value="" />
6349: <input type="hidden" name="multiremove" value="" />
6350: <input type="hidden" name="multicut" value="" />
6351: <input type="hidden" name="multicopy" value="" />
6352: <input type="hidden" name="multichange" value="" />
6353: <input type="hidden" name="copyfolder" value="$copyfolder" />
1.484.2.67 raeburn 6354: <input type="submit" name="savemultiples" value="$button" $disabled />
1.484.2.30 raeburn 6355: </form>
6356: </div>
6357: END
6358: }
6359: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'.$saveform."\n";
1.458 raeburn 6360: }
1.363 ehlerst 6361: foreach my $field (keys(%orderhash)){
1.390 tempelho 6362: if($field ne '00'){
1.422 onken 6363: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 6364: $active = 'style="display: none;float:left"';
1.422 onken 6365: }elsif($activetab eq $field){
1.458 raeburn 6366: $active = 'style="display:block;float:left"';
1.422 onken 6367: }
6368: $form .= '<div id="'.$field.$tid.'"'
6369: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 6370: .'</div>'."\n";
1.363 ehlerst 6371: }
6372: }
1.484 raeburn 6373: unless ($env{'form.docslog'}) {
6374: $form .= '</div></div>'."\n";
6375: }
1.329 droeschl 6376: return $form;
6377: }
6378:
6379: sub editing_js {
1.484.2.72.2. (raeburn 6380:): my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,$canedit,$navmapref) = @_;
1.484.2.61 raeburn 6381: my %js_lt = &Apache::lonlocal::texthash(
1.329 droeschl 6382: p_mnf => 'Name of New Folder',
6383: t_mnf => 'New Folder',
6384: p_mnp => 'Name of New Page',
6385: t_mnp => 'New Page',
1.451 www 6386: p_mxu => 'Title for the External Score',
1.349 biermanm 6387: p_msp => 'Name of Simple Course Page',
1.329 droeschl 6388: p_msb => 'Title for the Problem',
6389: p_mdb => 'Title for the Drop Box',
1.336 schafran 6390: p_mbb => 'Title for the Discussion Board',
1.484.2.27 raeburn 6391: p_mwp => 'Title for Web Page',
1.348 weissno 6392: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 6393: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 6394: p_mab_alrt1 => 'Not a valid user:domain',
6395: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
6396: p_chn => 'New Title',
6397: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
1.484.2.63 raeburn 6398: p_rmr2a => 'Remove',
6399: p_rmr2b => '?',
6400: p_rmr3a => 'Remove those',
6401: p_rmr3b => 'items?',
6402: p_rmr4 => 'WARNING: Removing a resource uploaded to a course cannot be undone via "Undo Delete".',
6403: p_rmr5 => 'Push "Cancel" and then use "Cut" instead if you might need to undo this change.',
1.329 droeschl 6404: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
6405: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
1.484.2.63 raeburn 6406: p_ctr2a => 'Cut',
6407: p_ctr2b => '?',
6408: p_ctr3a => 'Cut those',
6409: p_ctr3b => 'items?',
1.478 raeburn 6410: rpck => 'Enter number to pick (e.g., 3)',
1.484.2.12 raeburn 6411: imsfile => 'You must choose an IMS package for import',
6412: imscms => 'You must select which Course Management System was the source of the IMS package',
6413: invurl => 'Invalid URL',
6414: titbl => 'Title is blank',
1.484.2.30 raeburn 6415: more => '(More ...)',
6416: less => '(Less ...)',
6417: noor => 'No actions selected or changes to settings specified.',
6418: noch => 'No changes to settings specified.',
6419: noac => 'No actions selected.',
1.484.2.67 raeburn 6420: edri => 'Editing rights unavailable for your current role.',
1.329 droeschl 6421: );
6422:
1.484.2.61 raeburn 6423: &js_escape(\%js_lt);
1.433 raeburn 6424: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 6425: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
6426: my $main_container_page;
1.484.2.19 raeburn 6427: if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) {
6428: $main_container_page = 1;
1.434 raeburn 6429: }
1.484.2.67 raeburn 6430: my $backtourl;
6431: my $toplevelmain = &escape(&default_folderpath($coursenum,$coursedom,$navmapref));
1.446 www 6432: my $toplevelsupp = &supplemental_base();
1.433 raeburn 6433:
1.484.2.21 raeburn 6434: if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
6435: my $caller = $1;
6436: if ($caller =~ /^supplemental/) {
6437: $backtourl = '/adm/supplemental?folderpath='.&escape($caller);
6438: } else {
6439: my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
6440: $res = &Apache::lonnet::clutter($res);
6441: if (&Apache::lonnet::is_on_map($res)) {
1.484.2.66 raeburn 6442: my ($url,$anchor);
6443: if ($res =~ /^([^#]+)#([^#]+)$/) {
6444: $url = $1;
6445: $anchor = $2;
6446: if (($caller =~ m{^([^#]+)\Q#$anchor\E$})) {
6447: $caller = $1.&escape('#').$anchor;
6448: }
1.484.2.67 raeburn 6449: } else {
6450: $url = $res;
1.484.2.66 raeburn 6451: }
1.484.2.72.2. (raeburn 6452:): $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"');
6453:): if ($backtourl =~ m{^\Q/uploaded/$coursedom/$coursenum/\Edefault_\d+\.sequence$}) {
6454:): $backtourl .= '?navmap=1';
6455:): } else {
6456:): $backtourl .= '?symb='.
6457:): &HTML::Entities::encode($caller,'<>&"');
6458:): }
1.484.2.66 raeburn 6459: if ($anchor ne '') {
6460: $backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"');
6461: }
1.484.2.57 raeburn 6462: $backtourl = &Apache::loncommon::escape_single($backtourl);
1.484.2.31 raeburn 6463: } else {
6464: $backtourl = '/adm/navmaps';
1.484.2.21 raeburn 6465: }
6466: }
6467: } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
6468: $backtourl = '/adm/menu';
6469: } elsif ($supplementalflag) {
1.472 raeburn 6470: $backtourl = '/adm/supplemental';
1.484.2.21 raeburn 6471: } else {
6472: $backtourl = '/adm/navmaps';
1.472 raeburn 6473: }
6474:
1.484.2.19 raeburn 6475: my $fieldsets = "'ext','doc'";
1.484.2.72.2. (raeburn 6476:): if ($posslti) {
6477:): $fieldsets .= ",'tool'";
6478:): }
1.484.2.19 raeburn 6479: unless ($main_container_page) {
6480: $fieldsets .=",'ims'";
6481: }
1.484.2.12 raeburn 6482: if ($supplementalflag) {
6483: $fieldsets = "'suppext','suppdoc'";
1.484.2.72.2. (raeburn 6484:): if ($posslti) {
6485:): $fieldsets .= ",'supptool'";
6486:): }
1.484.2.12 raeburn 6487: }
6488:
1.484.2.67 raeburn 6489: my $jsmakefunctions;
6490: if ($canedit) {
6491: $jsmakefunctions = <<ENDNEWSCRIPT;
1.329 droeschl 6492: function makenewfolder(targetform,folderseq) {
1.484.2.65 raeburn 6493: var foldername=prompt('$js_lt{"p_mnf"}','$js_lt{"t_mnf"}');
1.329 droeschl 6494: if (foldername) {
6495: targetform.importdetail.value=escape(foldername)+"="+folderseq;
6496: targetform.submit();
6497: }
6498: }
6499:
6500: function makenewpage(targetform,folderseq) {
1.484.2.61 raeburn 6501: var pagename=prompt('$js_lt{"p_mnp"}','$js_lt{"t_mnp"}');
1.329 droeschl 6502: if (pagename) {
6503: targetform.importdetail.value=escape(pagename)+"="+folderseq;
6504: targetform.submit();
6505: }
6506: }
6507:
6508: function makeexamupload() {
1.484.2.61 raeburn 6509: var title=prompt('$js_lt{"p_mxu"}');
1.344 bisitz 6510: if (title) {
1.329 droeschl 6511: this.document.forms.newexamupload.importdetail.value=
6512: escape(title)+'=/res/lib/templates/examupload.problem';
6513: this.document.forms.newexamupload.submit();
6514: }
6515: }
6516:
6517: function makesmppage() {
1.484.2.61 raeburn 6518: var title=prompt('$js_lt{"p_msp"}');
1.344 bisitz 6519: if (title) {
1.329 droeschl 6520: this.document.forms.newsmppg.importdetail.value=
1.484.2.26 raeburn 6521: escape(title)+'=/adm/$udom/$uname/new/smppg';
1.329 droeschl 6522: this.document.forms.newsmppg.submit();
6523: }
6524: }
6525:
1.484.2.27 raeburn 6526: function makewebpage(type) {
1.484.2.61 raeburn 6527: var title=prompt('$js_lt{"p_mwp"}');
1.484.2.27 raeburn 6528: var formname;
6529: if (type == 'supp') {
6530: formname = this.document.forms.supwebpage;
6531: } else {
6532: formname = this.document.forms.newwebpage;
6533: }
6534: if (title) {
6535: var webpage = formname.importdetail.value;
6536: formname.importdetail.value = escape(title)+'='+webpage;
6537: formname.submit();
6538: }
6539: }
6540:
1.329 droeschl 6541: function makesmpproblem() {
1.484.2.61 raeburn 6542: var title=prompt('$js_lt{"p_msb"}');
1.344 bisitz 6543: if (title) {
1.329 droeschl 6544: this.document.forms.newsmpproblem.importdetail.value=
6545: escape(title)+'=/res/lib/templates/simpleproblem.problem';
6546: this.document.forms.newsmpproblem.submit();
6547: }
6548: }
6549:
6550: function makedropbox() {
1.484.2.61 raeburn 6551: var title=prompt('$js_lt{"p_mdb"}');
1.344 bisitz 6552: if (title) {
1.329 droeschl 6553: this.document.forms.newdropbox.importdetail.value=
6554: escape(title)+'=/res/lib/templates/DropBox.problem';
6555: this.document.forms.newdropbox.submit();
6556: }
6557: }
6558:
6559: function makebulboard() {
1.484.2.61 raeburn 6560: var title=prompt('$js_lt{"p_mbb"}');
1.329 droeschl 6561: if (title) {
6562: this.document.forms.newbul.importdetail.value=
1.484.2.26 raeburn 6563: escape(title)+'=/adm/$udom/$uname/new/bulletinboard';
1.329 droeschl 6564: this.document.forms.newbul.submit();
6565: }
6566: }
6567:
6568: function makeabout() {
1.484.2.61 raeburn 6569: var user=prompt("$js_lt{'p_mab'}");
1.329 droeschl 6570: if (user) {
6571: var comp=new Array();
6572: comp=user.split(':');
6573: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
6574: if ((comp[0]) && (comp[1])) {
6575: this.document.forms.newaboutsomeone.importdetail.value=
1.484.2.61 raeburn 6576: '$js_lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.484.2.67 raeburn 6577: this.document.forms.newaboutsomeone.submit();
6578: } else {
6579: alert("$js_lt{'p_mab_alrt1'}");
6580: }
6581: } else {
6582: alert("$js_lt{'p_mab_alrt2'}");
6583: }
6584: }
1.335 ehlerst 6585: }
1.484.2.67 raeburn 6586:
6587: function makenew(targetform) {
6588: targetform.submit();
1.335 ehlerst 6589: }
1.484.2.67 raeburn 6590:
6591: function changename(folderpath,index,oldtitle) {
6592: var title=prompt('$js_lt{"p_chn"}',oldtitle);
6593: if (title) {
6594: this.document.forms.renameform.markcopy.value='';
6595: this.document.forms.renameform.title.value=title;
6596: this.document.forms.renameform.cmd.value='rename_'+index;
6597: this.document.forms.renameform.folderpath.value=folderpath;
6598: this.document.forms.renameform.submit();
6599: }
1.329 droeschl 6600: }
6601:
1.484.2.67 raeburn 6602: ENDNEWSCRIPT
6603: } else {
6604: $jsmakefunctions = <<ENDNEWSCRIPT;
6605:
6606: function makenewfolder() {
6607: alert("$js_lt{'edri'}");
6608: }
6609:
6610: function makenewpage() {
6611: alert("$js_lt{'edri'}");
6612: }
6613:
6614: function makeexamupload() {
6615: alert("$js_lt{'edri'}");
6616: }
6617:
6618: function makesmppage() {
6619: alert("$js_lt{'edri'}");
6620: }
6621:
6622: function makewebpage(type) {
6623: alert("$js_lt{'edri'}");
6624: }
6625:
6626: function makesmpproblem() {
6627: alert("$js_lt{'edri'}");
6628: }
6629:
6630: function makedropbox() {
6631: alert("$js_lt{'edri'}");
6632: }
6633:
6634: function makebulboard() {
6635: alert("$js_lt{'edri'}");
6636: }
6637:
6638: function makeabout() {
6639: alert("$js_lt{'edri'}");
6640: }
6641:
6642: function changename() {
6643: alert("$js_lt{'edri'}");
6644: }
6645:
6646: function makenew() {
6647: alert("$js_lt{'edri'}");
6648: }
6649:
6650: function groupimport() {
6651: alert("$js_lt{'edri'}");
6652: }
6653:
6654: function groupsearch() {
6655: alert("$js_lt{'edri'}");
6656: }
6657:
6658: function groupopen(url,recover) {
6659: var options="scrollbars=1,resizable=1,menubar=0";
6660: idxflag=1;
6661: idx=open("/adm/groupsort?inhibitmenu=yes&mode=simple&recover="+recover+"&readfile="+url,"idxout",options);
6662: idx.focus();
6663: }
6664:
6665: ENDNEWSCRIPT
6666:
6667: }
6668: return <<ENDSCRIPT;
6669:
6670: $jsmakefunctions
6671:
1.484.2.13 raeburn 6672: function toggleUpload(caller) {
6673: var blocks = Array($fieldsets);
6674: for (var i=0; i<blocks.length; i++) {
6675: var disp = 'none';
6676: if (caller == blocks[i]) {
6677: var curr = document.getElementById('upload'+caller+'form').style.display;
6678: if (curr == 'none') {
6679: disp='block';
6680: }
6681: }
6682: document.getElementById('upload'+blocks[i]+'form').style.display=disp;
1.484.2.72.2. (raeburn 6683:): if ((caller == 'tool') || (caller == 'supptool')) {
6684:): if (disp == 'block') {
6685:): if (document.getElementById('LC_exttoolid')) {
6686:): var toolselector = document.getElementById('LC_exttoolid');
6687:): var suppflag = 0;
6688:): if (caller == 'supptool') {
6689:): suppflag = 1;
6690:): }
6691:): currForm = document.getElementById('new'+caller);
6692:): updateExttool(toolselector,currForm,suppflag);
6693:): }
6694:): }
6695:): }
1.484.2.13 raeburn 6696: }
6697: resize_scrollbox('contentscroll','1','1');
6698: return;
6699: }
6700:
1.484.2.19 raeburn 6701: function toggleMap(caller) {
1.484.2.13 raeburn 6702: var disp = 'none';
1.484.2.19 raeburn 6703: if (document.getElementById('importmapform')) {
6704: if (caller == 'map') {
6705: var curr = document.getElementById('importmapform').style.display;
6706: if (curr == 'none') {
6707: disp='block';
6708: }
1.484.2.12 raeburn 6709: }
1.484.2.19 raeburn 6710: document.getElementById('importmapform').style.display=disp;
6711: resize_scrollbox('contentscroll','1','1');
1.484.2.12 raeburn 6712: }
1.484.2.19 raeburn 6713: return;
1.329 droeschl 6714: }
6715:
1.484.2.12 raeburn 6716: function makeims(imsform) {
6717: if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
1.484.2.61 raeburn 6718: alert("$js_lt{'imsfile'}");
1.484.2.12 raeburn 6719: return;
6720: }
6721: if (imsform.source.selectedIndex == 0) {
1.484.2.61 raeburn 6722: alert("$js_lt{'imscms'}");
1.484.2.12 raeburn 6723: return;
6724: }
6725: newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
6726: imsform.submit();
6727: }
6728:
1.478 raeburn 6729: function updatePick(targetform,index,caller) {
1.484.2.29 raeburn 6730: var pickitem;
6731: var picknumitem;
6732: var picknumtext;
6733: if (index == 'all') {
6734: pickitem = document.getElementById('randompickall');
6735: picknumitem = document.getElementById('rpicknumall');
6736: picknumtext = document.getElementById('rpicktextall');
6737: } else {
6738: pickitem = document.getElementById('randompick_'+index);
6739: picknumitem = document.getElementById('rpicknum_'+index);
6740: picknumtext = document.getElementById('randompicknum_'+index);
6741: }
1.478 raeburn 6742: if (pickitem.checked) {
1.484.2.61 raeburn 6743: var picknum=prompt('$js_lt{"rpck"}',picknumitem.value);
1.478 raeburn 6744: if (picknum == '' || picknum == null) {
6745: if (caller == 'check') {
6746: pickitem.checked=false;
1.484.2.29 raeburn 6747: if (index == 'all') {
6748: picknumtext.innerHTML = '';
6749: if (caller == 'link') {
6750: propagateState(targetform,'rpicknum');
6751: }
6752: } else {
1.484.2.30 raeburn 6753: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 6754: }
1.478 raeburn 6755: }
6756: } else {
6757: picknum.toString();
6758: var regexdigit=/^\\d+\$/;
6759: if (regexdigit.test(picknum)) {
6760: picknumitem.value = picknum;
1.484.2.29 raeburn 6761: if (index == 'all') {
1.484.2.30 raeburn 6762: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.cumulativesettings,\\'all\\',\\'link\\');">'+picknum+'</a>';
1.484.2.29 raeburn 6763: if (caller == 'link') {
6764: propagateState(targetform,'rpicknum');
6765: }
6766: } else {
6767: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.edit_randompick_'+index+',\\''+index+'\\',\\'link\\');">'+picknum+'</a>';
1.484.2.30 raeburn 6768: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 6769: }
1.478 raeburn 6770: } else {
6771: if (caller == 'check') {
1.484.2.29 raeburn 6772: if (index == 'all') {
6773: picknumtext.innerHTML = '';
6774: if (caller == 'link') {
6775: propagateState(targetform,'rpicknum');
6776: }
6777: } else {
6778: pickitem.checked=false;
1.484.2.30 raeburn 6779: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 6780: }
1.478 raeburn 6781: }
6782: return;
6783: }
6784: }
6785: } else {
1.484.2.29 raeburn 6786: picknumitem.value = '';
6787: picknumtext.innerHTML = '';
6788: if (index == 'all') {
6789: if (caller == 'link') {
6790: propagateState(targetform,'rpicknum');
6791: }
6792: } else {
1.484.2.30 raeburn 6793: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 6794: }
6795: }
6796: }
6797:
6798: function propagateState(form,param) {
6799: if (document.getElementById(param+'all')) {
6800: var setcheck = 0;
6801: var rpick = 0;
6802: if (param == 'rpicknum') {
6803: if (document.getElementById('randompickall')) {
6804: if (document.getElementById('randompickall').checked) {
6805: if (document.getElementById('rpicknumall')) {
6806: rpick = document.getElementById('rpicknumall').value;
6807: }
6808: }
6809: }
6810: } else {
6811: if (document.getElementById(param+'all').checked) {
6812: setcheck = 1;
6813: }
6814: }
1.484.2.30 raeburn 6815: var allidxlist;
6816: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
6817: if (document.getElementById('all'+param+'idx')) {
6818: allidxlist = document.getElementById('all'+param+'idx').value;
6819: }
6820: var actions = new Array ('remove','cut','copy');
6821: for (var i=0; i<actions.length; i++) {
6822: if (actions[i] != param) {
6823: if (document.getElementById(actions[i]+'all')) {
6824: document.getElementById(actions[i]+'all').checked = false;
6825: }
6826: }
6827: }
6828: }
1.484.2.29 raeburn 6829: if ((param == 'encrypturl') || (param == 'hiddenresource')) {
1.484.2.30 raeburn 6830: allidxlist = form.allidx.value;
6831: }
6832: if ((param == 'randompick') || (param == 'rpicknum') || (param == 'randomorder')) {
6833: allidxlist = form.allmapidx.value;
6834: }
6835: if ((allidxlist != '') && (allidxlist != null)) {
6836: var allidxs = allidxlist.split(',');
6837: if (allidxs.length > 1) {
6838: for (var i=0; i<allidxs.length; i++) {
6839: if (document.getElementById(param+'_'+allidxs[i])) {
6840: if (param == 'rpicknum') {
6841: if (document.getElementById('randompick_'+allidxs[i])) {
6842: if (document.getElementById('randompick_'+allidxs[i]).checked) {
6843: document.getElementById(param+'_'+allidxs[i]).value = rpick;
6844: if (rpick > 0) {
6845: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = ': <a href="javascript:updatePick(document.edit_randompick_'+allidxs[i]+',\\''+allidxs[i]+'\\',\\'link\\')">'+rpick+'</a>';
6846: } else {
6847: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
6848: }
6849: }
6850: }
6851: } else {
1.484.2.29 raeburn 6852: if (setcheck == 1) {
6853: document.getElementById(param+'_'+allidxs[i]).checked = true;
6854: } else {
6855: document.getElementById(param+'_'+allidxs[i]).checked = false;
1.484.2.30 raeburn 6856: if (param == 'randompick') {
6857: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
6858: }
1.484.2.29 raeburn 6859: }
6860: }
6861: }
6862: }
1.484.2.30 raeburn 6863: if (setcheck == 1) {
6864: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
6865: var actions = new Array('copy','cut','remove');
6866: for (var i=0; i<actions.length; i++) {
6867: var otheractions;
6868: var otheridxs;
6869: if (actions[i] === param) {
6870: continue;
6871: } else {
6872: if (document.getElementById('all'+actions[i]+'idx')) {
6873: otheractions = document.getElementById('all'+actions[i]+'idx').value;
6874: otheridxs = otheractions.split(',');
6875: if (otheridxs.length > 1) {
6876: for (var j=0; j<otheridxs.length; j++) {
6877: if (document.getElementById(actions[i]+'_'+otheridxs[j])) {
6878: document.getElementById(actions[i]+'_'+otheridxs[j]).checked = false;
6879: }
1.484.2.29 raeburn 6880: }
6881: }
6882: }
6883: }
1.484.2.30 raeburn 6884: }
1.484.2.29 raeburn 6885: }
6886: }
6887: }
6888: }
1.478 raeburn 6889: }
1.484.2.29 raeburn 6890: return;
6891: }
6892:
1.484.2.63 raeburn 6893: function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder,confirm_removal) {
1.484.2.67 raeburn 6894: var canedit = '$canedit';
6895: if (canedit == '') {
6896: alert("$js_lt{'edri'}");
6897: return;
6898: }
1.484.2.30 raeburn 6899: var dosettings;
6900: var doaction;
6901: var control = document.togglemultsettings;
6902: if (context == 'actions') {
6903: control = document.togglemultactions;
6904: doaction = 1;
6905: } else {
6906: dosettings = 1;
6907: }
6908: if (control) {
6909: if (control.showmultpick.length) {
6910: for (var i=0; i<control.showmultpick.length; i++) {
6911: if (control.showmultpick[i].checked) {
6912: if (control.showmultpick[i].value == 1) {
6913: if (context == 'settings') {
6914: dosettings = 0;
6915: } else {
6916: doaction = 0;
6917: }
6918: }
6919: }
6920: }
6921: }
6922: }
6923: if (context == 'settings') {
6924: if (dosettings == 1) {
6925: targetform.changeparms.value=param;
6926: targetform.submit();
6927: }
6928: }
6929: if (context == 'actions') {
6930: if (doaction == 1) {
6931: targetform.cmd.value=param+'_'+index;
6932: targetform.folderpath.value=folderpath;
6933: targetform.markcopy.value=idx+':'+param;
6934: targetform.copyfolder.value=folder+'.'+container;
6935: if (param == 'remove') {
1.484.2.63 raeburn 6936: var doremove = 0;
6937: if (skip_confirm) {
6938: if (confirm_removal) {
6939: if (confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'"$js_lt{"p_rmr2b"}')) {
6940: doremove = 1;
6941: }
6942: } else {
6943: doremove = 1;
6944: }
6945: } else {
6946: if (confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'" $js_lt{"p_rmr2b"}')) {
6947: doremove = 1;
6948: }
6949: }
6950: if (doremove) {
1.484.2.30 raeburn 6951: targetform.markcopy.value='';
6952: targetform.copyfolder.value='';
1.484.2.29 raeburn 6953: targetform.submit();
6954: }
6955: }
1.484.2.30 raeburn 6956: if (param == 'cut') {
1.484.2.61 raeburn 6957: 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 6958: targetform.submit();
6959: return;
6960: }
6961: }
6962: if (param == 'copy') {
6963: targetform.submit();
6964: return;
6965: }
6966: targetform.markcopy.value='';
6967: targetform.copyfolder.value='';
6968: targetform.cmd.value='';
6969: targetform.folderpath.value='';
6970: return;
6971: } else {
6972: if (document.getElementById(param+'_'+idx)) {
6973: item = document.getElementById(param+'_'+idx);
6974: if (item.type == 'checkbox') {
6975: if (item.checked) {
6976: item.checked = false;
6977: } else {
6978: item.checked = true;
6979: singleCheck(item,idx,param);
6980: }
6981: }
6982: }
6983: }
6984: }
6985: return;
6986: }
6987:
6988: function singleCheck(caller,idx,action) {
6989: actions = new Array('cut','copy','remove');
6990: if (caller.checked) {
6991: for (var i=0; i<actions.length; i++) {
6992: if (actions[i] != action) {
6993: if (document.getElementById(actions[i]+'_'+idx)) {
6994: if (document.getElementById(actions[i]+'_'+idx).checked) {
6995: document.getElementById(actions[i]+'_'+idx).checked = false;
6996: }
6997: }
6998: }
1.484.2.29 raeburn 6999: }
7000: }
7001: return;
1.478 raeburn 7002: }
7003:
1.334 muellerd 7004: function unselectInactive(nav) {
1.335 ehlerst 7005: currentNav = document.getElementById(nav);
7006: currentLis = currentNav.getElementsByTagName('LI');
7007: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 7008: if (currentLis[i].className == 'goback') {
7009: currentLis[i].className = 'goback';
7010: } else {
7011: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 7012: currentLis[i].className = 'right';
1.472 raeburn 7013: } else {
1.374 tempelho 7014: currentLis[i].className = 'i';
1.472 raeburn 7015: }
7016: }
1.335 ehlerst 7017: }
1.332 tempelho 7018: }
7019:
1.334 muellerd 7020: function hideAll(current, nav, data) {
1.335 ehlerst 7021: unselectInactive(nav);
1.484.2.43 raeburn 7022: if (current) {
7023: if (current.className == 'right'){
1.374 tempelho 7024: current.className = 'right active'
1.484.2.43 raeburn 7025: } else {
1.374 tempelho 7026: current.className = 'active';
1.484.2.43 raeburn 7027: }
1.374 tempelho 7028: }
1.335 ehlerst 7029: currentData = document.getElementById(data);
7030: currentDivs = currentData.getElementsByTagName('DIV');
7031: for (i = 0; i < currentDivs.length; i++) {
7032: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 7033: currentDivs[i].style.display = 'none';
1.330 tempelho 7034: }
7035: }
1.335 ehlerst 7036: }
1.330 tempelho 7037:
1.374 tempelho 7038: function openTabs(pageId) {
7039: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 7040: if(tabnav.length > 2 ){
1.389 tempelho 7041: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 7042: currentLis = currentNav.getElementsByTagName('LI');
7043: for(i = 0; i< currentLis.length; i++){
7044: if(currentLis[i].className == 'active') {
1.375 tempelho 7045: funcString = currentLis[i].onclick.toString();
7046: tab = funcString.split('"');
1.420 onken 7047: if(tab.length < 2) {
7048: tab = funcString.split("'");
7049: }
1.375 tempelho 7050: currentData = document.getElementById(tab[1]);
7051: currentData.style.display = 'block';
1.374 tempelho 7052: }
7053: }
7054: }
7055: }
7056:
1.334 muellerd 7057: function showPage(current, pageId, nav, data) {
1.484.2.43 raeburn 7058: currstate = current.className;
1.334 muellerd 7059: hideAll(current, nav, data);
1.375 tempelho 7060: openTabs(pageId);
1.334 muellerd 7061: unselectInactive(nav);
1.484.2.43 raeburn 7062: if ((currstate == 'active') || (currstate == 'right active')) {
7063: if (currstate == 'active') {
7064: current.className = '';
7065: } else {
7066: current.className = 'right';
7067: }
7068: activeTab = '';
7069: toggleUpload();
7070: toggleMap();
7071: resize_scrollbox('contentscroll','1','0');
7072: return;
7073: } else {
7074: current.className = 'active';
7075: }
1.330 tempelho 7076: currentData = document.getElementById(pageId);
7077: currentData.style.display = 'block';
1.458 raeburn 7078: activeTab = pageId;
1.484.2.12 raeburn 7079: toggleUpload();
1.484.2.14 raeburn 7080: toggleMap();
1.433 raeburn 7081: if (nav == 'mainnav') {
7082: var storedpath = "$docs_folderpath";
1.434 raeburn 7083: var storedpage = "$main_container_page";
1.433 raeburn 7084: var reg = new RegExp("^supplemental");
7085: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 7086: if (storedpage == 1) {
7087: document.simpleedit.folderpath.value = '';
7088: document.uploaddocument.folderpath.value = '';
7089: } else {
7090: if (reg.test(storedpath)) {
7091: document.simpleedit.folderpath.value = '$toplevelmain';
7092: document.uploaddocument.folderpath.value = '$toplevelmain';
7093: document.newext.folderpath.value = '$toplevelmain';
7094: } else {
7095: document.simpleedit.folderpath.value = storedpath;
7096: document.uploaddocument.folderpath.value = storedpath;
7097: document.newext.folderpath.value = storedpath;
7098: }
1.433 raeburn 7099: }
7100: } else {
1.434 raeburn 7101: if (reg.test(storedpath)) {
7102: document.simpleedit.folderpath.value = storedpath;
7103: document.supuploaddocument.folderpath.value = storedpath;
7104: document.supnewext.folderpath.value = storedpath;
7105: } else {
1.433 raeburn 7106: document.simpleedit.folderpath.value = '$toplevelsupp';
7107: document.supuploaddocument.folderpath.value = '$toplevelsupp';
7108: document.supnewext.folderpath.value = '$toplevelsupp';
7109: }
7110: }
7111: }
1.484.2.3 raeburn 7112: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 7113: return false;
7114: }
1.329 droeschl 7115:
1.472 raeburn 7116: function toContents(jumpto) {
7117: var newurl = '$backtourl';
1.484.2.21 raeburn 7118: if ((newurl == '/adm/navmaps') && (jumpto != '')) {
1.472 raeburn 7119: newurl = newurl+'?postdata='+jumpto;
7120: }
7121: location.href=newurl;
7122: }
7123:
1.484.2.30 raeburn 7124: function togglePick(caller,value) {
7125: var disp = 'none';
7126: if (document.getElementById('multi'+caller)) {
7127: var curr = document.getElementById('multi'+caller).style.display;
7128: if (value == 1) {
7129: disp='block';
7130: }
7131: if (curr == disp) {
7132: return;
7133: }
7134: document.getElementById('multi'+caller).style.display=disp;
7135: if (value == 1) {
1.484.2.61 raeburn 7136: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.484.2.30 raeburn 7137: } else {
7138: document.getElementById('more'+caller).innerHTML = '';
7139: }
7140: if (caller == 'actions') {
7141: setClass(value);
7142: setBoxes(value);
7143: }
7144: }
7145: var showButton = multiSettings();
7146: if (showButton != 1) {
7147: showButton = multiActions();
7148: }
7149: if (document.getElementById('multisave')) {
7150: if (showButton == 1) {
7151: document.getElementById('multisave').style.display='block';
7152: } else {
7153: document.getElementById('multisave').style.display='none';
7154: }
7155: }
7156: resize_scrollbox('contentscroll','1','1');
7157: return;
7158: }
7159:
7160: function toggleCheckUncheck(caller,more) {
7161: if (more == 1) {
1.484.2.61 raeburn 7162: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',0);" style="text-decoration:none;">$js_lt{'less'}</a>';
1.484.2.30 raeburn 7163: document.getElementById('allfields'+caller).style.display='block';
7164: } else {
1.484.2.61 raeburn 7165: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.484.2.30 raeburn 7166: document.getElementById('allfields'+caller).style.display='none';
7167: }
7168: resize_scrollbox('contentscroll','1','1');
7169: }
7170:
7171: function multiSettings() {
7172: var inuse = 0;
7173: var settingsform = document.togglemultsettings;
7174: if (settingsform.showmultpick.length > 1) {
7175: for (var i=0; i<settingsform.showmultpick.length; i++) {
7176: if (settingsform.showmultpick[i].checked) {
7177: if (settingsform.showmultpick[i].value == 1) {
7178: inuse = 1;
7179: }
7180: }
7181: }
7182: }
7183: return inuse;
7184: }
7185:
7186: function multiActions() {
7187: var inuse = 0;
7188: var actionsform = document.togglemultactions;
7189: if (actionsform.showmultpick.length > 1) {
7190: for (var i=0; i<actionsform.showmultpick.length; i++) {
7191: if (actionsform.showmultpick[i].checked) {
7192: if (actionsform.showmultpick[i].value == 1) {
7193: inuse = 1;
7194: }
7195: }
7196: }
7197: }
7198: return inuse;
7199: }
7200:
7201: function checkSubmits() {
7202: var numchanges = 0;
7203: var form = document.saveactions;
7204: var doactions = multiActions();
7205: var cutwarnings = 0;
7206: var remwarnings = 0;
1.484.2.63 raeburn 7207: var removalinfo = 0;
1.484.2.30 raeburn 7208: if (doactions == 1) {
7209: var remidxlist = document.cumulativeactions.allremoveidx.value;
7210: if ((remidxlist != '') && (remidxlist != null)) {
7211: var remidxs = remidxlist.split(',');
7212: for (var i=0; i<remidxs.length; i++) {
7213: if (document.getElementById('remove_'+remidxs[i])) {
7214: if (document.getElementById('remove_'+remidxs[i]).checked) {
7215: form.multiremove.value += remidxs[i]+',';
7216: numchanges ++;
7217: if (document.getElementById('skip_remove_'+remidxs[i])) {
7218: if (document.getElementById('skip_remove_'+remidxs[i]).value == 0) {
7219: remwarnings ++;
7220: }
7221: }
1.484.2.63 raeburn 7222: if (document.getElementById('confirm_removal_'+remidxs[i])) {
7223: if (document.getElementById('confirm_removal_'+remidxs[i]).value == 1) {
7224: removalinfo ++;
7225: }
7226: }
1.484.2.30 raeburn 7227: }
7228: }
7229: }
7230: }
7231: var cutidxlist = document.cumulativeactions.allcutidx.value;
7232: if ((cutidxlist != '') && (cutidxlist != null)) {
7233: var cutidxs = cutidxlist.split(',');
7234: for (var i=0; i<cutidxs.length; i++) {
7235: if (document.getElementById('cut_'+cutidxs[i])) {
7236: if (document.getElementById('cut_'+cutidxs[i]).checked == true) {
7237: form.multicut.value += cutidxs[i]+',';
7238: numchanges ++;
7239: if (document.getElementById('skip_cut_'+cutidxs[i])) {
7240: if (document.getElementById('skip_cut_'+cutidxs[i]).value == 0) {
7241: cutwarnings ++;
7242: }
7243: }
7244: }
7245: }
7246: }
7247: }
7248: var copyidxlist = document.cumulativeactions.allcopyidx.value;
7249: if ((copyidxlist != '') && (copyidxlist != null)) {
7250: var copyidxs = copyidxlist.split(',');
7251: for (var i=0; i<copyidxs.length; i++) {
7252: if (document.getElementById('copy_'+copyidxs[i])) {
7253: if (document.getElementById('copy_'+copyidxs[i]).checked) {
7254: form.multicopy.value += copyidxs[i]+',';
7255: numchanges ++;
7256: }
7257: }
7258: }
7259: }
7260: if (numchanges > 0) {
7261: form.multichange.value = numchanges;
7262: }
7263: }
7264: var dosettings = multiSettings();
7265: var haschanges = 0;
7266: if (dosettings == 1) {
7267: form.allencrypturl.value = '';
7268: form.allhiddenresource.value = '';
7269: form.changeparms.value = 'all';
7270: var patt=new RegExp(",\$");
7271: var allidxlist = document.cumulativesettings.allidx.value;
7272: if ((allidxlist != '') && (allidxlist != null)) {
7273: var allidxs = allidxlist.split(',');
7274: if (allidxs.length > 1) {
7275: for (var i=0; i<allidxs.length; i++) {
7276: if (document.getElementById('hiddenresource_'+allidxs[i])) {
7277: if (document.getElementById('hiddenresource_'+allidxs[i]).checked) {
7278: form.allhiddenresource.value += allidxs[i]+',';
7279: }
7280: }
7281: if (document.getElementById('encrypturl_'+allidxs[i])) {
7282: if (document.getElementById('encrypturl_'+allidxs[i]).checked) {
7283: form.allencrypturl.value += allidxs[i]+',';
7284: }
1.484.2.29 raeburn 7285: }
7286: }
1.484.2.30 raeburn 7287: form.allhiddenresource.value = form.allhiddenresource.value.replace(patt,"");
7288: form.allencrypturl.value = form.allencrypturl.value.replace(patt,"");
7289: }
7290: }
7291: form.allrandompick.value = '';
7292: form.allrandomorder.value = '';
7293: var allmapidxlist = document.cumulativesettings.allmapidx.value;
7294: if ((allmapidxlist != '') && (allmapidxlist != null)) {
7295: var allmapidxs = allmapidxlist.split(',');
7296: for (var i=0; i<allmapidxs.length; i++) {
7297: var randompick = document.getElementById('randompick_'+allmapidxs[i]);
7298: var rpicknum = document.getElementById('rpicknum_'+allmapidxs[i]);
7299: var randorder = document.getElementById('randomorder_'+allmapidxs[i]);
7300: if ((randompick.checked) && (rpicknum.value != '')) {
7301: form.allrandompick.value += allmapidxs[i]+':'+rpicknum.value+',';
7302: }
7303: if (randorder.checked) {
7304: form.allrandomorder.value += allmapidxs[i]+',';
7305: }
7306: }
7307: form.allrandompick.value = form.allrandompick.value.replace(patt,"");
7308: form.allrandomorder.value = form.allrandomorder.value.replace(patt,"");
7309: }
7310: if (document.cumulativesettings.currhiddenresource.value != form.allhiddenresource.value) {
7311: haschanges = 1;
7312: }
7313: if (document.cumulativesettings.currencrypturl.value != form.allencrypturl.value) {
7314: haschanges = 1;
7315: }
7316: if (document.cumulativesettings.currrandomorder.value != form.allrandomorder.value) {
7317: haschanges = 1;
7318: }
7319: if (document.cumulativesettings.currrandompick.value != form.allrandompick.value) {
7320: haschanges = 1;
7321: }
7322: }
7323: if (doactions == 1) {
7324: if (numchanges > 0) {
1.484.2.63 raeburn 7325: if ((cutwarnings > 0) || (remwarnings > 0) || (removalinfo > 0)) {
1.484.2.30 raeburn 7326: if (remwarnings > 0) {
1.484.2.61 raeburn 7327: if (!confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr3a"} '+remwarnings+' $js_lt{"p_rmr3b"}')) {
1.484.2.30 raeburn 7328: return false;
7329: }
7330: }
1.484.2.63 raeburn 7331: if (removalinfo > 0) {
7332: if (!confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr3a"} '+removalinfo+' $js_lt{"p_rmr3b"}')) {
7333: return false;
7334: }
7335: }
1.484.2.30 raeburn 7336: if (cutwarnings > 0) {
1.484.2.61 raeburn 7337: 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 7338: return false;
1.484.2.29 raeburn 7339: }
7340: }
7341: }
1.484.2.30 raeburn 7342: form.submit();
7343: return true;
7344: }
7345: }
7346: if (dosettings == 1) {
7347: if (haschanges == 1) {
7348: form.submit();
7349: return true;
1.484.2.29 raeburn 7350: }
7351: }
1.484.2.30 raeburn 7352: if ((dosettings == 1) && (doactions == 1)) {
1.484.2.61 raeburn 7353: alert("$js_lt{'noor'}");
1.484.2.30 raeburn 7354: } else {
7355: if (dosettings == 1) {
1.484.2.61 raeburn 7356: alert("$js_lt{'noch'}");
1.484.2.30 raeburn 7357: } else {
1.484.2.61 raeburn 7358: alert("$js_lt{'noac'}");
1.484.2.30 raeburn 7359: }
7360: }
7361: return false;
7362: }
7363:
7364: function setClass(value) {
7365: var cutclass = 'LC_docs_cut';
7366: var copyclass = 'LC_docs_copy';
7367: var removeclass = 'LC_docs_remove';
7368: var cutreg = new RegExp("\\\\b"+cutclass+"\\\\b");
7369: var copyreg = new RegExp("\\\\b"+copyclass+"\\\\b");
7370: var removereg = new RegExp("\\\\"+removeclass+"\\\\b");
7371: var links = document.getElementsByTagName('a');
7372: for (var i=0; i<links.length; i++) {
7373: var classes = links[i].className;
7374: if (cutreg.test(classes)) {
7375: links[i].className = cutclass;
7376: if (value == 1) {
7377: links[i].className += " LC_menubuttons_link";
1.484.2.29 raeburn 7378: }
1.484.2.30 raeburn 7379: } else {
7380: if (copyreg.test(classes)) {
7381: links[i].className = copyclass;
7382: if (value == 1) {
7383: links[i].className += " LC_menubuttons_link";
7384: }
7385: } else {
7386: if (removereg.test(classes)) {
7387: links[i].className = removeclass;
7388: if (value == 1) {
7389: links[i].className += " LC_menubuttons_link";
7390: }
7391: }
1.484.2.29 raeburn 7392: }
7393: }
7394: }
1.484.2.30 raeburn 7395: return;
1.484.2.29 raeburn 7396: }
7397:
1.484.2.30 raeburn 7398: function setBoxes(value) {
7399: var remidxlist = document.cumulativeactions.allremoveidx.value;
7400: if ((remidxlist != '') && (remidxlist != null)) {
7401: var remidxs = remidxlist.split(',');
7402: for (var i=0; i<remidxs.length; i++) {
7403: if (document.getElementById('remove_'+remidxs[i])) {
7404: var item = document.getElementById('remove_'+remidxs[i]);
7405: if (value == 1) {
7406: item.className = 'LC_docs_remove';
7407: } else {
7408: item.className = 'LC_hidden';
7409: }
7410: }
1.484.2.29 raeburn 7411: }
7412: }
1.484.2.30 raeburn 7413: var cutidxlist = document.cumulativeactions.allcutidx.value;
7414: if ((cutidxlist != '') && (cutidxlist != null)) {
7415: var cutidxs = cutidxlist.split(',');
7416: for (var i=0; i<cutidxs.length; i++) {
7417: if (document.getElementById('cut_'+cutidxs[i])) {
7418: var item = document.getElementById('cut_'+cutidxs[i]);
7419: if (value == 1) {
7420: item.className = 'LC_docs_cut';
7421: } else {
7422: item.className = 'LC_hidden';
7423: }
7424: }
7425: }
7426: }
7427: var copyidxlist = document.cumulativeactions.allcopyidx.value;
7428: if ((copyidxlist != '') && (copyidxlist != null)) {
7429: var copyidxs = copyidxlist.split(',');
7430: for (var i=0; i<copyidxs.length; i++) {
7431: if (document.getElementById('copy_'+copyidxs[i])) {
7432: var item = document.getElementById('copy_'+copyidxs[i]);
7433: if (value == 1) {
7434: item.className = 'LC_docs_copy';
7435: } else {
7436: item.className = 'LC_hidden';
7437: }
7438: }
1.484.2.29 raeburn 7439: }
7440: }
7441: return;
7442: }
7443:
1.484.2.67 raeburn 7444: ENDSCRIPT
1.329 droeschl 7445: }
1.457 raeburn 7446:
1.483 raeburn 7447: sub history_tab_js {
7448: return <<"ENDHIST";
7449: function toggleHistoryDisp(choice) {
7450: document.docslogform.docslog.value = choice;
7451: document.docslogform.submit();
7452: return;
7453: }
7454:
7455: ENDHIST
7456: }
7457:
1.484 raeburn 7458: sub inject_data_js {
7459: return <<ENDINJECT;
7460:
7461: function injectData(current, hiddenField, name, value) {
7462: currentElement = document.getElementById(hiddenField);
7463: currentElement.name = name;
7464: currentElement.value = value;
7465: current.submit();
7466: }
7467:
7468: ENDINJECT
7469: }
7470:
7471: sub dump_switchserver_js {
7472: my @hosts = @_;
1.484.2.61 raeburn 7473: my %js_lt = &Apache::lonlocal::texthash(
1.484.2.46 raeburn 7474: dump => 'Copying content to Authoring Space requires switching server.',
1.484 raeburn 7475: swit => 'Switch server?',
1.484.2.61 raeburn 7476: );
7477: my %html_js_lt = &Apache::lonlocal::texthash(
7478: swit => 'Switch server?',
1.484.2.43 raeburn 7479: duco => 'Copying Content to Authoring Space',
1.484 raeburn 7480: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
7481: chos => 'Choose server',
7482: );
1.484.2.61 raeburn 7483: &js_escape(\%js_lt);
7484: &html_escape(\%html_js_lt);
7485: &js_escape(\%html_js_lt);
1.484 raeburn 7486: my $role = $env{'request.role'};
7487: my $js = <<"ENDSWJS";
7488: <script type="text/javascript">
7489: function write_switchserver() {
7490: var server;
7491: if (document.setserver.posshosts.length > 0) {
7492: for (var i=0; i<document.setserver.posshosts.length; i++) {
7493: if (document.setserver.posshosts[i].checked) {
7494: server = document.setserver.posshosts[i].value;
7495: }
7496: }
7497: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
7498: }
7499: window.close();
7500: }
7501: </script>
7502:
7503: ENDSWJS
7504:
7505: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
7506: {'only_body' => 1,
7507: 'js_ready' => 1,});
7508: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
7509:
7510: my $hostpicker;
7511: my $count = 0;
7512: foreach my $host (sort(@hosts)) {
7513: my $checked;
7514: if ($count == 0) {
7515: $checked = ' checked="checked"';
7516: }
7517: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
7518: $host.'"'.$checked.' />'.$host.'</label> ';
7519: $count++;
7520: }
7521:
7522: return <<"ENDSWITCHJS";
7523:
7524: function dump_needs_switchserver(url) {
7525: if (url!='' && url!= null) {
1.484.2.61 raeburn 7526: if (confirm("$js_lt{'dump'}\\n$js_lt{'swit'}")) {
1.484 raeburn 7527: go(url);
7528: }
7529: }
7530: return;
7531: }
7532:
7533: function choose_switchserver_window() {
7534: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
7535: newWindow.document.open();
7536: newWindow.document.writeln('$startpage');
1.484.2.61 raeburn 7537: newWindow.document.write('<h3>$html_js_lt{'duco'}<\\/h3>\\n'+
7538: '<p>$html_js_lt{'yone'}<\\/p>\\n'+
7539: '<div class="LC_left_float"><fieldset><legend>$html_js_lt{'chos'}<\\/legend>\\n'+
1.484 raeburn 7540: '<form name="setserver" method="post" action="" \\/>\\n'+
7541: '$hostpicker\\n'+
7542: '<br \\/><br \\/>\\n'+
1.484.2.61 raeburn 7543: '<input type="button" name="makeswitch" value="$html_js_lt{'swit'}" '+
1.484 raeburn 7544: 'onclick="write_switchserver();" \\/>\\n'+
7545: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
7546: newWindow.document.writeln('$endpage');
7547: newWindow.document.close();
7548: newWindow.focus();
7549: }
7550:
7551: ENDSWITCHJS
7552: }
7553:
7554: sub makedocslogform {
7555: my ($formelems,$docslog) = @_;
7556: return <<"LOGSFORM";
7557: <form action="/adm/coursedocs" method="post" name="docslogform">
7558: <input type="hidden" name="docslog" value="$docslog" />
7559: $formelems
7560: </form>
7561: LOGSFORM
7562: }
7563:
7564: sub makesimpleeditform {
7565: my ($formelems) = @_;
7566: return <<"SIMPFORM";
7567: <form name="simpleedit" method="post" action="/adm/coursedocs">
7568: <input type="hidden" name="importdetail" value="" />
7569: $formelems
7570: </form>
7571: SIMPFORM
7572: }
7573:
1.329 droeschl 7574: 1;
7575: __END__
7576:
7577:
7578: =head1 NAME
7579:
7580: Apache::londocs.pm
7581:
7582: =head1 SYNOPSIS
7583:
7584: This is part of the LearningOnline Network with CAPA project
7585: described at http://www.lon-capa.org.
7586:
7587: =head1 SUBROUTINES
7588:
7589: =over
7590:
7591: =item %help=()
7592:
7593: Available help topics
7594:
7595: =item mapread()
7596:
1.344 bisitz 7597: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 7598: @order and @resources, determines status
7599: sets @order - pointer to resources in right order
7600: sets @resources - array with the resources with correct idx
7601:
7602: =item authorhosts()
7603:
7604: Return hash with valid author names
7605:
7606: =item clean()
7607:
7608: =item dumpcourse()
7609:
7610: Actually dump course
7611:
7612: =item group_import()
7613:
7614: Imports the given (name, url) resources into the course
7615: coursenum, coursedom, and folder must precede the list
7616:
7617: =item breadcrumbs()
7618:
7619: =item log_docs()
7620:
7621: =item docs_change_log()
7622:
7623: =item update_paste_buffer()
7624:
7625: =item print_paste_buffer()
7626:
7627: =item do_paste_from_buffer()
7628:
1.484.2.30 raeburn 7629: =item do_buffer_empty()
7630:
7631: =item clear_from_buffer()
7632:
1.484.2.7 raeburn 7633: =item get_newmap_url()
7634:
7635: =item dbcopy()
7636:
7637: =item uniqueness_check()
7638:
7639: =item contained_map_check()
7640:
7641: =item url_paste_fixups()
7642:
7643: =item apply_fixups()
7644:
7645: =item copy_dependencies()
7646:
1.329 droeschl 7647: =item update_parameter()
7648:
7649: =item handle_edit_cmd()
7650:
7651: =item editor()
7652:
7653: =item process_file_upload()
7654:
7655: =item process_secondary_uploads()
7656:
7657: =item is_supplemental_title()
7658:
7659: =item entryline()
7660:
7661: =item tiehash()
7662:
7663: =item untiehash()
7664:
7665: =item checkonthis()
7666:
7667: check on this
7668:
7669: =item verifycontent()
7670:
7671: Verify Content
7672:
1.484.2.72.2. (raeburn 7673:): =item devalidateversioncache()
7674:):
7675:): =item checkversions()
1.329 droeschl 7676:
7677: Check Versions
7678:
7679: =item mark_hash_old()
7680:
7681: =item is_hash_old()
7682:
7683: =item changewarning()
7684:
7685: =item init_breadcrumbs()
7686:
7687: Breadcrumbs for special functions
7688:
1.484 raeburn 7689: =item create_list_elements()
7690:
7691: =item create_form_ul()
7692:
7693: =item startContentScreen()
7694:
7695: =item endContentScreen()
7696:
7697: =item supplemental_base()
7698:
7699: =item embedded_form_elems()
7700:
7701: =item embedded_destination()
7702:
7703: =item return_to_editor()
7704:
7705: =item decompression_info()
7706:
7707: =item decompression_phase_one()
7708:
7709: =item decompression_phase_two()
7710:
7711: =item remove_archive()
7712:
7713: =item generate_admin_menu()
7714:
7715: =item generate_edit_table()
7716:
7717: =item editing_js()
7718:
7719: =item history_tab_js()
7720:
7721: =item inject_data_js()
7722:
7723: =item dump_switchserver_js()
7724:
1.484.2.3 raeburn 7725: =item resize_scrollbox_js()
1.484 raeburn 7726:
7727: =item makedocslogform()
7728:
1.484.2.3 raeburn 7729: =item makesimpleeditform()
7730:
1.329 droeschl 7731: =back
7732:
7733: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>