Annotation of loncom/interface/londocs.pm, revision 1.484.2.72.4.2
1.329 droeschl 1: # The LearningOnline Network
2: # Documents
3: #
1.484.2.72.4. (raeburn 4:): # $Id: londocs.pm,v 1.484.2.72.4.1 2020/04/07 18:21:04 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.4. (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.4. (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','crsappend');
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'},$toolhash{'crsappend'}) = @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.4. (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.4. (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.4. (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.4. (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.4. (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.4. (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.4. (raeburn 1328:): } elsif ($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg|ext\.tool)$}) {
1329:): if ($cid ne $env{'request.course.id'}) {
1330:): my ($srcdom,$srcnum) = split(/_/,$cid);
1331:): if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1332:): if (($is_exttool) && ($srcdom ne $coursedom)) {
1333:): $canpaste = 0;
1334:): $nopaste = &mt('Paste from another domain unavailable.');
1335:): } else {
1336:): $othercrs = '<br />'.&mt('(from another course)');
1337:): }
1338:): } else {
1339:): $canpaste = 0;
1340:): $nopaste = &mt('Paste from another course unavailable.');
1341:): }
1342:): }
1.484.2.30 raeburn 1343: }
1344: }
1345: if ($canpaste) {
1346: push(@pasteable,$suffix);
1347: }
1348: my $buffer;
1349: if ($is_external) {
1350: $buffer = &mt('External Resource').': '.
1351: &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('.
1352: &LONCAPA::map::qtescape($url).')';
1.484.2.72.4. (raeburn 1353:): } elsif ($is_exttool) {
1354:): $buffer = &mt('External Tool').': '.
1355:): &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.484.2.30 raeburn 1356: } else {
1357: my $icon = &Apache::loncommon::icon($extension);
1358: if ($extension eq 'sequence' &&
1359: $url =~ m{/default_\d+\.sequence$}x) {
1360: $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
1361: $icon .= '/navmap.folder.closed.gif';
1362: }
1.484.2.57 raeburn 1363: my $title = $env{'docs.markedcopy_title_'.$suffix};
1364: if ($title eq '') {
1365: ($title) = ($url =~ m{/([^/]+)$});
1366: }
1.484.2.30 raeburn 1367: $buffer = '<img src="'.$icon.'" alt="" class="LC_icon" />'.
1368: ': '.
1369: &Apache::loncommon::parse_supplemental_title(
1.484.2.57 raeburn 1370: &LONCAPA::map::qtescape($title));
1.484.2.30 raeburn 1371: }
1372: $pasteitems .= '<div class="LC_left_float">';
1373: my ($options,$onclick);
1374: if (($canpaste) && (!$areachange) && (!$othercourse) &&
1375: ($env{'docs.markedcopy_cmd_'.$suffix} eq 'cut')) {
1376: if (($is_uploaded_map) ||
1377: ($url =~ /(bulletinboard|smppg)$/) ||
1378: ($url =~ m{^/uploaded/$coursedom/$coursenum/(?:docs|supplemental)/(.+)$})) {
1379: $options = &paste_options($suffix,$is_uploaded_map,$parent);
1380: $onclick= 'onclick="showOptions(this,'."'$suffix'".');" ';
1381: }
1382: }
1383: $pasteitems .= '<label><input type="checkbox" name="pasting" id="pasting_'.$suffix.'" value="'.$suffix.'" '.$onclick.'/>'.$buffer.'</label>';
1384: if ($nopaste) {
1385: $pasteitems .= $nopaste;
1386: } else {
1387: if ($othercrs) {
1388: $pasteitems .= $othercrs;
1389: }
1390: if ($options) {
1391: $pasteitems .= $options;
1.484.2.7 raeburn 1392: }
1393: }
1.484.2.30 raeburn 1394: $pasteitems .= '</div>';
1395: }
1396: }
1397: if ($pasteitems eq '') {
1398: &Apache::lonnet::delenv('docs.markedcopies');
1399: }
1400: my ($pasteform,$form_start,$buttons,$form_end);
1401: if ($pasteitems) {
1402: $pasteitems .= '<div style="padding:0;clear:both;margin:0;border:0"></div>';
1403: $form_start = '<form name="pasteform" action="/adm/coursedocs" method="post" onsubmit="return validateClipboard();">';
1404: if (@pasteable) {
1.484.2.47 raeburn 1405: my $value = &mt('Paste to current folder');
1406: if ($container eq 'page') {
1407: $value = &mt('Paste to current page');
1408: }
1409: $buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.(' 'x2);
1410: }
1.484.2.72.4. (raeburn 1411:): $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.(' 'x2);
1.484.2.47 raeburn 1412: if ($clipboardcount > 1) {
1413: $buttons .=
1414: '<span style="text-decoration:line-through">'.(' 'x20).'</span>'.(' 'x2).
1415: '<input type="button" name="checkallclip" value="'.&mt('Check all').'" style="height:20px;" onclick="checkClipboard();" />'.
1416: (' 'x2).
1417: '<input type="button" name="uncheckallclip" value="'.&mt('Uncheck all').'" style="height:20px;" onclick="uncheckClipboard();" />'.
1418: (' 'x2);
1.484.2.7 raeburn 1419: }
1.484.2.48 raeburn 1420: $form_end = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'.
1421: '</form>';
1.484.2.30 raeburn 1422: } else {
1423: $pasteitems = &mt('Clipboard is empty');
1424: }
1425: $r->print($form_start
1426: .'<fieldset>'
1427: .'<legend>'.&mt('Clipboard').(' ' x2).$buttons.'</legend>'
1428: .$pasteitems
1429: .'</fieldset>'
1430: .$form_end);
1431: }
1432:
1433: sub paste_options {
1434: my ($suffix,$is_uploaded_map,$parent) = @_;
1435: my ($copytext,$movetext);
1436: if ($is_uploaded_map) {
1437: $copytext = &mt('Copy to new folder');
1438: $movetext = &mt('Move old');
1439: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /bulletinboard$/) {
1440: $copytext = &mt('Copy to new board');
1441: $movetext = &mt('Move (not posts)');
1442: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /smppg$/) {
1443: $copytext = &mt('Copy to new page');
1444: $movetext = &mt('Move');
1.484.2.7 raeburn 1445: } else {
1.484.2.30 raeburn 1446: $copytext = &mt('Copy to new file');
1447: $movetext = &mt('Move');
1448: }
1449: my $output = '<br />'.
1450: '<span id="pasteoptionstext_'.$suffix.'" class="LC_fontsize_small LC_nobreak"></span>'.
1451: '<div id="pasteoptions_'.$suffix.'" class="LC_dccid" style="display:none;"><span class="LC_nobreak">'.(' 'x 4).
1452: '<label>'.
1453: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="new" checked="checked" />'.
1454: $copytext.'</label></span>'.(' 'x2).' '.
1455: '<span class="LC_nobreak"><label>'.
1456: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="move" />'.
1457: $movetext.'</label></span>';
1458: if (($is_uploaded_map) && ($env{'docs.markedcopy_nested_'.$suffix})) {
1459: $output .= '<br /><fieldset><legend>'.&mt('Folder to paste contains sub-folders').
1460: '</legend><table border="0">';
1461: my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1462: my @titles = split(/\Q___&&&___\E/,$env{'docs.markedcopy_nestednames_'.$suffix});
1463: my $lastdir = $parent;
1464: my %depths = (
1465: $lastdir => 0,
1466: );
1467: my (%display,%deps);
1468: for (my $i=0; $i<@pastemaps; $i++) {
1469: ($lastdir,my $subfolderstr) = split(/\:/,$pastemaps[$i]);
1470: my ($namedir,$esctitlestr) = split(/\:/,$titles[$i]);
1471: my @subfolders = split(/,/,$subfolderstr);
1472: $deps{$lastdir} = \@subfolders;
1473: my @subfoldertitles = map { &unescape($_); } split(/,/,$esctitlestr);
1474: my $depth = $depths{$lastdir} + 1;
1475: my $offset = int($depth * 4);
1476: my $indent = (' ' x $offset);
1477: for (my $j=0; $j<@subfolders; $j++) {
1478: $depths{$subfolders[$j]} = $depth;
1479: $display{$subfolders[$j]} =
1480: '<tr><td>'.$indent.$subfoldertitles[$j].' </td>'.
1481: '<td><label>'.
1482: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="new" checked="checked" />'.&mt('Copy to new').'</label>'.(' ' x2).
1483: '<label>'.
1484: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="move" />'.
1485: &mt('Move old').'</label>'.
1486: '</td></tr>';
1487: }
1488: }
1489: &recurse_print(\$output,$parent,\%deps,\%display);
1490: $output .= '</table></fieldset>';
1.329 droeschl 1491: }
1.484.2.30 raeburn 1492: $output .= '</div>';
1493: return $output;
1.329 droeschl 1494: }
1495:
1.484.2.7 raeburn 1496: sub recurse_print {
1.484.2.30 raeburn 1497: my ($outputref,$dir,$deps,$display) = @_;
1498: $$outputref .= $display->{$dir}."\n";
1.484.2.7 raeburn 1499: if (ref($deps->{$dir}) eq 'ARRAY') {
1500: foreach my $subdir (@{$deps->{$dir}}) {
1.484.2.30 raeburn 1501: &recurse_print($outputref,$subdir,$deps,$display);
1.484.2.7 raeburn 1502: }
1503: }
1504: }
1505:
1506: sub supp_pasteable {
1507: my ($url) = @_;
1508: if (($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//}) ||
1509: (($url =~ /\.sequence$/) && ($url =~ m{^/uploaded/})) ||
1510: ($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) ||
1511: ($url =~ m{^/adm/$match_domain/$match_username/aboutme}) ||
1.484.2.72.4. (raeburn 1512:): ($url =~ m{^/public/$match_domain/$match_courseid/syllabus}) ||
1513:): ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$})) {
1.484.2.7 raeburn 1514: return 1;
1515: }
1516: return;
1517: }
1518:
1519: sub paste_popup_js {
1.484.2.61 raeburn 1520: my %html_js_lt = &Apache::lonlocal::texthash(
1.484.2.30 raeburn 1521: show => 'Show Options',
1522: hide => 'Hide Options',
1.484.2.61 raeburn 1523: );
1524: my %js_lt = &Apache::lonlocal::texthash(
1.484.2.30 raeburn 1525: none => 'No items selected from clipboard.',
1.484.2.7 raeburn 1526: );
1.484.2.61 raeburn 1527: &html_escape(\%html_js_lt);
1528: &js_escape(\%html_js_lt);
1529: &js_escape(\%js_lt);
1.484.2.7 raeburn 1530: return <<"END";
1531:
1.484.2.30 raeburn 1532: function showPasteOptions(suffix) {
1533: document.getElementById('pasteoptions_'+suffix).style.display='block';
1.484.2.61 raeburn 1534: document.getElementById('pasteoptionstext_'+suffix).innerHTML = ' <a href="javascript:hidePasteOptions(\\''+suffix+'\\');" class="LC_menubuttons_link">$html_js_lt{'hide'}</a>';
1.484.2.7 raeburn 1535: return;
1536: }
1537:
1.484.2.30 raeburn 1538: function hidePasteOptions(suffix) {
1539: document.getElementById('pasteoptions_'+suffix).style.display='none';
1.484.2.61 raeburn 1540: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.484.2.7 raeburn 1541: return;
1542: }
1543:
1.484.2.30 raeburn 1544: function showOptions(caller,suffix) {
1545: if (document.getElementById('pasteoptionstext_'+suffix)) {
1546: if (caller.checked) {
1.484.2.61 raeburn 1547: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.484.2.30 raeburn 1548: } else {
1549: document.getElementById('pasteoptionstext_'+suffix).innerHTML ='';
1550: }
1551: if (document.getElementById('pasteoptions_'+suffix)) {
1552: document.getElementById('pasteoptions_'+suffix).style.display='none';
1553: }
1554: }
1555: return;
1556: }
1.484.2.7 raeburn 1557:
1.484.2.30 raeburn 1558: function validateClipboard() {
1559: var numchk = 0;
1560: if (document.pasteform.pasting.length > 1) {
1561: for (var i=0; i<document.pasteform.pasting.length; i++) {
1562: if (document.pasteform.pasting[i].checked) {
1563: numchk ++;
1564: }
1565: }
1566: } else {
1567: if (document.pasteform.pasting.type == 'checkbox') {
1568: if (document.pasteform.pasting.checked) {
1569: numchk ++;
1570: }
1571: }
1572: }
1573: if (numchk > 0) {
1574: return true;
1575: } else {
1.484.2.61 raeburn 1576: alert("$js_lt{'none'}");
1.484.2.30 raeburn 1577: return false;
1578: }
1.484.2.7 raeburn 1579: }
1580:
1.484.2.47 raeburn 1581: function checkClipboard() {
1582: if (document.pasteform.pasting.length > 1) {
1583: for (var i=0; i<document.pasteform.pasting.length; i++) {
1584: document.pasteform.pasting[i].checked = true;
1585: }
1586: }
1587: return;
1588: }
1589:
1590: function uncheckClipboard() {
1591: if (document.pasteform.pasting.length >1) {
1592: for (var i=0; i<document.pasteform.pasting.length; i++) {
1593: document.pasteform.pasting[i].checked = false;
1594: }
1595: }
1596: return;
1597: }
1598:
1.484.2.30 raeburn 1599: END
1600:
1601: }
1.484.2.7 raeburn 1602:
1.329 droeschl 1603: sub do_paste_from_buffer {
1.484.2.7 raeburn 1604: my ($coursenum,$coursedom,$folder,$container,$errors) = @_;
1.329 droeschl 1605:
1.484.2.30 raeburn 1606: # Array of items in paste buffer
1607: my (@currpaste,%pastebuffer,%allerrors);
1608: @currpaste = split(/,/,$env{'docs.markedcopies'});
1609:
1.484.2.7 raeburn 1610: # Early out if paste buffer is empty
1.484.2.30 raeburn 1611: if (@currpaste == 0) {
1.484.2.7 raeburn 1612: return ();
1.484.2.30 raeburn 1613: }
1614: map { $pastebuffer{$_} = 1; } @currpaste;
1615:
1616: # Array of items selected items to paste
1617: my @reqpaste = &Apache::loncommon::get_env_multiple('form.pasting');
1618:
1619: # Early out if nothing selected to paste
1620: if (@reqpaste == 0) {
1621: return();
1622: }
1623: my @topaste;
1624: foreach my $suffix (@reqpaste) {
1625: next if ($suffix =~ /\D/);
1626: next unless (exists($pastebuffer{$suffix}));
1627: push(@topaste,$suffix);
1.484.2.7 raeburn 1628: }
1629:
1.484.2.30 raeburn 1630: # Early out if nothing available to paste
1631: if (@topaste == 0) {
1632: return();
1.329 droeschl 1633: }
1634:
1.484.2.72.4. (raeburn 1635:): my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%notindom,%duplicate,
1.484.2.41 raeburn 1636: %prefixchg,%srcdom,%srcnum,%marktomove,$save_err,$lockerrors,$allresult);
1.484.2.7 raeburn 1637:
1.484.2.30 raeburn 1638: foreach my $suffix (@topaste) {
1639: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1.484.2.72.4. (raeburn 1640:): my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.484.2.30 raeburn 1641: # Supplemental content may only include certain types of content
1642: # Early out if pasted content is not supported in Supplemental area
1643: if ($folder =~ /^supplemental/) {
1644: unless (&supp_pasteable($url)) {
1645: $notinsupp{$suffix} = 1;
1646: next;
1647: }
1648: }
1649: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/}) {
1650: my $srcd = $1;
1651: my $srcn = $2;
1.484.2.7 raeburn 1652: # When paste buffer was populated using an active role in a different course
1.484.2.30 raeburn 1653: # check for mdc privilege in the course from which the resource was pasted
1654: if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1655: unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1656: $notincrs{$suffix} = 1;
1657: next;
1658: }
1.329 droeschl 1659: }
1.484.2.30 raeburn 1660: $srcdom{$suffix} = $srcd;
1661: $srcnum{$suffix} = $srcn;
1.484.2.72.4. (raeburn 1662:): } elsif (($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg)$}) ||
1663:): ($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.4. (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.4. (raeburn 1731:): notindom => 'Paste failed: Item is an external tool from a course in a different domain.',
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.4. (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.4. (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.4. (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.4. (raeburn 1840:): if ($url=~ m{/(bulletinboard|smppg|ext\.tool)$}) {
1.484.2.30 raeburn 1841: my $prefix = $1;
1.484.2.72.4. (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.4. (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 {
1864: if ($prefix eq 'smppg') {
1865: $msg = &mt('Paste failed: An error occurred when copying the simple page.').' '.$errtext;
1866: } elsif ($prefix eq 'bulletinboard') {
1.484.2.42 raeburn 1867: $msg = &mt('Paste failed: An error occurred when copying the discussion board.').' '.$errtext;
1.484.2.72.4. (raeburn 1868:): } elsif ($prefix eq 'ext.tool') {
1869:): $msg = &mt('Paste failed: An error occurred when copying the external tool.').' '.$errtext;
1.484.2.30 raeburn 1870: }
1871: $results{$suffix} = $result;
1872: $msgerrs{$suffix} = $msg;
1873: $lockerrs{$suffix} = $lockerr{$prefix};
1874: next;
1875: }
1876: if ($lockerr{$prefix}) {
1877: $lockerrs{$suffix} = $lockerr{$prefix};
1.484.2.26 raeburn 1878: }
1.484.2.7 raeburn 1879: }
1.484.2.30 raeburn 1880: }
1881: $title = &LONCAPA::map::qtunescape($title);
1882: my $ext='false';
1883: if ($url=~m{^http(|s)://}) { $ext='true'; }
1884: if ($env{'docs.markedcopy_supplemental_'.$suffix}) {
1885: if ($folder !~ /^supplemental/) {
1886: (undef,undef,$title) =
1887: &Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental_'.$suffix});
1888: }
1889: } else {
1890: if ($folder=~/^supplemental/) {
1891: $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
1892: $env{'user.domain'}.'___&&&___'.$title;
1.484.2.26 raeburn 1893: }
1894: }
1.484.2.7 raeburn 1895:
1896: # For uploaded files (excluding pages/sequences) path in copied file is changed
1897: # if paste is from Main to Supplemental (or vice versa), or if pasting between
1898: # courses.
1899:
1.484.2.30 raeburn 1900: unless ($is_map{$suffix}) {
1901: my $newidx;
1.329 droeschl 1902: # Now insert the URL at the bottom
1.484.2.30 raeburn 1903: $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
1904: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(.+)$}) {
1905: my $relpath = $1;
1906: if ($relpath ne '') {
1907: my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$});
1908: my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/);
1909: my $newprefix = $newloc;
1910: if ($newloc eq 'default') {
1911: $newprefix = 'docs';
1912: }
1913: if ($newdocsdir eq '') {
1914: $newdocsdir = 'default';
1915: }
1916: if (($prefixchg{$suffix}) ||
1917: ($srcdom{$suffix} ne $coursedom) ||
1918: ($srcnum{$suffix} ne $coursenum) ||
1919: ($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) {
1920: my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";
1921: $url =
1922: &Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath,
1923: &Apache::lonnet::getfile($oldurl));
1924: if ($url eq '/adm/notfound.html') {
1925: $msgs{$suffix} = &mt('Paste failed: an error occurred saving the file.');
1926: next;
1927: } else {
1928: my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$});
1929: $newsubpath =~ s{/+$}{/};
1930: $docmoves{$oldurl} = $newsubpath;
1931: }
1.484.2.7 raeburn 1932: }
1933: }
1934: }
1.484.2.30 raeburn 1935: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
1936: ':'.$ext.':normal:res';
1937: push(@LONCAPA::map::order,$newidx);
1938: # Store the result
1939: my ($errtext,$fatal) =
1940: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1941: if ($fatal) {
1942: $save_err .= $errtext;
1943: $allresult = 'fail';
1.484.2.7 raeburn 1944: }
1.329 droeschl 1945: }
1.484.2.30 raeburn 1946:
1947: # Apply any changes to maps, or copy dependencies for uploaded HTML pages
1948: unless ($allresult eq 'fail') {
1949: my %updated = (
1950: rewrites => \%rewrites,
1951: zombies => \%zombies,
1952: removefrommap => \%removefrommap,
1953: removeparam => \%removeparam,
1954: dbcopies => \%dbcopies,
1955: retitles => \%retitles,
1956: );
1957: my %info = (
1958: newsubdir => \%newsubdir,
1959: params => \%params,
1960: );
1961: if ($prefixchg{$suffix}) {
1962: $info{'before'} = $before{$prefixchg{$suffix}};
1963: $info{'after'} = $after{$prefixchg{$suffix}};
1964: }
1965: my %moves = (
1966: copies => \%copies,
1967: docmoves => \%docmoves,
1968: mapmoves => \%mapmoves,
1969: );
1970: (my $result,$msgs{$suffix},my $lockerror) =
1971: &apply_fixups($folder,$is_map{$suffix},$coursedom,$coursenum,$errors,
1972: \%updated,\%info,\%moves,$prefixchg{$suffix},$oldurl,
1973: $url,'paste');
1974: $lockerrors .= $lockerror;
1975: if ($result eq 'ok') {
1976: if ($is_map{$suffix}) {
1977: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1978: $folder.'.'.$container);
1979: if ($fatal) {
1980: $allresult = 'failread';
1981: } else {
1982: if ($#LONCAPA::map::order<1) {
1983: my $idx=&LONCAPA::map::getresidx();
1984: if ($idx<=0) { $idx=1; }
1985: $LONCAPA::map::order[0]=$idx;
1986: $LONCAPA::map::resources[$idx]='';
1987: }
1988: my $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
1989: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
1990: ':'.$ext.':normal:res';
1991: push(@LONCAPA::map::order,$newidx);
1.484.2.7 raeburn 1992:
1993: # Store the result
1.484.2.30 raeburn 1994: my ($errtext,$fatal) =
1995: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1996: if ($fatal) {
1997: $save_err .= $errtext;
1998: $allresult = 'failstore';
1999: }
2000: }
2001: }
2002: if ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
2003: push(@toclear,$suffix);
2004: }
2005: }
1.329 droeschl 2006: }
2007: }
1.484.2.30 raeburn 2008: &clear_from_buffer(\@toclear,\@currpaste);
2009: my $msgsarray;
2010: foreach my $suffix (keys(%msgs)) {
2011: if (ref($msgs{$suffix}) eq 'ARRAY') {
2012: $msgsarray .= join(',',@{$msgs{$suffix}});
2013: }
2014: }
2015: return ($allresult,$save_err,$msgsarray,$lockerrors);
2016: }
2017:
2018: sub do_buffer_empty {
2019: my @currpaste = split(/,/,$env{'docs.markedcopies'});
2020: if (@currpaste == 0) {
2021: return &mt('Clipboard is already empty');
2022: }
2023: my @toclear = &Apache::loncommon::get_env_multiple('form.pasting');
2024: if (@toclear == 0) {
2025: return &mt('Nothing selected to clear from clipboard');
2026: }
2027: my $numdel = &clear_from_buffer(\@toclear,\@currpaste);
2028: if ($numdel) {
2029: return &mt('[quant,_1,item] cleared from clipboard',$numdel);
2030: } else {
2031: return &mt('Clipboard unchanged');
1.484.2.7 raeburn 2032: }
1.484.2.30 raeburn 2033: return;
2034: }
2035:
2036: sub clear_from_buffer {
2037: my ($toclear,$currpaste) = @_;
2038: return unless ((ref($toclear) eq 'ARRAY') && (ref($currpaste) eq 'ARRAY'));
2039: my %pastebuffer;
2040: map { $pastebuffer{$_} = 1; } @{$currpaste};
2041: my $numdel = 0;
2042: foreach my $suffix (@{$toclear}) {
2043: next if ($suffix =~ /\D/);
2044: next unless (exists($pastebuffer{$suffix}));
2045: my $regexp = 'docs.markedcopy_[a-z]+_'.$suffix;
2046: if (&Apache::lonnet::delenv($regexp,1) eq 'ok') {
2047: delete($pastebuffer{$suffix});
2048: $numdel ++;
2049: }
2050: }
2051: my $newbuffer = join(',',sort(keys(%pastebuffer)));
2052: &Apache::lonnet::appenv({'docs.markedcopies' => $newbuffer});
2053: return $numdel;
1.484.2.7 raeburn 2054: }
2055:
2056: sub get_newmap_url {
2057: my ($url,$folder,$prefixchg,$coursedom,$coursenum,$srcdom,$srcnum,
2058: $titleref,$allmaps,$newurls) = @_;
2059: my $newurl;
2060: if ($url=~ m{^/uploaded/}) {
2061: $$titleref=&mt('Copy of').' '.$$titleref;
2062: }
2063: my $now = time;
2064: my $suffix=$$.int(rand(100)).$now;
2065: my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
2066: if ($oldid =~ m{^(/uploaded/$match_domain/$match_courseid/)(\D+)(\d+)$}) {
2067: my $path = $1;
2068: my $prefix = $2;
2069: my $ancestor = $3;
2070: if (length($ancestor) > 10) {
2071: $ancestor = substr($ancestor,-10,10);
2072: }
2073: my $newid;
2074: if ($prefixchg) {
2075: if ($folder =~ /^supplemental/) {
2076: $prefix =~ s/^default/supplemental/;
2077: } else {
2078: $prefix =~ s/^supplemental/default/;
2079: }
2080: }
2081: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
2082: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
2083: } else {
2084: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$now.'.'.$ext;
2085: }
2086: my $counter = 0;
2087: my $is_unique = &uniqueness_check($newurl);
2088: if ($folder =~ /^default/) {
2089: if ($allmaps->{$newurl}) {
2090: $is_unique = 0;
2091: }
2092: }
2093: while ((!$is_unique || $allmaps->{$newurl} || $newurls->{$newurl}) && ($counter < 100)) {
2094: $counter ++;
2095: $suffix ++;
2096: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
2097: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
2098: } else {
2099: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$ancestor.$suffix.'.'.$ext;
2100: }
2101: $is_unique = &uniqueness_check($newurl);
2102: }
2103: if ($is_unique) {
2104: $newurls->{$newurl} = 1;
2105: } else {
2106: if ($url=~/\.page$/) {
2107: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the composite page'));
2108: } else {
2109: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the folder'));
2110: }
2111: }
2112: }
2113: return ($newurl);
2114: }
2115:
2116: sub dbcopy {
1.484.2.26 raeburn 2117: my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_;
2118: my ($url,$result,$errtext);
2119: if (ref($dbref) eq 'HASH') {
1.484.2.71 raeburn 2120: $url = $dbref->{'src'};
1.484.2.72.4. (raeburn 2121:): if ($url =~ m{/(smppg|bulletinboard|ext\.tool)$}) {
1.484.2.26 raeburn 2122: my $prefix = $1;
1.484.2.72.4. (raeburn 2123:): if ($prefix eq 'ext.tool') {
2124:): $prefix = 'exttool';
2125:): }
1.484.2.26 raeburn 2126: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2127: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2128: my $db_name;
2129: my $marker = (split(m{/},$url))[4];
2130: $marker=~s/\D//g;
2131: if ($dbref->{'src'} =~ m{/smppg$}) {
2132: $db_name =
2133: &Apache::lonsimplepage::get_db_name($url,$marker,
2134: $dbref->{'cdom'},
2135: $dbref->{'cnum'});
1.484.2.72.4. (raeburn 2136:): } elsif ($dbref->{'src'} =~ m{/ext\.tool$}) {
2137:): $db_name = 'exttool_'.$marker;
1.484.2.26 raeburn 2138: } else {
2139: $db_name = 'bulletinpage_'.$marker;
2140: }
2141: my ($suffix,$freedlock,$error) =
2142: &Apache::lonnet::get_timebased_id($prefix,'num','templated',
2143: $coursedom,$coursenum,
2144: 'concat');
2145: if (!$suffix) {
2146: if ($prefix eq 'smppg') {
2147: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);
1.484.2.72.4. (raeburn 2148:): } elsif ($prefix eq 'exttool') {
2149:): $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying an external tool [_1].',$url);
1.484.2.26 raeburn 2150: } else {
1.484.2.42 raeburn 2151: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url);
1.484.2.26 raeburn 2152: }
2153: if ($error) {
2154: $errtext .= '<br />'.$error;
2155: }
2156: } else {
2157: #need to copy the db contents to a new one.
2158: my %contents=&Apache::lonnet::dump($db_name,
2159: $dbref->{'cdom'},
2160: $dbref->{'cnum'});
2161: if (exists($contents{'uploaded.photourl'})) {
2162: my $photo = $contents{'uploaded.photourl'};
2163: my ($subdir,$fname) =
2164: ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});
2165: my $newphoto;
2166: if ($fname ne '') {
2167: my $content = &Apache::lonnet::getfile($photo);
2168: unless ($content eq '-1') {
2169: $env{'form.'.$suffix.'.photourl'} = $content;
2170: $newphoto =
2171: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");
2172: delete($env{'form.'.$suffix.'.photourl'});
2173: }
2174: }
2175: if ($newphoto =~ m{^/uploaded/}) {
2176: $contents{'uploaded.photourl'} = $newphoto;
2177: }
2178: }
2179: $db_name =~ s{_\d*$ }{_$suffix}x;
2180: $result=&Apache::lonnet::put($db_name,\%contents,
2181: $coursedom,$coursenum);
2182: if ($result eq 'ok') {
1.484.2.72.4. (raeburn 2183:): $url =~ s{/(\d*)/(smppg|bulletinboard|ext\.tool)$}{/$suffix/$2}x;
1.484.2.26 raeburn 2184: }
2185: }
2186: if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) {
2187: $lockerrorsref->{$prefix} =
2188: '<div class="LC_error">'.
2189: &mt('There was a problem removing a lockfile.');
2190: if ($prefix eq 'smppg') {
2191: $lockerrorsref->{$prefix} .=
1.484.2.38 raeburn 2192: ' '.&mt('This will prevent creation of additional simple pages in this course.');
1.484.2.72.4. (raeburn 2193:): } elsif ($prefix eq 'exttool') {
2194:): $lockerrorsref->{$prefix} .=
2195:): ' '.&mt('This will prevent addition of more external tools to this course.');
1.484.2.26 raeburn 2196: } else {
1.484.2.42 raeburn 2197: $lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional discussion boards in this course.');
1.484.2.26 raeburn 2198: }
1.484.2.38 raeburn 2199: $lockerrorsref->{$prefix} .= ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
2200: '<a href="/adm/helpdesk" target="_helpdesk">','</a>').
2201: '</div>';
1.484.2.26 raeburn 2202: }
2203: }
2204: } elsif ($url =~ m{/syllabus$}) {
2205: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2206: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2207: if (($dbref->{'cdom'} ne $coursedom) ||
2208: ($dbref->{'cnum'} ne $coursenum)) {
2209: my %contents=&Apache::lonnet::dump('syllabus',
2210: $dbref->{'cdom'},
2211: $dbref->{'cnum'});
2212: $result=&Apache::lonnet::put('syllabus',\%contents,
2213: $coursedom,$coursenum);
2214: }
2215: }
1.484.2.7 raeburn 2216: }
2217: }
1.484.2.26 raeburn 2218: return ($url,$result,$errtext);
1.329 droeschl 2219: }
2220:
2221: sub uniqueness_check {
2222: my ($newurl) = @_;
2223: my $unique = 1;
2224: foreach my $res (@LONCAPA::map::order) {
2225: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2226: $url=&LONCAPA::map::qtescape($url);
2227: if ($newurl eq $url) {
2228: $unique = 0;
1.344 bisitz 2229: last;
1.329 droeschl 2230: }
2231: }
2232: return $unique;
2233: }
2234:
1.484.2.7 raeburn 2235: sub contained_map_check {
1.484.2.72.4. (raeburn 2236:): my ($url,$folder,$coursenum,$coursedom,$removefrommap,$removeparam,$addedmaps,
2237:): $hierarchy,$titles,$allmaps) = @_;
1.484.2.7 raeburn 2238: my $content = &Apache::lonnet::getfile($url);
2239: unless ($content eq '-1') {
2240: my $parser = HTML::TokeParser->new(\$content);
2241: $parser->attr_encoded(1);
2242: while (my $token = $parser->get_token) {
2243: next if ($token->[0] ne 'S');
2244: if ($token->[1] eq 'resource') {
2245: next if ($token->[2]->{'type'} eq 'zombie');
2246: my $ressrc = $token->[2]->{'src'};
2247: if ($folder =~ /^supplemental/) {
2248: unless (&supp_pasteable($ressrc)) {
2249: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2250: next;
2251: }
2252: }
2253: if ($ressrc =~ m{^/(res|uploaded)/.+\.(sequence|page)$}) {
2254: if ($1 eq 'uploaded') {
2255: $hierarchy->{$url}{$token->[2]->{'id'}} = $ressrc;
2256: $titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'};
2257: } else {
2258: if ($allmaps->{$ressrc}) {
1.484.2.23 raeburn 2259: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.484.2.7 raeburn 2260: } elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') {
2261: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2262: } else {
2263: $addedmaps->{$ressrc} = [$url];
2264: }
2265: }
1.484.2.72.4. (raeburn 2266:): &contained_map_check($ressrc,$folder,$coursenum,$coursedom,
2267:): $removefrommap,$removeparam,
1.484.2.7 raeburn 2268: $addedmaps,$hierarchy,$titles,$allmaps);
2269: }
2270: } elsif ($token->[1] eq 'param') {
2271: if ($folder =~ /^supplemental/) {
2272: if (ref($removeparam->{$url}{$token->[2]->{'to'}}) eq 'ARRAY') {
2273: push(@{$removeparam->{$url}{$token->[2]->{'to'}}},$token->[2]->{'name'});
2274: } else {
1.484.2.19 raeburn 2275: $removeparam->{$url}{$token->[2]->{'to'}} = [$token->[2]->{'name'}];
1.484.2.7 raeburn 2276: }
2277: }
2278: }
2279: }
2280: }
2281: return;
2282: }
2283:
2284: sub url_paste_fixups {
1.484.2.26 raeburn 2285: my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$fromcdom,$fromcnum,$allmaps,
2286: $rewrites,$retitles,$copies,$dbcopies,$zombies,$params,$mapmoves,
2287: $mapchanges,$tomove,$newsubdir,$newurls) = @_;
1.484.2.7 raeburn 2288: my $checktitle;
2289: if (($prefixchg) &&
2290: ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) {
2291: $checktitle = 1;
2292: }
2293: my $skip;
2294: if ($oldurl =~ m{^\Q/uploaded/$cdom/$cnum/\E(default|supplemental)(_?\d*)\.(?:page|sequence)$}) {
2295: my $mapid = $1.$2;
2296: if ($tomove->{$mapid}) {
2297: $skip = 1;
2298: }
2299: }
2300: my $file = &Apache::lonnet::getfile($oldurl);
2301: return if ($file eq '-1');
2302: my $parser = HTML::TokeParser->new(\$file);
2303: $parser->attr_encoded(1);
2304: my $changed = 0;
2305: while (my $token = $parser->get_token) {
2306: next if ($token->[0] ne 'S');
2307: if ($token->[1] eq 'resource') {
2308: my $ressrc = $token->[2]->{'src'};
2309: next if ($ressrc eq '');
2310: my $id = $token->[2]->{'id'};
2311: my $title = $token->[2]->{'title'};
2312: if ($checktitle) {
2313: if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1.484.2.25 raeburn 2314: $retitles->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2315: }
2316: }
2317: next if ($token->[2]->{'type'} eq 'external');
2318: if ($token->[2]->{'type'} eq 'zombie') {
1.484.2.30 raeburn 2319: next if ($skip);
1.484.2.25 raeburn 2320: $zombies->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2321: $changed = 1;
2322: } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
2323: my $srcdom = $1;
2324: my $srcnum = $2;
2325: my $rem = $3;
2326: my $newurl;
2327: my $mapname;
2328: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
2329: my $prefix = $1;
2330: $mapname = $prefix.$2;
2331: if ($tomove->{$mapname}) {
1.484.2.26 raeburn 2332: &url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,
2333: $srcdom,$srcnum,$allmaps,$rewrites,
2334: $retitles,$copies,$dbcopies,$zombies,
2335: $params,$mapmoves,$mapchanges,$tomove,
2336: $newsubdir,$newurls);
1.484.2.7 raeburn 2337: next;
2338: } else {
2339: ($newurl,my $error) =
2340: &get_newmap_url($ressrc,$folder,$prefixchg,$cdom,$cnum,
2341: $srcdom,$srcnum,\$title,$allmaps,$newurls);
2342: if ($newurl =~ /(?:default|supplemental)_(\d+)\.(?:sequence|page)$/) {
2343: $newsubdir->{$ressrc} = $1;
2344: }
2345: if ($error) {
2346: next;
2347: }
2348: }
2349: }
2350: if (($srcdom ne $cdom) || ($srcnum ne $cnum) || ($prefixchg) ||
2351: ($mapchanges->{$oldurl}) || (($newurl ne '') && ($newurl ne $oldurl))) {
1.484.2.19 raeburn 2352:
1.484.2.7 raeburn 2353: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
1.484.2.25 raeburn 2354: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2355: $mapchanges->{$ressrc} = 1;
1.484.2.26 raeburn 2356: unless (&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,
2357: $cnum,$srcdom,$srcnum,$allmaps,
2358: $rewrites,$retitles,$copies,$dbcopies,
2359: $zombies,$params,$mapmoves,$mapchanges,
2360: $tomove,$newsubdir,$newurls)) {
1.484.2.7 raeburn 2361: $mapmoves->{$ressrc} = 1;
2362: }
2363: $changed = 1;
2364: } else {
1.484.2.25 raeburn 2365: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2366: $copies->{$oldurl}{$ressrc} = $id;
2367: $changed = 1;
2368: }
2369: }
1.484.2.26 raeburn 2370: } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/.+$}) {
1.484.2.30 raeburn 2371: next if ($skip);
1.484.2.7 raeburn 2372: my $srcdom = $1;
2373: my $srcnum = $2;
2374: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.484.2.25 raeburn 2375: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.26 raeburn 2376: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2377: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2378: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
2379: $changed = 1;
2380: }
2381: } elsif ($ressrc =~ m{^/adm/$match_domain/$match_username/\d+/(smppg|bulletinboard)$}) {
2382: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum) ||
2383: ($env{'form.docs.markedcopy_options'} ne 'move')) {
2384: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2385: $dbcopies->{$oldurl}{$id}{'cdom'} = $fromcdom;
2386: $dbcopies->{$oldurl}{$id}{'cnum'} = $fromcnum;
1.484.2.7 raeburn 2387: $changed = 1;
2388: }
2389: } elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) {
2390: next if ($skip);
2391: my $srcdom = $1;
2392: my $srcnum = $2;
2393: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.484.2.26 raeburn 2394: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2395: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2396: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
1.484.2.7 raeburn 2397: $changed = 1;
2398: }
2399: }
2400: } elsif ($token->[1] eq 'param') {
2401: next if ($skip);
1.484.2.19 raeburn 2402: my $to = $token->[2]->{'to'};
1.484.2.7 raeburn 2403: if ($to ne '') {
2404: if (ref($params->{$oldurl}{$to}) eq 'ARRAY') {
2405: push(@{$params->{$oldurl}{$to}},$token->[2]->{'name'});
2406: } else {
2407: @{$params->{$oldurl}{$to}} = ($token->[2]->{'name'});
2408: }
2409: }
2410: }
2411: }
2412: return $changed;
2413: }
2414:
2415: sub apply_fixups {
1.484.2.23 raeburn 2416: my ($folder,$is_map,$cdom,$cnum,$errors,$updated,$info,$moves,$prefixchg,
2417: $oldurl,$url,$caller) = @_;
2418: my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles,
1.484.2.26 raeburn 2419: %params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs,
2420: %lockerrors,$lockmsg);
1.484.2.23 raeburn 2421: if (ref($updated) eq 'HASH') {
2422: if (ref($updated->{'rewrites'}) eq 'HASH') {
2423: %rewrites = %{$updated->{'rewrites'}};
2424: }
2425: if (ref($updated->{'zombies'}) eq 'HASH') {
2426: %zombies = %{$updated->{'zombies'}};
2427: }
2428: if (ref($updated->{'removefrommap'}) eq 'HASH') {
2429: %removefrommap = %{$updated->{'removefrommap'}};
2430: }
2431: if (ref($updated->{'removeparam'}) eq 'HASH') {
2432: %removeparam = %{$updated->{'removeparam'}};
2433: }
2434: if (ref($updated->{'dbcopies'}) eq 'HASH') {
2435: %dbcopies = %{$updated->{'dbcopies'}};
2436: }
2437: if (ref($updated->{'retitles'}) eq 'HASH') {
2438: %retitles = %{$updated->{'retitles'}};
2439: }
2440: }
2441: if (ref($info) eq 'HASH') {
2442: if (ref($info->{'newsubdir'}) eq 'HASH') {
2443: %newsubdir = %{$info->{'newsubdir'}};
2444: }
2445: if (ref($info->{'params'}) eq 'HASH') {
2446: %params = %{$info->{'params'}};
2447: }
2448: if (ref($info->{'before'}) eq 'HASH') {
2449: %before = %{$info->{'before'}};
2450: }
2451: if (ref($info->{'after'}) eq 'HASH') {
2452: %after = %{$info->{'after'}};
2453: }
2454: }
2455: if (ref($moves) eq 'HASH') {
2456: if (ref($moves->{'copies'}) eq 'HASH') {
2457: %copies = %{$moves->{'copies'}};
2458: }
2459: if (ref($moves->{'docmoves'}) eq 'HASH') {
2460: %docmoves = %{$moves->{'docmoves'}};
2461: }
2462: if (ref($moves->{'mapmoves'}) eq 'HASH') {
2463: %mapmoves = %{$moves->{'mapmoves'}};
2464: }
2465: }
2466: foreach my $key (keys(%copies),keys(%docmoves)) {
1.484.2.7 raeburn 2467: my @allcopies;
1.484.2.23 raeburn 2468: if (exists($copies{$key})) {
2469: if (ref($copies{$key}) eq 'HASH') {
2470: my %added;
2471: foreach my $innerkey (keys(%{$copies{$key}})) {
2472: if (($innerkey ne '') && (!$added{$innerkey})) {
2473: push(@allcopies,$innerkey);
2474: $added{$innerkey} = 1;
2475: }
1.484.2.7 raeburn 2476: }
1.484.2.23 raeburn 2477: undef(%added);
1.484.2.7 raeburn 2478: }
2479: }
2480: if ($key eq $oldurl) {
1.484.2.23 raeburn 2481: if ((exists($docmoves{$key}))) {
1.484.2.25 raeburn 2482: unless (grep(/^\Q$oldurl\E$/,@allcopies)) {
1.484.2.7 raeburn 2483: push(@allcopies,$oldurl);
2484: }
2485: }
2486: }
2487: if (@allcopies > 0) {
2488: foreach my $item (@allcopies) {
1.484.2.19 raeburn 2489: my ($relpath,$oldsubdir,$fname) =
1.484.2.7 raeburn 2490: ($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(default|\d+)/.*/)([^/]+)$});
2491: if ($fname ne '') {
2492: my $content = &Apache::lonnet::getfile($item);
2493: unless ($content eq '-1') {
2494: my $storefn;
1.484.2.23 raeburn 2495: if (($key eq $oldurl) && (exists($docmoves{$key}))) {
2496: $storefn = $docmoves{$key};
1.484.2.7 raeburn 2497: } else {
2498: $storefn = $relpath;
2499: $storefn =~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 2500: if ($prefixchg && $before{'doc'} && $after{'doc'}) {
2501: $storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/;
1.484.2.7 raeburn 2502: }
1.484.2.23 raeburn 2503: if ($newsubdir{$key}) {
1.484.2.25 raeburn 2504: $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}/#;
1.484.2.7 raeburn 2505: }
2506: }
2507: ©_dependencies($item,$storefn,$relpath,$errors,\$content);
1.484.2.19 raeburn 2508: my $copyurl =
1.484.2.7 raeburn 2509: &Apache::lonclonecourse::writefile($env{'request.course.id'},
2510: $storefn.$fname,$content);
2511: if ($copyurl eq '/adm/notfound.html') {
1.484.2.23 raeburn 2512: if (exists($docmoves{$oldurl})) {
1.484.2.7 raeburn 2513: return &mt('Paste failed: an error occurred copying the file.');
2514: } elsif (ref($errors) eq 'HASH') {
2515: $errors->{$item} = 1;
2516: }
2517: }
2518: }
2519: }
2520: }
2521: }
2522: }
1.484.2.23 raeburn 2523: foreach my $key (keys(%mapmoves)) {
1.484.2.7 raeburn 2524: my $storefn=$key;
2525: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 2526: if ($prefixchg && $before{'map'} && $after{'map'}) {
2527: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.484.2.7 raeburn 2528: }
1.484.2.23 raeburn 2529: if ($newsubdir{$key}) {
2530: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.484.2.7 raeburn 2531: }
2532: my $mapcontent = &Apache::lonnet::getfile($key);
2533: if ($mapcontent eq '-1') {
2534: if (ref($errors) eq 'HASH') {
2535: $errors->{$key} = 1;
2536: }
2537: } else {
2538: my $newmap =
2539: &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
2540: $mapcontent);
2541: if ($newmap eq '/adm/notfound.html') {
2542: if (ref($errors) eq 'HASH') {
2543: $errors->{$key} = 1;
2544: }
2545: }
2546: }
2547: }
2548: my %updates;
2549: if ($is_map) {
1.484.2.23 raeburn 2550: if (ref($updated) eq 'HASH') {
2551: foreach my $type (keys(%{$updated})) {
2552: if (ref($updated->{$type}) eq 'HASH') {
2553: foreach my $key (keys(%{$updated->{$type}})) {
2554: $updates{$key} = 1;
2555: }
2556: }
2557: }
1.484.2.7 raeburn 2558: }
2559: foreach my $key (keys(%updates)) {
2560: my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb);
1.484.2.23 raeburn 2561: if (ref($rewrites{$key}) eq 'HASH') {
2562: %torewrite = %{$rewrites{$key}};
1.484.2.7 raeburn 2563: }
1.484.2.23 raeburn 2564: if (ref($retitles{$key}) eq 'HASH') {
2565: %toretitle = %{$retitles{$key}};
1.484.2.7 raeburn 2566: }
1.484.2.23 raeburn 2567: if (ref($removefrommap{$key}) eq 'HASH') {
2568: %toremove = %{$removefrommap{$key}};
1.484.2.7 raeburn 2569: }
1.484.2.23 raeburn 2570: if (ref($removeparam{$key}) eq 'HASH') {
2571: %remparam = %{$removeparam{$key}};
1.484.2.7 raeburn 2572: }
1.484.2.23 raeburn 2573: if (ref($zombies{$key}) eq 'HASH') {
2574: %zombie = %{$zombies{$key}};
1.484.2.7 raeburn 2575: }
1.484.2.23 raeburn 2576: if (ref($dbcopies{$key}) eq 'HASH') {
1.484.2.26 raeburn 2577: foreach my $idx (keys(%{$dbcopies{$key}})) {
2578: if (ref($dbcopies{$key}{$idx}) eq 'HASH') {
2579: my ($newurl,$result,$errtext) =
2580: &dbcopy($dbcopies{$key}{$idx},$cdom,$cnum,\%lockerrors);
2581: if ($result eq 'ok') {
2582: $newdb{$idx} = $newurl;
2583: } elsif (ref($errors) eq 'HASH') {
2584: $errors->{$key} = 1;
2585: }
2586: push(@msgs,$errtext);
2587: }
1.484.2.7 raeburn 2588: }
2589: }
1.484.2.23 raeburn 2590: if (ref($params{$key}) eq 'HASH') {
2591: %currparam = %{$params{$key}};
1.484.2.7 raeburn 2592: }
2593: my ($errtext,$fatal) = &LONCAPA::map::mapread($key);
2594: if ($fatal) {
1.484.2.26 raeburn 2595: return ($errtext);
1.484.2.7 raeburn 2596: }
2597: for (my $i=0; $i<@LONCAPA::map::zombies; $i++) {
2598: if (defined($LONCAPA::map::zombies[$i])) {
2599: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::zombies[$i]);
1.484.2.25 raeburn 2600: if ($zombie{$i} eq $src) {
1.484.2.7 raeburn 2601: undef($LONCAPA::map::zombies[$i]);
2602: }
2603: }
2604: }
1.484.2.23 raeburn 2605: for (my $i=0; $i<@LONCAPA::map::order; $i++) {
2606: my $idx = $LONCAPA::map::order[$i];
2607: if (defined($LONCAPA::map::resources[$idx])) {
1.484.2.7 raeburn 2608: my $changed;
1.484.2.23 raeburn 2609: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]);
1.484.2.30 raeburn 2610: if ((exists($toremove{$idx})) &&
2611: ($toremove{$idx} eq &LONCAPA::map::qtescape($src))) {
1.484.2.7 raeburn 2612: splice(@LONCAPA::map::order,$i,1);
1.484.2.23 raeburn 2613: if (ref($currparam{$idx}) eq 'ARRAY') {
2614: foreach my $name (@{$currparam{$idx}}) {
2615: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
1.484.2.7 raeburn 2616: }
2617: }
2618: next;
2619: }
2620: my $origsrc = $src;
1.484.2.25 raeburn 2621: if ((exists($toretitle{$idx})) && ($toretitle{$idx} eq $src)) {
1.484.2.7 raeburn 2622: if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
2623: $changed = 1;
2624: }
2625: }
1.484.2.25 raeburn 2626: if ((exists($torewrite{$idx})) && ($torewrite{$idx} eq $src)) {
1.484.2.7 raeburn 2627: $src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
2628: if ($origsrc =~ m{^/uploaded/}) {
1.484.2.23 raeburn 2629: if ($prefixchg && $before{'map'} && $after{'map'}) {
1.484.2.7 raeburn 2630: if ($src =~ /\.(page|sequence)$/) {
1.484.2.23 raeburn 2631: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'map'}\E#$1$after{'map'}#;
1.484.2.7 raeburn 2632: } else {
1.484.2.23 raeburn 2633: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
1.484.2.7 raeburn 2634: }
2635: }
1.484.2.25 raeburn 2636: if ($origsrc =~ /\.(page|sequence)$/) {
2637: if ($newsubdir{$origsrc}) {
1.484.2.23 raeburn 2638: $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir{$origsrc}#;
1.484.2.7 raeburn 2639: }
1.484.2.25 raeburn 2640: } elsif ($newsubdir{$key}) {
2641: $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$key}#;
1.484.2.7 raeburn 2642: }
2643: }
2644: $changed = 1;
1.484.2.26 raeburn 2645: } elsif ($newdb{$idx} ne '') {
2646: $src = $newdb{$idx};
1.484.2.7 raeburn 2647: $changed = 1;
2648: }
2649: if ($changed) {
1.484.2.30 raeburn 2650: $LONCAPA::map::resources[$idx] = join(':',($title,&LONCAPA::map::qtunescape($src),$ext,$type));
1.484.2.7 raeburn 2651: }
2652: }
2653: }
2654: foreach my $idx (keys(%remparam)) {
2655: if (ref($remparam{$idx}) eq 'ARRAY') {
1.484.2.19 raeburn 2656: foreach my $name (@{$remparam{$idx}}) {
1.484.2.7 raeburn 2657: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
2658: }
2659: }
2660: }
1.484.2.26 raeburn 2661: if (values(%lockerrors) > 0) {
2662: $lockmsg = join('<br />',values(%lockerrors));
2663: }
1.484.2.7 raeburn 2664: my $storefn;
2665: if ($key eq $oldurl) {
2666: $storefn = $url;
2667: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
2668: } else {
2669: $storefn = $key;
2670: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 2671: if ($prefixchg && $before{'map'} && $after{'map'}) {
2672: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.484.2.7 raeburn 2673: }
1.484.2.23 raeburn 2674: if ($newsubdir{$key}) {
2675: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.484.2.7 raeburn 2676: }
2677: }
2678: my $report;
2679: if ($folder !~ /^supplemental/) {
2680: $report = 1;
2681: }
1.484.2.20 raeburn 2682: (my $outtext,$errtext) =
1.484.2.7 raeburn 2683: &LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report);
2684: if ($errtext) {
1.484.2.23 raeburn 2685: if ($caller eq 'paste') {
1.484.2.26 raeburn 2686: return (&mt('Paste failed: an error occurred saving the folder or page.'));
1.484.2.23 raeburn 2687: }
1.484.2.7 raeburn 2688: }
2689: }
2690: }
1.484.2.26 raeburn 2691: return ('ok',\@msgs,$lockmsg);
1.484.2.7 raeburn 2692: }
2693:
2694: sub copy_dependencies {
2695: my ($item,$storefn,$relpath,$errors,$contentref) = @_;
2696: my $content;
2697: if (ref($contentref)) {
2698: $content = $$contentref;
2699: } else {
2700: $content = &Apache::lonnet::getfile($item);
2701: }
2702: unless ($content eq '-1') {
2703: my $mm = new File::MMagic;
2704: my $mimetype = $mm->checktype_contents($content);
2705: if ($mimetype eq 'text/html') {
2706: my (%allfiles,%codebase,$state);
2707: my $res = &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,\$content);
2708: if ($res eq 'ok') {
2709: my ($numexisting,$numpathchanges,$existing);
2710: (undef,$numexisting,$numpathchanges,$existing) =
2711: &Apache::loncommon::ask_for_embedded_content(
2712: '/adm/coursedocs',$state,\%allfiles,\%codebase,
2713: {'error_on_invalid_names' => 1,
2714: 'ignore_remote_references' => 1,
2715: 'docs_url' => $item,
2716: 'context' => 'paste'});
2717: if ($numexisting > 0) {
2718: if (ref($existing) eq 'HASH') {
2719: foreach my $dep (keys(%{$existing})) {
2720: my $depfile = $dep;
2721: unless ($depfile =~ m{^\Q$relpath\E}) {
2722: $depfile = $relpath.$dep;
2723: }
2724: my $depcontent = &Apache::lonnet::getfile($depfile);
2725: unless ($depcontent eq '-1') {
2726: my $storedep = $dep;
2727: $storedep =~ s{^\Q$relpath\E}{};
2728: my $dep_url =
2729: &Apache::lonclonecourse::writefile(
2730: $env{'request.course.id'},
2731: $storefn.$storedep,$depcontent);
2732: if ($dep_url eq '/adm/notfound.html') {
2733: if (ref($errors) eq 'HASH') {
2734: $errors->{$depfile} = 1;
2735: }
2736: } else {
2737: ©_dependencies($depfile,$storefn,$relpath,$errors,\$depcontent);
2738: }
2739: }
2740: }
2741: }
2742: }
2743: }
2744: }
2745: }
2746: return;
2747: }
2748:
1.329 droeschl 2749: my %parameter_type = ( 'randompick' => 'int_pos',
2750: 'hiddenresource' => 'string_yesno',
2751: 'encrypturl' => 'string_yesno',
2752: 'randomorder' => 'string_yesno',);
2753: my $valid_parameters_re = join('|',keys(%parameter_type));
2754: # set parameters
2755: sub update_parameter {
1.484.2.29 raeburn 2756: if ($env{'form.changeparms'} eq 'all') {
2757: my (@allidx,@allmapidx,%allchecked,%currchecked);
2758: %allchecked = (
2759: 'hiddenresource' => {},
2760: 'encrypturl' => {},
2761: 'randompick' => {},
2762: 'randomorder' => {},
2763: );
2764: foreach my $which (keys(%allchecked)) {
2765: $env{'form.all'.$which} =~ s/,$//;
2766: if ($which eq 'randompick') {
2767: foreach my $item (split(/,/,$env{'form.all'.$which})) {
2768: my ($res,$value) = split(/:/,$item);
2769: if ($value =~ /^\d+$/) {
2770: $allchecked{$which}{$res} = $value;
2771: }
2772: }
2773: } else {
1.484.2.30 raeburn 2774: if ($env{'form.all'.$which}) {
2775: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.all'.$which});
2776: }
1.484.2.29 raeburn 2777: }
2778: }
2779: my $haschanges = 0;
2780: foreach my $res (@LONCAPA::map::order) {
2781: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2782: $name=&LONCAPA::map::qtescape($name);
2783: $url=&LONCAPA::map::qtescape($url);
2784: next unless ($name && $url);
2785: my $is_map;
2786: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
2787: $is_map = 1;
2788: }
2789: foreach my $which (keys(%allchecked)) {
2790: if (($which eq 'randompick' || $which eq 'randomorder')) {
2791: next if (!$is_map);
2792: }
2793: my $oldvalue = 0;
2794: my $newvalue = 0;
2795: if ($allchecked{$which}{$res}) {
2796: $newvalue = $allchecked{$which}{$res};
2797: }
2798: my $current = (&LONCAPA::map::getparameter($res,'parameter_'.$which))[0];
2799: if ($which eq 'randompick') {
2800: if ($current =~ /^(\d+)$/) {
2801: $oldvalue = $1;
2802: }
2803: } else {
2804: if ($current =~ /^yes$/i) {
2805: $oldvalue = 1;
2806: }
2807: }
2808: if ($oldvalue ne $newvalue) {
2809: $haschanges = 1;
2810: if ($newvalue) {
2811: my $storeval = 'yes';
2812: if ($which eq 'randompick') {
2813: $storeval = $newvalue;
2814: }
2815: &LONCAPA::map::storeparameter($res,'parameter_'.$which,
2816: $storeval,
2817: $parameter_type{$which});
2818: &remember_parms($res,$which,'set',$storeval);
2819: } elsif ($oldvalue) {
2820: &LONCAPA::map::delparameter($res,'parameter_'.$which);
2821: &remember_parms($res,$which,'del');
2822: }
2823: }
2824: }
2825: }
2826: return $haschanges;
1.329 droeschl 2827: } else {
1.484.2.59 raeburn 2828: my $haschanges = 0;
2829: return $haschanges if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
1.364 bisitz 2830:
1.484.2.29 raeburn 2831: my $which = $env{'form.changeparms'};
2832: my $idx = $env{'form.setparms'};
1.484.2.59 raeburn 2833: my $oldvalue = 0;
2834: my $newvalue = 0;
2835: my $current = (&LONCAPA::map::getparameter($idx,'parameter_'.$which))[0];
2836: if ($which eq 'randompick') {
2837: if ($current =~ /^(\d+)$/) {
2838: $oldvalue = $1;
2839: }
2840: } elsif ($current =~ /^yes$/i) {
2841: $oldvalue = 1;
2842: }
1.484.2.29 raeburn 2843: if ($env{'form.'.$which.'_'.$idx}) {
1.484.2.59 raeburn 2844: $newvalue = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx}
2845: : 1;
1.484.2.29 raeburn 2846: }
1.484.2.59 raeburn 2847: if ($oldvalue ne $newvalue) {
2848: $haschanges = 1;
2849: if ($newvalue) {
2850: my $storeval = 'yes';
2851: if ($which eq 'randompick') {
2852: $storeval = $newvalue;
2853: }
2854: &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $storeval,
2855: $parameter_type{$which});
2856: &remember_parms($idx,$which,'set',$storeval);
2857: } else {
2858: &LONCAPA::map::delparameter($idx,'parameter_'.$which);
2859: &remember_parms($idx,$which,'del');
2860: }
2861: }
2862: return $haschanges;
1.329 droeschl 2863: }
1.484.2.59 raeburn 2864: return;
1.329 droeschl 2865: }
2866:
2867: sub handle_edit_cmd {
2868: my ($coursenum,$coursedom) =@_;
1.484.2.30 raeburn 2869: if ($env{'form.cmd'} eq '') {
2870: return 0;
2871: }
1.329 droeschl 2872: my ($cmd,$idx)=split('_',$env{'form.cmd'});
2873:
2874: my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
2875: my ($title, $url, @rrest) = split(':', $ratstr);
2876:
1.484.2.30 raeburn 2877: if ($cmd eq 'remove') {
1.329 droeschl 2878: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
1.463 www 2879: ($url!~/$LONCAPA::assess_page_seq_re/)) {
1.329 droeschl 2880: &Apache::lonnet::removeuploadedurl($url);
2881: } else {
2882: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
2883: }
2884: splice(@LONCAPA::map::order, $idx, 1);
2885:
2886: } elsif ($cmd eq 'cut') {
2887: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
2888: splice(@LONCAPA::map::order, $idx, 1);
2889:
1.344 bisitz 2890: } elsif ($cmd eq 'up'
1.329 droeschl 2891: && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
2892: @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
2893:
2894: } elsif ($cmd eq 'down'
2895: && defined($LONCAPA::map::order[$idx+1])) {
2896: @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
2897:
2898: } elsif ($cmd eq 'rename') {
2899: my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
2900: if ($comment=~/\S/) {
2901: $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
2902: $comment.':'.join(':', $url, @rrest);
2903: }
2904: # Devalidate title cache
2905: my $renamed_url=&LONCAPA::map::qtescape($url);
2906: &Apache::lonnet::devalidate_title_cache($renamed_url);
1.484.2.30 raeburn 2907:
1.329 droeschl 2908: } else {
2909: return 0;
2910: }
2911: return 1;
2912: }
2913:
2914: sub editor {
1.458 raeburn 2915: my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
1.484.2.72.4. (raeburn 2916:): $supplementalflag,$orderhash,$iconpath,$pathitem,$ltitoolsref,
2917:): $canedit,$navmapref,$hiddentop)=@_;
1.484.2.19 raeburn 2918: my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
2919: if ($allowed) {
2920: (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
2921: $is_random_order,$container) =
2922: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
2923: $r->print($breadcrumbtrail);
2924: } elsif ($env{'form.folderpath'} =~ /\:1$/) {
2925: $container = 'page';
2926: } else {
2927: $container = 'sequence';
2928: }
1.484 raeburn 2929:
1.484.2.21 raeburn 2930: my $jumpto;
2931:
2932: unless ($supplementalflag) {
1.484.2.32 raeburn 2933: $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
1.484.2.21 raeburn 2934: }
1.484 raeburn 2935:
2936: unless ($allowed) {
2937: $randompick = -1;
2938: }
2939:
1.484.2.67 raeburn 2940: my ($errtext,$fatal);
2941: if (($folder eq '') && (!$supplementalflag)) {
2942: if (@LONCAPA::map::order) {
2943: undef(@LONCAPA::map::order);
2944: undef(@LONCAPA::map::resources);
2945: undef(@LONCAPA::map::resparms);
2946: undef(@LONCAPA::map::zombies);
2947: }
2948: $folder = 'default';
2949: $container = 'sequence';
2950: } else {
2951: ($errtext,$fatal) = &mapread($coursenum,$coursedom,
2952: $folder.'.'.$container);
2953: return $errtext if ($fatal);
2954: }
1.329 droeschl 2955:
2956: if ($#LONCAPA::map::order<1) {
2957: my $idx=&LONCAPA::map::getresidx();
2958: if ($idx<=0) { $idx=1; }
2959: $LONCAPA::map::order[0]=$idx;
2960: $LONCAPA::map::resources[$idx]='';
2961: }
1.364 bisitz 2962:
1.329 droeschl 2963: # ------------------------------------------------------------ Process commands
2964:
2965: # ---------------- if they are for this folder and user allowed to make changes
1.484.2.67 raeburn 2966: if (($allowed && $canedit) && ($env{'form.folder'} eq $folder)) {
1.329 droeschl 2967: # set parameters and change order
2968: &snapshotbefore();
2969:
2970: if (&update_parameter()) {
1.484.2.59 raeburn 2971: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1.329 droeschl 2972: return $errtext if ($fatal);
2973: }
2974:
2975: if ($env{'form.newpos'} && $env{'form.currentpos'}) {
2976: # change order
2977: my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
2978: splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
2979:
2980: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
2981: return $errtext if ($fatal);
2982: }
1.364 bisitz 2983:
1.329 droeschl 2984: if ($env{'form.pastemarked'}) {
1.484.2.7 raeburn 2985: my %paste_errors;
1.484.2.26 raeburn 2986: my ($paste_res,$save_error,$pastemsgarray,$lockerror) =
1.484.2.7 raeburn 2987: &do_paste_from_buffer($coursenum,$coursedom,$folder,$container,
2988: \%paste_errors);
1.484.2.30 raeburn 2989: if (ref($pastemsgarray) eq 'ARRAY') {
2990: if (@{$pastemsgarray} > 0) {
2991: $r->print('<p class="LC_info">'.
2992: join('<br />',@{$pastemsgarray}).
1.484.2.26 raeburn 2993: '</p>');
2994: }
1.484.2.30 raeburn 2995: }
2996: if ($lockerror) {
2997: $r->print('<p class="LC_error">'.
2998: $lockerror.
2999: '</p>');
3000: }
3001: if ($save_error ne '') {
3002: return $save_error;
3003: }
3004: if ($paste_res) {
3005: my %errortext = &Apache::lonlocal::texthash (
3006: fail => 'Storage of folder contents failed',
3007: failread => 'Reading folder contents failed',
3008: failstore => 'Storage of folder contents failed',
3009: );
3010: if ($errortext{$paste_res}) {
3011: $r->print('<p class="LC_error">'.$errortext{$paste_res}.'</p>');
1.484.2.7 raeburn 3012: }
1.329 droeschl 3013: }
1.484.2.7 raeburn 3014: if (keys(%paste_errors) > 0) {
1.484.2.30 raeburn 3015: $r->print('<p class="LC_warning">'."\n".
1.484.2.7 raeburn 3016: &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".
3017: '<ul>'."\n");
3018: foreach my $key (sort(keys(%paste_errors))) {
3019: $r->print('<li>'.$key.'</li>'."\n");
3020: }
3021: $r->print('</ul></p>'."\n");
3022: }
1.484.2.30 raeburn 3023: } elsif ($env{'form.clearmarked'}) {
3024: my $output = &do_buffer_empty();
3025: if ($output) {
3026: $r->print('<p class="LC_info">'.$output.'</p>');
3027: }
3028: }
1.329 droeschl 3029:
3030: $r->print($upload_output);
3031:
1.484.2.30 raeburn 3032: # Rename, cut, copy or remove a single resource
1.484.2.63 raeburn 3033: if (&handle_edit_cmd($coursenum,$coursedom)) {
1.484.2.7 raeburn 3034: my $contentchg;
1.484.2.58 raeburn 3035: if ($env{'form.cmd'} =~ m{^(remove|cut)_}) {
1.484.2.7 raeburn 3036: $contentchg = 1;
3037: }
3038: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);
1.329 droeschl 3039: return $errtext if ($fatal);
3040: }
1.484.2.30 raeburn 3041:
3042: # Cut, copy and/or remove multiple resources
3043: if ($env{'form.multichange'}) {
3044: my %allchecked = (
3045: cut => {},
3046: remove => {},
3047: );
3048: my $needsupdate;
3049: foreach my $which (keys(%allchecked)) {
3050: $env{'form.multi'.$which} =~ s/,$//;
3051: if ($env{'form.multi'.$which}) {
3052: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.multi'.$which});
3053: if (ref($allchecked{$which}) eq 'HASH') {
3054: $needsupdate += scalar(keys(%{$allchecked{$which}}));
3055: }
3056: }
3057: }
3058: if ($needsupdate) {
3059: my $haschanges = 0;
3060: my %curr_groups = &Apache::longroup::coursegroups();
3061: my $total = scalar(@LONCAPA::map::order) - 1;
3062: for (my $i=$total; $i>=0; $i--) {
3063: my $res = $LONCAPA::map::order[$i];
3064: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3065: $name=&LONCAPA::map::qtescape($name);
3066: $url=&LONCAPA::map::qtescape($url);
1.484.2.57 raeburn 3067: next unless $url;
1.484.2.30 raeburn 3068: my %denied =
3069: &action_restrictions($coursenum,$coursedom,$url,
3070: $env{'form.folderpath'},\%curr_groups);
3071: foreach my $which (keys(%allchecked)) {
3072: next if ($denied{$which});
3073: next unless ($allchecked{$which}{$res});
3074: if ($which eq 'remove') {
3075: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
3076: ($url!~/$LONCAPA::assess_page_seq_re/)) {
3077: &Apache::lonnet::removeuploadedurl($url);
3078: } else {
3079: &LONCAPA::map::makezombie($res);
3080: }
3081: splice(@LONCAPA::map::order,$i,1);
3082: $haschanges ++;
3083: } elsif ($which eq 'cut') {
3084: &LONCAPA::map::makezombie($res);
3085: splice(@LONCAPA::map::order,$i,1);
3086: $haschanges ++;
3087: }
3088: }
3089: }
3090: if ($haschanges) {
3091: ($errtext,$fatal) =
3092: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
3093: return $errtext if ($fatal);
3094: }
3095: }
3096: }
3097:
1.329 droeschl 3098: # Group import/search
3099: if ($env{'form.importdetail'}) {
3100: my @imports;
3101: foreach my $item (split(/\&/,$env{'form.importdetail'})) {
3102: if (defined($item)) {
3103: my ($name,$url,$residx)=
1.484.2.26 raeburn 3104: map { &unescape($_); } split(/\=/,$item);
3105: if ($url =~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
1.484.2.30 raeburn 3106: my ($suffix,$errortxt,$locknotfreed) =
1.484.2.26 raeburn 3107: &new_timebased_suffix($coursedom,$coursenum,'map',$1,$2);
1.484.2.15 raeburn 3108: if ($locknotfreed) {
3109: $r->print($locknotfreed);
3110: }
3111: if ($suffix) {
1.484.2.19 raeburn 3112: $url =~ s/_new\./_$suffix./;
1.484.2.15 raeburn 3113: } else {
3114: return $errortxt;
3115: }
1.484.2.26 raeburn 3116: } elsif ($url =~ m{^/adm/$match_domain/$match_username/new/(smppg|bulletinboard)$}) {
3117: my $type = $1;
3118: my ($suffix,$errortxt,$locknotfreed) =
3119: &new_timebased_suffix($coursedom,$coursenum,$type);
3120: if ($locknotfreed) {
3121: $r->print($locknotfreed);
3122: }
3123: if ($suffix) {
3124: $url =~ s{^(/adm/$match_domain/$match_username)/new}{$1/$suffix};
3125: } else {
3126: return $errortxt;
3127: }
1.484.2.72.4. (raeburn 3128:): } elsif ($url =~ m{^/adm/$coursedom/$coursenum/new/ext\.tool}) {
3129:): my ($suffix,$errortxt,$locknotfreed) =
3130:): &new_timebased_suffix($coursedom,$coursenum,'exttool');
3131:): if ($locknotfreed) {
3132:): $r->print($locknotfreed);
3133:): }
3134:): if ($suffix) {
3135:): $url =~ s{^(/adm/$coursedom/$coursenum)/new}{$1/$suffix};
3136:): } else {
3137:): return $errortxt;
3138:): }
1.484.2.27 raeburn 3139: } elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) {
3140: if ($supplementalflag) {
3141: next unless ($1 eq 'supplemental');
3142: if ($folder eq 'supplemental') {
3143: next unless ($2 eq 'default');
3144: } else {
3145: next unless ($folder eq 'supplemental_'.$2);
3146: }
3147: } else {
3148: next unless ($1 eq 'docs');
3149: if ($folder eq 'default') {
3150: next unless ($2 eq 'default');
3151: } else {
3152: next unless ($folder eq 'default_'.$2);
3153: }
3154: }
1.484.2.15 raeburn 3155: }
1.329 droeschl 3156: push(@imports, [$name, $url, $residx]);
3157: }
3158: }
1.484.2.23 raeburn 3159: ($errtext,$fatal,my $fixuperrors) =
3160: &group_import($coursenum, $coursedom, $folder,$container,
1.484.2.72.4. (raeburn 3161:): 'londocs',$ltitoolsref,@imports);
1.329 droeschl 3162: return $errtext if ($fatal);
1.484.2.23 raeburn 3163: if ($fixuperrors) {
3164: $r->print($fixuperrors);
3165: }
1.329 droeschl 3166: }
3167: # Loading a complete map
3168: if ($env{'form.loadmap'}) {
3169: if ($env{'form.importmap'}=~/\w/) {
3170: foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
3171: my ($title,$url,$ext,$type)=split(/\:/,$res);
3172: my $idx=&LONCAPA::map::getresidx($url);
3173: $LONCAPA::map::resources[$idx]=$res;
3174: $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
3175: }
3176: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.484.2.7 raeburn 3177: $folder.'.'.$container,1);
1.329 droeschl 3178: return $errtext if ($fatal);
3179: } else {
3180: $r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
1.364 bisitz 3181:
1.329 droeschl 3182: }
3183: }
3184: &log_differences($plain);
3185: }
3186: # ---------------------------------------------------------------- End commands
3187: # ---------------------------------------------------------------- Print screen
3188: my $idx=0;
3189: my $shown=0;
3190: if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
1.381 bisitz 3191: $r->print('<div class="LC_Box">'.
1.432 raeburn 3192: '<ol class="LC_docs_parameters"><li class="LC_docs_parameters_title">'.&mt('Parameters:').'</li>'.
3193: ($randompick>=0?'<li>'.&mt('randomly pick [quant,_1,resource]',$randompick).'</li>':'').
3194: ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
3195: ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
3196: ($is_random_order?'<li>'.&mt('random order').'</li>':'').
1.431 raeburn 3197: '</ol>');
1.381 bisitz 3198: if ($randompick>=0) {
3199: $r->print('<p class="LC_warning">'
3200: .&mt('Caution: this folder is set to randomly pick a subset'
3201: .' of resources. Adding or removing resources from this'
3202: .' folder will change the set of resources that the'
3203: .' students see, resulting in spurious or missing credit'
3204: .' for completed problems, not limited to ones you'
3205: .' modify. Do not modify the contents of this folder if'
3206: .' it is in active student use.')
3207: .'</p>'
3208: );
3209: }
3210: if ($is_random_order) {
3211: $r->print('<p class="LC_warning">'
3212: .&mt('Caution: this folder is set to randomly order its'
3213: .' contents. Adding or removing resources from this folder'
3214: .' will change the order of resources shown.')
3215: .'</p>'
3216: );
3217: }
3218: $r->print('</div>');
1.364 bisitz 3219: }
1.381 bisitz 3220:
1.484.2.30 raeburn 3221: my ($to_show,$output,@allidx,@allmapidx,%filters,%lists,%curr_groups);
3222: %filters = (
3223: canremove => [],
3224: cancut => [],
3225: cancopy => [],
3226: hiddenresource => [],
3227: encrypturl => [],
3228: randomorder => [],
3229: randompick => [],
3230: );
3231: %curr_groups = &Apache::longroup::coursegroups();
1.424 onken 3232: &Apache::loncommon::start_data_table_count(); #setup a row counter
1.381 bisitz 3233: foreach my $res (@LONCAPA::map::order) {
3234: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3235: $name=&LONCAPA::map::qtescape($name);
3236: $url=&LONCAPA::map::qtescape($url);
3237: unless ($name) { $name=(split(/\//,$url))[-1]; }
3238: unless ($name) { $idx++; next; }
1.484.2.29 raeburn 3239: push(@allidx,$res);
3240: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
3241: push(@allmapidx,$res);
3242: }
1.484.2.67 raeburn 3243:
1.381 bisitz 3244: $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
1.484.2.12 raeburn 3245: $coursenum,$coursedom,$crstype,
1.484.2.30 raeburn 3246: $pathitem,$supplementalflag,$container,
1.484.2.72.4. (raeburn 3247:): \%filters,\%curr_groups,$ltitoolsref,$canedit,
1.484.2.70 raeburn 3248: $isencrypted,$navmapref);
1.381 bisitz 3249: $idx++;
3250: $shown++;
1.329 droeschl 3251: }
1.424 onken 3252: &Apache::loncommon::end_data_table_count();
1.484.2.19 raeburn 3253:
1.484.2.30 raeburn 3254: my $need_save;
1.484.2.67 raeburn 3255: if ($allowed || ($supplementalflag && $folder eq 'supplemental')) {
1.484.2.31 raeburn 3256: my $toolslink;
1.484.2.67 raeburn 3257: if ($allowed) {
1.484.2.31 raeburn 3258: $toolslink = '<table><tr><td>'
1.484.2.19 raeburn 3259: .&Apache::loncommon::help_open_menu('Navigation Screen',
3260: 'Navigation_Screen',undef,'RAT')
3261: .'</td><td class="LC_middle">'.&mt('Tools:').'</td>'
3262: .'<td align="left"><ul id="LC_toolbar">'
1.484.2.21 raeburn 3263: .'<li><a href="/adm/coursedocs?forcesupplement=1&command=editsupp" '
1.484.2.19 raeburn 3264: .'id="LC_content_toolbar_edittoplevel" '
3265: .'class="LC_toolbarItem" '
3266: .'title="'.&mt('Supplemental Content Editor').'">'
3267: .'</a></li></ul></td></tr></table><br />';
1.484.2.31 raeburn 3268: }
1.484.2.19 raeburn 3269: if ($shown) {
3270: if ($allowed) {
3271: $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
3272: .&Apache::loncommon::start_data_table(undef,'contentlist')
3273: .&Apache::loncommon::start_data_table_header_row()
3274: .'<th colspan="2">'.&mt('Move').'</th>'
1.484.2.30 raeburn 3275: .'<th colspan="2">'.&mt('Actions').'</th>'
3276: .'<th>'.&mt('Document').'</th>';
1.484.2.19 raeburn 3277: if ($folder !~ /^supplemental/) {
3278: $to_show .= '<th colspan="4">'.&mt('Settings').'</th>';
3279: }
1.484.2.29 raeburn 3280: $to_show .= &Apache::loncommon::end_data_table_header_row();
3281: if ($folder !~ /^supplemental/) {
1.484.2.30 raeburn 3282: $lists{'canhide'} = join(',',@allidx);
3283: $lists{'canrandomlyorder'} = join(',',@allmapidx);
3284: my @possfilters = ('canremove','cancut','cancopy','hiddenresource','encrypturl',
3285: 'randomorder','randompick');
3286: foreach my $item (@possfilters) {
3287: if (ref($filters{$item}) eq 'ARRAY') {
3288: if (@{$filters{$item}} > 0) {
3289: $lists{$item} = join(',',@{$filters{$item}});
3290: }
3291: }
3292: }
1.484.2.29 raeburn 3293: if (@allidx > 0) {
3294: my $path;
3295: if ($env{'form.folderpath'}) {
3296: $path =
3297: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3298: }
1.484.2.30 raeburn 3299: if (@allidx > 1) {
3300: $to_show .=
3301: &Apache::loncommon::continue_data_table_row().
3302: '<td colspan="2"> </td>'.
3303: '<td>'.
1.484.2.67 raeburn 3304: &multiple_check_form('actions',\%lists,$canedit).
1.484.2.30 raeburn 3305: '</td>'.
3306: '<td> </td>'.
3307: '<td> </td>'.
3308: '<td colspan="4">'.
1.484.2.67 raeburn 3309: &multiple_check_form('settings',\%lists,$canedit).
1.484.2.30 raeburn 3310: '</td>'.
3311: &Apache::loncommon::end_data_table_row();
3312: $need_save = 1;
3313: }
1.484.2.29 raeburn 3314: }
3315: }
3316: $to_show .= $output.' '
1.484.2.19 raeburn 3317: .&Apache::loncommon::end_data_table()
3318: .'<br style="line-height:2px;" />'
3319: .&Apache::loncommon::end_scrollbox();
3320: } else {
3321: $to_show .= $toolslink
3322: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3323: .$output.' '
3324: .&Apache::loncommon::end_data_table();
3325: }
3326: } else {
3327: if (!$allowed) {
3328: $to_show .= $toolslink;
1.393 raeburn 3329: }
1.484.2.67 raeburn 3330: my $noresmsg;
3331: if ($allowed && $hiddentop && !$supplementalflag) {
3332: $noresmsg = &mt('Main Content Hidden');
3333: } else {
3334: $noresmsg = &mt('Currently empty');
3335: }
1.484.2.19 raeburn 3336: $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
3337: .'<div class="LC_info" id="contentlist">'
1.484.2.67 raeburn 3338: .$noresmsg
1.484.2.19 raeburn 3339: .'</div>'
3340: .&Apache::loncommon::end_scrollbox();
1.393 raeburn 3341: }
3342: } else {
1.484.2.19 raeburn 3343: if ($shown) {
3344: $to_show = '<div>'
3345: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3346: .$output
3347: .&Apache::loncommon::end_data_table()
3348: .'</div>';
3349: } else {
3350: $to_show = '<div class="LC_info" id="contentlist">'
1.484.2.34 raeburn 3351: .&mt('Currently empty')
1.484.2.19 raeburn 3352: .'</div>'
3353: }
1.458 raeburn 3354: }
3355: my $tid = 1;
3356: if ($supplementalflag) {
3357: $tid = 2;
1.329 droeschl 3358: }
3359: if ($allowed) {
1.484 raeburn 3360: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
1.484.2.30 raeburn 3361: $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,
1.484.2.67 raeburn 3362: $jumpto,$readfile,$need_save,"$folder.$container",$canedit));
1.484.2.68 raeburn 3363: if ($canedit) {
1.484.2.67 raeburn 3364: &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
3365: }
1.460 raeburn 3366: } else {
3367: $r->print($to_show);
1.329 droeschl 3368: }
3369: return;
3370: }
3371:
1.484.2.30 raeburn 3372: sub multiple_check_form {
1.484.2.67 raeburn 3373: my ($caller,$listsref,$canedit) = @_;
1.484.2.30 raeburn 3374: return unless (ref($listsref) eq 'HASH');
1.484.2.67 raeburn 3375: my $disabled;
3376: unless ($canedit) {
3377: $disabled = 'disabled="disabled"';
3378: }
1.484.2.30 raeburn 3379: my $output =
3380: '<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'.
3381: '<span class="LC_nobreak" style="font-size:x-small;font-weight:bold;">'.
3382: '<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>'.
3383: '<div id="multi'.$caller.'" style="display:none;margin:0;padding:0;border:0">'.
3384: '<form action="/adm/coursedocs" method="post" name="cumulative'.$caller.'">'."\n".
3385: '<fieldset id="allfields'.$caller.'" style="display:none"><legend style="font-size:x-small;">'.&mt('check/uncheck all').'</legend>'."\n";
3386: if ($caller eq 'settings') {
3387: $output .=
3388: '<table><tr>'.
3389: '<td class="LC_docs_entry_parameter">'.
3390: '<span class="LC_nobreak"><label>'.
1.484.2.67 raeburn 3391: '<input type="checkbox" name="hiddenresourceall" id="hiddenresourceall" onclick="propagateState(this.form,'."'hiddenresource'".')"'.$disabled.' />'.&mt('Hidden').
1.484.2.30 raeburn 3392: '</label></span></td>'.
3393: '<td class="LC_docs_entry_parameter">'.
1.484.2.67 raeburn 3394: '<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 3395: '</span></td>'.
3396: '</tr>'."\n".
3397: '<tr>'.
3398: '<td class="LC_docs_entry_parameter">'.
1.484.2.67 raeburn 3399: '<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 3400: '</label></span>'.
3401: '</td></tr></table>'."\n";
3402: } else {
3403: $output .=
3404: '<table><tr>'.
3405: '<td class="LC_docs_entry_parameter">'.
3406: '<span class="LC_nobreak LC_docs_remove">'.
1.484.2.67 raeburn 3407: '<label><input type="checkbox" name="removeall" id="removeall" onclick="propagateState(this.form,'."'remove'".')"'.$disabled.' />'.&mt('Remove').
1.484.2.30 raeburn 3408: '</label></span></td>'.
3409: '<td class="LC_docs_entry_parameter">'.
3410: '<span class="LC_nobreak LC_docs_cut">'.
1.484.2.67 raeburn 3411: '<label><input type="checkbox" name="cut" id="cutall" onclick="propagateState(this.form,'."'cut'".');"'.$disabled.' />'.&mt('Cut').
1.484.2.30 raeburn 3412: '</label></span></td>'."\n".
3413: '<td class="LC_docs_entry_parameter">'.
3414: '<span class="LC_nobreak LC_docs_copy">'.
1.484.2.67 raeburn 3415: '<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')"'.$disabled.' />'.&mt('Copy').
1.484.2.30 raeburn 3416: '</label></span></td>'.
3417: '</tr></table>'."\n";
3418: }
3419: $output .=
3420: '</fieldset>'.
3421: '<input type="hidden" name="allidx" value="'.$listsref->{'canhide'}.'" />';
3422: if ($caller eq 'settings') {
3423: $output .=
3424: '<input type="hidden" name="allmapidx" value="'.$listsref->{'canrandomlyorder'}.'" />'."\n".
3425: '<input type="hidden" name="currhiddenresource" value="'.$listsref->{'hiddenresource'}.'" />'."\n".
3426: '<input type="hidden" name="currencrypturl" value="'.$listsref->{'encrypturl'}.'" />'."\n".
3427: '<input type="hidden" name="currrandomorder" value="'.$listsref->{'randomorder'}.'" />'."\n".
3428: '<input type="hidden" name="currrandompick" value="'.$listsref->{'randompick'}.'" />'."\n";
3429: } elsif ($caller eq 'actions') {
3430: $output .=
3431: '<input type="hidden" name="allremoveidx" id="allremoveidx" value="'.$listsref->{'canremove'}.'" />'.
3432: '<input type="hidden" name="allcutidx" id="allcutidx" value="'.$listsref->{'cancut'}.'" />'.
3433: '<input type="hidden" name="allcopyidx" id="allcopyidx" value="'.$listsref->{'cancopy'}.'" />';
3434: }
3435: $output .=
3436: '</form>'.
3437: '</div>';
3438: return $output;
3439: }
3440:
1.329 droeschl 3441: sub process_file_upload {
1.484.2.36 raeburn 3442: my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd,$crstype) = @_;
1.329 droeschl 3443: # upload a file, if present
1.484.2.36 raeburn 3444: my $filesize = length($env{'form.uploaddoc'});
3445: if (!$filesize) {
3446: $$upload_output = '<div class="LC_error">'.
3447: &mt('Unable to upload [_1]. (size = [_2] bytes)',
3448: '<span class="LC_filename">'.$env{'form.uploaddoc.filename'}.'</span>',
3449: $filesize).'<br />'.
3450: &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'<br />'.
3451: '</div>';
3452: return;
3453: }
3454: my $quotatype = 'unofficial';
3455: if ($crstype eq 'Community') {
3456: $quotatype = 'community';
1.484.2.51 raeburn 3457: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
1.484.2.36 raeburn 3458: $quotatype = 'official';
1.484.2.45 raeburn 3459: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
3460: $quotatype = 'textbook';
1.484.2.36 raeburn 3461: }
3462: if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) {
3463: $filesize = int($filesize/1000); #expressed in kb
3464: $$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course',
1.484.2.51 raeburn 3465: $env{'form.uploaddoc.filename'},$filesize,
3466: 'upload',$quotatype);
1.484.2.36 raeburn 3467: return if ($$upload_output);
3468: }
1.440 raeburn 3469: my ($parseaction,$showupload,$nextphase,$mimetype);
3470: if ($env{'form.parserflag'}) {
1.329 droeschl 3471: $parseaction = 'parse';
3472: }
3473: my $folder=$env{'form.folder'};
3474: if ($folder eq '') {
3475: $folder='default';
3476: }
3477: if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
3478: my $errtext='';
3479: my $fatal=0;
3480: my $container='sequence';
1.484.2.19 raeburn 3481: if ($env{'form.folderpath'} =~ /:1$/) {
1.329 droeschl 3482: $container='page';
3483: }
3484: ($errtext,$fatal)=
1.484.2.27 raeburn 3485: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1.329 droeschl 3486: if ($#LONCAPA::map::order<1) {
3487: $LONCAPA::map::order[0]=1;
3488: $LONCAPA::map::resources[1]='';
3489: }
3490: my $destination = 'docs/';
3491: if ($folder =~ /^supplemental/) {
3492: $destination = 'supplemental/';
3493: }
3494: if (($folder eq 'default') || ($folder eq 'supplemental')) {
3495: $destination .= 'default/';
3496: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
3497: $destination .= $2.'/';
3498: }
1.484.2.27 raeburn 3499: if ($fatal) {
3500: $$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>';
3501: return;
3502: }
1.440 raeburn 3503: # this is for a course, not a user, so set context to coursedoc.
1.329 droeschl 3504: my $newidx=&LONCAPA::map::getresidx();
3505: $destination .= $newidx;
1.439 raeburn 3506: my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination,
1.329 droeschl 3507: $parseaction,$allfiles,
1.440 raeburn 3508: $codebase,undef,undef,undef,undef,
3509: undef,undef,\$mimetype);
3510: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) {
3511: my $stored = $1;
3512: $showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'.
3513: $stored.'</span>').'</p>';
3514: } else {
3515: my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});
3516:
1.457 raeburn 3517: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>';
1.440 raeburn 3518: return;
3519: }
1.329 droeschl 3520: my $ext='false';
3521: if ($url=~m{^http://}) { $ext='true'; }
3522: $url = &LONCAPA::map::qtunescape($url);
3523: my $comment=$env{'form.comment'};
3524: $comment = &LONCAPA::map::qtunescape($comment);
3525: if ($folder=~/^supplemental/) {
3526: $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
3527: $env{'user.domain'}.'___&&&___'.$comment;
3528: }
3529:
3530: $LONCAPA::map::resources[$newidx]=
3531: $comment.':'.$url.':'.$ext.':normal:res';
3532: $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
3533: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.484.2.7 raeburn 3534: $folder.'.'.$container,1);
1.329 droeschl 3535: if ($fatal) {
1.457 raeburn 3536: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>';
1.440 raeburn 3537: return;
1.329 droeschl 3538: } else {
1.440 raeburn 3539: if ($parseaction eq 'parse' && $mimetype eq 'text/html') {
3540: $$upload_output = $showupload;
1.384 raeburn 3541: my $total_embedded = scalar(keys(%{$allfiles}));
1.329 droeschl 3542: if ($total_embedded > 0) {
1.440 raeburn 3543: my $uploadphase = 'upload_embedded';
3544: my $primaryurl = &HTML::Entities::encode($url,'<>&"');
3545: my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx);
3546: my ($embedded,$num) =
3547: &Apache::loncommon::ask_for_embedded_content(
3548: '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url});
3549: if ($embedded) {
3550: if ($num) {
3551: $$upload_output .=
3552: '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
3553: $nextphase = $uploadphase;
3554: } else {
3555: $$upload_output .= $embedded;
3556: }
3557: } else {
3558: $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
3559: }
1.329 droeschl 3560: } else {
1.440 raeburn 3561: $$upload_output .= &mt('No embedded items identified').'<br />';
1.329 droeschl 3562: }
1.457 raeburn 3563: $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
1.484.2.51 raeburn 3564: } elsif ((&Apache::loncommon::is_archive_file($mimetype)) &&
3565: ($env{'form.uploaddoc.filename'} =~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i)) {
1.476 raeburn 3566: $nextphase = 'decompress_uploaded';
3567: my $position = scalar(@LONCAPA::map::order)-1;
3568: my $noextract = &return_to_editor();
3569: my $archiveurl = &HTML::Entities::encode($url,'<>&"');
3570: my %archiveitems = (
3571: folderpath => $env{'form.folderpath'},
3572: cmd => $nextphase,
3573: newidx => $newidx,
3574: position => $position,
3575: phase => $nextphase,
1.477 raeburn 3576: comment => $comment,
1.480 raeburn 3577: );
3578: my ($destination,$dir_root) = &embedded_destination($coursenum,$coursedom);
3579: my @current = &get_dir_list($url,$coursenum,$coursedom,$newidx);
1.476 raeburn 3580: $$upload_output = $showupload.
3581: &Apache::loncommon::decompress_form($mimetype,
3582: $archiveurl,'/adm/coursedocs',$noextract,
1.480 raeburn 3583: \%archiveitems,\@current);
1.329 droeschl 3584: }
3585: }
3586: }
1.440 raeburn 3587: return $nextphase;
1.329 droeschl 3588: }
3589:
1.480 raeburn 3590: sub get_dir_list {
3591: my ($url,$coursenum,$coursedom,$newidx) = @_;
3592: my ($destination,$dir_root) = &embedded_destination();
3593: my ($dirlistref,$listerror) =
3594: &Apache::lonnet::dirlist("$dir_root/$destination/$newidx",$coursedom,$coursenum,1);
3595: my @dir_lines;
3596: my $dirptr=16384;
3597: if (ref($dirlistref) eq 'ARRAY') {
3598: foreach my $dir_line (sort
3599: {
3600: my ($afile)=split('&',$a,2);
3601: my ($bfile)=split('&',$b,2);
3602: return (lc($afile) cmp lc($bfile));
3603: } (@{$dirlistref})) {
3604: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
3605: $filename =~ s/\s+$//;
3606: next if ($filename =~ /^\.\.?$/);
3607: my $isdir = 0;
3608: if ($dirptr&$testdir) {
3609: $isdir = 1;
3610: }
3611: push(@dir_lines, [$filename,$dom,$isdir,$size,$mtime,$obs]);
3612: }
3613: }
3614: return @dir_lines;
3615: }
3616:
1.329 droeschl 3617: sub is_supplemental_title {
3618: my ($title) = @_;
3619: return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
3620: }
3621:
3622: # --------------------------------------------------------------- An entry line
3623:
3624: sub entryline {
1.484.2.12 raeburn 3625: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
1.484.2.67 raeburn 3626: $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups,
1.484.2.72.4. (raeburn 3627:): $ltitoolsref,$canedit,$isencrypted,$navmapref)=@_;
1.484.2.52 raeburn 3628: my ($foldertitle,$renametitle,$oldtitle);
1.329 droeschl 3629: if (&is_supplemental_title($title)) {
1.484.2.7 raeburn 3630: ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
1.329 droeschl 3631: } else {
3632: $title=&HTML::Entities::encode($title,'"<>&\'');
3633: $renametitle=$title;
3634: $foldertitle=$title;
3635: }
3636:
1.484.2.67 raeburn 3637: my ($disabled,$readonly,$js_lt);
3638: unless ($canedit) {
3639: $disabled = 'disabled="disabled"';
3640: $readonly = 1;
3641: }
3642:
1.329 droeschl 3643: my $orderidx=$LONCAPA::map::order[$index];
1.364 bisitz 3644:
1.329 droeschl 3645: $renametitle=~s/\\/\\\\/g;
3646: $renametitle=~s/\"\;/\\\"/g;
1.484.2.55 raeburn 3647: $renametitle=~s/"/%22/g;
1.329 droeschl 3648: $renametitle=~s/ /%20/g;
1.484.2.52 raeburn 3649: $oldtitle = $renametitle;
3650: $renametitle=~s/\'\;/\\\'/g;
1.379 bisitz 3651: my $line=&Apache::loncommon::start_data_table_row();
1.484.2.30 raeburn 3652: my ($form_start,$form_end,$form_common,$form_param);
1.329 droeschl 3653: # Edit commands
1.484.2.28 raeburn 3654: my ($esc_path, $path, $symb);
1.329 droeschl 3655: if ($env{'form.folderpath'}) {
3656: $esc_path=&escape($env{'form.folderpath'});
3657: $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3658: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
3659: }
1.484.2.16 raeburn 3660: my $isexternal;
1.484.2.19 raeburn 3661: if ($residx) {
1.484.2.12 raeburn 3662: my $currurl = $url;
3663: $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.484.2.16 raeburn 3664: if ($currurl =~ m{^/adm/wrapper/ext/}) {
3665: $isexternal = 1;
3666: }
1.484.2.19 raeburn 3667: if (!$supplementalflag) {
3668: my $path = 'uploaded/'.
3669: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
3670: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
3671: $symb = &Apache::lonnet::encode_symb($path.$folder.".$container",
3672: $residx,
3673: &Apache::lonnet::declutter($currurl));
3674: }
1.484.2.12 raeburn 3675: }
1.484.2.30 raeburn 3676: my ($renamelink,%lt,$ishash);
3677: if (ref($filtersref) eq 'HASH') {
3678: $ishash = 1;
3679: }
3680:
1.329 droeschl 3681: if ($allowed) {
1.484.2.30 raeburn 3682: $form_start = '
3683: <form action="/adm/coursedocs" method="post">
3684: ';
3685: $form_common=(<<END);
3686: <input type="hidden" name="folderpath" value="$path" />
3687: <input type="hidden" name="symb" value="$symb" />
3688: END
3689: $form_param=(<<END);
3690: <input type="hidden" name="setparms" value="$orderidx" />
3691: <input type="hidden" name="changeparms" value="0" />
3692: END
3693: $form_end = '</form>';
3694:
1.329 droeschl 3695: my $incindex=$index+1;
3696: my $selectbox='';
1.471 raeburn 3697: if (($#LONCAPA::map::order>0) &&
1.329 droeschl 3698: ((split(/\:/,
1.344 bisitz 3699: $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
3700: ne '') &&
1.329 droeschl 3701: ((split(/\:/,
1.344 bisitz 3702: $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1.329 droeschl 3703: ne '')) {
3704: $selectbox=
3705: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.484.2.67 raeburn 3706: '<select name="newpos" onchange="this.form.submit()"'.$disabled.'>';
1.329 droeschl 3707: for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
3708: if ($i==$incindex) {
1.358 bisitz 3709: $selectbox.='<option value="" selected="selected">('.$i.')</option>';
1.329 droeschl 3710: } else {
3711: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
3712: }
3713: }
3714: $selectbox.='</select>';
3715: }
1.484.2.12 raeburn 3716: %lt=&Apache::lonlocal::texthash(
1.329 droeschl 3717: 'up' => 'Move Up',
3718: 'dw' => 'Move Down',
3719: 'rm' => 'Remove',
3720: 'ct' => 'Cut',
3721: 'rn' => 'Rename',
1.484.2.12 raeburn 3722: 'cp' => 'Copy',
3723: 'ex' => 'External Resource',
1.484.2.72.4. (raeburn 3724:): 'et' => 'External Tool',
1.484.2.12 raeburn 3725: 'ed' => 'Edit',
3726: 'pr' => 'Preview',
3727: 'sv' => 'Save',
3728: 'ul' => 'URL',
1.484.2.67 raeburn 3729: 'ti' => 'Title',
3730: 'er' => 'Editing rights unavailable for your current role.',
1.484.2.12 raeburn 3731: );
1.484.2.30 raeburn 3732: my %denied = &action_restrictions($coursenum,$coursedom,$url,
3733: $env{'form.folderpath'},
3734: $currgroups);
1.484.2.19 raeburn 3735: my ($copylink,$cutlink,$removelink);
1.329 droeschl 3736: my $skip_confirm = 0;
1.484.2.63 raeburn 3737: my $confirm_removal = 0;
1.329 droeschl 3738: if ( $folder =~ /^supplemental/
3739: || ($url =~ m{( /smppg$
3740: |/syllabus$
3741: |/aboutme$
3742: |/navmaps$
3743: |/bulletinboard$
1.484.2.72.4. (raeburn 3744:): |/ext\.tool$
1.484.2.16 raeburn 3745: |\.html$)}x)
1.484.2.19 raeburn 3746: || $isexternal) {
1.329 droeschl 3747: $skip_confirm = 1;
3748: }
1.484.2.63 raeburn 3749: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
3750: ($url!~/$LONCAPA::assess_page_seq_re/)) {
3751: $confirm_removal = 1;
3752: }
1.484.2.19 raeburn 3753:
1.484.2.30 raeburn 3754: if ($denied{'copy'}) {
3755: $copylink=(<<ENDCOPY)
1.484.2.16 raeburn 3756: <span style="visibility: hidden;">$lt{'cp'}</span>
3757: ENDCOPY
3758: } else {
1.484.2.30 raeburn 3759: my $formname = 'edit_copy_'.$orderidx;
3760: my $js = "javascript:checkForSubmit(document.forms.renameform,'copy','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.484.2.19 raeburn 3761: $copylink=(<<ENDCOPY);
1.484.2.30 raeburn 3762: <form name="$formname" method="post" action="/adm/coursedocs">
3763: $form_common
1.484.2.67 raeburn 3764: <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 3765: $form_end
1.329 droeschl 3766: ENDCOPY
1.484.2.30 raeburn 3767: if (($ishash) && (ref($filtersref->{'cancopy'}) eq 'ARRAY')) {
3768: push(@{$filtersref->{'cancopy'}},$orderidx);
3769: }
1.329 droeschl 3770: }
1.484.2.30 raeburn 3771: if ($denied{'cut'}) {
1.484.2.16 raeburn 3772: $cutlink=(<<ENDCUT);
3773: <span style="visibility: hidden;">$lt{'ct'}</span>
3774: ENDCUT
3775: } else {
1.484.2.30 raeburn 3776: my $formname = 'edit_cut_'.$orderidx;
3777: my $js = "javascript:checkForSubmit(document.forms.renameform,'cut','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.484.2.19 raeburn 3778: $cutlink=(<<ENDCUT);
1.484.2.30 raeburn 3779: <form name="$formname" method="post" action="/adm/coursedocs">
3780: $form_common
3781: <input type="hidden" name="skip_$orderidx" id="skip_cut_$orderidx" value="$skip_confirm" />
1.484.2.67 raeburn 3782: <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 3783: $form_end
1.329 droeschl 3784: ENDCUT
1.484.2.30 raeburn 3785: if (($ishash) && (ref($filtersref->{'cancut'}) eq 'ARRAY')) {
3786: push(@{$filtersref->{'cancut'}},$orderidx);
3787: }
1.329 droeschl 3788: }
1.484.2.30 raeburn 3789: if ($denied{'remove'}) {
1.484.2.16 raeburn 3790: $removelink=(<<ENDREM);
3791: <span style="visibility: hidden;">$lt{'rm'}</a>
3792: ENDREM
3793: } else {
1.484.2.30 raeburn 3794: my $formname = 'edit_remove_'.$orderidx;
1.484.2.63 raeburn 3795: 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 3796: $removelink=(<<ENDREM);
1.484.2.30 raeburn 3797: <form name="$formname" method="post" action="/adm/coursedocs">
3798: $form_common
3799: <input type="hidden" name="skip_$orderidx" id="skip_remove_$orderidx" value="$skip_confirm" />
1.484.2.63 raeburn 3800: <input type="hidden" name="confirm_rem_$orderidx" id="confirm_removal_$orderidx" value="$confirm_removal" />
1.484.2.67 raeburn 3801: <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 3802: $form_end
1.484.2.9 raeburn 3803: ENDREM
1.484.2.30 raeburn 3804: if (($ishash) && (ref($filtersref->{'canremove'}) eq 'ARRAY')) {
3805: push(@{$filtersref->{'canremove'}},$orderidx);
3806: }
1.484.2.9 raeburn 3807: }
1.484.2.35 raeburn 3808: $renamelink=(<<ENDREN);
1.484.2.52 raeburn 3809: <a href='javascript:changename("$esc_path","$index","$oldtitle");' class="LC_docs_rename">$lt{'rn'}</a>
1.484.2.16 raeburn 3810: ENDREN
1.484.2.67 raeburn 3811: my ($uplink,$downlink);
3812: if ($canedit) {
3813: $uplink = "/adm/coursedocs?cmd=up_$index&folderpath=$esc_path&symb=$symb";
3814: $downlink = "/adm/coursedocs?cmd=down_$index&folderpath=$esc_path&symb=$symb";
3815: } else {
3816: $uplink = "javascript:alert('".&js_escape($lt{'er'})."');";
3817: $downlink = $uplink;
3818: }
1.329 droeschl 3819: $line.=(<<END);
3820: <td>
1.379 bisitz 3821: <div class="LC_docs_entry_move">
1.484.2.67 raeburn 3822: <a href="$uplink">
1.484.2.12 raeburn 3823: <img src="${iconpath}move_up.gif" alt="$lt{'up'}" class="LC_icon" />
1.379 bisitz 3824: </a>
3825: </div>
3826: <div class="LC_docs_entry_move">
1.484.2.67 raeburn 3827: <a href="$downlink">
1.484.2.12 raeburn 3828: <img src="${iconpath}move_down.gif" alt="$lt{'dw'}" class="LC_icon" />
1.379 bisitz 3829: </a>
3830: </div>
1.329 droeschl 3831: </td>
3832: <td>
3833: $form_start
1.484.2.30 raeburn 3834: $form_param
1.478 raeburn 3835: $form_common
1.329 droeschl 3836: $selectbox
3837: $form_end
3838: </td>
1.484.2.30 raeburn 3839: <td class="LC_docs_entry_commands LC_nobreak">
1.484.2.9 raeburn 3840: $removelink
1.329 droeschl 3841: $cutlink
3842: $copylink
3843: </td>
3844: END
3845: }
3846: # Figure out what kind of a resource this is
3847: my ($extension)=($url=~/\.(\w+)$/);
3848: my $uploaded=($url=~/^\/*uploaded\//);
3849: my $icon=&Apache::loncommon::icon($url);
1.484.2.19 raeburn 3850: my $isfolder;
3851: my $ispage;
3852: my $containerarg;
1.484.2.67 raeburn 3853: my $folderurl;
1.329 droeschl 3854: if ($uploaded) {
1.472 raeburn 3855: if (($extension eq 'sequence') || ($extension eq 'page')) {
3856: $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
1.484.2.19 raeburn 3857: $containerarg = $1;
1.472 raeburn 3858: if ($extension eq 'sequence') {
3859: $icon=$iconpath.'navmap.folder.closed.gif';
3860: $isfolder=1;
3861: } else {
3862: $icon=$iconpath.'page.gif';
3863: $ispage=1;
3864: }
1.484.2.67 raeburn 3865: $folderurl = &Apache::lonnet::declutter($url);
1.472 raeburn 3866: if ($allowed) {
3867: $url='/adm/coursedocs?';
3868: } else {
3869: $url='/adm/supplemental?';
3870: }
1.329 droeschl 3871: } else {
3872: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
3873: }
3874: }
1.364 bisitz 3875:
1.484.2.70 raeburn 3876: my ($editlink,$extresform,$anchor,$hiddenres,$nomodal);
1.329 droeschl 3877: my $orig_url = $url;
1.340 raeburn 3878: $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
1.484.2.19 raeburn 3879: $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.484.2.12 raeburn 3880: if (!$supplementalflag && $residx && $symb) {
3881: if ((!$isfolder) && (!$ispage)) {
3882: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
3883: $url=&Apache::lonnet::clutter($url);
3884: if ($url=~/^\/*uploaded\//) {
3885: $url=~/\.(\w+)$/;
3886: my $embstyle=&Apache::loncommon::fileembstyle($1);
3887: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
3888: $url='/adm/wrapper'.$url;
3889: } elsif ($embstyle eq 'ssi') {
3890: #do nothing with these
3891: } elsif ($url!~/\.(sequence|page)$/) {
3892: $url='/adm/coursedocs/showdoc'.$url;
3893: }
1.484.2.70 raeburn 3894: } elsif ($url=~m{^(|/adm/wrapper)/ext/([^#]+)}) {
3895: my $wrapped = $1;
3896: my $exturl = $2;
3897: if ($wrapped eq '') {
3898: $url='/adm/wrapper'.$url;
3899: }
3900: if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) {
3901: $nomodal = 1;
3902: }
1.484.2.72.4. (raeburn 3903:): } elsif ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
3904:): $url='/adm/wrapper'.$url;
1.484.2.70 raeburn 3905: } elsif ($url eq "/public/$coursedom/$coursenum/syllabus") {
3906: if (($ENV{'SERVER_PORT'} == 443) &&
3907: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
3908: $nomodal = 1;
3909: }
1.484.2.19 raeburn 3910: }
1.484.2.12 raeburn 3911: if (&Apache::lonnet::symbverify($symb,$url)) {
1.484.2.66 raeburn 3912: my $shownsymb = $symb;
3913: if ($isexternal) {
3914: if ($url =~ /^([^#]+)#([^#]+)$/) {
3915: $url = $1;
3916: $anchor = $2;
3917: if ($symb =~ m{^([^#]+)\Q#$anchor\E$}) {
3918: $shownsymb = $1.&escape('#').$anchor;
3919: }
3920: }
3921: }
1.484.2.67 raeburn 3922: unless ($env{'request.role.adv'}) {
3923: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
3924: $url = '';
3925: }
3926: if (&Apache::lonnet::EXT('resource.0.hiddenresource',$symb) =~ /^yes$/i) {
3927: $url = '';
3928: $hiddenres = 1;
3929: }
3930: }
3931: if ($url ne '') {
3932: $url.=(($url=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&');
3933: }
3934: } elsif (!$env{'request.role.adv'}) {
3935: my $checkencrypt;
3936: if (((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) ||
3937: $isencrypted || (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i)) {
3938: $checkencrypt = 1;
1.484.2.70 raeburn 3939: } elsif (ref($navmapref)) {
1.484.2.67 raeburn 3940: unless (ref($$navmapref)) {
3941: $$navmapref = Apache::lonnavmaps::navmap->new();
3942: }
3943: if (ref($$navmapref)) {
3944: if (lc($$navmapref->get_mapparam($symb,undef,"0.encrypturl")) eq 'yes') {
3945: $checkencrypt = 1;
3946: }
3947: }
3948: }
3949: if ($checkencrypt) {
3950: my $shownsymb = &Apache::lonenc::encrypted($symb);
3951: my $shownurl = &Apache::lonenc::encrypted($url);
3952: if (&Apache::lonnet::symbverify($shownsymb,$shownurl)) {
3953: $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&');
3954: if ($env{'request.enc'} ne '') {
3955: delete($env{'request.enc'});
3956: }
3957: } else {
3958: $url='';
3959: }
3960: } else {
3961: $url='';
3962: }
1.484.2.12 raeburn 3963: } else {
3964: $url='';
3965: }
1.484.2.19 raeburn 3966: }
1.484.2.66 raeburn 3967: } elsif ($supplementalflag) {
3968: if ($isexternal) {
3969: if ($url =~ /^([^#]+)#([^#]+)$/) {
3970: $url = $1;
3971: $anchor = $2;
1.484.2.70 raeburn 3972: if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) {
3973: $nomodal = 1;
3974: }
3975: }
3976: } elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
3977: if (($ENV{'SERVER_PORT'} == 443) &&
3978: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
3979: $nomodal = 1;
1.484.2.66 raeburn 3980: }
3981: }
1.329 droeschl 3982: }
1.484.2.67 raeburn 3983: my ($rand_pick_text,$rand_order_text,$hiddenfolder);
3984: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.484.2.19 raeburn 3985: if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') {
1.329 droeschl 3986: my $foldername=&escape($foldertitle);
3987: my $folderpath=$env{'form.folderpath'};
3988: if ($folderpath) { $folderpath.='&' };
1.484.2.19 raeburn 3989: if (!$allowed && $supplementalflag) {
3990: $folderpath.=$containerarg.'&'.$foldername;
3991: $url.='folderpath='.&escape($folderpath);
3992: } else {
3993: my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
3994: 'parameter_randompick'))[0];
1.484.2.67 raeburn 3995: my $randorder = ((&LONCAPA::map::getparameter($orderidx,
3996: 'parameter_randomorder'))[0]=~/^yes$/i);
3997: my $hiddenmap = ((&LONCAPA::map::getparameter($orderidx,
3998: 'parameter_hiddenresource'))[0]=~/^yes$/i);
3999: my $encryptmap = ((&LONCAPA::map::getparameter($orderidx,
4000: 'parameter_encrypturl'))[0]=~/^yes$/i);
4001: unless ($hiddenmap) {
1.484.2.70 raeburn 4002: if (ref($navmapref)) {
4003: unless (ref($$navmapref)) {
4004: $$navmapref = Apache::lonnavmaps::navmap->new();
4005: }
4006: if (ref($$navmapref)) {
4007: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
4008: my @resources = $$navmapref->retrieveResources($folderurl,$filterFunc,1,1);
4009: unless (@resources) {
4010: $hiddenmap = 1;
4011: unless ($env{'request.role.adv'}) {
4012: $url = '';
4013: $hiddenfolder = 1;
4014: }
1.484.2.67 raeburn 4015: }
4016: }
4017: }
4018: }
4019: }
4020: unless ($encryptmap) {
1.484.2.70 raeburn 4021: if ((ref($navmapref)) && (ref($$navmapref))) {
4022: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.encrypturl")) eq 'yes') {
4023: $encryptmap = 1;
4024: }
1.484.2.67 raeburn 4025: }
4026: }
4027:
4028: # Append randompick number, hidden, and encrypted with ":" to foldername,
4029: # so it gets transferred between levels
4030: $folderpath.=$containerarg.'&'.$foldername.
4031: ':'.$rpicknum.':'.$hiddenmap.':'.$encryptmap.':'.$randorder.':'.$ispage;
4032: unless ($url eq '') {
4033: $url.='folderpath='.&escape($folderpath);
4034: }
1.484.2.19 raeburn 4035: my $rpckchk;
4036: if ($rpicknum) {
4037: $rpckchk = ' checked="checked"';
1.484.2.30 raeburn 4038: if (($ishash) && (ref($filtersref->{'randompick'}) eq 'ARRAY')) {
4039: push(@{$filtersref->{'randompick'}},$orderidx.':'.$rpicknum);
4040: }
1.484.2.19 raeburn 4041: }
1.484.2.29 raeburn 4042: my $formname = 'edit_randompick_'.$orderidx;
1.484.2.19 raeburn 4043: $rand_pick_text =
1.478 raeburn 4044: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.484.2.30 raeburn 4045: $form_param."\n".
1.478 raeburn 4046: $form_common."\n".
1.484.2.67 raeburn 4047: '<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 4048: if ($rpicknum ne '') {
4049: $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
4050: }
1.484.2.29 raeburn 4051: $rand_pick_text .= '</span></span>'.
4052: $form_end;
1.484.2.30 raeburn 4053: my $ro_set;
1.484.2.67 raeburn 4054: if ($randorder) {
1.484.2.30 raeburn 4055: $ro_set = 'checked="checked"';
4056: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4057: push(@{$filtersref->{'randomorder'}},$orderidx);
4058: }
4059: }
1.484.2.41 raeburn 4060: $formname = 'edit_rorder_'.$orderidx;
1.484.2.19 raeburn 4061: $rand_order_text =
1.484.2.29 raeburn 4062: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.484.2.30 raeburn 4063: $form_param."\n".
1.484.2.29 raeburn 4064: $form_common."\n".
1.484.2.67 raeburn 4065: '<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 4066: $form_end;
1.484.2.19 raeburn 4067: }
1.484.2.18 raeburn 4068: } elsif ($supplementalflag && !$allowed) {
1.484.2.72.4. (raeburn 4069:): my $isexttool;
4070:): if ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4071:): $url='/adm/wrapper'.$url;
4072:): $isexttool = 1;
4073:): }
1.484.2.19 raeburn 4074: $url .= ($url =~ /\?/) ? '&':'?';
1.484.2.18 raeburn 4075: $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
1.484.2.19 raeburn 4076: if ($title) {
4077: $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"');
4078: }
1.484.2.72.4. (raeburn 4079:): if ((($isexternal) || ($isexttool)) && $orderidx) {
1.484.2.19 raeburn 4080: $url .= '&idx='.$orderidx;
4081: }
1.484.2.66 raeburn 4082: if ($anchor ne '') {
4083: $url .= '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4084: }
1.329 droeschl 4085: }
1.484.2.19 raeburn 4086: my ($tdalign,$tdwidth);
1.484.2.12 raeburn 4087: if ($allowed) {
1.484.2.19 raeburn 4088: my $fileloc =
1.484.2.12 raeburn 4089: &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
1.484.2.19 raeburn 4090: if ($isexternal) {
4091: ($editlink,$extresform) =
1.484.2.67 raeburn 4092: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
1.484.2.72.4. (raeburn 4093:): undef,undef,undef,undef,undef,undef,
4094:): undef,$disabled);
4095:): } elsif ($orig_url =~ m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4096:): ($editlink,$extresform) =
4097:): &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
4098:): undef,undef,undef,'tool',$coursedom,
4099:): $coursenum,$ltitoolsref,$disabled);
1.484.2.19 raeburn 4100: } elsif (!$isfolder && !$ispage) {
4101: my ($cfile,$home,$switchserver,$forceedit,$forceview) =
1.484.2.14 raeburn 4102: &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
1.484.2.19 raeburn 4103: if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
1.484.2.66 raeburn 4104: my $suppanchor;
4105: if ($supplementalflag) {
4106: $suppanchor = $anchor;
4107: }
1.484.2.19 raeburn 4108: my $jscall =
1.484.2.12 raeburn 4109: &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
4110: $switchserver,
1.484.2.14 raeburn 4111: $forceedit,
1.484.2.19 raeburn 4112: undef,$symb,
4113: &escape($env{'form.folderpath'}),
1.484.2.66 raeburn 4114: $renametitle,'','',1,$suppanchor);
1.484.2.12 raeburn 4115: if ($jscall) {
1.484.2.19 raeburn 4116: $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
4117: $jscall.'" >'.&mt('Edit').'</a> '."\n";
1.484.2.12 raeburn 4118: }
4119: }
4120: }
1.484.2.19 raeburn 4121: $tdalign = ' align="right" valign="top"';
4122: $tdwidth = ' width="80%"';
1.329 droeschl 4123: }
1.408 raeburn 4124: my $reinit;
4125: if ($crstype eq 'Community') {
4126: $reinit = &mt('(re-initialize community to access)');
4127: } else {
4128: $reinit = &mt('(re-initialize course to access)');
1.484.2.19 raeburn 4129: }
4130: $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;
1.484.2.70 raeburn 4131: my $link;
1.472 raeburn 4132: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 4133: $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
4134: } elsif ($url) {
1.484.2.66 raeburn 4135: if ($anchor ne '') {
4136: if ($supplementalflag) {
4137: $anchor = '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4138: } else {
4139: $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');
4140: }
4141: }
1.484.2.70 raeburn 4142: $link = &js_escape($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.
4143: (($anchor ne '')?$anchor:''));
4144: if ($nomodal) {
4145: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4146: '<img src="'.$icon.'" alt="" class="LC_icon" border="0" /></a>';
4147: } else {
4148: $line.=&Apache::loncommon::modal_link($link,
4149: '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
4150: }
1.469 www 4151: } else {
4152: $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
4153: }
1.484.2.19 raeburn 4154: $line.='</span></td><td'.$tdwidth.'>';
1.472 raeburn 4155: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 4156: $line.='<a href="'.$url.'">'.$title.'</a>';
4157: } elsif ($url) {
1.484.2.70 raeburn 4158: if ($nomodal) {
4159: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4160: $title.'</a>';
4161: } else {
4162: $line.=&Apache::loncommon::modal_link($link,$title,600,500);
4163: }
1.484.2.67 raeburn 4164: } elsif (($hiddenfolder) || ($hiddenres)) {
1.484.2.72 raeburn 4165: $line.=$title.' <span class="LC_warning LC_docs_reinit_warn">('.&mt('Hidden').')</span>';
1.469 www 4166: } else {
4167: $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
4168: }
1.484.2.19 raeburn 4169: $line.="$extresform</td>";
1.478 raeburn 4170: $rand_pick_text = ' ' if ($rand_pick_text eq '');
4171: $rand_order_text = ' ' if ($rand_order_text eq '');
1.329 droeschl 4172: if (($allowed) && ($folder!~/^supplemental/)) {
4173: my %lt=&Apache::lonlocal::texthash(
4174: 'hd' => 'Hidden',
4175: 'ec' => 'URL hidden');
1.484.2.30 raeburn 4176: my ($enctext,$hidtext);
4177: if ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) {
4178: $enctext = ' checked="checked"';
4179: if (($ishash) && (ref($filtersref->{'encrypturl'}) eq 'ARRAY')) {
4180: push(@{$filtersref->{'encrypturl'}},$orderidx);
4181: }
4182: }
4183: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4184: $hidtext = ' checked="checked"';
4185: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4186: push(@{$filtersref->{'hiddenresource'}},$orderidx);
4187: }
4188: }
1.484.2.29 raeburn 4189: my $formhidden = 'edit_hiddenresource_'.$orderidx;
4190: my $formurlhidden = 'edit_encrypturl_'.$orderidx;
1.329 droeschl 4191: $line.=(<<ENDPARMS);
4192: <td class="LC_docs_entry_parameter">
1.484.2.30 raeburn 4193: <form action="/adm/coursedocs" method="post" name="$formhidden">
4194: $form_param
1.478 raeburn 4195: $form_common
1.484.2.67 raeburn 4196: <label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'hiddenresource','settings');" $hidtext $disabled /> $lt{'hd'}</label>
1.329 droeschl 4197: $form_end
1.458 raeburn 4198: <br />
1.484.2.29 raeburn 4199: <form action="/adm/coursedocs" method="post" name="$formurlhidden">
1.484.2.30 raeburn 4200: $form_param
1.478 raeburn 4201: $form_common
1.484.2.67 raeburn 4202: <label><input type="checkbox" name="encrypturl_$orderidx" id="encrypturl_$orderidx" onclick="checkForSubmit(this.form,'encrypturl','settings');" $enctext $disabled /> $lt{'ec'}</label>
1.329 droeschl 4203: $form_end
4204: </td>
1.478 raeburn 4205: <td class="LC_docs_entry_parameter">$rand_pick_text<br />
4206: $rand_order_text</td>
1.329 droeschl 4207: ENDPARMS
4208: }
1.379 bisitz 4209: $line.=&Apache::loncommon::end_data_table_row();
1.329 droeschl 4210: return $line;
4211: }
4212:
1.484.2.30 raeburn 4213: sub action_restrictions {
4214: my ($cnum,$cdom,$url,$folderpath,$currgroups) = @_;
4215: my %denied = (
4216: cut => 0,
4217: copy => 0,
4218: remove => 0,
4219: );
4220: if ($url=~ m{^/res/.+\.(page|sequence)$}) {
4221: # no copy for published maps
4222: $denied{'copy'} = 1;
4223: } elsif ($url=~m{^/res/lib/templates/}) {
4224: $denied{'copy'} = 1;
4225: $denied{'cut'} = 1;
4226: } elsif ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") {
4227: if ($folderpath =~ /^default&[^\&]+$/) {
4228: if ((ref($currgroups) eq 'HASH') && (keys(%{$currgroups}) > 0)) {
4229: $denied{'remove'} = 1;
4230: }
4231: $denied{'cut'} = 1;
4232: $denied{'copy'} = 1;
4233: }
4234: } elsif ($url =~ m{^\Q/uploaded/$cdom/$cnum/group_folder_\E(\w+)\.sequence$}) {
4235: my $group = $1;
4236: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+$/) {
4237: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4238: $denied{'remove'} = 1;
4239: }
4240: }
4241: $denied{'cut'} = 1;
4242: $denied{'copy'} = 1;
4243: } elsif ($url =~ m{^\Q/adm/$cdom/$cnum/\E(\w+)/smppg$}) {
4244: my $group = $1;
4245: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&\Qgroup_folder_$group\E\&[^\&]+$/) {
4246: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4247: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4248: if (keys(%groupsettings) > 0) {
4249: $denied{'remove'} = 1;
4250: }
4251: $denied{'cut'} = 1;
4252: $denied{'copy'} = 1;
4253: }
4254: }
4255: } elsif ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&group_folder_(\w+)\&/) {
4256: my $group = $1;
4257: if ($url =~ /group_boards_\Q$group\E/) {
4258: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4259: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4260: if (keys(%groupsettings) > 0) {
4261: if (ref($groupsettings{'functions'}) eq 'HASH') {
4262: if ($groupsettings{'functions'}{'discussion'} eq 'on') {
4263: $denied{'remove'} = 1;
4264: }
4265: }
4266: }
4267: $denied{'cut'} = 1;
4268: $denied{'copy'} = 1;
4269: }
4270: }
4271: }
4272: return %denied;
4273: }
4274:
1.484.2.26 raeburn 4275: sub new_timebased_suffix {
1.484.2.30 raeburn 4276: my ($dom,$num,$type,$area,$container) = @_;
1.484.2.26 raeburn 4277: my ($prefix,$namespace,$idtype,$errtext,$locknotfreed);
1.484.2.30 raeburn 4278: if ($type eq 'paste') {
4279: $prefix = $type;
4280: $namespace = 'courseeditor';
1.484.2.56 raeburn 4281: $idtype = 'addcode';
1.484.2.30 raeburn 4282: } elsif ($type eq 'map') {
1.484.2.26 raeburn 4283: $prefix = 'docs';
4284: if ($area eq 'supplemental') {
4285: $prefix = 'supp';
4286: }
4287: $prefix .= $container;
4288: $namespace = 'uploadedmaps';
4289: } else {
4290: $prefix = $type;
4291: $namespace = 'templated';
1.484.2.15 raeburn 4292: }
4293: my ($suffix,$freedlock,$error) =
1.484.2.56 raeburn 4294: &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num,$idtype);
1.484.2.15 raeburn 4295: if (!$suffix) {
1.484.2.30 raeburn 4296: if ($type eq 'paste') {
4297: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.');
4298: } elsif ($type eq 'map') {
1.484.2.26 raeburn 4299: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
4300: } elsif ($type eq 'smppg') {
4301: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.');
1.484.2.72.4. (raeburn 4302:): } elsif ($type eq 'exttool') {
4303:): $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new external tool.');
1.484.2.26 raeburn 4304: } else {
1.484.2.42 raeburn 4305: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new discussion board.');
1.484.2.26 raeburn 4306: }
1.484.2.15 raeburn 4307: if ($error) {
4308: $errtext .= '<br />'.$error;
4309: }
4310: }
4311: if ($freedlock ne 'ok') {
1.484.2.26 raeburn 4312: $locknotfreed =
4313: '<div class="LC_error">'.
4314: &mt('There was a problem removing a lockfile.').' ';
1.484.2.30 raeburn 4315: if ($type eq 'paste') {
1.484.2.57 raeburn 4316: if ($freedlock eq 'nolock') {
4317: $locknotfreed =
4318: '<div class="LC_error">'.
4319: &mt('A lockfile was not released when you added content to the clipboard earlier in this session.').' '.
4320:
1.484.2.60 raeburn 4321: &mt('As a result addition of items to the clipboard will be unavailable until your next log-in.');
1.484.2.57 raeburn 4322: } else {
4323: $locknotfreed .=
4324: &mt('This will prevent addition of items to the clipboard until your next log-in.');
4325: }
1.484.2.30 raeburn 4326: } elsif ($type eq 'map') {
1.484.2.57 raeburn 4327: $locknotfreed .=
4328: &mt('This will prevent creation of additional folders or composite pages in this course.');
1.484.2.26 raeburn 4329: } elsif ($type eq 'smppg') {
4330: $locknotfreed .=
4331: &mt('This will prevent creation of additional simple pages in this course.');
1.484.2.72.4. (raeburn 4332:): } elsif ($type eq 'exttool') {
4333:): $locknotfreed .=
4334:): &mt('This will prevent creation of additional external tools in this course.');
1.484.2.26 raeburn 4335: } else {
4336: $locknotfreed .=
1.484.2.42 raeburn 4337: &mt('This will prevent creation of additional discussion boards in this course.');
1.484.2.26 raeburn 4338: }
1.484.2.30 raeburn 4339: unless ($type eq 'paste') {
4340: $locknotfreed .=
1.484.2.38 raeburn 4341: ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
4342: '<a href="/adm/helpdesk" target="_helpdesk">','</a>');
1.484.2.30 raeburn 4343: }
4344: $locknotfreed .= '</div>';
1.484.2.15 raeburn 4345: }
4346: return ($suffix,$errtext,$locknotfreed);
4347: }
4348:
1.329 droeschl 4349: =pod
4350:
4351: =item tiehash()
4352:
4353: tie the hash
4354:
4355: =cut
4356:
4357: sub tiehash {
4358: my ($mode)=@_;
4359: $hashtied=0;
4360: if ($env{'request.course.fn'}) {
4361: if ($mode eq 'write') {
4362: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4363: &GDBM_WRCREAT(),0640)) {
4364: $hashtied=2;
4365: }
4366: } else {
4367: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4368: &GDBM_READER(),0640)) {
4369: $hashtied=1;
4370: }
4371: }
1.364 bisitz 4372: }
1.329 droeschl 4373: }
4374:
4375: sub untiehash {
4376: if ($hashtied) { untie %hash; }
4377: $hashtied=0;
4378: return OK;
4379: }
4380:
4381:
4382:
4383:
4384: sub checkonthis {
4385: my ($r,$url,$level,$title)=@_;
4386: $url=&unescape($url);
4387: $alreadyseen{$url}=1;
4388: $r->rflush();
4389: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
4390: $r->print("\n<br />");
4391: if ($level==0) {
4392: $r->print("<br />");
4393: }
4394: for (my $i=0;$i<=$level*5;$i++) {
4395: $r->print(' ');
4396: }
4397: $r->print('<a href="'.$url.'" target="cat">'.
4398: ($title?$title:$url).'</a> ');
4399: if ($url=~/^\/res\//) {
4400: my $result=&Apache::lonnet::repcopy(
4401: &Apache::lonnet::filelocation('',$url));
4402: if ($result eq 'ok') {
4403: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
4404: $r->rflush();
4405: &Apache::lonnet::countacc($url);
4406: $url=~/\.(\w+)$/;
4407: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
4408: $r->print('<br />');
4409: $r->rflush();
4410: for (my $i=0;$i<=$level*5;$i++) {
4411: $r->print(' ');
4412: }
4413: $r->print('- '.&mt('Rendering:').' ');
4414: my ($errorcount,$warningcount)=split(/:/,
4415: &Apache::lonnet::ssi_body($url,
4416: ('grade_target'=>'web',
4417: 'return_only_error_and_warning_counts' => 1)));
4418: if (($errorcount) ||
4419: ($warningcount)) {
4420: if ($errorcount) {
1.369 bisitz 4421: $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1.329 droeschl 4422: &mt('[quant,_1,error]',$errorcount).'</span>');
4423: }
4424: if ($warningcount) {
4425: $r->print('<span class="LC_warning">'.
4426: &mt('[quant,_1,warning]',$warningcount).'</span>');
4427: }
4428: } else {
4429: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
4430: }
4431: $r->rflush();
4432: }
4433: my $dependencies=
4434: &Apache::lonnet::metadata($url,'dependencies');
4435: foreach my $dep (split(/\,/,$dependencies)) {
4436: if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
4437: &checkonthis($r,$dep,$level+1);
4438: }
4439: }
4440: } elsif ($result eq 'unavailable') {
4441: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
4442: } elsif ($result eq 'not_found') {
4443: unless ($url=~/\$/) {
1.484.2.19 raeburn 4444: $r->print('<span class="LC_error">'.&mt('not found').'</span>');
1.329 droeschl 4445: } else {
1.366 bisitz 4446: $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1.329 droeschl 4447: }
4448: } else {
4449: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
4450: }
4451: }
4452: }
4453: }
4454:
4455:
4456:
4457: =pod
4458:
4459: =item list_symbs()
4460:
1.484.2.3 raeburn 4461: List Content Identifiers
1.329 droeschl 4462:
4463: =cut
4464:
4465: sub list_symbs {
4466: my ($r) = @_;
4467:
1.408 raeburn 4468: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 4469: $r->print(&Apache::loncommon::start_page('List of Content Identifiers'));
4470: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Identifiers'));
4471: $r->print(&startContentScreen('tools'));
1.329 droeschl 4472: my $navmap = Apache::lonnavmaps::navmap->new();
4473: if (!defined($navmap)) {
4474: $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
4475: '<div class="LC_error">'.
4476: &mt('Unable to retrieve information about course contents').
4477: '</div>');
1.408 raeburn 4478: &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
1.329 droeschl 4479: } else {
1.484 raeburn 4480: $r->print('<h4 class="LC_info">'.&mt("$crstype Content Identifiers").'</h4>'.
4481: &Apache::loncommon::start_data_table().
4482: &Apache::loncommon::start_data_table_header_row().
4483: '<th>'.&mt('Title').'</th><th>'.&mt('Identifier').'</th>'.
4484: &Apache::loncommon::end_data_table_header_row()."\n");
4485: my $count;
1.329 droeschl 4486: foreach my $res ($navmap->retrieveResources()) {
1.484 raeburn 4487: $r->print(&Apache::loncommon::start_data_table_row().
4488: '<td>'.$res->compTitle().'</td>'.
4489: '<td>'.$res->symb().'</td>'.
1.484.2.19 raeburn 4490: &Apache::loncommon::end_data_table_row());
1.484 raeburn 4491: $count ++;
4492: }
4493: if (!$count) {
4494: $r->print(&Apache::loncommon::start_data_table_row().
4495: '<td colspan="2">'.&mt("$crstype is empty").'</td>'.
4496: &Apache::loncommon::end_data_table_row());
1.329 droeschl 4497: }
1.484 raeburn 4498: $r->print(&Apache::loncommon::end_data_table());
1.329 droeschl 4499: }
1.484.2.19 raeburn 4500: $r->print(&endContentScreen());
1.329 droeschl 4501: }
4502:
4503:
4504: sub verifycontent {
4505: my ($r) = @_;
1.408 raeburn 4506: my $crstype = &Apache::loncommon::course_type();
1.484.2.34 raeburn 4507: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
4508: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
1.484 raeburn 4509: $r->print(&startContentScreen('tools'));
4510: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
1.329 droeschl 4511: $hashtied=0;
4512: undef %alreadyseen;
4513: %alreadyseen=();
4514: &tiehash();
1.484 raeburn 4515:
1.329 droeschl 4516: foreach my $key (keys(%hash)) {
4517: if ($hash{$key}=~/\.(page|sequence)$/) {
4518: if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
4519: $r->print('<hr /><span class="LC_error">'.
1.419 bisitz 4520: &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
1.329 droeschl 4521: &unescape($hash{$key}).'</span><br />'.
1.419 bisitz 4522: &mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />');
1.329 droeschl 4523: }
4524: }
4525: if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
4526: &checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
4527: }
4528: }
4529: &untiehash();
1.442 www 4530: $r->print('<p class="LC_success">'.&mt('Done').'</p>');
1.484.2.19 raeburn 4531: $r->print(&endContentScreen());
1.329 droeschl 4532: }
4533:
4534:
4535: sub devalidateversioncache {
4536: my $src=shift;
4537: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
4538: &Apache::lonnet::clutter($src));
4539: }
4540:
4541: sub checkversions {
1.484.2.67 raeburn 4542: my ($r,$canedit) = @_;
1.408 raeburn 4543: my $crstype = &Apache::loncommon::course_type();
1.484.2.44 raeburn 4544: $r->print(&Apache::loncommon::start_page("Check $crstype Resource Versions"));
4545: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Resource Versions"));
1.484 raeburn 4546: $r->print(&startContentScreen('tools'));
1.442 www 4547:
1.329 droeschl 4548: my $header='';
4549: my $startsel='';
4550: my $monthsel='';
4551: my $weeksel='';
4552: my $daysel='';
4553: my $allsel='';
4554: my %changes=();
4555: my $starttime=0;
4556: my $haschanged=0;
4557: my %setversions=&Apache::lonnet::dump('resourceversions',
4558: $env{'course.'.$env{'request.course.id'}.'.domain'},
4559: $env{'course.'.$env{'request.course.id'}.'.num'});
4560:
4561: $hashtied=0;
4562: &tiehash();
1.484.2.67 raeburn 4563: if ($canedit) {
4564: my %newsetversions=();
4565: if ($env{'form.setmostrecent'}) {
4566: $haschanged=1;
4567: foreach my $key (keys(%hash)) {
4568: if ($key=~/^ids\_(\/res\/.+)$/) {
4569: $newsetversions{$1}='mostrecent';
4570: &devalidateversioncache($1);
4571: }
1.329 droeschl 4572: }
1.484.2.67 raeburn 4573: } elsif ($env{'form.setcurrent'}) {
4574: $haschanged=1;
4575: foreach my $key (keys(%hash)) {
4576: if ($key=~/^ids\_(\/res\/.+)$/) {
4577: my $getvers=&Apache::lonnet::getversion($1);
4578: if ($getvers>0) {
4579: $newsetversions{$1}=$getvers;
4580: &devalidateversioncache($1);
4581: }
4582: }
1.329 droeschl 4583: }
1.484.2.67 raeburn 4584: } elsif ($env{'form.setversions'}) {
4585: $haschanged=1;
4586: foreach my $key (keys(%env)) {
4587: if ($key=~/^form\.set_version_(.+)$/) {
4588: my $src=$1;
4589: if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
4590: $newsetversions{$src}=$env{$key};
4591: &devalidateversioncache($src);
4592: }
4593: }
1.329 droeschl 4594: }
1.484.2.67 raeburn 4595: }
4596: if ($haschanged) {
4597: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
4598: $env{'course.'.$env{'request.course.id'}.'.domain'},
4599: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
4600: $r->print(&Apache::loncommon::confirmwrapper(
4601: &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
4602: } else {
4603: $r->print(&Apache::loncommon::confirmwrapper(
4604: &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
4605: }
4606: &mark_hash_old();
4607: }
4608: &changewarning($r,'');
1.329 droeschl 4609: }
4610: if ($env{'form.timerange'} eq 'all') {
4611: # show all documents
1.484.2.34 raeburn 4612: $header=&mt('All content in '.$crstype);
1.484.2.19 raeburn 4613: $allsel=' selected="selected"';
1.329 droeschl 4614: foreach my $key (keys(%hash)) {
4615: if ($key=~/^ids\_(\/res\/.+)$/) {
4616: my $src=$1;
4617: $changes{$src}=1;
4618: }
4619: }
4620: } else {
4621: # show documents which changed
4622: %changes=&Apache::lonnet::dump
4623: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
4624: $env{'course.'.$env{'request.course.id'}.'.num'});
4625: my $firstkey=(keys(%changes))[0];
4626: unless ($firstkey=~/^error\:/) {
4627: unless ($env{'form.timerange'}) {
4628: $env{'form.timerange'}=604800;
4629: }
4630: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
4631: .&mt('seconds');
4632: if ($env{'form.timerange'}==-1) {
4633: $seltext='since start of course';
1.484.2.19 raeburn 4634: $startsel=' selected="selected"';
1.329 droeschl 4635: $env{'form.timerange'}=time;
4636: }
4637: $starttime=time-$env{'form.timerange'};
4638: if ($env{'form.timerange'}==2592000) {
4639: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 4640: $monthsel=' selected="selected"';
1.329 droeschl 4641: } elsif ($env{'form.timerange'}==604800) {
4642: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 4643: $weeksel=' selected="selected"';
1.329 droeschl 4644: } elsif ($env{'form.timerange'}==86400) {
4645: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 4646: $daysel=' selected="selected"';
1.329 droeschl 4647: }
4648: $header=&mt('Content changed').' '.$seltext;
4649: } else {
4650: $header=&mt('No content modifications yet.');
4651: }
4652: }
4653: %setversions=&Apache::lonnet::dump('resourceversions',
4654: $env{'course.'.$env{'request.course.id'}.'.domain'},
4655: $env{'course.'.$env{'request.course.id'}.'.num'});
4656: my %lt=&Apache::lonlocal::texthash
1.408 raeburn 4657: ('st' => 'Version changes since start of '.$crstype,
1.329 droeschl 4658: 'lm' => 'Version changes since last Month',
4659: 'lw' => 'Version changes since last Week',
4660: 'sy' => 'Version changes since Yesterday',
4661: 'al' => 'All Resources (possibly large output)',
1.484 raeburn 4662: 'cd' => 'Change display',
1.329 droeschl 4663: 'sd' => 'Display',
4664: 'fi' => 'File',
4665: 'md' => 'Modification Date',
4666: 'mr' => 'Most recently published Version',
1.408 raeburn 4667: 've' => 'Version used in '.$crstype,
4668: 'vu' => 'Set Version to be used in '.$crstype,
4669: 'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
1.329 droeschl 4670: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
4671: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.479 golterma 4672: 'di' => 'Differences',
1.484 raeburn 4673: 'save' => 'Save changes',
4674: 'vers' => 'Version choice(s) for specific resources',
1.479 golterma 4675: 'act' => 'Actions');
1.484.2.67 raeburn 4676: my ($disabled,$readonly);
4677: unless ($canedit) {
4678: $disabled = 'disabled="disabled"';
4679: $readonly = 1;
4680: }
1.329 droeschl 4681: $r->print(<<ENDHEADERS);
1.484 raeburn 4682: <h4 class="LC_info">$header</h4>
1.329 droeschl 4683: <form action="/adm/coursedocs" method="post">
4684: <input type="hidden" name="versions" value="1" />
1.484 raeburn 4685: <div class="LC_left_float">
1.479 golterma 4686: <fieldset>
1.484 raeburn 4687: <legend>$lt{'cd'}</legend>
1.329 droeschl 4688: <select name="timerange">
1.484.2.19 raeburn 4689: <option value='all'$allsel>$lt{'al'}</option>
4690: <option value="-1"$startsel>$lt{'st'}</option>
4691: <option value="2592000"$monthsel>$lt{'lm'}</option>
4692: <option value="604800"$weeksel>$lt{'lw'}</option>
4693: <option value="86400"$daysel>$lt{'sy'}</option>
1.329 droeschl 4694: </select>
4695: <input type="submit" name="display" value="$lt{'sd'}" />
1.484 raeburn 4696: </fieldset>
4697: </div>
4698: <div class="LC_left_float">
4699: <fieldset>
4700: <legend>$lt{'act'}</legend>
1.484.2.67 raeburn 4701: $lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" $disabled /><br />
4702: $lt{'sc'}: <input type="submit" name="setcurrent" value="Go" $disabled />
1.484 raeburn 4703: </fieldset>
4704: </div>
4705: <br clear="all" />
4706: <hr />
4707: <h4>$lt{'vers'}</h4>
1.329 droeschl 4708: ENDHEADERS
1.479 golterma 4709: #number of columns for version history
1.484.2.44 raeburn 4710: my %changedbytime;
4711: foreach my $key (keys(%changes)) {
4712: #excludes not versionable problems from resource version history:
4713: next if ($key =~ /^\/res\/lib\/templates/);
4714: my $chg;
4715: if ($env{'form.timerange'} eq 'all') {
4716: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
4717: $chg = &Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate');
4718: } else {
4719: $chg = $changes{$key};
4720: next if ($chg < $starttime);
4721: }
4722: push(@{$changedbytime{$chg}},$key);
4723: }
4724: if (keys(%changedbytime) == 0) {
4725: &untiehash();
4726: $r->print(&mt('No content changes in imported content in specified time frame').
4727: &endContentScreen());
4728: return;
4729: }
1.479 golterma 4730: $r->print(
1.484.2.67 raeburn 4731: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.484.2.19 raeburn 4732: &Apache::loncommon::start_data_table().
4733: &Apache::loncommon::start_data_table_header_row().
4734: '<th>'.&mt('Resources').'</th>'.
4735: "<th>$lt{'mr'}</th>".
4736: "<th>$lt{'ve'}</th>".
4737: "<th>$lt{'vu'}</th>".
4738: '<th>'.&mt('History').'</th>'.
4739: &Apache::loncommon::end_data_table_header_row()
4740: );
1.484.2.44 raeburn 4741: foreach my $chg (sort {$b <=> $a } keys(%changedbytime)) {
4742: foreach my $key (sort(@{$changedbytime{$chg}})) {
4743: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
4744: my $currentversion=&Apache::lonnet::getversion($key);
4745: if ($currentversion<0) {
4746: $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
4747: }
4748: my $linkurl=&Apache::lonnet::clutter($key);
4749: $r->print(
4750: &Apache::loncommon::start_data_table_row().
4751: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br />'.
4752: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
4753: '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br />('.
4754: &Apache::lonlocal::locallocaltime($chg).')</span></td>'.
4755: '<td align="right">'
4756: );
4757: # Used in course
4758: my $usedversion=$hash{'version_'.$linkurl};
4759: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.484.2.19 raeburn 4760: if ($usedversion != $currentversion) {
1.479 golterma 4761: $r->print('<span class="LC_warning">'.$usedversion.'</span>');
1.484.2.19 raeburn 4762: } else {
1.479 golterma 4763: $r->print($usedversion);
4764: }
1.329 droeschl 4765: } else {
1.484.2.19 raeburn 4766: $r->print($currentversion);
1.329 droeschl 4767: }
1.484.2.44 raeburn 4768: $r->print('</td><td title="'.$lt{'vu'}.'">');
4769: # Set version
4770: $r->print(&Apache::loncommon::select_form(
4771: $setversions{$linkurl},
4772: 'set_version_'.$linkurl,
4773: {'select_form_order' => ['',1..$currentversion,'mostrecent'],
4774: '' => '',
4775: 'mostrecent' => &mt('most recent'),
1.484.2.67 raeburn 4776: map {$_,$_} (1..$currentversion)},'',$readonly));
1.484.2.44 raeburn 4777: my $lastold=1;
4778: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
4779: my $url=$root.'.'.$prevvers.'.'.$extension;
4780: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) {
4781: $lastold=$prevvers;
4782: }
4783: }
4784: $r->print('</td>');
4785: # List all available versions
4786: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
4787: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
4788: my $url=$root.'.'.$prevvers.'.'.$extension;
1.484.2.19 raeburn 4789: $r->print(
1.484.2.44 raeburn 4790: '<span class="LC_nobreak">'
4791: .'<a href="'.&Apache::lonnet::clutter($url).'">'
4792: .&mt('Version [_1]',$prevvers).'</a>'
4793: .' ('.&Apache::lonlocal::locallocaltime(
4794: &Apache::lonnet::metadata($url,'lastrevisiondate'))
4795: .')');
4796: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
4797: $r->print(
4798: ' <a href="/adm/diff?filename='.
4799: &Apache::lonnet::clutter($root.'.'.$extension).
4800: &HTML::Entities::encode('&versionone='.$prevvers,'"<>&').
4801: '" target="diffs">'.&mt('Diffs').'</a>');
4802: }
4803: $r->print('</span><br />');
1.329 droeschl 4804: }
1.484.2.44 raeburn 4805: $r->print('</span></td>'.&Apache::loncommon::end_data_table_row());
1.484.2.19 raeburn 4806: }
1.329 droeschl 4807: }
1.484.2.19 raeburn 4808: $r->print(
4809: &Apache::loncommon::end_data_table().
1.484.2.67 raeburn 4810: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.484.2.19 raeburn 4811: '</form>'
4812: );
1.329 droeschl 4813:
4814: &untiehash();
1.484.2.19 raeburn 4815: $r->print(&endContentScreen());
1.484.2.44 raeburn 4816: return;
1.329 droeschl 4817: }
4818:
4819: sub mark_hash_old {
4820: my $retie_hash=0;
4821: if ($hashtied) {
4822: $retie_hash=1;
4823: &untiehash();
4824: }
4825: &tiehash('write');
4826: $hash{'old'}=1;
4827: &untiehash();
4828: if ($retie_hash) { &tiehash(); }
4829: }
4830:
4831: sub is_hash_old {
4832: my $untie_hash=0;
4833: if (!$hashtied) {
4834: $untie_hash=1;
4835: &tiehash();
4836: }
4837: my $return=$hash{'old'};
4838: if ($untie_hash) { &untiehash(); }
4839: return $return;
4840: }
4841:
4842: sub changewarning {
4843: my ($r,$postexec,$message,$url)=@_;
4844: if (!&is_hash_old()) { return; }
4845: my $pathvar='folderpath';
4846: my $path=&escape($env{'form.folderpath'});
4847: if (!defined($url)) {
4848: $url='/adm/coursedocs?'.$pathvar.'='.$path;
4849: }
4850: my $course_type = &Apache::loncommon::course_type();
4851: if (!defined($message)) {
4852: $message='Changes will become active for your current session after [_1], or the next time you log in.';
4853: }
4854: $r->print("\n\n".
1.372 bisitz 4855: '<script type="text/javascript">'."\n".
4856: '// <![CDATA['."\n".
4857: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
4858: '// ]]>'."\n".
1.369 bisitz 4859: '</script>'."\n".
1.375 tempelho 4860: '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
1.329 droeschl 4861: '<input type="hidden" name="orgurl" value="'.$url.
1.372 bisitz 4862: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
1.329 droeschl 4863: &mt($message,' <input type="hidden" name="'.
4864: $env{'request.role'}.'" value="1" /><input type="button" value="'.
1.369 bisitz 4865: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1.372 bisitz 4866: $help{'Caching'}.'</p></form>'."\n\n");
1.329 droeschl 4867: }
4868:
4869:
4870: sub init_breadcrumbs {
1.484.2.44 raeburn 4871: my ($form,$text,$help)=@_;
1.329 droeschl 4872: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484 raeburn 4873: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
1.405 bisitz 4874: text=>&Apache::loncommon::course_type().' Editor',
1.329 droeschl 4875: faq=>273,
4876: bug=>'Instructor Interface',
1.484.2.44 raeburn 4877: help => $help});
1.329 droeschl 4878: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
4879: text=>$text,
4880: faq=>273,
4881: bug=>'Instructor Interface'});
4882: }
4883:
1.441 www 4884: # subroutine to list form elements
4885: sub create_list_elements {
4886: my @formarr = @_;
4887: my $list = '';
1.484.2.12 raeburn 4888: foreach my $button (@formarr){
4889: foreach my $picture (keys(%{$button})) {
4890: $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
1.441 www 4891: }
4892: }
4893: return $list;
4894: }
1.329 droeschl 4895:
1.441 www 4896: # subroutine to create ul from list elements
4897: sub create_form_ul {
4898: my $list = shift;
4899: my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
4900: return $ul;
4901: }
1.329 droeschl 4902:
1.442 www 4903: #
4904: # Start tabs
4905: #
4906:
4907: sub startContentScreen {
1.484 raeburn 4908: my ($mode) = @_;
4909: my $output = '<ul class="LC_TabContentBigger" id="mainnav">';
1.472 raeburn 4910: if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
1.484 raeburn 4911: $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n";
4912: $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n";
4913: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
4914: } else {
1.484.2.34 raeburn 4915: $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 4916: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
4917: $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>'."\n";
4918: '><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>';
4919: }
4920: $output .= "\n".'</ul>'."\n";
4921: $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
4922: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
4923: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
4924: return $output;
1.442 www 4925: }
4926:
4927: #
4928: # End tabs
4929: #
4930:
4931: sub endContentScreen {
1.484 raeburn 4932: return '</div></div></div>';
1.442 www 4933: }
1.329 droeschl 4934:
1.446 www 4935: sub supplemental_base {
1.484.2.33 raeburn 4936: return 'supplemental&'.&escape(&mt('Supplemental Content'));
1.446 www 4937: }
4938:
1.329 droeschl 4939: sub handler {
4940: my $r = shift;
4941: &Apache::loncommon::content_type($r,'text/html');
4942: $r->send_http_header;
4943: return OK if $r->header_only;
1.484 raeburn 4944:
4945: # get course data
1.408 raeburn 4946: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 4947: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
4948: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
4949:
4950: # graphics settings
4951: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329 droeschl 4952:
1.443 www 4953: #
1.329 droeschl 4954: # --------------------------------------------- Initialize help topics for this
4955: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
1.484.2.72.4. (raeburn 4956:): 'Adding_External_Resource','Adding_External_Tool',
4957:): 'Navigate_Content','Adding_Folders','Docs_Overview',
4958:): 'Load_Map','Supplemental','Score_Upload_Form',
4959:): 'Adding_Pages','Importing_LON-CAPA_Resource',
4960:): 'Importing_IMS_Course','Uploading_From_Harddrive',
4961:): 'Course_Roster','Web_Page','Dropbox','Simple_Problem') {
1.329 droeschl 4962: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
4963: }
4964: # Composite help files
4965: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
4966: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
4967: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
4968: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
4969: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
4970: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 4971: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 4972: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 4973: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 4974: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1.484.2.30 raeburn 4975:
1.484.2.67 raeburn 4976: my ($allowed,$canedit,$canview,$disabled);
1.472 raeburn 4977: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
4978: unless ($r->uri eq '/adm/supplemental') {
4979: # does this user have privileges to modify content.
1.484.2.67 raeburn 4980: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
4981: $allowed = 1;
4982: $canedit = 1;
4983: $canview = 1;
4984: } elsif (&Apache::lonnet::allowed('cev',$env{'request.course.id'})) {
4985: $allowed = 1;
4986: $canview = 1;
4987: }
4988: }
4989: unless ($canedit) {
4990: $disabled = ' disabled="disabled"';
1.472 raeburn 4991: }
1.484.2.53 raeburn 4992: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']);
4993: if ($allowed && $env{'form.verify'}) {
1.484.2.44 raeburn 4994: &init_breadcrumbs('verify','Verify Content','Docs_Verify_Content');
1.329 droeschl 4995: &verifycontent($r);
4996: } elsif ($allowed && $env{'form.listsymbs'}) {
1.484 raeburn 4997: &init_breadcrumbs('listsymbs','List Content IDs');
1.329 droeschl 4998: &list_symbs($r);
4999: } elsif ($allowed && $env{'form.docslog'}) {
5000: &init_breadcrumbs('docslog','Show Log');
1.484 raeburn 5001: my $folder = $env{'form.folder'};
5002: if ($folder eq '') {
5003: $folder='default';
5004: }
1.484.2.67 raeburn 5005: &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit);
1.329 droeschl 5006: } elsif ($allowed && $env{'form.versions'}) {
1.484.2.44 raeburn 5007: &init_breadcrumbs('versions','Check/Set Resource Versions','Docs_Check_Resource_Versions');
1.484.2.67 raeburn 5008: &checkversions($r,$canedit);
5009: } elsif ($canedit && $env{'form.dumpcourse'}) {
1.484.2.43 raeburn 5010: &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329 droeschl 5011: &dumpcourse($r);
5012: } elsif ($allowed && $env{'form.exportcourse'}) {
1.377 bisitz 5013: &init_breadcrumbs('exportcourse','IMS Export');
1.475 raeburn 5014: &Apache::imsexport::exportcourse($r);
1.329 droeschl 5015: } else {
1.445 www 5016: #
5017: # Done catching special calls
1.484 raeburn 5018: # The whole rest is for course and supplemental documents and utilities menu
1.445 www 5019: # Get the parameters that may be needed
5020: #
5021: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.484.2.19 raeburn 5022: ['folderpath',
5023: 'forcesupplement','forcestandard',
5024: 'tools','symb','command','supppath']);
1.445 www 5025:
5026: # standard=1: this is a "new-style" course with an uploaded map as top level
5027: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329 droeschl 5028:
5029: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445 www 5030:
1.484 raeburn 5031: # Decide whether this should display supplemental or main content or utilities
1.445 www 5032: # supplementalflag=1: show supplemental documents
5033: # supplementalflag=0: show standard documents
1.484 raeburn 5034: # toolsflag=1: show utilities
1.445 www 5035:
1.484.2.39 raeburn 5036: my $unesc_folderpath = &unescape($env{'form.folderpath'});
5037: my $supplementalflag=($unesc_folderpath=~/^supplemental/);
5038: if (($unesc_folderpath=~/^default/) || ($unesc_folderpath eq "")) {
1.445 www 5039: $supplementalflag=0;
5040: }
5041: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
5042: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
5043: unless ($allowed) { $supplementalflag=1; }
5044: unless ($standard) { $supplementalflag=1; }
1.484 raeburn 5045: my $toolsflag=0;
5046: if ($env{'form.tools'}) { $toolsflag=1; }
1.445 www 5047:
1.329 droeschl 5048: my $script='';
5049: my $showdoc=0;
1.457 raeburn 5050: my $addentries = {};
1.475 raeburn 5051: my $container;
1.329 droeschl 5052: my $containertag;
1.484.2.17 raeburn 5053: my $pathitem;
1.484.2.72.4. (raeburn 5054:): my %ltitools;
1.484.2.67 raeburn 5055: my $hiddentop;
5056: my $navmap;
5057: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.329 droeschl 5058:
1.464 www 5059: # Do we directly jump somewhere?
1.484.2.21 raeburn 5060: if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
1.472 raeburn 5061: if ($env{'form.symb'} ne '') {
1.484.2.19 raeburn 5062: $env{'form.folderpath'}=
1.484.2.67 raeburn 5063: &Apache::loncommon::symb_to_docspath($env{'form.symb'},\$navmap);
1.484.2.21 raeburn 5064: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
5065: $env{'form.command'}.'_'.$env{'form.symb'}});
1.472 raeburn 5066: } elsif ($env{'form.supppath'} ne '') {
5067: $env{'form.folderpath'}=$env{'form.supppath'};
1.484.2.21 raeburn 5068: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
5069: $env{'form.command'}.'_'.$env{'form.supppath'}});
1.466 www 5070: }
1.472 raeburn 5071: } elsif ($env{'form.command'} eq 'editdocs') {
1.484.2.67 raeburn 5072: $env{'form.folderpath'} = &default_folderpath($coursenum,$coursedom,\$navmap);
1.484.2.21 raeburn 5073: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
1.472 raeburn 5074: } elsif ($env{'form.command'} eq 'editsupp') {
1.484.2.67 raeburn 5075: $env{'form.folderpath'} = &supplemental_base();
1.484.2.21 raeburn 5076: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
5077: } elsif ($env{'form.command'} eq 'contents') {
5078: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
5079: } elsif ($env{'form.command'} eq 'home') {
5080: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
1.464 www 5081: }
5082:
1.484.2.23 raeburn 5083:
1.445 www 5084: # Where do we store these for when we come back?
5085: my $stored_folderpath='docs_folderpath';
5086: if ($supplementalflag) {
5087: $stored_folderpath='docs_sup_folderpath';
5088: }
1.464 www 5089:
1.484.2.19 raeburn 5090: # No folderpath, and in edit mode, see if we have something stored
5091: if ((!$env{'form.folderpath'}) && $allowed) {
1.445 www 5092: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.484.2.19 raeburn 5093: {'folderpath' => 'scalar'});
1.484.2.67 raeburn 5094:
5095: if (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
5096: if ($supplementalflag) {
5097: undef($env{'form.folderpath'}) if ($1 eq 'default');
5098: } else {
5099: undef($env{'form.folderpath'}) if ($1 eq 'supplemental');
5100: }
5101: } else {
1.484.2.19 raeburn 5102: undef($env{'form.folderpath'});
5103: }
1.329 droeschl 5104: }
1.446 www 5105:
5106: # If we are not allowed to make changes, all we can see are supplemental docs
1.409 raeburn 5107: if (!$allowed) {
1.446 www 5108: unless ($env{'form.folderpath'} =~ /^supplemental/) {
5109: $env{'form.folderpath'} = &supplemental_base();
1.409 raeburn 5110: }
5111: }
1.446 www 5112: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329 droeschl 5113: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446 www 5114: $env{'form.folderpath'} = &supplemental_base()
5115: .'&'.
1.329 droeschl 5116: $env{'form.folderpath'};
5117: }
1.484.2.67 raeburn 5118: # If allowed and user's role is not advanced check folderpath is not hidden
5119: if (($allowed) && (!$env{'request.role.adv'}) &&
5120: ($env{'form.folderpath'} ne '') && (!$supplementalflag)) {
5121: my $folderurl;
5122: my @pathitems = split(/\&/,$env{'form.folderpath'});
5123: my $folder = $pathitems[-2];
5124: if ($folder eq '') {
5125: undef($env{'form.folderpath'});
5126: } else {
5127: $folderurl = "uploaded/$coursedom/$coursenum/$folder";
5128: if ((split(/\:/,$pathitems[-1]))[4]) {
5129: $folderurl .= '.page';
5130: } else {
5131: $folderurl .= '.sequence';
5132: }
5133: unless (ref($navmap)) {
5134: $navmap = Apache::lonnavmaps::navmap->new();
5135: }
5136: if (ref($navmap)) {
5137: if (lc($navmap->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
5138: my @resources = $navmap->retrieveResources($folderurl,$filterFunc,1,1);
5139: unless (@resources) {
5140: undef($env{'form.folderpath'});
5141: }
5142: }
5143: }
5144: }
5145: }
5146:
5147:
1.446 www 5148: # If after all of this, we still don't have any paths, make them
1.484.2.19 raeburn 5149: unless ($env{'form.folderpath'}) {
1.446 www 5150: if ($supplementalflag) {
5151: $env{'form.folderpath'}=&supplemental_base();
1.484.2.67 raeburn 5152: } elsif ($allowed) {
5153: ($env{'form.folderpath'},$hiddentop) = &default_folderpath($coursenum,$coursedom,\$navmap);
1.446 www 5154: }
1.472 raeburn 5155: }
1.446 www 5156:
1.445 www 5157: # Store this
1.484 raeburn 5158: unless ($toolsflag) {
1.484.2.67 raeburn 5159: if (($allowed) && ($env{'form.folderpath'} ne '')) {
1.484.2.19 raeburn 5160: &Apache::loncommon::store_course_settings($stored_folderpath,
5161: {'folderpath' => 'scalar'});
5162: }
5163: my $folderpath;
1.484 raeburn 5164: if ($env{'form.folderpath'}) {
1.484.2.19 raeburn 5165: $folderpath = $env{'form.folderpath'};
5166: my (@folders)=split('&',$env{'form.folderpath'});
5167: $env{'form.foldername'}=&unescape(pop(@folders));
5168: if ($env{'form.foldername'} =~ /\:1$/) {
5169: $container = 'page';
5170: } else {
5171: $container = 'sequence';
5172: }
5173: $env{'form.folder'}=pop(@folders);
1.484 raeburn 5174: } else {
1.484.2.19 raeburn 5175: if ($env{'form.folder'} eq '' ||
5176: $env{'form.folder'} eq 'supplemental') {
1.484.2.67 raeburn 5177: if ($env{'form.folder'} eq 'supplemental') {
5178: $folderpath=&supplemental_base();
5179: } elsif (!$hiddentop) {
5180: $folderpath='default&'.
5181: &escape(&mt('Main Content').':::::');
5182: }
1.484 raeburn 5183: }
5184: }
1.484.2.19 raeburn 5185: $containertag = '<input type="hidden" name="folderpath" value="" />';
5186: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 5187: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
5188: $showdoc='/'.$1;
5189: }
5190: if ($showdoc) { # got called in sequence from course
5191: $allowed=0;
5192: } else {
1.484.2.67 raeburn 5193: if ($canedit) {
1.484 raeburn 5194: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
5195: $script=&Apache::lonratedt::editscript('simple');
1.433 raeburn 5196: }
5197: }
1.329 droeschl 5198: }
5199:
1.344 bisitz 5200: # get personal data
1.329 droeschl 5201: my $uname=$env{'user.name'};
5202: my $udom=$env{'user.domain'};
5203: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
5204:
5205: if ($allowed) {
1.484 raeburn 5206: if ($toolsflag) {
5207: $script .= &inject_data_js();
5208: my ($home,$other,%outhash)=&authorhosts();
5209: if (!$home && $other) {
5210: my @hosts;
5211: foreach my $aurole (keys(%outhash)) {
5212: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
5213: push(@hosts,$outhash{$aurole});
5214: }
5215: }
5216: $script .= &dump_switchserver_js(@hosts);
5217: }
1.458 raeburn 5218: } else {
1.484.2.43 raeburn 5219: my $tid = 1;
1.484 raeburn 5220: my @tabids;
5221: if ($supplementalflag) {
5222: @tabids = ('002','ee2','ff2');
1.484.2.43 raeburn 5223: $tid = 2;
1.484 raeburn 5224: } else {
5225: @tabids = ('aa1','bb1','cc1','ff1');
1.484.2.19 raeburn 5226: unless ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 5227: unshift(@tabids,'001');
5228: push(@tabids,('dd1','ee1'));
5229: }
1.458 raeburn 5230: }
1.484 raeburn 5231: my $tabidstr = join("','",@tabids);
1.484.2.72.4. (raeburn 5232:): %ltitools = &Apache::lonnet::get_domain_lti($coursedom,'consumer');
5233:): my $posslti = keys(%ltitools);
5234:): $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
1.484.2.67 raeburn 5235: $canedit,\$navmap).
1.484 raeburn 5236: &history_tab_js().
5237: &inject_data_js().
1.484.2.43 raeburn 5238: &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
1.484.2.72.4. (raeburn 5239:): &Apache::lonextresedit::extedit_javascript(\%ltitools);
1.484 raeburn 5240: $addentries = {
1.484.2.3 raeburn 5241: onload => "javascript:resize_scrollbox('contentscroll','1','1');",
1.484 raeburn 5242: };
1.458 raeburn 5243: }
1.484.2.30 raeburn 5244: $script .= &paste_popup_js();
1.484.2.12 raeburn 5245: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
5246: &mt('Switch server?');
1.484.2.19 raeburn 5247:
5248:
1.329 droeschl 5249: }
5250: # -------------------------------------------------------------------- Body tag
1.369 bisitz 5251: $script = '<script type="text/javascript">'."\n"
1.372 bisitz 5252: .'// <![CDATA['."\n"
5253: .$script."\n"
5254: .'// ]]>'."\n"
5255: .'</script>'."\n";
1.385 bisitz 5256:
5257: # Breadcrumbs
5258: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484.2.19 raeburn 5259:
5260: if ($showdoc) {
5261: $r->print(&Apache::loncommon::start_page("$crstype documents",undef,
5262: {'force_register' => $showdoc,}));
1.484.2.44 raeburn 5263: } elsif ($toolsflag) {
1.484.2.67 raeburn 5264: my ($breadtext,$breadtitle);
5265: $breadtext = "$crstype Editor";
5266: if ($canedit) {
5267: $breadtitle = 'Editing '.$crstype.' Contents';
5268: } else {
5269: $breadtext .= ' (View-only mode)';
5270: $breadtitle = 'Viewing '.$crstype.' Contents';
5271: }
1.484.2.44 raeburn 5272: &Apache::lonhtmlcommon::add_breadcrumb({
1.484.2.67 raeburn 5273: href=>"/adm/coursedocs",text=>$breadtext});
1.484.2.44 raeburn 5274: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script)
5275: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5276: .&Apache::lonhtmlcommon::breadcrumbs(
1.484.2.67 raeburn 5277: $breadtitle)
1.484.2.44 raeburn 5278: );
1.484.2.19 raeburn 5279: } elsif ($r->uri eq '/adm/supplemental') {
5280: my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
5281: $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
5282: {'bread_crumbs' => $brcrum,}));
5283: } else {
1.484.2.67 raeburn 5284: my ($breadtext,$breadtitle,$helpitem);
5285: $breadtext = "$crstype Editor";
5286: if ($canedit) {
5287: $breadtitle = 'Editing '.$crstype.' Contents';
5288: $helpitem = 'Docs_Adding_Course_Doc';
5289: } else {
5290: $breadtext .= ' (View-only mode)';
5291: $breadtitle = 'Viewing '.$crstype.' Contents';
5292: $helpitem = 'Docs_Viewing_Course_Doc';
5293: }
1.392 raeburn 5294: &Apache::lonhtmlcommon::add_breadcrumb({
1.484.2.67 raeburn 5295: href=>"/adm/coursedocs",text=>$breadtext});
1.446 www 5296: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.484.2.19 raeburn 5297: {'add_entries' => $addentries}
5298: )
1.392 raeburn 5299: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5300: .&Apache::lonhtmlcommon::breadcrumbs(
1.484.2.67 raeburn 5301: $breadtitle,
5302: $helpitem)
1.392 raeburn 5303: );
5304: }
1.364 bisitz 5305:
1.329 droeschl 5306: my %allfiles = ();
5307: my %codebase = ();
1.440 raeburn 5308: my ($upload_result,$upload_output,$uploadphase);
1.484.2.67 raeburn 5309: if ($canedit) {
1.329 droeschl 5310: if (($env{'form.uploaddoc.filename'}) &&
5311: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440 raeburn 5312: my $context = $1;
5313: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 5314: undef($hadchanges);
1.440 raeburn 5315: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
1.484.2.36 raeburn 5316: \%allfiles,\%codebase,$context,$crstype);
1.329 droeschl 5317: if ($hadchanges) {
5318: &mark_hash_old();
5319: }
1.440 raeburn 5320: $r->print($upload_output);
5321: } elsif ($env{'form.phase'} eq 'upload_embedded') {
5322: # Process file upload - phase two - upload embedded objects
5323: $uploadphase = 'check_embedded';
5324: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
5325: my $state = &embedded_form_elems($uploadphase,$primaryurl,
5326: $env{'form.newidx'});
5327: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5328: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5329: my ($destination,$dir_root) = &embedded_destination();
5330: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
5331: my $actionurl = '/adm/coursedocs';
5332: my ($result,$flag) =
5333: &Apache::loncommon::upload_embedded('coursedoc',$destination,
5334: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
5335: $actionurl);
5336: $r->print($result.&return_to_editor());
5337: } elsif ($env{'form.phase'} eq 'check_embedded') {
5338: # Process file upload - phase three - modify references in HTML file
5339: $uploadphase = 'modified_orightml';
5340: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5341: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5342: my ($destination,$dir_root) = &embedded_destination();
1.482 raeburn 5343: my $result =
5344: &Apache::loncommon::modify_html_refs('coursedoc',$destination,
5345: $docuname,$docudom,undef,
5346: $dir_root);
5347: $r->print($result.&return_to_editor());
1.476 raeburn 5348: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
5349: $uploadphase = 'decompress_phase_one';
5350: $r->print(&decompression_phase_one().
5351: &return_to_editor());
5352: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
5353: $uploadphase = 'decompress_phase_two';
5354: $r->print(&decompression_phase_two().
5355: &return_to_editor());
1.329 droeschl 5356: }
5357: }
5358:
1.484 raeburn 5359: if ($allowed && $toolsflag) {
5360: $r->print(&startContentScreen('tools'));
1.484.2.67 raeburn 5361: $r->print(&generate_admin_menu($crstype,$canedit));
1.484 raeburn 5362: $r->print(&endContentScreen());
5363: } elsif ((!$showdoc) && (!$uploadphase)) {
1.329 droeschl 5364: # -----------------------------------------------------------------------------
5365: my %lt=&Apache::lonlocal::texthash(
5366: 'copm' => 'All documents out of a published map into this folder',
1.484.2.12 raeburn 5367: 'upfi' => 'Upload File',
1.484.2.36 raeburn 5368: 'upld' => 'Upload Content',
1.329 droeschl 5369: 'srch' => 'Search',
5370: 'impo' => 'Import',
1.484.2.19 raeburn 5371: 'lnks' => 'Import from Stored Links',
1.484.2.13 raeburn 5372: 'impm' => 'Import from Assembled Map',
1.484.2.72.4. (raeburn 5373:): 'extr' => 'External Resource',
5374:): 'extt' => 'External Tool',
1.329 droeschl 5375: 'selm' => 'Select Map',
5376: 'load' => 'Load Map',
5377: 'newf' => 'New Folder',
5378: 'newp' => 'New Composite Page',
5379: 'syll' => 'Syllabus',
1.425 raeburn 5380: 'navc' => 'Table of Contents',
1.343 biermanm 5381: 'sipa' => 'Simple Course Page',
1.329 droeschl 5382: 'sipr' => 'Simple Problem',
1.484.2.27 raeburn 5383: 'webp' => 'Blank Web Page (editable)',
1.329 droeschl 5384: 'drbx' => 'Drop Box',
1.451 www 5385: 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336 schafran 5386: 'bull' => 'Discussion Board',
1.347 weissno 5387: 'mypi' => 'My Personal Information Page',
1.353 weissno 5388: 'grpo' => 'Group Portfolio',
1.329 droeschl 5389: 'rost' => 'Course Roster',
1.484.2.22 raeburn 5390: 'abou' => 'Personal Information Page for a User',
1.484.2.36 raeburn 5391: 'imsf' => 'IMS Upload',
5392: 'imsl' => 'Upload IMS package',
1.484.2.12 raeburn 5393: 'cms' => 'Origin of IMS package',
5394: 'se' => 'Select',
1.484.2.19 raeburn 5395: 'file' => 'File',
1.329 droeschl 5396: 'title' => 'Title',
5397: 'comment' => 'Comment',
1.403 raeburn 5398: 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.484.2.50 raeburn 5399: 'bb5' => 'Blackboard 5',
5400: 'bb6' => 'Blackboard 6',
5401: 'angel5' => 'ANGEL 5.5',
5402: 'webctce4' => 'WebCT 4 Campus Edition',
1.484.2.67 raeburn 5403: 'er' => 'Editing rights unavailable for your current role.',
1.484.2.50 raeburn 5404: );
1.329 droeschl 5405: # -----------------------------------------------------------------------------
1.484.2.64 raeburn 5406: # Calculate free quota space for a user or course.
5407: my $quotatype = 'unofficial';
5408: if ($crstype eq 'Community') {
5409: $quotatype = 'community';
5410: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
5411: $quotatype = 'official';
5412: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
5413: $quotatype = 'textbook';
5414: }
5415: my $disk_quota = &Apache::loncommon::get_user_quota($coursenum,$coursedom,
5416: 'course',$quotatype); # expressed in MB
5417: my $current_disk_usage = 0;
5418: foreach my $subdir ('docs','supplemental') {
5419: $current_disk_usage += &Apache::lonnet::diskusage($coursedom,$coursenum,
5420: "userfiles/$subdir",1); # expressed in kB
5421: }
5422: my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage);
5423: my $usage = $current_disk_usage/1024; # in MB
5424: my $quota = $disk_quota;
5425: my $percent;
5426: if ($disk_quota == 0) {
5427: $percent = 100.0;
5428: } else {
1.484.2.69 raeburn 5429: $percent = 100*($usage/$disk_quota);
1.484.2.64 raeburn 5430: }
5431: $usage = sprintf("%.2f",$usage);
5432: $quota = sprintf("%.2f",$quota);
5433: $percent = sprintf("%.0f",$percent);
5434: my $quotainfo = '<p>'.&mt('Currently using [_1] of the [_2] available.',
5435: $percent.'%',$quota.' MB').'</p>';
5436:
1.329 droeschl 5437: my $fileupload=(<<FIUP);
1.484.2.64 raeburn 5438: $quotainfo
1.329 droeschl 5439: $lt{'file'}:<br />
1.484.2.67 raeburn 5440: <input type="file" name="uploaddoc" size="40" $disabled />
1.329 droeschl 5441: FIUP
5442:
5443: my $checkbox=(<<CHBO);
5444: <!-- <label>$lt{'parse'}?
5445: <input type="checkbox" name="parserflag" />
5446: </label> -->
5447: <label>
1.484.2.67 raeburn 5448: <input type="checkbox" name="parserflag" checked="checked" $disabled /> $lt{'parse'}
1.329 droeschl 5449: </label>
5450: CHBO
1.484.2.12 raeburn 5451: my $imsfolder = $env{'form.folder'};
5452: if ($imsfolder eq '') {
1.484.2.19 raeburn 5453: $imsfolder = 'default';
1.484.2.12 raeburn 5454: }
5455: my $imspform=(<<IMSFORM);
5456: <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
5457: $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
5458: <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
1.484.2.19 raeburn 5459: <fieldset id="uploadimsform" style="display: none;">
1.484.2.12 raeburn 5460: <legend>$lt{'imsf'}</legend>
5461: $fileupload
5462: <br />
5463: <p>
1.484.2.19 raeburn 5464: $lt{'cms'}:
1.484.2.67 raeburn 5465: <select name="source" $disabled>
1.484.2.12 raeburn 5466: <option value="-1" selected="selected">$lt{'se'}</option>
1.484.2.50 raeburn 5467: <option value="bb5">$lt{'bb5'}</option>
5468: <option value="bb6">$lt{'bb6'}</option>
5469: <option value="angel5">$lt{'angel5'}</option>
5470: <option value="webctce4">$lt{'webctce4'}</option>
1.484.2.12 raeburn 5471: </select>
5472: <input type="hidden" name="folder" value="$imsfolder" />
5473: </p>
5474: <input type="hidden" name="phase" value="one" />
1.484.2.67 raeburn 5475: <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" $disabled />
1.484.2.12 raeburn 5476: </fieldset>
5477: </form>
5478: IMSFORM
5479:
1.484.2.19 raeburn 5480: my $fileuploadform=(<<FUFORM);
1.484.2.12 raeburn 5481: <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
5482: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
5483: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.484.2.19 raeburn 5484: <fieldset id="uploaddocform" style="display: none;">
1.484.2.12 raeburn 5485: <legend>$lt{'upfi'}</legend>
1.371 tempelho 5486: <input type="hidden" name="active" value="aa" />
1.329 droeschl 5487: $fileupload
5488: <br />
5489: $lt{'title'}:<br />
1.484.2.67 raeburn 5490: <input type="text" size="60" name="comment" $disabled />
1.484.2.17 raeburn 5491: $pathitem
1.329 droeschl 5492: <input type="hidden" name="cmd" value="upload_default" />
5493: <br />
1.458 raeburn 5494: <span class="LC_nobreak" style="float:left">
1.329 droeschl 5495: $checkbox
5496: </span>
1.484.2.12 raeburn 5497: <br clear="all" />
1.484.2.67 raeburn 5498: <input type="submit" value="$lt{'upld'}" $disabled />
1.484.2.12 raeburn 5499: </fieldset>
5500: </form>
1.383 tempelho 5501: FUFORM
1.329 droeschl 5502:
1.484.2.67 raeburn 5503: my $mapimportjs;
5504: if ($canedit) {
5505: $mapimportjs = "javascript:openbrowser('mapimportform','importmap','sequence,page','');";
5506: } else {
5507: $mapimportjs = "javascript:alert('".&js_escape($lt{'er'})."');";
5508: }
1.484.2.19 raeburn 5509: my $importpubform=(<<SEDFFORM);
5510: <a class="LC_menubuttons_link" href="javascript:toggleMap('map');">
1.484.2.13 raeburn 5511: $lt{'impm'}</a>$help{'Load_Map'}
1.484.2.19 raeburn 5512: <form action="/adm/coursedocs" method="post" name="mapimportform">
5513: <fieldset id="importmapform" style="display: none;">
1.484.2.13 raeburn 5514: <legend>$lt{'impm'}</legend>
1.484.2.19 raeburn 5515: <input type="hidden" name="active" value="bb" />
1.484.2.13 raeburn 5516: $lt{'copm'}<br />
5517: <span class="LC_nobreak">
1.484.2.19 raeburn 5518: <input type="text" name="importmap" size="40" value=""
1.484.2.67 raeburn 5519: onfocus="this.blur();$mapimportjs" $disabled />
5520: <a href="$mapimportjs">$lt{'selm'}</a></span><br />
5521: <input type="submit" name="loadmap" value="$lt{'load'}" $disabled />
1.484.2.13 raeburn 5522: </fieldset>
5523: </form>
5524:
1.383 tempelho 5525: SEDFFORM
1.484.2.67 raeburn 5526:
5527: my $fromstoredjs;
5528: if ($canedit) {
5529: $fromstoredjs = 'open_StoredLinks_Import()';
5530: } else {
5531: $fromstoredjs = "alert('".&js_escape($lt{'er'})."')";
5532: }
5533:
1.484.2.19 raeburn 5534: my @importpubforma = (
5535: { '<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 5536: { '<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 5537: { '<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 5538: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform }
5539: );
5540: $importpubform = &create_form_ul(&create_list_elements(@importpubforma));
5541: my $extresourcesform =
5542: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
1.484.2.67 raeburn 5543: $help{'Adding_External_Resource'},
1.484.2.72.4. (raeburn 5544:): undef,undef,undef,undef,undef,undef,$disabled);
5545:): my $exttoolform =
5546:): &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
5547:): $help{'Adding_External_Tool'},undef,
5548:): undef,'tool',$coursedom,$coursenum,
5549:): \%ltitools,$disabled);
1.329 droeschl 5550: if ($allowed) {
1.484.2.7 raeburn 5551: my $folder = $env{'form.folder'};
5552: if ($folder eq '') {
5553: $folder='default';
5554: }
1.484.2.67 raeburn 5555: if ($canedit) {
5556: my $output = &update_paste_buffer($coursenum,$coursedom,$folder);
5557: if ($output) {
5558: $r->print($output);
5559: }
1.484.2.30 raeburn 5560: }
1.337 ehlerst 5561: $r->print(<<HIDDENFORM);
5562: <form name="renameform" method="post" action="/adm/coursedocs">
5563: <input type="hidden" name="title" />
5564: <input type="hidden" name="cmd" />
5565: <input type="hidden" name="markcopy" />
5566: <input type="hidden" name="copyfolder" />
5567: $containertag
5568: </form>
1.484 raeburn 5569:
1.337 ehlerst 5570: HIDDENFORM
1.484.2.17 raeburn 5571: $r->print(&makesimpleeditform($pathitem)."\n".
5572: &makedocslogform($pathitem."\n".
1.484 raeburn 5573: '<input type="hidden" name="folder" value="'.
5574: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 5575: }
1.442 www 5576:
5577: # Generate the tabs
1.484.2.19 raeburn 5578: my ($mode,$needs_end);
1.472 raeburn 5579: if (($supplementalflag) && (!$allowed)) {
1.484.2.19 raeburn 5580: my @folders = split('&',$env{'form.folderpath'});
5581: unless (@folders > 2) {
5582: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
5583: $needs_end = 1;
5584: }
1.472 raeburn 5585: } else {
1.484 raeburn 5586: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484.2.19 raeburn 5587: $needs_end = 1;
1.472 raeburn 5588: }
1.443 www 5589:
1.442 www 5590: #
5591:
5592: my $savefolderpath;
5593:
1.395 raeburn 5594: if ($allowed) {
1.329 droeschl 5595: my $folder=$env{'form.folder'};
1.484.2.67 raeburn 5596: if ((($folder eq '') && (!$hiddentop)) || ($supplementalflag)) {
1.329 droeschl 5597: $folder='default';
1.356 tempelho 5598: $savefolderpath = $env{'form.folderpath'};
1.484.2.33 raeburn 5599: $env{'form.folderpath'}='default&'.&escape(&mt('Main Content'));
1.484.2.17 raeburn 5600: $pathitem = '<input type="hidden" name="folderpath" value="'.
1.329 droeschl 5601: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
5602: }
5603: my $postexec='';
5604: if ($folder eq 'default') {
1.372 bisitz 5605: $r->print('<script type="text/javascript">'."\n"
5606: .'// <![CDATA['."\n"
5607: .'this.window.name="loncapaclient";'."\n"
5608: .'// ]]>'."\n"
5609: .'</script>'."\n"
1.369 bisitz 5610: );
1.329 droeschl 5611: } else {
5612: #$postexec='self.close();';
5613: }
1.484.2.15 raeburn 5614: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
5615: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
1.329 droeschl 5616: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
5617:
5618: my $newnavform=(<<NNFORM);
5619: <form action="/adm/coursedocs" method="post" name="newnav">
1.484.2.43 raeburn 5620: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 5621: $pathitem
1.329 droeschl 5622: <input type="hidden" name="importdetail"
5623: value="$lt{'navc'}=/adm/navmaps" />
1.484.2.67 raeburn 5624: <a class="LC_menubuttons_link" href="javascript:makenew(document.newnav);">$lt{'navc'}</a>
1.329 droeschl 5625: $help{'Navigate_Content'}
5626: </form>
5627: NNFORM
5628: my $newsmppageform=(<<NSPFORM);
5629: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.484.2.43 raeburn 5630: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 5631: $pathitem
1.329 droeschl 5632: <input type="hidden" name="importdetail" value="" />
1.423 onken 5633: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 5634: $help{'Simple Page'}
1.329 droeschl 5635: </form>
5636: NSPFORM
5637:
5638: my $newsmpproblemform=(<<NSPROBFORM);
5639: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371 tempelho 5640: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 5641: $pathitem
1.329 droeschl 5642: <input type="hidden" name="importdetail" value="" />
1.423 onken 5643: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.484.2.44 raeburn 5644: $help{'Simple_Problem'}
1.329 droeschl 5645: </form>
5646:
5647: NSPROBFORM
5648:
5649: my $newdropboxform=(<<NDBFORM);
5650: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.371 tempelho 5651: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 5652: $pathitem
1.329 droeschl 5653: <input type="hidden" name="importdetail" value="" />
1.423 onken 5654: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.484.2.36 raeburn 5655: $help{'Dropbox'}
1.344 bisitz 5656: </form>
1.329 droeschl 5657: NDBFORM
5658:
5659: my $newexuploadform=(<<NEXUFORM);
5660: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.371 tempelho 5661: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 5662: $pathitem
1.329 droeschl 5663: <input type="hidden" name="importdetail" value="" />
1.423 onken 5664: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 5665: $help{'Score_Upload_Form'}
5666: </form>
5667: NEXUFORM
5668:
5669: my $newbulform=(<<NBFORM);
5670: <form action="/adm/coursedocs" method="post" name="newbul">
1.484.2.43 raeburn 5671: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5672: $pathitem
1.329 droeschl 5673: <input type="hidden" name="importdetail" value="" />
1.423 onken 5674: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 5675: $help{'Bulletin Board'}
5676: </form>
5677: NBFORM
5678:
5679: my $newaboutmeform=(<<NAMFORM);
5680: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.484.2.43 raeburn 5681: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5682: $pathitem
1.329 droeschl 5683: <input type="hidden" name="importdetail"
5684: value="$plainname=/adm/$udom/$uname/aboutme" />
1.484.2.67 raeburn 5685: <a class="LC_menubuttons_link" href="javascript:makenew(document.newaboutme);">$lt{'mypi'}</a>
1.347 weissno 5686: $help{'My Personal Information Page'}
1.329 droeschl 5687: </form>
5688: NAMFORM
5689:
5690: my $newaboutsomeoneform=(<<NASOFORM);
5691: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.484.2.43 raeburn 5692: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5693: $pathitem
1.329 droeschl 5694: <input type="hidden" name="importdetail" value="" />
1.423 onken 5695: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 5696: </form>
5697: NASOFORM
5698:
5699: my $newrosterform=(<<NROSTFORM);
5700: <form action="/adm/coursedocs" method="post" name="newroster">
1.484.2.43 raeburn 5701: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5702: $pathitem
1.329 droeschl 5703: <input type="hidden" name="importdetail"
5704: value="$lt{'rost'}=/adm/viewclasslist" />
1.484.2.67 raeburn 5705: <a class="LC_menubuttons_link" href="javascript:makenew(document.newroster);">$lt{'rost'}</a>
1.484.2.37 raeburn 5706: $help{'Course_Roster'}
1.329 droeschl 5707: </form>
5708: NROSTFORM
5709:
1.484.2.27 raeburn 5710: my $newwebpage;
5711: if ($folder =~ /^default_?(\d*)$/) {
5712: $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
5713: if ($1) {
5714: $newwebpage .= $1;
5715: } else {
5716: $newwebpage .= 'default';
5717: }
5718: $newwebpage .= '/new.html';
5719: }
5720: my $newwebpageform =(<<NWEBFORM);
5721: <form action="/adm/coursedocs" method="post" name="newwebpage">
1.484.2.43 raeburn 5722: <input type="hidden" name="active" value="ee" />
1.484.2.27 raeburn 5723: $pathitem
5724: <input type="hidden" name="importdetail" value="$newwebpage" />
5725: <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
1.484.2.36 raeburn 5726: $help{'Web_Page'}
1.484.2.27 raeburn 5727: </form>
5728: NWEBFORM
1.484.2.30 raeburn 5729:
1.484.2.27 raeburn 5730:
1.342 ehlerst 5731: my $specialdocumentsform;
1.383 tempelho 5732: my @specialdocumentsforma;
1.451 www 5733: my $gradingform;
5734: my @gradingforma;
5735: my $communityform;
5736: my @communityforma;
1.351 ehlerst 5737: my $newfolderform;
1.390 tempelho 5738: my $newfolderb;
1.342 ehlerst 5739:
1.451 www 5740: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 5741:
1.329 droeschl 5742: my $newpageform=(<<NPFORM);
5743: <form action="/adm/coursedocs" method="post" name="newpage">
5744: <input type="hidden" name="folderpath" value="$path" />
5745: <input type="hidden" name="importdetail" value="" />
1.484.2.43 raeburn 5746: <input type="hidden" name="active" value="ee" />
1.423 onken 5747: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 5748: $help{'Adding_Pages'}
1.329 droeschl 5749: </form>
5750: NPFORM
1.390 tempelho 5751:
5752:
1.351 ehlerst 5753: $newfolderform=(<<NFFORM);
1.329 droeschl 5754: <form action="/adm/coursedocs" method="post" name="newfolder">
1.484.2.19 raeburn 5755: $pathitem
1.329 droeschl 5756: <input type="hidden" name="importdetail" value="" />
1.484.2.43 raeburn 5757: <input type="hidden" name="active" value="" />
1.422 onken 5758: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 5759: </form>
5760: NFFORM
5761:
5762: my $newsylform=(<<NSYLFORM);
5763: <form action="/adm/coursedocs" method="post" name="newsyl">
1.484.2.43 raeburn 5764: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 5765: $pathitem
1.329 droeschl 5766: <input type="hidden" name="importdetail"
5767: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.484.2.67 raeburn 5768: <a class="LC_menubuttons_link" href="javascript:makenew(document.newsyl);">$lt{'syll'}</a>
1.329 droeschl 5769: $help{'Syllabus'}
1.383 tempelho 5770:
1.329 droeschl 5771: </form>
5772: NSYLFORM
1.364 bisitz 5773:
1.329 droeschl 5774: my $newgroupfileform=(<<NGFFORM);
5775: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.484.2.43 raeburn 5776: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5777: $pathitem
1.329 droeschl 5778: <input type="hidden" name="importdetail"
5779: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.484.2.67 raeburn 5780: <a class="LC_menubuttons_link" href="javascript:makenew(document.newgroupfiles);">$lt{'grpo'}</a>
1.353 weissno 5781: $help{'Group Portfolio'}
1.329 droeschl 5782: </form>
5783: NGFFORM
1.383 tempelho 5784: @specialdocumentsforma=(
1.421 onken 5785: {'<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 5786: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.newsyl);" />'=>$newsylform},
5787: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="javascript:makenew(document.newnav);" />'=>$newnavform},
1.451 www 5788: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
1.484.2.27 raeburn 5789: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
1.451 www 5790: );
5791: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
5792:
1.434 raeburn 5793:
5794: my @importdoc = (
1.484.2.19 raeburn 5795: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform}
5796: );
1.484.2.72.4. (raeburn 5797:): if (keys(%ltitools)) {
5798:): push(@importdoc,
5799:): {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="toggleUpload(\'tool\');" />'=>$exttoolform},
5800:): );
5801:): }
1.484.2.19 raeburn 5802: unless ($container eq 'page') {
5803: push(@importdoc,
5804: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform}
5805: );
5806: }
5807: push(@importdoc,
1.484.2.38 raeburn 5808: {'<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 5809: );
1.484.2.12 raeburn 5810: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
1.434 raeburn 5811:
1.451 www 5812: @gradingforma=(
5813: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
5814: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
5815: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
5816:
5817: );
5818: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
5819:
5820: @communityforma=(
5821: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
5822: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
5823: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
1.484.2.67 raeburn 5824: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="javascript:makenew(document.newroster);" />'=>$newrosterform},
5825: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="javascript:makenew(document.newgroupfiles);" />'=>$newgroupfileform},
1.451 www 5826: );
5827: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 5828:
1.330 tempelho 5829: my %orderhash = (
1.484.2.36 raeburn 5830: 'aa' => ['Upload',$fileuploadform],
5831: 'bb' => ['Import',$importpubform],
5832: 'cc' => ['Grading',$gradingform],
1.330 tempelho 5833: );
1.484.2.19 raeburn 5834: unless ($container eq 'page') {
1.434 raeburn 5835: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.484 raeburn 5836: $orderhash{'dd'} = ['Collaboration',$communityform];
1.484.2.36 raeburn 5837: $orderhash{'ee'} = ['Other',$specialdocumentsform];
1.434 raeburn 5838: }
5839:
1.341 ehlerst 5840: $hadchanges=0;
1.484 raeburn 5841: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 5842: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.67 raeburn 5843: $supplementalflag,\%orderhash,$iconpath,$pathitem,
1.484.2.72.4. (raeburn 5844:): \%ltitools,$canedit,\$navmap,$hiddentop);
1.484.2.67 raeburn 5845: undef($navmap);
1.443 www 5846: if ($error) {
5847: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
5848: }
5849: if ($hadchanges) {
5850: &mark_hash_old();
5851: }
1.341 ehlerst 5852:
1.443 www 5853: &changewarning($r,'');
5854: }
1.458 raeburn 5855: }
1.442 www 5856:
1.443 www 5857: # Supplemental documents start here
5858:
1.329 droeschl 5859: my $folder=$env{'form.folder'};
1.443 www 5860: unless ($supplementalflag) {
1.329 droeschl 5861: $folder='supplemental';
5862: }
5863: if ($folder =~ /^supplemental$/ &&
5864: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 5865: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 5866: } elsif ($allowed) {
1.356 tempelho 5867: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 5868: }
1.484.2.17 raeburn 5869: $pathitem = '<input type="hidden" name="folderpath" value="'.
5870: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.329 droeschl 5871: if ($allowed) {
5872: my $folderseq=
1.484.2.15 raeburn 5873: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
1.329 droeschl 5874:
5875: my $supupdocform=(<<SUPDOCFORM);
1.484.2.12 raeburn 5876: <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
5877: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
1.383 tempelho 5878: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.484.2.19 raeburn 5879: <fieldset id="uploadsuppdocform" style="display: none;">
1.484.2.12 raeburn 5880: <legend>$lt{'upfi'}</legend>
1.371 tempelho 5881: <input type="hidden" name="active" value="ee" />
1.329 droeschl 5882: $fileupload
5883: <br />
5884: <br />
5885: <span class="LC_nobreak">
5886: $checkbox
5887: </span>
5888: <br /><br />
5889: $lt{'comment'}:<br />
1.383 tempelho 5890: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 5891: <br />
1.484.2.19 raeburn 5892: $pathitem
1.329 droeschl 5893: <input type="hidden" name="cmd" value="upload_supplemental" />
1.484.2.12 raeburn 5894: <input type='submit' value="$lt{'upld'}" />
5895: </form>
1.484.2.19 raeburn 5896: SUPDOCFORM
1.329 droeschl 5897:
5898: my $supnewfolderform=(<<SNFFORM);
5899: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.484.2.43 raeburn 5900: <input type="hidden" name="active" value="" />
1.484.2.17 raeburn 5901: $pathitem
1.329 droeschl 5902: <input type="hidden" name="importdetail" value="" />
1.423 onken 5903: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 5904: $help{'Adding_Folders'}
1.329 droeschl 5905: </form>
5906: SNFFORM
1.383 tempelho 5907:
1.484.2.19 raeburn 5908: my $supextform =
5909: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
1.484.2.67 raeburn 5910: $help{'Adding_External_Resource'},
1.484.2.72.4. (raeburn 5911:): undef,undef,undef,undef,undef,undef,
5912:): $disabled);
1.329 droeschl 5913:
1.484.2.72.4. (raeburn 5914:): my $supexttoolform =
5915:): &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
5916:): $help{'Adding_External_Tool'},
5917:): undef,undef,'tool',$coursedom,
5918:): $coursenum,\%ltitools,$disabled);
1.329 droeschl 5919: my $supnewsylform=(<<SNSFORM);
5920: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 5921: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 5922: $pathitem
1.329 droeschl 5923: <input type="hidden" name="importdetail"
5924: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.484.2.67 raeburn 5925: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewsyl);">$lt{'syll'}</a>
1.329 droeschl 5926: $help{'Syllabus'}
5927: </form>
5928: SNSFORM
5929:
5930: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 5931: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 5932: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 5933: $pathitem
1.329 droeschl 5934: <input type="hidden" name="importdetail"
5935: value="$plainname=/adm/$udom/$uname/aboutme" />
1.484.2.67 raeburn 5936: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewaboutme);">$lt{'mypi'}</a>
1.347 weissno 5937: $help{'My Personal Information Page'}
1.329 droeschl 5938: </form>
5939: SNAMFORM
5940:
1.484.2.27 raeburn 5941: my $supwebpage;
5942: if ($folder =~ /^supplemental_?(\d*)$/) {
5943: $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
5944: if ($1) {
5945: $supwebpage .= $1;
5946: } else {
5947: $supwebpage .= 'default';
5948: }
5949: $supwebpage .= '/new.html';
5950: }
5951: my $supwebpageform =(<<SWEBFORM);
5952: <form action="/adm/coursedocs" method="post" name="supwebpage">
5953: <input type="hidden" name="active" value="cc" />
5954: $pathitem
5955: <input type="hidden" name="importdetail" value="$supwebpage" />
5956: <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
1.484.2.36 raeburn 5957: $help{'Web_Page'}
1.484.2.27 raeburn 5958: </form>
5959: SWEBFORM
5960:
1.333 muellerd 5961:
1.383 tempelho 5962: my @specialdocs = (
1.484.2.67 raeburn 5963: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.supnewsyl);" />'
1.417 droeschl 5964: =>$supnewsylform},
1.484.2.67 raeburn 5965: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makenew(document.supnewaboutme);" />'
1.417 droeschl 5966: =>$supnewaboutmeform},
1.484.2.27 raeburn 5967: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
5968:
1.383 tempelho 5969: );
1.417 droeschl 5970: my @supimportdoc = (
1.484.2.19 raeburn 5971: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleUpload(\'suppext\')" />'
1.484.2.72.4. (raeburn 5972:): =>$supextform});
5973:): if (keys(%ltitools)) {
5974:): push(@supimportdoc,
5975:): {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="javascript:toggleUpload(\'supptool\')" />'
5976:): =>$supexttoolform});
5977:): }
5978:): push(@supimportdoc,
1.484.2.12 raeburn 5979: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
5980: =>$supupdocform},
1.484.2.72.4. (raeburn 5981:): );
1.484.2.19 raeburn 5982:
1.484.2.12 raeburn 5983: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
1.333 muellerd 5984: my %suporderhash = (
1.390 tempelho 5985: '00' => ['Supnewfolder', $supnewfolderform],
1.484.2.36 raeburn 5986: 'ee' => ['Upload',$supupdocform],
5987: 'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 5988: );
1.443 www 5989: if ($supplementalflag) {
1.458 raeburn 5990: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.67 raeburn 5991: $supplementalflag,\%suporderhash,$iconpath,$pathitem,
1.484.2.72.4. (raeburn 5992:): \%ltitools,$canedit);
1.443 www 5993: if ($error) {
5994: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.484.2.37 raeburn 5995: } else {
5996: if ($suppchanges) {
5997: my %servers = &Apache::lonnet::internet_dom_servers($coursedom);
5998: my @ids=&Apache::lonnet::current_machine_ids();
5999: foreach my $server (keys(%servers)) {
6000: next if (grep(/^\Q$server\E$/,@ids));
6001: my $hashid=$coursenum.':'.$coursedom;
1.484.2.42 raeburn 6002: my $cachekey = &escape('suppcount').':'.&escape($hashid);
6003: &Apache::lonnet::remote_devalidate_cache($server,[$cachekey]);
1.484.2.37 raeburn 6004: }
6005: &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
6006: undef($suppchanges);
6007: }
1.443 www 6008: }
1.393 raeburn 6009: }
1.443 www 6010: } elsif ($supplementalflag) {
1.458 raeburn 6011: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.17 raeburn 6012: $supplementalflag,'',$iconpath,$pathitem);
1.393 raeburn 6013: if ($error) {
6014: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 6015: }
1.393 raeburn 6016: }
1.389 tempelho 6017:
1.484.2.19 raeburn 6018: if ($needs_end) {
6019: $r->print(&endContentScreen());
6020: }
1.383 tempelho 6021:
1.329 droeschl 6022: if ($allowed) {
6023: $r->print('
6024: <form method="post" name="extimport" action="/adm/coursedocs">
6025: <input type="hidden" name="title" />
6026: <input type="hidden" name="url" />
6027: <input type="hidden" name="useform" />
6028: <input type="hidden" name="residx" />
6029: </form>');
6030: }
1.484 raeburn 6031: } elsif ($showdoc) {
1.329 droeschl 6032: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 6033: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.484.2.10 raeburn 6034: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 6035: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 6036: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 6037: }
6038: }
6039: $r->print(&Apache::loncommon::end_page());
6040: return OK;
1.364 bisitz 6041: }
1.329 droeschl 6042:
1.440 raeburn 6043: sub embedded_form_elems {
6044: my ($phase,$primaryurl,$newidx) = @_;
6045: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
6046: return <<STATE;
6047: <input type="hidden" name="folderpath" value="$folderpath" />
6048: <input type="hidden" name="cmd" value="upload_embedded" />
6049: <input type="hidden" name="newidx" value="$newidx" />
6050: <input type="hidden" name="phase" value="$phase" />
6051: <input type="hidden" name="primaryurl" value="$primaryurl" />
6052: STATE
6053: }
6054:
6055: sub embedded_destination {
6056: my $folder=$env{'form.folder'};
6057: my $destination = 'docs/';
6058: if ($folder =~ /^supplemental/) {
6059: $destination = 'supplemental/';
6060: }
6061: if (($folder eq 'default') || ($folder eq 'supplemental')) {
6062: $destination .= 'default/';
6063: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
6064: $destination .= $2.'/';
6065: }
6066: $destination .= $env{'form.newidx'};
6067: my $dir_root = '/userfiles';
6068: return ($destination,$dir_root);
6069: }
6070:
6071: sub return_to_editor {
6072: my $actionurl = '/adm/coursedocs';
6073: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
6074: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
6075: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
6076: '</a></p>';
6077: }
6078:
1.476 raeburn 6079: sub decompression_info {
6080: my ($destination,$dir_root) = &embedded_destination();
6081: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
6082: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
6083: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
6084: my $container='sequence';
1.480 raeburn 6085: my ($pathitem,$hiddenelem);
1.484.2.54 raeburn 6086: my @hiddens = ('newidx','comment','position','folderpath','archiveurl');
1.484.2.19 raeburn 6087: if ($env{'form.folderpath'} =~ /\:1$/) {
1.476 raeburn 6088: $container='page';
6089: }
1.480 raeburn 6090: unshift(@hiddens,$pathitem);
6091: foreach my $item (@hiddens) {
6092: if ($env{'form.'.$item}) {
6093: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
1.484.2.54 raeburn 6094: &HTML::Entities::encode($env{'form.'.$item},'<>&"').'" />'."\n";
1.480 raeburn 6095: }
1.477 raeburn 6096: }
1.476 raeburn 6097: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
6098: $hiddenelem);
6099: }
6100:
6101: sub decompression_phase_one {
6102: my ($dir,$file,$warning,$error,$output);
6103: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
6104: &decompression_info();
1.484.2.7 raeburn 6105: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 6106: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
6107: } else {
6108: my $file = $1;
1.481 raeburn 6109: $output =
6110: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
6111: $destination,$dir_root,
6112: $hiddenelem);
6113: if ($env{'form.autoextract_camtasia'}) {
6114: $output .= &remove_archive($docudom,$docuname,$container);
6115: }
1.476 raeburn 6116: }
6117: if ($error) {
6118: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
6119: $error.'</p>'."\n";
6120: }
6121: if ($warning) {
6122: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
6123: }
6124: return $output;
6125: }
6126:
6127: sub decompression_phase_two {
6128: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
6129: &decompression_info();
1.481 raeburn 6130: my $output;
1.480 raeburn 6131: if ($env{'form.archivedelete'}) {
1.481 raeburn 6132: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 6133: }
6134: $output .=
1.481 raeburn 6135: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 6136: $destination,$dir_root,$hiddenelem);
6137: return $output;
6138: }
6139:
1.480 raeburn 6140: sub remove_archive {
6141: my ($docudom,$docuname,$container) = @_;
6142: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 6143: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 6144: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
6145: if ($fatal) {
6146: if ($container eq 'page') {
6147: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
6148: } else {
6149: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
6150: }
1.484.2.54 raeburn 6151: $delwarning .= ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 6152: } else {
6153: my $currcmd = $env{'form.cmd'};
6154: my $position = $env{'form.position'};
1.484.2.54 raeburn 6155: my $archiveidx = $position;
6156: if ($position > 0) {
6157: if (($env{'form.autoextract_camtasia'}) && (scalar(@LONCAPA::map::order) == 2)) {
6158: $archiveidx = $position-1;
6159: }
6160: $env{'form.cmd'} = 'remove_'.$archiveidx;
6161: my ($title,$url,@rrest) =
6162: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$archiveidx]]);
6163: if ($url eq $env{'form.archiveurl'}) {
6164: if (&handle_edit_cmd($docuname,$docudom)) {
6165: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
6166: if ($fatal) {
6167: if ($container eq 'page') {
6168: $delwarning = &mt('An error occurred updating the contents of the current page.');
6169: } else {
6170: $delwarning = &mt('An error occurred updating the contents of the current folder.');
6171: }
1.480 raeburn 6172: } else {
1.484.2.54 raeburn 6173: $delresult = &mt('Archive file removed.');
1.480 raeburn 6174: }
6175: }
1.484.2.54 raeburn 6176: } else {
6177: $delwarning .= &mt('Archive file had unexpected item number in folder.').
6178: ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 6179: }
6180: }
6181: $env{'form.cmd'} = $currcmd;
6182: }
6183: if ($delwarning) {
6184: $output = '<p class="LC_warning">'.
6185: $delwarning.
6186: '</p>';
6187: }
6188: if ($delresult) {
6189: $output .= '<p class="LC_info">'.
6190: $delresult.
6191: '</p>';
6192: }
1.481 raeburn 6193: return $output;
1.480 raeburn 6194: }
6195:
1.484 raeburn 6196: sub generate_admin_menu {
1.484.2.67 raeburn 6197: my ($crstype,$canedit) = @_;
1.484 raeburn 6198: my $lc_crstype = lc($crstype);
6199: my ($home,$other,%outhash)=&authorhosts();
1.484.2.43 raeburn 6200: my %lt= ( # do not translate here
1.484 raeburn 6201: 'vc' => 'Verify Content',
6202: 'cv' => 'Check/Set Resource Versions',
6203: 'ls' => 'List Resource Identifiers',
6204: 'imse' => 'Export contents to IMS Archive',
1.484.2.43 raeburn 6205: 'dcd' => "Copy $crstype Content to Authoring Space",
6206: );
1.484 raeburn 6207: my ($candump,$dumpurl);
6208: if ($home + $other > 0) {
6209: $candump = 'F';
6210: if ($home) {
6211: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
6212: } else {
6213: my @hosts;
6214: foreach my $aurole (keys(%outhash)) {
6215: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
6216: push(@hosts,$outhash{$aurole});
1.484.2.30 raeburn 6217: }
1.484 raeburn 6218: }
6219: if (@hosts == 1) {
6220: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
6221: '&role='.
6222: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
6223: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
6224: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
6225: } else {
6226: $dumpurl = "javascript:choose_switchserver_window()";
6227: }
6228: }
6229: }
6230: my @menu=
6231: ({ categorytitle=>'Administration',
6232: items =>[
6233: { linktext => $lt{'vc'},
6234: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
6235: permission => 'F',
1.484.2.44 raeburn 6236: help => 'Docs_Verify_Content',
1.484 raeburn 6237: icon => 'verify.png',
6238: linktitle => 'Verify contents can be retrieved/rendered',
6239: },
6240: { linktext => $lt{'cv'},
6241: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
6242: permission => 'F',
1.484.2.44 raeburn 6243: help => 'Docs_Check_Resource_Versions',
1.484 raeburn 6244: icon => 'resversion.png',
6245: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
6246: },
6247: { linktext => $lt{'ls'},
6248: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
6249: permission => 'F',
6250: #help => '',
6251: icon => 'symbs.png',
6252: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
6253: },
6254: ]
1.484.2.67 raeburn 6255: });
6256: if ($canedit) {
6257: push(@menu,
1.484 raeburn 6258: { categorytitle=>'Export',
6259: items =>[
6260: { linktext => $lt{'imse'},
6261: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
6262: permission => 'F',
6263: help => 'Docs_Export_Course_Docs',
6264: icon => 'imsexport.png',
6265: linktitle => $lt{'imse'},
6266: },
6267: { linktext => $lt{'dcd'},
6268: url => $dumpurl,
6269: permission => $candump,
1.484.2.44 raeburn 6270: help => 'Docs_Dump_Course_Docs',
1.484 raeburn 6271: icon => 'dump.png',
6272: linktitle => $lt{'dcd'},
6273: },
6274: ]
6275: });
1.484.2.67 raeburn 6276: }
1.484 raeburn 6277: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
6278: '<input type="hidden" id="dummy" />'."\n".
6279: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
6280: '</form>';
1.329 droeschl 6281: }
6282:
6283: sub generate_edit_table {
1.484.2.30 raeburn 6284: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile,
1.484.2.67 raeburn 6285: $need_save,$copyfolder,$canedit) = @_;
1.406 raeburn 6286: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 6287: my %orderhash = %{$orderhash_ref};
1.484.2.67 raeburn 6288: my ($form, $activetab, $active, $disabled);
1.484.2.43 raeburn 6289: if (($env{'form.active'} ne '') && ($env{'form.active'} ne '00')) {
1.371 tempelho 6290: $activetab = $env{'form.active'};
6291: }
1.484.2.67 raeburn 6292: unless ($canedit) {
6293: $disabled = ' disabled="disabled"';
6294: }
1.472 raeburn 6295: my $backicon = $iconpath.'clickhere.gif';
1.484.2.21 raeburn 6296: my $backtext = &mt('Exit Editor');
1.458 raeburn 6297: $form = '<div class="LC_Box" style="margin:0;">'.
1.484.2.19 raeburn 6298: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
6299: '<li class="goback">'.
1.484.2.32 raeburn 6300: '<a href="javascript:toContents('."'$jumpto'".');">'.
1.484.2.19 raeburn 6301: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
6302: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
6303: '<li>'.
6304: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
6305: &mt('Undo Delete').'</a></li>'."\n";
1.484.2.7 raeburn 6306: if ($env{'form.docslog'}) {
6307: $form .= '<li class="active">';
6308: } else {
6309: $form .= '<li>';
6310: }
6311: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
6312: &mt('History').'</a></li>'."\n";
6313: if ($env{'form.docslog'}) {
6314: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
6315: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 6316: }
1.458 raeburn 6317: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 6318: if($name ne '00'){
1.371 tempelho 6319: if($activetab eq '' || $activetab ne $name){
6320: $active = '';
6321: }elsif($activetab eq $name){
6322: $active = 'class="active"';
6323: }
1.458 raeburn 6324: $form .= '<li style="float:right" '.$active
1.484 raeburn 6325: .' 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 6326: } else {
1.484.2.43 raeburn 6327: $form .= '<li style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 6328:
6329: }
1.329 droeschl 6330: }
1.484 raeburn 6331: $form .= '</ul>'."\n";
6332: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 6333:
6334: if ($to_show ne '') {
1.484.2.30 raeburn 6335: my $saveform;
6336: if ($need_save) {
6337: my $button = &mt('Make changes');
6338: my $path;
6339: if ($env{'form.folderpath'}) {
6340: $path =
6341: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
6342: }
6343: $saveform = <<"END";
6344: <div id="multisave" style="display:none; clear:both;" >
6345: <form name="saveactions" method="post" action="/adm/coursedocs" onsubmit="return checkSubmits();">
6346: <input type="hidden" name="folderpath" value="$path" />
6347: <input type="hidden" name="symb" value="$env{'form.symb'}" />
6348: <input type="hidden" name="allhiddenresource" value="" />
6349: <input type="hidden" name="allencrypturl" value="" />
6350: <input type="hidden" name="allrandompick" value="" />
6351: <input type="hidden" name="allrandomorder" value="" />
6352: <input type="hidden" name="changeparms" value="" />
6353: <input type="hidden" name="multiremove" value="" />
6354: <input type="hidden" name="multicut" value="" />
6355: <input type="hidden" name="multicopy" value="" />
6356: <input type="hidden" name="multichange" value="" />
6357: <input type="hidden" name="copyfolder" value="$copyfolder" />
1.484.2.67 raeburn 6358: <input type="submit" name="savemultiples" value="$button" $disabled />
1.484.2.30 raeburn 6359: </form>
6360: </div>
6361: END
6362: }
6363: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'.$saveform."\n";
1.458 raeburn 6364: }
1.363 ehlerst 6365: foreach my $field (keys(%orderhash)){
1.390 tempelho 6366: if($field ne '00'){
1.422 onken 6367: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 6368: $active = 'style="display: none;float:left"';
1.422 onken 6369: }elsif($activetab eq $field){
1.458 raeburn 6370: $active = 'style="display:block;float:left"';
1.422 onken 6371: }
6372: $form .= '<div id="'.$field.$tid.'"'
6373: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 6374: .'</div>'."\n";
1.363 ehlerst 6375: }
6376: }
1.484 raeburn 6377: unless ($env{'form.docslog'}) {
6378: $form .= '</div></div>'."\n";
6379: }
1.329 droeschl 6380: return $form;
6381: }
6382:
6383: sub editing_js {
1.484.2.72.4. (raeburn 6384:): my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,$canedit,$navmapref) = @_;
1.484.2.61 raeburn 6385: my %js_lt = &Apache::lonlocal::texthash(
1.329 droeschl 6386: p_mnf => 'Name of New Folder',
6387: t_mnf => 'New Folder',
6388: p_mnp => 'Name of New Page',
6389: t_mnp => 'New Page',
1.451 www 6390: p_mxu => 'Title for the External Score',
1.349 biermanm 6391: p_msp => 'Name of Simple Course Page',
1.329 droeschl 6392: p_msb => 'Title for the Problem',
6393: p_mdb => 'Title for the Drop Box',
1.336 schafran 6394: p_mbb => 'Title for the Discussion Board',
1.484.2.27 raeburn 6395: p_mwp => 'Title for Web Page',
1.348 weissno 6396: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 6397: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 6398: p_mab_alrt1 => 'Not a valid user:domain',
6399: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
6400: p_chn => 'New Title',
6401: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
1.484.2.63 raeburn 6402: p_rmr2a => 'Remove',
6403: p_rmr2b => '?',
6404: p_rmr3a => 'Remove those',
6405: p_rmr3b => 'items?',
6406: p_rmr4 => 'WARNING: Removing a resource uploaded to a course cannot be undone via "Undo Delete".',
6407: p_rmr5 => 'Push "Cancel" and then use "Cut" instead if you might need to undo this change.',
1.329 droeschl 6408: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
6409: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
1.484.2.63 raeburn 6410: p_ctr2a => 'Cut',
6411: p_ctr2b => '?',
6412: p_ctr3a => 'Cut those',
6413: p_ctr3b => 'items?',
1.478 raeburn 6414: rpck => 'Enter number to pick (e.g., 3)',
1.484.2.12 raeburn 6415: imsfile => 'You must choose an IMS package for import',
6416: imscms => 'You must select which Course Management System was the source of the IMS package',
6417: invurl => 'Invalid URL',
6418: titbl => 'Title is blank',
1.484.2.30 raeburn 6419: more => '(More ...)',
6420: less => '(Less ...)',
6421: noor => 'No actions selected or changes to settings specified.',
6422: noch => 'No changes to settings specified.',
6423: noac => 'No actions selected.',
1.484.2.67 raeburn 6424: edri => 'Editing rights unavailable for your current role.',
1.329 droeschl 6425: );
6426:
1.484.2.61 raeburn 6427: &js_escape(\%js_lt);
1.433 raeburn 6428: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 6429: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
6430: my $main_container_page;
1.484.2.19 raeburn 6431: if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) {
6432: $main_container_page = 1;
1.434 raeburn 6433: }
1.484.2.67 raeburn 6434: my $backtourl;
6435: my $toplevelmain = &escape(&default_folderpath($coursenum,$coursedom,$navmapref));
1.446 www 6436: my $toplevelsupp = &supplemental_base();
1.433 raeburn 6437:
1.484.2.21 raeburn 6438: if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
6439: my $caller = $1;
6440: if ($caller =~ /^supplemental/) {
6441: $backtourl = '/adm/supplemental?folderpath='.&escape($caller);
6442: } else {
6443: my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
6444: $res = &Apache::lonnet::clutter($res);
6445: if (&Apache::lonnet::is_on_map($res)) {
1.484.2.66 raeburn 6446: my ($url,$anchor);
6447: if ($res =~ /^([^#]+)#([^#]+)$/) {
6448: $url = $1;
6449: $anchor = $2;
6450: if (($caller =~ m{^([^#]+)\Q#$anchor\E$})) {
6451: $caller = $1.&escape('#').$anchor;
6452: }
1.484.2.67 raeburn 6453: } else {
6454: $url = $res;
1.484.2.66 raeburn 6455: }
6456: $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"').'?symb='.
1.484.2.21 raeburn 6457: &HTML::Entities::encode($caller,'<>&"');
1.484.2.66 raeburn 6458: if ($anchor ne '') {
6459: $backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"');
6460: }
1.484.2.57 raeburn 6461: $backtourl = &Apache::loncommon::escape_single($backtourl);
1.484.2.31 raeburn 6462: } else {
6463: $backtourl = '/adm/navmaps';
1.484.2.21 raeburn 6464: }
6465: }
6466: } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
6467: $backtourl = '/adm/menu';
6468: } elsif ($supplementalflag) {
1.472 raeburn 6469: $backtourl = '/adm/supplemental';
1.484.2.21 raeburn 6470: } else {
6471: $backtourl = '/adm/navmaps';
1.472 raeburn 6472: }
6473:
1.484.2.19 raeburn 6474: my $fieldsets = "'ext','doc'";
1.484.2.72.4. (raeburn 6475:): if ($posslti) {
6476:): $fieldsets .= ",'tool'";
6477:): }
1.484.2.19 raeburn 6478: unless ($main_container_page) {
6479: $fieldsets .=",'ims'";
6480: }
1.484.2.12 raeburn 6481: if ($supplementalflag) {
6482: $fieldsets = "'suppext','suppdoc'";
1.484.2.72.4. (raeburn 6483:): if ($posslti) {
6484:): $fieldsets .= ",'supptool'";
6485:): }
1.484.2.12 raeburn 6486: }
6487:
1.484.2.67 raeburn 6488: my $jsmakefunctions;
6489: if ($canedit) {
6490: $jsmakefunctions = <<ENDNEWSCRIPT;
1.329 droeschl 6491: function makenewfolder(targetform,folderseq) {
1.484.2.65 raeburn 6492: var foldername=prompt('$js_lt{"p_mnf"}','$js_lt{"t_mnf"}');
1.329 droeschl 6493: if (foldername) {
6494: targetform.importdetail.value=escape(foldername)+"="+folderseq;
6495: targetform.submit();
6496: }
6497: }
6498:
6499: function makenewpage(targetform,folderseq) {
1.484.2.61 raeburn 6500: var pagename=prompt('$js_lt{"p_mnp"}','$js_lt{"t_mnp"}');
1.329 droeschl 6501: if (pagename) {
6502: targetform.importdetail.value=escape(pagename)+"="+folderseq;
6503: targetform.submit();
6504: }
6505: }
6506:
6507: function makeexamupload() {
1.484.2.61 raeburn 6508: var title=prompt('$js_lt{"p_mxu"}');
1.344 bisitz 6509: if (title) {
1.329 droeschl 6510: this.document.forms.newexamupload.importdetail.value=
6511: escape(title)+'=/res/lib/templates/examupload.problem';
6512: this.document.forms.newexamupload.submit();
6513: }
6514: }
6515:
6516: function makesmppage() {
1.484.2.61 raeburn 6517: var title=prompt('$js_lt{"p_msp"}');
1.344 bisitz 6518: if (title) {
1.329 droeschl 6519: this.document.forms.newsmppg.importdetail.value=
1.484.2.26 raeburn 6520: escape(title)+'=/adm/$udom/$uname/new/smppg';
1.329 droeschl 6521: this.document.forms.newsmppg.submit();
6522: }
6523: }
6524:
1.484.2.27 raeburn 6525: function makewebpage(type) {
1.484.2.61 raeburn 6526: var title=prompt('$js_lt{"p_mwp"}');
1.484.2.27 raeburn 6527: var formname;
6528: if (type == 'supp') {
6529: formname = this.document.forms.supwebpage;
6530: } else {
6531: formname = this.document.forms.newwebpage;
6532: }
6533: if (title) {
6534: var webpage = formname.importdetail.value;
6535: formname.importdetail.value = escape(title)+'='+webpage;
6536: formname.submit();
6537: }
6538: }
6539:
1.329 droeschl 6540: function makesmpproblem() {
1.484.2.61 raeburn 6541: var title=prompt('$js_lt{"p_msb"}');
1.344 bisitz 6542: if (title) {
1.329 droeschl 6543: this.document.forms.newsmpproblem.importdetail.value=
6544: escape(title)+'=/res/lib/templates/simpleproblem.problem';
6545: this.document.forms.newsmpproblem.submit();
6546: }
6547: }
6548:
6549: function makedropbox() {
1.484.2.61 raeburn 6550: var title=prompt('$js_lt{"p_mdb"}');
1.344 bisitz 6551: if (title) {
1.329 droeschl 6552: this.document.forms.newdropbox.importdetail.value=
6553: escape(title)+'=/res/lib/templates/DropBox.problem';
6554: this.document.forms.newdropbox.submit();
6555: }
6556: }
6557:
6558: function makebulboard() {
1.484.2.61 raeburn 6559: var title=prompt('$js_lt{"p_mbb"}');
1.329 droeschl 6560: if (title) {
6561: this.document.forms.newbul.importdetail.value=
1.484.2.26 raeburn 6562: escape(title)+'=/adm/$udom/$uname/new/bulletinboard';
1.329 droeschl 6563: this.document.forms.newbul.submit();
6564: }
6565: }
6566:
6567: function makeabout() {
1.484.2.61 raeburn 6568: var user=prompt("$js_lt{'p_mab'}");
1.329 droeschl 6569: if (user) {
6570: var comp=new Array();
6571: comp=user.split(':');
6572: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
6573: if ((comp[0]) && (comp[1])) {
6574: this.document.forms.newaboutsomeone.importdetail.value=
1.484.2.61 raeburn 6575: '$js_lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.484.2.67 raeburn 6576: this.document.forms.newaboutsomeone.submit();
6577: } else {
6578: alert("$js_lt{'p_mab_alrt1'}");
6579: }
6580: } else {
6581: alert("$js_lt{'p_mab_alrt2'}");
6582: }
6583: }
1.335 ehlerst 6584: }
1.484.2.67 raeburn 6585:
6586: function makenew(targetform) {
6587: targetform.submit();
1.335 ehlerst 6588: }
1.484.2.67 raeburn 6589:
6590: function changename(folderpath,index,oldtitle) {
6591: var title=prompt('$js_lt{"p_chn"}',oldtitle);
6592: if (title) {
6593: this.document.forms.renameform.markcopy.value='';
6594: this.document.forms.renameform.title.value=title;
6595: this.document.forms.renameform.cmd.value='rename_'+index;
6596: this.document.forms.renameform.folderpath.value=folderpath;
6597: this.document.forms.renameform.submit();
6598: }
1.329 droeschl 6599: }
6600:
1.484.2.67 raeburn 6601: ENDNEWSCRIPT
6602: } else {
6603: $jsmakefunctions = <<ENDNEWSCRIPT;
6604:
6605: function makenewfolder() {
6606: alert("$js_lt{'edri'}");
6607: }
6608:
6609: function makenewpage() {
6610: alert("$js_lt{'edri'}");
6611: }
6612:
6613: function makeexamupload() {
6614: alert("$js_lt{'edri'}");
6615: }
6616:
6617: function makesmppage() {
6618: alert("$js_lt{'edri'}");
6619: }
6620:
6621: function makewebpage(type) {
6622: alert("$js_lt{'edri'}");
6623: }
6624:
6625: function makesmpproblem() {
6626: alert("$js_lt{'edri'}");
6627: }
6628:
6629: function makedropbox() {
6630: alert("$js_lt{'edri'}");
6631: }
6632:
6633: function makebulboard() {
6634: alert("$js_lt{'edri'}");
6635: }
6636:
6637: function makeabout() {
6638: alert("$js_lt{'edri'}");
6639: }
6640:
6641: function changename() {
6642: alert("$js_lt{'edri'}");
6643: }
6644:
6645: function makenew() {
6646: alert("$js_lt{'edri'}");
6647: }
6648:
6649: function groupimport() {
6650: alert("$js_lt{'edri'}");
6651: }
6652:
6653: function groupsearch() {
6654: alert("$js_lt{'edri'}");
6655: }
6656:
6657: function groupopen(url,recover) {
6658: var options="scrollbars=1,resizable=1,menubar=0";
6659: idxflag=1;
6660: idx=open("/adm/groupsort?inhibitmenu=yes&mode=simple&recover="+recover+"&readfile="+url,"idxout",options);
6661: idx.focus();
6662: }
6663:
6664: ENDNEWSCRIPT
6665:
6666: }
6667: return <<ENDSCRIPT;
6668:
6669: $jsmakefunctions
6670:
1.484.2.13 raeburn 6671: function toggleUpload(caller) {
6672: var blocks = Array($fieldsets);
6673: for (var i=0; i<blocks.length; i++) {
6674: var disp = 'none';
6675: if (caller == blocks[i]) {
6676: var curr = document.getElementById('upload'+caller+'form').style.display;
6677: if (curr == 'none') {
6678: disp='block';
6679: }
6680: }
6681: document.getElementById('upload'+blocks[i]+'form').style.display=disp;
1.484.2.72.4. (raeburn 6682:): if ((caller == 'tool') || (caller == 'supptool')) {
6683:): if (disp == 'block') {
6684:): if (document.getElementById('LC_exttoolid')) {
6685:): var toolselector = document.getElementById('LC_exttoolid');
6686:): var suppflag = 0;
6687:): if (caller == 'supptool') {
6688:): suppflag = 1;
6689:): }
6690:): currForm = document.getElementById('new'+caller);
6691:): updateExttool(toolselector,currForm,suppflag);
6692:): }
6693:): }
6694:): }
1.484.2.13 raeburn 6695: }
6696: resize_scrollbox('contentscroll','1','1');
6697: return;
6698: }
6699:
1.484.2.19 raeburn 6700: function toggleMap(caller) {
1.484.2.13 raeburn 6701: var disp = 'none';
1.484.2.19 raeburn 6702: if (document.getElementById('importmapform')) {
6703: if (caller == 'map') {
6704: var curr = document.getElementById('importmapform').style.display;
6705: if (curr == 'none') {
6706: disp='block';
6707: }
1.484.2.12 raeburn 6708: }
1.484.2.19 raeburn 6709: document.getElementById('importmapform').style.display=disp;
6710: resize_scrollbox('contentscroll','1','1');
1.484.2.12 raeburn 6711: }
1.484.2.19 raeburn 6712: return;
1.329 droeschl 6713: }
6714:
1.484.2.12 raeburn 6715: function makeims(imsform) {
6716: if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
1.484.2.61 raeburn 6717: alert("$js_lt{'imsfile'}");
1.484.2.12 raeburn 6718: return;
6719: }
6720: if (imsform.source.selectedIndex == 0) {
1.484.2.61 raeburn 6721: alert("$js_lt{'imscms'}");
1.484.2.12 raeburn 6722: return;
6723: }
6724: newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
6725: imsform.submit();
6726: }
6727:
1.478 raeburn 6728: function updatePick(targetform,index,caller) {
1.484.2.29 raeburn 6729: var pickitem;
6730: var picknumitem;
6731: var picknumtext;
6732: if (index == 'all') {
6733: pickitem = document.getElementById('randompickall');
6734: picknumitem = document.getElementById('rpicknumall');
6735: picknumtext = document.getElementById('rpicktextall');
6736: } else {
6737: pickitem = document.getElementById('randompick_'+index);
6738: picknumitem = document.getElementById('rpicknum_'+index);
6739: picknumtext = document.getElementById('randompicknum_'+index);
6740: }
1.478 raeburn 6741: if (pickitem.checked) {
1.484.2.61 raeburn 6742: var picknum=prompt('$js_lt{"rpck"}',picknumitem.value);
1.478 raeburn 6743: if (picknum == '' || picknum == null) {
6744: if (caller == 'check') {
6745: pickitem.checked=false;
1.484.2.29 raeburn 6746: if (index == 'all') {
6747: picknumtext.innerHTML = '';
6748: if (caller == 'link') {
6749: propagateState(targetform,'rpicknum');
6750: }
6751: } else {
1.484.2.30 raeburn 6752: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 6753: }
1.478 raeburn 6754: }
6755: } else {
6756: picknum.toString();
6757: var regexdigit=/^\\d+\$/;
6758: if (regexdigit.test(picknum)) {
6759: picknumitem.value = picknum;
1.484.2.29 raeburn 6760: if (index == 'all') {
1.484.2.30 raeburn 6761: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.cumulativesettings,\\'all\\',\\'link\\');">'+picknum+'</a>';
1.484.2.29 raeburn 6762: if (caller == 'link') {
6763: propagateState(targetform,'rpicknum');
6764: }
6765: } else {
6766: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.edit_randompick_'+index+',\\''+index+'\\',\\'link\\');">'+picknum+'</a>';
1.484.2.30 raeburn 6767: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 6768: }
1.478 raeburn 6769: } else {
6770: if (caller == 'check') {
1.484.2.29 raeburn 6771: if (index == 'all') {
6772: picknumtext.innerHTML = '';
6773: if (caller == 'link') {
6774: propagateState(targetform,'rpicknum');
6775: }
6776: } else {
6777: pickitem.checked=false;
1.484.2.30 raeburn 6778: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 6779: }
1.478 raeburn 6780: }
6781: return;
6782: }
6783: }
6784: } else {
1.484.2.29 raeburn 6785: picknumitem.value = '';
6786: picknumtext.innerHTML = '';
6787: if (index == 'all') {
6788: if (caller == 'link') {
6789: propagateState(targetform,'rpicknum');
6790: }
6791: } else {
1.484.2.30 raeburn 6792: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 6793: }
6794: }
6795: }
6796:
6797: function propagateState(form,param) {
6798: if (document.getElementById(param+'all')) {
6799: var setcheck = 0;
6800: var rpick = 0;
6801: if (param == 'rpicknum') {
6802: if (document.getElementById('randompickall')) {
6803: if (document.getElementById('randompickall').checked) {
6804: if (document.getElementById('rpicknumall')) {
6805: rpick = document.getElementById('rpicknumall').value;
6806: }
6807: }
6808: }
6809: } else {
6810: if (document.getElementById(param+'all').checked) {
6811: setcheck = 1;
6812: }
6813: }
1.484.2.30 raeburn 6814: var allidxlist;
6815: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
6816: if (document.getElementById('all'+param+'idx')) {
6817: allidxlist = document.getElementById('all'+param+'idx').value;
6818: }
6819: var actions = new Array ('remove','cut','copy');
6820: for (var i=0; i<actions.length; i++) {
6821: if (actions[i] != param) {
6822: if (document.getElementById(actions[i]+'all')) {
6823: document.getElementById(actions[i]+'all').checked = false;
6824: }
6825: }
6826: }
6827: }
1.484.2.29 raeburn 6828: if ((param == 'encrypturl') || (param == 'hiddenresource')) {
1.484.2.30 raeburn 6829: allidxlist = form.allidx.value;
6830: }
6831: if ((param == 'randompick') || (param == 'rpicknum') || (param == 'randomorder')) {
6832: allidxlist = form.allmapidx.value;
6833: }
6834: if ((allidxlist != '') && (allidxlist != null)) {
6835: var allidxs = allidxlist.split(',');
6836: if (allidxs.length > 1) {
6837: for (var i=0; i<allidxs.length; i++) {
6838: if (document.getElementById(param+'_'+allidxs[i])) {
6839: if (param == 'rpicknum') {
6840: if (document.getElementById('randompick_'+allidxs[i])) {
6841: if (document.getElementById('randompick_'+allidxs[i]).checked) {
6842: document.getElementById(param+'_'+allidxs[i]).value = rpick;
6843: if (rpick > 0) {
6844: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = ': <a href="javascript:updatePick(document.edit_randompick_'+allidxs[i]+',\\''+allidxs[i]+'\\',\\'link\\')">'+rpick+'</a>';
6845: } else {
6846: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
6847: }
6848: }
6849: }
6850: } else {
1.484.2.29 raeburn 6851: if (setcheck == 1) {
6852: document.getElementById(param+'_'+allidxs[i]).checked = true;
6853: } else {
6854: document.getElementById(param+'_'+allidxs[i]).checked = false;
1.484.2.30 raeburn 6855: if (param == 'randompick') {
6856: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
6857: }
1.484.2.29 raeburn 6858: }
6859: }
6860: }
6861: }
1.484.2.30 raeburn 6862: if (setcheck == 1) {
6863: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
6864: var actions = new Array('copy','cut','remove');
6865: for (var i=0; i<actions.length; i++) {
6866: var otheractions;
6867: var otheridxs;
6868: if (actions[i] === param) {
6869: continue;
6870: } else {
6871: if (document.getElementById('all'+actions[i]+'idx')) {
6872: otheractions = document.getElementById('all'+actions[i]+'idx').value;
6873: otheridxs = otheractions.split(',');
6874: if (otheridxs.length > 1) {
6875: for (var j=0; j<otheridxs.length; j++) {
6876: if (document.getElementById(actions[i]+'_'+otheridxs[j])) {
6877: document.getElementById(actions[i]+'_'+otheridxs[j]).checked = false;
6878: }
1.484.2.29 raeburn 6879: }
6880: }
6881: }
6882: }
1.484.2.30 raeburn 6883: }
1.484.2.29 raeburn 6884: }
6885: }
6886: }
6887: }
1.478 raeburn 6888: }
1.484.2.29 raeburn 6889: return;
6890: }
6891:
1.484.2.63 raeburn 6892: function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder,confirm_removal) {
1.484.2.67 raeburn 6893: var canedit = '$canedit';
6894: if (canedit == '') {
6895: alert("$js_lt{'edri'}");
6896: return;
6897: }
1.484.2.30 raeburn 6898: var dosettings;
6899: var doaction;
6900: var control = document.togglemultsettings;
6901: if (context == 'actions') {
6902: control = document.togglemultactions;
6903: doaction = 1;
6904: } else {
6905: dosettings = 1;
6906: }
6907: if (control) {
6908: if (control.showmultpick.length) {
6909: for (var i=0; i<control.showmultpick.length; i++) {
6910: if (control.showmultpick[i].checked) {
6911: if (control.showmultpick[i].value == 1) {
6912: if (context == 'settings') {
6913: dosettings = 0;
6914: } else {
6915: doaction = 0;
6916: }
6917: }
6918: }
6919: }
6920: }
6921: }
6922: if (context == 'settings') {
6923: if (dosettings == 1) {
6924: targetform.changeparms.value=param;
6925: targetform.submit();
6926: }
6927: }
6928: if (context == 'actions') {
6929: if (doaction == 1) {
6930: targetform.cmd.value=param+'_'+index;
6931: targetform.folderpath.value=folderpath;
6932: targetform.markcopy.value=idx+':'+param;
6933: targetform.copyfolder.value=folder+'.'+container;
6934: if (param == 'remove') {
1.484.2.63 raeburn 6935: var doremove = 0;
6936: if (skip_confirm) {
6937: if (confirm_removal) {
6938: if (confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'"$js_lt{"p_rmr2b"}')) {
6939: doremove = 1;
6940: }
6941: } else {
6942: doremove = 1;
6943: }
6944: } else {
6945: if (confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'" $js_lt{"p_rmr2b"}')) {
6946: doremove = 1;
6947: }
6948: }
6949: if (doremove) {
1.484.2.30 raeburn 6950: targetform.markcopy.value='';
6951: targetform.copyfolder.value='';
1.484.2.29 raeburn 6952: targetform.submit();
6953: }
6954: }
1.484.2.30 raeburn 6955: if (param == 'cut') {
1.484.2.61 raeburn 6956: 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 6957: targetform.submit();
6958: return;
6959: }
6960: }
6961: if (param == 'copy') {
6962: targetform.submit();
6963: return;
6964: }
6965: targetform.markcopy.value='';
6966: targetform.copyfolder.value='';
6967: targetform.cmd.value='';
6968: targetform.folderpath.value='';
6969: return;
6970: } else {
6971: if (document.getElementById(param+'_'+idx)) {
6972: item = document.getElementById(param+'_'+idx);
6973: if (item.type == 'checkbox') {
6974: if (item.checked) {
6975: item.checked = false;
6976: } else {
6977: item.checked = true;
6978: singleCheck(item,idx,param);
6979: }
6980: }
6981: }
6982: }
6983: }
6984: return;
6985: }
6986:
6987: function singleCheck(caller,idx,action) {
6988: actions = new Array('cut','copy','remove');
6989: if (caller.checked) {
6990: for (var i=0; i<actions.length; i++) {
6991: if (actions[i] != action) {
6992: if (document.getElementById(actions[i]+'_'+idx)) {
6993: if (document.getElementById(actions[i]+'_'+idx).checked) {
6994: document.getElementById(actions[i]+'_'+idx).checked = false;
6995: }
6996: }
6997: }
1.484.2.29 raeburn 6998: }
6999: }
7000: return;
1.478 raeburn 7001: }
7002:
1.334 muellerd 7003: function unselectInactive(nav) {
1.335 ehlerst 7004: currentNav = document.getElementById(nav);
7005: currentLis = currentNav.getElementsByTagName('LI');
7006: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 7007: if (currentLis[i].className == 'goback') {
7008: currentLis[i].className = 'goback';
7009: } else {
7010: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 7011: currentLis[i].className = 'right';
1.472 raeburn 7012: } else {
1.374 tempelho 7013: currentLis[i].className = 'i';
1.472 raeburn 7014: }
7015: }
1.335 ehlerst 7016: }
1.332 tempelho 7017: }
7018:
1.334 muellerd 7019: function hideAll(current, nav, data) {
1.335 ehlerst 7020: unselectInactive(nav);
1.484.2.43 raeburn 7021: if (current) {
7022: if (current.className == 'right'){
1.374 tempelho 7023: current.className = 'right active'
1.484.2.43 raeburn 7024: } else {
1.374 tempelho 7025: current.className = 'active';
1.484.2.43 raeburn 7026: }
1.374 tempelho 7027: }
1.335 ehlerst 7028: currentData = document.getElementById(data);
7029: currentDivs = currentData.getElementsByTagName('DIV');
7030: for (i = 0; i < currentDivs.length; i++) {
7031: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 7032: currentDivs[i].style.display = 'none';
1.330 tempelho 7033: }
7034: }
1.335 ehlerst 7035: }
1.330 tempelho 7036:
1.374 tempelho 7037: function openTabs(pageId) {
7038: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 7039: if(tabnav.length > 2 ){
1.389 tempelho 7040: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 7041: currentLis = currentNav.getElementsByTagName('LI');
7042: for(i = 0; i< currentLis.length; i++){
7043: if(currentLis[i].className == 'active') {
1.375 tempelho 7044: funcString = currentLis[i].onclick.toString();
7045: tab = funcString.split('"');
1.420 onken 7046: if(tab.length < 2) {
7047: tab = funcString.split("'");
7048: }
1.375 tempelho 7049: currentData = document.getElementById(tab[1]);
7050: currentData.style.display = 'block';
1.374 tempelho 7051: }
7052: }
7053: }
7054: }
7055:
1.334 muellerd 7056: function showPage(current, pageId, nav, data) {
1.484.2.43 raeburn 7057: currstate = current.className;
1.334 muellerd 7058: hideAll(current, nav, data);
1.375 tempelho 7059: openTabs(pageId);
1.334 muellerd 7060: unselectInactive(nav);
1.484.2.43 raeburn 7061: if ((currstate == 'active') || (currstate == 'right active')) {
7062: if (currstate == 'active') {
7063: current.className = '';
7064: } else {
7065: current.className = 'right';
7066: }
7067: activeTab = '';
7068: toggleUpload();
7069: toggleMap();
7070: resize_scrollbox('contentscroll','1','0');
7071: return;
7072: } else {
7073: current.className = 'active';
7074: }
1.330 tempelho 7075: currentData = document.getElementById(pageId);
7076: currentData.style.display = 'block';
1.458 raeburn 7077: activeTab = pageId;
1.484.2.12 raeburn 7078: toggleUpload();
1.484.2.14 raeburn 7079: toggleMap();
1.433 raeburn 7080: if (nav == 'mainnav') {
7081: var storedpath = "$docs_folderpath";
1.434 raeburn 7082: var storedpage = "$main_container_page";
1.433 raeburn 7083: var reg = new RegExp("^supplemental");
7084: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 7085: if (storedpage == 1) {
7086: document.simpleedit.folderpath.value = '';
7087: document.uploaddocument.folderpath.value = '';
7088: } else {
7089: if (reg.test(storedpath)) {
7090: document.simpleedit.folderpath.value = '$toplevelmain';
7091: document.uploaddocument.folderpath.value = '$toplevelmain';
7092: document.newext.folderpath.value = '$toplevelmain';
7093: } else {
7094: document.simpleedit.folderpath.value = storedpath;
7095: document.uploaddocument.folderpath.value = storedpath;
7096: document.newext.folderpath.value = storedpath;
7097: }
1.433 raeburn 7098: }
7099: } else {
1.434 raeburn 7100: if (reg.test(storedpath)) {
7101: document.simpleedit.folderpath.value = storedpath;
7102: document.supuploaddocument.folderpath.value = storedpath;
7103: document.supnewext.folderpath.value = storedpath;
7104: } else {
1.433 raeburn 7105: document.simpleedit.folderpath.value = '$toplevelsupp';
7106: document.supuploaddocument.folderpath.value = '$toplevelsupp';
7107: document.supnewext.folderpath.value = '$toplevelsupp';
7108: }
7109: }
7110: }
1.484.2.3 raeburn 7111: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 7112: return false;
7113: }
1.329 droeschl 7114:
1.472 raeburn 7115: function toContents(jumpto) {
7116: var newurl = '$backtourl';
1.484.2.21 raeburn 7117: if ((newurl == '/adm/navmaps') && (jumpto != '')) {
1.472 raeburn 7118: newurl = newurl+'?postdata='+jumpto;
7119: }
7120: location.href=newurl;
7121: }
7122:
1.484.2.30 raeburn 7123: function togglePick(caller,value) {
7124: var disp = 'none';
7125: if (document.getElementById('multi'+caller)) {
7126: var curr = document.getElementById('multi'+caller).style.display;
7127: if (value == 1) {
7128: disp='block';
7129: }
7130: if (curr == disp) {
7131: return;
7132: }
7133: document.getElementById('multi'+caller).style.display=disp;
7134: if (value == 1) {
1.484.2.61 raeburn 7135: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.484.2.30 raeburn 7136: } else {
7137: document.getElementById('more'+caller).innerHTML = '';
7138: }
7139: if (caller == 'actions') {
7140: setClass(value);
7141: setBoxes(value);
7142: }
7143: }
7144: var showButton = multiSettings();
7145: if (showButton != 1) {
7146: showButton = multiActions();
7147: }
7148: if (document.getElementById('multisave')) {
7149: if (showButton == 1) {
7150: document.getElementById('multisave').style.display='block';
7151: } else {
7152: document.getElementById('multisave').style.display='none';
7153: }
7154: }
7155: resize_scrollbox('contentscroll','1','1');
7156: return;
7157: }
7158:
7159: function toggleCheckUncheck(caller,more) {
7160: if (more == 1) {
1.484.2.61 raeburn 7161: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',0);" style="text-decoration:none;">$js_lt{'less'}</a>';
1.484.2.30 raeburn 7162: document.getElementById('allfields'+caller).style.display='block';
7163: } else {
1.484.2.61 raeburn 7164: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.484.2.30 raeburn 7165: document.getElementById('allfields'+caller).style.display='none';
7166: }
7167: resize_scrollbox('contentscroll','1','1');
7168: }
7169:
7170: function multiSettings() {
7171: var inuse = 0;
7172: var settingsform = document.togglemultsettings;
7173: if (settingsform.showmultpick.length > 1) {
7174: for (var i=0; i<settingsform.showmultpick.length; i++) {
7175: if (settingsform.showmultpick[i].checked) {
7176: if (settingsform.showmultpick[i].value == 1) {
7177: inuse = 1;
7178: }
7179: }
7180: }
7181: }
7182: return inuse;
7183: }
7184:
7185: function multiActions() {
7186: var inuse = 0;
7187: var actionsform = document.togglemultactions;
7188: if (actionsform.showmultpick.length > 1) {
7189: for (var i=0; i<actionsform.showmultpick.length; i++) {
7190: if (actionsform.showmultpick[i].checked) {
7191: if (actionsform.showmultpick[i].value == 1) {
7192: inuse = 1;
7193: }
7194: }
7195: }
7196: }
7197: return inuse;
7198: }
7199:
7200: function checkSubmits() {
7201: var numchanges = 0;
7202: var form = document.saveactions;
7203: var doactions = multiActions();
7204: var cutwarnings = 0;
7205: var remwarnings = 0;
1.484.2.63 raeburn 7206: var removalinfo = 0;
1.484.2.30 raeburn 7207: if (doactions == 1) {
7208: var remidxlist = document.cumulativeactions.allremoveidx.value;
7209: if ((remidxlist != '') && (remidxlist != null)) {
7210: var remidxs = remidxlist.split(',');
7211: for (var i=0; i<remidxs.length; i++) {
7212: if (document.getElementById('remove_'+remidxs[i])) {
7213: if (document.getElementById('remove_'+remidxs[i]).checked) {
7214: form.multiremove.value += remidxs[i]+',';
7215: numchanges ++;
7216: if (document.getElementById('skip_remove_'+remidxs[i])) {
7217: if (document.getElementById('skip_remove_'+remidxs[i]).value == 0) {
7218: remwarnings ++;
7219: }
7220: }
1.484.2.63 raeburn 7221: if (document.getElementById('confirm_removal_'+remidxs[i])) {
7222: if (document.getElementById('confirm_removal_'+remidxs[i]).value == 1) {
7223: removalinfo ++;
7224: }
7225: }
1.484.2.30 raeburn 7226: }
7227: }
7228: }
7229: }
7230: var cutidxlist = document.cumulativeactions.allcutidx.value;
7231: if ((cutidxlist != '') && (cutidxlist != null)) {
7232: var cutidxs = cutidxlist.split(',');
7233: for (var i=0; i<cutidxs.length; i++) {
7234: if (document.getElementById('cut_'+cutidxs[i])) {
7235: if (document.getElementById('cut_'+cutidxs[i]).checked == true) {
7236: form.multicut.value += cutidxs[i]+',';
7237: numchanges ++;
7238: if (document.getElementById('skip_cut_'+cutidxs[i])) {
7239: if (document.getElementById('skip_cut_'+cutidxs[i]).value == 0) {
7240: cutwarnings ++;
7241: }
7242: }
7243: }
7244: }
7245: }
7246: }
7247: var copyidxlist = document.cumulativeactions.allcopyidx.value;
7248: if ((copyidxlist != '') && (copyidxlist != null)) {
7249: var copyidxs = copyidxlist.split(',');
7250: for (var i=0; i<copyidxs.length; i++) {
7251: if (document.getElementById('copy_'+copyidxs[i])) {
7252: if (document.getElementById('copy_'+copyidxs[i]).checked) {
7253: form.multicopy.value += copyidxs[i]+',';
7254: numchanges ++;
7255: }
7256: }
7257: }
7258: }
7259: if (numchanges > 0) {
7260: form.multichange.value = numchanges;
7261: }
7262: }
7263: var dosettings = multiSettings();
7264: var haschanges = 0;
7265: if (dosettings == 1) {
7266: form.allencrypturl.value = '';
7267: form.allhiddenresource.value = '';
7268: form.changeparms.value = 'all';
7269: var patt=new RegExp(",\$");
7270: var allidxlist = document.cumulativesettings.allidx.value;
7271: if ((allidxlist != '') && (allidxlist != null)) {
7272: var allidxs = allidxlist.split(',');
7273: if (allidxs.length > 1) {
7274: for (var i=0; i<allidxs.length; i++) {
7275: if (document.getElementById('hiddenresource_'+allidxs[i])) {
7276: if (document.getElementById('hiddenresource_'+allidxs[i]).checked) {
7277: form.allhiddenresource.value += allidxs[i]+',';
7278: }
7279: }
7280: if (document.getElementById('encrypturl_'+allidxs[i])) {
7281: if (document.getElementById('encrypturl_'+allidxs[i]).checked) {
7282: form.allencrypturl.value += allidxs[i]+',';
7283: }
1.484.2.29 raeburn 7284: }
7285: }
1.484.2.30 raeburn 7286: form.allhiddenresource.value = form.allhiddenresource.value.replace(patt,"");
7287: form.allencrypturl.value = form.allencrypturl.value.replace(patt,"");
7288: }
7289: }
7290: form.allrandompick.value = '';
7291: form.allrandomorder.value = '';
7292: var allmapidxlist = document.cumulativesettings.allmapidx.value;
7293: if ((allmapidxlist != '') && (allmapidxlist != null)) {
7294: var allmapidxs = allmapidxlist.split(',');
7295: for (var i=0; i<allmapidxs.length; i++) {
7296: var randompick = document.getElementById('randompick_'+allmapidxs[i]);
7297: var rpicknum = document.getElementById('rpicknum_'+allmapidxs[i]);
7298: var randorder = document.getElementById('randomorder_'+allmapidxs[i]);
7299: if ((randompick.checked) && (rpicknum.value != '')) {
7300: form.allrandompick.value += allmapidxs[i]+':'+rpicknum.value+',';
7301: }
7302: if (randorder.checked) {
7303: form.allrandomorder.value += allmapidxs[i]+',';
7304: }
7305: }
7306: form.allrandompick.value = form.allrandompick.value.replace(patt,"");
7307: form.allrandomorder.value = form.allrandomorder.value.replace(patt,"");
7308: }
7309: if (document.cumulativesettings.currhiddenresource.value != form.allhiddenresource.value) {
7310: haschanges = 1;
7311: }
7312: if (document.cumulativesettings.currencrypturl.value != form.allencrypturl.value) {
7313: haschanges = 1;
7314: }
7315: if (document.cumulativesettings.currrandomorder.value != form.allrandomorder.value) {
7316: haschanges = 1;
7317: }
7318: if (document.cumulativesettings.currrandompick.value != form.allrandompick.value) {
7319: haschanges = 1;
7320: }
7321: }
7322: if (doactions == 1) {
7323: if (numchanges > 0) {
1.484.2.63 raeburn 7324: if ((cutwarnings > 0) || (remwarnings > 0) || (removalinfo > 0)) {
1.484.2.30 raeburn 7325: if (remwarnings > 0) {
1.484.2.61 raeburn 7326: if (!confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr3a"} '+remwarnings+' $js_lt{"p_rmr3b"}')) {
1.484.2.30 raeburn 7327: return false;
7328: }
7329: }
1.484.2.63 raeburn 7330: if (removalinfo > 0) {
7331: if (!confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr3a"} '+removalinfo+' $js_lt{"p_rmr3b"}')) {
7332: return false;
7333: }
7334: }
1.484.2.30 raeburn 7335: if (cutwarnings > 0) {
1.484.2.61 raeburn 7336: 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 7337: return false;
1.484.2.29 raeburn 7338: }
7339: }
7340: }
1.484.2.30 raeburn 7341: form.submit();
7342: return true;
7343: }
7344: }
7345: if (dosettings == 1) {
7346: if (haschanges == 1) {
7347: form.submit();
7348: return true;
1.484.2.29 raeburn 7349: }
7350: }
1.484.2.30 raeburn 7351: if ((dosettings == 1) && (doactions == 1)) {
1.484.2.61 raeburn 7352: alert("$js_lt{'noor'}");
1.484.2.30 raeburn 7353: } else {
7354: if (dosettings == 1) {
1.484.2.61 raeburn 7355: alert("$js_lt{'noch'}");
1.484.2.30 raeburn 7356: } else {
1.484.2.61 raeburn 7357: alert("$js_lt{'noac'}");
1.484.2.30 raeburn 7358: }
7359: }
7360: return false;
7361: }
7362:
7363: function setClass(value) {
7364: var cutclass = 'LC_docs_cut';
7365: var copyclass = 'LC_docs_copy';
7366: var removeclass = 'LC_docs_remove';
7367: var cutreg = new RegExp("\\\\b"+cutclass+"\\\\b");
7368: var copyreg = new RegExp("\\\\b"+copyclass+"\\\\b");
7369: var removereg = new RegExp("\\\\"+removeclass+"\\\\b");
7370: var links = document.getElementsByTagName('a');
7371: for (var i=0; i<links.length; i++) {
7372: var classes = links[i].className;
7373: if (cutreg.test(classes)) {
7374: links[i].className = cutclass;
7375: if (value == 1) {
7376: links[i].className += " LC_menubuttons_link";
1.484.2.29 raeburn 7377: }
1.484.2.30 raeburn 7378: } else {
7379: if (copyreg.test(classes)) {
7380: links[i].className = copyclass;
7381: if (value == 1) {
7382: links[i].className += " LC_menubuttons_link";
7383: }
7384: } else {
7385: if (removereg.test(classes)) {
7386: links[i].className = removeclass;
7387: if (value == 1) {
7388: links[i].className += " LC_menubuttons_link";
7389: }
7390: }
1.484.2.29 raeburn 7391: }
7392: }
7393: }
1.484.2.30 raeburn 7394: return;
1.484.2.29 raeburn 7395: }
7396:
1.484.2.30 raeburn 7397: function setBoxes(value) {
7398: var remidxlist = document.cumulativeactions.allremoveidx.value;
7399: if ((remidxlist != '') && (remidxlist != null)) {
7400: var remidxs = remidxlist.split(',');
7401: for (var i=0; i<remidxs.length; i++) {
7402: if (document.getElementById('remove_'+remidxs[i])) {
7403: var item = document.getElementById('remove_'+remidxs[i]);
7404: if (value == 1) {
7405: item.className = 'LC_docs_remove';
7406: } else {
7407: item.className = 'LC_hidden';
7408: }
7409: }
1.484.2.29 raeburn 7410: }
7411: }
1.484.2.30 raeburn 7412: var cutidxlist = document.cumulativeactions.allcutidx.value;
7413: if ((cutidxlist != '') && (cutidxlist != null)) {
7414: var cutidxs = cutidxlist.split(',');
7415: for (var i=0; i<cutidxs.length; i++) {
7416: if (document.getElementById('cut_'+cutidxs[i])) {
7417: var item = document.getElementById('cut_'+cutidxs[i]);
7418: if (value == 1) {
7419: item.className = 'LC_docs_cut';
7420: } else {
7421: item.className = 'LC_hidden';
7422: }
7423: }
7424: }
7425: }
7426: var copyidxlist = document.cumulativeactions.allcopyidx.value;
7427: if ((copyidxlist != '') && (copyidxlist != null)) {
7428: var copyidxs = copyidxlist.split(',');
7429: for (var i=0; i<copyidxs.length; i++) {
7430: if (document.getElementById('copy_'+copyidxs[i])) {
7431: var item = document.getElementById('copy_'+copyidxs[i]);
7432: if (value == 1) {
7433: item.className = 'LC_docs_copy';
7434: } else {
7435: item.className = 'LC_hidden';
7436: }
7437: }
1.484.2.29 raeburn 7438: }
7439: }
7440: return;
7441: }
7442:
1.484.2.67 raeburn 7443: ENDSCRIPT
1.329 droeschl 7444: }
1.457 raeburn 7445:
1.483 raeburn 7446: sub history_tab_js {
7447: return <<"ENDHIST";
7448: function toggleHistoryDisp(choice) {
7449: document.docslogform.docslog.value = choice;
7450: document.docslogform.submit();
7451: return;
7452: }
7453:
7454: ENDHIST
7455: }
7456:
1.484 raeburn 7457: sub inject_data_js {
7458: return <<ENDINJECT;
7459:
7460: function injectData(current, hiddenField, name, value) {
7461: currentElement = document.getElementById(hiddenField);
7462: currentElement.name = name;
7463: currentElement.value = value;
7464: current.submit();
7465: }
7466:
7467: ENDINJECT
7468: }
7469:
7470: sub dump_switchserver_js {
7471: my @hosts = @_;
1.484.2.61 raeburn 7472: my %js_lt = &Apache::lonlocal::texthash(
1.484.2.46 raeburn 7473: dump => 'Copying content to Authoring Space requires switching server.',
1.484 raeburn 7474: swit => 'Switch server?',
1.484.2.61 raeburn 7475: );
7476: my %html_js_lt = &Apache::lonlocal::texthash(
7477: swit => 'Switch server?',
1.484.2.43 raeburn 7478: duco => 'Copying Content to Authoring Space',
1.484 raeburn 7479: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
7480: chos => 'Choose server',
7481: );
1.484.2.61 raeburn 7482: &js_escape(\%js_lt);
7483: &html_escape(\%html_js_lt);
7484: &js_escape(\%html_js_lt);
1.484 raeburn 7485: my $role = $env{'request.role'};
7486: my $js = <<"ENDSWJS";
7487: <script type="text/javascript">
7488: function write_switchserver() {
7489: var server;
7490: if (document.setserver.posshosts.length > 0) {
7491: for (var i=0; i<document.setserver.posshosts.length; i++) {
7492: if (document.setserver.posshosts[i].checked) {
7493: server = document.setserver.posshosts[i].value;
7494: }
7495: }
7496: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
7497: }
7498: window.close();
7499: }
7500: </script>
7501:
7502: ENDSWJS
7503:
7504: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
7505: {'only_body' => 1,
7506: 'js_ready' => 1,});
7507: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
7508:
7509: my $hostpicker;
7510: my $count = 0;
7511: foreach my $host (sort(@hosts)) {
7512: my $checked;
7513: if ($count == 0) {
7514: $checked = ' checked="checked"';
7515: }
7516: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
7517: $host.'"'.$checked.' />'.$host.'</label> ';
7518: $count++;
7519: }
7520:
7521: return <<"ENDSWITCHJS";
7522:
7523: function dump_needs_switchserver(url) {
7524: if (url!='' && url!= null) {
1.484.2.61 raeburn 7525: if (confirm("$js_lt{'dump'}\\n$js_lt{'swit'}")) {
1.484 raeburn 7526: go(url);
7527: }
7528: }
7529: return;
7530: }
7531:
7532: function choose_switchserver_window() {
7533: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
7534: newWindow.document.open();
7535: newWindow.document.writeln('$startpage');
1.484.2.61 raeburn 7536: newWindow.document.write('<h3>$html_js_lt{'duco'}<\\/h3>\\n'+
7537: '<p>$html_js_lt{'yone'}<\\/p>\\n'+
7538: '<div class="LC_left_float"><fieldset><legend>$html_js_lt{'chos'}<\\/legend>\\n'+
1.484 raeburn 7539: '<form name="setserver" method="post" action="" \\/>\\n'+
7540: '$hostpicker\\n'+
7541: '<br \\/><br \\/>\\n'+
1.484.2.61 raeburn 7542: '<input type="button" name="makeswitch" value="$html_js_lt{'swit'}" '+
1.484 raeburn 7543: 'onclick="write_switchserver();" \\/>\\n'+
7544: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
7545: newWindow.document.writeln('$endpage');
7546: newWindow.document.close();
7547: newWindow.focus();
7548: }
7549:
7550: ENDSWITCHJS
7551: }
7552:
7553: sub makedocslogform {
7554: my ($formelems,$docslog) = @_;
7555: return <<"LOGSFORM";
7556: <form action="/adm/coursedocs" method="post" name="docslogform">
7557: <input type="hidden" name="docslog" value="$docslog" />
7558: $formelems
7559: </form>
7560: LOGSFORM
7561: }
7562:
7563: sub makesimpleeditform {
7564: my ($formelems) = @_;
7565: return <<"SIMPFORM";
7566: <form name="simpleedit" method="post" action="/adm/coursedocs">
7567: <input type="hidden" name="importdetail" value="" />
7568: $formelems
7569: </form>
7570: SIMPFORM
7571: }
7572:
1.329 droeschl 7573: 1;
7574: __END__
7575:
7576:
7577: =head1 NAME
7578:
7579: Apache::londocs.pm
7580:
7581: =head1 SYNOPSIS
7582:
7583: This is part of the LearningOnline Network with CAPA project
7584: described at http://www.lon-capa.org.
7585:
7586: =head1 SUBROUTINES
7587:
7588: =over
7589:
7590: =item %help=()
7591:
7592: Available help topics
7593:
7594: =item mapread()
7595:
1.344 bisitz 7596: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 7597: @order and @resources, determines status
7598: sets @order - pointer to resources in right order
7599: sets @resources - array with the resources with correct idx
7600:
7601: =item authorhosts()
7602:
7603: Return hash with valid author names
7604:
7605: =item clean()
7606:
7607: =item dumpcourse()
7608:
7609: Actually dump course
7610:
7611: =item group_import()
7612:
7613: Imports the given (name, url) resources into the course
7614: coursenum, coursedom, and folder must precede the list
7615:
7616: =item breadcrumbs()
7617:
7618: =item log_docs()
7619:
7620: =item docs_change_log()
7621:
7622: =item update_paste_buffer()
7623:
7624: =item print_paste_buffer()
7625:
7626: =item do_paste_from_buffer()
7627:
1.484.2.30 raeburn 7628: =item do_buffer_empty()
7629:
7630: =item clear_from_buffer()
7631:
1.484.2.7 raeburn 7632: =item get_newmap_url()
7633:
7634: =item dbcopy()
7635:
7636: =item uniqueness_check()
7637:
7638: =item contained_map_check()
7639:
7640: =item url_paste_fixups()
7641:
7642: =item apply_fixups()
7643:
7644: =item copy_dependencies()
7645:
1.329 droeschl 7646: =item update_parameter()
7647:
7648: =item handle_edit_cmd()
7649:
7650: =item editor()
7651:
7652: =item process_file_upload()
7653:
7654: =item process_secondary_uploads()
7655:
7656: =item is_supplemental_title()
7657:
7658: =item entryline()
7659:
7660: =item tiehash()
7661:
7662: =item untiehash()
7663:
7664: =item checkonthis()
7665:
7666: check on this
7667:
7668: =item verifycontent()
7669:
7670: Verify Content
7671:
7672: =item devalidateversioncache() & checkversions()
7673:
7674: Check Versions
7675:
7676: =item mark_hash_old()
7677:
7678: =item is_hash_old()
7679:
7680: =item changewarning()
7681:
7682: =item init_breadcrumbs()
7683:
7684: Breadcrumbs for special functions
7685:
1.484 raeburn 7686: =item create_list_elements()
7687:
7688: =item create_form_ul()
7689:
7690: =item startContentScreen()
7691:
7692: =item endContentScreen()
7693:
7694: =item supplemental_base()
7695:
7696: =item embedded_form_elems()
7697:
7698: =item embedded_destination()
7699:
7700: =item return_to_editor()
7701:
7702: =item decompression_info()
7703:
7704: =item decompression_phase_one()
7705:
7706: =item decompression_phase_two()
7707:
7708: =item remove_archive()
7709:
7710: =item generate_admin_menu()
7711:
7712: =item generate_edit_table()
7713:
7714: =item editing_js()
7715:
7716: =item history_tab_js()
7717:
7718: =item inject_data_js()
7719:
7720: =item dump_switchserver_js()
7721:
1.484.2.3 raeburn 7722: =item resize_scrollbox_js()
1.484 raeburn 7723:
7724: =item makedocslogform()
7725:
1.484.2.3 raeburn 7726: =item makesimpleeditform()
7727:
1.329 droeschl 7728: =back
7729:
7730: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>