Annotation of loncom/interface/londocs.pm, revision 1.599
1.329 droeschl 1: # The LearningOnline Network
2: # Documents
3: #
1.599 ! damieng 4: # $Id: londocs.pm,v 1.598 2016/01/26 14:30:25 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.510 raeburn 43: use Apache::lonextresedit();
1.567 raeburn 44: use Apache::lontemplate();
45: use Apache::lonsimplepage();
1.329 droeschl 46: use HTML::Entities;
1.488 raeburn 47: use HTML::TokeParser;
1.329 droeschl 48: use GDBM_File;
1.578 raeburn 49: use File::MMagic;
1.329 droeschl 50: use Apache::lonlocal;
51: use Cwd;
52: use LONCAPA qw(:DEFAULT :match);
53:
54: my $iconpath;
55:
56: my %hash;
57:
58: my $hashtied;
59: my %alreadyseen=();
60:
61: my $hadchanges;
1.557 raeburn 62: my $suppchanges;
1.329 droeschl 63:
64:
65: my %help=();
66:
67:
68: sub mapread {
69: my ($coursenum,$coursedom,$map)=@_;
70: return
71: &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
72: $map);
73: }
74:
75: sub storemap {
1.492 raeburn 76: my ($coursenum,$coursedom,$map,$contentchg)=@_;
77: my $report;
78: if (($contentchg) && ($map =~ /^default/)) {
79: $report = 1;
80: }
1.329 droeschl 81: my ($outtext,$errtext)=
82: &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.492 raeburn 83: $map,1,$report);
1.329 droeschl 84: if ($errtext) { return ($errtext,2); }
1.364 bisitz 85:
1.557 raeburn 86: if ($map =~ /^default/) {
87: $hadchanges=1;
88: } else {
89: $suppchanges=1;
90: }
1.329 droeschl 91: return ($errtext,0);
92: }
93:
94:
95:
96: sub authorhosts {
97: my %outhash=();
98: my $home=0;
99: my $other=0;
100: foreach my $key (keys(%env)) {
101: if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
102: my $role=$1;
103: my $realm=$2;
104: my ($start,$end)=split(/\./,$env{$key});
105: if (($start) && ($start>time)) { next; }
106: if (($end) && (time>$end)) { next; }
107: my ($ca,$cd);
108: if ($1 eq 'au') {
109: $ca=$env{'user.name'};
110: $cd=$env{'user.domain'};
111: } else {
112: ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
113: }
114: my $allowed=0;
115: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
116: my @ids=&Apache::lonnet::current_machine_ids();
1.484 raeburn 117: foreach my $id (@ids) {
118: if ($id eq $myhome) {
119: $allowed=1;
120: last;
121: }
122: }
1.329 droeschl 123: if ($allowed) {
124: $home++;
1.484 raeburn 125: $outhash{'home_'.$ca.':'.$cd}=1;
1.329 droeschl 126: } else {
1.484 raeburn 127: $outhash{'otherhome_'.$ca.':'.$cd}=$myhome;
1.329 droeschl 128: $other++;
129: }
130: }
131: }
132: return ($home,$other,%outhash);
133: }
134:
135:
136: sub clean {
137: my ($title)=@_;
138: $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
1.344 bisitz 139: return $title;
1.329 droeschl 140: }
141:
142:
143:
144: sub dumpcourse {
145: my ($r) = @_;
1.408 raeburn 146: my $crstype = &Apache::loncommon::course_type();
1.567 raeburn 147: my ($starthash,$js);
148: unless (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
149: $js = <<"ENDJS";
150: <script type="text/javascript">
151: // <![CDATA[
152:
153: function hide_searching() {
154: if (document.getElementById('searching')) {
155: document.getElementById('searching').style.display = 'none';
156: }
157: return;
158: }
159:
160: // ]]>
161: </script>
162: ENDJS
163: $starthash = {
164: add_entries => {'onload' => "hide_searching();"},
165: };
166: }
1.568 raeburn 167: $r->print(&Apache::loncommon::start_page('Copy '.$crstype.' Content to Authoring Space',$js,$starthash)."\n".
168: &Apache::lonhtmlcommon::breadcrumbs('Copy '.$crstype.' Content to Authoring Space')."\n");
1.484 raeburn 169: $r->print(&startContentScreen('tools'));
1.329 droeschl 170: my ($home,$other,%outhash)=&authorhosts();
1.484 raeburn 171: unless ($home) {
172: $r->print(&endContentScreen());
173: return '';
174: }
1.329 droeschl 175: my $origcrsid=$env{'request.course.id'};
176: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
177: if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
178: # Do the dumping
1.484 raeburn 179: unless ($outhash{'home_'.$env{'form.authorspace'}}) {
180: $r->print(&endContentScreen());
181: return '';
182: }
1.531 raeburn 183: my ($ca,$cd)=split(/\:/,$env{'form.authorspace'});
1.329 droeschl 184: $r->print('<h3>'.&mt('Copying Files').'</h3>');
185: my $title=$env{'form.authorfolder'};
186: $title=&clean($title);
1.567 raeburn 187: my ($navmap,$errormsg) =
188: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
189: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
190: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
191: my (%maps,%resources,%titles);
192: if (!ref($navmap)) {
193: $r->print($errormsg.
194: &endContentScreen());
195: return '';
196: } else {
197: &Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles,
198: 'dumpdocs',$cdom,$cnum);
1.329 droeschl 199: }
1.567 raeburn 200: my @todump = &Apache::loncommon::get_env_multiple('form.archive');
201: my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages,
202: %newcontent,%has_simpleprobs);
203: foreach my $item (sort {$a <=> $b} (@todump)) {
204: my $name = $env{'form.namefor_'.$item};
205: if ($resources{$item}) {
206: my ($map,$id,$res) = &Apache::lonnet::decode_symb($resources{$item});
207: if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) {
208: $tocopy{$1} = $name;
209: $display{$item} = $1;
210: $lookup{$1} = $item;
211: } elsif ($res eq 'lib/templates/simpleproblem.problem') {
212: $simpleproblems{$item} = {
213: symb => $resources{$item},
214: name => $name,
215: };
216: $display{$item} = 'simpleproblem_'.$name;
217: if ($map =~ m{^\Quploaded/$cdom/$cnum/\E(.+)$}) {
218: $has_simpleprobs{$1}{$id} = $item;
219: }
220: } elsif ($res =~ m{^adm/$match_domain/$match_username/(\d+)/smppg}) {
221: my $marker = $1;
222: my $db_name = &Apache::lonsimplepage::get_db_name($res,$marker,$cdom,$cnum);
223: $simplepages{$item} = {
224: res => $res,
225: title => $titles{$item},
226: db => $db_name,
227: marker => $marker,
228: symb => $resources{$item},
229: name => $name,
230: };
231: $display{$item} = '/'.$res;
232: }
233: } elsif ($maps{$item}) {
234: if ($maps{$item} =~ m{^\Quploaded/$cdom/$cnum/\E((?:default|supplemental)_\d+\.(?:sequence|page))$}) {
235: $tocopy{$1} = $name;
236: $display{$item} = $1;
237: $lookup{$1} = $item;
238: }
239: } else {
240: next;
241: }
242: }
1.329 droeschl 243: my $crs='/uploaded/'.$env{'request.course.id'}.'/';
244: $crs=~s/\_/\//g;
1.567 raeburn 245: my $mm = new File::MMagic;
246: my $prefix = "/uploaded/$cdom/$cnum/";
247: %replacehash = %tocopy;
248: foreach my $item (sort(keys(%simpleproblems))) {
249: my $content = &Apache::imsexport::simpleproblem($simpleproblems{$item}{'symb'});
250: $newcontent{$display{$item}} = $content;
251: }
252: my $gateway = Apache::lonhtmlgateway->new('web');
253: foreach my $item (sort(keys(%simplepages))) {
254: if (ref($simplepages{$item}) eq 'HASH') {
255: my $pagetitle = $simplepages{$item}{'title'};
256: my %fields = &Apache::lonnet::dump($simplepages{$item}{'db'},$cdom,$cnum);
257: my %contents;
258: foreach my $field (keys(%fields)) {
259: if ($field =~ /^(?:aaa|bbb|ccc)_(\w+)$/) {
260: my $name = $1;
261: my $msg = $fields{$field};
262: if ($name eq 'webreferences') {
263: if ($msg =~ m{^https?://}) {
264: $contents{$name} = '<a href="'.$msg.'"><tt>'.$msg.'</tt></a>';
265: }
266: } else {
267: $msg = &Encode::decode('utf8',$msg);
268: $msg = $gateway->process_outgoing_html($msg,1);
269: $contents{$name} = $msg;
270: }
271: } elsif ($field eq 'uploaded.photourl') {
272: my $marker = $simplepages{$item}{marker};
273: if ($fields{$field} =~ m{^\Q$prefix\E(simplepage/$marker/.+)$}) {
274: my $filepath = $1;
275: my ($relpath,$fname) = ($filepath =~ m{^(.+/)([^/]+)$});
276: if ($fname ne '') {
277: $fname=~s/\.(\w+)$//;
278: my $ext=$1;
279: $fname = &clean($fname);
280: $fname.='.'.$ext;
281: $contents{image} = '<img src="'.$relpath.$fname.'" alt="Image" />';
282: $replacehash{$filepath} = $relpath.$fname;
283: $deps{$item}{$filepath} = 1;
284: }
285: }
286: }
287: }
288: $replacehash{'/'.$simplepages{$item}{'res'}} = $simplepages{$item}{'name'};
289: $lookup{'/'.$simplepages{$item}{'res'}} = $item;
290: my $content = '
291: <html>
292: <head>
293: <title>'.$pagetitle.'</title>
294: </head>
295: <body bgcolor="#ffffff">';
296: if ($contents{title}) {
297: $content .= "\n".'<h2>'.$contents{title}.'</h2>';
298: }
299: if ($contents{image}) {
300: $content .= "\n".$contents{image};
301: }
302: if ($contents{content}) {
303: $content .= '
304: <div class="LC_Box">
1.577 bisitz 305: <h4 class="LC_hcell">'.&mt('Content').'</h4>'.
1.567 raeburn 306: $contents{content}.'
307: </div>';
308: }
309: if ($contents{webreferences}) {
310: $content .= '
311: <div class="LC_Box">
1.577 bisitz 312: <h4 class="LC_hcell">'.&mt('Web References').'</h4>'.
1.567 raeburn 313: $contents{webreferences}.'
314: </div>';
315: }
316: $content .= '
317: </body>
318: </html>
319: ';
320: $newcontent{'/'.$simplepages{$item}{res}} = $content;
321: }
322: }
323: foreach my $item (keys(%tocopy)) {
324: unless ($item=~/\.(sequence|page)$/) {
325: my $currurlpath = $prefix.$item;
326: my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath);
327: &recurse_html($mm,$prefix,$currdirpath,$currurlpath,$item,$lookup{$item},\%replacehash,\%deps);
328: }
329: }
330: foreach my $num (sort {$a <=> $b} (@todump)) {
331: my $src = $display{$num};
332: next if ($src eq '');
333: my @needcopy = ();
334: if ($replacehash{$src}) {
335: push(@needcopy,$src);
336: if (ref($deps{$num}) eq 'HASH') {
337: foreach my $dep (sort(keys(%{$deps{$num}}))) {
338: if ($replacehash{$dep}) {
339: push(@needcopy,$dep);
340: }
341: }
342: }
343: } elsif ($src =~ /^simpleproblem_/) {
344: push(@needcopy,$src);
345: }
346: next if (@needcopy == 0);
347: my ($result,$depresult);
348: for (my $i=0; $i<@needcopy; $i++) {
349: my $item = $needcopy[$i];
350: my $newfilename;
351: if ($simpleproblems{$num}) {
352: $newfilename=$title.'/'.$simpleproblems{$num}{'name'};
353: } else {
354: $newfilename=$title.'/'.$replacehash{$item};
355: }
356: $newfilename=~s/\.(\w+)$//;
357: my $ext=$1;
358: $newfilename=&clean($newfilename);
359: $newfilename.='.'.$ext;
360: my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$});
361: if ($newrelpath ne $replacehash{$item}) {
362: $replacehash{$item} = $newrelpath;
363: }
364: my @dirs=split(/\//,$newfilename);
365: my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
366: my $makepath=$path;
367: my $fail;
368: my $origin;
369: for (my $i=0;$i<$#dirs;$i++) {
370: $makepath.='/'.$dirs[$i];
371: unless (-e $makepath) {
372: unless(mkdir($makepath,0755)) {
373: $fail = &mt('Directory creation failed.');
374: }
375: }
376: }
377: if ($i == 0) {
378: $result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ';
379: } else {
380: $depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '.
381: '<span class="LC_fontsize_small" style="font-weight: bold;">'.
382: &mt('(dependency)').'</span>: ';
383: }
384: if (-e $path.'/'.$newfilename) {
385: $fail = &mt('Destination already exists -- not overwriting.');
386: } else {
387: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
388: if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) ||
389: ($item =~ /^simpleproblem_/)) {
390: print $fh $newcontent{$item};
391: } else {
392: my $fileloc = &Apache::lonnet::filelocation('',$prefix.$item);
393: if (-e $fileloc) {
394: if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
395: if ((($1 eq 'sequence') || ($1 eq 'page')) &&
396: (ref($has_simpleprobs{$item}) eq 'HASH')) {
397: my %changes = %{$has_simpleprobs{$item}};
398: my $content = &Apache::lonclonecourse::rewritefile(
399: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
400: (%replacehash,$crs => '')
401: );
402: my $updatedcontent = '';
403: my $parser = HTML::TokeParser->new(\$content);
404: $parser->attr_encoded(1);
405: while (my $token = $parser->get_token) {
406: if ($token->[0] eq 'S') {
407: if (($token->[1] eq 'resource') &&
408: ($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') &&
409: ($changes{$token->[2]->{'id'}})) {
410: my $id = $token->[2]->{'id'};
411: $updatedcontent .= '<'.$token->[1];
412: foreach my $attrib (@{$token->[3]}) {
413: next unless ($attrib =~ /^(src|type|title|id)$/);
414: if ($attrib eq 'src') {
415: my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/);
416: if ($file) {
417: $updatedcontent .= ' '.$attrib.'="'.$file.'"';
418: } else {
419: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
420: }
421: } else {
422: $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
423: }
424: }
425: $updatedcontent .= ' />'."\n";
426: } else {
427: $updatedcontent .= $token->[4]."\n";
428: }
429: } else {
430: $updatedcontent .= $token->[2];
431: }
432: }
433: print $fh $updatedcontent;
434: } else {
435: print $fh &Apache::lonclonecourse::rewritefile(
436: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
437: (%replacehash,$crs => '')
438: );
439: }
440: } else {
441: print $fh
442: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
443: }
444: } else {
445: $fail = &mt('Source does not exist.');
446: }
447: }
448: $fh->close();
449: } else {
450: $fail = &mt('Could not write to destination.');
451: }
452: }
453: my $text;
454: if ($fail) {
455: $text = '<span class="LC_error">'.&mt('fail').(' 'x3).$fail.'</span>';
456: } else {
457: $text = '<span class="LC_success">'.&mt('ok').'</span>';
458: }
459: if ($i == 0) {
460: $result .= $text;
461: } else {
462: $depresult .= $text.'</li>';
463: }
464: }
465: $r->print($result);
466: if ($depresult) {
467: $r->print('<ul>'.$depresult.'</ul>');
468: }
469: }
470: } else {
471: my ($navmap,$errormsg) =
472: &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
473: if (!ref($navmap)) {
474: $r->print($errormsg);
475: } else {
476: $r->print('<div id="searching">'.&mt('Searching ...').'</div>');
477: $r->rflush();
478: my ($preamble,$formname);
479: $formname = 'dumpdoc';
480: unless ($home==1) {
481: $preamble = '<div class="LC_left_float">'.
482: '<fieldset><legend>'.
483: &mt('Select the Authoring Space').
484: '</legend><select name="authorspace">';
1.329 droeschl 485: }
1.567 raeburn 486: my @orderspaces = ();
487: foreach my $key (sort(keys(%outhash))) {
488: if ($key=~/^home_(.+)$/) {
489: if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) {
490: unshift(@orderspaces,$1);
491: } else {
492: push(@orderspaces,$1);
493: }
494: }
495: }
1.569 raeburn 496: if ($home>1) {
497: $preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>';
498: }
1.567 raeburn 499: foreach my $user (@orderspaces) {
1.329 droeschl 500: if ($home==1) {
1.567 raeburn 501: $preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />';
1.329 droeschl 502: } else {
1.567 raeburn 503: $preamble .= '<option value="'.$user.'">'.$user.' - '.
504: &Apache::loncommon::plainname(split(/\:/,$user)).'</option>';
505: }
1.329 droeschl 506: }
1.567 raeburn 507: unless ($home==1) {
508: $preamble .= '</select></fieldset></div>'."\n";
1.329 droeschl 509: }
1.567 raeburn 510: my $title=$origcrsdata{'description'};
511: $title=~s/[\/\s]+/\_/gs;
1.329 droeschl 512: $title=&clean($title);
1.567 raeburn 513: $preamble .= '<div class="LC_left_float">'.
514: '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.
515: '<input type="text" size="50" name="authorfolder" value="'.
516: $title.'" />'.
517: '</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n";
518: my %uploadedfiles;
519: &tiehash();
520: foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
521: my ($ext)=($file=~/\.(\w+)$/);
522: # FIXME Check supplemental here
523: my $title=$hash{'title_'.$hash{
524: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
525: if (!$title) {
526: $title=$file;
527: } else {
528: $title=~s|/|_|g;
529: }
530: $title=~s/\.(\w+)$//;
531: $title=&clean($title);
532: $title.='.'.$ext;
533: # $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
534: $uploadedfiles{$file} = $title;
535: }
536: &untiehash();
537: $r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef,
538: undef,undef,$preamble,$home,\%uploadedfiles));
539: }
1.329 droeschl 540: }
1.484 raeburn 541: $r->print(&endContentScreen());
1.329 droeschl 542: }
543:
1.567 raeburn 544: sub recurse_html {
545: my ($mm,$prefix,$currdirpath,$currurlpath,$container,$item,$replacehash,$deps) = @_;
546: return unless ((ref($replacehash) eq 'HASH') && (ref($deps) eq 'HASH'));
547: my (%allfiles,%codebase);
548: if (&Apache::lonnet::extract_embedded_items($currdirpath,\%allfiles,\%codebase) eq 'ok') {
549: if (keys(%allfiles)) {
550: foreach my $dependency (keys(%allfiles)) {
551: next if (($dependency =~ m{^/(res|adm)/}) || ($dependency =~ m{^https?://}));
552: my ($depurl,$relfile,$newcontainer);
553: if ($dependency =~ m{^/}) {
554: if ($dependency =~ m{^\Q$currurlpath/\E(.+)$}) {
555: $relfile = $1;
556: if ($dependency =~ m{^\Q$prefix\E(.+)$}) {
557: $newcontainer = $1;
558: next if ($replacehash->{$newcontainer});
559: }
560: $depurl = $dependency;
561: } else {
562: next;
563: }
564: } else {
565: $relfile = $dependency;
566: $depurl = $currurlpath;
567: $depurl =~ s{[^/]+$}{};
568: $depurl .= $dependency;
569: ($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$});
570: }
571: next if ($relfile eq '');
572: my $newname = $replacehash->{$container};
573: $newname =~ s{[^/]+$}{};
574: $replacehash->{$newcontainer} = $newname.$relfile;
575: $deps->{$item}{$newcontainer} = 1;
576: my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$});
577: my $depfile = &Apache::lonnet::filelocation('',$depurl);
578: my $type = $mm->checktype_filename($depfile);
579: if ($type eq 'text/html') {
580: &recurse_html($mm,$prefix,$depfile,$newurlpath,$newcontainer,$item,$replacehash,$deps);
581: }
582: }
583: }
584: }
585: return;
586: }
587:
1.329 droeschl 588: sub group_import {
1.598 raeburn 589: my ($coursenum, $coursedom, $folder, $container, $caller, $ltitoolsref, @files) = @_;
1.529 raeburn 590: my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap,
591: %removeparam,$importuploaded,$fixuperrors);
592: $allmaps = {};
1.329 droeschl 593: while (@files) {
594: my ($name, $url, $residx) = @{ shift(@files) };
1.344 bisitz 595: if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
1.329 droeschl 596: && ($caller eq 'londocs')
597: && (!&Apache::lonnet::stat_file($url))) {
1.364 bisitz 598:
1.329 droeschl 599: my $errtext = '';
600: my $fatal = 0;
601: my $newmapstr = '<map>'."\n".
602: '<resource id="1" src="" type="start"></resource>'."\n".
603: '<link from="1" to="2" index="1"></link>'."\n".
604: '<resource id="2" src="" type="finish"></resource>'."\n".
605: '</map>';
606: $env{'form.output'}=$newmapstr;
607: my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
608: 'output',$1.$2);
1.534 raeburn 609: if ($result !~ m{^/uploaded/}) {
1.329 droeschl 610: $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
611: $fatal = 2;
612: }
613: if ($fatal) {
614: return ($errtext,$fatal);
615: }
616: }
617: if ($url) {
1.598 raeburn 618: if ($url =~ m{^(/adm/$coursedom/$coursenum/(\d+)/exttool)s?\:?(.*)$}) {
619: $url = $1;
620: my $marker = $2;
621: my $info = $3;
622: my ($toolid,%toolhash);
623: my @toolinfo = split(/:/,$info);
624: if ($residx) {
625: my %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
626: $toolid = $toolsettings{'id'};
627: } else {
628: $toolid = shift(@toolinfo);
629: }
630: $toolid =~ s/\D//g;
631: ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'}) = @toolinfo;
632: if (ref($ltitoolsref) eq 'HASH') {
633: if (ref($ltitoolsref->{$toolid}) eq 'HASH') {
634: if ($ltitoolsref->{$toolid}->{'url'} =~ m{^https://}) {
635: $url =~ s/exttool$/exttools/;
636: }
637: $toolhash{'id'} = $toolid;
638: if ($toolhash{'target'} eq 'iframe') {
639: delete($toolhash{'width'});
640: delete($toolhash{'height'});
641: } elsif ($toolhash{'target'} eq 'window') {
642: foreach my $item ('width','height') {
643: $toolhash{$item} =~ s/^\s+//;
644: $toolhash{$item} =~ s/\s+$//;
645: }
646: }
647: my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum);
648: }
649: }
650: }
1.529 raeburn 651: if (($caller eq 'londocs') &&
652: ($folder =~ /^default/)) {
1.534 raeburn 653: if (($url =~ /\.(page|sequence)$/) && (!$donechk)) {
1.529 raeburn 654: my $chome = &Apache::lonnet::homeserver($coursenum,$coursedom);
655: my $cid = $coursedom.'_'.$coursenum;
656: $allmaps =
657: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
658: $chome,$cid);
659: $donechk = 1;
660: }
661: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) {
662: &contained_map_check($url,$folder,\%removefrommap,\%removeparam,
663: \%addedmaps,\%hierarchy,\%titles,$allmaps);
664: $importuploaded = 1;
665: } elsif ($url =~ m{^/res/.+\.(page|sequence)$}) {
666: next if ($allmaps->{$url});
667: }
668: }
1.344 bisitz 669: if (!$residx
1.329 droeschl 670: || defined($LONCAPA::map::zombies[$residx])) {
671: $residx = &LONCAPA::map::getresidx($url,$residx);
672: push(@LONCAPA::map::order, $residx);
673: }
674: my $ext = 'false';
675: if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
676: $name = &LONCAPA::map::qtunescape($name);
1.534 raeburn 677: if ($name eq '') {
1.538 raeburn 678: $name = &LONCAPA::map::qtunescape(&mt('Web Page'));
1.534 raeburn 679: }
680: if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) {
681: my $filepath = $1;
682: my $fname = $name;
683: if ($fname =~ /^\W+$/) {
684: $fname = 'web';
685: } else {
686: $fname =~ s/\W/_/g;
687: }
1.599 ! damieng 688: if (length($fname) > 15) {
1.534 raeburn 689: $fname = substr($fname,0,14);
690: }
691: my $initialtext = &mt('Replace with your own content.');
692: my $newhtml = <<END;
1.545 raeburn 693: <html>
1.534 raeburn 694: <head>
695: <title>$name</title>
696: </head>
697: <body bgcolor="#ffffff">
698: $initialtext
699: </body>
700: </html>
701: END
702: $env{'form.output'}=$newhtml;
703: my $result =
704: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
705: 'output',
706: "$filepath/$residx/$fname.html");
707: if ($result =~ m{^/uploaded/}) {
708: $url = $result;
709: if ($filepath =~ /^supplemental/) {
710: $name = time.'___&&&___'.$env{'user.name'}.'___&&&___'.
711: $env{'user.domain'}.'___&&&___'.$name;
712: }
713: } else {
714: return (&mt('Failed to save new web page.'),1);
715: }
716: }
1.538 raeburn 717: $url = &LONCAPA::map::qtunescape($url);
1.344 bisitz 718: $LONCAPA::map::resources[$residx] =
1.329 droeschl 719: join(':', ($name, $url, $ext, 'normal', 'res'));
720: }
721: }
1.529 raeburn 722: if ($importuploaded) {
723: my %import_errors;
724: my %updated = (
725: removefrommap => \%removefrommap,
726: removeparam => \%removeparam,
727: );
1.533 raeburn 728: my ($result,$msgsarray,$lockerror) =
729: &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
1.529 raeburn 730: if (keys(%import_errors) > 0) {
1.530 raeburn 731: $fixuperrors =
1.529 raeburn 732: '<p span class="LC_warning">'."\n".
733: &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".
734: '<ul>'."\n";
735: foreach my $key (sort(keys(%import_errors))) {
736: $fixuperrors .= '<li>'.$key.'</li>'."\n";
737: }
738: $fixuperrors .= '</ul></p>'."\n";
739: }
1.533 raeburn 740: if (ref($msgsarray) eq 'ARRAY') {
741: if (@{$msgsarray} > 0) {
742: $fixuperrors .= '<p class="LC_info">'.
743: join('<br />',@{$msgsarray}).
744: '</p>';
745: }
746: }
747: if ($lockerror) {
748: $fixuperrors .= '<p class="LC_error">'.
749: $lockerror.
750: '</p>';
751: }
1.529 raeburn 752: }
753: my ($errtext,$fatal) =
754: &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
1.557 raeburn 755: unless ($fatal) {
756: if ($folder =~ /^supplemental/) {
757: &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
1.561 raeburn 758: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
759: $folder.'.'.$container);
1.557 raeburn 760: }
761: }
1.529 raeburn 762: return ($errtext,$fatal,$fixuperrors);
1.329 droeschl 763: }
764:
765: sub log_docs {
1.494 raeburn 766: return &Apache::lonnet::write_log('course','docslog',@_);
1.329 droeschl 767: }
768:
769: {
770: my @oldresources=();
771: my @oldorder=();
772: my $parmidx;
773: my %parmaction=();
774: my %parmvalue=();
775: my $changedflag;
776:
777: sub snapshotbefore {
778: @oldresources=@LONCAPA::map::resources;
779: @oldorder=@LONCAPA::map::order;
780: $parmidx=undef;
781: %parmaction=();
782: %parmvalue=();
783: $changedflag=0;
784: }
785:
786: sub remember_parms {
787: my ($idx,$parameter,$action,$value)=@_;
788: $parmidx=$idx;
789: $parmaction{$parameter}=$action;
790: $parmvalue{$parameter}=$value;
791: $changedflag=1;
792: }
793:
794: sub log_differences {
795: my ($plain)=@_;
796: my %storehash=('folder' => $plain,
797: 'currentfolder' => $env{'form.folder'});
798: if ($parmidx) {
799: $storehash{'parameter_res'}=$oldresources[$parmidx];
800: foreach my $parm (keys(%parmaction)) {
801: $storehash{'parameter_action_'.$parm}=$parmaction{$parm};
802: $storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
803: }
804: }
805: my $maxidx=$#oldresources;
806: if ($#LONCAPA::map::resources>$#oldresources) {
807: $maxidx=$#LONCAPA::map::resources;
808: }
809: for (my $idx=0; $idx<=$maxidx; $idx++) {
810: if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
811: $storehash{'before_resources_'.$idx}=$oldresources[$idx];
812: $storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
813: $changedflag=1;
814: }
815: if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
816: $storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
817: $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
818: $changedflag=1;
819: }
820: }
821: $storehash{'maxidx'}=$maxidx;
822: if ($changedflag) { &log_docs(\%storehash); }
823: }
824: }
825:
826: sub docs_change_log {
1.484 raeburn 827: my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath)=@_;
1.486 raeburn 828: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
1.483 raeburn 829: my $js = '<script type="text/javascript">'."\n".
830: '// <![CDATA['."\n".
831: &Apache::loncommon::display_filter_js('docslog')."\n".
1.486 raeburn 832: &editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag)."\n".
1.483 raeburn 833: &history_tab_js()."\n".
1.484 raeburn 834: &Apache::lonratedt::editscript('simple')."\n".
1.483 raeburn 835: '// ]]>'."\n".
836: '</script>'."\n";
1.484 raeburn 837: $r->print(&Apache::loncommon::start_page('Content Change Log',$js));
838: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Change Log'));
1.489 raeburn 839: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484 raeburn 840: my %orderhash;
841: my $container='sequence';
842: my $pathitem;
1.519 raeburn 843: if ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 844: $container='page';
845: }
1.519 raeburn 846: my $folderpath=$env{'form.folderpath'};
847: if ($folderpath eq '') {
1.548 raeburn 848: $folderpath = 'default&'.&escape(&mt('Main Content').':::::');
1.519 raeburn 849: }
850: $pathitem = '<input type="hidden" name="folderpath" value="'.
851: &HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 852: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
853: my $jumpto = $readfile;
854: $jumpto =~ s{^/}{};
855: my $tid = 1;
1.489 raeburn 856: if ($supplementalflag) {
857: $tid = 2;
858: }
1.509 raeburn 859: my ($breadcrumbtrail) =
860: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
1.484 raeburn 861: $r->print($breadcrumbtrail.
862: &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto,
863: $readfile));
1.329 droeschl 864: my %docslog=&Apache::lonnet::dump('nohist_docslog',
865: $env{'course.'.$env{'request.course.id'}.'.domain'},
866: $env{'course.'.$env{'request.course.id'}.'.num'});
867:
868: if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
869:
870: my %saveable_parameters = ('show' => 'scalar',);
871: &Apache::loncommon::store_course_settings('docs_log',
872: \%saveable_parameters);
873: &Apache::loncommon::restore_course_settings('docs_log',
874: \%saveable_parameters);
875: if (!$env{'form.show'}) { $env{'form.show'}=10; }
1.452 www 876: # FIXME: internationalization seems wrong here
1.329 droeschl 877: my %lt=('hiddenresource' => 'Resources hidden',
878: 'encrypturl' => 'URL hidden',
879: 'randompick' => 'Randomly pick',
880: 'randomorder' => 'Randomly ordered',
881: 'set' => 'set to',
882: 'del' => 'deleted');
1.484 raeburn 883: my $filter = &Apache::loncommon::display_filter('docslog')."\n".
884: $pathitem."\n".
885: '<input type="hidden" name="folder" value="'.$env{'form.folder'}.'" />'.
886: (' 'x2).'<input type="submit" value="'.&mt('Display').'" />';
887: $r->print('<div class="LC_left_float">'.
888: '<fieldset><legend>'.&mt('Display of Content Changes').'</legend>'."\n".
889: &makedocslogform($filter,1).
890: '</fieldset></div><br clear="all" />');
1.329 droeschl 891: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
892: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
893: &mt('After').'</th>'.
894: &Apache::loncommon::end_data_table_header_row());
895: my $shown=0;
896: foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
897: if ($env{'form.displayfilter'} eq 'currentfolder') {
898: if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
899: }
900: my @changes=keys(%{$docslog{$id}{'logentry'}});
901: if ($env{'form.displayfilter'} eq 'containing') {
902: my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
903: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
904: foreach my $key (@changes) {
905: $wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
906: }
1.344 bisitz 907: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
1.329 droeschl 908: }
909: my $count = 0;
910: my $time =
911: &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
912: my $plainname =
913: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
914: $docslog{$id}{'exe_udom'});
915: my $about_me_link =
916: &Apache::loncommon::aboutmewrapper($plainname,
917: $docslog{$id}{'exe_uname'},
918: $docslog{$id}{'exe_udom'});
919: my $send_msg_link='';
920: if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
921: || ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
922: $send_msg_link ='<br />'.
923: &Apache::loncommon::messagewrapper(&mt('Send message'),
924: $docslog{$id}{'exe_uname'},
925: $docslog{$id}{'exe_udom'});
926: }
927: $r->print(&Apache::loncommon::start_data_table_row());
928: $r->print('<td>'.$time.'</td>
929: <td>'.$about_me_link.
930: '<br /><tt>'.$docslog{$id}{'exe_uname'}.
931: ':'.$docslog{$id}{'exe_udom'}.'</tt>'.
932: $send_msg_link.'</td><td>'.
933: $docslog{$id}{'logentry'}{'folder'}.'</td><td>');
1.488 raeburn 934: my $is_supp = 0;
935: if ($docslog{$id}{'logentry'}{'currentfolder'} =~ /^supplemental/) {
936: $is_supp = 1;
937: }
1.329 droeschl 938: # Before
939: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
940: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
941: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
942: if ($oldname ne $newname) {
1.488 raeburn 943: my $shown = &LONCAPA::map::qtescape($oldname);
944: if ($is_supp) {
945: $shown = &Apache::loncommon::parse_supplemental_title($shown);
946: }
947: $r->print($shown);
1.329 droeschl 948: }
949: }
950: $r->print('<ul>');
951: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
952: if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
1.488 raeburn 953: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]);
954: if ($is_supp) {
955: $shown = &Apache::loncommon::parse_supplemental_title($shown);
956: }
957: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 958: }
959: }
960: $r->print('</ul>');
961: # After
962: $r->print('</td><td>');
963:
964: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
965: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
966: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
967: if ($oldname ne '' && $oldname ne $newname) {
1.488 raeburn 968: my $shown = &LONCAPA::map::qtescape($newname);
969: if ($is_supp) {
970: $shown = &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($newname));
971: }
972: $r->print($shown);
1.329 droeschl 973: }
1.364 bisitz 974: }
1.329 droeschl 975: $r->print('<ul>');
976: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
977: if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
1.488 raeburn 978: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]);
979: if ($is_supp) {
980: $shown = &Apache::loncommon::parse_supplemental_title($shown);
981: }
982: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 983: }
984: }
985: $r->print('</ul>');
986: if ($docslog{$id}{'logentry'}{'parameter_res'}) {
987: $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
988: foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
989: if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
1.452 www 990: # FIXME: internationalization seems wrong here
1.329 droeschl 991: $r->print('<li>'.
992: &mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
993: $docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
994: .'</li>');
995: }
996: }
997: $r->print('</ul>');
998: }
999: # End
1000: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1001: $shown++;
1002: if (!($env{'form.show'} eq &mt('all')
1003: || $shown<=$env{'form.show'})) { last; }
1004: }
1.484 raeburn 1005: $r->print(&Apache::loncommon::end_data_table()."\n".
1006: &makesimpleeditform($pathitem)."\n".
1007: '</div></div>');
1008: $r->print(&endContentScreen());
1.329 droeschl 1009: }
1010:
1011: sub update_paste_buffer {
1.492 raeburn 1012: my ($coursenum,$coursedom,$folder) = @_;
1.591 raeburn 1013: my (@possibles,%removals,%cuts,$output);
1.538 raeburn 1014: if ($env{'form.multiremove'}) {
1015: $env{'form.multiremove'} =~ s/,$//;
1016: map { $removals{$_} = 1; } split(/,/,$env{'form.multiremove'});
1017: }
1018: if (($env{'form.multicopy'}) || ($env{'form.multicut'})) {
1019: if ($env{'form.multicut'}) {
1020: $env{'form.multicut'} =~ s/,$//;
1021: foreach my $item (split(/,/,$env{'form.multicut'})) {
1022: unless ($removals{$item}) {
1023: $cuts{$item} = 1;
1024: push(@possibles,$item.':cut');
1025: }
1026: }
1027: }
1028: if ($env{'form.multicopy'}) {
1029: $env{'form.multicopy'} =~ s/,$//;
1030: foreach my $item (split(/,/,$env{'form.multicopy'})) {
1031: unless ($removals{$item} || $cuts{$item}) {
1032: push(@possibles,$item.':copy');
1033: }
1034: }
1035: }
1036: } elsif ($env{'form.markcopy'}) {
1037: @possibles = split(/,/,$env{'form.markcopy'});
1038: }
1.329 droeschl 1039:
1.538 raeburn 1040: return if (@possibles == 0);
1.329 droeschl 1041: return if (!defined($env{'form.copyfolder'}));
1042:
1043: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1044: $env{'form.copyfolder'});
1.538 raeburn 1045: return if ($fatal);
1046:
1047: my %curr_groups = &Apache::longroup::coursegroups();
1.364 bisitz 1048:
1.538 raeburn 1049: # Retrieve current paste buffer suffixes.
1050: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1051: my (%pasteurls,@newpaste);
1052:
1053: # Construct identifiers for current contents of user's paste buffer
1054: if (@currpaste) {
1055: foreach my $suffix (@currpaste) {
1056: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1057: my $url = $env{'docs.markedcopy_url_'.$suffix};
1.597 raeburn 1058: my $mapidx = $env{'docs.markedcopy_map_'.$suffix};
1.538 raeburn 1059: if (($cid =~ /^$match_domain(?:_)$match_courseid$/) &&
1060: ($url ne '')) {
1.597 raeburn 1061: $pasteurls{$cid.'_'.$url.'_'.$mapidx} = 1;
1.538 raeburn 1062: }
1063: }
1064: }
1065:
1066: # Mark items for copying (skip any items already in user's paste buffer)
1067: my %addtoenv;
1.597 raeburn 1068:
1069: my @pathitems = split(/\&/,$env{'form.folderpath'});
1070: my @folderconf = split(/\:/,$pathitems[-1]);
1071: my $ispage = $folderconf[4];
1072:
1.538 raeburn 1073: foreach my $item (@possibles) {
1074: my ($orderidx,$cmd) = split(/:/,$item);
1075: next if ($orderidx =~ /\D/);
1076: next unless (($cmd eq 'cut') || ($cmd eq 'copy') || ($cmd eq 'remove'));
1.597 raeburn 1077: my $mapidx = $folder.':'.$orderidx.':'.$ispage;
1.538 raeburn 1078: my ($title,$url)=split(':',$LONCAPA::map::resources[$orderidx]);
1079: my %denied = &action_restrictions($coursenum,$coursedom,
1080: &LONCAPA::map::qtescape($url),
1081: $env{'form.folderpath'},\%curr_groups);
1082: next if ($denied{'copy'});
1083: $url=~s{http(:|:)//https(:|:)//}{https$2//};
1.597 raeburn 1084: next if (exists($pasteurls{$coursedom.'_'.$coursenum.'_'.$mapidx}));
1.538 raeburn 1085: my ($suffix,$errortxt,$locknotfreed) =
1086: &new_timebased_suffix($env{'user.domain'},$env{'user.name'},'paste');
1.591 raeburn 1087: if ($suffix ne '') {
1088: push(@newpaste,$suffix);
1089: } else {
1090: if ($locknotfreed) {
1091: return $locknotfreed;
1092: }
1.538 raeburn 1093: }
1094: if (&is_supplemental_title($title)) {
1095: &Apache::lonnet::appenv({'docs.markedcopy_supplemental_'.$suffix => $title});
1096: ($title) = &Apache::loncommon::parse_supplemental_title($title);
1097: }
1.329 droeschl 1098:
1.538 raeburn 1099: $addtoenv{'docs.markedcopy_title_'.$suffix} = $title,
1100: $addtoenv{'docs.markedcopy_url_'.$suffix} = $url,
1101: $addtoenv{'docs.markedcopy_cmd_'.$suffix} = $cmd,
1102: $addtoenv{'docs.markedcopy_crs_'.$suffix} = $env{'request.course.id'};
1.597 raeburn 1103: $addtoenv{'docs.markedcopy_map_'.$suffix} = $mapidx;
1.538 raeburn 1104: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) {
1105: my $prefix = $1;
1106: my $subdir =$2;
1107: if ($subdir eq '') {
1108: $subdir = $prefix;
1.492 raeburn 1109: }
1.538 raeburn 1110: my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps);
1111: &contained_map_check($url,$folder,\%removefrommap,\%removeparam,\%addedmaps,
1112: \%hierarchy,\%titles,\%allmaps);
1113: if (ref($hierarchy{$url}) eq 'HASH') {
1114: my ($nested,$nestednames);
1115: &recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames);
1116: $nested =~ s/\&$//;
1117: $nestednames =~ s/\Q___&&&___\E$//;
1118: if ($nested ne '') {
1119: $addtoenv{'docs.markedcopy_nested_'.$suffix} = $nested;
1120: }
1121: if ($nestednames ne '') {
1122: $addtoenv{'docs.markedcopy_nestednames_'.$suffix} = $nestednames;
1123: }
1.492 raeburn 1124: }
1125: }
1.591 raeburn 1126: if ($locknotfreed) {
1127: $output = $locknotfreed;
1128: last;
1129: }
1.492 raeburn 1130: }
1.538 raeburn 1131: if (@newpaste) {
1132: $addtoenv{'docs.markedcopies'} = join(',',(@currpaste,@newpaste));
1133: }
1.492 raeburn 1134: &Apache::lonnet::appenv(\%addtoenv);
1.329 droeschl 1135: delete($env{'form.markcopy'});
1.591 raeburn 1136: return $output;
1.329 droeschl 1137: }
1138:
1.492 raeburn 1139: sub recurse_uploaded_maps {
1140: my ($url,$dir,$hierarchy,$titlesref,$nestref,$namesref) = @_;
1141: if (ref($hierarchy->{$url}) eq 'HASH') {
1142: my @maps = map { $hierarchy->{$url}{$_}; } sort { $a <=> $b } (keys(%{$hierarchy->{$url}}));
1143: my @titles = map { $titlesref->{$url}{$_}; } sort { $a <=> $b } (keys(%{$titlesref->{$url}}));
1144: my (@uploaded,@names,%shorter);
1145: for (my $i=0; $i<@maps; $i++) {
1146: my ($inner) = ($maps[$i] =~ m{^/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_(\d+)\.(?:page|sequence)$});
1147: if ($inner ne '') {
1148: push(@uploaded,$inner);
1149: push(@names,&escape($titles[$i]));
1150: $shorter{$maps[$i]} = $inner;
1151: }
1152: }
1153: $$nestref .= "$dir:".join(',',@uploaded).'&';
1154: $$namesref .= "$dir:".(join(',',@names)).'___&&&___';
1155: foreach my $map (@maps) {
1156: if ($shorter{$map} ne '') {
1157: &recurse_uploaded_maps($map,$shorter{$map},$hierarchy,$titlesref,$nestref,$namesref);
1158: }
1159: }
1160: }
1161: return;
1162: }
1163:
1.329 droeschl 1164: sub print_paste_buffer {
1.492 raeburn 1165: my ($r,$container,$folder,$coursedom,$coursenum) = @_;
1.538 raeburn 1166: return if (!defined($env{'docs.markedcopies'}));
1.329 droeschl 1167:
1.538 raeburn 1168: unless (($env{'form.pastemarked'}) || ($env{'form.clearmarked'})) {
1169: return if ($env{'docs.markedcopies'} eq '');
1.488 raeburn 1170: }
1171:
1.538 raeburn 1172: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1173: my ($pasteitems,@pasteable);
1.575 raeburn 1174: my $clipboardcount = 0;
1.488 raeburn 1175:
1.538 raeburn 1176: # Construct identifiers for current contents of user's paste buffer
1177: foreach my $suffix (@currpaste) {
1178: next if ($suffix =~ /\D/);
1179: my $cid = $env{'docs.markedcopy_crs_'.$suffix};
1180: my $url = $env{'docs.markedcopy_url_'.$suffix};
1.597 raeburn 1181: my $mapidx = $env{'docs.markedcopy_map_'.$suffix};
1.538 raeburn 1182: if (($cid =~ /^$match_domain\_$match_courseid$/) &&
1183: ($url ne '')) {
1.575 raeburn 1184: $clipboardcount ++;
1.538 raeburn 1185: my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent,
1.598 raeburn 1186: $canpaste,$nopaste,$othercrs,$areachange,$is_exttool);
1.538 raeburn 1187: my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1];
1188: if ($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
1189: $is_external = 1;
1.598 raeburn 1190: } elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/exttools?$}) {
1191: $is_exttool = 1;
1.538 raeburn 1192: }
1193: if ($folder =~ /^supplemental/) {
1194: $canpaste = &supp_pasteable($env{'docs.markedcopy_url_'.$suffix});
1195: unless ($canpaste) {
1196: $nopaste = &mt('Paste into Supplemental Content unavailable.');
1197: }
1198: } else {
1199: $canpaste = 1;
1200: }
1201: if ($canpaste) {
1202: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1203: my $srcdom = $1;
1204: my $srcnum = $2;
1205: my $rem = $3;
1206: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
1207: $othercourse = 1;
1208: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1.596 raeburn 1209: $othercrs = '<br />'.&mt('(from another course)');
1.538 raeburn 1210: } else {
1211: $canpaste = 0;
1212: $nopaste = &mt('Paste from another course unavailable.');
1213: }
1214: }
1215: if ($rem =~ m{^(default|supplemental)_?(\d*)\.(?:page|sequence)$}) {
1216: my $prefix = $1;
1217: $parent = $2;
1218: if ($folder !~ /^\Q$prefix\E/) {
1219: $areachange = 1;
1220: }
1221: $is_uploaded_map = 1;
1.492 raeburn 1222: }
1.597 raeburn 1223: } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
1224: ($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg)$})) {
1.596 raeburn 1225: if ($cid ne $env{'request.course.id'}) {
1226: my ($srcdom,$srcnum) = split(/_/,$cid);
1227: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1228: $othercrs = '<br />'.&mt('(from another course)');
1229: } else {
1230: $canpaste = 0;
1231: $nopaste = &mt('Paste from another course unavailable.');
1232: }
1233: }
1.492 raeburn 1234: }
1.596 raeburn 1235: if ($canpaste) {
1236: push(@pasteable,$suffix);
1237: }
1.538 raeburn 1238: }
1239: my $buffer;
1.598 raeburn 1240: if (($is_external) || ($is_exttool)) {
1.538 raeburn 1241: $buffer = &mt('External Resource').': '.
1242: &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('.
1243: &LONCAPA::map::qtescape($url).')';
1244: } else {
1245: my $icon = &Apache::loncommon::icon($extension);
1246: if ($extension eq 'sequence' &&
1247: $url =~ m{/default_\d+\.sequence$}x) {
1248: $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
1249: $icon .= '/navmap.folder.closed.gif';
1250: }
1.589 raeburn 1251: my $title = $env{'docs.markedcopy_title_'.$suffix};
1252: if ($title eq '') {
1253: ($title) = ($url =~ m{/([^/]+)$});
1254: }
1.538 raeburn 1255: $buffer = '<img src="'.$icon.'" alt="" class="LC_icon" />'.
1256: ': '.
1257: &Apache::loncommon::parse_supplemental_title(
1.589 raeburn 1258: &LONCAPA::map::qtescape($title));
1.538 raeburn 1259: }
1260: $pasteitems .= '<div class="LC_left_float">';
1261: my ($options,$onclick);
1262: if (($canpaste) && (!$areachange) && (!$othercourse) &&
1263: ($env{'docs.markedcopy_cmd_'.$suffix} eq 'cut')) {
1264: if (($is_uploaded_map) ||
1265: ($url =~ /(bulletinboard|smppg)$/) ||
1266: ($url =~ m{^/uploaded/$coursedom/$coursenum/(?:docs|supplemental)/(.+)$})) {
1267: $options = &paste_options($suffix,$is_uploaded_map,$parent);
1268: $onclick= 'onclick="showOptions(this,'."'$suffix'".');" ';
1269: }
1270: }
1271: $pasteitems .= '<label><input type="checkbox" name="pasting" id="pasting_'.$suffix.'" value="'.$suffix.'" '.$onclick.'/>'.$buffer.'</label>';
1272: if ($nopaste) {
1273: $pasteitems .= $nopaste;
1274: } else {
1275: if ($othercrs) {
1276: $pasteitems .= $othercrs;
1277: }
1278: if ($options) {
1279: $pasteitems .= $options;
1.492 raeburn 1280: }
1281: }
1.538 raeburn 1282: $pasteitems .= '</div>';
1283: }
1284: }
1285: if ($pasteitems eq '') {
1286: &Apache::lonnet::delenv('docs.markedcopies');
1287: }
1288: my ($pasteform,$form_start,$buttons,$form_end);
1289: if ($pasteitems) {
1290: $pasteitems .= '<div style="padding:0;clear:both;margin:0;border:0"></div>';
1.541 raeburn 1291: $form_start = '<form name="pasteform" action="/adm/coursedocs" method="post" onsubmit="return validateClipboard();">';
1.538 raeburn 1292: if (@pasteable) {
1.575 raeburn 1293: my $value = &mt('Paste to current folder');
1294: if ($container eq 'page') {
1295: $value = &mt('Paste to current page');
1296: }
1297: $buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.(' 'x2);
1298: }
1299: $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.(' 'x2);
1300: if ($clipboardcount > 1) {
1301: $buttons .=
1302: '<span style="text-decoration:line-through">'.(' 'x20).'</span>'.(' 'x2).
1303: '<input type="button" name="checkallclip" value="'.&mt('Check all').'" style="height:20px;" onclick="checkClipboard();" />'.
1304: (' 'x2).
1305: '<input type="button" name="uncheckallclip" value="'.&mt('Uncheck all').'" style="height:20px;" onclick="uncheckClipboard();" />'.
1306: (' 'x2);
1.492 raeburn 1307: }
1.575 raeburn 1308: $form_end = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'.
1309: '</form>';
1.538 raeburn 1310: } else {
1311: $pasteitems = &mt('Clipboard is empty');
1.488 raeburn 1312: }
1.538 raeburn 1313: $r->print($form_start
1314: .'<fieldset>'
1315: .'<legend>'.&mt('Clipboard').(' ' x2).$buttons.'</legend>'
1316: .$pasteitems
1317: .'</fieldset>'
1318: .$form_end);
1319: }
1320:
1321: sub paste_options {
1322: my ($suffix,$is_uploaded_map,$parent) = @_;
1323: my ($copytext,$movetext);
1324: if ($is_uploaded_map) {
1325: $copytext = &mt('Copy to new folder');
1326: $movetext = &mt('Move old');
1327: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /bulletinboard$/) {
1328: $copytext = &mt('Copy to new board');
1329: $movetext = &mt('Move (not posts)');
1330: } elsif ($env{'docs.markedcopy_url_'.$suffix} =~ /smppg$/) {
1331: $copytext = &mt('Copy to new page');
1332: $movetext = &mt('Move');
1.533 raeburn 1333: } else {
1.538 raeburn 1334: $copytext = &mt('Copy to new file');
1335: $movetext = &mt('Move');
1336: }
1337: my $output = '<br />'.
1338: '<span id="pasteoptionstext_'.$suffix.'" class="LC_fontsize_small LC_nobreak"></span>'.
1339: '<div id="pasteoptions_'.$suffix.'" class="LC_dccid" style="display:none;"><span class="LC_nobreak">'.(' 'x 4).
1340: '<label>'.
1341: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="new" checked="checked" />'.
1342: $copytext.'</label></span>'.(' 'x2).' '.
1343: '<span class="LC_nobreak"><label>'.
1344: '<input type="radio" name="docs.markedcopy_options_'.$suffix.'" value="move" />'.
1345: $movetext.'</label></span>';
1346: if (($is_uploaded_map) && ($env{'docs.markedcopy_nested_'.$suffix})) {
1347: $output .= '<br /><fieldset><legend>'.&mt('Folder to paste contains sub-folders').
1348: '</legend><table border="0">';
1349: my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1350: my @titles = split(/\Q___&&&___\E/,$env{'docs.markedcopy_nestednames_'.$suffix});
1351: my $lastdir = $parent;
1352: my %depths = (
1353: $lastdir => 0,
1354: );
1355: my (%display,%deps);
1356: for (my $i=0; $i<@pastemaps; $i++) {
1357: ($lastdir,my $subfolderstr) = split(/\:/,$pastemaps[$i]);
1358: my ($namedir,$esctitlestr) = split(/\:/,$titles[$i]);
1359: my @subfolders = split(/,/,$subfolderstr);
1360: $deps{$lastdir} = \@subfolders;
1361: my @subfoldertitles = map { &unescape($_); } split(/,/,$esctitlestr);
1362: my $depth = $depths{$lastdir} + 1;
1363: my $offset = int($depth * 4);
1364: my $indent = (' ' x $offset);
1365: for (my $j=0; $j<@subfolders; $j++) {
1366: $depths{$subfolders[$j]} = $depth;
1367: $display{$subfolders[$j]} =
1368: '<tr><td>'.$indent.$subfoldertitles[$j].' </td>'.
1369: '<td><label>'.
1370: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="new" checked="checked" />'.&mt('Copy to new').'</label>'.(' ' x2).
1371: '<label>'.
1372: '<input type="radio" name="docs.markedcopy_'.$suffix.'_'.$subfolders[$j].'" value="move" />'.
1373: &mt('Move old').'</label>'.
1374: '</td></tr>';
1375: }
1.492 raeburn 1376: }
1.538 raeburn 1377: &recurse_print(\$output,$parent,\%deps,\%display);
1378: $output .= '</table></fieldset>';
1.329 droeschl 1379: }
1.538 raeburn 1380: $output .= '</div>';
1381: return $output;
1.488 raeburn 1382: }
1383:
1.492 raeburn 1384: sub recurse_print {
1.538 raeburn 1385: my ($outputref,$dir,$deps,$display) = @_;
1386: $$outputref .= $display->{$dir}."\n";
1.492 raeburn 1387: if (ref($deps->{$dir}) eq 'ARRAY') {
1388: foreach my $subdir (@{$deps->{$dir}}) {
1.538 raeburn 1389: &recurse_print($outputref,$subdir,$deps,$display);
1.492 raeburn 1390: }
1391: }
1392: }
1393:
1.488 raeburn 1394: sub supp_pasteable {
1395: my ($url) = @_;
1396: if (($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//}) ||
1397: (($url =~ /\.sequence$/) && ($url =~ m{^/uploaded/})) ||
1398: ($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) ||
1399: ($url =~ m{^/adm/$match_domain/$match_username/aboutme}) ||
1.598 raeburn 1400: ($url =~ m{^/public/$match_domain/$match_courseid/syllabus}) ||
1401: ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/exttools?$})) {
1.488 raeburn 1402: return 1;
1403: }
1404: return;
1.329 droeschl 1405: }
1406:
1.492 raeburn 1407: sub paste_popup_js {
1.594 damieng 1408: my %html_js_lt = &Apache::lonlocal::texthash(
1.538 raeburn 1409: show => 'Show Options',
1410: hide => 'Hide Options',
1.594 damieng 1411: );
1412: my %js_lt = &Apache::lonlocal::texthash(
1.541 raeburn 1413: none => 'No items selected from clipboard.',
1.492 raeburn 1414: );
1.594 damieng 1415: &html_escape(\%html_js_lt);
1416: &js_escape(\%html_js_lt);
1417: &js_escape(\%js_lt);
1.492 raeburn 1418: return <<"END";
1419:
1.538 raeburn 1420: function showPasteOptions(suffix) {
1421: document.getElementById('pasteoptions_'+suffix).style.display='block';
1.594 damieng 1422: document.getElementById('pasteoptionstext_'+suffix).innerHTML = ' <a href="javascript:hidePasteOptions(\\''+suffix+'\\');" class="LC_menubuttons_link">$html_js_lt{'hide'}</a>';
1.492 raeburn 1423: return;
1424: }
1425:
1.538 raeburn 1426: function hidePasteOptions(suffix) {
1427: document.getElementById('pasteoptions_'+suffix).style.display='none';
1.594 damieng 1428: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.538 raeburn 1429: return;
1430: }
1431:
1432: function showOptions(caller,suffix) {
1433: if (document.getElementById('pasteoptionstext_'+suffix)) {
1434: if (caller.checked) {
1.594 damieng 1435: document.getElementById('pasteoptionstext_'+suffix).innerHTML =' <a href="javascript:showPasteOptions(\\''+suffix+'\\')" class="LC_menubuttons_link">$html_js_lt{'show'}</a>';
1.538 raeburn 1436: } else {
1437: document.getElementById('pasteoptionstext_'+suffix).innerHTML ='';
1438: }
1439: if (document.getElementById('pasteoptions_'+suffix)) {
1440: document.getElementById('pasteoptions_'+suffix).style.display='none';
1441: }
1442: }
1.492 raeburn 1443: return;
1444: }
1445:
1.541 raeburn 1446: function validateClipboard() {
1447: var numchk = 0;
1448: if (document.pasteform.pasting.length > 1) {
1449: for (var i=0; i<document.pasteform.pasting.length; i++) {
1450: if (document.pasteform.pasting[i].checked) {
1451: numchk ++;
1452: }
1453: }
1454: } else {
1455: if (document.pasteform.pasting.type == 'checkbox') {
1456: if (document.pasteform.pasting.checked) {
1457: numchk ++;
1458: }
1459: }
1460: }
1461: if (numchk > 0) {
1462: return true;
1463: } else {
1.594 damieng 1464: alert("$js_lt{'none'}");
1.541 raeburn 1465: return false;
1466: }
1467: }
1468:
1.575 raeburn 1469: function checkClipboard() {
1470: if (document.pasteform.pasting.length > 1) {
1471: for (var i=0; i<document.pasteform.pasting.length; i++) {
1472: document.pasteform.pasting[i].checked = true;
1473: }
1474: }
1475: return;
1476: }
1477:
1478: function uncheckClipboard() {
1479: if (document.pasteform.pasting.length >1) {
1480: for (var i=0; i<document.pasteform.pasting.length; i++) {
1481: document.pasteform.pasting[i].checked = false;
1482: }
1483: }
1484: return;
1485: }
1486:
1.492 raeburn 1487: END
1488:
1489: }
1490:
1.329 droeschl 1491: sub do_paste_from_buffer {
1.492 raeburn 1492: my ($coursenum,$coursedom,$folder,$container,$errors) = @_;
1.329 droeschl 1493:
1.538 raeburn 1494: # Array of items in paste buffer
1495: my (@currpaste,%pastebuffer,%allerrors);
1496: @currpaste = split(/,/,$env{'docs.markedcopies'});
1497:
1.492 raeburn 1498: # Early out if paste buffer is empty
1.538 raeburn 1499: if (@currpaste == 0) {
1.492 raeburn 1500: return ();
1.538 raeburn 1501: }
1502: map { $pastebuffer{$_} = 1; } @currpaste;
1503:
1504: # Array of items selected items to paste
1505: my @reqpaste = &Apache::loncommon::get_env_multiple('form.pasting');
1506:
1507: # Early out if nothing selected to paste
1508: if (@reqpaste == 0) {
1509: return();
1510: }
1511: my @topaste;
1512: foreach my $suffix (@reqpaste) {
1513: next if ($suffix =~ /\D/);
1514: next unless (exists($pastebuffer{$suffix}));
1515: push(@topaste,$suffix);
1516: }
1517:
1518: # Early out if nothing available to paste
1519: if (@topaste == 0) {
1520: return();
1.329 droeschl 1521: }
1522:
1.538 raeburn 1523: my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%duplicate,
1.597 raeburn 1524: %prefixchg,%srcdom,%srcnum,%srcmapidx,%marktomove,$save_err,$lockerrors,$allresult);
1.538 raeburn 1525:
1526: foreach my $suffix (@topaste) {
1527: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1.596 raeburn 1528: my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.597 raeburn 1529: my $mapidx=&LONCAPA::map::qtescape($env{'docs.markedcopy_map_'.$suffix});
1.492 raeburn 1530: # Supplemental content may only include certain types of content
1531: # Early out if pasted content is not supported in Supplemental area
1.538 raeburn 1532: if ($folder =~ /^supplemental/) {
1533: unless (&supp_pasteable($url)) {
1534: $notinsupp{$suffix} = 1;
1535: next;
1536: }
1.492 raeburn 1537: }
1.538 raeburn 1538: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/}) {
1539: my $srcd = $1;
1540: my $srcn = $2;
1.492 raeburn 1541: # When paste buffer was populated using an active role in a different course
1.538 raeburn 1542: # check for mdc privilege in the course from which the resource was pasted
1543: if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1544: unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1545: $notincrs{$suffix} = 1;
1546: next;
1547: }
1.491 raeburn 1548: }
1.538 raeburn 1549: $srcdom{$suffix} = $srcd;
1550: $srcnum{$suffix} = $srcn;
1.597 raeburn 1551: } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) ||
1552: ($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg)$})) {
1.596 raeburn 1553: my ($srcd,$srcn) = split(/_/,$cid);
1554: # When paste buffer was populated using an active role in a different course
1555: # check for mdc privilege in the course from which the resource was pasted
1556: if (($srcd ne $coursedom) || ($srcn ne $coursenum)) {
1557: unless ($env{"user.priv.cm./$srcd/$srcn"} =~ /\Q:mdc&F\E/) {
1558: $notincrs{$suffix} = 1;
1559: next;
1560: }
1561: }
1562: $srcdom{$suffix} = $srcd;
1563: $srcnum{$suffix} = $srcn;
1.491 raeburn 1564: }
1.597 raeburn 1565: $srcmapidx{$suffix} = $mapidx;
1.538 raeburn 1566: push(@dopaste,$suffix);
1567: if ($url=~/\.(page|sequence)$/) {
1568: $is_map{$suffix} = 1;
1569: }
1570:
1571: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/([^/]+)}) {
1572: my $oldprefix = $1;
1.492 raeburn 1573: # When pasting content from Main Content to Supplemental Content and vice versa
1574: # URLs will contain different paths (which depend on whether pasted item is
1.597 raeburn 1575: # a folder/page or a document).
1.538 raeburn 1576: if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) {
1577: $prefixchg{$suffix} = 'docstosupp';
1578: } elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) {
1579: $prefixchg{$suffix} = 'supptodocs';
1580: }
1.491 raeburn 1581:
1.492 raeburn 1582: # If pasting an uploaded map, get list of contained uploaded maps.
1.538 raeburn 1583: if ($env{'docs.markedcopy_nested_'.$suffix}) {
1584: my @nested;
1585: my ($type) = ($oldprefix =~ /^(default|supplemental)/);
1586: my @items = split(/\&/,$env{'docs.markedcopy_nested_'.$suffix});
1587: my @deps = map { /\d+:([\d,]+$)/ } @items;
1588: foreach my $dep (@deps) {
1589: if ($dep =~ /,/) {
1590: push(@nested,split(/,/,$dep));
1591: } else {
1592: push(@nested,$dep);
1593: }
1.492 raeburn 1594: }
1.538 raeburn 1595: foreach my $item (@nested) {
1596: if ($env{'form.docs.markedcopy_'.$suffix.'_'.$item} eq 'move') {
1597: push(@{$marktomove{$suffix}},$type.'_'.$item);
1598: }
1.492 raeburn 1599: }
1600: }
1.488 raeburn 1601: }
1602: }
1603:
1.538 raeburn 1604: # Early out if nothing available to paste
1605: if (@dopaste == 0) {
1606: return ();
1607: }
1608:
1609: # Populate message hash and hashes used for main content <=> supplemental content
1610: # changes
1611:
1612: %msgs = &Apache::lonlocal::texthash (
1613: notinsupp => 'Paste failed: content type is not supported within Supplemental Content',
1614: notincrs => 'Paste failed: Item is from a different course which you do not have rights to edit.',
1615: duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.',
1616: );
1617:
1618: %before = (
1619: docstosupp => {
1620: map => 'default',
1621: doc => 'docs',
1622: },
1623: supptodocs => {
1624: map => 'supplemental',
1625: doc => 'supplemental',
1626: },
1627: );
1628:
1629: %after = (
1630: docstosupp => {
1631: map => 'supplemental',
1632: doc => 'supplemental'
1633: },
1634: supptodocs => {
1635: map => 'default',
1636: doc => 'docs',
1637: },
1638: );
1639:
1640: # Retrieve information about all course maps in main content area
1641:
1642: my $allmaps = {};
1643: if ($folder =~ /^default/) {
1644: $allmaps =
1645: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
1646: $env{"course.$env{'request.course.id'}.home"},
1647: $env{'request.course.id'});
1648: }
1649:
1650: my (@toclear,%mapurls,%lockerrs,%msgerrs,%results);
1651:
1652: # Loop over the items to paste
1653: foreach my $suffix (@dopaste) {
1.329 droeschl 1654: # Maps need to be copied first
1.538 raeburn 1655: my (%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies,
1656: %dbcopies,%zombies,%params,%docmoves,%mapmoves,%mapchanges,%newsubdir,
1.597 raeburn 1657: %newurls,%tomove,%resdatacopy);
1.538 raeburn 1658: if (ref($marktomove{$suffix}) eq 'ARRAY') {
1659: map { $tomove{$_} = 1; } @{$marktomove{$suffix}};
1660: }
1661: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix});
1662: my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix});
1.596 raeburn 1663: my $cid=&LONCAPA::map::qtescape($env{'docs.markedcopy_crs_'.$suffix});
1.538 raeburn 1664: my $oldurl = $url;
1665: if ($is_map{$suffix}) {
1.491 raeburn 1666: # If pasting a map, check if map contains other maps
1.538 raeburn 1667: my (%hierarchy,%titles);
1668: &contained_map_check($url,$folder,\%removefrommap,\%removeparam,
1669: \%addedmaps,\%hierarchy,\%titles,$allmaps);
1670: if ($url=~ m{^/uploaded/}) {
1671: my $newurl;
1672: unless ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
1673: ($newurl,my $error) =
1674: &get_newmap_url($url,$folder,$prefixchg{$suffix},$coursedom,
1675: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1676: \$title,$allmaps,\%newurls);
1677: if ($error) {
1678: $allerrors{$suffix} = $error;
1679: next;
1680: }
1681: if ($newurl ne '') {
1682: if ($newurl ne $url) {
1683: if ($newurl =~ /(?:default|supplemental)_(\d+).(?:sequence|page)$/) {
1684: $newsubdir{$url} = $1;
1685: }
1686: $mapchanges{$url} = 1;
1.492 raeburn 1687: }
1.538 raeburn 1688: }
1689: }
1690: if (($srcdom{$suffix} ne $coursedom) ||
1691: ($srcnum{$suffix} ne $coursenum) ||
1692: ($prefixchg{$suffix}) || (($newurl ne '') && ($newurl ne $url))) {
1693: unless (&url_paste_fixups($url,$folder,$prefixchg{$suffix},
1694: $coursedom,$coursenum,$srcdom{$suffix},
1695: $srcnum{$suffix},$allmaps,\%rewrites,
1696: \%retitles,\%copies,\%dbcopies,
1697: \%zombies,\%params,\%mapmoves,
1698: \%mapchanges,\%tomove,\%newsubdir,
1.597 raeburn 1699: \%newurls,\%resdatacopy)) {
1.538 raeburn 1700: $mapmoves{$url} = 1;
1701: }
1702: $url = $newurl;
1703: } elsif ($env{'docs.markedcopy_nested_'.$suffix}) {
1704: &url_paste_fixups($url,$folder,$prefixchg{$suffix},$coursedom,
1705: $coursenum,$srcdom{$suffix},$srcnum{$suffix},
1706: $allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies,
1707: \%zombies,\%params,\%mapmoves,\%mapchanges,
1.597 raeburn 1708: \%tomove,\%newsubdir,\%newurls,\%resdatacopy);
1.538 raeburn 1709: }
1710: } elsif ($url=~m {^/res/}) {
1.597 raeburn 1711: # published map can only exist once, so remove from paste buffer when done
1.538 raeburn 1712: push(@toclear,$suffix);
1713: # if pasting published map (main content area only) check map not already in course
1714: if ($folder =~ /^default/) {
1715: if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) {
1716: $duplicate{$suffix} = 1;
1717: next;
1.492 raeburn 1718: }
1.491 raeburn 1719: }
1720: }
1.538 raeburn 1721: }
1722: if ($url=~ m{/(bulletinboard|smppg)$}) {
1723: my $prefix = $1;
1.596 raeburn 1724: my $fromothercrs;
1.538 raeburn 1725: #need to copy the db contents to a new one, unless this is a move.
1726: my %info = (
1727: src => $url,
1728: cdom => $coursedom,
1729: cnum => $coursenum,
1.596 raeburn 1730: );
1731: if (($srcdom{$suffix} =~ /^$match_domain$/) && ($srcnum{$suffix} =~ /^$match_courseid$/)) {
1732: unless (($srcdom{$suffix} eq $coursedom) && ($srcnum{$suffix} eq $coursenum)) {
1733: $fromothercrs = 1;
1734: $info{'cdom'} = $srcdom{$suffix};
1735: $info{'cnum'} = $srcnum{$suffix};
1736: }
1737: }
1738: unless (($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') && (!$fromothercrs)) {
1.538 raeburn 1739: my (%lockerr,$msg);
1740: my ($newurl,$result,$errtext) =
1741: &dbcopy(\%info,$coursedom,$coursenum,\%lockerr);
1742: if ($result eq 'ok') {
1743: $url = $newurl;
1744: $title=&mt('Copy of').' '.$title;
1745: } else {
1746: if ($prefix eq 'smppg') {
1747: $msg = &mt('Paste failed: An error occurred when copying the simple page.').' '.$errtext;
1748: } elsif ($prefix eq 'bulletinboard') {
1.565 bisitz 1749: $msg = &mt('Paste failed: An error occurred when copying the discussion board.').' '.$errtext;
1.538 raeburn 1750: }
1751: $results{$suffix} = $result;
1752: $msgerrs{$suffix} = $msg;
1753: $lockerrs{$suffix} = $lockerr{$prefix};
1754: next;
1755: }
1756: if ($lockerr{$prefix}) {
1757: $lockerrs{$suffix} = $lockerr{$prefix};
1.491 raeburn 1758: }
1.489 raeburn 1759: }
1760: }
1.538 raeburn 1761: $title = &LONCAPA::map::qtunescape($title);
1762: my $ext='false';
1763: if ($url=~m{^http(|s)://}) { $ext='true'; }
1764: if ($env{'docs.markedcopy_supplemental_'.$suffix}) {
1765: if ($folder !~ /^supplemental/) {
1766: (undef,undef,$title) =
1767: &Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental_'.$suffix});
1768: }
1769: } else {
1770: if ($folder=~/^supplemental/) {
1771: $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
1772: $env{'user.domain'}.'___&&&___'.$title;
1.491 raeburn 1773: }
1.533 raeburn 1774: }
1.491 raeburn 1775:
1776: # For uploaded files (excluding pages/sequences) path in copied file is changed
1777: # if paste is from Main to Supplemental (or vice versa), or if pasting between
1778: # courses.
1779:
1.538 raeburn 1780: unless ($is_map{$suffix}) {
1781: my $newidx;
1.492 raeburn 1782: # Now insert the URL at the bottom
1.538 raeburn 1783: $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
1784: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(.+)$}) {
1785: my $relpath = $1;
1786: if ($relpath ne '') {
1787: my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$});
1788: my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/);
1789: my $newprefix = $newloc;
1790: if ($newloc eq 'default') {
1791: $newprefix = 'docs';
1792: }
1793: if ($newdocsdir eq '') {
1794: $newdocsdir = 'default';
1795: }
1796: if (($prefixchg{$suffix}) ||
1797: ($srcdom{$suffix} ne $coursedom) ||
1798: ($srcnum{$suffix} ne $coursenum) ||
1799: ($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) {
1800: my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";
1801: $url =
1802: &Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath,
1803: &Apache::lonnet::getfile($oldurl));
1804: if ($url eq '/adm/notfound.html') {
1805: $msgs{$suffix} = &mt('Paste failed: an error occurred saving the file.');
1806: next;
1807: } else {
1808: my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$});
1809: $newsubpath =~ s{/+$}{/};
1810: $docmoves{$oldurl} = $newsubpath;
1811: }
1.491 raeburn 1812: }
1813: }
1.597 raeburn 1814: } elsif ($url =~ m{^/res/lib/templates/(\w+)\.problem$}) {
1815: my $template = $1;
1816: if ($newidx) {
1817: ©_templated_files($url,$srcdom{$suffix},$srcnum{$suffix},$srcmapidx{$suffix},
1818: $coursedom,$coursenum,$template,$newidx,"$folder.$container");
1819: }
1.491 raeburn 1820: }
1.538 raeburn 1821: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
1822: ':'.$ext.':normal:res';
1823: push(@LONCAPA::map::order,$newidx);
1824: # Store the result
1825: my ($errtext,$fatal) =
1826: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1827: if ($fatal) {
1828: $save_err .= $errtext;
1829: $allresult = 'fail';
1830: }
1.488 raeburn 1831: }
1.538 raeburn 1832:
1.597 raeburn 1833: # Apply any changes to maps, or copy dependencies for uploaded HTML pages, or update
1834: # resourcedata for simpleproblems copied from another course
1.538 raeburn 1835: unless ($allresult eq 'fail') {
1836: my %updated = (
1837: rewrites => \%rewrites,
1838: zombies => \%zombies,
1839: removefrommap => \%removefrommap,
1840: removeparam => \%removeparam,
1841: dbcopies => \%dbcopies,
1.597 raeburn 1842: resdatacopy => \%resdatacopy,
1.538 raeburn 1843: retitles => \%retitles,
1844: );
1845: my %info = (
1846: newsubdir => \%newsubdir,
1847: params => \%params,
1848: );
1849: if ($prefixchg{$suffix}) {
1850: $info{'before'} = $before{$prefixchg{$suffix}};
1851: $info{'after'} = $after{$prefixchg{$suffix}};
1852: }
1853: my %moves = (
1854: copies => \%copies,
1855: docmoves => \%docmoves,
1856: mapmoves => \%mapmoves,
1857: );
1858: (my $result,$msgs{$suffix},my $lockerror) =
1859: &apply_fixups($folder,$is_map{$suffix},$coursedom,$coursenum,$errors,
1860: \%updated,\%info,\%moves,$prefixchg{$suffix},$oldurl,
1861: $url,'paste');
1862: $lockerrors .= $lockerror;
1863: if ($result eq 'ok') {
1864: if ($is_map{$suffix}) {
1865: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1866: $folder.'.'.$container);
1867: if ($fatal) {
1868: $allresult = 'failread';
1869: } else {
1870: if ($#LONCAPA::map::order<1) {
1871: my $idx=&LONCAPA::map::getresidx();
1872: if ($idx<=0) { $idx=1; }
1873: $LONCAPA::map::order[0]=$idx;
1874: $LONCAPA::map::resources[$idx]='';
1875: }
1876: my $newidx = &LONCAPA::map::getresidx(&LONCAPA::map::qtunescape($url));
1877: $LONCAPA::map::resources[$newidx]=$title.':'.&LONCAPA::map::qtunescape($url).
1878: ':'.$ext.':normal:res';
1879: push(@LONCAPA::map::order,$newidx);
1.492 raeburn 1880:
1881: # Store the result
1.538 raeburn 1882: my ($errtext,$fatal) =
1883: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1884: if ($fatal) {
1885: $save_err .= $errtext;
1886: $allresult = 'failstore';
1887: }
1888: }
1889: }
1890: if ($env{'form.docs.markedcopy_options_'.$suffix} eq 'move') {
1891: push(@toclear,$suffix);
1892: }
1893: }
1.492 raeburn 1894: }
1895: }
1.538 raeburn 1896: &clear_from_buffer(\@toclear,\@currpaste);
1897: my $msgsarray;
1898: foreach my $suffix (keys(%msgs)) {
1899: if (ref($msgs{$suffix}) eq 'ARRAY') {
1900: $msgsarray .= join(',',@{$msgs{$suffix}});
1901: }
1902: }
1903: return ($allresult,$save_err,$msgsarray,$lockerrors);
1904: }
1.533 raeburn 1905:
1.538 raeburn 1906: sub do_buffer_empty {
1907: my @currpaste = split(/,/,$env{'docs.markedcopies'});
1908: if (@currpaste == 0) {
1909: return &mt('Clipboard is already empty');
1910: }
1911: my @toclear = &Apache::loncommon::get_env_multiple('form.pasting');
1912: if (@toclear == 0) {
1913: return &mt('Nothing selected to clear from clipboard');
1914: }
1915: my $numdel = &clear_from_buffer(\@toclear,\@currpaste);
1916: if ($numdel) {
1917: return &mt('[quant,_1,item] cleared from clipboard',$numdel);
1918: } else {
1919: return &mt('Clipboard unchanged');
1.492 raeburn 1920: }
1.538 raeburn 1921: return;
1922: }
1923:
1924: sub clear_from_buffer {
1925: my ($toclear,$currpaste) = @_;
1926: return unless ((ref($toclear) eq 'ARRAY') && (ref($currpaste) eq 'ARRAY'));
1927: my %pastebuffer;
1928: map { $pastebuffer{$_} = 1; } @{$currpaste};
1929: my $numdel = 0;
1930: foreach my $suffix (@{$toclear}) {
1931: next if ($suffix =~ /\D/);
1932: next unless (exists($pastebuffer{$suffix}));
1933: my $regexp = 'docs.markedcopy_[a-z]+_'.$suffix;
1934: if (&Apache::lonnet::delenv($regexp,1) eq 'ok') {
1935: delete($pastebuffer{$suffix});
1936: $numdel ++;
1937: }
1938: }
1939: my $newbuffer = join(',',sort(keys(%pastebuffer)));
1940: &Apache::lonnet::appenv({'docs.markedcopies' => $newbuffer});
1941: return $numdel;
1.492 raeburn 1942: }
1943:
1944: sub get_newmap_url {
1945: my ($url,$folder,$prefixchg,$coursedom,$coursenum,$srcdom,$srcnum,
1946: $titleref,$allmaps,$newurls) = @_;
1947: my $newurl;
1948: if ($url=~ m{^/uploaded/}) {
1949: $$titleref=&mt('Copy of').' '.$$titleref;
1950: }
1951: my $now = time;
1952: my $suffix=$$.int(rand(100)).$now;
1953: my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
1954: if ($oldid =~ m{^(/uploaded/$match_domain/$match_courseid/)(\D+)(\d+)$}) {
1955: my $path = $1;
1956: my $prefix = $2;
1957: my $ancestor = $3;
1958: if (length($ancestor) > 10) {
1959: $ancestor = substr($ancestor,-10,10);
1960: }
1961: my $newid;
1962: if ($prefixchg) {
1963: if ($folder =~ /^supplemental/) {
1964: $prefix =~ s/^default/supplemental/;
1965: } else {
1966: $prefix =~ s/^supplemental/default/;
1967: }
1968: }
1969: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
1970: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
1971: } else {
1972: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$now.'.'.$ext;
1973: }
1974: my $counter = 0;
1975: my $is_unique = &uniqueness_check($newurl);
1976: if ($folder =~ /^default/) {
1977: if ($allmaps->{$newurl}) {
1978: $is_unique = 0;
1979: }
1980: }
1981: while ((!$is_unique || $allmaps->{$newurl} || $newurls->{$newurl}) && ($counter < 100)) {
1982: $counter ++;
1983: $suffix ++;
1984: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
1985: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
1986: } else {
1987: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$ancestor.$suffix.'.'.$ext;
1988: }
1989: $is_unique = &uniqueness_check($newurl);
1990: }
1991: if ($is_unique) {
1992: $newurls->{$newurl} = 1;
1993: } else {
1994: if ($url=~/\.page$/) {
1995: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the composite page'));
1996: } else {
1997: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the folder'));
1998: }
1999: }
1.329 droeschl 2000: }
1.492 raeburn 2001: return ($newurl);
1.329 droeschl 2002: }
2003:
1.488 raeburn 2004: sub dbcopy {
1.533 raeburn 2005: my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_;
2006: my ($url,$result,$errtext);
2007: if (ref($dbref) eq 'HASH') {
1.596 raeburn 2008: $url = $dbref->{'src'};
1.533 raeburn 2009: if ($url =~ m{/(smppg|bulletinboard)$}) {
2010: my $prefix = $1;
2011: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2012: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2013: my $db_name;
2014: my $marker = (split(m{/},$url))[4];
2015: $marker=~s/\D//g;
2016: if ($dbref->{'src'} =~ m{/smppg$}) {
2017: $db_name =
2018: &Apache::lonsimplepage::get_db_name($url,$marker,
2019: $dbref->{'cdom'},
2020: $dbref->{'cnum'});
2021: } else {
2022: $db_name = 'bulletinpage_'.$marker;
2023: }
2024: my ($suffix,$freedlock,$error) =
2025: &Apache::lonnet::get_timebased_id($prefix,'num','templated',
2026: $coursedom,$coursenum,
2027: 'concat');
2028: if (!$suffix) {
2029: if ($prefix eq 'smppg') {
2030: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);
2031: } else {
1.565 bisitz 2032: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url);
1.533 raeburn 2033: }
2034: if ($error) {
2035: $errtext .= '<br />'.$error;
2036: }
2037: } else {
2038: #need to copy the db contents to a new one.
2039: my %contents=&Apache::lonnet::dump($db_name,
2040: $dbref->{'cdom'},
2041: $dbref->{'cnum'});
2042: if (exists($contents{'uploaded.photourl'})) {
2043: my $photo = $contents{'uploaded.photourl'};
2044: my ($subdir,$fname) =
2045: ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});
1.596 raeburn 2046: my $newphoto;
1.533 raeburn 2047: if ($fname ne '') {
2048: my $content = &Apache::lonnet::getfile($photo);
2049: unless ($content eq '-1') {
2050: $env{'form.'.$suffix.'.photourl'} = $content;
2051: $newphoto =
2052: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");
2053: delete($env{'form.'.$suffix.'.photourl'});
2054: }
2055: }
2056: if ($newphoto =~ m{^/uploaded/}) {
2057: $contents{'uploaded.photourl'} = $newphoto;
2058: }
2059: }
2060: $db_name =~ s{_\d*$ }{_$suffix}x;
2061: $result=&Apache::lonnet::put($db_name,\%contents,
2062: $coursedom,$coursenum);
2063: if ($result eq 'ok') {
2064: $url =~ s{/(\d*)/(smppg|bulletinboard)$}{/$suffix/$2}x;
2065: }
2066: }
2067: if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) {
1.559 raeburn 2068: $lockerrorsref->{$prefix} =
1.533 raeburn 2069: '<div class="LC_error">'.
2070: &mt('There was a problem removing a lockfile.');
2071: if ($prefix eq 'smppg') {
1.560 raeburn 2072: $lockerrorsref->{$prefix} .=
1.559 raeburn 2073: ' '.&mt('This will prevent creation of additional simple pages in this course.');
1.533 raeburn 2074: } else {
1.565 bisitz 2075: $lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional discussion boards in this course.');
1.533 raeburn 2076: }
1.560 raeburn 2077: $lockerrorsref->{$prefix} .= ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
2078: '<a href="/adm/helpdesk" target="_helpdesk">','</a>').
2079: '</div>';
1.533 raeburn 2080: }
2081: }
2082: } elsif ($url =~ m{/syllabus$}) {
2083: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
2084: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
2085: if (($dbref->{'cdom'} ne $coursedom) ||
2086: ($dbref->{'cnum'} ne $coursenum)) {
2087: my %contents=&Apache::lonnet::dump('syllabus',
2088: $dbref->{'cdom'},
2089: $dbref->{'cnum'});
2090: $result=&Apache::lonnet::put('syllabus',\%contents,
2091: $coursedom,$coursenum);
2092: }
2093: }
1.488 raeburn 2094: }
2095: }
1.533 raeburn 2096: return ($url,$result,$errtext);
1.488 raeburn 2097: }
2098:
1.597 raeburn 2099: sub copy_templated_files {
2100: my ($srcurl,$srcdom,$srcnum,$srcmapinfo,$coursedom,$coursenum,$template,$newidx,$newmapname) = @_;
2101: my ($srcfolder,$srcid,$srcwaspage) = split(/:/,$srcmapinfo);
2102: my $srccontainer = 'sequence';
2103: if ($srcwaspage) {
2104: $srccontainer = 'page';
2105: }
2106: my $srcsymb = "uploaded/$srcdom/$srcnum/$srcfolder.$srccontainer".
2107: '___'.$srcid.'___'.&Apache::lonnet::declutter($srcurl);
2108: my $srcprefix = $srcdom.'_'.$srcnum.'.'.$srcsymb;
2109: my %srcparms=&Apache::lonnet::dump('resourcedata',$srcdom,$srcnum,$srcprefix);
2110: my $newsymb = "uploaded/$coursedom/$coursenum/$newmapname".'___'.$newidx.'___lib/templates/'.
2111: $template.'.problem';
2112: my $newprefix = $coursedom.'_'.$coursenum.'.'.$newsymb;
2113: if ($template eq 'simpleproblem') {
2114: $srcprefix .= '.0.';
2115: my $weightprefix = $newprefix;
2116: $newprefix .= '.0.';
2117: my @simpleprobqtypes = qw(radio option string essay numerical);
2118: my $qtype=$srcparms{$srcprefix.'questiontype'};
2119: if (grep(/^\Q$qtype\E$/,@simpleprobqtypes)) {
2120: my %newdata;
2121: foreach my $type (@simpleprobqtypes) {
2122: if ($type eq $qtype) {
2123: $newdata{"$weightprefix.$type.weight"}=1;
2124: } else {
2125: $newdata{"$weightprefix.$type.weight"}=0;
2126: }
2127: }
2128: $newdata{$newprefix.'hiddenparts'} = '!'.$qtype;
2129: $newdata{$newprefix.'questiontext'} = $srcparms{$srcprefix.'questiontext'};
2130: $newdata{$newprefix.'hinttext'} = $srcparms{$srcprefix.'hinttext'};
2131: if ($qtype eq 'numerical') {
2132: $newdata{$newprefix.'numericalscript'} = $srcparms{$srcprefix.'numericalscript'};
2133: $newdata{$newprefix.'numericalanswer'} = $srcparms{$srcprefix.'numericalanswer'};
2134: $newdata{$newprefix.'numericaltolerance'} = $srcparms{$srcprefix.'numericaltolerance'};
2135: $newdata{$newprefix.'numericalsigfigs'} = $srcparms{$srcprefix.'numericalsigfigs'};
2136: } elsif (($qtype eq 'option') || ($qtype eq 'radio')) {
2137: my $maxfoils=$srcparms{$srcprefix.'maxfoils'};
2138: unless (defined($maxfoils)) { $maxfoils=10; }
2139: unless ($maxfoils=~/^\d+$/) { $maxfoils=10; }
2140: if ($maxfoils<=0) { $maxfoils=10; }
2141: my $randomize=$srcparms{$srcprefix.'randomize'};
2142: unless (defined($randomize)) { $randomize='yes'; }
2143: unless ($randomize eq 'no') { $randomize='yes'; }
2144: $newdata{$newprefix.'maxfoils'} = $maxfoils;
2145: $newdata{$newprefix.'randomize'} = $randomize;
2146: if ($qtype eq 'option') {
2147: $newdata{$newprefix.'options'} = $srcparms{$srcprefix.'options'};
2148: }
2149: for (my $i=1; $i<=10; $i++) {
2150: $newdata{$newprefix.'value'.$i} = $srcparms{$srcprefix.'value'.$i};
2151: $newdata{$newprefix.'position'.$i} = $srcparms{$srcprefix.'position'.$i};
2152: $newdata{$newprefix.'text'.$i} = $srcparms{$srcprefix.'text'.$i};
2153: }
2154:
2155: } elsif (($qtype eq 'option') || ($qtype eq 'radio')) {
2156: my $maxfoils=$srcparms{$srcprefix.'maxfoils'};
2157: unless (defined($maxfoils)) { $maxfoils=10; }
2158: unless ($maxfoils=~/^\d+$/) { $maxfoils=10; }
2159: if ($maxfoils<=0) { $maxfoils=10; }
2160: my $randomize=$srcparms{$srcprefix.'randomize'};
2161: unless (defined($randomize)) { $randomize='yes'; }
2162: unless ($randomize eq 'no') { $randomize='yes'; }
2163: $newdata{$newprefix.'maxfoils'} = $maxfoils;
2164: $newdata{$newprefix.'randomize'} = $randomize;
2165: if ($qtype eq 'option') {
2166: $newdata{$newprefix.'options'} = $srcparms{$srcprefix.'options'};
2167: }
2168: for (my $i=1; $i<=10; $i++) {
2169: $newdata{$newprefix.'value'.$i} = $srcparms{$srcprefix.'value'.$i};
2170: $newdata{$newprefix.'position'.$i} = $srcparms{$srcprefix.'position'.$i};
2171: $newdata{$newprefix.'text'.$i} = $srcparms{$srcprefix.'text'.$i};
2172: }
2173: } elsif ($qtype eq 'string') {
2174: $newdata{$newprefix.'stringanswer'} = $srcparms{$srcprefix.'stringanswer'};
2175: $newdata{$newprefix.'stringtype'} = $srcparms{$srcprefix.'stringtype'};
2176: }
2177: if (keys(%newdata)) {
2178: my $putres = &Apache::lonnet::cput('resourcedata',\%newdata,$coursedom,
2179: $coursenum);
2180: if ($putres eq 'ok') {
2181: &Apache::lonnet::devalidatecourseresdata($coursenum,$coursedom);
2182: }
2183: }
2184: }
2185: }
2186: }
2187:
1.329 droeschl 2188: sub uniqueness_check {
2189: my ($newurl) = @_;
2190: my $unique = 1;
2191: foreach my $res (@LONCAPA::map::order) {
2192: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2193: $url=&LONCAPA::map::qtescape($url);
2194: if ($newurl eq $url) {
2195: $unique = 0;
1.344 bisitz 2196: last;
1.329 droeschl 2197: }
2198: }
2199: return $unique;
2200: }
2201:
1.488 raeburn 2202: sub contained_map_check {
1.492 raeburn 2203: my ($url,$folder,$removefrommap,$removeparam,$addedmaps,$hierarchy,$titles,
2204: $allmaps) = @_;
1.488 raeburn 2205: my $content = &Apache::lonnet::getfile($url);
2206: unless ($content eq '-1') {
2207: my $parser = HTML::TokeParser->new(\$content);
2208: $parser->attr_encoded(1);
2209: while (my $token = $parser->get_token) {
2210: next if ($token->[0] ne 'S');
2211: if ($token->[1] eq 'resource') {
2212: next if ($token->[2]->{'type'} eq 'zombie');
2213: my $ressrc = $token->[2]->{'src'};
2214: if ($folder =~ /^supplemental/) {
2215: unless (&supp_pasteable($ressrc)) {
1.492 raeburn 2216: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.488 raeburn 2217: next;
2218: }
2219: }
1.492 raeburn 2220: if ($ressrc =~ m{^/(res|uploaded)/.+\.(sequence|page)$}) {
2221: if ($1 eq 'uploaded') {
2222: $hierarchy->{$url}{$token->[2]->{'id'}} = $ressrc;
2223: $titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'};
1.488 raeburn 2224: } else {
1.492 raeburn 2225: if ($allmaps->{$ressrc}) {
1.529 raeburn 2226: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.492 raeburn 2227: } elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') {
2228: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
2229: } else {
2230: $addedmaps->{$ressrc} = [$url];
2231: }
1.488 raeburn 2232: }
1.492 raeburn 2233: &contained_map_check($ressrc,$folder,$removefrommap,$removeparam,
2234: $addedmaps,$hierarchy,$titles,$allmaps);
1.488 raeburn 2235: }
1.492 raeburn 2236: } elsif ($token->[1] eq 'param') {
1.488 raeburn 2237: if ($folder =~ /^supplemental/) {
1.492 raeburn 2238: if (ref($removeparam->{$url}{$token->[2]->{'to'}}) eq 'ARRAY') {
2239: push(@{$removeparam->{$url}{$token->[2]->{'to'}}},$token->[2]->{'name'});
2240: } else {
2241: $removeparam->{$url}{$token->[2]->{'to'}} = [$token->[2]->{'name'}];
2242: }
1.488 raeburn 2243: }
2244: }
2245: }
2246: }
2247: return;
2248: }
2249:
2250: sub url_paste_fixups {
1.533 raeburn 2251: my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$fromcdom,$fromcnum,$allmaps,
2252: $rewrites,$retitles,$copies,$dbcopies,$zombies,$params,$mapmoves,
1.597 raeburn 2253: $mapchanges,$tomove,$newsubdir,$newurls,$resdatacopy) = @_;
1.491 raeburn 2254: my $checktitle;
2255: if (($prefixchg) &&
1.492 raeburn 2256: ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) {
1.491 raeburn 2257: $checktitle = 1;
2258: }
1.492 raeburn 2259: my $skip;
2260: if ($oldurl =~ m{^\Q/uploaded/$cdom/$cnum/\E(default|supplemental)(_?\d*)\.(?:page|sequence)$}) {
2261: my $mapid = $1.$2;
2262: if ($tomove->{$mapid}) {
2263: $skip = 1;
2264: }
2265: }
1.491 raeburn 2266: my $file = &Apache::lonnet::getfile($oldurl);
1.488 raeburn 2267: return if ($file eq '-1');
2268: my $parser = HTML::TokeParser->new(\$file);
2269: $parser->attr_encoded(1);
1.491 raeburn 2270: my $changed = 0;
1.488 raeburn 2271: while (my $token = $parser->get_token) {
2272: next if ($token->[0] ne 'S');
2273: if ($token->[1] eq 'resource') {
2274: my $ressrc = $token->[2]->{'src'};
2275: next if ($ressrc eq '');
1.491 raeburn 2276: my $id = $token->[2]->{'id'};
1.492 raeburn 2277: my $title = $token->[2]->{'title'};
1.491 raeburn 2278: if ($checktitle) {
2279: if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1.532 raeburn 2280: $retitles->{$oldurl}{$id} = $ressrc;
1.491 raeburn 2281: }
2282: }
1.488 raeburn 2283: next if ($token->[2]->{'type'} eq 'external');
2284: if ($token->[2]->{'type'} eq 'zombie') {
1.492 raeburn 2285: next if ($skip);
1.532 raeburn 2286: $zombies->{$oldurl}{$id} = $ressrc;
1.491 raeburn 2287: $changed = 1;
2288: } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1.492 raeburn 2289: my $srcdom = $1;
2290: my $srcnum = $2;
1.488 raeburn 2291: my $rem = $3;
1.492 raeburn 2292: my $newurl;
2293: my $mapname;
2294: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
2295: my $prefix = $1;
2296: $mapname = $prefix.$2;
2297: if ($tomove->{$mapname}) {
1.533 raeburn 2298: &url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,
2299: $srcdom,$srcnum,$allmaps,$rewrites,
2300: $retitles,$copies,$dbcopies,$zombies,
2301: $params,$mapmoves,$mapchanges,$tomove,
1.597 raeburn 2302: $newsubdir,$newurls,$resdatacopy);
1.492 raeburn 2303: next;
2304: } else {
2305: ($newurl,my $error) =
2306: &get_newmap_url($ressrc,$folder,$prefixchg,$cdom,$cnum,
2307: $srcdom,$srcnum,\$title,$allmaps,$newurls);
2308: if ($newurl =~ /(?:default|supplemental)_(\d+)\.(?:sequence|page)$/) {
2309: $newsubdir->{$ressrc} = $1;
2310: }
2311: if ($error) {
2312: next;
2313: }
2314: }
2315: }
2316: if (($srcdom ne $cdom) || ($srcnum ne $cnum) || ($prefixchg) ||
2317: ($mapchanges->{$oldurl}) || (($newurl ne '') && ($newurl ne $oldurl))) {
2318:
1.488 raeburn 2319: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
1.532 raeburn 2320: $rewrites->{$oldurl}{$id} = $ressrc;
1.491 raeburn 2321: $mapchanges->{$ressrc} = 1;
1.533 raeburn 2322: unless (&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,
2323: $cnum,$srcdom,$srcnum,$allmaps,
2324: $rewrites,$retitles,$copies,$dbcopies,
2325: $zombies,$params,$mapmoves,$mapchanges,
1.597 raeburn 2326: $tomove,$newsubdir,$newurls,$resdatacopy)) {
1.491 raeburn 2327: $mapmoves->{$ressrc} = 1;
2328: }
2329: $changed = 1;
1.488 raeburn 2330: } else {
1.532 raeburn 2331: $rewrites->{$oldurl}{$id} = $ressrc;
1.488 raeburn 2332: $copies->{$oldurl}{$ressrc} = $id;
1.491 raeburn 2333: $changed = 1;
1.488 raeburn 2334: }
2335: }
1.533 raeburn 2336: } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/.+$}) {
2337: next if ($skip);
1.492 raeburn 2338: my $srcdom = $1;
2339: my $srcnum = $2;
2340: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.532 raeburn 2341: $rewrites->{$oldurl}{$id} = $ressrc;
1.533 raeburn 2342: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2343: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2344: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
2345: $changed = 1;
2346: }
2347: } elsif ($ressrc =~ m{^/adm/$match_domain/$match_username/\d+/(smppg|bulletinboard)$}) {
2348: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum) ||
2349: ($env{'form.docs.markedcopy_options'} ne 'move')) {
2350: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2351: $dbcopies->{$oldurl}{$id}{'cdom'} = $fromcdom;
2352: $dbcopies->{$oldurl}{$id}{'cnum'} = $fromcnum;
1.491 raeburn 2353: $changed = 1;
1.488 raeburn 2354: }
1.597 raeburn 2355: } elsif ($ressrc eq '/res/lib/templates/simpleproblem.problem') {
2356: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum)) {
2357: $resdatacopy->{$oldurl}{$id}{'src'} = $ressrc;
2358: $resdatacopy->{$oldurl}{$id}{'cdom'} = $fromcdom;
2359: $resdatacopy->{$oldurl}{$id}{'cnum'} = $fromcnum;
2360: }
1.488 raeburn 2361: } elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) {
1.492 raeburn 2362: next if ($skip);
2363: my $srcdom = $1;
2364: my $srcnum = $2;
2365: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.533 raeburn 2366: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
2367: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
2368: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
1.491 raeburn 2369: $changed = 1;
1.488 raeburn 2370: }
2371: }
2372: } elsif ($token->[1] eq 'param') {
1.492 raeburn 2373: next if ($skip);
1.488 raeburn 2374: my $to = $token->[2]->{'to'};
2375: if ($to ne '') {
2376: if (ref($params->{$oldurl}{$to}) eq 'ARRAY') {
1.492 raeburn 2377: push(@{$params->{$oldurl}{$to}},$token->[2]->{'name'});
1.488 raeburn 2378: } else {
2379: @{$params->{$oldurl}{$to}} = ($token->[2]->{'name'});
2380: }
2381: }
2382: }
2383: }
1.491 raeburn 2384: return $changed;
1.488 raeburn 2385: }
2386:
2387: sub apply_fixups {
1.529 raeburn 2388: my ($folder,$is_map,$cdom,$cnum,$errors,$updated,$info,$moves,$prefixchg,
2389: $oldurl,$url,$caller) = @_;
2390: my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles,
1.533 raeburn 2391: %params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs,
1.597 raeburn 2392: %resdatacopy,%lockerrors,$lockmsg);
1.529 raeburn 2393: if (ref($updated) eq 'HASH') {
2394: if (ref($updated->{'rewrites'}) eq 'HASH') {
2395: %rewrites = %{$updated->{'rewrites'}};
2396: }
2397: if (ref($updated->{'zombies'}) eq 'HASH') {
2398: %zombies = %{$updated->{'zombies'}};
2399: }
2400: if (ref($updated->{'removefrommap'}) eq 'HASH') {
2401: %removefrommap = %{$updated->{'removefrommap'}};
2402: }
2403: if (ref($updated->{'removeparam'}) eq 'HASH') {
2404: %removeparam = %{$updated->{'removeparam'}};
2405: }
2406: if (ref($updated->{'dbcopies'}) eq 'HASH') {
2407: %dbcopies = %{$updated->{'dbcopies'}};
2408: }
2409: if (ref($updated->{'retitles'}) eq 'HASH') {
2410: %retitles = %{$updated->{'retitles'}};
2411: }
1.597 raeburn 2412: if (ref($updated->{'resdatacopy'}) eq 'HASH') {
2413: %resdatacopy = %{$updated->{'resdatacopy'}};
2414: }
1.529 raeburn 2415: }
2416: if (ref($info) eq 'HASH') {
2417: if (ref($info->{'newsubdir'}) eq 'HASH') {
2418: %newsubdir = %{$info->{'newsubdir'}};
2419: }
2420: if (ref($info->{'params'}) eq 'HASH') {
2421: %params = %{$info->{'params'}};
2422: }
2423: if (ref($info->{'before'}) eq 'HASH') {
2424: %before = %{$info->{'before'}};
2425: }
2426: if (ref($info->{'after'}) eq 'HASH') {
2427: %after = %{$info->{'after'}};
2428: }
2429: }
2430: if (ref($moves) eq 'HASH') {
2431: if (ref($moves->{'copies'}) eq 'HASH') {
2432: %copies = %{$moves->{'copies'}};
2433: }
2434: if (ref($moves->{'docmoves'}) eq 'HASH') {
2435: %docmoves = %{$moves->{'docmoves'}};
2436: }
2437: if (ref($moves->{'mapmoves'}) eq 'HASH') {
2438: %mapmoves = %{$moves->{'mapmoves'}};
2439: }
2440: }
2441: foreach my $key (keys(%copies),keys(%docmoves)) {
1.491 raeburn 2442: my @allcopies;
1.529 raeburn 2443: if (exists($copies{$key})) {
2444: if (ref($copies{$key}) eq 'HASH') {
2445: my %added;
2446: foreach my $innerkey (keys(%{$copies{$key}})) {
2447: if (($innerkey ne '') && (!$added{$innerkey})) {
2448: push(@allcopies,$innerkey);
2449: $added{$innerkey} = 1;
2450: }
1.491 raeburn 2451: }
1.529 raeburn 2452: undef(%added);
1.491 raeburn 2453: }
2454: }
2455: if ($key eq $oldurl) {
1.529 raeburn 2456: if ((exists($docmoves{$key}))) {
1.532 raeburn 2457: unless (grep(/^\Q$oldurl\E$/,@allcopies)) {
1.491 raeburn 2458: push(@allcopies,$oldurl);
2459: }
2460: }
2461: }
2462: if (@allcopies > 0) {
2463: foreach my $item (@allcopies) {
1.492 raeburn 2464: my ($relpath,$oldsubdir,$fname) =
2465: ($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(default|\d+)/.*/)([^/]+)$});
1.491 raeburn 2466: if ($fname ne '') {
2467: my $content = &Apache::lonnet::getfile($item);
2468: unless ($content eq '-1') {
2469: my $storefn;
1.529 raeburn 2470: if (($key eq $oldurl) && (exists($docmoves{$key}))) {
2471: $storefn = $docmoves{$key};
1.491 raeburn 2472: } else {
2473: $storefn = $relpath;
2474: $storefn =~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 2475: if ($prefixchg && $before{'doc'} && $after{'doc'}) {
2476: $storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/;
1.491 raeburn 2477: }
1.529 raeburn 2478: if ($newsubdir{$key}) {
1.532 raeburn 2479: $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}/#;
1.491 raeburn 2480: }
2481: }
2482: ©_dependencies($item,$storefn,$relpath,$errors,\$content);
2483: my $copyurl =
2484: &Apache::lonclonecourse::writefile($env{'request.course.id'},
2485: $storefn.$fname,$content);
2486: if ($copyurl eq '/adm/notfound.html') {
1.529 raeburn 2487: if (exists($docmoves{$oldurl})) {
1.491 raeburn 2488: return &mt('Paste failed: an error occurred copying the file.');
2489: } elsif (ref($errors) eq 'HASH') {
2490: $errors->{$item} = 1;
1.489 raeburn 2491: }
2492: }
1.488 raeburn 2493: }
2494: }
1.491 raeburn 2495: }
2496: }
2497: }
1.529 raeburn 2498: foreach my $key (keys(%mapmoves)) {
1.491 raeburn 2499: my $storefn=$key;
2500: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 2501: if ($prefixchg && $before{'map'} && $after{'map'}) {
2502: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.491 raeburn 2503: }
1.529 raeburn 2504: if ($newsubdir{$key}) {
2505: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.492 raeburn 2506: }
1.491 raeburn 2507: my $mapcontent = &Apache::lonnet::getfile($key);
2508: if ($mapcontent eq '-1') {
2509: if (ref($errors) eq 'HASH') {
2510: $errors->{$key} = 1;
2511: }
2512: } else {
2513: my $newmap =
2514: &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
2515: $mapcontent);
2516: if ($newmap eq '/adm/notfound.html') {
2517: if (ref($errors) eq 'HASH') {
2518: $errors->{$key} = 1;
1.489 raeburn 2519: }
1.488 raeburn 2520: }
2521: }
2522: }
1.491 raeburn 2523: my %updates;
2524: if ($is_map) {
1.529 raeburn 2525: if (ref($updated) eq 'HASH') {
2526: foreach my $type (keys(%{$updated})) {
2527: if (ref($updated->{$type}) eq 'HASH') {
2528: foreach my $key (keys(%{$updated->{$type}})) {
2529: $updates{$key} = 1;
2530: }
2531: }
2532: }
1.491 raeburn 2533: }
2534: foreach my $key (keys(%updates)) {
1.492 raeburn 2535: my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb);
1.529 raeburn 2536: if (ref($rewrites{$key}) eq 'HASH') {
2537: %torewrite = %{$rewrites{$key}};
1.491 raeburn 2538: }
1.529 raeburn 2539: if (ref($retitles{$key}) eq 'HASH') {
2540: %toretitle = %{$retitles{$key}};
1.491 raeburn 2541: }
1.529 raeburn 2542: if (ref($removefrommap{$key}) eq 'HASH') {
2543: %toremove = %{$removefrommap{$key}};
1.491 raeburn 2544: }
1.529 raeburn 2545: if (ref($removeparam{$key}) eq 'HASH') {
2546: %remparam = %{$removeparam{$key}};
1.492 raeburn 2547: }
1.529 raeburn 2548: if (ref($zombies{$key}) eq 'HASH') {
2549: %zombie = %{$zombies{$key}};
1.491 raeburn 2550: }
1.529 raeburn 2551: if (ref($dbcopies{$key}) eq 'HASH') {
1.533 raeburn 2552: foreach my $idx (keys(%{$dbcopies{$key}})) {
2553: if (ref($dbcopies{$key}{$idx}) eq 'HASH') {
2554: my ($newurl,$result,$errtext) =
2555: &dbcopy($dbcopies{$key}{$idx},$cdom,$cnum,\%lockerrors);
2556: if ($result eq 'ok') {
2557: $newdb{$idx} = $newurl;
2558: } elsif (ref($errors) eq 'HASH') {
2559: $errors->{$key} = 1;
2560: }
2561: push(@msgs,$errtext);
2562: }
1.491 raeburn 2563: }
2564: }
1.597 raeburn 2565: if (ref($resdatacopy{$key}) eq 'HASH') {
2566: if ($newsubdir{$key}) {
2567:
2568: }
2569: foreach my $idx (keys(%{$resdatacopy{$key}})) {
2570: if (ref($resdatacopy{$key}{$idx}) eq 'HASH') {
2571: my $srcurl = $resdatacopy{$key}{$idx}{'src'};
2572: if ($srcurl =~ m{^/res/lib/templates/(\w+)\.problem$}) {
2573: my $template = $1;
2574: if (($resdatacopy{$key}{$idx}{'cdom'} =~ /^$match_domain$/) &&
2575: ($resdatacopy{$key}{$idx}{'cnum'} =~ /^$match_courseid$/)) {
2576: my $srcdom = $resdatacopy{$key}{$idx}{'cdom'};
2577: my $srcnum = $resdatacopy{$key}{$idx}{'cnum'};
2578: my ($newmapname) = ($key =~ m{/([^/]+)$});
2579: my ($srcfolder,$srccontainer) = split(/\./,$newmapname);
2580: my $srcmapinfo = $srcfolder.':'.$idx;
2581: if ($srccontainer eq 'page') {
2582: $srcmapinfo .= ':1';
2583: }
2584: if ($newsubdir{$key}) {
2585: $newmapname =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
2586: }
2587: ©_templated_files($srcurl,$srcdom,$srcnum,$srcmapinfo,$cdom,
2588: $cnum,$template,$idx,$newmapname);
2589: }
2590: }
2591: }
2592: }
2593: }
1.529 raeburn 2594: if (ref($params{$key}) eq 'HASH') {
2595: %currparam = %{$params{$key}};
1.492 raeburn 2596: }
2597: my ($errtext,$fatal) = &LONCAPA::map::mapread($key);
2598: if ($fatal) {
1.533 raeburn 2599: return ($errtext);
1.492 raeburn 2600: }
2601: for (my $i=0; $i<@LONCAPA::map::zombies; $i++) {
2602: if (defined($LONCAPA::map::zombies[$i])) {
2603: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::zombies[$i]);
1.532 raeburn 2604: if ($zombie{$i} eq $src) {
1.492 raeburn 2605: undef($LONCAPA::map::zombies[$i]);
2606: }
2607: }
2608: }
1.529 raeburn 2609: for (my $i=0; $i<@LONCAPA::map::order; $i++) {
2610: my $idx = $LONCAPA::map::order[$i];
2611: if (defined($LONCAPA::map::resources[$idx])) {
1.492 raeburn 2612: my $changed;
1.529 raeburn 2613: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]);
1.538 raeburn 2614: if ((exists($toremove{$idx})) &&
2615: ($toremove{$idx} eq &LONCAPA::map::qtescape($src))) {
1.492 raeburn 2616: splice(@LONCAPA::map::order,$i,1);
1.529 raeburn 2617: if (ref($currparam{$idx}) eq 'ARRAY') {
2618: foreach my $name (@{$currparam{$idx}}) {
2619: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
1.492 raeburn 2620: }
2621: }
2622: next;
2623: }
2624: my $origsrc = $src;
1.532 raeburn 2625: if ((exists($toretitle{$idx})) && ($toretitle{$idx} eq $src)) {
1.492 raeburn 2626: if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
2627: $changed = 1;
1.491 raeburn 2628: }
1.492 raeburn 2629: }
1.532 raeburn 2630: if ((exists($torewrite{$idx})) && ($torewrite{$idx} eq $src)) {
1.492 raeburn 2631: $src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
2632: if ($origsrc =~ m{^/uploaded/}) {
1.529 raeburn 2633: if ($prefixchg && $before{'map'} && $after{'map'}) {
1.492 raeburn 2634: if ($src =~ /\.(page|sequence)$/) {
1.529 raeburn 2635: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'map'}\E#$1$after{'map'}#;
1.492 raeburn 2636: } else {
1.529 raeburn 2637: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
1.488 raeburn 2638: }
1.491 raeburn 2639: }
1.532 raeburn 2640: if ($origsrc =~ /\.(page|sequence)$/) {
2641: if ($newsubdir{$origsrc}) {
1.529 raeburn 2642: $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir{$origsrc}#;
1.491 raeburn 2643: }
1.532 raeburn 2644: } elsif ($newsubdir{$key}) {
2645: $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$key}#;
1.488 raeburn 2646: }
2647: }
1.492 raeburn 2648: $changed = 1;
1.533 raeburn 2649: } elsif ($newdb{$idx} ne '') {
2650: $src = $newdb{$idx};
1.492 raeburn 2651: $changed = 1;
2652: }
2653: if ($changed) {
1.538 raeburn 2654: $LONCAPA::map::resources[$idx] = join(':',($title,&LONCAPA::map::qtunescape($src),$ext,$type));
1.492 raeburn 2655: }
2656: }
2657: }
2658: foreach my $idx (keys(%remparam)) {
2659: if (ref($remparam{$idx}) eq 'ARRAY') {
2660: foreach my $name (@{$remparam{$idx}}) {
2661: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
1.491 raeburn 2662: }
2663: }
2664: }
1.533 raeburn 2665: if (values(%lockerrors) > 0) {
2666: $lockmsg = join('<br />',values(%lockerrors));
2667: }
1.491 raeburn 2668: my $storefn;
2669: if ($key eq $oldurl) {
2670: $storefn = $url;
2671: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
2672: } else {
2673: $storefn = $key;
2674: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 2675: if ($prefixchg && $before{'map'} && $after{'map'}) {
2676: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.491 raeburn 2677: }
1.529 raeburn 2678: if ($newsubdir{$key}) {
2679: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.492 raeburn 2680: }
1.491 raeburn 2681: }
1.492 raeburn 2682: my $report;
2683: if ($folder !~ /^supplemental/) {
2684: $report = 1;
2685: }
1.527 raeburn 2686: (my $outtext,$errtext) =
1.492 raeburn 2687: &LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report);
2688: if ($errtext) {
1.529 raeburn 2689: if ($caller eq 'paste') {
1.533 raeburn 2690: return (&mt('Paste failed: an error occurred saving the folder or page.'));
1.529 raeburn 2691: }
1.491 raeburn 2692: }
2693: }
2694: }
1.533 raeburn 2695: return ('ok',\@msgs,$lockmsg);
1.491 raeburn 2696: }
2697:
2698: sub copy_dependencies {
2699: my ($item,$storefn,$relpath,$errors,$contentref) = @_;
2700: my $content;
2701: if (ref($contentref)) {
2702: $content = $$contentref;
2703: } else {
2704: $content = &Apache::lonnet::getfile($item);
2705: }
2706: unless ($content eq '-1') {
2707: my $mm = new File::MMagic;
2708: my $mimetype = $mm->checktype_contents($content);
2709: if ($mimetype eq 'text/html') {
2710: my (%allfiles,%codebase,$state);
2711: my $res = &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,\$content);
2712: if ($res eq 'ok') {
2713: my ($numexisting,$numpathchanges,$existing);
2714: (undef,$numexisting,$numpathchanges,$existing) =
2715: &Apache::loncommon::ask_for_embedded_content(
2716: '/adm/coursedocs',$state,\%allfiles,\%codebase,
2717: {'error_on_invalid_names' => 1,
2718: 'ignore_remote_references' => 1,
2719: 'docs_url' => $item,
2720: 'context' => 'paste'});
2721: if ($numexisting > 0) {
2722: if (ref($existing) eq 'HASH') {
2723: foreach my $dep (keys(%{$existing})) {
2724: my $depfile = $dep;
2725: unless ($depfile =~ m{^\Q$relpath\E}) {
2726: $depfile = $relpath.$dep;
2727: }
2728: my $depcontent = &Apache::lonnet::getfile($depfile);
2729: unless ($depcontent eq '-1') {
2730: my $storedep = $dep;
2731: $storedep =~ s{^\Q$relpath\E}{};
2732: my $dep_url =
2733: &Apache::lonclonecourse::writefile(
2734: $env{'request.course.id'},
2735: $storefn.$storedep,$depcontent);
2736: if ($dep_url eq '/adm/notfound.html') {
2737: if (ref($errors) eq 'HASH') {
2738: $errors->{$depfile} = 1;
2739: }
2740: } else {
2741: ©_dependencies($depfile,$storefn,$relpath,$errors,\$depcontent);
2742: }
2743: }
2744: }
1.488 raeburn 2745: }
2746: }
2747: }
2748: }
2749: }
2750: return;
2751: }
2752:
1.329 droeschl 2753: my %parameter_type = ( 'randompick' => 'int_pos',
2754: 'hiddenresource' => 'string_yesno',
2755: 'encrypturl' => 'string_yesno',
2756: 'randomorder' => 'string_yesno',);
2757: my $valid_parameters_re = join('|',keys(%parameter_type));
2758: # set parameters
2759: sub update_parameter {
1.537 raeburn 2760: if ($env{'form.changeparms'} eq 'all') {
2761: my (@allidx,@allmapidx,%allchecked,%currchecked);
2762: %allchecked = (
2763: 'hiddenresource' => {},
2764: 'encrypturl' => {},
2765: 'randompick' => {},
2766: 'randomorder' => {},
2767: );
2768: foreach my $which (keys(%allchecked)) {
2769: $env{'form.all'.$which} =~ s/,$//;
2770: if ($which eq 'randompick') {
2771: foreach my $item (split(/,/,$env{'form.all'.$which})) {
2772: my ($res,$value) = split(/:/,$item);
2773: if ($value =~ /^\d+$/) {
2774: $allchecked{$which}{$res} = $value;
2775: }
2776: }
2777: } else {
1.539 raeburn 2778: if ($env{'form.all'.$which}) {
2779: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.all'.$which});
2780: }
1.537 raeburn 2781: }
2782: }
2783: my $haschanges = 0;
2784: foreach my $res (@LONCAPA::map::order) {
2785: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2786: $name=&LONCAPA::map::qtescape($name);
2787: $url=&LONCAPA::map::qtescape($url);
2788: next unless ($name && $url);
2789: my $is_map;
2790: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
2791: $is_map = 1;
2792: }
2793: foreach my $which (keys(%allchecked)) {
2794: if (($which eq 'randompick' || $which eq 'randomorder')) {
2795: next if (!$is_map);
2796: }
2797: my $oldvalue = 0;
2798: my $newvalue = 0;
2799: if ($allchecked{$which}{$res}) {
2800: $newvalue = $allchecked{$which}{$res};
2801: }
2802: my $current = (&LONCAPA::map::getparameter($res,'parameter_'.$which))[0];
2803: if ($which eq 'randompick') {
2804: if ($current =~ /^(\d+)$/) {
2805: $oldvalue = $1;
2806: }
2807: } else {
2808: if ($current =~ /^yes$/i) {
2809: $oldvalue = 1;
2810: }
2811: }
2812: if ($oldvalue ne $newvalue) {
2813: $haschanges = 1;
2814: if ($newvalue) {
2815: my $storeval = 'yes';
2816: if ($which eq 'randompick') {
2817: $storeval = $newvalue;
2818: }
2819: &LONCAPA::map::storeparameter($res,'parameter_'.$which,
2820: $storeval,
2821: $parameter_type{$which});
2822: &remember_parms($res,$which,'set',$storeval);
2823: } elsif ($oldvalue) {
2824: &LONCAPA::map::delparameter($res,'parameter_'.$which);
2825: &remember_parms($res,$which,'del');
2826: }
2827: }
2828: }
2829: }
2830: return $haschanges;
2831: } else {
1.588 raeburn 2832: my $haschanges = 0;
2833: return $haschanges if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
1.329 droeschl 2834:
1.537 raeburn 2835: my $which = $env{'form.changeparms'};
2836: my $idx = $env{'form.setparms'};
1.588 raeburn 2837: my $oldvalue = 0;
2838: my $newvalue = 0;
2839: my $current = (&LONCAPA::map::getparameter($idx,'parameter_'.$which))[0];
2840: if ($which eq 'randompick') {
2841: if ($current =~ /^(\d+)$/) {
2842: $oldvalue = $1;
2843: }
2844: } elsif ($current =~ /^yes$/i) {
2845: $oldvalue = 1;
2846: }
1.537 raeburn 2847: if ($env{'form.'.$which.'_'.$idx}) {
1.588 raeburn 2848: $newvalue = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx}
2849: : 1;
2850: }
2851: if ($oldvalue ne $newvalue) {
2852: $haschanges = 1;
2853: if ($newvalue) {
2854: my $storeval = 'yes';
2855: if ($which eq 'randompick') {
2856: $storeval = $newvalue;
2857: }
2858: &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $storeval,
2859: $parameter_type{$which});
2860: &remember_parms($idx,$which,'set',$storeval);
2861: } else {
2862: &LONCAPA::map::delparameter($idx,'parameter_'.$which);
2863: &remember_parms($idx,$which,'del');
2864: }
1.537 raeburn 2865: }
1.588 raeburn 2866: return $haschanges;
1.329 droeschl 2867: }
2868: }
2869:
2870: sub handle_edit_cmd {
2871: my ($coursenum,$coursedom) =@_;
1.543 raeburn 2872: if ($env{'form.cmd'} eq '') {
2873: return 0;
2874: }
1.329 droeschl 2875: my ($cmd,$idx)=split('_',$env{'form.cmd'});
2876:
2877: my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
2878: my ($title, $url, @rrest) = split(':', $ratstr);
2879:
1.538 raeburn 2880: if ($cmd eq 'remove') {
1.329 droeschl 2881: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
1.463 www 2882: ($url!~/$LONCAPA::assess_page_seq_re/)) {
1.329 droeschl 2883: &Apache::lonnet::removeuploadedurl($url);
2884: } else {
2885: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
2886: }
2887: splice(@LONCAPA::map::order, $idx, 1);
2888:
2889: } elsif ($cmd eq 'cut') {
2890: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
2891: splice(@LONCAPA::map::order, $idx, 1);
2892:
1.344 bisitz 2893: } elsif ($cmd eq 'up'
1.329 droeschl 2894: && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
2895: @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
2896:
2897: } elsif ($cmd eq 'down'
2898: && defined($LONCAPA::map::order[$idx+1])) {
2899: @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
2900:
2901: } elsif ($cmd eq 'rename') {
2902: my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
2903: if ($comment=~/\S/) {
2904: $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
2905: $comment.':'.join(':', $url, @rrest);
2906: }
2907: # Devalidate title cache
2908: my $renamed_url=&LONCAPA::map::qtescape($url);
2909: &Apache::lonnet::devalidate_title_cache($renamed_url);
1.538 raeburn 2910:
1.329 droeschl 2911: } else {
2912: return 0;
2913: }
2914: return 1;
2915: }
2916:
2917: sub editor {
1.458 raeburn 2918: my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
1.598 raeburn 2919: $supplementalflag,$orderhash,$iconpath,$pathitem,$ltitoolsref)=@_;
1.519 raeburn 2920: my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
1.510 raeburn 2921: if ($allowed) {
1.519 raeburn 2922: (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
2923: $is_random_order,$container) =
1.510 raeburn 2924: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
2925: $r->print($breadcrumbtrail);
1.519 raeburn 2926: } elsif ($env{'form.folderpath'} =~ /\:1$/) {
2927: $container = 'page';
2928: } else {
2929: $container = 'sequence';
1.510 raeburn 2930: }
1.484 raeburn 2931:
1.525 raeburn 2932: my $jumpto;
2933:
2934: unless ($supplementalflag) {
1.546 raeburn 2935: $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
1.525 raeburn 2936: }
1.484 raeburn 2937:
2938: unless ($allowed) {
2939: $randompick = -1;
2940: }
2941:
1.329 droeschl 2942: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
2943: $folder.'.'.$container);
2944: return $errtext if ($fatal);
2945:
2946: if ($#LONCAPA::map::order<1) {
2947: my $idx=&LONCAPA::map::getresidx();
2948: if ($idx<=0) { $idx=1; }
2949: $LONCAPA::map::order[0]=$idx;
2950: $LONCAPA::map::resources[$idx]='';
2951: }
1.364 bisitz 2952:
1.329 droeschl 2953: # ------------------------------------------------------------ Process commands
2954:
2955: # ---------------- if they are for this folder and user allowed to make changes
2956: if (($allowed) && ($env{'form.folder'} eq $folder)) {
2957: # set parameters and change order
2958: &snapshotbefore();
2959:
2960: if (&update_parameter()) {
1.588 raeburn 2961: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1.329 droeschl 2962: return $errtext if ($fatal);
2963: }
2964:
2965: if ($env{'form.newpos'} && $env{'form.currentpos'}) {
2966: # change order
2967: my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
2968: splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
2969:
2970: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
2971: return $errtext if ($fatal);
2972: }
1.364 bisitz 2973:
1.329 droeschl 2974: if ($env{'form.pastemarked'}) {
1.491 raeburn 2975: my %paste_errors;
1.533 raeburn 2976: my ($paste_res,$save_error,$pastemsgarray,$lockerror) =
1.492 raeburn 2977: &do_paste_from_buffer($coursenum,$coursedom,$folder,$container,
2978: \%paste_errors);
1.541 raeburn 2979: if (ref($pastemsgarray) eq 'ARRAY') {
2980: if (@{$pastemsgarray} > 0) {
2981: $r->print('<p class="LC_info">'.
2982: join('<br />',@{$pastemsgarray}).
1.533 raeburn 2983: '</p>');
2984: }
1.541 raeburn 2985: }
2986: if ($lockerror) {
2987: $r->print('<p class="LC_error">'.
2988: $lockerror.
2989: '</p>');
2990: }
2991: if ($save_error ne '') {
2992: return $save_error;
2993: }
2994: if ($paste_res) {
2995: my %errortext = &Apache::lonlocal::texthash (
2996: fail => 'Storage of folder contents failed',
2997: failread => 'Reading folder contents failed',
2998: failstore => 'Storage of folder contents failed',
2999: );
3000: if ($errortext{$paste_res}) {
3001: $r->print('<p class="LC_error">'.$errortext{$paste_res}.'</p>');
1.492 raeburn 3002: }
1.329 droeschl 3003: }
1.491 raeburn 3004: if (keys(%paste_errors) > 0) {
1.538 raeburn 3005: $r->print('<p class="LC_warning">'."\n".
1.491 raeburn 3006: &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".
3007: '<ul>'."\n");
3008: foreach my $key (sort(keys(%paste_errors))) {
3009: $r->print('<li>'.$key.'</li>'."\n");
3010: }
3011: $r->print('</ul></p>'."\n");
3012: }
1.538 raeburn 3013: } elsif ($env{'form.clearmarked'}) {
3014: my $output = &do_buffer_empty();
3015: if ($output) {
3016: $r->print('<p class="LC_info">'.$output.'</p>');
3017: }
3018: }
1.329 droeschl 3019:
3020: $r->print($upload_output);
3021:
1.538 raeburn 3022: # Rename, cut, copy or remove a single resource
1.329 droeschl 3023: if (&handle_edit_cmd()) {
1.492 raeburn 3024: my $contentchg;
1.592 raeburn 3025: if ($env{'form.cmd'} =~ m{^(remove|cut)_}) {
1.492 raeburn 3026: $contentchg = 1;
3027: }
3028: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);
1.329 droeschl 3029: return $errtext if ($fatal);
3030: }
1.538 raeburn 3031:
3032: # Cut, copy and/or remove multiple resources
3033: if ($env{'form.multichange'}) {
3034: my %allchecked = (
3035: cut => {},
3036: remove => {},
3037: );
3038: my $needsupdate;
3039: foreach my $which (keys(%allchecked)) {
3040: $env{'form.multi'.$which} =~ s/,$//;
3041: if ($env{'form.multi'.$which}) {
3042: map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.multi'.$which});
3043: if (ref($allchecked{$which}) eq 'HASH') {
3044: $needsupdate += scalar(keys(%{$allchecked{$which}}));
3045: }
3046: }
3047: }
3048: if ($needsupdate) {
3049: my $haschanges = 0;
3050: my %curr_groups = &Apache::longroup::coursegroups();
3051: my $total = scalar(@LONCAPA::map::order) - 1;
3052: for (my $i=$total; $i>=0; $i--) {
3053: my $res = $LONCAPA::map::order[$i];
3054: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3055: $name=&LONCAPA::map::qtescape($name);
3056: $url=&LONCAPA::map::qtescape($url);
1.586 droeschl 3057: next unless $url;
1.538 raeburn 3058: my %denied =
3059: &action_restrictions($coursenum,$coursedom,$url,
3060: $env{'form.folderpath'},\%curr_groups);
3061: foreach my $which (keys(%allchecked)) {
3062: next if ($denied{$which});
3063: next unless ($allchecked{$which}{$res});
3064: if ($which eq 'remove') {
3065: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
3066: ($url!~/$LONCAPA::assess_page_seq_re/)) {
3067: &Apache::lonnet::removeuploadedurl($url);
3068: } else {
3069: &LONCAPA::map::makezombie($res);
3070: }
3071: splice(@LONCAPA::map::order,$i,1);
3072: $haschanges ++;
3073: } elsif ($which eq 'cut') {
3074: &LONCAPA::map::makezombie($res);
3075: splice(@LONCAPA::map::order,$i,1);
3076: $haschanges ++;
3077: }
3078: }
3079: }
3080: if ($haschanges) {
3081: ($errtext,$fatal) =
3082: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
3083: return $errtext if ($fatal);
3084: }
3085: }
3086: }
3087:
1.329 droeschl 3088: # Group import/search
3089: if ($env{'form.importdetail'}) {
3090: my @imports;
3091: foreach my $item (split(/\&/,$env{'form.importdetail'})) {
3092: if (defined($item)) {
3093: my ($name,$url,$residx)=
1.533 raeburn 3094: map { &unescape($_); } split(/\=/,$item);
3095: if ($url =~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
3096: my ($suffix,$errortxt,$locknotfreed) =
3097: &new_timebased_suffix($coursedom,$coursenum,'map',$1,$2);
1.504 raeburn 3098: if ($locknotfreed) {
3099: $r->print($locknotfreed);
3100: }
3101: if ($suffix) {
3102: $url =~ s/_new\./_$suffix./;
3103: } else {
3104: return $errortxt;
3105: }
1.533 raeburn 3106: } elsif ($url =~ m{^/adm/$match_domain/$match_username/new/(smppg|bulletinboard)$}) {
3107: my $type = $1;
3108: my ($suffix,$errortxt,$locknotfreed) =
3109: &new_timebased_suffix($coursedom,$coursenum,$type);
3110: if ($locknotfreed) {
3111: $r->print($locknotfreed);
3112: }
3113: if ($suffix) {
3114: $url =~ s{^(/adm/$match_domain/$match_username)/new}{$1/$suffix};
3115: } else {
3116: return $errortxt;
3117: }
1.598 raeburn 3118: } elsif ($url =~ m{^/adm/$coursedom/$coursenum/new/exttool}) {
3119: my ($suffix,$errortxt,$locknotfreed) =
3120: &new_timebased_suffix($coursedom,$coursenum,'exttool');
3121: if ($locknotfreed) {
3122: $r->print($locknotfreed);
3123: }
3124: if ($suffix) {
3125: $url =~ s{^(/adm/$coursedom/$coursenum)/new}{$1/$suffix};
3126: } else {
3127: return $errortxt;
3128: }
1.534 raeburn 3129: } elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) {
3130: if ($supplementalflag) {
3131: next unless ($1 eq 'supplemental');
3132: if ($folder eq 'supplemental') {
3133: next unless ($2 eq 'default');
3134: } else {
3135: next unless ($folder eq 'supplemental_'.$2);
3136: }
3137: } else {
3138: next unless ($1 eq 'docs');
3139: if ($folder eq 'default') {
3140: next unless ($2 eq 'default');
3141: } else {
3142: next unless ($folder eq 'default_'.$2);
3143: }
3144: }
1.504 raeburn 3145: }
1.329 droeschl 3146: push(@imports, [$name, $url, $residx]);
3147: }
3148: }
1.530 raeburn 3149: ($errtext,$fatal,my $fixuperrors) =
1.529 raeburn 3150: &group_import($coursenum, $coursedom, $folder,$container,
1.598 raeburn 3151: 'londocs',$ltitoolsref,@imports);
1.329 droeschl 3152: return $errtext if ($fatal);
1.529 raeburn 3153: if ($fixuperrors) {
3154: $r->print($fixuperrors);
3155: }
1.329 droeschl 3156: }
3157: # Loading a complete map
3158: if ($env{'form.loadmap'}) {
3159: if ($env{'form.importmap'}=~/\w/) {
3160: foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
3161: my ($title,$url,$ext,$type)=split(/\:/,$res);
3162: my $idx=&LONCAPA::map::getresidx($url);
3163: $LONCAPA::map::resources[$idx]=$res;
3164: $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
3165: }
3166: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.492 raeburn 3167: $folder.'.'.$container,1);
1.329 droeschl 3168: return $errtext if ($fatal);
3169: } else {
3170: $r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
1.364 bisitz 3171:
1.329 droeschl 3172: }
3173: }
3174: &log_differences($plain);
3175: }
3176: # ---------------------------------------------------------------- End commands
3177: # ---------------------------------------------------------------- Print screen
3178: my $idx=0;
3179: my $shown=0;
3180: if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
1.381 bisitz 3181: $r->print('<div class="LC_Box">'.
1.432 raeburn 3182: '<ol class="LC_docs_parameters"><li class="LC_docs_parameters_title">'.&mt('Parameters:').'</li>'.
3183: ($randompick>=0?'<li>'.&mt('randomly pick [quant,_1,resource]',$randompick).'</li>':'').
3184: ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
3185: ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
3186: ($is_random_order?'<li>'.&mt('random order').'</li>':'').
1.431 raeburn 3187: '</ol>');
1.381 bisitz 3188: if ($randompick>=0) {
3189: $r->print('<p class="LC_warning">'
3190: .&mt('Caution: this folder is set to randomly pick a subset'
3191: .' of resources. Adding or removing resources from this'
3192: .' folder will change the set of resources that the'
3193: .' students see, resulting in spurious or missing credit'
3194: .' for completed problems, not limited to ones you'
3195: .' modify. Do not modify the contents of this folder if'
3196: .' it is in active student use.')
3197: .'</p>'
3198: );
3199: }
3200: if ($is_random_order) {
3201: $r->print('<p class="LC_warning">'
3202: .&mt('Caution: this folder is set to randomly order its'
3203: .' contents. Adding or removing resources from this folder'
3204: .' will change the order of resources shown.')
3205: .'</p>'
3206: );
3207: }
3208: $r->print('</div>');
1.364 bisitz 3209: }
1.381 bisitz 3210:
1.538 raeburn 3211: my ($to_show,$output,@allidx,@allmapidx,%filters,%lists,%curr_groups);
3212: %filters = (
1.543 raeburn 3213: canremove => [],
3214: cancut => [],
3215: cancopy => [],
3216: hiddenresource => [],
3217: encrypturl => [],
3218: randomorder => [],
3219: randompick => [],
1.538 raeburn 3220: );
3221: %curr_groups = &Apache::longroup::coursegroups();
1.424 onken 3222: &Apache::loncommon::start_data_table_count(); #setup a row counter
1.381 bisitz 3223: foreach my $res (@LONCAPA::map::order) {
3224: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
3225: $name=&LONCAPA::map::qtescape($name);
3226: $url=&LONCAPA::map::qtescape($url);
3227: unless ($name) { $name=(split(/\//,$url))[-1]; }
3228: unless ($name) { $idx++; next; }
1.537 raeburn 3229: push(@allidx,$res);
3230: if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
3231: push(@allmapidx,$res);
3232: }
1.381 bisitz 3233: $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
1.501 raeburn 3234: $coursenum,$coursedom,$crstype,
1.538 raeburn 3235: $pathitem,$supplementalflag,$container,
1.598 raeburn 3236: \%filters,\%curr_groups,$ltitoolsref);
1.381 bisitz 3237: $idx++;
3238: $shown++;
1.329 droeschl 3239: }
1.424 onken 3240: &Apache::loncommon::end_data_table_count();
1.510 raeburn 3241:
1.538 raeburn 3242: my $need_save;
1.510 raeburn 3243: if (($allowed) || ($supplementalflag && $folder eq 'supplemental')) {
1.544 raeburn 3244: my $toolslink;
3245: if ($allowed || &Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
3246: $toolslink = '<table><tr><td>'
1.520 raeburn 3247: .&Apache::loncommon::help_open_menu('Navigation Screen',
3248: 'Navigation_Screen',undef,'RAT')
3249: .'</td><td class="LC_middle">'.&mt('Tools:').'</td>'
3250: .'<td align="left"><ul id="LC_toolbar">'
1.525 raeburn 3251: .'<li><a href="/adm/coursedocs?forcesupplement=1&command=editsupp" '
1.520 raeburn 3252: .'id="LC_content_toolbar_edittoplevel" '
3253: .'class="LC_toolbarItem" '
3254: .'title="'.&mt('Supplemental Content Editor').'">'
3255: .'</a></li></ul></td></tr></table><br />';
1.544 raeburn 3256: }
1.510 raeburn 3257: if ($shown) {
3258: if ($allowed) {
3259: $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
3260: .&Apache::loncommon::start_data_table(undef,'contentlist')
3261: .&Apache::loncommon::start_data_table_header_row()
3262: .'<th colspan="2">'.&mt('Move').'</th>'
1.538 raeburn 3263: .'<th colspan="2">'.&mt('Actions').'</th>'
3264: .'<th>'.&mt('Document').'</th>';
1.510 raeburn 3265: if ($folder !~ /^supplemental/) {
3266: $to_show .= '<th colspan="4">'.&mt('Settings').'</th>';
3267: }
1.537 raeburn 3268: $to_show .= &Apache::loncommon::end_data_table_header_row();
3269: if ($folder !~ /^supplemental/) {
1.538 raeburn 3270: $lists{'canhide'} = join(',',@allidx);
3271: $lists{'canrandomlyorder'} = join(',',@allmapidx);
1.543 raeburn 3272: my @possfilters = ('canremove','cancut','cancopy','hiddenresource','encrypturl',
3273: 'randomorder','randompick');
3274: foreach my $item (@possfilters) {
1.538 raeburn 3275: if (ref($filters{$item}) eq 'ARRAY') {
1.543 raeburn 3276: if (@{$filters{$item}} > 0) {
3277: $lists{$item} = join(',',@{$filters{$item}});
3278: }
1.538 raeburn 3279: }
3280: }
1.537 raeburn 3281: if (@allidx > 0) {
3282: my $path;
3283: if ($env{'form.folderpath'}) {
3284: $path =
3285: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3286: }
1.538 raeburn 3287: if (@allidx > 1) {
3288: $to_show .=
3289: &Apache::loncommon::continue_data_table_row().
3290: '<td colspan="2"> </td>'.
3291: '<td>'.
3292: &multiple_check_form('actions',\%lists).
3293: '</td>'.
3294: '<td> </td>'.
3295: '<td> </td>'.
3296: '<td colspan="4">'.
3297: &multiple_check_form('settings',\%lists).
3298: '</td>'.
3299: &Apache::loncommon::end_data_table_row();
3300: $need_save = 1;
3301: }
1.537 raeburn 3302: }
3303: }
3304: $to_show .= $output.' '
1.510 raeburn 3305: .&Apache::loncommon::end_data_table()
3306: .'<br style="line-height:2px;" />'
3307: .&Apache::loncommon::end_scrollbox();
3308: } else {
1.520 raeburn 3309: $to_show .= $toolslink
1.510 raeburn 3310: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3311: .$output.' '
3312: .&Apache::loncommon::end_data_table();
1.393 raeburn 3313: }
1.510 raeburn 3314: } else {
1.520 raeburn 3315: if (!$allowed) {
3316: $to_show .= $toolslink;
3317: }
1.510 raeburn 3318: $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
3319: .'<div class="LC_info" id="contentlist">'
1.550 raeburn 3320: .&mt('Currently empty')
1.510 raeburn 3321: .'</div>'
3322: .&Apache::loncommon::end_scrollbox();
1.393 raeburn 3323: }
3324: } else {
1.510 raeburn 3325: if ($shown) {
3326: $to_show = '<div>'
3327: .&Apache::loncommon::start_data_table('LC_tableOfContent')
3328: .$output
3329: .&Apache::loncommon::end_data_table()
3330: .'</div>';
3331: } else {
3332: $to_show = '<div class="LC_info" id="contentlist">'
1.550 raeburn 3333: .&mt('Currently empty')
1.510 raeburn 3334: .'</div>'
3335: }
1.458 raeburn 3336: }
3337: my $tid = 1;
3338: if ($supplementalflag) {
3339: $tid = 2;
1.329 droeschl 3340: }
3341: if ($allowed) {
1.484 raeburn 3342: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
1.538 raeburn 3343: $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,
3344: $jumpto,$readfile,$need_save,"$folder.$container"));
1.492 raeburn 3345: &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
1.460 raeburn 3346: } else {
3347: $r->print($to_show);
1.329 droeschl 3348: }
3349: return;
3350: }
3351:
1.538 raeburn 3352: sub multiple_check_form {
3353: my ($caller,$listsref) = @_;
3354: return unless (ref($listsref) eq 'HASH');
3355: my $output =
3356: '<form action="/adm/coursedocs" method="post" name="togglemult'.$caller.'">'.
3357: '<span class="LC_nobreak" style="font-size:x-small;font-weight:bold;">'.
3358: '<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>'.
3359: '<div id="multi'.$caller.'" style="display:none;margin:0;padding:0;border:0">'.
3360: '<form action="/adm/coursedocs" method="post" name="cumulative'.$caller.'">'."\n".
3361: '<fieldset id="allfields'.$caller.'" style="display:none"><legend style="font-size:x-small;">'.&mt('check/uncheck all').'</legend>'."\n";
3362: if ($caller eq 'settings') {
3363: $output .=
3364: '<table><tr>'.
3365: '<td class="LC_docs_entry_parameter">'.
3366: '<span class="LC_nobreak"><label>'.
3367: '<input type="checkbox" name="hiddenresourceall" id="hiddenresourceall" onclick="propagateState(this.form,'."'hiddenresource'".')" />'.&mt('Hidden').
3368: '</label></span></td>'.
3369: '<td class="LC_docs_entry_parameter">'.
3370: '<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'".');" />'.&mt('Randomly Pick').'</label><span id="rpicktextall"></span><input type="hidden" name="rpicknumall" id="rpicknumall" value="" />'.
3371: '</span></td>'.
3372: '</tr>'."\n".
3373: '<tr>'.
3374: '<td class="LC_docs_entry_parameter">'.
3375: '<span class="LC_nobreak"><label><input type="checkbox" name="encrypturlall" id="encrypturlall" onclick="propagateState(this.form,'."'encrypturl'".')" />'.&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'".')" />'.&mt('Random Order').
3376: '</label></span>'.
3377: '</td></tr></table>'."\n";
3378: } else {
3379: $output .=
3380: '<table><tr>'.
3381: '<td class="LC_docs_entry_parameter">'.
3382: '<span class="LC_nobreak LC_docs_remove">'.
3383: '<label><input type="checkbox" name="removeall" id="removeall" onclick="propagateState(this.form,'."'remove'".')" />'.&mt('Remove').
3384: '</label></span></td>'.
3385: '<td class="LC_docs_entry_parameter">'.
3386: '<span class="LC_nobreak LC_docs_cut">'.
3387: '<label><input type="checkbox" name="cut" id="cutall" onclick="propagateState(this.form,'."'cut'".');" />'.&mt('Cut').
3388: '</label></span></td>'."\n".
3389: '<td class="LC_docs_entry_parameter">'.
3390: '<span class="LC_nobreak LC_docs_copy">'.
3391: '<label><input type="checkbox" name="copyall" id="copyall" onclick="propagateState(this.form,'."'copy'".')" />'.&mt('Copy').
3392: '</label></span></td>'.
3393: '</tr></table>'."\n";
3394: }
3395: $output .=
3396: '</fieldset>'.
3397: '<input type="hidden" name="allidx" value="'.$listsref->{'canhide'}.'" />';
3398: if ($caller eq 'settings') {
3399: $output .=
1.543 raeburn 3400: '<input type="hidden" name="allmapidx" value="'.$listsref->{'canrandomlyorder'}.'" />'."\n".
3401: '<input type="hidden" name="currhiddenresource" value="'.$listsref->{'hiddenresource'}.'" />'."\n".
3402: '<input type="hidden" name="currencrypturl" value="'.$listsref->{'encrypturl'}.'" />'."\n".
3403: '<input type="hidden" name="currrandomorder" value="'.$listsref->{'randomorder'}.'" />'."\n".
3404: '<input type="hidden" name="currrandompick" value="'.$listsref->{'randompick'}.'" />'."\n";
1.538 raeburn 3405: } elsif ($caller eq 'actions') {
3406: $output .=
3407: '<input type="hidden" name="allremoveidx" id="allremoveidx" value="'.$listsref->{'canremove'}.'" />'.
3408: '<input type="hidden" name="allcutidx" id="allcutidx" value="'.$listsref->{'cancut'}.'" />'.
3409: '<input type="hidden" name="allcopyidx" id="allcopyidx" value="'.$listsref->{'cancopy'}.'" />';
3410: }
3411: $output .=
3412: '</form>'.
3413: '</div>';
3414: return $output;
3415: }
3416:
1.329 droeschl 3417: sub process_file_upload {
1.552 raeburn 3418: my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd,$crstype) = @_;
1.329 droeschl 3419: # upload a file, if present
1.552 raeburn 3420: my $filesize = length($env{'form.uploaddoc'});
3421: if (!$filesize) {
3422: $$upload_output = '<div class="LC_error">'.
3423: &mt('Unable to upload [_1]. (size = [_2] bytes)',
3424: '<span class="LC_filename">'.$env{'form.uploaddoc.filename'}.'</span>',
3425: $filesize).'<br />'.
3426: &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'<br />'.
3427: '</div>';
3428: return;
3429: }
3430: my $quotatype = 'unofficial';
3431: if ($crstype eq 'Community') {
3432: $quotatype = 'community';
1.580 raeburn 3433: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
1.552 raeburn 3434: $quotatype = 'official';
1.573 raeburn 3435: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
3436: $quotatype = 'textbook';
1.552 raeburn 3437: }
3438: if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) {
3439: $filesize = int($filesize/1000); #expressed in kb
3440: $$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course',
1.579 raeburn 3441: $env{'form.uploaddoc.filename'},$filesize,
3442: 'upload',$quotatype);
1.552 raeburn 3443: return if ($$upload_output);
3444: }
1.440 raeburn 3445: my ($parseaction,$showupload,$nextphase,$mimetype);
3446: if ($env{'form.parserflag'}) {
1.329 droeschl 3447: $parseaction = 'parse';
3448: }
3449: my $folder=$env{'form.folder'};
3450: if ($folder eq '') {
3451: $folder='default';
3452: }
3453: if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
3454: my $errtext='';
3455: my $fatal=0;
3456: my $container='sequence';
1.519 raeburn 3457: if ($env{'form.folderpath'} =~ /:1$/) {
1.329 droeschl 3458: $container='page';
3459: }
3460: ($errtext,$fatal)=
1.534 raeburn 3461: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1.329 droeschl 3462: if ($#LONCAPA::map::order<1) {
3463: $LONCAPA::map::order[0]=1;
3464: $LONCAPA::map::resources[1]='';
3465: }
3466: my $destination = 'docs/';
3467: if ($folder =~ /^supplemental/) {
3468: $destination = 'supplemental/';
3469: }
3470: if (($folder eq 'default') || ($folder eq 'supplemental')) {
3471: $destination .= 'default/';
3472: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
3473: $destination .= $2.'/';
3474: }
1.534 raeburn 3475: if ($fatal) {
3476: $$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>';
3477: return;
3478: }
1.440 raeburn 3479: # this is for a course, not a user, so set context to coursedoc.
1.329 droeschl 3480: my $newidx=&LONCAPA::map::getresidx();
3481: $destination .= $newidx;
1.439 raeburn 3482: my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination,
1.329 droeschl 3483: $parseaction,$allfiles,
1.440 raeburn 3484: $codebase,undef,undef,undef,undef,
3485: undef,undef,\$mimetype);
3486: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) {
3487: my $stored = $1;
3488: $showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'.
3489: $stored.'</span>').'</p>';
3490: } else {
3491: my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});
3492:
1.457 raeburn 3493: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>';
1.440 raeburn 3494: return;
3495: }
1.329 droeschl 3496: my $ext='false';
3497: if ($url=~m{^http://}) { $ext='true'; }
3498: $url = &LONCAPA::map::qtunescape($url);
3499: my $comment=$env{'form.comment'};
3500: $comment = &LONCAPA::map::qtunescape($comment);
3501: if ($folder=~/^supplemental/) {
3502: $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
3503: $env{'user.domain'}.'___&&&___'.$comment;
3504: }
3505:
3506: $LONCAPA::map::resources[$newidx]=
3507: $comment.':'.$url.':'.$ext.':normal:res';
3508: $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
3509: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.492 raeburn 3510: $folder.'.'.$container,1);
1.329 droeschl 3511: if ($fatal) {
1.457 raeburn 3512: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>';
1.440 raeburn 3513: return;
1.329 droeschl 3514: } else {
1.440 raeburn 3515: if ($parseaction eq 'parse' && $mimetype eq 'text/html') {
3516: $$upload_output = $showupload;
1.384 raeburn 3517: my $total_embedded = scalar(keys(%{$allfiles}));
1.329 droeschl 3518: if ($total_embedded > 0) {
1.440 raeburn 3519: my $uploadphase = 'upload_embedded';
3520: my $primaryurl = &HTML::Entities::encode($url,'<>&"');
3521: my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx);
3522: my ($embedded,$num) =
3523: &Apache::loncommon::ask_for_embedded_content(
3524: '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url});
3525: if ($embedded) {
3526: if ($num) {
3527: $$upload_output .=
3528: '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
3529: $nextphase = $uploadphase;
3530: } else {
3531: $$upload_output .= $embedded;
3532: }
3533: } else {
3534: $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
3535: }
1.329 droeschl 3536: } else {
1.440 raeburn 3537: $$upload_output .= &mt('No embedded items identified').'<br />';
1.329 droeschl 3538: }
1.457 raeburn 3539: $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
1.578 raeburn 3540: } elsif ((&Apache::loncommon::is_archive_file($mimetype)) &&
3541: ($env{'form.uploaddoc.filename'} =~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i)) {
1.476 raeburn 3542: $nextphase = 'decompress_uploaded';
3543: my $position = scalar(@LONCAPA::map::order)-1;
3544: my $noextract = &return_to_editor();
3545: my $archiveurl = &HTML::Entities::encode($url,'<>&"');
3546: my %archiveitems = (
3547: folderpath => $env{'form.folderpath'},
3548: cmd => $nextphase,
3549: newidx => $newidx,
3550: position => $position,
3551: phase => $nextphase,
1.477 raeburn 3552: comment => $comment,
1.480 raeburn 3553: );
3554: my ($destination,$dir_root) = &embedded_destination($coursenum,$coursedom);
3555: my @current = &get_dir_list($url,$coursenum,$coursedom,$newidx);
1.476 raeburn 3556: $$upload_output = $showupload.
3557: &Apache::loncommon::decompress_form($mimetype,
3558: $archiveurl,'/adm/coursedocs',$noextract,
1.480 raeburn 3559: \%archiveitems,\@current);
1.329 droeschl 3560: }
3561: }
3562: }
1.440 raeburn 3563: return $nextphase;
1.329 droeschl 3564: }
3565:
1.480 raeburn 3566: sub get_dir_list {
3567: my ($url,$coursenum,$coursedom,$newidx) = @_;
3568: my ($destination,$dir_root) = &embedded_destination();
3569: my ($dirlistref,$listerror) =
3570: &Apache::lonnet::dirlist("$dir_root/$destination/$newidx",$coursedom,$coursenum,1);
3571: my @dir_lines;
3572: my $dirptr=16384;
3573: if (ref($dirlistref) eq 'ARRAY') {
3574: foreach my $dir_line (sort
3575: {
3576: my ($afile)=split('&',$a,2);
3577: my ($bfile)=split('&',$b,2);
3578: return (lc($afile) cmp lc($bfile));
3579: } (@{$dirlistref})) {
3580: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
3581: $filename =~ s/\s+$//;
3582: next if ($filename =~ /^\.\.?$/);
3583: my $isdir = 0;
3584: if ($dirptr&$testdir) {
3585: $isdir = 1;
3586: }
3587: push(@dir_lines, [$filename,$dom,$isdir,$size,$mtime,$obs]);
3588: }
3589: }
3590: return @dir_lines;
3591: }
3592:
1.329 droeschl 3593: sub is_supplemental_title {
3594: my ($title) = @_;
3595: return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
3596: }
3597:
3598: # --------------------------------------------------------------- An entry line
3599:
3600: sub entryline {
1.501 raeburn 3601: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
1.598 raeburn 3602: $crstype,$pathitem,$supplementalflag,$container,$filtersref,$currgroups,
3603: $ltitoolsref)=@_;
1.581 raeburn 3604: my ($foldertitle,$renametitle,$oldtitle);
1.329 droeschl 3605: if (&is_supplemental_title($title)) {
1.488 raeburn 3606: ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
1.329 droeschl 3607: } else {
3608: $title=&HTML::Entities::encode($title,'"<>&\'');
3609: $renametitle=$title;
3610: $foldertitle=$title;
3611: }
3612:
3613: my $orderidx=$LONCAPA::map::order[$index];
1.364 bisitz 3614:
1.329 droeschl 3615: $renametitle=~s/\\/\\\\/g;
3616: $renametitle=~s/\"\;/\\\"/g;
1.585 raeburn 3617: $renametitle=~s/"/%22/g;
1.581 raeburn 3618: $renametitle=~s/ /%20/g;
3619: $oldtitle = $renametitle;
1.576 raeburn 3620: $renametitle=~s/\'/\\\'/g;
1.379 bisitz 3621: my $line=&Apache::loncommon::start_data_table_row();
1.538 raeburn 3622: my ($form_start,$form_end,$form_common,$form_param);
1.329 droeschl 3623: # Edit commands
1.535 raeburn 3624: my ($esc_path, $path, $symb);
1.329 droeschl 3625: if ($env{'form.folderpath'}) {
3626: $esc_path=&escape($env{'form.folderpath'});
3627: $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3628: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
3629: }
1.505 raeburn 3630: my $isexternal;
1.510 raeburn 3631: if ($residx) {
1.501 raeburn 3632: my $currurl = $url;
3633: $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.505 raeburn 3634: if ($currurl =~ m{^/adm/wrapper/ext/}) {
3635: $isexternal = 1;
3636: }
1.510 raeburn 3637: if (!$supplementalflag) {
3638: my $path = 'uploaded/'.
3639: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
3640: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
3641: $symb = &Apache::lonnet::encode_symb($path.$folder.".$container",
3642: $residx,
3643: &Apache::lonnet::declutter($currurl));
3644: }
1.501 raeburn 3645: }
1.538 raeburn 3646: my ($renamelink,%lt,$ishash);
3647: if (ref($filtersref) eq 'HASH') {
3648: $ishash = 1;
3649: }
3650:
1.329 droeschl 3651: if ($allowed) {
1.538 raeburn 3652: $form_start = '
3653: <form action="/adm/coursedocs" method="post">
3654: ';
3655: $form_common=(<<END);
3656: <input type="hidden" name="folderpath" value="$path" />
3657: <input type="hidden" name="symb" value="$symb" />
3658: END
3659: $form_param=(<<END);
3660: <input type="hidden" name="setparms" value="$orderidx" />
3661: <input type="hidden" name="changeparms" value="0" />
3662: END
3663: $form_end = '</form>';
3664:
1.329 droeschl 3665: my $incindex=$index+1;
3666: my $selectbox='';
1.471 raeburn 3667: if (($#LONCAPA::map::order>0) &&
1.329 droeschl 3668: ((split(/\:/,
1.344 bisitz 3669: $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
3670: ne '') &&
1.329 droeschl 3671: ((split(/\:/,
1.344 bisitz 3672: $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1.329 droeschl 3673: ne '')) {
3674: $selectbox=
3675: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.373 bisitz 3676: '<select name="newpos" onchange="this.form.submit()">';
1.329 droeschl 3677: for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
3678: if ($i==$incindex) {
1.358 bisitz 3679: $selectbox.='<option value="" selected="selected">('.$i.')</option>';
1.329 droeschl 3680: } else {
3681: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
3682: }
3683: }
3684: $selectbox.='</select>';
3685: }
1.501 raeburn 3686: %lt=&Apache::lonlocal::texthash(
1.329 droeschl 3687: 'up' => 'Move Up',
3688: 'dw' => 'Move Down',
3689: 'rm' => 'Remove',
3690: 'ct' => 'Cut',
3691: 'rn' => 'Rename',
1.501 raeburn 3692: 'cp' => 'Copy',
3693: 'ex' => 'External Resource',
1.598 raeburn 3694: 'et' => 'External Tool',
1.501 raeburn 3695: 'ed' => 'Edit',
3696: 'pr' => 'Preview',
3697: 'sv' => 'Save',
3698: 'ul' => 'URL',
3699: 'ti' => 'Title',
3700: );
1.538 raeburn 3701: my %denied = &action_restrictions($coursenum,$coursedom,$url,
3702: $env{'form.folderpath'},
3703: $currgroups);
1.517 raeburn 3704: my ($copylink,$cutlink,$removelink);
1.329 droeschl 3705: my $skip_confirm = 0;
3706: if ( $folder =~ /^supplemental/
3707: || ($url =~ m{( /smppg$
3708: |/syllabus$
3709: |/aboutme$
3710: |/navmaps$
3711: |/bulletinboard$
1.598 raeburn 3712: |/exttools?$
1.505 raeburn 3713: |\.html$)}x)
3714: || $isexternal) {
1.329 droeschl 3715: $skip_confirm = 1;
3716: }
3717:
1.538 raeburn 3718: if ($denied{'copy'}) {
1.543 raeburn 3719: $copylink=(<<ENDCOPY)
1.507 raeburn 3720: <span style="visibility: hidden;">$lt{'cp'}</span>
3721: ENDCOPY
3722: } else {
1.538 raeburn 3723: my $formname = 'edit_copy_'.$orderidx;
3724: my $js = "javascript:checkForSubmit(document.forms.renameform,'copy','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.329 droeschl 3725: $copylink=(<<ENDCOPY);
1.538 raeburn 3726: <form name="$formname" method="post" action="/adm/coursedocs">
3727: $form_common
1.540 raeburn 3728: <input type="checkbox" name="copy" id="copy_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','copy');" class="LC_hidden" /><a href="$js" class="LC_docs_copy">$lt{'cp'}</a>
1.538 raeburn 3729: $form_end
1.329 droeschl 3730: ENDCOPY
1.538 raeburn 3731: if (($ishash) && (ref($filtersref->{'cancopy'}) eq 'ARRAY')) {
3732: push(@{$filtersref->{'cancopy'}},$orderidx);
3733: }
1.329 droeschl 3734: }
1.538 raeburn 3735: if ($denied{'cut'}) {
1.507 raeburn 3736: $cutlink=(<<ENDCUT);
3737: <span style="visibility: hidden;">$lt{'ct'}</span>
3738: ENDCUT
3739: } else {
1.538 raeburn 3740: my $formname = 'edit_cut_'.$orderidx;
3741: my $js = "javascript:checkForSubmit(document.forms.renameform,'cut','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm,'$container','$folder');";
1.329 droeschl 3742: $cutlink=(<<ENDCUT);
1.538 raeburn 3743: <form name="$formname" method="post" action="/adm/coursedocs">
3744: $form_common
1.542 raeburn 3745: <input type="hidden" name="skip_$orderidx" id="skip_cut_$orderidx" value="$skip_confirm" />
1.540 raeburn 3746: <input type="checkbox" name="cut" id="cut_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','cut');" class="LC_hidden" /><a href="$js" class="LC_docs_cut">$lt{'ct'}</a>
1.538 raeburn 3747: $form_end
1.329 droeschl 3748: ENDCUT
1.538 raeburn 3749: if (($ishash) && (ref($filtersref->{'cancut'}) eq 'ARRAY')) {
3750: push(@{$filtersref->{'cancut'}},$orderidx);
3751: }
1.329 droeschl 3752: }
1.538 raeburn 3753: if ($denied{'remove'}) {
1.507 raeburn 3754: $removelink=(<<ENDREM);
3755: <span style="visibility: hidden;">$lt{'rm'}</a>
3756: ENDREM
3757: } else {
1.538 raeburn 3758: my $formname = 'edit_remove_'.$orderidx;
3759: my $js = "javascript:checkForSubmit(document.forms.renameform,'remove','actions','$orderidx','$esc_path','$index','$renametitle',$skip_confirm);";
1.497 raeburn 3760: $removelink=(<<ENDREM);
1.538 raeburn 3761: <form name="$formname" method="post" action="/adm/coursedocs">
3762: $form_common
1.542 raeburn 3763: <input type="hidden" name="skip_$orderidx" id="skip_remove_$orderidx" value="$skip_confirm" />
1.540 raeburn 3764: <input type="checkbox" name="remove" id="remove_$orderidx" value="$orderidx" onclick="javascript:singleCheck(this,'$orderidx','remove');" class="LC_hidden" /><a href="$js" class="LC_docs_remove">$lt{'rm'}</a>
1.538 raeburn 3765: $form_end
1.497 raeburn 3766: ENDREM
1.538 raeburn 3767: if (($ishash) && (ref($filtersref->{'canremove'}) eq 'ARRAY')) {
3768: push(@{$filtersref->{'canremove'}},$orderidx);
3769: }
1.497 raeburn 3770: }
1.551 raeburn 3771: $renamelink=(<<ENDREN);
1.581 raeburn 3772: <a href='javascript:changename("$esc_path","$index","$oldtitle");' class="LC_docs_rename">$lt{'rn'}</a>
1.507 raeburn 3773: ENDREN
1.329 droeschl 3774: $line.=(<<END);
3775: <td>
1.379 bisitz 3776: <div class="LC_docs_entry_move">
1.535 raeburn 3777: <a href='/adm/coursedocs?cmd=up_$index&folderpath=$esc_path&symb=$symb'>
1.501 raeburn 3778: <img src="${iconpath}move_up.gif" alt="$lt{'up'}" class="LC_icon" />
1.379 bisitz 3779: </a>
3780: </div>
3781: <div class="LC_docs_entry_move">
1.536 raeburn 3782: <a href='/adm/coursedocs?cmd=down_$index&folderpath=$esc_path&symb=$symb'>
1.501 raeburn 3783: <img src="${iconpath}move_down.gif" alt="$lt{'dw'}" class="LC_icon" />
1.379 bisitz 3784: </a>
3785: </div>
1.329 droeschl 3786: </td>
3787: <td>
3788: $form_start
1.538 raeburn 3789: $form_param
1.478 raeburn 3790: $form_common
1.329 droeschl 3791: $selectbox
3792: $form_end
3793: </td>
1.540 raeburn 3794: <td class="LC_docs_entry_commands LC_nobreak">
1.497 raeburn 3795: $removelink
1.329 droeschl 3796: $cutlink
3797: $copylink
3798: </td>
3799: END
3800: }
3801: # Figure out what kind of a resource this is
3802: my ($extension)=($url=~/\.(\w+)$/);
3803: my $uploaded=($url=~/^\/*uploaded\//);
3804: my $icon=&Apache::loncommon::icon($url);
1.519 raeburn 3805: my $isfolder;
3806: my $ispage;
3807: my $containerarg;
1.329 droeschl 3808: if ($uploaded) {
1.472 raeburn 3809: if (($extension eq 'sequence') || ($extension eq 'page')) {
3810: $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
1.519 raeburn 3811: $containerarg = $1;
1.472 raeburn 3812: if ($extension eq 'sequence') {
3813: $icon=$iconpath.'navmap.folder.closed.gif';
3814: $isfolder=1;
3815: } else {
3816: $icon=$iconpath.'page.gif';
3817: $ispage=1;
3818: }
3819: if ($allowed) {
3820: $url='/adm/coursedocs?';
3821: } else {
3822: $url='/adm/supplemental?';
3823: }
1.329 droeschl 3824: } else {
3825: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
3826: }
3827: }
1.364 bisitz 3828:
1.518 raeburn 3829: my ($editlink,$extresform);
1.329 droeschl 3830: my $orig_url = $url;
1.340 raeburn 3831: $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
1.510 raeburn 3832: $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.501 raeburn 3833: if (!$supplementalflag && $residx && $symb) {
3834: if ((!$isfolder) && (!$ispage)) {
3835: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
3836: $url=&Apache::lonnet::clutter($url);
3837: if ($url=~/^\/*uploaded\//) {
3838: $url=~/\.(\w+)$/;
3839: my $embstyle=&Apache::loncommon::fileembstyle($1);
3840: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
3841: $url='/adm/wrapper'.$url;
3842: } elsif ($embstyle eq 'ssi') {
3843: #do nothing with these
3844: } elsif ($url!~/\.(sequence|page)$/) {
3845: $url='/adm/coursedocs/showdoc'.$url;
3846: }
3847: } elsif ($url=~m|^/ext/|) {
3848: $url='/adm/wrapper'.$url;
1.598 raeburn 3849: } elsif ($url=~m{^/adm/$coursedom/$coursenum/\d+/exttools?$}) {
3850: $url='/adm/wrapper'.$url;
3851: }
1.501 raeburn 3852: if (&Apache::lonnet::symbverify($symb,$url)) {
3853: $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
3854: } else {
3855: $url='';
3856: }
1.329 droeschl 3857: }
3858: }
1.478 raeburn 3859: my ($rand_pick_text,$rand_order_text);
1.519 raeburn 3860: if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') {
1.329 droeschl 3861: my $foldername=&escape($foldertitle);
3862: my $folderpath=$env{'form.folderpath'};
3863: if ($folderpath) { $folderpath.='&' };
1.510 raeburn 3864: if (!$allowed && $supplementalflag) {
1.519 raeburn 3865: $folderpath.=$containerarg.'&'.$foldername;
1.510 raeburn 3866: $url.='folderpath='.&escape($folderpath);
3867: } else {
1.344 bisitz 3868: # Append randompick number, hidden, and encrypted with ":" to foldername,
1.329 droeschl 3869: # so it gets transferred between levels
1.519 raeburn 3870: $folderpath.=$containerarg.'&'.$foldername.
1.510 raeburn 3871: ':'.(&LONCAPA::map::getparameter($orderidx,
1.329 droeschl 3872: 'parameter_randompick'))[0]
3873: .':'.((&LONCAPA::map::getparameter($orderidx,
3874: 'parameter_hiddenresource'))[0]=~/^yes$/i)
3875: .':'.((&LONCAPA::map::getparameter($orderidx,
3876: 'parameter_encrypturl'))[0]=~/^yes$/i)
3877: .':'.((&LONCAPA::map::getparameter($orderidx,
1.519 raeburn 3878: 'parameter_randomorder'))[0]=~/^yes$/i)
3879: .':'.$ispage;
1.510 raeburn 3880: $url.='folderpath='.&escape($folderpath);
3881: my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
3882: 'parameter_randompick'))[0];
3883: my $rpckchk;
3884: if ($rpicknum) {
3885: $rpckchk = ' checked="checked"';
1.543 raeburn 3886: if (($ishash) && (ref($filtersref->{'randompick'}) eq 'ARRAY')) {
3887: push(@{$filtersref->{'randompick'}},$orderidx.':'.$rpicknum);
3888: }
1.510 raeburn 3889: }
1.537 raeburn 3890: my $formname = 'edit_randompick_'.$orderidx;
1.510 raeburn 3891: $rand_pick_text =
1.478 raeburn 3892: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.538 raeburn 3893: $form_param."\n".
1.478 raeburn 3894: $form_common."\n".
1.537 raeburn 3895: '<span class="LC_nobreak"><label><input type="checkbox" name="randompick_'.$orderidx.'" id="randompick_'.$orderidx.'" onclick="'."updatePick(this.form,'$orderidx','check');".'"'.$rpckchk.' /> '.&mt('Randomly Pick').'</label><input type="hidden" name="rpicknum_'.$orderidx.'" id="rpicknum_'.$orderidx.'" value="'.$rpicknum.'" /><span id="randompicknum_'.$orderidx.'">';
1.510 raeburn 3896: if ($rpicknum ne '') {
3897: $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
3898: }
1.537 raeburn 3899: $rand_pick_text .= '</span></span>'.
3900: $form_end;
1.543 raeburn 3901: my $ro_set;
3902: if ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i) {
3903: $ro_set = 'checked="checked"';
3904: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
3905: push(@{$filtersref->{'randomorder'}},$orderidx);
3906: }
3907: }
1.564 raeburn 3908: $formname = 'edit_rorder_'.$orderidx;
1.510 raeburn 3909: $rand_order_text =
1.537 raeburn 3910: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
1.538 raeburn 3911: $form_param."\n".
1.537 raeburn 3912: $form_common."\n".
1.538 raeburn 3913: '<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" id="randomorder_'.$orderidx.'" onclick="checkForSubmit(this.form,'."'randomorder','settings'".');" '.$ro_set.' /> '.&mt('Random Order').' </label></span>'.
1.537 raeburn 3914: $form_end;
1.510 raeburn 3915: }
1.509 raeburn 3916: } elsif ($supplementalflag && !$allowed) {
1.598 raeburn 3917: my $isexttool;
3918: if ($url=~m{^/adm/$coursedom/$coursenum/\d+/exttools?$}) {
3919: $url='/adm/wrapper'.$url;
3920: $isexttool = 1;
3921: }
1.510 raeburn 3922: $url .= ($url =~ /\?/) ? '&':'?';
1.509 raeburn 3923: $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
1.510 raeburn 3924: if ($title) {
3925: $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"');
3926: }
1.598 raeburn 3927: if ((($isexternal) || ($isexttool)) && $orderidx) {
1.510 raeburn 3928: $url .= '&idx='.$orderidx;
3929: }
1.329 droeschl 3930: }
1.519 raeburn 3931: my ($tdalign,$tdwidth);
1.501 raeburn 3932: if ($allowed) {
3933: my $fileloc =
3934: &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
1.510 raeburn 3935: if ($isexternal) {
1.518 raeburn 3936: ($editlink,$extresform) =
1.510 raeburn 3937: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem);
1.598 raeburn 3938: } elsif ($orig_url =~ m{^/adm/$coursedom/$coursenum/\d+/exttools?$}) {
3939: ($editlink,$extresform) =
3940: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem,
3941: undef,undef,undef,'tool',$coursedom,
3942: $coursenum,$ltitoolsref);
1.511 raeburn 3943: } elsif (!$isfolder && !$ispage) {
1.503 raeburn 3944: my ($cfile,$home,$switchserver,$forceedit,$forceview) =
3945: &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
1.511 raeburn 3946: if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
1.501 raeburn 3947: my $jscall =
3948: &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
3949: $switchserver,
1.503 raeburn 3950: $forceedit,
1.511 raeburn 3951: undef,$symb,
3952: &escape($env{'form.folderpath'}),
1.524 raeburn 3953: $renametitle,'','',1);
1.501 raeburn 3954: if ($jscall) {
1.518 raeburn 3955: $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
3956: $jscall.'" >'.&mt('Edit').'</a> '."\n";
1.501 raeburn 3957: }
3958: }
3959: }
1.519 raeburn 3960: $tdalign = ' align="right" valign="top"';
3961: $tdwidth = ' width="80%"';
1.329 droeschl 3962: }
1.408 raeburn 3963: my $reinit;
3964: if ($crstype eq 'Community') {
3965: $reinit = &mt('(re-initialize community to access)');
3966: } else {
3967: $reinit = &mt('(re-initialize course to access)');
1.519 raeburn 3968: }
3969: $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;
1.472 raeburn 3970: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 3971: $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
3972: } elsif ($url) {
1.484 raeburn 3973: $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
1.470 raeburn 3974: '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
1.469 www 3975: } else {
3976: $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
3977: }
1.519 raeburn 3978: $line.='</span></td><td'.$tdwidth.'>';
1.472 raeburn 3979: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 3980: $line.='<a href="'.$url.'">'.$title.'</a>';
3981: } elsif ($url) {
1.484 raeburn 3982: $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
1.470 raeburn 3983: $title,600,500);
1.469 www 3984: } else {
3985: $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
3986: }
1.518 raeburn 3987: $line.="$extresform</td>";
1.478 raeburn 3988: $rand_pick_text = ' ' if ($rand_pick_text eq '');
3989: $rand_order_text = ' ' if ($rand_order_text eq '');
1.329 droeschl 3990: if (($allowed) && ($folder!~/^supplemental/)) {
3991: my %lt=&Apache::lonlocal::texthash(
3992: 'hd' => 'Hidden',
3993: 'ec' => 'URL hidden');
1.543 raeburn 3994: my ($enctext,$hidtext);
3995: if ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) {
3996: $enctext = ' checked="checked"';
3997: if (($ishash) && (ref($filtersref->{'encrypturl'}) eq 'ARRAY')) {
3998: push(@{$filtersref->{'encrypturl'}},$orderidx);
3999: }
4000: }
4001: if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
4002: $hidtext = ' checked="checked"';
4003: if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) {
4004: push(@{$filtersref->{'hiddenresource'}},$orderidx);
4005: }
4006: }
1.537 raeburn 4007: my $formhidden = 'edit_hiddenresource_'.$orderidx;
4008: my $formurlhidden = 'edit_encrypturl_'.$orderidx;
1.329 droeschl 4009: $line.=(<<ENDPARMS);
4010: <td class="LC_docs_entry_parameter">
1.537 raeburn 4011: <form action="/adm/coursedocs" method="post" name="$formhidden">
1.538 raeburn 4012: $form_param
1.478 raeburn 4013: $form_common
1.538 raeburn 4014: <label><input type="checkbox" name="hiddenresource_$orderidx" id="hiddenresource_$orderidx" onclick="checkForSubmit(this.form,'hiddenresource','settings');" $hidtext /> $lt{'hd'}</label>
1.329 droeschl 4015: $form_end
1.458 raeburn 4016: <br />
1.537 raeburn 4017: <form action="/adm/coursedocs" method="post" name="$formurlhidden">
1.538 raeburn 4018: $form_param
1.478 raeburn 4019: $form_common
1.538 raeburn 4020: <label><input type="checkbox" name="encrypturl_$orderidx" id="encrypturl_$orderidx" onclick="checkForSubmit(this.form,'encrypturl','settings');" $enctext /> $lt{'ec'}</label>
1.329 droeschl 4021: $form_end
4022: </td>
1.478 raeburn 4023: <td class="LC_docs_entry_parameter">$rand_pick_text<br />
4024: $rand_order_text</td>
1.329 droeschl 4025: ENDPARMS
4026: }
1.379 bisitz 4027: $line.=&Apache::loncommon::end_data_table_row();
1.329 droeschl 4028: return $line;
4029: }
4030:
1.538 raeburn 4031: sub action_restrictions {
4032: my ($cnum,$cdom,$url,$folderpath,$currgroups) = @_;
4033: my %denied = (
4034: cut => 0,
4035: copy => 0,
4036: remove => 0,
4037: );
4038: if ($url=~ m{^/res/.+\.(page|sequence)$}) {
4039: # no copy for published maps
4040: $denied{'copy'} = 1;
1.597 raeburn 4041: } elsif ($url=~m{^/res/lib/templates/([^/]+)\.problem$}) {
4042: unless ($1 eq 'simpleproblem') {
4043: $denied{'copy'} = 1;
4044: }
4045: $denied{'cut'} = 1;
1.538 raeburn 4046: } elsif ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") {
4047: if ($folderpath =~ /^default&[^\&]+$/) {
4048: if ((ref($currgroups) eq 'HASH') && (keys(%{$currgroups}) > 0)) {
4049: $denied{'remove'} = 1;
4050: }
4051: $denied{'cut'} = 1;
4052: $denied{'copy'} = 1;
4053: }
4054: } elsif ($url =~ m{^\Q/uploaded/$cdom/$cnum/group_folder_\E(\w+)\.sequence$}) {
4055: my $group = $1;
4056: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+$/) {
4057: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4058: $denied{'remove'} = 1;
4059: }
4060: }
4061: $denied{'cut'} = 1;
4062: $denied{'copy'} = 1;
4063: } elsif ($url =~ m{^\Q/adm/$cdom/$cnum/\E(\w+)/smppg$}) {
4064: my $group = $1;
4065: if ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&\Qgroup_folder_$group\E\&[^\&]+$/) {
4066: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4067: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4068: if (keys(%groupsettings) > 0) {
4069: $denied{'remove'} = 1;
4070: }
4071: $denied{'cut'} = 1;
4072: $denied{'copy'} = 1;
4073: }
4074: }
4075: } elsif ($folderpath =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&group_folder_(\w+)\&/) {
4076: my $group = $1;
4077: if ($url =~ /group_boards_\Q$group\E/) {
4078: if ((ref($currgroups) eq 'HASH') && (exists($currgroups->{$group}))) {
4079: my %groupsettings = &Apache::longroup::get_group_settings($currgroups->{$group});
4080: if (keys(%groupsettings) > 0) {
4081: if (ref($groupsettings{'functions'}) eq 'HASH') {
4082: if ($groupsettings{'functions'}{'discussion'} eq 'on') {
4083: $denied{'remove'} = 1;
4084: }
4085: }
4086: }
4087: $denied{'cut'} = 1;
4088: $denied{'copy'} = 1;
4089: }
4090: }
4091: }
4092: return %denied;
4093: }
4094:
1.533 raeburn 4095: sub new_timebased_suffix {
1.538 raeburn 4096: my ($dom,$num,$type,$area,$container) = @_;
1.533 raeburn 4097: my ($prefix,$namespace,$idtype,$errtext,$locknotfreed);
1.538 raeburn 4098: if ($type eq 'paste') {
4099: $prefix = $type;
4100: $namespace = 'courseeditor';
1.587 raeburn 4101: $idtype = 'addcode';
1.538 raeburn 4102: } elsif ($type eq 'map') {
1.533 raeburn 4103: $prefix = 'docs';
4104: if ($area eq 'supplemental') {
4105: $prefix = 'supp';
4106: }
4107: $prefix .= $container;
4108: $namespace = 'uploadedmaps';
4109: } else {
4110: $prefix = $type;
4111: $namespace = 'templated';
1.504 raeburn 4112: }
4113: my ($suffix,$freedlock,$error) =
1.587 raeburn 4114: &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,$dom,$num,$idtype);
1.504 raeburn 4115: if (!$suffix) {
1.538 raeburn 4116: if ($type eq 'paste') {
4117: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when adding to the paste buffer.');
4118: } elsif ($type eq 'map') {
1.533 raeburn 4119: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
4120: } elsif ($type eq 'smppg') {
4121: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.');
4122: } else {
1.565 bisitz 4123: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new discussion board.');
1.533 raeburn 4124: }
1.504 raeburn 4125: if ($error) {
4126: $errtext .= '<br />'.$error;
4127: }
4128: }
4129: if ($freedlock ne 'ok') {
1.533 raeburn 4130: $locknotfreed =
4131: '<div class="LC_error">'.
4132: &mt('There was a problem removing a lockfile.').' ';
1.538 raeburn 4133: if ($type eq 'paste') {
1.591 raeburn 4134: if ($freedlock eq 'nolock') {
4135: $locknotfreed =
4136: '<div class="LC_error">'.
4137: &mt('A lockfile was not released when you added content to the clipboard earlier in this session.').' '.
4138:
1.593 droeschl 4139: &mt('As a result addition of items to the clipboard will be unavailable until your next log-in.');
1.591 raeburn 4140: } else {
4141: $locknotfreed .=
4142: &mt('This will prevent addition of items to the clipboard until your next log-in.');
4143: }
1.538 raeburn 4144: } elsif ($type eq 'map') {
1.591 raeburn 4145: $locknotfreed .=
4146: &mt('This will prevent creation of additional folders or composite pages in this course.');
1.533 raeburn 4147: } elsif ($type eq 'smppg') {
4148: $locknotfreed .=
4149: &mt('This will prevent creation of additional simple pages in this course.');
4150: } else {
4151: $locknotfreed .=
1.565 bisitz 4152: &mt('This will prevent creation of additional discussion boards in this course.');
1.533 raeburn 4153: }
1.538 raeburn 4154: unless ($type eq 'paste') {
4155: $locknotfreed .=
1.560 raeburn 4156: ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.',
4157: '<a href="/adm/helpdesk" target="_helpdesk">','</a>');
1.538 raeburn 4158: }
4159: $locknotfreed .= '</div>';
1.504 raeburn 4160: }
4161: return ($suffix,$errtext,$locknotfreed);
4162: }
4163:
1.329 droeschl 4164: =pod
4165:
4166: =item tiehash()
4167:
4168: tie the hash
4169:
4170: =cut
4171:
4172: sub tiehash {
4173: my ($mode)=@_;
4174: $hashtied=0;
4175: if ($env{'request.course.fn'}) {
4176: if ($mode eq 'write') {
4177: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4178: &GDBM_WRCREAT(),0640)) {
4179: $hashtied=2;
4180: }
4181: } else {
4182: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
4183: &GDBM_READER(),0640)) {
4184: $hashtied=1;
4185: }
4186: }
1.364 bisitz 4187: }
1.329 droeschl 4188: }
4189:
4190: sub untiehash {
4191: if ($hashtied) { untie %hash; }
4192: $hashtied=0;
4193: return OK;
4194: }
4195:
4196:
4197:
4198:
4199: sub checkonthis {
4200: my ($r,$url,$level,$title)=@_;
4201: $url=&unescape($url);
4202: $alreadyseen{$url}=1;
4203: $r->rflush();
4204: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
4205: $r->print("\n<br />");
4206: if ($level==0) {
4207: $r->print("<br />");
4208: }
4209: for (my $i=0;$i<=$level*5;$i++) {
4210: $r->print(' ');
4211: }
4212: $r->print('<a href="'.$url.'" target="cat">'.
4213: ($title?$title:$url).'</a> ');
4214: if ($url=~/^\/res\//) {
4215: my $result=&Apache::lonnet::repcopy(
4216: &Apache::lonnet::filelocation('',$url));
4217: if ($result eq 'ok') {
4218: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
4219: $r->rflush();
4220: &Apache::lonnet::countacc($url);
4221: $url=~/\.(\w+)$/;
4222: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
4223: $r->print('<br />');
4224: $r->rflush();
4225: for (my $i=0;$i<=$level*5;$i++) {
4226: $r->print(' ');
4227: }
4228: $r->print('- '.&mt('Rendering:').' ');
4229: my ($errorcount,$warningcount)=split(/:/,
4230: &Apache::lonnet::ssi_body($url,
4231: ('grade_target'=>'web',
4232: 'return_only_error_and_warning_counts' => 1)));
4233: if (($errorcount) ||
4234: ($warningcount)) {
4235: if ($errorcount) {
1.369 bisitz 4236: $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1.329 droeschl 4237: &mt('[quant,_1,error]',$errorcount).'</span>');
4238: }
4239: if ($warningcount) {
4240: $r->print('<span class="LC_warning">'.
4241: &mt('[quant,_1,warning]',$warningcount).'</span>');
4242: }
4243: } else {
4244: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
4245: }
4246: $r->rflush();
4247: }
4248: my $dependencies=
4249: &Apache::lonnet::metadata($url,'dependencies');
4250: foreach my $dep (split(/\,/,$dependencies)) {
4251: if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
4252: &checkonthis($r,$dep,$level+1);
4253: }
4254: }
4255: } elsif ($result eq 'unavailable') {
4256: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
4257: } elsif ($result eq 'not_found') {
4258: unless ($url=~/\$/) {
1.521 bisitz 4259: $r->print('<span class="LC_error">'.&mt('not found').'</span>');
1.329 droeschl 4260: } else {
1.366 bisitz 4261: $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1.329 droeschl 4262: }
4263: } else {
4264: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
4265: }
4266: }
4267: }
4268: }
4269:
4270:
4271:
4272: =pod
4273:
4274: =item list_symbs()
4275:
1.485 raeburn 4276: List Content Identifiers
1.329 droeschl 4277:
4278: =cut
4279:
4280: sub list_symbs {
4281: my ($r) = @_;
4282:
1.408 raeburn 4283: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 4284: $r->print(&Apache::loncommon::start_page('List of Content Identifiers'));
4285: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Identifiers'));
4286: $r->print(&startContentScreen('tools'));
1.329 droeschl 4287: my $navmap = Apache::lonnavmaps::navmap->new();
4288: if (!defined($navmap)) {
4289: $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
4290: '<div class="LC_error">'.
4291: &mt('Unable to retrieve information about course contents').
4292: '</div>');
1.408 raeburn 4293: &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
1.329 droeschl 4294: } else {
1.484 raeburn 4295: $r->print('<h4 class="LC_info">'.&mt("$crstype Content Identifiers").'</h4>'.
4296: &Apache::loncommon::start_data_table().
4297: &Apache::loncommon::start_data_table_header_row().
4298: '<th>'.&mt('Title').'</th><th>'.&mt('Identifier').'</th>'.
4299: &Apache::loncommon::end_data_table_header_row()."\n");
4300: my $count;
1.329 droeschl 4301: foreach my $res ($navmap->retrieveResources()) {
1.484 raeburn 4302: $r->print(&Apache::loncommon::start_data_table_row().
4303: '<td>'.$res->compTitle().'</td>'.
4304: '<td>'.$res->symb().'</td>'.
1.521 bisitz 4305: &Apache::loncommon::end_data_table_row());
1.484 raeburn 4306: $count ++;
4307: }
4308: if (!$count) {
4309: $r->print(&Apache::loncommon::start_data_table_row().
4310: '<td colspan="2">'.&mt("$crstype is empty").'</td>'.
4311: &Apache::loncommon::end_data_table_row());
1.329 droeschl 4312: }
1.484 raeburn 4313: $r->print(&Apache::loncommon::end_data_table());
1.329 droeschl 4314: }
1.521 bisitz 4315: $r->print(&endContentScreen());
1.329 droeschl 4316: }
4317:
4318:
4319: sub verifycontent {
4320: my ($r) = @_;
1.408 raeburn 4321: my $crstype = &Apache::loncommon::course_type();
1.549 raeburn 4322: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content'));
4323: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content'));
1.484 raeburn 4324: $r->print(&startContentScreen('tools'));
4325: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
1.329 droeschl 4326: $hashtied=0;
4327: undef %alreadyseen;
4328: %alreadyseen=();
4329: &tiehash();
1.484 raeburn 4330:
1.329 droeschl 4331: foreach my $key (keys(%hash)) {
4332: if ($hash{$key}=~/\.(page|sequence)$/) {
4333: if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
4334: $r->print('<hr /><span class="LC_error">'.
1.419 bisitz 4335: &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
1.329 droeschl 4336: &unescape($hash{$key}).'</span><br />'.
1.419 bisitz 4337: &mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />');
1.329 droeschl 4338: }
4339: }
4340: if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
4341: &checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
4342: }
4343: }
4344: &untiehash();
1.442 www 4345: $r->print('<p class="LC_success">'.&mt('Done').'</p>');
1.521 bisitz 4346: $r->print(&endContentScreen());
1.329 droeschl 4347: }
4348:
4349:
4350: sub devalidateversioncache {
4351: my $src=shift;
4352: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
4353: &Apache::lonnet::clutter($src));
4354: }
4355:
4356: sub checkversions {
4357: my ($r) = @_;
1.408 raeburn 4358: my $crstype = &Apache::loncommon::course_type();
1.571 raeburn 4359: $r->print(&Apache::loncommon::start_page("Check $crstype Resource Versions"));
4360: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Resource Versions"));
1.484 raeburn 4361: $r->print(&startContentScreen('tools'));
1.442 www 4362:
1.329 droeschl 4363: my $header='';
4364: my $startsel='';
4365: my $monthsel='';
4366: my $weeksel='';
4367: my $daysel='';
4368: my $allsel='';
4369: my %changes=();
4370: my $starttime=0;
4371: my $haschanged=0;
4372: my %setversions=&Apache::lonnet::dump('resourceversions',
4373: $env{'course.'.$env{'request.course.id'}.'.domain'},
4374: $env{'course.'.$env{'request.course.id'}.'.num'});
4375:
4376: $hashtied=0;
4377: &tiehash();
4378: my %newsetversions=();
4379: if ($env{'form.setmostrecent'}) {
4380: $haschanged=1;
4381: foreach my $key (keys(%hash)) {
4382: if ($key=~/^ids\_(\/res\/.+)$/) {
4383: $newsetversions{$1}='mostrecent';
4384: &devalidateversioncache($1);
4385: }
4386: }
4387: } elsif ($env{'form.setcurrent'}) {
4388: $haschanged=1;
4389: foreach my $key (keys(%hash)) {
4390: if ($key=~/^ids\_(\/res\/.+)$/) {
4391: my $getvers=&Apache::lonnet::getversion($1);
4392: if ($getvers>0) {
4393: $newsetversions{$1}=$getvers;
4394: &devalidateversioncache($1);
4395: }
4396: }
4397: }
4398: } elsif ($env{'form.setversions'}) {
4399: $haschanged=1;
4400: foreach my $key (keys(%env)) {
4401: if ($key=~/^form\.set_version_(.+)$/) {
4402: my $src=$1;
4403: if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
4404: $newsetversions{$src}=$env{$key};
4405: &devalidateversioncache($src);
4406: }
4407: }
4408: }
4409: }
4410: if ($haschanged) {
4411: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
4412: $env{'course.'.$env{'request.course.id'}.'.domain'},
1.344 bisitz 4413: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
1.479 golterma 4414: $r->print(&Apache::loncommon::confirmwrapper(
4415: &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
1.329 droeschl 4416: } else {
1.479 golterma 4417: $r->print(&Apache::loncommon::confirmwrapper(
4418: &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
1.329 droeschl 4419: }
4420: &mark_hash_old();
4421: }
4422: &changewarning($r,'');
4423: if ($env{'form.timerange'} eq 'all') {
4424: # show all documents
1.549 raeburn 4425: $header=&mt('All content in '.$crstype);
1.521 bisitz 4426: $allsel=' selected="selected"';
1.329 droeschl 4427: foreach my $key (keys(%hash)) {
4428: if ($key=~/^ids\_(\/res\/.+)$/) {
4429: my $src=$1;
4430: $changes{$src}=1;
4431: }
4432: }
4433: } else {
4434: # show documents which changed
4435: %changes=&Apache::lonnet::dump
4436: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
4437: $env{'course.'.$env{'request.course.id'}.'.num'});
4438: my $firstkey=(keys(%changes))[0];
4439: unless ($firstkey=~/^error\:/) {
4440: unless ($env{'form.timerange'}) {
4441: $env{'form.timerange'}=604800;
4442: }
4443: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
4444: .&mt('seconds');
4445: if ($env{'form.timerange'}==-1) {
4446: $seltext='since start of course';
1.521 bisitz 4447: $startsel=' selected="selected"';
1.329 droeschl 4448: $env{'form.timerange'}=time;
4449: }
4450: $starttime=time-$env{'form.timerange'};
4451: if ($env{'form.timerange'}==2592000) {
4452: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 4453: $monthsel=' selected="selected"';
1.329 droeschl 4454: } elsif ($env{'form.timerange'}==604800) {
4455: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 4456: $weeksel=' selected="selected"';
1.329 droeschl 4457: } elsif ($env{'form.timerange'}==86400) {
4458: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 4459: $daysel=' selected="selected"';
1.329 droeschl 4460: }
4461: $header=&mt('Content changed').' '.$seltext;
4462: } else {
4463: $header=&mt('No content modifications yet.');
4464: }
4465: }
4466: %setversions=&Apache::lonnet::dump('resourceversions',
4467: $env{'course.'.$env{'request.course.id'}.'.domain'},
4468: $env{'course.'.$env{'request.course.id'}.'.num'});
4469: my %lt=&Apache::lonlocal::texthash
1.408 raeburn 4470: ('st' => 'Version changes since start of '.$crstype,
1.329 droeschl 4471: 'lm' => 'Version changes since last Month',
4472: 'lw' => 'Version changes since last Week',
4473: 'sy' => 'Version changes since Yesterday',
4474: 'al' => 'All Resources (possibly large output)',
1.484 raeburn 4475: 'cd' => 'Change display',
1.329 droeschl 4476: 'sd' => 'Display',
4477: 'fi' => 'File',
4478: 'md' => 'Modification Date',
4479: 'mr' => 'Most recently published Version',
1.408 raeburn 4480: 've' => 'Version used in '.$crstype,
4481: 'vu' => 'Set Version to be used in '.$crstype,
4482: 'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
1.329 droeschl 4483: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
4484: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.479 golterma 4485: 'di' => 'Differences',
1.484 raeburn 4486: 'save' => 'Save changes',
4487: 'vers' => 'Version choice(s) for specific resources',
1.479 golterma 4488: 'act' => 'Actions');
1.329 droeschl 4489: $r->print(<<ENDHEADERS);
1.484 raeburn 4490: <h4 class="LC_info">$header</h4>
1.329 droeschl 4491: <form action="/adm/coursedocs" method="post">
4492: <input type="hidden" name="versions" value="1" />
1.484 raeburn 4493: <div class="LC_left_float">
1.479 golterma 4494: <fieldset>
1.484 raeburn 4495: <legend>$lt{'cd'}</legend>
1.329 droeschl 4496: <select name="timerange">
1.521 bisitz 4497: <option value='all'$allsel>$lt{'al'}</option>
4498: <option value="-1"$startsel>$lt{'st'}</option>
4499: <option value="2592000"$monthsel>$lt{'lm'}</option>
4500: <option value="604800"$weeksel>$lt{'lw'}</option>
4501: <option value="86400"$daysel>$lt{'sy'}</option>
1.329 droeschl 4502: </select>
4503: <input type="submit" name="display" value="$lt{'sd'}" />
1.484 raeburn 4504: </fieldset>
4505: </div>
4506: <div class="LC_left_float">
4507: <fieldset>
4508: <legend>$lt{'act'}</legend>
4509: $lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" /><br />
4510: $lt{'sc'}: <input type="submit" name="setcurrent" value="Go" />
4511: </fieldset>
4512: </div>
4513: <br clear="all" />
4514: <hr />
4515: <h4>$lt{'vers'}</h4>
1.329 droeschl 4516: ENDHEADERS
1.479 golterma 4517: #number of columns for version history
1.571 raeburn 4518: my %changedbytime;
4519: foreach my $key (keys(%changes)) {
4520: #excludes not versionable problems from resource version history:
4521: next if ($key =~ /^\/res\/lib\/templates/);
4522: my $chg;
4523: if ($env{'form.timerange'} eq 'all') {
4524: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
4525: $chg = &Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate');
4526: } else {
4527: $chg = $changes{$key};
4528: next if ($chg < $starttime);
4529: }
4530: push(@{$changedbytime{$chg}},$key);
4531: }
4532: if (keys(%changedbytime) == 0) {
4533: &untiehash();
4534: $r->print(&mt('No content changes in imported content in specified time frame').
4535: &endContentScreen());
4536: return;
4537: }
1.479 golterma 4538: $r->print(
1.571 raeburn 4539: '<input type="submit" name="setversions" value="'.$lt{'save'}.'" />'.
1.521 bisitz 4540: &Apache::loncommon::start_data_table().
4541: &Apache::loncommon::start_data_table_header_row().
4542: '<th>'.&mt('Resources').'</th>'.
4543: "<th>$lt{'mr'}</th>".
4544: "<th>$lt{'ve'}</th>".
4545: "<th>$lt{'vu'}</th>".
4546: '<th>'.&mt('History').'</th>'.
4547: &Apache::loncommon::end_data_table_header_row()
4548: );
1.571 raeburn 4549: foreach my $chg (sort {$b <=> $a } keys(%changedbytime)) {
4550: foreach my $key (sort(@{$changedbytime{$chg}})) {
4551: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
4552: my $currentversion=&Apache::lonnet::getversion($key);
4553: if ($currentversion<0) {
4554: $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
4555: }
4556: my $linkurl=&Apache::lonnet::clutter($key);
4557: $r->print(
4558: &Apache::loncommon::start_data_table_row().
4559: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br />'.
4560: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
4561: '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br />('.
4562: &Apache::lonlocal::locallocaltime($chg).')</span></td>'.
4563: '<td align="right">'
4564: );
4565: # Used in course
4566: my $usedversion=$hash{'version_'.$linkurl};
4567: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.521 bisitz 4568: if ($usedversion != $currentversion) {
1.479 golterma 4569: $r->print('<span class="LC_warning">'.$usedversion.'</span>');
1.521 bisitz 4570: } else {
1.479 golterma 4571: $r->print($usedversion);
4572: }
1.329 droeschl 4573: } else {
1.521 bisitz 4574: $r->print($currentversion);
1.329 droeschl 4575: }
1.571 raeburn 4576: $r->print('</td><td title="'.$lt{'vu'}.'">');
4577: # Set version
4578: $r->print(&Apache::loncommon::select_form(
4579: $setversions{$linkurl},
4580: 'set_version_'.$linkurl,
4581: {'select_form_order' => ['',1..$currentversion,'mostrecent'],
4582: '' => '',
4583: 'mostrecent' => &mt('most recent'),
4584: map {$_,$_} (1..$currentversion)}));
4585: my $lastold=1;
4586: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
4587: my $url=$root.'.'.$prevvers.'.'.$extension;
4588: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) {
4589: $lastold=$prevvers;
4590: }
4591: }
4592: $r->print('</td>');
4593: # List all available versions
4594: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
4595: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
4596: my $url=$root.'.'.$prevvers.'.'.$extension;
4597: $r->print(
4598: '<span class="LC_nobreak">'
4599: .'<a href="'.&Apache::lonnet::clutter($url).'">'
4600: .&mt('Version [_1]',$prevvers).'</a>'
4601: .' ('.&Apache::lonlocal::locallocaltime(
1.521 bisitz 4602: &Apache::lonnet::metadata($url,'lastrevisiondate'))
1.571 raeburn 4603: .')');
4604: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
4605: $r->print(
4606: ' <a href="/adm/diff?filename='.
4607: &Apache::lonnet::clutter($root.'.'.$extension).
4608: &HTML::Entities::encode('&versionone='.$prevvers,'"<>&').
4609: '" target="diffs">'.&mt('Diffs').'</a>');
4610: }
4611: $r->print('</span><br />');
1.329 droeschl 4612: }
1.571 raeburn 4613: $r->print('</span></td>'.&Apache::loncommon::end_data_table_row());
1.521 bisitz 4614: }
1.329 droeschl 4615: }
1.521 bisitz 4616: $r->print(
4617: &Apache::loncommon::end_data_table().
4618: '<input type="submit" name="setversions" value="'.$lt{'save'}.'" />'.
4619: '</form>'
4620: );
1.329 droeschl 4621:
4622: &untiehash();
1.521 bisitz 4623: $r->print(&endContentScreen());
1.571 raeburn 4624: return;
1.329 droeschl 4625: }
4626:
4627: sub mark_hash_old {
4628: my $retie_hash=0;
4629: if ($hashtied) {
4630: $retie_hash=1;
4631: &untiehash();
4632: }
4633: &tiehash('write');
4634: $hash{'old'}=1;
4635: &untiehash();
4636: if ($retie_hash) { &tiehash(); }
4637: }
4638:
4639: sub is_hash_old {
4640: my $untie_hash=0;
4641: if (!$hashtied) {
4642: $untie_hash=1;
4643: &tiehash();
4644: }
4645: my $return=$hash{'old'};
4646: if ($untie_hash) { &untiehash(); }
4647: return $return;
4648: }
4649:
4650: sub changewarning {
4651: my ($r,$postexec,$message,$url)=@_;
4652: if (!&is_hash_old()) { return; }
4653: my $pathvar='folderpath';
4654: my $path=&escape($env{'form.folderpath'});
4655: if (!defined($url)) {
4656: $url='/adm/coursedocs?'.$pathvar.'='.$path;
4657: }
4658: my $course_type = &Apache::loncommon::course_type();
4659: if (!defined($message)) {
4660: $message='Changes will become active for your current session after [_1], or the next time you log in.';
4661: }
4662: $r->print("\n\n".
1.372 bisitz 4663: '<script type="text/javascript">'."\n".
4664: '// <![CDATA['."\n".
4665: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
4666: '// ]]>'."\n".
1.369 bisitz 4667: '</script>'."\n".
1.375 tempelho 4668: '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
1.329 droeschl 4669: '<input type="hidden" name="orgurl" value="'.$url.
1.372 bisitz 4670: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
1.329 droeschl 4671: &mt($message,' <input type="hidden" name="'.
4672: $env{'request.role'}.'" value="1" /><input type="button" value="'.
1.369 bisitz 4673: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1.372 bisitz 4674: $help{'Caching'}.'</p></form>'."\n\n");
1.329 droeschl 4675: }
4676:
4677:
4678: sub init_breadcrumbs {
1.571 raeburn 4679: my ($form,$text,$help)=@_;
1.329 droeschl 4680: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484 raeburn 4681: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
1.405 bisitz 4682: text=>&Apache::loncommon::course_type().' Editor',
1.329 droeschl 4683: faq=>273,
4684: bug=>'Instructor Interface',
1.571 raeburn 4685: help => $help});
1.329 droeschl 4686: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
4687: text=>$text,
4688: faq=>273,
4689: bug=>'Instructor Interface'});
4690: }
4691:
1.441 www 4692: # subroutine to list form elements
4693: sub create_list_elements {
4694: my @formarr = @_;
4695: my $list = '';
1.501 raeburn 4696: foreach my $button (@formarr){
4697: foreach my $picture (keys(%{$button})) {
4698: $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
1.441 www 4699: }
4700: }
4701: return $list;
4702: }
1.329 droeschl 4703:
1.441 www 4704: # subroutine to create ul from list elements
4705: sub create_form_ul {
4706: my $list = shift;
4707: my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
4708: return $ul;
4709: }
1.329 droeschl 4710:
1.442 www 4711: #
4712: # Start tabs
4713: #
4714:
4715: sub startContentScreen {
1.484 raeburn 4716: my ($mode) = @_;
4717: my $output = '<ul class="LC_TabContentBigger" id="mainnav">';
1.472 raeburn 4718: if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
1.484 raeburn 4719: $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n";
4720: $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n";
4721: $output .= '<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b> '.&mt('Content Index').' </b></a></li>'."\n";
4722: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
4723: } else {
1.549 raeburn 4724: $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 4725: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
4726: $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>'."\n";
4727: '><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>';
4728: }
4729: $output .= "\n".'</ul>'."\n";
4730: $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
4731: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
4732: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
4733: return $output;
1.442 www 4734: }
4735:
4736: #
4737: # End tabs
4738: #
4739:
4740: sub endContentScreen {
1.484 raeburn 4741: return '</div></div></div>';
1.442 www 4742: }
1.329 droeschl 4743:
1.446 www 4744: sub supplemental_base {
1.548 raeburn 4745: return 'supplemental&'.&escape(&mt('Supplemental Content'));
1.446 www 4746: }
4747:
1.329 droeschl 4748: sub handler {
4749: my $r = shift;
4750: &Apache::loncommon::content_type($r,'text/html');
4751: $r->send_http_header;
4752: return OK if $r->header_only;
1.484 raeburn 4753:
4754: # get course data
1.408 raeburn 4755: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 4756: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
4757: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
4758:
4759: # graphics settings
4760: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329 droeschl 4761:
1.443 www 4762: #
1.329 droeschl 4763: # --------------------------------------------- Initialize help topics for this
4764: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
4765: 'Adding_External_Resource','Navigate_Content',
4766: 'Adding_Folders','Docs_Overview', 'Load_Map',
4767: 'Supplemental','Score_Upload_Form','Adding_Pages',
1.501 raeburn 4768: 'Importing_LON-CAPA_Resource','Importing_IMS_Course',
1.571 raeburn 4769: 'Uploading_From_Harddrive','Course_Roster','Web_Page',
1.572 raeburn 4770: 'Dropbox','Simple_Problem') {
1.329 droeschl 4771: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
4772: }
4773: # Composite help files
4774: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
4775: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
4776: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
4777: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
4778: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
4779: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 4780: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 4781: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 4782: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 4783: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1.534 raeburn 4784:
1.472 raeburn 4785: my $allowed;
4786: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
4787: unless ($r->uri eq '/adm/supplemental') {
4788: # does this user have privileges to modify content.
4789: $allowed = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
4790: }
4791:
1.582 raeburn 4792: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']);
4793: if ($allowed && $env{'form.verify'}) {
1.571 raeburn 4794: &init_breadcrumbs('verify','Verify Content','Docs_Verify_Content');
1.329 droeschl 4795: &verifycontent($r);
4796: } elsif ($allowed && $env{'form.listsymbs'}) {
1.484 raeburn 4797: &init_breadcrumbs('listsymbs','List Content IDs');
1.329 droeschl 4798: &list_symbs($r);
4799: } elsif ($allowed && $env{'form.docslog'}) {
4800: &init_breadcrumbs('docslog','Show Log');
1.484 raeburn 4801: my $folder = $env{'form.folder'};
4802: if ($folder eq '') {
4803: $folder='default';
4804: }
4805: &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath);
1.329 droeschl 4806: } elsif ($allowed && $env{'form.versions'}) {
1.571 raeburn 4807: &init_breadcrumbs('versions','Check/Set Resource Versions','Docs_Check_Resource_Versions');
1.329 droeschl 4808: &checkversions($r);
4809: } elsif ($allowed && $env{'form.dumpcourse'}) {
1.568 raeburn 4810: &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329 droeschl 4811: &dumpcourse($r);
4812: } elsif ($allowed && $env{'form.exportcourse'}) {
1.377 bisitz 4813: &init_breadcrumbs('exportcourse','IMS Export');
1.475 raeburn 4814: &Apache::imsexport::exportcourse($r);
1.329 droeschl 4815: } else {
1.445 www 4816: #
4817: # Done catching special calls
1.484 raeburn 4818: # The whole rest is for course and supplemental documents and utilities menu
1.445 www 4819: # Get the parameters that may be needed
4820: #
4821: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.519 raeburn 4822: ['folderpath',
4823: 'forcesupplement','forcestandard',
1.510 raeburn 4824: 'tools','symb','command','supppath']);
1.445 www 4825:
4826: # standard=1: this is a "new-style" course with an uploaded map as top level
4827: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329 droeschl 4828:
4829: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445 www 4830:
1.484 raeburn 4831: # Decide whether this should display supplemental or main content or utilities
1.445 www 4832: # supplementalflag=1: show supplemental documents
4833: # supplementalflag=0: show standard documents
1.484 raeburn 4834: # toolsflag=1: show utilities
1.445 www 4835:
1.561 raeburn 4836: my $unesc_folderpath = &unescape($env{'form.folderpath'});
4837: my $supplementalflag=($unesc_folderpath=~/^supplemental/);
4838: if (($unesc_folderpath=~/^default/) || ($unesc_folderpath eq "")) {
1.445 www 4839: $supplementalflag=0;
4840: }
4841: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
4842: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
4843: unless ($allowed) { $supplementalflag=1; }
4844: unless ($standard) { $supplementalflag=1; }
1.484 raeburn 4845: my $toolsflag=0;
4846: if ($env{'form.tools'}) { $toolsflag=1; }
1.445 www 4847:
1.329 droeschl 4848: my $script='';
4849: my $showdoc=0;
1.457 raeburn 4850: my $addentries = {};
1.475 raeburn 4851: my $container;
1.329 droeschl 4852: my $containertag;
1.508 raeburn 4853: my $pathitem;
1.598 raeburn 4854: my %ltitools;
1.329 droeschl 4855:
1.464 www 4856: # Do we directly jump somewhere?
1.466 www 4857:
1.525 raeburn 4858: if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
1.472 raeburn 4859: if ($env{'form.symb'} ne '') {
1.522 raeburn 4860: $env{'form.folderpath'}=
4861: &Apache::loncommon::symb_to_docspath($env{'form.symb'});
1.530 raeburn 4862: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
1.525 raeburn 4863: $env{'form.command'}.'_'.$env{'form.symb'}});
1.472 raeburn 4864: } elsif ($env{'form.supppath'} ne '') {
4865: $env{'form.folderpath'}=$env{'form.supppath'};
1.530 raeburn 4866: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
1.525 raeburn 4867: $env{'form.command'}.'_'.$env{'form.supppath'}});
1.466 www 4868: }
1.472 raeburn 4869: } elsif ($env{'form.command'} eq 'editdocs') {
1.525 raeburn 4870: $env{'form.folderpath'} = 'default&'.
1.548 raeburn 4871: &escape(&mt('Main Content').':::::');
1.525 raeburn 4872: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
1.472 raeburn 4873: } elsif ($env{'form.command'} eq 'editsupp') {
1.525 raeburn 4874: $env{'form.folderpath'} = 'supplemental&'.
1.538 raeburn 4875: &escape('Supplemental Content');
1.525 raeburn 4876: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
4877: } elsif ($env{'form.command'} eq 'contents') {
4878: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
4879: } elsif ($env{'form.command'} eq 'home') {
4880: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
1.464 www 4881: }
4882:
1.525 raeburn 4883:
1.445 www 4884: # Where do we store these for when we come back?
4885: my $stored_folderpath='docs_folderpath';
4886: if ($supplementalflag) {
4887: $stored_folderpath='docs_sup_folderpath';
4888: }
1.464 www 4889:
1.519 raeburn 4890: # No folderpath, and in edit mode, see if we have something stored
4891: if ((!$env{'form.folderpath'}) && $allowed) {
1.445 www 4892: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.510 raeburn 4893: {'folderpath' => 'scalar'});
1.523 raeburn 4894: unless (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
4895: undef($env{'form.folderpath'});
4896: }
1.329 droeschl 4897: }
1.446 www 4898:
4899: # If we are not allowed to make changes, all we can see are supplemental docs
1.409 raeburn 4900: if (!$allowed) {
1.446 www 4901: unless ($env{'form.folderpath'} =~ /^supplemental/) {
4902: $env{'form.folderpath'} = &supplemental_base();
1.409 raeburn 4903: }
4904: }
1.446 www 4905: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329 droeschl 4906: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446 www 4907: $env{'form.folderpath'} = &supplemental_base()
4908: .'&'.
1.329 droeschl 4909: $env{'form.folderpath'};
4910: }
1.446 www 4911: # If after all of this, we still don't have any paths, make them
1.519 raeburn 4912: unless ($env{'form.folderpath'}) {
1.446 www 4913: if ($supplementalflag) {
4914: $env{'form.folderpath'}=&supplemental_base();
4915: } else {
1.548 raeburn 4916: $env{'form.folderpath'}='default&'.&escape(&mt('Main Content').
1.538 raeburn 4917: ':::::');
1.446 www 4918: }
1.472 raeburn 4919: }
1.446 www 4920:
1.445 www 4921: # Store this
1.484 raeburn 4922: unless ($toolsflag) {
1.510 raeburn 4923: if ($allowed) {
4924: &Apache::loncommon::store_course_settings($stored_folderpath,
1.519 raeburn 4925: {'folderpath' => 'scalar'});
1.510 raeburn 4926: }
1.519 raeburn 4927: my $folderpath;
1.484 raeburn 4928: if ($env{'form.folderpath'}) {
1.519 raeburn 4929: $folderpath = $env{'form.folderpath'};
4930: my (@folders)=split('&',$env{'form.folderpath'});
4931: $env{'form.foldername'}=&unescape(pop(@folders));
4932: if ($env{'form.foldername'} =~ /\:1$/) {
4933: $container = 'page';
4934: } else {
4935: $container = 'sequence';
4936: }
4937: $env{'form.folder'}=pop(@folders);
1.484 raeburn 4938: } else {
1.519 raeburn 4939: if ($env{'form.folder'} eq '' ||
4940: $env{'form.folder'} eq 'supplemental') {
4941: $folderpath='default&'.
1.548 raeburn 4942: &escape(&mt('Main Content').':::::');
1.484 raeburn 4943: }
4944: }
1.519 raeburn 4945: $containertag = '<input type="hidden" name="folderpath" value="" />';
4946: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 4947: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
4948: $showdoc='/'.$1;
4949: }
4950: if ($showdoc) { # got called in sequence from course
4951: $allowed=0;
4952: } else {
4953: if ($allowed) {
4954: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
4955: $script=&Apache::lonratedt::editscript('simple');
1.433 raeburn 4956: }
4957: }
1.329 droeschl 4958: }
4959:
1.344 bisitz 4960: # get personal data
1.329 droeschl 4961: my $uname=$env{'user.name'};
4962: my $udom=$env{'user.domain'};
4963: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
4964:
4965: if ($allowed) {
1.484 raeburn 4966: if ($toolsflag) {
4967: $script .= &inject_data_js();
4968: my ($home,$other,%outhash)=&authorhosts();
4969: if (!$home && $other) {
4970: my @hosts;
4971: foreach my $aurole (keys(%outhash)) {
4972: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
4973: push(@hosts,$outhash{$aurole});
4974: }
4975: }
4976: $script .= &dump_switchserver_js(@hosts);
4977: }
1.458 raeburn 4978: } else {
1.570 raeburn 4979: my $tid = 1;
1.484 raeburn 4980: my @tabids;
4981: if ($supplementalflag) {
4982: @tabids = ('002','ee2','ff2');
1.570 raeburn 4983: $tid = 2;
1.484 raeburn 4984: } else {
4985: @tabids = ('aa1','bb1','cc1','ff1');
1.519 raeburn 4986: unless ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 4987: unshift(@tabids,'001');
4988: push(@tabids,('dd1','ee1'));
4989: }
1.458 raeburn 4990: }
1.484 raeburn 4991: my $tabidstr = join("','",@tabids);
1.598 raeburn 4992: %ltitools = &Apache::lonnet::get_domain_ltitools($coursedom);
4993: my $exttoolurl = "/adm/$coursedom/$coursenum/new/exttool";
1.484 raeburn 4994: $script .= &editing_js($udom,$uname,$supplementalflag).
4995: &history_tab_js().
4996: &inject_data_js().
1.570 raeburn 4997: &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
1.598 raeburn 4998: &Apache::lonextresedit::extedit_javascript(\%ltitools);
1.484 raeburn 4999: $addentries = {
1.485 raeburn 5000: onload => "javascript:resize_scrollbox('contentscroll','1','1');",
1.484 raeburn 5001: };
1.458 raeburn 5002: }
1.538 raeburn 5003: $script .= &paste_popup_js();
1.501 raeburn 5004: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
5005: &mt('Switch server?');
5006:
5007:
1.329 droeschl 5008: }
5009: # -------------------------------------------------------------------- Body tag
1.369 bisitz 5010: $script = '<script type="text/javascript">'."\n"
1.372 bisitz 5011: .'// <![CDATA['."\n"
5012: .$script."\n"
5013: .'// ]]>'."\n"
1.595 musolffc 5014: .'</script>'."\n"
5015: .'<script type="text/javascript"
5016: src="/res/adm/includes/file_upload.js"></script>'."\n";
1.385 bisitz 5017:
5018: # Breadcrumbs
5019: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.510 raeburn 5020:
5021: if ($showdoc) {
5022: $r->print(&Apache::loncommon::start_page("$crstype documents",undef,
5023: {'force_register' => $showdoc,}));
1.571 raeburn 5024: } elsif ($toolsflag) {
5025: &Apache::lonhtmlcommon::add_breadcrumb({
5026: href=>"/adm/coursedocs",text=>"$crstype Contents"});
5027: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script)
5028: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5029: .&Apache::lonhtmlcommon::breadcrumbs(
5030: 'Editing Course Contents')
5031: );
1.510 raeburn 5032: } elsif ($r->uri eq '/adm/supplemental') {
5033: my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
5034: $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
5035: {'bread_crumbs' => $brcrum,}));
5036: } else {
1.392 raeburn 5037: &Apache::lonhtmlcommon::add_breadcrumb({
1.446 www 5038: href=>"/adm/coursedocs",text=>"$crstype Contents"});
5039: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.510 raeburn 5040: {'add_entries' => $addentries}
5041: )
1.392 raeburn 5042: .&Apache::loncommon::help_open_menu('','',273,'RAT')
5043: .&Apache::lonhtmlcommon::breadcrumbs(
1.484 raeburn 5044: 'Editing '.$crstype.' Contents',
1.392 raeburn 5045: 'Docs_Adding_Course_Doc')
5046: );
5047: }
1.364 bisitz 5048:
1.329 droeschl 5049: my %allfiles = ();
5050: my %codebase = ();
1.440 raeburn 5051: my ($upload_result,$upload_output,$uploadphase);
1.329 droeschl 5052: if ($allowed) {
5053: if (($env{'form.uploaddoc.filename'}) &&
5054: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440 raeburn 5055: my $context = $1;
5056: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 5057: undef($hadchanges);
1.440 raeburn 5058: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
1.552 raeburn 5059: \%allfiles,\%codebase,$context,$crstype);
1.329 droeschl 5060: if ($hadchanges) {
5061: &mark_hash_old();
5062: }
1.440 raeburn 5063: $r->print($upload_output);
5064: } elsif ($env{'form.phase'} eq 'upload_embedded') {
5065: # Process file upload - phase two - upload embedded objects
5066: $uploadphase = 'check_embedded';
5067: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
5068: my $state = &embedded_form_elems($uploadphase,$primaryurl,
5069: $env{'form.newidx'});
5070: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5071: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5072: my ($destination,$dir_root) = &embedded_destination();
5073: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
5074: my $actionurl = '/adm/coursedocs';
5075: my ($result,$flag) =
5076: &Apache::loncommon::upload_embedded('coursedoc',$destination,
5077: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
5078: $actionurl);
5079: $r->print($result.&return_to_editor());
5080: } elsif ($env{'form.phase'} eq 'check_embedded') {
5081: # Process file upload - phase three - modify references in HTML file
5082: $uploadphase = 'modified_orightml';
5083: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5084: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5085: my ($destination,$dir_root) = &embedded_destination();
1.482 raeburn 5086: my $result =
5087: &Apache::loncommon::modify_html_refs('coursedoc',$destination,
5088: $docuname,$docudom,undef,
5089: $dir_root);
5090: $r->print($result.&return_to_editor());
1.476 raeburn 5091: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
5092: $uploadphase = 'decompress_phase_one';
5093: $r->print(&decompression_phase_one().
5094: &return_to_editor());
5095: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
5096: $uploadphase = 'decompress_phase_two';
5097: $r->print(&decompression_phase_two().
5098: &return_to_editor());
1.329 droeschl 5099: }
5100: }
5101:
1.484 raeburn 5102: if ($allowed && $toolsflag) {
5103: $r->print(&startContentScreen('tools'));
5104: $r->print(&generate_admin_menu($crstype));
5105: $r->print(&endContentScreen());
5106: } elsif ((!$showdoc) && (!$uploadphase)) {
1.329 droeschl 5107: # -----------------------------------------------------------------------------
5108: my %lt=&Apache::lonlocal::texthash(
5109: 'copm' => 'All documents out of a published map into this folder',
1.501 raeburn 5110: 'upfi' => 'Upload File',
1.553 raeburn 5111: 'upld' => 'Upload Content',
1.329 droeschl 5112: 'srch' => 'Search',
5113: 'impo' => 'Import',
1.487 raeburn 5114: 'lnks' => 'Import from Stored Links',
1.502 raeburn 5115: 'impm' => 'Import from Assembled Map',
1.598 raeburn 5116: 'extr' => 'External Resource',
5117: 'extt' => 'External Tool',
1.329 droeschl 5118: 'selm' => 'Select Map',
5119: 'load' => 'Load Map',
5120: 'newf' => 'New Folder',
5121: 'newp' => 'New Composite Page',
5122: 'syll' => 'Syllabus',
1.425 raeburn 5123: 'navc' => 'Table of Contents',
1.343 biermanm 5124: 'sipa' => 'Simple Course Page',
1.329 droeschl 5125: 'sipr' => 'Simple Problem',
1.534 raeburn 5126: 'webp' => 'Blank Web Page (editable)',
1.329 droeschl 5127: 'drbx' => 'Drop Box',
1.451 www 5128: 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336 schafran 5129: 'bull' => 'Discussion Board',
1.347 weissno 5130: 'mypi' => 'My Personal Information Page',
1.353 weissno 5131: 'grpo' => 'Group Portfolio',
1.329 droeschl 5132: 'rost' => 'Course Roster',
1.528 raeburn 5133: 'abou' => 'Personal Information Page for a User',
1.553 raeburn 5134: 'imsf' => 'IMS Upload',
5135: 'imsl' => 'Upload IMS package',
1.501 raeburn 5136: 'cms' => 'Origin of IMS package',
5137: 'se' => 'Select',
1.329 droeschl 5138: 'file' => 'File',
5139: 'title' => 'Title',
5140: 'comment' => 'Comment',
1.403 raeburn 5141: 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.577 bisitz 5142: 'bb5' => 'Blackboard 5',
5143: 'bb6' => 'Blackboard 6',
5144: 'angel5' => 'ANGEL 5.5',
5145: 'webctce4' => 'WebCT 4 Campus Edition',
5146: );
1.329 droeschl 5147: # -----------------------------------------------------------------------------
1.595 musolffc 5148:
5149: # Calculate free quota space for a user or course. A javascript function checks
5150: # file size to determine if upload should be allowed.
5151: my $quotatype = 'unofficial';
5152: if ($crstype eq 'Community') {
5153: $quotatype = 'community';
5154: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
5155: $quotatype = 'official';
5156: } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
5157: $quotatype = 'textbook';
5158: }
5159: my $disk_quota = &Apache::loncommon::get_user_quota($coursenum,$coursedom,
5160: 'course',$quotatype); # expressed in MB
5161: my $current_disk_usage = 0;
5162: foreach my $subdir ('docs','supplemental') {
5163: $current_disk_usage += &Apache::lonnet::diskusage($coursedom,$coursenum,
5164: "userfiles/$subdir",1); # expressed in kB
5165: }
5166: my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage);
5167:
1.329 droeschl 5168: my $fileupload=(<<FIUP);
5169: $lt{'file'}:<br />
1.595 musolffc 5170: <input type="file" name="uploaddoc" class="flUpload" size="40" />
5171: <input type="hidden" id="free_space" value="$free_space" />
1.329 droeschl 5172: FIUP
5173:
5174: my $checkbox=(<<CHBO);
5175: <!-- <label>$lt{'parse'}?
5176: <input type="checkbox" name="parserflag" />
5177: </label> -->
5178: <label>
5179: <input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
5180: </label>
5181: CHBO
1.501 raeburn 5182: my $imsfolder = $env{'form.folder'};
5183: if ($imsfolder eq '') {
5184: $imsfolder = 'default';
5185: }
5186: my $imspform=(<<IMSFORM);
5187: <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
5188: $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
5189: <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
1.516 raeburn 5190: <fieldset id="uploadimsform" style="display: none;">
1.501 raeburn 5191: <legend>$lt{'imsf'}</legend>
5192: $fileupload
5193: <br />
5194: <p>
5195: $lt{'cms'}:
5196: <select name="source">
5197: <option value="-1" selected="selected">$lt{'se'}</option>
1.577 bisitz 5198: <option value="bb5">$lt{'bb5'}</option>
5199: <option value="bb6">$lt{'bb6'}</option>
5200: <option value="angel5">$lt{'angel5'}</option>
5201: <option value="webctce4">$lt{'webctce4'}</option>
1.501 raeburn 5202: </select>
5203: <input type="hidden" name="folder" value="$imsfolder" />
5204: </p>
5205: <input type="hidden" name="phase" value="one" />
5206: <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" />
5207: </fieldset>
5208: </form>
5209: IMSFORM
1.329 droeschl 5210:
5211: my $fileuploadform=(<<FUFORM);
1.501 raeburn 5212: <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
5213: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
5214: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.516 raeburn 5215: <fieldset id="uploaddocform" style="display: none;">
1.501 raeburn 5216: <legend>$lt{'upfi'}</legend>
1.371 tempelho 5217: <input type="hidden" name="active" value="aa" />
1.595 musolffc 5218: $fileupload
1.329 droeschl 5219: <br />
5220: $lt{'title'}:<br />
1.458 raeburn 5221: <input type="text" size="60" name="comment" />
1.508 raeburn 5222: $pathitem
1.329 droeschl 5223: <input type="hidden" name="cmd" value="upload_default" />
5224: <br />
1.458 raeburn 5225: <span class="LC_nobreak" style="float:left">
1.329 droeschl 5226: $checkbox
5227: </span>
1.501 raeburn 5228: <br clear="all" />
5229: <input type="submit" value="$lt{'upld'}" />
5230: </fieldset>
5231: </form>
1.383 tempelho 5232: FUFORM
1.329 droeschl 5233:
1.502 raeburn 5234: my $importpubform=(<<SEDFFORM);
1.514 raeburn 5235: <a class="LC_menubuttons_link" href="javascript:toggleMap('map');">
1.502 raeburn 5236: $lt{'impm'}</a>$help{'Load_Map'}
5237: <form action="/adm/coursedocs" method="post" name="mapimportform">
1.516 raeburn 5238: <fieldset id="importmapform" style="display: none;">
1.502 raeburn 5239: <legend>$lt{'impm'}</legend>
1.371 tempelho 5240: <input type="hidden" name="active" value="bb" />
1.502 raeburn 5241: $lt{'copm'}<br />
5242: <span class="LC_nobreak">
5243: <input type="text" name="importmap" size="40" value=""
5244: onfocus="this.blur();openbrowser('mapimportform','importmap','sequence,page','');" />
1.516 raeburn 5245: <a href="javascript:openbrowser('mapimportform','importmap','sequence,page','');">$lt{'selm'}</a></span><br />
1.502 raeburn 5246: <input type="submit" name="loadmap" value="$lt{'load'}" />
5247: </fieldset>
5248: </form>
5249:
1.383 tempelho 5250: SEDFFORM
1.502 raeburn 5251: my @importpubforma = (
1.508 raeburn 5252: { '<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 5253: { '<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.487 raeburn 5254: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{lnks}.'" onclick="javascript:open_StoredLinks_Import();" />' => "<a class='LC_menubuttons_link' href='javascript:open_StoredLinks_Import();'>$lt{'lnks'}</a>" },
1.514 raeburn 5255: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform }
1.383 tempelho 5256: );
1.502 raeburn 5257: $importpubform = &create_form_ul(&create_list_elements(@importpubforma));
1.510 raeburn 5258: my $extresourcesform =
5259: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
5260: $help{'Adding_External_Resource'});
1.598 raeburn 5261: my $exttoolform =
5262: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
5263: $help{'Adding_External_Tool'},undef,
5264: undef,'tool',$coursedom,$coursenum,
5265: \%ltitools);
1.329 droeschl 5266: if ($allowed) {
1.492 raeburn 5267: my $folder = $env{'form.folder'};
5268: if ($folder eq '') {
5269: $folder='default';
5270: }
1.538 raeburn 5271: my $output = &update_paste_buffer($coursenum,$coursedom,$folder);
5272: if ($output) {
5273: $r->print($output);
5274: }
1.337 ehlerst 5275: $r->print(<<HIDDENFORM);
5276: <form name="renameform" method="post" action="/adm/coursedocs">
5277: <input type="hidden" name="title" />
5278: <input type="hidden" name="cmd" />
5279: <input type="hidden" name="markcopy" />
5280: <input type="hidden" name="copyfolder" />
5281: $containertag
5282: </form>
1.484 raeburn 5283:
1.337 ehlerst 5284: HIDDENFORM
1.508 raeburn 5285: $r->print(&makesimpleeditform($pathitem)."\n".
5286: &makedocslogform($pathitem."\n".
1.484 raeburn 5287: '<input type="hidden" name="folder" value="'.
5288: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 5289: }
1.442 www 5290:
5291: # Generate the tabs
1.510 raeburn 5292: my ($mode,$needs_end);
1.472 raeburn 5293: if (($supplementalflag) && (!$allowed)) {
1.510 raeburn 5294: my @folders = split('&',$env{'form.folderpath'});
5295: unless (@folders > 2) {
5296: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
5297: $needs_end = 1;
5298: }
1.472 raeburn 5299: } else {
1.484 raeburn 5300: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.510 raeburn 5301: $needs_end = 1;
1.472 raeburn 5302: }
1.443 www 5303:
1.442 www 5304: #
5305:
5306: my $savefolderpath;
5307:
1.395 raeburn 5308: if ($allowed) {
1.329 droeschl 5309: my $folder=$env{'form.folder'};
1.443 www 5310: if ($folder eq '' || $supplementalflag) {
1.329 droeschl 5311: $folder='default';
1.356 tempelho 5312: $savefolderpath = $env{'form.folderpath'};
1.548 raeburn 5313: $env{'form.folderpath'}='default&'.&escape(&mt('Main Content'));
1.508 raeburn 5314: $pathitem = '<input type="hidden" name="folderpath" value="'.
1.329 droeschl 5315: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
5316: }
5317: my $postexec='';
5318: if ($folder eq 'default') {
1.372 bisitz 5319: $r->print('<script type="text/javascript">'."\n"
5320: .'// <![CDATA['."\n"
5321: .'this.window.name="loncapaclient";'."\n"
5322: .'// ]]>'."\n"
5323: .'</script>'."\n"
1.369 bisitz 5324: );
1.329 droeschl 5325: } else {
5326: #$postexec='self.close();';
5327: }
1.504 raeburn 5328: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
5329: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
1.329 droeschl 5330: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
5331:
5332: my $newnavform=(<<NNFORM);
5333: <form action="/adm/coursedocs" method="post" name="newnav">
1.570 raeburn 5334: <input type="hidden" name="active" value="ee" />
1.508 raeburn 5335: $pathitem
1.329 droeschl 5336: <input type="hidden" name="importdetail"
5337: value="$lt{'navc'}=/adm/navmaps" />
1.423 onken 5338: <a class="LC_menubuttons_link" href="javascript:document.newnav.submit()">$lt{'navc'}</a>
1.329 droeschl 5339: $help{'Navigate_Content'}
5340: </form>
5341: NNFORM
5342: my $newsmppageform=(<<NSPFORM);
5343: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.570 raeburn 5344: <input type="hidden" name="active" value="ee" />
1.508 raeburn 5345: $pathitem
1.329 droeschl 5346: <input type="hidden" name="importdetail" value="" />
1.423 onken 5347: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 5348: $help{'Simple Page'}
1.329 droeschl 5349: </form>
5350: NSPFORM
5351:
5352: my $newsmpproblemform=(<<NSPROBFORM);
5353: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371 tempelho 5354: <input type="hidden" name="active" value="cc" />
1.508 raeburn 5355: $pathitem
1.329 droeschl 5356: <input type="hidden" name="importdetail" value="" />
1.423 onken 5357: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.572 raeburn 5358: $help{'Simple_Problem'}
1.329 droeschl 5359: </form>
5360:
5361: NSPROBFORM
5362:
5363: my $newdropboxform=(<<NDBFORM);
5364: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.371 tempelho 5365: <input type="hidden" name="active" value="cc" />
1.508 raeburn 5366: $pathitem
1.329 droeschl 5367: <input type="hidden" name="importdetail" value="" />
1.423 onken 5368: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.554 raeburn 5369: $help{'Dropbox'}
1.344 bisitz 5370: </form>
1.329 droeschl 5371: NDBFORM
5372:
5373: my $newexuploadform=(<<NEXUFORM);
5374: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.371 tempelho 5375: <input type="hidden" name="active" value="cc" />
1.508 raeburn 5376: $pathitem
1.329 droeschl 5377: <input type="hidden" name="importdetail" value="" />
1.423 onken 5378: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 5379: $help{'Score_Upload_Form'}
5380: </form>
5381: NEXUFORM
5382:
5383: my $newbulform=(<<NBFORM);
5384: <form action="/adm/coursedocs" method="post" name="newbul">
1.570 raeburn 5385: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5386: $pathitem
1.329 droeschl 5387: <input type="hidden" name="importdetail" value="" />
1.423 onken 5388: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 5389: $help{'Bulletin Board'}
5390: </form>
5391: NBFORM
5392:
5393: my $newaboutmeform=(<<NAMFORM);
5394: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.570 raeburn 5395: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5396: $pathitem
1.329 droeschl 5397: <input type="hidden" name="importdetail"
5398: value="$plainname=/adm/$udom/$uname/aboutme" />
1.423 onken 5399: <a class="LC_menubuttons_link" href="javascript:document.newaboutme.submit()">$lt{'mypi'}</a>
1.347 weissno 5400: $help{'My Personal Information Page'}
1.329 droeschl 5401: </form>
5402: NAMFORM
5403:
5404: my $newaboutsomeoneform=(<<NASOFORM);
5405: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.570 raeburn 5406: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5407: $pathitem
1.329 droeschl 5408: <input type="hidden" name="importdetail" value="" />
1.423 onken 5409: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 5410: </form>
5411: NASOFORM
5412:
5413: my $newrosterform=(<<NROSTFORM);
5414: <form action="/adm/coursedocs" method="post" name="newroster">
1.570 raeburn 5415: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5416: $pathitem
1.329 droeschl 5417: <input type="hidden" name="importdetail"
5418: value="$lt{'rost'}=/adm/viewclasslist" />
1.423 onken 5419: <a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a>
1.556 raeburn 5420: $help{'Course_Roster'}
1.329 droeschl 5421: </form>
5422: NROSTFORM
5423:
1.534 raeburn 5424: my $newwebpage;
5425: if ($folder =~ /^default_?(\d*)$/) {
5426: $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
5427: if ($1) {
5428: $newwebpage .= $1;
5429: } else {
5430: $newwebpage .= 'default';
5431: }
5432: $newwebpage .= '/new.html';
5433: }
5434: my $newwebpageform =(<<NWEBFORM);
5435: <form action="/adm/coursedocs" method="post" name="newwebpage">
1.570 raeburn 5436: <input type="hidden" name="active" value="ee" />
1.534 raeburn 5437: $pathitem
5438: <input type="hidden" name="importdetail" value="$newwebpage" />
5439: <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
1.556 raeburn 5440: $help{'Web_Page'}
1.534 raeburn 5441: </form>
5442: NWEBFORM
5443:
5444:
1.342 ehlerst 5445: my $specialdocumentsform;
1.383 tempelho 5446: my @specialdocumentsforma;
1.451 www 5447: my $gradingform;
5448: my @gradingforma;
5449: my $communityform;
5450: my @communityforma;
1.351 ehlerst 5451: my $newfolderform;
1.390 tempelho 5452: my $newfolderb;
1.342 ehlerst 5453:
1.451 www 5454: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 5455:
1.329 droeschl 5456: my $newpageform=(<<NPFORM);
5457: <form action="/adm/coursedocs" method="post" name="newpage">
5458: <input type="hidden" name="folderpath" value="$path" />
5459: <input type="hidden" name="importdetail" value="" />
1.570 raeburn 5460: <input type="hidden" name="active" value="ee" />
1.423 onken 5461: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 5462: $help{'Adding_Pages'}
1.329 droeschl 5463: </form>
5464: NPFORM
1.390 tempelho 5465:
5466:
1.351 ehlerst 5467: $newfolderform=(<<NFFORM);
1.329 droeschl 5468: <form action="/adm/coursedocs" method="post" name="newfolder">
1.508 raeburn 5469: $pathitem
1.329 droeschl 5470: <input type="hidden" name="importdetail" value="" />
1.570 raeburn 5471: <input type="hidden" name="active" value="" />
1.422 onken 5472: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 5473: </form>
5474: NFFORM
5475:
5476: my $newsylform=(<<NSYLFORM);
5477: <form action="/adm/coursedocs" method="post" name="newsyl">
1.570 raeburn 5478: <input type="hidden" name="active" value="ee" />
1.508 raeburn 5479: $pathitem
1.329 droeschl 5480: <input type="hidden" name="importdetail"
5481: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.423 onken 5482: <a class="LC_menubuttons_link" href="javascript:document.newsyl.submit()">$lt{'syll'}</a>
1.329 droeschl 5483: $help{'Syllabus'}
1.383 tempelho 5484:
1.329 droeschl 5485: </form>
5486: NSYLFORM
1.364 bisitz 5487:
1.329 droeschl 5488: my $newgroupfileform=(<<NGFFORM);
5489: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.570 raeburn 5490: <input type="hidden" name="active" value="dd" />
1.508 raeburn 5491: $pathitem
1.329 droeschl 5492: <input type="hidden" name="importdetail"
5493: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.423 onken 5494: <a class="LC_menubuttons_link" href="javascript:document.newgroupfiles.submit()">$lt{'grpo'}</a>
1.353 weissno 5495: $help{'Group Portfolio'}
1.329 droeschl 5496: </form>
5497: NGFFORM
1.383 tempelho 5498: @specialdocumentsforma=(
1.421 onken 5499: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/page.png" alt="'.$lt{newp}.'" onclick="javascript:makenewpage(document.newpage,\''.$pageseq.'\');" />'=>$newpageform},
1.417 droeschl 5500: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.newsyl.submit()" />'=>$newsylform},
1.451 www 5501: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="document.newnav.submit()" />'=>$newnavform},
5502: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
1.534 raeburn 5503: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
1.451 www 5504: );
5505: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
5506:
1.434 raeburn 5507:
5508: my @importdoc = (
1.519 raeburn 5509: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform}
5510: );
1.598 raeburn 5511: if (keys(%ltitools)) {
5512: push(@importdoc,
5513: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extt}.'" onclick="toggleUpload(\'tool\');" />'=>$exttoolform},
5514: );
5515: }
1.519 raeburn 5516: unless ($container eq 'page') {
5517: push(@importdoc,
5518: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform}
5519: );
5520: }
5521: push(@importdoc,
1.558 raeburn 5522: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'doc\');" />'=>$fileuploadform}
1.519 raeburn 5523: );
1.501 raeburn 5524: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
1.434 raeburn 5525:
1.451 www 5526: @gradingforma=(
5527: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
5528: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
5529: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
5530:
5531: );
5532: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
5533:
5534: @communityforma=(
5535: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
5536: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
5537: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
5538: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="document.newroster.submit()" />'=>$newrosterform},
5539: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="document.newgroupfiles.submit()" />'=>$newgroupfileform},
5540: );
5541: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 5542:
1.330 tempelho 5543: my %orderhash = (
1.553 raeburn 5544: 'aa' => ['Upload',$fileuploadform],
5545: 'bb' => ['Import',$importpubform],
5546: 'cc' => ['Grading',$gradingform],
1.330 tempelho 5547: );
1.519 raeburn 5548: unless ($container eq 'page') {
1.434 raeburn 5549: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.484 raeburn 5550: $orderhash{'dd'} = ['Collaboration',$communityform];
1.553 raeburn 5551: $orderhash{'ee'} = ['Other',$specialdocumentsform];
1.434 raeburn 5552: }
5553:
1.341 ehlerst 5554: $hadchanges=0;
1.484 raeburn 5555: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 5556: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.598 raeburn 5557: $supplementalflag,\%orderhash,$iconpath,$pathitem,\%ltitools);
1.443 www 5558: if ($error) {
5559: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
5560: }
5561: if ($hadchanges) {
5562: &mark_hash_old();
5563: }
1.341 ehlerst 5564:
1.443 www 5565: &changewarning($r,'');
5566: }
1.458 raeburn 5567: }
1.442 www 5568:
1.443 www 5569: # Supplemental documents start here
5570:
1.329 droeschl 5571: my $folder=$env{'form.folder'};
1.443 www 5572: unless ($supplementalflag) {
1.329 droeschl 5573: $folder='supplemental';
5574: }
5575: if ($folder =~ /^supplemental$/ &&
5576: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 5577: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 5578: } elsif ($allowed) {
1.356 tempelho 5579: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 5580: }
1.508 raeburn 5581: $pathitem = '<input type="hidden" name="folderpath" value="'.
5582: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.329 droeschl 5583: if ($allowed) {
5584: my $folderseq=
1.504 raeburn 5585: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
1.329 droeschl 5586:
5587: my $supupdocform=(<<SUPDOCFORM);
1.501 raeburn 5588: <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
5589: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
1.383 tempelho 5590: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.516 raeburn 5591: <fieldset id="uploadsuppdocform" style="display: none;">
1.501 raeburn 5592: <legend>$lt{'upfi'}</legend>
1.371 tempelho 5593: <input type="hidden" name="active" value="ee" />
1.329 droeschl 5594: $fileupload
5595: <br />
5596: <br />
5597: <span class="LC_nobreak">
5598: $checkbox
5599: </span>
5600: <br /><br />
5601: $lt{'comment'}:<br />
1.383 tempelho 5602: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 5603: <br />
1.508 raeburn 5604: $pathitem
1.329 droeschl 5605: <input type="hidden" name="cmd" value="upload_supplemental" />
1.501 raeburn 5606: <input type='submit' value="$lt{'upld'}" />
5607: </form>
1.329 droeschl 5608: SUPDOCFORM
5609:
5610: my $supnewfolderform=(<<SNFFORM);
5611: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.570 raeburn 5612: <input type="hidden" name="active" value="" />
1.508 raeburn 5613: $pathitem
1.329 droeschl 5614: <input type="hidden" name="importdetail" value="" />
1.423 onken 5615: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 5616: $help{'Adding_Folders'}
1.329 droeschl 5617: </form>
5618: SNFFORM
1.383 tempelho 5619:
1.510 raeburn 5620: my $supextform =
5621: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
5622: $help{'Adding_External_Resource'});
1.329 droeschl 5623:
1.598 raeburn 5624: my $supexttoolform =
5625: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
5626: $help{'Adding_External_Tool'},
5627: undef,undef,'tool',$coursedom,
5628: $coursenum,\%ltitools);
5629:
1.329 droeschl 5630: my $supnewsylform=(<<SNSFORM);
5631: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 5632: <input type="hidden" name="active" value="ff" />
1.508 raeburn 5633: $pathitem
1.329 droeschl 5634: <input type="hidden" name="importdetail"
5635: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.423 onken 5636: <a class="LC_menubuttons_link" href="javascript:document.supnewsyl.submit()">$lt{'syll'}</a>
1.329 droeschl 5637: $help{'Syllabus'}
5638: </form>
5639: SNSFORM
5640:
5641: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 5642: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 5643: <input type="hidden" name="active" value="ff" />
1.508 raeburn 5644: $pathitem
1.329 droeschl 5645: <input type="hidden" name="importdetail"
5646: value="$plainname=/adm/$udom/$uname/aboutme" />
1.423 onken 5647: <a class="LC_menubuttons_link" href="javascript:document.supnewaboutme.submit()">$lt{'mypi'}</a>
1.347 weissno 5648: $help{'My Personal Information Page'}
1.329 droeschl 5649: </form>
5650: SNAMFORM
5651:
1.534 raeburn 5652: my $supwebpage;
5653: if ($folder =~ /^supplemental_?(\d*)$/) {
5654: $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
5655: if ($1) {
5656: $supwebpage .= $1;
5657: } else {
5658: $supwebpage .= 'default';
5659: }
5660: $supwebpage .= '/new.html';
5661: }
5662: my $supwebpageform =(<<SWEBFORM);
5663: <form action="/adm/coursedocs" method="post" name="supwebpage">
5664: <input type="hidden" name="active" value="cc" />
5665: $pathitem
5666: <input type="hidden" name="importdetail" value="$supwebpage" />
5667: <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
1.556 raeburn 5668: $help{'Web_Page'}
1.534 raeburn 5669: </form>
5670: SWEBFORM
5671:
1.333 muellerd 5672:
1.383 tempelho 5673: my @specialdocs = (
1.417 droeschl 5674: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.supnewsyl.submit()" />'
5675: =>$supnewsylform},
5676: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="document.supnewaboutme.submit()" />'
5677: =>$supnewaboutmeform},
1.534 raeburn 5678: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
5679:
1.383 tempelho 5680: );
1.417 droeschl 5681: my @supimportdoc = (
1.515 raeburn 5682: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleUpload(\'suppext\')" />'
1.598 raeburn 5683: =>$supextform});
5684: if (keys(%ltitools)) {
5685: push(@supimportdoc,
5686: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extt}.'" onclick="javascript:toggleUpload(\'supptool\')" />'
5687: =>$supexttoolform});
5688: }
5689: push(@supimportdoc,
5690: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
1.501 raeburn 5691: =>$supupdocform},
1.598 raeburn 5692: );
1.501 raeburn 5693:
5694: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
1.333 muellerd 5695: my %suporderhash = (
1.390 tempelho 5696: '00' => ['Supnewfolder', $supnewfolderform],
1.553 raeburn 5697: 'ee' => ['Upload',$supupdocform],
5698: 'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 5699: );
1.443 www 5700: if ($supplementalflag) {
1.458 raeburn 5701: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.598 raeburn 5702: $supplementalflag,\%suporderhash,$iconpath,$pathitem,\%ltitools);
1.443 www 5703: if ($error) {
5704: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.557 raeburn 5705: } else {
5706: if ($suppchanges) {
5707: my %servers = &Apache::lonnet::internet_dom_servers($coursedom);
5708: my @ids=&Apache::lonnet::current_machine_ids();
5709: foreach my $server (keys(%servers)) {
5710: next if (grep(/^\Q$server\E$/,@ids));
5711: my $hashid=$coursenum.':'.$coursedom;
1.566 raeburn 5712: my $cachekey = &escape('suppcount').':'.&escape($hashid);
5713: &Apache::lonnet::remote_devalidate_cache($server,[$cachekey]);
1.557 raeburn 5714: }
5715: &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1);
5716: undef($suppchanges);
5717: }
5718: }
1.393 raeburn 5719: }
1.443 www 5720: } elsif ($supplementalflag) {
1.458 raeburn 5721: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.508 raeburn 5722: $supplementalflag,'',$iconpath,$pathitem);
1.393 raeburn 5723: if ($error) {
5724: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 5725: }
1.393 raeburn 5726: }
1.389 tempelho 5727:
1.510 raeburn 5728: if ($needs_end) {
5729: $r->print(&endContentScreen());
5730: }
1.383 tempelho 5731:
1.329 droeschl 5732: if ($allowed) {
5733: $r->print('
5734: <form method="post" name="extimport" action="/adm/coursedocs">
5735: <input type="hidden" name="title" />
5736: <input type="hidden" name="url" />
5737: <input type="hidden" name="useform" />
5738: <input type="hidden" name="residx" />
5739: </form>');
5740: }
1.484 raeburn 5741: } elsif ($showdoc) {
1.329 droeschl 5742: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 5743: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.498 bisitz 5744: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 5745: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 5746: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 5747: }
5748: }
5749: $r->print(&Apache::loncommon::end_page());
5750: return OK;
1.364 bisitz 5751: }
1.329 droeschl 5752:
1.440 raeburn 5753: sub embedded_form_elems {
5754: my ($phase,$primaryurl,$newidx) = @_;
5755: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
5756: return <<STATE;
5757: <input type="hidden" name="folderpath" value="$folderpath" />
5758: <input type="hidden" name="cmd" value="upload_embedded" />
5759: <input type="hidden" name="newidx" value="$newidx" />
5760: <input type="hidden" name="phase" value="$phase" />
5761: <input type="hidden" name="primaryurl" value="$primaryurl" />
5762: STATE
5763: }
5764:
5765: sub embedded_destination {
5766: my $folder=$env{'form.folder'};
5767: my $destination = 'docs/';
5768: if ($folder =~ /^supplemental/) {
5769: $destination = 'supplemental/';
5770: }
5771: if (($folder eq 'default') || ($folder eq 'supplemental')) {
5772: $destination .= 'default/';
5773: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
5774: $destination .= $2.'/';
5775: }
5776: $destination .= $env{'form.newidx'};
5777: my $dir_root = '/userfiles';
5778: return ($destination,$dir_root);
5779: }
5780:
5781: sub return_to_editor {
5782: my $actionurl = '/adm/coursedocs';
5783: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
5784: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
5785: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
5786: '</a></p>';
5787: }
5788:
1.476 raeburn 5789: sub decompression_info {
5790: my ($destination,$dir_root) = &embedded_destination();
5791: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
5792: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
5793: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
5794: my $container='sequence';
1.480 raeburn 5795: my ($pathitem,$hiddenelem);
1.583 raeburn 5796: my @hiddens = ('newidx','comment','position','folderpath','archiveurl');
1.519 raeburn 5797: if ($env{'form.folderpath'} =~ /\:1$/) {
1.476 raeburn 5798: $container='page';
5799: }
1.480 raeburn 5800: unshift(@hiddens,$pathitem);
5801: foreach my $item (@hiddens) {
5802: if ($env{'form.'.$item}) {
5803: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
1.583 raeburn 5804: &HTML::Entities::encode($env{'form.'.$item},'<>&"').'" />'."\n";
1.480 raeburn 5805: }
1.477 raeburn 5806: }
1.476 raeburn 5807: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
5808: $hiddenelem);
5809: }
5810:
5811: sub decompression_phase_one {
5812: my ($dir,$file,$warning,$error,$output);
5813: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
5814: &decompression_info();
1.490 raeburn 5815: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 5816: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
5817: } else {
5818: my $file = $1;
1.481 raeburn 5819: $output =
5820: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
5821: $destination,$dir_root,
5822: $hiddenelem);
5823: if ($env{'form.autoextract_camtasia'}) {
5824: $output .= &remove_archive($docudom,$docuname,$container);
5825: }
1.476 raeburn 5826: }
5827: if ($error) {
5828: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
5829: $error.'</p>'."\n";
5830: }
5831: if ($warning) {
5832: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
5833: }
5834: return $output;
5835: }
5836:
5837: sub decompression_phase_two {
5838: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
5839: &decompression_info();
1.481 raeburn 5840: my $output;
1.480 raeburn 5841: if ($env{'form.archivedelete'}) {
1.481 raeburn 5842: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 5843: }
5844: $output .=
1.481 raeburn 5845: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 5846: $destination,$dir_root,$hiddenelem);
5847: return $output;
5848: }
5849:
1.480 raeburn 5850: sub remove_archive {
5851: my ($docudom,$docuname,$container) = @_;
5852: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 5853: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 5854: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
5855: if ($fatal) {
5856: if ($container eq 'page') {
5857: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
5858: } else {
5859: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
5860: }
1.583 raeburn 5861: $delwarning .= ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 5862: } else {
5863: my $currcmd = $env{'form.cmd'};
5864: my $position = $env{'form.position'};
1.583 raeburn 5865: my $archiveidx = $position;
1.563 raeburn 5866: if ($position > 0) {
1.583 raeburn 5867: if (($env{'form.autoextract_camtasia'}) && (scalar(@LONCAPA::map::order) == 2)) {
5868: $archiveidx = $position-1;
5869: }
5870: $env{'form.cmd'} = 'remove_'.$archiveidx;
1.584 raeburn 5871: my ($title,$url,@rrest) =
1.583 raeburn 5872: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$archiveidx]]);
5873: if ($url eq $env{'form.archiveurl'}) {
5874: if (&handle_edit_cmd($docuname,$docudom)) {
5875: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
5876: if ($fatal) {
5877: if ($container eq 'page') {
5878: $delwarning = &mt('An error occurred updating the contents of the current page.');
5879: } else {
5880: $delwarning = &mt('An error occurred updating the contents of the current folder.');
5881: }
1.480 raeburn 5882: } else {
1.583 raeburn 5883: $delresult = &mt('Archive file removed.');
1.480 raeburn 5884: }
5885: }
1.583 raeburn 5886: } else {
5887: $delwarning .= &mt('Archive file had unexpected item number in folder.').
5888: ' '.&mt('As a result the archive file has not been removed.');
1.480 raeburn 5889: }
5890: }
5891: $env{'form.cmd'} = $currcmd;
5892: }
5893: if ($delwarning) {
5894: $output = '<p class="LC_warning">'.
5895: $delwarning.
5896: '</p>';
5897: }
5898: if ($delresult) {
5899: $output .= '<p class="LC_info">'.
5900: $delresult.
5901: '</p>';
5902: }
1.481 raeburn 5903: return $output;
1.480 raeburn 5904: }
5905:
1.484 raeburn 5906: sub generate_admin_menu {
5907: my ($crstype) = @_;
5908: my $lc_crstype = lc($crstype);
5909: my ($home,$other,%outhash)=&authorhosts();
1.562 bisitz 5910: my %lt= ( # do not translate here
1.484 raeburn 5911: 'vc' => 'Verify Content',
5912: 'cv' => 'Check/Set Resource Versions',
5913: 'ls' => 'List Resource Identifiers',
5914: 'imse' => 'Export contents to IMS Archive',
1.568 raeburn 5915: 'dcd' => "Copy $crstype Content to Authoring Space",
1.562 bisitz 5916: );
1.484 raeburn 5917: my ($candump,$dumpurl);
5918: if ($home + $other > 0) {
5919: $candump = 'F';
5920: if ($home) {
5921: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
5922: } else {
5923: my @hosts;
5924: foreach my $aurole (keys(%outhash)) {
5925: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
5926: push(@hosts,$outhash{$aurole});
1.538 raeburn 5927: }
1.484 raeburn 5928: }
5929: if (@hosts == 1) {
5930: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
5931: '&role='.
5932: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
5933: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
5934: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
5935: } else {
5936: $dumpurl = "javascript:choose_switchserver_window()";
5937: }
5938: }
5939: }
5940: my @menu=
5941: ({ categorytitle=>'Administration',
5942: items =>[
5943: { linktext => $lt{'vc'},
5944: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
5945: permission => 'F',
1.571 raeburn 5946: help => 'Docs_Verify_Content',
1.484 raeburn 5947: icon => 'verify.png',
5948: linktitle => 'Verify contents can be retrieved/rendered',
5949: },
5950: { linktext => $lt{'cv'},
5951: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
5952: permission => 'F',
1.571 raeburn 5953: help => 'Docs_Check_Resource_Versions',
1.484 raeburn 5954: icon => 'resversion.png',
5955: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
5956: },
5957: { linktext => $lt{'ls'},
5958: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
5959: permission => 'F',
5960: #help => '',
5961: icon => 'symbs.png',
5962: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
5963: },
5964: ]
5965: },
5966: { categorytitle=>'Export',
5967: items =>[
5968: { linktext => $lt{'imse'},
5969: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
5970: permission => 'F',
5971: help => 'Docs_Export_Course_Docs',
5972: icon => 'imsexport.png',
5973: linktitle => $lt{'imse'},
5974: },
5975: { linktext => $lt{'dcd'},
5976: url => $dumpurl,
5977: permission => $candump,
1.571 raeburn 5978: help => 'Docs_Dump_Course_Docs',
1.484 raeburn 5979: icon => 'dump.png',
5980: linktitle => $lt{'dcd'},
5981: },
5982: ]
5983: });
5984: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
5985: '<input type="hidden" id="dummy" />'."\n".
5986: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
5987: '</form>';
1.329 droeschl 5988: }
5989:
5990: sub generate_edit_table {
1.538 raeburn 5991: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile,
5992: $need_save,$copyfolder) = @_;
1.406 raeburn 5993: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 5994: my %orderhash = %{$orderhash_ref};
1.344 bisitz 5995: my $form;
1.371 tempelho 5996: my $activetab;
5997: my $active;
1.570 raeburn 5998: if (($env{'form.active'} ne '') && ($env{'form.active'} ne '00')) {
1.371 tempelho 5999: $activetab = $env{'form.active'};
6000: }
1.472 raeburn 6001: my $backicon = $iconpath.'clickhere.gif';
1.525 raeburn 6002: my $backtext = &mt('Exit Editor');
1.458 raeburn 6003: $form = '<div class="LC_Box" style="margin:0;">'.
1.488 raeburn 6004: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
6005: '<li class="goback">'.
1.546 raeburn 6006: '<a href="javascript:toContents('."'$jumpto'".');">'.
1.488 raeburn 6007: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
6008: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
6009: '<li>'.
6010: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
6011: &mt('Undo Delete').'</a></li>'."\n";
6012: if ($env{'form.docslog'}) {
6013: $form .= '<li class="active">';
6014: } else {
6015: $form .= '<li>';
6016: }
6017: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
6018: &mt('History').'</a></li>'."\n";
6019: if ($env{'form.docslog'}) {
6020: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
6021: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 6022: }
1.458 raeburn 6023: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 6024: if($name ne '00'){
1.371 tempelho 6025: if($activetab eq '' || $activetab ne $name){
6026: $active = '';
6027: }elsif($activetab eq $name){
6028: $active = 'class="active"';
6029: }
1.458 raeburn 6030: $form .= '<li style="float:right" '.$active
1.484 raeburn 6031: .' 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 6032: } else {
1.570 raeburn 6033: $form .= '<li style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 6034:
6035: }
1.329 droeschl 6036: }
1.484 raeburn 6037: $form .= '</ul>'."\n";
6038: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 6039:
6040: if ($to_show ne '') {
1.538 raeburn 6041: my $saveform;
6042: if ($need_save) {
6043: my $button = &mt('Make changes');
6044: my $path;
6045: if ($env{'form.folderpath'}) {
6046: $path =
6047: &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
6048: }
6049: $saveform = <<"END";
6050: <div id="multisave" style="display:none; clear:both;" >
6051: <form name="saveactions" method="post" action="/adm/coursedocs" onsubmit="return checkSubmits();">
6052: <input type="hidden" name="folderpath" value="$path" />
6053: <input type="hidden" name="symb" value="$env{'form.symb'}" />
6054: <input type="hidden" name="allhiddenresource" value="" />
6055: <input type="hidden" name="allencrypturl" value="" />
6056: <input type="hidden" name="allrandompick" value="" />
6057: <input type="hidden" name="allrandomorder" value="" />
6058: <input type="hidden" name="changeparms" value="" />
6059: <input type="hidden" name="multiremove" value="" />
6060: <input type="hidden" name="multicut" value="" />
6061: <input type="hidden" name="multicopy" value="" />
6062: <input type="hidden" name="multichange" value="" />
6063: <input type="hidden" name="copyfolder" value="$copyfolder" />
6064: <input type="submit" name="savemultiples" value="$button" />
6065: </form>
6066: </div>
6067: END
6068: }
6069: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'.$saveform."\n";
1.458 raeburn 6070: }
1.363 ehlerst 6071: foreach my $field (keys(%orderhash)){
1.390 tempelho 6072: if($field ne '00'){
1.422 onken 6073: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 6074: $active = 'style="display: none;float:left"';
1.422 onken 6075: }elsif($activetab eq $field){
1.458 raeburn 6076: $active = 'style="display:block;float:left"';
1.422 onken 6077: }
6078: $form .= '<div id="'.$field.$tid.'"'
6079: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 6080: .'</div>'."\n";
1.363 ehlerst 6081: }
6082: }
1.484 raeburn 6083: unless ($env{'form.docslog'}) {
6084: $form .= '</div></div>'."\n";
6085: }
1.329 droeschl 6086: return $form;
6087: }
6088:
6089: sub editing_js {
1.472 raeburn 6090: my ($udom,$uname,$supplementalflag) = @_;
1.594 damieng 6091: my %js_lt = &Apache::lonlocal::texthash(
1.329 droeschl 6092: p_mnf => 'Name of New Folder',
6093: t_mnf => 'New Folder',
6094: p_mnp => 'Name of New Page',
6095: t_mnp => 'New Page',
1.451 www 6096: p_mxu => 'Title for the External Score',
1.349 biermanm 6097: p_msp => 'Name of Simple Course Page',
1.329 droeschl 6098: p_msb => 'Title for the Problem',
6099: p_mdb => 'Title for the Drop Box',
1.336 schafran 6100: p_mbb => 'Title for the Discussion Board',
1.534 raeburn 6101: p_mwp => 'Title for Web Page',
1.348 weissno 6102: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 6103: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 6104: p_mab_alrt1 => 'Not a valid user:domain',
6105: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
6106: p_chn => 'New Title',
6107: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
6108: p_rmr2a => 'Remove[_99]',
6109: p_rmr2b => '?[_99]',
1.542 raeburn 6110: p_rmr3a => 'Remove those [_2]',
6111: p_rmr3b => 'items?[_2]',
1.329 droeschl 6112: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
6113: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
6114: p_ctr2a => 'Cut[_98]',
1.478 raeburn 6115: p_ctr2b => '?[_98]',
1.542 raeburn 6116: p_ctr3a => 'Cut those[_2]',
6117: p_ctr3b => 'items?[_2]',
1.478 raeburn 6118: rpck => 'Enter number to pick (e.g., 3)',
1.501 raeburn 6119: imsfile => 'You must choose an IMS package for import',
6120: imscms => 'You must select which Course Management System was the source of the IMS package',
6121: invurl => 'Invalid URL',
6122: titbl => 'Title is blank',
1.538 raeburn 6123: more => '(More ...)',
6124: less => '(Less ...)',
1.543 raeburn 6125: noor => 'No actions selected or changes to settings specified.',
6126: noch => 'No changes to settings specified.',
6127: noac => 'No actions selected.',
1.329 droeschl 6128: );
1.594 damieng 6129: &js_escape(\%js_lt);
1.433 raeburn 6130: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 6131: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
6132: my $main_container_page;
1.519 raeburn 6133: if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) {
6134: $main_container_page = 1;
1.434 raeburn 6135: }
1.538 raeburn 6136: my $toplevelmain =
1.548 raeburn 6137: &escape(&mt('Main Content').':::::');
1.446 www 6138: my $toplevelsupp = &supplemental_base();
1.433 raeburn 6139:
1.525 raeburn 6140: my $backtourl;
1.530 raeburn 6141: if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
6142: my $caller = $1;
1.525 raeburn 6143: if ($caller =~ /^supplemental/) {
6144: $backtourl = '/adm/supplemental?folderpath='.&escape($caller);
6145: } else {
6146: my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
6147: $res = &Apache::lonnet::clutter($res);
6148: if (&Apache::lonnet::is_on_map($res)) {
6149: $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($res),'<>&"').'?symb='.
6150: &HTML::Entities::encode($caller,'<>&"');
1.590 raeburn 6151: $backtourl = &Apache::loncommon::escape_single($backtourl);
1.544 raeburn 6152: } else {
6153: $backtourl = '/adm/navmaps';
1.525 raeburn 6154: }
6155: }
6156: } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
6157: $backtourl = '/adm/menu';
6158: } elsif ($supplementalflag) {
1.472 raeburn 6159: $backtourl = '/adm/supplemental';
1.525 raeburn 6160: } else {
6161: $backtourl = '/adm/navmaps';
1.472 raeburn 6162: }
6163:
1.598 raeburn 6164: my $fieldsets = "'ext','tool','doc'";
1.519 raeburn 6165: unless ($main_container_page) {
6166: $fieldsets .=",'ims'";
6167: }
1.501 raeburn 6168: if ($supplementalflag) {
1.598 raeburn 6169: $fieldsets = "'suppext','supptool','suppdoc'";
1.501 raeburn 6170: }
6171:
1.329 droeschl 6172: return <<ENDNEWSCRIPT;
6173: function makenewfolder(targetform,folderseq) {
1.594 damieng 6174: var foldername=prompt('$js_lt{"p_mnf"}','$js_lt{"t_mnf"}');
1.329 droeschl 6175: if (foldername) {
6176: targetform.importdetail.value=escape(foldername)+"="+folderseq;
6177: targetform.submit();
6178: }
6179: }
6180:
6181: function makenewpage(targetform,folderseq) {
1.594 damieng 6182: var pagename=prompt('$js_lt{"p_mnp"}','$js_lt{"t_mnp"}');
1.329 droeschl 6183: if (pagename) {
6184: targetform.importdetail.value=escape(pagename)+"="+folderseq;
6185: targetform.submit();
6186: }
6187: }
6188:
6189: function makeexamupload() {
1.594 damieng 6190: var title=prompt('$js_lt{"p_mxu"}');
1.344 bisitz 6191: if (title) {
1.329 droeschl 6192: this.document.forms.newexamupload.importdetail.value=
6193: escape(title)+'=/res/lib/templates/examupload.problem';
6194: this.document.forms.newexamupload.submit();
6195: }
6196: }
6197:
6198: function makesmppage() {
1.594 damieng 6199: var title=prompt('$js_lt{"p_msp"}');
1.344 bisitz 6200: if (title) {
1.329 droeschl 6201: this.document.forms.newsmppg.importdetail.value=
1.533 raeburn 6202: escape(title)+'=/adm/$udom/$uname/new/smppg';
1.329 droeschl 6203: this.document.forms.newsmppg.submit();
6204: }
6205: }
6206:
1.534 raeburn 6207: function makewebpage(type) {
1.594 damieng 6208: var title=prompt('$js_lt{"p_mwp"}');
1.534 raeburn 6209: var formname;
6210: if (type == 'supp') {
6211: formname = this.document.forms.supwebpage;
6212: } else {
6213: formname = this.document.forms.newwebpage;
6214: }
6215: if (title) {
6216: var webpage = formname.importdetail.value;
6217: formname.importdetail.value = escape(title)+'='+webpage;
6218: formname.submit();
6219: }
6220: }
6221:
1.329 droeschl 6222: function makesmpproblem() {
1.594 damieng 6223: var title=prompt('$js_lt{"p_msb"}');
1.344 bisitz 6224: if (title) {
1.329 droeschl 6225: this.document.forms.newsmpproblem.importdetail.value=
6226: escape(title)+'=/res/lib/templates/simpleproblem.problem';
6227: this.document.forms.newsmpproblem.submit();
6228: }
6229: }
6230:
6231: function makedropbox() {
1.594 damieng 6232: var title=prompt('$js_lt{"p_mdb"}');
1.344 bisitz 6233: if (title) {
1.329 droeschl 6234: this.document.forms.newdropbox.importdetail.value=
6235: escape(title)+'=/res/lib/templates/DropBox.problem';
6236: this.document.forms.newdropbox.submit();
6237: }
6238: }
6239:
6240: function makebulboard() {
1.594 damieng 6241: var title=prompt('$js_lt{"p_mbb"}');
1.329 droeschl 6242: if (title) {
6243: this.document.forms.newbul.importdetail.value=
1.533 raeburn 6244: escape(title)+'=/adm/$udom/$uname/new/bulletinboard';
1.329 droeschl 6245: this.document.forms.newbul.submit();
6246: }
6247: }
6248:
6249: function makeabout() {
1.594 damieng 6250: var user=prompt("$js_lt{'p_mab'}");
1.329 droeschl 6251: if (user) {
6252: var comp=new Array();
6253: comp=user.split(':');
6254: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
6255: if ((comp[0]) && (comp[1])) {
6256: this.document.forms.newaboutsomeone.importdetail.value=
1.594 damieng 6257: '$js_lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.335 ehlerst 6258: this.document.forms.newaboutsomeone.submit();
6259: } else {
1.594 damieng 6260: alert("$js_lt{'p_mab_alrt1'}");
1.329 droeschl 6261: }
1.335 ehlerst 6262: } else {
1.594 damieng 6263: alert("$js_lt{'p_mab_alrt2'}");
1.335 ehlerst 6264: }
6265: }
1.329 droeschl 6266: }
6267:
1.501 raeburn 6268: function toggleUpload(caller) {
6269: var blocks = Array($fieldsets);
6270: for (var i=0; i<blocks.length; i++) {
6271: var disp = 'none';
6272: if (caller == blocks[i]) {
6273: var curr = document.getElementById('upload'+caller+'form').style.display;
6274: if (curr == 'none') {
6275: disp='block';
6276: }
6277: }
6278: document.getElementById('upload'+blocks[i]+'form').style.display=disp;
1.598 raeburn 6279: if ((caller == 'tool') || (caller == 'supptool')) {
6280: if (disp == 'block') {
6281: if (document.getElementById('LC_exttoolid')) {
6282: var toolselector = document.getElementById('LC_exttoolid');
6283: var suppflag = 0;
6284: if (caller == 'supptool') {
6285: suppflag = 1;
6286: }
6287: currForm = document.getElementById('new'+caller);
6288: updateExttool(toolselector,currForm,suppflag);
6289: }
6290: }
6291: }
1.501 raeburn 6292: }
1.502 raeburn 6293: resize_scrollbox('contentscroll','1','1');
6294: return;
6295: }
6296:
1.514 raeburn 6297: function toggleMap(caller) {
1.502 raeburn 6298: var disp = 'none';
1.510 raeburn 6299: if (document.getElementById('importmapform')) {
1.514 raeburn 6300: if (caller == 'map') {
6301: var curr = document.getElementById('importmapform').style.display;
6302: if (curr == 'none') {
6303: disp='block';
6304: }
1.510 raeburn 6305: }
6306: document.getElementById('importmapform').style.display=disp;
6307: resize_scrollbox('contentscroll','1','1');
1.502 raeburn 6308: }
1.501 raeburn 6309: return;
1.329 droeschl 6310: }
6311:
1.501 raeburn 6312: function makeims(imsform) {
6313: if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
1.594 damieng 6314: alert("$js_lt{'imsfile'}");
1.501 raeburn 6315: return;
6316: }
6317: if (imsform.source.selectedIndex == 0) {
1.594 damieng 6318: alert("$js_lt{'imscms'}");
1.501 raeburn 6319: return;
6320: }
6321: newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
6322: imsform.submit();
6323: }
6324:
1.519 raeburn 6325: function changename(folderpath,index,oldtitle) {
1.594 damieng 6326: var title=prompt('$js_lt{"p_chn"}',oldtitle);
1.335 ehlerst 6327: if (title) {
1.538 raeburn 6328: this.document.forms.renameform.markcopy.value='';
1.335 ehlerst 6329: this.document.forms.renameform.title.value=title;
6330: this.document.forms.renameform.cmd.value='rename_'+index;
1.519 raeburn 6331: this.document.forms.renameform.folderpath.value=folderpath;
1.335 ehlerst 6332: this.document.forms.renameform.submit();
6333: }
1.329 droeschl 6334: }
6335:
1.478 raeburn 6336: function updatePick(targetform,index,caller) {
1.537 raeburn 6337: var pickitem;
6338: var picknumitem;
6339: var picknumtext;
6340: if (index == 'all') {
6341: pickitem = document.getElementById('randompickall');
6342: picknumitem = document.getElementById('rpicknumall');
6343: picknumtext = document.getElementById('rpicktextall');
6344: } else {
6345: pickitem = document.getElementById('randompick_'+index);
6346: picknumitem = document.getElementById('rpicknum_'+index);
6347: picknumtext = document.getElementById('randompicknum_'+index);
6348: }
1.478 raeburn 6349: if (pickitem.checked) {
1.594 damieng 6350: var picknum=prompt('$js_lt{"rpck"}',picknumitem.value);
1.478 raeburn 6351: if (picknum == '' || picknum == null) {
6352: if (caller == 'check') {
6353: pickitem.checked=false;
1.537 raeburn 6354: if (index == 'all') {
6355: picknumtext.innerHTML = '';
6356: if (caller == 'link') {
6357: propagateState(targetform,'rpicknum');
6358: }
6359: } else {
1.538 raeburn 6360: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 6361: }
1.478 raeburn 6362: }
6363: } else {
6364: picknum.toString();
6365: var regexdigit=/^\\d+\$/;
6366: if (regexdigit.test(picknum)) {
6367: picknumitem.value = picknum;
1.537 raeburn 6368: if (index == 'all') {
1.538 raeburn 6369: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.cumulativesettings,\\'all\\',\\'link\\');">'+picknum+'</a>';
1.537 raeburn 6370: if (caller == 'link') {
6371: propagateState(targetform,'rpicknum');
6372: }
6373: } else {
6374: picknumtext.innerHTML = ' <a href="javascript:updatePick(document.edit_randompick_'+index+',\\''+index+'\\',\\'link\\');">'+picknum+'</a>';
1.538 raeburn 6375: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 6376: }
1.478 raeburn 6377: } else {
6378: if (caller == 'check') {
1.537 raeburn 6379: if (index == 'all') {
6380: picknumtext.innerHTML = '';
6381: if (caller == 'link') {
6382: propagateState(targetform,'rpicknum');
6383: }
6384: } else {
6385: pickitem.checked=false;
1.538 raeburn 6386: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 6387: }
1.478 raeburn 6388: }
6389: return;
6390: }
6391: }
6392: } else {
1.537 raeburn 6393: picknumitem.value = '';
6394: picknumtext.innerHTML = '';
6395: if (index == 'all') {
6396: if (caller == 'link') {
6397: propagateState(targetform,'rpicknum');
6398: }
6399: } else {
1.538 raeburn 6400: checkForSubmit(targetform,'randompick','settings');
1.537 raeburn 6401: }
6402: }
6403: }
6404:
6405: function propagateState(form,param) {
6406: if (document.getElementById(param+'all')) {
6407: var setcheck = 0;
6408: var rpick = 0;
6409: if (param == 'rpicknum') {
6410: if (document.getElementById('randompickall')) {
6411: if (document.getElementById('randompickall').checked) {
6412: if (document.getElementById('rpicknumall')) {
6413: rpick = document.getElementById('rpicknumall').value;
6414: }
6415: }
6416: }
6417: } else {
6418: if (document.getElementById(param+'all').checked) {
6419: setcheck = 1;
6420: }
6421: }
1.538 raeburn 6422: var allidxlist;
6423: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
6424: if (document.getElementById('all'+param+'idx')) {
6425: allidxlist = document.getElementById('all'+param+'idx').value;
6426: }
6427: var actions = new Array ('remove','cut','copy');
6428: for (var i=0; i<actions.length; i++) {
6429: if (actions[i] != param) {
6430: if (document.getElementById(actions[i]+'all')) {
6431: document.getElementById(actions[i]+'all').checked = false;
6432: }
6433: }
6434: }
6435: }
1.537 raeburn 6436: if ((param == 'encrypturl') || (param == 'hiddenresource')) {
1.538 raeburn 6437: allidxlist = form.allidx.value;
6438: }
6439: if ((param == 'randompick') || (param == 'rpicknum') || (param == 'randomorder')) {
6440: allidxlist = form.allmapidx.value;
6441: }
6442: if ((allidxlist != '') && (allidxlist != null)) {
6443: var allidxs = allidxlist.split(',');
6444: if (allidxs.length > 1) {
6445: for (var i=0; i<allidxs.length; i++) {
6446: if (document.getElementById(param+'_'+allidxs[i])) {
6447: if (param == 'rpicknum') {
6448: if (document.getElementById('randompick_'+allidxs[i])) {
6449: if (document.getElementById('randompick_'+allidxs[i]).checked) {
6450: document.getElementById(param+'_'+allidxs[i]).value = rpick;
6451: if (rpick > 0) {
6452: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = ': <a href="javascript:updatePick(document.edit_randompick_'+allidxs[i]+',\\''+allidxs[i]+'\\',\\'link\\')">'+rpick+'</a>';
6453: } else {
6454: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
6455: }
6456: }
6457: }
6458: } else {
1.537 raeburn 6459: if (setcheck == 1) {
6460: document.getElementById(param+'_'+allidxs[i]).checked = true;
6461: } else {
6462: document.getElementById(param+'_'+allidxs[i]).checked = false;
1.538 raeburn 6463: if (param == 'randompick') {
6464: document.getElementById('randompicknum_'+allidxs[i]).innerHTML = '';
6465: }
1.537 raeburn 6466: }
6467: }
6468: }
6469: }
1.538 raeburn 6470: if (setcheck == 1) {
6471: if ((param == 'remove') || (param == 'cut') || (param == 'copy')) {
6472: var actions = new Array('copy','cut','remove');
6473: for (var i=0; i<actions.length; i++) {
6474: var otheractions;
6475: var otheridxs;
6476: if (actions[i] === param) {
6477: continue;
6478: } else {
6479: if (document.getElementById('all'+actions[i]+'idx')) {
6480: otheractions = document.getElementById('all'+actions[i]+'idx').value;
6481: otheridxs = otheractions.split(',');
6482: if (otheridxs.length > 1) {
6483: for (var j=0; j<otheridxs.length; j++) {
6484: if (document.getElementById(actions[i]+'_'+otheridxs[j])) {
6485: document.getElementById(actions[i]+'_'+otheridxs[j]).checked = false;
6486: }
1.537 raeburn 6487: }
6488: }
6489: }
1.538 raeburn 6490: }
6491: }
6492: }
6493: }
6494: }
6495: }
6496: }
6497: return;
6498: }
6499:
6500: function checkForSubmit(targetform,param,context,idx,folderpath,index,oldtitle,skip_confirm,container,folder) {
1.539 raeburn 6501: var dosettings;
6502: var doaction;
1.538 raeburn 6503: var control = document.togglemultsettings;
6504: if (context == 'actions') {
6505: control = document.togglemultactions;
1.539 raeburn 6506: doaction = 1;
6507: } else {
6508: dosettings = 1;
1.538 raeburn 6509: }
1.539 raeburn 6510: if (control) {
6511: if (control.showmultpick.length) {
6512: for (var i=0; i<control.showmultpick.length; i++) {
6513: if (control.showmultpick[i].checked) {
6514: if (control.showmultpick[i].value == 1) {
6515: if (context == 'settings') {
6516: dosettings = 0;
6517: } else {
6518: doaction = 0;
1.538 raeburn 6519: }
6520: }
6521: }
1.537 raeburn 6522: }
6523: }
1.539 raeburn 6524: }
6525: if (context == 'settings') {
6526: if (dosettings == 1) {
1.538 raeburn 6527: targetform.changeparms.value=param;
6528: targetform.submit();
6529: }
1.537 raeburn 6530: }
1.539 raeburn 6531: if (context == 'actions') {
6532: if (doaction == 1) {
6533: targetform.cmd.value=param+'_'+index;
6534: targetform.folderpath.value=folderpath;
6535: targetform.markcopy.value=idx+':'+param;
6536: targetform.copyfolder.value=folder+'.'+container;
6537: if (param == 'remove') {
1.594 damieng 6538: if (skip_confirm || confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr2a"} "'+oldtitle+'" $js_lt{"p_rmr2b"}')) {
1.539 raeburn 6539: targetform.markcopy.value='';
6540: targetform.copyfolder.value='';
6541: targetform.submit();
6542: }
6543: }
6544: if (param == 'cut') {
1.594 damieng 6545: 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.539 raeburn 6546: targetform.submit();
6547: return;
6548: }
6549: }
6550: if (param == 'copy') {
6551: targetform.submit();
6552: return;
6553: }
6554: targetform.markcopy.value='';
6555: targetform.copyfolder.value='';
6556: targetform.cmd.value='';
6557: targetform.folderpath.value='';
6558: return;
6559: } else {
6560: if (document.getElementById(param+'_'+idx)) {
6561: item = document.getElementById(param+'_'+idx);
6562: if (item.type == 'checkbox') {
6563: if (item.checked) {
6564: item.checked = false;
6565: } else {
6566: item.checked = true;
6567: singleCheck(item,idx,param);
6568: }
6569: }
6570: }
6571: }
6572: }
1.537 raeburn 6573: return;
6574: }
6575:
1.538 raeburn 6576: function singleCheck(caller,idx,action) {
6577: actions = new Array('cut','copy','remove');
6578: if (caller.checked) {
6579: for (var i=0; i<actions.length; i++) {
6580: if (actions[i] != action) {
6581: if (document.getElementById(actions[i]+'_'+idx)) {
6582: if (document.getElementById(actions[i]+'_'+idx).checked) {
6583: document.getElementById(actions[i]+'_'+idx).checked = false;
6584: }
1.537 raeburn 6585: }
6586: }
6587: }
1.478 raeburn 6588: }
1.537 raeburn 6589: return;
1.478 raeburn 6590: }
6591:
1.334 muellerd 6592: function unselectInactive(nav) {
1.335 ehlerst 6593: currentNav = document.getElementById(nav);
6594: currentLis = currentNav.getElementsByTagName('LI');
6595: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 6596: if (currentLis[i].className == 'goback') {
6597: currentLis[i].className = 'goback';
6598: } else {
6599: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 6600: currentLis[i].className = 'right';
1.472 raeburn 6601: } else {
1.374 tempelho 6602: currentLis[i].className = 'i';
1.472 raeburn 6603: }
6604: }
1.335 ehlerst 6605: }
1.332 tempelho 6606: }
6607:
1.334 muellerd 6608: function hideAll(current, nav, data) {
1.335 ehlerst 6609: unselectInactive(nav);
1.570 raeburn 6610: if (current) {
6611: if (current.className == 'right'){
6612: current.className = 'right active'
6613: } else {
6614: current.className = 'active';
6615: }
1.374 tempelho 6616: }
1.335 ehlerst 6617: currentData = document.getElementById(data);
6618: currentDivs = currentData.getElementsByTagName('DIV');
6619: for (i = 0; i < currentDivs.length; i++) {
6620: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 6621: currentDivs[i].style.display = 'none';
1.330 tempelho 6622: }
6623: }
1.335 ehlerst 6624: }
1.330 tempelho 6625:
1.374 tempelho 6626: function openTabs(pageId) {
6627: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 6628: if(tabnav.length > 2 ){
1.389 tempelho 6629: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 6630: currentLis = currentNav.getElementsByTagName('LI');
6631: for(i = 0; i< currentLis.length; i++){
6632: if(currentLis[i].className == 'active') {
1.375 tempelho 6633: funcString = currentLis[i].onclick.toString();
6634: tab = funcString.split('"');
1.420 onken 6635: if(tab.length < 2) {
6636: tab = funcString.split("'");
6637: }
1.375 tempelho 6638: currentData = document.getElementById(tab[1]);
6639: currentData.style.display = 'block';
1.374 tempelho 6640: }
6641: }
6642: }
6643: }
6644:
1.334 muellerd 6645: function showPage(current, pageId, nav, data) {
1.570 raeburn 6646: currstate = current.className;
1.334 muellerd 6647: hideAll(current, nav, data);
1.375 tempelho 6648: openTabs(pageId);
1.334 muellerd 6649: unselectInactive(nav);
1.570 raeburn 6650: if ((currstate == 'active') || (currstate == 'right active')) {
6651: if (currstate == 'active') {
6652: current.className = '';
6653: } else {
6654: current.className = 'right';
6655: }
6656: activeTab = '';
6657: toggleUpload();
6658: toggleMap();
6659: resize_scrollbox('contentscroll','1','0');
6660: return;
6661: } else {
6662: current.className = 'active';
6663: }
1.330 tempelho 6664: currentData = document.getElementById(pageId);
6665: currentData.style.display = 'block';
1.458 raeburn 6666: activeTab = pageId;
1.501 raeburn 6667: toggleUpload();
1.503 raeburn 6668: toggleMap();
1.433 raeburn 6669: if (nav == 'mainnav') {
6670: var storedpath = "$docs_folderpath";
1.434 raeburn 6671: var storedpage = "$main_container_page";
1.433 raeburn 6672: var reg = new RegExp("^supplemental");
6673: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 6674: if (storedpage == 1) {
6675: document.simpleedit.folderpath.value = '';
6676: document.uploaddocument.folderpath.value = '';
6677: } else {
6678: if (reg.test(storedpath)) {
6679: document.simpleedit.folderpath.value = '$toplevelmain';
6680: document.uploaddocument.folderpath.value = '$toplevelmain';
6681: document.newext.folderpath.value = '$toplevelmain';
6682: } else {
6683: document.simpleedit.folderpath.value = storedpath;
6684: document.uploaddocument.folderpath.value = storedpath;
6685: document.newext.folderpath.value = storedpath;
6686: }
1.433 raeburn 6687: }
6688: } else {
1.434 raeburn 6689: if (reg.test(storedpath)) {
6690: document.simpleedit.folderpath.value = storedpath;
6691: document.supuploaddocument.folderpath.value = storedpath;
6692: document.supnewext.folderpath.value = storedpath;
6693: } else {
1.433 raeburn 6694: document.simpleedit.folderpath.value = '$toplevelsupp';
6695: document.supuploaddocument.folderpath.value = '$toplevelsupp';
6696: document.supnewext.folderpath.value = '$toplevelsupp';
6697: }
6698: }
6699: }
1.485 raeburn 6700: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 6701: return false;
6702: }
1.329 droeschl 6703:
1.472 raeburn 6704: function toContents(jumpto) {
6705: var newurl = '$backtourl';
1.525 raeburn 6706: if ((newurl == '/adm/navmaps') && (jumpto != '')) {
1.472 raeburn 6707: newurl = newurl+'?postdata='+jumpto;
6708: }
6709: location.href=newurl;
6710: }
6711:
1.538 raeburn 6712: function togglePick(caller,value) {
6713: var disp = 'none';
6714: if (document.getElementById('multi'+caller)) {
6715: var curr = document.getElementById('multi'+caller).style.display;
6716: if (value == 1) {
6717: disp='block';
6718: }
6719: if (curr == disp) {
6720: return;
6721: }
6722: document.getElementById('multi'+caller).style.display=disp;
6723: if (value == 1) {
1.594 damieng 6724: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.538 raeburn 6725: } else {
6726: document.getElementById('more'+caller).innerHTML = '';
6727: }
6728: if (caller == 'actions') {
6729: setClass(value);
6730: setBoxes(value);
6731: }
6732: }
6733: var showButton = multiSettings();
6734: if (showButton != 1) {
6735: showButton = multiActions();
6736: }
6737: if (document.getElementById('multisave')) {
6738: if (showButton == 1) {
6739: document.getElementById('multisave').style.display='block';
6740: } else {
6741: document.getElementById('multisave').style.display='none';
6742: }
6743: }
6744: resize_scrollbox('contentscroll','1','1');
6745: return;
6746: }
6747:
6748: function toggleCheckUncheck(caller,more) {
6749: if (more == 1) {
1.594 damieng 6750: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',0);" style="text-decoration:none;">$js_lt{'less'}</a>';
1.538 raeburn 6751: document.getElementById('allfields'+caller).style.display='block';
6752: } else {
1.594 damieng 6753: document.getElementById('more'+caller).innerHTML = ' <a href="javascript:toggleCheckUncheck(\\''+caller+'\\',1);" style="text-decoration:none;">$js_lt{'more'}</a>';
1.538 raeburn 6754: document.getElementById('allfields'+caller).style.display='none';
6755: }
6756: resize_scrollbox('contentscroll','1','1');
6757: }
6758:
6759: function multiSettings() {
6760: var inuse = 0;
6761: var settingsform = document.togglemultsettings;
6762: if (settingsform.showmultpick.length > 1) {
6763: for (var i=0; i<settingsform.showmultpick.length; i++) {
6764: if (settingsform.showmultpick[i].checked) {
6765: if (settingsform.showmultpick[i].value == 1) {
6766: inuse = 1;
6767: }
6768: }
6769: }
6770: }
6771: return inuse;
6772: }
6773:
6774: function multiActions() {
6775: var inuse = 0;
6776: var actionsform = document.togglemultactions;
6777: if (actionsform.showmultpick.length > 1) {
6778: for (var i=0; i<actionsform.showmultpick.length; i++) {
6779: if (actionsform.showmultpick[i].checked) {
6780: if (actionsform.showmultpick[i].value == 1) {
6781: inuse = 1;
6782: }
6783: }
6784: }
6785: }
6786: return inuse;
6787: }
6788:
6789: function checkSubmits() {
6790: var numchanges = 0;
6791: var form = document.saveactions;
6792: var doactions = multiActions();
1.542 raeburn 6793: var cutwarnings = 0;
6794: var remwarnings = 0;
1.538 raeburn 6795: if (doactions == 1) {
6796: var remidxlist = document.cumulativeactions.allremoveidx.value;
6797: if ((remidxlist != '') && (remidxlist != null)) {
6798: var remidxs = remidxlist.split(',');
6799: for (var i=0; i<remidxs.length; i++) {
6800: if (document.getElementById('remove_'+remidxs[i])) {
6801: if (document.getElementById('remove_'+remidxs[i]).checked) {
6802: form.multiremove.value += remidxs[i]+',';
6803: numchanges ++;
1.542 raeburn 6804: if (document.getElementById('skip_remove_'+remidxs[i])) {
6805: if (document.getElementById('skip_remove_'+remidxs[i]).value == 0) {
6806: remwarnings ++;
6807: }
6808: }
1.537 raeburn 6809: }
6810: }
1.538 raeburn 6811: }
6812: }
6813: var cutidxlist = document.cumulativeactions.allcutidx.value;
6814: if ((cutidxlist != '') && (cutidxlist != null)) {
6815: var cutidxs = cutidxlist.split(',');
6816: for (var i=0; i<cutidxs.length; i++) {
6817: if (document.getElementById('cut_'+cutidxs[i])) {
6818: if (document.getElementById('cut_'+cutidxs[i]).checked == true) {
6819: form.multicut.value += cutidxs[i]+',';
6820: numchanges ++;
1.542 raeburn 6821: if (document.getElementById('skip_cut_'+cutidxs[i])) {
6822: if (document.getElementById('skip_cut_'+cutidxs[i]).value == 0) {
6823: cutwarnings ++;
6824: }
6825: }
1.537 raeburn 6826: }
6827: }
6828: }
6829: }
1.538 raeburn 6830: var copyidxlist = document.cumulativeactions.allcopyidx.value;
6831: if ((copyidxlist != '') && (copyidxlist != null)) {
6832: var copyidxs = copyidxlist.split(',');
6833: for (var i=0; i<copyidxs.length; i++) {
6834: if (document.getElementById('copy_'+copyidxs[i])) {
6835: if (document.getElementById('copy_'+copyidxs[i]).checked) {
6836: form.multicopy.value += copyidxs[i]+',';
6837: numchanges ++;
6838: }
6839: }
6840: }
6841: }
6842: if (numchanges > 0) {
6843: form.multichange.value = numchanges;
6844: }
1.537 raeburn 6845: }
1.538 raeburn 6846: var dosettings = multiSettings();
1.543 raeburn 6847: var haschanges = 0;
1.538 raeburn 6848: if (dosettings == 1) {
6849: form.allencrypturl.value = '';
6850: form.allhiddenresource.value = '';
1.543 raeburn 6851: form.changeparms.value = 'all';
6852: var patt=new RegExp(",\$");
1.538 raeburn 6853: var allidxlist = document.cumulativesettings.allidx.value;
6854: if ((allidxlist != '') && (allidxlist != null)) {
6855: var allidxs = allidxlist.split(',');
6856: if (allidxs.length > 1) {
6857: for (var i=0; i<allidxs.length; i++) {
6858: if (document.getElementById('hiddenresource_'+allidxs[i])) {
6859: if (document.getElementById('hiddenresource_'+allidxs[i]).checked) {
6860: form.allhiddenresource.value += allidxs[i]+',';
6861: }
6862: }
6863: if (document.getElementById('encrypturl_'+allidxs[i])) {
6864: if (document.getElementById('encrypturl_'+allidxs[i]).checked) {
6865: form.allencrypturl.value += allidxs[i]+',';
6866: }
6867: }
6868: }
1.543 raeburn 6869: form.allhiddenresource.value = form.allhiddenresource.value.replace(patt,"");
6870: form.allencrypturl.value = form.allencrypturl.value.replace(patt,"");
1.537 raeburn 6871: }
1.538 raeburn 6872: }
6873: form.allrandompick.value = '';
6874: form.allrandomorder.value = '';
6875: var allmapidxlist = document.cumulativesettings.allmapidx.value;
6876: if ((allmapidxlist != '') && (allmapidxlist != null)) {
6877: var allmapidxs = allmapidxlist.split(',');
6878: for (var i=0; i<allmapidxs.length; i++) {
6879: var randompick = document.getElementById('randompick_'+allmapidxs[i]);
6880: var rpicknum = document.getElementById('rpicknum_'+allmapidxs[i]);
6881: var randorder = document.getElementById('randomorder_'+allmapidxs[i]);
6882: if ((randompick.checked) && (rpicknum.value != '')) {
6883: form.allrandompick.value += allmapidxs[i]+':'+rpicknum.value+',';
6884: }
6885: if (randorder.checked) {
6886: form.allrandomorder.value += allmapidxs[i]+',';
6887: }
1.537 raeburn 6888: }
1.543 raeburn 6889: form.allrandompick.value = form.allrandompick.value.replace(patt,"");
6890: form.allrandomorder.value = form.allrandomorder.value.replace(patt,"");
6891: }
6892: if (document.cumulativesettings.currhiddenresource.value != form.allhiddenresource.value) {
6893: haschanges = 1;
6894: }
6895: if (document.cumulativesettings.currencrypturl.value != form.allencrypturl.value) {
6896: haschanges = 1;
6897: }
6898: if (document.cumulativesettings.currrandomorder.value != form.allrandomorder.value) {
6899: haschanges = 1;
6900: }
6901: if (document.cumulativesettings.currrandompick.value != form.allrandompick.value) {
6902: haschanges = 1;
1.537 raeburn 6903: }
6904: }
1.543 raeburn 6905: if (doactions == 1) {
1.542 raeburn 6906: if (numchanges > 0) {
6907: if ((cutwarnings > 0) || (remwarnings > 0)) {
6908: if (remwarnings > 0) {
1.594 damieng 6909: if (!confirm('$js_lt{"p_rmr1"}\\n\\n$js_lt{"p_rmr3a"} '+remwarnings+' $js_lt{"p_rmr3b"}')) {
1.542 raeburn 6910: return false;
6911: }
6912: }
6913: if (cutwarnings > 0) {
1.594 damieng 6914: if (!confirm('$js_lt{"p_ctr1a"}\\n$js_lt{"p_ctr1b"}\\n\\n$js_lt{"p_ctr3a"} '+cutwarnings+' $js_lt{"p_ctr3b"}')) {
1.542 raeburn 6915: return false;
6916: }
6917: }
6918: }
6919: form.submit();
6920: return true;
1.543 raeburn 6921: }
6922: }
6923: if (dosettings == 1) {
6924: if (haschanges == 1) {
1.542 raeburn 6925: form.submit();
6926: return true;
6927: }
1.543 raeburn 6928: }
6929: if ((dosettings == 1) && (doactions == 1)) {
1.594 damieng 6930: alert("$js_lt{'noor'}");
1.543 raeburn 6931: } else {
6932: if (dosettings == 1) {
1.594 damieng 6933: alert("$js_lt{'noch'}");
1.543 raeburn 6934: } else {
1.594 damieng 6935: alert("$js_lt{'noac'}");
1.543 raeburn 6936: }
6937: }
1.538 raeburn 6938: return false;
6939: }
6940:
6941: function setClass(value) {
6942: var cutclass = 'LC_docs_cut';
6943: var copyclass = 'LC_docs_copy';
6944: var removeclass = 'LC_docs_remove';
6945: var cutreg = new RegExp("\\\\b"+cutclass+"\\\\b");
6946: var copyreg = new RegExp("\\\\b"+copyclass+"\\\\b");
6947: var removereg = new RegExp("\\\\"+removeclass+"\\\\b");
6948: var links = document.getElementsByTagName('a');
6949: for (var i=0; i<links.length; i++) {
6950: var classes = links[i].className;
6951: if (cutreg.test(classes)) {
6952: links[i].className = cutclass;
6953: if (value == 1) {
6954: links[i].className += " LC_menubuttons_link";
6955: }
6956: } else {
6957: if (copyreg.test(classes)) {
6958: links[i].className = copyclass;
6959: if (value == 1) {
6960: links[i].className += " LC_menubuttons_link";
6961: }
6962: } else {
6963: if (removereg.test(classes)) {
6964: links[i].className = removeclass;
6965: if (value == 1) {
6966: links[i].className += " LC_menubuttons_link";
6967: }
6968: }
6969: }
6970: }
6971: }
6972: return;
1.537 raeburn 6973: }
6974:
1.538 raeburn 6975: function setBoxes(value) {
6976: var remidxlist = document.cumulativeactions.allremoveidx.value;
6977: if ((remidxlist != '') && (remidxlist != null)) {
6978: var remidxs = remidxlist.split(',');
6979: for (var i=0; i<remidxs.length; i++) {
6980: if (document.getElementById('remove_'+remidxs[i])) {
6981: var item = document.getElementById('remove_'+remidxs[i]);
6982: if (value == 1) {
6983: item.className = 'LC_docs_remove';
6984: } else {
6985: item.className = 'LC_hidden';
6986: }
6987: }
6988: }
6989: }
6990: var cutidxlist = document.cumulativeactions.allcutidx.value;
6991: if ((cutidxlist != '') && (cutidxlist != null)) {
6992: var cutidxs = cutidxlist.split(',');
6993: for (var i=0; i<cutidxs.length; i++) {
6994: if (document.getElementById('cut_'+cutidxs[i])) {
6995: var item = document.getElementById('cut_'+cutidxs[i]);
6996: if (value == 1) {
6997: item.className = 'LC_docs_cut';
6998: } else {
6999: item.className = 'LC_hidden';
7000: }
7001: }
1.537 raeburn 7002: }
7003: }
1.538 raeburn 7004: var copyidxlist = document.cumulativeactions.allcopyidx.value;
7005: if ((copyidxlist != '') && (copyidxlist != null)) {
7006: var copyidxs = copyidxlist.split(',');
7007: for (var i=0; i<copyidxs.length; i++) {
7008: if (document.getElementById('copy_'+copyidxs[i])) {
7009: var item = document.getElementById('copy_'+copyidxs[i]);
7010: if (value == 1) {
7011: item.className = 'LC_docs_copy';
7012: } else {
7013: item.className = 'LC_hidden';
7014: }
7015: }
1.537 raeburn 7016: }
7017: }
7018: return;
7019: }
7020:
1.329 droeschl 7021: ENDNEWSCRIPT
7022: }
1.457 raeburn 7023:
1.483 raeburn 7024: sub history_tab_js {
7025: return <<"ENDHIST";
7026: function toggleHistoryDisp(choice) {
7027: document.docslogform.docslog.value = choice;
7028: document.docslogform.submit();
7029: return;
7030: }
7031:
7032: ENDHIST
7033: }
7034:
1.484 raeburn 7035: sub inject_data_js {
7036: return <<ENDINJECT;
7037:
7038: function injectData(current, hiddenField, name, value) {
7039: currentElement = document.getElementById(hiddenField);
7040: currentElement.name = name;
7041: currentElement.value = value;
7042: current.submit();
7043: }
7044:
7045: ENDINJECT
7046: }
7047:
7048: sub dump_switchserver_js {
7049: my @hosts = @_;
1.594 damieng 7050: my %js_lt = &Apache::lonlocal::texthash(
1.574 raeburn 7051: dump => 'Copying content to Authoring Space requires switching server.',
1.484 raeburn 7052: swit => 'Switch server?',
1.594 damieng 7053: );
7054: my %html_js_lt = &Apache::lonlocal::texthash(
7055: swit => 'Switch server?',
1.568 raeburn 7056: duco => 'Copying Content to Authoring Space',
1.484 raeburn 7057: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
7058: chos => 'Choose server',
7059: );
1.594 damieng 7060: &js_escape(\%js_lt);
7061: &html_escape(\%html_js_lt);
7062: &js_escape(\%html_js_lt);
1.484 raeburn 7063: my $role = $env{'request.role'};
7064: my $js = <<"ENDSWJS";
7065: <script type="text/javascript">
7066: function write_switchserver() {
7067: var server;
7068: if (document.setserver.posshosts.length > 0) {
7069: for (var i=0; i<document.setserver.posshosts.length; i++) {
7070: if (document.setserver.posshosts[i].checked) {
7071: server = document.setserver.posshosts[i].value;
7072: }
7073: }
7074: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
7075: }
7076: window.close();
7077: }
7078: </script>
7079:
7080: ENDSWJS
7081:
7082: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
7083: {'only_body' => 1,
7084: 'js_ready' => 1,});
7085: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
7086:
7087: my $hostpicker;
7088: my $count = 0;
7089: foreach my $host (sort(@hosts)) {
7090: my $checked;
7091: if ($count == 0) {
7092: $checked = ' checked="checked"';
7093: }
7094: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
7095: $host.'"'.$checked.' />'.$host.'</label> ';
7096: $count++;
7097: }
7098:
7099: return <<"ENDSWITCHJS";
7100:
7101: function dump_needs_switchserver(url) {
7102: if (url!='' && url!= null) {
1.594 damieng 7103: if (confirm("$js_lt{'dump'}\\n$js_lt{'swit'}")) {
1.484 raeburn 7104: go(url);
7105: }
7106: }
7107: return;
7108: }
7109:
7110: function choose_switchserver_window() {
7111: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
7112: newWindow.document.open();
7113: newWindow.document.writeln('$startpage');
1.594 damieng 7114: newWindow.document.write('<h3>$html_js_lt{'duco'}<\\/h3>\\n'+
7115: '<p>$html_js_lt{'yone'}<\\/p>\\n'+
7116: '<div class="LC_left_float"><fieldset><legend>$html_js_lt{'chos'}<\\/legend>\\n'+
1.484 raeburn 7117: '<form name="setserver" method="post" action="" \\/>\\n'+
7118: '$hostpicker\\n'+
7119: '<br \\/><br \\/>\\n'+
1.594 damieng 7120: '<input type="button" name="makeswitch" value="$html_js_lt{'swit'}" '+
1.484 raeburn 7121: 'onclick="write_switchserver();" \\/>\\n'+
7122: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
7123: newWindow.document.writeln('$endpage');
7124: newWindow.document.close();
7125: newWindow.focus();
7126: }
7127:
7128: ENDSWITCHJS
7129: }
7130:
7131: sub makedocslogform {
7132: my ($formelems,$docslog) = @_;
7133: return <<"LOGSFORM";
7134: <form action="/adm/coursedocs" method="post" name="docslogform">
7135: <input type="hidden" name="docslog" value="$docslog" />
7136: $formelems
7137: </form>
7138: LOGSFORM
7139: }
7140:
7141: sub makesimpleeditform {
7142: my ($formelems) = @_;
7143: return <<"SIMPFORM";
7144: <form name="simpleedit" method="post" action="/adm/coursedocs">
7145: <input type="hidden" name="importdetail" value="" />
7146: $formelems
7147: </form>
7148: SIMPFORM
7149: }
7150:
1.329 droeschl 7151: 1;
7152: __END__
7153:
7154:
7155: =head1 NAME
7156:
7157: Apache::londocs.pm
7158:
7159: =head1 SYNOPSIS
7160:
7161: This is part of the LearningOnline Network with CAPA project
7162: described at http://www.lon-capa.org.
7163:
7164: =head1 SUBROUTINES
7165:
7166: =over
7167:
7168: =item %help=()
7169:
7170: Available help topics
7171:
7172: =item mapread()
7173:
1.344 bisitz 7174: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 7175: @order and @resources, determines status
7176: sets @order - pointer to resources in right order
7177: sets @resources - array with the resources with correct idx
7178:
7179: =item authorhosts()
7180:
7181: Return hash with valid author names
7182:
7183: =item clean()
7184:
7185: =item dumpcourse()
7186:
7187: Actually dump course
7188:
7189: =item group_import()
7190:
7191: Imports the given (name, url) resources into the course
7192: coursenum, coursedom, and folder must precede the list
7193:
7194: =item breadcrumbs()
7195:
7196: =item log_docs()
7197:
7198: =item docs_change_log()
7199:
7200: =item update_paste_buffer()
7201:
7202: =item print_paste_buffer()
7203:
7204: =item do_paste_from_buffer()
7205:
1.538 raeburn 7206: =item do_buffer_empty()
7207:
7208: =item clear_from_buffer()
7209:
1.492 raeburn 7210: =item get_newmap_url()
7211:
7212: =item dbcopy()
7213:
7214: =item uniqueness_check()
7215:
7216: =item contained_map_check()
7217:
7218: =item url_paste_fixups()
7219:
7220: =item apply_fixups()
7221:
7222: =item copy_dependencies()
7223:
1.329 droeschl 7224: =item update_parameter()
7225:
7226: =item handle_edit_cmd()
7227:
7228: =item editor()
7229:
7230: =item process_file_upload()
7231:
7232: =item process_secondary_uploads()
7233:
7234: =item is_supplemental_title()
7235:
7236: =item entryline()
7237:
7238: =item tiehash()
7239:
7240: =item untiehash()
7241:
7242: =item checkonthis()
7243:
7244: check on this
7245:
7246: =item verifycontent()
7247:
7248: Verify Content
7249:
7250: =item devalidateversioncache() & checkversions()
7251:
7252: Check Versions
7253:
7254: =item mark_hash_old()
7255:
7256: =item is_hash_old()
7257:
7258: =item changewarning()
7259:
7260: =item init_breadcrumbs()
7261:
7262: Breadcrumbs for special functions
7263:
1.484 raeburn 7264: =item create_list_elements()
7265:
7266: =item create_form_ul()
7267:
7268: =item startContentScreen()
7269:
7270: =item endContentScreen()
7271:
7272: =item supplemental_base()
7273:
7274: =item embedded_form_elems()
7275:
7276: =item embedded_destination()
7277:
7278: =item return_to_editor()
7279:
7280: =item decompression_info()
7281:
7282: =item decompression_phase_one()
7283:
7284: =item decompression_phase_two()
7285:
7286: =item remove_archive()
7287:
7288: =item generate_admin_menu()
7289:
7290: =item generate_edit_table()
7291:
7292: =item editing_js()
7293:
7294: =item history_tab_js()
7295:
7296: =item inject_data_js()
7297:
7298: =item dump_switchserver_js()
7299:
1.485 raeburn 7300: =item resize_scrollbox_js()
1.484 raeburn 7301:
7302: =item makedocslogform()
7303:
1.485 raeburn 7304: =item makesimpleeditform()
7305:
1.329 droeschl 7306: =back
7307:
7308: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>