Annotation of loncom/interface/londocs.pm, revision 1.484.2.72.2.6
1.329 droeschl 1: # The LearningOnline Network
2: # Documents
3: #
1.484.2.72.2. (raeburn 4:): # $Id: londocs.pm,v 1.484.2.72.2.5 2018/04/29 17:33:52 raeburn Exp $
1.329 droeschl 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29: package Apache::londocs;
30:
31: use strict;
32: use Apache::Constants qw(:common :http);
33: use Apache::imsexport;
34: use Apache::lonnet;
35: use Apache::loncommon;
1.383 tempelho 36: use Apache::lonhtmlcommon;
1.329 droeschl 37: use LONCAPA::map();
38: use Apache::lonratedt();
39: use Apache::lonxml;
40: use Apache::lonclonecourse;
41: use Apache::lonnavmaps;
1.472 raeburn 42: use Apache::lonnavdisplay();
1.484.2.19 raeburn 43: use Apache::lonextresedit();
1.484.2.43 raeburn 44: use Apache::lontemplate();
45: use Apache::lonsimplepage();
1.484.2.72.2. (raeburn 46:): use Apache::loncourserespicker();
1.329 droeschl 47: use HTML::Entities;
1.484.2.7 raeburn 48: use HTML::TokeParser;
1.329 droeschl 49: use GDBM_File;
1.484.2.51 raeburn 50: use File::MMagic;
1.329 droeschl 51: use Apache::lonlocal;
52: use Cwd;
53: use LONCAPA qw(:DEFAULT :match);
54:
55: my $iconpath;
56:
57: my %hash;
58:
59: my $hashtied;
60: my %alreadyseen=();
61:
62: my $hadchanges;
1.484.2.37 raeburn 63: my $suppchanges;
1.329 droeschl 64:
65:
66: my %help=();
67:
68:
69: sub mapread {
70: my ($coursenum,$coursedom,$map)=@_;
71: return
72: &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
73: $map);
74: }
75:
76: sub storemap {
1.484.2.7 raeburn 77: my ($coursenum,$coursedom,$map,$contentchg)=@_;
78: my $report;
79: if (($contentchg) && ($map =~ /^default/)) {
80: $report = 1;
81: }
1.329 droeschl 82: my ($outtext,$errtext)=
83: &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.484.2.7 raeburn 84: $map,1,$report);
1.329 droeschl 85: if ($errtext) { return ($errtext,2); }
1.364 bisitz 86:
1.484.2.37 raeburn 87: if ($map =~ /^default/) {
88: $hadchanges=1;
89: } else {
90: $suppchanges=1;
91: }
1.329 droeschl 92: return ($errtext,0);
93: }
94:
95:
96:
97: sub authorhosts {
98: my %outhash=();
99: my $home=0;
100: my $other=0;
101: foreach my $key (keys(%env)) {
102: if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
103: my $role=$1;
104: my $realm=$2;
105: my ($start,$end)=split(/\./,$env{$key});
106: if (($start) && ($start>time)) { next; }
107: if (($end) && (time>$end)) { next; }
108: my ($ca,$cd);
109: if ($1 eq 'au') {
110: $ca=$env{'user.name'};
111: $cd=$env{'user.domain'};
112: } else {
113: ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
114: }
115: my $allowed=0;
116: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
117: my @ids=&Apache::lonnet::current_machine_ids();
1.484 raeburn 118: foreach my $id (@ids) {
119: if ($id eq $myhome) {
120: $allowed=1;
121: last;
122: }
123: }
1.329 droeschl 124: if ($allowed) {
125: $home++;
1.484 raeburn 126: $outhash{'home_'.$ca.':'.$cd}=1;
1.329 droeschl 127: } else {
1.484 raeburn 128: $outhash{'otherhome_'.$ca.':'.$cd}=$myhome;
1.329 droeschl 129: $other++;
130: }
131: }
132: }
133: return ($home,$other,%outhash);
134: }
135:
136:
137: sub clean {
138: my ($title)=@_;
139: $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
1.344 bisitz 140: return $title;
1.329 droeschl 141: }
142:
1.484.2.67 raeburn 143: sub default_folderpath {
144: my ($coursenum,$coursedom,$navmapref) = @_;
145: return unless ($coursenum && $coursedom && ref($navmapref));
146: # Check if entire course is hidden and/or encrypted
147: my ($hiddenmap,$encryptmap,$folderpath,$hiddentop);
148: my $toplevel = "uploaded/$coursedom/$coursenum/default.sequence";
149: unless (ref($$navmapref)) {
150: $$navmapref = Apache::lonnavmaps::navmap->new();
151: }
152: if (ref($$navmapref)) {
153: if (lc($$navmapref->get_mapparam(undef,$toplevel,"0.hiddenresource")) eq 'yes') {
154: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
155: my @resources = $$navmapref->retrieveResources($toplevel,$filterFunc,1,1);
156: unless (@resources) {
157: $hiddenmap = 1;
158: unless ($env{'request.role.adv'}) {
159: $hiddentop = 1;
160: if ($env{'form.folder'}) {
161: undef($env{'form.folder'});
162: }
163: }
164: }
165: }
166: if (lc($$navmapref->get_mapparam(undef,$toplevel,"0.encrypturl")) eq 'yes') {
167: $encryptmap = 1;
168: }
169: }
170: unless ($hiddentop) {
171: $folderpath='default&'.&escape(&mt('Main Content')).
172: '::'.$hiddenmap.':'.$encryptmap.'::';
173: }
174: if (wantarray) {
175: return ($folderpath,$hiddentop);
176: } else {
177: return $folderpath;
178: }
179: }
1.329 droeschl 180:
181: sub dumpcourse {
182: my ($r) = @_;
1.408 raeburn 183: my $crstype = &Apache::loncommon::course_type();
1.484.2.43 raeburn 184: my ($starthash,$js);
185: unless (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
186: $js = <<"ENDJS";
187: <script type="text/javascript">
188: // <![CDATA[
189:
190: function hide_searching() {
191: if (document.getElementById('searching')) {
192: document.getElementById('searching').style.display = 'none';
193: }
194: return;
195: }
196:
197: // ]]>
198: </script>
199: ENDJS
200: $starthash = {
201: add_entries => {'onload' => "hide_searching();"},
202: };
203: }
204: $r->print(&Apache::loncommon::start_page('Copy '.$crstype.' Content to Authoring Space',$js,$starthash)."\n".
205: &Apache::lonhtmlcommon::breadcrumbs('Copy '.$crstype.' Content to Authoring Space')."\n");
1.484 raeburn 206: $r->print(&startContentScreen('tools'));
1.329 droeschl 207: my ($home,$other,%outhash)=&authorhosts();
1.484 raeburn 208: unless ($home) {
209: $r->print(&endContentScreen());
210: return '';
211: }
1.329 droeschl 212: my $origcrsid=$env{'request.course.id'};
213: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
214: if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
215: # Do the dumping
1.484 raeburn 216: unless ($outhash{'home_'.$env{'form.authorspace'}}) {
217: $r->print(&endContentScreen());
218: return '';
219: }
1.484.2.24 raeburn 220: my ($ca,$cd)=split(/\:/,$env{'form.authorspace'});
1.329 droeschl 221: $r->print('<h3>'.&mt('Copying Files').'</h3>');
222: my $title=$env{'form.authorfolder'};
223: $title=&clean($title);
1.484.2.43 raeburn 224: my ($navmap,$errormsg) =
225: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
226: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
227: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
228: my (%maps,%resources,%titles);
229: if (!ref($navmap)) {
230: $r->print($errormsg.
231: &endContentScreen());
232: return '';
233: } else {
234: &Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles,
235: 'dumpdocs',$cdom,$cnum);
236: }
237: my @todump = &Apache::loncommon::get_env_multiple('form.archive');
238: my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages,
239: %newcontent,%has_simpleprobs);
240: foreach my $item (sort {$a <=> $b} (@todump)) {
241: my $name = $env{'form.namefor_'.$item};
242: if ($resources{$item}) {
243: my ($map,$id,$res) = &Apache::lonnet::decode_symb($resources{$item});
244: if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) {
245: $tocopy{$1} = $name;
246: $display{$item} = $1;
247: $lookup{$1} = $item;
248: } elsif ($res eq 'lib/templates/simpleproblem.problem') {
249: $simpleproblems{$item} = {
250: symb => $resources{$item},
251: name => $name,
252: };
253: $display{$item} = 'simpleproblem_'.$name;
254: if ($map =~ m{^\Quploaded/$cdom/$cnum/\E(.+)$}) {
255: $has_simpleprobs{$1}{$id} = $item;
256: }
257: } elsif ($res =~ m{^adm/$match_domain/$match_username/(\d+)/smppg}) {
258: my $marker = $1;
259: my $db_name = &Apache::lonsimplepage::get_db_name($res,$marker,$cdom,$cnum);
260: $simplepages{$item} = {
261: res => $res,
262: title => $titles{$item},
263: db => $db_name,
264: marker => $marker,
265: symb => $resources{$item},
266: name => $name,
267: };
268: $display{$item} = '/'.$res;
269: }
270: } elsif ($maps{$item}) {
271: if ($maps{$item} =~ m{^\Quploaded/$cdom/$cnum/\E((?:default|supplemental)_\d+\.(?:sequence|page))$}) {
272: $tocopy{$1} = $name;
273: $display{$item} = $1;
274: $lookup{$1} = $item;
275: }
276: } else {
277: next;
278: }
279: }
1.329 droeschl 280: my $crs='/uploaded/'.$env{'request.course.id'}.'/';
281: $crs=~s/\_/\//g;
1.484.2.43 raeburn 282: my $mm = new File::MMagic;
283: my $prefix = "/uploaded/$cdom/$cnum/";
284: %replacehash = %tocopy;
285: foreach my $item (sort(keys(%simpleproblems))) {
286: my $content = &Apache::imsexport::simpleproblem($simpleproblems{$item}{'symb'});
287: $newcontent{$display{$item}} = $content;
288: }
289: my $gateway = Apache::lonhtmlgateway->new('web');
290: foreach my $item (sort(keys(%simplepages))) {
291: if (ref($simplepages{$item}) eq 'HASH') {
292: my $pagetitle = $simplepages{$item}{'title'};
293: my %fields = &Apache::lonnet::dump($simplepages{$item}{'db'},$cdom,$cnum);
294: my %contents;
295: foreach my $field (keys(%fields)) {
296: if ($field =~ /^(?:aaa|bbb|ccc)_(\w+)$/) {
297: my $name = $1;
298: my $msg = $fields{$field};
299: if ($name eq 'webreferences') {
300: if ($msg =~ m{^https?://}) {
301: $contents{$name} = '<a href="'.$msg.'"><tt>'.$msg.'</tt></a>';
302: }
303: } else {
304: $msg = &Encode::decode('utf8',$msg);
305: $msg = $gateway->process_outgoing_html($msg,1);
306: $contents{$name} = $msg;
307: }
308: } elsif ($field eq 'uploaded.photourl') {
309: my $marker = $simplepages{$item}{marker};
310: if ($fields{$field} =~ m{^\Q$prefix\E(simplepage/$marker/.+)$}) {
311: my $filepath = $1;
312: my ($relpath,$fname) = ($filepath =~ m{^(.+/)([^/]+)$});
313: if ($fname ne '') {
314: $fname=~s/\.(\w+)$//;
315: my $ext=$1;
316: $fname = &clean($fname);
317: $fname.='.'.$ext;
318: $contents{image} = '<img src="'.$relpath.$fname.'" alt="Image" />';
319: $replacehash{$filepath} = $relpath.$fname;
320: $deps{$item}{$filepath} = 1;
321: }
322: }
323: }
324: }
325: $replacehash{'/'.$simplepages{$item}{'res'}} = $simplepages{$item}{'name'};
326: $lookup{'/'.$simplepages{$item}{'res'}} = $item;
327: my $content = '
328: <html>
329: <head>
330: <title>'.$pagetitle.'</title>
331: </head>
332: <body bgcolor="#ffffff">';
333: if ($contents{title}) {
334: $content .= "\n".'<h2>'.$contents{title}.'</h2>';
335: }
336: if ($contents{image}) {
337: $content .= "\n".$contents{image};
338: }
339: if ($contents{content}) {
340: $content .= '
341: <div class="LC_Box">
1.484.2.50 raeburn 342: <h4 class="LC_hcell">'.&mt('Content').'</h4>'.
1.484.2.43 raeburn 343: $contents{content}.'
344: </div>';
345: }
346: if ($contents{webreferences}) {
347: $content .= '
348: <div class="LC_Box">
1.484.2.50 raeburn 349: <h4 class="LC_hcell">'.&mt('Web References').'</h4>'.
1.484.2.43 raeburn 350: $contents{webreferences}.'
351: </div>';
352: }
353: $content .= '
354: </body>
355: </html>
356: ';
357: $newcontent{'/'.$simplepages{$item}{res}} = $content;
358: }
359: }
360: foreach my $item (keys(%tocopy)) {
361: unless ($item=~/\.(sequence|page)$/) {
362: my $currurlpath = $prefix.$item;
363: my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath);
364: &recurse_html($mm,$prefix,$currdirpath,$currurlpath,$item,$lookup{$item},\%replacehash,\%deps);
365: }
366: }
367: foreach my $num (sort {$a <=> $b} (@todump)) {
368: my $src = $display{$num};
369: next if ($src eq '');
370: my @needcopy = ();
371: if ($replacehash{$src}) {
372: push(@needcopy,$src);
373: if (ref($deps{$num}) eq 'HASH') {
374: foreach my $dep (sort(keys(%{$deps{$num}}))) {
375: if ($replacehash{$dep}) {
376: push(@needcopy,$dep);
377: }
378: }
379: }
380: } elsif ($src =~ /^simpleproblem_/) {
381: push(@needcopy,$src);
382: }
383: next if (@needcopy == 0);
384: my ($result,$depresult);
385: for (my $i=0; $i<@needcopy; $i++) {
386: my $item = $needcopy[$i];
387: my $newfilename;
388: if ($simpleproblems{$num}) {
389: $newfilename=$title.'/'.$simpleproblems{$num}{'name'};
390: } else {
391: $newfilename=$title.'/'.$replacehash{$item};
392: }
393: $newfilename=~s/\.(\w+)$//;
394: my $ext=$1;
395: $newfilename=&clean($newfilename);
396: $newfilename.='.'.$ext;
397: my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$});
398: if ($newrelpath ne $replacehash{$item}) {
399: $replacehash{$item} = $newrelpath;
400: }
401: my @dirs=split(/\//,$newfilename);
402: my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
403: my $makepath=$path;
404: my $fail;
405: my $origin;
406: for (my $i=0;$i<$#dirs;$i++) {
407: $makepath.='/'.$dirs[$i];
408: unless (-e $makepath) {
409: unless(mkdir($makepath,0755)) {
410: $fail = &mt('Directory creation failed.');
411: }
412: }
413: }
414: if ($i == 0) {
415: $result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ';
416: } else {
417: $depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '.
418: '<span class="LC_fontsize_small" style="font-weight: bold;">'.
419: &mt('(dependency)').'</span>: ';
420: }
421: if (-e $path.'/'.$newfilename) {
422: $fail = &mt('Destination already exists -- not overwriting.');
423: } else {
424: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
425: if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) ||
426: ($item =~ /^simpleproblem_/)) {
427: print $fh $newcontent{$item};
428: } else {
429: my $fileloc = &Apache::lonnet::filelocation('',$prefix.$item);
430: if (-e $fileloc) {
431: if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
432: if ((($1 eq 'sequence') || ($1 eq 'page')) &&
433: (ref($has_simpleprobs{$item}) eq 'HASH')) {
434: my %changes = %{$has_simpleprobs{$item}};
435: my $content = &Apache::lonclonecourse::rewritefile(
436: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
437: (%replacehash,$crs => '')
438: );
439: my $updatedcontent = '';
440: my $parser = HTML::TokeParser->new(\$content);
441: $parser->attr_encoded(1);
442: while (my $token = $parser->get_token) {
443: if ($token->[0] eq 'S') {
444: if (($token->[1] eq 'resource') &&
445: ($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') &&
446: ($changes{$token->[2]->{'id'}})) {
447: my $id = $token->[2]->{'id'};
448: $updatedcontent .= '<'.$token->[1];
449: foreach my $attrib (@{$token->[3]}) {
450: next unless ($attrib =~ /^(src|type|title|id)$/);
451: if ($attrib eq 'src') {
452: my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/);
453: if ($file) {
454: $updatedcontent .= ' '.$attrib.'="'.$file.'"';
455: } else {
456: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
457: }
458: } else {
459: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
460: }
461: }
462: $updatedcontent .= ' />'."\n";
463: } else {
464: $updatedcontent .= $token->[4]."\n";
465: }
466: } else {
467: $updatedcontent .= $token->[2];
468: }
469: }
470: print $fh $updatedcontent;
471: } else {
472: print $fh &Apache::lonclonecourse::rewritefile(
473: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
474: (%replacehash,$crs => '')
475: );
476: }
477: } else {
478: print $fh
479: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
480: }
481: } else {
482: $fail = &mt('Source does not exist.');
483: }
484: }
485: $fh->close();
486: } else {
487: $fail = &mt('Could not write to destination.');
488: }
489: }
490: my $text;
491: if ($fail) {
492: $text = '<span class="LC_error">'.&mt('fail').(' 'x3).$fail.'</span>';
493: } else {
494: $text = '<span class="LC_success">'.&mt('ok').'</span>';
495: }
496: if ($i == 0) {
497: $result .= $text;
498: } else {
499: $depresult .= $text.'</li>';
500: }
501: }
502: $r->print($result);
503: if ($depresult) {
504: $r->print('<ul>'.$depresult.'</ul>');
505: }
506: }
1.329 droeschl 507: } else {
1.484.2.43 raeburn 508: my ($navmap,$errormsg) =
509: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
510: if (!ref($navmap)) {
511: $r->print($errormsg);
512: } else {
513: $r->print('<div id="searching">'.&mt('Searching ...').'</div>');
514: $r->rflush();
515: my ($preamble,$formname);
516: $formname = 'dumpdoc';
517: unless ($home==1) {
518: $preamble = '<div class="LC_left_float">'.
519: '<fieldset><legend>'.
520: &mt('Select the Authoring Space').
521: '</legend><select name="authorspace">';
522: }
523: my @orderspaces = ();
524: foreach my $key (sort(keys(%outhash))) {
525: if ($key=~/^home_(.+)$/) {
526: if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) {
527: unshift(@orderspaces,$1);
528: } else {
529: push(@orderspaces,$1);
530: }
531: }
532: }
533: if ($home>1) {
534: $preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>';
535: }
536: foreach my $user (@orderspaces) {
537: if ($home==1) {
538: $preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />';
539: } else {
540: $preamble .= '<option value="'.$user.'">'.$user.' - '.
541: &Apache::loncommon::plainname(split(/\:/,$user)).'</option>';
542: }
543: }
544: unless ($home==1) {
545: $preamble .= '</select></fieldset></div>'."\n";
546: }
547: my $title=$origcrsdata{'description'};
548: $title=~s/[\/\s]+/\_/gs;
549: $title=&clean($title);
550: $preamble .= '<div class="LC_left_float">'.
551: '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.
552: '<input type="text" size="50" name="authorfolder" value="'.
553: $title.'" />'.
554: '</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n";
555: my %uploadedfiles;
556: &tiehash();
557: foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
558: my ($ext)=($file=~/\.(\w+)$/);
559: # FIXME Check supplemental here
560: my $title=$hash{'title_'.$hash{
561: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
562: if (!$title) {
563: $title=$file;
564: } else {
565: $title=~s|/|_|g;
566: }
567: $title=~s/\.(\w+)$//;
568: $title=&clean($title);
569: $title.='.'.$ext;
570: # $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
571: $uploadedfiles{$file} = $title;
572: }
573: &untiehash();
574: $r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef,
575: undef,undef,$preamble,$home,\%uploadedfiles));
576: }
1.329 droeschl 577: }
1.484 raeburn 578: $r->print(&endContentScreen());
1.329 droeschl 579: }
580:
1.484.2.43 raeburn 581: sub recurse_html {
582: my ($mm,$prefix,$currdirpath,$currurlpath,$container,$item,$replacehash,$deps) = @_;
583: return unless ((ref($replacehash) eq 'HASH') && (ref($deps) eq 'HASH'));
584: my (%allfiles,%codebase);
585: if (&Apache::lonnet::extract_embedded_items($currdirpath,\%allfiles,\%codebase) eq 'ok') {
586: if (keys(%allfiles)) {
587: foreach my $dependency (keys(%allfiles)) {
588: next if (($dependency =~ m{^/(res|adm)/}) || ($dependency =~ m{^https?://}));
589: my ($depurl,$relfile,$newcontainer);
590: if ($dependency =~ m{^/}) {
591: if ($dependency =~ m{^\Q$currurlpath/\E(.+)$}) {
592: $relfile = $1;
593: if ($dependency =~ m{^\Q$prefix\E(.+)$}) {
594: $newcontainer = $1;
595: next if ($replacehash->{$newcontainer});
596: }
597: $depurl = $dependency;
598: } else {
599: next;
600: }
601: } else {
602: $relfile = $dependency;
603: $depurl = $currurlpath;
604: $depurl =~ s{[^/]+$}{};
605: $depurl .= $dependency;
606: ($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$});
607: }
608: next if ($relfile eq '');
609: my $newname = $replacehash->{$container};
610: $newname =~ s{[^/]+$}{};
611: $replacehash->{$newcontainer} = $newname.$relfile;
612: $deps->{$item}{$newcontainer} = 1;
613: my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$});
614: my $depfile = &Apache::lonnet::filelocation('',$depurl);
615: my $type = $mm->checktype_filename($depfile);
616: if ($type eq 'text/html') {
617: &recurse_html($mm,$prefix,$depfile,$newurlpath,$newcontainer,$item,$replacehash,$deps);
618: }
619: }
620: }
621: }
622: return;
623: }
624:
1.329 droeschl 625: sub group_import {
1.484.2.72.2. (raeburn 626:): my ($coursenum, $coursedom, $folder, $container, $caller, $ltitoolsref, @files) = @_;
1.484.2.23 raeburn 627: my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap,
628: %removeparam,$importuploaded,$fixuperrors);
629: $allmaps = {};
1.329 droeschl 630: while (@files) {
631: my ($name, $url, $residx) = @{ shift(@files) };
1.344 bisitz 632: if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
1.329 droeschl 633: && ($caller eq 'londocs')
634: && (!&Apache::lonnet::stat_file($url))) {
1.364 bisitz 635:
1.329 droeschl 636: my $errtext = '';
637: my $fatal = 0;
638: my $newmapstr = '<map>'."\n".
639: '<resource id="1" src="" type="start"></resource>'."\n".
640: '<link from="1" to="2" index="1"></link>'."\n".
641: '<resource id="2" src="" type="finish"></resource>'."\n".
642: '</map>';
643: $env{'form.output'}=$newmapstr;
644: my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
645: 'output',$1.$2);
1.484.2.27 raeburn 646: if ($result !~ m{^/uploaded/}) {
1.329 droeschl 647: $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
648: $fatal = 2;
649: }
650: if ($fatal) {
651: return ($errtext,$fatal);
652: }
653: }
654: if ($url) {
1.484.2.72.2. (raeburn 655:): if ($url =~ m{^(/adm/$coursedom/$coursenum/(\d+)/ext\.tool)\:?(.*)$}) {
656:): $url = $1;
657:): my $marker = $2;
658:): my $info = $3;
659:): my ($toolid,%toolhash,%toolsettings);
660:): my @extras = ('linktext','explanation','crslabel','crstitle');
661:): my @toolinfo = split(/:/,$info);
662:): if ($residx) {
663:): %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
664:): $toolid = $toolsettings{'id'};
665:): } else {
666:): $toolid = shift(@toolinfo);
667:): }
668:): $toolid =~ s/\D//g;
669:): ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'},
670:): $toolhash{'linktext'},$toolhash{'explanation'},
671:): $toolhash{'crslabel'},$toolhash{'crstitle'}) = @toolinfo;
672:): foreach my $item (@extras) {
673:): $toolhash{$item} = &unescape($toolhash{$item});
674:): }
675:): if (ref($ltitoolsref) eq 'HASH') {
676:): my @deleted;
677:): if (ref($ltitoolsref->{$toolid}) eq 'HASH') {
678:): $toolhash{'id'} = $toolid;
679:): if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'tab') ||
680:): ($toolhash{'target'} eq 'window')) {
681:): if ($toolhash{'target'} eq 'window') {
682:): foreach my $item ('width','height') {
683:): $toolhash{$item} =~ s/^\s+//;
684:): $toolhash{$item} =~ s/\s+$//;
685:): if ($toolhash{$item} =~ /\D/) {
686:): delete($toolhash{$item});
687:): if ($residx) {
688:): if ($toolsettings{$item}) {
689:): push(@deleted,$item);
690:): }
691:): }
692:): }
693:): }
694:): }
695:): } elsif ($residx) {
696:): $toolhash{'target'} = $toolsettings{'target'};
697:): if ($toolhash{'target'} eq 'window') {
698:): foreach my $item ('width','height') {
699:): $toolhash{$item} = $toolsettings{$item};
700:): }
701:): }
702:): } elsif (ref($ltitoolsref->{$toolid}->{'display'}) eq 'HASH') {
703:): $toolhash{'target'} = $ltitoolsref->{$toolid}->{'display'}->{'target'};
704:): if ($toolhash{'target'} eq 'window') {
705:): $toolhash{'width'} = $ltitoolsref->{$toolid}->{'display'}->{'width'};
706:): $toolhash{'height'} = $ltitoolsref->{$toolid}->{'display'}->{'height'};
707:): }
708:): }
709:): if ($toolhash{'target'} eq 'iframe') {
710:): foreach my $item ('width','height','linktext','explanation') {
711:): delete($toolhash{$item});
712:): if ($residx) {
713:): if ($toolsettings{$item}) {
714:): push(@deleted,$item);
715:): }
716:): }
717:): }
718:): } elsif ($toolhash{'target'} eq 'tab') {
719:): foreach my $item ('width','height') {
720:): delete($toolhash{$item});
721:): if ($residx) {
722:): if ($toolsettings{$item}) {
723:): push(@deleted,$item);
724:): }
725:): }
726:): }
727:): }
728:): if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') {
729:): foreach my $item ('label','title','linktext','explanation') {
730:): my $crsitem;
731:): if (($item eq 'label') || ($item eq 'title')) {
732:): $crsitem = 'crs'.$item;
733:): } else {
734:): $crsitem = $item;
735:): }
736:): if ($ltitoolsref->{$toolid}->{'crsconf'}->{$item}) {
737:): $toolhash{$crsitem} =~ s/^\s+//;
738:): $toolhash{$crsitem} =~ s/\s+$//;
739:): if ($toolhash{$crsitem} eq '') {
740:): delete($toolhash{$crsitem});
741:): }
742:): } else {
743:): delete($toolhash{$crsitem});
744:): }
745:): if (($residx) && (exists($toolsettings{$crsitem}))) {
746:): unless (exists($toolhash{$crsitem})) {
747:): push(@deleted,$crsitem);
748:): }
749:): }
750:): }
751:): }
752:): my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum);
753:): if ($putres eq 'ok') {
754:): if (@deleted) {
755:): &Apache::lonnet::del('exttool_'.$marker,\@deleted,$coursedom,$coursenum);
756:): }
757:): }
758:): }
759:): }
760:): }
1.484.2.23 raeburn 761: if (($caller eq 'londocs') &&
762: ($folder =~ /^default/)) {
1.484.2.27 raeburn 763: if (($url =~ /\.(page|sequence)$/) && (!$donechk)) {
1.484.2.23 raeburn 764: my $chome = &Apache::lonnet::homeserver($coursenum,$coursedom);
765: my $cid = $coursedom.'_'.$coursenum;
766: $allmaps =
767: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
768: $chome,$cid);
769: $donechk = 1;
770: }
771: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) {
1.484.2.72.2. (raeburn 772:): &contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap,
773:): \%removeparam,\%addedmaps,\%hierarchy,\%titles,$allmaps);
1.484.2.23 raeburn 774: $importuploaded = 1;
775: } elsif ($url =~ m{^/res/.+\.(page|sequence)$}) {
776: next if ($allmaps->{$url});
777: }
778: }
1.344 bisitz 779: if (!$residx
1.329 droeschl 780: || defined($LONCAPA::map::zombies[$residx])) {
781: $residx = &LONCAPA::map::getresidx($url,$residx);
782: push(@LONCAPA::map::order, $residx);
783: }
784: my $ext = 'false';
785: if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
786: $name = &LONCAPA::map::qtunescape($name);
1.484.2.27 raeburn 787: if ($name eq '') {
1.484.2.30 raeburn 788: $name = &LONCAPA::map::qtunescape(&mt('Web Page'));
1.484.2.27 raeburn 789: }
790: if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) {
791: my $filepath = $1;
792: my $fname = $name;
793: if ($fname =~ /^\W+$/) {
794: $fname = 'web';
795: } else {
796: $fname =~ s/\W/_/g;
797: }
1.484.2.62 raeburn 798: if (length($fname) > 15) {
1.484.2.27 raeburn 799: $fname = substr($fname,0,14);
800: }
801: my $initialtext = &mt('Replace with your own content.');
802: my $newhtml = <<END;
1.484.2.31 raeburn 803: <html>
1.484.2.27 raeburn 804: <head>
805: <title>$name</title>
806: </head>
807: <body bgcolor="#ffffff">
808: $initialtext
809: </body>
810: </html>
811: END
812: $env{'form.output'}=$newhtml;
813: my $result =
814: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
815: 'output',
816: "$filepath/$residx/$fname.html");
817: if ($result =~ m{^/uploaded/}) {
818: $url = $result;
819: if ($filepath =~ /^supplemental/) {
820: $name = time.'___&&&___'.$env{'user.name'}.'___&&&___'.
821: $env{'user.domain'}.'___&&&___'.$name;
822: }
823: } else {
824: return (&mt('Failed to save new web page.'),1);
825: }
826: }
1.484.2.30 raeburn 827: $url = &LONCAPA::map::qtunescape($url);
1.344 bisitz 828: $LONCAPA::map::resources[$residx] =
1.329 droeschl 829: join(':', ($name, $url, $ext, 'normal', 'res'));
830: }
831: }
1.484.2.23 raeburn 832: if ($importuploaded) {
833: my %import_errors;
834: my %updated = (
835: removefrommap => \%removefrommap,
836: removeparam => \%removeparam,
837: );
1.484.2.26 raeburn 838: my ($result,$msgsarray,$lockerror) =
839: &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
1.484.2.23 raeburn 840: if (keys(%import_errors) > 0) {
841: $fixuperrors =
842: '<p span class="LC_warning">'."\n".
843: &mt('The following files are either dependencies of a web page or references within a folder and/or composite page for which errors occurred during import:')."\n".
844: '<ul>'."\n";
845: foreach my $key (sort(keys(%import_errors))) {
846: $fixuperrors .= '<li>'.$key.'</li>'."\n";
847: }
848: $fixuperrors .= '</ul></p>'."\n";
849: }
1.484.2.26 raeburn 850: if (ref($msgsarray) eq 'ARRAY') {
851: if (@{$msgsarray} > 0) {
852: $fixuperrors .= '<p class="LC_info">'.
853: join('<br />',@{$msgsarray}).
854: '</p>';
855: }
856: }
857: if ($lockerror) {
858: $fixuperrors .= '<p class="LC_error">'.
859: $lockerror.
860: '</p>';
861: }
1.484.2.23 raeburn 862: }
863: my ($errtext,$fatal) =
864: &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
1.484.2.37 raeburn 865: unless ($fatal) {
866: if ($folder =~ /^supplemental/) {
867: &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
1.484.2.39 raeburn 868: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
869: $folder.'.'.$container);
1.484.2.37 raeburn 870: }
871: }
1.484.2.23 raeburn 872: return ($errtext,$fatal,$fixuperrors);
1.329 droeschl 873: }
874:
875: sub log_docs {
1.484.2.8 raeburn 876: return &Apache::lonnet::write_log('course','docslog',@_);
1.329 droeschl 877: }
878:
879: {
880: my @oldresources=();
881: my @oldorder=();
882: my $parmidx;
883: my %parmaction=();
884: my %parmvalue=();
885: my $changedflag;
886:
887: sub snapshotbefore {
888: @oldresources=@LONCAPA::map::resources;
889: @oldorder=@LONCAPA::map::order;
890: $parmidx=undef;
891: %parmaction=();
892: %parmvalue=();
893: $changedflag=0;
894: }
895:
896: sub remember_parms {
897: my ($idx,$parameter,$action,$value)=@_;
898: $parmidx=$idx;
899: $parmaction{$parameter}=$action;
900: $parmvalue{$parameter}=$value;
901: $changedflag=1;
902: }
903:
904: sub log_differences {
905: my ($plain)=@_;
906: my %storehash=('folder' => $plain,
907: 'currentfolder' => $env{'form.folder'});
908: if ($parmidx) {
909: $storehash{'parameter_res'}=$oldresources[$parmidx];
910: foreach my $parm (keys(%parmaction)) {
911: $storehash{'parameter_action_'.$parm}=$parmaction{$parm};
912: $storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
913: }
914: }
915: my $maxidx=$#oldresources;
916: if ($#LONCAPA::map::resources>$#oldresources) {
917: $maxidx=$#LONCAPA::map::resources;
918: }
919: for (my $idx=0; $idx<=$maxidx; $idx++) {
920: if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
921: $storehash{'before_resources_'.$idx}=$oldresources[$idx];
922: $storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
923: $changedflag=1;
924: }
925: if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
926: $storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
927: $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
928: $changedflag=1;
929: }
930: }
931: $storehash{'maxidx'}=$maxidx;
932: if ($changedflag) { &log_docs(\%storehash); }
933: }
934: }
935:
936: sub docs_change_log {
1.484.2.67 raeburn 937: my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit)=@_;
1.484.2.6 raeburn 938: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
1.484.2.67 raeburn 939: my $navmap;
1.483 raeburn 940: my $js = '<script type="text/javascript">'."\n".
941: '// <![CDATA['."\n".
942: &Apache::loncommon::display_filter_js('docslog')."\n".
1.484.2.67 raeburn 943: &editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag,
1.484.2.72.2. (raeburn 944:): $coursedom,$coursenum,'',$canedit,\$navmap)."\n".
1.483 raeburn 945: &history_tab_js()."\n".
1.484 raeburn 946: &Apache::lonratedt::editscript('simple')."\n".
1.483 raeburn 947: '// ]]>'."\n".
948: '</script>'."\n";
1.484 raeburn 949: $r->print(&Apache::loncommon::start_page('Content Change Log',$js));
950: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Change Log'));
1.484.2.7 raeburn 951: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484 raeburn 952: my %orderhash;
953: my $container='sequence';
954: my $pathitem;
1.484.2.19 raeburn 955: if ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 956: $container='page';
957: }
1.484.2.19 raeburn 958: my $folderpath=$env{'form.folderpath'};
959: if ($folderpath eq '') {
1.484.2.67 raeburn 960: $folderpath = &default_folderpath($coursenum,$coursedom,\$navmap);
1.484.2.19 raeburn 961: }
1.484.2.67 raeburn 962: undef($navmap);
1.484.2.19 raeburn 963: $pathitem = '<input type="hidden" name="folderpath" value="'.
964: &HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 965: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
966: my $jumpto = $readfile;
967: $jumpto =~ s{^/}{};
968: my $tid = 1;
1.484.2.7 raeburn 969: if ($supplementalflag) {
970: $tid = 2;
971: }
1.484.2.19 raeburn 972: my ($breadcrumbtrail) =
1.484.2.18 raeburn 973: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
1.484 raeburn 974: $r->print($breadcrumbtrail.
975: &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto,
976: $readfile));
1.329 droeschl 977: my %docslog=&Apache::lonnet::dump('nohist_docslog',
978: $env{'course.'.$env{'request.course.id'}.'.domain'},
979: $env{'course.'.$env{'request.course.id'}.'.num'});
980:
981: if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
982:
983: my %saveable_parameters = ('show' => 'scalar',);
984: &Apache::loncommon::store_course_settings('docs_log',
985: \%saveable_parameters);
986: &Apache::loncommon::restore_course_settings('docs_log',
987: \%saveable_parameters);
988: if (!$env{'form.show'}) { $env{'form.show'}=10; }
1.452 www 989: # FIXME: internationalization seems wrong here
1.329 droeschl 990: my %lt=('hiddenresource' => 'Resources hidden',
991: 'encrypturl' => 'URL hidden',
992: 'randompick' => 'Randomly pick',
993: 'randomorder' => 'Randomly ordered',
994: 'set' => 'set to',
995: 'del' => 'deleted');
1.484 raeburn 996: my $filter = &Apache::loncommon::display_filter('docslog')."\n".
997: $pathitem."\n".
998: '<input type="hidden" name="folder" value="'.$env{'form.folder'}.'" />'.
999: (' 'x2).'<input type="submit" value="'.&mt('Display').'" />';
1000: $r->print('<div class="LC_left_float">'.
1001: '<fieldset><legend>'.&mt('Display of Content Changes').'</legend>'."\n".
1002: &makedocslogform($filter,1).
1003: '</fieldset></div><br clear="all" />');
1.329 droeschl 1004: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
1005: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
1006: &mt('After').'</th>'.
1007: &Apache::loncommon::end_data_table_header_row());
1008: my $shown=0;
1009: foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
1010: if ($env{'form.displayfilter'} eq 'currentfolder') {
1011: if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
1012: }
1013: my @changes=keys(%{$docslog{$id}{'logentry'}});
1014: if ($env{'form.displayfilter'} eq 'containing') {
1015: my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
1016: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
1017: foreach my $key (@changes) {
1018: $wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
1019: }
1.344 bisitz 1020: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
1.329 droeschl 1021: }
1022: my $count = 0;
1023: my $time =
1024: &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
1025: my $plainname =
1026: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
1027: $docslog{$id}{'exe_udom'});
1028: my $about_me_link =
1029: &Apache::loncommon::aboutmewrapper($plainname,
1030: $docslog{$id}{'exe_uname'},
1031: $docslog{$id}{'exe_udom'});
1032: my $send_msg_link='';
1033: if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
1034: || ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
1035: $send_msg_link ='<br />'.
1036: &Apache::loncommon::messagewrapper(&mt('Send message'),
1037: $docslog{$id}{'exe_uname'},
1038: $docslog{$id}{'exe_udom'});
1039: }
1040: $r->print(&Apache::loncommon::start_data_table_row());
1041: $r->print('<td>'.$time.'</td>
1042: <td>'.$about_me_link.
1043: '<br /><tt>'.$docslog{$id}{'exe_uname'}.
1044: ':'.$docslog{$id}{'exe_udom'}.'</tt>'.
1045: $send_msg_link.'</td><td>'.
1046: $docslog{$id}{'logentry'}{'folder'}.'</td><td>');
1.484.2.19 raeburn 1047: my $is_supp = 0;
1.484.2.7 raeburn 1048: if ($docslog{$id}{'logentry'}{'currentfolder'} =~ /^supplemental/) {
1049: $is_supp = 1;
1050: }
1.329 droeschl 1051: # Before
1052: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1053: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
1054: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
1055: if ($oldname ne $newname) {
1.484.2.7 raeburn 1056: my $shown = &LONCAPA::map::qtescape($oldname);
1057: if ($is_supp) {
1058: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1059: }
1060: $r->print($shown);
1.329 droeschl 1061: }
1062: }
1063: $r->print('<ul>');
1064: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1065: if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
1.484.2.7 raeburn 1066: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]);
1067: if ($is_supp) {
1068: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1069: }
1.484.2.19 raeburn 1070: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 1071: }
1072: }
1073: $r->print('</ul>');
1074: # After
1075: $r->print('</td><td>');
1076:
1077: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1078: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
1079: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
1080: if ($oldname ne '' && $oldname ne $newname) {
1.484.2.7 raeburn 1081: my $shown = &LONCAPA::map::qtescape($newname);
1082: if ($is_supp) {
1083: $shown = &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($newname));
1084: }
1085: $r->print($shown);
1.329 droeschl 1086: }
1.364 bisitz 1087: }
1.329 droeschl 1088: $r->print('<ul>');
1089: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1090: if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
1.484.2.7 raeburn 1091: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]);
1092: if ($is_supp) {
1093: $shown = &Apache::loncommon::parse_supplemental_title($shown);
1094: }
1095: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 1096: }
1097: }
1098: $r->print('</ul>');
1099: if ($docslog{$id}{'logentry'}{'parameter_res'}) {
1100: $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
1101: foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
1102: if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
1.452 www 1103: # FIXME: internationalization seems wrong here
1.329 droeschl 1104: $r->print('<li>'.
1105: &mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
1106: $docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
1107: .'</li>');
1108: }
1109: }
1110: $r->print('</ul>');
1111: }
1112: # End
1113: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1114: $shown++;
1115: if (!($env{'form.show'} eq &mt('all')
1116: || $shown<=$env{'form.show'})) { last; }
1117: }
1.484 raeburn 1118: $r->print(&Apache::loncommon::end_data_table()."\n".
1119: &makesimpleeditform($pathitem)."\n".
1120: '</div></div>');
1121: $r->print(&endContentScreen());
1.329 droeschl 1122: }
1123:
1124: sub update_paste_buffer {
1.484.2.7 raeburn 1125: my ($coursenum,$coursedom,$folder) = @_;
1.484.2.57 raeburn 1126: my (@possibles,%removals,%cuts,$output);
1.484.2.30 raeburn 1127: if ($env{'form.multiremove'}) {
1128: $env{'form.multiremove'} =~ s/,$//;
1129: map { $removals{$_} = 1; } split(/,/,$env{'form.multiremove'});
1130: }
1131: if (($env{'form.multicopy'}) || ($env{'form.multicut'})) {
1132: if ($env{'form.multicut'}) {
1133: $env{'form.multicut'} =~ s/,$//;
1134: foreach my $item (split(/,/,$env{'form.multicut'})) {
1135: unless ($removals{$item}) {
1136: $cuts{$item} = 1;
1137: push(@possibles,$item.':cut');
1138: }
1139: }
1140: }
1141: if ($env{'form.multicopy'}) {
1142: $env{'form.multicopy'} =~ s/,$//;
1143: foreach my $item (split(/,/,$env{'form.multicopy'})) {
1144: unless ($removals{$item} || $cuts{$item}) {
1145: push(@possibles,$item.':copy');
1146: }
1147: }
1148: }
1149: } elsif ($env{'form.markcopy'}) {
1150: @possibles = split(/,/,$env{'form.markcopy'});
1151: }
1.329 droeschl 1152:
1.484.2.30 raeburn 1153: return if (@possibles == 0);
1.329 droeschl 1154: return if (!defined($env{'form.copyfolder'}));
1155:
1156: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1157: $env{'form.copyfolder'});
1158: return if ($fatal);
1159:
1.484.2.30 raeburn 1160: my %curr_groups = &Apache::longroup::coursegroups();
1161:
1162: # Retrieve current paste buffer suffixes.
1163: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1164: my (%pasteurls,@newpaste);
1165:
1166: # Construct identifiers for current contents of user's paste buffer
1167: if (@currpaste) {
1168: foreach my $suffix (@currpaste) {
1169: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1170: my $url = $env{'docs.markedcopy_url_'.$suffix};
1171: if (($cid =~ /^$match_domain(?:_)$match_courseid$/) &&
1172: ($url ne '')) {
1.484.2.41 raeburn 1173: $pasteurls{$cid.'_'.$url} = 1;
1.484.2.30 raeburn 1174: }
1175: }
1176: }
1177:
1178: # Mark items for copying (skip any items already in user's paste buffer)
1179: my %addtoenv;
1180:
1181: foreach my $item (@possibles) {
1182: my ($orderidx,$cmd) = split(/:/,$item);
1183: next if ($orderidx =~ /\D/);
1184: next unless (($cmd eq 'cut') || ($cmd eq 'copy') || ($cmd eq 'remove'));
1185: my ($title,$url)=split(':',$LONCAPA::map::resources[$orderidx]);
1186: my %denied = &action_restrictions($coursenum,$coursedom,
1187: &LONCAPA::map::qtescape($url),
1188: $env{'form.folderpath'},\%curr_groups);
1189: next if ($denied{'copy'});
1190: $url=~s{http(:|:)//https(:|:)//}{https$2//};
1191: next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$url}));
1192: my ($suffix,$errortxt,$locknotfreed) =
1193: &new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste');
1.484.2.57 raeburn 1194: if ($suffix ne '') {
1195: push(@newpaste,$suffix);
1196: } else {
1197: if ($locknotfreed) {
1198: return $locknotfreed;
1199: }
1.484.2.30 raeburn 1200: }
1201: if (&is_supplemental_title($title)) {
1202: &Apache::lonnet::appenv({'docs.markedcopy_supplemental_'.$suffix => $title});
1203: ($title) = &Apache::loncommon::parse_supplemental_title($title);
1204: }
1205:
1206: $addtoenv{'docs.markedcopy_title_'.$suffix} = $title,
1207: $addtoenv{'docs.markedcopy_url_'.$suffix} = $url,
1208: $addtoenv{'docs.markedcopy_cmd_'.$suffix} = $cmd,
1209: $addtoenv{'docs.markedcopy_crs_'.$suffix} = $env{'request.course.id'};
1210:
1211: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) {
1212: my $prefix = $1;
1213: my $subdir =$2;
1214: if ($subdir eq '') {
1215: $subdir = $prefix;
1.484.2.7 raeburn 1216: }
1.484.2.30 raeburn 1217: my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps);
1.484.2.72.2. (raeburn 1218:): &contained_map_check($url,$folder,$coursenum,$coursedom,\%removefrommap,
1219:): \%removeparam,\%addedmaps,\%hierarchy,\%titles,\%allmaps);
1.484.2.30 raeburn 1220: if (ref($hierarchy{$url}) eq 'HASH') {
1221: my ($nested,$nestednames);
1222: &recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames);
1223: $nested =~ s/\&$//;
1224: $nestednames =~ s/\Q___&&&___\E$//;
1225: if ($nested ne '') {
1226: $addtoenv{'docs.markedcopy_nested_'.$suffix} = $nested;
1227: }
1228: if ($nestednames ne '') {
1229: $addtoenv{'docs.markedcopy_nestednames_'.$suffix} = $nestednames;
1230: }
1.484.2.7 raeburn 1231: }
1232: }
1.484.2.57 raeburn 1233: if ($locknotfreed) {
1234: $output = $locknotfreed;
1235: last;
1236: }
1.484.2.7 raeburn 1237: }
1.484.2.30 raeburn 1238: if (@newpaste) {
1239: $addtoenv{'docs.markedcopies'} = join(',',(@currpaste,@newpaste));
1240: }
1.484.2.7 raeburn 1241: &Apache::lonnet::appenv(\%addtoenv);
1.329 droeschl 1242: delete($env{'form.markcopy'});
1.484.2.57 raeburn 1243: return $output;
1.329 droeschl 1244: }
1245:
1.484.2.7 raeburn 1246: sub recurse_uploaded_maps {
1247: my ($url,$dir,$hierarchy,$titlesref,$nestref,$namesref) = @_;
1248: if (ref($hierarchy->{$url}) eq 'HASH') {
1249: my @maps = map { $hierarchy->{$url}{$_}; } sort { $a <=> $b } (keys(%{$hierarchy->{$url}}));
1250: my @titles = map { $titlesref->{$url}{$_}; } sort { $a <=> $b } (keys(%{$titlesref->{$url}}));
1251: my (@uploaded,@names,%shorter);
1252: for (my $i=0; $i<@maps; $i++) {
1253: my ($inner) = ($maps[$i] =~ m{^/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_(\d+)\.(?:page|sequence)$});
1254: if ($inner ne '') {
1255: push(@uploaded,$inner);
1256: push(@names,&escape($titles[$i]));
1257: $shorter{$maps[$i]} = $inner;
1258: }
1259: }
1260: $$nestref .= "$dir:".join(',',@uploaded).'&';
1261: $$namesref .= "$dir:".(join(',',@names)).'___&&&___';
1262: foreach my $map (@maps) {
1263: if ($shorter{$map} ne '') {
1264: &recurse_uploaded_maps($map,$shorter{$map},$hierarchy,$titlesref,$nestref,$namesref);
1265: }
1266: }
1267: }
1268: return;
1269: }
1270:
1.329 droeschl 1271: sub print_paste_buffer {
1.484.2.7 raeburn 1272: my ($r,$container,$folder,$coursedom,$coursenum) = @_;
1.484.2.30 raeburn 1273: return if (!defined($env{'docs.markedcopies'}));
1.329 droeschl 1274:
1.484.2.30 raeburn 1275: unless (($env{'form.pastemarked'}) || ($env{'form.clearmarked'})) {
1276: return if ($env{'docs.markedcopies'} eq '');
1.484.2.7 raeburn 1277: }
1278:
1.484.2.30 raeburn 1279: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1280: my ($pasteitems,@pasteable);
1.484.2.47 raeburn 1281: my $clipboardcount = 0;
1.484.2.7 raeburn 1282:
1.484.2.30 raeburn 1283: # Construct identifiers for current contents of user's paste buffer
1284: foreach my $suffix (@currpaste) {
1285: next if ($suffix =~ /\D/);
1286: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1287: my $url = $env{'docs.markedcopy_url_'.$suffix};
1288: if (($cid =~ /^$match_domain\_$match_courseid$/) &&
1289: ($url ne '')) {
1.484.2.47 raeburn 1290: $clipboardcount ++;
1.484.2.30 raeburn 1291: my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent,
1.484.2.72.2. (raeburn 1292:): $canpaste,$nopaste,$othercrs,$areachange,$is_exttool);
1.484.2.30 raeburn 1293: my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1];
1294: if ($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
1295: $is_external = 1;
1.484.2.72.2. (raeburn 1296:): } elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$}) {
1297:): $is_exttool = 1;
1.484.2.7 raeburn 1298: }
1.484.2.30 raeburn 1299: if ($folder =~ /^supplemental/) {
1300: $canpaste = &supp_pasteable($env{'docs.markedcopy_url_'.$suffix});
1301: unless ($canpaste) {
1302: $nopaste = &mt('Paste into Supplemental Content unavailable.');
1.484.2.7 raeburn 1303: }
1.484.2.30 raeburn 1304: } else {
1305: $canpaste = 1;
1.484.2.7 raeburn 1306: }
1.484.2.30 raeburn 1307: if ($canpaste) {
1308: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1309: my $srcdom = $1;
1310: my $srcnum = $2;
1311: my $rem = $3;
1312: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
1313: $othercourse = 1;
1314: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1.484.2.72.2. (raeburn 1315:): $othercrs = '<br />'.&mt('(from another course)');
1.484.2.30 raeburn 1316: } else {
1317: $canpaste = 0;
1318: $nopaste = &mt('Paste from another course unavailable.');
1.484.2.7 raeburn 1319: }
1320: }
1.484.2.30 raeburn 1321: if ($rem =~ m{^(default|supplemental)_?(\d*)\.(?:page|sequence)$}) {
1322: my $prefix = $1;
1323: $parent = $2;
1324: if ($folder !~ /^\Q$prefix\E/) {
1325: $areachange = 1;
1326: }
1327: $is_uploaded_map = 1;
1328: }
1.484.2.72.2. (raeburn 1329:): } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
1330:): ($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg|ext\.tool)$})) {
1331:): if ($cid ne $env{'request.course.id'}) {
1332:): my ($srcdom,$srcnum) = split(/_/,$cid);
1333:): if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1334:): if (($is_exttool) && ($srcdom ne $coursedom)) {
1335:): $canpaste = 0;
1336:): $nopaste = &mt('Paste from another domain unavailable.');
1337:): } else {
1338:): $othercrs = '<br />'.&mt('(from another course)');
1339:): }
1340:): } else {
1341:): $canpaste = 0;
1342:): $nopaste = &mt('Paste from another course unavailable.');
1343:): }
1344:): }
1.484.2.30 raeburn 1345: }
1346: }
1347: if ($canpaste) {
1348: push(@pasteable,$suffix);
1349: }
1350: my $buffer;
1.484.2.72.2. (raeburn 1351:): if ($is_external) {
1.484.2.30 raeburn 1352: $buffer = &mt('External Resource').': '.
1353: &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('.
1354: &LONCAPA::map::qtescape($url).')';
1.484.2.72.2. (raeburn 1355:): } elsif ($is_exttool) {
1356:): $buffer = &mt('External Tool').': '.
1357:): &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.484.2.30 raeburn 1358: } else {
1359: my $icon = &Apache::loncommon::icon($extension);
1360: if ($extension eq 'sequence' &&
1361: $url =~ m{/default_\d+\.sequence$}x) {
1362: $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
1363: $icon .= '/navmap.folder.closed.gif';
1364: }
1.484.2.57 raeburn 1365: my $title = $env{'docs.markedcopy_title_'.$suffix};
1366: if ($title eq '') {
1367: ($title) = ($url =~ m{/([^/]+)$});
1368: }
1.484.2.30 raeburn 1369: $buffer = '<img src="'.$icon.'" alt="" class="LC_icon" />'.
1370: ': '.
1371: &Apache::loncommon::parse_supplemental_title(
1.484.2.57 raeburn 1372: &LONCAPA::map::qtescape($title));
1.484.2.30 raeburn 1373: }
1374: $pasteitems .= '<div class="LC_left_float">';
1375: my ($options,$onclick);
1376: if (($canpaste) && (!$areachange) && (!$othercourse) &&
1377: ($env{'docs.markedcopy_cmd_'.$suffix} eq 'cut')) {
1378: if (($is_uploaded_map) ||
1379: ($url =~ /(bulletinboard|smppg)$/) ||
1380: ($url =~ m{^/uploaded/$coursedom/$coursenum/(?:docs|supplemental)/(.+)$})) {
1381: $options = &paste_options($suffix,$is_uploaded_map,$parent);
1382: $onclick= 'onclick="showOptions(this,'."'$suffix'".');" ';
1383: }
1384: }
1385: $pasteitems .= '<label><input type="checkbox" name="pasting" id="pasting_'.$suffix.'" value="'.$suffix.'" '.$onclick.'/>'.$buffer.'</label>';
1386: if ($nopaste) {
1387: $pasteitems .= $nopaste;
1388: } else {
1389: if ($othercrs) {
1390: $pasteitems .= $othercrs;
1391: }
1392: if ($options) {
1393: $pasteitems .= $options;
1.484.2.7 raeburn 1394: }
1395: }
1.484.2.30 raeburn 1396: $pasteitems .= '</div>';
1397: }
1398: }
1399: if ($pasteitems eq '') {
1400: &Apache::lonnet::delenv('docs.markedcopies');
1401: }
1402: my ($pasteform,$form_start,$buttons,$form_end);
1403: if ($pasteitems) {
1404: $pasteitems .= '<div style="padding:0;clear:both;margin:0;border:0"></div>';
1405: $form_start = '<form name="pasteform" action="/adm/coursedocs" method="post" onsubmit="return validateClipboard();">';
1406: if (@pasteable) {
1.484.2.47 raeburn 1407: my $value = &mt('Paste to current folder');
1408: if ($container eq 'page') {
1409: $value = &mt('Paste to current page');
1410: }
1411: $buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.(' 'x2);
1412: }
1.484.2.72.2. (raeburn 1413:): $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.(' 'x2);
1.484.2.47 raeburn 1414: if ($clipboardcount > 1) {
1415: $buttons .=
1416: '<span style="text-decoration:line-through">'.(' 'x20).'</span>'.(' 'x2).
1417: '<input type="button" name="checkallclip" value="'.&mt('Check all').'" style="height:20px;" onclick="checkClipboard();" />'.
1418: (' 'x2).
1419: '<input type="button" name="uncheckallclip" value="'.&mt('Uncheck all').'" style="height:20px;" onclick="uncheckClipboard();" />'.
1420: (' 'x2);
1.484.2.7 raeburn 1421: }
1.484.2.48 raeburn 1422: $form_end = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'.
1423: '</form>';
1.484.2.30 raeburn 1424: } else {
1425: $pasteitems = &mt('Clipboard is empty');
1426: }
1427: $r->print($form_start
1428: .'<fieldset>'
1429: .'<legend>'.&mt('Clipboard').(' ' x2).$buttons.'</legend>'
1430: .$pasteitems
1431: .'</fieldset>'
1432: .$form_end);
1433: }
1434:
1435: sub paste_options {
1436: my ($suffix,$is_uploaded_map,$parent) = @_;
1437: my ($copytext,$movetext);
1438: if ($is_uploaded_map) {
1439: $copytext = &mt('Copy to new folder');
1440: $movetext = &mt('Move old');
1441: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /bulletinboard$/) {
1442: $copytext = &mt('Copy to new board');
1443: $movetext = &mt('Move (not posts)');
1444: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /smppg$/) {
1445: $copytext = &mt('Copy to new page');
1446: $movetext = &mt('Move');
1.484.2.7 raeburn 1447: } else {
1.484.2.30 raeburn 1448: $copytext = &mt('Copy to new file');
1449: $movetext = &mt('Move');
1450: }
1451: my $output = '<br />'.
1452: '<span id="pasteoptionstext_'.$suffix.'" class="LC_fontsize_small LC_nobreak"></span>'.
1453: '<div id="pasteoptions_'.$suffix.'" class="LC_dccid" style="display:none;"><span class="LC_nobreak">'.(' 'x 4).
1454: '<label>'.
1455: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="new" checked="checked" />'.
1456: $copytext.'</label></span>'.(' 'x2).' '.
1457: '<span class="LC_nobreak"><label>'.
1458: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="move" />'.
1459: $movetext.'</label></span>';
1460: if (($is_uploaded_map) && ($env{'docs.markedcopy_nested_'.$suffix})) {
1461: $output .= '<br /><fieldset><legend>'.&mt('Folder to paste contains sub-folders').
1462: '</legend><table border="0">';
1463: my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1464: my @titles = split(/\Q___&&&___\E/,$env{'docs.markedcopy_nestednames_'.$suffix});
1465: my $lastdir = $parent;
1466: my %depths = (
1467: $lastdir => 0,
1468: );
1469: my (%display,%deps);
1470: for (my $i=0; $i<@pastemaps; $i++) {
1471: ($lastdir,my $subfolderstr) = split(/\:/,$pastemaps[$i]);
1472: my ($namedir,$esctitlestr) = split(/\:/,$titles[$i]);
1473: my @subfolders = split(/,/,$subfolderstr);
1474: $deps{$lastdir} = \@subfolders;
1475: my @subfoldertitles = map { &unescape($_); } split(/,/,$esctitlestr);
1476: my $depth = $depths{$lastdir} + 1;
1477: my $offset = int($depth * 4);
1478: my $indent = (' ' x $offset);
1479: for (my $j=0; $j<@subfolders; $j++) {
1480: $depths{$subfolders[$j]} = $depth;
1481: $display{$subfolders[$j]} =
1482: '<tr><td>'.$indent.$subfoldertitles[$j].' </td>'.
1483: '<td><label>'.
1484: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="new" checked="checked" />'.&mt('Copy to new').'</label>'.(' ' x2).
1485: '<label>'.
1486: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="move" />'.
1487: &mt('Move old').'</label>'.
1488: '</td></tr>';
1489: }
1490: }
1491: &recurse_print(\$output,$parent,\%deps,\%display);
1492: $output .= '</table></fieldset>';
1.329 droeschl 1493: }
1.484.2.30 raeburn 1494: $output .= '</div>';
1495: return $output;
1.329 droeschl 1496: }
1497:
1.484.2.7 raeburn 1498: sub recurse_print {
1.484.2.30 raeburn 1499: my ($outputref,$dir,$deps,$display) = @_;
1500: $$outputref .= $display->{$dir}."\n";
1.484.2.7 raeburn 1501: if (ref($deps->{$dir}) eq 'ARRAY') {
1502: foreach my $subdir (@{$deps->{$dir}}) {
1.484.2.30 raeburn 1503: &recurse_print($outputref,$subdir,$deps,$display);
1.484.2.7 raeburn 1504: }
1505: }
1506: }
1507:
1508: sub supp_pasteable {
1509: my ($url) = @_;
1510: if (($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//}) ||
1511: (($url =~ /\.sequence$/) && ($url =~ m{^/uploaded/})) ||
1512: ($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) ||
1513: ($url =~ m{^/adm/$match_domain/$match_username/aboutme}) ||
1.484.2.72.2. (raeburn 1514:): ($url =~ m{^/public/$match_domain/$match_courseid/syllabus}) ||
1515:): ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$})) {
1.484.2.7 raeburn 1516: return 1;
1517: }
1518: return;
1519: }
1520:
1521: sub paste_popup_js {
1.484.2.61 raeburn 1522: my %html_js_lt = &Apache::lonlocal::texthash(
1.484.2.30 raeburn 1523: show => 'Show Options',
1524: hide => 'Hide Options',
1.484.2.61 raeburn 1525: );
1526: my %js_lt = &Apache::lonlocal::texthash(
1.484.2.30 raeburn 1527: none => 'No items selected from clipboard.',
1.484.2.7 raeburn 1528: );
1.484.2.61 raeburn 1529: &html_escape(\%html_js_lt);
1530: &js_escape(\%html_js_lt);
1531: &js_escape(\%js_lt);
1.484.2.7 raeburn 1532: return <<"END";
1533:
1.484.2.30 raeburn 1534: function showPasteOptions(suffix) {
1535: document.getElementById('pasteoptions_'+suffix).style.display='block';
1.484.2.61 raeburn 1536: document.getElementById('pasteoptionstext_'+suffix).innerHTML = ' <a href="javascript:hidePasteOptions(\\''+suffix+'\\');" class="LC_menubuttons_link">$html_js_lt{'hide'}</a>';
1.484.2.7 raeburn 1537: return;
1538: }
1539:
1.484.2.30 raeburn 1540: function hidePasteOptions(suffix) {
1541: document.getElementById('pasteoptions_'+suffix).style.display='none';
1.484.2.61 raeburn 1542: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.484.2.7 raeburn 1543: return;
1544: }
1545:
1.484.2.30 raeburn 1546: function showOptions(caller,suffix) {
1547: if (document.getElementById('pasteoptionstext_'+suffix)) {
1548: if (caller.checked) {
1.484.2.61 raeburn 1549: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.484.2.30 raeburn 1550: } else {
1551: document.getElementById('pasteoptionstext_'+suffix).innerHTML ='';
1552: }
1553: if (document.getElementById('pasteoptions_'+suffix)) {
1554: document.getElementById('pasteoptions_'+suffix).style.display='none';
1555: }
1556: }
1557: return;
1558: }
1.484.2.7 raeburn 1559:
1.484.2.30 raeburn 1560: function validateClipboard() {
1561: var numchk = 0;
1562: if (document.pasteform.pasting.length > 1) {
1563: for (var i=0; i<document.pasteform.pasting.length; i++) {
1564: if (document.pasteform.pasting[i].checked) {
1565: numchk ++;
1566: }
1567: }
1568: } else {
1569: if (document.pasteform.pasting.type == 'checkbox') {
1570: if (document.pasteform.pasting.checked) {
1571: numchk ++;
1572: }
1573: }
1574: }
1575: if (numchk > 0) {
1576: return true;
1577: } else {
1.484.2.61 raeburn 1578: alert("$js_lt{'none'}");
1.484.2.30 raeburn 1579: return false;
1580: }
1.484.2.7 raeburn 1581: }
1582:
1.484.2.47 raeburn 1583: function checkClipboard() {
1584: if (document.pasteform.pasting.length > 1) {
1585: for (var i=0; i<document.pasteform.pasting.length; i++) {
1586: document.pasteform.pasting[i].checked = true;
1587: }
1588: }
1589: return;
1590: }
1591:
1592: function uncheckClipboard() {
1593: if (document.pasteform.pasting.length >1) {
1594: for (var i=0; i<document.pasteform.pasting.length; i++) {
1595: document.pasteform.pasting[i].checked = false;
1596: }
1597: }
1598: return;
1599: }
1600:
1.484.2.30 raeburn 1601: END
1602:
1603: }
1.484.2.7 raeburn 1604:
1.329 droeschl 1605: sub do_paste_from_buffer {
1.484.2.7 raeburn 1606: my ($coursenum,$coursedom,$folder,$container,$errors) = @_;
1.329 droeschl 1607:
1.484.2.30 raeburn 1608: # Array of items in paste buffer
1609: my (@currpaste,%pastebuffer,%allerrors);
1610: @currpaste = split(/,/,$env{'docs.markedcopies'});
1611:
1.484.2.7 raeburn 1612: # Early out if paste buffer is empty
1.484.2.30 raeburn 1613: if (@currpaste == 0) {
1.484.2.7 raeburn 1614: return ();
1.484.2.30 raeburn 1615: }
1616: map { $pastebuffer{$_} = 1; } @currpaste;
1617:
1618: # Array of items selected items to paste
1619: my @reqpaste = &Apache::loncommon::get_env_multiple('form.pasting');
1620:
1621: # Early out if nothing selected to paste
1622: if (@reqpaste == 0) {
1623: return();
1624: }
1625: my @topaste;
1626: foreach my $suffix (@reqpaste) {
1627: next if ($suffix =~ /\D/);
1628: next unless (exists($pastebuffer{$suffix}));
1629: push(@topaste,$suffix);
1.484.2.7 raeburn 1630: }
1631:
1.484.2.30 raeburn 1632: # Early out if nothing available to paste
1633: if (@topaste == 0) {
1634: return();
1.329 droeschl 1635: }
1636:
1.484.2.72.2. (raeburn 1637:): my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%notindom,%duplicate,
1.484.2.41 raeburn 1638: %prefixchg,%srcdom,%srcnum,%marktomove,$save_err,$lockerrors,$allresult);
1.484.2.7 raeburn 1639:
1.484.2.30 raeburn 1640: foreach my $suffix (@topaste) {
1641: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1.484.2.72.2. (raeburn 1642:): my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.484.2.30 raeburn 1643: # Supplemental content may only include certain types of content
1644: # Early out if pasted content is not supported in Supplemental area
1645: if ($folder =~ /^supplemental/) {
1646: unless (&supp_pasteable($url)) {
1647: $notinsupp{$suffix} = 1;
1648: next;
1649: }
1650: }
1651: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/}) {
1652: my $srcd = $1;
1653: my $srcn = $2;
1.484.2.7 raeburn 1654: # When paste buffer was populated using an active role in a different course
1.484.2.30 raeburn 1655: # check for mdc privilege in the course from which the resource was pasted
1656: if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1657: unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1658: $notincrs{$suffix} = 1;
1659: next;
1660: }
1.329 droeschl 1661: }
1.484.2.30 raeburn 1662: $srcdom{$suffix} = $srcd;
1663: $srcnum{$suffix} = $srcn;
1.484.2.72.2. (raeburn 1664:): } elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$}) {
1665:): my ($srcd,$srcn) = split(/_/,$cid);
1666:): # When paste buffer was populated using an active role in a different course
1667:): # check for mdc privilege in the course from which the resource was pasted
1668:): if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1669:): unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1670:): $notincrs{$suffix} = 1;
1671:): next;
1672:): }
1673:): }
1674:): # When buffer was populated using an active role in a different course
1675:): # disallow pasting of External Tool if course is in a different domain.
1676:): if ($srcd ne $coursedom) {
1677:): $notindom{$suffix} = 1;
1678:): next;
1679:): }
1680:): $srcdom{$suffix} = $srcd;
1681:): $srcnum{$suffix} = $srcn;
1.484.2.30 raeburn 1682: }
1683: push(@dopaste,$suffix);
1684: if ($url=~/\.(page|sequence)$/) {
1685: $is_map{$suffix} = 1;
1.329 droeschl 1686: }
1.484.2.30 raeburn 1687:
1688: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/([^/]+)}) {
1689: my $oldprefix = $1;
1.484.2.19 raeburn 1690: # When pasting content from Main Content to Supplemental Content and vice versa
1.484.2.7 raeburn 1691: # URLs will contain different paths (which depend on whether pasted item is
1.484.2.72.2. (raeburn 1692:): # a folder/page or a document).
1.484.2.30 raeburn 1693: if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) {
1694: $prefixchg{$suffix} = 'docstosupp';
1695: } elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) {
1696: $prefixchg{$suffix} = 'supptodocs';
1697: }
1.484.2.7 raeburn 1698:
1699: # If pasting an uploaded map, get list of contained uploaded maps.
1.484.2.30 raeburn 1700: if ($env{'docs.markedcopy_nested_'.$suffix}) {
1701: my @nested;
1702: my ($type) = ($oldprefix =~ /^(default|supplemental)/);
1703: my @items = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1704: my @deps = map { /\d+:([\d,]+$)/ } @items;
1705: foreach my $dep (@deps) {
1706: if ($dep =~ /,/) {
1707: push(@nested,split(/,/,$dep));
1708: } else {
1709: push(@nested,$dep);
1710: }
1.484.2.7 raeburn 1711: }
1.484.2.30 raeburn 1712: foreach my $item (@nested) {
1713: if ($env{'form.docs.markedcopy_'.$suffix.'_'.$item} eq 'move') {
1714: push(@{$marktomove{$suffix}},$type.'_'.$item);
1715: }
1.484.2.7 raeburn 1716: }
1717: }
1.329 droeschl 1718: }
1.484.2.7 raeburn 1719: }
1720:
1.484.2.30 raeburn 1721: # Early out if nothing available to paste
1722: if (@dopaste == 0) {
1723: return ();
1724: }
1725:
1726: # Populate message hash and hashes used for main content <=> supplemental content
1727: # changes
1728:
1729: %msgs = &Apache::lonlocal::texthash (
1730: notinsupp => 'Paste failed: content type is not supported within Supplemental Content',
1731: notincrs => 'Paste failed: Item is from a different course which you do not have rights to edit.',
1.484.2.72.2. (raeburn 1732:): notindom => 'Paste failed: Item is an external tool from a course in a different donain.',
1.484.2.30 raeburn 1733: duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.',
1734: );
1735:
1736: %before = (
1737: docstosupp => {
1738: map => 'default',
1739: doc => 'docs',
1740: },
1741: supptodocs => {
1742: map => 'supplemental',
1743: doc => 'supplemental',
1744: },
1745: );
1746:
1747: %after = (
1748: docstosupp => {
1749: map => 'supplemental',
1750: doc => 'supplemental'
1751: },
1752: supptodocs => {
1753: map => 'default',
1754: doc => 'docs',
1755: },
1756: );
1757:
1758: # Retrieve information about all course maps in main content area
1759:
1760: my $allmaps = {};
1761: if ($folder =~ /^default/) {
1762: $allmaps =
1763: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
1764: $env{"course.$env{'request.course.id'}.home"},
1765: $env{'request.course.id'});
1766: }
1767:
1768: my (@toclear,%mapurls,%lockerrs,%msgerrs,%results);
1769:
1770: # Loop over the items to paste
1771: foreach my $suffix (@dopaste) {
1.484.2.7 raeburn 1772: # Maps need to be copied first
1.484.2.30 raeburn 1773: my (%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies,
1774: %dbcopies,%zombies,%params,%docmoves,%mapmoves,%mapchanges,%newsubdir,
1775: %newurls,%tomove);
1776: if (ref($marktomove{$suffix}) eq 'ARRAY') {
1777: map { $tomove{$_} = 1; } @{$marktomove{$suffix}};
1778: }
1779: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1780: my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.484.2.72.2. (raeburn 1781:): my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.484.2.30 raeburn 1782: my $oldurl = $url;
1783: if ($is_map{$suffix}) {
1.484.2.7 raeburn 1784: # If pasting a map, check if map contains other maps
1.484.2.30 raeburn 1785: my (%hierarchy,%titles);
1.484.2.72.2. (raeburn 1786:): &contained_map_check($url,$folder,$coursenum,$coursedom,
1787:): \%removefrommap,\%removeparam,\%addedmaps,
1788:): \%hierarchy,\%titles,$allmaps);
1.484.2.30 raeburn 1789: if ($url=~ m{^/uploaded/}) {
1790: my $newurl;
1791: unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
1792: ($newurl,my $error) =
1793: &get_newmap_url($url,$folder,$prefixchg{$suffix},$coursedom,
1794: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1795: \$title,$allmaps,\%newurls);
1796: if ($error) {
1797: $allerrors{$suffix} = $error;
1798: next;
1799: }
1800: if ($newurl ne '') {
1801: if ($newurl ne $url) {
1802: if ($newurl =~ /(?:default|supplemental)_(\d+).(?:sequence|page)$/) {
1803: $newsubdir{$url} = $1;
1804: }
1805: $mapchanges{$url} = 1;
1.484.2.7 raeburn 1806: }
1807: }
1808: }
1.484.2.30 raeburn 1809: if (($srcdom{$suffix} ne $coursedom) ||
1810: ($srcnum{$suffix} ne $coursenum) ||
1811: ($prefixchg{$suffix}) || (($newurl ne '') && ($newurl ne $url))) {
1812: unless (&url_paste_fixups($url,$folder,$prefixchg{$suffix},
1813: $coursedom,$coursenum,$srcdom{$suffix},
1814: $srcnum{$suffix},$allmaps,\%rewrites,
1815: \%retitles,\%copies,\%dbcopies,
1816: \%zombies,\%params,\%mapmoves,
1817: \%mapchanges,\%tomove,\%newsubdir,
1818: \%newurls)) {
1819: $mapmoves{$url} = 1;
1820: }
1821: $url = $newurl;
1822: } elsif ($env{'docs.markedcopy_nested_'.$suffix}) {
1823: &url_paste_fixups($url,$folder,$prefixchg{$suffix},$coursedom,
1824: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1825: $allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies,
1826: \%zombies,\%params,\%mapmoves,\%mapchanges,
1827: \%tomove,\%newsubdir,\%newurls);
1828: }
1829: } elsif ($url=~m {^/res/}) {
1.484.2.72.2. (raeburn 1830:): # published map can only exist once, so remove from paste buffer when done
1.484.2.30 raeburn 1831: push(@toclear,$suffix);
1832: # if pasting published map (main content area only) check map not already in course
1833: if ($folder =~ /^default/) {
1834: if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) {
1835: $duplicate{$suffix} = 1;
1836: next;
1837: }
1.484.2.7 raeburn 1838: }
1839: }
1840: }
1.484.2.72.2. (raeburn 1841:): if ($url=~ m{/(ext\.tool)$}) {
1.484.2.30 raeburn 1842: my $prefix = $1;
1.484.2.72.2. (raeburn 1843:): my $fromothercrs;
1.484.2.30 raeburn 1844: #need to copy the db contents to a new one, unless this is a move.
1845: my %info = (
1846: src => $url,
1847: cdom => $coursedom,
1848: cnum => $coursenum,
1849: );
1.484.2.72.2. (raeburn 1850:): if (($srcdom{$suffix} =~ /^$match_domain$/) && ($srcnum{$suffix} =~ /^$match_courseid$/)) {
1851:): unless (($srcdom{$suffix} eq $coursedom) && ($srcnum{$suffix} eq $coursenum)) {
1852:): $fromothercrs = 1;
1853:): $info{'cdom'} = $srcdom{$suffix};
1854:): $info{'cnum'} = $srcnum{$suffix};
1855:): }
1856:): }
1857:): unless (($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') && (!$fromothercrs)) {
1.484.2.30 raeburn 1858: my (%lockerr,$msg);
1859: my ($newurl,$result,$errtext) =
1860: &dbcopy(\%info,$coursedom,$coursenum,\%lockerr);
1861: if ($result eq 'ok') {
1862: $url = $newurl;
1863: $title=&mt('Copy of').' '.$title;
1864: } else {
1.484.2.72.2. (raeburn 1865:): if ($prefix eq 'ext.tool') {
1866:): $msg = &mt('Paste failed: An error occurred when copying the external tool.').' '.$errtext;
1.484.2.30 raeburn 1867: }
1868: $results{$suffix} = $result;
1869: $msgerrs{$suffix} = $msg;
1870: $lockerrs{$suffix} = $lockerr{$prefix};
1871: next;
1872: }
1873: if ($lockerr{$prefix}) {
1874: $lockerrs{$suffix} = $lockerr{$prefix};
1.484.2.26 raeburn 1875: }
1.484.2.7 raeburn 1876: }
1.484.2.30 raeburn 1877: }
1878: $title = &LONCAPA::map::qtunescape($title);
1879: my $ext='false';
1880: if ($url=~m{^http(|s)://}) { $ext='true'; }
1881: if ($env{'docs.markedcopy_supplemental_'.$suffix}) {
1882: if ($folder !~ /^supplemental/) {
1883: (undef,undef,$title) =
1884: &Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental_'.$suffix});
1885: }
1886: } else {
1887: if ($folder=~/^supplemental/) {
1888: $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
1889: $env{'user.domain'}.'___&&&___'.$title;
1.484.2.26 raeburn 1890: }
1891: }
1.484.2.7 raeburn 1892:
1893: # For uploaded files (excluding pages/sequences) path in copied file is changed
1894: # if paste is from Main to Supplemental (or vice versa), or if pasting between
1895: # courses.
1896:
1.484.2.30 raeburn 1897: unless ($is_map{$suffix}) {
1898: my $newidx;
1.329 droeschl 1899: # Now insert the URL at the bottom
1.484.2.30 raeburn 1900: $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
1901: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(.+)$}) {
1902: my $relpath = $1;
1903: if ($relpath ne '') {
1904: my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$});
1905: my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/);
1906: my $newprefix = $newloc;
1907: if ($newloc eq 'default') {
1908: $newprefix = 'docs';
1909: }
1910: if ($newdocsdir eq '') {
1911: $newdocsdir = 'default';
1912: }
1913: if (($prefixchg{$suffix}) ||
1914: ($srcdom{$suffix} ne $coursedom) ||
1915: ($srcnum{$suffix} ne $coursenum) ||
1916: ($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) {
1917: my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";
1918: $url =
1919: &Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath,
1920: &Apache::lonnet::getfile($oldurl));
1921: if ($url eq '/adm/notfound.html') {
1922: $msgs{$suffix} = &mt('Paste failed: an error occurred saving the file.');
1923: next;
1924: } else {
1925: my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$});
1926: $newsubpath =~ s{/+$}{/};
1927: $docmoves{$oldurl} = $newsubpath;
1928: }
1.484.2.7 raeburn 1929: }
1930: }
1931: }
1.484.2.30 raeburn 1932: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
1933: ':'.$ext.':normal:res';
1934: push(@LONCAPA::map::order,$newidx);
1935: # Store the result
1936: my ($errtext,$fatal) =
1937: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1938: if ($fatal) {
1939: $save_err .= $errtext;
1940: $allresult = 'fail';
1.484.2.7 raeburn 1941: }
1.329 droeschl 1942: }
1.484.2.30 raeburn 1943:
1944: # Apply any changes to maps, or copy dependencies for uploaded HTML pages
1945: unless ($allresult eq 'fail') {
1946: my %updated = (
1947: rewrites => \%rewrites,
1948: zombies => \%zombies,
1949: removefrommap => \%removefrommap,
1950: removeparam => \%removeparam,
1951: dbcopies => \%dbcopies,
1952: retitles => \%retitles,
1953: );
1954: my %info = (
1955: newsubdir => \%newsubdir,
1956: params => \%params,
1957: );
1958: if ($prefixchg{$suffix}) {
1959: $info{'before'} = $before{$prefixchg{$suffix}};
1960: $info{'after'} = $after{$prefixchg{$suffix}};
1961: }
1962: my %moves = (
1963: copies => \%copies,
1964: docmoves => \%docmoves,
1965: mapmoves => \%mapmoves,
1966: );
1967: (my $result,$msgs{$suffix},my $lockerror) =
1968: &apply_fixups($folder,$is_map{$suffix},$coursedom,$coursenum,$errors,
1969: \%updated,\%info,\%moves,$prefixchg{$suffix},$oldurl,
1970: $url,'paste');
1971: $lockerrors .= $lockerror;
1972: if ($result eq 'ok') {
1973: if ($is_map{$suffix}) {
1974: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1975: $folder.'.'.$container);
1976: if ($fatal) {
1977: $allresult = 'failread';
1978: } else {
1979: if ($#LONCAPA::map::order<1) {
1980: my $idx=&LONCAPA::map::getresidx();
1981: if ($idx<=0) { $idx=1; }
1982: $LONCAPA::map::order[0]=$idx;
1983: $LONCAPA::map::resources[$idx]='';
1984: }
1985: my $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
1986: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
1987: ':'.$ext.':normal:res';
1988: push(@LONCAPA::map::order,$newidx);
1.484.2.7 raeburn 1989:
1990: # Store the result
1.484.2.30 raeburn 1991: my ($errtext,$fatal) =
1992: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1993: if ($fatal) {
1994: $save_err .= $errtext;
1995: $allresult = 'failstore';
1996: }
1997: }
1998: }
1999: if ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
2000: push(@toclear,$suffix);
2001: }
2002: }
1.329 droeschl 2003: }
2004: }
1.484.2.30 raeburn 2005: &clear_from_buffer(\@toclear,\@currpaste);
2006: my $msgsarray;
2007: foreach my $suffix (keys(%msgs)) {
2008: if (ref($msgs{$suffix}) eq 'ARRAY') {
2009: $msgsarray .= join(',',@{$msgs{$suffix}});
2010: }
2011: }
2012: return ($allresult,$save_err,$msgsarray,$lockerrors);
2013: }
2014:
2015: sub do_buffer_empty {
2016: my @currpaste = split(/,/,$env{'docs.markedcopies'});
2017: if (@currpaste == 0) {
2018: return &mt('Clipboard is already empty');
2019: }
2020: my @toclear = &Apache::loncommon::get_env_multiple('form.pasting');
2021: if (@toclear == 0) {
2022: return &mt('Nothing selected to clear from clipboard');
2023: }
2024: my $numdel = &clear_from_buffer(\@toclear,\@currpaste);
2025: if ($numdel) {
2026: return &mt('[quant,_1,item] cleared from clipboard',$numdel);
2027: } else {
2028: return &mt('Clipboard unchanged');
1.484.2.7 raeburn 2029: }
1.484.2.30 raeburn 2030: return;
2031: }
2032:
2033: sub clear_from_buffer {
2034: my ($toclear,$currpaste) = @_;
2035: return unless ((ref($toclear) eq 'ARRAY') && (ref($currpaste) eq 'ARRAY'));
2036: my %pastebuffer;
2037: map { $pastebuffer{$_} = 1; } @{$currpaste};
2038: my $numdel = 0;
2039: foreach my $suffix (@{$toclear}) {
2040: next if ($suffix =~ /\D/);
2041: next unless (exists($pastebuffer{$suffix}));
2042: my $regexp = 'docs.markedcopy_[a-z]+_'.$suffix;
2043: if (&Apache::lonnet::delenv($regexp,1) eq 'ok') {
2044: delete($pastebuffer{$suffix});
2045: $numdel ++;
2046: }
2047: }
2048: my $newbuffer = join(',',sort(keys(%pastebuffer)));
2049: &Apache::lonnet::appenv({'docs.markedcopies' => $newbuffer});
2050: return $numdel;
1.484.2.7 raeburn 2051: }
2052:
2053: sub get_newmap_url {
2054: my ($url,$folder,$prefixchg,$coursedom,$coursenum,$srcdom,$srcnum,
2055: $titleref,$allmaps,$newurls) = @_;
2056: my $newurl;
2057: if ($url=~ m{^/uploaded/}) {
2058: $$titleref=&mt('Copy of').' '.$$titleref;
2059: }
2060: my $now = time;
2061: my $suffix=$$.int(rand(100)).$now;
2062: my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
2063: if ($oldid =~ m{^(/uploaded/$match_domain/$match_courseid/)(\D+)(\d+)$}) {
2064: my $path = $1;
2065: my $prefix = $2;
2066: my $ancestor = $3;
2067: if (length($ancestor) > 10) {
2068: $ancestor = substr($ancestor,-10,10);
2069: }
2070: my $newid;
2071: if ($prefixchg) {
2072: if ($folder =~ /^supplemental/) {
2073: $prefix =~ s/^default/supplemental/;
2074: } else {
2075: $prefix =~ s/^supplemental/default/;
2076: }
2077: }
2078: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
2079: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
2080: } else {
2081: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$now.'.'.$ext;
2082: }
2083: my $counter = 0;
2084: my $is_unique = &uniqueness_check($newurl);
2085: if ($folder =~ /^default/) {
2086: if ($allmaps->{$newurl}) {
2087: $is_unique = 0;
2088: }
2089: }
2090: while ((!$is_unique || $allmaps->{$newurl} || $newurls->{$newurl}) && ($counter < 100)) {
2091: $counter ++;
2092: $suffix ++;
2093: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
2094: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
2095: } else {
2096: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$ancestor.$suffix.'.'.$ext;
2097: }
2098: $is_unique = &uniqueness_check($newurl);
2099: }
2100: if ($is_unique) {
2101: $newurls->{$newurl} = 1;
2102: } else {
2103: if ($url=~/\.page$/) {
2104: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the composite page'));
2105: } else {
2106: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the folder'));
2107: }
2108: }
2109: }
2110: return ($newurl);
2111: }
2112:
2113: sub dbcopy {
1.484.2.26 raeburn 2114: my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_;
2115: my ($url,$result,$errtext);
2116: if (ref($dbref) eq 'HASH') {
1.484.2.71 raeburn 2117: $url = $dbref->{'src'};
1.484.2.72.2. (raeburn 2118:): if ($url =~ m{/(smppg|bulletinboard|ext\.tool)$}) {
1.484.2.26 raeburn 2119: my $prefix = $1;
1.484.2.72.2. (raeburn 2120:): if ($prefix eq 'ext.tool') {
2121:): $prefix = 'exttool';
2122:): }
1.484.2.26 raeburn 2123: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2124: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2125: my $db_name;
2126: my $marker = (split(m{/},$url))[4];
2127: $marker=~s/\D//g;
2128: if ($dbref->{'src'} =~ m{/smppg$}) {
2129: $db_name =
2130: &Apache::lonsimplepage::get_db_name($url,$marker,
2131: $dbref->{'cdom'},
2132: $dbref->{'cnum'});
1.484.2.72.2. (raeburn 2133:): } elsif ($dbref->{'src'} =~ m{/ext\.tool$}) {
2134:): $db_name = 'exttool_'.$marker;
1.484.2.26 raeburn 2135: } else {
2136: $db_name = 'bulletinpage_'.$marker;
2137: }
2138: my ($suffix,$freedlock,$error) =
2139: &Apache::lonnet::get_timebased_id($prefix,'num','templated',
2140: $coursedom,$coursenum,
2141: 'concat');
2142: if (!$suffix) {
2143: if ($prefix eq 'smppg') {
2144: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);
1.484.2.72.2. (raeburn 2145:): } elsif ($prefix eq 'exttool') {
2146:): $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying an external tool [_1].',$url);
1.484.2.26 raeburn 2147: } else {
1.484.2.42 raeburn 2148: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url);
1.484.2.26 raeburn 2149: }
2150: if ($error) {
2151: $errtext .= '<br />'.$error;
2152: }
2153: } else {
2154: #need to copy the db contents to a new one.
2155: my %contents=&Apache::lonnet::dump($db_name,
2156: $dbref->{'cdom'},
2157: $dbref->{'cnum'});
2158: if (exists($contents{'uploaded.photourl'})) {
2159: my $photo = $contents{'uploaded.photourl'};
2160: my ($subdir,$fname) =
2161: ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});
2162: my $newphoto;
2163: if ($fname ne '') {
2164: my $content = &Apache::lonnet::getfile($photo);
2165: unless ($content eq '-1') {
2166: $env{'form.'.$suffix.'.photourl'} = $content;
2167: $newphoto =
2168: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");
2169: delete($env{'form.'.$suffix.'.photourl'});
2170: }
2171: }
2172: if ($newphoto =~ m{^/uploaded/}) {
2173: $contents{'uploaded.photourl'} = $newphoto;
2174: }
2175: }
2176: $db_name =~ s{_\d*$ }{_$suffix}x;
2177: $result=&Apache::lonnet::put($db_name,\%contents,
2178: $coursedom,$coursenum);
2179: if ($result eq 'ok') {
1.484.2.72.2. (raeburn 2180:): $url =~ s{/(\d*)/(smppg|bulletinboard|ext\.tool)$}{/$suffix/$2}x;
1.484.2.26 raeburn 2181: }
2182: }
2183: if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) {
2184: $lockerrorsref->{$prefix} =
2185: '<div class="LC_error">'.
2186: &mt('There was a problem removing a lockfile.');
2187: if ($prefix eq 'smppg') {
2188: $lockerrorsref->{$prefix} .=
1.484.2.38 raeburn 2189: ' '.&mt('This will prevent creation of additional simple pages in this course.');
1.484.2.72.2. (raeburn 2190:): } elsif ($prefix eq 'exttool') {
2191:): $lockerrorsref->{$prefix} .=
2192:): ' '.&mt('This will prevent addition of more external tools to this course.');
1.484.2.26 raeburn 2193: } else {
1.484.2.42 raeburn 2194: $lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional discussion boards in this course.');
1.484.2.26 raeburn 2195: }
1.484.2.38 raeburn 2196: $lockerrorsref->{$prefix} .= ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
2197: '<a href="/adm/helpdesk" target="_helpdesk">','</a>').
2198: '</div>';
1.484.2.26 raeburn 2199: }
2200: }
2201: } elsif ($url =~ m{/syllabus$}) {
2202: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2203: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2204: if (($dbref->{'cdom'} ne $coursedom) ||
2205: ($dbref->{'cnum'} ne $coursenum)) {
2206: my %contents=&Apache::lonnet::dump('syllabus',
2207: $dbref->{'cdom'},
2208: $dbref->{'cnum'});
2209: $result=&Apache::lonnet::put('syllabus',\%contents,
2210: $coursedom,$coursenum);
2211: }
2212: }
1.484.2.7 raeburn 2213: }
2214: }
1.484.2.26 raeburn 2215: return ($url,$result,$errtext);
1.329 droeschl 2216: }
2217:
2218: sub uniqueness_check {
2219: my ($newurl) = @_;
2220: my $unique = 1;
2221: foreach my $res (@LONCAPA::map::order) {
2222: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2223: $url=&LONCAPA::map::qtescape($url);
2224: if ($newurl eq $url) {
2225: $unique = 0;
1.344 bisitz 2226: last;
1.329 droeschl 2227: }
2228: }
2229: return $unique;
2230: }
2231:
1.484.2.7 raeburn 2232: sub contained_map_check {
1.484.2.72.2. (raeburn 2233:): my ($url,$folder,$coursenum,$coursedom,$removefrommap,$removeparam,$addedmaps,
2234:): $hierarchy,$titles,$allmaps) = @_;
1.484.2.7 raeburn 2235: my $content = &Apache::lonnet::getfile($url);
2236: unless ($content eq '-1') {
2237: my $parser = HTML::TokeParser->new(\$content);
2238: $parser->attr_encoded(1);
2239: while (my $token = $parser->get_token) {
2240: next if ($token->[0] ne 'S');
2241: if ($token->[1] eq 'resource') {
2242: next if ($token->[2]->{'type'} eq 'zombie');
2243: my $ressrc = $token->[2]->{'src'};
2244: if ($folder =~ /^supplemental/) {
2245: unless (&supp_pasteable($ressrc)) {
2246: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2247: next;
2248: }
2249: }
2250: if ($ressrc =~ m{^/(res|uploaded)/.+\.(sequence|page)$}) {
2251: if ($1 eq 'uploaded') {
2252: $hierarchy->{$url}{$token->[2]->{'id'}} = $ressrc;
2253: $titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'};
2254: } else {
2255: if ($allmaps->{$ressrc}) {
1.484.2.23 raeburn 2256: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.484.2.7 raeburn 2257: } elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') {
2258: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2259: } else {
2260: $addedmaps->{$ressrc} = [$url];
2261: }
2262: }
1.484.2.72.2. (raeburn 2263:): &contained_map_check($ressrc,$folder,$coursenum,$coursedom,
2264:): $removefrommap,$removeparam,
1.484.2.7 raeburn 2265: $addedmaps,$hierarchy,$titles,$allmaps);
2266: }
2267: } elsif ($token->[1] eq 'param') {
2268: if ($folder =~ /^supplemental/) {
2269: if (ref($removeparam->{$url}{$token->[2]->{'to'}}) eq 'ARRAY') {
2270: push(@{$removeparam->{$url}{$token->[2]->{'to'}}},$token->[2]->{'name'});
2271: } else {
1.484.2.19 raeburn 2272: $removeparam->{$url}{$token->[2]->{'to'}} = [$token->[2]->{'name'}];
1.484.2.7 raeburn 2273: }
2274: }
2275: }
2276: }
2277: }
2278: return;
2279: }
2280:
2281: sub url_paste_fixups {
1.484.2.26 raeburn 2282: my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$fromcdom,$fromcnum,$allmaps,
2283: $rewrites,$retitles,$copies,$dbcopies,$zombies,$params,$mapmoves,
2284: $mapchanges,$tomove,$newsubdir,$newurls) = @_;
1.484.2.7 raeburn 2285: my $checktitle;
2286: if (($prefixchg) &&
2287: ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) {
2288: $checktitle = 1;
2289: }
2290: my $skip;
2291: if ($oldurl =~ m{^\Q/uploaded/$cdom/$cnum/\E(default|supplemental)(_?\d*)\.(?:page|sequence)$}) {
2292: my $mapid = $1.$2;
2293: if ($tomove->{$mapid}) {
2294: $skip = 1;
2295: }
2296: }
2297: my $file = &Apache::lonnet::getfile($oldurl);
2298: return if ($file eq '-1');
2299: my $parser = HTML::TokeParser->new(\$file);
2300: $parser->attr_encoded(1);
2301: my $changed = 0;
2302: while (my $token = $parser->get_token) {
2303: next if ($token->[0] ne 'S');
2304: if ($token->[1] eq 'resource') {
2305: my $ressrc = $token->[2]->{'src'};
2306: next if ($ressrc eq '');
2307: my $id = $token->[2]->{'id'};
2308: my $title = $token->[2]->{'title'};
2309: if ($checktitle) {
2310: if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1.484.2.25 raeburn 2311: $retitles->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2312: }
2313: }
2314: next if ($token->[2]->{'type'} eq 'external');
2315: if ($token->[2]->{'type'} eq 'zombie') {
1.484.2.30 raeburn 2316: next if ($skip);
1.484.2.25 raeburn 2317: $zombies->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2318: $changed = 1;
2319: } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
2320: my $srcdom = $1;
2321: my $srcnum = $2;
2322: my $rem = $3;
2323: my $newurl;
2324: my $mapname;
2325: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
2326: my $prefix = $1;
2327: $mapname = $prefix.$2;
2328: if ($tomove->{$mapname}) {
1.484.2.26 raeburn 2329: &url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,
2330: $srcdom,$srcnum,$allmaps,$rewrites,
2331: $retitles,$copies,$dbcopies,$zombies,
2332: $params,$mapmoves,$mapchanges,$tomove,
2333: $newsubdir,$newurls);
1.484.2.7 raeburn 2334: next;
2335: } else {
2336: ($newurl,my $error) =
2337: &get_newmap_url($ressrc,$folder,$prefixchg,$cdom,$cnum,
2338: $srcdom,$srcnum,\$title,$allmaps,$newurls);
2339: if ($newurl =~ /(?:default|supplemental)_(\d+)\.(?:sequence|page)$/) {
2340: $newsubdir->{$ressrc} = $1;
2341: }
2342: if ($error) {
2343: next;
2344: }
2345: }
2346: }
2347: if (($srcdom ne $cdom) || ($srcnum ne $cnum) || ($prefixchg) ||
2348: ($mapchanges->{$oldurl}) || (($newurl ne '') && ($newurl ne $oldurl))) {
1.484.2.19 raeburn 2349:
1.484.2.7 raeburn 2350: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
1.484.2.25 raeburn 2351: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2352: $mapchanges->{$ressrc} = 1;
1.484.2.26 raeburn 2353: unless (&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,
2354: $cnum,$srcdom,$srcnum,$allmaps,
2355: $rewrites,$retitles,$copies,$dbcopies,
2356: $zombies,$params,$mapmoves,$mapchanges,
2357: $tomove,$newsubdir,$newurls)) {
1.484.2.7 raeburn 2358: $mapmoves->{$ressrc} = 1;
2359: }
2360: $changed = 1;
2361: } else {
1.484.2.25 raeburn 2362: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 2363: $copies->{$oldurl}{$ressrc} = $id;
2364: $changed = 1;
2365: }
2366: }
1.484.2.26 raeburn 2367: } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/.+$}) {
1.484.2.30 raeburn 2368: next if ($skip);
1.484.2.7 raeburn 2369: my $srcdom = $1;
2370: my $srcnum = $2;
2371: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.484.2.25 raeburn 2372: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.26 raeburn 2373: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2374: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2375: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
2376: $changed = 1;
2377: }
2378: } elsif ($ressrc =~ m{^/adm/$match_domain/$match_username/\d+/(smppg|bulletinboard)$}) {
2379: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum) ||
2380: ($env{'form.docs.markedcopy_options'} ne 'move')) {
2381: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2382: $dbcopies->{$oldurl}{$id}{'cdom'} = $fromcdom;
2383: $dbcopies->{$oldurl}{$id}{'cnum'} = $fromcnum;
1.484.2.7 raeburn 2384: $changed = 1;
2385: }
2386: } elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) {
2387: next if ($skip);
2388: my $srcdom = $1;
2389: my $srcnum = $2;
2390: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.484.2.26 raeburn 2391: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2392: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2393: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
1.484.2.7 raeburn 2394: $changed = 1;
2395: }
2396: }
2397: } elsif ($token->[1] eq 'param') {
2398: next if ($skip);
1.484.2.19 raeburn 2399: my $to = $token->[2]->{'to'};
1.484.2.7 raeburn 2400: if ($to ne '') {
2401: if (ref($params->{$oldurl}{$to}) eq 'ARRAY') {
2402: push(@{$params->{$oldurl}{$to}},$token->[2]->{'name'});
2403: } else {
2404: @{$params->{$oldurl}{$to}} = ($token->[2]->{'name'});
2405: }
2406: }
2407: }
2408: }
2409: return $changed;
2410: }
2411:
2412: sub apply_fixups {
1.484.2.23 raeburn 2413: my ($folder,$is_map,$cdom,$cnum,$errors,$updated,$info,$moves,$prefixchg,
2414: $oldurl,$url,$caller) = @_;
2415: my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles,
1.484.2.26 raeburn 2416: %params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs,
2417: %lockerrors,$lockmsg);
1.484.2.23 raeburn 2418: if (ref($updated) eq 'HASH') {
2419: if (ref($updated->{'rewrites'}) eq 'HASH') {
2420: %rewrites = %{$updated->{'rewrites'}};
2421: }
2422: if (ref($updated->{'zombies'}) eq 'HASH') {
2423: %zombies = %{$updated->{'zombies'}};
2424: }
2425: if (ref($updated->{'removefrommap'}) eq 'HASH') {
2426: %removefrommap = %{$updated->{'removefrommap'}};
2427: }
2428: if (ref($updated->{'removeparam'}) eq 'HASH') {
2429: %removeparam = %{$updated->{'removeparam'}};
2430: }
2431: if (ref($updated->{'dbcopies'}) eq 'HASH') {
2432: %dbcopies = %{$updated->{'dbcopies'}};
2433: }
2434: if (ref($updated->{'retitles'}) eq 'HASH') {
2435: %retitles = %{$updated->{'retitles'}};
2436: }
2437: }
2438: if (ref($info) eq 'HASH') {
2439: if (ref($info->{'newsubdir'}) eq 'HASH') {
2440: %newsubdir = %{$info->{'newsubdir'}};
2441: }
2442: if (ref($info->{'params'}) eq 'HASH') {
2443: %params = %{$info->{'params'}};
2444: }
2445: if (ref($info->{'before'}) eq 'HASH') {
2446: %before = %{$info->{'before'}};
2447: }
2448: if (ref($info->{'after'}) eq 'HASH') {
2449: %after = %{$info->{'after'}};
2450: }
2451: }
2452: if (ref($moves) eq 'HASH') {
2453: if (ref($moves->{'copies'}) eq 'HASH') {
2454: %copies = %{$moves->{'copies'}};
2455: }
2456: if (ref($moves->{'docmoves'}) eq 'HASH') {
2457: %docmoves = %{$moves->{'docmoves'}};
2458: }
2459: if (ref($moves->{'mapmoves'}) eq 'HASH') {
2460: %mapmoves = %{$moves->{'mapmoves'}};
2461: }
2462: }
2463: foreach my $key (keys(%copies),keys(%docmoves)) {
1.484.2.7 raeburn 2464: my @allcopies;
1.484.2.23 raeburn 2465: if (exists($copies{$key})) {
2466: if (ref($copies{$key}) eq 'HASH') {
2467: my %added;
2468: foreach my $innerkey (keys(%{$copies{$key}})) {
2469: if (($innerkey ne '') && (!$added{$innerkey})) {
2470: push(@allcopies,$innerkey);
2471: $added{$innerkey} = 1;
2472: }
1.484.2.7 raeburn 2473: }
1.484.2.23 raeburn 2474: undef(%added);
1.484.2.7 raeburn 2475: }
2476: }
2477: if ($key eq $oldurl) {
1.484.2.23 raeburn 2478: if ((exists($docmoves{$key}))) {
1.484.2.25 raeburn 2479: unless (grep(/^\Q$oldurl\E$/,@allcopies)) {
1.484.2.7 raeburn 2480: push(@allcopies,$oldurl);
2481: }
2482: }
2483: }
2484: if (@allcopies > 0) {
2485: foreach my $item (@allcopies) {
1.484.2.19 raeburn 2486: my ($relpath,$oldsubdir,$fname) =
1.484.2.7 raeburn 2487: ($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(default|\d+)/.*/)([^/]+)$});
2488: if ($fname ne '') {
2489: my $content = &Apache::lonnet::getfile($item);
2490: unless ($content eq '-1') {
2491: my $storefn;
1.484.2.23 raeburn 2492: if (($key eq $oldurl) && (exists($docmoves{$key}))) {
2493: $storefn = $docmoves{$key};
1.484.2.7 raeburn 2494: } else {
2495: $storefn = $relpath;
2496: $storefn =~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 2497: if ($prefixchg && $before{'doc'} && $after{'doc'}) {
2498: $storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/;
1.484.2.7 raeburn 2499: }
1.484.2.23 raeburn 2500: if ($newsubdir{$key}) {
1.484.2.25 raeburn 2501: $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}/#;
1.484.2.7 raeburn 2502: }
2503: }
2504: ©_dependencies($item,$storefn,$relpath,$errors,\$content);
1.484.2.19 raeburn 2505: my $copyurl =
1.484.2.7 raeburn 2506: &Apache::lonclonecourse::writefile($env{'request.course.id'},
2507: $storefn.$fname,$content);
2508: if ($copyurl eq '/adm/notfound.html') {
1.484.2.23 raeburn 2509: if (exists($docmoves{$oldurl})) {
1.484.2.7 raeburn 2510: return &mt('Paste failed: an error occurred copying the file.');
2511: } elsif (ref($errors) eq 'HASH') {
2512: $errors->{$item} = 1;
2513: }
2514: }
2515: }
2516: }
2517: }
2518: }
2519: }
1.484.2.23 raeburn 2520: foreach my $key (keys(%mapmoves)) {
1.484.2.7 raeburn 2521: my $storefn=$key;
2522: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 2523: if ($prefixchg && $before{'map'} && $after{'map'}) {
2524: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.484.2.7 raeburn 2525: }
1.484.2.23 raeburn 2526: if ($newsubdir{$key}) {
2527: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.484.2.7 raeburn 2528: }
2529: my $mapcontent = &Apache::lonnet::getfile($key);
2530: if ($mapcontent eq '-1') {
2531: if (ref($errors) eq 'HASH') {
2532: $errors->{$key} = 1;
2533: }
2534: } else {
2535: my $newmap =
2536: &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
2537: $mapcontent);
2538: if ($newmap eq '/adm/notfound.html') {
2539: if (ref($errors) eq 'HASH') {
2540: $errors->{$key} = 1;
2541: }
2542: }
2543: }
2544: }
2545: my %updates;
2546: if ($is_map) {
1.484.2.23 raeburn 2547: if (ref($updated) eq 'HASH') {
2548: foreach my $type (keys(%{$updated})) {
2549: if (ref($updated->{$type}) eq 'HASH') {
2550: foreach my $key (keys(%{$updated->{$type}})) {
2551: $updates{$key} = 1;
2552: }
2553: }
2554: }
1.484.2.7 raeburn 2555: }
2556: foreach my $key (keys(%updates)) {
2557: my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb);
1.484.2.23 raeburn 2558: if (ref($rewrites{$key}) eq 'HASH') {
2559: %torewrite = %{$rewrites{$key}};
1.484.2.7 raeburn 2560: }
1.484.2.23 raeburn 2561: if (ref($retitles{$key}) eq 'HASH') {
2562: %toretitle = %{$retitles{$key}};
1.484.2.7 raeburn 2563: }
1.484.2.23 raeburn 2564: if (ref($removefrommap{$key}) eq 'HASH') {
2565: %toremove = %{$removefrommap{$key}};
1.484.2.7 raeburn 2566: }
1.484.2.23 raeburn 2567: if (ref($removeparam{$key}) eq 'HASH') {
2568: %remparam = %{$removeparam{$key}};
1.484.2.7 raeburn 2569: }
1.484.2.23 raeburn 2570: if (ref($zombies{$key}) eq 'HASH') {
2571: %zombie = %{$zombies{$key}};
1.484.2.7 raeburn 2572: }
1.484.2.23 raeburn 2573: if (ref($dbcopies{$key}) eq 'HASH') {
1.484.2.26 raeburn 2574: foreach my $idx (keys(%{$dbcopies{$key}})) {
2575: if (ref($dbcopies{$key}{$idx}) eq 'HASH') {
2576: my ($newurl,$result,$errtext) =
2577: &dbcopy($dbcopies{$key}{$idx},$cdom,$cnum,\%lockerrors);
2578: if ($result eq 'ok') {
2579: $newdb{$idx} = $newurl;
2580: } elsif (ref($errors) eq 'HASH') {
2581: $errors->{$key} = 1;
2582: }
2583: push(@msgs,$errtext);
2584: }
1.484.2.7 raeburn 2585: }
2586: }
1.484.2.23 raeburn 2587: if (ref($params{$key}) eq 'HASH') {
2588: %currparam = %{$params{$key}};
1.484.2.7 raeburn 2589: }
2590: my ($errtext,$fatal) = &LONCAPA::map::mapread($key);
2591: if ($fatal) {
1.484.2.26 raeburn 2592: return ($errtext);
1.484.2.7 raeburn 2593: }
2594: for (my $i=0; $i<@LONCAPA::map::zombies; $i++) {
2595: if (defined($LONCAPA::map::zombies[$i])) {
2596: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::zombies[$i]);
1.484.2.25 raeburn 2597: if ($zombie{$i} eq $src) {
1.484.2.7 raeburn 2598: undef($LONCAPA::map::zombies[$i]);
2599: }
2600: }
2601: }
1.484.2.72.2. (raeburn 2602:): my $total = scalar(@LONCAPA::map::order) - 1;
2603:): for (my $i=$total; $i>=0; $i--) {
1.484.2.23 raeburn 2604: my $idx = $LONCAPA::map::order[$i];
2605: if (defined($LONCAPA::map::resources[$idx])) {
1.484.2.7 raeburn 2606: my $changed;
1.484.2.23 raeburn 2607: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]);
1.484.2.30 raeburn 2608: if ((exists($toremove{$idx})) &&
2609: ($toremove{$idx} eq &LONCAPA::map::qtescape($src))) {
1.484.2.7 raeburn 2610: splice(@LONCAPA::map::order,$i,1);
1.484.2.23 raeburn 2611: if (ref($currparam{$idx}) eq 'ARRAY') {
2612: foreach my $name (@{$currparam{$idx}}) {
1.484.2.72.2. (raeburn 2613:): &LONCAPA::map::delparameter($idx,$name);
1.484.2.7 raeburn 2614: }
2615: }
2616: next;
2617: }
2618: my $origsrc = $src;
1.484.2.25 raeburn 2619: if ((exists($toretitle{$idx})) && ($toretitle{$idx} eq $src)) {
1.484.2.7 raeburn 2620: if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
2621: $changed = 1;
2622: }
2623: }
1.484.2.25 raeburn 2624: if ((exists($torewrite{$idx})) && ($torewrite{$idx} eq $src)) {
1.484.2.7 raeburn 2625: $src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
2626: if ($origsrc =~ m{^/uploaded/}) {
1.484.2.23 raeburn 2627: if ($prefixchg && $before{'map'} && $after{'map'}) {
1.484.2.7 raeburn 2628: if ($src =~ /\.(page|sequence)$/) {
1.484.2.23 raeburn 2629: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'map'}\E#$1$after{'map'}#;
1.484.2.7 raeburn 2630: } else {
1.484.2.23 raeburn 2631: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
1.484.2.7 raeburn 2632: }
2633: }
1.484.2.25 raeburn 2634: if ($origsrc =~ /\.(page|sequence)$/) {
2635: if ($newsubdir{$origsrc}) {
1.484.2.23 raeburn 2636: $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir{$origsrc}#;
1.484.2.7 raeburn 2637: }
1.484.2.25 raeburn 2638: } elsif ($newsubdir{$key}) {
2639: $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$key}#;
1.484.2.7 raeburn 2640: }
2641: }
2642: $changed = 1;
1.484.2.26 raeburn 2643: } elsif ($newdb{$idx} ne '') {
2644: $src = $newdb{$idx};
1.484.2.7 raeburn 2645: $changed = 1;
2646: }
2647: if ($changed) {
1.484.2.30 raeburn 2648: $LONCAPA::map::resources[$idx] = join(':',($title,&LONCAPA::map::qtunescape($src),$ext,$type));
1.484.2.7 raeburn 2649: }
2650: }
2651: }
2652: foreach my $idx (keys(%remparam)) {
2653: if (ref($remparam{$idx}) eq 'ARRAY') {
1.484.2.19 raeburn 2654: foreach my $name (@{$remparam{$idx}}) {
1.484.2.72.2. (raeburn 2655:): &LONCAPA::map::delparameter($idx,$name);
1.484.2.7 raeburn 2656: }
2657: }
2658: }
1.484.2.26 raeburn 2659: if (values(%lockerrors) > 0) {
2660: $lockmsg = join('<br />',values(%lockerrors));
2661: }
1.484.2.7 raeburn 2662: my $storefn;
2663: if ($key eq $oldurl) {
2664: $storefn = $url;
2665: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
2666: } else {
2667: $storefn = $key;
2668: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 2669: if ($prefixchg && $before{'map'} && $after{'map'}) {
2670: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.484.2.7 raeburn 2671: }
1.484.2.23 raeburn 2672: if ($newsubdir{$key}) {
2673: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.484.2.7 raeburn 2674: }
2675: }
2676: my $report;
2677: if ($folder !~ /^supplemental/) {
2678: $report = 1;
2679: }
1.484.2.20 raeburn 2680: (my $outtext,$errtext) =
1.484.2.7 raeburn 2681: &LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report);
2682: if ($errtext) {
1.484.2.23 raeburn 2683: if ($caller eq 'paste') {
1.484.2.26 raeburn 2684: return (&mt('Paste failed: an error occurred saving the folder or page.'));
1.484.2.23 raeburn 2685: }
1.484.2.7 raeburn 2686: }
2687: }
2688: }
1.484.2.26 raeburn 2689: return ('ok',\@msgs,$lockmsg);
1.484.2.7 raeburn 2690: }
2691:
2692: sub copy_dependencies {
2693: my ($item,$storefn,$relpath,$errors,$contentref) = @_;
2694: my $content;
2695: if (ref($contentref)) {
2696: $content = $$contentref;
2697: } else {
2698: $content = &Apache::lonnet::getfile($item);
2699: }
2700: unless ($content eq '-1') {
2701: my $mm = new File::MMagic;
2702: my $mimetype = $mm->checktype_contents($content);
2703: if ($mimetype eq 'text/html') {
2704: my (%allfiles,%codebase,$state);
2705: my $res = &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,\$content);
2706: if ($res eq 'ok') {
2707: my ($numexisting,$numpathchanges,$existing);
2708: (undef,$numexisting,$numpathchanges,$existing) =
2709: &Apache::loncommon::ask_for_embedded_content(
2710: '/adm/coursedocs',$state,\%allfiles,\%codebase,
2711: {'error_on_invalid_names' => 1,
2712: 'ignore_remote_references' => 1,
2713: 'docs_url' => $item,
2714: 'context' => 'paste'});
2715: if ($numexisting > 0) {
2716: if (ref($existing) eq 'HASH') {
2717: foreach my $dep (keys(%{$existing})) {
2718: my $depfile = $dep;
2719: unless ($depfile =~ m{^\Q$relpath\E}) {
2720: $depfile = $relpath.$dep;
2721: }
2722: my $depcontent = &Apache::lonnet::getfile($depfile);
2723: unless ($depcontent eq '-1') {
2724: my $storedep = $dep;
2725: $storedep =~ s{^\Q$relpath\E}{};
2726: my $dep_url =
2727: &Apache::lonclonecourse::writefile(
2728: $env{'request.course.id'},
2729: $storefn.$storedep,$depcontent);
2730: if ($dep_url eq '/adm/notfound.html') {
2731: if (ref($errors) eq 'HASH') {
2732: $errors->{$depfile} = 1;
2733: }
2734: } else {
2735: ©_dependencies($depfile,$storefn,$relpath,$errors,\$depcontent);
2736: }
2737: }
2738: }
2739: }
2740: }
2741: }
2742: }
2743: }
2744: return;
2745: }
2746:
1.329 droeschl 2747: my %parameter_type = ( 'randompick' => 'int_pos',
2748: 'hiddenresource' => 'string_yesno',
2749: 'encrypturl' => 'string_yesno',
2750: 'randomorder' => 'string_yesno',);
2751: my $valid_parameters_re = join('|',keys(%parameter_type));
2752: # set parameters
2753: sub update_parameter {
1.484.2.29 raeburn 2754: if ($env{'form.changeparms'} eq 'all') {
2755: my (@allidx,@allmapidx,%allchecked,%currchecked);
2756: %allchecked = (
2757: 'hiddenresource' => {},
2758: 'encrypturl' => {},
2759: 'randompick' => {},
2760: 'randomorder' => {},
2761: );
2762: foreach my $which (keys(%allchecked)) {
2763: $env{'form.all'.$which} =~ s/,$//;
2764: if ($which eq 'randompick') {
2765: foreach my $item (split(/,/,$env{'form.all'.$which})) {
2766: my ($res,$value) = split(/:/,$item);
2767: if ($value =~ /^\d+$/) {
2768: $allchecked{$which}{$res} = $value;
2769: }
2770: }
2771: } else {
1.484.2.30 raeburn 2772: if ($env{'form.all'.$which}) {
2773: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.all'.$which});
2774: }
1.484.2.29 raeburn 2775: }
2776: }
2777: my $haschanges = 0;
2778: foreach my $res (@LONCAPA::map::order) {
2779: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2780: $name=&LONCAPA::map::qtescape($name);
2781: $url=&LONCAPA::map::qtescape($url);
2782: next unless ($name && $url);
2783: my $is_map;
2784: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
2785: $is_map = 1;
2786: }
2787: foreach my $which (keys(%allchecked)) {
2788: if (($which eq 'randompick' || $which eq 'randomorder')) {
2789: next if (!$is_map);
2790: }
2791: my $oldvalue = 0;
2792: my $newvalue = 0;
2793: if ($allchecked{$which}{$res}) {
2794: $newvalue = $allchecked{$which}{$res};
2795: }
2796: my $current = (&LONCAPA::map::getparameter($res,'parameter_'.$which))[0];
2797: if ($which eq 'randompick') {
2798: if ($current =~ /^(\d+)$/) {
2799: $oldvalue = $1;
2800: }
2801: } else {
2802: if ($current =~ /^yes$/i) {
2803: $oldvalue = 1;
2804: }
2805: }
2806: if ($oldvalue ne $newvalue) {
2807: $haschanges = 1;
2808: if ($newvalue) {
2809: my $storeval = 'yes';
2810: if ($which eq 'randompick') {
2811: $storeval = $newvalue;
2812: }
2813: &LONCAPA::map::storeparameter($res,'parameter_'.$which,
2814: $storeval,
2815: $parameter_type{$which});
2816: &remember_parms($res,$which,'set',$storeval);
2817: } elsif ($oldvalue) {
2818: &LONCAPA::map::delparameter($res,'parameter_'.$which);
2819: &remember_parms($res,$which,'del');
2820: }
2821: }
2822: }
2823: }
2824: return $haschanges;
1.329 droeschl 2825: } else {
1.484.2.59 raeburn 2826: my $haschanges = 0;
2827: return $haschanges if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
1.364 bisitz 2828:
1.484.2.29 raeburn 2829: my $which = $env{'form.changeparms'};
2830: my $idx = $env{'form.setparms'};
1.484.2.59 raeburn 2831: my $oldvalue = 0;
2832: my $newvalue = 0;
2833: my $current = (&LONCAPA::map::getparameter($idx,'parameter_'.$which))[0];
2834: if ($which eq 'randompick') {
2835: if ($current =~ /^(\d+)$/) {
2836: $oldvalue = $1;
2837: }
2838: } elsif ($current =~ /^yes$/i) {
2839: $oldvalue = 1;
2840: }
1.484.2.29 raeburn 2841: if ($env{'form.'.$which.'_'.$idx}) {
1.484.2.59 raeburn 2842: $newvalue = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx}
2843: : 1;
1.484.2.29 raeburn 2844: }
1.484.2.59 raeburn 2845: if ($oldvalue ne $newvalue) {
2846: $haschanges = 1;
2847: if ($newvalue) {
2848: my $storeval = 'yes';
2849: if ($which eq 'randompick') {
2850: $storeval = $newvalue;
2851: }
2852: &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $storeval,
2853: $parameter_type{$which});
2854: &remember_parms($idx,$which,'set',$storeval);
2855: } else {
2856: &LONCAPA::map::delparameter($idx,'parameter_'.$which);
2857: &remember_parms($idx,$which,'del');
2858: }
2859: }
2860: return $haschanges;
1.329 droeschl 2861: }
1.484.2.59 raeburn 2862: return;
1.329 droeschl 2863: }
2864:
2865: sub handle_edit_cmd {
2866: my ($coursenum,$coursedom) =@_;
1.484.2.30 raeburn 2867: if ($env{'form.cmd'} eq '') {
2868: return 0;
2869: }
1.329 droeschl 2870: my ($cmd,$idx)=split('_',$env{'form.cmd'});
2871:
2872: my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
2873: my ($title, $url, @rrest) = split(':', $ratstr);
2874:
1.484.2.30 raeburn 2875: if ($cmd eq 'remove') {
1.329 droeschl 2876: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
1.463 www 2877: ($url!~/$LONCAPA::assess_page_seq_re/)) {
1.329 droeschl 2878: &Apache::lonnet::removeuploadedurl($url);
2879: } else {
2880: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
2881: }
2882: splice(@LONCAPA::map::order, $idx, 1);
2883:
2884: } elsif ($cmd eq 'cut') {
2885: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
2886: splice(@LONCAPA::map::order, $idx, 1);
2887:
1.344 bisitz 2888: } elsif ($cmd eq 'up'
1.329 droeschl 2889: && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
2890: @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
2891:
2892: } elsif ($cmd eq 'down'
2893: && defined($LONCAPA::map::order[$idx+1])) {
2894: @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
2895:
2896: } elsif ($cmd eq 'rename') {
2897: my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
2898: if ($comment=~/\S/) {
2899: $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
2900: $comment.':'.join(':', $url, @rrest);
2901: }
2902: # Devalidate title cache
2903: my $renamed_url=&LONCAPA::map::qtescape($url);
2904: &Apache::lonnet::devalidate_title_cache($renamed_url);
1.484.2.30 raeburn 2905:
1.329 droeschl 2906: } else {
2907: return 0;
2908: }
2909: return 1;
2910: }
2911:
2912: sub editor {
1.458 raeburn 2913: my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
1.484.2.72.2. (raeburn 2914:): $supplementalflag,$orderhash,$iconpath,$pathitem,$ltitoolsref,
2915:): $canedit,$navmapref,$hiddentop)=@_;
1.484.2.19 raeburn 2916: my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
2917: if ($allowed) {
2918: (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
2919: $is_random_order,$container) =
2920: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
2921: $r->print($breadcrumbtrail);
2922: } elsif ($env{'form.folderpath'} =~ /\:1$/) {
2923: $container = 'page';
2924: } else {
2925: $container = 'sequence';
2926: }
1.484 raeburn 2927:
1.484.2.21 raeburn 2928: my $jumpto;
2929:
2930: unless ($supplementalflag) {
1.484.2.32 raeburn 2931: $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
1.484.2.21 raeburn 2932: }
1.484 raeburn 2933:
2934: unless ($allowed) {
2935: $randompick = -1;
2936: }
2937:
1.484.2.67 raeburn 2938: my ($errtext,$fatal);
2939: if (($folder eq '') && (!$supplementalflag)) {
2940: if (@LONCAPA::map::order) {
2941: undef(@LONCAPA::map::order);
2942: undef(@LONCAPA::map::resources);
2943: undef(@LONCAPA::map::resparms);
2944: undef(@LONCAPA::map::zombies);
2945: }
2946: $folder = 'default';
2947: $container = 'sequence';
2948: } else {
2949: ($errtext,$fatal) = &mapread($coursenum,$coursedom,
2950: $folder.'.'.$container);
2951: return $errtext if ($fatal);
2952: }
1.329 droeschl 2953:
2954: if ($#LONCAPA::map::order<1) {
2955: my $idx=&LONCAPA::map::getresidx();
2956: if ($idx<=0) { $idx=1; }
2957: $LONCAPA::map::order[0]=$idx;
2958: $LONCAPA::map::resources[$idx]='';
2959: }
1.364 bisitz 2960:
1.329 droeschl 2961: # ------------------------------------------------------------ Process commands
2962:
2963: # ---------------- if they are for this folder and user allowed to make changes
1.484.2.67 raeburn 2964: if (($allowed && $canedit) && ($env{'form.folder'} eq $folder)) {
1.329 droeschl 2965: # set parameters and change order
2966: &snapshotbefore();
2967:
2968: if (&update_parameter()) {
1.484.2.59 raeburn 2969: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1.329 droeschl 2970: return $errtext if ($fatal);
2971: }
2972:
2973: if ($env{'form.newpos'} && $env{'form.currentpos'}) {
2974: # change order
2975: my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
2976: splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
2977:
2978: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
2979: return $errtext if ($fatal);
2980: }
1.364 bisitz 2981:
1.329 droeschl 2982: if ($env{'form.pastemarked'}) {
1.484.2.7 raeburn 2983: my %paste_errors;
1.484.2.26 raeburn 2984: my ($paste_res,$save_error,$pastemsgarray,$lockerror) =
1.484.2.7 raeburn 2985: &do_paste_from_buffer($coursenum,$coursedom,$folder,$container,
2986: \%paste_errors);
1.484.2.30 raeburn 2987: if (ref($pastemsgarray) eq 'ARRAY') {
2988: if (@{$pastemsgarray} > 0) {
2989: $r->print('<p class="LC_info">'.
2990: join('<br />',@{$pastemsgarray}).
1.484.2.26 raeburn 2991: '</p>');
2992: }
1.484.2.30 raeburn 2993: }
2994: if ($lockerror) {
2995: $r->print('<p class="LC_error">'.
2996: $lockerror.
2997: '</p>');
2998: }
2999: if ($save_error ne '') {
3000: return $save_error;
3001: }
3002: if ($paste_res) {
3003: my %errortext = &Apache::lonlocal::texthash (
3004: fail => 'Storage of folder contents failed',
3005: failread => 'Reading folder contents failed',
3006: failstore => 'Storage of folder contents failed',
3007: );
3008: if ($errortext{$paste_res}) {
3009: $r->print('<p class="LC_error">'.$errortext{$paste_res}.'</p>');
1.484.2.7 raeburn 3010: }
1.329 droeschl 3011: }
1.484.2.7 raeburn 3012: if (keys(%paste_errors) > 0) {
1.484.2.30 raeburn 3013: $r->print('<p class="LC_warning">'."\n".
1.484.2.7 raeburn 3014: &mt('The following files are either dependencies of a web page or references within a folder and/or composite page which could not be copied during the paste operation:')."\n".
3015: '<ul>'."\n");
3016: foreach my $key (sort(keys(%paste_errors))) {
3017: $r->print('<li>'.$key.'</li>'."\n");
3018: }
3019: $r->print('</ul></p>'."\n");
3020: }
1.484.2.30 raeburn 3021: } elsif ($env{'form.clearmarked'}) {
3022: my $output = &do_buffer_empty();
3023: if ($output) {
3024: $r->print('<p class="LC_info">'.$output.'</p>');
3025: }
3026: }
1.329 droeschl 3027:
3028: $r->print($upload_output);
3029:
1.484.2.30 raeburn 3030: # Rename, cut, copy or remove a single resource
1.484.2.63 raeburn 3031: if (&handle_edit_cmd($coursenum,$coursedom)) {
1.484.2.7 raeburn 3032: my $contentchg;
1.484.2.58 raeburn 3033: if ($env{'form.cmd'} =~ m{^(remove|cut)_}) {
1.484.2.7 raeburn 3034: $contentchg = 1;
3035: }
3036: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);
1.329 droeschl 3037: return $errtext if ($fatal);
3038: }
1.484.2.30 raeburn 3039:
3040: # Cut, copy and/or remove multiple resources
3041: if ($env{'form.multichange'}) {
3042: my %allchecked = (
3043: cut => {},
3044: remove => {},
3045: );
3046: my $needsupdate;
3047: foreach my $which (keys(%allchecked)) {
3048: $env{'form.multi'.$which} =~ s/,$//;
3049: if ($env{'form.multi'.$which}) {
3050: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.multi'.$which});
3051: if (ref($allchecked{$which}) eq 'HASH') {
3052: $needsupdate += scalar(keys(%{$allchecked{$which}}));
3053: }
3054: }
3055: }
3056: if ($needsupdate) {
3057: my $haschanges = 0;
3058: my %curr_groups = &Apache::longroup::coursegroups();
3059: my $total = scalar(@LONCAPA::map::order) - 1;
3060: for (my $i=$total; $i>=0; $i--) {
3061: my $res = $LONCAPA::map::order[$i];
3062: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3063: $name=&LONCAPA::map::qtescape($name);
3064: $url=&LONCAPA::map::qtescape($url);
1.484.2.57 raeburn 3065: next unless $url;
1.484.2.30 raeburn 3066: my %denied =
3067: &action_restrictions($coursenum,$coursedom,$url,
3068: $env{'form.folderpath'},\%curr_groups);
3069: foreach my $which (keys(%allchecked)) {
3070: next if ($denied{$which});
3071: next unless ($allchecked{$which}{$res});
3072: if ($which eq 'remove') {
3073: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
3074: ($url!~/$LONCAPA::assess_page_seq_re/)) {
3075: &Apache::lonnet::removeuploadedurl($url);
3076: } else {
3077: &LONCAPA::map::makezombie($res);
3078: }
3079: splice(@LONCAPA::map::order,$i,1);
3080: $haschanges ++;
3081: } elsif ($which eq 'cut') {
3082: &LONCAPA::map::makezombie($res);
3083: splice(@LONCAPA::map::order,$i,1);
3084: $haschanges ++;
3085: }
3086: }
3087: }
3088: if ($haschanges) {
3089: ($errtext,$fatal) =
3090: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
3091: return $errtext if ($fatal);
3092: }
3093: }
3094: }
3095:
1.329 droeschl 3096: # Group import/search
3097: if ($env{'form.importdetail'}) {
3098: my @imports;
3099: foreach my $item (split(/\&/,$env{'form.importdetail'})) {
3100: if (defined($item)) {
3101: my ($name,$url,$residx)=
1.484.2.26 raeburn 3102: map { &unescape($_); } split(/\=/,$item);
3103: if ($url =~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
1.484.2.30 raeburn 3104: my ($suffix,$errortxt,$locknotfreed) =
1.484.2.26 raeburn 3105: &new_timebased_suffix($coursedom,$coursenum,'map',$1,$2);
1.484.2.15 raeburn 3106: if ($locknotfreed) {
3107: $r->print($locknotfreed);
3108: }
3109: if ($suffix) {
1.484.2.19 raeburn 3110: $url =~ s/_new\./_$suffix./;
1.484.2.15 raeburn 3111: } else {
3112: return $errortxt;
3113: }
1.484.2.26 raeburn 3114: } elsif ($url =~ m{^/adm/$match_domain/$match_username/new/(smppg|bulletinboard)$}) {
3115: my $type = $1;
3116: my ($suffix,$errortxt,$locknotfreed) =
3117: &new_timebased_suffix($coursedom,$coursenum,$type);
3118: if ($locknotfreed) {
3119: $r->print($locknotfreed);
3120: }
3121: if ($suffix) {
3122: $url =~ s{^(/adm/$match_domain/$match_username)/new}{$1/$suffix};
3123: } else {
3124: return $errortxt;
3125: }
1.484.2.72.2. (raeburn 3126:): } elsif ($url =~ m{^/adm/$coursedom/$coursenum/new/ext\.tool}) {
3127:): my ($suffix,$errortxt,$locknotfreed) =
3128:): &new_timebased_suffix($coursedom,$coursenum,'exttool');
3129:): if ($locknotfreed) {
3130:): $r->print($locknotfreed);
3131:): }
3132:): if ($suffix) {
3133:): $url =~ s{^(/adm/$coursedom/$coursenum)/new}{$1/$suffix};
3134:): } else {
3135:): return $errortxt;
3136:): }
1.484.2.27 raeburn 3137: } elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) {
3138: if ($supplementalflag) {
3139: next unless ($1 eq 'supplemental');
3140: if ($folder eq 'supplemental') {
3141: next unless ($2 eq 'default');
3142: } else {
3143: next unless ($folder eq 'supplemental_'.$2);
3144: }
3145: } else {
3146: next unless ($1 eq 'docs');
3147: if ($folder eq 'default') {
3148: next unless ($2 eq 'default');
3149: } else {
3150: next unless ($folder eq 'default_'.$2);
3151: }
3152: }
1.484.2.15 raeburn 3153: }
1.329 droeschl 3154: push(@imports, [$name, $url, $residx]);
3155: }
3156: }
1.484.2.23 raeburn 3157: ($errtext,$fatal,my $fixuperrors) =
3158: &group_import($coursenum, $coursedom, $folder,$container,
1.484.2.72.2. (raeburn 3159:): 'londocs',$ltitoolsref,@imports);
1.329 droeschl 3160: return $errtext if ($fatal);
1.484.2.23 raeburn 3161: if ($fixuperrors) {
3162: $r->print($fixuperrors);
3163: }
1.329 droeschl 3164: }
3165: # Loading a complete map
3166: if ($env{'form.loadmap'}) {
3167: if ($env{'form.importmap'}=~/\w/) {
3168: foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
3169: my ($title,$url,$ext,$type)=split(/\:/,$res);
3170: my $idx=&LONCAPA::map::getresidx($url);
3171: $LONCAPA::map::resources[$idx]=$res;
3172: $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
3173: }
3174: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.484.2.7 raeburn 3175: $folder.'.'.$container,1);
1.329 droeschl 3176: return $errtext if ($fatal);
3177: } else {
3178: $r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
1.364 bisitz 3179:
1.329 droeschl 3180: }
3181: }
3182: &log_differences($plain);
3183: }
3184: # ---------------------------------------------------------------- End commands
3185: # ---------------------------------------------------------------- Print screen
3186: my $idx=0;
3187: my $shown=0;
3188: if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
1.381 bisitz 3189: $r->print('<div class="LC_Box">'.
1.432 raeburn 3190: '<ol class="LC_docs_parameters"><li class="LC_docs_parameters_title">'.&mt('Parameters:').'</li>'.
3191: ($randompick>=0?'<li>'.&mt('randomly pick [quant,_1,resource]',$randompick).'</li>':'').
3192: ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
3193: ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
3194: ($is_random_order?'<li>'.&mt('random order').'</li>':'').
1.431 raeburn 3195: '</ol>');
1.381 bisitz 3196: if ($randompick>=0) {
3197: $r->print('<p class="LC_warning">'
3198: .&mt('Caution: this folder is set to randomly pick a subset'
3199: .' of resources. Adding or removing resources from this'
3200: .' folder will change the set of resources that the'
3201: .' students see, resulting in spurious or missing credit'
3202: .' for completed problems, not limited to ones you'
3203: .' modify. Do not modify the contents of this folder if'
3204: .' it is in active student use.')
3205: .'</p>'
3206: );
3207: }
3208: if ($is_random_order) {
3209: $r->print('<p class="LC_warning">'
3210: .&mt('Caution: this folder is set to randomly order its'
3211: .' contents. Adding or removing resources from this folder'
3212: .' will change the order of resources shown.')
3213: .'</p>'
3214: );
3215: }
3216: $r->print('</div>');
1.364 bisitz 3217: }
1.381 bisitz 3218:
1.484.2.30 raeburn 3219: my ($to_show,$output,@allidx,@allmapidx,%filters,%lists,%curr_groups);
3220: %filters = (
3221: canremove => [],
3222: cancut => [],
3223: cancopy => [],
3224: hiddenresource => [],
3225: encrypturl => [],
3226: randomorder => [],
3227: randompick => [],
3228: );
3229: %curr_groups = &Apache::longroup::coursegroups();
1.424 onken 3230: &Apache::loncommon::start_data_table_count(); #setup a row counter
1.381 bisitz 3231: foreach my $res (@LONCAPA::map::order) {
3232: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3233: $name=&LONCAPA::map::qtescape($name);
3234: $url=&LONCAPA::map::qtescape($url);
3235: unless ($name) { $name=(split(/\//,$url))[-1]; }
3236: unless ($name) { $idx++; next; }
1.484.2.29 raeburn 3237: push(@allidx,$res);
3238: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
3239: push(@allmapidx,$res);
3240: }
1.484.2.67 raeburn 3241:
1.381 bisitz 3242: $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
1.484.2.12 raeburn 3243: $coursenum,$coursedom,$crstype,
1.484.2.30 raeburn 3244: $pathitem,$supplementalflag,$container,
1.484.2.72.2. (raeburn 3245:): \%filters,\%curr_groups,$ltitoolsref,$canedit,
1.484.2.70 raeburn 3246: $isencrypted,$navmapref);
1.381 bisitz 3247: $idx++;
3248: $shown++;
1.329 droeschl 3249: }
1.424 onken 3250: &Apache::loncommon::end_data_table_count();
1.484.2.19 raeburn 3251:
1.484.2.30 raeburn 3252: my $need_save;
1.484.2.67 raeburn 3253: if ($allowed || ($supplementalflag && $folder eq 'supplemental')) {
1.484.2.31 raeburn 3254: my $toolslink;
1.484.2.67 raeburn 3255: if ($allowed) {
1.484.2.31 raeburn 3256: $toolslink = '<table><tr><td>'
1.484.2.19 raeburn 3257: .&Apache::loncommon::help_open_menu('Navigation Screen',
3258: 'Navigation_Screen',undef,'RAT')
3259: .'</td><td class="LC_middle">'.&mt('Tools:').'</td>'
3260: .'<td align="left"><ul id="LC_toolbar">'
1.484.2.21 raeburn 3261: .'<li><a href="/adm/coursedocs?forcesupplement=1&command=editsupp" '
1.484.2.19 raeburn 3262: .'id="LC_content_toolbar_edittoplevel" '
3263: .'class="LC_toolbarItem" '
3264: .'title="'.&mt('Supplemental Content Editor').'">'
3265: .'</a></li></ul></td></tr></table><br />';
1.484.2.31 raeburn 3266: }
1.484.2.19 raeburn 3267: if ($shown) {
3268: if ($allowed) {
3269: $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
3270: .&Apache::loncommon::start_data_table(undef,'contentlist')
3271: .&Apache::loncommon::start_data_table_header_row()
3272: .'<th colspan="2">'.&mt('Move').'</th>'
1.484.2.30 raeburn 3273: .'<th colspan="2">'.&mt('Actions').'</th>'
3274: .'<th>'.&mt('Document').'</th>';
1.484.2.19 raeburn 3275: if ($folder !~ /^supplemental/) {
3276: $to_show .= '<th colspan="4">'.&mt('Settings').'</th>';
3277: }
1.484.2.29 raeburn 3278: $to_show .= &Apache::loncommon::end_data_table_header_row();
3279: if ($folder !~ /^supplemental/) {
1.484.2.30 raeburn 3280: $lists{'canhide'} = join(',',@allidx);
3281: $lists{'canrandomlyorder'} = join(',',@allmapidx);
3282: my @possfilters = ('canremove','cancut','cancopy','hiddenresource','encrypturl',
3283: 'randomorder','randompick');
3284: foreach my $item (@possfilters) {
3285: if (ref($filters{$item}) eq 'ARRAY') {
3286: if (@{$filters{$item}} > 0) {
3287: $lists{$item} = join(',',@{$filters{$item}});
3288: }
3289: }
3290: }
1.484.2.29 raeburn 3291: if (@allidx > 0) {
3292: my $path;
3293: if ($env{'form.folderpath'}) {
3294: $path =
3295: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3296: }
1.484.2.30 raeburn 3297: if (@allidx > 1) {
3298: $to_show .=
3299: &Apache::loncommon::continue_data_table_row().
3300: '<td colspan="2"> </td>'.
3301: '<td>'.
1.484.2.67 raeburn 3302: &multiple_check_form('actions',\%lists,$canedit).
1.484.2.30 raeburn 3303: '</td>'.
3304: '<td> </td>'.
3305: '<td> </td>'.
3306: '<td colspan="4">'.
1.484.2.67 raeburn 3307: &multiple_check_form('settings',\%lists,$canedit).
1.484.2.30 raeburn 3308: '</td>'.
3309: &Apache::loncommon::end_data_table_row();
3310: $need_save = 1;
3311: }
1.484.2.29 raeburn 3312: }
3313: }
3314: $to_show .= $output.' '
1.484.2.19 raeburn 3315: .&Apache::loncommon::end_data_table()
3316: .'<br style="line-height:2px;" />'
3317: .&Apache::loncommon::end_scrollbox();
3318: } else {
3319: $to_show .= $toolslink
3320: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3321: .$output.' '
3322: .&Apache::loncommon::end_data_table();
3323: }
3324: } else {
3325: if (!$allowed) {
3326: $to_show .= $toolslink;
1.393 raeburn 3327: }
1.484.2.67 raeburn 3328: my $noresmsg;
3329: if ($allowed && $hiddentop && !$supplementalflag) {
3330: $noresmsg = &mt('Main Content Hidden');
3331: } else {
3332: $noresmsg = &mt('Currently empty');
3333: }
1.484.2.19 raeburn 3334: $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
3335: .'<div class="LC_info" id="contentlist">'
1.484.2.67 raeburn 3336: .$noresmsg
1.484.2.19 raeburn 3337: .'</div>'
3338: .&Apache::loncommon::end_scrollbox();
1.393 raeburn 3339: }
3340: } else {
1.484.2.19 raeburn 3341: if ($shown) {
3342: $to_show = '<div>'
3343: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3344: .$output
3345: .&Apache::loncommon::end_data_table()
3346: .'</div>';
3347: } else {
3348: $to_show = '<div class="LC_info" id="contentlist">'
1.484.2.34 raeburn 3349: .&mt('Currently empty')
1.484.2.19 raeburn 3350: .'</div>'
3351: }
1.458 raeburn 3352: }
3353: my $tid = 1;
3354: if ($supplementalflag) {
3355: $tid = 2;
1.329 droeschl 3356: }
3357: if ($allowed) {
1.484 raeburn 3358: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
1.484.2.30 raeburn 3359: $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,
1.484.2.67 raeburn 3360: $jumpto,$readfile,$need_save,"$folder.$container",$canedit));
1.484.2.68 raeburn 3361: if ($canedit) {
1.484.2.67 raeburn 3362: &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
3363: }
1.460 raeburn 3364: } else {
3365: $r->print($to_show);
1.329 droeschl 3366: }
3367: return;
3368: }
3369:
1.484.2.30 raeburn 3370: sub multiple_check_form {
1.484.2.67 raeburn 3371: my ($caller,$listsref,$canedit) = @_;
1.484.2.30 raeburn 3372: return unless (ref($listsref) eq 'HASH');
1.484.2.67 raeburn 3373: my $disabled;
3374: unless ($canedit) {
3375: $disabled = 'disabled="disabled"';
3376: }
1.484.2.30 raeburn 3377: my $output =
3378: '<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'.
3379: '<span class="LC_nobreak" style="font-size:x-small;font-weight:bold;">'.
3380: '<label><input type="radio" name="showmultpick" value="0" onclick="javascript:togglePick('."'$caller','0'".');" checked="checked" />'.&mt('one').'</label>'.(' 'x2).'<label><input type="radio" name="showmultpick" value="1" onclick="javascript:togglePick('."'$caller','1'".');" />'.&mt('multiple').'</label></span><span id="more'.$caller.'" class="LC_nobreak LC_docs_ext_edit"></span></form>'.
3381: '<div id="multi'.$caller.'" style="display:none;margin:0;padding:0;border:0">'.
3382: '<form action="/adm/coursedocs" method="post" name="cumulative'.$caller.'">'."\n".
3383: '<fieldset id="allfields'.$caller.'" style="display:none"><legend style="font-size:x-small;">'.&mt('check/uncheck all').'</legend>'."\n";
3384: if ($caller eq 'settings') {
3385: $output .=
3386: '<table><tr>'.
3387: '<td class="LC_docs_entry_parameter">'.
3388: '<span class="LC_nobreak"><label>'.
1.484.2.67 raeburn 3389: '<input type="checkbox" name="hiddenresourceall" id="hiddenresourceall" onclick="propagateState(this.form,'."'hiddenresource'".')"'.$disabled.' />'.&mt('Hidden').
1.484.2.30 raeburn 3390: '</label></span></td>'.
3391: '<td class="LC_docs_entry_parameter">'.
1.484.2.67 raeburn 3392: '<span class="LC_nobreak"><label><input type="checkbox" name="randompickall" id="randompickall" onclick="updatePick(this.form,'."'all','check'".');propagateState(this.form,'."'randompick'".');propagateState(this.form,'."'rpicknum'".');"'.$disabled.' />'.&mt('Randomly Pick').'</label><span id="rpicktextall"></span><input type="hidden" name="rpicknumall" id="rpicknumall" value="" />'.
1.484.2.30 raeburn 3393: '</span></td>'.
3394: '</tr>'."\n".
3395: '<tr>'.
3396: '<td class="LC_docs_entry_parameter">'.
1.484.2.67 raeburn 3397: '<span class="LC_nobreak"><label><input type="checkbox" name="encrypturlall" id="encrypturlall" onclick="propagateState(this.form,'."'encrypturl'".')"'.$disabled.' />'.&mt('URL hidden').'</label></span></td><td class="LC_docs_entry_parameter"><span class="LC_nobreak"><label><input type="checkbox" name="randomorderall" id="randomorderall" onclick="propagateState(this.form,'."'randomorder'".')"'.$disabled.' />'.&mt('Random Order').
1.484.2.30 raeburn 3398: '</label></span>'.
3399: '</td></tr></table>'."\n";
3400: } else {
3401: $output .=
3402: '<table><tr>'.
3403: '<td class="LC_docs_entry_parameter">'.
3404: '<span class="LC_nobreak LC_docs_remove">'.
1.484.2.67 raeburn 3405: '<label><input type="checkbox" name="removeall" id="removeall" onclick="propagateState(this.form,'."'remove'".')"'.$disabled.' />'.&mt('Remove').
1.484.2.30 raeburn 3406: '</label></span></td>'.
3407: '<td class="LC_docs_entry_parameter">'.
3408: '<span class="LC_nobreak LC_docs_cut">'.
1.484.2.67 raeburn 3409: '<label><input type="checkbox" name="cut" id="cutall" onclick="propagateState(this.form,'."'cut'".');"'.$disabled.' />'.&mt('Cut').
1.484.2.30 raeburn 3410: '</label></span></td>'."\n".
3411: '<td class="LC_docs_entry_parameter">'.
3412: '<span class="LC_nobreak LC_docs_copy">'.
1.484.2.67 raeburn 3413: '<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')"'.$disabled.' />'.&mt('Copy').
1.484.2.30 raeburn 3414: '</label></span></td>'.
3415: '</tr></table>'."\n";
3416: }
3417: $output .=
3418: '</fieldset>'.
3419: '<input type="hidden" name="allidx" value="'.$listsref->{'canhide'}.'" />';
3420: if ($caller eq 'settings') {
3421: $output .=
3422: '<input type="hidden" name="allmapidx" value="'.$listsref->{'canrandomlyorder'}.'" />'."\n".
3423: '<input type="hidden" name="currhiddenresource" value="'.$listsref->{'hiddenresource'}.'" />'."\n".
3424: '<input type="hidden" name="currencrypturl" value="'.$listsref->{'encrypturl'}.'" />'."\n".
3425: '<input type="hidden" name="currrandomorder" value="'.$listsref->{'randomorder'}.'" />'."\n".
3426: '<input type="hidden" name="currrandompick" value="'.$listsref->{'randompick'}.'" />'."\n";
3427: } elsif ($caller eq 'actions') {
3428: $output .=
3429: '<input type="hidden" name="allremoveidx" id="allremoveidx" value="'.$listsref->{'canremove'}.'" />'.
3430: '<input type="hidden" name="allcutidx" id="allcutidx" value="'.$listsref->{'cancut'}.'" />'.
3431: '<input type="hidden" name="allcopyidx" id="allcopyidx" value="'.$listsref->{'cancopy'}.'" />';
3432: }
3433: $output .=
3434: '</form>'.
3435: '</div>';
3436: return $output;
3437: }
3438:
1.329 droeschl 3439: sub process_file_upload {
1.484.2.36 raeburn 3440: my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd,$crstype) = @_;
1.329 droeschl 3441: # upload a file, if present
1.484.2.36 raeburn 3442: my $filesize = length($env{'form.uploaddoc'});
3443: if (!$filesize) {
3444: $$upload_output = '<div class="LC_error">'.
3445: &mt('Unable to upload [_1]. (size = [_2] bytes)',
3446: '<span class="LC_filename">'.$env{'form.uploaddoc.filename'}.'</span>',
3447: $filesize).'<br />'.
3448: &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'<br />'.
3449: '</div>';
3450: return;
3451: }
3452: my $quotatype = 'unofficial';
3453: if ($crstype eq 'Community') {
3454: $quotatype = 'community';
1.484.2.51 raeburn 3455: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
1.484.2.36 raeburn 3456: $quotatype = 'official';
1.484.2.45 raeburn 3457: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
3458: $quotatype = 'textbook';
1.484.2.36 raeburn 3459: }
3460: if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) {
3461: $filesize = int($filesize/1000); #expressed in kb
3462: $$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course',
1.484.2.51 raeburn 3463: $env{'form.uploaddoc.filename'},$filesize,
3464: 'upload',$quotatype);
1.484.2.36 raeburn 3465: return if ($$upload_output);
3466: }
1.440 raeburn 3467: my ($parseaction,$showupload,$nextphase,$mimetype);
3468: if ($env{'form.parserflag'}) {
1.329 droeschl 3469: $parseaction = 'parse';
3470: }
3471: my $folder=$env{'form.folder'};
3472: if ($folder eq '') {
3473: $folder='default';
3474: }
3475: if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
3476: my $errtext='';
3477: my $fatal=0;
3478: my $container='sequence';
1.484.2.19 raeburn 3479: if ($env{'form.folderpath'} =~ /:1$/) {
1.329 droeschl 3480: $container='page';
3481: }
3482: ($errtext,$fatal)=
1.484.2.27 raeburn 3483: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1.329 droeschl 3484: if ($#LONCAPA::map::order<1) {
3485: $LONCAPA::map::order[0]=1;
3486: $LONCAPA::map::resources[1]='';
3487: }
3488: my $destination = 'docs/';
3489: if ($folder =~ /^supplemental/) {
3490: $destination = 'supplemental/';
3491: }
3492: if (($folder eq 'default') || ($folder eq 'supplemental')) {
3493: $destination .= 'default/';
3494: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
3495: $destination .= $2.'/';
3496: }
1.484.2.27 raeburn 3497: if ($fatal) {
3498: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'</div>';
3499: return;
3500: }
1.440 raeburn 3501: # this is for a course, not a user, so set context to coursedoc.
1.329 droeschl 3502: my $newidx=&LONCAPA::map::getresidx();
3503: $destination .= $newidx;
1.439 raeburn 3504: my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination,
1.329 droeschl 3505: $parseaction,$allfiles,
1.440 raeburn 3506: $codebase,undef,undef,undef,undef,
3507: undef,undef,\$mimetype);
3508: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) {
3509: my $stored = $1;
3510: $showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'.
3511: $stored.'</span>').'</p>';
3512: } else {
3513: my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});
3514:
1.457 raeburn 3515: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>';
1.440 raeburn 3516: return;
3517: }
1.329 droeschl 3518: my $ext='false';
3519: if ($url=~m{^http://}) { $ext='true'; }
3520: $url = &LONCAPA::map::qtunescape($url);
3521: my $comment=$env{'form.comment'};
3522: $comment = &LONCAPA::map::qtunescape($comment);
3523: if ($folder=~/^supplemental/) {
3524: $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
3525: $env{'user.domain'}.'___&&&___'.$comment;
3526: }
3527:
3528: $LONCAPA::map::resources[$newidx]=
3529: $comment.':'.$url.':'.$ext.':normal:res';
3530: $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
3531: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.484.2.7 raeburn 3532: $folder.'.'.$container,1);
1.329 droeschl 3533: if ($fatal) {
1.457 raeburn 3534: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>';
1.440 raeburn 3535: return;
1.329 droeschl 3536: } else {
1.440 raeburn 3537: if ($parseaction eq 'parse' && $mimetype eq 'text/html') {
3538: $$upload_output = $showupload;
1.384 raeburn 3539: my $total_embedded = scalar(keys(%{$allfiles}));
1.329 droeschl 3540: if ($total_embedded > 0) {
1.440 raeburn 3541: my $uploadphase = 'upload_embedded';
3542: my $primaryurl = &HTML::Entities::encode($url,'<>&"');
3543: my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx);
3544: my ($embedded,$num) =
3545: &Apache::loncommon::ask_for_embedded_content(
3546: '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url});
3547: if ($embedded) {
3548: if ($num) {
3549: $$upload_output .=
3550: '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
3551: $nextphase = $uploadphase;
3552: } else {
3553: $$upload_output .= $embedded;
3554: }
3555: } else {
3556: $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
3557: }
1.329 droeschl 3558: } else {
1.440 raeburn 3559: $$upload_output .= &mt('No embedded items identified').'<br />';
1.329 droeschl 3560: }
1.457 raeburn 3561: $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
1.484.2.51 raeburn 3562: } elsif ((&Apache::loncommon::is_archive_file($mimetype)) &&
3563: ($env{'form.uploaddoc.filename'} =~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i)) {
1.476 raeburn 3564: $nextphase = 'decompress_uploaded';
3565: my $position = scalar(@LONCAPA::map::order)-1;
3566: my $noextract = &return_to_editor();
3567: my $archiveurl = &HTML::Entities::encode($url,'<>&"');
3568: my %archiveitems = (
3569: folderpath => $env{'form.folderpath'},
3570: cmd => $nextphase,
3571: newidx => $newidx,
3572: position => $position,
3573: phase => $nextphase,
1.477 raeburn 3574: comment => $comment,
1.480 raeburn 3575: );
3576: my ($destination,$dir_root) = &embedded_destination($coursenum,$coursedom);
3577: my @current = &get_dir_list($url,$coursenum,$coursedom,$newidx);
1.476 raeburn 3578: $$upload_output = $showupload.
3579: &Apache::loncommon::decompress_form($mimetype,
3580: $archiveurl,'/adm/coursedocs',$noextract,
1.480 raeburn 3581: \%archiveitems,\@current);
1.329 droeschl 3582: }
3583: }
3584: }
1.440 raeburn 3585: return $nextphase;
1.329 droeschl 3586: }
3587:
1.480 raeburn 3588: sub get_dir_list {
3589: my ($url,$coursenum,$coursedom,$newidx) = @_;
3590: my ($destination,$dir_root) = &embedded_destination();
3591: my ($dirlistref,$listerror) =
3592: &Apache::lonnet::dirlist("$dir_root/$destination/$newidx",$coursedom,$coursenum,1);
3593: my @dir_lines;
3594: my $dirptr=16384;
3595: if (ref($dirlistref) eq 'ARRAY') {
3596: foreach my $dir_line (sort
3597: {
3598: my ($afile)=split('&',$a,2);
3599: my ($bfile)=split('&',$b,2);
3600: return (lc($afile) cmp lc($bfile));
3601: } (@{$dirlistref})) {
3602: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
3603: $filename =~ s/\s+$//;
3604: next if ($filename =~ /^\.\.?$/);
3605: my $isdir = 0;
3606: if ($dirptr&$testdir) {
3607: $isdir = 1;
3608: }
3609: push(@dir_lines, [$filename,$dom,$isdir,$size,$mtime,$obs]);
3610: }
3611: }
3612: return @dir_lines;
3613: }
3614:
1.329 droeschl 3615: sub is_supplemental_title {
3616: my ($title) = @_;
3617: return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
3618: }
3619:
3620: # --------------------------------------------------------------- An entry line
3621:
3622: sub entryline {
1.484.2.12 raeburn 3623: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
1.484.2.67 raeburn 3624: $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups,
1.484.2.72.2. (raeburn 3625:): $ltitoolsref,$canedit,$isencrypted,$navmapref)=@_;
1.484.2.52 raeburn 3626: my ($foldertitle,$renametitle,$oldtitle);
1.329 droeschl 3627: if (&is_supplemental_title($title)) {
1.484.2.7 raeburn 3628: ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
1.329 droeschl 3629: } else {
3630: $title=&HTML::Entities::encode($title,'"<>&\'');
3631: $renametitle=$title;
3632: $foldertitle=$title;
3633: }
3634:
1.484.2.67 raeburn 3635: my ($disabled,$readonly,$js_lt);
3636: unless ($canedit) {
3637: $disabled = 'disabled="disabled"';
3638: $readonly = 1;
3639: }
3640:
1.329 droeschl 3641: my $orderidx=$LONCAPA::map::order[$index];
1.364 bisitz 3642:
1.329 droeschl 3643: $renametitle=~s/\\/\\\\/g;
3644: $renametitle=~s/\"\;/\\\"/g;
1.484.2.55 raeburn 3645: $renametitle=~s/"/%22/g;
1.329 droeschl 3646: $renametitle=~s/ /%20/g;
1.484.2.52 raeburn 3647: $oldtitle = $renametitle;
3648: $renametitle=~s/\'\;/\\\'/g;
1.379 bisitz 3649: my $line=&Apache::loncommon::start_data_table_row();
1.484.2.30 raeburn 3650: my ($form_start,$form_end,$form_common,$form_param);
1.329 droeschl 3651: # Edit commands
1.484.2.28 raeburn 3652: my ($esc_path, $path, $symb);
1.329 droeschl 3653: if ($env{'form.folderpath'}) {
3654: $esc_path=&escape($env{'form.folderpath'});
3655: $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3656: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
3657: }
1.484.2.16 raeburn 3658: my $isexternal;
1.484.2.19 raeburn 3659: if ($residx) {
1.484.2.12 raeburn 3660: my $currurl = $url;
3661: $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.484.2.16 raeburn 3662: if ($currurl =~ m{^/adm/wrapper/ext/}) {
3663: $isexternal = 1;
3664: }
1.484.2.19 raeburn 3665: if (!$supplementalflag) {
3666: my $path = 'uploaded/'.
3667: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
3668: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
3669: $symb = &Apache::lonnet::encode_symb($path.$folder.".$container",
3670: $residx,
3671: &Apache::lonnet::declutter($currurl));
3672: }
1.484.2.12 raeburn 3673: }
1.484.2.30 raeburn 3674: my ($renamelink,%lt,$ishash);
3675: if (ref($filtersref) eq 'HASH') {
3676: $ishash = 1;
3677: }
3678:
1.329 droeschl 3679: if ($allowed) {
1.484.2.30 raeburn 3680: $form_start = '
3681: <form action="/adm/coursedocs" method="post">
3682: ';
3683: $form_common=(<<END);
3684: <input type="hidden" name="folderpath" value="$path" />
3685: <input type="hidden" name="symb" value="$symb" />
3686: END
3687: $form_param=(<<END);
3688: <input type="hidden" name="setparms" value="$orderidx" />
3689: <input type="hidden" name="changeparms" value="0" />
3690: END
3691: $form_end = '</form>';
3692:
1.329 droeschl 3693: my $incindex=$index+1;
3694: my $selectbox='';
1.471 raeburn 3695: if (($#LONCAPA::map::order>0) &&
1.329 droeschl 3696: ((split(/\:/,
1.344 bisitz 3697: $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
3698: ne '') &&
1.329 droeschl 3699: ((split(/\:/,
1.344 bisitz 3700: $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1.329 droeschl 3701: ne '')) {
3702: $selectbox=
3703: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.484.2.67 raeburn 3704: '<select name="newpos" onchange="this.form.submit()"'.$disabled.'>';
1.329 droeschl 3705: for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
3706: if ($i==$incindex) {
1.358 bisitz 3707: $selectbox.='<option value="" selected="selected">('.$i.')</option>';
1.329 droeschl 3708: } else {
3709: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
3710: }
3711: }
3712: $selectbox.='</select>';
3713: }
1.484.2.12 raeburn 3714: %lt=&Apache::lonlocal::texthash(
1.329 droeschl 3715: 'up' => 'Move Up',
3716: 'dw' => 'Move Down',
3717: 'rm' => 'Remove',
3718: 'ct' => 'Cut',
3719: 'rn' => 'Rename',
1.484.2.12 raeburn 3720: 'cp' => 'Copy',
3721: 'ex' => 'External Resource',
1.484.2.72.2. (raeburn 3722:): 'et' => 'External Tool',
1.484.2.12 raeburn 3723: 'ed' => 'Edit',
3724: 'pr' => 'Preview',
3725: 'sv' => 'Save',
3726: 'ul' => 'URL',
1.484.2.67 raeburn 3727: 'ti' => 'Title',
3728: 'er' => 'Editing rights unavailable for your current role.',
1.484.2.12 raeburn 3729: );
1.484.2.30 raeburn 3730: my %denied = &action_restrictions($coursenum,$coursedom,$url,
3731: $env{'form.folderpath'},
3732: $currgroups);
1.484.2.19 raeburn 3733: my ($copylink,$cutlink,$removelink);
1.329 droeschl 3734: my $skip_confirm = 0;
1.484.2.63 raeburn 3735: my $confirm_removal = 0;
1.329 droeschl 3736: if ( $folder =~ /^supplemental/
3737: || ($url =~ m{( /smppg$
3738: |/syllabus$
3739: |/aboutme$
3740: |/navmaps$
3741: |/bulletinboard$
1.484.2.72.2. (raeburn 3742:): |/ext\.tool$
1.484.2.16 raeburn 3743: |\.html$)}x)
1.484.2.19 raeburn 3744: || $isexternal) {
1.329 droeschl 3745: $skip_confirm = 1;
3746: }
1.484.2.63 raeburn 3747: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
3748: ($url!~/$LONCAPA::assess_page_seq_re/)) {
3749: $confirm_removal = 1;
3750: }
1.484.2.19 raeburn 3751:
1.484.2.30 raeburn 3752: if ($denied{'copy'}) {
3753: $copylink=(<<ENDCOPY)
1.484.2.16 raeburn 3754: <span style="visibility: hidden;">$lt{'cp'}</span>
3755: ENDCOPY
3756: } else {
1.484.2.30 raeburn 3757: my $formname = 'edit_copy_'.$orderidx;
3758: my $js = "javascript:checkForSubmit(document.forms.renameform,'copy','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.484.2.19 raeburn 3759: $copylink=(<<ENDCOPY);
1.484.2.30 raeburn 3760: <form name="$formname" method="post" action="/adm/coursedocs">
3761: $form_common
1.484.2.67 raeburn 3762: <input type="checkbox" name="copy" id="copy_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','copy');" class="LC_hidden" $disabled /><a href="$js" class="LC_docs_copy">$lt{'cp'}</a>
1.484.2.30 raeburn 3763: $form_end
1.329 droeschl 3764: ENDCOPY
1.484.2.30 raeburn 3765: if (($ishash) && (ref($filtersref->{'cancopy'}) eq 'ARRAY')) {
3766: push(@{$filtersref->{'cancopy'}},$orderidx);
3767: }
1.329 droeschl 3768: }
1.484.2.30 raeburn 3769: if ($denied{'cut'}) {
1.484.2.16 raeburn 3770: $cutlink=(<<ENDCUT);
3771: <span style="visibility: hidden;">$lt{'ct'}</span>
3772: ENDCUT
3773: } else {
1.484.2.30 raeburn 3774: my $formname = 'edit_cut_'.$orderidx;
3775: my $js = "javascript:checkForSubmit(document.forms.renameform,'cut','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.484.2.19 raeburn 3776: $cutlink=(<<ENDCUT);
1.484.2.30 raeburn 3777: <form name="$formname" method="post" action="/adm/coursedocs">
3778: $form_common
3779: <input type="hidden" name="skip_$orderidx" id="skip_cut_$orderidx" value="$skip_confirm" />
1.484.2.67 raeburn 3780: <input type="checkbox" name="cut" id="cut_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','cut');" class="LC_hidden" $disabled /><a href="$js" class="LC_docs_cut">$lt{'ct'}</a>
1.484.2.30 raeburn 3781: $form_end
1.329 droeschl 3782: ENDCUT
1.484.2.30 raeburn 3783: if (($ishash) && (ref($filtersref->{'cancut'}) eq 'ARRAY')) {
3784: push(@{$filtersref->{'cancut'}},$orderidx);
3785: }
1.329 droeschl 3786: }
1.484.2.30 raeburn 3787: if ($denied{'remove'}) {
1.484.2.16 raeburn 3788: $removelink=(<<ENDREM);
3789: <span style="visibility: hidden;">$lt{'rm'}</a>
3790: ENDREM
3791: } else {
1.484.2.30 raeburn 3792: my $formname = 'edit_remove_'.$orderidx;
1.484.2.63 raeburn 3793: my $js = "javascript:checkForSubmit(document.forms.renameform,'remove','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder',$confirm_removal);";
1.484.2.9 raeburn 3794: $removelink=(<<ENDREM);
1.484.2.30 raeburn 3795: <form name="$formname" method="post" action="/adm/coursedocs">
3796: $form_common
3797: <input type="hidden" name="skip_$orderidx" id="skip_remove_$orderidx" value="$skip_confirm" />
1.484.2.63 raeburn 3798: <input type="hidden" name="confirm_rem_$orderidx" id="confirm_removal_$orderidx" value="$confirm_removal" />
1.484.2.67 raeburn 3799: <input type="checkbox" name="remove" id="remove_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','remove');" class="LC_hidden" $disabled /><a href="$js" class="LC_docs_remove">$lt{'rm'}</a>
1.484.2.30 raeburn 3800: $form_end
1.484.2.9 raeburn 3801: ENDREM
1.484.2.30 raeburn 3802: if (($ishash) && (ref($filtersref->{'canremove'}) eq 'ARRAY')) {
3803: push(@{$filtersref->{'canremove'}},$orderidx);
3804: }
1.484.2.9 raeburn 3805: }
1.484.2.35 raeburn 3806: $renamelink=(<<ENDREN);
1.484.2.52 raeburn 3807: <a href='javascript:changename("$esc_path","$index","$oldtitle");' class="LC_docs_rename">$lt{'rn'}</a>
1.484.2.16 raeburn 3808: ENDREN
1.484.2.67 raeburn 3809: my ($uplink,$downlink);
3810: if ($canedit) {
3811: $uplink = "/adm/coursedocs?cmd=up_$index&folderpath=$esc_path&symb=$symb";
3812: $downlink = "/adm/coursedocs?cmd=down_$index&folderpath=$esc_path&symb=$symb";
3813: } else {
3814: $uplink = "javascript:alert('".&js_escape($lt{'er'})."');";
3815: $downlink = $uplink;
3816: }
1.329 droeschl 3817: $line.=(<<END);
3818: <td>
1.379 bisitz 3819: <div class="LC_docs_entry_move">
1.484.2.67 raeburn 3820: <a href="$uplink">
1.484.2.12 raeburn 3821: <img src="${iconpath}move_up.gif" alt="$lt{'up'}" class="LC_icon" />
1.379 bisitz 3822: </a>
3823: </div>
3824: <div class="LC_docs_entry_move">
1.484.2.67 raeburn 3825: <a href="$downlink">
1.484.2.12 raeburn 3826: <img src="${iconpath}move_down.gif" alt="$lt{'dw'}" class="LC_icon" />
1.379 bisitz 3827: </a>
3828: </div>
1.329 droeschl 3829: </td>
3830: <td>
3831: $form_start
1.484.2.30 raeburn 3832: $form_param
1.478 raeburn 3833: $form_common
1.329 droeschl 3834: $selectbox
3835: $form_end
3836: </td>
1.484.2.30 raeburn 3837: <td class="LC_docs_entry_commands LC_nobreak">
1.484.2.9 raeburn 3838: $removelink
1.329 droeschl 3839: $cutlink
3840: $copylink
3841: </td>
3842: END
3843: }
3844: # Figure out what kind of a resource this is
3845: my ($extension)=($url=~/\.(\w+)$/);
3846: my $uploaded=($url=~/^\/*uploaded\//);
3847: my $icon=&Apache::loncommon::icon($url);
1.484.2.19 raeburn 3848: my $isfolder;
3849: my $ispage;
3850: my $containerarg;
1.484.2.67 raeburn 3851: my $folderurl;
1.329 droeschl 3852: if ($uploaded) {
1.472 raeburn 3853: if (($extension eq 'sequence') || ($extension eq 'page')) {
3854: $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
1.484.2.19 raeburn 3855: $containerarg = $1;
1.472 raeburn 3856: if ($extension eq 'sequence') {
3857: $icon=$iconpath.'navmap.folder.closed.gif';
3858: $isfolder=1;
3859: } else {
3860: $icon=$iconpath.'page.gif';
3861: $ispage=1;
3862: }
1.484.2.67 raeburn 3863: $folderurl = &Apache::lonnet::declutter($url);
1.472 raeburn 3864: if ($allowed) {
3865: $url='/adm/coursedocs?';
3866: } else {
3867: $url='/adm/supplemental?';
3868: }
1.329 droeschl 3869: } else {
3870: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
3871: }
3872: }
1.364 bisitz 3873:
1.484.2.70 raeburn 3874: my ($editlink,$extresform,$anchor,$hiddenres,$nomodal);
1.329 droeschl 3875: my $orig_url = $url;
1.340 raeburn 3876: $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
1.484.2.19 raeburn 3877: $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.484.2.12 raeburn 3878: if (!$supplementalflag && $residx && $symb) {
3879: if ((!$isfolder) && (!$ispage)) {
3880: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
3881: $url=&Apache::lonnet::clutter($url);
3882: if ($url=~/^\/*uploaded\//) {
3883: $url=~/\.(\w+)$/;
3884: my $embstyle=&Apache::loncommon::fileembstyle($1);
3885: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
3886: $url='/adm/wrapper'.$url;
3887: } elsif ($embstyle eq 'ssi') {
3888: #do nothing with these
3889: } elsif ($url!~/\.(sequence|page)$/) {
3890: $url='/adm/coursedocs/showdoc'.$url;
3891: }
1.484.2.70 raeburn 3892: } elsif ($url=~m{^(|/adm/wrapper)/ext/([^#]+)}) {
3893: my $wrapped = $1;
3894: my $exturl = $2;
3895: if ($wrapped eq '') {
3896: $url='/adm/wrapper'.$url;
3897: }
3898: if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) {
3899: $nomodal = 1;
3900: }
1.484.2.72.2. (raeburn 3901:): } elsif ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
3902:): $url='/adm/wrapper'.$url;
1.484.2.70 raeburn 3903: } elsif ($url eq "/public/$coursedom/$coursenum/syllabus") {
3904: if (($ENV{'SERVER_PORT'} == 443) &&
3905: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
3906: $nomodal = 1;
3907: }
1.484.2.19 raeburn 3908: }
1.484.2.12 raeburn 3909: if (&Apache::lonnet::symbverify($symb,$url)) {
1.484.2.66 raeburn 3910: my $shownsymb = $symb;
3911: if ($isexternal) {
3912: if ($url =~ /^([^#]+)#([^#]+)$/) {
3913: $url = $1;
3914: $anchor = $2;
3915: if ($symb =~ m{^([^#]+)\Q#$anchor\E$}) {
3916: $shownsymb = $1.&escape('#').$anchor;
3917: }
3918: }
3919: }
1.484.2.67 raeburn 3920: unless ($env{'request.role.adv'}) {
3921: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
3922: $url = '';
3923: }
3924: if (&Apache::lonnet::EXT('resource.0.hiddenresource',$symb) =~ /^yes$/i) {
3925: $url = '';
3926: $hiddenres = 1;
3927: }
3928: }
3929: if ($url ne '') {
1.484.2.72.2. (raeburn 3930:): $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
1.484.2.67 raeburn 3931: }
3932: } elsif (!$env{'request.role.adv'}) {
3933: my $checkencrypt;
3934: if (((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) ||
3935: $isencrypted || (&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i)) {
3936: $checkencrypt = 1;
1.484.2.70 raeburn 3937: } elsif (ref($navmapref)) {
1.484.2.67 raeburn 3938: unless (ref($$navmapref)) {
3939: $$navmapref = Apache::lonnavmaps::navmap->new();
3940: }
3941: if (ref($$navmapref)) {
3942: if (lc($$navmapref->get_mapparam($symb,undef,"0.encrypturl")) eq 'yes') {
3943: $checkencrypt = 1;
3944: }
3945: }
3946: }
3947: if ($checkencrypt) {
3948: my $shownsymb = &Apache::lonenc::encrypted($symb);
3949: my $shownurl = &Apache::lonenc::encrypted($url);
3950: if (&Apache::lonnet::symbverify($shownsymb,$shownurl)) {
1.484.2.72.2. (raeburn 3951:): $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
1.484.2.67 raeburn 3952: if ($env{'request.enc'} ne '') {
3953: delete($env{'request.enc'});
3954: }
3955: } else {
3956: $url='';
3957: }
3958: } else {
3959: $url='';
3960: }
1.484.2.12 raeburn 3961: } else {
3962: $url='';
3963: }
1.484.2.19 raeburn 3964: }
1.484.2.66 raeburn 3965: } elsif ($supplementalflag) {
3966: if ($isexternal) {
3967: if ($url =~ /^([^#]+)#([^#]+)$/) {
3968: $url = $1;
3969: $anchor = $2;
1.484.2.70 raeburn 3970: if (($url =~ m{^(|/adm/wrapper)/ext/(?!https:)}) && ($ENV{'SERVER_PORT'} == 443)) {
3971: $nomodal = 1;
3972: }
3973: }
3974: } elsif ($url =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
3975: if (($ENV{'SERVER_PORT'} == 443) &&
3976: ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
3977: $nomodal = 1;
1.484.2.66 raeburn 3978: }
3979: }
1.329 droeschl 3980: }
1.484.2.67 raeburn 3981: my ($rand_pick_text,$rand_order_text,$hiddenfolder);
3982: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.484.2.19 raeburn 3983: if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') {
1.329 droeschl 3984: my $foldername=&escape($foldertitle);
3985: my $folderpath=$env{'form.folderpath'};
3986: if ($folderpath) { $folderpath.='&' };
1.484.2.19 raeburn 3987: if (!$allowed && $supplementalflag) {
3988: $folderpath.=$containerarg.'&'.$foldername;
3989: $url.='folderpath='.&escape($folderpath);
3990: } else {
3991: my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
3992: 'parameter_randompick'))[0];
1.484.2.67 raeburn 3993: my $randorder = ((&LONCAPA::map::getparameter($orderidx,
3994: 'parameter_randomorder'))[0]=~/^yes$/i);
3995: my $hiddenmap = ((&LONCAPA::map::getparameter($orderidx,
3996: 'parameter_hiddenresource'))[0]=~/^yes$/i);
3997: my $encryptmap = ((&LONCAPA::map::getparameter($orderidx,
3998: 'parameter_encrypturl'))[0]=~/^yes$/i);
3999: unless ($hiddenmap) {
1.484.2.70 raeburn 4000: if (ref($navmapref)) {
4001: unless (ref($$navmapref)) {
4002: $$navmapref = Apache::lonnavmaps::navmap->new();
4003: }
4004: if (ref($$navmapref)) {
4005: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
4006: my @resources = $$navmapref->retrieveResources($folderurl,$filterFunc,1,1);
4007: unless (@resources) {
4008: $hiddenmap = 1;
4009: unless ($env{'request.role.adv'}) {
4010: $url = '';
4011: $hiddenfolder = 1;
4012: }
1.484.2.67 raeburn 4013: }
4014: }
4015: }
4016: }
4017: }
4018: unless ($encryptmap) {
1.484.2.70 raeburn 4019: if ((ref($navmapref)) && (ref($$navmapref))) {
4020: if (lc($$navmapref->get_mapparam(undef,$folderurl,"0.encrypturl")) eq 'yes') {
4021: $encryptmap = 1;
4022: }
1.484.2.67 raeburn 4023: }
4024: }
4025:
4026: # Append randompick number, hidden, and encrypted with ":" to foldername,
4027: # so it gets transferred between levels
4028: $folderpath.=$containerarg.'&'.$foldername.
4029: ':'.$rpicknum.':'.$hiddenmap.':'.$encryptmap.':'.$randorder.':'.$ispage;
4030: unless ($url eq '') {
4031: $url.='folderpath='.&escape($folderpath);
4032: }
1.484.2.19 raeburn 4033: my $rpckchk;
4034: if ($rpicknum) {
4035: $rpckchk = ' checked="checked"';
1.484.2.30 raeburn 4036: if (($ishash) && (ref($filtersref->{'randompick'}) eq 'ARRAY')) {
4037: push(@{$filtersref->{'randompick'}},$orderidx.':'.$rpicknum);
4038: }
1.484.2.19 raeburn 4039: }
1.484.2.29 raeburn 4040: my $formname = 'edit_randompick_'.$orderidx;
1.484.2.19 raeburn 4041: $rand_pick_text =
1.478 raeburn 4042: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.484.2.30 raeburn 4043: $form_param."\n".
1.478 raeburn 4044: $form_common."\n".
1.484.2.67 raeburn 4045: '<span class="LC_nobreak"><label><input type="checkbox" name="randompick_'.$orderidx.'" id="randompick_'.$orderidx.'" onclick="'."updatePick(this.form,'$orderidx','check');".'"'.$rpckchk.$disabled.' /> '.&mt('Randomly Pick').'</label><input type="hidden" name="rpicknum_'.$orderidx.'" id="rpicknum_'.$orderidx.'" value="'.$rpicknum.'" /><span id="randompicknum_'.$orderidx.'">';
1.484.2.19 raeburn 4046: if ($rpicknum ne '') {
4047: $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
4048: }
1.484.2.29 raeburn 4049: $rand_pick_text .= '</span></span>'.
4050: $form_end;
1.484.2.30 raeburn 4051: my $ro_set;
1.484.2.67 raeburn 4052: if ($randorder) {
1.484.2.30 raeburn 4053: $ro_set = 'checked="checked"';
4054: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4055: push(@{$filtersref->{'randomorder'}},$orderidx);
4056: }
4057: }
1.484.2.41 raeburn 4058: $formname = 'edit_rorder_'.$orderidx;
1.484.2.19 raeburn 4059: $rand_order_text =
1.484.2.29 raeburn 4060: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.484.2.30 raeburn 4061: $form_param."\n".
1.484.2.29 raeburn 4062: $form_common."\n".
1.484.2.67 raeburn 4063: '<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.$disabled.' /> '.&mt('Random Order').' </label></span>'.
1.484.2.29 raeburn 4064: $form_end;
1.484.2.19 raeburn 4065: }
1.484.2.18 raeburn 4066: } elsif ($supplementalflag && !$allowed) {
1.484.2.72.2. (raeburn 4067:): my $isexttool;
4068:): if ($url=~m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4069:): $url='/adm/wrapper'.$url;
4070:): $isexttool = 1;
4071:): }
1.484.2.19 raeburn 4072: $url .= ($url =~ /\?/) ? '&':'?';
1.484.2.18 raeburn 4073: $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
1.484.2.19 raeburn 4074: if ($title) {
4075: $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"');
4076: }
1.484.2.72.2. (raeburn 4077:): if ((($isexternal) || ($isexttool)) && $orderidx) {
1.484.2.19 raeburn 4078: $url .= '&idx='.$orderidx;
4079: }
1.484.2.66 raeburn 4080: if ($anchor ne '') {
4081: $url .= '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4082: }
1.329 droeschl 4083: }
1.484.2.19 raeburn 4084: my ($tdalign,$tdwidth);
1.484.2.12 raeburn 4085: if ($allowed) {
1.484.2.19 raeburn 4086: my $fileloc =
1.484.2.12 raeburn 4087: &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
1.484.2.19 raeburn 4088: if ($isexternal) {
4089: ($editlink,$extresform) =
1.484.2.67 raeburn 4090: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
4091: undef,undef,undef,$disabled);
1.484.2.72.2. (raeburn 4092:): } elsif ($orig_url =~ m{^/adm/$coursedom/$coursenum/\d+/ext\.tool$}) {
4093:): ($editlink,$extresform) =
4094:): &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
4095:): undef,undef,undef,'tool',$coursedom,
4096:): $coursenum,$ltitoolsref,$disabled);
1.484.2.19 raeburn 4097: } elsif (!$isfolder && !$ispage) {
4098: my ($cfile,$home,$switchserver,$forceedit,$forceview) =
1.484.2.14 raeburn 4099: &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
1.484.2.19 raeburn 4100: if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
1.484.2.66 raeburn 4101: my $suppanchor;
4102: if ($supplementalflag) {
4103: $suppanchor = $anchor;
4104: }
1.484.2.19 raeburn 4105: my $jscall =
1.484.2.12 raeburn 4106: &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
4107: $switchserver,
1.484.2.14 raeburn 4108: $forceedit,
1.484.2.19 raeburn 4109: undef,$symb,
4110: &escape($env{'form.folderpath'}),
1.484.2.66 raeburn 4111: $renametitle,'','',1,$suppanchor);
1.484.2.12 raeburn 4112: if ($jscall) {
1.484.2.19 raeburn 4113: $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
4114: $jscall.'" >'.&mt('Edit').'</a> '."\n";
1.484.2.12 raeburn 4115: }
4116: }
4117: }
1.484.2.19 raeburn 4118: $tdalign = ' align="right" valign="top"';
4119: $tdwidth = ' width="80%"';
1.329 droeschl 4120: }
1.408 raeburn 4121: my $reinit;
4122: if ($crstype eq 'Community') {
4123: $reinit = &mt('(re-initialize community to access)');
4124: } else {
4125: $reinit = &mt('(re-initialize course to access)');
1.484.2.19 raeburn 4126: }
4127: $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;
1.484.2.70 raeburn 4128: my $link;
1.472 raeburn 4129: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 4130: $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
4131: } elsif ($url) {
1.484.2.66 raeburn 4132: if ($anchor ne '') {
4133: if ($supplementalflag) {
4134: $anchor = '&anchor='.&HTML::Entities::encode($anchor,'"<>&');
4135: } else {
4136: $anchor = '#'.&HTML::Entities::encode($anchor,'"<>&');
4137: }
4138: }
1.484.2.70 raeburn 4139: $link = &js_escape($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes'.
4140: (($anchor ne '')?$anchor:''));
4141: if ($nomodal) {
4142: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4143: '<img src="'.$icon.'" alt="" class="LC_icon" border="0" /></a>';
4144: } else {
4145: $line.=&Apache::loncommon::modal_link($link,
4146: '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
4147: }
1.469 www 4148: } else {
4149: $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
4150: }
1.484.2.19 raeburn 4151: $line.='</span></td><td'.$tdwidth.'>';
1.472 raeburn 4152: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 4153: $line.='<a href="'.$url.'">'.$title.'</a>';
4154: } elsif ($url) {
1.484.2.70 raeburn 4155: if ($nomodal) {
4156: $line.='<a href="#" onclick="javascript:window.open('."'$link','syllabuspreview','height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1')".'; return false;" />'.
4157: $title.'</a>';
4158: } else {
4159: $line.=&Apache::loncommon::modal_link($link,$title,600,500);
4160: }
1.484.2.67 raeburn 4161: } elsif (($hiddenfolder) || ($hiddenres)) {
1.484.2.72 raeburn 4162: $line.=$title.' <span class="LC_warning LC_docs_reinit_warn">('.&mt('Hidden').')</span>';
1.469 www 4163: } else {
4164: $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
4165: }
1.484.2.19 raeburn 4166: $line.="$extresform</td>";
1.478 raeburn 4167: $rand_pick_text = ' ' if ($rand_pick_text eq '');
4168: $rand_order_text = ' ' if ($rand_order_text eq '');
1.329 droeschl 4169: if (($allowed) && ($folder!~/^supplemental/)) {
4170: my %lt=&Apache::lonlocal::texthash(
4171: 'hd' => 'Hidden',
4172: 'ec' => 'URL hidden');
1.484.2.30 raeburn 4173: my ($enctext,$hidtext);
4174: if ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) {
4175: $enctext = ' checked="checked"';
4176: if (($ishash) && (ref($filtersref->{'encrypturl'}) eq 'ARRAY')) {
4177: push(@{$filtersref->{'encrypturl'}},$orderidx);
4178: }
4179: }
4180: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4181: $hidtext = ' checked="checked"';
4182: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4183: push(@{$filtersref->{'hiddenresource'}},$orderidx);
4184: }
4185: }
1.484.2.29 raeburn 4186: my $formhidden = 'edit_hiddenresource_'.$orderidx;
4187: my $formurlhidden = 'edit_encrypturl_'.$orderidx;
1.329 droeschl 4188: $line.=(<<ENDPARMS);
4189: <td class="LC_docs_entry_parameter">
1.484.2.30 raeburn 4190: <form action="/adm/coursedocs" method="post" name="$formhidden">
4191: $form_param
1.478 raeburn 4192: $form_common
1.484.2.67 raeburn 4193: <label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'hiddenresource','settings');" $hidtext $disabled /> $lt{'hd'}</label>
1.329 droeschl 4194: $form_end
1.458 raeburn 4195: <br />
1.484.2.29 raeburn 4196: <form action="/adm/coursedocs" method="post" name="$formurlhidden">
1.484.2.30 raeburn 4197: $form_param
1.478 raeburn 4198: $form_common
1.484.2.67 raeburn 4199: <label><input type="checkbox" name="encrypturl_$orderidx" id="encrypturl_$orderidx" onclick="checkForSubmit(this.form,'encrypturl','settings');" $enctext $disabled /> $lt{'ec'}</label>
1.329 droeschl 4200: $form_end
4201: </td>
1.478 raeburn 4202: <td class="LC_docs_entry_parameter">$rand_pick_text<br />
4203: $rand_order_text</td>
1.329 droeschl 4204: ENDPARMS
4205: }
1.379 bisitz 4206: $line.=&Apache::loncommon::end_data_table_row();
1.329 droeschl 4207: return $line;
4208: }
4209:
1.484.2.30 raeburn 4210: sub action_restrictions {
4211: my ($cnum,$cdom,$url,$folderpath,$currgroups) = @_;
4212: my %denied = (
4213: cut => 0,
4214: copy => 0,
4215: remove => 0,
4216: );
4217: if ($url=~ m{^/res/.+\.(page|sequence)$}) {
4218: # no copy for published maps
4219: $denied{'copy'} = 1;
4220: } elsif ($url=~m{^/res/lib/templates/}) {
4221: $denied{'copy'} = 1;
4222: $denied{'cut'} = 1;
4223: } elsif ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") {
4224: if ($folderpath =~ /^default&[^\&]+$/) {
4225: if ((ref($currgroups) eq 'HASH') && (keys(%{$currgroups}) > 0)) {
4226: $denied{'remove'} = 1;
4227: }
4228: $denied{'cut'} = 1;
4229: $denied{'copy'} = 1;
4230: }
4231: } elsif ($url =~ m{^\Q/uploaded/$cdom/$cnum/group_folder_\E(\w+)\.sequence$}) {
4232: my $group = $1;
4233: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+$/) {
4234: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4235: $denied{'remove'} = 1;
4236: }
4237: }
4238: $denied{'cut'} = 1;
4239: $denied{'copy'} = 1;
4240: } elsif ($url =~ m{^\Q/adm/$cdom/$cnum/\E(\w+)/smppg$}) {
4241: my $group = $1;
4242: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&\Qgroup_folder_$group\E\&[^\&]+$/) {
4243: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4244: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4245: if (keys(%groupsettings) > 0) {
4246: $denied{'remove'} = 1;
4247: }
4248: $denied{'cut'} = 1;
4249: $denied{'copy'} = 1;
4250: }
4251: }
4252: } elsif ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&group_folder_(\w+)\&/) {
4253: my $group = $1;
4254: if ($url =~ /group_boards_\Q$group\E/) {
4255: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4256: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4257: if (keys(%groupsettings) > 0) {
4258: if (ref($groupsettings{'functions'}) eq 'HASH') {
4259: if ($groupsettings{'functions'}{'discussion'} eq 'on') {
4260: $denied{'remove'} = 1;
4261: }
4262: }
4263: }
4264: $denied{'cut'} = 1;
4265: $denied{'copy'} = 1;
4266: }
4267: }
4268: }
4269: return %denied;
4270: }
4271:
1.484.2.26 raeburn 4272: sub new_timebased_suffix {
1.484.2.30 raeburn 4273: my ($dom,$num,$type,$area,$container) = @_;
1.484.2.26 raeburn 4274: my ($prefix,$namespace,$idtype,$errtext,$locknotfreed);
1.484.2.30 raeburn 4275: if ($type eq 'paste') {
4276: $prefix = $type;
4277: $namespace = 'courseeditor';
1.484.2.56 raeburn 4278: $idtype = 'addcode';
1.484.2.30 raeburn 4279: } elsif ($type eq 'map') {
1.484.2.26 raeburn 4280: $prefix = 'docs';
4281: if ($area eq 'supplemental') {
4282: $prefix = 'supp';
4283: }
4284: $prefix .= $container;
4285: $namespace = 'uploadedmaps';
4286: } else {
4287: $prefix = $type;
4288: $namespace = 'templated';
1.484.2.15 raeburn 4289: }
4290: my ($suffix,$freedlock,$error) =
1.484.2.56 raeburn 4291: &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num,$idtype);
1.484.2.15 raeburn 4292: if (!$suffix) {
1.484.2.30 raeburn 4293: if ($type eq 'paste') {
4294: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.');
4295: } elsif ($type eq 'map') {
1.484.2.26 raeburn 4296: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
4297: } elsif ($type eq 'smppg') {
4298: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.');
1.484.2.72.2. (raeburn 4299:): } elsif ($type eq 'exttool') {
4300:): $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new external tool.');
1.484.2.26 raeburn 4301: } else {
1.484.2.42 raeburn 4302: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new discussion board.');
1.484.2.26 raeburn 4303: }
1.484.2.15 raeburn 4304: if ($error) {
4305: $errtext .= '<br />'.$error;
4306: }
4307: }
4308: if ($freedlock ne 'ok') {
1.484.2.26 raeburn 4309: $locknotfreed =
4310: '<div class="LC_error">'.
4311: &mt('There was a problem removing a lockfile.').' ';
1.484.2.30 raeburn 4312: if ($type eq 'paste') {
1.484.2.57 raeburn 4313: if ($freedlock eq 'nolock') {
4314: $locknotfreed =
4315: '<div class="LC_error">'.
4316: &mt('A lockfile was not released when you added content to the clipboard earlier in this session.').' '.
4317:
1.484.2.60 raeburn 4318: &mt('As a result addition of items to the clipboard will be unavailable until your next log-in.');
1.484.2.57 raeburn 4319: } else {
4320: $locknotfreed .=
4321: &mt('This will prevent addition of items to the clipboard until your next log-in.');
4322: }
1.484.2.30 raeburn 4323: } elsif ($type eq 'map') {
1.484.2.57 raeburn 4324: $locknotfreed .=
4325: &mt('This will prevent creation of additional folders or composite pages in this course.');
1.484.2.26 raeburn 4326: } elsif ($type eq 'smppg') {
4327: $locknotfreed .=
4328: &mt('This will prevent creation of additional simple pages in this course.');
1.484.2.72.2. (raeburn 4329:): } elsif ($type eq 'exttool') {
4330:): $locknotfreed .=
4331:): &mt('This will prevent creation of additional external tools in this course.');
1.484.2.26 raeburn 4332: } else {
4333: $locknotfreed .=
1.484.2.42 raeburn 4334: &mt('This will prevent creation of additional discussion boards in this course.');
1.484.2.26 raeburn 4335: }
1.484.2.30 raeburn 4336: unless ($type eq 'paste') {
4337: $locknotfreed .=
1.484.2.38 raeburn 4338: ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
4339: '<a href="/adm/helpdesk" target="_helpdesk">','</a>');
1.484.2.30 raeburn 4340: }
4341: $locknotfreed .= '</div>';
1.484.2.15 raeburn 4342: }
4343: return ($suffix,$errtext,$locknotfreed);
4344: }
4345:
1.329 droeschl 4346: =pod
4347:
4348: =item tiehash()
4349:
4350: tie the hash
4351:
4352: =cut
4353:
4354: sub tiehash {
4355: my ($mode)=@_;
4356: $hashtied=0;
4357: if ($env{'request.course.fn'}) {
4358: if ($mode eq 'write') {
4359: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4360: &GDBM_WRCREAT(),0640)) {
4361: $hashtied=2;
4362: }
4363: } else {
4364: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4365: &GDBM_READER(),0640)) {
4366: $hashtied=1;
4367: }
4368: }
1.364 bisitz 4369: }
1.329 droeschl 4370: }
4371:
4372: sub untiehash {
4373: if ($hashtied) { untie %hash; }
4374: $hashtied=0;
4375: return OK;
4376: }
4377:
4378:
4379:
4380:
4381: sub checkonthis {
4382: my ($r,$url,$level,$title)=@_;
4383: $url=&unescape($url);
4384: $alreadyseen{$url}=1;
4385: $r->rflush();
4386: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
4387: $r->print("\n<br />");
4388: if ($level==0) {
4389: $r->print("<br />");
4390: }
4391: for (my $i=0;$i<=$level*5;$i++) {
4392: $r->print(' ');
4393: }
4394: $r->print('<a href="'.$url.'" target="cat">'.
4395: ($title?$title:$url).'</a> ');
4396: if ($url=~/^\/res\//) {
4397: my $result=&Apache::lonnet::repcopy(
4398: &Apache::lonnet::filelocation('',$url));
4399: if ($result eq 'ok') {
4400: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
4401: $r->rflush();
4402: &Apache::lonnet::countacc($url);
4403: $url=~/\.(\w+)$/;
4404: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
4405: $r->print('<br />');
4406: $r->rflush();
4407: for (my $i=0;$i<=$level*5;$i++) {
4408: $r->print(' ');
4409: }
4410: $r->print('- '.&mt('Rendering:').' ');
4411: my ($errorcount,$warningcount)=split(/:/,
4412: &Apache::lonnet::ssi_body($url,
4413: ('grade_target'=>'web',
4414: 'return_only_error_and_warning_counts' => 1)));
4415: if (($errorcount) ||
4416: ($warningcount)) {
4417: if ($errorcount) {
1.369 bisitz 4418: $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1.329 droeschl 4419: &mt('[quant,_1,error]',$errorcount).'</span>');
4420: }
4421: if ($warningcount) {
4422: $r->print('<span class="LC_warning">'.
4423: &mt('[quant,_1,warning]',$warningcount).'</span>');
4424: }
4425: } else {
4426: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
4427: }
4428: $r->rflush();
4429: }
4430: my $dependencies=
4431: &Apache::lonnet::metadata($url,'dependencies');
4432: foreach my $dep (split(/\,/,$dependencies)) {
4433: if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
4434: &checkonthis($r,$dep,$level+1);
4435: }
4436: }
4437: } elsif ($result eq 'unavailable') {
4438: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
4439: } elsif ($result eq 'not_found') {
4440: unless ($url=~/\$/) {
1.484.2.19 raeburn 4441: $r->print('<span class="LC_error">'.&mt('not found').'</span>');
1.329 droeschl 4442: } else {
1.366 bisitz 4443: $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1.329 droeschl 4444: }
4445: } else {
4446: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
4447: }
4448: }
4449: }
4450: }
4451:
4452:
4453:
4454: =pod
4455:
4456: =item list_symbs()
4457:
1.484.2.3 raeburn 4458: List Content Identifiers
1.329 droeschl 4459:
4460: =cut
4461:
4462: sub list_symbs {
4463: my ($r) = @_;
4464:
1.408 raeburn 4465: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 4466: $r->print(&Apache::loncommon::start_page('List of Content Identifiers'));
4467: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Identifiers'));
4468: $r->print(&startContentScreen('tools'));
1.329 droeschl 4469: my $navmap = Apache::lonnavmaps::navmap->new();
4470: if (!defined($navmap)) {
4471: $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
4472: '<div class="LC_error">'.
4473: &mt('Unable to retrieve information about course contents').
4474: '</div>');
1.408 raeburn 4475: &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
1.329 droeschl 4476: } else {
1.484 raeburn 4477: $r->print('<h4 class="LC_info">'.&mt("$crstype Content Identifiers").'</h4>'.
4478: &Apache::loncommon::start_data_table().
4479: &Apache::loncommon::start_data_table_header_row().
4480: '<th>'.&mt('Title').'</th><th>'.&mt('Identifier').'</th>'.
4481: &Apache::loncommon::end_data_table_header_row()."\n");
4482: my $count;
1.329 droeschl 4483: foreach my $res ($navmap->retrieveResources()) {
1.484 raeburn 4484: $r->print(&Apache::loncommon::start_data_table_row().
4485: '<td>'.$res->compTitle().'</td>'.
4486: '<td>'.$res->symb().'</td>'.
1.484.2.19 raeburn 4487: &Apache::loncommon::end_data_table_row());
1.484 raeburn 4488: $count ++;
4489: }
4490: if (!$count) {
4491: $r->print(&Apache::loncommon::start_data_table_row().
4492: '<td colspan="2">'.&mt("$crstype is empty").'</td>'.
4493: &Apache::loncommon::end_data_table_row());
1.329 droeschl 4494: }
1.484 raeburn 4495: $r->print(&Apache::loncommon::end_data_table());
1.329 droeschl 4496: }
1.484.2.19 raeburn 4497: $r->print(&endContentScreen());
1.329 droeschl 4498: }
4499:
1.484.2.72.2. (raeburn 4500:): sub short_urls {
4501:): my ($r,$canedit) = @_;
4502:): my $crstype = &Apache::loncommon::course_type();
4503:): my $formname = 'shortenurl';
4504:): $r->print(&Apache::loncommon::start_page('Display/Set Shortened URLs'));
4505:): $r->print(&Apache::lonhtmlcommon::breadcrumbs('Shortened URLs'));
4506:): $r->print(&startContentScreen('tools'));
4507:): my ($navmap,$errormsg) =
4508:): &Apache::loncourserespicker::get_navmap_object($crstype,'shorturls');
4509:): my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
4510:): my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4511:): my (%maps,%resources,%titles);
4512:): if (!ref($navmap)) {
4513:): $r->print($errormsg.
4514:): &endContentScreen());
4515:): return '';
4516:): } else {
4517:): $r->print('<h4 class="LC_info">'.&mt('Tiny URLs for deep-linking into course').'</h4>'."\n");
4518:): $r->rflush();
4519:): my $readonly;
4520:): if ($canedit) {
4521:): my ($numnew,$errors) = &Apache::loncommon::make_short_symbs($cdom,$cnum,$navmap);
4522:): if ($numnew) {
4523:): $r->print('<p class="LC_info">'.&mt('Created [quant,_1,URL]',$numnew).'</p>');
4524:): }
4525:): if ((ref($errors) eq 'ARRAY') && (@{$errors} > 0)) {
4526:): $r->print(&mt('The following errors occurred when processing your request to create shortened URLs:').'<br /><ul>');
4527:): foreach my $error (@{$errors}) {
4528:): $r->print('<li>'.$error.'</li>');
4529:): }
4530:): $r->print('</ul><br />');
4531:): }
4532:): } else {
4533:): $readonly = 1;
4534:): }
4535:): my %currtiny = &Apache::lonnet::dump('tiny',$cdom,$cnum);
4536:): $r->print(&Apache::loncourserespicker::create_picker($navmap,'shorturls',$formname,$crstype,undef,
4537:): undef,undef,undef,undef,undef,\%currtiny,$readonly));
4538:): }
4539:): $r->print(&endContentScreen());
4540:): }
1.329 droeschl 4541:
4542: sub verifycontent {
4543: my ($r) = @_;
1.408 raeburn 4544: my $crstype = &Apache::loncommon::course_type();
1.484.2.34 raeburn 4545: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
4546: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
1.484 raeburn 4547: $r->print(&startContentScreen('tools'));
4548: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
1.329 droeschl 4549: $hashtied=0;
4550: undef %alreadyseen;
4551: %alreadyseen=();
4552: &tiehash();
1.484 raeburn 4553:
1.329 droeschl 4554: foreach my $key (keys(%hash)) {
4555: if ($hash{$key}=~/\.(page|sequence)$/) {
4556: if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
4557: $r->print('<hr /><span class="LC_error">'.
1.419 bisitz 4558: &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
1.329 droeschl 4559: &unescape($hash{$key}).'</span><br />'.
1.419 bisitz 4560: &mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />');
1.329 droeschl 4561: }
4562: }
4563: if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
4564: &checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
4565: }
4566: }
4567: &untiehash();
1.442 www 4568: $r->print('<p class="LC_success">'.&mt('Done').'</p>');
1.484.2.19 raeburn 4569: $r->print(&endContentScreen());
1.329 droeschl 4570: }
4571:
4572:
4573: sub devalidateversioncache {
4574: my $src=shift;
4575: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
4576: &Apache::lonnet::clutter($src));
4577: }
4578:
4579: sub checkversions {
1.484.2.67 raeburn 4580: my ($r,$canedit) = @_;
1.408 raeburn 4581: my $crstype = &Apache::loncommon::course_type();
1.484.2.44 raeburn 4582: $r->print(&Apache::loncommon::start_page("Check $crstype Resource Versions"));
4583: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Resource Versions"));
1.484 raeburn 4584: $r->print(&startContentScreen('tools'));
1.442 www 4585:
1.329 droeschl 4586: my $header='';
4587: my $startsel='';
4588: my $monthsel='';
4589: my $weeksel='';
4590: my $daysel='';
4591: my $allsel='';
4592: my %changes=();
4593: my $starttime=0;
4594: my $haschanged=0;
4595: my %setversions=&Apache::lonnet::dump('resourceversions',
4596: $env{'course.'.$env{'request.course.id'}.'.domain'},
4597: $env{'course.'.$env{'request.course.id'}.'.num'});
4598:
4599: $hashtied=0;
4600: &tiehash();
1.484.2.67 raeburn 4601: if ($canedit) {
4602: my %newsetversions=();
4603: if ($env{'form.setmostrecent'}) {
4604: $haschanged=1;
4605: foreach my $key (keys(%hash)) {
4606: if ($key=~/^ids\_(\/res\/.+)$/) {
4607: $newsetversions{$1}='mostrecent';
4608: &devalidateversioncache($1);
4609: }
1.329 droeschl 4610: }
1.484.2.67 raeburn 4611: } elsif ($env{'form.setcurrent'}) {
4612: $haschanged=1;
4613: foreach my $key (keys(%hash)) {
4614: if ($key=~/^ids\_(\/res\/.+)$/) {
4615: my $getvers=&Apache::lonnet::getversion($1);
4616: if ($getvers>0) {
4617: $newsetversions{$1}=$getvers;
4618: &devalidateversioncache($1);
4619: }
4620: }
1.329 droeschl 4621: }
1.484.2.67 raeburn 4622: } elsif ($env{'form.setversions'}) {
4623: $haschanged=1;
4624: foreach my $key (keys(%env)) {
4625: if ($key=~/^form\.set_version_(.+)$/) {
4626: my $src=$1;
4627: if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
4628: $newsetversions{$src}=$env{$key};
4629: &devalidateversioncache($src);
4630: }
4631: }
1.329 droeschl 4632: }
1.484.2.67 raeburn 4633: }
4634: if ($haschanged) {
4635: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
4636: $env{'course.'.$env{'request.course.id'}.'.domain'},
4637: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
4638: $r->print(&Apache::loncommon::confirmwrapper(
4639: &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
4640: } else {
4641: $r->print(&Apache::loncommon::confirmwrapper(
4642: &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
4643: }
4644: &mark_hash_old();
4645: }
4646: &changewarning($r,'');
1.329 droeschl 4647: }
4648: if ($env{'form.timerange'} eq 'all') {
4649: # show all documents
1.484.2.34 raeburn 4650: $header=&mt('All content in '.$crstype);
1.484.2.19 raeburn 4651: $allsel=' selected="selected"';
1.329 droeschl 4652: foreach my $key (keys(%hash)) {
4653: if ($key=~/^ids\_(\/res\/.+)$/) {
4654: my $src=$1;
4655: $changes{$src}=1;
4656: }
4657: }
4658: } else {
4659: # show documents which changed
4660: %changes=&Apache::lonnet::dump
4661: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
4662: $env{'course.'.$env{'request.course.id'}.'.num'});
4663: my $firstkey=(keys(%changes))[0];
4664: unless ($firstkey=~/^error\:/) {
4665: unless ($env{'form.timerange'}) {
4666: $env{'form.timerange'}=604800;
4667: }
4668: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
4669: .&mt('seconds');
4670: if ($env{'form.timerange'}==-1) {
4671: $seltext='since start of course';
1.484.2.19 raeburn 4672: $startsel=' selected="selected"';
1.329 droeschl 4673: $env{'form.timerange'}=time;
4674: }
4675: $starttime=time-$env{'form.timerange'};
4676: if ($env{'form.timerange'}==2592000) {
4677: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 4678: $monthsel=' selected="selected"';
1.329 droeschl 4679: } elsif ($env{'form.timerange'}==604800) {
4680: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 4681: $weeksel=' selected="selected"';
1.329 droeschl 4682: } elsif ($env{'form.timerange'}==86400) {
4683: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 4684: $daysel=' selected="selected"';
1.329 droeschl 4685: }
4686: $header=&mt('Content changed').' '.$seltext;
4687: } else {
4688: $header=&mt('No content modifications yet.');
4689: }
4690: }
4691: %setversions=&Apache::lonnet::dump('resourceversions',
4692: $env{'course.'.$env{'request.course.id'}.'.domain'},
4693: $env{'course.'.$env{'request.course.id'}.'.num'});
4694: my %lt=&Apache::lonlocal::texthash
1.408 raeburn 4695: ('st' => 'Version changes since start of '.$crstype,
1.329 droeschl 4696: 'lm' => 'Version changes since last Month',
4697: 'lw' => 'Version changes since last Week',
4698: 'sy' => 'Version changes since Yesterday',
4699: 'al' => 'All Resources (possibly large output)',
1.484 raeburn 4700: 'cd' => 'Change display',
1.329 droeschl 4701: 'sd' => 'Display',
4702: 'fi' => 'File',
4703: 'md' => 'Modification Date',
4704: 'mr' => 'Most recently published Version',
1.408 raeburn 4705: 've' => 'Version used in '.$crstype,
4706: 'vu' => 'Set Version to be used in '.$crstype,
4707: 'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
1.329 droeschl 4708: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
4709: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.479 golterma 4710: 'di' => 'Differences',
1.484 raeburn 4711: 'save' => 'Save changes',
4712: 'vers' => 'Version choice(s) for specific resources',
1.479 golterma 4713: 'act' => 'Actions');
1.484.2.67 raeburn 4714: my ($disabled,$readonly);
4715: unless ($canedit) {
4716: $disabled = 'disabled="disabled"';
4717: $readonly = 1;
4718: }
1.329 droeschl 4719: $r->print(<<ENDHEADERS);
1.484 raeburn 4720: <h4 class="LC_info">$header</h4>
1.329 droeschl 4721: <form action="/adm/coursedocs" method="post">
4722: <input type="hidden" name="versions" value="1" />
1.484 raeburn 4723: <div class="LC_left_float">
1.479 golterma 4724: <fieldset>
1.484 raeburn 4725: <legend>$lt{'cd'}</legend>
1.329 droeschl 4726: <select name="timerange">
1.484.2.19 raeburn 4727: <option value='all'$allsel>$lt{'al'}</option>
4728: <option value="-1"$startsel>$lt{'st'}</option>
4729: <option value="2592000"$monthsel>$lt{'lm'}</option>
4730: <option value="604800"$weeksel>$lt{'lw'}</option>
4731: <option value="86400"$daysel>$lt{'sy'}</option>
1.329 droeschl 4732: </select>
4733: <input type="submit" name="display" value="$lt{'sd'}" />
1.484 raeburn 4734: </fieldset>
4735: </div>
4736: <div class="LC_left_float">
4737: <fieldset>
4738: <legend>$lt{'act'}</legend>
1.484.2.67 raeburn 4739: $lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" $disabled /><br />
4740: $lt{'sc'}: <input type="submit" name="setcurrent" value="Go" $disabled />
1.484 raeburn 4741: </fieldset>
4742: </div>
4743: <br clear="all" />
4744: <hr />
4745: <h4>$lt{'vers'}</h4>
1.329 droeschl 4746: ENDHEADERS
1.479 golterma 4747: #number of columns for version history
1.484.2.44 raeburn 4748: my %changedbytime;
4749: foreach my $key (keys(%changes)) {
4750: #excludes not versionable problems from resource version history:
4751: next if ($key =~ /^\/res\/lib\/templates/);
4752: my $chg;
4753: if ($env{'form.timerange'} eq 'all') {
4754: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
4755: $chg = &Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate');
4756: } else {
4757: $chg = $changes{$key};
4758: next if ($chg < $starttime);
4759: }
4760: push(@{$changedbytime{$chg}},$key);
4761: }
4762: if (keys(%changedbytime) == 0) {
4763: &untiehash();
4764: $r->print(&mt('No content changes in imported content in specified time frame').
4765: &endContentScreen());
4766: return;
4767: }
1.479 golterma 4768: $r->print(
1.484.2.67 raeburn 4769: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.484.2.19 raeburn 4770: &Apache::loncommon::start_data_table().
4771: &Apache::loncommon::start_data_table_header_row().
4772: '<th>'.&mt('Resources').'</th>'.
4773: "<th>$lt{'mr'}</th>".
4774: "<th>$lt{'ve'}</th>".
4775: "<th>$lt{'vu'}</th>".
4776: '<th>'.&mt('History').'</th>'.
4777: &Apache::loncommon::end_data_table_header_row()
4778: );
1.484.2.44 raeburn 4779: foreach my $chg (sort {$b <=> $a } keys(%changedbytime)) {
4780: foreach my $key (sort(@{$changedbytime{$chg}})) {
4781: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
4782: my $currentversion=&Apache::lonnet::getversion($key);
4783: if ($currentversion<0) {
4784: $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
4785: }
4786: my $linkurl=&Apache::lonnet::clutter($key);
4787: $r->print(
4788: &Apache::loncommon::start_data_table_row().
4789: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br />'.
4790: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
4791: '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br />('.
4792: &Apache::lonlocal::locallocaltime($chg).')</span></td>'.
4793: '<td align="right">'
4794: );
4795: # Used in course
4796: my $usedversion=$hash{'version_'.$linkurl};
4797: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.484.2.19 raeburn 4798: if ($usedversion != $currentversion) {
1.479 golterma 4799: $r->print('<span class="LC_warning">'.$usedversion.'</span>');
1.484.2.19 raeburn 4800: } else {
1.479 golterma 4801: $r->print($usedversion);
4802: }
1.329 droeschl 4803: } else {
1.484.2.19 raeburn 4804: $r->print($currentversion);
1.329 droeschl 4805: }
1.484.2.44 raeburn 4806: $r->print('</td><td title="'.$lt{'vu'}.'">');
4807: # Set version
4808: $r->print(&Apache::loncommon::select_form(
4809: $setversions{$linkurl},
4810: 'set_version_'.$linkurl,
4811: {'select_form_order' => ['',1..$currentversion,'mostrecent'],
4812: '' => '',
4813: 'mostrecent' => &mt('most recent'),
1.484.2.67 raeburn 4814: map {$_,$_} (1..$currentversion)},'',$readonly));
1.484.2.44 raeburn 4815: my $lastold=1;
4816: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
4817: my $url=$root.'.'.$prevvers.'.'.$extension;
4818: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) {
4819: $lastold=$prevvers;
4820: }
4821: }
4822: $r->print('</td>');
4823: # List all available versions
4824: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
4825: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
4826: my $url=$root.'.'.$prevvers.'.'.$extension;
1.484.2.19 raeburn 4827: $r->print(
1.484.2.44 raeburn 4828: '<span class="LC_nobreak">'
4829: .'<a href="'.&Apache::lonnet::clutter($url).'">'
4830: .&mt('Version [_1]',$prevvers).'</a>'
4831: .' ('.&Apache::lonlocal::locallocaltime(
4832: &Apache::lonnet::metadata($url,'lastrevisiondate'))
4833: .')');
4834: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
4835: $r->print(
4836: ' <a href="/adm/diff?filename='.
4837: &Apache::lonnet::clutter($root.'.'.$extension).
4838: &HTML::Entities::encode('&versionone='.$prevvers,'"<>&').
4839: '" target="diffs">'.&mt('Diffs').'</a>');
4840: }
4841: $r->print('</span><br />');
1.329 droeschl 4842: }
1.484.2.44 raeburn 4843: $r->print('</span></td>'.&Apache::loncommon::end_data_table_row());
1.484.2.19 raeburn 4844: }
1.329 droeschl 4845: }
1.484.2.19 raeburn 4846: $r->print(
4847: &Apache::loncommon::end_data_table().
1.484.2.67 raeburn 4848: '<input type="submit" name="setversions" value="'.$lt{'save'}.'"'.$disabled.' />'.
1.484.2.19 raeburn 4849: '</form>'
4850: );
1.329 droeschl 4851:
4852: &untiehash();
1.484.2.19 raeburn 4853: $r->print(&endContentScreen());
1.484.2.44 raeburn 4854: return;
1.329 droeschl 4855: }
4856:
4857: sub mark_hash_old {
4858: my $retie_hash=0;
4859: if ($hashtied) {
4860: $retie_hash=1;
4861: &untiehash();
4862: }
4863: &tiehash('write');
4864: $hash{'old'}=1;
4865: &untiehash();
4866: if ($retie_hash) { &tiehash(); }
4867: }
4868:
4869: sub is_hash_old {
4870: my $untie_hash=0;
4871: if (!$hashtied) {
4872: $untie_hash=1;
4873: &tiehash();
4874: }
4875: my $return=$hash{'old'};
4876: if ($untie_hash) { &untiehash(); }
4877: return $return;
4878: }
4879:
4880: sub changewarning {
4881: my ($r,$postexec,$message,$url)=@_;
4882: if (!&is_hash_old()) { return; }
4883: my $pathvar='folderpath';
4884: my $path=&escape($env{'form.folderpath'});
4885: if (!defined($url)) {
4886: $url='/adm/coursedocs?'.$pathvar.'='.$path;
4887: }
4888: my $course_type = &Apache::loncommon::course_type();
4889: if (!defined($message)) {
4890: $message='Changes will become active for your current session after [_1], or the next time you log in.';
4891: }
4892: $r->print("\n\n".
1.372 bisitz 4893: '<script type="text/javascript">'."\n".
4894: '// <![CDATA['."\n".
4895: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
4896: '// ]]>'."\n".
1.369 bisitz 4897: '</script>'."\n".
1.375 tempelho 4898: '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
1.329 droeschl 4899: '<input type="hidden" name="orgurl" value="'.$url.
1.372 bisitz 4900: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
1.329 droeschl 4901: &mt($message,' <input type="hidden" name="'.
4902: $env{'request.role'}.'" value="1" /><input type="button" value="'.
1.369 bisitz 4903: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1.372 bisitz 4904: $help{'Caching'}.'</p></form>'."\n\n");
1.329 droeschl 4905: }
4906:
4907:
4908: sub init_breadcrumbs {
1.484.2.44 raeburn 4909: my ($form,$text,$help)=@_;
1.329 droeschl 4910: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484 raeburn 4911: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
1.405 bisitz 4912: text=>&Apache::loncommon::course_type().' Editor',
1.329 droeschl 4913: faq=>273,
4914: bug=>'Instructor Interface',
1.484.2.44 raeburn 4915: help => $help});
1.329 droeschl 4916: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
4917: text=>$text,
4918: faq=>273,
4919: bug=>'Instructor Interface'});
4920: }
4921:
1.441 www 4922: # subroutine to list form elements
4923: sub create_list_elements {
4924: my @formarr = @_;
4925: my $list = '';
1.484.2.12 raeburn 4926: foreach my $button (@formarr){
4927: foreach my $picture (keys(%{$button})) {
4928: $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
1.441 www 4929: }
4930: }
4931: return $list;
4932: }
1.329 droeschl 4933:
1.441 www 4934: # subroutine to create ul from list elements
4935: sub create_form_ul {
4936: my $list = shift;
4937: my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
4938: return $ul;
4939: }
1.329 droeschl 4940:
1.442 www 4941: #
4942: # Start tabs
4943: #
4944:
4945: sub startContentScreen {
1.484 raeburn 4946: my ($mode) = @_;
4947: my $output = '<ul class="LC_TabContentBigger" id="mainnav">';
1.472 raeburn 4948: if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
1.484 raeburn 4949: $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n";
4950: $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n";
4951: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
4952: } else {
1.484.2.34 raeburn 4953: $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 4954: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
4955: $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>'."\n";
4956: '><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>';
4957: }
4958: $output .= "\n".'</ul>'."\n";
4959: $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
4960: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
4961: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
4962: return $output;
1.442 www 4963: }
4964:
4965: #
4966: # End tabs
4967: #
4968:
4969: sub endContentScreen {
1.484 raeburn 4970: return '</div></div></div>';
1.442 www 4971: }
1.329 droeschl 4972:
1.446 www 4973: sub supplemental_base {
1.484.2.33 raeburn 4974: return 'supplemental&'.&escape(&mt('Supplemental Content'));
1.446 www 4975: }
4976:
1.329 droeschl 4977: sub handler {
4978: my $r = shift;
4979: &Apache::loncommon::content_type($r,'text/html');
4980: $r->send_http_header;
4981: return OK if $r->header_only;
1.484 raeburn 4982:
4983: # get course data
1.408 raeburn 4984: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 4985: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
4986: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
4987:
4988: # graphics settings
4989: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329 droeschl 4990:
1.443 www 4991: #
1.329 droeschl 4992: # --------------------------------------------- Initialize help topics for this
4993: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
1.484.2.72.2. (raeburn 4994:): 'Adding_External_Resource','Adding_External_Tool',
4995:): 'Navigate_Content','Adding_Folders','Docs_Overview',
4996:): 'Load_Map','Supplemental','Score_Upload_Form',
4997:): 'Adding_Pages','Importing_LON-CAPA_Resource',
4998:): 'Importing_IMS_Course','Uploading_From_Harddrive',
4999:): 'Course_Roster','Web_Page','Dropbox','Simple_Problem') {
1.329 droeschl 5000: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
5001: }
5002: # Composite help files
5003: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
5004: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
5005: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
5006: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
5007: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
5008: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 5009: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 5010: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 5011: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 5012: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1.484.2.30 raeburn 5013:
1.484.2.67 raeburn 5014: my ($allowed,$canedit,$canview,$disabled);
1.472 raeburn 5015: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
5016: unless ($r->uri eq '/adm/supplemental') {
5017: # does this user have privileges to modify content.
1.484.2.67 raeburn 5018: if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
5019: $allowed = 1;
5020: $canedit = 1;
5021: $canview = 1;
5022: } elsif (&Apache::lonnet::allowed('cev',$env{'request.course.id'})) {
5023: $allowed = 1;
5024: $canview = 1;
5025: }
5026: }
5027: unless ($canedit) {
5028: $disabled = ' disabled="disabled"';
1.472 raeburn 5029: }
1.484.2.53 raeburn 5030: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']);
1.484.2.72.2. (raeburn 5031:): if ($env{'form.inhibitmenu'}) {
5032:): unless ($env{'form.inhibitmenu'} eq 'yes') {
5033:): delete($env{'form.inhibitmenu'});
5034:): }
5035:): }
1.484.2.53 raeburn 5036: if ($allowed && $env{'form.verify'}) {
1.484.2.44 raeburn 5037: &init_breadcrumbs('verify','Verify Content','Docs_Verify_Content');
1.329 droeschl 5038: &verifycontent($r);
5039: } elsif ($allowed && $env{'form.listsymbs'}) {
1.484 raeburn 5040: &init_breadcrumbs('listsymbs','List Content IDs');
1.329 droeschl 5041: &list_symbs($r);
1.484.2.72.2. (raeburn 5042:): } elsif ($allowed && $env{'form.shorturls'}) {
5043:): &init_breadcrumbs('shorturls','Set/Display Shortened URLs','Docs_Short_URLs');
5044:): &short_urls($r,$canedit);
1.329 droeschl 5045: } elsif ($allowed && $env{'form.docslog'}) {
5046: &init_breadcrumbs('docslog','Show Log');
1.484 raeburn 5047: my $folder = $env{'form.folder'};
5048: if ($folder eq '') {
5049: $folder='default';
5050: }
1.484.2.67 raeburn 5051: &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath,$canedit);
1.329 droeschl 5052: } elsif ($allowed && $env{'form.versions'}) {
1.484.2.44 raeburn 5053: &init_breadcrumbs('versions','Check/Set Resource Versions','Docs_Check_Resource_Versions');
1.484.2.67 raeburn 5054: &checkversions($r,$canedit);
5055: } elsif ($canedit && $env{'form.dumpcourse'}) {
1.484.2.43 raeburn 5056: &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329 droeschl 5057: &dumpcourse($r);
5058: } elsif ($allowed && $env{'form.exportcourse'}) {
1.377 bisitz 5059: &init_breadcrumbs('exportcourse','IMS Export');
1.475 raeburn 5060: &Apache::imsexport::exportcourse($r);
1.329 droeschl 5061: } else {
1.445 www 5062: #
5063: # Done catching special calls
1.484 raeburn 5064: # The whole rest is for course and supplemental documents and utilities menu
1.445 www 5065: # Get the parameters that may be needed
5066: #
5067: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.484.2.19 raeburn 5068: ['folderpath',
5069: 'forcesupplement','forcestandard',
5070: 'tools','symb','command','supppath']);
1.445 www 5071:
1.484.2.72.2. (raeburn 5072:): foreach my $item ('forcesupplement','forcestandard','tools') {
5073:): next if ($env{'form.'.$item} eq '');
5074:): unless ($env{'form.'.$item} eq '1') {
5075:): delete($env{'form.'.$item});
5076:): }
5077:): }
5078:):
5079:): if ($env{'form.command'}) {
5080:): unless ($env{'form.command'} =~ /^(direct|directnav|editdocs|editsupp|contents|home)$/) {
5081:): delete($env{'form.command'});
5082:): }
5083:): }
5084:):
5085:): if ($env{'form.symb'}) {
5086:): my ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.symb'});
5087:): unless (($id =~ /^\d+$/) && (&Apache::lonnet::is_on_map($resurl))) {
5088:): delete($env{'form.symb'});
5089:): }
5090:): }
1.445 www 5091: # standard=1: this is a "new-style" course with an uploaded map as top level
5092: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329 droeschl 5093:
5094: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445 www 5095:
1.484 raeburn 5096: # Decide whether this should display supplemental or main content or utilities
1.445 www 5097: # supplementalflag=1: show supplemental documents
5098: # supplementalflag=0: show standard documents
1.484 raeburn 5099: # toolsflag=1: show utilities
1.445 www 5100:
1.484.2.39 raeburn 5101: my $unesc_folderpath = &unescape($env{'form.folderpath'});
5102: my $supplementalflag=($unesc_folderpath=~/^supplemental/);
5103: if (($unesc_folderpath=~/^default/) || ($unesc_folderpath eq "")) {
1.445 www 5104: $supplementalflag=0;
5105: }
5106: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
5107: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
5108: unless ($allowed) { $supplementalflag=1; }
5109: unless ($standard) { $supplementalflag=1; }
1.484 raeburn 5110: my $toolsflag=0;
5111: if ($env{'form.tools'}) { $toolsflag=1; }
1.445 www 5112:
1.484.2.72.2. (raeburn 5113:): if ($env{'form.folderpath'} ne '') {
5114:): my @items = split(/\&/,$env{'form.folderpath'});
5115:): my $badpath;
5116:): for (my $i=0; $i<@items; $i++) {
5117:): my $odd = $i%2;
5118:): if (($odd) && (!$supplementalflag) && ($items[$i] !~ /^[^:]*:(|\d+):(|1):(|1):(|1):(|1)$/)) {
5119:): $badpath = 1;
5120:): } elsif ((!$odd) && ($items[$i] !~ /^(default|supplemental)(|_\d+)$/)) {
5121:): $badpath = 1;
5122:): }
5123:): last if ($badpath);
5124:): }
5125:): if ($badpath) {
5126:): delete($env{'form.folderpath'});
5127:): }
5128:): }
5129:):
5130:): if ($env{'form.supppath'} ne '') {
5131:): my @items = split(/\&/,$env{'form.supppath'});
5132:): my $badpath;
5133:): for (my $i=0; $i<@items; $i++) {
5134:): my $odd = $i%2;
5135:): if ((!$odd) && ($items[$i] !~ /^supplemental(|_\d+)$/)) {
5136:): $badpath = 1;
5137:): }
5138:): last if ($badpath);
5139:): }
5140:): if ($badpath) {
5141:): delete($env{'form.supppath'});
5142:): }
5143:): }
5144:):
1.329 droeschl 5145: my $script='';
5146: my $showdoc=0;
1.457 raeburn 5147: my $addentries = {};
1.475 raeburn 5148: my $container;
1.329 droeschl 5149: my $containertag;
1.484.2.17 raeburn 5150: my $pathitem;
1.484.2.72.2. (raeburn 5151:): my %ltitools;
1.484.2.67 raeburn 5152: my $hiddentop;
5153: my $navmap;
5154: my $filterFunc = sub { my $res = shift; return (!$res->randomout() && !$res->is_map()) };
1.329 droeschl 5155:
1.464 www 5156: # Do we directly jump somewhere?
1.484.2.21 raeburn 5157: if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
1.472 raeburn 5158: if ($env{'form.symb'} ne '') {
1.484.2.19 raeburn 5159: $env{'form.folderpath'}=
1.484.2.67 raeburn 5160: &Apache::loncommon::symb_to_docspath($env{'form.symb'},\$navmap);
1.484.2.21 raeburn 5161: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
5162: $env{'form.command'}.'_'.$env{'form.symb'}});
1.472 raeburn 5163: } elsif ($env{'form.supppath'} ne '') {
5164: $env{'form.folderpath'}=$env{'form.supppath'};
1.484.2.21 raeburn 5165: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
5166: $env{'form.command'}.'_'.$env{'form.supppath'}});
1.466 www 5167: }
1.472 raeburn 5168: } elsif ($env{'form.command'} eq 'editdocs') {
1.484.2.67 raeburn 5169: $env{'form.folderpath'} = &default_folderpath($coursenum,$coursedom,\$navmap);
1.484.2.21 raeburn 5170: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
1.472 raeburn 5171: } elsif ($env{'form.command'} eq 'editsupp') {
1.484.2.67 raeburn 5172: $env{'form.folderpath'} = &supplemental_base();
1.484.2.21 raeburn 5173: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
5174: } elsif ($env{'form.command'} eq 'contents') {
5175: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
5176: } elsif ($env{'form.command'} eq 'home') {
5177: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
1.464 www 5178: }
5179:
1.484.2.23 raeburn 5180:
1.445 www 5181: # Where do we store these for when we come back?
5182: my $stored_folderpath='docs_folderpath';
5183: if ($supplementalflag) {
5184: $stored_folderpath='docs_sup_folderpath';
5185: }
1.464 www 5186:
1.484.2.19 raeburn 5187: # No folderpath, and in edit mode, see if we have something stored
5188: if ((!$env{'form.folderpath'}) && $allowed) {
1.445 www 5189: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.484.2.19 raeburn 5190: {'folderpath' => 'scalar'});
1.484.2.67 raeburn 5191:
5192: if (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
5193: if ($supplementalflag) {
5194: undef($env{'form.folderpath'}) if ($1 eq 'default');
5195: } else {
5196: undef($env{'form.folderpath'}) if ($1 eq 'supplemental');
5197: }
5198: } else {
1.484.2.19 raeburn 5199: undef($env{'form.folderpath'});
5200: }
1.329 droeschl 5201: }
1.446 www 5202:
5203: # If we are not allowed to make changes, all we can see are supplemental docs
1.409 raeburn 5204: if (!$allowed) {
1.446 www 5205: unless ($env{'form.folderpath'} =~ /^supplemental/) {
5206: $env{'form.folderpath'} = &supplemental_base();
1.409 raeburn 5207: }
5208: }
1.446 www 5209: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329 droeschl 5210: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446 www 5211: $env{'form.folderpath'} = &supplemental_base()
5212: .'&'.
1.329 droeschl 5213: $env{'form.folderpath'};
5214: }
1.484.2.67 raeburn 5215: # If allowed and user's role is not advanced check folderpath is not hidden
5216: if (($allowed) && (!$env{'request.role.adv'}) &&
5217: ($env{'form.folderpath'} ne '') && (!$supplementalflag)) {
5218: my $folderurl;
5219: my @pathitems = split(/\&/,$env{'form.folderpath'});
5220: my $folder = $pathitems[-2];
5221: if ($folder eq '') {
5222: undef($env{'form.folderpath'});
5223: } else {
5224: $folderurl = "uploaded/$coursedom/$coursenum/$folder";
5225: if ((split(/\:/,$pathitems[-1]))[4]) {
5226: $folderurl .= '.page';
5227: } else {
5228: $folderurl .= '.sequence';
5229: }
5230: unless (ref($navmap)) {
5231: $navmap = Apache::lonnavmaps::navmap->new();
5232: }
5233: if (ref($navmap)) {
5234: if (lc($navmap->get_mapparam(undef,$folderurl,"0.hiddenresource")) eq 'yes') {
5235: my @resources = $navmap->retrieveResources($folderurl,$filterFunc,1,1);
5236: unless (@resources) {
5237: undef($env{'form.folderpath'});
5238: }
5239: }
5240: }
5241: }
5242: }
5243:
5244:
1.446 www 5245: # If after all of this, we still don't have any paths, make them
1.484.2.19 raeburn 5246: unless ($env{'form.folderpath'}) {
1.446 www 5247: if ($supplementalflag) {
5248: $env{'form.folderpath'}=&supplemental_base();
1.484.2.67 raeburn 5249: } elsif ($allowed) {
5250: ($env{'form.folderpath'},$hiddentop) = &default_folderpath($coursenum,$coursedom,\$navmap);
1.446 www 5251: }
1.472 raeburn 5252: }
1.446 www 5253:
1.445 www 5254: # Store this
1.484 raeburn 5255: unless ($toolsflag) {
1.484.2.67 raeburn 5256: if (($allowed) && ($env{'form.folderpath'} ne '')) {
1.484.2.19 raeburn 5257: &Apache::loncommon::store_course_settings($stored_folderpath,
5258: {'folderpath' => 'scalar'});
5259: }
5260: my $folderpath;
1.484 raeburn 5261: if ($env{'form.folderpath'}) {
1.484.2.19 raeburn 5262: $folderpath = $env{'form.folderpath'};
5263: my (@folders)=split('&',$env{'form.folderpath'});
5264: $env{'form.foldername'}=&unescape(pop(@folders));
5265: if ($env{'form.foldername'} =~ /\:1$/) {
5266: $container = 'page';
5267: } else {
5268: $container = 'sequence';
5269: }
5270: $env{'form.folder'}=pop(@folders);
1.484 raeburn 5271: } else {
1.484.2.19 raeburn 5272: if ($env{'form.folder'} eq '' ||
5273: $env{'form.folder'} eq 'supplemental') {
1.484.2.67 raeburn 5274: if ($env{'form.folder'} eq 'supplemental') {
5275: $folderpath=&supplemental_base();
5276: } elsif (!$hiddentop) {
5277: $folderpath='default&'.
5278: &escape(&mt('Main Content').':::::');
5279: }
1.484 raeburn 5280: }
5281: }
1.484.2.19 raeburn 5282: $containertag = '<input type="hidden" name="folderpath" value="" />';
5283: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 5284: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
5285: $showdoc='/'.$1;
5286: }
5287: if ($showdoc) { # got called in sequence from course
5288: $allowed=0;
5289: } else {
1.484.2.67 raeburn 5290: if ($canedit) {
1.484 raeburn 5291: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
5292: $script=&Apache::lonratedt::editscript('simple');
1.433 raeburn 5293: }
5294: }
1.329 droeschl 5295: }
5296:
1.344 bisitz 5297: # get personal data
1.329 droeschl 5298: my $uname=$env{'user.name'};
5299: my $udom=$env{'user.domain'};
5300: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
5301:
5302: if ($allowed) {
1.484 raeburn 5303: if ($toolsflag) {
5304: $script .= &inject_data_js();
5305: my ($home,$other,%outhash)=&authorhosts();
5306: if (!$home && $other) {
5307: my @hosts;
5308: foreach my $aurole (keys(%outhash)) {
5309: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
5310: push(@hosts,$outhash{$aurole});
5311: }
5312: }
5313: $script .= &dump_switchserver_js(@hosts);
5314: }
1.458 raeburn 5315: } else {
1.484.2.43 raeburn 5316: my $tid = 1;
1.484 raeburn 5317: my @tabids;
5318: if ($supplementalflag) {
5319: @tabids = ('002','ee2','ff2');
1.484.2.43 raeburn 5320: $tid = 2;
1.484 raeburn 5321: } else {
5322: @tabids = ('aa1','bb1','cc1','ff1');
1.484.2.19 raeburn 5323: unless ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 5324: unshift(@tabids,'001');
5325: push(@tabids,('dd1','ee1'));
5326: }
1.458 raeburn 5327: }
1.484 raeburn 5328: my $tabidstr = join("','",@tabids);
1.484.2.72.2. (raeburn 5329:): %ltitools = &Apache::lonnet::get_domain_ltitools($coursedom);
5330:): my $posslti = keys(%ltitools);
5331:): $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
1.484.2.67 raeburn 5332: $canedit,\$navmap).
1.484 raeburn 5333: &history_tab_js().
5334: &inject_data_js().
1.484.2.43 raeburn 5335: &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
1.484.2.72.2. (raeburn 5336:): &Apache::lonextresedit::extedit_javascript(\%ltitools);
1.484 raeburn 5337: $addentries = {
1.484.2.3 raeburn 5338: onload => "javascript:resize_scrollbox('contentscroll','1','1');",
1.484 raeburn 5339: };
1.458 raeburn 5340: }
1.484.2.30 raeburn 5341: $script .= &paste_popup_js();
1.484.2.12 raeburn 5342: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
5343: &mt('Switch server?');
1.484.2.19 raeburn 5344:
5345:
1.329 droeschl 5346: }
5347: # -------------------------------------------------------------------- Body tag
1.369 bisitz 5348: $script = '<script type="text/javascript">'."\n"
1.372 bisitz 5349: .'// <![CDATA['."\n"
5350: .$script."\n"
5351: .'// ]]>'."\n"
5352: .'</script>'."\n";
1.385 bisitz 5353:
5354: # Breadcrumbs
5355: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484.2.19 raeburn 5356:
5357: if ($showdoc) {
5358: $r->print(&Apache::loncommon::start_page("$crstype documents",undef,
5359: {'force_register' => $showdoc,}));
1.484.2.44 raeburn 5360: } elsif ($toolsflag) {
1.484.2.67 raeburn 5361: my ($breadtext,$breadtitle);
5362: $breadtext = "$crstype Editor";
5363: if ($canedit) {
5364: $breadtitle = 'Editing '.$crstype.' Contents';
5365: } else {
5366: $breadtext .= ' (View-only mode)';
5367: $breadtitle = 'Viewing '.$crstype.' Contents';
5368: }
1.484.2.44 raeburn 5369: &Apache::lonhtmlcommon::add_breadcrumb({
1.484.2.67 raeburn 5370: href=>"/adm/coursedocs",text=>$breadtext});
1.484.2.44 raeburn 5371: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script)
5372: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5373: .&Apache::lonhtmlcommon::breadcrumbs(
1.484.2.67 raeburn 5374: $breadtitle)
1.484.2.44 raeburn 5375: );
1.484.2.19 raeburn 5376: } elsif ($r->uri eq '/adm/supplemental') {
5377: my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
5378: $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
5379: {'bread_crumbs' => $brcrum,}));
5380: } else {
1.484.2.67 raeburn 5381: my ($breadtext,$breadtitle,$helpitem);
5382: $breadtext = "$crstype Editor";
5383: if ($canedit) {
5384: $breadtitle = 'Editing '.$crstype.' Contents';
5385: $helpitem = 'Docs_Adding_Course_Doc';
5386: } else {
5387: $breadtext .= ' (View-only mode)';
5388: $breadtitle = 'Viewing '.$crstype.' Contents';
5389: $helpitem = 'Docs_Viewing_Course_Doc';
5390: }
1.392 raeburn 5391: &Apache::lonhtmlcommon::add_breadcrumb({
1.484.2.67 raeburn 5392: href=>"/adm/coursedocs",text=>$breadtext});
1.446 www 5393: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.484.2.19 raeburn 5394: {'add_entries' => $addentries}
5395: )
1.392 raeburn 5396: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5397: .&Apache::lonhtmlcommon::breadcrumbs(
1.484.2.67 raeburn 5398: $breadtitle,
5399: $helpitem)
1.392 raeburn 5400: );
5401: }
1.364 bisitz 5402:
1.329 droeschl 5403: my %allfiles = ();
5404: my %codebase = ();
1.440 raeburn 5405: my ($upload_result,$upload_output,$uploadphase);
1.484.2.67 raeburn 5406: if ($canedit) {
1.329 droeschl 5407: if (($env{'form.uploaddoc.filename'}) &&
5408: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440 raeburn 5409: my $context = $1;
5410: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 5411: undef($hadchanges);
1.440 raeburn 5412: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
1.484.2.36 raeburn 5413: \%allfiles,\%codebase,$context,$crstype);
1.484.2.72.2. (raeburn 5414:): undef($navmap);
1.329 droeschl 5415: if ($hadchanges) {
5416: &mark_hash_old();
5417: }
1.440 raeburn 5418: $r->print($upload_output);
5419: } elsif ($env{'form.phase'} eq 'upload_embedded') {
5420: # Process file upload - phase two - upload embedded objects
5421: $uploadphase = 'check_embedded';
5422: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
5423: my $state = &embedded_form_elems($uploadphase,$primaryurl,
5424: $env{'form.newidx'});
5425: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5426: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5427: my ($destination,$dir_root) = &embedded_destination();
5428: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
5429: my $actionurl = '/adm/coursedocs';
5430: my ($result,$flag) =
5431: &Apache::loncommon::upload_embedded('coursedoc',$destination,
5432: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
5433: $actionurl);
5434: $r->print($result.&return_to_editor());
5435: } elsif ($env{'form.phase'} eq 'check_embedded') {
5436: # Process file upload - phase three - modify references in HTML file
5437: $uploadphase = 'modified_orightml';
5438: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5439: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5440: my ($destination,$dir_root) = &embedded_destination();
1.482 raeburn 5441: my $result =
5442: &Apache::loncommon::modify_html_refs('coursedoc',$destination,
5443: $docuname,$docudom,undef,
5444: $dir_root);
5445: $r->print($result.&return_to_editor());
1.476 raeburn 5446: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
5447: $uploadphase = 'decompress_phase_one';
5448: $r->print(&decompression_phase_one().
5449: &return_to_editor());
5450: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
5451: $uploadphase = 'decompress_phase_two';
5452: $r->print(&decompression_phase_two().
5453: &return_to_editor());
1.329 droeschl 5454: }
5455: }
5456:
1.484 raeburn 5457: if ($allowed && $toolsflag) {
5458: $r->print(&startContentScreen('tools'));
1.484.2.67 raeburn 5459: $r->print(&generate_admin_menu($crstype,$canedit));
1.484 raeburn 5460: $r->print(&endContentScreen());
5461: } elsif ((!$showdoc) && (!$uploadphase)) {
1.329 droeschl 5462: # -----------------------------------------------------------------------------
5463: my %lt=&Apache::lonlocal::texthash(
5464: 'copm' => 'All documents out of a published map into this folder',
1.484.2.12 raeburn 5465: 'upfi' => 'Upload File',
1.484.2.36 raeburn 5466: 'upld' => 'Upload Content',
1.329 droeschl 5467: 'srch' => 'Search',
5468: 'impo' => 'Import',
1.484.2.19 raeburn 5469: 'lnks' => 'Import from Stored Links',
1.484.2.13 raeburn 5470: 'impm' => 'Import from Assembled Map',
1.484.2.72.2. (raeburn 5471:): 'extr' => 'External Resource',
5472:): 'extt' => 'External Tool',
1.329 droeschl 5473: 'selm' => 'Select Map',
5474: 'load' => 'Load Map',
5475: 'newf' => 'New Folder',
5476: 'newp' => 'New Composite Page',
5477: 'syll' => 'Syllabus',
1.425 raeburn 5478: 'navc' => 'Table of Contents',
1.343 biermanm 5479: 'sipa' => 'Simple Course Page',
1.329 droeschl 5480: 'sipr' => 'Simple Problem',
1.484.2.27 raeburn 5481: 'webp' => 'Blank Web Page (editable)',
1.329 droeschl 5482: 'drbx' => 'Drop Box',
1.451 www 5483: 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336 schafran 5484: 'bull' => 'Discussion Board',
1.347 weissno 5485: 'mypi' => 'My Personal Information Page',
1.353 weissno 5486: 'grpo' => 'Group Portfolio',
1.329 droeschl 5487: 'rost' => 'Course Roster',
1.484.2.22 raeburn 5488: 'abou' => 'Personal Information Page for a User',
1.484.2.36 raeburn 5489: 'imsf' => 'IMS Upload',
5490: 'imsl' => 'Upload IMS package',
1.484.2.12 raeburn 5491: 'cms' => 'Origin of IMS package',
5492: 'se' => 'Select',
1.484.2.19 raeburn 5493: 'file' => 'File',
1.329 droeschl 5494: 'title' => 'Title',
5495: 'comment' => 'Comment',
1.403 raeburn 5496: 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.484.2.50 raeburn 5497: 'bb5' => 'Blackboard 5',
5498: 'bb6' => 'Blackboard 6',
5499: 'angel5' => 'ANGEL 5.5',
5500: 'webctce4' => 'WebCT 4 Campus Edition',
1.484.2.67 raeburn 5501: 'er' => 'Editing rights unavailable for your current role.',
1.484.2.50 raeburn 5502: );
1.329 droeschl 5503: # -----------------------------------------------------------------------------
1.484.2.64 raeburn 5504: # Calculate free quota space for a user or course.
5505: my $quotatype = 'unofficial';
5506: if ($crstype eq 'Community') {
5507: $quotatype = 'community';
5508: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
5509: $quotatype = 'official';
5510: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
5511: $quotatype = 'textbook';
5512: }
5513: my $disk_quota = &Apache::loncommon::get_user_quota($coursenum,$coursedom,
5514: 'course',$quotatype); # expressed in MB
5515: my $current_disk_usage = 0;
5516: foreach my $subdir ('docs','supplemental') {
5517: $current_disk_usage += &Apache::lonnet::diskusage($coursedom,$coursenum,
5518: "userfiles/$subdir",1); # expressed in kB
5519: }
5520: my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage);
5521: my $usage = $current_disk_usage/1024; # in MB
5522: my $quota = $disk_quota;
5523: my $percent;
5524: if ($disk_quota == 0) {
5525: $percent = 100.0;
5526: } else {
1.484.2.69 raeburn 5527: $percent = 100*($usage/$disk_quota);
1.484.2.64 raeburn 5528: }
5529: $usage = sprintf("%.2f",$usage);
5530: $quota = sprintf("%.2f",$quota);
5531: $percent = sprintf("%.0f",$percent);
5532: my $quotainfo = '<p>'.&mt('Currently using [_1] of the [_2] available.',
5533: $percent.'%',$quota.' MB').'</p>';
5534:
1.329 droeschl 5535: my $fileupload=(<<FIUP);
1.484.2.64 raeburn 5536: $quotainfo
1.329 droeschl 5537: $lt{'file'}:<br />
1.484.2.67 raeburn 5538: <input type="file" name="uploaddoc" size="40" $disabled />
1.329 droeschl 5539: FIUP
5540:
5541: my $checkbox=(<<CHBO);
5542: <!-- <label>$lt{'parse'}?
5543: <input type="checkbox" name="parserflag" />
5544: </label> -->
5545: <label>
1.484.2.67 raeburn 5546: <input type="checkbox" name="parserflag" checked="checked" $disabled /> $lt{'parse'}
1.329 droeschl 5547: </label>
5548: CHBO
1.484.2.12 raeburn 5549: my $imsfolder = $env{'form.folder'};
5550: if ($imsfolder eq '') {
1.484.2.19 raeburn 5551: $imsfolder = 'default';
1.484.2.12 raeburn 5552: }
5553: my $imspform=(<<IMSFORM);
5554: <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
5555: $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
5556: <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
1.484.2.19 raeburn 5557: <fieldset id="uploadimsform" style="display: none;">
1.484.2.12 raeburn 5558: <legend>$lt{'imsf'}</legend>
5559: $fileupload
5560: <br />
5561: <p>
1.484.2.19 raeburn 5562: $lt{'cms'}:
1.484.2.67 raeburn 5563: <select name="source" $disabled>
1.484.2.12 raeburn 5564: <option value="-1" selected="selected">$lt{'se'}</option>
1.484.2.50 raeburn 5565: <option value="bb5">$lt{'bb5'}</option>
5566: <option value="bb6">$lt{'bb6'}</option>
5567: <option value="angel5">$lt{'angel5'}</option>
5568: <option value="webctce4">$lt{'webctce4'}</option>
1.484.2.12 raeburn 5569: </select>
5570: <input type="hidden" name="folder" value="$imsfolder" />
5571: </p>
5572: <input type="hidden" name="phase" value="one" />
1.484.2.67 raeburn 5573: <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" $disabled />
1.484.2.12 raeburn 5574: </fieldset>
5575: </form>
5576: IMSFORM
5577:
1.484.2.19 raeburn 5578: my $fileuploadform=(<<FUFORM);
1.484.2.12 raeburn 5579: <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
5580: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
5581: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.484.2.19 raeburn 5582: <fieldset id="uploaddocform" style="display: none;">
1.484.2.12 raeburn 5583: <legend>$lt{'upfi'}</legend>
1.371 tempelho 5584: <input type="hidden" name="active" value="aa" />
1.329 droeschl 5585: $fileupload
5586: <br />
5587: $lt{'title'}:<br />
1.484.2.67 raeburn 5588: <input type="text" size="60" name="comment" $disabled />
1.484.2.17 raeburn 5589: $pathitem
1.329 droeschl 5590: <input type="hidden" name="cmd" value="upload_default" />
5591: <br />
1.458 raeburn 5592: <span class="LC_nobreak" style="float:left">
1.329 droeschl 5593: $checkbox
5594: </span>
1.484.2.12 raeburn 5595: <br clear="all" />
1.484.2.67 raeburn 5596: <input type="submit" value="$lt{'upld'}" $disabled />
1.484.2.12 raeburn 5597: </fieldset>
5598: </form>
1.383 tempelho 5599: FUFORM
1.329 droeschl 5600:
1.484.2.67 raeburn 5601: my $mapimportjs;
5602: if ($canedit) {
5603: $mapimportjs = "javascript:openbrowser('mapimportform','importmap','sequence,page','');";
5604: } else {
5605: $mapimportjs = "javascript:alert('".&js_escape($lt{'er'})."');";
5606: }
1.484.2.19 raeburn 5607: my $importpubform=(<<SEDFFORM);
5608: <a class="LC_menubuttons_link" href="javascript:toggleMap('map');">
1.484.2.13 raeburn 5609: $lt{'impm'}</a>$help{'Load_Map'}
1.484.2.19 raeburn 5610: <form action="/adm/coursedocs" method="post" name="mapimportform">
5611: <fieldset id="importmapform" style="display: none;">
1.484.2.13 raeburn 5612: <legend>$lt{'impm'}</legend>
1.484.2.19 raeburn 5613: <input type="hidden" name="active" value="bb" />
1.484.2.13 raeburn 5614: $lt{'copm'}<br />
5615: <span class="LC_nobreak">
1.484.2.19 raeburn 5616: <input type="text" name="importmap" size="40" value=""
1.484.2.67 raeburn 5617: onfocus="this.blur();$mapimportjs" $disabled />
5618: <a href="$mapimportjs">$lt{'selm'}</a></span><br />
5619: <input type="submit" name="loadmap" value="$lt{'load'}" $disabled />
1.484.2.13 raeburn 5620: </fieldset>
5621: </form>
5622:
1.383 tempelho 5623: SEDFFORM
1.484.2.67 raeburn 5624:
5625: my $fromstoredjs;
5626: if ($canedit) {
5627: $fromstoredjs = 'open_StoredLinks_Import()';
5628: } else {
5629: $fromstoredjs = "alert('".&js_escape($lt{'er'})."')";
5630: }
5631:
1.484.2.19 raeburn 5632: my @importpubforma = (
5633: { '<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 5634: { '<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 5635: { '<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 5636: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform }
5637: );
5638: $importpubform = &create_form_ul(&create_list_elements(@importpubforma));
5639: my $extresourcesform =
5640: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
1.484.2.67 raeburn 5641: $help{'Adding_External_Resource'},
5642: undef,undef,$disabled);
1.484.2.72.2. (raeburn 5643:): my $exttoolform =
5644:): &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
5645:): $help{'Adding_External_Tool'},undef,
5646:): undef,'tool',$coursedom,$coursenum,
5647:): \%ltitools,$disabled);
1.329 droeschl 5648: if ($allowed) {
1.484.2.7 raeburn 5649: my $folder = $env{'form.folder'};
5650: if ($folder eq '') {
5651: $folder='default';
5652: }
1.484.2.67 raeburn 5653: if ($canedit) {
5654: my $output = &update_paste_buffer($coursenum,$coursedom,$folder);
5655: if ($output) {
5656: $r->print($output);
5657: }
1.484.2.30 raeburn 5658: }
1.337 ehlerst 5659: $r->print(<<HIDDENFORM);
5660: <form name="renameform" method="post" action="/adm/coursedocs">
5661: <input type="hidden" name="title" />
5662: <input type="hidden" name="cmd" />
5663: <input type="hidden" name="markcopy" />
5664: <input type="hidden" name="copyfolder" />
5665: $containertag
5666: </form>
1.484 raeburn 5667:
1.337 ehlerst 5668: HIDDENFORM
1.484.2.17 raeburn 5669: $r->print(&makesimpleeditform($pathitem)."\n".
5670: &makedocslogform($pathitem."\n".
1.484 raeburn 5671: '<input type="hidden" name="folder" value="'.
5672: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 5673: }
1.442 www 5674:
5675: # Generate the tabs
1.484.2.19 raeburn 5676: my ($mode,$needs_end);
1.472 raeburn 5677: if (($supplementalflag) && (!$allowed)) {
1.484.2.19 raeburn 5678: my @folders = split('&',$env{'form.folderpath'});
5679: unless (@folders > 2) {
5680: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
5681: $needs_end = 1;
5682: }
1.472 raeburn 5683: } else {
1.484 raeburn 5684: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484.2.19 raeburn 5685: $needs_end = 1;
1.472 raeburn 5686: }
1.443 www 5687:
1.442 www 5688: #
5689:
5690: my $savefolderpath;
5691:
1.395 raeburn 5692: if ($allowed) {
1.329 droeschl 5693: my $folder=$env{'form.folder'};
1.484.2.67 raeburn 5694: if ((($folder eq '') && (!$hiddentop)) || ($supplementalflag)) {
1.329 droeschl 5695: $folder='default';
1.356 tempelho 5696: $savefolderpath = $env{'form.folderpath'};
1.484.2.33 raeburn 5697: $env{'form.folderpath'}='default&'.&escape(&mt('Main Content'));
1.484.2.17 raeburn 5698: $pathitem = '<input type="hidden" name="folderpath" value="'.
1.329 droeschl 5699: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
5700: }
5701: my $postexec='';
5702: if ($folder eq 'default') {
1.372 bisitz 5703: $r->print('<script type="text/javascript">'."\n"
5704: .'// <![CDATA['."\n"
5705: .'this.window.name="loncapaclient";'."\n"
5706: .'// ]]>'."\n"
5707: .'</script>'."\n"
1.369 bisitz 5708: );
1.329 droeschl 5709: } else {
5710: #$postexec='self.close();';
5711: }
1.484.2.15 raeburn 5712: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
5713: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
1.329 droeschl 5714: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
5715:
5716: my $newnavform=(<<NNFORM);
5717: <form action="/adm/coursedocs" method="post" name="newnav">
1.484.2.43 raeburn 5718: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 5719: $pathitem
1.329 droeschl 5720: <input type="hidden" name="importdetail"
5721: value="$lt{'navc'}=/adm/navmaps" />
1.484.2.67 raeburn 5722: <a class="LC_menubuttons_link" href="javascript:makenew(document.newnav);">$lt{'navc'}</a>
1.329 droeschl 5723: $help{'Navigate_Content'}
5724: </form>
5725: NNFORM
5726: my $newsmppageform=(<<NSPFORM);
5727: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.484.2.43 raeburn 5728: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 5729: $pathitem
1.329 droeschl 5730: <input type="hidden" name="importdetail" value="" />
1.423 onken 5731: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 5732: $help{'Simple Page'}
1.329 droeschl 5733: </form>
5734: NSPFORM
5735:
5736: my $newsmpproblemform=(<<NSPROBFORM);
5737: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371 tempelho 5738: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 5739: $pathitem
1.329 droeschl 5740: <input type="hidden" name="importdetail" value="" />
1.423 onken 5741: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.484.2.44 raeburn 5742: $help{'Simple_Problem'}
1.329 droeschl 5743: </form>
5744:
5745: NSPROBFORM
5746:
5747: my $newdropboxform=(<<NDBFORM);
5748: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.371 tempelho 5749: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 5750: $pathitem
1.329 droeschl 5751: <input type="hidden" name="importdetail" value="" />
1.423 onken 5752: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.484.2.36 raeburn 5753: $help{'Dropbox'}
1.344 bisitz 5754: </form>
1.329 droeschl 5755: NDBFORM
5756:
5757: my $newexuploadform=(<<NEXUFORM);
5758: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.371 tempelho 5759: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 5760: $pathitem
1.329 droeschl 5761: <input type="hidden" name="importdetail" value="" />
1.423 onken 5762: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 5763: $help{'Score_Upload_Form'}
5764: </form>
5765: NEXUFORM
5766:
5767: my $newbulform=(<<NBFORM);
5768: <form action="/adm/coursedocs" method="post" name="newbul">
1.484.2.43 raeburn 5769: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5770: $pathitem
1.329 droeschl 5771: <input type="hidden" name="importdetail" value="" />
1.423 onken 5772: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 5773: $help{'Bulletin Board'}
5774: </form>
5775: NBFORM
5776:
5777: my $newaboutmeform=(<<NAMFORM);
5778: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.484.2.43 raeburn 5779: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5780: $pathitem
1.329 droeschl 5781: <input type="hidden" name="importdetail"
5782: value="$plainname=/adm/$udom/$uname/aboutme" />
1.484.2.67 raeburn 5783: <a class="LC_menubuttons_link" href="javascript:makenew(document.newaboutme);">$lt{'mypi'}</a>
1.347 weissno 5784: $help{'My Personal Information Page'}
1.329 droeschl 5785: </form>
5786: NAMFORM
5787:
5788: my $newaboutsomeoneform=(<<NASOFORM);
5789: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.484.2.43 raeburn 5790: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5791: $pathitem
1.329 droeschl 5792: <input type="hidden" name="importdetail" value="" />
1.423 onken 5793: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 5794: </form>
5795: NASOFORM
5796:
5797: my $newrosterform=(<<NROSTFORM);
5798: <form action="/adm/coursedocs" method="post" name="newroster">
1.484.2.43 raeburn 5799: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5800: $pathitem
1.329 droeschl 5801: <input type="hidden" name="importdetail"
5802: value="$lt{'rost'}=/adm/viewclasslist" />
1.484.2.67 raeburn 5803: <a class="LC_menubuttons_link" href="javascript:makenew(document.newroster);">$lt{'rost'}</a>
1.484.2.37 raeburn 5804: $help{'Course_Roster'}
1.329 droeschl 5805: </form>
5806: NROSTFORM
5807:
1.484.2.27 raeburn 5808: my $newwebpage;
5809: if ($folder =~ /^default_?(\d*)$/) {
5810: $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
5811: if ($1) {
5812: $newwebpage .= $1;
5813: } else {
5814: $newwebpage .= 'default';
5815: }
5816: $newwebpage .= '/new.html';
5817: }
5818: my $newwebpageform =(<<NWEBFORM);
5819: <form action="/adm/coursedocs" method="post" name="newwebpage">
1.484.2.43 raeburn 5820: <input type="hidden" name="active" value="ee" />
1.484.2.27 raeburn 5821: $pathitem
5822: <input type="hidden" name="importdetail" value="$newwebpage" />
5823: <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
1.484.2.36 raeburn 5824: $help{'Web_Page'}
1.484.2.27 raeburn 5825: </form>
5826: NWEBFORM
1.484.2.30 raeburn 5827:
1.484.2.27 raeburn 5828:
1.342 ehlerst 5829: my $specialdocumentsform;
1.383 tempelho 5830: my @specialdocumentsforma;
1.451 www 5831: my $gradingform;
5832: my @gradingforma;
5833: my $communityform;
5834: my @communityforma;
1.351 ehlerst 5835: my $newfolderform;
1.390 tempelho 5836: my $newfolderb;
1.342 ehlerst 5837:
1.451 www 5838: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 5839:
1.329 droeschl 5840: my $newpageform=(<<NPFORM);
5841: <form action="/adm/coursedocs" method="post" name="newpage">
5842: <input type="hidden" name="folderpath" value="$path" />
5843: <input type="hidden" name="importdetail" value="" />
1.484.2.43 raeburn 5844: <input type="hidden" name="active" value="ee" />
1.423 onken 5845: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 5846: $help{'Adding_Pages'}
1.329 droeschl 5847: </form>
5848: NPFORM
1.390 tempelho 5849:
5850:
1.351 ehlerst 5851: $newfolderform=(<<NFFORM);
1.329 droeschl 5852: <form action="/adm/coursedocs" method="post" name="newfolder">
1.484.2.19 raeburn 5853: $pathitem
1.329 droeschl 5854: <input type="hidden" name="importdetail" value="" />
1.484.2.43 raeburn 5855: <input type="hidden" name="active" value="" />
1.422 onken 5856: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 5857: </form>
5858: NFFORM
5859:
5860: my $newsylform=(<<NSYLFORM);
5861: <form action="/adm/coursedocs" method="post" name="newsyl">
1.484.2.43 raeburn 5862: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 5863: $pathitem
1.329 droeschl 5864: <input type="hidden" name="importdetail"
5865: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.484.2.67 raeburn 5866: <a class="LC_menubuttons_link" href="javascript:makenew(document.newsyl);">$lt{'syll'}</a>
1.329 droeschl 5867: $help{'Syllabus'}
1.383 tempelho 5868:
1.329 droeschl 5869: </form>
5870: NSYLFORM
1.364 bisitz 5871:
1.329 droeschl 5872: my $newgroupfileform=(<<NGFFORM);
5873: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.484.2.43 raeburn 5874: <input type="hidden" name="active" value="dd" />
1.484.2.17 raeburn 5875: $pathitem
1.329 droeschl 5876: <input type="hidden" name="importdetail"
5877: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.484.2.67 raeburn 5878: <a class="LC_menubuttons_link" href="javascript:makenew(document.newgroupfiles);">$lt{'grpo'}</a>
1.353 weissno 5879: $help{'Group Portfolio'}
1.329 droeschl 5880: </form>
5881: NGFFORM
1.383 tempelho 5882: @specialdocumentsforma=(
1.421 onken 5883: {'<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 5884: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.newsyl);" />'=>$newsylform},
5885: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="javascript:makenew(document.newnav);" />'=>$newnavform},
1.451 www 5886: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
1.484.2.27 raeburn 5887: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
1.451 www 5888: );
5889: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
5890:
1.434 raeburn 5891:
5892: my @importdoc = (
1.484.2.19 raeburn 5893: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform}
5894: );
1.484.2.72.2. (raeburn 5895:): if (keys(%ltitools)) {
5896:): push(@importdoc,
5897:): {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="toggleUpload(\'tool\');" />'=>$exttoolform},
5898:): );
5899:): }
1.484.2.19 raeburn 5900: unless ($container eq 'page') {
5901: push(@importdoc,
5902: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform}
5903: );
5904: }
5905: push(@importdoc,
1.484.2.38 raeburn 5906: {'<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 5907: );
1.484.2.12 raeburn 5908: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
1.434 raeburn 5909:
1.451 www 5910: @gradingforma=(
5911: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
5912: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
5913: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
5914:
5915: );
5916: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
5917:
5918: @communityforma=(
5919: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
5920: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
5921: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
1.484.2.67 raeburn 5922: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="javascript:makenew(document.newroster);" />'=>$newrosterform},
5923: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="javascript:makenew(document.newgroupfiles);" />'=>$newgroupfileform},
1.451 www 5924: );
5925: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 5926:
1.330 tempelho 5927: my %orderhash = (
1.484.2.36 raeburn 5928: 'aa' => ['Upload',$fileuploadform],
5929: 'bb' => ['Import',$importpubform],
5930: 'cc' => ['Grading',$gradingform],
1.330 tempelho 5931: );
1.484.2.19 raeburn 5932: unless ($container eq 'page') {
1.434 raeburn 5933: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.484 raeburn 5934: $orderhash{'dd'} = ['Collaboration',$communityform];
1.484.2.36 raeburn 5935: $orderhash{'ee'} = ['Other',$specialdocumentsform];
1.434 raeburn 5936: }
5937:
1.341 ehlerst 5938: $hadchanges=0;
1.484 raeburn 5939: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 5940: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.67 raeburn 5941: $supplementalflag,\%orderhash,$iconpath,$pathitem,
1.484.2.72.2. (raeburn 5942:): \%ltitools,$canedit,\$navmap,$hiddentop);
1.484.2.67 raeburn 5943: undef($navmap);
1.443 www 5944: if ($error) {
5945: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
5946: }
5947: if ($hadchanges) {
1.484.2.72.2. (raeburn 5948:): unless (&is_hash_old()) {
5949:): &mark_hash_old();
5950:): }
1.443 www 5951: }
5952: &changewarning($r,'');
5953: }
1.458 raeburn 5954: }
1.442 www 5955:
1.443 www 5956: # Supplemental documents start here
5957:
1.329 droeschl 5958: my $folder=$env{'form.folder'};
1.443 www 5959: unless ($supplementalflag) {
1.329 droeschl 5960: $folder='supplemental';
5961: }
5962: if ($folder =~ /^supplemental$/ &&
5963: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 5964: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 5965: } elsif ($allowed) {
1.356 tempelho 5966: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 5967: }
1.484.2.17 raeburn 5968: $pathitem = '<input type="hidden" name="folderpath" value="'.
5969: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.329 droeschl 5970: if ($allowed) {
5971: my $folderseq=
1.484.2.15 raeburn 5972: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
1.329 droeschl 5973:
5974: my $supupdocform=(<<SUPDOCFORM);
1.484.2.12 raeburn 5975: <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
5976: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
1.383 tempelho 5977: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.484.2.19 raeburn 5978: <fieldset id="uploadsuppdocform" style="display: none;">
1.484.2.12 raeburn 5979: <legend>$lt{'upfi'}</legend>
1.371 tempelho 5980: <input type="hidden" name="active" value="ee" />
1.329 droeschl 5981: $fileupload
5982: <br />
5983: <br />
5984: <span class="LC_nobreak">
5985: $checkbox
5986: </span>
5987: <br /><br />
5988: $lt{'comment'}:<br />
1.383 tempelho 5989: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 5990: <br />
1.484.2.19 raeburn 5991: $pathitem
1.329 droeschl 5992: <input type="hidden" name="cmd" value="upload_supplemental" />
1.484.2.12 raeburn 5993: <input type='submit' value="$lt{'upld'}" />
5994: </form>
1.484.2.19 raeburn 5995: SUPDOCFORM
1.329 droeschl 5996:
5997: my $supnewfolderform=(<<SNFFORM);
5998: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.484.2.43 raeburn 5999: <input type="hidden" name="active" value="" />
1.484.2.17 raeburn 6000: $pathitem
1.329 droeschl 6001: <input type="hidden" name="importdetail" value="" />
1.423 onken 6002: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 6003: $help{'Adding_Folders'}
1.329 droeschl 6004: </form>
6005: SNFFORM
1.383 tempelho 6006:
1.484.2.19 raeburn 6007: my $supextform =
6008: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
1.484.2.67 raeburn 6009: $help{'Adding_External_Resource'},
6010: undef,undef,$disabled);
1.329 droeschl 6011:
1.484.2.72.2. (raeburn 6012:): my $supexttoolform =
6013:): &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
6014:): $help{'Adding_External_Tool'},
6015:): undef,undef,'tool',$coursedom,
6016:): $coursenum,\%ltitools,$disabled);
1.329 droeschl 6017: my $supnewsylform=(<<SNSFORM);
6018: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 6019: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 6020: $pathitem
1.329 droeschl 6021: <input type="hidden" name="importdetail"
6022: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.484.2.67 raeburn 6023: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewsyl);">$lt{'syll'}</a>
1.329 droeschl 6024: $help{'Syllabus'}
6025: </form>
6026: SNSFORM
6027:
6028: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 6029: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 6030: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 6031: $pathitem
1.329 droeschl 6032: <input type="hidden" name="importdetail"
6033: value="$plainname=/adm/$udom/$uname/aboutme" />
1.484.2.67 raeburn 6034: <a class="LC_menubuttons_link" href="javascript:makenew(document.supnewaboutme);">$lt{'mypi'}</a>
1.347 weissno 6035: $help{'My Personal Information Page'}
1.329 droeschl 6036: </form>
6037: SNAMFORM
6038:
1.484.2.27 raeburn 6039: my $supwebpage;
6040: if ($folder =~ /^supplemental_?(\d*)$/) {
6041: $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
6042: if ($1) {
6043: $supwebpage .= $1;
6044: } else {
6045: $supwebpage .= 'default';
6046: }
6047: $supwebpage .= '/new.html';
6048: }
6049: my $supwebpageform =(<<SWEBFORM);
6050: <form action="/adm/coursedocs" method="post" name="supwebpage">
6051: <input type="hidden" name="active" value="cc" />
6052: $pathitem
6053: <input type="hidden" name="importdetail" value="$supwebpage" />
6054: <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
1.484.2.36 raeburn 6055: $help{'Web_Page'}
1.484.2.27 raeburn 6056: </form>
6057: SWEBFORM
6058:
1.333 muellerd 6059:
1.383 tempelho 6060: my @specialdocs = (
1.484.2.67 raeburn 6061: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="javascript:makenew(document.supnewsyl);" />'
1.417 droeschl 6062: =>$supnewsylform},
1.484.2.67 raeburn 6063: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makenew(document.supnewaboutme);" />'
1.417 droeschl 6064: =>$supnewaboutmeform},
1.484.2.27 raeburn 6065: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
6066:
1.383 tempelho 6067: );
1.417 droeschl 6068: my @supimportdoc = (
1.484.2.19 raeburn 6069: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleUpload(\'suppext\')" />'
1.484.2.72.2. (raeburn 6070:): =>$supextform});
6071:): if (keys(%ltitools)) {
6072:): push(@supimportdoc,
6073:): {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/exttool.png" alt="'.$lt{extt}.'" onclick="javascript:toggleUpload(\'supptool\')" />'
6074:): =>$supexttoolform});
6075:): }
6076:): push(@supimportdoc,
1.484.2.12 raeburn 6077: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
6078: =>$supupdocform},
1.484.2.72.2. (raeburn 6079:): );
1.484.2.19 raeburn 6080:
1.484.2.12 raeburn 6081: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
1.333 muellerd 6082: my %suporderhash = (
1.390 tempelho 6083: '00' => ['Supnewfolder', $supnewfolderform],
1.484.2.36 raeburn 6084: 'ee' => ['Upload',$supupdocform],
6085: 'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 6086: );
1.443 www 6087: if ($supplementalflag) {
1.458 raeburn 6088: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.67 raeburn 6089: $supplementalflag,\%suporderhash,$iconpath,$pathitem,
1.484.2.72.2. (raeburn 6090:): \%ltitools,$canedit);
1.443 www 6091: if ($error) {
6092: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.484.2.37 raeburn 6093: } else {
6094: if ($suppchanges) {
6095: my %servers = &Apache::lonnet::internet_dom_servers($coursedom);
6096: my @ids=&Apache::lonnet::current_machine_ids();
6097: foreach my $server (keys(%servers)) {
6098: next if (grep(/^\Q$server\E$/,@ids));
6099: my $hashid=$coursenum.':'.$coursedom;
1.484.2.42 raeburn 6100: my $cachekey = &escape('suppcount').':'.&escape($hashid);
6101: &Apache::lonnet::remote_devalidate_cache($server,[$cachekey]);
1.484.2.37 raeburn 6102: }
6103: &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
6104: undef($suppchanges);
6105: }
1.443 www 6106: }
1.393 raeburn 6107: }
1.443 www 6108: } elsif ($supplementalflag) {
1.458 raeburn 6109: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.17 raeburn 6110: $supplementalflag,'',$iconpath,$pathitem);
1.393 raeburn 6111: if ($error) {
6112: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 6113: }
1.393 raeburn 6114: }
1.389 tempelho 6115:
1.484.2.19 raeburn 6116: if ($needs_end) {
6117: $r->print(&endContentScreen());
6118: }
1.383 tempelho 6119:
1.329 droeschl 6120: if ($allowed) {
6121: $r->print('
6122: <form method="post" name="extimport" action="/adm/coursedocs">
6123: <input type="hidden" name="title" />
6124: <input type="hidden" name="url" />
6125: <input type="hidden" name="useform" />
6126: <input type="hidden" name="residx" />
6127: </form>');
6128: }
1.484 raeburn 6129: } elsif ($showdoc) {
1.329 droeschl 6130: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 6131: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.484.2.10 raeburn 6132: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 6133: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 6134: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 6135: }
6136: }
6137: $r->print(&Apache::loncommon::end_page());
6138: return OK;
1.364 bisitz 6139: }
1.329 droeschl 6140:
1.440 raeburn 6141: sub embedded_form_elems {
6142: my ($phase,$primaryurl,$newidx) = @_;
6143: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.484.2.72.2. (raeburn 6144:): $newidx =~s /\D+//g;
1.440 raeburn 6145: return <<STATE;
6146: <input type="hidden" name="folderpath" value="$folderpath" />
6147: <input type="hidden" name="cmd" value="upload_embedded" />
6148: <input type="hidden" name="newidx" value="$newidx" />
6149: <input type="hidden" name="phase" value="$phase" />
6150: <input type="hidden" name="primaryurl" value="$primaryurl" />
6151: STATE
6152: }
6153:
6154: sub embedded_destination {
6155: my $folder=$env{'form.folder'};
6156: my $destination = 'docs/';
6157: if ($folder =~ /^supplemental/) {
6158: $destination = 'supplemental/';
6159: }
6160: if (($folder eq 'default') || ($folder eq 'supplemental')) {
6161: $destination .= 'default/';
6162: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
6163: $destination .= $2.'/';
6164: }
1.484.2.72.2. (raeburn 6165:): my $newidx = $env{'form.newidx'};
6166:): $newidx =~s /\D+//g;
6167:): if ($newidx) {
6168:): $destination .= $newidx;
6169:): }
1.440 raeburn 6170: my $dir_root = '/userfiles';
6171: return ($destination,$dir_root);
6172: }
6173:
6174: sub return_to_editor {
6175: my $actionurl = '/adm/coursedocs';
6176: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
6177: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
6178: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
6179: '</a></p>';
6180: }
6181:
1.476 raeburn 6182: sub decompression_info {
6183: my ($destination,$dir_root) = &embedded_destination();
6184: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
6185: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
6186: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
6187: my $container='sequence';
1.480 raeburn 6188: my ($pathitem,$hiddenelem);
1.484.2.54 raeburn 6189: my @hiddens = ('newidx','comment','position','folderpath','archiveurl');
1.484.2.19 raeburn 6190: if ($env{'form.folderpath'} =~ /\:1$/) {
1.476 raeburn 6191: $container='page';
6192: }
1.480 raeburn 6193: unshift(@hiddens,$pathitem);
6194: foreach my $item (@hiddens) {
1.484.2.72.2. (raeburn 6195:): if ($item eq 'newidx') {
6196:): next if ($env{'form.'.$item} =~ /\D/);
6197:): }
1.480 raeburn 6198: if ($env{'form.'.$item}) {
6199: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
1.484.2.54 raeburn 6200: &HTML::Entities::encode($env{'form.'.$item},'<>&"').'" />'."\n";
1.480 raeburn 6201: }
1.477 raeburn 6202: }
1.476 raeburn 6203: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
6204: $hiddenelem);
6205: }
6206:
6207: sub decompression_phase_one {
6208: my ($dir,$file,$warning,$error,$output);
6209: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
6210: &decompression_info();
1.484.2.7 raeburn 6211: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 6212: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
6213: } else {
6214: my $file = $1;
1.481 raeburn 6215: $output =
6216: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
6217: $destination,$dir_root,
6218: $hiddenelem);
6219: if ($env{'form.autoextract_camtasia'}) {
6220: $output .= &remove_archive($docudom,$docuname,$container);
6221: }
1.476 raeburn 6222: }
6223: if ($error) {
6224: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
6225: $error.'</p>'."\n";
6226: }
6227: if ($warning) {
6228: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
6229: }
6230: return $output;
6231: }
6232:
6233: sub decompression_phase_two {
6234: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
6235: &decompression_info();
1.481 raeburn 6236: my $output;
1.480 raeburn 6237: if ($env{'form.archivedelete'}) {
1.481 raeburn 6238: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 6239: }
6240: $output .=
1.481 raeburn 6241: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 6242: $destination,$dir_root,$hiddenelem);
6243: return $output;
6244: }
6245:
1.480 raeburn 6246: sub remove_archive {
6247: my ($docudom,$docuname,$container) = @_;
6248: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 6249: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 6250: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
6251: if ($fatal) {
6252: if ($container eq 'page') {
6253: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
6254: } else {
6255: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
6256: }
1.484.2.54 raeburn 6257: $delwarning .= ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 6258: } else {
6259: my $currcmd = $env{'form.cmd'};
6260: my $position = $env{'form.position'};
1.484.2.54 raeburn 6261: my $archiveidx = $position;
6262: if ($position > 0) {
6263: if (($env{'form.autoextract_camtasia'}) && (scalar(@LONCAPA::map::order) == 2)) {
6264: $archiveidx = $position-1;
6265: }
6266: $env{'form.cmd'} = 'remove_'.$archiveidx;
6267: my ($title,$url,@rrest) =
6268: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$archiveidx]]);
6269: if ($url eq $env{'form.archiveurl'}) {
6270: if (&handle_edit_cmd($docuname,$docudom)) {
6271: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
6272: if ($fatal) {
6273: if ($container eq 'page') {
6274: $delwarning = &mt('An error occurred updating the contents of the current page.');
6275: } else {
6276: $delwarning = &mt('An error occurred updating the contents of the current folder.');
6277: }
1.480 raeburn 6278: } else {
1.484.2.54 raeburn 6279: $delresult = &mt('Archive file removed.');
1.480 raeburn 6280: }
6281: }
1.484.2.54 raeburn 6282: } else {
6283: $delwarning .= &mt('Archive file had unexpected item number in folder.').
6284: ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 6285: }
6286: }
6287: $env{'form.cmd'} = $currcmd;
6288: }
6289: if ($delwarning) {
6290: $output = '<p class="LC_warning">'.
6291: $delwarning.
6292: '</p>';
6293: }
6294: if ($delresult) {
6295: $output .= '<p class="LC_info">'.
6296: $delresult.
6297: '</p>';
6298: }
1.481 raeburn 6299: return $output;
1.480 raeburn 6300: }
6301:
1.484 raeburn 6302: sub generate_admin_menu {
1.484.2.67 raeburn 6303: my ($crstype,$canedit) = @_;
1.484 raeburn 6304: my $lc_crstype = lc($crstype);
6305: my ($home,$other,%outhash)=&authorhosts();
1.484.2.43 raeburn 6306: my %lt= ( # do not translate here
1.484 raeburn 6307: 'vc' => 'Verify Content',
6308: 'cv' => 'Check/Set Resource Versions',
6309: 'ls' => 'List Resource Identifiers',
1.484.2.72.2. (raeburn 6310:): 'ct' => 'Display/Set Shortened URLs for Deep-linking',
1.484 raeburn 6311: 'imse' => 'Export contents to IMS Archive',
1.484.2.43 raeburn 6312: 'dcd' => "Copy $crstype Content to Authoring Space",
6313: );
1.484 raeburn 6314: my ($candump,$dumpurl);
6315: if ($home + $other > 0) {
6316: $candump = 'F';
6317: if ($home) {
6318: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
6319: } else {
6320: my @hosts;
6321: foreach my $aurole (keys(%outhash)) {
6322: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
6323: push(@hosts,$outhash{$aurole});
1.484.2.30 raeburn 6324: }
1.484 raeburn 6325: }
6326: if (@hosts == 1) {
6327: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
6328: '&role='.
6329: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
6330: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
6331: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
6332: } else {
6333: $dumpurl = "javascript:choose_switchserver_window()";
6334: }
6335: }
6336: }
6337: my @menu=
6338: ({ categorytitle=>'Administration',
6339: items =>[
6340: { linktext => $lt{'vc'},
6341: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
6342: permission => 'F',
1.484.2.44 raeburn 6343: help => 'Docs_Verify_Content',
1.484 raeburn 6344: icon => 'verify.png',
6345: linktitle => 'Verify contents can be retrieved/rendered',
6346: },
6347: { linktext => $lt{'cv'},
6348: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
6349: permission => 'F',
1.484.2.44 raeburn 6350: help => 'Docs_Check_Resource_Versions',
1.484 raeburn 6351: icon => 'resversion.png',
6352: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
6353: },
6354: { linktext => $lt{'ls'},
6355: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
6356: permission => 'F',
6357: #help => '',
6358: icon => 'symbs.png',
6359: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
6360: },
1.484.2.72.2. (raeburn 6361:): { linktext => $lt{'ct'},
6362:): url => "javascript:injectData(document.courseverify,'dummy','shorturls','$lt{'ct'}')",
6363:): permission => 'F',
6364:): help => 'Docs_Short_URLs',
6365:): icon => 'shorturls.png',
6366:): linktitle => "Set shortened URLs for a resource or folder in your $lc_crstype for use in deep-linking"
6367:): },
1.484 raeburn 6368: ]
1.484.2.67 raeburn 6369: });
6370: if ($canedit) {
6371: push(@menu,
1.484 raeburn 6372: { categorytitle=>'Export',
6373: items =>[
6374: { linktext => $lt{'imse'},
6375: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
6376: permission => 'F',
6377: help => 'Docs_Export_Course_Docs',
6378: icon => 'imsexport.png',
6379: linktitle => $lt{'imse'},
6380: },
6381: { linktext => $lt{'dcd'},
6382: url => $dumpurl,
6383: permission => $candump,
1.484.2.44 raeburn 6384: help => 'Docs_Dump_Course_Docs',
1.484 raeburn 6385: icon => 'dump.png',
6386: linktitle => $lt{'dcd'},
6387: },
6388: ]
6389: });
1.484.2.67 raeburn 6390: }
1.484 raeburn 6391: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
6392: '<input type="hidden" id="dummy" />'."\n".
6393: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
6394: '</form>';
1.329 droeschl 6395: }
6396:
6397: sub generate_edit_table {
1.484.2.30 raeburn 6398: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile,
1.484.2.67 raeburn 6399: $need_save,$copyfolder,$canedit) = @_;
1.406 raeburn 6400: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 6401: my %orderhash = %{$orderhash_ref};
1.484.2.67 raeburn 6402: my ($form, $activetab, $active, $disabled);
1.484.2.43 raeburn 6403: if (($env{'form.active'} ne '') && ($env{'form.active'} ne '00')) {
1.371 tempelho 6404: $activetab = $env{'form.active'};
6405: }
1.484.2.67 raeburn 6406: unless ($canedit) {
6407: $disabled = ' disabled="disabled"';
6408: }
1.472 raeburn 6409: my $backicon = $iconpath.'clickhere.gif';
1.484.2.21 raeburn 6410: my $backtext = &mt('Exit Editor');
1.458 raeburn 6411: $form = '<div class="LC_Box" style="margin:0;">'.
1.484.2.19 raeburn 6412: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
6413: '<li class="goback">'.
1.484.2.32 raeburn 6414: '<a href="javascript:toContents('."'$jumpto'".');">'.
1.484.2.19 raeburn 6415: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
6416: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
6417: '<li>'.
6418: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
6419: &mt('Undo Delete').'</a></li>'."\n";
1.484.2.7 raeburn 6420: if ($env{'form.docslog'}) {
6421: $form .= '<li class="active">';
6422: } else {
6423: $form .= '<li>';
6424: }
6425: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
6426: &mt('History').'</a></li>'."\n";
6427: if ($env{'form.docslog'}) {
6428: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
6429: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 6430: }
1.458 raeburn 6431: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 6432: if($name ne '00'){
1.371 tempelho 6433: if($activetab eq '' || $activetab ne $name){
6434: $active = '';
6435: }elsif($activetab eq $name){
6436: $active = 'class="active"';
6437: }
1.458 raeburn 6438: $form .= '<li style="float:right" '.$active
1.484 raeburn 6439: .' 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 6440: } else {
1.484.2.43 raeburn 6441: $form .= '<li style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 6442:
6443: }
1.329 droeschl 6444: }
1.484 raeburn 6445: $form .= '</ul>'."\n";
6446: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 6447:
6448: if ($to_show ne '') {
1.484.2.30 raeburn 6449: my $saveform;
6450: if ($need_save) {
6451: my $button = &mt('Make changes');
6452: my $path;
6453: if ($env{'form.folderpath'}) {
6454: $path =
6455: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
6456: }
6457: $saveform = <<"END";
6458: <div id="multisave" style="display:none; clear:both;" >
6459: <form name="saveactions" method="post" action="/adm/coursedocs" onsubmit="return checkSubmits();">
6460: <input type="hidden" name="folderpath" value="$path" />
6461: <input type="hidden" name="symb" value="$env{'form.symb'}" />
6462: <input type="hidden" name="allhiddenresource" value="" />
6463: <input type="hidden" name="allencrypturl" value="" />
6464: <input type="hidden" name="allrandompick" value="" />
6465: <input type="hidden" name="allrandomorder" value="" />
6466: <input type="hidden" name="changeparms" value="" />
6467: <input type="hidden" name="multiremove" value="" />
6468: <input type="hidden" name="multicut" value="" />
6469: <input type="hidden" name="multicopy" value="" />
6470: <input type="hidden" name="multichange" value="" />
6471: <input type="hidden" name="copyfolder" value="$copyfolder" />
1.484.2.67 raeburn 6472: <input type="submit" name="savemultiples" value="$button" $disabled />
1.484.2.30 raeburn 6473: </form>
6474: </div>
6475: END
6476: }
6477: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'.$saveform."\n";
1.458 raeburn 6478: }
1.363 ehlerst 6479: foreach my $field (keys(%orderhash)){
1.390 tempelho 6480: if($field ne '00'){
1.422 onken 6481: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 6482: $active = 'style="display: none;float:left"';
1.422 onken 6483: }elsif($activetab eq $field){
1.458 raeburn 6484: $active = 'style="display:block;float:left"';
1.422 onken 6485: }
6486: $form .= '<div id="'.$field.$tid.'"'
6487: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 6488: .'</div>'."\n";
1.363 ehlerst 6489: }
6490: }
1.484 raeburn 6491: unless ($env{'form.docslog'}) {
6492: $form .= '</div></div>'."\n";
6493: }
1.329 droeschl 6494: return $form;
6495: }
6496:
6497: sub editing_js {
1.484.2.72.2. (raeburn 6498:): my ($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,$canedit,$navmapref) = @_;
1.484.2.61 raeburn 6499: my %js_lt = &Apache::lonlocal::texthash(
1.329 droeschl 6500: p_mnf => 'Name of New Folder',
6501: t_mnf => 'New Folder',
6502: p_mnp => 'Name of New Page',
6503: t_mnp => 'New Page',
1.451 www 6504: p_mxu => 'Title for the External Score',
1.349 biermanm 6505: p_msp => 'Name of Simple Course Page',
1.329 droeschl 6506: p_msb => 'Title for the Problem',
6507: p_mdb => 'Title for the Drop Box',
1.336 schafran 6508: p_mbb => 'Title for the Discussion Board',
1.484.2.27 raeburn 6509: p_mwp => 'Title for Web Page',
1.348 weissno 6510: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 6511: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 6512: p_mab_alrt1 => 'Not a valid user:domain',
6513: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
6514: p_chn => 'New Title',
6515: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
1.484.2.63 raeburn 6516: p_rmr2a => 'Remove',
6517: p_rmr2b => '?',
6518: p_rmr3a => 'Remove those',
6519: p_rmr3b => 'items?',
6520: p_rmr4 => 'WARNING: Removing a resource uploaded to a course cannot be undone via "Undo Delete".',
6521: p_rmr5 => 'Push "Cancel" and then use "Cut" instead if you might need to undo this change.',
1.329 droeschl 6522: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
6523: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
1.484.2.63 raeburn 6524: p_ctr2a => 'Cut',
6525: p_ctr2b => '?',
6526: p_ctr3a => 'Cut those',
6527: p_ctr3b => 'items?',
1.478 raeburn 6528: rpck => 'Enter number to pick (e.g., 3)',
1.484.2.12 raeburn 6529: imsfile => 'You must choose an IMS package for import',
6530: imscms => 'You must select which Course Management System was the source of the IMS package',
6531: invurl => 'Invalid URL',
6532: titbl => 'Title is blank',
1.484.2.30 raeburn 6533: more => '(More ...)',
6534: less => '(Less ...)',
6535: noor => 'No actions selected or changes to settings specified.',
6536: noch => 'No changes to settings specified.',
6537: noac => 'No actions selected.',
1.484.2.67 raeburn 6538: edri => 'Editing rights unavailable for your current role.',
1.329 droeschl 6539: );
6540:
1.484.2.61 raeburn 6541: &js_escape(\%js_lt);
1.433 raeburn 6542: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 6543: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
6544: my $main_container_page;
1.484.2.19 raeburn 6545: if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) {
6546: $main_container_page = 1;
1.434 raeburn 6547: }
1.484.2.67 raeburn 6548: my $backtourl;
6549: my $toplevelmain = &escape(&default_folderpath($coursenum,$coursedom,$navmapref));
1.446 www 6550: my $toplevelsupp = &supplemental_base();
1.433 raeburn 6551:
1.484.2.21 raeburn 6552: if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
6553: my $caller = $1;
6554: if ($caller =~ /^supplemental/) {
6555: $backtourl = '/adm/supplemental?folderpath='.&escape($caller);
6556: } else {
6557: my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
6558: $res = &Apache::lonnet::clutter($res);
6559: if (&Apache::lonnet::is_on_map($res)) {
1.484.2.66 raeburn 6560: my ($url,$anchor);
6561: if ($res =~ /^([^#]+)#([^#]+)$/) {
6562: $url = $1;
6563: $anchor = $2;
6564: if (($caller =~ m{^([^#]+)\Q#$anchor\E$})) {
6565: $caller = $1.&escape('#').$anchor;
6566: }
1.484.2.67 raeburn 6567: } else {
6568: $url = $res;
1.484.2.66 raeburn 6569: }
1.484.2.72.2. (raeburn 6570:): $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"');
6571:): if ($backtourl =~ m{^\Q/uploaded/$coursedom/$coursenum/\Edefault_\d+\.sequence$}) {
6572:): $backtourl .= '?navmap=1';
6573:): } else {
6574:): $backtourl .= '?symb='.
6575:): &HTML::Entities::encode($caller,'<>&"');
6576:): }
1.484.2.66 raeburn 6577: if ($anchor ne '') {
6578: $backtourl .= '#'.&HTML::Entities::encode($anchor,'<>&"');
6579: }
1.484.2.57 raeburn 6580: $backtourl = &Apache::loncommon::escape_single($backtourl);
1.484.2.31 raeburn 6581: } else {
6582: $backtourl = '/adm/navmaps';
1.484.2.21 raeburn 6583: }
6584: }
6585: } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
6586: $backtourl = '/adm/menu';
6587: } elsif ($supplementalflag) {
1.472 raeburn 6588: $backtourl = '/adm/supplemental';
1.484.2.21 raeburn 6589: } else {
6590: $backtourl = '/adm/navmaps';
1.472 raeburn 6591: }
6592:
1.484.2.19 raeburn 6593: my $fieldsets = "'ext','doc'";
1.484.2.72.2. (raeburn 6594:): if ($posslti) {
6595:): $fieldsets .= ",'tool'";
6596:): }
1.484.2.19 raeburn 6597: unless ($main_container_page) {
6598: $fieldsets .=",'ims'";
6599: }
1.484.2.12 raeburn 6600: if ($supplementalflag) {
6601: $fieldsets = "'suppext','suppdoc'";
1.484.2.72.2. (raeburn 6602:): if ($posslti) {
6603:): $fieldsets .= ",'supptool'";
6604:): }
1.484.2.12 raeburn 6605: }
6606:
1.484.2.67 raeburn 6607: my $jsmakefunctions;
6608: if ($canedit) {
6609: $jsmakefunctions = <<ENDNEWSCRIPT;
1.329 droeschl 6610: function makenewfolder(targetform,folderseq) {
1.484.2.65 raeburn 6611: var foldername=prompt('$js_lt{"p_mnf"}','$js_lt{"t_mnf"}');
1.329 droeschl 6612: if (foldername) {
6613: targetform.importdetail.value=escape(foldername)+"="+folderseq;
6614: targetform.submit();
6615: }
6616: }
6617:
6618: function makenewpage(targetform,folderseq) {
1.484.2.61 raeburn 6619: var pagename=prompt('$js_lt{"p_mnp"}','$js_lt{"t_mnp"}');
1.329 droeschl 6620: if (pagename) {
6621: targetform.importdetail.value=escape(pagename)+"="+folderseq;
6622: targetform.submit();
6623: }
6624: }
6625:
6626: function makeexamupload() {
1.484.2.61 raeburn 6627: var title=prompt('$js_lt{"p_mxu"}');
1.344 bisitz 6628: if (title) {
1.329 droeschl 6629: this.document.forms.newexamupload.importdetail.value=
6630: escape(title)+'=/res/lib/templates/examupload.problem';
6631: this.document.forms.newexamupload.submit();
6632: }
6633: }
6634:
6635: function makesmppage() {
1.484.2.61 raeburn 6636: var title=prompt('$js_lt{"p_msp"}');
1.344 bisitz 6637: if (title) {
1.329 droeschl 6638: this.document.forms.newsmppg.importdetail.value=
1.484.2.26 raeburn 6639: escape(title)+'=/adm/$udom/$uname/new/smppg';
1.329 droeschl 6640: this.document.forms.newsmppg.submit();
6641: }
6642: }
6643:
1.484.2.27 raeburn 6644: function makewebpage(type) {
1.484.2.61 raeburn 6645: var title=prompt('$js_lt{"p_mwp"}');
1.484.2.27 raeburn 6646: var formname;
6647: if (type == 'supp') {
6648: formname = this.document.forms.supwebpage;
6649: } else {
6650: formname = this.document.forms.newwebpage;
6651: }
6652: if (title) {
6653: var webpage = formname.importdetail.value;
6654: formname.importdetail.value = escape(title)+'='+webpage;
6655: formname.submit();
6656: }
6657: }
6658:
1.329 droeschl 6659: function makesmpproblem() {
1.484.2.61 raeburn 6660: var title=prompt('$js_lt{"p_msb"}');
1.344 bisitz 6661: if (title) {
1.329 droeschl 6662: this.document.forms.newsmpproblem.importdetail.value=
6663: escape(title)+'=/res/lib/templates/simpleproblem.problem';
6664: this.document.forms.newsmpproblem.submit();
6665: }
6666: }
6667:
6668: function makedropbox() {
1.484.2.61 raeburn 6669: var title=prompt('$js_lt{"p_mdb"}');
1.344 bisitz 6670: if (title) {
1.329 droeschl 6671: this.document.forms.newdropbox.importdetail.value=
6672: escape(title)+'=/res/lib/templates/DropBox.problem';
6673: this.document.forms.newdropbox.submit();
6674: }
6675: }
6676:
6677: function makebulboard() {
1.484.2.61 raeburn 6678: var title=prompt('$js_lt{"p_mbb"}');
1.329 droeschl 6679: if (title) {
6680: this.document.forms.newbul.importdetail.value=
1.484.2.26 raeburn 6681: escape(title)+'=/adm/$udom/$uname/new/bulletinboard';
1.329 droeschl 6682: this.document.forms.newbul.submit();
6683: }
6684: }
6685:
6686: function makeabout() {
1.484.2.61 raeburn 6687: var user=prompt("$js_lt{'p_mab'}");
1.329 droeschl 6688: if (user) {
6689: var comp=new Array();
6690: comp=user.split(':');
6691: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
6692: if ((comp[0]) && (comp[1])) {
6693: this.document.forms.newaboutsomeone.importdetail.value=
1.484.2.61 raeburn 6694: '$js_lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.484.2.67 raeburn 6695: this.document.forms.newaboutsomeone.submit();
6696: } else {
6697: alert("$js_lt{'p_mab_alrt1'}");
6698: }
6699: } else {
6700: alert("$js_lt{'p_mab_alrt2'}");
6701: }
6702: }
1.335 ehlerst 6703: }
1.484.2.67 raeburn 6704:
6705: function makenew(targetform) {
6706: targetform.submit();
1.335 ehlerst 6707: }
1.484.2.67 raeburn 6708:
6709: function changename(folderpath,index,oldtitle) {
6710: var title=prompt('$js_lt{"p_chn"}',oldtitle);
6711: if (title) {
6712: this.document.forms.renameform.markcopy.value='';
6713: this.document.forms.renameform.title.value=title;
6714: this.document.forms.renameform.cmd.value='rename_'+index;
6715: this.document.forms.renameform.folderpath.value=folderpath;
6716: this.document.forms.renameform.submit();
6717: }
1.329 droeschl 6718: }
6719:
1.484.2.67 raeburn 6720: ENDNEWSCRIPT
6721: } else {
6722: $jsmakefunctions = <<ENDNEWSCRIPT;
6723:
6724: function makenewfolder() {
6725: alert("$js_lt{'edri'}");
6726: }
6727:
6728: function makenewpage() {
6729: alert("$js_lt{'edri'}");
6730: }
6731:
6732: function makeexamupload() {
6733: alert("$js_lt{'edri'}");
6734: }
6735:
6736: function makesmppage() {
6737: alert("$js_lt{'edri'}");
6738: }
6739:
6740: function makewebpage(type) {
6741: alert("$js_lt{'edri'}");
6742: }
6743:
6744: function makesmpproblem() {
6745: alert("$js_lt{'edri'}");
6746: }
6747:
6748: function makedropbox() {
6749: alert("$js_lt{'edri'}");
6750: }
6751:
6752: function makebulboard() {
6753: alert("$js_lt{'edri'}");
6754: }
6755:
6756: function makeabout() {
6757: alert("$js_lt{'edri'}");
6758: }
6759:
6760: function changename() {
6761: alert("$js_lt{'edri'}");
6762: }
6763:
6764: function makenew() {
6765: alert("$js_lt{'edri'}");
6766: }
6767:
6768: function groupimport() {
6769: alert("$js_lt{'edri'}");
6770: }
6771:
6772: function groupsearch() {
6773: alert("$js_lt{'edri'}");
6774: }
6775:
6776: function groupopen(url,recover) {
6777: var options="scrollbars=1,resizable=1,menubar=0";
6778: idxflag=1;
6779: idx=open("/adm/groupsort?inhibitmenu=yes&mode=simple&recover="+recover+"&readfile="+url,"idxout",options);
6780: idx.focus();
6781: }
6782:
6783: ENDNEWSCRIPT
6784:
6785: }
6786: return <<ENDSCRIPT;
6787:
6788: $jsmakefunctions
6789:
1.484.2.13 raeburn 6790: function toggleUpload(caller) {
6791: var blocks = Array($fieldsets);
6792: for (var i=0; i<blocks.length; i++) {
6793: var disp = 'none';
6794: if (caller == blocks[i]) {
6795: var curr = document.getElementById('upload'+caller+'form').style.display;
6796: if (curr == 'none') {
6797: disp='block';
6798: }
6799: }
6800: document.getElementById('upload'+blocks[i]+'form').style.display=disp;
1.484.2.72.2. (raeburn 6801:): if ((caller == 'tool') || (caller == 'supptool')) {
6802:): if (disp == 'block') {
6803:): if (document.getElementById('LC_exttoolid')) {
6804:): var toolselector = document.getElementById('LC_exttoolid');
6805:): var suppflag = 0;
6806:): if (caller == 'supptool') {
6807:): suppflag = 1;
6808:): }
6809:): currForm = document.getElementById('new'+caller);
6810:): updateExttool(toolselector,currForm,suppflag);
6811:): }
6812:): }
6813:): }
1.484.2.13 raeburn 6814: }
6815: resize_scrollbox('contentscroll','1','1');
6816: return;
6817: }
6818:
1.484.2.19 raeburn 6819: function toggleMap(caller) {
1.484.2.13 raeburn 6820: var disp = 'none';
1.484.2.19 raeburn 6821: if (document.getElementById('importmapform')) {
6822: if (caller == 'map') {
6823: var curr = document.getElementById('importmapform').style.display;
6824: if (curr == 'none') {
6825: disp='block';
6826: }
1.484.2.12 raeburn 6827: }
1.484.2.19 raeburn 6828: document.getElementById('importmapform').style.display=disp;
6829: resize_scrollbox('contentscroll','1','1');
1.484.2.12 raeburn 6830: }
1.484.2.19 raeburn 6831: return;
1.329 droeschl 6832: }
6833:
1.484.2.12 raeburn 6834: function makeims(imsform) {
6835: if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
1.484.2.61 raeburn 6836: alert("$js_lt{'imsfile'}");
1.484.2.12 raeburn 6837: return;
6838: }
6839: if (imsform.source.selectedIndex == 0) {
1.484.2.61 raeburn 6840: alert("$js_lt{'imscms'}");
1.484.2.12 raeburn 6841: return;
6842: }
6843: newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
6844: imsform.submit();
6845: }
6846:
1.478 raeburn 6847: function updatePick(targetform,index,caller) {
1.484.2.29 raeburn 6848: var pickitem;
6849: var picknumitem;
6850: var picknumtext;
6851: if (index == 'all') {
6852: pickitem = document.getElementById('randompickall');
6853: picknumitem = document.getElementById('rpicknumall');
6854: picknumtext = document.getElementById('rpicktextall');
6855: } else {
6856: pickitem = document.getElementById('randompick_'+index);
6857: picknumitem = document.getElementById('rpicknum_'+index);
6858: picknumtext = document.getElementById('randompicknum_'+index);
6859: }
1.478 raeburn 6860: if (pickitem.checked) {
1.484.2.61 raeburn 6861: var picknum=prompt('$js_lt{"rpck"}',picknumitem.value);
1.478 raeburn 6862: if (picknum == '' || picknum == null) {
6863: if (caller == 'check') {
6864: pickitem.checked=false;
1.484.2.29 raeburn 6865: if (index == 'all') {
6866: picknumtext.innerHTML = '';
6867: if (caller == 'link') {
6868: propagateState(targetform,'rpicknum');
6869: }
6870: } else {
1.484.2.30 raeburn 6871: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 6872: }
1.478 raeburn 6873: }
6874: } else {
6875: picknum.toString();
6876: var regexdigit=/^\\d+\$/;
6877: if (regexdigit.test(picknum)) {
6878: picknumitem.value = picknum;
1.484.2.29 raeburn 6879: if (index == 'all') {
1.484.2.30 raeburn 6880: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.cumulativesettings,\\'all\\',\\'link\\');">'+picknum+'</a>';
1.484.2.29 raeburn 6881: if (caller == 'link') {
6882: propagateState(targetform,'rpicknum');
6883: }
6884: } else {
6885: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.edit_randompick_'+index+',\\''+index+'\\',\\'link\\');">'+picknum+'</a>';
1.484.2.30 raeburn 6886: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 6887: }
1.478 raeburn 6888: } else {
6889: if (caller == 'check') {
1.484.2.29 raeburn 6890: if (index == 'all') {
6891: picknumtext.innerHTML = '';
6892: if (caller == 'link') {
6893: propagateState(targetform,'rpicknum');
6894: }
6895: } else {
6896: pickitem.checked=false;
1.484.2.30 raeburn 6897: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 6898: }
1.478 raeburn 6899: }
6900: return;
6901: }
6902: }
6903: } else {
1.484.2.29 raeburn 6904: picknumitem.value = '';
6905: picknumtext.innerHTML = '';
6906: if (index == 'all') {
6907: if (caller == 'link') {
6908: propagateState(targetform,'rpicknum');
6909: }
6910: } else {
1.484.2.30 raeburn 6911: checkForSubmit(targetform,'randompick','settings');
1.484.2.29 raeburn 6912: }
6913: }
6914: }
6915:
6916: function propagateState(form,param) {
6917: if (document.getElementById(param+'all')) {
6918: var setcheck = 0;
6919: var rpick = 0;
6920: if (param == 'rpicknum') {
6921: if (document.getElementById('randompickall')) {
6922: if (document.getElementById('randompickall').checked) {
6923: if (document.getElementById('rpicknumall')) {
6924: rpick = document.getElementById('rpicknumall').value;
6925: }
6926: }
6927: }
6928: } else {
6929: if (document.getElementById(param+'all').checked) {
6930: setcheck = 1;
6931: }
6932: }
1.484.2.30 raeburn 6933: var allidxlist;
6934: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
6935: if (document.getElementById('all'+param+'idx')) {
6936: allidxlist = document.getElementById('all'+param+'idx').value;
6937: }
6938: var actions = new Array ('remove','cut','copy');
6939: for (var i=0; i<actions.length; i++) {
6940: if (actions[i] != param) {
6941: if (document.getElementById(actions[i]+'all')) {
6942: document.getElementById(actions[i]+'all').checked = false;
6943: }
6944: }
6945: }
6946: }
1.484.2.29 raeburn 6947: if ((param == 'encrypturl') || (param == 'hiddenresource')) {
1.484.2.30 raeburn 6948: allidxlist = form.allidx.value;
6949: }
6950: if ((param == 'randompick') || (param == 'rpicknum') || (param == 'randomorder')) {
6951: allidxlist = form.allmapidx.value;
6952: }
6953: if ((allidxlist != '') && (allidxlist != null)) {
6954: var allidxs = allidxlist.split(',');
6955: if (allidxs.length > 1) {
6956: for (var i=0; i<allidxs.length; i++) {
6957: if (document.getElementById(param+'_'+allidxs[i])) {
6958: if (param == 'rpicknum') {
6959: if (document.getElementById('randompick_'+allidxs[i])) {
6960: if (document.getElementById('randompick_'+allidxs[i]).checked) {
6961: document.getElementById(param+'_'+allidxs[i]).value = rpick;
6962: if (rpick > 0) {
6963: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = ': <a href="javascript:updatePick(document.edit_randompick_'+allidxs[i]+',\\''+allidxs[i]+'\\',\\'link\\')">'+rpick+'</a>';
6964: } else {
6965: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
6966: }
6967: }
6968: }
6969: } else {
1.484.2.29 raeburn 6970: if (setcheck == 1) {
6971: document.getElementById(param+'_'+allidxs[i]).checked = true;
6972: } else {
6973: document.getElementById(param+'_'+allidxs[i]).checked = false;
1.484.2.30 raeburn 6974: if (param == 'randompick') {
6975: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
6976: }
1.484.2.29 raeburn 6977: }
6978: }
6979: }
6980: }
1.484.2.30 raeburn 6981: if (setcheck == 1) {
6982: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
6983: var actions = new Array('copy','cut','remove');
6984: for (var i=0; i<actions.length; i++) {
6985: var otheractions;
6986: var otheridxs;
6987: if (actions[i] === param) {
6988: continue;
6989: } else {
6990: if (document.getElementById('all'+actions[i]+'idx')) {
6991: otheractions = document.getElementById('all'+actions[i]+'idx').value;
6992: otheridxs = otheractions.split(',');
6993: if (otheridxs.length > 1) {
6994: for (var j=0; j<otheridxs.length; j++) {
6995: if (document.getElementById(actions[i]+'_'+otheridxs[j])) {
6996: document.getElementById(actions[i]+'_'+otheridxs[j]).checked = false;
6997: }
1.484.2.29 raeburn 6998: }
6999: }
7000: }
7001: }
1.484.2.30 raeburn 7002: }
1.484.2.29 raeburn 7003: }
7004: }
7005: }
7006: }
1.478 raeburn 7007: }
1.484.2.29 raeburn 7008: return;
7009: }
7010:
1.484.2.63 raeburn 7011: function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder,confirm_removal) {
1.484.2.67 raeburn 7012: var canedit = '$canedit';
7013: if (canedit == '') {
7014: alert("$js_lt{'edri'}");
7015: return;
7016: }
1.484.2.30 raeburn 7017: var dosettings;
7018: var doaction;
7019: var control = document.togglemultsettings;
7020: if (context == 'actions') {
7021: control = document.togglemultactions;
7022: doaction = 1;
7023: } else {
7024: dosettings = 1;
7025: }
7026: if (control) {
7027: if (control.showmultpick.length) {
7028: for (var i=0; i<control.showmultpick.length; i++) {
7029: if (control.showmultpick[i].checked) {
7030: if (control.showmultpick[i].value == 1) {
7031: if (context == 'settings') {
7032: dosettings = 0;
7033: } else {
7034: doaction = 0;
7035: }
7036: }
7037: }
7038: }
7039: }
7040: }
7041: if (context == 'settings') {
7042: if (dosettings == 1) {
7043: targetform.changeparms.value=param;
7044: targetform.submit();
7045: }
7046: }
7047: if (context == 'actions') {
7048: if (doaction == 1) {
7049: targetform.cmd.value=param+'_'+index;
7050: targetform.folderpath.value=folderpath;
7051: targetform.markcopy.value=idx+':'+param;
7052: targetform.copyfolder.value=folder+'.'+container;
7053: if (param == 'remove') {
1.484.2.63 raeburn 7054: var doremove = 0;
7055: if (skip_confirm) {
7056: if (confirm_removal) {
7057: if (confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'"$js_lt{"p_rmr2b"}')) {
7058: doremove = 1;
7059: }
7060: } else {
7061: doremove = 1;
7062: }
7063: } else {
7064: if (confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'" $js_lt{"p_rmr2b"}')) {
7065: doremove = 1;
7066: }
7067: }
7068: if (doremove) {
1.484.2.30 raeburn 7069: targetform.markcopy.value='';
7070: targetform.copyfolder.value='';
1.484.2.29 raeburn 7071: targetform.submit();
7072: }
7073: }
1.484.2.30 raeburn 7074: if (param == 'cut') {
1.484.2.61 raeburn 7075: 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 7076: targetform.submit();
7077: return;
7078: }
7079: }
7080: if (param == 'copy') {
7081: targetform.submit();
7082: return;
7083: }
7084: targetform.markcopy.value='';
7085: targetform.copyfolder.value='';
7086: targetform.cmd.value='';
7087: targetform.folderpath.value='';
7088: return;
7089: } else {
7090: if (document.getElementById(param+'_'+idx)) {
7091: item = document.getElementById(param+'_'+idx);
7092: if (item.type == 'checkbox') {
7093: if (item.checked) {
7094: item.checked = false;
7095: } else {
7096: item.checked = true;
7097: singleCheck(item,idx,param);
7098: }
7099: }
7100: }
7101: }
7102: }
7103: return;
7104: }
7105:
7106: function singleCheck(caller,idx,action) {
7107: actions = new Array('cut','copy','remove');
7108: if (caller.checked) {
7109: for (var i=0; i<actions.length; i++) {
7110: if (actions[i] != action) {
7111: if (document.getElementById(actions[i]+'_'+idx)) {
7112: if (document.getElementById(actions[i]+'_'+idx).checked) {
7113: document.getElementById(actions[i]+'_'+idx).checked = false;
7114: }
7115: }
7116: }
1.484.2.29 raeburn 7117: }
7118: }
7119: return;
1.478 raeburn 7120: }
7121:
1.334 muellerd 7122: function unselectInactive(nav) {
1.335 ehlerst 7123: currentNav = document.getElementById(nav);
7124: currentLis = currentNav.getElementsByTagName('LI');
7125: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 7126: if (currentLis[i].className == 'goback') {
7127: currentLis[i].className = 'goback';
7128: } else {
7129: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 7130: currentLis[i].className = 'right';
1.472 raeburn 7131: } else {
1.374 tempelho 7132: currentLis[i].className = 'i';
1.472 raeburn 7133: }
7134: }
1.335 ehlerst 7135: }
1.332 tempelho 7136: }
7137:
1.334 muellerd 7138: function hideAll(current, nav, data) {
1.335 ehlerst 7139: unselectInactive(nav);
1.484.2.43 raeburn 7140: if (current) {
7141: if (current.className == 'right'){
1.374 tempelho 7142: current.className = 'right active'
1.484.2.43 raeburn 7143: } else {
1.374 tempelho 7144: current.className = 'active';
1.484.2.43 raeburn 7145: }
1.374 tempelho 7146: }
1.335 ehlerst 7147: currentData = document.getElementById(data);
7148: currentDivs = currentData.getElementsByTagName('DIV');
7149: for (i = 0; i < currentDivs.length; i++) {
7150: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 7151: currentDivs[i].style.display = 'none';
1.330 tempelho 7152: }
7153: }
1.335 ehlerst 7154: }
1.330 tempelho 7155:
1.374 tempelho 7156: function openTabs(pageId) {
7157: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 7158: if(tabnav.length > 2 ){
1.389 tempelho 7159: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 7160: currentLis = currentNav.getElementsByTagName('LI');
7161: for(i = 0; i< currentLis.length; i++){
7162: if(currentLis[i].className == 'active') {
1.375 tempelho 7163: funcString = currentLis[i].onclick.toString();
7164: tab = funcString.split('"');
1.420 onken 7165: if(tab.length < 2) {
7166: tab = funcString.split("'");
7167: }
1.375 tempelho 7168: currentData = document.getElementById(tab[1]);
7169: currentData.style.display = 'block';
1.374 tempelho 7170: }
7171: }
7172: }
7173: }
7174:
1.334 muellerd 7175: function showPage(current, pageId, nav, data) {
1.484.2.43 raeburn 7176: currstate = current.className;
1.334 muellerd 7177: hideAll(current, nav, data);
1.375 tempelho 7178: openTabs(pageId);
1.334 muellerd 7179: unselectInactive(nav);
1.484.2.43 raeburn 7180: if ((currstate == 'active') || (currstate == 'right active')) {
7181: if (currstate == 'active') {
7182: current.className = '';
7183: } else {
7184: current.className = 'right';
7185: }
7186: activeTab = '';
7187: toggleUpload();
7188: toggleMap();
7189: resize_scrollbox('contentscroll','1','0');
7190: return;
7191: } else {
7192: current.className = 'active';
7193: }
1.330 tempelho 7194: currentData = document.getElementById(pageId);
7195: currentData.style.display = 'block';
1.458 raeburn 7196: activeTab = pageId;
1.484.2.12 raeburn 7197: toggleUpload();
1.484.2.14 raeburn 7198: toggleMap();
1.433 raeburn 7199: if (nav == 'mainnav') {
7200: var storedpath = "$docs_folderpath";
1.434 raeburn 7201: var storedpage = "$main_container_page";
1.433 raeburn 7202: var reg = new RegExp("^supplemental");
7203: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 7204: if (storedpage == 1) {
7205: document.simpleedit.folderpath.value = '';
7206: document.uploaddocument.folderpath.value = '';
7207: } else {
7208: if (reg.test(storedpath)) {
7209: document.simpleedit.folderpath.value = '$toplevelmain';
7210: document.uploaddocument.folderpath.value = '$toplevelmain';
7211: document.newext.folderpath.value = '$toplevelmain';
7212: } else {
7213: document.simpleedit.folderpath.value = storedpath;
7214: document.uploaddocument.folderpath.value = storedpath;
7215: document.newext.folderpath.value = storedpath;
7216: }
1.433 raeburn 7217: }
7218: } else {
1.434 raeburn 7219: if (reg.test(storedpath)) {
7220: document.simpleedit.folderpath.value = storedpath;
7221: document.supuploaddocument.folderpath.value = storedpath;
7222: document.supnewext.folderpath.value = storedpath;
7223: } else {
1.433 raeburn 7224: document.simpleedit.folderpath.value = '$toplevelsupp';
7225: document.supuploaddocument.folderpath.value = '$toplevelsupp';
7226: document.supnewext.folderpath.value = '$toplevelsupp';
7227: }
7228: }
7229: }
1.484.2.3 raeburn 7230: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 7231: return false;
7232: }
1.329 droeschl 7233:
1.472 raeburn 7234: function toContents(jumpto) {
7235: var newurl = '$backtourl';
1.484.2.21 raeburn 7236: if ((newurl == '/adm/navmaps') && (jumpto != '')) {
1.472 raeburn 7237: newurl = newurl+'?postdata='+jumpto;
7238: }
7239: location.href=newurl;
7240: }
7241:
1.484.2.30 raeburn 7242: function togglePick(caller,value) {
7243: var disp = 'none';
7244: if (document.getElementById('multi'+caller)) {
7245: var curr = document.getElementById('multi'+caller).style.display;
7246: if (value == 1) {
7247: disp='block';
7248: }
7249: if (curr == disp) {
7250: return;
7251: }
7252: document.getElementById('multi'+caller).style.display=disp;
7253: if (value == 1) {
1.484.2.61 raeburn 7254: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.484.2.30 raeburn 7255: } else {
7256: document.getElementById('more'+caller).innerHTML = '';
7257: }
7258: if (caller == 'actions') {
7259: setClass(value);
7260: setBoxes(value);
7261: }
7262: }
7263: var showButton = multiSettings();
7264: if (showButton != 1) {
7265: showButton = multiActions();
7266: }
7267: if (document.getElementById('multisave')) {
7268: if (showButton == 1) {
7269: document.getElementById('multisave').style.display='block';
7270: } else {
7271: document.getElementById('multisave').style.display='none';
7272: }
7273: }
7274: resize_scrollbox('contentscroll','1','1');
7275: return;
7276: }
7277:
7278: function toggleCheckUncheck(caller,more) {
7279: if (more == 1) {
1.484.2.61 raeburn 7280: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',0);" style="text-decoration:none;">$js_lt{'less'}</a>';
1.484.2.30 raeburn 7281: document.getElementById('allfields'+caller).style.display='block';
7282: } else {
1.484.2.61 raeburn 7283: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.484.2.30 raeburn 7284: document.getElementById('allfields'+caller).style.display='none';
7285: }
7286: resize_scrollbox('contentscroll','1','1');
7287: }
7288:
7289: function multiSettings() {
7290: var inuse = 0;
7291: var settingsform = document.togglemultsettings;
7292: if (settingsform.showmultpick.length > 1) {
7293: for (var i=0; i<settingsform.showmultpick.length; i++) {
7294: if (settingsform.showmultpick[i].checked) {
7295: if (settingsform.showmultpick[i].value == 1) {
7296: inuse = 1;
7297: }
7298: }
7299: }
7300: }
7301: return inuse;
7302: }
7303:
7304: function multiActions() {
7305: var inuse = 0;
7306: var actionsform = document.togglemultactions;
7307: if (actionsform.showmultpick.length > 1) {
7308: for (var i=0; i<actionsform.showmultpick.length; i++) {
7309: if (actionsform.showmultpick[i].checked) {
7310: if (actionsform.showmultpick[i].value == 1) {
7311: inuse = 1;
7312: }
7313: }
7314: }
7315: }
7316: return inuse;
7317: }
7318:
7319: function checkSubmits() {
7320: var numchanges = 0;
7321: var form = document.saveactions;
7322: var doactions = multiActions();
7323: var cutwarnings = 0;
7324: var remwarnings = 0;
1.484.2.63 raeburn 7325: var removalinfo = 0;
1.484.2.30 raeburn 7326: if (doactions == 1) {
7327: var remidxlist = document.cumulativeactions.allremoveidx.value;
7328: if ((remidxlist != '') && (remidxlist != null)) {
7329: var remidxs = remidxlist.split(',');
7330: for (var i=0; i<remidxs.length; i++) {
7331: if (document.getElementById('remove_'+remidxs[i])) {
7332: if (document.getElementById('remove_'+remidxs[i]).checked) {
7333: form.multiremove.value += remidxs[i]+',';
7334: numchanges ++;
7335: if (document.getElementById('skip_remove_'+remidxs[i])) {
7336: if (document.getElementById('skip_remove_'+remidxs[i]).value == 0) {
7337: remwarnings ++;
7338: }
7339: }
1.484.2.63 raeburn 7340: if (document.getElementById('confirm_removal_'+remidxs[i])) {
7341: if (document.getElementById('confirm_removal_'+remidxs[i]).value == 1) {
7342: removalinfo ++;
7343: }
7344: }
1.484.2.30 raeburn 7345: }
7346: }
7347: }
7348: }
7349: var cutidxlist = document.cumulativeactions.allcutidx.value;
7350: if ((cutidxlist != '') && (cutidxlist != null)) {
7351: var cutidxs = cutidxlist.split(',');
7352: for (var i=0; i<cutidxs.length; i++) {
7353: if (document.getElementById('cut_'+cutidxs[i])) {
7354: if (document.getElementById('cut_'+cutidxs[i]).checked == true) {
7355: form.multicut.value += cutidxs[i]+',';
7356: numchanges ++;
7357: if (document.getElementById('skip_cut_'+cutidxs[i])) {
7358: if (document.getElementById('skip_cut_'+cutidxs[i]).value == 0) {
7359: cutwarnings ++;
7360: }
7361: }
7362: }
7363: }
7364: }
7365: }
7366: var copyidxlist = document.cumulativeactions.allcopyidx.value;
7367: if ((copyidxlist != '') && (copyidxlist != null)) {
7368: var copyidxs = copyidxlist.split(',');
7369: for (var i=0; i<copyidxs.length; i++) {
7370: if (document.getElementById('copy_'+copyidxs[i])) {
7371: if (document.getElementById('copy_'+copyidxs[i]).checked) {
7372: form.multicopy.value += copyidxs[i]+',';
7373: numchanges ++;
7374: }
7375: }
7376: }
7377: }
7378: if (numchanges > 0) {
7379: form.multichange.value = numchanges;
7380: }
7381: }
7382: var dosettings = multiSettings();
7383: var haschanges = 0;
7384: if (dosettings == 1) {
7385: form.allencrypturl.value = '';
7386: form.allhiddenresource.value = '';
7387: form.changeparms.value = 'all';
7388: var patt=new RegExp(",\$");
7389: var allidxlist = document.cumulativesettings.allidx.value;
7390: if ((allidxlist != '') && (allidxlist != null)) {
7391: var allidxs = allidxlist.split(',');
7392: if (allidxs.length > 1) {
7393: for (var i=0; i<allidxs.length; i++) {
7394: if (document.getElementById('hiddenresource_'+allidxs[i])) {
7395: if (document.getElementById('hiddenresource_'+allidxs[i]).checked) {
7396: form.allhiddenresource.value += allidxs[i]+',';
7397: }
7398: }
7399: if (document.getElementById('encrypturl_'+allidxs[i])) {
7400: if (document.getElementById('encrypturl_'+allidxs[i]).checked) {
7401: form.allencrypturl.value += allidxs[i]+',';
7402: }
1.484.2.29 raeburn 7403: }
7404: }
1.484.2.30 raeburn 7405: form.allhiddenresource.value = form.allhiddenresource.value.replace(patt,"");
7406: form.allencrypturl.value = form.allencrypturl.value.replace(patt,"");
7407: }
7408: }
7409: form.allrandompick.value = '';
7410: form.allrandomorder.value = '';
7411: var allmapidxlist = document.cumulativesettings.allmapidx.value;
7412: if ((allmapidxlist != '') && (allmapidxlist != null)) {
7413: var allmapidxs = allmapidxlist.split(',');
7414: for (var i=0; i<allmapidxs.length; i++) {
7415: var randompick = document.getElementById('randompick_'+allmapidxs[i]);
7416: var rpicknum = document.getElementById('rpicknum_'+allmapidxs[i]);
7417: var randorder = document.getElementById('randomorder_'+allmapidxs[i]);
7418: if ((randompick.checked) && (rpicknum.value != '')) {
7419: form.allrandompick.value += allmapidxs[i]+':'+rpicknum.value+',';
7420: }
7421: if (randorder.checked) {
7422: form.allrandomorder.value += allmapidxs[i]+',';
7423: }
7424: }
7425: form.allrandompick.value = form.allrandompick.value.replace(patt,"");
7426: form.allrandomorder.value = form.allrandomorder.value.replace(patt,"");
7427: }
7428: if (document.cumulativesettings.currhiddenresource.value != form.allhiddenresource.value) {
7429: haschanges = 1;
7430: }
7431: if (document.cumulativesettings.currencrypturl.value != form.allencrypturl.value) {
7432: haschanges = 1;
7433: }
7434: if (document.cumulativesettings.currrandomorder.value != form.allrandomorder.value) {
7435: haschanges = 1;
7436: }
7437: if (document.cumulativesettings.currrandompick.value != form.allrandompick.value) {
7438: haschanges = 1;
7439: }
7440: }
7441: if (doactions == 1) {
7442: if (numchanges > 0) {
1.484.2.63 raeburn 7443: if ((cutwarnings > 0) || (remwarnings > 0) || (removalinfo > 0)) {
1.484.2.30 raeburn 7444: if (remwarnings > 0) {
1.484.2.61 raeburn 7445: if (!confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr3a"} '+remwarnings+' $js_lt{"p_rmr3b"}')) {
1.484.2.30 raeburn 7446: return false;
7447: }
7448: }
1.484.2.63 raeburn 7449: if (removalinfo > 0) {
7450: if (!confirm('$js_lt{"p_rmr4"}\\n$js_lt{"p_rmr5"}\\n\\n$js_lt{"p_rmr3a"} '+removalinfo+' $js_lt{"p_rmr3b"}')) {
7451: return false;
7452: }
7453: }
1.484.2.30 raeburn 7454: if (cutwarnings > 0) {
1.484.2.61 raeburn 7455: 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 7456: return false;
1.484.2.29 raeburn 7457: }
7458: }
7459: }
1.484.2.30 raeburn 7460: form.submit();
7461: return true;
7462: }
7463: }
7464: if (dosettings == 1) {
7465: if (haschanges == 1) {
7466: form.submit();
7467: return true;
1.484.2.29 raeburn 7468: }
7469: }
1.484.2.30 raeburn 7470: if ((dosettings == 1) && (doactions == 1)) {
1.484.2.61 raeburn 7471: alert("$js_lt{'noor'}");
1.484.2.30 raeburn 7472: } else {
7473: if (dosettings == 1) {
1.484.2.61 raeburn 7474: alert("$js_lt{'noch'}");
1.484.2.30 raeburn 7475: } else {
1.484.2.61 raeburn 7476: alert("$js_lt{'noac'}");
1.484.2.30 raeburn 7477: }
7478: }
7479: return false;
7480: }
7481:
7482: function setClass(value) {
7483: var cutclass = 'LC_docs_cut';
7484: var copyclass = 'LC_docs_copy';
7485: var removeclass = 'LC_docs_remove';
7486: var cutreg = new RegExp("\\\\b"+cutclass+"\\\\b");
7487: var copyreg = new RegExp("\\\\b"+copyclass+"\\\\b");
7488: var removereg = new RegExp("\\\\"+removeclass+"\\\\b");
7489: var links = document.getElementsByTagName('a');
7490: for (var i=0; i<links.length; i++) {
7491: var classes = links[i].className;
7492: if (cutreg.test(classes)) {
7493: links[i].className = cutclass;
7494: if (value == 1) {
7495: links[i].className += " LC_menubuttons_link";
1.484.2.29 raeburn 7496: }
1.484.2.30 raeburn 7497: } else {
7498: if (copyreg.test(classes)) {
7499: links[i].className = copyclass;
7500: if (value == 1) {
7501: links[i].className += " LC_menubuttons_link";
7502: }
7503: } else {
7504: if (removereg.test(classes)) {
7505: links[i].className = removeclass;
7506: if (value == 1) {
7507: links[i].className += " LC_menubuttons_link";
7508: }
7509: }
1.484.2.29 raeburn 7510: }
7511: }
7512: }
1.484.2.30 raeburn 7513: return;
1.484.2.29 raeburn 7514: }
7515:
1.484.2.30 raeburn 7516: function setBoxes(value) {
7517: var remidxlist = document.cumulativeactions.allremoveidx.value;
7518: if ((remidxlist != '') && (remidxlist != null)) {
7519: var remidxs = remidxlist.split(',');
7520: for (var i=0; i<remidxs.length; i++) {
7521: if (document.getElementById('remove_'+remidxs[i])) {
7522: var item = document.getElementById('remove_'+remidxs[i]);
7523: if (value == 1) {
7524: item.className = 'LC_docs_remove';
7525: } else {
7526: item.className = 'LC_hidden';
7527: }
7528: }
1.484.2.29 raeburn 7529: }
7530: }
1.484.2.30 raeburn 7531: var cutidxlist = document.cumulativeactions.allcutidx.value;
7532: if ((cutidxlist != '') && (cutidxlist != null)) {
7533: var cutidxs = cutidxlist.split(',');
7534: for (var i=0; i<cutidxs.length; i++) {
7535: if (document.getElementById('cut_'+cutidxs[i])) {
7536: var item = document.getElementById('cut_'+cutidxs[i]);
7537: if (value == 1) {
7538: item.className = 'LC_docs_cut';
7539: } else {
7540: item.className = 'LC_hidden';
7541: }
7542: }
7543: }
7544: }
7545: var copyidxlist = document.cumulativeactions.allcopyidx.value;
7546: if ((copyidxlist != '') && (copyidxlist != null)) {
7547: var copyidxs = copyidxlist.split(',');
7548: for (var i=0; i<copyidxs.length; i++) {
7549: if (document.getElementById('copy_'+copyidxs[i])) {
7550: var item = document.getElementById('copy_'+copyidxs[i]);
7551: if (value == 1) {
7552: item.className = 'LC_docs_copy';
7553: } else {
7554: item.className = 'LC_hidden';
7555: }
7556: }
1.484.2.29 raeburn 7557: }
7558: }
7559: return;
7560: }
7561:
1.484.2.67 raeburn 7562: ENDSCRIPT
1.329 droeschl 7563: }
1.457 raeburn 7564:
1.483 raeburn 7565: sub history_tab_js {
7566: return <<"ENDHIST";
7567: function toggleHistoryDisp(choice) {
7568: document.docslogform.docslog.value = choice;
7569: document.docslogform.submit();
7570: return;
7571: }
7572:
7573: ENDHIST
7574: }
7575:
1.484 raeburn 7576: sub inject_data_js {
7577: return <<ENDINJECT;
7578:
7579: function injectData(current, hiddenField, name, value) {
7580: currentElement = document.getElementById(hiddenField);
7581: currentElement.name = name;
7582: currentElement.value = value;
7583: current.submit();
7584: }
7585:
7586: ENDINJECT
7587: }
7588:
7589: sub dump_switchserver_js {
7590: my @hosts = @_;
1.484.2.61 raeburn 7591: my %js_lt = &Apache::lonlocal::texthash(
1.484.2.46 raeburn 7592: dump => 'Copying content to Authoring Space requires switching server.',
1.484 raeburn 7593: swit => 'Switch server?',
1.484.2.61 raeburn 7594: );
7595: my %html_js_lt = &Apache::lonlocal::texthash(
7596: swit => 'Switch server?',
1.484.2.43 raeburn 7597: duco => 'Copying Content to Authoring Space',
1.484 raeburn 7598: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
7599: chos => 'Choose server',
7600: );
1.484.2.61 raeburn 7601: &js_escape(\%js_lt);
7602: &html_escape(\%html_js_lt);
7603: &js_escape(\%html_js_lt);
1.484 raeburn 7604: my $role = $env{'request.role'};
7605: my $js = <<"ENDSWJS";
7606: <script type="text/javascript">
7607: function write_switchserver() {
7608: var server;
7609: if (document.setserver.posshosts.length > 0) {
7610: for (var i=0; i<document.setserver.posshosts.length; i++) {
7611: if (document.setserver.posshosts[i].checked) {
7612: server = document.setserver.posshosts[i].value;
7613: }
7614: }
7615: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
7616: }
7617: window.close();
7618: }
7619: </script>
7620:
7621: ENDSWJS
7622:
7623: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
7624: {'only_body' => 1,
7625: 'js_ready' => 1,});
7626: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
7627:
7628: my $hostpicker;
7629: my $count = 0;
7630: foreach my $host (sort(@hosts)) {
7631: my $checked;
7632: if ($count == 0) {
7633: $checked = ' checked="checked"';
7634: }
7635: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
7636: $host.'"'.$checked.' />'.$host.'</label> ';
7637: $count++;
7638: }
7639:
7640: return <<"ENDSWITCHJS";
7641:
7642: function dump_needs_switchserver(url) {
7643: if (url!='' && url!= null) {
1.484.2.61 raeburn 7644: if (confirm("$js_lt{'dump'}\\n$js_lt{'swit'}")) {
1.484 raeburn 7645: go(url);
7646: }
7647: }
7648: return;
7649: }
7650:
7651: function choose_switchserver_window() {
7652: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
7653: newWindow.document.open();
7654: newWindow.document.writeln('$startpage');
1.484.2.61 raeburn 7655: newWindow.document.write('<h3>$html_js_lt{'duco'}<\\/h3>\\n'+
7656: '<p>$html_js_lt{'yone'}<\\/p>\\n'+
7657: '<div class="LC_left_float"><fieldset><legend>$html_js_lt{'chos'}<\\/legend>\\n'+
1.484 raeburn 7658: '<form name="setserver" method="post" action="" \\/>\\n'+
7659: '$hostpicker\\n'+
7660: '<br \\/><br \\/>\\n'+
1.484.2.61 raeburn 7661: '<input type="button" name="makeswitch" value="$html_js_lt{'swit'}" '+
1.484 raeburn 7662: 'onclick="write_switchserver();" \\/>\\n'+
7663: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
7664: newWindow.document.writeln('$endpage');
7665: newWindow.document.close();
7666: newWindow.focus();
7667: }
7668:
7669: ENDSWITCHJS
7670: }
7671:
7672: sub makedocslogform {
7673: my ($formelems,$docslog) = @_;
7674: return <<"LOGSFORM";
7675: <form action="/adm/coursedocs" method="post" name="docslogform">
7676: <input type="hidden" name="docslog" value="$docslog" />
7677: $formelems
7678: </form>
7679: LOGSFORM
7680: }
7681:
7682: sub makesimpleeditform {
7683: my ($formelems) = @_;
7684: return <<"SIMPFORM";
7685: <form name="simpleedit" method="post" action="/adm/coursedocs">
7686: <input type="hidden" name="importdetail" value="" />
7687: $formelems
7688: </form>
7689: SIMPFORM
7690: }
7691:
1.329 droeschl 7692: 1;
7693: __END__
7694:
7695:
7696: =head1 NAME
7697:
7698: Apache::londocs.pm
7699:
7700: =head1 SYNOPSIS
7701:
7702: This is part of the LearningOnline Network with CAPA project
7703: described at http://www.lon-capa.org.
7704:
7705: =head1 SUBROUTINES
7706:
7707: =over
7708:
7709: =item %help=()
7710:
7711: Available help topics
7712:
7713: =item mapread()
7714:
1.344 bisitz 7715: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 7716: @order and @resources, determines status
7717: sets @order - pointer to resources in right order
7718: sets @resources - array with the resources with correct idx
7719:
7720: =item authorhosts()
7721:
7722: Return hash with valid author names
7723:
7724: =item clean()
7725:
7726: =item dumpcourse()
7727:
7728: Actually dump course
7729:
7730: =item group_import()
7731:
7732: Imports the given (name, url) resources into the course
7733: coursenum, coursedom, and folder must precede the list
7734:
7735: =item breadcrumbs()
7736:
7737: =item log_docs()
7738:
7739: =item docs_change_log()
7740:
7741: =item update_paste_buffer()
7742:
7743: =item print_paste_buffer()
7744:
7745: =item do_paste_from_buffer()
7746:
1.484.2.30 raeburn 7747: =item do_buffer_empty()
7748:
7749: =item clear_from_buffer()
7750:
1.484.2.7 raeburn 7751: =item get_newmap_url()
7752:
7753: =item dbcopy()
7754:
7755: =item uniqueness_check()
7756:
7757: =item contained_map_check()
7758:
7759: =item url_paste_fixups()
7760:
7761: =item apply_fixups()
7762:
7763: =item copy_dependencies()
7764:
1.329 droeschl 7765: =item update_parameter()
7766:
7767: =item handle_edit_cmd()
7768:
7769: =item editor()
7770:
7771: =item process_file_upload()
7772:
7773: =item process_secondary_uploads()
7774:
7775: =item is_supplemental_title()
7776:
7777: =item entryline()
7778:
7779: =item tiehash()
7780:
7781: =item untiehash()
7782:
7783: =item checkonthis()
7784:
7785: check on this
7786:
7787: =item verifycontent()
7788:
7789: Verify Content
7790:
1.484.2.72.2. (raeburn 7791:): =item devalidateversioncache()
7792:):
7793:): =item checkversions()
1.329 droeschl 7794:
7795: Check Versions
7796:
7797: =item mark_hash_old()
7798:
7799: =item is_hash_old()
7800:
7801: =item changewarning()
7802:
7803: =item init_breadcrumbs()
7804:
7805: Breadcrumbs for special functions
7806:
1.484 raeburn 7807: =item create_list_elements()
7808:
7809: =item create_form_ul()
7810:
7811: =item startContentScreen()
7812:
7813: =item endContentScreen()
7814:
7815: =item supplemental_base()
7816:
7817: =item embedded_form_elems()
7818:
7819: =item embedded_destination()
7820:
7821: =item return_to_editor()
7822:
7823: =item decompression_info()
7824:
7825: =item decompression_phase_one()
7826:
7827: =item decompression_phase_two()
7828:
7829: =item remove_archive()
7830:
7831: =item generate_admin_menu()
7832:
7833: =item generate_edit_table()
7834:
7835: =item editing_js()
7836:
7837: =item history_tab_js()
7838:
7839: =item inject_data_js()
7840:
7841: =item dump_switchserver_js()
7842:
1.484.2.3 raeburn 7843: =item resize_scrollbox_js()
1.484 raeburn 7844:
7845: =item makedocslogform()
7846:
1.484.2.3 raeburn 7847: =item makesimpleeditform()
7848:
1.329 droeschl 7849: =back
7850:
7851: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>